@dudko.dev/agent 0.0.45 → 0.0.47

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,8 @@
1
- import { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js';
1
+ import { OAuthClientProvider, OAuthDiscoveryState } from '@modelcontextprotocol/sdk/client/auth.js';
2
2
  import { FetchLike } from '@modelcontextprotocol/sdk/shared/transport.js';
3
- import { ToolSet, LanguageModel, Tool, SystemModelMessage, ModelMessage } from 'ai';
3
+ import { Experimental_DecisionModel, ToolSet, Tool, ImageModel, SpeechModel, TranscriptionModel, LanguageModel, SystemModelMessage, ModelMessage } from 'ai';
4
4
  import { OAuthClientMetadata, OAuthClientInformationMixed, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
5
+ import { JsonWebKey, KeyObject } from 'node:crypto';
5
6
 
6
7
  /**
7
8
  * Steering a run that is already going.
@@ -27,6 +28,13 @@ interface SubagentInfo {
27
28
  /** The profile the parent chose for this call, when it chose one. */
28
29
  profile?: string;
29
30
  startedAt: number;
31
+ /** The subagent that started it; absent when the run itself did. */
32
+ parentId?: string;
33
+ /** 1 for the run's own subagents, 2 for theirs, ... (set for helpers the model started). */
34
+ depth?: number;
35
+ /** Set for a helper the model started with spawn_subagent: the role it was given, if any. */
36
+ dynamic?: true;
37
+ role?: string;
30
38
  }
31
39
  interface RunControl {
32
40
  /**
@@ -54,6 +62,269 @@ interface RunControl {
54
62
  }
55
63
  declare const createRunControl: () => RunControl;
56
64
 
65
+ interface IDecisionOption {
66
+ id: string;
67
+ description?: string;
68
+ }
69
+ interface IDecisionQuestion {
70
+ id: string;
71
+ prompt: string;
72
+ options: readonly IDecisionOption[];
73
+ context?: string;
74
+ }
75
+ interface IDecisionCallOptions {
76
+ abortSignal?: AbortSignal;
77
+ }
78
+ interface IDecisionAnswer {
79
+ choice: string;
80
+ confidence: number;
81
+ usage?: {
82
+ inputTokens?: number;
83
+ outputTokens?: number;
84
+ };
85
+ }
86
+ interface IDecisionModel {
87
+ readonly name?: string;
88
+ decide: (question: IDecisionQuestion, options: IDecisionCallOptions) => Promise<IDecisionAnswer>;
89
+ }
90
+ interface IDecisionConfig {
91
+ confidenceThreshold?: number;
92
+ timeoutMs?: number;
93
+ replan?: boolean;
94
+ route?: boolean;
95
+ }
96
+ declare const DEFAULT_DECISION_CONFIDENCE_THRESHOLD = 0.8;
97
+ declare const DEFAULT_DECISION_TIMEOUT_MS = 5000;
98
+ type DecisionPoint = 'replan' | 'route';
99
+ type DecisionFallbackReason = 'low-confidence' | 'invalid-choice' | 'invalid-confidence' | 'error' | 'timeout' | 'needs-model';
100
+ interface IDecisionOutcome {
101
+ accepted: boolean;
102
+ choice?: string;
103
+ confidence?: number;
104
+ threshold: number;
105
+ reason?: DecisionFallbackReason;
106
+ error?: string;
107
+ durationMs: number;
108
+ usage?: {
109
+ inputTokens?: number;
110
+ outputTokens?: number;
111
+ };
112
+ }
113
+ interface IDecisionEvent {
114
+ type: 'decision';
115
+ point: DecisionPoint;
116
+ accepted: boolean;
117
+ choice?: string;
118
+ confidence?: number;
119
+ threshold: number;
120
+ reason?: DecisionFallbackReason;
121
+ error?: string;
122
+ durationMs: number;
123
+ model?: string;
124
+ }
125
+ declare const askDecisionModel: (model: IDecisionModel, question: IDecisionQuestion, config?: IDecisionConfig, signal?: AbortSignal) => Promise<IDecisionOutcome>;
126
+ interface IAiSdkDecisionOptions {
127
+ name?: string;
128
+ maxRetries?: number;
129
+ headers?: Record<string, string>;
130
+ }
131
+ declare const decisionModelFromAiSdk: (model: Experimental_DecisionModel, options?: IAiSdkDecisionOptions) => IDecisionModel;
132
+
133
+ interface PipelineDefinition {
134
+ version: 1;
135
+ name?: string;
136
+ entry: string;
137
+ nodes: PipelineNode[];
138
+ edges: PipelineEdge[];
139
+ limits?: {
140
+ maxNodeVisits?: number;
141
+ maxRuns?: number;
142
+ };
143
+ }
144
+ interface PipelineNode {
145
+ id: string;
146
+ name?: string;
147
+ instructions?: string;
148
+ model?: string;
149
+ skills?: string[];
150
+ tools?: string[];
151
+ mcpServers?: string[];
152
+ routes?: PipelineRoute[];
153
+ join?: 'all' | 'any';
154
+ settings?: Record<string, unknown>;
155
+ position?: {
156
+ x: number;
157
+ y: number;
158
+ };
159
+ }
160
+ interface PipelineRoute {
161
+ label: string;
162
+ description?: string;
163
+ }
164
+ type PipelineCondition = {
165
+ kind: 'always';
166
+ } | {
167
+ kind: 'contains';
168
+ text: string;
169
+ caseSensitive?: boolean;
170
+ } | {
171
+ kind: 'matches';
172
+ pattern: string;
173
+ flags?: string;
174
+ } | {
175
+ kind: 'route';
176
+ label: string;
177
+ } | {
178
+ kind: 'otherwise';
179
+ };
180
+ interface PipelineEdge {
181
+ id?: string;
182
+ from: string;
183
+ to: string;
184
+ when?: PipelineCondition;
185
+ }
186
+ declare const PIPELINE_LIMITS: {
187
+ readonly maxNodeVisits: 3;
188
+ readonly maxRuns: 25;
189
+ readonly maxNodeVisitsCeiling: 100;
190
+ readonly maxRunsCeiling: 1000;
191
+ readonly maxNodes: 200;
192
+ readonly maxEdges: 1000;
193
+ readonly maxRoutes: 20;
194
+ readonly maxPatternLength: 500;
195
+ readonly maxPatternProgram: 1000;
196
+ readonly conditionInputChars: 50000;
197
+ };
198
+ interface PipelineUsage {
199
+ inputTokens: number;
200
+ outputTokens: number;
201
+ totalTokens: number;
202
+ reasoningTokens?: number;
203
+ cachedInputTokens?: number;
204
+ cacheWriteTokens?: number;
205
+ }
206
+ interface PipelineNodeSource {
207
+ nodeId: string;
208
+ name?: string;
209
+ text: string;
210
+ }
211
+ interface PipelineNodeInput {
212
+ request: string;
213
+ from: PipelineNodeSource[];
214
+ visit: number;
215
+ }
216
+ interface PipelineNodeOutput {
217
+ text: string;
218
+ usage?: PipelineUsage;
219
+ route?: string;
220
+ }
221
+ interface PipelineNodeContext<E = never> {
222
+ signal: AbortSignal;
223
+ pipeline: PipelineDefinition;
224
+ emit: (event: E) => void;
225
+ }
226
+ type PipelineNodeRunner<E = never> = (node: PipelineNode, input: PipelineNodeInput, ctx: PipelineNodeContext<E>) => Promise<PipelineNodeOutput>;
227
+ type PipelineStop = 'maxRuns' | 'maxNodeVisits' | 'aborted';
228
+ type PipelineEvent = {
229
+ type: 'pipeline.started';
230
+ pipeline?: string;
231
+ } | {
232
+ type: 'pipeline.node.started';
233
+ nodeId: string;
234
+ visit: number;
235
+ from: string[];
236
+ } | {
237
+ type: 'pipeline.node.finished';
238
+ nodeId: string;
239
+ visit: number;
240
+ text: string;
241
+ route?: string;
242
+ usage?: PipelineUsage;
243
+ } | {
244
+ type: 'pipeline.node.failed';
245
+ nodeId: string;
246
+ visit: number;
247
+ error: string;
248
+ } | {
249
+ type: 'pipeline.node.skipped';
250
+ nodeId: string;
251
+ from: string[];
252
+ reason: 'maxRuns' | 'maxNodeVisits';
253
+ } | {
254
+ type: 'pipeline.edge';
255
+ from: string;
256
+ to: string;
257
+ edgeId: string;
258
+ visit: number;
259
+ fired: boolean;
260
+ } | {
261
+ type: 'pipeline.finished';
262
+ stoppedBy?: PipelineStop;
263
+ runs: number;
264
+ };
265
+ type PipelineTraceEntry = {
266
+ type: 'node';
267
+ nodeId: string;
268
+ visit: number;
269
+ wave: number;
270
+ from: string[];
271
+ text: string;
272
+ route?: string;
273
+ usage?: PipelineUsage;
274
+ } | {
275
+ type: 'edge';
276
+ from: string;
277
+ to: string;
278
+ edgeId: string;
279
+ visit: number;
280
+ fired: boolean;
281
+ } | {
282
+ type: 'dropped';
283
+ nodeId: string;
284
+ from: string[];
285
+ reason: 'maxRuns' | 'maxNodeVisits';
286
+ };
287
+ interface PipelineResult {
288
+ text: string;
289
+ outputs: Record<string, {
290
+ visit: number;
291
+ text: string;
292
+ route?: string;
293
+ }[]>;
294
+ trace: PipelineTraceEntry[];
295
+ usage: PipelineUsage;
296
+ stoppedBy?: PipelineStop;
297
+ runs: number;
298
+ }
299
+ interface PipelineIssue {
300
+ code: string;
301
+ message: string;
302
+ nodeId?: string;
303
+ edgeId?: string;
304
+ edgeIndex?: number;
305
+ }
306
+ interface PipelineValidation {
307
+ ok: boolean;
308
+ errors: PipelineIssue[];
309
+ warnings: PipelineIssue[];
310
+ }
311
+ declare class PipelineValidationError extends Error {
312
+ errors: PipelineIssue[];
313
+ constructor(errors: PipelineIssue[]);
314
+ }
315
+ declare class PipelineNodeError extends Error {
316
+ nodeId: string;
317
+ visit: number;
318
+ constructor(nodeId: string, visit: number, cause: unknown);
319
+ }
320
+ declare const testPipelineCondition: (when: PipelineCondition | undefined, output: {
321
+ text: string;
322
+ route?: string;
323
+ }, matcher?: (text: string) => boolean) => boolean;
324
+ declare const normalizePipeline: (definition: PipelineDefinition) => PipelineDefinition;
325
+ declare const validatePipeline: (definition: PipelineDefinition) => PipelineValidation;
326
+ declare const renderPipelineNodeInput: (input: PipelineNodeInput) => string;
327
+
57
328
  type EgressErrorCode = 'disabled' | 'bad-url' | 'bad-protocol' | 'bad-port' | 'bad-method' | 'credentials-in-url' | 'denied-host' | 'not-allowed-host' | 'denied-address' | 'dns' | 'bad-redirect' | 'too-many-redirects' | 'too-large' | 'timeout';
58
329
  declare class EgressError extends Error {
59
330
  readonly code: EgressErrorCode;
@@ -99,10 +370,328 @@ declare const checkRedirect: (from: URL, to: URL) => void;
99
370
  type SafeFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
100
371
  declare const createSafeFetch: (policy?: IEgressPolicy) => SafeFetch;
101
372
 
373
+ /**
374
+ * What the `web_search` tools of the two agent packages share: the result shape and its caps, how
375
+ * a search engine's answer is cleaned before a model reads it, and the built-in adapters as pure
376
+ * request builders and response parsers (one HTTP call each). Pure, no imports: the request itself
377
+ * is made by each package's own safe fetch.
378
+ *
379
+ * This file is a COPY, byte for byte, in `@dudko.dev/agent` (`src/web-search-shared.ts`) and
380
+ * `@dudko.dev/agent-web` (`src/tools/web-search-shared.ts`): change both. The Node package's
381
+ * `tests/web-search-shared.test.ts` compares the two files and tests every cap and guard here.
382
+ */
383
+ declare const WEB_SEARCH_TOOL = "web_search";
384
+ /** Results returned when neither the host nor the model says how many. */
385
+ declare const SEARCH_DEFAULT_MAX_RESULTS = 5;
386
+ /** The most results one call returns, whatever the host or the model asks for. */
387
+ declare const SEARCH_MAX_RESULTS = 10;
388
+ /** The longest query sent to a search engine, in characters. */
389
+ declare const SEARCH_MAX_QUERY_CHARS = 400;
390
+ /** The most of a result's title a model sees. */
391
+ declare const SEARCH_MAX_TITLE_CHARS = 200;
392
+ /** A result whose URL is longer than this is dropped (a cut URL is another URL). */
393
+ declare const SEARCH_MAX_URL_CHARS = 2000;
394
+ /** The most of a result's snippet a model sees. */
395
+ declare const SEARCH_MAX_SNIPPET_CHARS = 500;
396
+ /** The most all results of one call take together (titles, URLs, snippets, dates). */
397
+ declare const SEARCH_MAX_TOTAL_CHARS = 6000;
398
+ /** One search result, as the model sees it. Third-party text: data, never instructions. */
399
+ interface ISearchResult {
400
+ title: string;
401
+ url: string;
402
+ snippet: string;
403
+ /** When the page was published or last changed, as the engine reported it. */
404
+ date?: string;
405
+ }
406
+ type SearchFreshness = 'day' | 'week' | 'month' | 'year';
407
+ /** What a search engine function is called with, next to the query. */
408
+ interface ISearchOptions {
409
+ /** How many results are wanted (1..SEARCH_MAX_RESULTS); more are cut. */
410
+ maxResults: number;
411
+ /** Only results from the last day / week / month / year, when the model asked for it. */
412
+ freshness?: SearchFreshness;
413
+ /** Aborted when the run is stopped. */
414
+ signal?: AbortSignal;
415
+ }
416
+ /**
417
+ * A search engine of the host's own: any function that answers a query with results. What it
418
+ * returns is treated like a built-in adapter's answer - cleaned, capped and filtered.
419
+ */
420
+ type SearchEngine = (query: string, options: ISearchOptions) => Promise<ISearchResult[]>;
421
+ /** The hosted search APIs with a built-in adapter. */
422
+ type SearchProvider = 'brave' | 'tavily' | 'searxng';
423
+ declare const SEARCH_PROVIDERS: readonly SearchProvider[];
424
+ /** Where each hosted API lives. SearXNG is self-hosted: its `baseURL` is the host's to give. */
425
+ declare const SEARCH_API_BASE_URL: Record<'brave' | 'tavily', string>;
426
+ /** One HTTP call to a search API. The key, if any, is in `headers` only - never in the URL. */
427
+ interface ISearchRequest {
428
+ url: string;
429
+ method: 'GET' | 'POST';
430
+ headers: Record<string, string>;
431
+ body?: string;
432
+ }
433
+ interface ISearchRequestInput {
434
+ provider: SearchProvider;
435
+ query: string;
436
+ maxResults: number;
437
+ freshness?: SearchFreshness;
438
+ apiKey?: string;
439
+ baseURL?: string;
440
+ }
441
+ /**
442
+ * The request for one query, per the API's public documentation:
443
+ * - brave: GET {base}/res/v1/web/search?q=&count= header X-Subscription-Token
444
+ * - tavily: POST {base}/search { query, max_results } header Authorization: Bearer
445
+ * - searxng: GET {base}/search?q=&format=json no key
446
+ */
447
+ declare const buildSearchRequest: (input: ISearchRequestInput) => ISearchRequest;
448
+ /**
449
+ * The results inside an API's JSON answer, mapped to `{ title, url, snippet, date }` and nothing
450
+ * else. Still raw third-party values: `sanitizeSearchResults` is what makes them safe to show.
451
+ */
452
+ declare const parseSearchResponse: (provider: SearchProvider, json: unknown) => unknown[];
453
+ interface ISanitizedSearch {
454
+ results: ISearchResult[];
455
+ /** Results dropped because the host's egress policy does not let the model reach them. */
456
+ filtered: number;
457
+ /** True when results were left out for a cap (the count, or the total size). */
458
+ truncated: boolean;
459
+ }
460
+ /**
461
+ * What a model sees of an engine's answer. `raw` is whatever came back - nothing about it is
462
+ * trusted: a result needs a valid http(s) URL, every field is cleaned and capped, duplicates go,
463
+ * `accepts` (the egress policy) drops links the model could not fetch, and the list stops at
464
+ * `maxResults` and at SEARCH_MAX_TOTAL_CHARS.
465
+ */
466
+ declare const sanitizeSearchResults: (raw: unknown, options?: {
467
+ maxResults?: number;
468
+ accepts?: (url: URL) => boolean;
469
+ }) => ISanitizedSearch;
470
+
471
+ interface ISearchConfig {
472
+ engine?: SearchEngine;
473
+ provider?: SearchProvider;
474
+ apiKey?: string;
475
+ baseURL?: string;
476
+ maxResults?: number;
477
+ allowPrivateNetwork?: boolean;
478
+ timeoutMs?: number;
479
+ readOnly?: boolean;
480
+ }
481
+ interface IWebSearchOptions {
482
+ search: ISearchConfig;
483
+ egress?: boolean | IEgressPolicy;
484
+ fetch?: SafeFetch;
485
+ }
486
+ declare const searchEgressPolicy: (search: ISearchConfig, egress?: boolean | IEgressPolicy) => IEgressPolicy;
487
+ declare const createWebSearchTool: (options: IWebSearchOptions) => Tool;
488
+ declare const createSearchTools: (search: ISearchConfig | undefined, egress?: boolean | IEgressPolicy) => ToolSet | undefined;
489
+
490
+ declare const RUN_JS_TOOL = "run_js";
491
+ interface ISandboxConfig {
492
+ timeoutMs?: number;
493
+ memoryLimitBytes?: number;
494
+ maxOutputChars?: number;
495
+ maxCodeChars?: number;
496
+ files?: boolean;
497
+ }
498
+ interface ISandboxLimits {
499
+ timeoutMs: number;
500
+ memoryLimitBytes: number;
501
+ maxOutputChars: number;
502
+ maxCodeChars: number;
503
+ }
504
+ declare const resolveSandboxLimits: (config: ISandboxConfig | undefined) => ISandboxLimits;
505
+ interface ISandboxError {
506
+ name: string;
507
+ message: string;
508
+ stack?: string;
509
+ }
510
+ interface ISandboxResult {
511
+ ok: boolean;
512
+ stdout: string;
513
+ result?: unknown;
514
+ error?: ISandboxError;
515
+ truncated: boolean;
516
+ durationMs: number;
517
+ }
518
+ declare class SandboxUnavailableError extends Error {
519
+ constructor(message: string);
520
+ }
521
+
522
+ declare const GENERATE_IMAGE_TOOL = "generate_image";
523
+ declare const GENERATE_SPEECH_TOOL = "generate_speech";
524
+ declare const TRANSCRIBE_AUDIO_TOOL = "transcribe_audio";
525
+ type MediaKind = 'image' | 'speech' | 'transcription';
526
+ declare const MEDIA_DEFAULT_MAX_CALLS = 8;
527
+ declare const MEDIA_TIMEOUT_MS = 120000;
528
+ declare const MEDIA_MAX_IMAGE_BYTES: number;
529
+ declare const MEDIA_MAX_SPEECH_BYTES: number;
530
+ declare const MEDIA_MAX_AUDIO_INPUT_BYTES: number;
531
+ declare const MEDIA_MAX_PROMPT_CHARS = 4000;
532
+ declare const MEDIA_MAX_SPEECH_CHARS = 4000;
533
+ declare const MEDIA_MAX_TRANSCRIPT_CHARS = 20000;
534
+ declare const MEDIA_MAX_ATTACHED_AUDIO = 4;
535
+ declare const MEDIA_FOLDER = "media";
536
+ declare class MediaError extends Error {
537
+ constructor(message: string);
538
+ toJSON(): string;
539
+ }
540
+ declare class MediaBudgetError extends MediaError {
541
+ constructor(cap: number);
542
+ }
543
+ declare const MEDIA_IMAGE_TYPES: Readonly<Record<string, string>>;
544
+ declare const MEDIA_AUDIO_TYPES: Readonly<Record<string, string>>;
545
+ declare const sniffMediaType: (bytes: Uint8Array) => string | undefined;
546
+ interface IAcceptedMedia {
547
+ mediaType: string;
548
+ ext: string;
549
+ }
550
+ declare const acceptMedia: (family: "image" | "audio", bytes: Uint8Array, maxBytes: number, what: string) => IAcceptedMedia;
551
+ interface IMediaUsage {
552
+ mediaCalls: number;
553
+ imagesGenerated: number;
554
+ speechCharacters: number;
555
+ transcriptionSeconds: number;
556
+ }
557
+ declare const mediaUsageOf: (usage: Partial<IMediaUsage> | undefined) => IMediaUsage | undefined;
558
+ interface ITranscriptBlock {
559
+ name: string;
560
+ text: string;
561
+ language?: string;
562
+ durationInSeconds?: number;
563
+ }
564
+ declare const wrapTranscript: (block: ITranscriptBlock) => string;
565
+
566
+ type IMediaModelSpec = IAgentStageOverride & {
567
+ model: string;
568
+ };
569
+ type MediaImageModel = Exclude<ImageModel, string>;
570
+ type MediaSpeechModel = Exclude<SpeechModel, string>;
571
+ type MediaTranscriptionModel = Exclude<TranscriptionModel, string>;
572
+ interface IMediaConfig {
573
+ imageModel?: MediaImageModel | IMediaModelSpec;
574
+ speechModel?: MediaSpeechModel | IMediaModelSpec;
575
+ transcriptionModel?: MediaTranscriptionModel | IMediaModelSpec;
576
+ maxCalls?: number;
577
+ timeoutMs?: number;
578
+ dir?: string;
579
+ voice?: string;
580
+ speechFormat?: string;
581
+ }
582
+ interface IRunFile {
583
+ data: string | Uint8Array;
584
+ mediaType?: string;
585
+ name?: string;
586
+ }
587
+ interface IMediaFile {
588
+ path: string;
589
+ mediaType: string;
590
+ bytes: number;
591
+ }
592
+ interface ITranscription {
593
+ path: string;
594
+ text: string;
595
+ language?: string;
596
+ durationInSeconds?: number;
597
+ truncated?: true;
598
+ untrusted: true;
599
+ }
600
+ interface IMedia {
601
+ tools: ToolSet;
602
+ attach: (input: string, files: IRunFile[], signal?: AbortSignal) => Promise<string>;
603
+ }
604
+ declare const createMedia: (config: IAgentConfig) => Promise<IMedia | undefined>;
605
+
606
+ declare const SPAWN_SUBAGENT_TOOL = "spawn_subagent";
607
+ type SubagentDefaultTools = 'read-only' | 'all';
608
+ interface IDynamicSubagentsConfig {
609
+ maxDepth?: number;
610
+ maxChildren?: number;
611
+ maxConcurrent?: number;
612
+ budgetShare?: number;
613
+ minTokens?: number;
614
+ timeoutMs?: number;
615
+ defaultTools?: SubagentDefaultTools;
616
+ }
617
+ interface ISubagentsConfig {
618
+ dynamic?: boolean | IDynamicSubagentsConfig;
619
+ }
620
+ interface IResolvedDynamicSubagents {
621
+ maxDepth: number;
622
+ maxChildren: number;
623
+ maxConcurrent: number;
624
+ budgetShare: number;
625
+ minTokens: number;
626
+ timeoutMs: number;
627
+ defaultTools: SubagentDefaultTools;
628
+ }
629
+ declare const SUBAGENT_DEFAULTS: IResolvedDynamicSubagents;
630
+ declare const SUBAGENT_MAX_DEPTH_LIMIT = 4;
631
+ /**
632
+ * The effective settings, or undefined when the feature is off (nothing is mounted, nothing is
633
+ * added to a prompt). A bad value is a configuration error, thrown when the agent is created.
634
+ */
635
+ declare const resolveDynamicSubagents: (subagents: ISubagentsConfig | undefined) => IResolvedDynamicSubagents | undefined;
636
+ /**
637
+ * A spawn that was refused: the model reads the message as the tool's error and can correct the
638
+ * call or carry on without a helper.
639
+ */
640
+ declare class SubagentSpawnError extends Error {
641
+ constructor(message: string);
642
+ toJSON(): string;
643
+ }
644
+ declare const SPAWN_INPUT_SCHEMA: {
645
+ readonly type: "object";
646
+ readonly properties: {
647
+ readonly task: {
648
+ readonly type: "string";
649
+ readonly description: "The complete, self-contained sub-task. The helper sees nothing of your context except this text: include every fact, id and constraint it needs, and say what to return.";
650
+ };
651
+ readonly role: {
652
+ readonly type: "string";
653
+ readonly description: "Optional: who the helper should be for this task and how to work, in a sentence or two (e.g. \"a careful code reviewer; report only real bugs\").";
654
+ };
655
+ readonly tools: {
656
+ readonly type: "array";
657
+ readonly items: {
658
+ readonly type: "string";
659
+ };
660
+ readonly description: "Optional: the names of YOUR tools the helper may use. Only tools you have can be named. Omit it for the default set; pass [] for a helper that only reasons.";
661
+ };
662
+ };
663
+ readonly required: readonly ["task"];
664
+ readonly additionalProperties: false;
665
+ };
666
+ /**
667
+ * A child's event on its way up through the subagent `parentId` (the `subagent.event` envelope is
668
+ * added by the caller). A `subagent.start` is emitted with `depth: 1` and the id of the run that
669
+ * made the call as `parentId`; each subagent it passes through on the way up adds one level, and
670
+ * the first one - its real parent - puts its own id in `parentId`. So at the top of the stream
671
+ * every start carries its true depth and parent, whatever mix of static and dynamic subagents,
672
+ * threads and workers is below.
673
+ */
674
+ declare const adoptSubagentEvent: <E extends {
675
+ type: string;
676
+ }>(event: E, parentId: string) => E;
677
+
102
678
  type ProviderType = 'openai' | 'anthropic' | 'openai-compatible' | 'google' | 'xai' | 'azure' | 'amazon-bedrock' | 'google-vertex' | 'deepseek' | 'gateway' | 'cloudflare';
103
679
  type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
104
680
  type ToolSelectionStrategy = 'all' | 'plan-narrowed' | 'search' | 'auto';
105
681
  type AgentStage = 'planner' | 'executor' | 'replanner' | 'synthesizer';
682
+ type ModelTier = 'light' | 'standard' | 'strong';
683
+ type StepComplexity = 'low' | 'medium' | 'high';
684
+ type TierReason = 'planned' | 'default' | 'fallback';
685
+ type EscalationReason = 'blocked' | 'empty-result' | 'tool-arguments' | 'output-cut' | 'error';
686
+ interface IStepEscalation {
687
+ from: ModelTier;
688
+ to: ModelTier;
689
+ reason: EscalationReason;
690
+ }
691
+ interface IEscalationConfig {
692
+ maxPerStep?: number;
693
+ maxPerRun?: number;
694
+ }
106
695
  type ThinkingLevel = 'provider-default' | 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
107
696
  interface IThinkingConfig {
108
697
  level?: ThinkingLevel;
@@ -180,6 +769,10 @@ interface IToolApprovalRequest {
180
769
  readOnly: boolean;
181
770
  step?: IPlanStep;
182
771
  runId?: string;
772
+ subagent?: {
773
+ id: string;
774
+ depth: number;
775
+ };
183
776
  }
184
777
  type ToolApprovalDecision = boolean | {
185
778
  approved: boolean;
@@ -234,13 +827,21 @@ interface IAgentConfig {
234
827
  providerOptions?: Record<string, unknown>;
235
828
  planner?: IAgentStageOverride;
236
829
  synthesizer?: IAgentStageOverride;
830
+ executorTiers?: Partial<Record<ModelTier, IAgentStageOverride>>;
831
+ escalation?: boolean | IEscalationConfig;
237
832
  /** @deprecated use `planner: { model }` */
238
833
  plannerModel?: string;
239
834
  /** @deprecated use `synthesizer: { model }` */
240
835
  synthesizerModel?: string;
241
836
  mcpServers: Record<string, IMcpServerConfig>;
242
837
  egress?: boolean | IEgressPolicy;
838
+ search?: ISearchConfig;
839
+ decisionModel?: IDecisionModel;
840
+ decision?: IDecisionConfig;
243
841
  learning?: boolean | ILearningConfig;
842
+ sandbox?: boolean | ISandboxConfig;
843
+ media?: IMediaConfig;
844
+ subagents?: ISubagentsConfig;
244
845
  tools?: ToolSet;
245
846
  availableTools?: string[];
246
847
  excludedTools?: string[];
@@ -259,6 +860,7 @@ interface IAgentConfig {
259
860
  toolApproval?: IToolApprovalConfig;
260
861
  toolSearchThreshold?: number;
261
862
  mcpConnectTimeoutMs?: number;
863
+ mcpInstructions?: boolean;
262
864
  promptCaching?: PromptCachingSetting;
263
865
  llmTimeoutMs?: number;
264
866
  llmMaxRetries?: number;
@@ -284,6 +886,11 @@ interface IUsage {
284
886
  reasoningTokens?: number;
285
887
  cachedInputTokens?: number;
286
888
  cacheWriteTokens?: number;
889
+ mediaCalls?: number;
890
+ imagesGenerated?: number;
891
+ speechCharacters?: number;
892
+ transcriptionSeconds?: number;
893
+ decisionCalls?: number;
287
894
  }
288
895
  interface IPlanStep {
289
896
  id: string;
@@ -291,6 +898,7 @@ interface IPlanStep {
291
898
  expectedOutcome: string;
292
899
  suggestedTools?: string[];
293
900
  requiresTools?: boolean;
901
+ complexity?: StepComplexity;
294
902
  }
295
903
  interface IPlan {
296
904
  thought: string;
@@ -308,10 +916,13 @@ interface IStepResult {
308
916
  }[];
309
917
  durationMs: number;
310
918
  blocked: boolean;
919
+ tier?: ModelTier;
920
+ model?: string;
921
+ escalations?: IStepEscalation[];
311
922
  }
312
923
  type ReplanTrigger = 'failure' | 'always' | ((result: IStepResult) => boolean | Promise<boolean>);
313
- type ReplanCause = 'last-step' | 'clean-step' | 'llm-decision' | 'user-message';
314
- type UsagePhase = 'plan' | 'execute' | 'replan' | 'synthesize' | 'compact' | 'subagent';
924
+ type ReplanCause = 'last-step' | 'clean-step' | 'llm-decision' | 'user-message' | 'decision-model';
925
+ type UsagePhase = 'plan' | 'execute' | 'replan' | 'synthesize' | 'compact' | 'subagent' | 'decision' | 'media';
315
926
  type AgentEventBody = {
316
927
  type: 'plan.thought-delta';
317
928
  delta: string;
@@ -330,6 +941,16 @@ type AgentEventBody = {
330
941
  type: 'step.start';
331
942
  step: IPlanStep;
332
943
  index: number;
944
+ tier?: ModelTier;
945
+ model?: string;
946
+ tierReason?: TierReason;
947
+ } | {
948
+ type: 'step.escalated';
949
+ step: IPlanStep;
950
+ from: ModelTier;
951
+ to: ModelTier;
952
+ model: string;
953
+ reason: EscalationReason;
333
954
  } | {
334
955
  type: 'step.text-delta';
335
956
  step: IPlanStep;
@@ -358,7 +979,9 @@ type AgentEventBody = {
358
979
  mode: 'continue' | 'revise' | 'finish';
359
980
  reason: string;
360
981
  cause: ReplanCause;
361
- } | {
982
+ failed?: true;
983
+ confidence?: number;
984
+ } | IDecisionEvent | {
362
985
  type: 'final.text-delta';
363
986
  delta: string;
364
987
  } | {
@@ -406,6 +1029,10 @@ type AgentEventBody = {
406
1029
  input: unknown;
407
1030
  readOnly: boolean;
408
1031
  step?: IPlanStep;
1032
+ subagent?: {
1033
+ id: string;
1034
+ depth: number;
1035
+ };
409
1036
  } | {
410
1037
  type: 'tool.approval-resolved';
411
1038
  id: string;
@@ -419,6 +1046,11 @@ type AgentEventBody = {
419
1046
  name: string;
420
1047
  task: string;
421
1048
  profile?: string;
1049
+ parentId?: string;
1050
+ depth?: number;
1051
+ dynamic?: true;
1052
+ role?: string;
1053
+ tools?: string[];
422
1054
  } | {
423
1055
  type: 'subagent.event';
424
1056
  id: string;
@@ -436,6 +1068,7 @@ type AgentEventBody = {
436
1068
  name: string;
437
1069
  error: string;
438
1070
  stopped?: boolean;
1071
+ usage?: IUsage;
439
1072
  } | {
440
1073
  type: 'message.queued';
441
1074
  id: string;
@@ -461,6 +1094,22 @@ type AgentEventBody = {
461
1094
  } | {
462
1095
  type: 'skill.forgotten';
463
1096
  name: string;
1097
+ } | {
1098
+ type: 'media.generated';
1099
+ kind: 'image' | 'speech';
1100
+ path: string;
1101
+ mediaType: string;
1102
+ bytes: number;
1103
+ model: string;
1104
+ step?: IPlanStep;
1105
+ } | {
1106
+ type: 'media.transcribed';
1107
+ source: 'attachment' | 'tool';
1108
+ name: string;
1109
+ text: string;
1110
+ language?: string;
1111
+ durationInSeconds?: number;
1112
+ model: string;
464
1113
  } | {
465
1114
  type: 'revisions.exceeded';
466
1115
  cap: number;
@@ -468,9 +1117,11 @@ type AgentEventBody = {
468
1117
  type: 'error';
469
1118
  error: Error;
470
1119
  phase: 'plan' | 'execute' | 'replan' | 'synthesize' | 'init';
471
- };
1120
+ } | PipelineEvent;
472
1121
  type AgentEvent = AgentEventBody & {
473
1122
  runId?: string;
1123
+ nodeId?: string;
1124
+ visit?: number;
474
1125
  };
475
1126
  type EventHandler = (event: AgentEvent) => void;
476
1127
  interface IStepStartInfo {
@@ -481,6 +1132,7 @@ interface IStepStartInfo {
481
1132
  interface IAgentRunOptions {
482
1133
  input: string;
483
1134
  history?: IConversationTurn[];
1135
+ files?: IRunFile[];
484
1136
  signal?: AbortSignal;
485
1137
  onEvent?: EventHandler;
486
1138
  onStepStart?: (info: IStepStartInfo) => void;
@@ -519,6 +1171,8 @@ interface IRunSnapshot {
519
1171
  text: string;
520
1172
  reconciled: boolean;
521
1173
  }[];
1174
+ escalations?: number;
1175
+ subagentsSpawned?: number;
522
1176
  }
523
1177
  interface IPersistence {
524
1178
  onRunStart?: (snapshot: IRunSnapshot) => void | Promise<void>;
@@ -604,10 +1258,14 @@ interface IToolDecision {
604
1258
  */
605
1259
  declare const decideToolPermission: (input: IToolDecisionInput) => IToolDecision;
606
1260
 
1261
+ declare const REPLAY_NOTE = "[not run again: this exact call already succeeded in an earlier attempt at this step, and its effect is in place. Its result then:]";
1262
+ declare const isReplayedToolOutput: (output: unknown) => boolean;
1263
+
607
1264
  declare const getCurrentRunId: () => string | undefined;
608
1265
  declare const getCurrentRunSandbox: () => string | undefined;
609
1266
 
610
1267
  declare const redactHeaders: (headers: Record<string, string> | undefined) => Record<string, string> | undefined;
1268
+ type IFilledUsage = Required<Omit<IUsage, 'decisionCalls' | keyof IMediaUsage>> & Pick<IUsage, 'decisionCalls'> & Partial<IMediaUsage>;
611
1269
  interface ISdkUsageLike {
612
1270
  inputTokens?: number;
613
1271
  outputTokens?: number;
@@ -619,19 +1277,26 @@ interface ISdkUsageLike {
619
1277
  outputTokenDetails?: {
620
1278
  reasoningTokens?: number;
621
1279
  };
1280
+ decisionCalls?: number;
622
1281
  reasoningTokens?: number;
623
1282
  cachedInputTokens?: number;
1283
+ mediaCalls?: number;
1284
+ imagesGenerated?: number;
1285
+ speechCharacters?: number;
1286
+ transcriptionSeconds?: number;
624
1287
  }
625
- declare const normalizeUsage: (usage: ISdkUsageLike | undefined | null) => Required<IUsage>;
626
- declare const addUsage: (a: IUsage, b: IUsage) => Required<IUsage>;
1288
+ declare const normalizeUsage: (usage: ISdkUsageLike | undefined | null) => IFilledUsage;
1289
+ declare const addUsage: (a: IUsage, b: IUsage) => IFilledUsage;
627
1290
 
628
1291
  /**
629
1292
  * OAuth 2.1 for remote MCP servers, from Node.
630
1293
  *
631
1294
  * The MCP SDK owns the protocol - discovery (RFC 9728), dynamic client
632
- * registration (RFC 7591), PKCE, the code exchange and the refresh on 401.
633
- * What it does not own, and what this module supplies, is WHERE the resulting
634
- * tokens live between processes and HOW an operator is asked to authorize.
1295
+ * registration (RFC 7591) or a client ID metadata document (CIMD), PKCE, the
1296
+ * code exchange and the refresh on 401. What it does not own, and what this
1297
+ * module supplies, is WHERE the resulting tokens live between processes, HOW an
1298
+ * operator is asked to authorize, and the check of the `iss` parameter on the
1299
+ * way back (RFC 9207).
635
1300
  *
636
1301
  * Pass the result to `mcpServers[name].authProvider`.
637
1302
  */
@@ -689,8 +1354,19 @@ interface INodeOAuthProviderOptions {
689
1354
  clientName?: string;
690
1355
  /** Fallback scope when the server advertises none. */
691
1356
  scope?: string;
692
- /** Merged over the defaults (e.g. `software_id`, `contacts`). */
693
- clientMetadata?: Partial<OAuthClientMetadata>;
1357
+ /** Merged over the defaults (e.g. `software_id`, `contacts`, `application_type`). */
1358
+ clientMetadata?: Partial<OAuthClientMetadata> & {
1359
+ application_type?: string;
1360
+ };
1361
+ /**
1362
+ * URL of a client ID metadata document (CIMD) you host. When the
1363
+ * authorization server advertises `client_id_metadata_document_supported`,
1364
+ * this URL is used as the `client_id` and no dynamic registration is made;
1365
+ * otherwise registration runs as before. A registration already in the store
1366
+ * wins over both. Must be https with a non-root path, and the document served
1367
+ * there must list the same `redirect_uris` as `redirectUrl`.
1368
+ */
1369
+ clientMetadataUrl?: string;
694
1370
  /** Defaults to a 0600 JSON file under ~/.agent. */
695
1371
  store?: IOAuthStore;
696
1372
  /** Treat the access token as expired this many seconds early. Default 30. */
@@ -702,6 +1378,25 @@ interface INodeOAuthProviderOptions {
702
1378
  */
703
1379
  onAuthorizationUrl?: (url: URL) => void | Promise<void>;
704
1380
  }
1381
+ /**
1382
+ * RFC 9207: is the `iss` parameter of an authorization response the
1383
+ * authorization server this flow was started with? Throws when it is not; the
1384
+ * caller must not exchange the code then (a mix-up attack hands the code of an
1385
+ * honest server to another one's token endpoint).
1386
+ *
1387
+ * - expected issuer: the `issuer` of the stored authorization server metadata,
1388
+ * else the authorization server URL discovery used;
1389
+ * - `iss` present: it must equal the expected issuer, compared as plain strings
1390
+ * (RFC 9207 section 2.4: no normalization);
1391
+ * - `iss` absent: refused when the metadata says
1392
+ * `authorization_response_iss_parameter_supported: true`;
1393
+ * - no stored discovery state (a store written by an older version): `iss` is
1394
+ * compared with the issuer stamped on the stored client information, and with
1395
+ * nothing to compare against the response is accepted.
1396
+ *
1397
+ * The browser package carries the same function; change both.
1398
+ */
1399
+ declare const checkAuthorizationResponseIssuer: (iss: string | undefined, discoveryState: OAuthDiscoveryState | undefined, clientIssuer?: string) => void;
705
1400
  /**
706
1401
  * A persistent `OAuthClientProvider`. Also exposes `isAccessTokenExpired`,
707
1402
  * which `connectMcpServers` uses to refresh a known-dead token before the
@@ -715,11 +1410,14 @@ declare class NodeOAuthProvider implements OAuthClientProvider {
715
1410
  private readonly ns;
716
1411
  private readonly _redirectUrl;
717
1412
  private readonly _clientMetadata;
1413
+ private readonly _clientMetadataUrl?;
718
1414
  private readonly skewMs;
719
1415
  private readonly onAuthorizationUrl?;
720
1416
  constructor(opts: INodeOAuthProviderOptions);
721
1417
  get redirectUrl(): string;
722
1418
  get clientMetadata(): OAuthClientMetadata;
1419
+ /** The client ID metadata document URL (CIMD), when one was configured. */
1420
+ get clientMetadataUrl(): string | undefined;
723
1421
  private key;
724
1422
  private readJSON;
725
1423
  state(): Promise<string>;
@@ -731,17 +1429,25 @@ declare class NodeOAuthProvider implements OAuthClientProvider {
731
1429
  saveTokens(tokens: OAuthTokens): Promise<void>;
732
1430
  saveCodeVerifier(verifier: string): Promise<void>;
733
1431
  codeVerifier(): Promise<string>;
1432
+ /**
1433
+ * What discovery found (the authorization server, its metadata, the resource
1434
+ * metadata). The SDK reuses it instead of discovering again, and
1435
+ * {@link finishMcpOAuth} reads the expected issuer from it.
1436
+ */
1437
+ saveDiscoveryState(state: OAuthDiscoveryState): Promise<void>;
1438
+ discoveryState(): Promise<OAuthDiscoveryState | undefined>;
734
1439
  redirectToAuthorization(url: URL): Promise<void>;
735
1440
  /**
736
1441
  * Called by the SDK when the server rejects what we hold: `'tokens'` on an
737
- * `invalid_grant` (dead refresh token), `'client'` / `'all'` on an
738
- * `invalid_client` (the AS forgot our dynamic registration).
1442
+ * `invalid_grant` (dead refresh token), `'all'` on an `invalid_client` (the
1443
+ * AS forgot our dynamic registration). `'client'`, `'verifier'` and
1444
+ * `'discovery'` are in its type and handled the same way: one key each.
739
1445
  */
740
- invalidateCredentials(scope: 'all' | 'client' | 'tokens' | 'verifier'): Promise<void>;
1446
+ invalidateCredentials(scope: 'all' | 'client' | 'tokens' | 'verifier' | 'discovery'): Promise<void>;
741
1447
  /** True when there is no access token, or it expires within the skew window. */
742
1448
  isAccessTokenExpired(): Promise<boolean>;
743
1449
  isAuthorized(): Promise<boolean>;
744
- /** Forget tokens, registration, verifier and state for this server. */
1450
+ /** Forget tokens, registration, verifier, state and discovery for this server. */
745
1451
  reset(): Promise<void>;
746
1452
  }
747
1453
  /** Convenience factory mirroring the rest of the package's `createX` style. */
@@ -759,15 +1465,343 @@ interface IOAuthRequestOptions {
759
1465
  */
760
1466
  declare const beginMcpOAuth: (provider: NodeOAuthProvider, opts?: IOAuthRequestOptions) => Promise<"AUTHORIZED" | "REDIRECT">;
761
1467
  /**
762
- * Complete the flow with the `code` (and `state`) the authorization server sent
763
- * back. Verifies `state`, exchanges the code with the stored PKCE verifier and
764
- * persists the tokens. Throws unless the exchange fully succeeded.
1468
+ * Complete the flow with the `code` (and `state`, and `iss` when the redirect
1469
+ * carried one) the authorization server sent back. Verifies `state`, then the
1470
+ * issuer (RFC 9207, {@link checkAuthorizationResponseIssuer}), exchanges the
1471
+ * code with the stored PKCE verifier and persists the tokens. Throws unless the
1472
+ * exchange fully succeeded.
765
1473
  */
766
1474
  declare const finishMcpOAuth: (provider: NodeOAuthProvider, callback: {
767
1475
  code: string;
768
1476
  state?: string;
1477
+ iss?: string;
769
1478
  }, opts?: IOAuthRequestOptions) => Promise<void>;
770
1479
 
1480
+ /**
1481
+ * What the MCP connectors of the two agent packages share: how a server's `instructions` reach a
1482
+ * system prompt, and how a tool result's `structuredContent` reaches the model. Pure, no imports.
1483
+ *
1484
+ * This file is a COPY, byte for byte, in `@dudko.dev/agent` (`src/mcp-shared.ts`) and
1485
+ * `@dudko.dev/agent-web` (`src/mcp/shared.ts`): change both. The Node package's
1486
+ * `tests/mcp-shared.test.ts` compares the two files and tests every cap and guard here.
1487
+ */
1488
+ /** The `instructions` one connected MCP server returned in its `initialize` result. */
1489
+ interface McpServerInstructions {
1490
+ /** The server's name: its key in the host's configuration. */
1491
+ server: string;
1492
+ instructions: string;
1493
+ }
1494
+ /** The most one server's instructions take in a system prompt, in characters. */
1495
+ declare const MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER = 2000;
1496
+ /** The most all servers' instructions take together, in characters. */
1497
+ declare const MCP_INSTRUCTIONS_MAX_CHARS_TOTAL = 8000;
1498
+ /**
1499
+ * The system-prompt section for the servers' instructions, or '' when no server sent any (the
1500
+ * prompt is then exactly what it was). Each server's text is capped
1501
+ * (MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER), so is the sum (MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, in
1502
+ * the order given: a server past the total is named as omitted), and every line of it is
1503
+ * prefixed with "| ", so a server cannot write something that reads as a heading of this prompt
1504
+ * or as another server's note.
1505
+ */
1506
+ declare const renderMcpInstructions: (list: readonly McpServerInstructions[] | undefined) => string;
1507
+
1508
+ /**
1509
+ * Enterprise-Managed Authorization for remote MCP servers (the MCP extension
1510
+ * `io.modelcontextprotocol/enterprise-managed-authorization`, also called Cross
1511
+ * App Access): the organization's identity provider decides which MCP servers
1512
+ * a user's client may reach, and no one is sent to a consent page.
1513
+ *
1514
+ * Two hops, both plain HTTP POSTs:
1515
+ *
1516
+ * 1. at the IdP - an RFC 8693 token exchange turns the user's ID token into an
1517
+ * Identity Assertion JWT Authorization Grant (ID-JAG) addressed to the MCP
1518
+ * server's authorization server;
1519
+ * 2. at the MCP authorization server - an RFC 7523 `jwt-bearer` grant turns the
1520
+ * ID-JAG into an ordinary access token.
1521
+ *
1522
+ * The MCP SDK owns discovery (RFC 9728 / RFC 8414), the second hop and the
1523
+ * retry on a 401; this module supplies the first hop and the checks around it.
1524
+ * Only the resulting access token is stored. The ID token, the ID-JAG and the
1525
+ * client assertions pass through memory and are never written, logged or put
1526
+ * in an error.
1527
+ *
1528
+ * The client authenticates on each hop with a secret or with a signed
1529
+ * assertion (`private_key_jwt`, RFC 7523 section 2.2). By default the audience
1530
+ * of that assertion is the issuer identifier of the server it is for and
1531
+ * nothing else, as draft-ietf-oauth-rfc7523bis requires: an assertion made for
1532
+ * the IdP is of no use at the authorization server, and the other way round.
1533
+ * For a server built to RFC 7523 as published, `assertionAudience:
1534
+ * 'token-endpoint'` and `assertionType: 'JWT'` produce the older form - see
1535
+ * `EnterpriseAssertionAudience` for what that gives up.
1536
+ *
1537
+ * Follows draft-ietf-oauth-identity-assertion-authz-grant and the extension's
1538
+ * 2026-07-28 revision. The browser package carries the same provider; change both.
1539
+ *
1540
+ * Pass the result to `mcpServers[name].authProvider`.
1541
+ */
1542
+ /** The extension identifier a client declares in its capabilities. */
1543
+ declare const ENTERPRISE_MANAGED_AUTHORIZATION_EXTENSION = "io.modelcontextprotocol/enterprise-managed-authorization";
1544
+ /** Which part of the flow refused. */
1545
+ type EnterpriseOAuthHop = 'discovery' | 'idp' | 'authorization-server';
1546
+ /**
1547
+ * A failure of the enterprise flow, with the hop that refused: `'discovery'`
1548
+ * (what the MCP server published cannot be trusted or used), `'idp'` (the token
1549
+ * exchange) or `'authorization-server'` (the `jwt-bearer` grant). The message
1550
+ * is short and safe to show: never a request body, a token, an assertion, a
1551
+ * secret or a key. What the authorization server said in full goes to the log
1552
+ * (`onLog`), redacted the same way.
1553
+ */
1554
+ declare class EnterpriseOAuthError extends Error {
1555
+ readonly hop: EnterpriseOAuthHop;
1556
+ /** The OAuth `error` code the server answered with, when it sent one. */
1557
+ readonly code?: string;
1558
+ constructor(hop: EnterpriseOAuthHop, message: string, code?: string);
1559
+ }
1560
+ /** Signature algorithms for a `private_key_jwt` client assertion. */
1561
+ type EnterpriseAssertionAlgorithm = 'ES256' | 'ES384' | 'ES512' | 'RS256' | 'RS384' | 'RS512' | 'PS256' | 'PS384' | 'PS512';
1562
+ /**
1563
+ * The private key that signs a client assertion: a PEM string (PKCS#8 or the
1564
+ * older SEC1 / PKCS#1), a JWK object, or a `KeyObject`. It must be a key for
1565
+ * the chosen `algorithm` (an EC P-256 key for ES256, an RSA key for RS256...).
1566
+ */
1567
+ type EnterprisePrivateKey = string | JsonWebKey | KeyObject;
1568
+ /**
1569
+ * What a `private_key_jwt` client assertion names as its audience (`aud`).
1570
+ *
1571
+ * - `'issuer'` (the default): the issuer identifier of the server the
1572
+ * assertion is for, as draft-ietf-oauth-rfc7523bis requires.
1573
+ * - `'token-endpoint'`: the URL of that server's token endpoint, which is what
1574
+ * RFC 7523 as published describes and what many deployed identity providers
1575
+ * check for.
1576
+ *
1577
+ * The default is the issuer because an assertion addressed to a token endpoint
1578
+ * URL is exactly what the bis draft forbids. The token endpoint is one field of
1579
+ * a metadata document; a client that reads its audience from metadata can be
1580
+ * handed a document that names an honest server's endpoint (audience
1581
+ * injection), and then signs an assertion the party that served the document
1582
+ * can replay at that honest server. The issuer identifier is the one value a
1583
+ * client checks before it trusts the rest of the document. This provider never
1584
+ * takes either value from the MCP server alone - the IdP's endpoint is
1585
+ * configuration, and the authorization server's is used only after its
1586
+ * metadata matched `expectedIssuer` - so `'token-endpoint'` here costs the
1587
+ * defence in depth, not the check itself. Use it only for a server that
1588
+ * refuses the issuer form.
1589
+ */
1590
+ type EnterpriseAssertionAudience = 'issuer' | 'token-endpoint';
1591
+ /**
1592
+ * The `typ` header of a client assertion: `client-authentication+jwt` (the
1593
+ * default, from draft-ietf-oauth-rfc7523bis: a token typed this way cannot be
1594
+ * mistaken for another kind of JWT) or `JWT`, for a server that refuses a
1595
+ * `typ` it does not know.
1596
+ */
1597
+ type EnterpriseAssertionType = 'client-authentication+jwt' | 'JWT';
1598
+ /** Where the provider reports what it will not put in an error. */
1599
+ type EnterpriseOAuthLog = (level: 'info' | 'warn' | 'error', message: string) => void;
1600
+ interface IEnterpriseIdpOptions {
1601
+ /**
1602
+ * The IdP's token endpoint, where the token exchange is posted. Configured,
1603
+ * not discovered: it is where the user's ID token and the client's IdP
1604
+ * credentials go, so nothing fetched at run time may choose it.
1605
+ */
1606
+ tokenEndpoint: string;
1607
+ /**
1608
+ * The IdP's issuer identifier. REQUIRED with `private_key_jwt`, where it is
1609
+ * the audience of the client assertion - unless `assertionAudience` is
1610
+ * `'token-endpoint'`, which addresses the assertion to `tokenEndpoint`.
1611
+ */
1612
+ issuer?: string;
1613
+ /** This client's `client_id` at the IdP (the audience of the ID token). */
1614
+ clientId: string;
1615
+ /** This client's secret at the IdP. Omit for a client the IdP treats as public. */
1616
+ clientSecret?: string;
1617
+ /**
1618
+ * How the client authenticates at the IdP. With a secret: in an
1619
+ * `Authorization: Basic` header (the default, which every OAuth server must
1620
+ * accept) or in the form body. `'private_key_jwt'`: a signed assertion, which
1621
+ * needs `privateKey`, `algorithm` and `issuer` (or `assertionAudience:
1622
+ * 'token-endpoint'`).
1623
+ */
1624
+ clientAuthMethod?: 'client_secret_basic' | 'client_secret_post' | 'private_key_jwt';
1625
+ /** The key for `private_key_jwt`. Never stored, logged or put in an error. */
1626
+ privateKey?: EnterprisePrivateKey;
1627
+ /** `kid` header of the assertion: the key's id in the JWKS the IdP holds. */
1628
+ keyId?: string;
1629
+ /** Signature algorithm of the assertion. */
1630
+ algorithm?: EnterpriseAssertionAlgorithm;
1631
+ /**
1632
+ * The audience of the assertion: `'issuer'` (the default: `issuer`) or
1633
+ * `'token-endpoint'` (`tokenEndpoint`, for an IdP built to RFC 7523 - the
1634
+ * weaker form, see `EnterpriseAssertionAudience`). Only with `private_key_jwt`.
1635
+ */
1636
+ assertionAudience?: EnterpriseAssertionAudience;
1637
+ /**
1638
+ * The `typ` header of the assertion: `'client-authentication+jwt'` (the
1639
+ * default) or `'JWT'` for an IdP that refuses the new one. Only with
1640
+ * `private_key_jwt`.
1641
+ */
1642
+ assertionType?: EnterpriseAssertionType;
1643
+ }
1644
+ interface IEnterpriseOAuthProviderOptions {
1645
+ /** The MCP endpoint being authorized. */
1646
+ serverUrl: string;
1647
+ /**
1648
+ * This client's `client_id` at the MCP server's authorization server: a
1649
+ * pre-registered identifier, or the https URL of a client ID metadata
1650
+ * document (CIMD) you host. A URL must be https with a path of its own, and
1651
+ * cannot be used with `clientSecret`: a document anyone can read establishes
1652
+ * no shared secret, so such a client is public or uses `private_key_jwt`
1653
+ * with the keys the document lists (`jwks` / `jwks_uri`).
1654
+ */
1655
+ clientId: string;
1656
+ /**
1657
+ * Its secret there. The grant is meant for confidential clients. A secret
1658
+ * needs `expectedIssuer`: without it the MCP server's metadata would choose
1659
+ * who receives the secret, and the constructor throws.
1660
+ */
1661
+ clientSecret?: string;
1662
+ /**
1663
+ * How the client authenticates at the authorization server. Left out, the
1664
+ * SDK decides: a secret is sent the way the server's metadata allows (Basic
1665
+ * first), no secret means `client_id` alone. `'private_key_jwt'` signs an
1666
+ * assertion and needs `privateKey`, `algorithm` and `expectedIssuer`.
1667
+ */
1668
+ clientAuthMethod?: 'client_secret_basic' | 'client_secret_post' | 'private_key_jwt' | 'none';
1669
+ /** The key for `private_key_jwt`. Never stored, logged or put in an error. */
1670
+ privateKey?: EnterprisePrivateKey;
1671
+ /** `kid` header of the assertion: the key's id in the JWKS the server holds. */
1672
+ keyId?: string;
1673
+ /** Signature algorithm of the assertion. */
1674
+ algorithm?: EnterpriseAssertionAlgorithm;
1675
+ /**
1676
+ * The audience of the assertion for the authorization server: `'issuer'`
1677
+ * (the default: the issuer discovery found, once it matched
1678
+ * `expectedIssuer`) or `'token-endpoint'` (the token endpoint from that same
1679
+ * metadata, for a server built to RFC 7523 - the weaker form, see
1680
+ * `EnterpriseAssertionAudience`). The endpoint is read only from metadata
1681
+ * whose issuer is `expectedIssuer`, and must be https or loopback. Only with
1682
+ * `private_key_jwt`.
1683
+ */
1684
+ assertionAudience?: EnterpriseAssertionAudience;
1685
+ /**
1686
+ * The `typ` header of the assertion: `'client-authentication+jwt'` (the
1687
+ * default) or `'JWT'` for a server that refuses the new one. Only with
1688
+ * `private_key_jwt`.
1689
+ */
1690
+ assertionType?: EnterpriseAssertionType;
1691
+ /**
1692
+ * The issuer of the MCP server's authorization server. Anything else the MCP
1693
+ * server points at is refused before a credential leaves the process.
1694
+ * REQUIRED with `clientSecret` and with `private_key_jwt`: neither the
1695
+ * receiver of a secret nor the audience of a signed assertion may come from
1696
+ * the MCP server's metadata alone. A client with no credential at the
1697
+ * authorization server may omit it: then the only thing sent there is the
1698
+ * ID-JAG, which the IdP addressed to that one server and which is of no use
1699
+ * to any other.
1700
+ */
1701
+ expectedIssuer?: string;
1702
+ /** The enterprise identity provider. */
1703
+ idp: IEnterpriseIdpOptions;
1704
+ /**
1705
+ * The user's OpenID Connect ID token from the IdP. How it was obtained (the
1706
+ * single sign-on of your application) is yours; it is called each time a new
1707
+ * ID-JAG is needed, so return a current one. The value is never stored.
1708
+ */
1709
+ getIdToken: () => string | Promise<string>;
1710
+ /** Scopes to ask the IdP for (space-separated). */
1711
+ scope?: string;
1712
+ /** Defaults to a 0600 JSON file under ~/.agent. Holds the access token only. */
1713
+ store?: IOAuthStore;
1714
+ /** Treat the access token as expired this many seconds early. Default 30. */
1715
+ expirySkewSeconds?: number;
1716
+ /** Custom fetch for the request to the IdP. */
1717
+ fetch?: FetchLike;
1718
+ /**
1719
+ * Receives the detail a refusal's error leaves out (what the authorization
1720
+ * server answered), redacted. `connectMcpServers` passes its own log; this is
1721
+ * for a provider used without it.
1722
+ */
1723
+ onLog?: EnterpriseOAuthLog;
1724
+ }
1725
+ /**
1726
+ * A non-interactive `OAuthClientProvider`: no redirect, no browser, no human.
1727
+ * On first use, and whenever the access token is missing, expired or rejected,
1728
+ * the SDK asks it for a token request and it answers with a fresh ID-JAG.
1729
+ */
1730
+ declare class NodeEnterpriseOAuthProvider implements OAuthClientProvider {
1731
+ #private;
1732
+ readonly serverUrl: string;
1733
+ /** The MCP extension this provider implements; the connector declares it. */
1734
+ readonly extension = "io.modelcontextprotocol/enterprise-managed-authorization";
1735
+ /**
1736
+ * Present only with an explicit `clientAuthMethod`: the SDK then leaves the
1737
+ * client authentication of the grant to it (a `private_key_jwt` assertion is
1738
+ * signed here, for the issuer discovery found and `expectedIssuer` confirmed).
1739
+ */
1740
+ addClientAuthentication?: OAuthClientProvider['addClientAuthentication'];
1741
+ constructor(opts: IEnterpriseOAuthProviderOptions);
1742
+ /** Never set: this is what tells the SDK the flow has no human step. */
1743
+ get redirectUrl(): undefined;
1744
+ get clientMetadata(): OAuthClientMetadata;
1745
+ /**
1746
+ * The pre-registered client, from configuration and never from the store.
1747
+ * With `expectedIssuer` it carries that stamp, and the SDK then refuses to
1748
+ * present it to any other authorization server.
1749
+ */
1750
+ clientInformation(): OAuthClientInformationMixed;
1751
+ tokens(): Promise<OAuthTokens | undefined>;
1752
+ saveTokens(tokens: OAuthTokens): Promise<void>;
1753
+ saveDiscoveryState(state: OAuthDiscoveryState): Promise<void>;
1754
+ discoveryState(): Promise<OAuthDiscoveryState | undefined>;
1755
+ /**
1756
+ * Called by the SDK inside `auth()`, after discovery and before the token
1757
+ * request to the MCP authorization server: get an ID token from the host,
1758
+ * exchange it at the IdP for an ID-JAG addressed to exactly the authorization
1759
+ * server and resource discovery found for this server, and hand the SDK the
1760
+ * `jwt-bearer` request. Throws before anything reaches the authorization
1761
+ * server when discovery cannot be trusted or the IdP's answer is not an ID-JAG.
1762
+ */
1763
+ prepareTokenRequest(scope?: string): Promise<URLSearchParams>;
1764
+ /** The codes of the interactive flow: this provider has none. */
1765
+ redirectToAuthorization(): never;
1766
+ saveCodeVerifier(): never;
1767
+ codeVerifier(): never;
1768
+ /**
1769
+ * Called by the SDK when the authorization server rejects what it was sent.
1770
+ * The client is configuration, so there is nothing of it to forget; tokens
1771
+ * and discovery are dropped as asked.
1772
+ */
1773
+ invalidateCredentials(scope: 'all' | 'client' | 'tokens' | 'verifier' | 'discovery'): Promise<void>;
1774
+ /** True when there is no access token, or it expires within the skew window. */
1775
+ isAccessTokenExpired(): Promise<boolean>;
1776
+ isAuthorized(): Promise<boolean>;
1777
+ /**
1778
+ * The fetch to give the transport that carries this provider (the connector
1779
+ * does). It changes one thing: when the request that carries the ID-JAG is
1780
+ * refused, the caller gets an `EnterpriseOAuthError` (`hop:
1781
+ * 'authorization-server'`) with a short message - the OAuth error code and
1782
+ * the status - and what the server said in full goes to `log`, redacted.
1783
+ * That holds whenever the SDK asks for a token, at connect or in the middle
1784
+ * of a session, so an application never has the server's raw words to show.
1785
+ * A refusal is final: every grant is already a fresh one, so the SDK's
1786
+ * "drop the token and try again" would only repeat the IdP exchange.
1787
+ */
1788
+ transportFetch(base?: FetchLike, log?: EnterpriseOAuthLog): FetchLike;
1789
+ /**
1790
+ * Run the whole flow now (discovery, IdP exchange, grant) and store the
1791
+ * access token. `connectMcpServers` calls it before connecting when there is
1792
+ * no usable token; call it yourself to fail early. A refusal is an
1793
+ * `EnterpriseOAuthError` whose `hop` says who refused.
1794
+ */
1795
+ authorize(opts?: {
1796
+ fetch?: FetchLike;
1797
+ onLog?: EnterpriseOAuthLog;
1798
+ }): Promise<void>;
1799
+ /** Forget the access token and what discovery found for this server. */
1800
+ reset(): Promise<void>;
1801
+ }
1802
+ /** Convenience factory mirroring the rest of the package's `createX` style. */
1803
+ declare const createEnterpriseOAuthProvider: (opts: IEnterpriseOAuthProviderOptions) => NodeEnterpriseOAuthProvider;
1804
+
771
1805
  type ProviderOptionsMap = Record<string, Record<string, unknown>>;
772
1806
  interface IResolvedThinking {
773
1807
  reasoning?: ThinkingLevel;
@@ -979,6 +2013,49 @@ interface IWebFetchOptions {
979
2013
  declare const createWebFetchTool: (options?: IWebFetchOptions) => Tool;
980
2014
  declare const createEgressTools: (egress: boolean | IEgressPolicy | undefined) => ToolSet | undefined;
981
2015
 
2016
+ interface IResolvedStage {
2017
+ providerType: ProviderType;
2018
+ baseURL?: string;
2019
+ apiKey: string;
2020
+ model: string;
2021
+ providerOptions?: Record<string, unknown>;
2022
+ }
2023
+ type MediaModelKind = 'image' | 'speech' | 'transcription';
2024
+ declare const buildMediaModelFromStage: (clientName: string, stage: IResolvedStage, kind: MediaModelKind) => Promise<unknown>;
2025
+
2026
+ interface ISandboxDeps {
2027
+ workerUrl?: URL;
2028
+ peerInstalled?: () => boolean;
2029
+ }
2030
+ declare const createSandboxTool: (config?: ISandboxConfig, deps?: ISandboxDeps) => Tool;
2031
+ declare const createSandboxTools: (sandbox: boolean | ISandboxConfig | undefined, deps?: ISandboxDeps) => ToolSet | undefined;
2032
+
2033
+ interface PipelineOptions {
2034
+ runNode?: PipelineNodeRunner<AgentEvent>;
2035
+ resolveNode?: (node: PipelineNode) => IAgentConfig | Promise<IAgentConfig>;
2036
+ }
2037
+ interface PipelineRunOptions {
2038
+ input: string;
2039
+ signal?: AbortSignal;
2040
+ onEvent?: EventHandler;
2041
+ }
2042
+ interface Pipeline {
2043
+ definition: PipelineDefinition;
2044
+ run: (options: PipelineRunOptions) => Promise<PipelineResult>;
2045
+ close: () => Promise<void>;
2046
+ }
2047
+ declare const createPipeline: (definition: PipelineDefinition, options: PipelineOptions) => Pipeline;
2048
+ type PipelineModelConfig = Pick<IAgentConfig, 'model'> & Partial<Pick<IAgentConfig, 'providerType' | 'baseURL' | 'apiKey' | 'providerOptions' | 'planner' | 'synthesizer' | 'executorTiers'>>;
2049
+ interface NodeResolverOptions {
2050
+ base: IAgentConfig;
2051
+ models?: Record<string, PipelineModelConfig>;
2052
+ skills?: Record<string, ISkill>;
2053
+ tools?: Record<string, ToolSet>;
2054
+ mcpServers?: Record<string, IMcpServerConfig>;
2055
+ configure?: (config: IAgentConfig, node: PipelineNode) => IAgentConfig | Promise<IAgentConfig>;
2056
+ }
2057
+ declare const nodeResolver: (options: NodeResolverOptions) => NonNullable<PipelineOptions["resolveNode"]>;
2058
+
982
2059
  type SubagentIsolation = 'worker' | 'in-process';
983
2060
  interface ISubagentProfile {
984
2061
  description: string;
@@ -1005,5 +2082,5 @@ interface ISubagentToolOptions {
1005
2082
  */
1006
2083
  declare const createSubagentTool: (opts: ISubagentToolOptions) => Tool;
1007
2084
 
1008
- export { DEFAULT_COMPACTION_THRESHOLD_RATIO, DirSkillStore, EgressError, FORGET_SKILL_TOOL, FileOAuthStore, MemoryOAuthStore, MemorySkillStore, NodeOAuthProvider, SAVE_SKILL_TOOL, SUMMARY_PREFIX, ToolBudgetError, ToolDeniedError, WEB_FETCH_TOOL, addUsage, beginMcpOAuth, buildInstructions, checkEgressUrl, checkLimits, checkRedirect, classifyAddress, compactHistory, createAgent, createEgressTools, createLearning, createNodeOAuthProvider, createRunControl, createSafeFetch, createSubagentTool, createToolResultClearer, createWebFetchTool, decideToolPermission, defineSkill, estimateTokens, findSecret, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, hostMatches, htmlToText, isReadOnlyTool, loadSkillsFromDir, markReadOnly, matchToolRule, mergeProviderOptions, normalizeSkillName, normalizeUsage, parseSkillMarkdown, redactHeaders, resolveCompaction, resolveEgressPolicy, resolveLimits, resolvePromptCaching, resolveThinking, searchTools, truncateToolModelOutput, withRollingBreakpoint, withToolOutputLimit };
1009
- export type { AgentEvent, AgentStage, BudgetKind, EgressErrorCode, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, IEgressPolicy, ILearning, ILearningConfig, ILimitBreach, IMcpHttpServerConfig, IMcpServerConfig, IMcpStdioServerConfig, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IPersistence, IPlan, IPlanStep, IResolvedAddress, IResolvedThinking, IRunSnapshot, ISaveSkillInput, ISearchToolsOptions, ISkill, ISkillOrigin, ISkillStore, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, IUsage, LogLevel, PromptCachingSetting, ProviderType, ReplanCause, ReplanTrigger, RunControl, SafeFetch, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TokenLimitKind, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolSelectionStrategy, UsagePhase };
2085
+ export { DEFAULT_COMPACTION_THRESHOLD_RATIO, DEFAULT_DECISION_CONFIDENCE_THRESHOLD, DEFAULT_DECISION_TIMEOUT_MS, DirSkillStore, ENTERPRISE_MANAGED_AUTHORIZATION_EXTENSION, EgressError, EnterpriseOAuthError, FORGET_SKILL_TOOL, FileOAuthStore, GENERATE_IMAGE_TOOL, GENERATE_SPEECH_TOOL, MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER, MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, MEDIA_AUDIO_TYPES, MEDIA_DEFAULT_MAX_CALLS, MEDIA_FOLDER, MEDIA_IMAGE_TYPES, MEDIA_MAX_ATTACHED_AUDIO, MEDIA_MAX_AUDIO_INPUT_BYTES, MEDIA_MAX_IMAGE_BYTES, MEDIA_MAX_PROMPT_CHARS, MEDIA_MAX_SPEECH_BYTES, MEDIA_MAX_SPEECH_CHARS, MEDIA_MAX_TRANSCRIPT_CHARS, MEDIA_TIMEOUT_MS, MediaBudgetError, MediaError, MemoryOAuthStore, MemorySkillStore, NodeEnterpriseOAuthProvider, NodeOAuthProvider, PIPELINE_LIMITS, PipelineNodeError, PipelineValidationError, REPLAY_NOTE, RUN_JS_TOOL, SAVE_SKILL_TOOL, SEARCH_API_BASE_URL, SEARCH_DEFAULT_MAX_RESULTS, SEARCH_MAX_QUERY_CHARS, SEARCH_MAX_RESULTS, SEARCH_MAX_SNIPPET_CHARS, SEARCH_MAX_TITLE_CHARS, SEARCH_MAX_TOTAL_CHARS, SEARCH_MAX_URL_CHARS, SEARCH_PROVIDERS, SPAWN_INPUT_SCHEMA, SPAWN_SUBAGENT_TOOL, SUBAGENT_DEFAULTS, SUBAGENT_MAX_DEPTH_LIMIT, SUMMARY_PREFIX, SandboxUnavailableError, SubagentSpawnError, TRANSCRIBE_AUDIO_TOOL, ToolBudgetError, ToolDeniedError, WEB_FETCH_TOOL, WEB_SEARCH_TOOL, acceptMedia, addUsage, adoptSubagentEvent, askDecisionModel, beginMcpOAuth, buildInstructions, buildMediaModelFromStage, buildSearchRequest, checkAuthorizationResponseIssuer, checkEgressUrl, checkLimits, checkRedirect, classifyAddress, compactHistory, createAgent, createEgressTools, createEnterpriseOAuthProvider, createLearning, createMedia, createNodeOAuthProvider, createPipeline, createRunControl, createSafeFetch, createSandboxTool, createSandboxTools, createSearchTools, createSubagentTool, createToolResultClearer, createWebFetchTool, createWebSearchTool, decideToolPermission, decisionModelFromAiSdk, defineSkill, estimateTokens, findSecret, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, hostMatches, htmlToText, isReadOnlyTool, isReplayedToolOutput, loadSkillsFromDir, markReadOnly, matchToolRule, mediaUsageOf, mergeProviderOptions, nodeResolver, normalizePipeline, normalizeSkillName, normalizeUsage, parseSearchResponse, parseSkillMarkdown, redactHeaders, renderMcpInstructions, renderPipelineNodeInput, resolveCompaction, resolveDynamicSubagents, resolveEgressPolicy, resolveLimits, resolvePromptCaching, resolveSandboxLimits, resolveThinking, sanitizeSearchResults, searchEgressPolicy, searchTools, sniffMediaType, testPipelineCondition, truncateToolModelOutput, validatePipeline, withRollingBreakpoint, withToolOutputLimit, wrapTranscript };
2086
+ export type { AgentEvent, AgentStage, BudgetKind, DecisionFallbackReason, DecisionPoint, EgressErrorCode, EnterpriseAssertionAlgorithm, EnterpriseAssertionAudience, EnterpriseAssertionType, EnterpriseOAuthHop, EnterpriseOAuthLog, EnterprisePrivateKey, EscalationReason, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IAiSdkDecisionOptions, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, IDecisionAnswer, IDecisionCallOptions, IDecisionConfig, IDecisionEvent, IDecisionModel, IDecisionOption, IDecisionOutcome, IDecisionQuestion, IDynamicSubagentsConfig, IEgressPolicy, IEnterpriseIdpOptions, IEnterpriseOAuthProviderOptions, IEscalationConfig, ILearning, ILearningConfig, ILimitBreach, IMcpHttpServerConfig, IMcpServerConfig, IMcpStdioServerConfig, IMedia, IMediaConfig, IMediaFile, IMediaModelSpec, IMediaUsage, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IPersistence, IPlan, IPlanStep, IResolvedAddress, IResolvedDynamicSubagents, IResolvedThinking, IRunFile, IRunSnapshot, ISandboxConfig, ISandboxError, ISandboxLimits, ISandboxResult, ISanitizedSearch, ISaveSkillInput, ISearchConfig, ISearchOptions, ISearchRequest, ISearchResult, ISearchToolsOptions, ISkill, ISkillOrigin, ISkillStore, IStepEscalation, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, ISubagentsConfig, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, ITranscription, IUsage, IWebSearchOptions, LogLevel, McpServerInstructions, MediaImageModel, MediaKind, MediaModelKind, MediaSpeechModel, MediaTranscriptionModel, ModelTier, NodeResolverOptions, Pipeline, PipelineCondition, PipelineDefinition, PipelineEdge, PipelineEvent, PipelineIssue, PipelineModelConfig, PipelineNode, PipelineNodeContext, PipelineNodeInput, PipelineNodeOutput, PipelineNodeRunner, PipelineNodeSource, PipelineOptions, PipelineResult, PipelineRoute, PipelineRunOptions, PipelineStop, PipelineTraceEntry, PipelineUsage, PipelineValidation, PromptCachingSetting, ProviderType, ReplanCause, ReplanTrigger, RunControl, SafeFetch, SearchEngine, SearchFreshness, SearchProvider, StepComplexity, SubagentDefaultTools, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TierReason, TokenLimitKind, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolSelectionStrategy, UsagePhase };