zidane 5.12.4 → 5.12.6

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.
Files changed (67) hide show
  1. package/dist/{agent-CVTAoYS0.d.ts → agent-D1qjXlkI.d.ts} +32 -1
  2. package/dist/agent-D1qjXlkI.d.ts.map +1 -0
  3. package/dist/chat/pure.d.ts +3 -3
  4. package/dist/chat.d.ts +6 -6
  5. package/dist/chat.js +2 -2
  6. package/dist/contexts/e2b.d.ts +1 -1
  7. package/dist/eval.d.ts +1 -1
  8. package/dist/eval.js +2 -2
  9. package/dist/{headless-DM5JeUiE.js → headless-Bg-Ju0Cz.js} +5 -5
  10. package/dist/{headless-DM5JeUiE.js.map → headless-Bg-Ju0Cz.js.map} +1 -1
  11. package/dist/headless.d.ts +1 -1
  12. package/dist/headless.js +1 -1
  13. package/dist/{index-BuIaw3r3.d.ts → index-BXGPPmHr.d.ts} +2 -2
  14. package/dist/{index-BuIaw3r3.d.ts.map → index-BXGPPmHr.d.ts.map} +1 -1
  15. package/dist/{index-Gin_mFQJ.d.ts → index-CtRZU1no.d.ts} +2 -2
  16. package/dist/{index-Gin_mFQJ.d.ts.map → index-CtRZU1no.d.ts.map} +1 -1
  17. package/dist/index.d.ts +4 -4
  18. package/dist/index.js +7 -7
  19. package/dist/{logger-CYtWKlBF.d.ts → logger-ICqlipiT.d.ts} +2 -2
  20. package/dist/{logger-CYtWKlBF.d.ts.map → logger-ICqlipiT.d.ts.map} +1 -1
  21. package/dist/{login-94imBv_3.js → login-zK_YpxeU.js} +27 -4
  22. package/dist/login-zK_YpxeU.js.map +1 -0
  23. package/dist/mcp.d.ts +1 -1
  24. package/dist/{messages-9wyCuvLF.js → messages-CV_K9I6j.js} +64 -22
  25. package/dist/messages-CV_K9I6j.js.map +1 -0
  26. package/dist/output/stream-json.d.ts +2 -2
  27. package/dist/output/stream-json.js +1 -1
  28. package/dist/output/terminal.d.ts +2 -2
  29. package/dist/{presets-BorC0fVx.js → presets-CrDhfNeO.js} +2 -2
  30. package/dist/{presets-BorC0fVx.js.map → presets-CrDhfNeO.js.map} +1 -1
  31. package/dist/presets.d.ts +2 -2
  32. package/dist/presets.js +1 -1
  33. package/dist/{providers-C_zClj1S.js → providers-C6rpOk0l.js} +2 -2
  34. package/dist/{providers-C_zClj1S.js.map → providers-C6rpOk0l.js.map} +1 -1
  35. package/dist/providers.d.ts +1 -1
  36. package/dist/providers.js +2 -2
  37. package/dist/restate.d.ts +1 -1
  38. package/dist/session/sqlite.d.ts +1 -1
  39. package/dist/{session-CB23Ne0_.js → session-nRmW_P8d.js} +2 -2
  40. package/dist/{session-CB23Ne0_.js.map → session-nRmW_P8d.js.map} +1 -1
  41. package/dist/session.d.ts +1 -1
  42. package/dist/session.js +2 -2
  43. package/dist/skills.d.ts +2 -2
  44. package/dist/{tool-formatters-Chwpa2Ix.d.ts → tool-formatters-Bsn5DqaN.d.ts} +2 -2
  45. package/dist/{tool-formatters-Chwpa2Ix.d.ts.map → tool-formatters-Bsn5DqaN.d.ts.map} +1 -1
  46. package/dist/tools/fetch-url.d.ts +1 -1
  47. package/dist/tools/web-search.d.ts +1 -1
  48. package/dist/{tools-BlMV33N1.js → tools-CbuxYK28.js} +148 -14
  49. package/dist/tools-CbuxYK28.js.map +1 -0
  50. package/dist/tools.d.ts +2 -2
  51. package/dist/tools.js +1 -1
  52. package/dist/{transcript-anchors-LMTpzn6r.d.ts → transcript-anchors-Bx7X5mDb.d.ts} +4 -4
  53. package/dist/{transcript-anchors-LMTpzn6r.d.ts.map → transcript-anchors-Bx7X5mDb.d.ts.map} +1 -1
  54. package/dist/{transcript-anchors-D2zBge6D.js → transcript-anchors-D2f8sAnd.js} +6 -6
  55. package/dist/{transcript-anchors-D2zBge6D.js.map → transcript-anchors-D2f8sAnd.js.map} +1 -1
  56. package/dist/tui.d.ts +3 -3
  57. package/dist/tui.d.ts.map +1 -1
  58. package/dist/tui.js +157 -46
  59. package/dist/tui.js.map +1 -1
  60. package/dist/{turn-operations-DyOAiVE3.d.ts → turn-operations-DDF9RPz1.d.ts} +3 -3
  61. package/dist/{turn-operations-DyOAiVE3.d.ts.map → turn-operations-DDF9RPz1.d.ts.map} +1 -1
  62. package/dist/types.d.ts +2 -2
  63. package/package.json +6 -6
  64. package/dist/agent-CVTAoYS0.d.ts.map +0 -1
  65. package/dist/login-94imBv_3.js.map +0 -1
  66. package/dist/messages-9wyCuvLF.js.map +0 -1
  67. package/dist/tools-BlMV33N1.js.map +0 -1
@@ -1,9 +1,9 @@
1
+ import { F as canonicalizePrompt, L as fnv1aBase36, O as appendStaticSection, P as buildPromptMessage, a as detectTurnInterruption, c as filterUnresolvedToolUses, d as remintDuplicateToolCallIds, f as resolveContentRefsInMessages, j as renderSystemForWire, n as SYNTHETIC_TOOL_RESULT_PLACEHOLDER, o as ensureEndsWithUserMessage, s as ensureToolResultPairing } from "./messages-CV_K9I6j.js";
1
2
  import { r as utf8ByteLength } from "./utils-ngQzYzZD.js";
2
3
  import { t as buildContextBreakdown } from "./context-breakdown-kO-pDsay.js";
3
4
  import { a as formatTaskStatus, i as formatDuration, o as formatTaskSummary, s as previewLine } from "./format-BNOXpl-1.js";
4
- import { _ as ANTHROPIC_EXTRA_MODELS, a as local, c as generatePkce, f as arcee, g as writeFileAtomicAsync, i as openai, l as cerebras, n as createXaiOAuthProvider, p as anthropic, r as openrouter, s as createCursorOAuthProvider, t as xai, u as baseten, v as FAST_MODE_OPTIONS } from "./providers-C_zClj1S.js";
5
+ import { _ as ANTHROPIC_EXTRA_MODELS, a as local, c as generatePkce, f as arcee, g as writeFileAtomicAsync, i as openai, l as cerebras, n as createXaiOAuthProvider, p as anthropic, r as openrouter, s as createCursorOAuthProvider, t as xai, u as baseten, v as FAST_MODE_OPTIONS } from "./providers-C6rpOk0l.js";
5
6
  import { i as AgentProviderError, l as errorMessage, m as toTypedError, n as AgentBudgetExceededError, o as AgentToolPairingError, t as AgentAbortedError, u as isAbortLikeError } from "./errors-BpPfMo_4.js";
6
- import { F as canonicalizePrompt, O as appendStaticSection, P as buildPromptMessage, a as detectTurnInterruption, c as filterUnresolvedToolUses, d as remintDuplicateToolCallIds, f as resolveContentRefsInMessages, j as renderSystemForWire, n as SYNTHETIC_TOOL_RESULT_PLACEHOLDER, o as ensureEndsWithUserMessage, s as ensureToolResultPairing } from "./messages-9wyCuvLF.js";
7
7
  import { n as reconcileImageMediaType } from "./media-sniff-Bn76JxAu.js";
8
8
  import { a as toolOutputByteLength, i as toolOutputBudgetByteLength, o as toolResultToText, r as documentBlockMarker, t as DEFAULT_AGENT_CLOCK } from "./types-DxHDaqN7.js";
9
9
  import { r as createProcessContext, t as resolveDetachedTasksCapability } from "./contexts-DglWSzmR.js";
@@ -71,6 +71,66 @@ function toCanonicalName(wire, maps) {
71
71
  return maps.canonicalByAlias.get(wire) ?? wire;
72
72
  }
73
73
  /**
74
+ * Tool names must match `^[a-zA-Z0-9_-]{1,N}$`. The charset is universal; the
75
+ * length cap is taken as the STRICTEST across providers (OpenAI/-compat: 64;
76
+ * Anthropic allows 128) so a sanitized name is valid on EVERY provider — and so
77
+ * a mid-session model switch can never make the provider-level drop guard
78
+ * (`sanitizeToolSpecs`) discard a tool we could have kept.
79
+ *
80
+ * MCP tool names are minted verbatim as `mcp_<server>_<tool>` (see
81
+ * `connectMcpServers`), so a server configured as `SSH Ipseity` yields
82
+ * `mcp_SSH Ipseity_exec` — the space (and `.`/`:`/`/`, unicode, or a >64-char
83
+ * join) 400s the request the instant that tool lands in the `tools` array:
84
+ * `tools.N.custom.name: String should match pattern ...`.
85
+ */
86
+ const WIRE_NAME_MAX = 64;
87
+ const WIRE_NAME_OK = /^[\w-]{1,64}$/;
88
+ const WIRE_NAME_BAD_CHAR = /[^\w-]/g;
89
+ /**
90
+ * Build OUTBOUND wire aliases that coerce any tool name violating the provider
91
+ * name constraint into a valid one. Only offenders get an entry; clean setups
92
+ * return `undefined` (no alias map churn, prompt cache untouched).
93
+ *
94
+ * Returned as a `Record` so it merges into `effectiveToolAliases` upstream of
95
+ * BOTH wire-name computations — the `tool_search` catalog and the `tools` array
96
+ * — keeping them in lockstep. Canonical names (dispatch, hooks, persisted
97
+ * turns) never change; only the bytes the model sees do.
98
+ *
99
+ * Scoped to MCP names (the only third-party-controlled, thus only realistically
100
+ * invalid, source). The hash suffix keeps distinct originals distinct even when
101
+ * they collapse to the same replacement; `taken` guards the residual collision.
102
+ */
103
+ function buildSanitizedWireAliases(names, existing) {
104
+ const wireOf = (name) => {
105
+ const alias = existing?.[name];
106
+ return typeof alias === "string" && alias.length > 0 ? alias : name;
107
+ };
108
+ const taken = /* @__PURE__ */ new Set();
109
+ const offenders = [];
110
+ for (const name of names) {
111
+ const wire = wireOf(name);
112
+ if (WIRE_NAME_OK.test(wire)) taken.add(wire);
113
+ else offenders.push(name);
114
+ }
115
+ if (offenders.length === 0) return void 0;
116
+ const out = {};
117
+ for (const name of offenders) {
118
+ const sanitized = sanitizeWireName(wireOf(name), taken);
119
+ out[name] = sanitized;
120
+ taken.add(sanitized);
121
+ }
122
+ return out;
123
+ }
124
+ function sanitizeWireName(name, taken) {
125
+ let base = name.replace(WIRE_NAME_BAD_CHAR, "_");
126
+ if (base.length === 0) base = "tool";
127
+ const hash = fnv1aBase36(name);
128
+ const withSuffix = (suffix) => `${base.slice(0, Math.max(1, WIRE_NAME_MAX - suffix.length))}${suffix}`;
129
+ let candidate = withSuffix(`_${hash}`);
130
+ for (let n = 1; taken.has(candidate); n++) candidate = withSuffix(`_${hash}_${n}`);
131
+ return candidate;
132
+ }
133
+ /**
74
134
  * Augment {@link AliasMaps} with INBOUND-ONLY aliases for the Claude Code
75
135
  * `mcp__server__tool` double-underscore naming convention. For every MCP
76
136
  * tool registered with the canonical `mcp_<server>_<tool>` form, add a
@@ -3080,6 +3140,24 @@ const RETRY_DEFAULTS = {
3080
3140
  maxDelayMs: 3e4
3081
3141
  };
3082
3142
  /**
3143
+ * Reactive context-overflow recovery schedule. When a turn is rejected with
3144
+ * `context_exceeded` (pre-stream — the request was too big for the model's
3145
+ * window), the loop emergency-compacts older `tool_result` bodies via
3146
+ * {@link applyTailCompaction} and re-issues, instead of surfacing the error.
3147
+ *
3148
+ * Each entry is the `keepTurns` floor for one recovery pass: the first pass
3149
+ * keeps the last 4 turns' tool output intact, then 1, then everything is
3150
+ * eligible. Progressive so the model loses as little fresh context as possible
3151
+ * while still shrinking enough to fit. The array length bounds the number of
3152
+ * recoveries per turn. Runs regardless of `behavior.compactStrategy` (calls the
3153
+ * compactor directly), so it protects runs that never opted into compaction.
3154
+ */
3155
+ const CONTEXT_OVERFLOW_KEEP_TURNS = [
3156
+ 4,
3157
+ 1,
3158
+ 0
3159
+ ];
3160
+ /**
3083
3161
  * Normalize a user-supplied `RetryConfig` (any field may be missing or invalid)
3084
3162
  * into a fully-populated config the retry loop can use without per-field guards.
3085
3163
  *
@@ -3272,6 +3350,7 @@ async function executeTurn(ctx, turn, priorUsage) {
3272
3350
  const retryCfg = resolveRetryConfig(ctx.retry);
3273
3351
  let result;
3274
3352
  let attempt = 0;
3353
+ let overflowRecoveries = 0;
3275
3354
  while (true) {
3276
3355
  attempt += 1;
3277
3356
  try {
@@ -3322,7 +3401,8 @@ async function executeTurn(ctx, turn, priorUsage) {
3322
3401
  let wasAborted = ctx.signal.aborted || caught instanceof Error && caught.name === "AbortError";
3323
3402
  const classified = !wasAborted ? ctx.provider.classifyError?.(caught) : null;
3324
3403
  const isRetryable = classified?.kind === "provider_error" && classified.retryable === true;
3325
- if (!wasAborted && isRetryable && currentText === "" && currentThinking === "" && attempt < retryCfg.maxAttempts) {
3404
+ const cleanSlate = currentText === "" && currentThinking === "";
3405
+ if (!wasAborted && isRetryable && cleanSlate && attempt < retryCfg.maxAttempts) {
3326
3406
  const meta = extractStreamErrorMeta(caught);
3327
3407
  const delayMs = computeRetryDelayMs(attempt, retryCfg, extractRetryAfterMs(caught));
3328
3408
  await ctx.hooks.callHook("stream:retry", {
@@ -3343,6 +3423,36 @@ async function executeTurn(ctx, turn, priorUsage) {
3343
3423
  wasAborted = true;
3344
3424
  }
3345
3425
  }
3426
+ if (!wasAborted && classified?.kind === "context_exceeded" && cleanSlate && overflowRecoveries < CONTEXT_OVERFLOW_KEEP_TURNS.length) {
3427
+ const { readPathByCallId, toolNameByCallId } = collectCallMaps(canonicalMessages);
3428
+ let recoveredMessages;
3429
+ let elidedReadPaths = [];
3430
+ for (let k = overflowRecoveries; k < CONTEXT_OVERFLOW_KEEP_TURNS.length; k++) {
3431
+ const compacted = applyTailCompaction(streamOptions.messages, 0, CONTEXT_OVERFLOW_KEEP_TURNS[k], {
3432
+ readPathByCallId,
3433
+ toolNameByCallId,
3434
+ chunkTurns: 1
3435
+ });
3436
+ if (compacted.messages !== streamOptions.messages) {
3437
+ recoveredMessages = compacted.messages;
3438
+ elidedReadPaths = compacted.elidedReadPaths;
3439
+ overflowRecoveries = k + 1;
3440
+ break;
3441
+ }
3442
+ }
3443
+ if (recoveredMessages) {
3444
+ markReadStateForElidedPaths(ctx, ctx.handle.cwd, elidedReadPaths);
3445
+ let repaired = applyPairingRepair(ctx, recoveredMessages, turnId);
3446
+ repaired = ensureEndsWithUserMessage(repaired, ctx.provider);
3447
+ streamOptions.messages = repaired;
3448
+ await ctx.hooks.callHook("context:overflow", {
3449
+ turnId,
3450
+ attempt: overflowRecoveries,
3451
+ err: caught
3452
+ });
3453
+ continue;
3454
+ }
3455
+ }
3346
3456
  await streamHookChain;
3347
3457
  const errorUsage = {
3348
3458
  input: 0,
@@ -6079,6 +6189,7 @@ const HOOK_EVENT_SET = new Set([
6079
6189
  "stream:server_tool_result",
6080
6190
  "stream:error",
6081
6191
  "stream:retry",
6192
+ "context:overflow",
6082
6193
  "oauth:refresh",
6083
6194
  "content-ref:resolve",
6084
6195
  "tool:gate",
@@ -6685,10 +6796,15 @@ function createAgent({ provider, name: agentName, system: agentSystem, tools: ag
6685
6796
  } : sourceTools;
6686
6797
  const mcpToolNames = options.tools === void 0 && mcpConnection ? new Set(Object.keys(mcpConnection.tools)) : /* @__PURE__ */ new Set();
6687
6798
  const generatedMcpToolAliases = buildMcpToolNameSeparatorAliases(mcpToolNames, mcpServers, mcpToolNameSeparator);
6688
- const effectiveToolAliases = generatedMcpToolAliases ? {
6799
+ const baseToolAliases = generatedMcpToolAliases ? {
6689
6800
  ...generatedMcpToolAliases,
6690
6801
  ...toolAliases ?? {}
6691
6802
  } : toolAliases;
6803
+ const sanitizedWireAliases = buildSanitizedWireAliases(mcpToolNames, baseToolAliases);
6804
+ const effectiveToolAliases = sanitizedWireAliases ? {
6805
+ ...baseToolAliases ?? {},
6806
+ ...sanitizedWireAliases
6807
+ } : baseToolAliases;
6692
6808
  const mergedWithSkills = options.tools === void 0 && !!resolvedSkills && resolvedSkills.length > 0 && skillsConfig?.tool !== false ? {
6693
6809
  skills_use: createSkillsUseTool({
6694
6810
  catalog: resolvedSkills,
@@ -7402,29 +7518,47 @@ function createAgent({ provider, name: agentName, system: agentSystem, tools: ag
7402
7518
  ...mcpConnection.tools
7403
7519
  } : sourceTools;
7404
7520
  const mcpNames = new Set(mcpConnection ? Object.keys(mcpConnection.tools) : []);
7521
+ const preRunSeparatorAliases = buildMcpToolNameSeparatorAliases(mcpNames, mcpServers, agentBehavior?.mcpToolNameSeparator ?? "_");
7522
+ const preRunBaseAliases = preRunSeparatorAliases ? {
7523
+ ...preRunSeparatorAliases,
7524
+ ...toolAliases ?? {}
7525
+ } : toolAliases;
7526
+ const preRunSanitizedAliases = buildSanitizedWireAliases(mcpNames, preRunBaseAliases);
7527
+ const preRunAliases = preRunSanitizedAliases ? {
7528
+ ...preRunBaseAliases ?? {},
7529
+ ...preRunSanitizedAliases
7530
+ } : preRunBaseAliases;
7531
+ const wireNameFor = (canonical) => preRunAliases?.[canonical] ?? canonical;
7405
7532
  const disclosedTools = [];
7406
7533
  const nativeSpecs = [];
7407
7534
  const mcpSpecs = [];
7535
+ const mcpServerByIndex = [];
7408
7536
  for (const t of Object.values(baseTools)) {
7537
+ const canonical = t.spec.name;
7409
7538
  const spec = {
7410
- name: t.spec.name,
7539
+ name: wireNameFor(canonical),
7411
7540
  description: t.spec.description || "",
7412
7541
  inputSchema: t.spec.inputSchema
7413
7542
  };
7414
- if (mcpNames.has(t.spec.name)) mcpSpecs.push(spec);
7415
- else nativeSpecs.push(spec);
7543
+ if (mcpNames.has(canonical)) {
7544
+ mcpSpecs.push(spec);
7545
+ mcpServerByIndex.push(resolveMcpToolParts(canonical, mcpServers)?.server ?? "mcp");
7546
+ } else nativeSpecs.push(spec);
7416
7547
  }
7417
7548
  for (const spec of nativeSpecs) disclosedTools.push({
7418
7549
  name: spec.name,
7419
7550
  description: spec.description || "",
7420
7551
  inputSchema: spec.inputSchema
7421
7552
  });
7422
- for (const spec of mcpSpecs) disclosedTools.push({
7423
- name: spec.name,
7424
- description: spec.description || "",
7425
- inputSchema: spec.inputSchema,
7426
- mcpServer: resolveMcpToolParts(spec.name, mcpServers)?.server ?? "mcp"
7427
- });
7553
+ for (let i = 0; i < mcpSpecs.length; i++) {
7554
+ const spec = mcpSpecs[i];
7555
+ disclosedTools.push({
7556
+ name: spec.name,
7557
+ description: spec.description || "",
7558
+ inputSchema: spec.inputSchema,
7559
+ mcpServer: mcpServerByIndex[i]
7560
+ });
7561
+ }
7428
7562
  const wireTools = nativeSpecs.length + mcpSpecs.length > 0 ? provider.formatTools([...nativeSpecs, ...mcpSpecs]) : [];
7429
7563
  const mcpInstructionsText = mcpConnection?.instructions && mcpConnection.instructions.size > 0 ? renderMcpInstructionsSection(mcpConnection.instructions) : void 0;
7430
7564
  if (mcpInstructionsText) system = appendStaticSection(system, mcpInstructionsText);
@@ -9141,4 +9275,4 @@ const writeFile$1 = {
9141
9275
  //#endregion
9142
9276
  export { restoreModelOptions as $, PERSISTENCE_PREVIEW_BYTES as A, cerebrasDescriptor as B, stableStringify as C, TOOL_USE_SKIPPED_MESSAGE as D, TOOL_USE_CANCELLED_MESSAGE as E, resolvePersistDir as F, getModelInfo as G, effectiveContextWindow as H, resolveTasksDir as I, modelSupportsReasoning as J, localDescriptor as K, BUILTIN_PROVIDERS as L, cleanupPersistedSession as M, maybePersistToolResult as N, validateToolArgs as O, resolveMcpWarningsDir as P, piIdOf as Q, OUTPUT_RESERVE_TOKENS as R, normalizeShellCommand as S, SHELL_CASCADE_CANCEL_MESSAGE as T, enabledModelOptions as U, credKeyOf as V, getContextWindow as W, openaiDescriptor as X, modelsForDescriptor as Y, openrouterDescriptor as Z, createSkillsReadTool as _, multiEdit as a, defaultRepeatGuardNormalize as b, grep as c, createAgent as d, WAIT_TASK_TIMED_OUT_PREFIX as f, createSkillsRunScriptTool as g, createSkillsUseTool as h, readFile$1 as i, buildPersistedStub as j, PERSISTED_STUB_PREFIX as k, glob$1 as l, createToolSearchTool as m, createSpawnTool as n, listFiles as o, waitTask as p, modelOptionsFor as q, shellKill as r, createInteractionTool as s, writeFile$1 as t, edit as u, createShellTool as v, INTERRUPT_MESSAGE_FOR_TOOL_USE as w, defaultRepeatGuardTracked as x, shell as y, anthropicDescriptor as z };
9143
9277
 
9144
- //# sourceMappingURL=tools-BlMV33N1.js.map
9278
+ //# sourceMappingURL=tools-CbuxYK28.js.map