zidane 6.5.0 → 6.5.1

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 (75) hide show
  1. package/dist/acp-cli.js +6 -6
  2. package/dist/{acp-B-AOovHz.js → acp-o-LQAjFw.js} +4 -5
  3. package/dist/{acp-B-AOovHz.js.map → acp-o-LQAjFw.js.map} +1 -1
  4. package/dist/acp.js +1 -1
  5. package/dist/{agent-SQ6rxfpT.js → agent-BVNkC1h4.js} +658 -10
  6. package/dist/agent-BVNkC1h4.js.map +1 -0
  7. package/dist/agent.js +1 -2
  8. package/dist/{anthropic-D3lkw5mv.js → anthropic-Dov2mC5e.js} +3 -3
  9. package/dist/{anthropic-D3lkw5mv.js.map → anthropic-Dov2mC5e.js.map} +1 -1
  10. package/dist/{auth-BzYbbdN_.js → auth-B8ZuBcKC.js} +5 -5
  11. package/dist/{auth-BzYbbdN_.js.map → auth-B8ZuBcKC.js.map} +1 -1
  12. package/dist/chat/pure.js +2 -2
  13. package/dist/chat.js +5 -5
  14. package/dist/{edit-utils-EGosADZq.js → context-breakdown-BLF10tOO.js} +154 -2
  15. package/dist/context-breakdown-BLF10tOO.js.map +1 -0
  16. package/dist/{context-transport-CDBatvQc.js → context-transport-D-daWOmp.js} +3 -3
  17. package/dist/{context-transport-CDBatvQc.js.map → context-transport-D-daWOmp.js.map} +1 -1
  18. package/dist/eval.js +1 -1
  19. package/dist/extensions.js +1 -1
  20. package/dist/headless.js +3 -3
  21. package/dist/index-CWBSrqI6.d.ts.map +1 -1
  22. package/dist/index.js +9 -10
  23. package/dist/index.js.map +1 -1
  24. package/dist/{login-XZDS4K2o.js → login-CR3fDHXh.js} +2 -2
  25. package/dist/{login-XZDS4K2o.js.map → login-CR3fDHXh.js.map} +1 -1
  26. package/dist/{mcp-D27rP47I.js → mcp-C6IkXNOS.js} +3 -3
  27. package/dist/{mcp-D27rP47I.js.map → mcp-C6IkXNOS.js.map} +1 -1
  28. package/dist/mcp.js +1 -1
  29. package/dist/{messages-C01kKGj0.js → messages-C_H9soi5.js} +2 -3
  30. package/dist/{messages-C01kKGj0.js.map → messages-C_H9soi5.js.map} +1 -1
  31. package/dist/{openai-compat-B3c_hzwf.js → openai-compat-CnHeo4Lz.js} +216 -3
  32. package/dist/openai-compat-CnHeo4Lz.js.map +1 -0
  33. package/dist/presets.js +1 -1
  34. package/dist/providers/anthropic.js +1 -1
  35. package/dist/providers/arcee.js +1 -1
  36. package/dist/providers/baseten.js +1 -1
  37. package/dist/providers/cerebras.js +1 -1
  38. package/dist/providers/local.js +1 -1
  39. package/dist/providers/openai-compat.js +1 -1
  40. package/dist/providers/openai.js +2 -2
  41. package/dist/providers/openrouter.js +1 -1
  42. package/dist/providers/xai.js +1 -1
  43. package/dist/{providers-z1vU0b2Q.js → providers-B6mFe7OD.js} +3 -3
  44. package/dist/{providers-z1vU0b2Q.js.map → providers-B6mFe7OD.js.map} +1 -1
  45. package/dist/providers.js +4 -4
  46. package/dist/restate.d.ts +178 -2
  47. package/dist/restate.d.ts.map +1 -1
  48. package/dist/restate.js +458 -4
  49. package/dist/restate.js.map +1 -1
  50. package/dist/{session-cr9VdoEO.js → session-VpLrNaFQ.js} +2 -2
  51. package/dist/{session-cr9VdoEO.js.map → session-VpLrNaFQ.js.map} +1 -1
  52. package/dist/session.js +2 -2
  53. package/dist/{stdio-O-m9WVkE.js → stdio-DzUUkkhS.js} +2 -2
  54. package/dist/{stdio-O-m9WVkE.js.map → stdio-DzUUkkhS.js.map} +1 -1
  55. package/dist/{stdio-loader-BSGQmG4L.js → stdio-loader-BILyUGmi.js} +2 -2
  56. package/dist/{stdio-loader-BSGQmG4L.js.map → stdio-loader-BILyUGmi.js.map} +1 -1
  57. package/dist/tools.js +1 -2
  58. package/dist/{transcript-anchors-D4IxJifV.js → transcript-anchors-DEIr0tJC.js} +5 -5
  59. package/dist/{transcript-anchors-D4IxJifV.js.map → transcript-anchors-DEIr0tJC.js.map} +1 -1
  60. package/dist/tui.js +8 -8
  61. package/dist/{turn-operations-CAvi8NYt.js → turn-operations-C3IijXMW.js} +2 -2
  62. package/dist/{turn-operations-CAvi8NYt.js.map → turn-operations-C3IijXMW.js.map} +1 -1
  63. package/dist/{xai-BPwMQSuF.js → xai-Du6Wfnlb.js} +2 -2
  64. package/dist/{xai-BPwMQSuF.js.map → xai-Du6Wfnlb.js.map} +1 -1
  65. package/docs/RESTATE.md +102 -3
  66. package/package.json +1 -1
  67. package/dist/agent-SQ6rxfpT.js.map +0 -1
  68. package/dist/aliasing-lVFbm81n.js +0 -217
  69. package/dist/aliasing-lVFbm81n.js.map +0 -1
  70. package/dist/context-breakdown-Dzo25N45.js +0 -155
  71. package/dist/context-breakdown-Dzo25N45.js.map +0 -1
  72. package/dist/edit-utils-EGosADZq.js.map +0 -1
  73. package/dist/openai-compat-B3c_hzwf.js.map +0 -1
  74. package/dist/tool-state-DTs-3ZHH.js +0 -653
  75. package/dist/tool-state-DTs-3ZHH.js.map +0 -1
@@ -1,10 +1,223 @@
1
- import { a as rewriteMessagesToWire, n as buildAliasMaps, o as toCanonicalName, r as buildSanitizedWireAliases, s as toWireName } from "./aliasing-lVFbm81n.js";
2
1
  import { i as documentBlockMarker, n as assertResolvedMediaBlock } from "./types-BIarq1qE.js";
3
2
  import { n as estimateTokens } from "./utils-ngQzYzZD.js";
4
3
  import { f as isRetryableHttpStatus, l as classifyErrorPrelude, m as matchesToolPairingError, p as matchesContextExceeded } from "./errors-BwBxu3zD.js";
5
4
  import { t as audioFormatFromMediaType } from "./media-sniff-UKijEaiQ.js";
6
5
  import { renderSystemForWire, splitSystemPrompt } from "./prompt.js";
7
6
  import { createHash } from "node:crypto";
7
+ //#region src/hash.ts
8
+ /**
9
+ * FNV-1a (32-bit) rendered in base36 — a tiny, dependency-free, deterministic
10
+ * hash.
11
+ *
12
+ * Used to disambiguate sanitized identifiers: distinct inputs that would
13
+ * otherwise collapse to the same sanitized string (e.g. `a.b` and `a/b` both
14
+ * → `a_b`, or two over-long names truncated to the same prefix) keep a stable,
15
+ * unique suffix. Determinism matters because the suffix must be identical
16
+ * across runs and across a `tool_use` / `tool_result` pair derived from the
17
+ * same original value.
18
+ */
19
+ function fnv1aBase36(value) {
20
+ let hash = 2166136261;
21
+ for (let i = 0; i < value.length; i++) {
22
+ hash ^= value.charCodeAt(i);
23
+ hash = Math.imul(hash, 16777619);
24
+ }
25
+ return (hash >>> 0).toString(36);
26
+ }
27
+ //#endregion
28
+ //#region src/aliasing.ts
29
+ /**
30
+ * Build alias lookup maps from a `toolAliases` record.
31
+ *
32
+ * Validates:
33
+ * - No two canonical names map to the same alias (collision).
34
+ * - No alias collides with another canonical tool name (would shadow).
35
+ *
36
+ * Silently ignores alias entries whose canonical name isn't in `canonicalNames` —
37
+ * preset/agent authors can declare aliases for tools that may be added later via MCP.
38
+ *
39
+ * @param aliases - The `toolAliases` map from the agent options.
40
+ * @param canonicalNames - All tool canonical names currently in scope (agent + MCP).
41
+ */
42
+ function buildAliasMaps(aliases, canonicalNames) {
43
+ const aliasByCanonical = /* @__PURE__ */ new Map();
44
+ const canonicalByAlias = /* @__PURE__ */ new Map();
45
+ if (!aliases) return {
46
+ aliasByCanonical,
47
+ canonicalByAlias
48
+ };
49
+ const canonicalSet = new Set(canonicalNames);
50
+ function isRemappedAway(canonical) {
51
+ const mapped = aliases[canonical];
52
+ return typeof mapped === "string" && mapped.length > 0 && mapped !== canonical;
53
+ }
54
+ for (const [canonical, alias] of Object.entries(aliases)) {
55
+ if (typeof alias !== "string" || alias.length === 0) throw new Error(`Tool alias for "${canonical}" must be a non-empty string`);
56
+ if (alias === canonical) continue;
57
+ if (!canonicalSet.has(canonical)) continue;
58
+ if (canonicalSet.has(alias) && !isRemappedAway(alias)) throw new Error(`Tool alias "${canonical}" -> "${alias}" collides with an existing canonical tool name`);
59
+ const existingCanonical = canonicalByAlias.get(alias);
60
+ if (existingCanonical && existingCanonical !== canonical) throw new Error(`Tool alias collision: both "${existingCanonical}" and "${canonical}" map to alias "${alias}"`);
61
+ aliasByCanonical.set(canonical, alias);
62
+ canonicalByAlias.set(alias, canonical);
63
+ }
64
+ return {
65
+ aliasByCanonical,
66
+ canonicalByAlias
67
+ };
68
+ }
69
+ /** Return the alias for a canonical name, falling back to the canonical name itself. */
70
+ function toWireName(canonical, maps) {
71
+ return maps.aliasByCanonical.get(canonical) ?? canonical;
72
+ }
73
+ /** Return the canonical name for a wire name, falling back to the wire name itself. */
74
+ function toCanonicalName(wire, maps) {
75
+ return maps.canonicalByAlias.get(wire) ?? wire;
76
+ }
77
+ /**
78
+ * Tool names must match `^[a-zA-Z0-9_-]{1,N}$`. The charset is universal; the
79
+ * length cap is taken as the STRICTEST across providers (OpenAI/-compat: 64;
80
+ * Anthropic allows 128) so a sanitized name is valid on EVERY provider — and so
81
+ * a mid-session model switch can never make the provider-level drop guard
82
+ * (`sanitizeToolSpecs`) discard a tool we could have kept.
83
+ *
84
+ * MCP tool names are minted verbatim as `mcp_<server>_<tool>` (see
85
+ * `connectMcpServers`), so a server configured as `SSH Ipseity` yields
86
+ * `mcp_SSH Ipseity_exec` — the space (and `.`/`:`/`/`, unicode, or a >64-char
87
+ * join) 400s the request the instant that tool lands in the `tools` array:
88
+ * `tools.N.custom.name: String should match pattern ...`.
89
+ */
90
+ const WIRE_NAME_MAX = 64;
91
+ const WIRE_NAME_OK = /^[\w-]{1,64}$/;
92
+ const WIRE_NAME_BAD_CHAR = /[^\w-]/g;
93
+ /**
94
+ * Build OUTBOUND wire aliases that coerce any tool name violating the provider
95
+ * name constraint into a valid one. Only offenders get an entry; clean setups
96
+ * return `undefined` (no alias map churn, prompt cache untouched).
97
+ *
98
+ * Returned as a `Record` so it merges into `effectiveToolAliases` upstream of
99
+ * BOTH wire-name computations — the `tool_search` catalog and the `tools` array
100
+ * — keeping them in lockstep. Canonical names (dispatch, hooks, persisted
101
+ * turns) never change; only the bytes the model sees do.
102
+ *
103
+ * Scoped to MCP names (the only third-party-controlled, thus only realistically
104
+ * invalid, source). The hash suffix keeps distinct originals distinct even when
105
+ * they collapse to the same replacement; `taken` guards the residual collision.
106
+ */
107
+ function buildSanitizedWireAliases(names, existing) {
108
+ const wireOf = (name) => {
109
+ const alias = existing?.[name];
110
+ return typeof alias === "string" && alias.length > 0 ? alias : name;
111
+ };
112
+ const taken = /* @__PURE__ */ new Set();
113
+ const offenders = [];
114
+ for (const name of names) {
115
+ const wire = wireOf(name);
116
+ if (WIRE_NAME_OK.test(wire)) taken.add(wire);
117
+ else offenders.push(name);
118
+ }
119
+ if (offenders.length === 0) return void 0;
120
+ const out = {};
121
+ for (const name of offenders) {
122
+ const sanitized = sanitizeWireName(wireOf(name), taken);
123
+ out[name] = sanitized;
124
+ taken.add(sanitized);
125
+ }
126
+ return out;
127
+ }
128
+ function sanitizeWireName(name, taken) {
129
+ let base = name.replace(WIRE_NAME_BAD_CHAR, "_");
130
+ if (base.length === 0) base = "tool";
131
+ const hash = fnv1aBase36(name);
132
+ const withSuffix = (suffix) => `${base.slice(0, Math.max(1, WIRE_NAME_MAX - suffix.length))}${suffix}`;
133
+ let candidate = withSuffix(`_${hash}`);
134
+ for (let n = 1; taken.has(candidate); n++) candidate = withSuffix(`_${hash}_${n}`);
135
+ return candidate;
136
+ }
137
+ /**
138
+ * Augment {@link AliasMaps} with INBOUND-ONLY aliases for the Claude Code
139
+ * `mcp__server__tool` double-underscore naming convention. For every MCP
140
+ * tool registered with the canonical `mcp_<server>_<tool>` form, add a
141
+ * `canonicalByAlias` entry mapping the double-underscore variant to the
142
+ * same canonical name. Outbound (`aliasByCanonical`) is left untouched —
143
+ * the model still sees the single-underscore canonical on the wire, so
144
+ * the tools-array byte count (and the provider prompt cache) is
145
+ * unaffected.
146
+ *
147
+ * Why: SDK consumers and tool descriptions across the ecosystem
148
+ * inconsistently reference one form or the other (Anthropic's docs use
149
+ * double, zidane uses single). A Claude-Code-trained model emitting
150
+ * `mcp__acme__apply_migration` against a server zidane registered as
151
+ * `mcp_acme_apply_migration` would otherwise trip the `tool:unknown`
152
+ * path and waste a turn on the correction.
153
+ *
154
+ * Idempotent: a canonical that already has a double-underscore alias
155
+ * mapped (host's explicit `toolAliases` got there first) is left alone.
156
+ * Tools whose canonical name DOESN'T start with `mcp_` (or that contain
157
+ * no inner separator) are skipped — we don't want to invent aliases for
158
+ * non-MCP tools or malformed names.
159
+ *
160
+ * Mutates `maps.canonicalByAlias` in place and returns the same object
161
+ * for chaining.
162
+ */
163
+ function augmentMcpDoubleUnderscoreAliases(maps, canonicalNames) {
164
+ for (const canonical of canonicalNames) {
165
+ if (!canonical.startsWith("mcp_")) continue;
166
+ const tail = canonical.slice(4);
167
+ const sep = tail.indexOf("_");
168
+ if (sep <= 0 || sep >= tail.length - 1) continue;
169
+ const doubleForm = `mcp__${tail.slice(0, sep)}__${tail.slice(sep + 1)}`;
170
+ if (doubleForm === canonical) continue;
171
+ if (maps.canonicalByAlias.has(doubleForm)) continue;
172
+ maps.canonicalByAlias.set(doubleForm, canonical);
173
+ }
174
+ return maps;
175
+ }
176
+ /**
177
+ * Rewrite `tool_call` block names in a content array from canonical → wire for outbound
178
+ * messages sent to the provider. Mutation is non-destructive (returns a new array).
179
+ */
180
+ function rewriteContentToWire(content, maps) {
181
+ if (maps.aliasByCanonical.size === 0) return content;
182
+ return content.map((block) => {
183
+ if (block.type !== "tool_call") return block;
184
+ const wire = maps.aliasByCanonical.get(block.name);
185
+ if (!wire || wire === block.name) return block;
186
+ return {
187
+ ...block,
188
+ name: wire
189
+ };
190
+ });
191
+ }
192
+ /**
193
+ * Rewrite `tool_call` block names in a content array from wire → canonical for inbound
194
+ * messages received from the provider. Non-destructive.
195
+ */
196
+ function rewriteContentToCanonical(content, maps) {
197
+ if (maps.canonicalByAlias.size === 0) return content;
198
+ return content.map((block) => {
199
+ if (block.type !== "tool_call") return block;
200
+ const canonical = maps.canonicalByAlias.get(block.name);
201
+ if (!canonical || canonical === block.name) return block;
202
+ return {
203
+ ...block,
204
+ name: canonical
205
+ };
206
+ });
207
+ }
208
+ /**
209
+ * Rewrite every `SessionMessage.content` in an array from canonical → wire.
210
+ * Returns a new array of new message objects — input messages are not mutated.
211
+ * When the alias map is empty, returns the input by reference (no allocation).
212
+ */
213
+ function rewriteMessagesToWire(messages, maps) {
214
+ if (maps.aliasByCanonical.size === 0) return messages;
215
+ return messages.map((msg) => ({
216
+ ...msg,
217
+ content: rewriteContentToWire(msg.content, maps)
218
+ }));
219
+ }
220
+ //#endregion
8
221
  //#region src/prompt.ts
9
222
  /**
10
223
  * Coerce the run-level prompt into a `PromptPart[]`.
@@ -2067,6 +2280,6 @@ function openaiCompat(params) {
2067
2280
  };
2068
2281
  }
2069
2282
  //#endregion
2070
- export { mergeCatalogEntry as A, estimateRebilledCostUsd as C, listModelOverlay as D, getModelCatalog as E, unsupportedMediaError as F, buildPromptMessage as M, canonicalizePrompt as N, listModels as O, defaultPromptMessage as P, resolvePromptCacheKey as S, aliasCatalogProviders as T, userMessage as _, applyOAICacheBreakpoints as a, sanitizeToolSpecs as b, buildAssistantContent as c, formatTools as d, mapOAIFinishReason as f, toolResultsMessage as g, toOAIMessages as h, TOOL_RESULTS_TAG as i, setModelCatalog as j, lookupModel as k, classifyOpenAICompatError as l, openaiCompat as m, OpenAICompatHttpError as n, applyOAIToolCacheBreakpoint as o, openAICompatPromptMessage as p, OpenAICompatStreamError as r, assistantMessage as s, ASSISTANT_TOOL_CALLS_TAG as t, consumeSSE as u, createToolNameBoundary as v, fillEstimatedCost as w, derivePromptCacheKey as x, sanitizeToolSchema as y };
2283
+ export { mergeCatalogEntry as A, rewriteMessagesToWire as B, estimateRebilledCostUsd as C, listModelOverlay as D, getModelCatalog as E, unsupportedMediaError as F, toWireName as H, augmentMcpDoubleUnderscoreAliases as I, buildAliasMaps as L, buildPromptMessage as M, canonicalizePrompt as N, listModels as O, defaultPromptMessage as P, buildSanitizedWireAliases as R, resolvePromptCacheKey as S, aliasCatalogProviders as T, fnv1aBase36 as U, toCanonicalName as V, userMessage as _, applyOAICacheBreakpoints as a, sanitizeToolSpecs as b, buildAssistantContent as c, formatTools as d, mapOAIFinishReason as f, toolResultsMessage as g, toOAIMessages as h, TOOL_RESULTS_TAG as i, setModelCatalog as j, lookupModel as k, classifyOpenAICompatError as l, openaiCompat as m, OpenAICompatHttpError as n, applyOAIToolCacheBreakpoint as o, openAICompatPromptMessage as p, OpenAICompatStreamError as r, assistantMessage as s, ASSISTANT_TOOL_CALLS_TAG as t, consumeSSE as u, createToolNameBoundary as v, fillEstimatedCost as w, derivePromptCacheKey as x, sanitizeToolSchema as y, rewriteContentToCanonical as z };
2071
2284
 
2072
- //# sourceMappingURL=openai-compat-B3c_hzwf.js.map
2285
+ //# sourceMappingURL=openai-compat-CnHeo4Lz.js.map