zidane 4.0.2 → 4.1.3

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 (77) hide show
  1. package/README.md +196 -614
  2. package/dist/agent-BoV5Twdl.d.ts +2347 -0
  3. package/dist/agent-BoV5Twdl.d.ts.map +1 -0
  4. package/dist/contexts-3Arvn7yR.js +321 -0
  5. package/dist/contexts-3Arvn7yR.js.map +1 -0
  6. package/dist/contexts.d.ts +2 -25
  7. package/dist/contexts.js +2 -10
  8. package/dist/errors-D1lhd6mX.js +118 -0
  9. package/dist/errors-D1lhd6mX.js.map +1 -0
  10. package/dist/index-28otmfLX.d.ts +400 -0
  11. package/dist/index-28otmfLX.d.ts.map +1 -0
  12. package/dist/index-BfSdALzk.d.ts +113 -0
  13. package/dist/index-BfSdALzk.d.ts.map +1 -0
  14. package/dist/index-DPsd0qwm.d.ts +254 -0
  15. package/dist/index-DPsd0qwm.d.ts.map +1 -0
  16. package/dist/index.d.ts +5 -95
  17. package/dist/index.js +141 -271
  18. package/dist/index.js.map +1 -0
  19. package/dist/interpolate-CukJwP2G.js +887 -0
  20. package/dist/interpolate-CukJwP2G.js.map +1 -0
  21. package/dist/mcp-8wClKY-3.js +771 -0
  22. package/dist/mcp-8wClKY-3.js.map +1 -0
  23. package/dist/mcp.d.ts +2 -4
  24. package/dist/mcp.js +2 -13
  25. package/dist/messages-z5Pq20p7.js +1020 -0
  26. package/dist/messages-z5Pq20p7.js.map +1 -0
  27. package/dist/presets-Cs7_CsMk.js +39 -0
  28. package/dist/presets-Cs7_CsMk.js.map +1 -0
  29. package/dist/presets.d.ts +2 -43
  30. package/dist/presets.js +2 -17
  31. package/dist/providers-CX-R-Oy-.js +969 -0
  32. package/dist/providers-CX-R-Oy-.js.map +1 -0
  33. package/dist/providers.d.ts +2 -4
  34. package/dist/providers.js +3 -23
  35. package/dist/session/sqlite.d.ts +7 -12
  36. package/dist/session/sqlite.d.ts.map +1 -0
  37. package/dist/session/sqlite.js +67 -79
  38. package/dist/session/sqlite.js.map +1 -0
  39. package/dist/session-Cn68UASv.js +440 -0
  40. package/dist/session-Cn68UASv.js.map +1 -0
  41. package/dist/session.d.ts +2 -4
  42. package/dist/session.js +3 -27
  43. package/dist/skills.d.ts +3 -322
  44. package/dist/skills.js +24 -47
  45. package/dist/skills.js.map +1 -0
  46. package/dist/stats-DoKUtF5T.js +58 -0
  47. package/dist/stats-DoKUtF5T.js.map +1 -0
  48. package/dist/tools-DpeWKzP1.js +3941 -0
  49. package/dist/tools-DpeWKzP1.js.map +1 -0
  50. package/dist/tools.d.ts +3 -95
  51. package/dist/tools.js +2 -40
  52. package/dist/tui.d.ts +533 -0
  53. package/dist/tui.d.ts.map +1 -0
  54. package/dist/tui.js +2004 -0
  55. package/dist/tui.js.map +1 -0
  56. package/dist/types-Bx_F8jet.js +39 -0
  57. package/dist/types-Bx_F8jet.js.map +1 -0
  58. package/dist/types.d.ts +4 -55
  59. package/dist/types.js +4 -28
  60. package/package.json +38 -4
  61. package/dist/agent-BAHrGtqu.d.ts +0 -2425
  62. package/dist/chunk-4ILGBQ23.js +0 -803
  63. package/dist/chunk-4LPBN547.js +0 -3540
  64. package/dist/chunk-64LLNY7F.js +0 -28
  65. package/dist/chunk-6STZTA4N.js +0 -830
  66. package/dist/chunk-7GQ7P6DM.js +0 -566
  67. package/dist/chunk-IC7FT4OD.js +0 -37
  68. package/dist/chunk-JCOB6IYO.js +0 -22
  69. package/dist/chunk-JH6IAAFA.js +0 -28
  70. package/dist/chunk-LNN5UTS2.js +0 -97
  71. package/dist/chunk-PMCQOMV4.js +0 -490
  72. package/dist/chunk-UD25QF3H.js +0 -304
  73. package/dist/chunk-W57VY6DJ.js +0 -834
  74. package/dist/sandbox-D7v6Wy62.d.ts +0 -28
  75. package/dist/skills-use-DwZrNmcw.d.ts +0 -80
  76. package/dist/types-Bai5rKpa.d.ts +0 -89
  77. package/dist/validation-Pm--dQEU.d.ts +0 -185
@@ -1,28 +0,0 @@
1
- import { S as SpawnConfig, E as ExecResult, a as ExecutionContext } from './types-Bai5rKpa.js';
2
-
3
- /**
4
- * Remote sandbox execution context.
5
- *
6
- * Offloads execution to a remote sandbox API (e.g. Rivet, E2B).
7
- * Specific providers implement the SandboxProvider interface.
8
- */
9
-
10
- interface SandboxProvider {
11
- name: string;
12
- spawn: (config: SpawnConfig) => Promise<{
13
- id: string;
14
- cwd: string;
15
- }>;
16
- exec: (sandboxId: string, command: string, options?: {
17
- cwd?: string;
18
- env?: Record<string, string>;
19
- timeout?: number;
20
- }) => Promise<ExecResult>;
21
- readFile: (sandboxId: string, path: string) => Promise<string>;
22
- writeFile: (sandboxId: string, path: string, content: string) => Promise<void>;
23
- listFiles: (sandboxId: string, path: string) => Promise<string[]>;
24
- destroy: (sandboxId: string) => Promise<void>;
25
- }
26
- declare function createSandboxContext(provider: SandboxProvider): ExecutionContext;
27
-
28
- export { type SandboxProvider as S, createSandboxContext as c };
@@ -1,80 +0,0 @@
1
- import { a7 as ToolDef, X as SkillConfig, V as SkillActivationState, A as AgentHooks } from './agent-BAHrGtqu.js';
2
- import { Hookable } from 'hookable';
3
-
4
- /**
5
- * Surgical edit — replace `old_string` with `new_string` in a single file.
6
- *
7
- * Mirrors Claude Code's `Edit` semantics so models post-trained on Anthropic's
8
- * tool surface need no relearning. Fails clearly when `old_string` isn't unique
9
- * (unless `replace_all: true`) and when not found, with a nearest-match preview
10
- * so the model can recover without a separate `read_file` round-trip.
11
- */
12
- declare const edit: ToolDef;
13
-
14
- declare const glob: ToolDef;
15
-
16
- declare const grep: ToolDef;
17
-
18
- declare const multiEdit: ToolDef;
19
-
20
- /**
21
- * `skills_read` tool — reads a bundled resource file from an active skill.
22
- *
23
- * Requires the skill to be active (model must have called `skills_use` first).
24
- * Paths are validated against the skill's `baseDir` to prevent directory
25
- * traversal. File I/O goes through `ctx.execution.readFile` so docker/sandbox
26
- * execution contexts work identically to in-process.
27
- */
28
-
29
- interface SkillsReadToolOptions {
30
- catalog: readonly SkillConfig[];
31
- state: SkillActivationState;
32
- }
33
- declare function createSkillsReadTool(options: SkillsReadToolOptions): ToolDef;
34
-
35
- /**
36
- * `skills_run_script` tool — executes a script from an active skill's
37
- * `scripts/` directory via the agent's execution context.
38
- *
39
- * Path is validated against the skill's `baseDir` and constrained to the
40
- * `scripts/` subdirectory. Timeout is configurable via
41
- * `SkillsConfig.scriptTimeoutMs` (default 60 s).
42
- */
43
-
44
- interface SkillsRunScriptToolOptions {
45
- catalog: readonly SkillConfig[];
46
- state: SkillActivationState;
47
- /** Script timeout in milliseconds. Default 60000. */
48
- scriptTimeoutMs?: number;
49
- }
50
- declare function createSkillsRunScriptTool(options: SkillsRunScriptToolOptions): ToolDef;
51
-
52
- /**
53
- * `skills_use` tool — activates a skill and returns its full instructions.
54
- *
55
- * Implements tier 2 of progressive disclosure per the Agent Skills spec.
56
- * Body is frontmatter-stripped (the model gets the markdown only, wrapped in
57
- * `<skill_content>` tags so downstream context management can identify it).
58
- * Shell-interpolation (`!` `` `cmd` ``) runs per-activation rather than once
59
- * per agent, so values like `gh pr diff` reflect the current state.
60
- */
61
-
62
- interface SkillsUseToolOptions {
63
- /** Resolved skills catalog for this run. */
64
- catalog: readonly SkillConfig[];
65
- /** Per-agent activation state the tool mutates. */
66
- state: SkillActivationState;
67
- /** Agent hooks — used to fire `skills:activate` on first activation. */
68
- hooks: Hookable<AgentHooks>;
69
- }
70
- /**
71
- * Factory for `skills_use`. Auto-injected into the agent's tool set by the
72
- * agent runtime when a non-empty skills catalog is available (unless
73
- * `SkillsConfig.tool === false`).
74
- *
75
- * The tool schema's `name` property is `enum`-constrained to the resolved
76
- * catalog so the LLM cannot hallucinate a skill that doesn't exist.
77
- */
78
- declare function createSkillsUseTool(options: SkillsUseToolOptions): ToolDef;
79
-
80
- export { type SkillsReadToolOptions as S, type SkillsRunScriptToolOptions as a, type SkillsUseToolOptions as b, createSkillsReadTool as c, createSkillsRunScriptTool as d, createSkillsUseTool as e, edit as f, glob as g, grep as h, multiEdit as m };
@@ -1,89 +0,0 @@
1
- /**
2
- * Execution context types.
3
- *
4
- * An execution context defines *where* and *how* an agent's tools run.
5
- * The agent loop and tools interact through this interface without knowing
6
- * whether they're running in-process, in a Docker container, or in a
7
- * remote sandbox.
8
- */
9
- interface ContextCapabilities {
10
- /** Can execute shell commands */
11
- shell: boolean;
12
- /** Can read/write files in a workspace */
13
- filesystem: boolean;
14
- /** Can make outbound network requests */
15
- network: boolean;
16
- /** Has GPU access */
17
- gpu: boolean;
18
- }
19
- /** Opaque handle to a running execution context instance */
20
- interface ExecutionHandle {
21
- id: string;
22
- type: ContextType;
23
- /** Working directory within the context */
24
- cwd: string;
25
- }
26
- interface ExecResult {
27
- stdout: string;
28
- stderr: string;
29
- exitCode: number;
30
- }
31
- interface SpawnConfig {
32
- /** Working directory (created if it doesn't exist) */
33
- cwd?: string;
34
- /** Environment variables */
35
- env?: Record<string, string>;
36
- /** Docker image (only for 'docker' context) */
37
- image?: string;
38
- /** Resource limits */
39
- limits?: {
40
- /** Memory limit in MB */
41
- memory?: number;
42
- /** CPU limit (e.g. '1.0' = 1 core) */
43
- cpu?: string;
44
- /** Timeout in seconds for the entire context lifetime */
45
- timeout?: number;
46
- };
47
- /** Sandbox provider config (only for 'sandbox' context) */
48
- sandbox?: {
49
- provider: string;
50
- apiKey?: string;
51
- [key: string]: unknown;
52
- };
53
- }
54
- type ContextType = 'process' | 'docker' | 'sandbox';
55
- interface ExecutionContext {
56
- /** Context type identifier */
57
- readonly type: ContextType;
58
- /** What this context supports */
59
- readonly capabilities: ContextCapabilities;
60
- /** Spawn a new execution environment */
61
- spawn: (config?: SpawnConfig) => Promise<ExecutionHandle>;
62
- /** Execute a shell command in the context */
63
- exec: (handle: ExecutionHandle, command: string, options?: {
64
- cwd?: string;
65
- env?: Record<string, string>;
66
- timeout?: number;
67
- }) => Promise<ExecResult>;
68
- /** Read a file from the context's filesystem */
69
- readFile: (handle: ExecutionHandle, path: string) => Promise<string>;
70
- /**
71
- * Read a file from the context's filesystem as raw bytes.
72
- *
73
- * Used by `read_file` to dispatch image / binary files into the multimodal
74
- * `ToolResultContent[]` route. Optional — when not implemented, the tool
75
- * falls back to `base64 < path` via the `exec` seam, which works in any
76
- * shell-capable context. Implementations that already have a native
77
- * binary read (in-process `fs.readFile` without encoding, container API,
78
- * sandbox SDK) should override for the latency win.
79
- */
80
- readFileBinary?: (handle: ExecutionHandle, path: string) => Promise<Uint8Array>;
81
- /** Write a file to the context's filesystem */
82
- writeFile: (handle: ExecutionHandle, path: string, content: string) => Promise<void>;
83
- /** List files in a directory */
84
- listFiles: (handle: ExecutionHandle, path: string) => Promise<string[]>;
85
- /** Destroy the execution environment and clean up resources */
86
- destroy: (handle: ExecutionHandle) => Promise<void>;
87
- }
88
-
89
- export type { ContextCapabilities as C, ExecResult as E, SpawnConfig as S, ExecutionContext as a, ContextType as b, ExecutionHandle as c };
@@ -1,185 +0,0 @@
1
- import { a6 as ToolContext, a7 as ToolDef, j as AgentStats, aK as ChildRunStats } from './agent-BAHrGtqu.js';
2
- import { Preset } from './presets.js';
3
-
4
- /**
5
- * Interaction tool — lets the agent request structured input from the outside world.
6
- *
7
- * Not included in any preset by default. Add it explicitly:
8
- *
9
- * import { createInteractionTool } from 'zidane'
10
- *
11
- * const askUser = createInteractionTool({
12
- * schema: { type: 'object', properties: { question: { type: 'string' } }, required: ['question'] },
13
- * onRequest: async (payload) => {
14
- * const answer = await promptUser(payload.question)
15
- * return { answer }
16
- * },
17
- * })
18
- *
19
- * const preset = definePreset({ name: 'interactive', tools: { ...basicTools, ask_user: askUser } })
20
- */
21
-
22
- interface InteractionToolOptions {
23
- /** JSON Schema for the request payload the model sends */
24
- schema: Record<string, unknown>;
25
- /** Tool name (default: 'interaction') */
26
- name?: string;
27
- /** Tool description shown to the model */
28
- description?: string;
29
- /** Called when the model invokes this tool. Receives the validated payload and tool context, returns data for the model. */
30
- onRequest: (payload: Record<string, unknown>, ctx: ToolContext) => Promise<Record<string, unknown> | string>;
31
- }
32
- /**
33
- * Create an interaction tool that lets the agent request structured input.
34
- *
35
- * The model calls this tool with a payload matching the schema.
36
- * `onRequest` is called with the payload and should return the response
37
- * (string or object) that gets sent back to the model as the tool result.
38
- */
39
- declare function createInteractionTool(options: InteractionToolOptions): ToolDef;
40
-
41
- /**
42
- * Spawn tool — create sub-agents from a parent agent.
43
- *
44
- * A configurable factory that reads the parent's preset-y fields from ToolContext.
45
- *
46
- * Usage:
47
- * ```ts
48
- * import { createSpawnTool } from 'zidane'
49
- * import { definePreset, basicTools } from 'zidane/presets'
50
- *
51
- * const preset = definePreset({
52
- * name: 'orchestrator',
53
- * tools: { ...basicTools, spawn: createSpawnTool({ maxConcurrent: 5 }) },
54
- * })
55
- * ```
56
- *
57
- * Each `createSpawnTool()` call returns a fresh instance with its own
58
- * concurrency counter, depth cap, and child-stats accumulator — never
59
- * share an instance across unrelated parent agents.
60
- *
61
- * Key guarantees:
62
- * - **Depth-capped** to `maxDepth` (default 3) to prevent infinite recursion.
63
- * - **Concurrency slot is reserved synchronously** before any `await`, so a
64
- * parent running tools in parallel cannot exceed `maxConcurrent`.
65
- * - **Pre-aborted signals short-circuit** without paying agent-spawn cost.
66
- * - **Abort / timeout / error are surfaced distinctly** in the returned text
67
- * and via `ChildRunStats.status` on `spawn:complete`.
68
- * - **`agent.destroy()` errors never mask the original run error** (captured
69
- * and emitted via `spawn:error` but the primary error wins).
70
- * - **Child hooks bubble** to the parent as `child:*` events when
71
- * `forwardHooks` is set (default `true`).
72
- * - **Persistence** via `persist: true` — child runs get appended to the
73
- * parent's session with `parentRunId` wired, so the run tree is
74
- * reconstructible from a stored `SessionData`.
75
- */
76
-
77
- interface ChildAgent {
78
- id: string;
79
- task: string;
80
- startedAt: number;
81
- /** Subagent depth — 1 for a direct child of a top-level agent. */
82
- depth: number;
83
- }
84
- interface SpawnToolState {
85
- /** Currently running children. */
86
- readonly children: ReadonlyMap<string, ChildAgent>;
87
- /**
88
- * Cumulative stats across every completed direct child of this spawn-tool
89
- * instance (returns a copy). Each child's contribution is the cumulative
90
- * `AgentStats` returned by its `agent.run()` — so
91
- * `totalIn`/`totalOut`/`totalCacheRead`/`totalCacheCreation` cover the
92
- * entire subtree (children + grandchildren + …), while `turns` and
93
- * `elapsed` stay parent-loop-only per child and are summed across direct
94
- * children. `elapsed` over-counts when children ran in parallel.
95
- *
96
- * Lives across multiple parent runs that share this instance.
97
- */
98
- readonly totalChildStats: Readonly<AgentStats>;
99
- }
100
- interface SpawnToolOptions {
101
- /** Maximum concurrent sub-agents (default: 3). */
102
- maxConcurrent?: number;
103
- /**
104
- * Maximum subagent depth. 0 disables spawning entirely; 1 allows top-level
105
- * spawns but forbids grandchildren; 3 (default) allows three levels of
106
- * recursion — enough for most orchestration patterns, a sharp ceiling
107
- * against runaway loops.
108
- */
109
- maxDepth?: number;
110
- /** Child model override. */
111
- model?: string;
112
- /** Child system prompt override. Per-spawn `input.system` takes precedence. */
113
- system?: string;
114
- /** Child thinking level. */
115
- thinking?: 'off' | 'minimal' | 'low' | 'medium' | 'high';
116
- /** Preset override for children. Shallow-merged over the parent's preset (parent fields still win for anything left unset). */
117
- preset?: Preset;
118
- /**
119
- * Per-child timeout, in milliseconds. When the child exceeds it the spawn
120
- * tool returns a timeout marker, fires `spawn:error`, and destroys the
121
- * child agent. Default: none.
122
- */
123
- timeoutMs?: number;
124
- /**
125
- * When `true` and the parent has a session, the child reuses the parent's
126
- * session — child turns are appended with the child's own `runId`, and the
127
- * resulting `SessionRun` carries `parentRunId` so the tree is
128
- * reconstructible. Default: `false` (child is in-memory only).
129
- */
130
- persist?: boolean;
131
- /**
132
- * Forward a curated subset of child hook events (`stream:*`, `tool:*`,
133
- * `turn:after`) onto the parent's hook bus as `child:*` events. Default:
134
- * `true`. Grandchildren bubble through their child transparently.
135
- */
136
- forwardHooks?: boolean;
137
- /** Called when a child agent starts. */
138
- onSpawn?: (child: ChildAgent) => void;
139
- /** Called when a child agent completes (success, abort, timeout, or error). */
140
- onComplete?: (child: ChildAgent, stats: AgentStats, status: NonNullable<ChildRunStats['status']>) => void;
141
- }
142
- /**
143
- * Create a configured spawn tool.
144
- *
145
- * State (`children`, `totalChildStats`, counters, active count) is scoped to
146
- * the returned instance. Multiple parent agents using the same instance will
147
- * share counters + stats + concurrency slots — call `createSpawnTool()` per
148
- * agent (or use the stateless default `spawn`) to keep them isolated.
149
- */
150
- declare function createSpawnTool(options?: SpawnToolOptions): ToolDef & SpawnToolState;
151
-
152
- /**
153
- * Tool argument validation against JSON Schema-style inputSchema.
154
- *
155
- * Two passes:
156
- * 1. Required-field presence. Missing or null/undefined required fields fail.
157
- * 2. Top-level type checks with **best-effort coercion**. Small/OSS models
158
- * routinely send `"true"` for a `boolean` field or `"42"` for a `number`,
159
- * and rejecting outright forces a confusing retry. Instead, we auto-heal
160
- * coerce when the conversion is unambiguous, fail only when the value
161
- * cannot be reasonably normalized to any of the declared types.
162
- *
163
- * Nested validation is intentionally out of scope — keep it cheap and let the
164
- * tool's `execute` body assert deeper invariants.
165
- */
166
- interface ValidationResult {
167
- valid: boolean;
168
- /** Human-readable reason. Present on failure only. */
169
- error?: string;
170
- /**
171
- * Possibly-coerced input. Present iff `valid: true`. Tools should call
172
- * `execute(coercedInput, ctx)` so auto-healed values reach the tool body.
173
- * When no coercion was applied, this is reference-equal to the input.
174
- */
175
- coercedInput?: Record<string, unknown>;
176
- /**
177
- * Names of fields whose values were coerced. Empty when nothing changed.
178
- * Useful for telemetry (`validation:reject` on failure already carries the
179
- * reason; this is the success-path equivalent).
180
- */
181
- coercions?: readonly string[];
182
- }
183
- declare function validateToolArgs(input: Record<string, unknown>, schema: Record<string, unknown>): ValidationResult;
184
-
185
- export { type ChildAgent as C, type InteractionToolOptions as I, type SpawnToolOptions as S, type ValidationResult as V, type SpawnToolState as a, createSpawnTool as b, createInteractionTool as c, validateToolArgs as v };