zidane 6.4.1 → 6.4.2

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 (111) hide show
  1. package/README.md +1 -1
  2. package/dist/{acp-CH5tOdRb.js → acp-Ba4OzG71.js} +4 -4
  3. package/dist/{acp-CH5tOdRb.js.map → acp-Ba4OzG71.js.map} +1 -1
  4. package/dist/acp-cli.js +6 -6
  5. package/dist/acp.d.ts +1 -1
  6. package/dist/acp.js +1 -1
  7. package/dist/{agent-CjhcxKp7.js → agent-BMJKrD84.js} +10 -6
  8. package/dist/{agent-CjhcxKp7.js.map → agent-BMJKrD84.js.map} +1 -1
  9. package/dist/agent.d.ts +1 -1
  10. package/dist/agent.js +1 -1
  11. package/dist/{anthropic-BAuvWmqU.js → anthropic-BJhMEi7x.js} +13 -8
  12. package/dist/anthropic-BJhMEi7x.js.map +1 -0
  13. package/dist/{auth-C1N0jfb5.js → auth-C2Hmb0tt.js} +105 -12
  14. package/dist/auth-C2Hmb0tt.js.map +1 -0
  15. package/dist/chat/pure.d.ts +3 -3
  16. package/dist/chat.d.ts +16 -7
  17. package/dist/chat.d.ts.map +1 -1
  18. package/dist/chat.js +4 -4
  19. package/dist/{context-transport-C5Qq5MXb.js → context-transport-CwJZxs56.js} +3 -3
  20. package/dist/{context-transport-C5Qq5MXb.js.map → context-transport-CwJZxs56.js.map} +1 -1
  21. package/dist/contexts/daytona.d.ts +1 -1
  22. package/dist/contexts/e2b.d.ts +1 -1
  23. package/dist/eval.d.ts +1 -1
  24. package/dist/eval.js +1 -1
  25. package/dist/extensions.d.ts +1 -1
  26. package/dist/extensions.js +1 -1
  27. package/dist/headless.d.ts +1 -1
  28. package/dist/headless.js +3 -3
  29. package/dist/{index-LxAV7xSk.d.ts → index-Gy9wi80M.d.ts} +166 -7
  30. package/dist/index-Gy9wi80M.d.ts.map +1 -0
  31. package/dist/index.d.ts +2 -2
  32. package/dist/index.js +10 -10
  33. package/dist/{inline-autocomplete-DC2cxprN.js → inline-autocomplete-D0MPvBaS.js} +103 -17
  34. package/dist/inline-autocomplete-D0MPvBaS.js.map +1 -0
  35. package/dist/{login-cfxezMQT.js → login-llWTV13a.js} +2 -2
  36. package/dist/{login-cfxezMQT.js.map → login-llWTV13a.js.map} +1 -1
  37. package/dist/{mcp-BFlrDmGB.js → mcp-IaEpSauj.js} +3 -3
  38. package/dist/{mcp-BFlrDmGB.js.map → mcp-IaEpSauj.js.map} +1 -1
  39. package/dist/mcp.d.ts +1 -1
  40. package/dist/mcp.js +1 -1
  41. package/dist/{messages-XfLqem2d.js → messages-D1EryrDs.js} +2 -2
  42. package/dist/{messages-XfLqem2d.js.map → messages-D1EryrDs.js.map} +1 -1
  43. package/dist/{openai-compat-70-QNsmd.js → openai-compat-0MJq4-g9.js} +191 -18
  44. package/dist/openai-compat-0MJq4-g9.js.map +1 -0
  45. package/dist/output/stream-json.d.ts +1 -1
  46. package/dist/output/terminal.d.ts +1 -1
  47. package/dist/presets.d.ts +1 -1
  48. package/dist/presets.js +1 -1
  49. package/dist/providers/anthropic.d.ts +1 -1
  50. package/dist/providers/anthropic.js +1 -1
  51. package/dist/providers/arcee.d.ts +1 -1
  52. package/dist/providers/arcee.js +1 -1
  53. package/dist/providers/baseten.d.ts +1 -1
  54. package/dist/providers/baseten.js +1 -1
  55. package/dist/providers/cerebras.d.ts +1 -1
  56. package/dist/providers/cerebras.js +1 -1
  57. package/dist/providers/local.d.ts +1 -1
  58. package/dist/providers/local.js +1 -1
  59. package/dist/providers/openai-compat.d.ts +1 -1
  60. package/dist/providers/openai-compat.js +1 -1
  61. package/dist/providers/openai.d.ts +1 -1
  62. package/dist/providers/openai.js +13 -12
  63. package/dist/providers/openai.js.map +1 -1
  64. package/dist/providers/openrouter.d.ts +1 -1
  65. package/dist/providers/openrouter.js +1 -1
  66. package/dist/providers/xai.d.ts +1 -1
  67. package/dist/providers/xai.js +1 -1
  68. package/dist/{providers-DQFY2gl-.js → providers-BSrJx0Tn.js} +3 -3
  69. package/dist/{providers-DQFY2gl-.js.map → providers-BSrJx0Tn.js.map} +1 -1
  70. package/dist/providers.d.ts +2 -2
  71. package/dist/providers.js +5 -5
  72. package/dist/restate.d.ts +1 -1
  73. package/dist/session/sqlite.d.ts +1 -1
  74. package/dist/{session-SOpMv7kl.js → session-B40flcj7.js} +2 -2
  75. package/dist/{session-SOpMv7kl.js.map → session-B40flcj7.js.map} +1 -1
  76. package/dist/session.d.ts +1 -1
  77. package/dist/session.js +2 -2
  78. package/dist/skills.d.ts +1 -1
  79. package/dist/{stdio-CnDuGcCi.js → stdio-D-02FOVT.js} +2 -2
  80. package/dist/{stdio-CnDuGcCi.js.map → stdio-D-02FOVT.js.map} +1 -1
  81. package/dist/{stdio-loader-CknZi5f-.js → stdio-loader-Byqw5KjJ.js} +2 -2
  82. package/dist/{stdio-loader-CknZi5f-.js.map → stdio-loader-Byqw5KjJ.js.map} +1 -1
  83. package/dist/{tool-formatters-Bto7FF6V.d.ts → tool-formatters-CU0memLh.d.ts} +2 -2
  84. package/dist/{tool-formatters-Bto7FF6V.d.ts.map → tool-formatters-CU0memLh.d.ts.map} +1 -1
  85. package/dist/tools/fetch-url.d.ts +1 -1
  86. package/dist/tools/web-search.d.ts +1 -1
  87. package/dist/tools.d.ts +1 -1
  88. package/dist/tools.js +1 -1
  89. package/dist/{transcript-anchors-BTu5SjfP.d.ts → transcript-anchors-4IdT10xC.d.ts} +2 -2
  90. package/dist/{transcript-anchors-BTu5SjfP.d.ts.map → transcript-anchors-4IdT10xC.d.ts.map} +1 -1
  91. package/dist/{transcript-anchors-BtKt8Nwx.js → transcript-anchors-CJ4gJn1T.js} +4 -4
  92. package/dist/{transcript-anchors-BtKt8Nwx.js.map → transcript-anchors-CJ4gJn1T.js.map} +1 -1
  93. package/dist/tui.d.ts +24 -3
  94. package/dist/tui.d.ts.map +1 -1
  95. package/dist/tui.js +48 -15
  96. package/dist/tui.js.map +1 -1
  97. package/dist/{turn-operations-BYYMryiI.d.ts → turn-operations-B08dE8kH.d.ts} +3 -3
  98. package/dist/{turn-operations-BYYMryiI.d.ts.map → turn-operations-B08dE8kH.d.ts.map} +1 -1
  99. package/dist/types-BIarq1qE.js.map +1 -1
  100. package/dist/types.d.ts +1 -1
  101. package/dist/{xai-BapwnBgs.js → xai-CpPbCGWO.js} +2 -2
  102. package/dist/{xai-BapwnBgs.js.map → xai-CpPbCGWO.js.map} +1 -1
  103. package/docs/ARCHITECTURE.md +2 -0
  104. package/docs/CHAT.md +1 -1
  105. package/docs/TUI.md +1 -1
  106. package/package.json +8 -8
  107. package/dist/anthropic-BAuvWmqU.js.map +0 -1
  108. package/dist/auth-C1N0jfb5.js.map +0 -1
  109. package/dist/index-LxAV7xSk.d.ts.map +0 -1
  110. package/dist/inline-autocomplete-DC2cxprN.js.map +0 -1
  111. package/dist/openai-compat-70-QNsmd.js.map +0 -1
@@ -124,6 +124,154 @@ function buildPromptMessage(provider, parts) {
124
124
  return defaultPromptMessage(parts);
125
125
  }
126
126
  //#endregion
127
+ //#region src/providers/model-catalog.ts
128
+ const holder = { current: void 0 };
129
+ /**
130
+ * Normalization cache. Per-call catalogs arrive on every turn; without this a
131
+ * table form would allocate a fresh closure per lookup. Weak so a discarded
132
+ * catalog doesn't pin memory.
133
+ */
134
+ const normalized = /* @__PURE__ */ new WeakMap();
135
+ /**
136
+ * Install (or clear, with `null`) the process-wide catalog. Latest call wins.
137
+ *
138
+ * Prefer `behavior.modelCatalog` when you can: it needs no global state and
139
+ * scopes to one agent or one run. Use this for a deployment-wide correction,
140
+ * or when the host's model picker must see the override too.
141
+ */
142
+ function setModelCatalog(catalog) {
143
+ holder.current = catalog ? normalize(catalog) : void 0;
144
+ }
145
+ /** The process-wide catalog, normalized to source form. */
146
+ function getModelCatalog() {
147
+ return holder.current;
148
+ }
149
+ function normalize(catalog) {
150
+ const cached = normalized.get(catalog);
151
+ if (cached) return cached;
152
+ const source = isSource(catalog) ? catalog : (() => {
153
+ const table = catalog;
154
+ return {
155
+ table,
156
+ get: (provider, modelId) => table[`${provider}:${modelId}`]
157
+ };
158
+ })();
159
+ normalized.set(catalog, source);
160
+ return source;
161
+ }
162
+ /** A `ModelCatalog` is a source when it declares either accessor. */
163
+ function isSource(catalog) {
164
+ const candidate = catalog;
165
+ return typeof candidate.get === "function" || typeof candidate.list === "function";
166
+ }
167
+ /**
168
+ * Resolve one model through the catalog chain, WITHOUT consulting the bundled
169
+ * registry — callers own that fallback because each reader has a different
170
+ * bundled shape (pi-ai `Model`, `CodexModel`, `ModelInfo`).
171
+ *
172
+ * `perCall` (an agent's / run's `behavior.modelCatalog`) shadows the global.
173
+ */
174
+ function lookupModel(provider, modelId, perCall) {
175
+ for (const source of sourcesFor(perCall)) {
176
+ const entry = source.get?.(provider, modelId);
177
+ if (entry) return entry;
178
+ }
179
+ }
180
+ /**
181
+ * Authoritative model list for a provider, or `undefined` when no catalog
182
+ * claims ownership (the caller then uses the bundled list).
183
+ *
184
+ * Only the function form can claim ownership; table entries are overlaid via
185
+ * {@link listModelOverlay} instead.
186
+ */
187
+ function listModels(provider, perCall) {
188
+ for (const source of sourcesFor(perCall)) {
189
+ const list = source.list?.(provider);
190
+ if (list) return list;
191
+ }
192
+ }
193
+ /**
194
+ * Table-form entries for one provider, to merge on top of a bundled list
195
+ * (these win on id collision). Empty when no table-form catalog is active.
196
+ */
197
+ function listModelOverlay(provider, perCall) {
198
+ const prefix = `${provider}:`;
199
+ const out = [];
200
+ const seen = /* @__PURE__ */ new Set();
201
+ for (const source of sourcesFor(perCall)) {
202
+ if (!source.table) continue;
203
+ for (const [key, entry] of Object.entries(source.table)) {
204
+ if (!key.startsWith(prefix)) continue;
205
+ const id = entry.id ?? key.slice(prefix.length);
206
+ if (seen.has(id)) continue;
207
+ seen.add(id);
208
+ out.push(entry.id ? entry : {
209
+ ...entry,
210
+ id
211
+ });
212
+ }
213
+ }
214
+ return out;
215
+ }
216
+ /**
217
+ * View of `catalog` that resolves a model under several provider ids, in
218
+ * order — for providers whose metadata and pricing live under DIFFERENT
219
+ * registry keys.
220
+ *
221
+ * The Codex provider is the case: model records come from `openai-codex`
222
+ * while cost estimation runs under `openai`. Without this, one catalog entry
223
+ * fixes the ceiling or the price but not both, depending on which key the
224
+ * consumer guessed — and neither key is guessable.
225
+ *
226
+ * Returns `undefined` for an absent catalog so callers can pass it straight
227
+ * through.
228
+ */
229
+ function aliasCatalogProviders(catalog, providers) {
230
+ if (!catalog) return void 0;
231
+ return { get: (_provider, modelId) => {
232
+ for (const id of providers) {
233
+ const entry = lookupModel(id, modelId, catalog);
234
+ if (entry) return entry;
235
+ }
236
+ } };
237
+ }
238
+ /**
239
+ * Overlay a catalog entry onto a bundled model record (pi-ai `Model`, the
240
+ * chat layer's `ModelInfo`, …). Only fields the entry actually defines are
241
+ * replaced, so a one-field override corrects that field and inherits the rest.
242
+ *
243
+ * `cost` merges per-rate rather than wholesale, so `{ cost: { output: 30 } }`
244
+ * keeps the bundled input/cache rates instead of zeroing them.
245
+ *
246
+ * Kept here rather than at each reader so the merge semantics can't drift
247
+ * between the wire path and the host layer.
248
+ */
249
+ function mergeCatalogEntry(base, entry) {
250
+ if (!entry) return base;
251
+ const patch = {};
252
+ if (entry.id !== void 0) patch.id = entry.id;
253
+ if (entry.name !== void 0) patch.name = entry.name;
254
+ if (entry.maxTokens !== void 0) patch.maxTokens = entry.maxTokens;
255
+ if (entry.contextWindow !== void 0) patch.contextWindow = entry.contextWindow;
256
+ if (entry.reasoning !== void 0) patch.reasoning = entry.reasoning;
257
+ if (entry.input !== void 0) patch.input = entry.input;
258
+ if (entry.cost !== void 0) patch.cost = {
259
+ ...base.cost,
260
+ ...entry.cost
261
+ };
262
+ return {
263
+ ...base,
264
+ ...patch
265
+ };
266
+ }
267
+ /** Per-call source first (it shadows), then the process-wide one. */
268
+ function sourcesFor(perCall) {
269
+ const out = [];
270
+ if (perCall) out.push(normalize(perCall));
271
+ if (holder.current) out.push(holder.current);
272
+ return out;
273
+ }
274
+ //#endregion
127
275
  //#region src/providers/cost.ts
128
276
  let getModelPromise;
129
277
  function loadGetModel() {
@@ -134,6 +282,11 @@ function loadGetModel() {
134
282
  * Per-MTok rates for models not yet in pi-ai's bundled registry. Keyed by
135
283
  * `provider:modelId`. Consulted only when pi-ai's `getModel` misses, so a
136
284
  * later dep bump that bundles the model transparently takes over.
285
+ *
286
+ * MAINTAINER-side stopgap only. Consumers with custom / gateway / private
287
+ * models should install a catalog instead of sending PRs against this table:
288
+ * `behavior.modelCatalog` per agent, or `setModelCatalog()` process-wide
289
+ * (see `./model-catalog`) — both outrank the registry AND this table.
137
290
  */
138
291
  const EXTRA_COST_RATES = {
139
292
  "anthropic:claude-opus-5": {
@@ -238,33 +391,53 @@ const EXTRA_COST_RATES = {
238
391
  * rate miss (unknown provider/model, or no published cache-write rate) —
239
392
  * better than fabricating a $0. An optional `multiplier` scales the base
240
393
  * rates for premium modes (e.g. Anthropic fast mode, 1h-TTL writes at 2x).
394
+ *
395
+ * `catalog` is caller-supplied because this helper has no run context to read
396
+ * `behavior.modelCatalog` from: cache-break telemetry is computed by the host
397
+ * that owns the `cache:break` hook, not by the loop. A host using a model
398
+ * catalog must pass the same one here, or a re-bill estimate for an
399
+ * override-only model comes back `undefined` while the per-turn cost is
400
+ * priced correctly.
241
401
  */
242
- async function estimateRebilledCostUsd(provider, modelId, rebilledTokens, multiplier) {
243
- if (!modelId || rebilledTokens <= 0) return void 0;
402
+ /**
403
+ * Rates for one model: catalog over pi-ai registry over local table.
404
+ *
405
+ * A catalog entry wins because it's an explicit claim about a model we may not
406
+ * know (gateway alias, private deployment, post-pin release) — but it merges
407
+ * PER-RATE over whatever the registry knows, matching `mergeCatalogEntry` and
408
+ * the documented contract. Replacing the whole rate object would zero the rates
409
+ * a partial entry doesn't mention, so `{ cost: { output: 30 } }` would bill
410
+ * input and cache traffic at $0 — and the picker (which merges per-rate) would
411
+ * disagree with the invoice.
412
+ */
413
+ async function resolveRates(provider, modelId, catalog) {
414
+ const override = lookupModel(provider, modelId, catalog)?.cost;
244
415
  const getModel = await loadGetModel();
245
- let model;
416
+ let base;
246
417
  if (getModel) try {
247
- model = getModel(provider, modelId);
418
+ base = getModel(provider, modelId)?.cost;
248
419
  } catch {
249
- model = void 0;
420
+ base = void 0;
250
421
  }
251
- const rates = model?.cost ?? EXTRA_COST_RATES[`${provider}:${modelId}`];
422
+ base ??= EXTRA_COST_RATES[`${provider}:${modelId}`];
423
+ if (!override) return base;
424
+ return base ? {
425
+ ...base,
426
+ ...override
427
+ } : override;
428
+ }
429
+ async function estimateRebilledCostUsd(provider, modelId, rebilledTokens, multiplier, catalog) {
430
+ if (!modelId || rebilledTokens <= 0) return void 0;
431
+ const rates = await resolveRates(provider, modelId, catalog);
252
432
  if (!rates || rates.cacheWrite === void 0) return void 0;
253
433
  const write = rates.cacheWrite * (multiplier?.cacheWrite ?? 1);
254
434
  const read = (rates.cacheRead ?? 0) * (multiplier?.cacheRead ?? 1);
255
435
  return Math.max(0, (write - read) * rebilledTokens / 1e6);
256
436
  }
257
- async function fillEstimatedCost(usage, provider, multiplier) {
437
+ async function fillEstimatedCost(usage, provider, multiplier, catalog) {
258
438
  if (usage.cost !== void 0) return usage;
259
439
  if (!usage.modelId) return usage;
260
- const getModel = await loadGetModel();
261
- let model;
262
- if (getModel) try {
263
- model = getModel(provider, usage.modelId);
264
- } catch {
265
- model = void 0;
266
- }
267
- const rates = model?.cost ?? EXTRA_COST_RATES[`${provider}:${usage.modelId}`];
440
+ const rates = await resolveRates(provider, usage.modelId, catalog);
268
441
  if (!rates) return usage;
269
442
  const mul = multiplier ?? {};
270
443
  const total = ((rates.input ?? 0) * (mul.input ?? 1) * (usage.input ?? 0) + (rates.output ?? 0) * (mul.output ?? 1) * (usage.output ?? 0) + (rates.cacheRead ?? 0) * (mul.cacheRead ?? 1) * (usage.cacheRead ?? 0) + (rates.cacheWrite ?? 0) * (mul.cacheWrite ?? 1) * (usage.cacheCreation ?? 0)) / 1e6;
@@ -1838,7 +2011,7 @@ function openaiCompat(params) {
1838
2011
  ...usage.cost !== void 0 ? { cost: usage.cost } : {},
1839
2012
  ...finishReason ? { finishReason } : {},
1840
2013
  modelId
1841
- }, name);
2014
+ }, name, void 0, options.modelCatalog);
1842
2015
  const toolCalls = result.toolCalls.map((call) => ({
1843
2016
  ...call,
1844
2017
  name: nameBoundary.fromWire(call.name)
@@ -1854,6 +2027,6 @@ function openaiCompat(params) {
1854
2027
  };
1855
2028
  }
1856
2029
  //#endregion
1857
- export { estimateRebilledCostUsd as C, defaultPromptMessage as D, canonicalizePrompt as E, unsupportedMediaError as O, resolvePromptCacheKey as S, buildPromptMessage 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, 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 };
2030
+ 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 };
1858
2031
 
1859
- //# sourceMappingURL=openai-compat-70-QNsmd.js.map
2032
+ //# sourceMappingURL=openai-compat-0MJq4-g9.js.map