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,370 @@
1
+ import { s as LifecycleCapability } from "./capability-runner-BUBa6Ake.js";
2
+
3
+ //#region src/streams/types.d.ts
4
+ /**
5
+ * JSON-serializable data accepted as stream chunks and metadata.
6
+ *
7
+ * @experimental The API surface may change before stabilizing.
8
+ */
9
+ type StreamJson =
10
+ | string
11
+ | number
12
+ | boolean
13
+ | null
14
+ | StreamJson[]
15
+ | {
16
+ [key: string]: StreamJson;
17
+ };
18
+ /**
19
+ * States a stream moves through. A stream is `streaming` from `open()` until
20
+ * its producer settles it; both terminal states keep the chunk log readable.
21
+ *
22
+ * @experimental The API surface may change before stabilizing.
23
+ */
24
+ type StreamState = "streaming" | "completed" | "errored";
25
+ /**
26
+ * One durable chunk. `seq` is the stream's monotonic cursor: 0-based,
27
+ * assigned at append time, and stable across replays.
28
+ *
29
+ * @experimental The API surface may change before stabilizing.
30
+ */
31
+ interface StreamChunk {
32
+ readonly seq: number;
33
+ readonly chunk: StreamJson;
34
+ }
35
+ /**
36
+ * Read-only status of one stream — the recovery-evidence surface a Task's
37
+ * `recover` callback consults.
38
+ *
39
+ * @experimental The API surface may change before stabilizing.
40
+ */
41
+ interface StreamStatus {
42
+ streamId: string;
43
+ state: StreamState;
44
+ /** The next sequence number to be assigned == durable chunk count. */
45
+ cursor: number;
46
+ /** Application lookup key assigned at `open()`, when one was. */
47
+ tag?: string;
48
+ metadata?: Record<string, StreamJson>;
49
+ /** Reason recorded by `error()`, when the state is `errored`. */
50
+ error?: string;
51
+ createdAt: number;
52
+ /**
53
+ * Last write activity: advances with every append and with settlement.
54
+ * The liveness signal retention policies key off — a `streaming` stream
55
+ * whose `updatedAt` is old has a producer that stopped appending. (For a
56
+ * live stream this is derived from the chunk log's newest entry; the
57
+ * stored row is only stamped at open and settle.)
58
+ */
59
+ updatedAt: number;
60
+ closedAt?: number;
61
+ }
62
+ /**
63
+ * Producer handle returned by `Streams.open()`. Appends are synchronous
64
+ * durable writes; a terminal stream rejects further appends.
65
+ *
66
+ * @experimental The API surface may change before stabilizing.
67
+ */
68
+ interface StreamWriter {
69
+ readonly streamId: string;
70
+ /** The next sequence number to be assigned. */
71
+ readonly cursor: number;
72
+ /** Durably append one chunk and wake live readers. Returns its `seq`. */
73
+ append(chunk: StreamJson): number;
74
+ /**
75
+ * Settle the stream as completed. No-op if already terminal or deleted:
76
+ * `options.commit` runs only when this call ends the stream.
77
+ */
78
+ close(options?: StreamSettleOptions): void;
79
+ /** Settle the stream as errored. Same no-op contract as {@link close}. */
80
+ error(reason?: string, options?: StreamSettleOptions): void;
81
+ }
82
+ /**
83
+ * The cutover: settle a stream, run the caller's own synchronous writes
84
+ * (typically persisting the finished message), and discard the stream's
85
+ * rows, all in ONE SQLite transaction. A crash leaves either the live
86
+ * stream or the finished message, never neither. `commit` must not await
87
+ * and must not throw for a reason it wants ignored: a throw rolls the
88
+ * settle back and leaves the stream live.
89
+ *
90
+ * Settlement stays idempotent: on a stream already terminal or deleted,
91
+ * `commit` does not run and nothing is discarded. Events and reader wakeups
92
+ * fire after the transaction commits, never for a rolled-back cutover.
93
+ *
94
+ * @experimental The API surface may change before stabilizing.
95
+ */
96
+ interface StreamSettleOptions {
97
+ /** Synchronous writes to commit with the settlement. */
98
+ readonly commit?: () => void;
99
+ /**
100
+ * Delete the stream's rows in the same transaction. The stream ceases
101
+ * to exist (`status()` returns null); readers tailing it end. Use when
102
+ * the chunks have been handed off, so nothing is left to sweep later.
103
+ */
104
+ readonly discard?: boolean;
105
+ }
106
+ /** Options accepted by `Streams.open()`. */
107
+ interface StreamOpenOptions {
108
+ /** JSON metadata retained with the stream. */
109
+ metadata?: Record<string, StreamJson>;
110
+ /**
111
+ * Indexed application lookup key, set once at creation. Deliberately not
112
+ * unique: an operation that produces successive streams (a retried turn, a
113
+ * regenerated reply) stamps each with the same tag, and
114
+ * `list({ tag, limit: 1 })` finds the latest. Reopening a live stream with
115
+ * a *different* tag throws — a config conflict, not a new stream.
116
+ */
117
+ tag?: string;
118
+ }
119
+ /** Options accepted by `Streams.read()`. */
120
+ interface StreamReadOptions {
121
+ /** First sequence number to yield (inclusive). Defaults to 0. */
122
+ from?: number;
123
+ /** Abort a read that is tailing a live stream. */
124
+ signal?: AbortSignal;
125
+ }
126
+ /** Options accepted by `Streams.readBatches()`. */
127
+ interface StreamReadBatchesOptions extends StreamReadOptions {
128
+ /** Maximum chunks per yielded batch. Defaults to 100. */
129
+ batchSize?: number;
130
+ /**
131
+ * Invoked once, the first time the reader reaches the durable tail —
132
+ * i.e. every chunk stored so far has been yielded. Distinct from the
133
+ * stream ending: a live stream is "up to date" while tailing. Useful as a
134
+ * transition signal (flush replayed UI, show a live indicator).
135
+ */
136
+ onUpToDate?: () => void;
137
+ }
138
+ /** Filters accepted by `Streams.list()`. */
139
+ interface StreamListOptions {
140
+ state?: StreamState | StreamState[];
141
+ /** Only streams opened with this exact tag (indexed). */
142
+ tag?: string;
143
+ limit?: number;
144
+ }
145
+ /**
146
+ * @internal Raw `cf_agents_streams` SQLite row.
147
+ *
148
+ * While `state` is `streaming`, `chunk_count` and `updated_at` are NOT
149
+ * maintained per append (appends write only the chunk log; the log's tail
150
+ * is authoritative — see `Streams.#tail`). Both are stamped exact by the
151
+ * settle UPDATE, so terminal rows read straight through. Consumers of a
152
+ * live row must derive cursor/liveness rather than trust these columns.
153
+ */
154
+ type StreamRow = {
155
+ stream_id: string;
156
+ state: StreamState;
157
+ tag: string | null;
158
+ metadata: string | null;
159
+ error_message: string | null;
160
+ chunk_count: number;
161
+ created_at: number;
162
+ updated_at: number;
163
+ closed_at: number | null;
164
+ };
165
+ /** @internal One chunk as read back from a `cf_agents_stream_blocks` row. */
166
+ type StreamChunkRow = {
167
+ stream_id: string;
168
+ seq: number;
169
+ chunk: string;
170
+ created_at: number;
171
+ };
172
+ //#endregion
173
+ //#region src/streams/streams.d.ts
174
+ /** Default ceiling for one serialized chunk (1 MiB). */
175
+ declare const DEFAULT_MAX_CHUNK_BYTES = 1048576;
176
+ /**
177
+ * Policy for a Streams capability.
178
+ *
179
+ * @experimental The API surface may change before stabilizing.
180
+ */
181
+ interface StreamsOptions {
182
+ /** Ceiling for one serialized chunk. Default: 1 MiB. */
183
+ readonly maxChunkBytes?: number;
184
+ }
185
+ /**
186
+ * @internal Synchronous operations returned by
187
+ * {@link Streams.__DO_NOT_USE_WILL_BREAK__sync}. For same-isolate first-party
188
+ * machinery only (the chat `ResumableStream` adapter); every method bypasses
189
+ * `lifecycle.ready()`, so the caller owns startup ordering.
190
+ */
191
+ interface StreamsSyncInternal {
192
+ /** Idempotent DDL — safe to call before the Lifecycle starts. */
193
+ ensureTables(): void;
194
+ getStream(streamId: string): StreamRow | undefined;
195
+ /** Insert a live stream row (no idempotency — caller checks first). */
196
+ insertStream(
197
+ streamId: string,
198
+ tag: string | null,
199
+ metadata: Record<string, StreamJson> | undefined
200
+ ): void;
201
+ /** The read-fenced append: one chunk insert at the log tail, reader wakeup. */
202
+ append(streamId: string, chunk: StreamJson): number;
203
+ /**
204
+ * The newest chunk's timestamp, or null for an empty log. One PK-served
205
+ * read — the per-append liveness signal retention sweeps verify against
206
+ * (a live row's `updated_at` is set at open and not bumped by appends).
207
+ */
208
+ lastChunkAt(streamId: string): number | null;
209
+ /**
210
+ * Segments durably appended so far: the chunk log's tail, read in the
211
+ * calling synchronous block. Zero for an unknown stream.
212
+ */
213
+ cursor(streamId: string): number;
214
+ /**
215
+ * Observe every deletion of a stream's rows — the public `delete()`, the
216
+ * aperture's own deletes, and a cutover's discard — with the row and its
217
+ * cursor as they were just before removal, in the same synchronous block
218
+ * (and, for a cutover, the same transaction). Hooks must be synchronous
219
+ * and must not await: the cutover runs them inside `transactionSync`.
220
+ * The chat adapter uses this to keep its recovery progress marker exact
221
+ * however a chat row leaves the table. Returns the unsubscribe: an owner
222
+ * constructed again (a host whose startup retried) must drop its earlier
223
+ * hook, or a deletion is observed once per construction.
224
+ */
225
+ onDelete(hook: (row: StreamRow, cursor: number) => void): () => void;
226
+ /**
227
+ * Idempotent settlement with events and reader wakeup. With `options`,
228
+ * the settle, the caller's `commit` writes and the log discard run in
229
+ * one SQLite transaction (see {@link StreamSettleOptions}). Returns
230
+ * whether the stream transitioned; on a repeat or a deleted stream the
231
+ * `commit` callback does not run.
232
+ */
233
+ settle(
234
+ streamId: string,
235
+ state: "completed" | "errored",
236
+ reason: string | null,
237
+ options?: StreamSettleOptions
238
+ ): boolean;
239
+ /** Delete a stream and its chunks regardless of state. */
240
+ deleteUnchecked(streamId: string): void;
241
+ /** Delete many streams and their chunks regardless of state, silently. */
242
+ deleteMany(streamIds: string[]): void;
243
+ /**
244
+ * One page of a stream's chunk log from `fromSeq` (inclusive), ordered by
245
+ * seq. Paged rather than read-it-all so replaying a large stream holds
246
+ * one page of segment bodies in memory, not the whole turn.
247
+ */
248
+ readChunks(
249
+ streamId: string,
250
+ fromSeq: number,
251
+ limit: number
252
+ ): StreamChunkRow[];
253
+ /** Every stream row, newest first (created_at, then insertion order). */
254
+ listRows(): StreamRow[];
255
+ /**
256
+ * Every row carrying a tag, newest first, optionally narrowed to one
257
+ * state. Tags are non-unique and the table is shared across producers,
258
+ * so callers apply their own ownership filter (e.g. chat's metadata
259
+ * marker) rather than trusting the newest row.
260
+ */
261
+ rowsByTag(tag: string, state?: StreamState): StreamRow[];
262
+ /**
263
+ * Import one historical stream row verbatim (migrations, test seeding):
264
+ * explicit timestamps and count, no events, no wakeups.
265
+ */
266
+ importStream(row: {
267
+ streamId: string;
268
+ state: StreamState;
269
+ tag: string | null;
270
+ metadata: Record<string, StreamJson> | undefined;
271
+ chunkCount: number;
272
+ createdAt: number;
273
+ updatedAt: number;
274
+ closedAt: number | null;
275
+ }): void;
276
+ /**
277
+ * Import one historical chunk at the log's tail: one INSERT, nothing else.
278
+ * The stream row is not touched — importers pass the final `chunkCount`
279
+ * and `updatedAt` to {@link importStream}, so the row is exact at rest
280
+ * without a per-chunk row write.
281
+ */
282
+ importChunk(streamId: string, chunk: StreamJson, createdAt: number): void;
283
+ }
284
+ /**
285
+ * Durable incremental output for a Lifecycle Object.
286
+ *
287
+ * `open()` a stream, `append()` chunks (synchronous durable writes that wake
288
+ * live readers), and settle it with `close()` or `error()`. `read()` replays
289
+ * persisted chunks from a cursor and then tails live appends; `status()`
290
+ * reports the state and cursor — the recovery evidence a Task's `recover`
291
+ * callback consults after its producer was interrupted.
292
+ *
293
+ * @experimental The API surface may change before stabilizing.
294
+ */
295
+ declare class Streams extends LifecycleCapability {
296
+ #private;
297
+ constructor(options?: StreamsOptions);
298
+ /** Migrate stream storage during Lifecycle startup. */
299
+ onStart(): Promise<void>;
300
+ /**
301
+ * Open a stream for writing. Idempotent on the id: reopening a live stream
302
+ * returns a writer positioned at its current cursor; reopening a terminal
303
+ * stream throws {@link StreamClosedError}.
304
+ */
305
+ open(streamId: string, options?: StreamOpenOptions): Promise<StreamWriter>;
306
+ /**
307
+ * Replay persisted chunks from `from` (inclusive), then tail live appends
308
+ * until the stream settles. Ends when the stream reaches a terminal state
309
+ * and every durable chunk has been yielded; a read of an `errored` stream
310
+ * still yields its chunks and then simply ends — consult {@link status}
311
+ * for the terminal outcome. Aborting `options.signal` throws its reason.
312
+ */
313
+ read(
314
+ streamId: string,
315
+ options?: StreamReadOptions
316
+ ): AsyncGenerator<StreamChunk, void, undefined>;
317
+ /**
318
+ * Batched form of {@link read}: yields non-empty arrays of consecutive
319
+ * chunks instead of one chunk at a time. Replay yields up to
320
+ * `options.batchSize` chunks per array; a live tail yields everything
321
+ * that accumulated since the last wakeup as one array — so a consumer
322
+ * paying per write (an SSE flush, an RPC hop, a history append) pays
323
+ * once per backlog, not once per chunk. Same lifecycle as {@link read}:
324
+ * ends when the stream settles and every durable chunk has been
325
+ * yielded; aborting `options.signal` throws its reason.
326
+ */
327
+ readBatches(
328
+ streamId: string,
329
+ options?: StreamReadBatchesOptions
330
+ ): AsyncGenerator<StreamChunk[], void, undefined>;
331
+ /** Read one stream's state and cursor, or null when it does not exist. */
332
+ status(streamId: string): Promise<StreamStatus | null>;
333
+ /** List streams, newest first. */
334
+ list(options?: StreamListOptions): Promise<StreamStatus[]>;
335
+ /**
336
+ * Delete one terminal stream and its chunk log.
337
+ *
338
+ * @returns True when a terminal stream was deleted; false when none
339
+ * exists. Throws on a live stream — settle it first.
340
+ */
341
+ delete(streamId: string): Promise<boolean>;
342
+ /**
343
+ * @internal Synchronous storage operations for same-isolate first-party
344
+ * machinery — today the chat `ResumableStream` adapter, whose whole public
345
+ * surface is synchronous and constructed before the Lifecycle starts.
346
+ * Bypasses `lifecycle.ready()`: the caller owns startup ordering. The
347
+ * invariant-bearing writes (append fence, settlement, wakeups, events) go
348
+ * through the same private methods as the public API, so live readers and
349
+ * diagnostics observe aperture writes exactly like capability writes. Will
350
+ * break without notice; never use from application code.
351
+ */
352
+ __DO_NOT_USE_WILL_BREAK__sync(): StreamsSyncInternal;
353
+ }
354
+ //#endregion
355
+ export {
356
+ StreamJson as a,
357
+ StreamReadBatchesOptions as c,
358
+ StreamState as d,
359
+ StreamStatus as f,
360
+ StreamChunk as i,
361
+ StreamReadOptions as l,
362
+ Streams as n,
363
+ StreamListOptions as o,
364
+ StreamWriter as p,
365
+ StreamsOptions as r,
366
+ StreamOpenOptions as s,
367
+ DEFAULT_MAX_CHUNK_BYTES as t,
368
+ StreamSettleOptions as u
369
+ };
370
+ //# sourceMappingURL=streams-BcE8JP2X.d.ts.map