zidane 5.2.1 → 5.3.0

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 (44) hide show
  1. package/README.md +7 -5
  2. package/dist/{agent-CGQajqtC.d.ts → agent-CYpPKn5Z.d.ts} +2 -2
  3. package/dist/{agent-CGQajqtC.d.ts.map → agent-CYpPKn5Z.d.ts.map} +1 -1
  4. package/dist/chat.d.ts +5 -155
  5. package/dist/chat.d.ts.map +1 -1
  6. package/dist/chat.js +2 -2
  7. package/dist/{index-BDP6mA3Y.d.ts → index-Cc-q1hLT.d.ts} +2 -2
  8. package/dist/{index-BDP6mA3Y.d.ts.map → index-Cc-q1hLT.d.ts.map} +1 -1
  9. package/dist/{index-DwbcFBr_.d.ts → index-D-cTScN3.d.ts} +9 -30
  10. package/dist/{index-DwbcFBr_.d.ts.map → index-D-cTScN3.d.ts.map} +1 -1
  11. package/dist/index.d.ts +3 -3
  12. package/dist/index.js +3 -3
  13. package/dist/{login-D7Tp-K5f.js → login-BXVt5wuA.js} +2 -2
  14. package/dist/{login-D7Tp-K5f.js.map → login-BXVt5wuA.js.map} +1 -1
  15. package/dist/mcp.d.ts +1 -1
  16. package/dist/{presets-AgF0RFx1.js → presets-tvD28pCu.js} +10 -29
  17. package/dist/presets-tvD28pCu.js.map +1 -0
  18. package/dist/presets.d.ts +2 -2
  19. package/dist/presets.js +1 -1
  20. package/dist/providers.d.ts +1 -1
  21. package/dist/session/sqlite.d.ts +1 -1
  22. package/dist/session.d.ts +1 -1
  23. package/dist/skills.d.ts +2 -2
  24. package/dist/{tools-BRbbfdJh.js → tools-CMVruxF0.js} +2 -130
  25. package/dist/tools-CMVruxF0.js.map +1 -0
  26. package/dist/tools.d.ts +2 -2
  27. package/dist/tools.js +1 -1
  28. package/dist/{transcript-anchors-BBuIoU0x.d.ts → transcript-anchors-eyhlGeBI.d.ts} +3 -3
  29. package/dist/transcript-anchors-eyhlGeBI.d.ts.map +1 -0
  30. package/dist/tui.d.ts +2 -2
  31. package/dist/tui.js +55 -5
  32. package/dist/tui.js.map +1 -1
  33. package/dist/{turn-operations-gJ0qtLPv.js → turn-operations-Y7e15gJf.js} +7 -345
  34. package/dist/turn-operations-Y7e15gJf.js.map +1 -0
  35. package/dist/types-IcokUOyC.js.map +1 -1
  36. package/dist/types.d.ts +2 -2
  37. package/docs/ARCHITECTURE.md +3 -2
  38. package/docs/CHAT.md +55 -16
  39. package/docs/TUI.md +22 -2
  40. package/package.json +1 -1
  41. package/dist/presets-AgF0RFx1.js.map +0 -1
  42. package/dist/tools-BRbbfdJh.js.map +0 -1
  43. package/dist/transcript-anchors-BBuIoU0x.d.ts.map +0 -1
  44. package/dist/turn-operations-gJ0qtLPv.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { a as multiEdit, i as readFile, n as createSpawnTool, o as listFiles, r as shell, t as writeFile, u as edit } from "./tools-BRbbfdJh.js";
1
+ import { a as multiEdit, i as readFile, n as createSpawnTool, o as listFiles, r as shell, t as writeFile, u as edit } from "./tools-CMVruxF0.js";
2
2
  //#region src/presets/basic.ts
3
3
  /**
4
4
  * Core tools available in every basic preset (without spawn).
@@ -38,11 +38,10 @@ function definePreset(config) {
38
38
  * objects shallow-merge; arrays and hook handler lists concatenate. Designed so
39
39
  * stacking presets does the obvious thing without the spread-collision footgun:
40
40
  *
41
- * - `name`, `system`, `eager`, `skills` → last-defined wins
42
- * - `tools`, `toolAliases`, `behavior` → shallow-merge (later keys override)
43
- * - `behavior.dedupTools`, `behavior.toolBudgets` **deep-merge** (per-tool-name; later wins on collision)
44
- * - `mcpServers` → concat with last-wins on `name` collision
45
- * - `hooks` → per-event concat; every handler fires
41
+ * - `name`, `system`, `eager`, `skills` → last-defined wins
42
+ * - `tools`, `toolAliases`, `behavior` → shallow-merge (later keys override)
43
+ * - `mcpServers` concat with last-wins on `name` collision
44
+ * - `hooks` per-event concat; every handler fires
46
45
  *
47
46
  * `hooks` always emerges as `event → handler[]` so downstream registration
48
47
  * (in `createAgent`) sees a uniform shape. Order of handlers within an event
@@ -51,13 +50,6 @@ function definePreset(config) {
51
50
  * `mcpServers` is deduped by `name` because shipping two servers with the same
52
51
  * name would trip the connector at runtime — a later preset overriding an
53
52
  * earlier preset's `github` server is the practical intent.
54
- *
55
- * `behavior.dedupTools` and `behavior.toolBudgets` get the same per-key deep-merge
56
- * because they are tool-name-keyed records — a preset that ships a dedup hasher
57
- * for one tool should not erase a hasher another preset ships for a different
58
- * tool. Last-wins still applies on a per-tool collision so a downstream preset
59
- * can override an upstream preset's policy for one specific tool. Other
60
- * `behavior` fields keep last-wins semantics.
61
53
  */
62
54
  function composePresets(...presets) {
63
55
  const out = {};
@@ -76,21 +68,10 @@ function composePresets(...presets) {
76
68
  ...out.toolAliases,
77
69
  ...p.toolAliases
78
70
  };
79
- if (p.behavior) {
80
- const merged = {
81
- ...out.behavior,
82
- ...p.behavior
83
- };
84
- if (out.behavior?.dedupTools || p.behavior.dedupTools) merged.dedupTools = {
85
- ...out.behavior?.dedupTools,
86
- ...p.behavior.dedupTools
87
- };
88
- if (out.behavior?.toolBudgets || p.behavior.toolBudgets) merged.toolBudgets = {
89
- ...out.behavior?.toolBudgets,
90
- ...p.behavior.toolBudgets
91
- };
92
- out.behavior = merged;
93
- }
71
+ if (p.behavior) out.behavior = {
72
+ ...out.behavior,
73
+ ...p.behavior
74
+ };
94
75
  if (p.mcpServers) for (const server of p.mcpServers) mcpByName.set(server.name, server);
95
76
  if (p.hooks) for (const [event, handler] of Object.entries(p.hooks)) {
96
77
  if (handler === void 0) continue;
@@ -106,4 +87,4 @@ function composePresets(...presets) {
106
87
  //#endregion
107
88
  export { basic_default as i, definePreset as n, basicTools as r, composePresets as t };
108
89
 
109
- //# sourceMappingURL=presets-AgF0RFx1.js.map
90
+ //# sourceMappingURL=presets-tvD28pCu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets-tvD28pCu.js","names":[],"sources":["../src/presets/basic.ts","../src/presets/index.ts"],"sourcesContent":["import { definePreset } from '.'\nimport { edit, listFiles, multiEdit, readFile, shell, writeFile } from '../tools'\nimport { createSpawnTool } from '../tools/spawn'\n\n/**\n * Core tools available in every basic preset (without spawn).\n *\n * `edit` and `multi_edit` ship in the basic set because surgical edits are the\n * default modality for production agents — `write_file` is for full overwrites.\n * `glob` and `grep` are exported but opt-in: not every agent needs codebase\n * search, and shipping them by default would force `tool:gate` work onto\n * consumers that prefer the model to use `shell` + classic Unix tools.\n */\nexport const basicTools = { shell, readFile, writeFile, listFiles, edit, multiEdit }\n\nexport default definePreset({\n name: 'basic',\n system: 'You are a helpful assistant with access to shell, file reading, file writing, surgical and multi-edit tools, directory listing, and sub-agent spawning. Prefer `edit` / `multi_edit` for in-place changes and `write_file` for full file overwrites. Use them to accomplish tasks in the project directory.',\n // `persist: true` shares the parent's session with every child agent — child\n // turns land in `session.turns` tagged with their own `runId`, and the run\n // itself is recorded in `session.runs` with `parentRunId` + `depth`. That's\n // what lets a reloaded TUI session reconstruct the full subagent tree (see\n // `eventsFromTurns` in `tui/store.ts`). Hosts that want children in-memory\n // only can construct their own preset with `createSpawnTool()`.\n tools: { ...basicTools, spawn: createSpawnTool({ persist: true }) },\n})\n","import type { AgentHooks, AgentOptions } from '../agent'\n\nexport type { AgentHookMap } from '../agent'\n\n/**\n * A preset is a reusable slice of `AgentOptions` — spread it into `createAgent()`\n * to configure tools, a default system prompt, aliases, behavior defaults, and\n * agent-lifetime hooks.\n *\n * `provider`, `execution`, `session`, and internal fields are excluded so presets\n * remain shareable and composable.\n *\n * ```ts\n * import { basic } from 'zidane/presets'\n * createAgent({ ...basic, provider })\n * ```\n *\n * ### Composing multiple presets\n *\n * Bare `...spread` is shallow — `{ ...a, ...b }` overwrites every key `b`\n * defines, including `hooks`. Use {@link composePresets} when you want\n * field-aware merging (per-event hook concat, tools shallow-merge, etc.):\n *\n * ```ts\n * createAgent({ ...composePresets(basic, telemetry, mine), provider })\n * ```\n */\nexport type Preset = Omit<Partial<AgentOptions>, 'provider' | 'execution' | 'session' | 'mcpConnector'>\n\n/**\n * Identity helper for type inference when defining a preset.\n */\nexport function definePreset(config: Preset): Preset {\n return config\n}\n\n/**\n * Field-aware composition of presets. Right-most preset wins for scalar fields;\n * objects shallow-merge; arrays and hook handler lists concatenate. Designed so\n * stacking presets does the obvious thing without the spread-collision footgun:\n *\n * - `name`, `system`, `eager`, `skills` → last-defined wins\n * - `tools`, `toolAliases`, `behavior` → shallow-merge (later keys override)\n * - `mcpServers` → concat with last-wins on `name` collision\n * - `hooks` → per-event concat; every handler fires\n *\n * `hooks` always emerges as `event → handler[]` so downstream registration\n * (in `createAgent`) sees a uniform shape. Order of handlers within an event\n * follows preset order: earlier presets register first.\n *\n * `mcpServers` is deduped by `name` because shipping two servers with the same\n * name would trip the connector at runtime — a later preset overriding an\n * earlier preset's `github` server is the practical intent.\n */\nexport function composePresets(...presets: Preset[]): Preset {\n const out: Preset = {}\n const hooksByEvent: { [K in keyof AgentHooks]?: AgentHooks[K][] } = {}\n // Keep mcpServers in source-order on first sight, but allow later\n // declarations to override earlier ones with the same `name`. A `Map`\n // keyed by name gives O(1) override + stable iteration.\n const mcpByName = new Map<string, NonNullable<Preset['mcpServers']>[number]>()\n\n for (const p of presets) {\n if (p.name !== undefined)\n out.name = p.name\n if (p.system !== undefined)\n out.system = p.system\n if (p.eager !== undefined)\n out.eager = p.eager\n if (p.skills !== undefined)\n out.skills = p.skills\n if (p.tools)\n out.tools = { ...out.tools, ...p.tools }\n if (p.toolAliases)\n out.toolAliases = { ...out.toolAliases, ...p.toolAliases }\n if (p.behavior)\n out.behavior = { ...out.behavior, ...p.behavior }\n if (p.mcpServers) {\n for (const server of p.mcpServers)\n mcpByName.set(server.name, server)\n }\n if (p.hooks) {\n for (const [event, handler] of Object.entries(p.hooks)) {\n if (handler === undefined)\n continue\n const list = Array.isArray(handler) ? handler : [handler]\n const key = event as keyof AgentHooks\n // Safe cast: we read the loose `AgentHookMap` shape (handler-or-array)\n // and re-emit only as arrays. Each `list` element matches the event's\n // handler signature by construction (the input was typed `AgentHookMap`).\n const bucket = (hooksByEvent[key] ??= []) as unknown[]\n bucket.push(...(list as unknown[]))\n }\n }\n }\n\n if (mcpByName.size > 0)\n out.mcpServers = [...mcpByName.values()]\n\n if (Object.keys(hooksByEvent).length > 0)\n out.hooks = hooksByEvent\n\n return out\n}\n\nexport { default as basic, basicTools } from './basic'\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,aAAa;CAAE;CAAO;CAAU;CAAW;CAAW;CAAM;CAAW;AAEpF,IAAA,gBAAe,aAAa;CAC1B,MAAM;CACN,QAAQ;CAOR,OAAO;EAAE,GAAG;EAAY,OAAO,gBAAgB,EAAE,SAAS,MAAM,CAAC;EAAE;CACpE,CAAC;;;;;;ACOF,SAAgB,aAAa,QAAwB;CACnD,OAAO;;;;;;;;;;;;;;;;;;;;AAqBT,SAAgB,eAAe,GAAG,SAA2B;CAC3D,MAAM,MAAc,EAAE;CACtB,MAAM,eAA8D,EAAE;CAItE,MAAM,4BAAY,IAAI,KAAwD;CAE9E,KAAK,MAAM,KAAK,SAAS;EACvB,IAAI,EAAE,SAAS,KAAA,GACb,IAAI,OAAO,EAAE;EACf,IAAI,EAAE,WAAW,KAAA,GACf,IAAI,SAAS,EAAE;EACjB,IAAI,EAAE,UAAU,KAAA,GACd,IAAI,QAAQ,EAAE;EAChB,IAAI,EAAE,WAAW,KAAA,GACf,IAAI,SAAS,EAAE;EACjB,IAAI,EAAE,OACJ,IAAI,QAAQ;GAAE,GAAG,IAAI;GAAO,GAAG,EAAE;GAAO;EAC1C,IAAI,EAAE,aACJ,IAAI,cAAc;GAAE,GAAG,IAAI;GAAa,GAAG,EAAE;GAAa;EAC5D,IAAI,EAAE,UACJ,IAAI,WAAW;GAAE,GAAG,IAAI;GAAU,GAAG,EAAE;GAAU;EACnD,IAAI,EAAE,YACJ,KAAK,MAAM,UAAU,EAAE,YACrB,UAAU,IAAI,OAAO,MAAM,OAAO;EAEtC,IAAI,EAAE,OACJ,KAAK,MAAM,CAAC,OAAO,YAAY,OAAO,QAAQ,EAAE,MAAM,EAAE;GACtD,IAAI,YAAY,KAAA,GACd;GACF,MAAM,OAAO,MAAM,QAAQ,QAAQ,GAAG,UAAU,CAAC,QAAQ;GACzD,MAAM,MAAM;GAKZ,CADgB,aAAa,SAAS,EAAE,EACjC,KAAK,GAAI,KAAmB;;;CAKzC,IAAI,UAAU,OAAO,GACnB,IAAI,aAAa,CAAC,GAAG,UAAU,QAAQ,CAAC;CAE1C,IAAI,OAAO,KAAK,aAAa,CAAC,SAAS,GACrC,IAAI,QAAQ;CAEd,OAAO"}
package/dist/presets.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { n as AgentHookMap } from "./agent-CGQajqtC.js";
2
- import { a as basicTools, i as _default, n as composePresets, r as definePreset, t as Preset } from "./index-DwbcFBr_.js";
1
+ import { n as AgentHookMap } from "./agent-CYpPKn5Z.js";
2
+ import { a as basicTools, i as _default, n as composePresets, r as definePreset, t as Preset } from "./index-D-cTScN3.js";
3
3
  export { AgentHookMap, Preset, _default as basic, basicTools, composePresets, definePreset };
package/dist/presets.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as basic_default, n as definePreset, r as basicTools, t as composePresets } from "./presets-AgF0RFx1.js";
1
+ import { i as basic_default, n as definePreset, r as basicTools, t as composePresets } from "./presets-tvD28pCu.js";
2
2
  export { basic_default as basic, basicTools, composePresets, definePreset };
@@ -1,2 +1,2 @@
1
- import { $ as openrouter, G as ProviderCapabilities, J as ToolCall, K as StreamCallbacks, Q as OpenRouterParams, W as Provider, X as ToolSpec, Y as ToolResult, Z as TurnResult, at as openaiCompat, ct as CerebrasParams, dt as anthropic, et as OpenAICompatAuthHeader, it as mapOAIFinishReason, lt as cerebras, nt as OpenAICompatParams, ot as OpenAIParams, q as StreamOptions, rt as classifyOpenAICompatError, st as openai, tt as OpenAICompatHttpError, ut as AnthropicParams } from "./agent-CGQajqtC.js";
1
+ import { $ as openrouter, G as ProviderCapabilities, J as ToolCall, K as StreamCallbacks, Q as OpenRouterParams, W as Provider, X as ToolSpec, Y as ToolResult, Z as TurnResult, at as openaiCompat, ct as CerebrasParams, dt as anthropic, et as OpenAICompatAuthHeader, it as mapOAIFinishReason, lt as cerebras, nt as OpenAICompatParams, ot as OpenAIParams, q as StreamOptions, rt as classifyOpenAICompatError, st as openai, tt as OpenAICompatHttpError, ut as AnthropicParams } from "./agent-CYpPKn5Z.js";
2
2
  export { AnthropicParams, CerebrasParams, OpenAICompatAuthHeader, OpenAICompatHttpError, OpenAICompatParams, OpenAIParams, OpenRouterParams, Provider, ProviderCapabilities, StreamCallbacks, StreamOptions, ToolCall, ToolResult, ToolSpec, TurnResult, anthropic, cerebras, classifyOpenAICompatError, mapOAIFinishReason, openai, openaiCompat, openrouter };
@@ -1,4 +1,4 @@
1
- import { A as SessionStore } from "../agent-CGQajqtC.js";
1
+ import { A as SessionStore } from "../agent-CYpPKn5Z.js";
2
2
 
3
3
  //#region src/session/sqlite.d.ts
4
4
  interface SqliteStoreOptions {
package/dist/session.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as SessionStore, B as createMemoryStore, D as Session, E as CreateSessionOptions, F as autoDetectAndConvert, H as FileMapStoreOptions, I as fromAnthropic, L as fromOpenAI, M as loadSession, N as RemoteStoreOptions, O as SessionData, Ot as SessionMessage, P as createRemoteStore, R as toAnthropic, Tt as SessionContentBlock, U as createFileMapStore, V as FileMapAdapter, j as createSession, k as SessionRun, kt as SessionTurn, z as toOpenAI } from "./agent-CGQajqtC.js";
1
+ import { A as SessionStore, B as createMemoryStore, D as Session, E as CreateSessionOptions, F as autoDetectAndConvert, H as FileMapStoreOptions, I as fromAnthropic, L as fromOpenAI, M as loadSession, N as RemoteStoreOptions, O as SessionData, Ot as SessionMessage, P as createRemoteStore, R as toAnthropic, Tt as SessionContentBlock, U as createFileMapStore, V as FileMapAdapter, j as createSession, k as SessionRun, kt as SessionTurn, z as toOpenAI } from "./agent-CYpPKn5Z.js";
2
2
  export { CreateSessionOptions, FileMapAdapter, FileMapStoreOptions, RemoteStoreOptions, Session, SessionContentBlock, SessionData, SessionMessage, SessionRun, SessionStore, SessionTurn, autoDetectAndConvert, createFileMapStore, createMemoryStore, createRemoteStore, createSession, fromAnthropic, fromOpenAI, loadSession, toAnthropic, toOpenAI };
package/dist/skills.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { C as SkillResource, S as SkillDiagnostic, T as SkillsConfig, c as DeactivationReason, d as createSkillActivationState, l as SkillActivationState, o as ActivationVia, s as ActiveSkill, u as SkillActivationStateOptions, w as SkillSource, x as SkillConfig } from "./agent-CGQajqtC.js";
2
- import { S as installAllowedToolsGate, _ as inferSource, a as SkillValidationResult, b as buildCatalog, c as parseAllowedToolPattern, d as validateSkillName, f as resolveSkills, g as getDefaultScanPaths, h as discoverSkills, i as SkillValidationIssue, l as validateResourcePath, m as SourcedScanPath, n as writeSkillToDisk, o as isToolAllowedByUnion, p as interpolateShellCommands, r as writeSkillsToDisk, s as matchesAllowedTool, t as defineSkill, u as validateSkillForWrite, v as parseFrontmatter, x as IMPLICITLY_ALLOWED_SKILL_TOOLS, y as parseSkillFile } from "./index-BDP6mA3Y.js";
1
+ import { C as SkillResource, S as SkillDiagnostic, T as SkillsConfig, c as DeactivationReason, d as createSkillActivationState, l as SkillActivationState, o as ActivationVia, s as ActiveSkill, u as SkillActivationStateOptions, w as SkillSource, x as SkillConfig } from "./agent-CYpPKn5Z.js";
2
+ import { S as installAllowedToolsGate, _ as inferSource, a as SkillValidationResult, b as buildCatalog, c as parseAllowedToolPattern, d as validateSkillName, f as resolveSkills, g as getDefaultScanPaths, h as discoverSkills, i as SkillValidationIssue, l as validateResourcePath, m as SourcedScanPath, n as writeSkillToDisk, o as isToolAllowedByUnion, p as interpolateShellCommands, r as writeSkillsToDisk, s as matchesAllowedTool, t as defineSkill, u as validateSkillForWrite, v as parseFrontmatter, x as IMPLICITLY_ALLOWED_SKILL_TOOLS, y as parseSkillFile } from "./index-Cc-q1hLT.js";
3
3
  export { ActivationVia, ActiveSkill, DeactivationReason, IMPLICITLY_ALLOWED_SKILL_TOOLS, SkillActivationState, SkillActivationStateOptions, SkillConfig, SkillDiagnostic, SkillResource, SkillSource, SkillValidationIssue, SkillValidationResult, SkillsConfig, SourcedScanPath, buildCatalog, createSkillActivationState, defineSkill, discoverSkills, getDefaultScanPaths, inferSource, installAllowedToolsGate, interpolateShellCommands, isToolAllowedByUnion, matchesAllowedTool, parseAllowedToolPattern, parseFrontmatter, parseSkillFile, resolveSkills, validateResourcePath, validateSkillForWrite, validateSkillName, writeSkillToDisk, writeSkillsToDisk };
@@ -480,7 +480,6 @@ function validateToolArgs(input, schema) {
480
480
  };
481
481
  let coerced;
482
482
  const coercions = [];
483
- let droppedItems;
484
483
  for (const [key, value] of Object.entries(input)) {
485
484
  const propSchema = properties[key];
486
485
  if (!propSchema?.type) continue;
@@ -495,138 +494,11 @@ function validateToolArgs(input, schema) {
495
494
  coerced[key] = outcome.value;
496
495
  coercions.push(key);
497
496
  }
498
- const arrayValue = outcome.changed ? outcome.value : value;
499
- if (propSchema.type === "array" && propSchema.items && Array.isArray(arrayValue)) {
500
- const itemOutcome = validateArrayItems(arrayValue, propSchema);
501
- if (itemOutcome.error) return {
502
- valid: false,
503
- error: `Field "${key}": ${itemOutcome.error}`
504
- };
505
- if (itemOutcome.changed || itemOutcome.dropped.length > 0 || itemOutcome.truncated) {
506
- if (!coerced) coerced = { ...input };
507
- coerced[key] = itemOutcome.items;
508
- if (!coercions.includes(key)) coercions.push(key);
509
- }
510
- if (itemOutcome.dropped.length > 0) {
511
- if (!droppedItems) droppedItems = {};
512
- droppedItems[key] = itemOutcome.dropped;
513
- }
514
- }
515
497
  }
516
498
  return {
517
499
  valid: true,
518
500
  coercedInput: coerced ?? input,
519
- coercions,
520
- ...droppedItems ? { droppedItems } : {}
521
- };
522
- }
523
- function validateArrayItems(items, schema) {
524
- if (schema.minItems !== void 0 && items.length < schema.minItems) return {
525
- items,
526
- changed: false,
527
- truncated: false,
528
- dropped: [],
529
- error: `expected at least ${schema.minItems} item${schema.minItems === 1 ? "" : "s"}, got ${items.length}`
530
- };
531
- const itemSchema = schema.items;
532
- if (!itemSchema) return {
533
- items,
534
- changed: false,
535
- truncated: false,
536
- dropped: []
537
- };
538
- const out = [];
539
- const outOriginalIdx = [];
540
- const dropped = [];
541
- let changed = false;
542
- for (let i = 0; i < items.length; i++) {
543
- const item = items[i];
544
- const v = validateOneItem(item, itemSchema);
545
- if (v.dropped) {
546
- dropped.push(i);
547
- changed = true;
548
- continue;
549
- }
550
- if (v.changed) changed = true;
551
- out.push(v.value);
552
- outOriginalIdx.push(i);
553
- }
554
- let truncated = false;
555
- if (schema.maxItems !== void 0 && out.length > schema.maxItems) {
556
- for (let i = schema.maxItems; i < out.length; i++) dropped.push(outOriginalIdx[i]);
557
- out.length = schema.maxItems;
558
- truncated = true;
559
- changed = true;
560
- }
561
- dropped.sort((a, b) => a - b);
562
- return {
563
- items: out,
564
- changed,
565
- truncated,
566
- dropped
567
- };
568
- }
569
- function validateOneItem(item, schema) {
570
- if (schema.type === "object") {
571
- if (!item || typeof item !== "object" || Array.isArray(item)) return {
572
- value: item,
573
- changed: false,
574
- dropped: true
575
- };
576
- const obj = item;
577
- const required = schema.required ?? [];
578
- for (const field of required) {
579
- const v = obj[field];
580
- if (v === void 0 || v === null) return {
581
- value: item,
582
- changed: false,
583
- dropped: true
584
- };
585
- }
586
- const properties = schema.properties ?? {};
587
- let coercedItem;
588
- for (const [key, value] of Object.entries(obj)) {
589
- const subSchema = properties[key];
590
- if (!subSchema?.type) continue;
591
- if (value === void 0 || value === null) continue;
592
- const outcome = coerceValue(value, subSchema);
593
- if (outcome.error) return {
594
- value: item,
595
- changed: false,
596
- dropped: true
597
- };
598
- if (outcome.changed) {
599
- if (!coercedItem) coercedItem = { ...obj };
600
- coercedItem[key] = outcome.value;
601
- }
602
- }
603
- return coercedItem ? {
604
- value: coercedItem,
605
- changed: true,
606
- dropped: false
607
- } : {
608
- value: item,
609
- changed: false,
610
- dropped: false
611
- };
612
- }
613
- if (schema.type) {
614
- const outcome = coerceValue(item, schema);
615
- if (outcome.error) return {
616
- value: item,
617
- changed: false,
618
- dropped: true
619
- };
620
- return {
621
- value: outcome.value,
622
- changed: outcome.changed,
623
- dropped: false
624
- };
625
- }
626
- return {
627
- value: item,
628
- changed: false,
629
- dropped: false
501
+ coercions
630
502
  };
631
503
  }
632
504
  function coerceValue(value, schema) {
@@ -4701,4 +4573,4 @@ const writeFile$1 = {
4701
4573
  //#endregion
4702
4574
  export { maybePersistToolResult as C, cleanupPersistedSession as S, getReadState as T, createSkillsReadTool as _, multiEdit as a, PERSISTENCE_PREVIEW_BYTES as b, grep as c, resolveOldString as d, styleReplacementForVia as f, createSkillsRunScriptTool as g, createSkillsUseTool as h, readFile$1 as i, glob as l, createToolSearchTool as m, createSpawnTool as n, listFiles as o, createAgent as p, shell as r, createInteractionTool as s, writeFile$1 as t, edit as u, validateToolArgs as v, resolvePersistDir as w, buildPersistedStub as x, PERSISTED_STUB_PREFIX as y };
4703
4575
 
4704
- //# sourceMappingURL=tools-BRbbfdJh.js.map
4576
+ //# sourceMappingURL=tools-CMVruxF0.js.map