@zqagent/core 0.3.9 → 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.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { M as Mode, S as ShellPolicy, E as EngineHook, C as CompactionStartInfo, a as CompactionDoneInfo, b as EventType, c as EngineErrorInfo, P as ProviderClient, T as TurnEngine } from './TurnEngine-BPKhWuSI.cjs';
2
2
  export { A as ApprovalOutcome, d as Approver, e as CompactionTrigger, D as Decision, O as OpenAIProvider, f as PermissionEngine, g as PermissionRequest, h as ShellSandboxStatus, i as TurnEngineOpts, W as WsEvent } from './TurnEngine-BPKhWuSI.cjs';
3
- import { T as TokenUsage, R as ReasoningEffort, M as Message } from './types-BYyXWWPW.cjs';
3
+ import { T as TokenUsage, M as Message, R as ReasoningEffort } from './types-BYyXWWPW.cjs';
4
4
  export { A as ATTACHMENT_DIR, d as AssistantTurn, e as AttachmentError, f as MAX_ATTACHMENTS, g as MAX_ATTACHMENT_BYTES, b as MessageAttachment, c as StoredAttachment, S as StreamChunk, h as ToolCall, a as ToolSchema, U as UPLOAD_DIR, W as WorkspaceFileRef, i as attachmentBytes, j as buildWorkspaceFileNotice, k as hasNonImageAttachments, n as normalizeAttachments, r as readStoredAttachment, s as saveAttachments, l as saveAttachmentsToWorkspace, m as splitByCapability, o as stripAttachments } from './types-BYyXWWPW.cjs';
5
5
  import { T as ToolRegistry } from './ToolRegistry-DouDvn9E.cjs';
6
6
  export { R as RiskClass, a as ToolMetadata, b as ToolSpec } from './ToolRegistry-DouDvn9E.cjs';
@@ -323,6 +323,50 @@ declare class MarkdownRenderer {
323
323
  private _fgReset;
324
324
  }
325
325
 
326
+ /**
327
+ * 会话历史里「工具调用 ↔ 工具结果」的配对修复
328
+ *
329
+ * OpenAI 兼容接口要求:带 `tool_calls` 的 assistant 消息,之后必须**逐条**跟随
330
+ * 对应的 `tool` 消息(`tool_call_id` 一一对应),否则整个请求直接 400:
331
+ *
332
+ * An assistant message with 'tool_calls' must be followed by tool messages
333
+ * responding to each 'tool_call_id'. (insufficient tool messages following
334
+ * tool_calls message)
335
+ *
336
+ * 历史里出现这种「悬空」调用很常见,属于中断/崩溃后的正常残留:
337
+ * - 用户在工具执行途中 Ctrl+C,退出前把 `engine.messages` 原样落盘;
338
+ * - 进程被杀、断电,落盘时正好停在「assistant 已追加、结果还没写回」;
339
+ * - 从旧版本(还没有清洗逻辑)恢复的会话。
340
+ *
341
+ * 这些历史一旦被原样回放,之后**每一条消息**都会失败——用户看到的是一进会话
342
+ * 就报 400,且换模型也没用。因此发送前必须修掉,而不是只在新建会话时清一次。
343
+ *
344
+ * 修复规则(保守:宁可少一段工具调用,也不改动其它内容):
345
+ * 1. assistant 的 `tool_calls` 只保留「紧随其后有 tool 结果」的那些;
346
+ * 2. 一条都不剩时去掉 `tool_calls` 字段——若正文也空了,则整条消息丢弃
347
+ * (空 assistant 消息部分供应商同样会拒绝);
348
+ * 3. 没有对应调用的孤立 tool 消息丢弃(它同样会触发 400)。
349
+ */
350
+
351
+ interface RepairResult {
352
+ messages: Message[];
353
+ /** 被丢弃的「没有结果」的工具调用数 */
354
+ droppedCalls: number;
355
+ /** 被丢弃的孤立工具结果数 */
356
+ droppedResults: number;
357
+ /** 因为「只剩空正文」而被整条丢弃的 assistant 消息数 */
358
+ droppedMessages: number;
359
+ }
360
+ /**
361
+ * 修复工具调用配对,返回新数组(不修改入参)。
362
+ *
363
+ * 只有紧随 assistant 的连续 tool 消息算作它的结果——这也是 OpenAI 协议本身的
364
+ * 要求;更远位置的 tool 消息一律视为孤立结果。
365
+ */
366
+ declare function repairToolCallHistoryDetailed(messages: Message[]): RepairResult;
367
+ /** 修复工具调用配对(只看结果) */
368
+ declare function repairToolCallHistory(messages: Message[]): Message[];
369
+
326
370
  /**
327
371
  * Agent 提示词的多语言形状。
328
372
  *
@@ -1141,4 +1185,4 @@ interface CreateEngineOpts {
1141
1185
  */
1142
1186
  declare function createDefaultEngine(opts: CreateEngineOpts): TurnEngine;
1143
1187
 
1144
- export { type AgentDef, AgentRegistry, BUILTIN_AGENTS, CODE_INSTRUCTIONS, COWORK_INSTRUCTIONS, CompactionDoneInfo, CompactionStartInfo, CompositeHook, type ConfinementResult, ConsoleHook, type ConsoleHookOptions, type CreateEngineOpts, DEFAULT_ALLOWED_COMMANDS, DISCUSS_MODE_CONTEXT, type DownloadResult, EngineErrorInfo, EngineHook, EventType, type GitResult, MCP_CALL_TOOL, MCP_GUIDANCE, MCP_SEARCH_TOOL, MarkdownRenderer, McpBuiltinContext, type McpConnectResult, type McpLazyOptions, McpManager, type McpManagerOptions, McpServerConfig, Message, Mode, OCR_GUIDANCE, PLAN_MODE_CONTEXT, PROMPT_LANGS, type PermissionConfig, type PromptLang, type PromptSet, ProviderClient, ReasoningEffort, type ResolveVcsOptions, type ResolvedBin, type ResolvedMedia, type RestoreResult, SHADOW_DIR, SandboxMode, SandboxOptions, SessionVcs, ShellPolicy, SubagentHook, type TerminalMetaView, type TerminalRecordView, type TerminalSource, TokenUsage, ToolRegistry, type TurnCommit, TurnEngine, type VcsConfigMode, VcsHook, type VcsMode, type VcsPlan, agentRef, assessCommand, buildEnvBlock, buildExplorerInstructions, buildInstructions, createDefaultEngine, downloadFfmpeg, getPrompts, gitMessage, gitOk, installHints, isGitRepo, loadPermissionConfig, matchPromptLang, normalizePromptLang, promptSets, registerTerminalTools, resetFfmpegCache, resolveMedia, resolveVcsPlan, runGit, sessionIndexPath };
1188
+ export { type AgentDef, AgentRegistry, BUILTIN_AGENTS, CODE_INSTRUCTIONS, COWORK_INSTRUCTIONS, CompactionDoneInfo, CompactionStartInfo, CompositeHook, type ConfinementResult, ConsoleHook, type ConsoleHookOptions, type CreateEngineOpts, DEFAULT_ALLOWED_COMMANDS, DISCUSS_MODE_CONTEXT, type DownloadResult, EngineErrorInfo, EngineHook, EventType, type GitResult, MCP_CALL_TOOL, MCP_GUIDANCE, MCP_SEARCH_TOOL, MarkdownRenderer, McpBuiltinContext, type McpConnectResult, type McpLazyOptions, McpManager, type McpManagerOptions, McpServerConfig, Message, Mode, OCR_GUIDANCE, PLAN_MODE_CONTEXT, PROMPT_LANGS, type PermissionConfig, type PromptLang, type PromptSet, ProviderClient, ReasoningEffort, type RepairResult, type ResolveVcsOptions, type ResolvedBin, type ResolvedMedia, type RestoreResult, SHADOW_DIR, SandboxMode, SandboxOptions, SessionVcs, ShellPolicy, SubagentHook, type TerminalMetaView, type TerminalRecordView, type TerminalSource, TokenUsage, ToolRegistry, type TurnCommit, TurnEngine, type VcsConfigMode, VcsHook, type VcsMode, type VcsPlan, agentRef, assessCommand, buildEnvBlock, buildExplorerInstructions, buildInstructions, createDefaultEngine, downloadFfmpeg, getPrompts, gitMessage, gitOk, installHints, isGitRepo, loadPermissionConfig, matchPromptLang, normalizePromptLang, promptSets, registerTerminalTools, repairToolCallHistory, repairToolCallHistoryDetailed, resetFfmpegCache, resolveMedia, resolveVcsPlan, runGit, sessionIndexPath };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { M as Mode, S as ShellPolicy, E as EngineHook, C as CompactionStartInfo, a as CompactionDoneInfo, b as EventType, c as EngineErrorInfo, P as ProviderClient, T as TurnEngine } from './TurnEngine-DtGEuVLT.js';
2
2
  export { A as ApprovalOutcome, d as Approver, e as CompactionTrigger, D as Decision, O as OpenAIProvider, f as PermissionEngine, g as PermissionRequest, h as ShellSandboxStatus, i as TurnEngineOpts, W as WsEvent } from './TurnEngine-DtGEuVLT.js';
3
- import { T as TokenUsage, R as ReasoningEffort, M as Message } from './types-BYyXWWPW.js';
3
+ import { T as TokenUsage, M as Message, R as ReasoningEffort } from './types-BYyXWWPW.js';
4
4
  export { A as ATTACHMENT_DIR, d as AssistantTurn, e as AttachmentError, f as MAX_ATTACHMENTS, g as MAX_ATTACHMENT_BYTES, b as MessageAttachment, c as StoredAttachment, S as StreamChunk, h as ToolCall, a as ToolSchema, U as UPLOAD_DIR, W as WorkspaceFileRef, i as attachmentBytes, j as buildWorkspaceFileNotice, k as hasNonImageAttachments, n as normalizeAttachments, r as readStoredAttachment, s as saveAttachments, l as saveAttachmentsToWorkspace, m as splitByCapability, o as stripAttachments } from './types-BYyXWWPW.js';
5
5
  import { T as ToolRegistry } from './ToolRegistry-Cy0fQxrb.js';
6
6
  export { R as RiskClass, a as ToolMetadata, b as ToolSpec } from './ToolRegistry-Cy0fQxrb.js';
@@ -323,6 +323,50 @@ declare class MarkdownRenderer {
323
323
  private _fgReset;
324
324
  }
325
325
 
326
+ /**
327
+ * 会话历史里「工具调用 ↔ 工具结果」的配对修复
328
+ *
329
+ * OpenAI 兼容接口要求:带 `tool_calls` 的 assistant 消息,之后必须**逐条**跟随
330
+ * 对应的 `tool` 消息(`tool_call_id` 一一对应),否则整个请求直接 400:
331
+ *
332
+ * An assistant message with 'tool_calls' must be followed by tool messages
333
+ * responding to each 'tool_call_id'. (insufficient tool messages following
334
+ * tool_calls message)
335
+ *
336
+ * 历史里出现这种「悬空」调用很常见,属于中断/崩溃后的正常残留:
337
+ * - 用户在工具执行途中 Ctrl+C,退出前把 `engine.messages` 原样落盘;
338
+ * - 进程被杀、断电,落盘时正好停在「assistant 已追加、结果还没写回」;
339
+ * - 从旧版本(还没有清洗逻辑)恢复的会话。
340
+ *
341
+ * 这些历史一旦被原样回放,之后**每一条消息**都会失败——用户看到的是一进会话
342
+ * 就报 400,且换模型也没用。因此发送前必须修掉,而不是只在新建会话时清一次。
343
+ *
344
+ * 修复规则(保守:宁可少一段工具调用,也不改动其它内容):
345
+ * 1. assistant 的 `tool_calls` 只保留「紧随其后有 tool 结果」的那些;
346
+ * 2. 一条都不剩时去掉 `tool_calls` 字段——若正文也空了,则整条消息丢弃
347
+ * (空 assistant 消息部分供应商同样会拒绝);
348
+ * 3. 没有对应调用的孤立 tool 消息丢弃(它同样会触发 400)。
349
+ */
350
+
351
+ interface RepairResult {
352
+ messages: Message[];
353
+ /** 被丢弃的「没有结果」的工具调用数 */
354
+ droppedCalls: number;
355
+ /** 被丢弃的孤立工具结果数 */
356
+ droppedResults: number;
357
+ /** 因为「只剩空正文」而被整条丢弃的 assistant 消息数 */
358
+ droppedMessages: number;
359
+ }
360
+ /**
361
+ * 修复工具调用配对,返回新数组(不修改入参)。
362
+ *
363
+ * 只有紧随 assistant 的连续 tool 消息算作它的结果——这也是 OpenAI 协议本身的
364
+ * 要求;更远位置的 tool 消息一律视为孤立结果。
365
+ */
366
+ declare function repairToolCallHistoryDetailed(messages: Message[]): RepairResult;
367
+ /** 修复工具调用配对(只看结果) */
368
+ declare function repairToolCallHistory(messages: Message[]): Message[];
369
+
326
370
  /**
327
371
  * Agent 提示词的多语言形状。
328
372
  *
@@ -1141,4 +1185,4 @@ interface CreateEngineOpts {
1141
1185
  */
1142
1186
  declare function createDefaultEngine(opts: CreateEngineOpts): TurnEngine;
1143
1187
 
1144
- export { type AgentDef, AgentRegistry, BUILTIN_AGENTS, CODE_INSTRUCTIONS, COWORK_INSTRUCTIONS, CompactionDoneInfo, CompactionStartInfo, CompositeHook, type ConfinementResult, ConsoleHook, type ConsoleHookOptions, type CreateEngineOpts, DEFAULT_ALLOWED_COMMANDS, DISCUSS_MODE_CONTEXT, type DownloadResult, EngineErrorInfo, EngineHook, EventType, type GitResult, MCP_CALL_TOOL, MCP_GUIDANCE, MCP_SEARCH_TOOL, MarkdownRenderer, McpBuiltinContext, type McpConnectResult, type McpLazyOptions, McpManager, type McpManagerOptions, McpServerConfig, Message, Mode, OCR_GUIDANCE, PLAN_MODE_CONTEXT, PROMPT_LANGS, type PermissionConfig, type PromptLang, type PromptSet, ProviderClient, ReasoningEffort, type ResolveVcsOptions, type ResolvedBin, type ResolvedMedia, type RestoreResult, SHADOW_DIR, SandboxMode, SandboxOptions, SessionVcs, ShellPolicy, SubagentHook, type TerminalMetaView, type TerminalRecordView, type TerminalSource, TokenUsage, ToolRegistry, type TurnCommit, TurnEngine, type VcsConfigMode, VcsHook, type VcsMode, type VcsPlan, agentRef, assessCommand, buildEnvBlock, buildExplorerInstructions, buildInstructions, createDefaultEngine, downloadFfmpeg, getPrompts, gitMessage, gitOk, installHints, isGitRepo, loadPermissionConfig, matchPromptLang, normalizePromptLang, promptSets, registerTerminalTools, resetFfmpegCache, resolveMedia, resolveVcsPlan, runGit, sessionIndexPath };
1188
+ export { type AgentDef, AgentRegistry, BUILTIN_AGENTS, CODE_INSTRUCTIONS, COWORK_INSTRUCTIONS, CompactionDoneInfo, CompactionStartInfo, CompositeHook, type ConfinementResult, ConsoleHook, type ConsoleHookOptions, type CreateEngineOpts, DEFAULT_ALLOWED_COMMANDS, DISCUSS_MODE_CONTEXT, type DownloadResult, EngineErrorInfo, EngineHook, EventType, type GitResult, MCP_CALL_TOOL, MCP_GUIDANCE, MCP_SEARCH_TOOL, MarkdownRenderer, McpBuiltinContext, type McpConnectResult, type McpLazyOptions, McpManager, type McpManagerOptions, McpServerConfig, Message, Mode, OCR_GUIDANCE, PLAN_MODE_CONTEXT, PROMPT_LANGS, type PermissionConfig, type PromptLang, type PromptSet, ProviderClient, ReasoningEffort, type RepairResult, type ResolveVcsOptions, type ResolvedBin, type ResolvedMedia, type RestoreResult, SHADOW_DIR, SandboxMode, SandboxOptions, SessionVcs, ShellPolicy, SubagentHook, type TerminalMetaView, type TerminalRecordView, type TerminalSource, TokenUsage, ToolRegistry, type TurnCommit, TurnEngine, type VcsConfigMode, VcsHook, type VcsMode, type VcsPlan, agentRef, assessCommand, buildEnvBlock, buildExplorerInstructions, buildInstructions, createDefaultEngine, downloadFfmpeg, getPrompts, gitMessage, gitOk, installHints, isGitRepo, loadPermissionConfig, matchPromptLang, normalizePromptLang, promptSets, registerTerminalTools, repairToolCallHistory, repairToolCallHistoryDetailed, resetFfmpegCache, resolveMedia, resolveVcsPlan, runGit, sessionIndexPath };
package/dist/index.js CHANGED
@@ -216,10 +216,22 @@ function authErrorHints(message, code = "") {
216
216
  "\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"
217
217
  ];
218
218
  }
219
+ function toolCallHistoryHints(message, code = "") {
220
+ const text = `${message} ${code}`;
221
+ 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(
222
+ text
223
+ )) {
224
+ return [];
225
+ }
226
+ return [
227
+ "\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",
228
+ "\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"
229
+ ];
230
+ }
219
231
  function paramErrorHints(message, code = "") {
220
232
  const text = `${message} ${code}`;
221
233
  const hints = [];
222
- if (/not[_\s]*(activated|enabled|purchased)|arrearage|quota|subscription|insufficient|未开通|欠费|额度|余额不足/i.test(
234
+ if (/not[_\s]*(activated|enabled|purchased)|arrearage|quota|subscription|billing|未开通|欠费|额度|余额不足|insufficient[_\s]*(quota|balance|credit|funds)/i.test(
223
235
  text
224
236
  )) {
225
237
  hints.push(
@@ -2091,6 +2103,76 @@ function applyToolResultBudget(tool, result, opts = {}) {
2091
2103
  return { content, truncated: true, savedPath };
2092
2104
  }
2093
2105
 
2106
+ // src/engine/history.ts
2107
+ function repairToolCallHistoryDetailed(messages) {
2108
+ const out = [];
2109
+ let droppedCalls = 0;
2110
+ let droppedResults = 0;
2111
+ let droppedMessages = 0;
2112
+ let i = 0;
2113
+ while (i < messages.length) {
2114
+ const m = messages[i];
2115
+ if (m.role === "tool") {
2116
+ droppedResults += 1;
2117
+ i += 1;
2118
+ continue;
2119
+ }
2120
+ const calls = m.role === "assistant" ? m.tool_calls : void 0;
2121
+ if (!calls?.length) {
2122
+ if (m.role === "assistant" && m.tool_calls) {
2123
+ const { tool_calls, ...rest } = m;
2124
+ void tool_calls;
2125
+ out.push(rest);
2126
+ } else {
2127
+ out.push(m);
2128
+ }
2129
+ i += 1;
2130
+ continue;
2131
+ }
2132
+ const responders = /* @__PURE__ */ new Map();
2133
+ const notices = [];
2134
+ let j = i + 1;
2135
+ while (j < messages.length) {
2136
+ const t = messages[j];
2137
+ if (t.role === "notice") {
2138
+ notices.push(t);
2139
+ j += 1;
2140
+ continue;
2141
+ }
2142
+ if (t.role !== "tool") break;
2143
+ if (t.tool_call_id && !responders.has(t.tool_call_id)) {
2144
+ responders.set(t.tool_call_id, t);
2145
+ }
2146
+ j += 1;
2147
+ }
2148
+ const kept = calls.filter((tc) => tc.id && responders.has(tc.id));
2149
+ droppedCalls += calls.length - kept.length;
2150
+ droppedResults += responders.size - kept.length;
2151
+ if (kept.length === 0) {
2152
+ const { tool_calls, ...rest } = m;
2153
+ void tool_calls;
2154
+ if ((rest.content ?? "").trim() !== "") out.push(rest);
2155
+ else droppedMessages += 1;
2156
+ out.push(...notices);
2157
+ } else {
2158
+ out.push(kept.length === calls.length ? m : { ...m, tool_calls: kept });
2159
+ for (const tc of kept) out.push(responders.get(tc.id));
2160
+ out.push(...notices);
2161
+ }
2162
+ i = j;
2163
+ }
2164
+ const unchanged = out.length === messages.length && out.every((m, idx) => m === messages[idx]);
2165
+ return {
2166
+ messages: unchanged ? messages : out,
2167
+ droppedCalls,
2168
+ droppedResults,
2169
+ droppedMessages
2170
+ };
2171
+ }
2172
+ function repairToolCallHistory(messages) {
2173
+ return repairToolCallHistoryDetailed(messages).messages;
2174
+ }
2175
+
2094
2176
  // src/engine/TurnEngine.ts
2095
2177
  import * as crypto from "crypto";
2096
2178
  import * as fs3 from "fs";
@@ -2631,6 +2713,7 @@ ${notice}` : text,
2631
2713
  attachments = routed.attachments;
2632
2714
  this.taskId = taskId;
2633
2715
  this._turnStartTime = Date.now();
2716
+ this.messages = repairToolCallHistory(this.messages);
2634
2717
  this.messages.push({
2635
2718
  role: "user",
2636
2719
  content: userInput,
@@ -3632,7 +3715,7 @@ ${notice}` : text,
3632
3715
  /** 过滤 notice + 剥离 display-only 字段,得到最终发送视图 */
3633
3716
  _finalizeOutbound(sourceMessages) {
3634
3717
  const _STRIP = /* @__PURE__ */ new Set(["source", "_display", "ts", "reasoning", "usage", "attachmentRefs"]);
3635
- return sourceMessages.filter((m) => m.role !== "notice").map((m) => {
3718
+ const stripped = sourceMessages.filter((m) => m.role !== "notice").map((m) => {
3636
3719
  if (m.role === "tool") {
3637
3720
  return {
3638
3721
  role: "tool",
@@ -3641,15 +3724,16 @@ ${notice}` : text,
3641
3724
  };
3642
3725
  }
3643
3726
  const staleAttachments = Boolean(m.attachments?.length) && (m.ts ?? 0) < this._turnStartTime;
3644
- const stripped = {};
3727
+ const plain = {};
3645
3728
  for (const [k, v] of Object.entries(m)) {
3646
3729
  if (staleAttachments && k === "attachments") continue;
3647
3730
  if (!_STRIP.has(k)) {
3648
- stripped[k] = v;
3731
+ plain[k] = v;
3649
3732
  }
3650
3733
  }
3651
- return stripped;
3734
+ return plain;
3652
3735
  });
3736
+ return repairToolCallHistory(stripped);
3653
3737
  }
3654
3738
  /** 软阈值(token 数):达到它只淘汰旧工具结果 */
3655
3739
  _softTriggerTokens() {
@@ -7169,6 +7253,9 @@ var ConsoleHook = class {
7169
7253
  for (const hint of authErrorHints(error, errorType)) {
7170
7254
  cliLog(` \u{1F4A1} ${hint}`);
7171
7255
  }
7256
+ for (const hint of toolCallHistoryHints(error, errorType)) {
7257
+ cliLog(` \u{1F4A1} ${hint}`);
7258
+ }
7172
7259
  for (const hint of paramErrorHints(error)) {
7173
7260
  cliLog(` \u{1F4A1} ${hint}`);
7174
7261
  }
@@ -13371,6 +13458,8 @@ export {
13371
13458
  registerTerminalTools,
13372
13459
  registerTodoTool,
13373
13460
  registerWebTools,
13461
+ repairToolCallHistory,
13462
+ repairToolCallHistoryDetailed,
13374
13463
  resetFfmpegCache,
13375
13464
  resetSandboxCache,
13376
13465
  resolveMedia,