agents 0.21.0 → 0.22.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 (137) hide show
  1. package/README.md +1 -0
  2. package/dist/{agent-tool-types-CzGGB-20.d.ts → agent-routing-CnkaHb-v.d.ts} +2921 -3057
  3. package/dist/agent-routing.d.ts +14 -0
  4. package/dist/agent-routing.js +187 -0
  5. package/dist/agent-routing.js.map +1 -0
  6. package/dist/agent-tool-types.d.ts +26 -26
  7. package/dist/{agent-tools-zR2d5uij.d.ts → agent-tools-C0XJqWzB.d.ts} +7 -7
  8. package/dist/agent-tools.d.ts +21 -21
  9. package/dist/agent-tools.js +2 -1
  10. package/dist/agent-tools.js.map +1 -1
  11. package/dist/browser/ai.js +2 -1
  12. package/dist/browser/ai.js.map +1 -1
  13. package/dist/capability-BjSKYpzg.js +42 -0
  14. package/dist/capability-BjSKYpzg.js.map +1 -0
  15. package/dist/capability-runner-CvHGZqUu.d.ts +150 -0
  16. package/dist/chat/index.d.ts +22 -15
  17. package/dist/chat/index.js +4 -4
  18. package/dist/chat/index.js.map +1 -1
  19. package/dist/chat/react.d.ts +14 -1
  20. package/dist/chat/react.js +82 -52
  21. package/dist/chat/react.js.map +1 -1
  22. package/dist/chat/transport.js +1 -1
  23. package/dist/chat-sdk/index.d.ts +4 -4
  24. package/dist/chat-sdk/index.js +1 -1
  25. package/dist/{client-zqKcsyFa.js → client-jagG8a9_.js} +129 -37
  26. package/dist/client-jagG8a9_.js.map +1 -0
  27. package/dist/client.d.ts +1 -1
  28. package/dist/client.js +1 -1
  29. package/dist/{cloudflare-BduZwmYK.js → cloudflare-Dzvc7V2N.js} +10 -3
  30. package/dist/{cloudflare-BduZwmYK.js.map → cloudflare-Dzvc7V2N.js.map} +1 -1
  31. package/dist/current-agent-CuMErtly.d.ts +283 -0
  32. package/dist/current-agent-DhoDkSnH.js +51 -0
  33. package/dist/current-agent-DhoDkSnH.js.map +1 -0
  34. package/dist/diagnostics-CaBjfz4J.js +41 -0
  35. package/dist/diagnostics-CaBjfz4J.js.map +1 -0
  36. package/dist/{do-oauth-client-provider-VTZj2VtM.d.ts → do-oauth-client-provider-Tmf1vgKz.d.ts} +2 -2
  37. package/dist/durable-object-lifecycle-D6nNQJJd.js +862 -0
  38. package/dist/durable-object-lifecycle-D6nNQJJd.js.map +1 -0
  39. package/dist/{email-CL27preh.d.ts → email-7TatiTnl.d.ts} +38 -9
  40. package/dist/email-send.d.ts +15 -0
  41. package/dist/email-send.js +32 -0
  42. package/dist/email-send.js.map +1 -0
  43. package/dist/email.d.ts +14 -10
  44. package/dist/email.js.map +1 -1
  45. package/dist/experimental/memory/session/index.d.ts +3 -2
  46. package/dist/experimental/memory/session/index.js +15 -10
  47. package/dist/experimental/memory/session/index.js.map +1 -1
  48. package/dist/{handler-stateless-C_bo-Ytq.d.ts → handler-stateless-DxYpJ_XF.d.ts} +3 -3
  49. package/dist/{handler-stateless-CIkKPETH.js → handler-stateless-VvrWSAVA.js} +5 -5
  50. package/dist/handler-stateless-VvrWSAVA.js.map +1 -0
  51. package/dist/{index-BRnybD6X.d.ts → index-DcSAZKsB.d.ts} +19 -31
  52. package/dist/index.d.ts +98 -95
  53. package/dist/index.js +10 -7234
  54. package/dist/internal_context-BlxFEWfn.d.ts +19 -0
  55. package/dist/internal_context.d.ts +10 -4
  56. package/dist/internal_context.js +1 -10
  57. package/dist/{client-invoker-BNSZxAkv.d.ts → invoker-CG0_p_Wq.d.ts} +2 -2
  58. package/dist/{client-invoker-VNZ7X0nn.js → invoker-CHMnoxIA.js} +2 -2
  59. package/dist/invoker-CHMnoxIA.js.map +1 -0
  60. package/dist/lifecycle/index.d.ts +48 -0
  61. package/dist/lifecycle/index.js +4 -0
  62. package/dist/mcp/{do-oauth-client-provider.d.ts → client/do-oauth-client-provider.d.ts} +1 -1
  63. package/dist/mcp/{do-oauth-client-provider.js → client/do-oauth-client-provider.js} +1 -1
  64. package/dist/mcp/client/do-oauth-client-provider.js.map +1 -0
  65. package/dist/mcp/client/index.d.ts +42 -0
  66. package/dist/mcp/{client.js → client/index.js} +1 -1
  67. package/dist/mcp/{x402.d.ts → client/x402.d.ts} +2 -2
  68. package/dist/mcp/{x402.js → client/x402.js} +2 -2
  69. package/dist/mcp/client/x402.js.map +1 -0
  70. package/dist/mcp/index.d.ts +36 -36
  71. package/dist/mcp/index.js +14 -16
  72. package/dist/mcp/index.js.map +1 -1
  73. package/dist/mcp/{server.d.ts → server/index.d.ts} +1 -1
  74. package/dist/mcp/{server.js → server/index.js} +1 -1
  75. package/dist/observability/ai/index.js +50 -35
  76. package/dist/observability/ai/index.js.map +1 -1
  77. package/dist/observability/index.d.ts +4 -4
  78. package/dist/observability/index.js +3 -50
  79. package/dist/observability/index.js.map +1 -1
  80. package/dist/{protocol-Dqc2MQxo.js → protocol-B0nh6KNf.js} +19 -21
  81. package/dist/protocol-B0nh6KNf.js.map +1 -0
  82. package/dist/react.d.ts +4 -4
  83. package/dist/react.js +1 -1
  84. package/dist/schedule.d.ts +25 -94
  85. package/dist/schedule.js +1 -98
  86. package/dist/schedule.js.map +1 -1
  87. package/dist/scheduler-CR9RHGos.js +857 -0
  88. package/dist/scheduler-CR9RHGos.js.map +1 -0
  89. package/dist/scheduler-DQoTGoAW.d.ts +224 -0
  90. package/dist/schedules/index.d.ts +22 -0
  91. package/dist/schedules/index.js +2 -0
  92. package/dist/schedules/parser.d.ts +79 -0
  93. package/dist/schedules/parser.js +103 -0
  94. package/dist/schedules/parser.js.map +1 -0
  95. package/dist/serializable.d.ts +1 -1
  96. package/dist/sql-error-CPY-GXyI.d.ts +12 -0
  97. package/dist/sql-error.d.ts +2 -0
  98. package/dist/sql-error.js +16 -0
  99. package/dist/sql-error.js.map +1 -0
  100. package/dist/src-5W6JNKVb.js +6613 -0
  101. package/dist/src-5W6JNKVb.js.map +1 -0
  102. package/dist/sub-routing.d.ts +12 -12
  103. package/dist/workflow-types.d.ts +25 -25
  104. package/dist/workflows.d.ts +22 -22
  105. package/dist/workflows.js +2 -1
  106. package/dist/workflows.js.map +1 -1
  107. package/dist/{ws-chat-transport-CIoOBbO7.js → ws-chat-transport-rWwta645.js} +152 -15
  108. package/dist/ws-chat-transport-rWwta645.js.map +1 -0
  109. package/docs/agent-class.md +28 -86
  110. package/docs/chat-agents.md +13 -12
  111. package/docs/durable-execution.md +1 -1
  112. package/docs/http-websockets.md +1 -11
  113. package/docs/human-in-the-loop.md +1 -1
  114. package/docs/index.md +1 -0
  115. package/docs/lifecycle.md +323 -0
  116. package/docs/long-running-agents.md +2 -4
  117. package/docs/mcp-client.md +55 -0
  118. package/docs/observability.md +11 -11
  119. package/docs/resumable-streaming.md +1 -1
  120. package/docs/scheduling.md +175 -15
  121. package/docs/server-driven-messages.md +1 -1
  122. package/docs/sub-agents.md +1 -1
  123. package/package.json +30 -21
  124. package/dist/cli/index.d.ts +0 -1
  125. package/dist/cli/index.js +0 -26
  126. package/dist/cli/index.js.map +0 -1
  127. package/dist/client-invoker-VNZ7X0nn.js.map +0 -1
  128. package/dist/client-zqKcsyFa.js.map +0 -1
  129. package/dist/handler-stateless-CIkKPETH.js.map +0 -1
  130. package/dist/index.js.map +0 -1
  131. package/dist/internal_context-Dg4Cgjcu.d.ts +0 -37
  132. package/dist/internal_context.js.map +0 -1
  133. package/dist/mcp/client.d.ts +0 -42
  134. package/dist/mcp/do-oauth-client-provider.js.map +0 -1
  135. package/dist/mcp/x402.js.map +0 -1
  136. package/dist/protocol-Dqc2MQxo.js.map +0 -1
  137. package/dist/ws-chat-transport-CIoOBbO7.js.map +0 -1
@@ -44,13 +44,13 @@ interface ServeOptions {
44
44
  jurisdiction?: DurableObjectJurisdiction;
45
45
  }
46
46
  //#endregion
47
- //#region src/mcp/auth-context.d.ts
47
+ //#region src/mcp/server/auth-context.d.ts
48
48
  interface McpAuthContext {
49
49
  props: Record<string, unknown>;
50
50
  }
51
51
  declare function getMcpAuthContext(): McpAuthContext | undefined;
52
52
  //#endregion
53
- //#region src/mcp/handler-stateless.d.ts
53
+ //#region src/mcp/server/handler-stateless.d.ts
54
54
  interface CreateStatelessMcpHandlerOptions extends Omit<
55
55
  CreateMcpHandlerOptions,
56
56
  "bus"
@@ -104,4 +104,4 @@ export {
104
104
  CreateStatelessMcpHandlerOptions as t,
105
105
  McpClientOptions as u
106
106
  };
107
- //# sourceMappingURL=handler-stateless-C_bo-Ytq.d.ts.map
107
+ //# sourceMappingURL=handler-stateless-DxYpJ_XF.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import { WebStandardStreamableHTTPServerTransport, createMcpHandler, hostHeaderValidationResponse, isJSONRPCRequest, isLegacyRequest, localhostAllowedHostnames, localhostAllowedOrigins, originValidationResponse } from "@modelcontextprotocol/server";
3
- //#region src/mcp/auth-context.ts
3
+ //#region src/mcp/server/auth-context.ts
4
4
  const VERIFIED_OAUTH_CONTEXT = Symbol.for("cloudflare.workers-oauth-provider.verified-context.v1");
5
5
  const authContextStorage = new AsyncLocalStorage();
6
6
  function getMcpAuthContext() {
@@ -49,7 +49,7 @@ function getVerifiedOAuthAuthInfo(ctx) {
49
49
  };
50
50
  }
51
51
  //#endregion
52
- //#region src/mcp/handler-errors.ts
52
+ //#region src/mcp/server/handler-errors.ts
53
53
  function internalErrorResponse(id = null) {
54
54
  return Response.json({
55
55
  jsonrpc: "2.0",
@@ -70,7 +70,7 @@ function reportHandlerError(onerror, error) {
70
70
  } catch {}
71
71
  }
72
72
  //#endregion
73
- //#region src/mcp/handler-legacy-compat.ts
73
+ //#region src/mcp/server/handler-legacy-compat.ts
74
74
  /**
75
75
  * Temporary adapter for Legacy compatibility on the SDK v2 transport.
76
76
  *
@@ -178,7 +178,7 @@ function createLegacyCompatibilityRequestHandler(factory, handlerOptions = {}) {
178
178
  return { fetch };
179
179
  }
180
180
  //#endregion
181
- //#region src/mcp/handler-stateless.ts
181
+ //#region src/mcp/server/handler-stateless.ts
182
182
  const DEFAULT_CORS_OPTIONS = {
183
183
  origin: "*",
184
184
  headers: "Content-Type, Accept, Authorization, mcp-session-id, MCP-Protocol-Version, Mcp-Method, Mcp-Name",
@@ -315,4 +315,4 @@ function createStatelessMcpHandler(factory, options = {}) {
315
315
  //#endregion
316
316
  export { getMcpAuthContext as n, runWithAuthContext as r, createStatelessMcpHandler as t };
317
317
 
318
- //# sourceMappingURL=handler-stateless-CIkKPETH.js.map
318
+ //# sourceMappingURL=handler-stateless-VvrWSAVA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler-stateless-VvrWSAVA.js","names":["candidate","createSdkMcpHandler"],"sources":["../src/mcp/server/auth-context.ts","../src/mcp/server/handler-errors.ts","../src/mcp/server/handler-legacy-compat.ts","../src/mcp/server/handler-stateless.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { AuthInfo } from \"@modelcontextprotocol/server\";\n\nconst VERIFIED_OAUTH_CONTEXT = Symbol.for(\n \"cloudflare.workers-oauth-provider.verified-context.v1\"\n);\n\ninterface VerifiedWorkersOAuthContext {\n version: 1;\n token: string;\n clientId: string;\n scopes: string[];\n expiresAt?: number;\n resource?: string;\n props: Record<string, unknown>;\n}\n\nexport interface McpAuthContext {\n props: Record<string, unknown>;\n}\n\nconst authContextStorage = new AsyncLocalStorage<McpAuthContext>();\n\nexport function getMcpAuthContext(): McpAuthContext | undefined {\n return authContextStorage.getStore();\n}\n\nexport function runWithAuthContext<T>(context: McpAuthContext, fn: () => T): T {\n return authContextStorage.run(context, fn);\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return false;\n }\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction invalidVerifiedContext(): never {\n throw new TypeError(\"Invalid verified OAuth request context\");\n}\n\nexport function getVerifiedOAuthAuthInfo(\n ctx: ExecutionContext\n): { authInfo: AuthInfo; props: Record<string, unknown> } | undefined {\n const symbolContext = ctx as ExecutionContext & Record<symbol, unknown>;\n if (!(VERIFIED_OAUTH_CONTEXT in symbolContext)) return undefined;\n\n const value = symbolContext[VERIFIED_OAUTH_CONTEXT];\n if (!isPlainRecord(value) || value.version !== 1) invalidVerifiedContext();\n\n const candidate = value as Partial<VerifiedWorkersOAuthContext>;\n const { token, clientId, scopes, expiresAt, resource, props } = candidate;\n if (\n typeof token !== \"string\" ||\n token.length === 0 ||\n typeof clientId !== \"string\" ||\n clientId.length === 0 ||\n !Array.isArray(scopes) ||\n !scopes.every((scope) => typeof scope === \"string\") ||\n !isPlainRecord(props)\n ) {\n invalidVerifiedContext();\n }\n\n if (\n expiresAt !== undefined &&\n (typeof expiresAt !== \"number\" ||\n !Number.isFinite(expiresAt) ||\n expiresAt <= 0)\n ) {\n invalidVerifiedContext();\n }\n\n let resourceUrl: URL | undefined;\n if (resource !== undefined) {\n if (typeof resource !== \"string\") invalidVerifiedContext();\n try {\n resourceUrl = new URL(resource);\n } catch {\n invalidVerifiedContext();\n }\n if (resourceUrl.protocol !== \"http:\" && resourceUrl.protocol !== \"https:\") {\n invalidVerifiedContext();\n }\n }\n\n if (ctx.props !== props) invalidVerifiedContext();\n\n return {\n props,\n authInfo: {\n token,\n clientId,\n scopes: [...scopes],\n ...(expiresAt !== undefined && { expiresAt }),\n ...(resourceUrl !== undefined && { resource: resourceUrl }),\n extra: { props }\n }\n };\n}\n","export function internalErrorResponse(\n id: string | number | null = null\n): Response {\n return Response.json(\n {\n jsonrpc: \"2.0\",\n error: { code: -32603, message: \"Internal server error\" },\n id\n },\n { status: 500 }\n );\n}\n\nexport function requestIdFromParsedBody(body: unknown): string | number | null {\n if (\n typeof body !== \"object\" ||\n body === null ||\n Array.isArray(body) ||\n !(\"method\" in body) ||\n typeof body.method !== \"string\" ||\n !(\"id\" in body)\n ) {\n return null;\n }\n return typeof body.id === \"string\" || typeof body.id === \"number\"\n ? body.id\n : null;\n}\n\nexport function reportHandlerError(\n onerror: ((error: Error) => void) | undefined,\n error: unknown\n): void {\n try {\n onerror?.(error instanceof Error ? error : new Error(String(error)));\n } catch {\n // Error reporting must not change the response.\n }\n}\n","import {\n WebStandardStreamableHTTPServerTransport,\n isJSONRPCRequest,\n type CreateMcpHandlerOptions,\n type McpHandlerRequestOptions,\n type McpServer,\n type McpServerFactory,\n type Server\n} from \"@modelcontextprotocol/server\";\nimport {\n internalErrorResponse,\n reportHandlerError,\n requestIdFromParsedBody\n} from \"./handler-errors\";\n/**\n * Temporary adapter for Legacy compatibility on the SDK v2 transport.\n *\n * Local deltas from the upstream stateless fallback:\n *\n * - impossible stateless server-to-client requests fail immediately rather\n * than leaving the tool handler waiting for a session response.\n *\n * Streaming and keepalive behavior remain delegated to the SDK transport.\n * Remove this adapter once the SDK exposes the reverse-request policy directly.\n */\nexport function createLegacyCompatibilityRequestHandler(\n factory: McpServerFactory,\n handlerOptions: Pick<CreateMcpHandlerOptions, \"keepAliveMs\" | \"onerror\"> = {}\n) {\n const { keepAliveMs, onerror } = handlerOptions;\n const fetch = async (\n request: Request,\n requestOptions: McpHandlerRequestOptions | undefined\n ): Promise<Response> => {\n // Match the upstream Legacy fallback: GET and DELETE are session operations\n // and cannot be served by a fresh per-request transport. Reject\n // them before running a factory with application-visible side effects.\n if (request.method.toUpperCase() !== \"POST\") {\n return Response.json(\n {\n jsonrpc: \"2.0\",\n error: { code: -32000, message: \"Method not allowed.\" },\n id: null\n },\n { status: 405 }\n );\n }\n\n if (request.signal.aborted) {\n return new Response(null, { status: 499 });\n }\n\n let product: McpServer | Server | undefined;\n let transport: WebStandardStreamableHTTPServerTransport | undefined;\n let teardownPromise: Promise<void> | undefined;\n const teardown = () =>\n (teardownPromise ??= (async () => {\n await Promise.all([\n transport?.close().catch(() => {}),\n product?.close().catch(() => {})\n ]);\n })());\n const onAbort = () => void teardown();\n\n try {\n product = await factory({\n era: \"legacy\",\n ...(requestOptions?.authInfo !== undefined && {\n authInfo: requestOptions.authInfo\n }),\n requestInfo: request\n });\n transport = new WebStandardStreamableHTTPServerTransport({\n keepAliveMs,\n sessionIdGenerator: undefined\n });\n\n const send = transport.send.bind(transport);\n transport.send = async (message, sendOptions) => {\n if (isJSONRPCRequest(message)) {\n transport?.onmessage?.({\n jsonrpc: \"2.0\",\n id: message.id,\n error: {\n code: -32603,\n message:\n \"Server-to-client requests are unavailable in the Legacy compatibility lane. \" +\n \"Use inputRequired(...) for Stateless clients, or route \" +\n \"Legacy traffic to a sessionful transport.\"\n }\n });\n return;\n }\n await send(message, sendOptions);\n };\n\n await product.connect(transport);\n if (request.signal.aborted) {\n await teardown();\n return new Response(null, { status: 499 });\n }\n request.signal.addEventListener(\"abort\", onAbort, { once: true });\n const response = await transport.handleRequest(request, {\n ...(requestOptions?.authInfo !== undefined && {\n authInfo: requestOptions.authInfo\n }),\n ...(requestOptions?.parsedBody !== undefined && {\n parsedBody: requestOptions.parsedBody\n })\n });\n\n if (\n response.body === null ||\n !response.headers.get(\"content-type\")?.includes(\"text/event-stream\")\n ) {\n request.signal.removeEventListener(\"abort\", onAbort);\n await teardown();\n return response;\n }\n\n const reader = response.body.getReader();\n const body = new ReadableStream<Uint8Array>({\n async pull(controller) {\n try {\n const { done, value } = await reader.read();\n if (done) {\n request.signal.removeEventListener(\"abort\", onAbort);\n await teardown();\n controller.close();\n } else if (value !== undefined) {\n controller.enqueue(value);\n }\n } catch (error) {\n request.signal.removeEventListener(\"abort\", onAbort);\n await teardown();\n controller.error(error);\n }\n },\n async cancel(reason) {\n request.signal.removeEventListener(\"abort\", onAbort);\n await reader.cancel(reason).catch(() => {});\n await teardown();\n }\n });\n return new Response(body, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers\n });\n } catch (error) {\n request.signal.removeEventListener(\"abort\", onAbort);\n await teardown();\n reportHandlerError(onerror, error);\n return internalErrorResponse(\n requestIdFromParsedBody(requestOptions?.parsedBody)\n );\n }\n };\n\n return { fetch };\n}\n","import {\n createMcpHandler as createSdkMcpHandler,\n hostHeaderValidationResponse,\n isLegacyRequest,\n localhostAllowedHostnames,\n localhostAllowedOrigins,\n originValidationResponse,\n type AuthInfo,\n type CreateMcpHandlerOptions as SdkCreateMcpHandlerOptions,\n type McpHandlerRequestOptions,\n type McpServerFactory,\n type ServerNotifier\n} from \"@modelcontextprotocol/server\";\nimport {\n getVerifiedOAuthAuthInfo,\n runWithAuthContext,\n type McpAuthContext\n} from \"./auth-context\";\nimport { internalErrorResponse, reportHandlerError } from \"./handler-errors\";\nimport { createLegacyCompatibilityRequestHandler } from \"./handler-legacy-compat\";\nimport type { CORSOptions } from \"../types\";\n\nexport interface CreateStatelessMcpHandlerOptions extends Omit<\n SdkCreateMcpHandlerOptions,\n \"bus\"\n> {\n /** Exact pathname handled by this Worker wrapper. @default \"/mcp\" */\n route?: string;\n /** CORS headers applied by the Worker wrapper. Pass `false` to disable. */\n corsOptions?: CORSOptions | false;\n /**\n * Restrict `Host` headers to these hostnames. Localhost and `workers.dev`\n * endpoints receive matching defaults; custom domains rely on Cloudflare\n * routing unless this option is set.\n */\n allowedHostnames?: string[];\n /**\n * Restrict present browser `Origin` headers to these hostnames. Requests\n * without an Origin (including non-browser MCP clients) remain valid. The\n * default includes localhost-class Origins, the endpoint's `workers.dev`\n * hostname, and a concrete `corsOptions.origin` hostname. Pass `\"*\"` only\n * when equivalent Origin validation runs in trusted middleware upstream.\n */\n allowedOriginHostnames?: string[] | \"*\";\n /** Application props exposed through {@link getMcpAuthContext}. */\n authContext?: McpAuthContext;\n}\n\nexport type StatelessMcpHandler = {\n (request: Request, env: unknown, ctx: ExecutionContext): Promise<Response>;\n fetch(\n request: Request,\n options?: McpHandlerRequestOptions\n ): Promise<Response>;\n notify: ServerNotifier;\n};\n\nexport type StatelessMcpServerInput = McpServerFactory;\n\nconst DEFAULT_CORS_OPTIONS: Required<CORSOptions> = {\n origin: \"*\",\n headers:\n \"Content-Type, Accept, Authorization, mcp-session-id, MCP-Protocol-Version, Mcp-Method, Mcp-Name\",\n methods: \"GET, POST, DELETE, OPTIONS\",\n exposeHeaders: \"mcp-session-id\",\n maxAge: 86400\n};\n\nfunction corsHeaders(options: CORSOptions = {}): Headers {\n const merged = { ...DEFAULT_CORS_OPTIONS, ...options };\n return new Headers({\n \"Access-Control-Allow-Headers\": merged.headers,\n \"Access-Control-Allow-Methods\": merged.methods,\n \"Access-Control-Allow-Origin\": merged.origin,\n \"Access-Control-Expose-Headers\": merged.exposeHeaders,\n \"Access-Control-Max-Age\": String(merged.maxAge)\n });\n}\n\nfunction withCors(response: Response, options: CORSOptions | false): Response {\n const headers = new Headers(response.headers);\n if (options === false) {\n for (const name of Array.from(headers.keys())) {\n if (name.toLowerCase().startsWith(\"access-control-\")) {\n headers.delete(name);\n }\n }\n } else {\n for (const [name, value] of corsHeaders(options)) {\n headers.set(name, value);\n }\n }\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers\n });\n}\n\nfunction wrapResponseBodyWithAuthContext(\n response: Response,\n authContext: McpAuthContext | undefined\n): Response {\n if (!authContext || !response.body) return response;\n\n const reader = response.body.getReader();\n const body = new ReadableStream<Uint8Array>({\n pull(controller) {\n return runWithAuthContext(authContext, async () => {\n try {\n const { done, value } = await reader.read();\n if (done) {\n controller.close();\n } else {\n controller.enqueue(value);\n }\n } catch (error) {\n controller.error(error);\n }\n });\n },\n cancel(reason) {\n return runWithAuthContext(authContext, () => reader.cancel(reason));\n }\n });\n\n return new Response(body, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers\n });\n}\n\nexport function createStatelessMcpHandler(\n factory: StatelessMcpServerInput,\n options: CreateStatelessMcpHandlerOptions = {}\n): StatelessMcpHandler {\n const optionRecord = options as Record<string, unknown>;\n if (optionRecord.bus !== undefined) {\n throw new TypeError(\n 'createMcpHandler option \"bus\" is not exposed by the Agents SDK.'\n );\n }\n const legacyOnlyOption = [\n \"transport\",\n \"storage\",\n \"sessionIdGenerator\",\n \"onsessioninitialized\",\n \"onsessionclosed\",\n \"enableJsonResponse\",\n \"eventStore\",\n \"allowedHosts\",\n \"allowedOrigins\",\n \"enableDnsRebindingProtection\",\n \"retryInterval\"\n ].find((key) => optionRecord[key] !== undefined);\n if (legacyOnlyOption) {\n throw new TypeError(\n `createMcpHandler option \"${legacyOnlyOption}\" is only supported with an MCP SDK v1 server. The managed SDK v2 handler is stateless; remove this option or keep the v1 server during migration.`\n );\n }\n\n const {\n route = \"/mcp\",\n corsOptions = {},\n allowedHostnames,\n allowedOriginHostnames,\n authContext,\n legacy = \"stateless\",\n ...sdkOptions\n } = options;\n\n const sdkHandler = createSdkMcpHandler(factory, {\n ...sdkOptions,\n legacy: \"reject\"\n });\n const legacyCompatibilityHandler =\n legacy === \"stateless\"\n ? createLegacyCompatibilityRequestHandler(factory, {\n keepAliveMs: sdkOptions.keepAliveMs,\n onerror: sdkOptions.onerror\n })\n : undefined;\n\n const serve = async (\n request: Request,\n requestOptions?: McpHandlerRequestOptions,\n workerCtx?: ExecutionContext\n ): Promise<Response> => {\n const requestUrl = new URL(request.url);\n if (requestUrl.pathname !== route) {\n return withCors(new Response(\"Not Found\", { status: 404 }), corsOptions);\n }\n\n // The SDK app factories can distinguish their bind address from an\n // attacker-controlled Host header. A bare Worker cannot. Use defaults we\n // can establish independently: localhost-class names, a standard\n // workers.dev route, and any concrete CORS Origin the application chose.\n // Custom-domain deployments can provide explicit Host and Origin lists.\n const localEndpoint = localhostAllowedHostnames().includes(\n requestUrl.hostname\n );\n const workersDevEndpoint = requestUrl.hostname.endsWith(\".workers.dev\");\n const acceptedHostnames =\n allowedHostnames ??\n (localEndpoint\n ? localhostAllowedHostnames()\n : workersDevEndpoint\n ? [requestUrl.hostname]\n : undefined);\n const hostRejection = acceptedHostnames\n ? hostHeaderValidationResponse(request, acceptedHostnames)\n : undefined;\n if (hostRejection) {\n return withCors(hostRejection, corsOptions);\n }\n if (allowedOriginHostnames !== \"*\") {\n let acceptedOriginHostnames = allowedOriginHostnames;\n if (acceptedOriginHostnames === undefined) {\n const defaults = new Set(localhostAllowedOrigins());\n if (workersDevEndpoint) defaults.add(requestUrl.hostname);\n if (corsOptions !== false && corsOptions.origin !== undefined) {\n try {\n const configuredOrigin = new URL(corsOptions.origin);\n if (\n (configuredOrigin.protocol === \"http:\" ||\n configuredOrigin.protocol === \"https:\") &&\n configuredOrigin.hostname\n ) {\n defaults.add(configuredOrigin.hostname);\n }\n } catch {\n // A wildcard or malformed CORS value does not expand the allowlist.\n }\n }\n acceptedOriginHostnames = [...defaults];\n }\n const originRejection = originValidationResponse(\n request,\n acceptedOriginHostnames ?? []\n );\n if (originRejection) {\n return withCors(originRejection, corsOptions);\n }\n }\n\n if (request.method === \"OPTIONS\" && corsOptions !== false) {\n return new Response(null, { headers: corsHeaders(corsOptions) });\n }\n\n const legacyRequest =\n legacyCompatibilityHandler !== undefined &&\n (await isLegacyRequest(request, requestOptions?.parsedBody));\n\n try {\n const verified = workerCtx\n ? getVerifiedOAuthAuthInfo(workerCtx)\n : undefined;\n const explicitAuthInfo = requestOptions?.authInfo;\n if (\n verified &&\n explicitAuthInfo &&\n explicitAuthInfo.clientId !== verified.authInfo.clientId\n ) {\n throw new TypeError(\"Conflicting verified OAuth client identity\");\n }\n\n const authInfo: AuthInfo | undefined =\n explicitAuthInfo ?? verified?.authInfo;\n const resolvedAuthContext =\n authContext ??\n (verified\n ? { props: verified.props }\n : workerCtx?.props && Object.keys(workerCtx.props).length > 0\n ? { props: workerCtx.props as Record<string, unknown> }\n : undefined);\n const upstreamOptions: McpHandlerRequestOptions | undefined =\n requestOptions || authInfo\n ? { ...requestOptions, ...(authInfo && { authInfo }) }\n : undefined;\n const invoke = async () => {\n if (legacyRequest && legacyCompatibilityHandler) {\n return legacyCompatibilityHandler.fetch(request, upstreamOptions);\n }\n return sdkHandler.fetch(request, upstreamOptions);\n };\n const response = resolvedAuthContext\n ? await runWithAuthContext(resolvedAuthContext, invoke)\n : await invoke();\n return withCors(\n wrapResponseBodyWithAuthContext(response, resolvedAuthContext),\n corsOptions\n );\n } catch (error) {\n reportHandlerError(sdkOptions.onerror, error);\n return withCors(internalErrorResponse(), corsOptions);\n }\n };\n\n const callable = (request: Request, _env: unknown, ctx: ExecutionContext) =>\n serve(request, undefined, ctx);\n const fetch = (request: Request, requestOptions?: McpHandlerRequestOptions) =>\n serve(request, requestOptions);\n\n return Object.assign(callable, {\n fetch,\n notify: sdkHandler.notify\n }) as StatelessMcpHandler;\n}\n"],"mappings":";;;AAGA,MAAM,yBAAyB,OAAO,IACpC,uDACF;AAgBA,MAAM,qBAAqB,IAAI,kBAAkC;AAEjE,SAAgB,oBAAgD;CAC9D,OAAO,mBAAmB,SAAS;AACrC;AAEA,SAAgB,mBAAsB,SAAyB,IAAgB;CAC7E,OAAO,mBAAmB,IAAI,SAAS,EAAE;AAC3C;AAEA,SAAS,cAAc,OAAkD;CACvE,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GACpE,OAAO;CAET,MAAM,YAAY,OAAO,eAAe,KAAK;CAC7C,OAAO,cAAc,OAAO,aAAa,cAAc;AACzD;AAEA,SAAS,yBAAgC;CACvC,MAAM,IAAI,UAAU,wCAAwC;AAC9D;AAEA,SAAgB,yBACd,KACoE;CACpE,MAAM,gBAAgB;CACtB,IAAI,EAAE,0BAA0B,gBAAgB,OAAO,KAAA;CAEvD,MAAM,QAAQ,cAAc;CAC5B,IAAI,CAAC,cAAc,KAAK,KAAK,MAAM,YAAY,GAAG,uBAAuB;CAGzE,MAAM,EAAE,OAAO,UAAU,QAAQ,WAAW,UAAU,UAAUA;CAChE,IACE,OAAO,UAAU,YACjB,MAAM,WAAW,KACjB,OAAO,aAAa,YACpB,SAAS,WAAW,KACpB,CAAC,MAAM,QAAQ,MAAM,KACrB,CAAC,OAAO,OAAO,UAAU,OAAO,UAAU,QAAQ,KAClD,CAAC,cAAc,KAAK,GAEpB,uBAAuB;CAGzB,IACE,cAAc,KAAA,MACb,OAAO,cAAc,YACpB,CAAC,OAAO,SAAS,SAAS,KAC1B,aAA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CAC/B,MAAM,SAAS,SAAkB,mBAC/B,MAAM,SAAS,cAAc;CAE/B,OAAO,OAAO,OAAO,UAAU;EAC7B;EACA,QAAQ,WAAW;CACrB,CAAC;AACH"}
@@ -776,33 +776,8 @@ type AgentObservabilityEvent =
776
776
  }
777
777
  >;
778
778
  //#endregion
779
- //#region src/observability/index.d.ts
780
- /**
781
- * Union of all observability event types from different domains
782
- */
783
- type ObservabilityEvent = AgentObservabilityEvent | MCPObservabilityEvent;
784
- interface Observability {
785
- /**
786
- * Emit an event for the Agent's observability implementation to handle.
787
- * @param event - The event to emit
788
- */
789
- emit(event: ObservabilityEvent): void;
790
- }
791
- /**
792
- * Diagnostics channels for agent observability.
793
- *
794
- * Events are published to named channels using the Node.js diagnostics_channel API.
795
- * By default, publishing to a channel with no subscribers is a no-op (zero overhead).
796
- *
797
- * To observe events, subscribe to the channels you care about:
798
- * ```ts
799
- * import { subscribe } from "node:diagnostics_channel";
800
- * subscribe("agents:rpc", (event) => console.log(event));
801
- * ```
802
- *
803
- * In production, all published messages are automatically forwarded to
804
- * Tail Workers via `event.diagnosticsChannelEvents` — no subscription needed.
805
- */
779
+ //#region src/observability/diagnostics.d.ts
780
+ /** Diagnostics channels for Agent and Lifecycle telemetry. */
806
781
  declare const channels: {
807
782
  readonly state: Channel<any, any>;
808
783
  readonly rpc: Channel<any, any>;
@@ -818,6 +793,19 @@ declare const channels: {
818
793
  readonly email: Channel<any, any>;
819
794
  readonly channel: Channel<any, any>;
820
795
  };
796
+ //#endregion
797
+ //#region src/observability/index.d.ts
798
+ /**
799
+ * Union of all observability event types from different domains
800
+ */
801
+ type ObservabilityEvent = AgentObservabilityEvent | MCPObservabilityEvent;
802
+ interface Observability {
803
+ /**
804
+ * Emit an event for the Agent's observability implementation to handle.
805
+ * @param event - The event to emit
806
+ */
807
+ emit(event: ObservabilityEvent): void;
808
+ }
821
809
  /**
822
810
  * The default observability implementation.
823
811
  *
@@ -936,12 +924,12 @@ declare function subscribe$1<K extends keyof ChannelEventMap>(
936
924
  ): () => void;
937
925
  //#endregion
938
926
  export {
939
- genericObservability as a,
940
- channels as i,
927
+ subscribe$1 as a,
928
+ genericObservability as i,
941
929
  Observability as n,
942
- subscribe$1 as o,
930
+ channels as o,
943
931
  ObservabilityEvent as r,
944
932
  MCPObservabilityEvent as s,
945
933
  ChannelEventMap as t
946
934
  };
947
- //# sourceMappingURL=index-BRnybD6X.d.ts.map
935
+ //# sourceMappingURL=index-DcSAZKsB.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,91 +1,93 @@
1
1
  /// <reference path="../skills-module.d.ts" />
2
- import { r as __DO_NOT_USE_WILL_BREAK__agentContext } from "./internal_context-Dg4Cgjcu.js";
3
2
  import {
4
- $ as RoutingRetryOptions,
5
- A as AgentGetOptions,
6
- B as EmailSendBinding,
7
- Bn as parseSubAgentPath,
8
- C as DetachedRunAgentToolResult,
9
- D as AddRpcMcpServerOptions,
10
- E as AddMcpServerOptions,
11
- F as Connection,
12
- Fn as buildAgentPath,
13
- G as FiberStatus,
14
- H as FiberInspection,
15
- Hn as withInvocationScope,
16
- I as ConnectionContext,
17
- In as buildAgentUrl,
18
- J as MCPServerMessage,
19
- K as ListFibersOptions,
20
- L as DEFAULT_AGENT_STATIC_OPTIONS,
21
- M as AgentOptions,
22
- Mn as BuildAgentPathOptions,
23
- N as AgentStaticOptions,
24
- Nn as SUB_PREFIX,
25
- O as Agent,
26
- P as CallableMetadata,
27
- Pn as SubAgentPathMatch,
28
- Q as RPCResponse,
29
- R as DeleteFibersOptions,
30
- S as DetachedAgentToolConfig,
31
- T as RunAgentToolResult,
32
- U as FiberRecoveryContext,
33
- Ut as MCPAITool,
34
- V as FiberContext,
35
- Vn as routeSubAgentRequest,
36
- W as FiberRecoveryResult,
37
- Wt as MCPAIToolSet,
38
- X as QueueItem,
39
- Y as MCPServersState,
40
- Z as RPCRequest,
41
- _ as AgentToolRunState,
42
- a as AgentToolEvent,
43
- an as normalizeServerId,
44
- at as StartFiberResult,
45
- b as AgentToolTerminalStatus,
46
- c as AgentToolFailure,
47
- ct as SubAgentClass,
48
- d as AgentToolMilestone,
49
- dt as callable,
50
- et as Schedule,
51
- f as AgentToolProgress,
52
- ft as getAgentByName,
53
- g as AgentToolRunPart,
54
- gt as unstable_callable,
55
- h as AgentToolRunInspection,
56
- ht as routeAgentRequest,
57
- i as AgentToolDisplayMetadata,
58
- it as StartFiberOptions,
59
- j as AgentNamespace,
60
- jn as AgentPathStep,
61
- k as AgentContext,
62
- l as AgentToolInterruptedReason,
63
- lt as SubAgentStub,
64
- m as AgentToolRunInfo,
65
- mt as routeAgentEmail,
66
- n as AGENT_TOOL_PROGRESS_PART,
67
- nn as MCP_SERVER_ID_MAX_LENGTH,
68
- nt as SendEmailOptions,
69
- o as AgentToolEventMessage,
70
- ot as StateUpdateMessage,
71
- p as AgentToolProgressSnapshot,
72
- pt as getCurrentAgent,
73
- q as MCPServer,
74
- r as AgentToolChildAdapter,
75
- rt as SqlError,
76
- s as AgentToolEventState,
77
- st as StreamingResponse,
78
- t as AGENT_TOOL_MILESTONE_PART,
79
- tt as ScheduleCriteria,
80
- u as AgentToolLifecycleResult,
81
- ut as WSMessage,
82
- v as AgentToolRunStatus,
83
- w as RunAgentToolOptions,
84
- x as ChatCapableAgentClass,
85
- y as AgentToolStoredChunk,
86
- z as EmailRoutingOptions,
87
- zn as getSubAgentByName
88
- } from "./agent-tool-types-CzGGB-20.js";
3
+ c as WSMessage,
4
+ i as __DO_NOT_USE_WILL_BREAK__agentContext,
5
+ l as Connection,
6
+ u as ConnectionContext
7
+ } from "./current-agent-CuMErtly.js";
8
+ import {
9
+ $ as AgentToolRunPart,
10
+ A as StateUpdateMessage,
11
+ B as AgentToolChildAdapter,
12
+ C as MCPServerMessage,
13
+ Cn as AgentPathStep,
14
+ D as RPCResponse,
15
+ Dn as buildAgentPath,
16
+ E as RPCRequest,
17
+ En as SubAgentPathMatch,
18
+ F as getCurrentAgent,
19
+ Ft as MCPAITool,
20
+ G as AgentToolFailure,
21
+ H as AgentToolEvent,
22
+ I as routeAgentEmail,
23
+ It as MCPAIToolSet,
24
+ J as AgentToolMilestone,
25
+ Jt as MCP_SERVER_ID_MAX_LENGTH,
26
+ K as AgentToolInterruptedReason,
27
+ L as unstable_callable,
28
+ M as SubAgentClass,
29
+ Mn as parseSubAgentPath,
30
+ N as SubAgentStub,
31
+ Nn as routeSubAgentRequest,
32
+ O as StartFiberOptions,
33
+ On as buildAgentUrl,
34
+ P as callable,
35
+ Pn as withInvocationScope,
36
+ Q as AgentToolRunInspection,
37
+ R as AGENT_TOOL_MILESTONE_PART,
38
+ S as MCPServer,
39
+ T as QueueItem,
40
+ Tn as SUB_PREFIX,
41
+ U as AgentToolEventMessage,
42
+ V as AgentToolDisplayMetadata,
43
+ W as AgentToolEventState,
44
+ X as AgentToolProgressSnapshot,
45
+ Y as AgentToolProgress,
46
+ Z as AgentToolRunInfo,
47
+ Zt as normalizeServerId,
48
+ _ as FiberInspection,
49
+ a as routeAgentRequest,
50
+ at as DetachedAgentToolConfig,
51
+ b as FiberStatus,
52
+ c as Agent,
53
+ ct as RunAgentToolResult,
54
+ d as AgentStaticOptions,
55
+ et as AgentToolRunState,
56
+ f as CallableMetadata,
57
+ g as FiberContext,
58
+ h as EmailRoutingOptions,
59
+ i as getAgentByName,
60
+ it as ChatCapableAgentClass,
61
+ j as StreamingResponse,
62
+ jn as getSubAgentByName,
63
+ k as StartFiberResult,
64
+ l as AgentContext,
65
+ m as DeleteFibersOptions,
66
+ n as AgentOptions,
67
+ nt as AgentToolStoredChunk,
68
+ o as AddMcpServerOptions,
69
+ ot as DetachedRunAgentToolResult,
70
+ p as DEFAULT_AGENT_STATIC_OPTIONS,
71
+ q as AgentToolLifecycleResult,
72
+ r as RoutingRetryOptions,
73
+ rt as AgentToolTerminalStatus,
74
+ s as AddRpcMcpServerOptions,
75
+ st as RunAgentToolOptions,
76
+ t as AgentGetOptions,
77
+ tt as AgentToolRunStatus,
78
+ u as AgentNamespace,
79
+ v as FiberRecoveryContext,
80
+ w as MCPServersState,
81
+ wn as BuildAgentPathOptions,
82
+ x as ListFibersOptions,
83
+ y as FiberRecoveryResult,
84
+ z as AGENT_TOOL_PROGRESS_PART
85
+ } from "./agent-routing-CnkaHb-v.js";
86
+ import {
87
+ a as EmailSendBinding,
88
+ d as createHeaderBasedEmailResolver,
89
+ s as SendEmailOptions
90
+ } from "./email-7TatiTnl.js";
89
91
  import { n as camelCaseToKebabCase } from "./utils-CGtGDSgA.js";
90
92
  import {
91
93
  i as isDurableObjectStorageReset,
@@ -98,10 +100,11 @@ import {
98
100
  n as AgentsOAuthProvider,
99
101
  r as DurableObjectOAuthClientProvider,
100
102
  t as AgentMcpOAuthProvider
101
- } from "./do-oauth-client-provider-VTZj2VtM.js";
102
- import { f as TransportType } from "./handler-stateless-C_bo-Ytq.js";
103
+ } from "./do-oauth-client-provider-Tmf1vgKz.js";
104
+ import { f as TransportType } from "./handler-stateless-DxYpJ_XF.js";
103
105
  import { t as MessageType } from "./types-6Zo2zfoO.js";
104
- import { l as createHeaderBasedEmailResolver } from "./email-CL27preh.js";
106
+ import { a as ScheduleCriteria, i as Schedule } from "./scheduler-DQoTGoAW.js";
107
+ import { t as SqlError } from "./sql-error-CPY-GXyI.js";
105
108
  export {
106
109
  AGENT_TOOL_MILESTONE_PART,
107
110
  AGENT_TOOL_PROGRESS_PART,
@@ -109,10 +112,10 @@ export {
109
112
  AddRpcMcpServerOptions,
110
113
  Agent,
111
114
  AgentContext,
112
- AgentGetOptions,
115
+ type AgentGetOptions,
113
116
  type AgentMcpOAuthProvider,
114
117
  AgentNamespace,
115
- AgentOptions,
118
+ type AgentOptions,
116
119
  type AgentPathStep,
117
120
  AgentStaticOptions,
118
121
  type AgentToolChildAdapter,
@@ -145,7 +148,7 @@ export {
145
148
  type DetachedRunAgentToolResult,
146
149
  DurableObjectOAuthClientProvider,
147
150
  EmailRoutingOptions,
148
- EmailSendBinding,
151
+ type EmailSendBinding,
149
152
  FiberContext,
150
153
  FiberInspection,
151
154
  FiberRecoveryContext,
@@ -167,9 +170,9 @@ export {
167
170
  type RunAgentToolOptions,
168
171
  type RunAgentToolResult,
169
172
  SUB_PREFIX,
170
- Schedule,
171
- ScheduleCriteria,
172
- SendEmailOptions,
173
+ type Schedule,
174
+ type ScheduleCriteria,
175
+ type SendEmailOptions,
173
176
  SqlError,
174
177
  StartFiberOptions,
175
178
  StartFiberResult,