zidane 1.8.1 → 2.0.1
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/dist/{agent-8QBOx4_0.d.ts → agent-D-ZFMbSd.d.ts} +371 -11
- package/dist/{chunk-FFFDQHMA.js → chunk-7JTBBZ2U.js} +21 -0
- package/dist/chunk-BCXXXJ3G.js +779 -0
- package/dist/{chunk-3S377TS4.js → chunk-FRNFVKWW.js} +24 -7
- package/dist/{chunk-EC7IRWVS.js → chunk-LN4LLLHA.js} +101 -7
- package/dist/chunk-LVC7NQUZ.js +22 -0
- package/dist/chunk-MYWDHD7C.js +14 -0
- package/dist/{chunk-3RJOWJOJ.js → chunk-OVQ4N64O.js} +1 -1
- package/dist/{chunk-4N5ADW7A.js → chunk-PASFWG7S.js} +343 -32
- package/dist/{chunk-TBC6MSVK.js → chunk-PJUUYBKF.js} +53 -4
- package/dist/harnesses.d.ts +1 -2
- package/dist/harnesses.js +5 -5
- package/dist/index.d.ts +5 -6
- package/dist/index.js +41 -9
- package/dist/mcp.d.ts +1 -2
- package/dist/mcp.js +3 -1
- package/dist/providers.d.ts +1 -2
- package/dist/providers.js +3 -3
- package/dist/session/sqlite.d.ts +1 -2
- package/dist/session.d.ts +1 -2
- package/dist/session.js +2 -2
- package/dist/skills-use-C4KFVla0.d.ts +66 -0
- package/dist/skills.d.ts +215 -30
- package/dist/skills.js +21 -2
- package/dist/{spawn-jjxPcNcH.d.ts → spawn-RoqpjYLZ.d.ts} +1 -1
- package/dist/tools.d.ts +3 -4
- package/dist/tools.js +10 -4
- package/dist/types.d.ts +2 -3
- package/dist/types.js +8 -2
- package/package.json +1 -1
- package/dist/chunk-4C6Y56CC.js +0 -390
- package/dist/chunk-CFLC2I7D.js +0 -8
- package/dist/glob-Bo0GAiKk.d.ts +0 -5
- package/dist/types-CDI8Kmve.d.ts +0 -64
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Hookable } from 'hookable';
|
|
2
2
|
import { b as ExecutionContext, c as ExecutionHandle } from './types-BpvTmawk.js';
|
|
3
3
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
4
|
-
import { b as SkillsConfig, S as SkillConfig } from './types-CDI8Kmve.js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Typed error classes for agent runs.
|
|
@@ -60,6 +59,32 @@ declare class AgentAbortedError extends Error {
|
|
|
60
59
|
cause?: unknown;
|
|
61
60
|
});
|
|
62
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Thrown (well — constructed; attach via the `tool:gate` block signal) when the
|
|
64
|
+
* union of `allowed-tools` across active skills does not permit a tool call.
|
|
65
|
+
*
|
|
66
|
+
* Produced by the allowed-tools middleware registered on `tool:gate` /
|
|
67
|
+
* `mcp:tool:gate`. The gate's `block = true` + `reason` carry the same message
|
|
68
|
+
* so consumers that don't look at this typed error still get a useful string.
|
|
69
|
+
*/
|
|
70
|
+
declare class AgentToolNotAllowedError extends Error {
|
|
71
|
+
readonly code: "tool_not_allowed";
|
|
72
|
+
/** Canonical tool name the agent tried to call. */
|
|
73
|
+
readonly toolName: string;
|
|
74
|
+
/** Aliased / wire name the LLM saw. */
|
|
75
|
+
readonly displayName: string;
|
|
76
|
+
/** Flattened union of `allowedTools` patterns across active skills. */
|
|
77
|
+
readonly allowedUnion: readonly string[];
|
|
78
|
+
/** Names of the skills currently active when the block fired. */
|
|
79
|
+
readonly activeSkills: readonly string[];
|
|
80
|
+
constructor(options: {
|
|
81
|
+
toolName: string;
|
|
82
|
+
displayName: string;
|
|
83
|
+
allowedUnion: readonly string[];
|
|
84
|
+
activeSkills: readonly string[];
|
|
85
|
+
cause?: unknown;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
63
88
|
/**
|
|
64
89
|
* Regex patterns matching common "context window exceeded" messages across providers.
|
|
65
90
|
*
|
|
@@ -91,8 +116,24 @@ interface McpServerConfig {
|
|
|
91
116
|
command?: string;
|
|
92
117
|
/** For stdio: command arguments */
|
|
93
118
|
args?: string[];
|
|
94
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* For stdio: environment variables to pass to the server process.
|
|
121
|
+
*
|
|
122
|
+
* Merged on top of the MCP SDK's default inherited environment — a safety
|
|
123
|
+
* whitelist (`PATH`, `HOME`, `LANG`, `SHELL`, `USER` on POSIX; `APPDATA`,
|
|
124
|
+
* `PATH`, ... on Win32). Setting this to `{}` no longer strips `PATH` from
|
|
125
|
+
* the child process. Set {@link McpServerConfig.strictEnv} to `true` to
|
|
126
|
+
* pass `env` verbatim with no inherited defaults.
|
|
127
|
+
*/
|
|
95
128
|
env?: Record<string, string>;
|
|
129
|
+
/**
|
|
130
|
+
* When true, {@link McpServerConfig.env} is passed verbatim to the spawned
|
|
131
|
+
* process — the MCP SDK's default inherited environment (`PATH`, `HOME`, ...)
|
|
132
|
+
* is NOT merged in. Most consumers should leave this off; the default merge
|
|
133
|
+
* prevents `spawn ENOENT` when a stdio server declares an `env` without
|
|
134
|
+
* restating `PATH`.
|
|
135
|
+
*/
|
|
136
|
+
strictEnv?: boolean;
|
|
96
137
|
/** For sse/streamable-http: server URL */
|
|
97
138
|
url?: string;
|
|
98
139
|
/** Optional headers for HTTP transports */
|
|
@@ -156,6 +197,38 @@ interface PromptDocumentPart {
|
|
|
156
197
|
/** Optional display name used in attachment headers */
|
|
157
198
|
name?: string;
|
|
158
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* A single block of structured tool-result content.
|
|
202
|
+
*
|
|
203
|
+
* MCP servers can return a mix of text, image, resource, and audio blocks. Tools
|
|
204
|
+
* return `string` for the common text-only case or `ToolResultContent[]` when they
|
|
205
|
+
* need to preserve non-text content (e.g. screenshots from a browser MCP).
|
|
206
|
+
*
|
|
207
|
+
* Providers that support native multi-part tool results (Anthropic, OpenAI Codex via
|
|
208
|
+
* pi-ai) route image blocks into their wire format verbatim; OpenAI-compat providers
|
|
209
|
+
* route them via a companion-user-message fallback when the underlying model/endpoint
|
|
210
|
+
* does not accept images inside tool-role messages.
|
|
211
|
+
*/
|
|
212
|
+
type ToolResultContent = ToolResultTextContent | ToolResultImageContent;
|
|
213
|
+
interface ToolResultTextContent {
|
|
214
|
+
type: 'text';
|
|
215
|
+
text: string;
|
|
216
|
+
}
|
|
217
|
+
interface ToolResultImageContent {
|
|
218
|
+
type: 'image';
|
|
219
|
+
/** IANA media type (e.g. `image/png`, `image/jpeg`) */
|
|
220
|
+
mediaType: string;
|
|
221
|
+
/** Base64-encoded payload */
|
|
222
|
+
data: string;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Lossy flattener — converts `ToolResultContent[]` (or a plain string) to a single
|
|
226
|
+
* string. Image blocks are replaced with `[image: <media> — <n> b64 bytes]` markers.
|
|
227
|
+
*
|
|
228
|
+
* Use at UI boundaries where a string is required; providers that understand
|
|
229
|
+
* structured content should route the array through without flattening.
|
|
230
|
+
*/
|
|
231
|
+
declare function toolResultToText(content: string | ToolResultContent[]): string;
|
|
159
232
|
type SessionContentBlock = {
|
|
160
233
|
type: 'text';
|
|
161
234
|
text: string;
|
|
@@ -171,7 +244,11 @@ type SessionContentBlock = {
|
|
|
171
244
|
} | {
|
|
172
245
|
type: 'tool_result';
|
|
173
246
|
callId: string;
|
|
174
|
-
|
|
247
|
+
/**
|
|
248
|
+
* Tool output — either a plain string (text-only, the common case) or a structured
|
|
249
|
+
* array of content blocks (text + image for multimodal tools such as screenshots).
|
|
250
|
+
*/
|
|
251
|
+
output: string | ToolResultContent[];
|
|
175
252
|
isError?: boolean;
|
|
176
253
|
} | {
|
|
177
254
|
type: 'thinking';
|
|
@@ -370,6 +447,12 @@ declare function anthropic(anthropicParams?: AnthropicParams): Provider;
|
|
|
370
447
|
interface CerebrasParams {
|
|
371
448
|
apiKey?: string;
|
|
372
449
|
defaultModel?: string;
|
|
450
|
+
/**
|
|
451
|
+
* Provider capability flags. Cerebras currently serves text-only OSS models
|
|
452
|
+
* (GLM, Llama-family, Qwen-family) — default: `{ vision: false, imageInToolResult: false }`.
|
|
453
|
+
* Override when routing to a vision-capable deployment.
|
|
454
|
+
*/
|
|
455
|
+
capabilities?: ProviderCapabilities;
|
|
373
456
|
}
|
|
374
457
|
/**
|
|
375
458
|
* Cerebras provider.
|
|
@@ -455,6 +538,17 @@ interface OpenAICompatParams {
|
|
|
455
538
|
authHeader?: OpenAICompatAuthHeader;
|
|
456
539
|
/** Extra headers sent with every request (e.g. referer, user-agent). */
|
|
457
540
|
extraHeaders?: Record<string, string>;
|
|
541
|
+
/**
|
|
542
|
+
* Provider-level capability flags. Routed into the message shaper and the
|
|
543
|
+
* agent loop so images in tool results + user messages are handled correctly
|
|
544
|
+
* for the underlying model.
|
|
545
|
+
*
|
|
546
|
+
* Defaults when omitted: `vision: false`, `imageInToolResult: false` — a
|
|
547
|
+
* conservative assumption matching most OSS text-only OpenAI-compat
|
|
548
|
+
* endpoints. Override when routing to a known vision-capable endpoint
|
|
549
|
+
* (e.g. OpenRouter vision models, Baseten image-capable deployments).
|
|
550
|
+
*/
|
|
551
|
+
capabilities?: ProviderCapabilities;
|
|
458
552
|
}
|
|
459
553
|
/**
|
|
460
554
|
* Factory for any OpenAI-compatible HTTP endpoint.
|
|
@@ -477,6 +571,16 @@ declare function openaiCompat(params: OpenAICompatParams): Provider;
|
|
|
477
571
|
interface OpenRouterParams {
|
|
478
572
|
apiKey?: string;
|
|
479
573
|
defaultModel?: string;
|
|
574
|
+
/**
|
|
575
|
+
* Provider capability flags. OpenRouter itself is a router — whether vision or
|
|
576
|
+
* native image-in-tool-result are supported depends on the downstream model.
|
|
577
|
+
* Default: `{ vision: true, imageInToolResult: false }` — matches the default
|
|
578
|
+
* `anthropic/claude-sonnet-4-6` model (vision-capable via companion user-message
|
|
579
|
+
* fallback since OpenRouter exposes Claude over the Chat Completions dialect).
|
|
580
|
+
*
|
|
581
|
+
* Override when routing to a known-text-only model (e.g. `meta-llama/llama-3-8b-instruct`).
|
|
582
|
+
*/
|
|
583
|
+
capabilities?: ProviderCapabilities;
|
|
480
584
|
}
|
|
481
585
|
/**
|
|
482
586
|
* OpenRouter provider.
|
|
@@ -498,7 +602,44 @@ interface ToolCall {
|
|
|
498
602
|
}
|
|
499
603
|
interface ToolResult {
|
|
500
604
|
id: string;
|
|
501
|
-
|
|
605
|
+
/**
|
|
606
|
+
* Tool output — plain string for text-only tools (the common case) or a structured
|
|
607
|
+
* array of content blocks for tools that return images or mixed content (e.g. an
|
|
608
|
+
* MCP browser server returning a screenshot).
|
|
609
|
+
*
|
|
610
|
+
* Use `toolResultToText(content)` when a downstream consumer only handles strings.
|
|
611
|
+
*/
|
|
612
|
+
content: string | ToolResultContent[];
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Provider-level capability flags used by the agent loop to route tool results
|
|
616
|
+
* and user messages appropriately.
|
|
617
|
+
*
|
|
618
|
+
* When a flag is `undefined` (omitted), the loop applies the conservative
|
|
619
|
+
* text-only default — images are stripped and replaced with a text marker so
|
|
620
|
+
* non-vision models do not confabulate about content they cannot see.
|
|
621
|
+
*/
|
|
622
|
+
interface ProviderCapabilities {
|
|
623
|
+
/**
|
|
624
|
+
* Model accepts image input anywhere (user messages and tool results).
|
|
625
|
+
*
|
|
626
|
+
* When `false`, the loop replaces image blocks with
|
|
627
|
+
* `"[image omitted — model does not support vision]"` before they reach the provider.
|
|
628
|
+
* Gives the model an honest marker instead of letting JSON-stringified base64 slip
|
|
629
|
+
* through and get confabulated over.
|
|
630
|
+
*/
|
|
631
|
+
vision?: boolean;
|
|
632
|
+
/**
|
|
633
|
+
* Provider wire format embeds images inside tool-role messages natively
|
|
634
|
+
* (Anthropic `tool_result.content` arrays, OpenAI Codex pi-ai `toolResult` blocks).
|
|
635
|
+
*
|
|
636
|
+
* When `false`, a vision-capable provider still gets images — but via a
|
|
637
|
+
* companion `user` message emitted immediately after the flattened
|
|
638
|
+
* `tool`/`tool_result` marker. This is the Claude Desktop / Cline pattern
|
|
639
|
+
* and works on any OpenAI Chat Completions endpoint that accepts image
|
|
640
|
+
* URLs in user messages.
|
|
641
|
+
*/
|
|
642
|
+
imageInToolResult?: boolean;
|
|
502
643
|
}
|
|
503
644
|
interface StreamCallbacks {
|
|
504
645
|
onText: (delta: string) => void;
|
|
@@ -538,6 +679,8 @@ interface Provider {
|
|
|
538
679
|
readonly name: string;
|
|
539
680
|
readonly meta: {
|
|
540
681
|
defaultModel: string;
|
|
682
|
+
/** Provider-level capability flags. See {@link ProviderCapabilities}. */
|
|
683
|
+
capabilities?: ProviderCapabilities;
|
|
541
684
|
} & Record<string, unknown>;
|
|
542
685
|
/** Format tool specs for this provider */
|
|
543
686
|
formatTools: (tools: ToolSpec[]) => unknown[];
|
|
@@ -568,6 +711,108 @@ interface Provider {
|
|
|
568
711
|
classifyError?: (err: unknown) => ClassifiedError | null;
|
|
569
712
|
}
|
|
570
713
|
|
|
714
|
+
/**
|
|
715
|
+
* Types for the Agent Skills system.
|
|
716
|
+
*
|
|
717
|
+
* Follows the Agent Skills open standard (agentskills.io/specification).
|
|
718
|
+
* Zidane-specific metadata conventionally uses the `zidane.` key prefix
|
|
719
|
+
* (e.g. `metadata['zidane.paths']`) to stay spec-compliant.
|
|
720
|
+
*/
|
|
721
|
+
interface SkillResource {
|
|
722
|
+
/** Relative path from skill directory */
|
|
723
|
+
path: string;
|
|
724
|
+
/** Resource type inferred from directory */
|
|
725
|
+
type: 'script' | 'reference' | 'asset' | 'other';
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Where the skill came from. Used for collision precedence (project beats user)
|
|
729
|
+
* and for host SDKs to gate project-level skills on a trust check.
|
|
730
|
+
*/
|
|
731
|
+
type SkillSource = 'project' | 'user' | 'inline' | 'builtin';
|
|
732
|
+
/** Severity + code for lenient-load warnings surfaced to host UIs. */
|
|
733
|
+
interface SkillDiagnostic {
|
|
734
|
+
severity: 'warning' | 'error';
|
|
735
|
+
/** Stable machine-readable code (e.g. `name-mismatch-directory`). */
|
|
736
|
+
code: string;
|
|
737
|
+
/** Human-readable description. */
|
|
738
|
+
message: string;
|
|
739
|
+
/** Optional frontmatter field name the diagnostic relates to. */
|
|
740
|
+
field?: string;
|
|
741
|
+
}
|
|
742
|
+
interface SkillConfig {
|
|
743
|
+
/** Skill name: 1-64 chars, lowercase alphanumeric + hyphens */
|
|
744
|
+
name: string;
|
|
745
|
+
/** What the skill does and when to use it (1-1024 chars) */
|
|
746
|
+
description: string;
|
|
747
|
+
/** The SKILL.md body content (after YAML frontmatter) */
|
|
748
|
+
instructions: string;
|
|
749
|
+
/**
|
|
750
|
+
* Where this skill was loaded from. Drives collision precedence and the
|
|
751
|
+
* `trustProjectSkills` gate. Optional — `parseSkillFile` stamps it; raw
|
|
752
|
+
* fixtures that omit it are treated as `'project'` by downstream readers.
|
|
753
|
+
*/
|
|
754
|
+
source?: SkillSource;
|
|
755
|
+
/** Absolute path to SKILL.md (undefined for inline skills) */
|
|
756
|
+
location?: string;
|
|
757
|
+
/** Skill directory path for resolving relative references */
|
|
758
|
+
baseDir?: string;
|
|
759
|
+
/** License identifier or reference */
|
|
760
|
+
license?: string;
|
|
761
|
+
/** Environment requirements */
|
|
762
|
+
compatibility?: string;
|
|
763
|
+
/**
|
|
764
|
+
* Flat key-value metadata bag per the spec. For Zidane-specific hints,
|
|
765
|
+
* use the `zidane.` key prefix (e.g. `metadata['zidane.paths']`).
|
|
766
|
+
*/
|
|
767
|
+
metadata?: Record<string, string>;
|
|
768
|
+
/** Pre-approved tool names (experimental per spec) */
|
|
769
|
+
allowedTools?: string[];
|
|
770
|
+
/** Bundled resource files discovered in the skill directory */
|
|
771
|
+
resources?: SkillResource[];
|
|
772
|
+
/**
|
|
773
|
+
* Lenient-load warnings recorded during parsing. Host SDKs can surface these
|
|
774
|
+
* as inline UI hints. Absent when no issues were found.
|
|
775
|
+
*/
|
|
776
|
+
diagnostics?: SkillDiagnostic[];
|
|
777
|
+
}
|
|
778
|
+
interface SkillsConfig {
|
|
779
|
+
/**
|
|
780
|
+
* Control which skills are active.
|
|
781
|
+
* - `true` (default): all discovered skills are enabled
|
|
782
|
+
* - `false` or `[]`: fully disable the skills system (no resolution, no catalog, no hooks)
|
|
783
|
+
* - `string[]`: allowlist — only skills with matching names are enabled
|
|
784
|
+
*/
|
|
785
|
+
enabled?: boolean | string[];
|
|
786
|
+
/** Directories to scan for SKILL.md files */
|
|
787
|
+
scan?: string[];
|
|
788
|
+
/** Dynamic skills written to disk at agent start, then loaded normally */
|
|
789
|
+
write?: SkillConfig[];
|
|
790
|
+
/** Skill names to exclude from the catalog */
|
|
791
|
+
exclude?: string[];
|
|
792
|
+
/** Skip default scan paths (~/.agents/skills, .zidane/skills, etc.) */
|
|
793
|
+
skipDefaultPaths?: boolean;
|
|
794
|
+
/**
|
|
795
|
+
* Auto-inject `skills_use` / `skills_read` / `skills_run_script` tools
|
|
796
|
+
* when the catalog is non-empty. Default `true`. Set `false` to opt out
|
|
797
|
+
* (the system prompt will then instruct the model to use its file-read
|
|
798
|
+
* tool instead).
|
|
799
|
+
*/
|
|
800
|
+
tool?: boolean;
|
|
801
|
+
/**
|
|
802
|
+
* Cap on concurrently active skills per run. Default `undefined` (unlimited).
|
|
803
|
+
* Attempts to activate past the cap throw from `skills_use`.
|
|
804
|
+
*/
|
|
805
|
+
maxActive?: number;
|
|
806
|
+
/** Script timeout for `skills_run_script`, in milliseconds. Default `60000`. */
|
|
807
|
+
scriptTimeoutMs?: number;
|
|
808
|
+
/**
|
|
809
|
+
* When `false`, skills with `source: 'project'` are skipped during
|
|
810
|
+
* resolution with a diagnostic. Default `true` (preserves existing behavior).
|
|
811
|
+
* Useful for host SDKs handling untrusted repositories.
|
|
812
|
+
*/
|
|
813
|
+
trustProjectSkills?: boolean;
|
|
814
|
+
}
|
|
815
|
+
|
|
571
816
|
/** Core tools available in every basic harness (without spawn) */
|
|
572
817
|
declare const basicTools: {
|
|
573
818
|
shell: ToolDef;
|
|
@@ -601,7 +846,16 @@ interface ToolContext {
|
|
|
601
846
|
}
|
|
602
847
|
interface ToolDef {
|
|
603
848
|
spec: ToolSpec;
|
|
604
|
-
|
|
849
|
+
/**
|
|
850
|
+
* Execute the tool and return its output.
|
|
851
|
+
*
|
|
852
|
+
* Return a plain string for text-only tools (the common case). Return a
|
|
853
|
+
* `ToolResultContent[]` when the tool produces non-text content (images, mixed
|
|
854
|
+
* text+image) that the provider can route through natively (Anthropic
|
|
855
|
+
* `tool_result.content` arrays, OpenAI Codex pi-ai) or through the
|
|
856
|
+
* companion-user-message fallback (OpenAI Chat Completions).
|
|
857
|
+
*/
|
|
858
|
+
execute: (input: Record<string, unknown>, ctx: ToolContext) => Promise<string | ToolResultContent[]>;
|
|
605
859
|
}
|
|
606
860
|
type ToolMap = Map<string, ToolDef>;
|
|
607
861
|
interface HarnessConfig {
|
|
@@ -679,10 +933,29 @@ interface McpConnection {
|
|
|
679
933
|
*/
|
|
680
934
|
declare function normalizeMcpServers(input: unknown): McpServerConfig[];
|
|
681
935
|
/**
|
|
682
|
-
*
|
|
936
|
+
* Lossy flattener — converts MCP `CallToolResult.content` blocks to a single string.
|
|
683
937
|
* Text blocks are extracted; non-text blocks are JSON-stringified.
|
|
938
|
+
*
|
|
939
|
+
* Prefer {@link normalizeMcpBlocks} for new code — it preserves image blocks so the
|
|
940
|
+
* provider can route them through to the model natively (Anthropic tool_result blocks,
|
|
941
|
+
* OpenAI companion-user-message). This function is kept for back-compat and is useful
|
|
942
|
+
* as a logging/display helper where a single string is required.
|
|
684
943
|
*/
|
|
685
944
|
declare function resultToString(content: unknown[]): string;
|
|
945
|
+
/**
|
|
946
|
+
* Normalize MCP `CallToolResult.content` to zidane's {@link ToolResultContent[]} shape.
|
|
947
|
+
*
|
|
948
|
+
* Handles the four MCP content block types:
|
|
949
|
+
* - `text` → preserved as `{type:'text', text}`
|
|
950
|
+
* - `image` → preserved as `{type:'image', mediaType, data}` (MCP uses `mimeType`)
|
|
951
|
+
* - `resource` with embedded text → flattened to a text block
|
|
952
|
+
* - `resource` with embedded blob whose `mimeType` is `image/*` → flattened to an image block
|
|
953
|
+
* - Any unrecognized block → JSON-stringified fallback text block (lossy but safe)
|
|
954
|
+
*
|
|
955
|
+
* Returns `null` when the input is not an array — callers should fall back to an empty
|
|
956
|
+
* result in that case.
|
|
957
|
+
*/
|
|
958
|
+
declare function normalizeMcpBlocks(content: unknown): ToolResultContent[] | null;
|
|
686
959
|
/**
|
|
687
960
|
* Connect to MCP servers and discover their tools.
|
|
688
961
|
*
|
|
@@ -943,6 +1216,74 @@ declare function createSession(options?: CreateSessionOptions): Promise<Session>
|
|
|
943
1216
|
*/
|
|
944
1217
|
declare function loadSession(store: SessionStore, sessionId: string): Promise<Session | null>;
|
|
945
1218
|
|
|
1219
|
+
/**
|
|
1220
|
+
* Per-agent skill activation state machine.
|
|
1221
|
+
*
|
|
1222
|
+
* Tracks which skills are active across a run. The three skills tools
|
|
1223
|
+
* (`skills_use` / `skills_read` / `skills_run_script`) read from this state
|
|
1224
|
+
* for gating + listing. Allowed-tools enforcement reads from it too.
|
|
1225
|
+
*
|
|
1226
|
+
* Lifecycle:
|
|
1227
|
+
* - Storage lives on the agent instance (created once in `createAgent`), but
|
|
1228
|
+
* every `run()` ends with an implicit deactivate-all pass (reason `'run-end'`)
|
|
1229
|
+
* so activation does **not** persist across run boundaries. To keep a skill
|
|
1230
|
+
* active across successive runs, call `agent.activateSkill(name)` before each
|
|
1231
|
+
* run — the explicit-activation path is idempotent.
|
|
1232
|
+
* - `agent.reset()` clears the state with reason `'reset'`.
|
|
1233
|
+
* - On session-resume, carried-forward `skills_use` tool_call blocks (in prior
|
|
1234
|
+
* assistant turns) are replayed at run-start to rehydrate state with
|
|
1235
|
+
* `via: 'resume'`.
|
|
1236
|
+
*
|
|
1237
|
+
* The caps (`maxActive` from SkillsConfig) is enforced here — returning `false`
|
|
1238
|
+
* from `activate()` when the cap is hit lets the caller surface an actionable
|
|
1239
|
+
* "max skills active" error to the model.
|
|
1240
|
+
*/
|
|
1241
|
+
|
|
1242
|
+
/** How a skill was activated. Surfaced in `skills:activate` hook ctx. */
|
|
1243
|
+
type ActivationVia = 'model' | 'explicit' | 'resume';
|
|
1244
|
+
/** Reason a skill was deactivated. Surfaced in `skills:deactivate` hook ctx. */
|
|
1245
|
+
type DeactivationReason = 'run-end' | 'explicit' | 'reset';
|
|
1246
|
+
/** A skill currently active in the state machine. */
|
|
1247
|
+
interface ActiveSkill {
|
|
1248
|
+
skill: SkillConfig;
|
|
1249
|
+
activatedAt: number;
|
|
1250
|
+
activatedVia: ActivationVia;
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Per-agent skill activation state. Public read-surface is the `active()` list
|
|
1254
|
+
* and `isActive(name)` predicate; writes go through `activate()` / `deactivate()`.
|
|
1255
|
+
*/
|
|
1256
|
+
interface SkillActivationState {
|
|
1257
|
+
/** List of currently active skills in activation order. Returns a snapshot. */
|
|
1258
|
+
active: () => readonly ActiveSkill[];
|
|
1259
|
+
/** Is the skill with this canonical name currently active? */
|
|
1260
|
+
isActive: (name: string) => boolean;
|
|
1261
|
+
/** Retrieve the `ActiveSkill` record by name, or `undefined`. */
|
|
1262
|
+
get: (name: string) => ActiveSkill | undefined;
|
|
1263
|
+
/**
|
|
1264
|
+
* Mark a skill as active.
|
|
1265
|
+
* - Returns `'ok'` on a fresh activation (caller should fire `skills:activate`).
|
|
1266
|
+
* - Returns `'already-active'` if the skill was already in the set (idempotent).
|
|
1267
|
+
* - Returns `'cap-reached'` if the `maxActive` cap would be exceeded. State is unchanged.
|
|
1268
|
+
*/
|
|
1269
|
+
activate: (skill: SkillConfig, via: ActivationVia) => 'ok' | 'already-active' | 'cap-reached';
|
|
1270
|
+
/**
|
|
1271
|
+
* Mark a skill as inactive. Returns the removed `ActiveSkill` record or `undefined`
|
|
1272
|
+
* if it wasn't active. Callers fire `skills:deactivate` on removal.
|
|
1273
|
+
*/
|
|
1274
|
+
deactivate: (name: string) => ActiveSkill | undefined;
|
|
1275
|
+
/** Remove every active skill. Returns the list of removed records. */
|
|
1276
|
+
clear: () => readonly ActiveSkill[];
|
|
1277
|
+
}
|
|
1278
|
+
interface SkillActivationStateOptions {
|
|
1279
|
+
/**
|
|
1280
|
+
* Cap on concurrent activations. `undefined` (the default) disables the cap.
|
|
1281
|
+
* When set, `activate()` returns `'cap-reached'` once the set is at size `maxActive`.
|
|
1282
|
+
*/
|
|
1283
|
+
maxActive?: number;
|
|
1284
|
+
}
|
|
1285
|
+
declare function createSkillActivationState(options?: SkillActivationStateOptions): SkillActivationState;
|
|
1286
|
+
|
|
946
1287
|
/**
|
|
947
1288
|
* Agent creation and state management.
|
|
948
1289
|
*/
|
|
@@ -980,13 +1321,13 @@ interface AgentHooks {
|
|
|
980
1321
|
}) => void;
|
|
981
1322
|
'tool:before': (ctx: ToolHookContext) => void;
|
|
982
1323
|
'tool:after': (ctx: ToolHookContext & {
|
|
983
|
-
result: string;
|
|
1324
|
+
result: string | ToolResultContent[];
|
|
984
1325
|
}) => void;
|
|
985
1326
|
'tool:error': (ctx: ToolHookContext & {
|
|
986
1327
|
error: Error;
|
|
987
1328
|
}) => void;
|
|
988
1329
|
'tool:transform': (ctx: ToolHookContext & {
|
|
989
|
-
result: string;
|
|
1330
|
+
result: string | ToolResultContent[];
|
|
990
1331
|
isError: boolean;
|
|
991
1332
|
}) => void;
|
|
992
1333
|
'context:transform': (ctx: {
|
|
@@ -1018,10 +1359,10 @@ interface AgentHooks {
|
|
|
1018
1359
|
}) => void;
|
|
1019
1360
|
'mcp:tool:before': (ctx: McpToolHookContext) => void;
|
|
1020
1361
|
'mcp:tool:after': (ctx: McpToolHookContext & {
|
|
1021
|
-
result: string;
|
|
1362
|
+
result: string | ToolResultContent[];
|
|
1022
1363
|
}) => void;
|
|
1023
1364
|
'mcp:tool:transform': (ctx: McpToolHookContext & {
|
|
1024
|
-
result: string;
|
|
1365
|
+
result: string | ToolResultContent[];
|
|
1025
1366
|
}) => void;
|
|
1026
1367
|
'mcp:tool:error': (ctx: McpToolHookContext & {
|
|
1027
1368
|
error: Error;
|
|
@@ -1035,6 +1376,11 @@ interface AgentHooks {
|
|
|
1035
1376
|
}) => void;
|
|
1036
1377
|
'skills:activate': (ctx: {
|
|
1037
1378
|
skill: SkillConfig;
|
|
1379
|
+
via: ActivationVia;
|
|
1380
|
+
}) => void;
|
|
1381
|
+
'skills:deactivate': (ctx: {
|
|
1382
|
+
skill: SkillConfig;
|
|
1383
|
+
reason: DeactivationReason;
|
|
1038
1384
|
}) => void;
|
|
1039
1385
|
'usage': (ctx: {
|
|
1040
1386
|
turn: number;
|
|
@@ -1095,13 +1441,27 @@ interface Agent {
|
|
|
1095
1441
|
reset: () => void;
|
|
1096
1442
|
/** Destroy the execution context and clean up resources */
|
|
1097
1443
|
destroy: () => Promise<void>;
|
|
1444
|
+
/**
|
|
1445
|
+
* Explicitly activate a skill by name. Fires `skills:activate` with
|
|
1446
|
+
* `via: 'explicit'`. Throws if the skill isn't in the resolved catalog or
|
|
1447
|
+
* if the `maxActive` cap is reached. Idempotent — activating an already-active
|
|
1448
|
+
* skill is a no-op.
|
|
1449
|
+
*/
|
|
1450
|
+
activateSkill: (name: string) => Promise<void>;
|
|
1451
|
+
/**
|
|
1452
|
+
* Deactivate a skill by name. Fires `skills:deactivate` with `reason: 'explicit'`.
|
|
1453
|
+
* No-op when the skill wasn't active.
|
|
1454
|
+
*/
|
|
1455
|
+
deactivateSkill: (name: string) => Promise<void>;
|
|
1098
1456
|
readonly isRunning: boolean;
|
|
1099
1457
|
readonly turns: SessionTurn[];
|
|
1100
1458
|
readonly execution: ExecutionContext;
|
|
1101
1459
|
readonly handle: ExecutionHandle | null;
|
|
1102
1460
|
readonly session: Session | null;
|
|
1461
|
+
/** Snapshot of currently active skills. */
|
|
1462
|
+
readonly activeSkills: readonly ActiveSkill[];
|
|
1103
1463
|
meta: Record<string, unknown>;
|
|
1104
1464
|
}
|
|
1105
1465
|
declare function createAgent({ harness: harnessOption, provider, behavior: agentBehavior, execution, mcpServers, session, skills: agentSkills, _mcpConnector }: AgentOptions): Agent;
|
|
1106
1466
|
|
|
1107
|
-
export { type
|
|
1467
|
+
export { type ToolDef as $, type Agent as A, type SessionContentBlock as B, CONTEXT_EXCEEDED_MESSAGE_PATTERNS as C, type SessionData as D, type SessionEndStatus as E, type SessionHookContext as F, type SessionMessage as G, type Harness as H, type ImageContent as I, type SessionRun as J, type SessionStore as K, type SessionTurn as L, type McpConnection as M, type SkillConfig as N, type OAuthRefreshHookContext as O, type PromptDocumentPart as P, type SkillResource as Q, type RemoteStoreOptions as R, type Session as S, type SkillsConfig as T, type SpawnHookContext as U, type StreamCallbacks as V, type StreamHookContext as W, type StreamOptions as X, type ThinkingLevel as Y, type ToolCall as Z, type ToolContext as _, AgentAbortedError as a, type ToolExecutionMode as a0, type ToolHookContext as a1, type ToolMap as a2, type ToolResult as a3, type ToolResultContent as a4, type ToolResultImageContent as a5, type ToolResultTextContent as a6, type ToolSpec as a7, type TurnFinishReason as a8, type TurnResult as a9, defineHarness as aA, fromAnthropic as aB, fromOpenAI as aC, loadSession as aD, mapOAIFinishReason as aE, noTools as aF, normalizeMcpBlocks as aG, normalizeMcpServers as aH, openai as aI, openaiCompat as aJ, openrouter as aK, resultToString as aL, toAnthropic as aM, toOpenAI as aN, toTypedError as aO, _default as aP, basicTools as aQ, type TurnUsage as aa, matchesContextExceeded as ab, toolResultToText as ac, type ActivationVia as ad, type ActiveSkill as ae, type DeactivationReason as af, type FileMapAdapter as ag, type FileMapStoreOptions as ah, type OpenAICompatAuthHeader as ai, OpenAICompatHttpError as aj, type OpenAICompatParams as ak, type SkillActivationState as al, type SkillActivationStateOptions as am, type SkillDiagnostic as an, type SkillSource as ao, anthropic as ap, autoDetectAndConvert as aq, cerebras as ar, classifyOpenAICompatError as as, connectMcpServers as at, createAgent as au, createFileMapStore as av, createMemoryStore as aw, createRemoteStore as ax, createSession as ay, createSkillActivationState as az, type AgentBehavior as b, AgentContextExceededError as c, type AgentHooks as d, type AgentOptions as e, AgentProviderError as f, type AgentRunOptions as g, type AgentStats as h, AgentToolNotAllowedError as i, type AnthropicParams as j, type CerebrasParams as k, type ChildRunStats as l, type ClassifiedError as m, type ClassifiedErrorKind as n, type CreateSessionOptions as o, type HarnessConfig as p, type McpServerConfig as q, type McpToolHookContext as r, type OpenAIParams as s, type OpenRouterParams as t, type PromptImagePart as u, type PromptPart as v, type PromptTextPart as w, type Provider as x, type ProviderCapabilities as y, type RunHookMap as z };
|
|
@@ -28,6 +28,26 @@ var AgentAbortedError = class extends Error {
|
|
|
28
28
|
this.name = "AgentAbortedError";
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
+
var AgentToolNotAllowedError = class extends Error {
|
|
32
|
+
code = "tool_not_allowed";
|
|
33
|
+
/** Canonical tool name the agent tried to call. */
|
|
34
|
+
toolName;
|
|
35
|
+
/** Aliased / wire name the LLM saw. */
|
|
36
|
+
displayName;
|
|
37
|
+
/** Flattened union of `allowedTools` patterns across active skills. */
|
|
38
|
+
allowedUnion;
|
|
39
|
+
/** Names of the skills currently active when the block fired. */
|
|
40
|
+
activeSkills;
|
|
41
|
+
constructor(options) {
|
|
42
|
+
const msg = `Tool "${options.displayName}" is not in the allowed-tools union of the active skill(s) [${options.activeSkills.join(", ")}]. Union: [${options.allowedUnion.join(" ")}].`;
|
|
43
|
+
super(msg, options.cause !== void 0 ? { cause: options.cause } : void 0);
|
|
44
|
+
this.name = "AgentToolNotAllowedError";
|
|
45
|
+
this.toolName = options.toolName;
|
|
46
|
+
this.displayName = options.displayName;
|
|
47
|
+
this.allowedUnion = options.allowedUnion;
|
|
48
|
+
this.activeSkills = options.activeSkills;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
31
51
|
var CONTEXT_EXCEEDED_MESSAGE_PATTERNS = [
|
|
32
52
|
/context[_\s]length[_\s]exceeded/i,
|
|
33
53
|
/maximum context length/i,
|
|
@@ -62,6 +82,7 @@ export {
|
|
|
62
82
|
AgentContextExceededError,
|
|
63
83
|
AgentProviderError,
|
|
64
84
|
AgentAbortedError,
|
|
85
|
+
AgentToolNotAllowedError,
|
|
65
86
|
CONTEXT_EXCEEDED_MESSAGE_PATTERNS,
|
|
66
87
|
matchesContextExceeded,
|
|
67
88
|
toTypedError
|