zidane 6.4.3 → 6.5.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 (104) hide show
  1. package/README.md +1 -0
  2. package/dist/{acp-Kr7LyExq.js → acp-B-AOovHz.js} +3 -3
  3. package/dist/{acp-Kr7LyExq.js.map → acp-B-AOovHz.js.map} +1 -1
  4. package/dist/acp-cli.js +3 -2
  5. package/dist/acp-cli.js.map +1 -1
  6. package/dist/acp.d.ts +1 -1
  7. package/dist/acp.js +1 -1
  8. package/dist/{agent-CEvzc1Ao.js → agent-SQ6rxfpT.js} +298 -110
  9. package/dist/agent-SQ6rxfpT.js.map +1 -0
  10. package/dist/agent.d.ts +1 -1
  11. package/dist/agent.js +2 -2
  12. package/dist/chat/pure.d.ts +3 -3
  13. package/dist/chat.d.ts +13 -44
  14. package/dist/chat.d.ts.map +1 -1
  15. package/dist/chat.js +5 -4
  16. package/dist/chat.js.map +1 -1
  17. package/dist/{context-transport-DbzJctSl.js → context-transport-CDBatvQc.js} +3 -3
  18. package/dist/{context-transport-DbzJctSl.js.map → context-transport-CDBatvQc.js.map} +1 -1
  19. package/dist/contexts/daytona.d.ts +1 -1
  20. package/dist/contexts/e2b.d.ts +1 -1
  21. package/dist/eval.d.ts +1 -1
  22. package/dist/extensions.d.ts +2 -2
  23. package/dist/extensions.js +2 -2
  24. package/dist/headless.d.ts +1 -1
  25. package/dist/headless.js +1 -1
  26. package/dist/{index-W_8010Lt.d.ts → index-CWBSrqI6.d.ts} +931 -3
  27. package/dist/index-CWBSrqI6.d.ts.map +1 -0
  28. package/dist/index.d.ts +2 -2
  29. package/dist/index.js +8 -7
  30. package/dist/index.js.map +1 -1
  31. package/dist/{login-Blkiy-58.js → login-XZDS4K2o.js} +3 -3
  32. package/dist/{login-Blkiy-58.js.map → login-XZDS4K2o.js.map} +1 -1
  33. package/dist/{mcp-CDN-m5lp.js → mcp-D27rP47I.js} +87 -6
  34. package/dist/mcp-D27rP47I.js.map +1 -0
  35. package/dist/mcp.d.ts +2 -2
  36. package/dist/mcp.js +3 -2
  37. package/dist/origin-pinned-fetch-CqG8VZIq.js +159 -0
  38. package/dist/origin-pinned-fetch-CqG8VZIq.js.map +1 -0
  39. package/dist/output/stream-json.d.ts +1 -1
  40. package/dist/output/terminal.d.ts +1 -1
  41. package/dist/plugins-2PMTVcp-.js +1174 -0
  42. package/dist/plugins-2PMTVcp-.js.map +1 -0
  43. package/dist/plugins.d.ts +2 -0
  44. package/dist/plugins.js +2 -0
  45. package/dist/presets.d.ts +1 -1
  46. package/dist/presets.js +1 -1
  47. package/dist/providers/anthropic.d.ts +1 -1
  48. package/dist/providers/arcee.d.ts +1 -1
  49. package/dist/providers/baseten.d.ts +1 -1
  50. package/dist/providers/cerebras.d.ts +1 -1
  51. package/dist/providers/local.d.ts +1 -1
  52. package/dist/providers/openai-compat.d.ts +1 -1
  53. package/dist/providers/openai.d.ts +1 -1
  54. package/dist/providers/openrouter.d.ts +1 -1
  55. package/dist/providers/xai.d.ts +1 -1
  56. package/dist/providers.d.ts +1 -1
  57. package/dist/restate.d.ts +52 -2
  58. package/dist/restate.d.ts.map +1 -1
  59. package/dist/restate.js +156 -36
  60. package/dist/restate.js.map +1 -1
  61. package/dist/session/sqlite.d.ts +1 -1
  62. package/dist/session.d.ts +1 -1
  63. package/dist/{resolve-CZJxds85.js → skills-Cp9vnBwd.js} +1430 -1006
  64. package/dist/skills-Cp9vnBwd.js.map +1 -0
  65. package/dist/skills.d.ts +1 -1
  66. package/dist/skills.js +1 -2
  67. package/dist/{stdio-DWQKYKad.js → stdio-O-m9WVkE.js} +2 -2
  68. package/dist/{stdio-DWQKYKad.js.map → stdio-O-m9WVkE.js.map} +1 -1
  69. package/dist/{stdio-loader-3uz37d_3.js → stdio-loader-BSGQmG4L.js} +2 -2
  70. package/dist/{stdio-loader-3uz37d_3.js.map → stdio-loader-BSGQmG4L.js.map} +1 -1
  71. package/dist/{tool-formatters-bhC2Xp8z.d.ts → tool-formatters-gFqQbzPY.d.ts} +2 -2
  72. package/dist/{tool-formatters-bhC2Xp8z.d.ts.map → tool-formatters-gFqQbzPY.d.ts.map} +1 -1
  73. package/dist/{read-state-Dt7UbVsd.js → tool-state-DTs-3ZHH.js} +218 -2
  74. package/dist/tool-state-DTs-3ZHH.js.map +1 -0
  75. package/dist/tools/fetch-url.d.ts +1 -1
  76. package/dist/tools/web-search.d.ts +1 -1
  77. package/dist/tools.d.ts +1 -1
  78. package/dist/tools.js +2 -2
  79. package/dist/{transcript-anchors-D7wVCZ2S.js → transcript-anchors-D4IxJifV.js} +42 -5
  80. package/dist/transcript-anchors-D4IxJifV.js.map +1 -0
  81. package/dist/{transcript-anchors-mcMLuXM1.d.ts → transcript-anchors-qCs3wZpu.d.ts} +98 -92
  82. package/dist/transcript-anchors-qCs3wZpu.d.ts.map +1 -0
  83. package/dist/tui.d.ts +38 -4
  84. package/dist/tui.d.ts.map +1 -1
  85. package/dist/tui.js +893 -148
  86. package/dist/tui.js.map +1 -1
  87. package/dist/{turn-operations-B5vVcG0Z.d.ts → turn-operations-M9-jUyDd.d.ts} +3 -3
  88. package/dist/{turn-operations-B5vVcG0Z.d.ts.map → turn-operations-M9-jUyDd.d.ts.map} +1 -1
  89. package/dist/types-BIarq1qE.js.map +1 -1
  90. package/dist/types.d.ts +2 -2
  91. package/docs/ARCHITECTURE.md +2 -0
  92. package/docs/PLUGINS.md +340 -0
  93. package/docs/RESTATE.md +133 -3
  94. package/docs/SKILL.md +24 -8
  95. package/package.json +6 -1
  96. package/dist/agent-CEvzc1Ao.js.map +0 -1
  97. package/dist/index-W_8010Lt.d.ts.map +0 -1
  98. package/dist/mcp-CDN-m5lp.js.map +0 -1
  99. package/dist/read-state-Dt7UbVsd.js.map +0 -1
  100. package/dist/resolve-CZJxds85.js.map +0 -1
  101. package/dist/skills-Dd6XCi4s.js +0 -420
  102. package/dist/skills-Dd6XCi4s.js.map +0 -1
  103. package/dist/transcript-anchors-D7wVCZ2S.js.map +0 -1
  104. package/dist/transcript-anchors-mcMLuXM1.d.ts.map +0 -1
package/docs/SKILL.md CHANGED
@@ -262,10 +262,22 @@ interface ToolDef {
262
262
  ) => Promise<string | ToolResultContent[]>
263
263
  /** Default `false`. See "Per-tool concurrency" below. */
264
264
  isConcurrencySafe?: boolean | ((input: Record<string, unknown>) => boolean)
265
+ /**
266
+ * Set it when `execute` runs a full nested agent loop (calls `agent.run`).
267
+ * The built-in `spawn` does. Inert outside durable execution; under a durable
268
+ * runtime it is load-bearing — `wrapAgentTools` keeps such tools out of its
269
+ * journaling wrapper, because the child's own journaled calls cannot nest
270
+ * inside the outer tool's journal entry. Miss it on a host orchestrator tool
271
+ * and the invocation fails on its first retry. See `docs/RESTATE.md`
272
+ * § Subagents.
273
+ */
274
+ runsNestedAgent?: boolean
265
275
  }
266
276
  ```
267
277
 
268
- `ToolContext` exposes `provider`, `signal`, `execution`, `handle`, `hooks`, `turnId`, `callId`, `runId?`, `parentRunId?`, `session?`, `readState?`, `depth?`, plus preset fields (`name`, `system`, `tools`, `toolAliases`, `mcpServers`, `skills`, `behavior`) so `spawn` can inherit.
278
+ `ToolContext` exposes `provider`, `signal`, `execution`, `handle`, `hooks`, `turnId`, `callId`, `runId?`, `parentRunId?`, `parentCallId?`, `session?`, `readState?`, `clock?`, `depth?`, plus preset fields (`name`, `system`, `tools`, `toolAliases`, `mcpServers`, `skills`, `behavior`) so `spawn` can inherit.
279
+
280
+ `clock` is the run's time / UUID source (`AgentClock`) — prefer it over `Date.now()` / `crypto.randomUUID()` for anything that gets persisted or shown to the model, because a durable host replaces it with a journaled one so those values replay byte-identically. If you write your own durable adapter, set `AgentClock.journaled: true` on the clock you install: consumers read it to avoid deciding on a wall-clock timer inside a journaled region (the `spawn` tool switches its per-child timeout to a turn-boundary check on that signal).
269
281
 
270
282
  Returns `string` (common) or `ToolResultContent[]` (images / mixed content). Routed natively via `tool_result.content` when supported, or via companion user message on plain Chat Completions. Flatten via `toolResultToText(result)`.
271
283
 
@@ -372,7 +384,7 @@ For post-edit validation, use `createMutationValidationHooks()` from `zidane`. I
372
384
  | `session:turns` | Turns persisted | — | `sessionId, turns, count` |
373
385
  | `session:save` | Session store write | — | `sessionId` |
374
386
  | `session:meta` | Session metadata write | — | `sessionId, key: string, value: unknown` |
375
- | `spawn:before`, `spawn:complete`, `spawn:error` | Sub-agent lifecycle | — | `id, task, stats?, error?` |
387
+ | `spawn:before`, `spawn:complete`, `spawn:error` | Sub-agent lifecycle | — | `id, task, callId?, stats?, error?` (`callId` = the spawn call's own id, i.e. the child's `parentCallId`) |
376
388
  | `session:start`, `session:end` | Run boundaries (always fire) | — | `sessionId, runId` + (`prompt` \| `status, turnRange`) |
377
389
  | `agent:abort` | `agent.abort()` called | — | `{}` |
378
390
  | `agent:done` | Run finished (all exit paths) | — | `AgentStats` |
@@ -385,13 +397,14 @@ Mutable ctx fields: `tool:gate` (`block`, `reason`, `result`), `tool:transform`
385
397
 
386
398
  ### Identity fields on tool hook contexts
387
399
 
388
- Every `tool:*` and `mcp:tool:*` hook ctx additionally carries three optional identity fields (omitted from the per-row "key ctx fields" column above to keep the table readable):
400
+ Every `tool:*` and `mcp:tool:*` hook ctx additionally carries four optional identity fields (omitted from the per-row "key ctx fields" column above to keep the table readable):
389
401
 
390
402
  - `runId?: string` — the `SessionRun.id` this call belongs to. Lets one listener disambiguate calls across parallel runs / subagent trees without subscribing to `child:tool:*`.
391
- - `parentRunId?: string` — set when the call's agent is a subagent (mirrors `SessionRun.parentRunId`); absent on top-level runs. Drives UI grouping for subagent-scoped state (todowrite batches, edit groups, etc.) without resolving the run row.
403
+ - `parentRunId?: string` — set when the call's agent is a subagent (mirrors `SessionRun.parentRunId`); absent on top-level runs. Drives UI grouping for subagent-scoped state (todowrite batches, edit groups, etc.) without resolving the run row. Only wired when the spawn shares the parent's session (`persist`) — for grouping that must hold on every subagent, use `parentCallId`.
404
+ - `parentCallId?: string` — the `callId` of the `spawn` call that created this run; absent on top-level runs. Set for every child the built-in `spawn` tool starts (it forwards its own call id; no session required), so hosts mirroring subagent work into a client protocol can use it as the "parent tool use" grouping key — absent at depth 0, a real tool-call id at depth ≥ 1. Two qualifications: it is not implied by `depth >= 1` (a host that spawns by calling `agent.run({ depth })` itself must also pass `AgentRunOptions.parentCallId`), and it resolves against the parent's own `tool:*` stream only at depth 1 — at depth ≥ 2 it names a call in the child's turn, which the top-level listener saw only as `child:tool:*`. Same ancestry semantics as `childId` / `depth` on `child:*` events. The spawn payloads (`spawn:before` / `:complete` / `:error`) carry the same id as `callId`, which is where a host learns the `childId` → call mapping for a child that never dispatches a tool.
392
405
  - `depth?: number` — subagent depth, 0 = top-level. Mirrors `ToolContext.depth`.
393
406
 
394
- Same three fields land on `ToolContext` (visible to the tool body via `ctx.runId` / `ctx.parentRunId` / `ctx.depth`). The loop centralizes their construction in `buildToolHookBase`, so a new tool-related hook event automatically inherits them.
407
+ All four land on `ToolContext` as well (visible to the tool body via `ctx.runId` / `ctx.parentRunId` / `ctx.parentCallId` / `ctx.depth`). The loop centralizes their construction in `buildToolHookBase`, so a new tool-related hook event automatically inherits them.
395
408
 
396
409
  ### Child (sub-agent) bubble events
397
410
 
@@ -599,14 +612,17 @@ definePreset({
599
612
  })
600
613
  ```
601
614
 
602
- ### Parent/child boundaries — `persist` and `shareReadState`
615
+ ### Parent/child boundaries — `persist`, `shareReadState`, `shareHandle`
603
616
 
604
- Two **independent** flags control what crosses the parent/child boundary:
617
+ Three **independent** flags control what crosses the parent/child boundary:
605
618
 
606
619
  | Flag | Default | What it shares |
607
620
  |---|---|---|
608
621
  | `persist` | `false` | The parent's `Session`. Child turns get appended to the same `session.turns` stream with the child's `runId`; the child's `SessionRun` carries `parentRunId` so the tree is reconstructible. As a side-effect the read-state map (Session-keyed) is also shared. |
609
622
  | `shareReadState` | `false` | Only the read-state map. The child gets `AgentOptions.readState` populated with the parent's resolved map but **no session** — `read_file` populations land in the parent's tracking, but child turns stay in-memory. |
623
+ | `shareHandle` | `false` | The parent's `ExecutionHandle`. The child skips its own `execution.spawn()` and never destroys the handle (host owns the lifecycle), so children see the parent's filesystem and background-task namespace instead of an isolated scratch space. Matters most for remote contexts (sandbox / container), where a per-child allocation is real — and under a durable runtime is an unjournaled side effect that orphans a sandbox on every replayed attempt. See `docs/RESTATE.md` § Subagents. |
624
+
625
+ Always inherited (not flags): the parent's `AgentClock`, so a durable host's journaled time/UUID source stamps child metadata too, and `AgentBehavior`, which carries the durable tool-batch scheduler.
610
626
 
611
627
  Use `shareReadState: true` (without `persist`) when you want the parent's `requireReadBeforeEdit` gate to honor reads the child performed, without polluting the parent's session with child turns. The gate's error message now hints at this when the entry is missing — re-read in the calling context OR opt into one of the sharing flags.
612
628
 
@@ -918,7 +934,7 @@ createSandboxContext(myProvider) // implement SandboxProvider (E2B, Rivet, …)
918
934
  | `RunHookMap` | `run({ hooks })` shape. |
919
935
  | `AgentBehavior.maxConcurrentTools` | Cap on in-flight tools per turn (default `10`, clamped at `1`). See "Per-tool concurrency" above. |
920
936
  | `ToolDef.isConcurrencySafe` | `boolean \| ((input) => boolean)`. Defaults to `false`. See "Per-tool concurrency" above. |
921
- | `ToolHookContext` / `McpToolHookContext` / `SessionHookContext` / `StreamHookContext` / `SpawnHookContext` | Hook ctx base types. `ToolHookContext` / `McpToolHookContext` carry `runId? / parentRunId? / depth?` identity fields on every `tool:*` / `mcp:tool:*` event — see Identity fields above. |
937
+ | `ToolHookContext` / `McpToolHookContext` / `SessionHookContext` / `StreamHookContext` / `SpawnHookContext` | Hook ctx base types. `ToolHookContext` / `McpToolHookContext` carry `runId? / parentRunId? / parentCallId? / depth?` identity fields on every `tool:*` / `mcp:tool:*` event — see Identity fields above. |
922
938
  | `ReadStateMap` / `ReadStateEntry` | Per-file read-tracking map (`Map<canonicalAbsPath, { contentHash, offset, limit, maxBytes, lineNumbers?, mtimeMs }>`). Construct one manually for `AgentOptions.readState` to share across an agent tree; or get the session-bound one via `getReadState(session)` / the lookup-aware `resolveReadStateMap(ctx)`. Canonical keys come from `readStateKey(cwd, path)`. |
923
939
  | `ClassifiedError` | `{ kind, providerCode?, message? }` from `Provider.classifyError`. |
924
940
  | `AgentContextExceededError` / `AgentProviderError` / `AgentAbortedError` / `AgentToolNotAllowedError` / `AgentBudgetExceededError` | Typed errors. `toTypedError(err)` wraps native errors. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zidane",
3
- "version": "6.4.3",
3
+ "version": "6.5.0",
4
4
  "description": "an agent that goes straight to the goal",
5
5
  "type": "module",
6
6
  "private": false,
@@ -171,6 +171,11 @@
171
171
  "import": "./dist/skills.js",
172
172
  "default": "./dist/skills.js"
173
173
  },
174
+ "./plugins": {
175
+ "types": "./dist/plugins.d.ts",
176
+ "import": "./dist/plugins.js",
177
+ "default": "./dist/plugins.js"
178
+ },
174
179
  "./extensions": {
175
180
  "types": "./dist/extensions.d.ts",
176
181
  "import": "./dist/extensions.js",