zidane 4.0.2 → 4.1.4
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.
- package/README.md +196 -614
- package/dist/agent-BoV5Twdl.d.ts +2347 -0
- package/dist/agent-BoV5Twdl.d.ts.map +1 -0
- package/dist/contexts-3Arvn7yR.js +321 -0
- package/dist/contexts-3Arvn7yR.js.map +1 -0
- package/dist/contexts.d.ts +2 -25
- package/dist/contexts.js +2 -10
- package/dist/errors-D1lhd6mX.js +118 -0
- package/dist/errors-D1lhd6mX.js.map +1 -0
- package/dist/index-28otmfLX.d.ts +400 -0
- package/dist/index-28otmfLX.d.ts.map +1 -0
- package/dist/index-BfSdALzk.d.ts +113 -0
- package/dist/index-BfSdALzk.d.ts.map +1 -0
- package/dist/index-DPsd0qwm.d.ts +254 -0
- package/dist/index-DPsd0qwm.d.ts.map +1 -0
- package/dist/index.d.ts +5 -95
- package/dist/index.js +141 -271
- package/dist/index.js.map +1 -0
- package/dist/interpolate-CukJwP2G.js +887 -0
- package/dist/interpolate-CukJwP2G.js.map +1 -0
- package/dist/mcp-8wClKY-3.js +771 -0
- package/dist/mcp-8wClKY-3.js.map +1 -0
- package/dist/mcp.d.ts +2 -4
- package/dist/mcp.js +2 -13
- package/dist/messages-z5Pq20p7.js +1020 -0
- package/dist/messages-z5Pq20p7.js.map +1 -0
- package/dist/presets-Cs7_CsMk.js +39 -0
- package/dist/presets-Cs7_CsMk.js.map +1 -0
- package/dist/presets.d.ts +2 -43
- package/dist/presets.js +2 -17
- package/dist/providers-CX-R-Oy-.js +969 -0
- package/dist/providers-CX-R-Oy-.js.map +1 -0
- package/dist/providers.d.ts +2 -4
- package/dist/providers.js +3 -23
- package/dist/session/sqlite.d.ts +7 -12
- package/dist/session/sqlite.d.ts.map +1 -0
- package/dist/session/sqlite.js +67 -79
- package/dist/session/sqlite.js.map +1 -0
- package/dist/session-Cn68UASv.js +440 -0
- package/dist/session-Cn68UASv.js.map +1 -0
- package/dist/session.d.ts +2 -4
- package/dist/session.js +3 -27
- package/dist/skills.d.ts +3 -322
- package/dist/skills.js +24 -47
- package/dist/skills.js.map +1 -0
- package/dist/stats-DoKUtF5T.js +58 -0
- package/dist/stats-DoKUtF5T.js.map +1 -0
- package/dist/tools-DpeWKzP1.js +3941 -0
- package/dist/tools-DpeWKzP1.js.map +1 -0
- package/dist/tools.d.ts +3 -95
- package/dist/tools.js +2 -40
- package/dist/tui.d.ts +533 -0
- package/dist/tui.d.ts.map +1 -0
- package/dist/tui.js +2004 -0
- package/dist/tui.js.map +1 -0
- package/dist/types-Bx_F8jet.js +39 -0
- package/dist/types-Bx_F8jet.js.map +1 -0
- package/dist/types.d.ts +4 -55
- package/dist/types.js +4 -28
- package/package.json +38 -4
- package/dist/agent-BAHrGtqu.d.ts +0 -2425
- package/dist/chunk-4ILGBQ23.js +0 -803
- package/dist/chunk-4LPBN547.js +0 -3540
- package/dist/chunk-64LLNY7F.js +0 -28
- package/dist/chunk-6STZTA4N.js +0 -830
- package/dist/chunk-7GQ7P6DM.js +0 -566
- package/dist/chunk-IC7FT4OD.js +0 -37
- package/dist/chunk-JCOB6IYO.js +0 -22
- package/dist/chunk-JH6IAAFA.js +0 -28
- package/dist/chunk-LNN5UTS2.js +0 -97
- package/dist/chunk-PMCQOMV4.js +0 -490
- package/dist/chunk-UD25QF3H.js +0 -304
- package/dist/chunk-W57VY6DJ.js +0 -834
- package/dist/sandbox-D7v6Wy62.d.ts +0 -28
- package/dist/skills-use-DwZrNmcw.d.ts +0 -80
- package/dist/types-Bai5rKpa.d.ts +0 -89
- package/dist/validation-Pm--dQEU.d.ts +0 -185
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { It as TurnUsage, _ as ToolDef, c as SkillActivationState, ft as AgentStats, g as ToolContext, n as AgentHooks, pt as ChildRunStats, r as AgentOptions, y as SkillConfig } from "./agent-BoV5Twdl.js";
|
|
2
|
+
import { Hookable } from "hookable";
|
|
3
|
+
|
|
4
|
+
//#region src/presets/basic.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Core tools available in every basic preset (without spawn).
|
|
7
|
+
*
|
|
8
|
+
* `edit` and `multi_edit` ship in the basic set because surgical edits are the
|
|
9
|
+
* default modality for production agents — `write_file` is for full overwrites.
|
|
10
|
+
* `glob` and `grep` are exported but opt-in: not every agent needs codebase
|
|
11
|
+
* search, and shipping them by default would force `tool:gate` work onto
|
|
12
|
+
* consumers that prefer the model to use `shell` + classic Unix tools.
|
|
13
|
+
*/
|
|
14
|
+
declare const basicTools: {
|
|
15
|
+
shell: ToolDef;
|
|
16
|
+
readFile: ToolDef;
|
|
17
|
+
writeFile: ToolDef;
|
|
18
|
+
listFiles: ToolDef;
|
|
19
|
+
edit: ToolDef;
|
|
20
|
+
multiEdit: ToolDef;
|
|
21
|
+
};
|
|
22
|
+
declare const _default: Preset;
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/presets/index.d.ts
|
|
25
|
+
/**
|
|
26
|
+
* A preset is a reusable slice of `AgentOptions` — spread it into `createAgent()`
|
|
27
|
+
* to configure tools, a default system prompt, aliases, and behavior defaults.
|
|
28
|
+
*
|
|
29
|
+
* `provider`, `execution`, `session`, and internal fields are excluded so presets
|
|
30
|
+
* remain shareable and composable.
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { basic } from 'zidane/presets'
|
|
34
|
+
* createAgent({ ...basic, provider })
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
type Preset = Omit<Partial<AgentOptions>, 'provider' | 'execution' | 'session' | 'mcpConnector'>;
|
|
38
|
+
/**
|
|
39
|
+
* Identity helper for type inference when defining a preset.
|
|
40
|
+
*/
|
|
41
|
+
declare function definePreset(config: Preset): Preset;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/stats.d.ts
|
|
44
|
+
/**
|
|
45
|
+
* Per-model usage rollup produced by {@link statsByModel}.
|
|
46
|
+
*
|
|
47
|
+
* `turns` counts the number of `TurnUsage` entries attributed to the model
|
|
48
|
+
* across the whole tree (parent loop + every recursively-spawned child).
|
|
49
|
+
* Cache and cost numbers are summed from the same set of turns.
|
|
50
|
+
*/
|
|
51
|
+
interface ModelUsage {
|
|
52
|
+
input: number;
|
|
53
|
+
output: number;
|
|
54
|
+
cost: number;
|
|
55
|
+
cacheRead: number;
|
|
56
|
+
cacheCreation: number;
|
|
57
|
+
turns: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Depth-first walk over the stats tree, returning every `TurnUsage` entry
|
|
61
|
+
* — parent loop first, then each child subtree in completion order.
|
|
62
|
+
*
|
|
63
|
+
* Closes the cache-token aggregation gap: `TurnUsage.cacheRead` /
|
|
64
|
+
* `cacheCreation` live only on per-turn entries, and the top-level
|
|
65
|
+
* `AgentStats` deliberately doesn't carry cumulative forms (one source of
|
|
66
|
+
* truth, no risk of drift). Anything that needs a tree-wide sum walks
|
|
67
|
+
* through this.
|
|
68
|
+
*/
|
|
69
|
+
declare function flattenTurns(stats: AgentStats): TurnUsage[];
|
|
70
|
+
/**
|
|
71
|
+
* Group cumulative usage by `TurnUsage.modelId`. Each entry sums the input,
|
|
72
|
+
* output, cache, cost, and turn-count across every turn the tree attributed
|
|
73
|
+
* to that model — naturally handling cross-model runs (vision-fallback,
|
|
74
|
+
* model-shifted subagents, mixed-provider workflows).
|
|
75
|
+
*
|
|
76
|
+
* Turns missing `modelId` (mock providers, providers that don't echo a model
|
|
77
|
+
* id) are bucketed under the literal string `'(unknown)'`.
|
|
78
|
+
*/
|
|
79
|
+
declare function statsByModel(stats: AgentStats): Map<string, ModelUsage>;
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/tools/edit.d.ts
|
|
82
|
+
/**
|
|
83
|
+
* Surgical edit — replace `old_string` with `new_string` in a single file.
|
|
84
|
+
*
|
|
85
|
+
* Mirrors Claude Code's `Edit` semantics so models post-trained on Anthropic's
|
|
86
|
+
* tool surface need no relearning. Fails clearly when `old_string` isn't unique
|
|
87
|
+
* (unless `replace_all: true`) and when not found, with a nearest-match preview
|
|
88
|
+
* so the model can recover without a separate `read_file` round-trip.
|
|
89
|
+
*/
|
|
90
|
+
declare const edit: ToolDef;
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/tools/glob.d.ts
|
|
93
|
+
declare const glob: ToolDef;
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/tools/grep.d.ts
|
|
96
|
+
declare const grep: ToolDef;
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/tools/interaction.d.ts
|
|
99
|
+
interface InteractionToolOptions {
|
|
100
|
+
/** JSON Schema for the request payload the model sends */
|
|
101
|
+
schema: Record<string, unknown>;
|
|
102
|
+
/** Tool name (default: 'interaction') */
|
|
103
|
+
name?: string;
|
|
104
|
+
/** Tool description shown to the model */
|
|
105
|
+
description?: string;
|
|
106
|
+
/** Called when the model invokes this tool. Receives the validated payload and tool context, returns data for the model. */
|
|
107
|
+
onRequest: (payload: Record<string, unknown>, ctx: ToolContext) => Promise<Record<string, unknown> | string>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Create an interaction tool that lets the agent request structured input.
|
|
111
|
+
*
|
|
112
|
+
* The model calls this tool with a payload matching the schema.
|
|
113
|
+
* `onRequest` is called with the payload and should return the response
|
|
114
|
+
* (string or object) that gets sent back to the model as the tool result.
|
|
115
|
+
*/
|
|
116
|
+
declare function createInteractionTool(options: InteractionToolOptions): ToolDef;
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/tools/list-files.d.ts
|
|
119
|
+
declare const listFiles: ToolDef;
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/tools/multi-edit.d.ts
|
|
122
|
+
declare const multiEdit: ToolDef;
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/tools/read-file.d.ts
|
|
125
|
+
declare const readFile: ToolDef;
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/tools/shell.d.ts
|
|
128
|
+
declare const shell: ToolDef;
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/tools/skills-read.d.ts
|
|
131
|
+
interface SkillsReadToolOptions {
|
|
132
|
+
catalog: readonly SkillConfig[];
|
|
133
|
+
state: SkillActivationState;
|
|
134
|
+
}
|
|
135
|
+
declare function createSkillsReadTool(options: SkillsReadToolOptions): ToolDef;
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/tools/skills-run-script.d.ts
|
|
138
|
+
interface SkillsRunScriptToolOptions {
|
|
139
|
+
catalog: readonly SkillConfig[];
|
|
140
|
+
state: SkillActivationState;
|
|
141
|
+
/** Script timeout in milliseconds. Default 60000. */
|
|
142
|
+
scriptTimeoutMs?: number;
|
|
143
|
+
}
|
|
144
|
+
declare function createSkillsRunScriptTool(options: SkillsRunScriptToolOptions): ToolDef;
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/tools/skills-use.d.ts
|
|
147
|
+
interface SkillsUseToolOptions {
|
|
148
|
+
/** Resolved skills catalog for this run. */
|
|
149
|
+
catalog: readonly SkillConfig[];
|
|
150
|
+
/** Per-agent activation state the tool mutates. */
|
|
151
|
+
state: SkillActivationState;
|
|
152
|
+
/** Agent hooks — used to fire `skills:activate` on first activation. */
|
|
153
|
+
hooks: Hookable<AgentHooks>;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Factory for `skills_use`. Auto-injected into the agent's tool set by the
|
|
157
|
+
* agent runtime when a non-empty skills catalog is available (unless
|
|
158
|
+
* `SkillsConfig.tool === false`).
|
|
159
|
+
*
|
|
160
|
+
* The tool schema's `name` property is `enum`-constrained to the resolved
|
|
161
|
+
* catalog so the LLM cannot hallucinate a skill that doesn't exist.
|
|
162
|
+
*/
|
|
163
|
+
declare function createSkillsUseTool(options: SkillsUseToolOptions): ToolDef;
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/tools/spawn.d.ts
|
|
166
|
+
interface ChildAgent {
|
|
167
|
+
id: string;
|
|
168
|
+
task: string;
|
|
169
|
+
startedAt: number;
|
|
170
|
+
/** Subagent depth — 1 for a direct child of a top-level agent. */
|
|
171
|
+
depth: number;
|
|
172
|
+
}
|
|
173
|
+
interface SpawnToolState {
|
|
174
|
+
/** Currently running children. */
|
|
175
|
+
readonly children: ReadonlyMap<string, ChildAgent>;
|
|
176
|
+
/**
|
|
177
|
+
* Cumulative stats across every completed direct child of this spawn-tool
|
|
178
|
+
* instance (returns a copy). Each child's contribution is the cumulative
|
|
179
|
+
* `AgentStats` returned by its `agent.run()` — so
|
|
180
|
+
* `totalIn`/`totalOut`/`totalCacheRead`/`totalCacheCreation` cover the
|
|
181
|
+
* entire subtree (children + grandchildren + …), while `turns` and
|
|
182
|
+
* `elapsed` stay parent-loop-only per child and are summed across direct
|
|
183
|
+
* children. `elapsed` over-counts when children ran in parallel.
|
|
184
|
+
*
|
|
185
|
+
* Lives across multiple parent runs that share this instance.
|
|
186
|
+
*/
|
|
187
|
+
readonly totalChildStats: Readonly<AgentStats>;
|
|
188
|
+
}
|
|
189
|
+
interface SpawnToolOptions {
|
|
190
|
+
/** Maximum concurrent sub-agents (default: 3). */
|
|
191
|
+
maxConcurrent?: number;
|
|
192
|
+
/**
|
|
193
|
+
* Maximum subagent depth. 0 disables spawning entirely; 1 allows top-level
|
|
194
|
+
* spawns but forbids grandchildren; 3 (default) allows three levels of
|
|
195
|
+
* recursion — enough for most orchestration patterns, a sharp ceiling
|
|
196
|
+
* against runaway loops.
|
|
197
|
+
*/
|
|
198
|
+
maxDepth?: number;
|
|
199
|
+
/** Child model override. */
|
|
200
|
+
model?: string;
|
|
201
|
+
/** Child system prompt override. Per-spawn `input.system` takes precedence. */
|
|
202
|
+
system?: string;
|
|
203
|
+
/** Child thinking level. */
|
|
204
|
+
thinking?: 'off' | 'minimal' | 'low' | 'medium' | 'high';
|
|
205
|
+
/** Preset override for children. Shallow-merged over the parent's preset (parent fields still win for anything left unset). */
|
|
206
|
+
preset?: Preset;
|
|
207
|
+
/**
|
|
208
|
+
* Per-child timeout, in milliseconds. When the child exceeds it the spawn
|
|
209
|
+
* tool returns a timeout marker, fires `spawn:error`, and destroys the
|
|
210
|
+
* child agent. Default: none.
|
|
211
|
+
*/
|
|
212
|
+
timeoutMs?: number;
|
|
213
|
+
/**
|
|
214
|
+
* When `true` and the parent has a session, the child reuses the parent's
|
|
215
|
+
* session — child turns are appended with the child's own `runId`, and the
|
|
216
|
+
* resulting `SessionRun` carries `parentRunId` so the tree is
|
|
217
|
+
* reconstructible. Default: `false` (child is in-memory only).
|
|
218
|
+
*/
|
|
219
|
+
persist?: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Forward a curated subset of child hook events (`stream:*`, `tool:*`,
|
|
222
|
+
* `turn:after`) onto the parent's hook bus as `child:*` events. Default:
|
|
223
|
+
* `true`. Grandchildren bubble through their child transparently.
|
|
224
|
+
*/
|
|
225
|
+
forwardHooks?: boolean;
|
|
226
|
+
/** Called when a child agent starts. */
|
|
227
|
+
onSpawn?: (child: ChildAgent) => void;
|
|
228
|
+
/** Called when a child agent completes (success, abort, timeout, or error). */
|
|
229
|
+
onComplete?: (child: ChildAgent, stats: AgentStats, status: NonNullable<ChildRunStats['status']>) => void;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Create a configured spawn tool.
|
|
233
|
+
*
|
|
234
|
+
* State (`children`, `totalChildStats`, counters, active count) is scoped to
|
|
235
|
+
* the returned instance. Multiple parent agents using the same instance will
|
|
236
|
+
* share counters + stats + concurrency slots — call `createSpawnTool()` per
|
|
237
|
+
* agent (or use the stateless default `spawn`) to keep them isolated.
|
|
238
|
+
*/
|
|
239
|
+
declare function createSpawnTool(options?: SpawnToolOptions): ToolDef & SpawnToolState;
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/tools/tool-search.d.ts
|
|
242
|
+
interface LazyToolEntry {
|
|
243
|
+
/**
|
|
244
|
+
* Wire name (after `toolAliases` rewrite). What the model sees in the
|
|
245
|
+
* catalog, what `tool_search` matches against, and what the provider's
|
|
246
|
+
* tool list will carry once the entry is unlocked.
|
|
247
|
+
*/
|
|
248
|
+
name: string;
|
|
249
|
+
/**
|
|
250
|
+
* Canonical (registry-key) name used for unlock-set membership and for the
|
|
251
|
+
* loop's `ctx.tools[name]` dispatch lookup. Equal to `name` when no alias
|
|
252
|
+
* is configured for this tool.
|
|
253
|
+
*/
|
|
254
|
+
canonicalName: string;
|
|
255
|
+
description: string;
|
|
256
|
+
inputSchema: Record<string, unknown>;
|
|
257
|
+
/** Source MCP server, when applicable. Used for `server`-bulk unlock. */
|
|
258
|
+
server?: string;
|
|
259
|
+
}
|
|
260
|
+
interface ToolSearchToolOptions {
|
|
261
|
+
/**
|
|
262
|
+
* Snapshot of every lazy tool the model can discover. Built once per run by
|
|
263
|
+
* the agent — the tool closes over this array and never mutates it.
|
|
264
|
+
*/
|
|
265
|
+
catalog: readonly LazyToolEntry[];
|
|
266
|
+
/**
|
|
267
|
+
* Mutable per-run set of unlocked **canonical** tool names. The tool adds
|
|
268
|
+
* matches in place; the loop reads the set when rebuilding the wire-level
|
|
269
|
+
* tool list. Keyed by canonical (not wire) so dispatch lookups stay
|
|
270
|
+
* alias-stable.
|
|
271
|
+
*/
|
|
272
|
+
unlocked: Set<string>;
|
|
273
|
+
/** Default cap on returned matches when the model omits `limit`. */
|
|
274
|
+
defaultLimit?: number;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Factory for `tool_search`. Auto-injected by the agent when
|
|
278
|
+
* `behavior.toolDisclosure === 'lazy'` and at least one MCP tool is in the
|
|
279
|
+
* registry. Opt out via `behavior.toolSearch.tool === false`.
|
|
280
|
+
*/
|
|
281
|
+
declare function createToolSearchTool(options: ToolSearchToolOptions): ToolDef;
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/tools/validation.d.ts
|
|
284
|
+
/**
|
|
285
|
+
* Tool argument validation against JSON Schema-style inputSchema.
|
|
286
|
+
*
|
|
287
|
+
* Two passes:
|
|
288
|
+
* 1. Required-field presence. Missing or null/undefined required fields fail.
|
|
289
|
+
* 2. Top-level type checks with **best-effort coercion**. Small/OSS models
|
|
290
|
+
* routinely send `"true"` for a `boolean` field or `"42"` for a `number`,
|
|
291
|
+
* and rejecting outright forces a confusing retry. Instead, we auto-heal
|
|
292
|
+
* coerce when the conversion is unambiguous, fail only when the value
|
|
293
|
+
* cannot be reasonably normalized to any of the declared types.
|
|
294
|
+
*
|
|
295
|
+
* Nested validation is intentionally out of scope — keep it cheap and let the
|
|
296
|
+
* tool's `execute` body assert deeper invariants.
|
|
297
|
+
*/
|
|
298
|
+
interface ValidationResult {
|
|
299
|
+
valid: boolean;
|
|
300
|
+
/** Human-readable reason. Present on failure only. */
|
|
301
|
+
error?: string;
|
|
302
|
+
/**
|
|
303
|
+
* Possibly-coerced input. Present iff `valid: true`. Tools should call
|
|
304
|
+
* `execute(coercedInput, ctx)` so auto-healed values reach the tool body.
|
|
305
|
+
* When no coercion was applied, this is reference-equal to the input.
|
|
306
|
+
*/
|
|
307
|
+
coercedInput?: Record<string, unknown>;
|
|
308
|
+
/**
|
|
309
|
+
* Names of fields whose values were coerced. Empty when nothing changed.
|
|
310
|
+
* Useful for telemetry (`validation:reject` on failure already carries the
|
|
311
|
+
* reason; this is the success-path equivalent).
|
|
312
|
+
*/
|
|
313
|
+
coercions?: readonly string[];
|
|
314
|
+
}
|
|
315
|
+
declare function validateToolArgs(input: Record<string, unknown>, schema: Record<string, unknown>): ValidationResult;
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/tools/write-file.d.ts
|
|
318
|
+
/**
|
|
319
|
+
* Write a file, with an idempotency signal when the content is unchanged.
|
|
320
|
+
*
|
|
321
|
+
* Three return shapes — chosen so the model can recognize a no-op without a
|
|
322
|
+
* separate read:
|
|
323
|
+
* - `Created path (N bytes)` — file did not exist
|
|
324
|
+
* - `Updated path (N bytes)` — content differed from on-disk
|
|
325
|
+
* - `No change needed: path already at target state (N bytes)` — equal
|
|
326
|
+
*
|
|
327
|
+
* Race window: in non-process execution contexts (docker, sandbox) shared by
|
|
328
|
+
* multiple agents, another writer can mutate the file between our read and
|
|
329
|
+
* our write. Local process context is single-writer per agent so the race is
|
|
330
|
+
* a non-issue there. Documented rather than locked because the cost of
|
|
331
|
+
* cross-context locking outweighs the cost of a stale "No change" message.
|
|
332
|
+
*/
|
|
333
|
+
declare const writeFile: ToolDef;
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region src/tracing.d.ts
|
|
336
|
+
/** Minimal span shape — any tracer that provides these two methods is compatible. */
|
|
337
|
+
interface Span {
|
|
338
|
+
/** Close the span. Called exactly once per span. */
|
|
339
|
+
end: () => void;
|
|
340
|
+
/** Optional: attach additional attributes after the span is started (ignored if unsupported). */
|
|
341
|
+
setAttributes?: (attrs: Record<string, unknown>) => void;
|
|
342
|
+
}
|
|
343
|
+
/** Function that opens a span. Caller-provided so we stay tracer-agnostic. */
|
|
344
|
+
type StartSpan = (name: string, attrs?: Record<string, unknown>) => Span;
|
|
345
|
+
interface TracingHooksOptions {
|
|
346
|
+
/** Tracer seam. Receives a span name + attributes; must return a `Span`. */
|
|
347
|
+
startSpan: StartSpan;
|
|
348
|
+
/**
|
|
349
|
+
* Optional attribute namespace. Prepended to every span name (e.g. `"agent"` →
|
|
350
|
+
* span names like `agent/turn:0`, `agent/tool:Bash`).
|
|
351
|
+
*/
|
|
352
|
+
namespace?: string;
|
|
353
|
+
}
|
|
354
|
+
/** Value returned by {@link createTracingHooks} — install entrypoint. */
|
|
355
|
+
interface TracingHookSet {
|
|
356
|
+
/**
|
|
357
|
+
* Attach every hook handler to the given agent hooks instance.
|
|
358
|
+
*
|
|
359
|
+
* @returns an `uninstall` function that detaches every handler and closes any
|
|
360
|
+
* still-open spans. Safe to call multiple times.
|
|
361
|
+
*/
|
|
362
|
+
install: (hooks: Hookable<AgentHooks>) => () => void;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Build a set of tracing hook handlers that can be installed on an agent.
|
|
366
|
+
*
|
|
367
|
+
* @example Sentry
|
|
368
|
+
* ```ts
|
|
369
|
+
* const tracing = createTracingHooks({
|
|
370
|
+
* startSpan: (name, attrs) => Sentry.startInactiveSpan({ name, attributes: attrs }),
|
|
371
|
+
* })
|
|
372
|
+
* const uninstall = tracing.install(agent.hooks)
|
|
373
|
+
* try { await agent.run({ prompt }) }
|
|
374
|
+
* finally { uninstall() }
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
declare function createTracingHooks(options: TracingHooksOptions): TracingHookSet;
|
|
378
|
+
//#endregion
|
|
379
|
+
//#region src/zod.d.ts
|
|
380
|
+
/**
|
|
381
|
+
* Zod v4 integration helper.
|
|
382
|
+
*
|
|
383
|
+
* Normalizes the output of z.toJsonSchema() for use as ToolSpec.inputSchema.
|
|
384
|
+
* Zod is an optional peer dependency — consumers call z.toJsonSchema() themselves.
|
|
385
|
+
*
|
|
386
|
+
* Usage:
|
|
387
|
+
* import { z } from 'zod'
|
|
388
|
+
* import { zodToJsonSchema } from 'zidane'
|
|
389
|
+
* const schema = zodToJsonSchema(z.toJsonSchema(z.object({ name: z.string() })))
|
|
390
|
+
*/
|
|
391
|
+
/**
|
|
392
|
+
* Normalize a JSON Schema (e.g. from zod v4's z.toJsonSchema()) for use
|
|
393
|
+
* as a ToolSpec.inputSchema.
|
|
394
|
+
*
|
|
395
|
+
* Strips the $schema key that some providers reject.
|
|
396
|
+
*/
|
|
397
|
+
declare function zodToJsonSchema(jsonSchema: Record<string, unknown>): Record<string, unknown>;
|
|
398
|
+
//#endregion
|
|
399
|
+
export { edit as A, readFile as C, createInteractionTool as D, InteractionToolOptions as E, definePreset as F, _default as I, basicTools as L, flattenTurns as M, statsByModel as N, grep as O, Preset as P, shell as S, listFiles as T, createSkillsUseTool as _, createTracingHooks as a, SkillsReadToolOptions as b, validateToolArgs as c, createToolSearchTool as d, ChildAgent as f, SkillsUseToolOptions as g, createSpawnTool as h, TracingHooksOptions as i, ModelUsage as j, glob as k, LazyToolEntry as l, SpawnToolState as m, Span as n, writeFile as o, SpawnToolOptions as p, TracingHookSet as r, ValidationResult as s, zodToJsonSchema as t, ToolSearchToolOptions as u, SkillsRunScriptToolOptions as v, multiEdit as w, createSkillsReadTool as x, createSkillsRunScriptTool as y };
|
|
400
|
+
//# sourceMappingURL=index-28otmfLX.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-28otmfLX.d.ts","names":[],"sources":["../src/presets/basic.ts","../src/presets/index.ts","../src/stats.ts","../src/tools/edit.ts","../src/tools/glob.ts","../src/tools/grep.ts","../src/tools/interaction.ts","../src/tools/list-files.ts","../src/tools/multi-edit.ts","../src/tools/read-file.ts","../src/tools/shell.ts","../src/tools/skills-read.ts","../src/tools/skills-run-script.ts","../src/tools/skills-use.ts","../src/tools/spawn.ts","../src/tools/tool-search.ts","../src/tools/validation.ts","../src/tools/write-file.ts","../src/tracing.ts","../src/zod.ts"],"mappings":";;;;;;;;;AAaA;;;;cAAa,UAAA;SAAuE,OAAA;;;;;;;cAAA,QAAA;;;;;;;AAApF;;;;;;;;KCCY,MAAA,GAAS,IAAA,CAAK,OAAA,CAAQ,YAAA;;;;iBAKlB,YAAA,CAAa,MAAA,EAAQ,MAAA,GAAS,MAAA;;;;;;;;;;UCF7B,UAAA;EACf,KAAA;EACA,MAAA;EACA,IAAA;EACA,SAAA;EACA,aAAA;EACA,KAAA;AAAA;;;;;;;;AFVkF;;;iBEuBpE,YAAA,CAAa,KAAA,EAAO,UAAA,GAAa,SAAA;;;;;ADtBjD;;;;;iBC8CgB,YAAA,CAAa,KAAA,EAAO,UAAA,GAAa,GAAA,SAAY,UAAA;;;;;;;AF/C7D;;;;cGCa,IAAA,EAAM,OAAA;;;cC8CN,IAAA,EAAM,OAAA;;;cClBN,IAAA,EAAM,OAAA;;;UCtBF,sBAAA;;EAEf,MAAA,EAAQ,MAAA;;EAER,IAAA;;EAEA,WAAA;;EAEA,SAAA,GAAY,OAAA,EAAS,MAAA,mBAAyB,GAAA,EAAK,W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
/**
|
|
3
|
+
* Execution context types.
|
|
4
|
+
*
|
|
5
|
+
* An execution context defines *where* and *how* an agent's tools run.
|
|
6
|
+
* The agent loop and tools interact through this interface without knowing
|
|
7
|
+
* whether they're running in-process, in a Docker container, or in a
|
|
8
|
+
* remote sandbox.
|
|
9
|
+
*/
|
|
10
|
+
interface ContextCapabilities {
|
|
11
|
+
/** Can execute shell commands */
|
|
12
|
+
shell: boolean;
|
|
13
|
+
/** Can read/write files in a workspace */
|
|
14
|
+
filesystem: boolean;
|
|
15
|
+
/** Can make outbound network requests */
|
|
16
|
+
network: boolean;
|
|
17
|
+
/** Has GPU access */
|
|
18
|
+
gpu: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** Opaque handle to a running execution context instance */
|
|
21
|
+
interface ExecutionHandle {
|
|
22
|
+
id: string;
|
|
23
|
+
type: ContextType;
|
|
24
|
+
/** Working directory within the context */
|
|
25
|
+
cwd: string;
|
|
26
|
+
}
|
|
27
|
+
interface ExecResult {
|
|
28
|
+
stdout: string;
|
|
29
|
+
stderr: string;
|
|
30
|
+
exitCode: number;
|
|
31
|
+
}
|
|
32
|
+
interface SpawnConfig {
|
|
33
|
+
/** Working directory (created if it doesn't exist) */
|
|
34
|
+
cwd?: string;
|
|
35
|
+
/** Environment variables */
|
|
36
|
+
env?: Record<string, string>;
|
|
37
|
+
/** Docker image (only for 'docker' context) */
|
|
38
|
+
image?: string;
|
|
39
|
+
/** Resource limits */
|
|
40
|
+
limits?: {
|
|
41
|
+
/** Memory limit in MB */memory?: number; /** CPU limit (e.g. '1.0' = 1 core) */
|
|
42
|
+
cpu?: string; /** Timeout in seconds for the entire context lifetime */
|
|
43
|
+
timeout?: number;
|
|
44
|
+
};
|
|
45
|
+
/** Sandbox provider config (only for 'sandbox' context) */
|
|
46
|
+
sandbox?: {
|
|
47
|
+
provider: string;
|
|
48
|
+
apiKey?: string;
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
type ContextType = 'process' | 'docker' | 'sandbox';
|
|
53
|
+
interface ExecutionContext {
|
|
54
|
+
/** Context type identifier */
|
|
55
|
+
readonly type: ContextType;
|
|
56
|
+
/** What this context supports */
|
|
57
|
+
readonly capabilities: ContextCapabilities;
|
|
58
|
+
/** Spawn a new execution environment */
|
|
59
|
+
spawn: (config?: SpawnConfig) => Promise<ExecutionHandle>;
|
|
60
|
+
/** Execute a shell command in the context */
|
|
61
|
+
exec: (handle: ExecutionHandle, command: string, options?: {
|
|
62
|
+
cwd?: string;
|
|
63
|
+
env?: Record<string, string>;
|
|
64
|
+
timeout?: number;
|
|
65
|
+
}) => Promise<ExecResult>;
|
|
66
|
+
/** Read a file from the context's filesystem */
|
|
67
|
+
readFile: (handle: ExecutionHandle, path: string) => Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Read a file from the context's filesystem as raw bytes.
|
|
70
|
+
*
|
|
71
|
+
* Used by `read_file` to dispatch image / binary files into the multimodal
|
|
72
|
+
* `ToolResultContent[]` route. Optional — when not implemented, the tool
|
|
73
|
+
* falls back to `base64 < path` via the `exec` seam, which works in any
|
|
74
|
+
* shell-capable context. Implementations that already have a native
|
|
75
|
+
* binary read (in-process `fs.readFile` without encoding, container API,
|
|
76
|
+
* sandbox SDK) should override for the latency win.
|
|
77
|
+
*/
|
|
78
|
+
readFileBinary?: (handle: ExecutionHandle, path: string) => Promise<Uint8Array>;
|
|
79
|
+
/** Write a file to the context's filesystem */
|
|
80
|
+
writeFile: (handle: ExecutionHandle, path: string, content: string) => Promise<void>;
|
|
81
|
+
/** List files in a directory */
|
|
82
|
+
listFiles: (handle: ExecutionHandle, path: string) => Promise<string[]>;
|
|
83
|
+
/** Destroy the execution environment and clean up resources */
|
|
84
|
+
destroy: (handle: ExecutionHandle) => Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/contexts/docker.d.ts
|
|
88
|
+
declare function createDockerContext(config?: SpawnConfig): ExecutionContext;
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/contexts/process.d.ts
|
|
91
|
+
declare function createProcessContext(config?: SpawnConfig): ExecutionContext;
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/contexts/sandbox.d.ts
|
|
94
|
+
interface SandboxProvider {
|
|
95
|
+
name: string;
|
|
96
|
+
spawn: (config: SpawnConfig) => Promise<{
|
|
97
|
+
id: string;
|
|
98
|
+
cwd: string;
|
|
99
|
+
}>;
|
|
100
|
+
exec: (sandboxId: string, command: string, options?: {
|
|
101
|
+
cwd?: string;
|
|
102
|
+
env?: Record<string, string>;
|
|
103
|
+
timeout?: number;
|
|
104
|
+
}) => Promise<ExecResult>;
|
|
105
|
+
readFile: (sandboxId: string, path: string) => Promise<string>;
|
|
106
|
+
writeFile: (sandboxId: string, path: string, content: string) => Promise<void>;
|
|
107
|
+
listFiles: (sandboxId: string, path: string) => Promise<string[]>;
|
|
108
|
+
destroy: (sandboxId: string) => Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
declare function createSandboxContext(provider: SandboxProvider): ExecutionContext;
|
|
111
|
+
//#endregion
|
|
112
|
+
export { ContextCapabilities as a, ExecutionContext as c, createDockerContext as i, ExecutionHandle as l, createSandboxContext as n, ContextType as o, createProcessContext as r, ExecResult as s, SandboxProvider as t, SpawnConfig as u };
|
|
113
|
+
//# sourceMappingURL=index-BfSdALzk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BfSdALzk.d.ts","names":[],"sources":["../src/contexts/types.ts","../src/contexts/docker.ts","../src/contexts/process.ts","../src/contexts/sandbox.ts"],"mappings":";;AAaA;;;;;;;UAAiB,mBAAA;EAQZ;EANH,KAAA;EAce;EAZf,UAAA;;EAEA,OAAA;EAWA;EATA,GAAA;AAAA;;UAQe,eAAA;EACf,EAAA;EACA,IAAA,EAAM,WAAA;EASmB;EAPzB,GAAA;AAAA;AAAA,UAOe,UAAA;EACf,MAAA;EACA,MAAA;EACA,QAAA;A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