@dudko.dev/agent 0.0.50 → 0.0.51

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,5 +1,7 @@
1
1
  import { OAuthClientProvider, FetchLike, OAuthClientMetadata, OAuthClientInformationMixed, OAuthTokens, OAuthDiscoveryState } from '@modelcontextprotocol/client';
2
2
  import { Experimental_DecisionModel, ToolSet, Tool, ImageModel, SpeechModel, TranscriptionModel, LanguageModel, SystemModelMessage, ModelMessage } from 'ai';
3
+ import { PipelineEvent, PipelineNode, PipelineDefinition, PipelineResult, PipelineNodeRunner } from './pipeline-engine.cjs';
4
+ export { PIPELINE_LIMITS, PIPELINE_ROUTER_SYSTEM, PipelineAbortBehaviour, PipelineCondition, PipelineEdge, PipelineGraphRunOptions, PipelineIssue, PipelineNodeContext, PipelineNodeError, PipelineNodeEvent, PipelineNodeInput, PipelineNodeOutput, PipelineNodeSource, PipelinePlan, PipelineRoute, PipelineStop, PipelineTraceEntry, PipelineUsage, PipelineValidation, PipelineValidationError, matchPipelineRoute, normalizePipeline, preparePipeline, renderPipelineNodeInput, renderPipelineRoutePrompt, runPipelineGraph, testPipelineCondition, validatePipeline } from './pipeline-engine.cjs';
3
5
  import { JsonWebKey, KeyObject } from 'node:crypto';
4
6
 
5
7
  /**
@@ -128,201 +130,6 @@ interface IAiSdkDecisionOptions {
128
130
  }
129
131
  declare const decisionModelFromAiSdk: (model: Experimental_DecisionModel, options?: IAiSdkDecisionOptions) => IDecisionModel;
130
132
 
131
- interface PipelineDefinition {
132
- version: 1;
133
- name?: string;
134
- entry: string;
135
- nodes: PipelineNode[];
136
- edges: PipelineEdge[];
137
- limits?: {
138
- maxNodeVisits?: number;
139
- maxRuns?: number;
140
- };
141
- }
142
- interface PipelineNode {
143
- id: string;
144
- name?: string;
145
- instructions?: string;
146
- model?: string;
147
- skills?: string[];
148
- tools?: string[];
149
- mcpServers?: string[];
150
- routes?: PipelineRoute[];
151
- join?: 'all' | 'any';
152
- settings?: Record<string, unknown>;
153
- position?: {
154
- x: number;
155
- y: number;
156
- };
157
- }
158
- interface PipelineRoute {
159
- label: string;
160
- description?: string;
161
- }
162
- type PipelineCondition = {
163
- kind: 'always';
164
- } | {
165
- kind: 'contains';
166
- text: string;
167
- caseSensitive?: boolean;
168
- } | {
169
- kind: 'matches';
170
- pattern: string;
171
- flags?: string;
172
- } | {
173
- kind: 'route';
174
- label: string;
175
- } | {
176
- kind: 'otherwise';
177
- };
178
- interface PipelineEdge {
179
- id?: string;
180
- from: string;
181
- to: string;
182
- when?: PipelineCondition;
183
- }
184
- declare const PIPELINE_LIMITS: {
185
- readonly maxNodeVisits: 3;
186
- readonly maxRuns: 25;
187
- readonly maxNodeVisitsCeiling: 100;
188
- readonly maxRunsCeiling: 1000;
189
- readonly maxNodes: 200;
190
- readonly maxEdges: 1000;
191
- readonly maxRoutes: 20;
192
- readonly maxPatternLength: 500;
193
- readonly maxPatternProgram: 1000;
194
- readonly conditionInputChars: 50000;
195
- };
196
- interface PipelineUsage {
197
- inputTokens: number;
198
- outputTokens: number;
199
- totalTokens: number;
200
- reasoningTokens?: number;
201
- cachedInputTokens?: number;
202
- cacheWriteTokens?: number;
203
- }
204
- interface PipelineNodeSource {
205
- nodeId: string;
206
- name?: string;
207
- text: string;
208
- }
209
- interface PipelineNodeInput {
210
- request: string;
211
- from: PipelineNodeSource[];
212
- visit: number;
213
- }
214
- interface PipelineNodeOutput {
215
- text: string;
216
- usage?: PipelineUsage;
217
- route?: string;
218
- }
219
- interface PipelineNodeContext<E = never> {
220
- signal: AbortSignal;
221
- pipeline: PipelineDefinition;
222
- emit: (event: E) => void;
223
- }
224
- type PipelineNodeRunner<E = never> = (node: PipelineNode, input: PipelineNodeInput, ctx: PipelineNodeContext<E>) => Promise<PipelineNodeOutput>;
225
- type PipelineStop = 'maxRuns' | 'maxNodeVisits' | 'aborted';
226
- type PipelineEvent = {
227
- type: 'pipeline.started';
228
- pipeline?: string;
229
- } | {
230
- type: 'pipeline.node.started';
231
- nodeId: string;
232
- visit: number;
233
- from: string[];
234
- } | {
235
- type: 'pipeline.node.finished';
236
- nodeId: string;
237
- visit: number;
238
- text: string;
239
- route?: string;
240
- usage?: PipelineUsage;
241
- } | {
242
- type: 'pipeline.node.failed';
243
- nodeId: string;
244
- visit: number;
245
- error: string;
246
- } | {
247
- type: 'pipeline.node.skipped';
248
- nodeId: string;
249
- from: string[];
250
- reason: 'maxRuns' | 'maxNodeVisits';
251
- } | {
252
- type: 'pipeline.edge';
253
- from: string;
254
- to: string;
255
- edgeId: string;
256
- visit: number;
257
- fired: boolean;
258
- } | {
259
- type: 'pipeline.finished';
260
- stoppedBy?: PipelineStop;
261
- runs: number;
262
- };
263
- type PipelineTraceEntry = {
264
- type: 'node';
265
- nodeId: string;
266
- visit: number;
267
- wave: number;
268
- from: string[];
269
- text: string;
270
- route?: string;
271
- usage?: PipelineUsage;
272
- } | {
273
- type: 'edge';
274
- from: string;
275
- to: string;
276
- edgeId: string;
277
- visit: number;
278
- fired: boolean;
279
- } | {
280
- type: 'dropped';
281
- nodeId: string;
282
- from: string[];
283
- reason: 'maxRuns' | 'maxNodeVisits';
284
- };
285
- interface PipelineResult {
286
- text: string;
287
- outputs: Record<string, {
288
- visit: number;
289
- text: string;
290
- route?: string;
291
- }[]>;
292
- trace: PipelineTraceEntry[];
293
- usage: PipelineUsage;
294
- stoppedBy?: PipelineStop;
295
- runs: number;
296
- }
297
- interface PipelineIssue {
298
- code: string;
299
- message: string;
300
- nodeId?: string;
301
- edgeId?: string;
302
- edgeIndex?: number;
303
- }
304
- interface PipelineValidation {
305
- ok: boolean;
306
- errors: PipelineIssue[];
307
- warnings: PipelineIssue[];
308
- }
309
- declare class PipelineValidationError extends Error {
310
- errors: PipelineIssue[];
311
- constructor(errors: PipelineIssue[]);
312
- }
313
- declare class PipelineNodeError extends Error {
314
- nodeId: string;
315
- visit: number;
316
- constructor(nodeId: string, visit: number, cause: unknown);
317
- }
318
- declare const testPipelineCondition: (when: PipelineCondition | undefined, output: {
319
- text: string;
320
- route?: string;
321
- }, matcher?: (text: string) => boolean) => boolean;
322
- declare const normalizePipeline: (definition: PipelineDefinition) => PipelineDefinition;
323
- declare const validatePipeline: (definition: PipelineDefinition) => PipelineValidation;
324
- declare const renderPipelineNodeInput: (input: PipelineNodeInput) => string;
325
-
326
133
  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';
327
134
  declare class EgressError extends Error {
328
135
  readonly code: EgressErrorCode;
@@ -1056,6 +863,81 @@ declare const MCP_SKILL_SNAPSHOT_MAX_DEPTH = 8;
1056
863
  /** The most bytes the snapshots of one agent hold in memory together. */
1057
864
  declare const MCP_SKILL_SNAPSHOTS_MAX_BYTES: number;
1058
865
 
866
+ interface IRunLease {
867
+ acquire: (runId: string, options: IRunLeaseOptions) => boolean | Promise<boolean>;
868
+ renew: (runId: string, options: IRunLeaseOptions) => boolean | Promise<boolean>;
869
+ release: (runId: string, options: {
870
+ owner: string;
871
+ }) => void | Promise<void>;
872
+ ttlMs?: number;
873
+ owner?: string;
874
+ }
875
+ interface IRunLeaseOptions {
876
+ owner: string;
877
+ ttlMs: number;
878
+ }
879
+ type RunLeaseLostReason = 'refused' | 'error' | 'expired';
880
+ declare class RunLeaseError extends Error {
881
+ readonly runId: string;
882
+ readonly owner: string;
883
+ readonly lost: boolean;
884
+ readonly reason: RunLeaseLostReason;
885
+ constructor(runId: string, owner: string, lost: boolean, reason: RunLeaseLostReason, detail?: string, options?: {
886
+ cause?: unknown;
887
+ });
888
+ toJSON(): string;
889
+ }
890
+ declare const RUN_LEASE_DEFAULT_TTL_MS = 30000;
891
+
892
+ declare const isModelCallRefused: (err: unknown, seen?: Set<unknown>) => boolean;
893
+ declare const redactHeaders: (headers: Record<string, string> | undefined) => Record<string, string> | undefined;
894
+ type IFilledUsage = Required<Omit<IUsage, 'decisionCalls' | keyof IMediaUsage>> & Pick<IUsage, 'decisionCalls'> & Partial<IMediaUsage>;
895
+ interface ISdkUsageLike {
896
+ inputTokens?: number;
897
+ outputTokens?: number;
898
+ totalTokens?: number;
899
+ inputTokenDetails?: {
900
+ cacheReadTokens?: number;
901
+ cacheWriteTokens?: number;
902
+ };
903
+ outputTokenDetails?: {
904
+ reasoningTokens?: number;
905
+ };
906
+ decisionCalls?: number;
907
+ reasoningTokens?: number;
908
+ cachedInputTokens?: number;
909
+ mediaCalls?: number;
910
+ imagesGenerated?: number;
911
+ speechCharacters?: number;
912
+ transcriptionSeconds?: number;
913
+ }
914
+ declare const normalizeUsage: (usage: ISdkUsageLike | undefined | null) => IFilledUsage;
915
+ declare const isAuthError: (err: unknown, seen?: Set<unknown>) => boolean;
916
+ declare const addUsage: (a: IUsage, b: IUsage) => IFilledUsage;
917
+
918
+ type ModelCallStage = AgentStage | 'compaction' | 'route';
919
+ interface IModelCall {
920
+ runId?: string;
921
+ stage: ModelCallStage;
922
+ provider?: string;
923
+ modelId: string;
924
+ estimatedInputTokens?: number;
925
+ maxOutputTokens?: number;
926
+ }
927
+ interface ISharedLimits {
928
+ beforeModelCall: (call: IModelCall, context: {
929
+ signal?: AbortSignal;
930
+ }) => void | Promise<void>;
931
+ afterModelCall?: (call: IModelCall, usage: IUsage, outcome: {
932
+ ok: boolean;
933
+ }) => void | Promise<void>;
934
+ }
935
+ declare class ModelCallRefusedError extends Error {
936
+ readonly call: IModelCall;
937
+ constructor(call: IModelCall, cause: unknown);
938
+ toJSON(): string;
939
+ }
940
+
1059
941
  declare const SPAWN_SUBAGENT_TOOL = "spawn_subagent";
1060
942
  type SubagentDefaultTools = 'read-only' | 'all';
1061
943
  interface IDynamicSubagentsConfig {
@@ -1113,7 +995,7 @@ declare const SPAWN_INPUT_SCHEMA: {
1113
995
  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.";
1114
996
  };
1115
997
  };
1116
- readonly required: readonly ["task"];
998
+ readonly required: string[];
1117
999
  readonly additionalProperties: false;
1118
1000
  };
1119
1001
  /**
@@ -1237,11 +1119,14 @@ interface IToolApprovalRequest {
1237
1119
  interface IToolApprovalContext {
1238
1120
  signal: AbortSignal;
1239
1121
  }
1240
- type ToolApprovalDecision = boolean | {
1122
+ type ToolApprovalAnswer = boolean | {
1241
1123
  approved: boolean;
1242
1124
  reason?: string;
1243
1125
  remember?: boolean;
1244
1126
  };
1127
+ type ToolApprovalDecision = ToolApprovalAnswer | {
1128
+ park: true;
1129
+ };
1245
1130
  interface IToolApprovalConfig {
1246
1131
  mode?: ToolApprovalMode;
1247
1132
  rules?: Record<string, ToolPermission>;
@@ -1338,6 +1223,8 @@ interface IAgentConfig {
1338
1223
  llmMaxRetries?: number;
1339
1224
  maxConcurrentRuns?: number;
1340
1225
  persistence?: IPersistence;
1226
+ runLease?: IRunLease;
1227
+ sharedLimits?: ISharedLimits;
1341
1228
  toolSelectionStrategy?: ToolSelectionStrategy;
1342
1229
  inputSanitizer?: (toolName: string, input: unknown) => unknown | Promise<unknown>;
1343
1230
  outputSanitizer?: (toolName: string, output: unknown) => unknown | Promise<unknown>;
@@ -1515,6 +1402,7 @@ type AgentEventBody = {
1515
1402
  approved: boolean;
1516
1403
  reason?: string;
1517
1404
  automatic: boolean;
1405
+ parked?: true;
1518
1406
  } | {
1519
1407
  type: 'mcp.elicitation-requested';
1520
1408
  id: string;
@@ -1611,6 +1499,20 @@ type AgentEventBody = {
1611
1499
  } | {
1612
1500
  type: 'revisions.exceeded';
1613
1501
  cap: number;
1502
+ } | {
1503
+ type: 'lease.lost';
1504
+ owner: string;
1505
+ reason: RunLeaseLostReason;
1506
+ error?: string;
1507
+ } | {
1508
+ type: 'run.parked';
1509
+ items: ParkedItem[];
1510
+ at: number;
1511
+ } | {
1512
+ type: 'journal.diverged';
1513
+ position: string;
1514
+ kind: 'model' | 'tool';
1515
+ stage?: ModelCallStage;
1614
1516
  } | {
1615
1517
  type: 'error';
1616
1518
  error: Error;
@@ -1618,6 +1520,8 @@ type AgentEventBody = {
1618
1520
  } | PipelineEvent;
1619
1521
  type AgentEvent = AgentEventBody & {
1620
1522
  runId?: string;
1523
+ seq?: number;
1524
+ attempt?: number;
1621
1525
  nodeId?: string;
1622
1526
  visit?: number;
1623
1527
  };
@@ -1635,9 +1539,39 @@ interface IAgentRunOptions {
1635
1539
  onEvent?: EventHandler;
1636
1540
  onStepStart?: (info: IStepStartInfo) => void;
1637
1541
  resumeFromRunId?: string;
1542
+ runId?: string;
1638
1543
  control?: RunControl;
1544
+ answers?: Record<string, ParkAnswer>;
1545
+ }
1546
+ type ToolResultAnswer = {
1547
+ output: unknown;
1548
+ } | {
1549
+ error: string;
1550
+ };
1551
+ type ParkAnswer = ToolApprovalAnswer | ToolResultAnswer;
1552
+ type ParkedItem = {
1553
+ id: string;
1554
+ kind: 'approval';
1555
+ request: IToolApprovalRequest;
1556
+ } | {
1557
+ id: string;
1558
+ kind: 'tool';
1559
+ toolName: string;
1560
+ input: unknown;
1561
+ note?: string;
1562
+ step?: IPlanStep;
1563
+ subagent?: {
1564
+ id: string;
1565
+ depth: number;
1566
+ };
1567
+ };
1568
+ interface IParkedRun {
1569
+ runId: string;
1570
+ items: ParkedItem[];
1571
+ at: number;
1639
1572
  }
1640
1573
  interface IAgentRunResult {
1574
+ runId?: string;
1641
1575
  text: string;
1642
1576
  plan: IPlan;
1643
1577
  trace: IStepResult[];
@@ -1645,11 +1579,12 @@ interface IAgentRunResult {
1645
1579
  usage: IUsage;
1646
1580
  compactedHistory?: IConversationTurn[];
1647
1581
  undelivered?: string[];
1582
+ parked?: IParkedRun;
1648
1583
  }
1649
1584
  interface IRunSnapshot {
1650
1585
  runId: string;
1651
1586
  startedAt: number;
1652
- status: 'executing' | 'complete' | 'failed' | 'cancelled';
1587
+ status: 'executing' | 'waiting' | 'complete' | 'failed' | 'cancelled';
1653
1588
  input: string;
1654
1589
  history?: IConversationTurn[];
1655
1590
  plan?: IPlan;
@@ -1671,13 +1606,79 @@ interface IRunSnapshot {
1671
1606
  }[];
1672
1607
  escalations?: number;
1673
1608
  subagentsSpawned?: number;
1609
+ attempt?: number;
1610
+ leaseOwner?: string;
1611
+ parked?: IParkedRun;
1674
1612
  }
1675
1613
  interface IPersistence {
1676
1614
  onRunStart?: (snapshot: IRunSnapshot) => void | Promise<void>;
1677
1615
  onStepComplete?: (snapshot: IRunSnapshot) => void | Promise<void>;
1678
1616
  onRunComplete?: (snapshot: IRunSnapshot) => void | Promise<void>;
1617
+ onRunResume?: (snapshot: IRunSnapshot) => void | Promise<void>;
1618
+ onRunPark?: (snapshot: IRunSnapshot) => void | Promise<void>;
1679
1619
  loadRun?: (runId: string) => IRunSnapshot | null | Promise<IRunSnapshot | null>;
1620
+ journal?: IRunJournal;
1621
+ }
1622
+ interface IRunJournal {
1623
+ append: (runId: string, entry: IJournalEntry) => void | Promise<void>;
1624
+ load: (runId: string) => IJournalEntry[] | Promise<IJournalEntry[]>;
1625
+ }
1626
+ interface IJournalEntryBase {
1627
+ id: string;
1628
+ position: string;
1629
+ attempt: number;
1630
+ at: number;
1631
+ }
1632
+ interface IJournalModelEntry extends IJournalEntryBase {
1633
+ kind: 'model';
1634
+ stage: ModelCallStage;
1635
+ hash: string;
1636
+ call: 'stream' | 'generate';
1637
+ response: {
1638
+ parts?: Record<string, unknown>[];
1639
+ content?: Record<string, unknown>[];
1640
+ finishReason: unknown;
1641
+ providerMetadata?: unknown;
1642
+ meta?: {
1643
+ id?: string;
1644
+ modelId?: string;
1645
+ timestamp?: string;
1646
+ };
1647
+ };
1648
+ usage: IUsage;
1649
+ }
1650
+ interface IJournalToolEntry extends IJournalEntryBase {
1651
+ kind: 'tool';
1652
+ parent: string;
1653
+ tool: string;
1654
+ hash: string;
1655
+ ok: boolean;
1656
+ model?: unknown;
1657
+ output?: unknown;
1658
+ error?: {
1659
+ name: string;
1660
+ message: string;
1661
+ };
1662
+ answered?: true;
1663
+ }
1664
+ interface IJournalPendingEntry extends IJournalEntryBase {
1665
+ kind: 'pending';
1666
+ parent: string;
1667
+ hash: string;
1668
+ item: ParkedItem;
1669
+ }
1670
+ interface IJournalAnswerEntry extends IJournalEntryBase {
1671
+ kind: 'answer';
1672
+ parent: string;
1673
+ hash: string;
1674
+ itemId: string;
1675
+ answer: {
1676
+ approved: boolean;
1677
+ reason?: string;
1678
+ remember?: boolean;
1679
+ };
1680
1680
  }
1681
+ type IJournalEntry = IJournalModelEntry | IJournalToolEntry | IJournalPendingEntry | IJournalAnswerEntry;
1681
1682
 
1682
1683
  interface ICloseOptions {
1683
1684
  waitForRuns?: boolean;
@@ -1714,6 +1715,7 @@ interface IAgent {
1714
1715
  reconnect: () => Promise<void>;
1715
1716
  close: (options?: ICloseOptions) => Promise<void>;
1716
1717
  activeRuns: () => number;
1718
+ readonly leaseOwner?: string;
1717
1719
  }
1718
1720
  declare const createAgent: (config: IAgentConfig, baseEventHandler?: EventHandler) => Promise<IAgent>;
1719
1721
 
@@ -1770,33 +1772,41 @@ declare const TOOL_APPROVAL_TIMEOUT_MS = 300000;
1770
1772
  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:]";
1771
1773
  declare const isReplayedToolOutput: (output: unknown) => boolean;
1772
1774
 
1775
+ /** The bounds on what comes from outside the run (a deferred call's note, an answer). */
1776
+ declare const JOURNAL_LIMITS: Readonly<{
1777
+ noteChars: 2000;
1778
+ answerChars: 1000000;
1779
+ errorChars: 4000;
1780
+ answerDepth: 64;
1781
+ }>;
1782
+ declare const DEFERRED: unique symbol;
1783
+ /** What `deferResult()` returns. Opaque: return it from a tool's `execute`. */
1784
+ interface IDeferredResult {
1785
+ readonly [DEFERRED]: true;
1786
+ readonly note?: string;
1787
+ }
1788
+ /**
1789
+ * Return this from a tool's `execute` when its result will come from outside the run, later (a
1790
+ * long job, a webhook, a review in another system). The run parks at the end of the tool round;
1791
+ * the host resumes it with the result as the answer to that item. Needs `persistence.journal`:
1792
+ * without it the call fails with a clear error. `note` (clipped, invisible characters removed)
1793
+ * is shown with the parked item.
1794
+ */
1795
+ declare const deferResult: (options?: {
1796
+ note?: string;
1797
+ }) => IDeferredResult;
1798
+ declare const isDeferredResult: (value: unknown) => value is IDeferredResult;
1799
+ /** An append to (or a read of) the journal failed: the run cannot go on with an exact record. */
1800
+ declare class JournalError extends Error {
1801
+ constructor(message: string, options?: {
1802
+ cause?: unknown;
1803
+ });
1804
+ toJSON(): string;
1805
+ }
1806
+
1773
1807
  declare const getCurrentRunId: () => string | undefined;
1774
1808
  declare const getCurrentRunSandbox: () => string | undefined;
1775
1809
 
1776
- declare const redactHeaders: (headers: Record<string, string> | undefined) => Record<string, string> | undefined;
1777
- type IFilledUsage = Required<Omit<IUsage, 'decisionCalls' | keyof IMediaUsage>> & Pick<IUsage, 'decisionCalls'> & Partial<IMediaUsage>;
1778
- interface ISdkUsageLike {
1779
- inputTokens?: number;
1780
- outputTokens?: number;
1781
- totalTokens?: number;
1782
- inputTokenDetails?: {
1783
- cacheReadTokens?: number;
1784
- cacheWriteTokens?: number;
1785
- };
1786
- outputTokenDetails?: {
1787
- reasoningTokens?: number;
1788
- };
1789
- decisionCalls?: number;
1790
- reasoningTokens?: number;
1791
- cachedInputTokens?: number;
1792
- mediaCalls?: number;
1793
- imagesGenerated?: number;
1794
- speechCharacters?: number;
1795
- transcriptionSeconds?: number;
1796
- }
1797
- declare const normalizeUsage: (usage: ISdkUsageLike | undefined | null) => IFilledUsage;
1798
- declare const addUsage: (a: IUsage, b: IUsage) => IFilledUsage;
1799
-
1800
1810
  /**
1801
1811
  * OAuth 2.1 for remote MCP servers, from Node.
1802
1812
  *
@@ -2610,6 +2620,16 @@ interface Pipeline {
2610
2620
  run: (options: PipelineRunOptions) => Promise<PipelineResult>;
2611
2621
  close: () => Promise<void>;
2612
2622
  }
2623
+ interface PipelineRouteOptions {
2624
+ config: IAgentConfig;
2625
+ signal?: AbortSignal;
2626
+ onEvent?: EventHandler;
2627
+ }
2628
+ interface PipelineRouteResult {
2629
+ route?: string;
2630
+ usage: IUsage;
2631
+ }
2632
+ declare const pickPipelineRoute: (node: PipelineNode, text: string, options: PipelineRouteOptions) => Promise<PipelineRouteResult>;
2613
2633
  declare const createPipeline: (definition: PipelineDefinition, options: PipelineOptions) => Pipeline;
2614
2634
  type PipelineModelConfig = Pick<IAgentConfig, 'model'> & Partial<Pick<IAgentConfig, 'providerType' | 'baseURL' | 'apiKey' | 'providerOptions' | 'planner' | 'synthesizer' | 'executorTiers'>>;
2615
2635
  interface NodeResolverOptions {
@@ -2622,23 +2642,59 @@ interface NodeResolverOptions {
2622
2642
  }
2623
2643
  declare const nodeResolver: (options: NodeResolverOptions) => NonNullable<PipelineOptions["resolveNode"]>;
2624
2644
 
2625
- type SubagentIsolation = 'worker' | 'in-process';
2645
+ type SubagentIsolation = 'worker' | 'in-process' | 'remote';
2626
2646
  interface ISubagentProfile {
2627
2647
  description: string;
2628
2648
  config?: Partial<IAgentConfig>;
2629
2649
  }
2630
- interface ISubagentToolOptions {
2650
+ interface ISubagentToolBase {
2631
2651
  name: string;
2632
2652
  description: string;
2633
- config: IAgentConfig;
2634
- isolation?: SubagentIsolation;
2635
- tools?: ToolSet;
2636
2653
  maxConcurrent?: number;
2637
2654
  timeoutMs?: number;
2638
2655
  outputMaxChars?: number;
2639
2656
  readOnly?: boolean;
2657
+ }
2658
+ interface ILocalSubagentToolOptions extends ISubagentToolBase {
2659
+ config: IAgentConfig;
2660
+ isolation?: 'worker' | 'in-process';
2661
+ tools?: ToolSet;
2640
2662
  profiles?: Record<string, ISubagentProfile>;
2663
+ dispatch?: never;
2641
2664
  }
2665
+ interface IRemoteSubagentTask {
2666
+ id: string;
2667
+ name: string;
2668
+ profile?: string;
2669
+ input: string;
2670
+ parentRunId?: string;
2671
+ rootRunId?: string;
2672
+ depth: number;
2673
+ }
2674
+ interface IRemoteSubagentContext {
2675
+ signal: AbortSignal;
2676
+ emit: (event: AgentEvent) => void;
2677
+ }
2678
+ interface IRemoteSubagentResult {
2679
+ text: string;
2680
+ usage?: IUsage;
2681
+ }
2682
+ type RemoteSubagentDispatch = (task: IRemoteSubagentTask, context: IRemoteSubagentContext) => Promise<IRemoteSubagentResult | IDeferredResult>;
2683
+ interface IRemoteSubagentToolOptions extends ISubagentToolBase {
2684
+ isolation: 'remote';
2685
+ dispatch: RemoteSubagentDispatch;
2686
+ profiles?: Record<string, {
2687
+ description: string;
2688
+ }>;
2689
+ config?: never;
2690
+ tools?: never;
2691
+ }
2692
+ type ISubagentToolOptions = ILocalSubagentToolOptions | IRemoteSubagentToolOptions;
2693
+ declare const REMOTE_SUBAGENT_LIMITS: {
2694
+ readonly maxEvents: 10000;
2695
+ readonly maxEventChars: 64000;
2696
+ readonly maxTypeChars: 64;
2697
+ };
2642
2698
  /**
2643
2699
  * Expose a whole agent as ONE tool of a parent agent: input `{ task }`,
2644
2700
  * output the child's final text. Calls in one model step run in parallel
@@ -2648,5 +2704,5 @@ interface ISubagentToolOptions {
2648
2704
  */
2649
2705
  declare const createSubagentTool: (opts: ISubagentToolOptions) => Tool;
2650
2706
 
2651
- 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_ELICITATION_MAX_PER_RUN, MCP_ELICITATION_MAX_PER_TOOL_CALL, MCP_ELICITATION_TIMEOUT_MS, MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER, MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, MCP_MODERN_PROTOCOL_VERSION, MCP_SKILLS_EXTENSION, MCP_SKILLS_MAX_PER_SERVER, MCP_SKILLS_MAX_TOTAL, MCP_SKILL_BODY_MAX_CHARS, MCP_SKILL_CONSENTS, MCP_SKILL_CONSENT_DEFAULT, MCP_SKILL_DESCRIPTION_MAX_CHARS, MCP_SKILL_DIRECTORY_ENTRIES_MAX, MCP_SKILL_FILE_MAX_CHARS, MCP_SKILL_MAX_RESOURCES, MCP_SKILL_MAX_TOTAL_BYTES, MCP_SKILL_SNAPSHOTS_MAX_BYTES, MCP_SKILL_SNAPSHOT_MAX_DEPTH, MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES, MCP_SKILL_URI_MAX_CHARS, 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_GOOGLE_DEFAULT_MODEL, SEARCH_GOOGLE_NOTE, SEARCH_MAX_QUERY_CHARS, SEARCH_MAX_RESULTS, SEARCH_MAX_SNIPPET_CHARS, SEARCH_MAX_SUMMARY_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, TOOL_APPROVAL_TIMEOUT_MS, 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, isCodeExecutionTool, isReadOnlyTool, isReplayedToolOutput, loadSkillsFromDir, markCodeExecution, markReadOnly, matchToolRule, mcpSkillEntryRefusal, mcpSkillPreamble, mcpSkillUriRefusal, mediaUsageOf, mergeProviderOptions, nodeResolver, normalizeMcpElicitationSchema, normalizePipeline, normalizeSkillName, normalizeUsage, parseSearchResponse, parseSkillMarkdown, redactHeaders, renderMcpInstructions, renderPipelineNodeInput, resolveCompaction, resolveDynamicSubagents, resolveEgressPolicy, resolveLimits, resolvePromptCaching, resolveSandboxLimits, resolveThinking, sanitizeSearchResults, searchEgressPolicy, searchStatusMessage, searchToolResult, searchTools, sniffMediaType, testPipelineCondition, truncateToolModelOutput, validateMcpElicitationContent, validatePipeline, withRollingBreakpoint, withToolOutputLimit, wrapTranscript };
2652
- 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, IMcpSkillOrigin, IMcpStdioServerConfig, IMedia, IMediaConfig, IMediaFile, IMediaModelSpec, IMediaUsage, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IPersistence, IPlan, IPlanStep, IResolvedAddress, IResolvedDynamicSubagents, IResolvedThinking, IRunFile, IRunSnapshot, ISandboxConfig, ISandboxError, ISandboxLimits, ISandboxResult, ISanitizedSearch, ISaveSkillInput, ISearchAnswer, ISearchConfig, ISearchOptions, ISearchRequest, ISearchResult, ISearchToolResult, ISearchToolsOptions, ISearchUsage, ISkill, ISkillOrigin, ISkillStore, IStepEscalation, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, ISubagentsConfig, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalContext, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, ITranscription, IUsage, IWebSearchOptions, LogLevel, McpElicitationContent, McpElicitationContext, McpElicitationFieldSchema, McpElicitationHandler, McpElicitationOptions, McpElicitationReason, McpElicitationRequest, McpElicitationResult, McpElicitationSchema, McpOAuthRegistration, McpOAuthRegistrationKind, McpProtocolMode, McpServerInstructions, McpServerProtocol, McpSkillConsent, McpSkillConsentView, McpSkillsOptions, McpSkillsSetting, 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, SkillDirectoryListing, StepComplexity, SubagentDefaultTools, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TierReason, TokenLimitKind, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolSelectionStrategy, UsagePhase };
2707
+ 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, JOURNAL_LIMITS, JournalError, MCP_ELICITATION_MAX_PER_RUN, MCP_ELICITATION_MAX_PER_TOOL_CALL, MCP_ELICITATION_TIMEOUT_MS, MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER, MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, MCP_MODERN_PROTOCOL_VERSION, MCP_SKILLS_EXTENSION, MCP_SKILLS_MAX_PER_SERVER, MCP_SKILLS_MAX_TOTAL, MCP_SKILL_BODY_MAX_CHARS, MCP_SKILL_CONSENTS, MCP_SKILL_CONSENT_DEFAULT, MCP_SKILL_DESCRIPTION_MAX_CHARS, MCP_SKILL_DIRECTORY_ENTRIES_MAX, MCP_SKILL_FILE_MAX_CHARS, MCP_SKILL_MAX_RESOURCES, MCP_SKILL_MAX_TOTAL_BYTES, MCP_SKILL_SNAPSHOTS_MAX_BYTES, MCP_SKILL_SNAPSHOT_MAX_DEPTH, MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES, MCP_SKILL_URI_MAX_CHARS, 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, ModelCallRefusedError, NodeEnterpriseOAuthProvider, NodeOAuthProvider, PipelineDefinition, PipelineEvent, PipelineNode, PipelineNodeRunner, PipelineResult, REMOTE_SUBAGENT_LIMITS, REPLAY_NOTE, RUN_JS_TOOL, RUN_LEASE_DEFAULT_TTL_MS, RunLeaseError, SAVE_SKILL_TOOL, SEARCH_API_BASE_URL, SEARCH_DEFAULT_MAX_RESULTS, SEARCH_GOOGLE_DEFAULT_MODEL, SEARCH_GOOGLE_NOTE, SEARCH_MAX_QUERY_CHARS, SEARCH_MAX_RESULTS, SEARCH_MAX_SNIPPET_CHARS, SEARCH_MAX_SUMMARY_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, TOOL_APPROVAL_TIMEOUT_MS, 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, deferResult, defineSkill, estimateTokens, findSecret, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, hostMatches, htmlToText, isAuthError, isCodeExecutionTool, isDeferredResult, isModelCallRefused, isReadOnlyTool, isReplayedToolOutput, loadSkillsFromDir, markCodeExecution, markReadOnly, matchToolRule, mcpSkillEntryRefusal, mcpSkillPreamble, mcpSkillUriRefusal, mediaUsageOf, mergeProviderOptions, nodeResolver, normalizeMcpElicitationSchema, normalizeSkillName, normalizeUsage, parseSearchResponse, parseSkillMarkdown, pickPipelineRoute, redactHeaders, renderMcpInstructions, resolveCompaction, resolveDynamicSubagents, resolveEgressPolicy, resolveLimits, resolvePromptCaching, resolveSandboxLimits, resolveThinking, sanitizeSearchResults, searchEgressPolicy, searchStatusMessage, searchToolResult, searchTools, sniffMediaType, truncateToolModelOutput, validateMcpElicitationContent, withRollingBreakpoint, withToolOutputLimit, wrapTranscript };
2708
+ 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, IDeferredResult, IDynamicSubagentsConfig, IEgressPolicy, IEnterpriseIdpOptions, IEnterpriseOAuthProviderOptions, IEscalationConfig, IJournalAnswerEntry, IJournalEntry, IJournalModelEntry, IJournalPendingEntry, IJournalToolEntry, ILearning, ILearningConfig, ILimitBreach, ILocalSubagentToolOptions, IMcpHttpServerConfig, IMcpServerConfig, IMcpSkillOrigin, IMcpStdioServerConfig, IMedia, IMediaConfig, IMediaFile, IMediaModelSpec, IMediaUsage, IModelCall, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IParkedRun, IPersistence, IPlan, IPlanStep, IRemoteSubagentContext, IRemoteSubagentResult, IRemoteSubagentTask, IRemoteSubagentToolOptions, IResolvedAddress, IResolvedDynamicSubagents, IResolvedThinking, IRunFile, IRunJournal, IRunLease, IRunLeaseOptions, IRunSnapshot, ISandboxConfig, ISandboxError, ISandboxLimits, ISandboxResult, ISanitizedSearch, ISaveSkillInput, ISearchAnswer, ISearchConfig, ISearchOptions, ISearchRequest, ISearchResult, ISearchToolResult, ISearchToolsOptions, ISearchUsage, ISharedLimits, ISkill, ISkillOrigin, ISkillStore, IStepEscalation, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, ISubagentsConfig, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalContext, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, ITranscription, IUsage, IWebSearchOptions, LogLevel, McpElicitationContent, McpElicitationContext, McpElicitationFieldSchema, McpElicitationHandler, McpElicitationOptions, McpElicitationReason, McpElicitationRequest, McpElicitationResult, McpElicitationSchema, McpOAuthRegistration, McpOAuthRegistrationKind, McpProtocolMode, McpServerInstructions, McpServerProtocol, McpSkillConsent, McpSkillConsentView, McpSkillsOptions, McpSkillsSetting, MediaImageModel, MediaKind, MediaModelKind, MediaSpeechModel, MediaTranscriptionModel, ModelCallStage, ModelTier, NodeResolverOptions, ParkAnswer, ParkedItem, Pipeline, PipelineModelConfig, PipelineOptions, PipelineRouteOptions, PipelineRouteResult, PipelineRunOptions, PromptCachingSetting, ProviderType, RemoteSubagentDispatch, ReplanCause, ReplanTrigger, RunControl, RunLeaseLostReason, SafeFetch, SearchEngine, SearchFreshness, SearchProvider, SkillDirectoryListing, StepComplexity, SubagentDefaultTools, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TierReason, TokenLimitKind, ToolApprovalAnswer, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolResultAnswer, ToolSelectionStrategy, UsagePhase };