@zqagent/core 0.3.10 → 0.3.11
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/index.cjs +96 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -2
- package/dist/index.d.ts +46 -2
- package/dist/index.js +94 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/providers/diagnostics.cjs +17 -3
- package/dist/internal/providers/diagnostics.cjs.map +1 -1
- package/dist/internal/providers/diagnostics.d.cts +11 -1
- package/dist/internal/providers/diagnostics.d.ts +11 -1
- package/dist/internal/providers/diagnostics.js +15 -2
- package/dist/internal/providers/diagnostics.js.map +1 -1
- package/dist/internal/providers/models.cjs.map +1 -1
- package/dist/internal/providers/models.js.map +1 -1
- package/dist/internal/update/controller.cjs +2 -2
- package/dist/internal/update/controller.cjs.map +1 -1
- package/dist/internal/update/controller.js +1 -1
- package/dist/internal/update/platform.cjs +2 -2
- package/dist/internal/update/platform.cjs.map +1 -1
- package/dist/internal/update/platform.js +1 -1
- package/dist/tools/explore.cjs +76 -4
- package/dist/tools/explore.cjs.map +1 -1
- package/dist/tools/explore.js +76 -4
- package/dist/tools/explore.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -125,6 +125,8 @@ __export(src_exports, {
|
|
|
125
125
|
registerTerminalTools: () => registerTerminalTools,
|
|
126
126
|
registerTodoTool: () => registerTodoTool,
|
|
127
127
|
registerWebTools: () => registerWebTools,
|
|
128
|
+
repairToolCallHistory: () => repairToolCallHistory,
|
|
129
|
+
repairToolCallHistoryDetailed: () => repairToolCallHistoryDetailed,
|
|
128
130
|
resetFfmpegCache: () => resetFfmpegCache,
|
|
129
131
|
resetSandboxCache: () => resetSandboxCache,
|
|
130
132
|
resolveMedia: () => resolveMedia,
|
|
@@ -345,10 +347,22 @@ function authErrorHints(message, code = "") {
|
|
|
345
347
|
"\u51ED\u636E\u65E0\u6548\uFF1A\u82E5\u7528\u7684\u662F\u300C\u5FD7\u524D\u5927\u6A21\u578B\uFF08\u5185\u7F6E\uFF09\u300D\uFF0C\u5728\u8282\u70B9\u8BBE\u7F6E\u7684\u6A21\u578B\u9875\u70B9\u300C\u5237\u65B0\u5185\u7F6E\u6A21\u578B\u300D\u91CD\u65B0\u9886\u53D6 Key\uFF08\u5728\u63A7\u5236\u53F0\u91CD\u7F6E\u8FC7 Key \u540E\u9700\u8981\u8FD9\u4E00\u6B65\uFF09\uFF1B\u82E5\u662F\u81EA\u586B\u7684\u4F9B\u5E94\u5546\uFF0C\u8BF7\u68C0\u67E5 Key \u662F\u5426\u6B63\u786E\u6216\u5DF2\u8FC7\u671F"
|
|
346
348
|
];
|
|
347
349
|
}
|
|
350
|
+
function toolCallHistoryHints(message, code = "") {
|
|
351
|
+
const text = `${message} ${code}`;
|
|
352
|
+
if (!/tool_calls|tool[_ ]?call[_ ]?id/i.test(text) || !/must be followed by tool messages|insufficient tool messages|no tool output found|tool messages responding/i.test(
|
|
353
|
+
text
|
|
354
|
+
)) {
|
|
355
|
+
return [];
|
|
356
|
+
}
|
|
357
|
+
return [
|
|
358
|
+
"\u8FD9\u4E0D\u662F\u6A21\u578B\u6216\u4F59\u989D\u95EE\u9898\uFF1A\u4F1A\u8BDD\u5386\u53F2\u91CC\u6709\u4E00\u6761\u300C\u5DE5\u5177\u8C03\u7528\u6CA1\u6709\u62FF\u5230\u7ED3\u679C\u300D\u7684\u8BB0\u5F55\uFF08\u901A\u5E38\u662F\u4E0A\u6B21\u5728\u5DE5\u5177\u6267\u884C\u4E2D\u6309\u4E86 Ctrl+C\uFF0C\u6216\u8FDB\u7A0B\u88AB\u4E2D\u65AD\uFF09",
|
|
359
|
+
"\u5F15\u64CE\u5DF2\u81EA\u52A8\u6E05\u7406\u5E76\u91CD\u8BD5\uFF1B\u5982\u679C\u4ECD\u62A5\u540C\u6837\u7684\u9519\u8BEF\uFF0C\u7528 /new \u5F00\u4E00\u4E2A\u65B0\u4F1A\u8BDD\u5373\u53EF\uFF08\u65E7\u4F1A\u8BDD\u7684\u5386\u53F2\u91CC\u8FD8\u7559\u7740\u8FD9\u6761\u8BB0\u5F55\uFF09"
|
|
360
|
+
];
|
|
361
|
+
}
|
|
348
362
|
function paramErrorHints(message, code = "") {
|
|
349
363
|
const text = `${message} ${code}`;
|
|
350
364
|
const hints = [];
|
|
351
|
-
if (/not[_\s]*(activated|enabled|purchased)|arrearage|quota|subscription|insufficient
|
|
365
|
+
if (/not[_\s]*(activated|enabled|purchased)|arrearage|quota|subscription|billing|未开通|欠费|额度|余额不足|insufficient[_\s]*(quota|balance|credit|funds)/i.test(
|
|
352
366
|
text
|
|
353
367
|
)) {
|
|
354
368
|
hints.push(
|
|
@@ -2220,6 +2234,76 @@ function applyToolResultBudget(tool, result, opts = {}) {
|
|
|
2220
2234
|
return { content, truncated: true, savedPath };
|
|
2221
2235
|
}
|
|
2222
2236
|
|
|
2237
|
+
// src/engine/history.ts
|
|
2238
|
+
function repairToolCallHistoryDetailed(messages) {
|
|
2239
|
+
const out = [];
|
|
2240
|
+
let droppedCalls = 0;
|
|
2241
|
+
let droppedResults = 0;
|
|
2242
|
+
let droppedMessages = 0;
|
|
2243
|
+
let i = 0;
|
|
2244
|
+
while (i < messages.length) {
|
|
2245
|
+
const m = messages[i];
|
|
2246
|
+
if (m.role === "tool") {
|
|
2247
|
+
droppedResults += 1;
|
|
2248
|
+
i += 1;
|
|
2249
|
+
continue;
|
|
2250
|
+
}
|
|
2251
|
+
const calls = m.role === "assistant" ? m.tool_calls : void 0;
|
|
2252
|
+
if (!calls?.length) {
|
|
2253
|
+
if (m.role === "assistant" && m.tool_calls) {
|
|
2254
|
+
const { tool_calls, ...rest } = m;
|
|
2255
|
+
void tool_calls;
|
|
2256
|
+
out.push(rest);
|
|
2257
|
+
} else {
|
|
2258
|
+
out.push(m);
|
|
2259
|
+
}
|
|
2260
|
+
i += 1;
|
|
2261
|
+
continue;
|
|
2262
|
+
}
|
|
2263
|
+
const responders = /* @__PURE__ */ new Map();
|
|
2264
|
+
const notices = [];
|
|
2265
|
+
let j = i + 1;
|
|
2266
|
+
while (j < messages.length) {
|
|
2267
|
+
const t = messages[j];
|
|
2268
|
+
if (t.role === "notice") {
|
|
2269
|
+
notices.push(t);
|
|
2270
|
+
j += 1;
|
|
2271
|
+
continue;
|
|
2272
|
+
}
|
|
2273
|
+
if (t.role !== "tool") break;
|
|
2274
|
+
if (t.tool_call_id && !responders.has(t.tool_call_id)) {
|
|
2275
|
+
responders.set(t.tool_call_id, t);
|
|
2276
|
+
}
|
|
2277
|
+
j += 1;
|
|
2278
|
+
}
|
|
2279
|
+
const kept = calls.filter((tc) => tc.id && responders.has(tc.id));
|
|
2280
|
+
droppedCalls += calls.length - kept.length;
|
|
2281
|
+
droppedResults += responders.size - kept.length;
|
|
2282
|
+
if (kept.length === 0) {
|
|
2283
|
+
const { tool_calls, ...rest } = m;
|
|
2284
|
+
void tool_calls;
|
|
2285
|
+
if ((rest.content ?? "").trim() !== "") out.push(rest);
|
|
2286
|
+
else droppedMessages += 1;
|
|
2287
|
+
out.push(...notices);
|
|
2288
|
+
} else {
|
|
2289
|
+
out.push(kept.length === calls.length ? m : { ...m, tool_calls: kept });
|
|
2290
|
+
for (const tc of kept) out.push(responders.get(tc.id));
|
|
2291
|
+
out.push(...notices);
|
|
2292
|
+
}
|
|
2293
|
+
i = j;
|
|
2294
|
+
}
|
|
2295
|
+
const unchanged = out.length === messages.length && out.every((m, idx) => m === messages[idx]);
|
|
2296
|
+
return {
|
|
2297
|
+
messages: unchanged ? messages : out,
|
|
2298
|
+
droppedCalls,
|
|
2299
|
+
droppedResults,
|
|
2300
|
+
droppedMessages
|
|
2301
|
+
};
|
|
2302
|
+
}
|
|
2303
|
+
function repairToolCallHistory(messages) {
|
|
2304
|
+
return repairToolCallHistoryDetailed(messages).messages;
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2223
2307
|
// src/engine/TurnEngine.ts
|
|
2224
2308
|
var crypto = __toESM(require("crypto"), 1);
|
|
2225
2309
|
var fs3 = __toESM(require("fs"), 1);
|
|
@@ -2758,6 +2842,7 @@ ${notice}` : text,
|
|
|
2758
2842
|
attachments = routed.attachments;
|
|
2759
2843
|
this.taskId = taskId;
|
|
2760
2844
|
this._turnStartTime = Date.now();
|
|
2845
|
+
this.messages = repairToolCallHistory(this.messages);
|
|
2761
2846
|
this.messages.push({
|
|
2762
2847
|
role: "user",
|
|
2763
2848
|
content: userInput,
|
|
@@ -3759,7 +3844,7 @@ ${notice}` : text,
|
|
|
3759
3844
|
/** 过滤 notice + 剥离 display-only 字段,得到最终发送视图 */
|
|
3760
3845
|
_finalizeOutbound(sourceMessages) {
|
|
3761
3846
|
const _STRIP = /* @__PURE__ */ new Set(["source", "_display", "ts", "reasoning", "usage", "attachmentRefs"]);
|
|
3762
|
-
|
|
3847
|
+
const stripped = sourceMessages.filter((m) => m.role !== "notice").map((m) => {
|
|
3763
3848
|
if (m.role === "tool") {
|
|
3764
3849
|
return {
|
|
3765
3850
|
role: "tool",
|
|
@@ -3768,15 +3853,16 @@ ${notice}` : text,
|
|
|
3768
3853
|
};
|
|
3769
3854
|
}
|
|
3770
3855
|
const staleAttachments = Boolean(m.attachments?.length) && (m.ts ?? 0) < this._turnStartTime;
|
|
3771
|
-
const
|
|
3856
|
+
const plain = {};
|
|
3772
3857
|
for (const [k, v] of Object.entries(m)) {
|
|
3773
3858
|
if (staleAttachments && k === "attachments") continue;
|
|
3774
3859
|
if (!_STRIP.has(k)) {
|
|
3775
|
-
|
|
3860
|
+
plain[k] = v;
|
|
3776
3861
|
}
|
|
3777
3862
|
}
|
|
3778
|
-
return
|
|
3863
|
+
return plain;
|
|
3779
3864
|
});
|
|
3865
|
+
return repairToolCallHistory(stripped);
|
|
3780
3866
|
}
|
|
3781
3867
|
/** 软阈值(token 数):达到它只淘汰旧工具结果 */
|
|
3782
3868
|
_softTriggerTokens() {
|
|
@@ -7296,6 +7382,9 @@ var ConsoleHook = class {
|
|
|
7296
7382
|
for (const hint of authErrorHints(error, errorType)) {
|
|
7297
7383
|
cliLog(` \u{1F4A1} ${hint}`);
|
|
7298
7384
|
}
|
|
7385
|
+
for (const hint of toolCallHistoryHints(error, errorType)) {
|
|
7386
|
+
cliLog(` \u{1F4A1} ${hint}`);
|
|
7387
|
+
}
|
|
7299
7388
|
for (const hint of paramErrorHints(error)) {
|
|
7300
7389
|
cliLog(` \u{1F4A1} ${hint}`);
|
|
7301
7390
|
}
|
|
@@ -13489,6 +13578,8 @@ function createDefaultEngine(opts) {
|
|
|
13489
13578
|
registerTerminalTools,
|
|
13490
13579
|
registerTodoTool,
|
|
13491
13580
|
registerWebTools,
|
|
13581
|
+
repairToolCallHistory,
|
|
13582
|
+
repairToolCallHistoryDetailed,
|
|
13492
13583
|
resetFfmpegCache,
|
|
13493
13584
|
resetSandboxCache,
|
|
13494
13585
|
resolveMedia,
|