agents 0.25.0 → 0.27.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.
- package/README.md +8 -9
- package/dist/{agent-routing-0DR0Tk2v.d.ts → agent-routing-Bhdbvf7s.d.ts} +13 -8
- package/dist/agent-routing.d.ts +1 -1
- package/dist/agent-tool-types.d.ts +1 -1
- package/dist/{agent-tools-YrATZJu2.d.ts → agent-tools-bJZwBMfq.d.ts} +2 -2
- package/dist/agent-tools.d.ts +1 -1
- package/dist/ai-sdk-OoGkFy3s.js +2444 -0
- package/dist/ai-sdk-OoGkFy3s.js.map +1 -0
- package/dist/apply-chunks-1FheRb9W.js +99 -0
- package/dist/apply-chunks-1FheRb9W.js.map +1 -0
- package/dist/broadcast-state-CEyI4uAK.js +69 -0
- package/dist/broadcast-state-CEyI4uAK.js.map +1 -0
- package/dist/browser/ai-sdk.d.ts +1 -1
- package/dist/browser/ai-sdk.js +2 -2
- package/dist/browser/ai-sdk.js.map +1 -1
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/tanstack-ai.d.ts +1 -1
- package/dist/browser/tanstack-ai.js +1 -1
- package/dist/{browser-DE3d-RLk.d.ts → browser-tmkcAAI3.d.ts} +2 -2
- package/dist/{browser-tool-DuNdlwZ9.d.ts → browser-tool-Bn-nzJQI.d.ts} +3 -3
- package/dist/{browser-tool-CQ10e6Kj.js → browser-tool-CBqs6hqa.js} +58 -18
- package/dist/browser-tool-CBqs6hqa.js.map +1 -0
- package/dist/capability-B4WbF81e.js.map +1 -1
- package/dist/{capability-runner-DBAnGr6L.d.ts → capability-runner-O5VbQzqg.d.ts} +9 -1
- package/dist/channel-Bak_6zDP.d.ts +333 -0
- package/dist/chat/index.d.ts +11 -9
- package/dist/chat/index.js +5 -194
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/react.d.ts +2 -4
- package/dist/chat/react.js +3 -1
- package/dist/chat/react.js.map +1 -1
- package/dist/chat-sdk/index.d.ts +1 -1
- package/dist/chat-sdk/index.js +1 -1
- package/dist/cli.js +144 -0
- package/dist/{client-fyQrLGkD.js → client-1tEQ1Oqz.js} +27 -2
- package/dist/{client-fyQrLGkD.js.map → client-1tEQ1Oqz.js.map} +1 -1
- package/dist/{client-je3koD9Z.d.ts → client-DS3Dz9l0.d.ts} +2 -2
- package/dist/client-tools-aIBO0Fk7.d.ts +53 -0
- package/dist/client.d.ts +1 -1
- package/dist/conversations-DH0ut_8n.d.ts +192 -0
- package/dist/{current-agent-vAk_5JMt.d.ts → current-agent-C07C5o5Y.d.ts} +3 -3
- package/dist/daemon-core-Buubj-y1.js +481 -0
- package/dist/daemon-core-Buubj-y1.js.map +1 -0
- package/dist/daemon-core-CbohVPAu.d.ts +132 -0
- package/dist/{do-oauth-client-provider-Tmf1vgKz.d.ts → do-oauth-client-provider-DfsUcpc3.d.ts} +7 -1
- package/dist/{durable-object-lifecycle-HhgOMWq9.d.ts → durable-object-lifecycle-DRqp475_.d.ts} +2 -2
- package/dist/{channels/email.d.ts → experimental/channels/email/index.d.ts} +25 -12
- package/dist/{channels/email.js → experimental/channels/email/index.js} +13 -35
- package/dist/experimental/channels/email/index.js.map +1 -0
- package/dist/experimental/channels/index.d.ts +270 -0
- package/dist/experimental/channels/index.js +1186 -0
- package/dist/experimental/channels/index.js.map +1 -0
- package/dist/{channels/slack.d.ts → experimental/channels/slack/index.d.ts} +19 -9
- package/dist/experimental/channels/slack/index.js +267 -0
- package/dist/experimental/channels/slack/index.js.map +1 -0
- package/dist/{channels/telegram.d.ts → experimental/channels/telegram/index.d.ts} +19 -9
- package/dist/experimental/channels/telegram/index.js +198 -0
- package/dist/experimental/channels/telegram/index.js.map +1 -0
- package/dist/experimental/channels/web/ai-sdk.d.ts +55 -0
- package/dist/experimental/channels/web/ai-sdk.js +266 -0
- package/dist/experimental/channels/web/ai-sdk.js.map +1 -0
- package/dist/experimental/channels/web/client.d.ts +97 -0
- package/dist/experimental/channels/web/client.js +349 -0
- package/dist/experimental/channels/web/client.js.map +1 -0
- package/dist/experimental/channels/web/index.d.ts +189 -0
- package/dist/experimental/channels/web/index.js +332 -0
- package/dist/experimental/channels/web/index.js.map +1 -0
- package/dist/gateway-BDC07gYO.d.ts +100 -0
- package/dist/handle-zAzh0UW2.d.ts +460 -0
- package/dist/harness/ai-sdk/index.d.ts +175 -0
- package/dist/harness/ai-sdk/index.js +605 -0
- package/dist/harness/ai-sdk/index.js.map +1 -0
- package/dist/harness/container/daemon/index.d.ts +76 -0
- package/dist/harness/container/daemon/index.js +3 -0
- package/dist/harness/container/index.d.ts +740 -0
- package/dist/harness/container/index.js +2152 -0
- package/dist/harness/container/index.js.map +1 -0
- package/dist/harness/container/runtime/index.d.ts +144 -0
- package/dist/harness/container/runtime/index.js +1082 -0
- package/dist/harness/container/runtime/index.js.map +1 -0
- package/dist/harness/opencode/index.d.ts +369 -0
- package/dist/harness/opencode/index.js +1072 -0
- package/dist/harness/opencode/index.js.map +1 -0
- package/dist/{harnesses → harness}/pi/index.d.ts +85 -88
- package/dist/{harnesses → harness}/pi/index.js +196 -77
- package/dist/harness/pi/index.js.map +1 -0
- package/dist/harness/store/index.d.ts +24 -0
- package/dist/harness/store/index.js +2 -0
- package/dist/harness/think/index.d.ts +821 -0
- package/dist/harness/think/index.js +2529 -0
- package/dist/harness/think/index.js.map +1 -0
- package/dist/harness-B6B9S3rb.d.ts +203 -0
- package/dist/{images-iiTDSyRu.js → images-Ce9SCu3X.js} +2 -248
- package/dist/images-Ce9SCu3X.js.map +1 -0
- package/dist/{index-BreL0YrQ.d.ts → index-D0A5tbWu.d.ts} +2 -2
- package/dist/index-Ib_4dwOo.d.ts +200 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -2
- package/dist/ingress-EFbrS547.js +9 -0
- package/dist/ingress-EFbrS547.js.map +1 -0
- package/dist/input-schema-DNrpTu49.js +23 -0
- package/dist/input-schema-DNrpTu49.js.map +1 -0
- package/dist/internal-kmw70xwR.js +46 -0
- package/dist/internal-kmw70xwR.js.map +1 -0
- package/dist/internal_context.d.ts +1 -1
- package/dist/lifecycle/index.d.ts +3 -3
- package/dist/mcp/client/do-oauth-client-provider.d.ts +1 -1
- package/dist/mcp/client/do-oauth-client-provider.js +9 -0
- package/dist/mcp/client/do-oauth-client-provider.js.map +1 -1
- package/dist/mcp/client/index.d.ts +1 -1
- package/dist/mcp/client/index.js +1 -1
- package/dist/mcp/client/x402.d.ts +35 -4
- package/dist/mcp/client/x402.js +24 -3
- package/dist/mcp/client/x402.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +2 -2
- package/dist/models/ai-sdk/index.d.ts +16 -14
- package/dist/models/ai-sdk/index.js +1 -2442
- package/dist/models/opencode/index.d.ts +65 -0
- package/dist/models/opencode/index.js +285 -0
- package/dist/models/opencode/index.js.map +1 -0
- package/dist/models/pi-ai/index.d.ts +23 -21
- package/dist/models/pi-ai/index.js +7 -6
- package/dist/models/pi-ai/index.js.map +1 -1
- package/dist/options-pwTNq9z6.d.ts +134 -0
- package/dist/protocol-BEgrJYC5.d.ts +331 -0
- package/dist/protocol-CukuI73M.d.ts +386 -0
- package/dist/protocol-cOklVBBD.js +227 -0
- package/dist/protocol-cOklVBBD.js.map +1 -0
- package/dist/{protocol-kHsr-f0X.js → protocol-eXeJxhgu.js} +2 -67
- package/dist/protocol-eXeJxhgu.js.map +1 -0
- package/dist/protocol-y2sSY584.js +148 -0
- package/dist/protocol-y2sSY584.js.map +1 -0
- package/dist/queue/index.d.ts +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/routing/index.d.ts +2 -2
- package/dist/{scheduler-RdACNXDP.d.ts → scheduler-CrFCnv_J.d.ts} +2 -2
- package/dist/schedules/index.d.ts +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/sessions/index.d.ts +11 -434
- package/dist/sessions/index.js +1 -2271
- package/dist/sessions-B9pNuxdT.js +2272 -0
- package/dist/sessions-B9pNuxdT.js.map +1 -0
- package/dist/settings-C45hDliX.js +253 -0
- package/dist/settings-C45hDliX.js.map +1 -0
- package/dist/{transport-PfFnt-Ld.d.ts → settings-NgGwF7Qt.d.ts} +14 -208
- package/dist/{src-BZeu-SCD.js → src-DgCbZtIR.js} +4 -4
- package/dist/{src-BZeu-SCD.js.map → src-DgCbZtIR.js.map} +1 -1
- package/dist/stall-watchdog-BpRF2uwG.js +195 -0
- package/dist/stall-watchdog-BpRF2uwG.js.map +1 -0
- package/dist/state/index.d.ts +1 -1
- package/dist/store-DLeqKuj3.d.ts +310 -0
- package/dist/store-vgcPYo8K.js +432 -0
- package/dist/store-vgcPYo8K.js.map +1 -0
- package/dist/streams/index.d.ts +1 -1
- package/dist/streams/index.js +1 -1
- package/dist/{streams-DW-UCOUc.js → streams-CITClVer.js} +16 -3
- package/dist/streams-CITClVer.js.map +1 -0
- package/dist/{streams-Cmkj9QfW.d.ts → streams-fbG61qM8.d.ts} +2 -2
- package/dist/sub-routing.d.ts +1 -1
- package/dist/tasks/index.d.ts +1 -1
- package/dist/tasks/index.js +1 -1
- package/dist/{tasks-68DESxf0.js → tasks-CkTZNaV1.js} +2 -1
- package/dist/tasks-CkTZNaV1.js.map +1 -0
- package/dist/{tasks-9YxYtByh.d.ts → tasks-PtlB4Uyn.d.ts} +2 -2
- package/dist/tool-3PA8xjB_.js +421 -0
- package/dist/tool-3PA8xjB_.js.map +1 -0
- package/dist/tool-BPJEbwaX.d.ts +278 -0
- package/dist/transport-k2mFrtL8.d.ts +200 -0
- package/dist/turns-DCV3ycDl.js +317 -0
- package/dist/turns-DCV3ycDl.js.map +1 -0
- package/dist/voice/client.js +1 -1
- package/dist/voice/index.d.ts +2 -2
- package/dist/voice/index.js +1 -1
- package/dist/websearch/index.d.ts +58 -0
- package/dist/websearch/index.js +2 -0
- package/dist/websearch/tools/ai-sdk.d.ts +77 -0
- package/dist/websearch/tools/ai-sdk.js +46 -0
- package/dist/websearch/tools/ai-sdk.js.map +1 -0
- package/dist/websearch/tools/pi.d.ts +82 -0
- package/dist/websearch/tools/pi.js +89 -0
- package/dist/websearch/tools/pi.js.map +1 -0
- package/dist/websearch/tools/tanstack-ai.d.ts +71 -0
- package/dist/websearch/tools/tanstack-ai.js +46 -0
- package/dist/websearch/tools/tanstack-ai.js.map +1 -0
- package/dist/websockets/index.d.ts +12 -296
- package/dist/websockets/index.js +1 -1
- package/dist/{websockets-Ci-LZFHH.js → websockets-CmENGb-Z.js} +18 -4
- package/dist/websockets-CmENGb-Z.js.map +1 -0
- package/dist/{wire-types-CrjKvDyi.d.ts → wire-types-Cv0iwjk5.d.ts} +3 -51
- package/dist/workflow-types.d.ts +1 -1
- package/dist/workflows.d.ts +1 -1
- package/dist/workflows.js +1 -1
- package/docs/browse-the-web.md +3 -0
- package/docs/harnesses/pi.md +114 -32
- package/docs/harnesses/think.md +215 -0
- package/docs/index.md +4 -3
- package/docs/lifecycle.md +40 -0
- package/docs/models-pi-ai.md +5 -5
- package/docs/search-the-web.md +133 -0
- package/package.json +126 -47
- package/dist/browser-tool-CQ10e6Kj.js.map +0 -1
- package/dist/channel-Bnm4S7T2.d.ts +0 -491
- package/dist/channels/ai-sdk.d.ts +0 -46
- package/dist/channels/ai-sdk.js +0 -120
- package/dist/channels/ai-sdk.js.map +0 -1
- package/dist/channels/email.js.map +0 -1
- package/dist/channels/index.d.ts +0 -233
- package/dist/channels/index.js +0 -608
- package/dist/channels/index.js.map +0 -1
- package/dist/channels/slack.js +0 -614
- package/dist/channels/slack.js.map +0 -1
- package/dist/channels/tanstack-ai.d.ts +0 -39
- package/dist/channels/tanstack-ai.js +0 -17
- package/dist/channels/tanstack-ai.js.map +0 -1
- package/dist/channels/telegram.js +0 -427
- package/dist/channels/telegram.js.map +0 -1
- package/dist/channels/voice.d.ts +0 -45
- package/dist/channels/voice.js +0 -122
- package/dist/channels/voice.js.map +0 -1
- package/dist/harnesses/pi/index.js.map +0 -1
- package/dist/images-iiTDSyRu.js.map +0 -1
- package/dist/index-BB0kqhIz.d.ts +0 -101
- package/dist/ingress-BfetZbMO.js +0 -83
- package/dist/ingress-BfetZbMO.js.map +0 -1
- package/dist/internal-CYlgHl1l.js +0 -59
- package/dist/internal-CYlgHl1l.js.map +0 -1
- package/dist/models/ai-sdk/index.js.map +0 -1
- package/dist/protocol-kHsr-f0X.js.map +0 -1
- package/dist/sessions/index.js.map +0 -1
- package/dist/streams-DW-UCOUc.js.map +0 -1
- package/dist/surface-bZZJqBka.js +0 -17
- package/dist/surface-bZZJqBka.js.map +0 -1
- package/dist/tasks-68DESxf0.js.map +0 -1
- package/dist/tool-schema-CBjGPrsQ.js +0 -31
- package/dist/tool-schema-CBjGPrsQ.js.map +0 -1
- package/dist/websockets-Ci-LZFHH.js.map +0 -1
- package/docs/channels.md +0 -323
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-C45hDliX.js","names":[],"sources":["../src/models/core/settings.ts"],"sourcesContent":["import type { WorkersAIModelId } from \"./catalog\";\n\n/** The gateway id Cloudflare auto-creates on first use. */\nexport const DEFAULT_GATEWAY_ID = \"default\";\n\n/** Key that per-call options live under in a framework's per-call options bag. */\nexport const PROVIDER_OPTIONS_KEY = \"cloudflare\";\n\n/**\n * AI Gateway settings for a request. The gateway is an option, not a separate\n * product: every call goes through one, and `id` defaults to `\"default\"`,\n * which Cloudflare creates on first use.\n *\n * @experimental This surface is experimental and may change.\n */\nexport interface GatewayOptions {\n /** Gateway id. Defaults to `\"default\"` (auto-created on first use). */\n id?: string;\n /** Bypass the cache for this request. */\n skipCache?: boolean;\n /** Cache lifetime in seconds. */\n cacheTtl?: number;\n /** Explicit cache key, instead of the request-derived one. */\n cacheKey?: string;\n /** Whether the gateway stores the request/response in its log. */\n collectLog?: boolean;\n /** Arbitrary key/values attached to the gateway log entry. */\n metadata?: Record<string, string | number | boolean | null>;\n /** Correlates several requests into one gateway event. */\n eventId?: string;\n /** Upstream request timeout in milliseconds. */\n requestTimeoutMs?: number;\n /** Server-side retry policy for the upstream provider call. */\n retries?: {\n maxAttempts?: 1 | 2 | 3 | 4 | 5;\n retryDelayMs?: number;\n backoff?: \"constant\" | \"linear\" | \"exponential\";\n };\n}\n\n/**\n * How `createAI` reaches Cloudflare: the Workers AI binding, and nothing else.\n * Workers AI models go through `env.AI.run`, vendor models through\n * `env.AI.gateway(id).run` — both are the binding, so there is no HTTP\n * transport, no account id and no API token to hold.\n *\n * @experimental This surface is experimental and may change.\n */\nexport type AISettings = {\n /** The `AI` binding from a Worker's env. */\n binding: Ai;\n} & ProviderGatewaySettings;\n\n/**\n * Provider-wide gateway defaults, in either spelling: nested under `gateway`,\n * or flat (`{ id: \"prod\", cacheTtl: 60 }`). Both merge, the flat key winning.\n *\n * @experimental This surface is experimental and may change.\n */\nexport interface ProviderGatewaySettings extends GatewayOptions {\n /** Gateway id or full gateway options. */\n gateway?: string | GatewayOptions;\n}\n\n/**\n * Per-model and per-call options. The flat gateway keys are sugar for\n * `gateway: { ... }`; both forms merge, with the flat key winning.\n *\n * The same shape is accepted per call under\n * `providerOptions.cloudflare`, where it takes precedence over the per-model\n * options, which in turn take precedence over the `createAI` settings.\n *\n * `Leg` is what a framework module accepts as a fallback leg. Workers AI ids\n * are the only kind this module can resolve on its own, so they are the\n * default; a module whose legs may also be model objects says so\n * (`ModelOptions<WorkersAIModelId | LanguageModelV4>`) rather than rebuilding\n * the type.\n *\n * @experimental This surface is experimental and may change.\n */\nexport interface ModelOptions<\n Leg = WorkersAIModelId\n> extends ProviderGatewaySettings {\n /**\n * Models to try, in order, if the primary fails before any output is\n * produced. A leg travels with the chain's gateway options — those win over\n * a leg's own, and `metadata` merges — while everything a leg was built with\n * itself stays its own. Client-side today; becomes server-side when the\n * platform ships model-first routing.\n */\n fallback?: Leg[];\n /** Extra request headers, merged last. */\n headers?: Record<string, string>;\n /**\n * Workers AI only: route same-key requests to the same replica for\n * prefix-cache hits. Sent as the `x-session-affinity` header.\n */\n sessionAffinity?: string;\n /**\n * Explicit reasoning effort. `null` disables reasoning on models that\n * support toggling it. The unified AI SDK `reasoning` call option maps onto\n * this when this is not set.\n */\n reasoningEffort?: \"low\" | \"medium\" | \"high\" | null;\n /**\n * Workers AI only: forwarded verbatim as `chat_template_kwargs`, e.g.\n * `{ enable_thinking: false }`.\n */\n chatTemplateKwargs?: Record<string, unknown>;\n}\n\n/** A gateway config with the id filled in. */\nexport interface ResolvedGateway extends GatewayOptions {\n id: string;\n}\n\n/** Everything one request needs, after merging all three option layers. */\nexport interface ResolvedOptions {\n gateway: ResolvedGateway;\n headers: Record<string, string>;\n sessionAffinity: string | undefined;\n reasoningEffort: \"low\" | \"medium\" | \"high\" | null | undefined;\n chatTemplateKwargs: Record<string, unknown> | undefined;\n /**\n * The fallback legs given as ids. A module whose legs may also be model\n * objects keeps its own ordered list; this one is what the id-only callers\n * (embeddings, the other modalities) need.\n */\n fallback: string[];\n}\n\n/** The id legs of a fallback list; model objects are their module's business. */\nfunction idLegs(fallback: unknown[] | undefined): string[] {\n return (fallback ?? []).filter(\n (leg): leg is string => typeof leg === \"string\"\n );\n}\n\n/** Strips `undefined` values so a later layer never blanks an earlier one. */\nfunction defined<T extends object>(value: T): T {\n const result: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n if (entry !== undefined) result[key] = entry;\n }\n return result as T;\n}\n\nfunction normalizeGateway(\n gateway: string | GatewayOptions | undefined\n): GatewayOptions {\n if (gateway === undefined) return {};\n // An explicit `undefined` inside a gateway object means \"not set\", exactly\n // as the flat sugar does; it must not blank out a lower layer's value.\n return typeof gateway === \"string\" ? { id: gateway } : defined(gateway);\n}\n\n/**\n * Folds one layer's flat gateway sugar into its `gateway` object. The flat key\n * wins over the nested one, and an explicit `undefined` on either never blanks\n * a lower layer.\n */\nfunction layerGateway(\n options: ProviderGatewaySettings | undefined\n): GatewayOptions {\n if (options === undefined) return {};\n return {\n ...normalizeGateway(options.gateway),\n ...defined({\n cacheKey: options.cacheKey,\n cacheTtl: options.cacheTtl,\n collectLog: options.collectLog,\n eventId: options.eventId,\n id: options.id,\n metadata: options.metadata,\n requestTimeoutMs: options.requestTimeoutMs,\n retries: options.retries,\n skipCache: options.skipCache\n })\n };\n}\n\n/** The flat gateway sugar {@link layerGateway} folds into `gateway`. */\nconst FLAT_GATEWAY_KEYS = [\n \"cacheKey\",\n \"cacheTtl\",\n \"collectLog\",\n \"eventId\",\n \"gateway\",\n \"id\",\n \"metadata\",\n \"requestTimeoutMs\",\n \"retries\",\n \"skipCache\"\n] as const;\n\n/**\n * One layer's gateway options as a single object, both spellings folded in.\n * Exported so a module that collapses two option layers into one bag (a\n * fallback leg inheriting a chain's gateway) can merge them field by field\n * rather than replacing one object with the other.\n *\n * @experimental This surface is experimental and may change.\n */\nexport function gatewayLayerOf(\n options: ProviderGatewaySettings | undefined\n): GatewayOptions {\n return layerGateway(options);\n}\n\n/** An option bag without the gateway keys, whichever spelling they used. */\nfunction withoutGatewayKeys<Leg>(\n options: ModelOptions<Leg>\n): ModelOptions<Leg> {\n const rest: Record<string, unknown> = { ...options };\n for (const key of FLAT_GATEWAY_KEYS) delete rest[key];\n return defined(rest as ModelOptions<Leg>);\n}\n\n/**\n * Collapses two option layers into one bag, `override` winning field by field.\n *\n * The gateway keys of both are folded into a single `gateway` object, so\n * neither layer's flat sugar can out-rank the other's nested spelling when the\n * bag is resolved later, and `metadata` merges rather than replaces — the same\n * rules {@link resolveOptions} applies across its three layers.\n *\n * @experimental This surface is experimental and may change.\n */\nexport function mergeModelOptions<Leg>(\n base: ModelOptions<Leg> | undefined,\n override: ModelOptions<Leg> | undefined\n): ModelOptions<Leg> | undefined {\n if (base === undefined) return override;\n if (override === undefined) return base;\n const layers = [layerGateway(base), layerGateway(override)];\n const gateway: GatewayOptions = Object.assign({}, ...layers);\n const metadata = Object.assign({}, ...layers.map((layer) => layer.metadata));\n const retries = mergeRetries(layers);\n // Headers merge field by field, as they do across `resolveOptions`' three\n // layers: replacing the object wholesale would drop a header the lower layer\n // was configured with. The spread comes after the override's own keys so it\n // wins over the `headers` that spread carried.\n const headers = { ...base.headers, ...override.headers };\n return {\n ...withoutGatewayKeys(base),\n ...withoutGatewayKeys(override),\n ...(Object.keys(headers).length > 0 ? { headers } : {}),\n gateway: {\n ...gateway,\n ...(Object.keys(metadata).length > 0 ? { metadata } : {}),\n ...(retries === undefined ? {} : { retries })\n }\n };\n}\n\n/**\n * Merges the retry policies field by field, so a provider-wide `backoff` still\n * applies when a call only sets `maxAttempts`. `undefined` on any layer means\n * \"not set\" and never blanks a lower one.\n */\nfunction mergeRetries(\n layers: GatewayOptions[]\n): GatewayOptions[\"retries\"] | undefined {\n const merged = layers.reduce<NonNullable<GatewayOptions[\"retries\"]>>(\n (result, layer) => ({\n ...result,\n ...(layer.retries === undefined ? {} : defined(layer.retries))\n }),\n {}\n );\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\n/**\n * Merges the option layers. Precedence is per-call\n * (`providerOptions.cloudflare`) > per-model (`ai(id, options)`) >\n * provider (`createAI({ ... })`).\n *\n * The provider layer takes the whole settings object as well as a bare\n * `gateway` value, so `createAI({ binding, id: \"prod\", cacheTtl: 60 })` reads\n * the same as `createAI({ binding, gateway: { id: \"prod\", cacheTtl: 60 } })`.\n *\n * @experimental This surface is experimental and may change.\n */\nexport function resolveOptions(\n provider: string | ProviderGatewaySettings | undefined,\n model: ModelOptions<unknown> | undefined,\n call: ModelOptions<unknown> | undefined\n): ResolvedOptions {\n const layers =\n typeof provider === \"string\"\n ? [normalizeGateway(provider), layerGateway(model), layerGateway(call)]\n : [layerGateway(provider), layerGateway(model), layerGateway(call)];\n const gateway: GatewayOptions = Object.assign({}, ...layers);\n const metadata = Object.assign({}, ...layers.map((layer) => layer.metadata));\n const retries = mergeRetries(layers);\n return {\n chatTemplateKwargs: call?.chatTemplateKwargs ?? model?.chatTemplateKwargs,\n fallback: idLegs(call?.fallback ?? model?.fallback),\n gateway: {\n ...gateway,\n id: gateway.id ?? DEFAULT_GATEWAY_ID,\n ...(Object.keys(metadata).length > 0 ? { metadata } : {}),\n ...(retries === undefined ? {} : { retries })\n },\n headers: { ...model?.headers, ...call?.headers },\n // `null` is a meaningful value here (it disables reasoning), so the call\n // layer wins on any value it actually set, not just on a truthy one.\n reasoningEffort:\n call?.reasoningEffort !== undefined\n ? call.reasoningEffort\n : model?.reasoningEffort,\n sessionAffinity: call?.sessionAffinity ?? model?.sessionAffinity\n };\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n return value !== null && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\nfunction asStringRecord(value: unknown): Record<string, string> | undefined {\n const record = asRecord(value);\n if (record === undefined) return undefined;\n const result: Record<string, string> = {};\n for (const [key, entry] of Object.entries(record)) {\n if (typeof entry === \"string\") result[key] = entry;\n }\n return result;\n}\n\nfunction asString(value: unknown): string | undefined {\n return typeof value === \"string\" ? value : undefined;\n}\n\nfunction asNumber(value: unknown): number | undefined {\n return typeof value === \"number\" ? value : undefined;\n}\n\nfunction asBoolean(value: unknown): boolean | undefined {\n return typeof value === \"boolean\" ? value : undefined;\n}\n\nfunction asReasoningEffort(\n value: unknown\n): \"low\" | \"medium\" | \"high\" | null | undefined {\n if (value === null) return null;\n if (value === \"low\" || value === \"medium\" || value === \"high\") return value;\n return undefined;\n}\n\n/**\n * Metadata values the gateway accepts are scalars only; a nested object or\n * array would be rejected by the binding, so drop those rather than forward\n * them.\n */\nfunction asMetadata(value: unknown): GatewayOptions[\"metadata\"] {\n const record = asRecord(value);\n if (record === undefined) return undefined;\n const result: NonNullable<GatewayOptions[\"metadata\"]> = {};\n for (const [key, entry] of Object.entries(record)) {\n if (\n entry === null ||\n typeof entry === \"string\" ||\n typeof entry === \"number\" ||\n typeof entry === \"boolean\"\n ) {\n result[key] = entry;\n }\n }\n return result;\n}\n\nconst BACKOFFS = [\"constant\", \"linear\", \"exponential\"] as const;\n\n/** Reads the retry policy field by field; the binding validates it strictly. */\nfunction asRetries(value: unknown): GatewayOptions[\"retries\"] {\n const record = asRecord(value);\n if (record === undefined) return undefined;\n const maxAttempts = asNumber(record.maxAttempts);\n const backoff = asString(record.backoff);\n const retries = defined({\n backoff: BACKOFFS.find((entry) => entry === backoff),\n maxAttempts:\n maxAttempts !== undefined &&\n Number.isInteger(maxAttempts) &&\n maxAttempts >= 1 &&\n maxAttempts <= 5\n ? (maxAttempts as 1 | 2 | 3 | 4 | 5)\n : undefined,\n retryDelayMs: asNumber(record.retryDelayMs)\n });\n // An empty policy is not a policy: returning `{}` would out-rank a lower\n // layer's real one when the layers merge.\n return Object.keys(retries).length > 0 ? retries : undefined;\n}\n\n/** Reads the shared gateway keys out of a loosely-typed record. */\nfunction parseGatewayFields(raw: Record<string, unknown>): GatewayOptions {\n return defined({\n cacheKey: asString(raw.cacheKey),\n cacheTtl: asNumber(raw.cacheTtl),\n collectLog: asBoolean(raw.collectLog),\n eventId: asString(raw.eventId),\n id: asString(raw.id),\n metadata: asMetadata(raw.metadata),\n requestTimeoutMs: asNumber(raw.requestTimeoutMs),\n retries: asRetries(raw.retries),\n skipCache: asBoolean(raw.skipCache)\n });\n}\n\n/**\n * Reads per-call options out of a loosely-typed options bag (the value a\n * framework keeps under {@link PROVIDER_OPTIONS_KEY}).\n *\n * The bag is plain JSON, so every field is read defensively: anything of an\n * unexpected type is dropped rather than thrown, because a malformed\n * observability hint should never fail a generation.\n *\n * @experimental This surface is experimental and may change.\n */\nexport function parseModelOptions(value: unknown): ModelOptions | undefined {\n const raw = asRecord(value);\n if (raw === undefined) return undefined;\n\n const nested = asRecord(raw.gateway);\n const gateway: string | GatewayOptions | undefined =\n typeof raw.gateway === \"string\"\n ? raw.gateway\n : nested !== undefined\n ? parseGatewayFields(nested)\n : undefined;\n\n const fallback = Array.isArray(raw.fallback)\n ? raw.fallback.filter(\n (entry): entry is WorkersAIModelId => typeof entry === \"string\"\n )\n : undefined;\n\n return defined({\n ...parseGatewayFields(raw),\n chatTemplateKwargs: asRecord(raw.chatTemplateKwargs),\n fallback,\n gateway,\n headers: asStringRecord(raw.headers),\n reasoningEffort: asReasoningEffort(raw.reasoningEffort),\n sessionAffinity: asString(raw.sessionAffinity)\n });\n}\n"],"mappings":";;AAGA,MAAa,qBAAqB;;AAGlC,MAAa,uBAAuB;;AA8HpC,SAAS,OAAO,UAA2C;CACzD,QAAQ,YAAY,CAAC,EAAA,CAAG,QACrB,QAAuB,OAAO,QAAQ,QACzC;AACF;;AAGA,SAAS,QAA0B,OAAa;CAC9C,MAAM,SAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,GAC7C,IAAI,UAAU,KAAA,GAAW,OAAO,OAAO;CAEzC,OAAO;AACT;AAEA,SAAS,iBACP,SACgB;CAChB,IAAI,YAAY,KAAA,GAAW,OAAO,CAAC;CAGnC,OAAO,OAAO,YAAY,WAAW,EAAE,IAAI,QAAQ,IAAI,QAAQ,OAAO;AACxE;;;;;;AAOA,SAAS,aACP,SACgB;CAChB,IAAI,YAAY,KAAA,GAAW,OAAO,CAAC;CACnC,OAAO;EACL,GAAG,iBAAiB,QAAQ,OAAO;EACnC,GAAG,QAAQ;GACT,UAAU,QAAQ;GAClB,UAAU,QAAQ;GAClB,YAAY,QAAQ;GACpB,SAAS,QAAQ;GACjB,IAAI,QAAQ;GACZ,UAAU,QAAQ;GAClB,kBAAkB,QAAQ;GAC1B,SAAS,QAAQ;GACjB,WAAW,QAAQ;EACrB,CAAC;CACH;AACF;;AAGA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;AAUA,SAAgB,eACd,SACgB;CAChB,OAAO,aAAa,OAAO;AAC7B;;AAGA,SAAS,mBACP,SACmB;CACnB,MAAM,OAAgC,EAAE,GAAG,QAAQ;CACnD,KAAK,MAAM,OAAO,mBAAmB,OAAO,KAAK;CACjD,OAAO,QAAQ,IAAyB;AAC1C;;;;;;;;;;;AAYA,SAAgB,kBACd,MACA,UAC+B;CAC/B,I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,KAAA;CAE9B,MAAM,SAAS,SAAS,IAAI,OAAO;CACnC,MAAM,UACJ,OAAO,IAAI,YAAY,WACnB,IAAI,UACJ,WAAW,KAAA,IACT,mBAAmB,MAAM,IACzB,KAAA;CAER,MAAM,WAAW,MAAM,QAAQ,IAAI,QAAQ,IACvC,IAAI,SAAS,QACV,UAAqC,OAAO,UAAU,QACzD,IACA,KAAA;CAEJ,OAAO,QAAQ;EACb,GAAG,mBAAmB,GAAG;EACzB,oBAAoB,SAAS,IAAI,kBAAkB;EACnD;EACA;EACA,SAAS,eAAe,IAAI,OAAO;EACnC,iBAAiB,kBAAkB,IAAI,eAAe;EACtD,iBAAiB,SAAS,IAAI,eAAe;CAC/C,CAAC;AACH"}
|
|
@@ -313,213 +313,19 @@ interface ResolvedGateway extends GatewayOptions {
|
|
|
313
313
|
id: string;
|
|
314
314
|
}
|
|
315
315
|
//#endregion
|
|
316
|
-
//#region src/models/core/errors.d.ts
|
|
317
|
-
/**
|
|
318
|
-
* Coarse classification of a failed Cloudflare AI call.
|
|
319
|
-
*
|
|
320
|
-
* @experimental This surface is experimental and may change.
|
|
321
|
-
*/
|
|
322
|
-
type CloudflareAIErrorCode =
|
|
323
|
-
| "auth"
|
|
324
|
-
| "rate-limit"
|
|
325
|
-
| "not-found"
|
|
326
|
-
| "bad-request"
|
|
327
|
-
| "provider-error"
|
|
328
|
-
| "gateway-error"
|
|
329
|
-
| "unknown";
|
|
330
|
-
/**
|
|
331
|
-
* One leg of a {@link CloudflareAIError} fallback chain.
|
|
332
|
-
*
|
|
333
|
-
* @experimental This surface is experimental and may change.
|
|
334
|
-
*/
|
|
335
|
-
interface CloudflareAIAttempt {
|
|
336
|
-
/** The model id that was tried. */
|
|
337
|
-
model: string;
|
|
338
|
-
/** The error that leg failed with. */
|
|
339
|
-
error: unknown;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Error thrown for every failed Cloudflare AI call, whether it came back as a
|
|
343
|
-
* non-2xx `Response` or as a thrown Workers AI binding error. Framework
|
|
344
|
-
* modules wrap it into their own error type at their boundary (the AI SDK
|
|
345
|
-
* module into an `APICallError`, so `ai`'s retry loop honours
|
|
346
|
-
* {@link CloudflareAIError.isRetryable}).
|
|
347
|
-
*
|
|
348
|
-
* @experimental This surface is experimental and may change.
|
|
349
|
-
*/
|
|
350
|
-
declare class CloudflareAIError extends Error {
|
|
351
|
-
/** HTTP status, when the failure carried one. */
|
|
352
|
-
readonly status: number | undefined;
|
|
353
|
-
/** Coarse classification used for routing and fallback decisions. */
|
|
354
|
-
readonly code: CloudflareAIErrorCode;
|
|
355
|
-
/** `cf-aig-log-id` of the failed request, when the response carried one. */
|
|
356
|
-
readonly logId: string | undefined;
|
|
357
|
-
/** The model id that produced this error. */
|
|
358
|
-
readonly model: string;
|
|
359
|
-
/** Which binding path the request went down, for error reporting. */
|
|
360
|
-
readonly url: string;
|
|
361
|
-
/** The request body that failed. */
|
|
362
|
-
readonly requestBodyValues: unknown;
|
|
363
|
-
/** Response headers, when there was a response. */
|
|
364
|
-
readonly responseHeaders: Record<string, string> | undefined;
|
|
365
|
-
/** Raw response body text, when there was a response. */
|
|
366
|
-
readonly responseBody: string | undefined;
|
|
367
|
-
/** Whether a retry is worth attempting. */
|
|
368
|
-
readonly isRetryable: boolean;
|
|
369
|
-
/** Parsed error envelope, or other structured detail. */
|
|
370
|
-
readonly data: unknown;
|
|
371
|
-
/** Every leg tried, when this error ends a fallback chain. */
|
|
372
|
-
readonly attempts: CloudflareAIAttempt[] | undefined;
|
|
373
|
-
readonly cause: unknown;
|
|
374
|
-
constructor(options: {
|
|
375
|
-
message: string;
|
|
376
|
-
model: string;
|
|
377
|
-
url: string;
|
|
378
|
-
requestBodyValues: unknown;
|
|
379
|
-
status?: number;
|
|
380
|
-
code: CloudflareAIErrorCode;
|
|
381
|
-
logId?: string;
|
|
382
|
-
responseHeaders?: Record<string, string>;
|
|
383
|
-
responseBody?: string;
|
|
384
|
-
isRetryable?: boolean;
|
|
385
|
-
data?: unknown;
|
|
386
|
-
cause?: unknown;
|
|
387
|
-
attempts?: CloudflareAIAttempt[];
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
//#endregion
|
|
391
|
-
//#region src/models/core/gateway-providers.d.ts
|
|
392
|
-
/**
|
|
393
|
-
* The AI Gateway provider table: which gateway provider slug a vendor's own
|
|
394
|
-
* base URL belongs to, and what the universal request's `endpoint` is for a
|
|
395
|
-
* given upstream URL.
|
|
396
|
-
*
|
|
397
|
-
* This is platform knowledge, not vendor knowledge — the gateway publishes the
|
|
398
|
-
* list, and every entry here appears in `AIGatewayProviders` from
|
|
399
|
-
* `@cloudflare/workers-types`. Nothing about a vendor's wire format, model ids
|
|
400
|
-
* or capabilities lives here: the vendor's own provider package builds the
|
|
401
|
-
* request, and this table only says where it goes.
|
|
402
|
-
*
|
|
403
|
-
* Adapted from `@cloudflare/ai-gateway-provider`'s `providers.ts`.
|
|
404
|
-
*
|
|
405
|
-
* @experimental This surface is experimental and may change.
|
|
406
|
-
*/
|
|
407
|
-
/**
|
|
408
|
-
* The gateway provider slugs this table maps onto. A subset of the ambient
|
|
409
|
-
* `AIGatewayProviders` union; {@link GatewayProviderNameCheck} keeps it one.
|
|
410
|
-
*
|
|
411
|
-
* @experimental This surface is experimental and may change.
|
|
412
|
-
*/
|
|
413
|
-
declare const GATEWAY_PROVIDER_NAMES: readonly [
|
|
414
|
-
"workers-ai",
|
|
415
|
-
"anthropic",
|
|
416
|
-
"openai",
|
|
417
|
-
"azure-openai",
|
|
418
|
-
"google-ai-studio",
|
|
419
|
-
"google-vertex-ai",
|
|
420
|
-
"grok",
|
|
421
|
-
"mistral",
|
|
422
|
-
"perplexity-ai",
|
|
423
|
-
"replicate",
|
|
424
|
-
"groq",
|
|
425
|
-
"deepseek",
|
|
426
|
-
"openrouter",
|
|
427
|
-
"cerebras",
|
|
428
|
-
"cohere",
|
|
429
|
-
"huggingface",
|
|
430
|
-
"aws-bedrock",
|
|
431
|
-
"elevenlabs",
|
|
432
|
-
"cartesia"
|
|
433
|
-
];
|
|
434
|
-
/**
|
|
435
|
-
* A gateway provider slug.
|
|
436
|
-
*
|
|
437
|
-
* @experimental This surface is experimental and may change.
|
|
438
|
-
*/
|
|
439
|
-
type GatewayProviderName = (typeof GATEWAY_PROVIDER_NAMES)[number];
|
|
440
|
-
//#endregion
|
|
441
|
-
//#region src/models/core/transport.d.ts
|
|
442
|
-
/** One request on the Cloudflare run path. */
|
|
443
|
-
interface TransportRequest {
|
|
444
|
-
/** Model id — Workers AI slug or catalog `<author>/<model>`. */
|
|
445
|
-
model: string;
|
|
446
|
-
/** The provider-shaped request body (`input` on the run path). */
|
|
447
|
-
input: Record<string, unknown>;
|
|
448
|
-
/** Gateway options for this request. */
|
|
449
|
-
gateway: ResolvedGateway;
|
|
450
|
-
/** Extra request headers, merged last. */
|
|
451
|
-
headers: Record<string, string>;
|
|
452
|
-
/** Abort signal, forwarded to the binding or to `fetch`. */
|
|
453
|
-
signal?: AbortSignal;
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* One request on the universal AI Gateway path: a vendor's own request, routed
|
|
457
|
-
* by the gateway to that vendor. The body is the vendor's, untouched — nothing
|
|
458
|
-
* here knows the vendor's wire format.
|
|
459
|
-
*
|
|
460
|
-
* @experimental This surface is experimental and may change.
|
|
461
|
-
*/
|
|
462
|
-
interface UniversalRequest {
|
|
463
|
-
/** The gateway provider slug the request is routed to. */
|
|
464
|
-
provider: GatewayProviderName | string;
|
|
465
|
-
/** The vendor path the gateway appends to that provider's base URL. */
|
|
466
|
-
endpoint: string;
|
|
467
|
-
/** The vendor's own request headers, minus its credential header. */
|
|
468
|
-
headers: Record<string, string>;
|
|
469
|
-
/** The vendor's request body, verbatim. */
|
|
470
|
-
query: unknown;
|
|
471
|
-
/** Gateway options for this request. */
|
|
472
|
-
gateway: ResolvedGateway;
|
|
473
|
-
/** Extra headers merged last, outside the vendor's own set. */
|
|
474
|
-
extraHeaders?: Record<string, string>;
|
|
475
|
-
/** Abort signal, forwarded to the binding or to `fetch`. */
|
|
476
|
-
signal?: AbortSignal;
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* The single code path both backends implement. Always resolves to a raw
|
|
480
|
-
* `Response`, so streaming and non-streaming calls share one path and nothing
|
|
481
|
-
* is buffered on the caller's behalf.
|
|
482
|
-
*
|
|
483
|
-
* @experimental This surface is experimental and may change.
|
|
484
|
-
*/
|
|
485
|
-
interface Transport {
|
|
486
|
-
/** A stable identifier for the endpoint, used in error reporting. */
|
|
487
|
-
readonly url: string;
|
|
488
|
-
run(request: TransportRequest): Promise<Response>;
|
|
489
|
-
/**
|
|
490
|
-
* Sends a vendor's own request through the gateway's universal endpoint.
|
|
491
|
-
* Always resolves to the vendor's raw `Response`, error responses included:
|
|
492
|
-
* only the gateway's own failures (a missing gateway, an unpaid account) are
|
|
493
|
-
* lifted into a {@link CloudflareAIError}, because the vendor's provider
|
|
494
|
-
* knows how to read its own errors and we do not.
|
|
495
|
-
*/
|
|
496
|
-
universal(request: UniversalRequest): Promise<Response>;
|
|
497
|
-
/**
|
|
498
|
-
* A log id read off the backend itself when the response carried none. The
|
|
499
|
-
* Workers AI binding exposes the last gateway log id as a mutable property,
|
|
500
|
-
* so it is captured per response rather than read late.
|
|
501
|
-
*/
|
|
502
|
-
logIdFallback(response: Response): string | undefined;
|
|
503
|
-
}
|
|
504
|
-
//#endregion
|
|
505
316
|
export {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
GatewayProviderName as r,
|
|
520
|
-
AISettings as s,
|
|
521
|
-
Transport as t,
|
|
522
|
-
ProviderGatewaySettings as u,
|
|
523
|
-
WorkersAIModelId as v
|
|
317
|
+
ResolvedGateway as a,
|
|
318
|
+
CloudflareRerankingModelId as c,
|
|
319
|
+
KnownImageModelId as d,
|
|
320
|
+
KnownSpeechModelId as f,
|
|
321
|
+
ProviderGatewaySettings as i,
|
|
322
|
+
CloudflareSpeechModelId as l,
|
|
323
|
+
GatewayOptions as n,
|
|
324
|
+
CloudflareEmbeddingModelId as o,
|
|
325
|
+
WorkersAIModelId as p,
|
|
326
|
+
ModelOptions as r,
|
|
327
|
+
CloudflareImageModelId as s,
|
|
328
|
+
AISettings as t,
|
|
329
|
+
CloudflareTranscriptionModelId as u
|
|
524
330
|
};
|
|
525
|
-
//# sourceMappingURL=
|
|
331
|
+
//# sourceMappingURL=settings-NgGwF7Qt.d.ts.map
|
|
@@ -11,17 +11,17 @@ import { signAgentHeaders } from "./email.js";
|
|
|
11
11
|
import { sendAgentEmail } from "./email-send.js";
|
|
12
12
|
import { n as withInvocationScope, r as writeSpanAttributes, t as tracer } from "./cloudflare-Dzvc7V2N.js";
|
|
13
13
|
import { parseSubAgentPath } from "./sub-routing.js";
|
|
14
|
-
import { a as getConnectionFlag, c as isConnectionReadonly, d as setConnectionProtocolEnabled, f as setConnectionReadonly, i as ensureConnectionWrapped, l as registerInternalConnectionKeys, o as getConnectionRawState, s as isConnectionProtocolEnabled, t as WebSockets, u as setConnectionFlag } from "./websockets-
|
|
14
|
+
import { a as getConnectionFlag, c as isConnectionReadonly, d as setConnectionProtocolEnabled, f as setConnectionReadonly, i as ensureConnectionWrapped, l as registerInternalConnectionKeys, o as getConnectionRawState, s as isConnectionProtocolEnabled, t as WebSockets, u as setConnectionFlag } from "./websockets-CmENGb-Z.js";
|
|
15
15
|
import { t as LifecycleCapability } from "./capability-B4WbF81e.js";
|
|
16
16
|
import { a as abortWithoutAlarmRetry, i as setLifecycleRouteTransport, n as setLifecycleEventSink, r as setLifecycleHostInvoker, t as Lifecycle } from "./lifecycle-CFu6OV03.js";
|
|
17
17
|
import { isErrorRetryable, tryN, validateRetryOptions } from "./retries.js";
|
|
18
18
|
import { SqlError } from "./sql-error.js";
|
|
19
|
-
import { a as ensureMcpServerTable, d as DisposableStore, i as normalizeServerId, l as RPC_DO_PREFIX, o as MCPConnectionState, t as MCPClientManager } from "./client-
|
|
19
|
+
import { a as ensureMcpServerTable, d as DisposableStore, i as normalizeServerId, l as RPC_DO_PREFIX, o as MCPConnectionState, t as MCPClientManager } from "./client-1tEQ1Oqz.js";
|
|
20
20
|
import { DurableObjectOAuthClientProvider } from "./mcp/client/do-oauth-client-provider.js";
|
|
21
21
|
import { genericObservability } from "./observability/index.js";
|
|
22
22
|
import { n as setSchedulerCallbackResolver, t as Scheduler } from "./scheduler-DZ3xQfeK.js";
|
|
23
23
|
import { n as setQueueCallbackResolver, t as Queue } from "./queue-BB-zfIYF.js";
|
|
24
|
-
import { n as setTaskDefinitionResolver, r as setTaskRoutedMemoryLimitHandler, t as Tasks } from "./tasks-
|
|
24
|
+
import { n as setTaskDefinitionResolver, r as setTaskRoutedMemoryLimitHandler, t as Tasks } from "./tasks-CkTZNaV1.js";
|
|
25
25
|
import { State } from "./state/index.js";
|
|
26
26
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
27
27
|
import { DurableObject, RpcTarget, exports } from "cloudflare:workers";
|
|
@@ -7001,4 +7001,4 @@ var StreamingResponse = class {
|
|
|
7001
7001
|
//#endregion
|
|
7002
7002
|
export { routeAgentEmail as a, getCurrentAgent as i, DEFAULT_AGENT_STATIC_OPTIONS as n, StreamingResponse as r, Agent as t };
|
|
7003
7003
|
|
|
7004
|
-
//# sourceMappingURL=src-
|
|
7004
|
+
//# sourceMappingURL=src-DgCbZtIR.js.map
|