agents 0.22.0 → 0.24.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 (215) hide show
  1. package/README.md +20 -1
  2. package/dist/{agent-routing-CnkaHb-v.d.ts → agent-routing-B2XLNMxq.d.ts} +1094 -443
  3. package/dist/agent-routing.d.ts +1 -1
  4. package/dist/agent-tool-types.d.ts +26 -26
  5. package/dist/{agent-tools-C0XJqWzB.d.ts → agent-tools-Dj5Mzlw7.d.ts} +7 -7
  6. package/dist/agent-tools.d.ts +21 -21
  7. package/dist/browser/ai.js +4 -1
  8. package/dist/browser/ai.js.map +1 -1
  9. package/dist/browser/tanstack-ai.js.map +1 -1
  10. package/dist/callable-decorator-DP__HhBA.d.ts +72 -0
  11. package/dist/callable-decorator.d.ts +18 -0
  12. package/dist/callable-decorator.js +71 -0
  13. package/dist/callable-decorator.js.map +1 -0
  14. package/dist/{capability-BjSKYpzg.js → capability-B4WbF81e.js} +2 -1
  15. package/dist/capability-B4WbF81e.js.map +1 -0
  16. package/dist/capability-runner-BUBa6Ake.d.ts +484 -0
  17. package/dist/channel-Bnm4S7T2.d.ts +491 -0
  18. package/dist/channels/ai-sdk.d.ts +46 -0
  19. package/dist/channels/ai-sdk.js +120 -0
  20. package/dist/channels/ai-sdk.js.map +1 -0
  21. package/dist/channels/email.d.ts +95 -0
  22. package/dist/channels/email.js +323 -0
  23. package/dist/channels/email.js.map +1 -0
  24. package/dist/channels/index.d.ts +233 -0
  25. package/dist/channels/index.js +608 -0
  26. package/dist/channels/index.js.map +1 -0
  27. package/dist/channels/slack.d.ts +140 -0
  28. package/dist/channels/slack.js +614 -0
  29. package/dist/channels/slack.js.map +1 -0
  30. package/dist/channels/tanstack-ai.d.ts +39 -0
  31. package/dist/channels/tanstack-ai.js +17 -0
  32. package/dist/channels/tanstack-ai.js.map +1 -0
  33. package/dist/channels/telegram.d.ts +106 -0
  34. package/dist/channels/telegram.js +427 -0
  35. package/dist/channels/telegram.js.map +1 -0
  36. package/dist/channels/voice.d.ts +45 -0
  37. package/dist/channels/voice.js +122 -0
  38. package/dist/channels/voice.js.map +1 -0
  39. package/dist/chat/index.d.ts +2319 -2010
  40. package/dist/chat/index.js +892 -518
  41. package/dist/chat/index.js.map +1 -1
  42. package/dist/chat-sdk/index.d.ts +7 -7
  43. package/dist/chat-sdk/index.js +1 -1
  44. package/dist/client-BxdkCuVy.d.ts +411 -0
  45. package/dist/client-C9DAjZIY.js +518 -0
  46. package/dist/client-C9DAjZIY.js.map +1 -0
  47. package/dist/{client-jagG8a9_.js → client-fyQrLGkD.js} +2 -2
  48. package/dist/{client-jagG8a9_.js.map → client-fyQrLGkD.js.map} +1 -1
  49. package/dist/client.d.ts +27 -283
  50. package/dist/client.js +2 -274
  51. package/dist/context/index.d.ts +216 -0
  52. package/dist/context/index.js +454 -0
  53. package/dist/context/index.js.map +1 -0
  54. package/dist/current-agent-C4w86kcN.d.ts +93 -0
  55. package/dist/current-agent-DhoDkSnH.js.map +1 -1
  56. package/dist/{diagnostics-CaBjfz4J.js → diagnostics-BzvaX2UT.js} +5 -1
  57. package/dist/diagnostics-BzvaX2UT.js.map +1 -0
  58. package/dist/diagnostics-C4jcz3VK.js +360 -0
  59. package/dist/diagnostics-C4jcz3VK.js.map +1 -0
  60. package/dist/durable-object-lifecycle-ei7M7lqB.d.ts +157 -0
  61. package/dist/index-BB0kqhIz.d.ts +101 -0
  62. package/dist/index-BVVgDSdq.d.ts +1 -0
  63. package/dist/index-Dlgtd3Mj.d.ts +78 -0
  64. package/dist/index-XDkuQ7zm.d.ts +89 -0
  65. package/dist/{index-DcSAZKsB.d.ts → index-YSKgfgg9.d.ts} +3 -1
  66. package/dist/index.d.ts +92 -83
  67. package/dist/index.js +4 -3
  68. package/dist/ingress-BfetZbMO.js +83 -0
  69. package/dist/ingress-BfetZbMO.js.map +1 -0
  70. package/dist/internal-CYlgHl1l.js +59 -0
  71. package/dist/internal-CYlgHl1l.js.map +1 -0
  72. package/dist/internal_context.d.ts +1 -1
  73. package/dist/lifecycle/index.d.ts +39 -19
  74. package/dist/lifecycle/index.js +2 -2
  75. package/dist/lifecycle-Mm_jQh7r.js +1314 -0
  76. package/dist/lifecycle-Mm_jQh7r.js.map +1 -0
  77. package/dist/mcp/client/index.d.ts +20 -20
  78. package/dist/mcp/client/index.js +1 -1
  79. package/dist/mcp/index.d.ts +35 -35
  80. package/dist/mcp/index.js +2 -2
  81. package/dist/observability/index.d.ts +1 -1
  82. package/dist/observability/index.js +1 -1
  83. package/dist/queue/index.d.ts +123 -0
  84. package/dist/queue/index.js +2 -0
  85. package/dist/queue-BC9F5cUo.js +406 -0
  86. package/dist/queue-BC9F5cUo.js.map +1 -0
  87. package/dist/react.d.ts +34 -16
  88. package/dist/react.js +31 -8
  89. package/dist/react.js.map +1 -1
  90. package/dist/{retries-CAvxtG9d.d.ts → retries-D9B2UCq3.d.ts} +23 -6
  91. package/dist/retries.d.ts +10 -6
  92. package/dist/retries.js +21 -1
  93. package/dist/retries.js.map +1 -1
  94. package/dist/routing/index.d.ts +137 -0
  95. package/dist/routing/index.js +244 -0
  96. package/dist/routing/index.js.map +1 -0
  97. package/dist/sanitize-D9TujEK8.js +79 -0
  98. package/dist/sanitize-D9TujEK8.js.map +1 -0
  99. package/dist/{scheduler-DQoTGoAW.d.ts → scheduler-BGq6M5Kd.d.ts} +20 -21
  100. package/dist/scheduler-D_KHqxBa.js +658 -0
  101. package/dist/scheduler-D_KHqxBa.js.map +1 -0
  102. package/dist/schedules/index.d.ts +1 -1
  103. package/dist/schedules/index.js +1 -1
  104. package/dist/sentence-chunker-BAidJ4DA.d.ts +68 -0
  105. package/dist/serializable.d.ts +1 -1
  106. package/dist/sessions/index.d.ts +441 -0
  107. package/dist/sessions/index.js +2063 -0
  108. package/dist/sessions/index.js.map +1 -0
  109. package/dist/skills/index.d.ts +99 -0
  110. package/dist/skills/index.js +254 -5
  111. package/dist/skills/index.js.map +1 -1
  112. package/dist/{src-5W6JNKVb.js → src-BNU3ZiJM.js} +1524 -1441
  113. package/dist/src-BNU3ZiJM.js.map +1 -0
  114. package/dist/state/index.d.ts +6 -0
  115. package/dist/state/index.js +137 -0
  116. package/dist/state/index.js.map +1 -0
  117. package/dist/streams/index.d.ts +120 -0
  118. package/dist/streams/index.js +107 -0
  119. package/dist/streams/index.js.map +1 -0
  120. package/dist/streams-BcE8JP2X.d.ts +370 -0
  121. package/dist/streams-CCPRV6dt.js +709 -0
  122. package/dist/streams-CCPRV6dt.js.map +1 -0
  123. package/dist/sub-routing.d.ts +12 -12
  124. package/dist/surface-bZZJqBka.js +17 -0
  125. package/dist/surface-bZZJqBka.js.map +1 -0
  126. package/dist/tasks/index.d.ts +64 -0
  127. package/dist/tasks/index.js +2 -0
  128. package/dist/tasks-D4nLqVSI.js +1656 -0
  129. package/dist/tasks-D4nLqVSI.js.map +1 -0
  130. package/dist/tasks-V2lCT8ZV.d.ts +517 -0
  131. package/dist/text-segment-joiner-BtAFQSA_.js +57 -0
  132. package/dist/text-segment-joiner-BtAFQSA_.js.map +1 -0
  133. package/dist/text-stream-CpdiKrJB.js +272 -0
  134. package/dist/text-stream-CpdiKrJB.js.map +1 -0
  135. package/dist/tokens-nHAKcN6M.js +52 -0
  136. package/dist/tokens-nHAKcN6M.js.map +1 -0
  137. package/dist/tool-schema-CBjGPrsQ.js +31 -0
  138. package/dist/tool-schema-CBjGPrsQ.js.map +1 -0
  139. package/dist/transport-protocol-BxyngQ_R.js +25 -0
  140. package/dist/transport-protocol-BxyngQ_R.js.map +1 -0
  141. package/dist/transport-protocol-ZTew5Wso.d.ts +27 -0
  142. package/dist/types-B7LojTe4.d.ts +202 -0
  143. package/dist/types-DCD6BNZH.d.ts +70 -0
  144. package/dist/types-_Faxb570.d.ts +439 -0
  145. package/dist/voice/client.d.ts +226 -0
  146. package/dist/voice/client.js +932 -0
  147. package/dist/voice/client.js.map +1 -0
  148. package/dist/voice/errors.d.ts +43 -0
  149. package/dist/voice/errors.js +41 -0
  150. package/dist/voice/errors.js.map +1 -0
  151. package/dist/voice/index.d.ts +271 -0
  152. package/dist/voice/index.js +1812 -0
  153. package/dist/voice/index.js.map +1 -0
  154. package/dist/voice/react.d.ts +167 -0
  155. package/dist/voice/react.js +234 -0
  156. package/dist/voice/react.js.map +1 -0
  157. package/dist/voice/sfu.d.ts +71 -0
  158. package/dist/voice/sfu.js +157 -0
  159. package/dist/voice/sfu.js.map +1 -0
  160. package/dist/voice/text.d.ts +6 -0
  161. package/dist/voice/text.js +2 -0
  162. package/dist/voice/types.d.ts +58 -0
  163. package/dist/voice/types.js +18 -0
  164. package/dist/voice/types.js.map +1 -0
  165. package/dist/voice/workers-ai.d.ts +136 -0
  166. package/dist/voice/workers-ai.js +568 -0
  167. package/dist/voice/workers-ai.js.map +1 -0
  168. package/dist/websockets/index.d.ts +301 -0
  169. package/dist/websockets/index.js +3 -0
  170. package/dist/websockets-D7IzWbZb.js +1005 -0
  171. package/dist/websockets-D7IzWbZb.js.map +1 -0
  172. package/dist/workflow-types.d.ts +25 -25
  173. package/dist/workflows.d.ts +21 -21
  174. package/dist/workflows.js +1 -1
  175. package/docs/agent-class.md +4 -4
  176. package/docs/agent-tools.md +2 -1
  177. package/docs/channels.md +323 -0
  178. package/docs/chat-agents.md +6 -13
  179. package/docs/client-sdk.md +30 -0
  180. package/docs/context.md +131 -0
  181. package/docs/index.md +16 -13
  182. package/docs/lifecycle.md +179 -57
  183. package/docs/long-running-agents.md +2 -2
  184. package/docs/mcp-servers.md +5 -1
  185. package/docs/queue.md +135 -241
  186. package/docs/resumable-streaming.md +1 -1
  187. package/docs/retries.md +1 -1
  188. package/docs/routing.md +105 -0
  189. package/docs/sessions.md +237 -871
  190. package/docs/streams.md +213 -0
  191. package/docs/sub-agents.md +184 -124
  192. package/docs/tasks.md +246 -0
  193. package/docs/voice.md +745 -0
  194. package/package.json +126 -14
  195. package/dist/capability-BjSKYpzg.js.map +0 -1
  196. package/dist/capability-runner-CvHGZqUu.d.ts +0 -150
  197. package/dist/client.js.map +0 -1
  198. package/dist/compaction-helpers-iiKMr2TQ.js +0 -340
  199. package/dist/compaction-helpers-iiKMr2TQ.js.map +0 -1
  200. package/dist/compaction-helpers-wUz6M3us.d.ts +0 -621
  201. package/dist/current-agent-CuMErtly.d.ts +0 -283
  202. package/dist/diagnostics-CaBjfz4J.js.map +0 -1
  203. package/dist/durable-object-lifecycle-D6nNQJJd.js +0 -862
  204. package/dist/durable-object-lifecycle-D6nNQJJd.js.map +0 -1
  205. package/dist/experimental/memory/session/index.d.ts +0 -671
  206. package/dist/experimental/memory/session/index.js +0 -2379
  207. package/dist/experimental/memory/session/index.js.map +0 -1
  208. package/dist/experimental/memory/utils/index.d.ts +0 -96
  209. package/dist/experimental/memory/utils/index.js +0 -79
  210. package/dist/experimental/memory/utils/index.js.map +0 -1
  211. package/dist/scheduler-CR9RHGos.js +0 -857
  212. package/dist/scheduler-CR9RHGos.js.map +0 -1
  213. package/dist/src-5W6JNKVb.js.map +0 -1
  214. package/dist/tool-output-truncation-CNnnGZQ3.js +0 -98
  215. package/dist/tool-output-truncation-CNnnGZQ3.js.map +0 -1
@@ -0,0 +1,157 @@
1
+ import {
2
+ T as WSMessage,
3
+ b as LifecycleJobs,
4
+ i as DurableObjectCapability,
5
+ u as LifecycleRouteAddress
6
+ } from "./capability-runner-BUBa6Ake.js";
7
+ import { DurableObject } from "cloudflare:workers";
8
+
9
+ //#region src/lifecycle/durable-object-lifecycle.d.ts
10
+ /** Internal envelope transported between routed Lifecycle instances. */
11
+ type LifecycleRouteEnvelope = {
12
+ readonly capability: string;
13
+ readonly source: LifecycleRouteAddress | undefined;
14
+ readonly payload: unknown;
15
+ };
16
+ /** Configuration accepted when constructing a {@link Lifecycle}. */
17
+ type LifecycleOptions = {
18
+ /**
19
+ * Consecutive alarm invocations that may end in a Durable Object
20
+ * memory-limit reset before the circuit breaker (#1825) seals recovery
21
+ * work instead of backing it off. Default: 3.
22
+ */
23
+ readonly maxAlarmMemoryLimitStrikes?: number;
24
+ };
25
+ declare class Lifecycle<
26
+ Env extends object = Cloudflare.Env,
27
+ Props extends Record<string, unknown> = Record<string, unknown>
28
+ > {
29
+ #private;
30
+ /**
31
+ * Construct and install a lifecycle in one explicit operation.
32
+ *
33
+ * @param host - The Durable Object whose runtime handlers the lifecycle owns.
34
+ * @returns The installed lifecycle.
35
+ */
36
+ static install<
37
+ Env extends object,
38
+ Props extends Record<string, unknown> = Record<string, unknown>
39
+ >(
40
+ host: DurableObject<Env>,
41
+ options?: LifecycleOptions
42
+ ): Lifecycle<Env, Props>;
43
+ /**
44
+ * Bind a lifecycle to a Durable Object instance without mutating its handlers.
45
+ *
46
+ * @param host - The Durable Object whose runtime lifecycle this object owns.
47
+ * @param options - Policy configuration for this lifecycle.
48
+ */
49
+ constructor(host: DurableObject<Env>, options?: LifecycleOptions);
50
+ /**
51
+ * Install platform fetch, alarm, and hibernating WebSocket handlers.
52
+ *
53
+ * Existing handlers are preserved for framework-owned dispatch such as the
54
+ * Agent's sub-agent router and alarm circuit breaker. Calling this method
55
+ * more than once is an error.
56
+ */
57
+ installHandlers(): void;
58
+ /**
59
+ * Add a reusable capability before this lifecycle starts.
60
+ *
61
+ * Capabilities dispatch in registration order, except that a capability
62
+ * declaring `claims: "catch-all"` always comes last, whenever it was
63
+ * installed. Catch-alls are unique per dispatch hook: two may coexist
64
+ * when they claim disjoint traffic (one `onRequest`, one
65
+ * `onWebSocketUpgrade`), but a second catch-all for the same hook could
66
+ * never be reached and is refused.
67
+ *
68
+ * @param capability - The capability to add.
69
+ * @returns This lifecycle.
70
+ */
71
+ use(capability: DurableObjectCapability<Props>): this;
72
+ /** @internal Deliver a generic capability envelope to this Lifecycle. */
73
+ route(envelope: LifecycleRouteEnvelope): Promise<unknown>;
74
+ /**
75
+ * Execute SQL queries against the Durable Object's database
76
+ * @template T Type of the returned rows
77
+ * @param strings SQL query template strings
78
+ * @param values Values to be inserted into the query
79
+ * @returns Array of query results
80
+ */
81
+ sql<T = Record<string, string | number | boolean | null>>(
82
+ strings: TemplateStringsArray,
83
+ ...values: (string | number | boolean | null)[]
84
+ ): T[];
85
+ /**
86
+ * Handle an incoming request for the owning Durable Object.
87
+ *
88
+ * Non-upgrade requests run through the capability middleware chain first,
89
+ * then fall through to the host's `onRequest`.
90
+ */
91
+ fetch(request: Request): Promise<Response>;
92
+ /** @internal Dispatch a hibernating WebSocket message. */
93
+ webSocketMessage(ws: WebSocket, message: WSMessage): Promise<void>;
94
+ /** @internal Dispatch a hibernating WebSocket close. */
95
+ webSocketClose(
96
+ ws: WebSocket,
97
+ code: number,
98
+ reason: string,
99
+ wasClean: boolean
100
+ ): Promise<void>;
101
+ /** @internal Dispatch a hibernating WebSocket error. */
102
+ webSocketError(ws: WebSocket, error: unknown): Promise<void>;
103
+ /**
104
+ * Start lifecycle capabilities and the owning Durable Object.
105
+ *
106
+ * Runtime fetch, alarm, and WebSocket entry points call this automatically.
107
+ * RPC methods may call it explicitly because native RPC bypasses fetch.
108
+ *
109
+ * @param props - Optional properties supplied to capability and host startup.
110
+ */
111
+ start(props?: Props): Promise<void>;
112
+ /**
113
+ * The name used to address this Durable Object.
114
+ *
115
+ * Native `ctx.id.name` is authoritative. A read-only legacy storage fallback
116
+ * lets objects created by older PartyServer releases migrate without new
117
+ * name writes.
118
+ */
119
+ get name(): string;
120
+ /**
121
+ * The host's scoped access to the Lifecycle work queue. Items pushed here
122
+ * are dispatched to the host's `onJob` inside the host invocation
123
+ * boundary.
124
+ */
125
+ get jobs(): LifecycleJobs;
126
+ /**
127
+ * Recompute the physical Durable Object alarm from job-queue state.
128
+ *
129
+ * Concurrent requests are serialized so a later durable-state change cannot
130
+ * be overwritten by an earlier alarm calculation. Queue mutations call this
131
+ * automatically; it stays public for composition roots and tests.
132
+ */
133
+ rearmAlarm(): Promise<void>;
134
+ /**
135
+ * Keep work a job handed off at a bounded return inside the current
136
+ * alarm's memory-limit breaker domain (#1825). Hosts call this where a
137
+ * queue-driven callback detaches long work and returns.
138
+ *
139
+ * @returns True when called during an alarm invocation; false otherwise.
140
+ */
141
+ trackAlarmWork(work: Promise<unknown>): boolean;
142
+ /** Dispose installed capabilities in reverse registration order. */
143
+ dispose(): Promise<void>;
144
+ /** Permanently disable and clear alarms during explicit object teardown. */
145
+ disableAlarms(): Promise<void>;
146
+ /**
147
+ * Run one alarm invocation. The job driver owns the event loop — deadman
148
+ * pre-arm, due-job dispatch with retry and deferral policy, the alarm
149
+ * memory-limit circuit breaker (#1825) — and re-arms the physical alarm
150
+ * from queue state. The host's `onAlarm()` runs after due jobs, inside
151
+ * the host invocation boundary.
152
+ */
153
+ alarm(): Promise<void>;
154
+ }
155
+ //#endregion
156
+ export { LifecycleOptions as n, LifecycleRouteEnvelope as r, Lifecycle as t };
157
+ //# sourceMappingURL=durable-object-lifecycle-ei7M7lqB.d.ts.map
@@ -0,0 +1,101 @@
1
+ import {
2
+ D as ChannelInboundMessage,
3
+ F as ChannelMessageSurface,
4
+ U as UserIdentity,
5
+ V as ChannelIdentity,
6
+ a as ChannelApprovalRequestOptions,
7
+ d as ChannelRoute,
8
+ h as DeliveryResult,
9
+ j as ChannelIngressEvent,
10
+ l as ChannelDeliveryOptions,
11
+ n as Channel,
12
+ p as ChannelStreamOptions,
13
+ s as ChannelChunkSource,
14
+ u as ChannelMessage,
15
+ w as ChannelEmailInput,
16
+ y as ChannelApprovalResponse
17
+ } from "./channel-Bnm4S7T2.js";
18
+
19
+ //#region src/channels/host/index.d.ts
20
+ type ChannelMessageEvent = {
21
+ channelKey: string;
22
+ route: string /** Stable identity derived only from the configured Channel and eventId. */;
23
+ dispatchId: string;
24
+ message: ChannelInboundMessage;
25
+ };
26
+ type ChannelApprovalResponseEvent = {
27
+ channelKey: string;
28
+ route: string /** Stable identity derived only from the configured Channel and eventId. */;
29
+ dispatchId: string;
30
+ response: ChannelApprovalResponse;
31
+ };
32
+ type ChannelRouteEvent = {
33
+ channelKey: string;
34
+ event: ChannelIngressEvent;
35
+ route:
36
+ | string
37
+ | null /** Stable identity derived only from the configured Channel and eventId. */;
38
+ dispatchId: string;
39
+ };
40
+ type ChannelHostOptions = {
41
+ channels: Record<
42
+ string,
43
+ Channel
44
+ > /** Used when a Channel does not provide a route. Default: event thread id. */;
45
+ defaultRoute?: ChannelRoute /** Resolve an existing, explicitly linked application user. */;
46
+ findUser?(
47
+ identity: ChannelIdentity
48
+ ): Promise<UserIdentity | null> /** Observes every valid route outcome before application dispatch. */;
49
+ onRoute?(event: ChannelRouteEvent): void | Promise<void>;
50
+ onMessage?(event: ChannelMessageEvent): void | Promise<void>;
51
+ onApprovalResponse?(
52
+ event: ChannelApprovalResponseEvent
53
+ ): void | Promise<void>;
54
+ };
55
+ /**
56
+ * Authenticates and normalizes ingress through configured Channel adapters,
57
+ * resolves outbound surfaces, and awaits the application's durable handoff.
58
+ */
59
+ declare class ChannelHost {
60
+ #private;
61
+ constructor(options: ChannelHostOptions);
62
+ handleRequest(request: Request): Promise<Response | undefined>;
63
+ handleEmail(email: ChannelEmailInput): Promise<boolean>;
64
+ /** Deliver through the configured Channel or composite named by the surface. */
65
+ deliver(
66
+ surface: ChannelMessageSurface,
67
+ message: ChannelMessage,
68
+ options?: ChannelDeliveryOptions
69
+ ): Promise<DeliveryResult>;
70
+ /**
71
+ * Deliver a progressively generated answer to the Channel or composite
72
+ * named by the surface.
73
+ *
74
+ * A Channel that can stream consumes the stream itself. A Channel that
75
+ * cannot never learns it was a stream, because the Host collects the answer
76
+ * and calls `deliver` once.
77
+ */
78
+ stream(
79
+ surface: ChannelMessageSurface,
80
+ chunks: ChannelChunkSource,
81
+ options?: ChannelStreamOptions
82
+ ): Promise<DeliveryResult>;
83
+ /** Request approval through the Channel or composite named by the surface. */
84
+ requestApproval(
85
+ surface: ChannelMessageSurface,
86
+ options: ChannelApprovalRequestOptions
87
+ ): Promise<DeliveryResult>;
88
+ /** Return the identity's configured Channel destination, when supported. */
89
+ contactSurface(identity: ChannelIdentity): ChannelMessageSurface | null;
90
+ /** Resolve whether a surface can currently be selected without delivery. */
91
+ isAvailable(surface: ChannelMessageSurface): Promise<boolean>;
92
+ }
93
+ //#endregion
94
+ export {
95
+ ChannelRouteEvent as a,
96
+ ChannelMessageEvent as i,
97
+ ChannelHost as n,
98
+ ChannelHostOptions as r,
99
+ ChannelApprovalResponseEvent as t
100
+ };
101
+ //# sourceMappingURL=index-BB0kqhIz.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,78 @@
1
+ import {
2
+ s as LifecycleCapability,
3
+ x as Connection
4
+ } from "./capability-runner-BUBa6Ake.js";
5
+ //#region src/state/index.d.ts
6
+ /**
7
+ * Source of a state change: `"server"` for host code (e.g. `setState()`), or
8
+ * the {@link Connection} the change arrived from. Hosts use it to exclude the
9
+ * originating connection from a broadcast.
10
+ */
11
+ type StateChangeSource = Connection | "server";
12
+ /**
13
+ * Options for a {@link State} capability. Validation and the post-change hook
14
+ * stay on the host, which passes them in; the capability owns storage and
15
+ * change ordering.
16
+ *
17
+ * @experimental The API surface may change before stabilizing.
18
+ */
19
+ interface StateOptions<T = unknown> {
20
+ /** Seeded on first access when nothing is stored. `undefined` seeds nothing. */
21
+ readonly initialState?: T;
22
+ /** Called after a change is validated and persisted. May be async. */
23
+ readonly onChanged?: (
24
+ state: T,
25
+ source: StateChangeSource
26
+ ) => void | Promise<void>;
27
+ /**
28
+ * Synchronous gating hook run before a change is persisted. Throw to reject
29
+ * the change; the throw propagates to the caller of {@link State.set}.
30
+ */
31
+ readonly validateStateChange?: (
32
+ nextState: T,
33
+ source: StateChangeSource
34
+ ) => void;
35
+ }
36
+ /**
37
+ * Durable state storage for a Lifecycle Object.
38
+ *
39
+ * Owns the `cf_agents_state` state row, lazy load with an in-memory cache, and
40
+ * validated persistence. Install the instance with `Lifecycle.use()`. State
41
+ * validation and the post-change notification hook stay on the host, which
42
+ * injects both callbacks. This capability never touches connections.
43
+ *
44
+ * @experimental The API surface may change before stabilizing.
45
+ */
46
+ declare class State<T = unknown> extends LifecycleCapability {
47
+ #private;
48
+ /**
49
+ * Create a durable state capability.
50
+ *
51
+ * @param options - Optional initial state and a synchronous validation hook
52
+ * injected by the host.
53
+ */
54
+ constructor(options?: StateOptions<T>);
55
+ /** Initialize state storage during Lifecycle startup. */
56
+ onStart(): Promise<void>;
57
+ /**
58
+ * Current state.
59
+ *
60
+ * Loads lazily from storage on first access and caches in memory. Row
61
+ * existence in `cf_agents_state` is the signal that state was previously
62
+ * set, so falsy values persist correctly. On a corrupt row, falls back to
63
+ * the initial state (re-persisting it) or clears the row.
64
+ */
65
+ get(): T | undefined;
66
+ /**
67
+ * Validate and persist a state change, then call the change hook.
68
+ *
69
+ * @param nextState - The new state to persist.
70
+ * @param source - `"server"` for host-originated changes, or the originating
71
+ * connection for client-originated changes.
72
+ * @throws Whatever the injected `validateStateChange` throws.
73
+ */
74
+ set(nextState: T, source?: StateChangeSource): void;
75
+ }
76
+ //#endregion
77
+ export { StateChangeSource as n, StateOptions as r, State as t };
78
+ //# sourceMappingURL=index-Dlgtd3Mj.d.ts.map
@@ -0,0 +1,89 @@
1
+ //#region src/tasks/errors.d.ts
2
+ /**
3
+ * Error classes for the Tasks capability. Each carries a stable `name` so
4
+ * hosts and tests can classify failures without depending on message text.
5
+ */
6
+ /**
7
+ * Thrown by a step callback to fail its run immediately, skipping any
8
+ * remaining retry attempts.
9
+ *
10
+ * Errors named `"NonRetryableError"` from other sources (for example
11
+ * `cloudflare:workflows`) are honored the same way.
12
+ *
13
+ * @experimental The API surface may change before stabilizing.
14
+ */
15
+ declare class NonRetryableError extends Error {
16
+ constructor(
17
+ message: string,
18
+ options?: {
19
+ cause?: unknown;
20
+ }
21
+ );
22
+ }
23
+ /**
24
+ * Thrown before executing user code when one replay uses the same step name
25
+ * twice. Step names are durable journal keys and must be unique within a run.
26
+ *
27
+ * @experimental The API surface may change before stabilizing.
28
+ */
29
+ declare class DuplicateTaskStepError extends Error {
30
+ /** The step name used more than once. */
31
+ readonly stepName: string;
32
+ constructor(stepName: string);
33
+ }
34
+ /**
35
+ * Thrown when a replay observes a journal that this handler code cannot have
36
+ * written — a known step under a different kind, for example. The run fails
37
+ * rather than guessing; changing a definition's step layout for in-flight
38
+ * runs requires versioning the definition name.
39
+ *
40
+ * @experimental The API surface may change before stabilizing.
41
+ */
42
+ declare class TaskReplayDivergedError extends Error {
43
+ /** The step name where replay diverged from the journal. */
44
+ readonly stepName: string;
45
+ constructor(stepName: string, detail: string);
46
+ }
47
+ /**
48
+ * Recorded against a run whose persisted definition name is no longer
49
+ * registered after a deployment. The run fails visibly; it is never silently
50
+ * deleted and never replayed against a different handler.
51
+ *
52
+ * @experimental The API surface may change before stabilizing.
53
+ */
54
+ declare class MissingTaskDefinitionError extends Error {
55
+ /** The persisted definition name that no longer resolves. */
56
+ readonly definition: string;
57
+ constructor(definition: string);
58
+ }
59
+ /**
60
+ * Thrown when a Task input, step result, metadata value, or final result is
61
+ * not JSON-serializable or exceeds the serialized size limit.
62
+ *
63
+ * @experimental The API surface may change before stabilizing.
64
+ */
65
+ declare class TaskSerializationError extends Error {
66
+ constructor(context: string, detail: string);
67
+ }
68
+ //#endregion
69
+ //#region src/tasks/serialization.d.ts
70
+ /**
71
+ * Value serialization for the Tasks capability.
72
+ *
73
+ * Task inputs, step results, metadata, and final results persist as JSON
74
+ * text in SQLite. `undefined` (and a `void` handler result) is represented
75
+ * as SQL `NULL` rather than a JSON envelope, so the JSON column space stays
76
+ * plain: `"null"` is JSON `null`, column `NULL` is `undefined`.
77
+ */
78
+ /** Default ceiling for one serialized value (1 MiB). */
79
+ declare const MAX_SERIALIZED_BYTES = 1048576;
80
+ //#endregion
81
+ export {
82
+ TaskReplayDivergedError as a,
83
+ NonRetryableError as i,
84
+ DuplicateTaskStepError as n,
85
+ TaskSerializationError as o,
86
+ MissingTaskDefinitionError as r,
87
+ MAX_SERIALIZED_BYTES as t
88
+ };
89
+ //# sourceMappingURL=index-XDkuQ7zm.d.ts.map
@@ -785,6 +785,8 @@ declare const channels: {
785
785
  readonly chat: Channel<any, any>;
786
786
  readonly transcript: Channel<any, any>;
787
787
  readonly fiber: Channel<any, any>;
788
+ readonly task: Channel<any, any>;
789
+ readonly stream: Channel<any, any>;
788
790
  readonly agentTool: Channel<any, any>;
789
791
  readonly schedule: Channel<any, any>;
790
792
  readonly lifecycle: Channel<any, any>;
@@ -932,4 +934,4 @@ export {
932
934
  MCPObservabilityEvent as s,
933
935
  ChannelEventMap as t
934
936
  };
935
- //# sourceMappingURL=index-DcSAZKsB.d.ts.map
937
+ //# sourceMappingURL=index-YSKgfgg9.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,101 +1,97 @@
1
1
  /// <reference path="../skills-module.d.ts" />
2
2
  import {
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";
3
+ S as ConnectionContext,
4
+ T as WSMessage,
5
+ x as Connection
6
+ } from "./capability-runner-BUBa6Ake.js";
8
7
  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,
8
+ i as isDurableObjectStorageReset,
9
+ n as isDurableObjectCodeUpdateReset,
10
+ r as isDurableObjectMemoryLimitReset,
11
+ s as isPlatformTransientError,
12
+ t as RetryOptions
13
+ } from "./retries-D9B2UCq3.js";
14
+ import { i as __DO_NOT_USE_WILL_BREAK__agentContext } from "./current-agent-C4w86kcN.js";
15
+ import {
16
+ $ as DetachedAgentToolConfig,
17
+ A as getCurrentAgent,
18
+ An as withInvocationScope,
19
+ At as MCPAIToolSet,
20
+ B as AgentToolInterruptedReason,
21
+ C as MCPServersState,
22
+ Cn as buildAgentPath,
23
+ D as StartFiberResult,
24
+ Dn as getSubAgentByName,
25
+ E as StartFiberOptions,
26
+ F as AgentToolDisplayMetadata,
27
+ G as AgentToolRunInfo,
28
+ Gt as normalizeServerId,
29
+ H as AgentToolMilestone,
30
+ Ht as MCP_SERVER_ID_MAX_LENGTH,
31
+ I as AgentToolEvent,
32
+ J as AgentToolRunState,
33
+ K as AgentToolRunInspection,
34
+ L as AgentToolEventMessage,
35
+ M as AGENT_TOOL_MILESTONE_PART,
36
+ N as AGENT_TOOL_PROGRESS_PART,
37
+ O as StateUpdateMessage,
38
+ On as parseSubAgentPath,
39
+ P as AgentToolChildAdapter,
40
+ Q as ChatCapableAgentClass,
41
+ R as AgentToolEventState,
42
+ S as MCPServerMessage,
43
+ Sn as SubAgentPathMatch,
44
+ T as RPCResponse,
45
+ U as AgentToolProgress,
46
+ V as AgentToolLifecycleResult,
47
+ W as AgentToolProgressSnapshot,
48
+ X as AgentToolStoredChunk,
49
+ Y as AgentToolRunStatus,
50
+ Z as AgentToolTerminalStatus,
51
+ _ as FiberRecoveryContext,
52
+ _n as DynamicAgentClass,
49
53
  a as routeAgentRequest,
50
- at as DetachedAgentToolConfig,
51
- b as FiberStatus,
54
+ b as ListFibersOptions,
55
+ bn as BuildAgentPathOptions,
52
56
  c as Agent,
53
- ct as RunAgentToolResult,
54
57
  d as AgentStaticOptions,
55
- et as AgentToolRunState,
56
- f as CallableMetadata,
57
- g as FiberContext,
58
- h as EmailRoutingOptions,
58
+ et as DetachedRunAgentToolResult,
59
+ f as DEFAULT_AGENT_STATIC_OPTIONS,
60
+ g as FiberInspection,
61
+ h as FiberContext,
59
62
  i as getAgentByName,
60
- it as ChatCapableAgentClass,
61
- j as StreamingResponse,
62
- jn as getSubAgentByName,
63
- k as StartFiberResult,
63
+ j as routeAgentEmail,
64
+ k as StreamingResponse,
65
+ kn as routeSubAgentRequest,
66
+ kt as MCPAITool,
64
67
  l as AgentContext,
65
- m as DeleteFibersOptions,
68
+ m as EmailRoutingOptions,
66
69
  n as AgentOptions,
67
- nt as AgentToolStoredChunk,
70
+ nt as RunAgentToolResult,
68
71
  o as AddMcpServerOptions,
69
- ot as DetachedRunAgentToolResult,
70
- p as DEFAULT_AGENT_STATIC_OPTIONS,
71
- q as AgentToolLifecycleResult,
72
+ p as DeleteFibersOptions,
73
+ q as AgentToolRunPart,
72
74
  r as RoutingRetryOptions,
73
- rt as AgentToolTerminalStatus,
74
75
  s as AddRpcMcpServerOptions,
75
- st as RunAgentToolOptions,
76
76
  t as AgentGetOptions,
77
- tt as AgentToolRunStatus,
77
+ tt as RunAgentToolOptions,
78
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";
79
+ v as FiberRecoveryResult,
80
+ vn as DynamicAgentStub,
81
+ w as RPCRequest,
82
+ wn as buildAgentUrl,
83
+ x as MCPServer,
84
+ xn as SUB_PREFIX,
85
+ y as FiberStatus,
86
+ yn as AgentPathStep,
87
+ z as AgentToolFailure
88
+ } from "./agent-routing-B2XLNMxq.js";
86
89
  import {
87
90
  a as EmailSendBinding,
88
91
  d as createHeaderBasedEmailResolver,
89
92
  s as SendEmailOptions
90
93
  } from "./email-7TatiTnl.js";
91
94
  import { n as camelCaseToKebabCase } from "./utils-CGtGDSgA.js";
92
- import {
93
- i as isDurableObjectStorageReset,
94
- n as isDurableObjectCodeUpdateReset,
95
- o as isPlatformTransientError,
96
- r as isDurableObjectMemoryLimitReset,
97
- t as RetryOptions
98
- } from "./retries-CAvxtG9d.js";
99
95
  import {
100
96
  n as AgentsOAuthProvider,
101
97
  r as DurableObjectOAuthClientProvider,
@@ -103,7 +99,17 @@ import {
103
99
  } from "./do-oauth-client-provider-Tmf1vgKz.js";
104
100
  import { f as TransportType } from "./handler-stateless-DxYpJ_XF.js";
105
101
  import { t as MessageType } from "./types-6Zo2zfoO.js";
106
- import { a as ScheduleCriteria, i as Schedule } from "./scheduler-DQoTGoAW.js";
102
+ import {
103
+ a as ScheduleCriteria,
104
+ i as Schedule,
105
+ o as ScheduleOptions
106
+ } from "./scheduler-BGq6M5Kd.js";
107
+ import { i as QueueItem } from "./types-DCD6BNZH.js";
108
+ import {
109
+ n as callable,
110
+ s as unstable_callable,
111
+ t as CallableMetadata
112
+ } from "./callable-decorator-DP__HhBA.js";
107
113
  import { t as SqlError } from "./sql-error-CPY-GXyI.js";
108
114
  export {
109
115
  AGENT_TOOL_MILESTONE_PART,
@@ -138,7 +144,7 @@ export {
138
144
  type AgentToolTerminalStatus,
139
145
  type AgentsOAuthProvider,
140
146
  type BuildAgentPathOptions,
141
- CallableMetadata,
147
+ type CallableMetadata,
142
148
  type ChatCapableAgentClass,
143
149
  type Connection,
144
150
  type ConnectionContext,
@@ -147,6 +153,10 @@ export {
147
153
  type DetachedAgentToolConfig,
148
154
  type DetachedRunAgentToolResult,
149
155
  DurableObjectOAuthClientProvider,
156
+ type DynamicAgentClass,
157
+ type DynamicAgentClass as SubAgentClass,
158
+ type DynamicAgentStub,
159
+ type DynamicAgentStub as SubAgentStub,
150
160
  EmailRoutingOptions,
151
161
  type EmailSendBinding,
152
162
  FiberContext,
@@ -162,7 +172,7 @@ export {
162
172
  MCPServersState,
163
173
  MCP_SERVER_ID_MAX_LENGTH,
164
174
  MessageType,
165
- QueueItem,
175
+ type QueueItem,
166
176
  RPCRequest,
167
177
  RPCResponse,
168
178
  type RetryOptions,
@@ -172,15 +182,14 @@ export {
172
182
  SUB_PREFIX,
173
183
  type Schedule,
174
184
  type ScheduleCriteria,
185
+ type ScheduleOptions,
175
186
  type SendEmailOptions,
176
187
  SqlError,
177
188
  StartFiberOptions,
178
189
  StartFiberResult,
179
190
  StateUpdateMessage,
180
191
  StreamingResponse,
181
- SubAgentClass,
182
192
  type SubAgentPathMatch,
183
- SubAgentStub,
184
193
  type TransportType,
185
194
  type WSMessage,
186
195
  __DO_NOT_USE_WILL_BREAK__agentContext,