mirror of
https://github.com/7836246/cursor2api.git
synced 2026-05-10 07:43:49 +08:00
feat: show tools mode (disabled/passthrough) in startup and request logs
- Startup log: Tools: disabled / passthrough / schema=full - Request log: tools=98(跳过) / tools=98(透传) / tools=98
This commit is contained in:
18
src/index.ts
18
src/index.ts
@@ -159,12 +159,18 @@ app.listen(config.port, () => {
|
||||
const toolsCfg = config.tools;
|
||||
let toolsInfo = 'default (full, desc=full)';
|
||||
if (toolsCfg) {
|
||||
const parts: string[] = [];
|
||||
parts.push(`schema=${toolsCfg.schemaMode}`);
|
||||
parts.push(toolsCfg.descriptionMaxLength === 0 ? 'desc=full' : `desc≤${toolsCfg.descriptionMaxLength}`);
|
||||
if (toolsCfg.includeOnly?.length) parts.push(`whitelist=${toolsCfg.includeOnly.length}`);
|
||||
if (toolsCfg.exclude?.length) parts.push(`blacklist=${toolsCfg.exclude.length}`);
|
||||
toolsInfo = parts.join(', ');
|
||||
if (toolsCfg.disabled) {
|
||||
toolsInfo = '\x1b[33mdisabled\x1b[0m (不注入工具定义,节省上下文)';
|
||||
} else if (toolsCfg.passthrough) {
|
||||
toolsInfo = '\x1b[36mpassthrough\x1b[0m (原始 JSON 嵌入)';
|
||||
} else {
|
||||
const parts: string[] = [];
|
||||
parts.push(`schema=${toolsCfg.schemaMode}`);
|
||||
parts.push(toolsCfg.descriptionMaxLength === 0 ? 'desc=full' : `desc≤${toolsCfg.descriptionMaxLength}`);
|
||||
if (toolsCfg.includeOnly?.length) parts.push(`whitelist=${toolsCfg.includeOnly.length}`);
|
||||
if (toolsCfg.exclude?.length) parts.push(`blacklist=${toolsCfg.exclude.length}`);
|
||||
toolsInfo = parts.join(', ');
|
||||
}
|
||||
}
|
||||
|
||||
console.log('');
|
||||
|
||||
@@ -316,7 +316,13 @@ export function createRequestLogger(opts: {
|
||||
requestPayloads.delete(oldId);
|
||||
}
|
||||
|
||||
const toolInfo = opts.hasTools ? ` tools=${opts.toolCount}` : '';
|
||||
const toolMode = (() => {
|
||||
const cfg = getConfig().tools;
|
||||
if (cfg?.disabled) return '(跳过)';
|
||||
if (cfg?.passthrough) return '(透传)';
|
||||
return '';
|
||||
})();
|
||||
const toolInfo = opts.hasTools ? ` tools=${opts.toolCount}${toolMode}` : '';
|
||||
const fmtTag = summary.apiFormat === 'openai' ? ' [OAI]' : summary.apiFormat === 'responses' ? ' [RSP]' : '';
|
||||
console.log(`\x1b[36m⟶\x1b[0m [${requestId}] ${opts.method} ${opts.path}${fmtTag} | model=${opts.model} stream=${opts.stream}${toolInfo} msgs=${opts.messageCount}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user