Skip to content

Commit 1c1f5b7

Browse files
author
linyuan.yang
committed
格式化所有 error
1 parent effcdfb commit 1c1f5b7

25 files changed

Lines changed: 115 additions & 47 deletions

‎packages/sbot/src/Processing/classifyIntent.ts‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { MessageRole, truncate, contentToString, type MessageContent } from "sco
33
import { config } from "../Core/Config";
44
import { LoggerService } from "../Core/LoggerService";
55
import { loadPrompt } from "../Core/PromptLoader";
6-
import { channelDataService } from "../Session/ChannelDataService";
6+
import { getSessionName } from "../utils";
77

88
const logger = LoggerService.getLogger("classifyIntent.ts");
99

@@ -21,16 +21,6 @@ const IntentSchema = z.object({
2121

2222
type IntentResult = z.infer<typeof IntentSchema>;
2323

24-
async function resolveSessionName(sessionId: number | string | undefined): Promise<string> {
25-
const fallback = sessionId == null ? "?" : String(sessionId);
26-
try {
27-
const session = await channelDataService.getSession(sessionId);
28-
return session?.sessionName || session?.autoSessionName || session?.sessionId || fallback;
29-
} catch {
30-
return fallback;
31-
}
32-
}
33-
3424
/**
3525
* Classify whether a group chat message needs an AI reply.
3626
* Returns true = should reply, false = skip silently.
@@ -47,7 +37,7 @@ export async function classifyIntent(
4737
if (!modelService) return true;
4838
let text = truncate(contentToString(query), 100);
4939
const modelInfo = `intentModelId=${intentModelId}`;
50-
const sessionName = await resolveSessionName(sessionId);
40+
const sessionName = await getSessionName(sessionId);
5141
try {
5242
const systemPrompt = [
5343
intentPrompt || loadPrompt('intent/default.txt'),

‎packages/sbot/src/Server/HttpServer.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { tunnelService } from '../Tunnel';
1313
import { WEB_CHANNEL_ID } from 'sbot.commons';
1414
import { webService } from '../Channel/web/WebService';
1515
import { ptyService, listShells } from '../Channel/web/PtyService';
16-
import { api } from './utils';
16+
import { api } from '../utils';
1717

1818
import type { RouteContext } from './routes/types';
1919
import { systemRoutes } from './routes/system';

‎packages/sbot/src/Server/helpers/promptTree.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'fs';
22
import path from 'path';
3-
import { dirFirstByName } from '../utils';
3+
import { dirFirstByName } from '../../utils';
44

55
export type PromptNode = { name: string; type: 'file' | 'dir'; path: string; isOverride?: boolean; isUserOnly?: boolean; children?: PromptNode[] };
66

‎packages/sbot/src/Server/helpers/settingsCrud.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import express from 'express';
22
import { randomUUID } from 'crypto';
33
import { config } from '../../Core/Config';
4-
import { api, throwBad } from '../utils';
4+
import { api, throwBad } from '../../utils';
55

66
export interface SettingsCrudOptions {
77
label?: string;

‎packages/sbot/src/Server/routes/acp.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import express from 'express';
22
import { ACPAgentPool } from '../../Agent/ACPAgentPool';
3-
import { api } from '../utils';
3+
import { api } from '../../utils';
44
import type { RouteContext } from './types';
55

66
export class AcpRoutes {

‎packages/sbot/src/Server/routes/agendas.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
} from 'scorpio.ai';
1111
import { agendaServicePool, agendaStorePool, agendaTriggerEnginePool } from '../../Agenda';
1212
import { config } from '../../Core/Config';
13-
import { api, throwBad } from '../utils';
13+
import { api, throwBad } from '../../utils';
1414
import type { RouteContext } from './types';
1515

1616
function num(v: unknown): number | undefined {

‎packages/sbot/src/Server/routes/agentStore.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import express from 'express';
2-
import { api, throwBad } from '../utils';
2+
import { api, throwBad } from '../../utils';
33
import type { RouteContext } from './types';
44

55
export class AgentStoreRoutes {

‎packages/sbot/src/Server/routes/agents.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import express from 'express';
22
import { config, isValidAgentId, AgentMode } from '../../Core/Config';
3-
import { api, throwBad } from '../utils';
3+
import { api, throwBad } from '../../utils';
44
import { resolveAgentMcp, resolveAgentSkills } from './agentCapabilities';
55
import type { RouteContext } from './types';
66

‎packages/sbot/src/Server/routes/data.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { database, type ChannelSessionRow } from '../../Core/Database';
77
import { channelDataService } from '../../Session/ChannelDataService';
88
import { wikiPluginRegistry } from '../../Wiki/WikiPluginRegistry';
99
import { WEB_CHANNEL_ID } from 'sbot.commons';
10-
import { api, throwBad } from '../utils';
10+
import { api, throwBad } from '../../utils';
1111
import type { RouteContext } from './types';
1212

1313
type SaverResolver = (req: Request) => Promise<{ saverId: string; threadId: string }> | { saverId: string; threadId: string };

‎packages/sbot/src/Server/routes/filesystem.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path from 'path';
55
import multer from 'multer';
66
import { FsApi } from '../FsApi';
77
import { gitHelper } from '../helpers/git';
8-
import { api, throwBad, parseRangeQuery, resolveExistingDir, safeRelPath, isPathInside, MAX_FILE_READ_SIZE } from '../utils';
8+
import { api, throwBad, parseRangeQuery, resolveExistingDir, safeRelPath, isPathInside, MAX_FILE_READ_SIZE } from '../../utils';
99
import type { RouteContext } from './types';
1010

1111
export class FilesystemRoutes {

0 commit comments

Comments
 (0)