xiaozuoassistant 0.2.57 → 0.2.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/core/brain.js +15 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { config } from '../config/loader.js';
|
|
|
2
2
|
import { skillRegistry } from '../skills/registry.js';
|
|
3
3
|
import { SYSTEM_PROMPT } from '../config/prompts.js';
|
|
4
4
|
import { createOpenAIClient } from '../llm/openai.js';
|
|
5
|
+
import path from 'path';
|
|
5
6
|
export class Brain {
|
|
6
7
|
constructor() {
|
|
7
8
|
this.openai = createOpenAIClient(config.llm);
|
|
@@ -155,8 +156,21 @@ export class Brain {
|
|
|
155
156
|
const fsSuccess = fsToolOutcomes.some(x => x.success);
|
|
156
157
|
if (!fsSuccess) {
|
|
157
158
|
const lastFsError = [...fsToolOutcomes].reverse().find(x => !x.success)?.error;
|
|
159
|
+
const attemptedFsTools = fsToolOutcomes.map(x => x.name);
|
|
160
|
+
const absPathMatch = newMessage.match(/\/[^\s"'`]+/);
|
|
161
|
+
const requestedPath = absPathMatch ? absPathMatch[0] : '';
|
|
162
|
+
const resolvedWorkspace = effectiveWorkspace ? path.resolve(effectiveWorkspace) : '';
|
|
163
|
+
const resolvedRequested = requestedPath ? path.resolve(requestedPath) : '';
|
|
164
|
+
let workspaceCheck = '';
|
|
165
|
+
if (resolvedWorkspace && resolvedRequested) {
|
|
166
|
+
const rel = path.relative(resolvedWorkspace, resolvedRequested);
|
|
167
|
+
const outside = Boolean(rel) && (rel.startsWith('..') || path.isAbsolute(rel));
|
|
168
|
+
workspaceCheck = outside
|
|
169
|
+
? `路径检查:目标路径在 workspace 之外(${resolvedRequested} 不在 ${resolvedWorkspace} 内)。`
|
|
170
|
+
: `路径检查:目标路径位于 workspace 内。`;
|
|
171
|
+
}
|
|
158
172
|
const ws = effectiveWorkspace || '(not set)';
|
|
159
|
-
return `未能实际读取文件:文件工具未成功执行。\n当前会话 workspace:${ws}\n${
|
|
173
|
+
return `未能实际读取文件:文件工具未成功执行。\n当前会话 workspace:${ws}\n请求路径:${requestedPath || '(未识别到明确路径)'}\n${workspaceCheck || '路径检查:无法判定。'}\n${attemptedFsTools.length > 0 ? `已触发工具:${attemptedFsTools.join(', ')}` : '未触发任何 fs_* 文件工具调用(模型未选择工具)。'}\n${lastFsError ? `工具错误:${lastFsError}` : '原因:未拿到可用的文件工具执行结果。请重试,或缩短指令为“读取 <绝对路径>”。'}`;
|
|
160
174
|
}
|
|
161
175
|
}
|
|
162
176
|
if (process.env.DEBUG)
|