@directive-run/ai 0.4.0 → 0.4.2

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/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { G as GuardrailFn, I as InputGuardrailData, O as OutputGuardrailData, S as SchemaValidator, T as ToolCallGuardrailData, A as AgentLike, M as Message, a as AdapterHooks, b as AgentRunner, c as ApprovalState, d as AgentState, R as RunOptions, e as RunResult, D as DebugEvent, B as BreakpointState, f as GoalResult } from './types-D5veI9su.cjs';
2
2
  export { g as AgentCircuitBreakerConfig, h as AgentCompleteEvent, i as AgentErrorEvent, j as AgentHealthState, k as AgentRetryConfig, l as AgentRetryEvent, m as AgentSelectionStrategy, n as AgentStartEvent, o as ApprovalRequest, p as ApprovalRequestEvent, q as ApprovalResponseEvent, r as BreakpointConfig, s as BreakpointContext, t as BreakpointHitEvent, u as BreakpointModifications, v as BreakpointRequest, w as BreakpointResumedEvent, x as BreakpointState, y as BreakpointType, C as Checkpoint, z as CheckpointContext, E as CheckpointDiff, F as CheckpointLocalState, H as CheckpointProgress, J as CheckpointRestoreEvent, K as CheckpointSaveEvent, L as CheckpointStore, N as ConstraintEvaluateEvent, P as CrossAgentDerivationFn, Q as CrossAgentSnapshot, U as DagCheckpointState, V as DagExecutionContext, W as DagNode, X as DagNodeStatus, Y as DagNodeUpdateEvent, Z as DagPattern, _ as DebateCheckpointState, $ as DebateRoundEvent, a0 as DebugEventBase, a1 as DebugEventType, a2 as DerivationUpdateEvent, a3 as GoalCheckpointConfig, a4 as GoalCheckpointState, a5 as GoalMetrics, a6 as GoalNode, a7 as GoalPattern, a8 as GoalStepMetrics, a9 as GuardrailCheckEvent, aa as GuardrailContext, ab as GuardrailError, ac as GuardrailErrorCode, ad as GuardrailResult, ae as GuardrailRetryConfig, af as GuardrailsConfig, ag as HandoffCompleteEvent, ah as HandoffStartEvent, ai as HealthMonitorConfig, aj as InMemoryCheckpointStore, ak as InMemoryCheckpointStoreOptions, al as MAX_BREAKPOINT_HISTORY, am as MultiAgentBreakpointType, an as MultiAgentCheckpointLocalState, ao as MultiAgentLifecycleHooks, ap as MultiAgentSelfHealingConfig, aq as NamedGuardrail, ar as OrchestratorConstraint, as as OrchestratorDebugConfig, at as OrchestratorLifecycleHooks, au as OrchestratorResolver, av as OrchestratorResolverContext, aw as OrchestratorState, ax as PatternCheckpointBase, ay as PatternCheckpointConfig, az as PatternCheckpointState, aA as PatternCompleteEvent, aB as PatternStartEvent, aC as RaceCancelledEvent, aD as RaceStartEvent, aE as RaceWinnerEvent, aF as ReflectCheckpointState, aG as ReflectionIterationEvent, aH as RejectedRequest, aI as RelaxationContext, aJ as RelaxationRecord, aK as RelaxationStrategy, aL as RelaxationTier, aM as RerouteDebugEvent, aN as RerouteEvent, aO as ResolverCompleteEvent, aP as ResolverErrorEvent, aQ as ResolverStartEvent, aR as SchemaValidationResult, aS as Scratchpad, aT as ScratchpadUpdateEvent, aU as SelfHealingConfig, aV as SequentialCheckpointState, aW as SingleAgentCheckpointLocalState, aX as StreamingCallbackRunner, aY as SupervisorCheckpointState, aZ as TaskCompleteEvent, a_ as TaskErrorEvent, a$ as TaskProgressEvent, b0 as TaskStartEvent, b1 as TokenUsage, b2 as ToolCall, b3 as createBreakpointId, b4 as createCheckpointId, b5 as createInitialBreakpointState, b6 as isGuardrailError, b7 as matchBreakpoint, b8 as validateCheckpoint } from './types-D5veI9su.cjs';
3
- import { E as ExecutionPattern, S as SerializedPattern, A as AgentHealthMetrics, D as DebugTimeline, H as HealthMonitor } from './multi-agent-orchestrator-YFs28JsF.cjs';
4
- export { a as AgentMemory, b as AgentMemoryConfig, c as AgentOrchestrator, d as AgentRegistration, e as AgentRegistry, B as BackpressureStrategy, f as DebateConfig, g as DebatePattern, h as DebateResult, i as DebugTimelineListener, j as DebugTimelineOptions, k as DoneChunk, l as ErrorChunk, G as GuardrailTriggeredChunk, m as HandoffRequest, n as HandoffResult, o as HealthCircuitState, M as MemoryManageResult, p as MemoryState, q as MemoryStrategy, r as MemoryStrategyConfig, s as MemoryStrategyResult, t as MergedTaggedStreamResult, u as MessageChunk, v as MessageSummarizer, w as MultiAgentOrchestrator, x as MultiAgentOrchestratorOptions, y as MultiAgentRunCallOptions, z as MultiAgentState, C as MultiplexedStreamChunk, F as MultiplexedStreamResult, O as OrchestratorOptions, I as OrchestratorStreamChunk, J as OrchestratorStreamResult, P as ParallelPattern, K as ProgressChunk, R as RacePattern, L as RaceResult, N as RaceSuccessEntry, Q as ReflectIterationRecord, T as ReflectPattern, U as ReflectionConfig, V as ReflectionContext, W as ReflectionEvaluation, X as ReflectionEvaluator, Y as ReflectionExhaustedError, Z as RunAgentRequirement, _ as RunCallOptions, $ as SafeParseResult, a0 as SafeParseable, a1 as Semaphore, a2 as SequentialPattern, a3 as SerializedDagNode, a4 as SerializedGoalNode, a5 as SpawnOnConditionOptions, a6 as SpawnPoolConfig, a7 as StreamChunk, a8 as StreamRunOptions, a9 as StreamRunner, aa as StreamingGuardrail, ab as StreamingGuardrailResult, ac as StreamingRunResult, ad as StructuredOutputConfig, ae as StructuredOutputError, af as SupervisorPattern, ag as TaskContext, ah as TaskRegistration, ai as TokenChunk, aj as ToolEndChunk, ak as ToolStartChunk, al as adaptOutputGuardrail, am as aggregateTokens, an as allReadyStrategy, ao as capabilityRoute, ap as collectOutputs, aq as collectTokens, ar as combineStreamingGuardrails, as as composePatterns, at as concatResults, au as costEfficientStrategy, av as createAgentMemory, aw as createAgentOrchestrator, ax as createDebugTimeline, ay as createDebugTimelinePlugin, az as createHealthMonitor, aA as createHybridStrategy, aB as createKeyPointsSummarizer, aC as createLLMSummarizer, aD as createLengthStreamingGuardrail, aE as createMultiAgentOrchestrator, aF as createPatternStreamingGuardrail, aG as createSlidingWindowStrategy, aH as createStreamingRunner, aI as createTokenBasedStrategy, aJ as createToxicityStreamingGuardrail, aK as createTruncationSummarizer, aL as dag, aM as debate, aN as derivedConstraint, aO as diffCheckpoints, aP as extractJsonFromOutput, aQ as filterStream, aR as findAgentsByCapability, aS as forkFromCheckpoint, aT as getCheckpointProgress, aU as getPatternStep, aV as goal, aW as highestImpactStrategy, aX as mapStream, aY as mergeTaggedStreams, aZ as parallel, a_ as patternFromJSON, a$ as patternToJSON, b0 as pickBestResult, b1 as race, b2 as reflect, b3 as runAgentRequirement, b4 as runDebate, b5 as selectAgent, b6 as sequential, b7 as spawnOnCondition, b8 as spawnPool, b9 as supervisor, ba as tapStream, bb as withReflection, bc as withStructuredOutput } from './multi-agent-orchestrator-YFs28JsF.cjs';
3
+ import { E as ExecutionPattern, S as SerializedPattern, A as AgentHealthMetrics, D as DebugTimeline, H as HealthMonitor } from './multi-agent-orchestrator-CFOzWVNd.cjs';
4
+ export { a as AgentMemory, b as AgentMemoryConfig, c as AgentOrchestrator, d as AgentRegistration, e as AgentRegistry, B as BackpressureStrategy, f as DebateConfig, g as DebatePattern, h as DebateResult, i as DebugTimelineListener, j as DebugTimelineOptions, k as DoneChunk, l as ErrorChunk, G as GuardrailTriggeredChunk, m as HandoffRequest, n as HandoffResult, o as HealthCircuitState, M as MemoryManageResult, p as MemoryState, q as MemoryStrategy, r as MemoryStrategyConfig, s as MemoryStrategyResult, t as MergedTaggedStreamResult, u as MessageChunk, v as MessageSummarizer, w as MultiAgentOrchestrator, x as MultiAgentOrchestratorOptions, y as MultiAgentRunCallOptions, z as MultiAgentState, C as MultiplexedStreamChunk, F as MultiplexedStreamResult, O as OrchestratorOptions, I as OrchestratorStreamChunk, J as OrchestratorStreamResult, P as ParallelPattern, K as ProgressChunk, R as RacePattern, L as RaceResult, N as RaceSuccessEntry, Q as ReflectIterationRecord, T as ReflectPattern, U as ReflectionConfig, V as ReflectionContext, W as ReflectionEvaluation, X as ReflectionEvaluator, Y as ReflectionExhaustedError, Z as RunAgentRequirement, _ as RunCallOptions, $ as SafeParseResult, a0 as SafeParseable, a1 as Semaphore, a2 as SequentialPattern, a3 as SerializedDagNode, a4 as SerializedGoalNode, a5 as SpawnOnConditionOptions, a6 as SpawnPoolConfig, a7 as StreamChunk, a8 as StreamRunOptions, a9 as StreamRunner, aa as StreamingGuardrail, ab as StreamingGuardrailResult, ac as StreamingRunResult, ad as StructuredOutputConfig, ae as StructuredOutputError, af as SupervisorPattern, ag as TaskContext, ah as TaskRegistration, ai as TokenChunk, aj as ToolEndChunk, ak as ToolStartChunk, al as adaptOutputGuardrail, am as aggregateTokens, an as allReadyStrategy, ao as capabilityRoute, ap as collectOutputs, aq as collectTokens, ar as combineStreamingGuardrails, as as composePatterns, at as concatResults, au as costEfficientStrategy, av as createAgentMemory, aw as createAgentOrchestrator, ax as createDebugTimeline, ay as createDebugTimelinePlugin, az as createHealthMonitor, aA as createHybridStrategy, aB as createKeyPointsSummarizer, aC as createLLMSummarizer, aD as createLengthStreamingGuardrail, aE as createMultiAgentOrchestrator, aF as createPatternStreamingGuardrail, aG as createSlidingWindowStrategy, aH as createStreamingRunner, aI as createTokenBasedStrategy, aJ as createToxicityStreamingGuardrail, aK as createTruncationSummarizer, aL as dag, aM as debate, aN as derivedConstraint, aO as diffCheckpoints, aP as extractJsonFromOutput, aQ as filterStream, aR as findAgentsByCapability, aS as forkFromCheckpoint, aT as getCheckpointProgress, aU as getPatternStep, aV as goal, aW as highestImpactStrategy, aX as mapStream, aY as mergeTaggedStreams, aZ as parallel, a_ as patternFromJSON, a$ as patternToJSON, b0 as pickBestResult, b1 as race, b2 as reflect, b3 as runAgentRequirement, b4 as runDebate, b5 as selectAgent, b6 as sequential, b7 as spawnOnCondition, b8 as spawnPool, b9 as supervisor, ba as tapStream, bb as withReflection, bc as withStructuredOutput } from './multi-agent-orchestrator-CFOzWVNd.cjs';
5
5
  export { AggregatedMetric, AlertConfig, AlertEvent, CircuitBreaker, CircuitBreakerConfig, CircuitBreakerOpenError, CircuitBreakerStats, CircuitState, DashboardData, MetricDataPoint, MetricType, OTLPExporter, OTLPExporterConfig, ObservabilityConfig, ObservabilityInstance, TraceSpan, createAgentMetrics, createCircuitBreaker, createOTLPExporter, createObservability } from '@directive-run/core/plugins';
6
6
  import { ModuleSchema, Plugin } from '@directive-run/core';
7
7
  import { E as Embedding, a as EmbedderFn } from './semantic-cache-F0psCRuz.cjs';
@@ -12,7 +12,12 @@ export { B as BatchedEmbedder, C as CacheEntry, b as CacheLookupResult, c as Cac
12
12
  */
13
13
 
14
14
  /**
15
- * Create a PII detection guardrail.
15
+ * Create a PII detection guardrail that scans input text for personally identifiable
16
+ * information. Blocks input when PII is detected, or optionally redacts matches and
17
+ * passes the sanitized text through.
18
+ *
19
+ * @param options - Configuration for PII detection: `patterns` sets the RegExp list (defaults to SSN, credit card, email), `redact` replaces matches instead of blocking, `redactReplacement` sets the replacement string (defaults to `"[REDACTED]"`).
20
+ * @returns An input guardrail that blocks or redacts PII in user input.
16
21
  *
17
22
  * @example
18
23
  * ```typescript
@@ -24,6 +29,8 @@ export { B as BatchedEmbedder, C as CacheEntry, b as CacheLookupResult, c as Cac
24
29
  * redact: true,
25
30
  * });
26
31
  * ```
32
+ *
33
+ * @public
27
34
  */
28
35
  declare function createPIIGuardrail(options: {
29
36
  patterns?: RegExp[];
@@ -31,7 +38,12 @@ declare function createPIIGuardrail(options: {
31
38
  redactReplacement?: string;
32
39
  }): GuardrailFn<InputGuardrailData>;
33
40
  /**
34
- * Create a content moderation guardrail.
41
+ * Create a content moderation guardrail that delegates to a user-supplied check function.
42
+ * Works on both input and output data — the guardrail extracts the text content
43
+ * automatically and passes it to {@link options.checkFn}.
44
+ *
45
+ * @param options - Configuration for content moderation: `checkFn` returns `true` when content should be flagged (supports async), `message` sets the rejection reason (defaults to `"Content flagged by moderation"`).
46
+ * @returns A guardrail that blocks content flagged by the check function.
35
47
  *
36
48
  * @example
37
49
  * ```typescript
@@ -42,6 +54,8 @@ declare function createPIIGuardrail(options: {
42
54
  * },
43
55
  * });
44
56
  * ```
57
+ *
58
+ * @public
45
59
  */
46
60
  declare function createModerationGuardrail(options: {
47
61
  checkFn: (text: string) => boolean | Promise<boolean>;
@@ -52,15 +66,44 @@ interface RateLimitGuardrail extends GuardrailFn<InputGuardrailData> {
52
66
  reset(): void;
53
67
  }
54
68
  /**
55
- * Create a rate limit guardrail based on token usage.
56
- * Returns a guardrail function with an additional `reset()` method for testing.
69
+ * Create a rate limit guardrail that tracks token and request counts over a sliding
70
+ * one-minute window. Returns a {@link RateLimitGuardrail} a guardrail function with
71
+ * an additional `reset()` method for testing.
72
+ *
73
+ * @param options - Configuration for rate limiting: `maxTokensPerMinute` caps tokens in the sliding window (defaults to `100000`), `maxRequestsPerMinute` caps requests (defaults to `60`).
74
+ * @returns A rate limit guardrail with an attached `reset()` method.
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const rateLimiter = createRateLimitGuardrail({
79
+ * maxTokensPerMinute: 50000,
80
+ * maxRequestsPerMinute: 30,
81
+ * });
82
+ * ```
83
+ *
84
+ * @public
57
85
  */
58
86
  declare function createRateLimitGuardrail(options: {
59
87
  maxTokensPerMinute?: number;
60
88
  maxRequestsPerMinute?: number;
61
89
  }): RateLimitGuardrail;
62
90
  /**
63
- * Create a tool allowlist/denylist guardrail.
91
+ * Create a tool-call guardrail that restricts which tools an agent may invoke.
92
+ * Supports allowlist mode, denylist mode, or both — when both are provided, a tool
93
+ * must appear in the allowlist and not appear in the denylist.
94
+ *
95
+ * @param options - Configuration for tool filtering: `allowlist` sets permitted tool names, `denylist` sets blocked tool names, `caseSensitive` controls case matching (defaults to `false`).
96
+ * @returns A tool-call guardrail that enforces the allowlist/denylist rules.
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * const toolGuardrail = createToolGuardrail({
101
+ * allowlist: ["search", "calculate"],
102
+ * denylist: ["delete_account"],
103
+ * });
104
+ * ```
105
+ *
106
+ * @public
64
107
  */
65
108
  declare function createToolGuardrail(options: {
66
109
  allowlist?: string[];
@@ -69,14 +112,48 @@ declare function createToolGuardrail(options: {
69
112
  caseSensitive?: boolean;
70
113
  }): GuardrailFn<ToolCallGuardrailData>;
71
114
  /**
72
- * Create an output schema validation guardrail.
115
+ * Create an output guardrail that validates agent output against a schema using
116
+ * a user-supplied {@link SchemaValidator}. Compatible with any validation library
117
+ * (Zod, Valibot, ArkType, etc.) via the adapter pattern.
118
+ *
119
+ * @param options - Configuration for schema validation: `validate` checks the output against the expected schema, `errorPrefix` is prepended to error messages (defaults to `"Output schema validation failed"`).
120
+ * @returns An output guardrail that rejects output failing schema validation.
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * import { z } from "zod";
125
+ *
126
+ * const schemaGuardrail = createOutputSchemaGuardrail({
127
+ * validate: (value) => {
128
+ * const result = z.object({ answer: z.string() }).safeParse(value);
129
+ * return { valid: result.success, errors: result.error?.issues.map(i => i.message) };
130
+ * },
131
+ * });
132
+ * ```
133
+ *
134
+ * @public
73
135
  */
74
136
  declare function createOutputSchemaGuardrail<T = unknown>(options: {
75
137
  validate: SchemaValidator<T>;
76
138
  errorPrefix?: string;
77
139
  }): GuardrailFn<OutputGuardrailData>;
78
140
  /**
79
- * Create a simple type check guardrail for common output types.
141
+ * Create an output guardrail that performs lightweight runtime type checks without
142
+ * requiring a schema library. Supports `"string"`, `"number"`, `"boolean"`, `"object"`,
143
+ * and `"array"` with optional size and field constraints.
144
+ *
145
+ * @param options - Configuration for type checking: `type` sets the expected JS type, `requiredFields` lists object keys that must exist, `minLength`/`maxLength` constrain array size, `minStringLength`/`maxStringLength` constrain string length.
146
+ * @returns An output guardrail that rejects output not matching the expected type or constraints.
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * const typeGuardrail = createOutputTypeGuardrail({
151
+ * type: "object",
152
+ * requiredFields: ["id", "name"],
153
+ * });
154
+ * ```
155
+ *
156
+ * @public
80
157
  */
81
158
  declare function createOutputTypeGuardrail(options: {
82
159
  type: "string" | "number" | "boolean" | "object" | "array";
@@ -87,14 +164,21 @@ declare function createOutputTypeGuardrail(options: {
87
164
  maxStringLength?: number;
88
165
  }): GuardrailFn<OutputGuardrailData>;
89
166
  /**
90
- * Create a length guardrail that limits output size.
167
+ * Create an output guardrail that enforces maximum length constraints on agent output,
168
+ * measured in characters or estimated tokens.
169
+ *
170
+ * @param options - Configuration for length limits: `maxCharacters` caps character count, `maxTokens` caps estimated token count, `estimateTokens` provides a custom token estimator (defaults to `Math.ceil(text.length / 4)`).
171
+ * @returns An output guardrail that rejects output exceeding the configured length limits.
91
172
  *
92
173
  * @example
93
174
  * ```typescript
94
175
  * const lengthGuardrail = createLengthGuardrail({
95
176
  * maxCharacters: 5000,
177
+ * maxTokens: 1200,
96
178
  * });
97
179
  * ```
180
+ *
181
+ * @public
98
182
  */
99
183
  declare function createLengthGuardrail(options: {
100
184
  /** Maximum characters in output */
@@ -105,7 +189,15 @@ declare function createLengthGuardrail(options: {
105
189
  estimateTokens?: (text: string) => number;
106
190
  }): GuardrailFn<OutputGuardrailData>;
107
191
  /**
108
- * Create a content filter guardrail that blocks output matching specific patterns.
192
+ * Create an output guardrail that blocks content matching any of the provided patterns.
193
+ * String patterns are escaped and compiled to RegExp; RegExp patterns are used as-is.
194
+ *
195
+ * @remarks
196
+ * A warning is logged when `blockedPatterns` is empty, since an empty list means no
197
+ * content will ever be filtered.
198
+ *
199
+ * @param options - Configuration for content filtering: `blockedPatterns` lists strings or RegExps to match against output, `caseSensitive` controls case matching for string patterns (defaults to `false`).
200
+ * @returns An output guardrail that rejects output containing any blocked pattern.
109
201
  *
110
202
  * @example
111
203
  * ```typescript
@@ -117,6 +209,8 @@ declare function createLengthGuardrail(options: {
117
209
  * ],
118
210
  * });
119
211
  * ```
212
+ *
213
+ * @public
120
214
  */
121
215
  declare function createContentFilterGuardrail(options: {
122
216
  /** Patterns to block — strings or RegExp */
@@ -129,21 +223,39 @@ declare function createContentFilterGuardrail(options: {
129
223
  * Agent utilities — createRunner, estimateCost, state queries, URL validation.
130
224
  */
131
225
 
132
- /** Check if agent is currently running. */
226
+ /**
227
+ * Check whether an agent is currently executing a run.
228
+ *
229
+ * @param state - The current {@link AgentState} to inspect.
230
+ * @returns `true` when the agent status is `"running"`.
231
+ */
133
232
  declare function isAgentRunning(state: AgentState): boolean;
134
- /** Check if there are pending approvals. */
233
+ /**
234
+ * Check whether there are tool-call approvals waiting for user confirmation.
235
+ *
236
+ * @param state - The current {@link ApprovalState} to inspect.
237
+ * @returns `true` when one or more approvals are pending.
238
+ */
135
239
  declare function hasPendingApprovals(state: ApprovalState): boolean;
136
240
  /**
137
- * Get total cost estimate based on token usage.
241
+ * Estimate the dollar cost of an agent run based on total token usage.
138
242
  *
139
- * @param tokenUsage - Total token count
140
- * @param ratePerMillionTokens - Cost per million tokens (required, no default to avoid stale pricing)
141
- * @returns Estimated cost in dollars
243
+ * @remarks
244
+ * No default rate is provided callers must supply the current per-million-token
245
+ * price to avoid silently using stale pricing.
246
+ *
247
+ * @param tokenUsage - Total number of tokens consumed (input + output).
248
+ * @param ratePerMillionTokens - Cost in dollars per one million tokens.
249
+ * @returns Estimated cost in dollars.
142
250
  */
143
251
  declare function estimateCost(tokenUsage: number, ratePerMillionTokens: number): number;
144
252
  /**
145
- * Validate that a baseURL uses http or https.
146
- * Throws immediately at adapter creation time (not at call time) to catch config errors early.
253
+ * Validate that a base URL uses the `http:` or `https:` protocol.
254
+ * Throws immediately at adapter creation time (not at call time) to surface
255
+ * configuration errors before any LLM requests are made.
256
+ *
257
+ * @param baseURL - The base URL string to validate.
258
+ * @throws When the URL is malformed or uses a protocol other than `http:` or `https:`.
147
259
  */
148
260
  declare function validateBaseURL(baseURL: string): void;
149
261
  /** Parsed response from an LLM provider */
@@ -168,14 +280,21 @@ interface CreateRunnerOptions {
168
280
  hooks?: AdapterHooks;
169
281
  }
170
282
  /**
171
- * Create an AgentRunner from buildRequest/parseResponse helpers.
172
- * Reduces ~50 lines of fetch boilerplate to ~20 lines of configuration.
283
+ * Create an {@link AgentRunner} from `buildRequest`/`parseResponse` helpers, reducing
284
+ * ~50 lines of fetch boilerplate to ~20 lines of configuration.
173
285
  *
286
+ * @remarks
174
287
  * Supports lifecycle hooks for observability:
175
288
  * - `onBeforeCall` fires before each API request
176
289
  * - `onAfterCall` fires after a successful response (includes token breakdown)
177
290
  * - `onError` fires when the request fails
178
291
  *
292
+ * Output parsing defaults to `JSON.parse` with a string fallback. Supply a custom
293
+ * `parseOutput` to override (e.g. for structured output schemas).
294
+ *
295
+ * @param options - Configuration for the runner, including request building, response parsing, and hooks.
296
+ * @returns An {@link AgentRunner} function that performs LLM calls via fetch.
297
+ *
179
298
  * @example
180
299
  * ```typescript
181
300
  * const runClaude = createRunner({
@@ -209,6 +328,8 @@ interface CreateRunnerOptions {
209
328
  * },
210
329
  * });
211
330
  * ```
331
+ *
332
+ * @public
212
333
  */
213
334
  declare function createRunner(options: CreateRunnerOptions): AgentRunner;
214
335
 
@@ -281,7 +402,7 @@ interface MermaidOptions {
281
402
  * // fetch[fetcher] --> report[reporter]
282
403
  * ```
283
404
  *
284
- * @throws {Error} If pattern type is not one of the 8 known types.
405
+ * @throws If pattern type is not one of the 8 known types.
285
406
  */
286
407
  declare function patternToMermaid(pattern: ExecutionPattern<unknown> | SerializedPattern, options?: MermaidOptions): string;
287
408
 
@@ -3634,9 +3755,12 @@ interface EvalCostOptions {
3634
3755
  /**
3635
3756
  * Evaluate cost efficiency — scores based on token usage relative to a budget.
3636
3757
  *
3637
- * Score = 1.0 when tokens <= maxTokensPerRun * 0.5
3638
- * Score = 0.0 when tokens >= maxTokensPerRun * 2
3758
+ * Score = 1.0 when tokens \<= maxTokensPerRun * 0.5,
3759
+ * Score = 0.0 when tokens \>= maxTokensPerRun * 2.
3639
3760
  * Linear interpolation between.
3761
+ *
3762
+ * @param options - Cost evaluation options including `maxTokensPerRun`.
3763
+ * @returns An eval criterion that scores token usage against the budget.
3640
3764
  */
3641
3765
  declare function evalCost(options: EvalCostOptions): EvalCriterion;
3642
3766
  /** Options for latency evaluation */
@@ -3647,9 +3771,12 @@ interface EvalLatencyOptions {
3647
3771
  /**
3648
3772
  * Evaluate latency — scores based on agent run duration.
3649
3773
  *
3650
- * Score = 1.0 when duration <= maxMs * 0.5
3651
- * Score = 0.0 when duration >= maxMs * 2
3774
+ * Score = 1.0 when duration \<= maxMs * 0.5,
3775
+ * Score = 0.0 when duration \>= maxMs * 2.
3652
3776
  * Linear interpolation between.
3777
+ *
3778
+ * @param options - Latency evaluation options including `maxMs`.
3779
+ * @returns An eval criterion that scores run duration against the limit.
3653
3780
  */
3654
3781
  declare function evalLatency(options: EvalLatencyOptions): EvalCriterion;
3655
3782
  /** Options for output length evaluation */
@@ -3710,6 +3837,12 @@ interface EvalJudgeOptions {
3710
3837
  /** Timeout for the judge call in ms. Default: 30_000 */
3711
3838
  timeoutMs?: number;
3712
3839
  }
3840
+ /**
3841
+ * Evaluate output quality by delegating to a judge agent that scores from 0.0 to 1.0.
3842
+ *
3843
+ * @param options - Judge evaluation options including `runner`, `judge` agent, and optional `promptTemplate`.
3844
+ * @returns An eval criterion that runs a judge agent and returns its score.
3845
+ */
3713
3846
  declare function evalJudge(options: EvalJudgeOptions): EvalCriterion;
3714
3847
  /**
3715
3848
  * Evaluate exact or substring match against expected output.
@@ -3720,6 +3853,12 @@ interface EvalMatchOptions {
3720
3853
  /** Case-insensitive matching. Default: true */
3721
3854
  caseInsensitive?: boolean;
3722
3855
  }
3856
+ /**
3857
+ * Evaluate exact or substring match against expected output.
3858
+ *
3859
+ * @param options - Match evaluation options including `mode` and `caseInsensitive`.
3860
+ * @returns An eval criterion that checks output against the expected value.
3861
+ */
3723
3862
  declare function evalMatch(options?: EvalMatchOptions): EvalCriterion;
3724
3863
  /** Options for LLM-based semantic evaluation criteria */
3725
3864
  interface EvalSemanticOptions {