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
package/dist/skills.d.ts CHANGED
@@ -1,322 +1,3 @@
1
- import { A as AgentHooks, V as SkillActivationState, X as SkillConfig, _ as SkillSource, Y as SkillDiagnostic, $ as SkillsConfig } from './agent-BAHrGtqu.js';
2
- export { a as ActivationVia, b as ActiveSkill, D as DeactivationReason, W as SkillActivationStateOptions, Z as SkillResource, at as createSkillActivationState } from './agent-BAHrGtqu.js';
3
- import { Hookable } from 'hookable';
4
- import { a as ExecutionContext, c as ExecutionHandle } from './types-Bai5rKpa.js';
5
- import '@modelcontextprotocol/sdk/client/index.js';
6
-
7
- /**
8
- * `allowed-tools` enforcement middleware.
9
- *
10
- * Installed by the agent on `tool:gate` and `mcp:tool:gate`. Computes the
11
- * union of `allowedTools` patterns across currently-active skills; blocks any
12
- * tool call whose `displayName` is not in that union. The three injected
13
- * skills tools (`skills_use` / `skills_read` / `skills_run_script`) are
14
- * implicitly allowed so a skill declaring an allow-list cannot lock out the
15
- * scaffolding that lets it run at all.
16
- *
17
- * The match target is `displayName` (wire / LLM-facing name), not the
18
- * canonical name, because skill authors write allow-list entries to match
19
- * what the model sees.
20
- */
21
-
22
- /** Tools that are always allowed regardless of the active skills' allow-list. */
23
- declare const IMPLICITLY_ALLOWED_SKILL_TOOLS: readonly string[];
24
- /**
25
- * Register `tool:gate` / `mcp:tool:gate` handlers that enforce the union of
26
- * `allowedTools` across active skills.
27
- *
28
- * No-op when no active skill declares an allow-list (permissive default —
29
- * matches the spec's "experimental" note for `allowed-tools`).
30
- *
31
- * Returns an `uninstall` fn. The agent calls this at run end to detach the
32
- * handlers and prevent cross-run hook leaks.
33
- */
34
- declare function installAllowedToolsGate(hooks: Hookable<AgentHooks>, state: SkillActivationState): () => void;
35
-
36
- /**
37
- * Skill catalog generation.
38
- *
39
- * Builds the system prompt section that discloses available skills to the
40
- * agent — tier 1 of progressive disclosure per the Agent Skills spec.
41
- *
42
- * The catalog's behavioral prose branches on which activation mechanism is
43
- * active for the run:
44
- *
45
- * - When the `skills_use` tool is auto-injected (the default for a non-empty
46
- * catalog), the prose tells the model to call `skills_use` with the skill's
47
- * name. The agent returns a structured `<skill_content>` block.
48
- * - When the skills tool is opted out (`SkillsConfig.tool: false`), the prose
49
- * falls back to the file-read pattern — the model reads `SKILL.md` itself
50
- * via its file-read tool.
51
- */
52
-
53
- interface BuildCatalogOptions {
54
- /**
55
- * When true (the default), the prose instructs the model to call
56
- * `skills_use`. Set to false when `SkillsConfig.tool === false` so the
57
- * system prompt matches the active activation mechanism.
58
- */
59
- skillsToolRegistered?: boolean;
60
- /**
61
- * Name of the tool the model should use to read `SKILL.md` files when
62
- * `skillsToolRegistered` is false. Defaults to `'read_file'`.
63
- */
64
- readToolName?: string;
65
- }
66
- /**
67
- * Build the skill catalog XML and behavioral instructions for the system prompt.
68
- */
69
- declare function buildCatalog(skills: SkillConfig[], options?: BuildCatalogOptions): string;
70
-
71
- /**
72
- * Skill discovery and parsing.
73
- *
74
- * Scans filesystem directories for SKILL.md files following the
75
- * Agent Skills specification (agentskills.io/specification).
76
- *
77
- * Parsing is intentionally **lenient** — per the spec's client-implementation
78
- * guide: warn, don't block. Diagnostics are attached to the returned
79
- * SkillConfig for host UIs to surface; only unrecoverable errors (missing
80
- * description, unparseable YAML) skip the skill entirely.
81
- */
82
-
83
- interface ParsedSkillFile {
84
- frontmatter: Record<string, unknown>;
85
- body: string;
86
- diagnostics: SkillDiagnostic[];
87
- }
88
- /**
89
- * Parse a SKILL.md file into frontmatter + body.
90
- *
91
- * Uses a simple regex-based YAML extractor that handles:
92
- * - Flat key: value pairs
93
- * - Quoted values
94
- * - One-level nested maps (for `metadata:`)
95
- * - Lenient recovery from unquoted-colon values (e.g.
96
- * `description: Use when: the user asks …`) via a quote-wrap retry.
97
- */
98
- declare function parseFrontmatter(content: string): ParsedSkillFile;
99
- interface ParseSkillOptions {
100
- /** Source tag to attach to the returned SkillConfig. */
101
- source?: SkillSource;
102
- }
103
- /**
104
- * Parse a SKILL.md file into a SkillConfig (lenient).
105
- *
106
- * Returns `null` only when the skill is fundamentally unusable:
107
- * - The file is missing
108
- * - The description is absent (required by spec for disclosure)
109
- *
110
- * All other issues are surfaced as `SkillConfig.diagnostics` with severity
111
- * `warning`. Deprecated top-level fields (`paths`, `model`, `thinking`) are
112
- * auto-migrated into `metadata['zidane.*']`.
113
- */
114
- declare function parseSkillFile(filePath: string, options?: ParseSkillOptions): Promise<SkillConfig | null>;
115
- /** A scan path paired with the source tag that should be attached to any skills found in it. */
116
- interface SourcedScanPath {
117
- path: string;
118
- source: SkillSource;
119
- }
120
- /**
121
- * Return the default scan paths tagged by source. Project-scope paths come
122
- * first; their skills therefore win on name collisions against user-scope
123
- * skills (first-found wins in discovery).
124
- */
125
- declare function getDefaultScanPaths(): SourcedScanPath[];
126
- /**
127
- * Infer a source tag for a user-provided scan path.
128
- * Paths under `$HOME` are treated as 'user'; everything else as 'project'.
129
- */
130
- declare function inferSource(path: string): SkillSource;
131
- /**
132
- * Discover skills from sourced filesystem paths.
133
- * Each path is scanned for subdirectories containing SKILL.md.
134
- * Earlier paths have higher priority (first-found wins on name collision).
135
- */
136
- declare function discoverSkills(paths: SourcedScanPath[]): Promise<SkillConfig[]>;
137
-
138
- /**
139
- * Shell interpolation for skill instructions.
140
- *
141
- * The `!\`command\`` syntax runs shell commands as a preprocessing step
142
- * before skill content is sent to the agent. The command output replaces
143
- * the placeholder — the agent only sees the final result.
144
- *
145
- * Example:
146
- * - PR diff: !\`gh pr diff\`
147
- * → - PR diff: <actual diff output>
148
- */
149
-
150
- /**
151
- * Interpolate shell commands in skill instructions.
152
- *
153
- * Runs each !\`command\` through the execution context and replaces
154
- * the placeholder with the command's stdout. If a command fails,
155
- * the placeholder is replaced with an error message.
156
- *
157
- * @param instructions - Raw skill instructions with potential !\`command\` patterns
158
- * @param execution - The execution context to run commands in
159
- * @param handle - The active execution handle
160
- * @returns Instructions with all !\`command\` patterns replaced by output
161
- */
162
- declare function interpolateShellCommands(instructions: string, execution: ExecutionContext, handle: ExecutionHandle): Promise<string>;
163
-
164
- /**
165
- * Skill resolution — discovers filesystem skills, writes dynamic skills,
166
- * merges everything, and applies filtering.
167
- */
168
-
169
- /**
170
- * Resolved-skills bundle: the materialized list plus a `cleanup` fn that
171
- * removes any temporary directory created for `config.write` skills.
172
- *
173
- * Inline skills must live on disk for the lifetime of the agent (the
174
- * `skills_read` / `skills_run_script` tools resolve relative paths against
175
- * `baseDir`), so cleanup is deferred to `agent.destroy()`. When no temp
176
- * directory was created, `cleanup` is a no-op.
177
- */
178
- interface ResolvedSkillsBundle {
179
- skills: SkillConfig[];
180
- cleanup: () => void;
181
- }
182
- /**
183
- * Resolve all skills from a SkillsConfig:
184
- *
185
- * 1. Materialize `config.write` entries to a temp directory, tagged as `inline`
186
- * 2. Combine with default + user-provided scan paths (project-first, user-next)
187
- * 3. Run lenient discovery
188
- * 4. Apply filters: `exclude`, `enabled` allowlist, optional project-skill trust gate
189
- *
190
- * Returns `{ skills, cleanup }` — call `cleanup()` on agent destroy to remove
191
- * the temp directory created for inline `config.write` skills. The agent
192
- * factory wires this automatically; standalone callers must invoke it
193
- * themselves to avoid leaking OS temp.
194
- */
195
- declare function resolveSkills(config: SkillsConfig): Promise<ResolvedSkillsBundle>;
196
-
197
- /**
198
- * Strict validators for Agent Skills.
199
- *
200
- * Applied on the authoring path (`defineSkill`, `writeSkillToDisk`). Parser-time
201
- * validation is intentionally lenient — see `parseSkillFile` for diagnostic collection.
202
- */
203
-
204
- /**
205
- * A single issue surfaced by skill-authoring validation.
206
- * Distinct from `ValidationResult` in `tools/validation.ts` (tool-input JSON
207
- * schema validation) — different domain, different module.
208
- */
209
- interface SkillValidationIssue {
210
- /** Stable machine-readable code for consumer matching. */
211
- code: string;
212
- /** Human-readable description. */
213
- message: string;
214
- /** Frontmatter field name the issue relates to, when applicable. */
215
- field?: string;
216
- }
217
- interface SkillValidationResult {
218
- valid: boolean;
219
- errors: SkillValidationIssue[];
220
- }
221
- /**
222
- * Validate a skill name per the spec:
223
- * - 1–64 characters
224
- * - Lowercase alphanumeric + hyphens only
225
- * - Must not start or end with a hyphen
226
- * - Must not contain consecutive hyphens
227
- *
228
- * The parent-directory match is validated separately (it requires knowing the
229
- * skill's `location`, which this function does not).
230
- */
231
- declare function validateSkillName(name: string): boolean;
232
- /**
233
- * Strict validation for a skill that is about to be authored / written to disk.
234
- * Rejects anything that would violate the spec. Use the lenient parser path
235
- * (`parseSkillFile`) for loading third-party skills.
236
- */
237
- declare function validateSkillForWrite(skill: SkillConfig): SkillValidationResult;
238
- /**
239
- * Validate that `relPath` stays inside `baseDir` when resolved.
240
- *
241
- * Rejects:
242
- * - Absolute paths (`/etc/passwd`, `C:\…`)
243
- * - Parent traversal (`..` segments that escape baseDir)
244
- * - Null-byte tricks
245
- *
246
- * Returns `{ valid: true, absolutePath }` on success or `{ valid: false, error }`
247
- * with a human-readable reason.
248
- */
249
- declare function validateResourcePath(relPath: string, baseDir: string): {
250
- valid: true;
251
- absolutePath: string;
252
- } | {
253
- valid: false;
254
- error: string;
255
- };
256
- /**
257
- * Parse a single `allowed-tools` entry into its tool name + optional argument pattern.
258
- *
259
- * Examples:
260
- * - `Read` → `{ tool: 'Read' }`
261
- * - `Bash(git:*)` → `{ tool: 'Bash', argPrefix: 'git' }`
262
- */
263
- declare function parseAllowedToolPattern(entry: string): {
264
- tool: string;
265
- argPrefix?: string;
266
- } | null;
267
- /**
268
- * Check whether a tool call (identified by its wire/displayName and argument input)
269
- * matches a skill's allow-list entry.
270
- *
271
- * Matching rules (Zidane's interpretation of the spec's unspecified syntax):
272
- * - Exact match: displayName === pattern (no parens).
273
- * - Prefix match: for `Tool(arg:*)`, displayName === 'Tool' AND **any** string
274
- * value in the input object starts with `arg`. This is intentionally
275
- * permissive: it doesn't depend on a convention about which property carries
276
- * the "command" (schemas vary across tools), and for the common
277
- * `shell({ command: 'git …' })` shape it behaves identically to a "primary
278
- * string" rule.
279
- * - For tools whose inputs carry no string values, the arg-match returns false.
280
- */
281
- declare function matchesAllowedTool(displayName: string, input: Record<string, unknown>, pattern: string): boolean;
282
- /**
283
- * Test whether a tool call is allowed by the union of `allowedTools` across a set
284
- * of active skills. Returns `true` when the union is empty (permissive default)
285
- * OR when any entry matches.
286
- */
287
- declare function isToolAllowedByUnion(displayName: string, input: Record<string, unknown>, union: readonly string[]): boolean;
288
-
289
- /**
290
- * Skill writer — materializes inline SkillConfig objects to disk as proper
291
- * SKILL.md files so they participate fully in the filesystem-based skill system.
292
- *
293
- * Strict-validates each skill before writing (see `validateSkillForWrite`).
294
- */
295
-
296
- /**
297
- * Write a `SkillConfig` to disk as a proper skill directory with SKILL.md.
298
- * Returns the path to the written SKILL.md file.
299
- *
300
- * Throws if the skill fails `validateSkillForWrite` — the authoring path is
301
- * strict on purpose. For loading third-party skills, use `parseSkillFile`
302
- * directly (lenient).
303
- */
304
- declare function writeSkillToDisk(skill: SkillConfig, targetDir: string): string;
305
- /**
306
- * Write multiple `SkillConfig` objects to a target directory.
307
- * Each skill gets its own subdirectory with a SKILL.md file.
308
- * Returns the target directory path (for use as a scan path).
309
- */
310
- declare function writeSkillsToDisk(skills: SkillConfig[], targetDir: string): string;
311
-
312
- /**
313
- * Define an inline skill configuration.
314
- *
315
- * Strict-validates at author-time — throws if the config would be rejected by
316
- * `writeSkillToDisk` or the spec. Source defaults to `'inline'`.
317
- */
318
- declare function defineSkill(config: Omit<SkillConfig, 'source'> & {
319
- source?: SkillConfig['source'];
320
- }): SkillConfig;
321
-
322
- export { IMPLICITLY_ALLOWED_SKILL_TOOLS, SkillActivationState, SkillConfig, SkillDiagnostic, SkillSource, type SkillValidationIssue, type SkillValidationResult, SkillsConfig, type SourcedScanPath, buildCatalog, defineSkill, discoverSkills, getDefaultScanPaths, inferSource, installAllowedToolsGate, interpolateShellCommands, isToolAllowedByUnion, matchesAllowedTool, parseAllowedToolPattern, parseFrontmatter, parseSkillFile, resolveSkills, validateResourcePath, validateSkillForWrite, validateSkillName, writeSkillToDisk, writeSkillsToDisk };
1
+ import { C as SkillsConfig, S as SkillSource, a as ActivationVia, b as SkillDiagnostic, c as SkillActivationState, l as SkillActivationStateOptions, o as ActiveSkill, s as DeactivationReason, u as createSkillActivationState, x as SkillResource, y as SkillConfig } from "./agent-BoV5Twdl.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-DPsd0qwm.js";
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 };
package/dist/skills.js CHANGED
@@ -1,47 +1,24 @@
1
- import {
2
- defineSkill
3
- } from "./chunk-JCOB6IYO.js";
4
- import {
5
- IMPLICITLY_ALLOWED_SKILL_TOOLS,
6
- buildCatalog,
7
- createSkillActivationState,
8
- discoverSkills,
9
- getDefaultScanPaths,
10
- inferSource,
11
- installAllowedToolsGate,
12
- interpolateShellCommands,
13
- isToolAllowedByUnion,
14
- matchesAllowedTool,
15
- parseAllowedToolPattern,
16
- parseFrontmatter,
17
- parseSkillFile,
18
- resolveSkills,
19
- validateResourcePath,
20
- validateSkillForWrite,
21
- validateSkillName,
22
- writeSkillToDisk,
23
- writeSkillsToDisk
24
- } from "./chunk-6STZTA4N.js";
25
- import "./chunk-LNN5UTS2.js";
26
- export {
27
- IMPLICITLY_ALLOWED_SKILL_TOOLS,
28
- buildCatalog,
29
- createSkillActivationState,
30
- defineSkill,
31
- discoverSkills,
32
- getDefaultScanPaths,
33
- inferSource,
34
- installAllowedToolsGate,
35
- interpolateShellCommands,
36
- isToolAllowedByUnion,
37
- matchesAllowedTool,
38
- parseAllowedToolPattern,
39
- parseFrontmatter,
40
- parseSkillFile,
41
- resolveSkills,
42
- validateResourcePath,
43
- validateSkillForWrite,
44
- validateSkillName,
45
- writeSkillToDisk,
46
- writeSkillsToDisk
47
- };
1
+ import { _ as validateResourcePath, a as discoverSkills, b as createSkillActivationState, c as parseFrontmatter, f as IMPLICITLY_ALLOWED_SKILL_TOOLS, g as parseAllowedToolPattern, h as matchesAllowedTool, i as writeSkillsToDisk, l as parseSkillFile, m as isToolAllowedByUnion, n as resolveSkills, o as getDefaultScanPaths, p as installAllowedToolsGate, r as writeSkillToDisk, s as inferSource, t as interpolateShellCommands, u as buildCatalog, v as validateSkillForWrite, y as validateSkillName } from "./interpolate-CukJwP2G.js";
2
+ //#region src/skills/index.ts
3
+ /**
4
+ * Define an inline skill configuration.
5
+ *
6
+ * Strict-validates at author-time — throws if the config would be rejected by
7
+ * `writeSkillToDisk` or the spec. Source defaults to `'inline'`.
8
+ */
9
+ function defineSkill(config) {
10
+ const normalized = {
11
+ ...config,
12
+ source: config.source ?? "inline"
13
+ };
14
+ const result = validateSkillForWrite(normalized);
15
+ if (!result.valid) {
16
+ const summary = result.errors.map((e) => ` - [${e.code}] ${e.message}`).join("\n");
17
+ throw new Error(`Invalid skill "${normalized.name}":\n${summary}`);
18
+ }
19
+ return normalized;
20
+ }
21
+ //#endregion
22
+ export { IMPLICITLY_ALLOWED_SKILL_TOOLS, buildCatalog, createSkillActivationState, defineSkill, discoverSkills, getDefaultScanPaths, inferSource, installAllowedToolsGate, interpolateShellCommands, isToolAllowedByUnion, matchesAllowedTool, parseAllowedToolPattern, parseFrontmatter, parseSkillFile, resolveSkills, validateResourcePath, validateSkillForWrite, validateSkillName, writeSkillToDisk, writeSkillsToDisk };
23
+
24
+ //# sourceMappingURL=skills.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills.js","names":[],"sources":["../src/skills/index.ts"],"sourcesContent":["import type { SkillConfig } from './types'\nimport { validateSkillForWrite } from './validate'\n\nexport {\n type ActivationVia,\n type ActiveSkill,\n createSkillActivationState,\n type DeactivationReason,\n type SkillActivationState,\n type SkillActivationStateOptions,\n} from './activation'\nexport {\n IMPLICITLY_ALLOWED_SKILL_TOOLS,\n installAllowedToolsGate,\n} from './allowed-tools'\nexport { buildCatalog } from './catalog'\nexport {\n discoverSkills,\n getDefaultScanPaths,\n inferSource,\n parseFrontmatter,\n parseSkillFile,\n} from './discovery'\nexport type { SourcedScanPath } from './discovery'\nexport { interpolateShellCommands } from './interpolate'\nexport { resolveSkills } from './resolve'\nexport type {\n SkillConfig,\n SkillDiagnostic,\n SkillResource,\n SkillsConfig,\n SkillSource,\n} from './types'\nexport {\n isToolAllowedByUnion,\n matchesAllowedTool,\n parseAllowedToolPattern,\n validateResourcePath,\n validateSkillForWrite,\n validateSkillName,\n} from './validate'\nexport type { SkillValidationIssue, SkillValidationResult } from './validate'\nexport { writeSkillsToDisk, writeSkillToDisk } from './writer'\n\n// ---------------------------------------------------------------------------\n// defineSkill helper\n// ---------------------------------------------------------------------------\n\n/**\n * Define an inline skill configuration.\n *\n * Strict-validates at author-time — throws if the config would be rejected by\n * `writeSkillToDisk` or the spec. Source defaults to `'inline'`.\n */\nexport function defineSkill(config: Omit<SkillConfig, 'source'> & { source?: SkillConfig['source'] }): SkillConfig {\n const normalized: SkillConfig = {\n ...config,\n source: config.source ?? 'inline',\n }\n const result = validateSkillForWrite(normalized)\n if (!result.valid) {\n const summary = result.errors.map(e => ` - [${e.code}] ${e.message}`).join('\\n')\n throw new Error(`Invalid skill \"${normalized.name}\":\\n${summary}`)\n }\n return normalized\n}\n"],"mappings":";;;;;;;;AAsDA,SAAgB,YAAY,QAAuF;CACjH,MAAM,aAA0B;EAC9B,GAAG;EACH,QAAQ,OAAO,UAAU;EAC1B;CACD,MAAM,SAAS,sBAAsB,WAAW;CAChD,IAAI,CAAC,OAAO,OAAO;EACjB,MAAM,UAAU,OAAO,OAAO,KAAI,MAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,UAAU,CAAC,KAAK,KAAK;EACjF,MAAM,IAAI,MAAM,kBAAkB,WAAW,KAAK,MAAM,UAAU;;CAEpE,OAAO"}
@@ -0,0 +1,58 @@
1
+ //#region src/stats.ts
2
+ /**
3
+ * Depth-first walk over the stats tree, returning every `TurnUsage` entry
4
+ * — parent loop first, then each child subtree in completion order.
5
+ *
6
+ * Closes the cache-token aggregation gap: `TurnUsage.cacheRead` /
7
+ * `cacheCreation` live only on per-turn entries, and the top-level
8
+ * `AgentStats` deliberately doesn't carry cumulative forms (one source of
9
+ * truth, no risk of drift). Anything that needs a tree-wide sum walks
10
+ * through this.
11
+ */
12
+ function flattenTurns(stats) {
13
+ const out = [];
14
+ collectTurns(stats, out);
15
+ return out;
16
+ }
17
+ function collectTurns(stats, out) {
18
+ if (stats.turnUsage) out.push(...stats.turnUsage);
19
+ if (stats.children) for (const child of stats.children) collectTurns(child.stats, out);
20
+ }
21
+ /**
22
+ * Group cumulative usage by `TurnUsage.modelId`. Each entry sums the input,
23
+ * output, cache, cost, and turn-count across every turn the tree attributed
24
+ * to that model — naturally handling cross-model runs (vision-fallback,
25
+ * model-shifted subagents, mixed-provider workflows).
26
+ *
27
+ * Turns missing `modelId` (mock providers, providers that don't echo a model
28
+ * id) are bucketed under the literal string `'(unknown)'`.
29
+ */
30
+ function statsByModel(stats) {
31
+ const out = /* @__PURE__ */ new Map();
32
+ for (const turn of flattenTurns(stats)) {
33
+ const key = turn.modelId ?? "(unknown)";
34
+ let entry = out.get(key);
35
+ if (!entry) {
36
+ entry = {
37
+ input: 0,
38
+ output: 0,
39
+ cost: 0,
40
+ cacheRead: 0,
41
+ cacheCreation: 0,
42
+ turns: 0
43
+ };
44
+ out.set(key, entry);
45
+ }
46
+ entry.input += turn.input;
47
+ entry.output += turn.output;
48
+ entry.cost += turn.cost ?? 0;
49
+ entry.cacheRead += turn.cacheRead ?? 0;
50
+ entry.cacheCreation += turn.cacheCreation ?? 0;
51
+ entry.turns += 1;
52
+ }
53
+ return out;
54
+ }
55
+ //#endregion
56
+ export { statsByModel as n, flattenTurns as t };
57
+
58
+ //# sourceMappingURL=stats-DoKUtF5T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats-DoKUtF5T.js","names":[],"sources":["../src/stats.ts"],"sourcesContent":["/**\n * Pure derivations over `AgentStats`.\n *\n * Both helpers are tree-shakeable — import only what you need. They never\n * touch agent state, never do I/O, and always operate on the recursive\n * `AgentStats` tree returned by `agent.run()`.\n */\n\nimport type { AgentStats, TurnUsage } from './types'\n\n/**\n * Per-model usage rollup produced by {@link statsByModel}.\n *\n * `turns` counts the number of `TurnUsage` entries attributed to the model\n * across the whole tree (parent loop + every recursively-spawned child).\n * Cache and cost numbers are summed from the same set of turns.\n */\nexport interface ModelUsage {\n input: number\n output: number\n cost: number\n cacheRead: number\n cacheCreation: number\n turns: number\n}\n\n/**\n * Depth-first walk over the stats tree, returning every `TurnUsage` entry\n * — parent loop first, then each child subtree in completion order.\n *\n * Closes the cache-token aggregation gap: `TurnUsage.cacheRead` /\n * `cacheCreation` live only on per-turn entries, and the top-level\n * `AgentStats` deliberately doesn't carry cumulative forms (one source of\n * truth, no risk of drift). Anything that needs a tree-wide sum walks\n * through this.\n */\nexport function flattenTurns(stats: AgentStats): TurnUsage[] {\n const out: TurnUsage[] = []\n collectTurns(stats, out)\n return out\n}\n\nfunction collectTurns(stats: AgentStats, out: TurnUsage[]): void {\n if (stats.turnUsage)\n out.push(...stats.turnUsage)\n if (stats.children) {\n for (const child of stats.children)\n collectTurns(child.stats, out)\n }\n}\n\n/**\n * Group cumulative usage by `TurnUsage.modelId`. Each entry sums the input,\n * output, cache, cost, and turn-count across every turn the tree attributed\n * to that model — naturally handling cross-model runs (vision-fallback,\n * model-shifted subagents, mixed-provider workflows).\n *\n * Turns missing `modelId` (mock providers, providers that don't echo a model\n * id) are bucketed under the literal string `'(unknown)'`.\n */\nexport function statsByModel(stats: AgentStats): Map<string, ModelUsage> {\n const out = new Map<string, ModelUsage>()\n for (const turn of flattenTurns(stats)) {\n const key = turn.modelId ?? '(unknown)'\n let entry = out.get(key)\n if (!entry) {\n entry = { input: 0, output: 0, cost: 0, cacheRead: 0, cacheCreation: 0, turns: 0 }\n out.set(key, entry)\n }\n entry.input += turn.input\n entry.output += turn.output\n entry.cost += turn.cost ?? 0\n entry.cacheRead += turn.cacheRead ?? 0\n entry.cacheCreation += turn.cacheCreation ?? 0\n entry.turns += 1\n }\n return out\n}\n"],"mappings":";;;;;;;;;;;AAoCA,SAAgB,aAAa,OAAgC;CAC3D,MAAM,MAAmB,EAAE;CAC3B,aAAa,OAAO,IAAI;CACxB,OAAO;;AAGT,SAAS,aAAa,OAAmB,KAAwB;CAC/D,IAAI,MAAM,WACR,IAAI,KAAK,GAAG,MAAM,UAAU;CAC9B,IAAI,MAAM,UACR,KAAK,MAAM,SAAS,MAAM,UACxB,aAAa,MAAM,OAAO,IAAI;;;;;;;;;;;AAapC,SAAgB,aAAa,OAA4C;CACvE,MAAM,sBAAM,IAAI,KAAyB;CACzC,KAAK,MAAM,QAAQ,aAAa,MAAM,EAAE;EACtC,MAAM,MAAM,KAAK,WAAW;EAC5B,IAAI,QAAQ,IAAI,IAAI,IAAI;EACxB,IAAI,CAAC,OAAO;GACV,QAAQ;IAAE,OAAO;IAAG,QAAQ;IAAG,MAAM;IAAG,WAAW;IAAG,eAAe;IAAG,OAAO;IAAG;GAClF,IAAI,IAAI,KAAK,MAAM;;EAErB,MAAM,SAAS,KAAK;EACpB,MAAM,UAAU,KAAK;EACrB,MAAM,QAAQ,KAAK,QAAQ;EAC3B,MAAM,aAAa,KAAK,aAAa;EACrC,MAAM,iBAAiB,KAAK,iBAAiB;EAC7C,MAAM,SAAS;;CAEjB,OAAO"}