agents 0.17.3 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/{agent-tool-types-CNyE1iz_.d.ts → agent-tool-types-BNUGGBzQ.d.ts} +191 -61
  2. package/dist/agent-tool-types.d.ts +1 -1
  3. package/dist/{agent-tools-BeOheFBK.d.ts → agent-tools-BFbzVLFc.d.ts} +2 -2
  4. package/dist/agent-tools.d.ts +1 -1
  5. package/dist/chat/index.d.ts +29 -9
  6. package/dist/chat/index.js +31 -41
  7. package/dist/chat/index.js.map +1 -1
  8. package/dist/chat/react.d.ts +25 -1
  9. package/dist/chat/react.js +249 -93
  10. package/dist/chat/react.js.map +1 -1
  11. package/dist/chat-sdk/index.d.ts +1 -1
  12. package/dist/{client-BZ-B3NhC.js → client-CcjiFpTf.js} +352 -81
  13. package/dist/client-CcjiFpTf.js.map +1 -0
  14. package/dist/client.d.ts +1 -1
  15. package/dist/cloudflare-BldFV0Pa.js +117 -0
  16. package/dist/cloudflare-BldFV0Pa.js.map +1 -0
  17. package/dist/index.d.ts +13 -11
  18. package/dist/index.js +153 -48
  19. package/dist/index.js.map +1 -1
  20. package/dist/mcp/client.d.ts +18 -14
  21. package/dist/mcp/client.js +1 -1
  22. package/dist/mcp/index.d.ts +38 -30
  23. package/dist/mcp/index.js +1 -1
  24. package/dist/mcp/index.js.map +1 -1
  25. package/dist/observability/ai/index.d.ts +155 -0
  26. package/dist/observability/ai/index.js +1845 -0
  27. package/dist/observability/ai/index.js.map +1 -0
  28. package/dist/react.d.ts +1 -1
  29. package/dist/{retries-CvHJwSuh.d.ts → retries-CAvxtG9d.d.ts} +16 -7
  30. package/dist/retries.d.ts +8 -6
  31. package/dist/retries.js +20 -2
  32. package/dist/retries.js.map +1 -1
  33. package/dist/serializable.d.ts +1 -1
  34. package/dist/sub-routing.d.ts +6 -6
  35. package/dist/vite.d.ts +4 -4
  36. package/dist/vite.js +4 -2
  37. package/dist/vite.js.map +1 -1
  38. package/dist/{wire-types-nflOzNuU.js → wire-types-CU9rLoeS.js} +33 -2
  39. package/dist/wire-types-CU9rLoeS.js.map +1 -0
  40. package/dist/workflows.d.ts +1 -1
  41. package/docs/agent-class.md +9 -1
  42. package/docs/configuration.md +20 -0
  43. package/docs/mcp-client.md +52 -4
  44. package/docs/observability.md +282 -0
  45. package/package.json +7 -2
  46. package/dist/client-BZ-B3NhC.js.map +0 -1
  47. package/dist/wire-types-nflOzNuU.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { n as AgentEmail } from "./internal_context-Dg4Cgjcu.js";
2
- import { t as RetryOptions } from "./retries-CvHJwSuh.js";
2
+ import { t as RetryOptions } from "./retries-CAvxtG9d.js";
3
3
  import {
4
4
  n as Observability,
5
5
  r as ObservabilityEvent,
@@ -41,6 +41,7 @@ import {
41
41
  import {
42
42
  CallToolRequest,
43
43
  CallToolResultSchema,
44
+ ClientCapabilities,
44
45
  CompatibilityCallToolResultSchema,
45
46
  ElicitRequest,
46
47
  ElicitRequest as ElicitRequest$1,
@@ -799,20 +800,40 @@ type MCPTransportOptions = (
799
800
  authProvider?: AgentMcpOAuthProvider;
800
801
  type?: TransportType;
801
802
  };
803
+ /** Result of discovering server capabilities. */
804
+ type MCPDiscoveryResult =
805
+ | {
806
+ success: true;
807
+ }
808
+ | {
809
+ success: false;
810
+ reason: "error" | "stale-session";
811
+ error: string;
812
+ };
802
813
  /**
803
- * Result of a discovery operation.
804
- * success indicates whether discovery completed successfully.
805
- * error is present when success is false.
814
+ * Handler for server-initiated `elicitation/create` requests.
815
+ * Held in memory only never persisted — so it must be re-supplied when a
816
+ * connection is recreated (e.g. after Durable Object hibernation).
806
817
  */
807
- type MCPDiscoveryResult = {
808
- success: boolean;
809
- error?: string;
818
+ type MCPElicitationHandler = (request: ElicitRequest) => Promise<ElicitResult>;
819
+ type MCPElicitationHandlers = {
820
+ form?: MCPElicitationHandler;
821
+ url?: MCPElicitationHandler;
810
822
  };
811
823
  declare class MCPClientConnection {
812
824
  url: URL;
825
+ private readonly _info;
813
826
  options: {
814
827
  transport: MCPTransportOptions;
815
828
  client: McpClientOptions;
829
+ elicitationHandlers?: MCPElicitationHandlers;
830
+ /**
831
+ * Client capabilities persisted from a previous session, advertised
832
+ * until handlers are reconfigured after a hibernation restore. Cleared
833
+ * by {@link configureElicitationHandlers} — reconfigured handlers are
834
+ * the source of truth. Explicit `client.capabilities` win per key.
835
+ */
836
+ capabilitySeed?: ClientCapabilities;
816
837
  };
817
838
  client: Client;
818
839
  connectionState: MCPConnectionState;
@@ -839,14 +860,41 @@ declare class MCPClientConnection {
839
860
  private _discoveryAbortController;
840
861
  private readonly _onObservabilityEvent;
841
862
  readonly onObservabilityEvent: Event<MCPObservabilityEvent>;
863
+ /**
864
+ * Whether the connection advertised the elicitation capability. The SDK
865
+ * client refuses to register an `elicitation/create` request handler when
866
+ * the capability was not declared, so handler registration is gated on
867
+ * this.
868
+ */
869
+ private _elicitationEnabled;
842
870
  constructor(
843
871
  url: URL,
844
- info: ConstructorParameters<typeof Client>[0],
872
+ _info: ConstructorParameters<typeof Client>[0],
845
873
  options?: {
846
874
  transport: MCPTransportOptions;
847
875
  client: McpClientOptions;
876
+ elicitationHandlers?: MCPElicitationHandlers;
877
+ /**
878
+ * Client capabilities persisted from a previous session, advertised
879
+ * until handlers are reconfigured after a hibernation restore. Cleared
880
+ * by {@link configureElicitationHandlers} — reconfigured handlers are
881
+ * the source of truth. Explicit `client.capabilities` win per key.
882
+ */
883
+ capabilitySeed?: ClientCapabilities;
848
884
  }
849
885
  );
886
+ private createClient;
887
+ /**
888
+ * Configure the handler used for server-initiated elicitation requests.
889
+ *
890
+ * If the connection has not been initialized yet, rebuild the SDK client so
891
+ * handler-driven elicitation capabilities are reflected in the initial
892
+ * handshake. A rebuild (rather than `Client.registerCapabilities`) is
893
+ * required because SDK capability registration is merge-only — it cannot
894
+ * un-advertise a mode when handlers are cleared before connecting. Active
895
+ * connections keep their negotiated capabilities until they reconnect.
896
+ */
897
+ configureElicitationHandlers(handlers?: MCPElicitationHandlers): void;
850
898
  /**
851
899
  * Initialize a client connection, if authentication is required, the connection will be in the AUTHENTICATING state
852
900
  * Sets connection state based on the result and emits observability events
@@ -1047,12 +1095,18 @@ declare class MCPClientConnection {
1047
1095
  }[]
1048
1096
  >;
1049
1097
  /**
1050
- * Handle elicitation request from server
1051
- * Automatically uses the Agent's built-in elicitation handling if available
1098
+ * Handle elicitation request from server.
1099
+ *
1100
+ * Delegates to the `elicitationHandlers` connection option when provided.
1101
+ *
1102
+ * @deprecated Overriding or instance-patching this method directly is
1103
+ * deprecated — pass the `elicitationHandlers` connection option instead.
1052
1104
  */
1053
- handleElicitationRequest(_request: ElicitRequest): Promise<ElicitResult>;
1105
+ handleElicitationRequest(request: ElicitRequest): Promise<ElicitResult>;
1054
1106
  private isResumedStreamableHttpSession;
1055
1107
  get sessionId(): string | undefined;
1108
+ /** @internal Clear a restored session before reconnecting. */
1109
+ clearResumedSession(): void;
1056
1110
  private getTransportName;
1057
1111
  close(): Promise<void>;
1058
1112
  /**
@@ -1135,6 +1189,12 @@ type MCPServerOptions = {
1135
1189
  sessionId?: string;
1136
1190
  } /** Retry options for connection and reconnection attempts */;
1137
1191
  retry?: RetryOptions;
1192
+ /**
1193
+ * Client capabilities advertised from configured handlers (currently the
1194
+ * elicitation modes). Handlers are functions and cannot be persisted, so
1195
+ * this records what they advertised for restores after hibernation.
1196
+ */
1197
+ capabilities?: ClientCapabilities;
1138
1198
  };
1139
1199
  /**
1140
1200
  * Result of an OAuth callback request
@@ -1207,6 +1267,14 @@ type MCPClientOAuthResult =
1207
1267
  authSuccess: false /** May contain untrusted content from external OAuth providers. Escape appropriately for your output context. */;
1208
1268
  authError: string;
1209
1269
  };
1270
+ type MCPClientElicitationHandler = (
1271
+ request: ElicitRequest,
1272
+ serverId: string
1273
+ ) => Promise<ElicitResult>;
1274
+ type MCPClientElicitationHandlers = {
1275
+ form?: MCPClientElicitationHandler;
1276
+ url?: MCPClientElicitationHandler;
1277
+ };
1210
1278
  type MCPClientManagerOptions = {
1211
1279
  storage: DurableObjectStorage;
1212
1280
  createAuthProvider?: (callbackUrl: string) => AgentMcpOAuthProvider;
@@ -1231,6 +1299,8 @@ declare class MCPClientManager {
1231
1299
  private _name;
1232
1300
  private _version;
1233
1301
  mcpConnections: Record<string, MCPClientConnection>;
1302
+ /** Cache only the current catalog so old schema graphs are not retained. */
1303
+ private readonly _aiToolSchemas;
1234
1304
  private _didWarnAboutUnstableGetAITools;
1235
1305
  private _oauthCallbackConfig?;
1236
1306
  private _connectionDisposables;
@@ -1238,6 +1308,7 @@ declare class MCPClientManager {
1238
1308
  private _createAuthProviderFn?;
1239
1309
  private _isRestored;
1240
1310
  private _pendingConnections;
1311
+ private _elicitationHandlers?;
1241
1312
  /** @internal Protected for testing purposes. */
1242
1313
  protected readonly _onObservabilityEvent: Emitter<MCPObservabilityEvent>;
1243
1314
  readonly onObservabilityEvent: Event<MCPObservabilityEvent>;
@@ -1257,6 +1328,12 @@ declare class MCPClientManager {
1257
1328
  _version: string,
1258
1329
  options: MCPClientManagerOptions
1259
1330
  );
1331
+ /**
1332
+ * Scope the manager-level elicitation handler to a single connection.
1333
+ * Returns undefined when no handler is configured so the connection keeps
1334
+ * its default throwing behavior.
1335
+ */
1336
+ private scopedElicitationHandlers;
1260
1337
  private sql;
1261
1338
  private saveServerToStorage;
1262
1339
  private removeServerFromStorage;
@@ -1287,6 +1364,19 @@ declare class MCPClientManager {
1287
1364
  private _renameInMemoryConnection;
1288
1365
  private getServersFromStorage;
1289
1366
  private filterConnections;
1367
+ /**
1368
+ * Get the parsed server_options for a stored server, if any.
1369
+ */
1370
+ private getStoredServerOptions;
1371
+ /**
1372
+ * Clear the capabilities persisted on a stored server row. Called once a
1373
+ * seeded connection's handshake completes (see `createConnection`): the
1374
+ * stamp is valid for one successful restore — sessions that configure
1375
+ * handlers re-stamp every row, so a deploy that stops configuring them
1376
+ * stops advertising stale modes after its first connected wake instead of
1377
+ * forever, while wakes that never handshake don't burn the stamp.
1378
+ */
1379
+ private clearStoredCapabilities;
1290
1380
  /**
1291
1381
  * Get the retry options for a server from stored server_options
1292
1382
  */
@@ -1297,6 +1387,8 @@ declare class MCPClientManager {
1297
1387
  private isAuthAcceptedConnection;
1298
1388
  private oauthCallbackSuccess;
1299
1389
  private runWithCodeVerifierState;
1390
+ private hasRedeemableOAuthState;
1391
+ private ignoreUnverifiedCallback;
1300
1392
  private consumeStaleOAuthState;
1301
1393
  private completeAuthorizationAndCleanupVerifier;
1302
1394
  /**
@@ -1348,6 +1440,7 @@ declare class MCPClientManager {
1348
1440
  * `undefined` (default) waits indefinitely.
1349
1441
  */
1350
1442
  waitForConnections(options?: { timeout?: number }): Promise<void>;
1443
+ private _connectWithRetry;
1351
1444
  /**
1352
1445
  * Internal method to restore a single server connection and discovery
1353
1446
  */
@@ -1431,6 +1524,8 @@ declare class MCPClientManager {
1431
1524
  timeoutMs?: number;
1432
1525
  }
1433
1526
  ): Promise<MCPDiscoverResult | undefined>;
1527
+ private _toDiscoverResult;
1528
+ private _recoverStaleSession;
1434
1529
  /**
1435
1530
  * Establish connection in the background after OAuth completion.
1436
1531
  * This method connects to the server and discovers its capabilities.
@@ -1445,6 +1540,33 @@ declare class MCPClientManager {
1445
1540
  * @param config OAuth callback configuration
1446
1541
  */
1447
1542
  configureOAuthCallback(config: MCPClientOAuthCallbackConfig): void;
1543
+ /**
1544
+ * Configure handling for server-initiated `elicitation/create` requests.
1545
+ *
1546
+ * The handler is held in memory only and applied to every MCP connection
1547
+ * created or restored by this manager. Call this before registering
1548
+ * connections when you want the initial MCP handshake to advertise
1549
+ * handler-driven form- and url-mode elicitation. Existing active connections
1550
+ * keep their negotiated capabilities until they reconnect.
1551
+ *
1552
+ * The advertised modes are persisted with each stored server, so
1553
+ * connections restored after hibernation re-advertise them at the handshake
1554
+ * even when this is called later in the wake-up (e.g. from onStart) — the
1555
+ * handlers attach to the live connections as soon as this runs.
1556
+ *
1557
+ * Pass undefined to clear the handler.
1558
+ *
1559
+ * @param handlers Elicitation handlers keyed by mode, each scoped with the server id that sent the request
1560
+ */
1561
+ configureElicitationHandlers(handlers?: MCPClientElicitationHandlers): void;
1562
+ /** Client capabilities advertised from the currently configured handlers. */
1563
+ private advertisedHandlerCapabilities;
1564
+ /**
1565
+ * Record the handler-derived capabilities on every stored server row so a
1566
+ * restore after hibernation re-advertises them before the handlers
1567
+ * themselves are reconfigured.
1568
+ */
1569
+ private persistAdvertisedCapabilities;
1448
1570
  /**
1449
1571
  * Get the current OAuth callback configuration
1450
1572
  * @returns The current OAuth callback configuration
@@ -1456,6 +1578,10 @@ declare class MCPClientManager {
1456
1578
  */
1457
1579
  listTools(filter?: MCPServerFilter): NamespacedData["tools"];
1458
1580
  /**
1581
+ * Convert connected MCP tools for the AI SDK. Converted schemas are reused
1582
+ * while a live connection retains the same catalog array and schema-source
1583
+ * identities; tool records and execute closures are rebuilt on every call.
1584
+ *
1459
1585
  * @param filter - Optional filter to scope results to specific servers
1460
1586
  * @returns a set of tools that you can use with the AI SDK
1461
1587
  */
@@ -1743,9 +1869,7 @@ declare class MCPClientManager {
1743
1869
  uri: string;
1744
1870
  text: string;
1745
1871
  mimeType?: string | undefined;
1746
- _meta /** Include only connections matching this server ID (or IDs). */?/** Include only connections matching this server ID (or IDs). */ :
1747
- | Record<string, unknown>
1748
- | undefined;
1872
+ _meta?: Record<string, unknown> | undefined;
1749
1873
  }
1750
1874
  | {
1751
1875
  uri: string;
@@ -1784,11 +1908,7 @@ declare class MCPClientManager {
1784
1908
  icons?:
1785
1909
  | {
1786
1910
  src: string;
1787
- mimeType?/**
1788
- * Event that fires whenever any MCP server state changes (registered, connected, removed, etc.)
1789
- * This is useful for broadcasting server state to clients.
1790
- */
1791
- : string | undefined;
1911
+ mimeType?: string | undefined;
1792
1912
  sizes?: string[] | undefined;
1793
1913
  theme?: "light" | "dark" | undefined;
1794
1914
  }[]
@@ -2627,6 +2747,8 @@ declare class Agent<
2627
2747
  type: ObservabilityEvent["type"],
2628
2748
  payload?: Record<string, unknown>
2629
2749
  ): void;
2750
+ /** Run SDK work under a stable parent for platform child spans. */
2751
+ private _withAgentSpan;
2630
2752
  /**
2631
2753
  * Execute SQL queries against the Agent's database
2632
2754
  * @template T Type of the returned rows
@@ -2638,6 +2760,7 @@ declare class Agent<
2638
2760
  strings: TemplateStringsArray,
2639
2761
  ...values: (string | number | boolean | null)[]
2640
2762
  ): T[];
2763
+ private _schemaInitialization;
2641
2764
  /**
2642
2765
  * Create all internal tables and run migrations if needed.
2643
2766
  * Called by the constructor on every wake. Idempotent — skips DDL when
@@ -3421,6 +3544,7 @@ declare class Agent<
3421
3544
  */
3422
3545
  private _hasPendingFiberRecovery;
3423
3546
  private _scheduleNextAlarm;
3547
+ private _scheduleNextAlarmBody;
3424
3548
  /**
3425
3549
  * Override PartyServer's onAlarm hook as a no-op.
3426
3550
  * Agent handles alarm logic directly in the alarm() method override,
@@ -4663,6 +4787,8 @@ declare class Agent<
4663
4787
  state: typeof MCPConnectionState.READY;
4664
4788
  }
4665
4789
  >;
4790
+ private _redeemableAuthUrl;
4791
+ private _isAbsoluteHttpUrl;
4666
4792
  removeMcpServer(id: string): Promise<void>;
4667
4793
  getMcpServers(): MCPServersState;
4668
4794
  /**
@@ -5275,71 +5401,72 @@ type AgentToolEventState<Part extends AgentToolRunPart = AgentToolRunPart> = {
5275
5401
  //#endregion
5276
5402
  export {
5277
5403
  RoutingRetryOptions as $,
5278
- McpClientOptions as $t,
5404
+ WorkerTransport as $t,
5279
5405
  AgentGetOptions as A,
5280
- getNamespacedData as At,
5406
+ MCP_SERVER_ID_MAX_LENGTH as At,
5281
5407
  EmailSendBinding as B,
5282
- McpAgent as Bt,
5408
+ RPC_DO_PREFIX as Bt,
5283
5409
  DetachedRunAgentToolResult as C,
5284
- MCPConnectionResult as Ct,
5410
+ MCPClientOAuthCallbackConfig as Ct,
5285
5411
  AddRpcMcpServerOptions as D,
5286
- MCPServerOptions as Dt,
5412
+ MCPOAuthCallbackResult as Dt,
5287
5413
  AddMcpServerOptions as E,
5288
- MCPServerFilter as Et,
5414
+ MCPDiscoverResult as Et,
5289
5415
  Connection$1 as F,
5290
- RPCServerTransportOptions as Ft,
5416
+ MCPElicitationHandlers as Ft,
5291
5417
  FiberStatus as G,
5292
- experimental_createMcpHandler as Gt,
5418
+ ClearableEventStore as Gt,
5293
5419
  FiberInspection as H,
5294
- DurableObjectEventStore as Ht,
5420
+ ElicitRequestSchema$1 as Ht,
5295
5421
  ConnectionContext$1 as I,
5296
- RPC_DO_PREFIX as It,
5422
+ RPCClientTransport as It,
5297
5423
  MCPServerMessage as J,
5298
- TransportState as Jt,
5424
+ createMcpHandler as Jt,
5299
5425
  ListFibersOptions as K,
5300
- McpAuthContext as Kt,
5426
+ DurableObjectEventStore as Kt,
5301
5427
  DEFAULT_AGENT_STATIC_OPTIONS as L,
5302
- ElicitRequest$1 as Lt,
5428
+ RPCClientTransportOptions as Lt,
5303
5429
  AgentOptions as M,
5304
- RPCClientTransport as Mt,
5430
+ getNamespacedData as Mt,
5305
5431
  AgentStaticOptions as N,
5306
- RPCClientTransportOptions as Nt,
5432
+ normalizeServerId as Nt,
5307
5433
  Agent as O,
5308
- MCP_SERVER_ID_MAX_LENGTH as Ot,
5434
+ MCPServerFilter as Ot,
5309
5435
  CallableMetadata as P,
5310
- RPCServerTransport as Pt,
5436
+ MCPElicitationHandler as Pt,
5311
5437
  RPCResponse as Q,
5312
- StreamableHTTPEdgeClientTransport as Qt,
5438
+ TransportState as Qt,
5313
5439
  DeleteFibersOptions as R,
5314
- ElicitRequestSchema$1 as Rt,
5440
+ RPCServerTransport as Rt,
5315
5441
  DetachedAgentToolConfig as S,
5316
- MCPClientOAuthResult as St,
5442
+ MCPClientManagerOptions as St,
5317
5443
  RunAgentToolResult as T,
5318
- MCPOAuthCallbackResult as Tt,
5444
+ MCPConnectionResult as Tt,
5319
5445
  FiberRecoveryContext as U,
5320
- CreateMcpHandlerOptions as Ut,
5446
+ ElicitResult$1 as Ut,
5321
5447
  FiberContext as V,
5322
- ClearableEventStore as Vt,
5448
+ ElicitRequest$1 as Vt,
5323
5449
  FiberRecoveryResult as W,
5324
- createMcpHandler as Wt,
5450
+ McpAgent as Wt,
5325
5451
  QueueItem as X,
5326
- WorkerTransportOptions as Xt,
5452
+ McpAuthContext as Xt,
5327
5453
  MCPServersState as Y,
5328
- WorkerTransport as Yt,
5454
+ experimental_createMcpHandler as Yt,
5329
5455
  RPCRequest as Z,
5330
- SSEEdgeClientTransport as Zt,
5456
+ getMcpAuthContext as Zt,
5331
5457
  AgentToolRunState as _,
5332
5458
  MCPAITool as _t,
5333
5459
  AgentToolEvent as a,
5334
- routeSubAgentRequest as an,
5460
+ SUB_PREFIX as an,
5335
5461
  StartFiberResult as at,
5336
5462
  AgentToolTerminalStatus as b,
5337
- MCPClientManagerOptions as bt,
5463
+ MCPClientElicitationHandlers as bt,
5338
5464
  AgentToolFailure as c,
5465
+ parseSubAgentPath as cn,
5339
5466
  SubAgentClass as ct,
5340
5467
  AgentToolMilestone as d,
5341
5468
  callable as dt,
5342
- TransportType as en,
5469
+ WorkerTransportOptions as en,
5343
5470
  Schedule as et,
5344
5471
  AgentToolProgress as f,
5345
5472
  getAgentByName as ft,
@@ -5348,44 +5475,47 @@ export {
5348
5475
  AgentToolRunInspection as h,
5349
5476
  routeAgentRequest as ht,
5350
5477
  AgentToolDisplayMetadata as i,
5351
- parseSubAgentPath as in,
5478
+ TransportType as in,
5352
5479
  StartFiberOptions as it,
5353
5480
  AgentNamespace as j,
5354
- normalizeServerId as jt,
5481
+ RegisterServerOptions as jt,
5355
5482
  AgentContext as k,
5356
- RegisterServerOptions as kt,
5483
+ MCPServerOptions as kt,
5357
5484
  AgentToolInterruptedReason as l,
5485
+ routeSubAgentRequest as ln,
5358
5486
  SubAgentStub as lt,
5359
5487
  AgentToolRunInfo as m,
5360
5488
  routeAgentEmail as mt,
5361
5489
  AGENT_TOOL_PROGRESS_PART as n,
5362
- SubAgentPathMatch as nn,
5490
+ StreamableHTTPEdgeClientTransport as nn,
5363
5491
  SendEmailOptions as nt,
5364
5492
  AgentToolEventMessage as o,
5493
+ SubAgentPathMatch as on,
5365
5494
  StateUpdateMessage as ot,
5366
5495
  AgentToolProgressSnapshot as p,
5367
5496
  getCurrentAgent as pt,
5368
5497
  MCPServer as q,
5369
- getMcpAuthContext as qt,
5498
+ CreateMcpHandlerOptions as qt,
5370
5499
  AgentToolChildAdapter as r,
5371
- getSubAgentByName as rn,
5500
+ McpClientOptions as rn,
5372
5501
  SqlError as rt,
5373
5502
  AgentToolEventState as s,
5503
+ getSubAgentByName as sn,
5374
5504
  StreamingResponse as st,
5375
5505
  AGENT_TOOL_MILESTONE_PART as t,
5376
- SUB_PREFIX as tn,
5506
+ SSEEdgeClientTransport as tn,
5377
5507
  ScheduleCriteria as tt,
5378
5508
  AgentToolLifecycleResult as u,
5379
5509
  WSMessage$1 as ut,
5380
5510
  AgentToolRunStatus as v,
5381
5511
  MCPAIToolSet as vt,
5382
5512
  RunAgentToolOptions as w,
5383
- MCPDiscoverResult as wt,
5513
+ MCPClientOAuthResult as wt,
5384
5514
  ChatCapableAgentClass as x,
5385
- MCPClientOAuthCallbackConfig as xt,
5515
+ MCPClientManager as xt,
5386
5516
  AgentToolStoredChunk as y,
5387
- MCPClientManager as yt,
5517
+ MCPClientElicitationHandler as yt,
5388
5518
  EmailRoutingOptions as z,
5389
- ElicitResult$1 as zt
5519
+ RPCServerTransportOptions as zt
5390
5520
  };
5391
- //# sourceMappingURL=agent-tool-types-CNyE1iz_.d.ts.map
5521
+ //# sourceMappingURL=agent-tool-types-BNUGGBzQ.d.ts.map
@@ -24,7 +24,7 @@ import {
24
24
  w as RunAgentToolOptions,
25
25
  x as ChatCapableAgentClass,
26
26
  y as AgentToolStoredChunk
27
- } from "./agent-tool-types-CNyE1iz_.js";
27
+ } from "./agent-tool-types-BNUGGBzQ.js";
28
28
  export {
29
29
  AGENT_TOOL_MILESTONE_PART,
30
30
  AGENT_TOOL_PROGRESS_PART,
@@ -4,7 +4,7 @@ import {
4
4
  o as AgentToolEventMessage,
5
5
  s as AgentToolEventState,
6
6
  y as AgentToolStoredChunk
7
- } from "./agent-tool-types-CNyE1iz_.js";
7
+ } from "./agent-tool-types-BNUGGBzQ.js";
8
8
 
9
9
  //#region src/chat/agent-tools.d.ts
10
10
  type AgentToolProgressEmitResult = "emitted" | "coalesced" | "inactive";
@@ -130,4 +130,4 @@ export {
130
130
  interceptAgentToolBroadcast as s,
131
131
  AgentToolBroadcastHooks as t
132
132
  };
133
- //# sourceMappingURL=agent-tools-BeOheFBK.d.ts.map
133
+ //# sourceMappingURL=agent-tools-BFbzVLFc.d.ts.map
@@ -19,7 +19,7 @@ import {
19
19
  w as RunAgentToolOptions,
20
20
  x as ChatCapableAgentClass,
21
21
  y as AgentToolStoredChunk
22
- } from "./agent-tool-types-CNyE1iz_.js";
22
+ } from "./agent-tool-types-BNUGGBzQ.js";
23
23
  import { Tool } from "ai";
24
24
 
25
25
  //#region src/agent-tools.d.ts
@@ -4,7 +4,7 @@ import {
4
4
  a as AgentToolEvent,
5
5
  o as AgentToolEventMessage,
6
6
  s as AgentToolEventState
7
- } from "../agent-tool-types-CNyE1iz_.js";
7
+ } from "../agent-tool-types-BNUGGBzQ.js";
8
8
  import {
9
9
  n as ClientToolSchema,
10
10
  r as createToolsFromClientSchemas,
@@ -18,7 +18,7 @@ import {
18
18
  r as AgentToolProgressEmitResult,
19
19
  s as interceptAgentToolBroadcast,
20
20
  t as AgentToolBroadcastHooks
21
- } from "../agent-tools-BeOheFBK.js";
21
+ } from "../agent-tools-BFbzVLFc.js";
22
22
  import { JSONSchema7, UIMessage } from "ai";
23
23
  import { Connection } from "agents";
24
24
 
@@ -987,6 +987,12 @@ declare function buildInClauseStrings(
987
987
  * clients. Both @cloudflare/ai-chat (via its MessageType enum) and
988
988
  * @cloudflare/think use these values.
989
989
  */
990
+ declare const STREAM_RESUME_NONE_REASONS: {
991
+ /** No active, pending, or terminal stream exists for this agent. */ readonly IDLE: "idle" /** An active tool continuation is owned by another live connection. */;
992
+ readonly CONTINUATION_OWNED: "continuation-owned";
993
+ };
994
+ type StreamResumeNoneReason =
995
+ (typeof STREAM_RESUME_NONE_REASONS)[keyof typeof STREAM_RESUME_NONE_REASONS];
990
996
  declare const CHAT_MESSAGE_TYPES: {
991
997
  readonly CHAT_MESSAGES: "cf_agent_chat_messages";
992
998
  readonly USE_CHAT_REQUEST: "cf_agent_use_chat_request";
@@ -1069,14 +1075,21 @@ type OutgoingMessage<ChatMessage extends UIMessage = UIMessage> =
1069
1075
  }
1070
1076
  | {
1071
1077
  /** Indicates the server is resuming an active stream */ type: MessageType.CF_AGENT_STREAM_RESUMING /** The request ID of the stream being resumed */;
1072
- id: string;
1078
+ id: string /** Present when this offer directly answers a client resume probe. */;
1079
+ probeId?: string;
1073
1080
  }
1074
1081
  | {
1075
1082
  /** Server notifies client that a message was updated (e.g., tool result applied) */ type: MessageType.CF_AGENT_MESSAGE_UPDATED /** The updated message */;
1076
1083
  message: ChatMessage;
1077
1084
  }
1078
1085
  | {
1079
- /** Server responds to resume request when no active stream exists */ type: MessageType.CF_AGENT_STREAM_RESUME_NONE;
1086
+ /** Server responds to a resume request with no stream for this client. */ type: MessageType.CF_AGENT_STREAM_RESUME_NONE;
1087
+ /**
1088
+ * Why no stream was offered. Only `idle` proves global inactivity;
1089
+ * omitted by older servers and by non-authoritative delayed releases.
1090
+ */
1091
+ reason?: StreamResumeNoneReason /** Correlates an authoritative response to its client resume probe. */;
1092
+ probeId?: string;
1080
1093
  }
1081
1094
  | {
1082
1095
  /**
@@ -1085,7 +1098,8 @@ type OutgoingMessage<ChatMessage extends UIMessage = UIMessage> =
1085
1098
  * `STREAM_RESUME_NONE`) rather than give up. See #1784.
1086
1099
  */
1087
1100
  type: MessageType.CF_AGENT_STREAM_PENDING /** The accepted request id, when known. */;
1088
- id?: string;
1101
+ id?: string /** Correlates a direct keep-waiting response to its client probe. */;
1102
+ probeId?: string;
1089
1103
  }
1090
1104
  | {
1091
1105
  /**
@@ -1135,7 +1149,8 @@ type IncomingMessage<ChatMessage extends UIMessage = UIMessage> =
1135
1149
  id: string;
1136
1150
  }
1137
1151
  | {
1138
- /** Client requests stream resume check after message handler is registered */ type: MessageType.CF_AGENT_STREAM_RESUME_REQUEST;
1152
+ /** Client requests stream resume check after message handler is registered */ type: MessageType.CF_AGENT_STREAM_RESUME_REQUEST /** Opaque correlation id echoed by direct server responses. */;
1153
+ probeId?: string;
1139
1154
  }
1140
1155
  | {
1141
1156
  /** Client sends tool result to server (for client-side tools) */ type: MessageType.CF_AGENT_TOOL_RESULT /** The tool call ID this result is for */;
@@ -1299,7 +1314,7 @@ declare class PreStreamTurns<
1299
1314
  * `pendingResumeConnections` — they must keep receiving any live broadcast —
1300
1315
  * until the host flushes them through `notifyStreamResuming` on stream start.
1301
1316
  */
1302
- park(connection: TConnection): boolean;
1317
+ park(connection: TConnection, probeId?: string): boolean;
1303
1318
  /** Drop a single connection (e.g. on socket close) without releasing others. */
1304
1319
  release(connectionId: string): void;
1305
1320
  /**
@@ -1774,6 +1789,7 @@ type ChatProtocolEvent =
1774
1789
  }
1775
1790
  | {
1776
1791
  type: "stream-resume-request";
1792
+ probeId?: string;
1777
1793
  }
1778
1794
  | {
1779
1795
  type: "stream-resume-ack";
@@ -3153,14 +3169,16 @@ declare class ResumeHandshake {
3153
3169
  * `reconnectToStream` hangs to its timeout with no replay), and the proactive
3154
3170
  * notify is required for clients that never send a request. The notify is one
3155
3171
  * tiny frame; the client dedupes its ACK so the buffer is not replayed twice.
3172
+ * Direct responses echo the opaque probe id; proactive notifications omit it.
3156
3173
  */
3157
- notifyStreamResuming(connection: Connection): void;
3174
+ notifyStreamResuming(connection: Connection, probeId?: string): void;
3158
3175
  /**
3159
3176
  * Handle a client `STREAM_RESUME_REQUEST`. The client sends this after its
3160
3177
  * message handler is registered, avoiding the race where a proactive
3161
3178
  * `STREAM_RESUMING` from onConnect arrives before the handler is ready.
3162
3179
  */
3163
- handleResumeRequest(connection: Connection): Promise<void>;
3180
+ handleResumeRequest(connection: Connection, probeId?: string): Promise<void>;
3181
+ private _sendResumeNone;
3164
3182
  /** Send a keep-waiting `STREAM_PENDING` frame (#1784). */
3165
3183
  private _sendStreamPending;
3166
3184
  /** Whether the active continuation's owner connection is still present. */
@@ -3324,6 +3342,7 @@ export {
3324
3342
  ResumeHandshake,
3325
3343
  type ResumeHandshakeHost,
3326
3344
  STREAM_CLEANUP_DELAY_SECONDS,
3345
+ STREAM_RESUME_NONE_REASONS,
3327
3346
  type SaveMessagesOptions,
3328
3347
  type SaveMessagesResult,
3329
3348
  type SnapshotMessage,
@@ -3332,6 +3351,7 @@ export {
3332
3351
  type StreamAccumulatorOptions,
3333
3352
  type StreamChunkData,
3334
3353
  StreamProgressCreditThrottle,
3354
+ type StreamResumeNoneReason,
3335
3355
  SubmitConcurrencyController,
3336
3356
  type SubmitConcurrencyDecision,
3337
3357
  TIMED_OUT,