agents 0.27.0 → 0.28.1

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 (216) hide show
  1. package/dist/abortable-C1SpfVoi.js +21 -0
  2. package/dist/abortable-C1SpfVoi.js.map +1 -0
  3. package/dist/{agent-routing-Bhdbvf7s.d.ts → agent-routing-BMvWTFEp.d.ts} +21 -15
  4. package/dist/agent-routing.d.ts +1 -1
  5. package/dist/agent-tool-types.d.ts +1 -1
  6. package/dist/{agent-tools-bJZwBMfq.d.ts → agent-tools-ohoewW-B.d.ts} +2 -2
  7. package/dist/agent-tools.d.ts +1 -1
  8. package/dist/ai-ahruGw7e.d.ts +239 -0
  9. package/dist/{ai-sdk-OoGkFy3s.js → ai-sdk-C2iTAwUd.js} +44 -18
  10. package/dist/ai-sdk-C2iTAwUd.js.map +1 -0
  11. package/dist/browser/ai.d.ts +8 -227
  12. package/dist/browser/ai.js +259 -1
  13. package/dist/browser/ai.js.map +1 -0
  14. package/dist/browser/index.d.ts +56 -46
  15. package/dist/browser/index.js +4 -361
  16. package/dist/browser/{ai-sdk.d.ts → tools/ai-sdk.d.ts} +7 -7
  17. package/dist/browser/{ai-sdk.js → tools/ai-sdk.js} +5 -4
  18. package/dist/browser/tools/ai-sdk.js.map +1 -0
  19. package/dist/browser/tools/pi.d.ts +111 -0
  20. package/dist/browser/tools/pi.js +119 -0
  21. package/dist/browser/tools/pi.js.map +1 -0
  22. package/dist/browser/{tanstack-ai.d.ts → tools/tanstack-ai.d.ts} +39 -37
  23. package/dist/browser/{tanstack-ai.js → tools/tanstack-ai.js} +73 -59
  24. package/dist/browser/tools/tanstack-ai.js.map +1 -0
  25. package/dist/browser-CEdNlsaD.js +481 -0
  26. package/dist/browser-CEdNlsaD.js.map +1 -0
  27. package/dist/{browser-tmkcAAI3.d.ts → browser-D30VlpcA.d.ts} +63 -37
  28. package/dist/{browser-tool-CBqs6hqa.js → browser-tool-4iomavs_.js} +145 -49
  29. package/dist/browser-tool-4iomavs_.js.map +1 -0
  30. package/dist/{browser-tool-Bn-nzJQI.d.ts → browser-tool-vtrPOV8e.d.ts} +24 -5
  31. package/dist/{capability-B4WbF81e.js → capability-DBAKc6UZ.js} +1 -3
  32. package/dist/capability-DBAKc6UZ.js.map +1 -0
  33. package/dist/{capability-runner-O5VbQzqg.d.ts → capability-runner-BiVUtjqC.d.ts} +1 -7
  34. package/dist/chat/index.d.ts +4 -4
  35. package/dist/chat/index.js +1 -1
  36. package/dist/chat-sdk/index.d.ts +1 -1
  37. package/dist/chat-sdk/index.js +1 -1
  38. package/dist/{client-1tEQ1Oqz.js → client-BnYbNT3z.js} +3 -4
  39. package/dist/client-BnYbNT3z.js.map +1 -0
  40. package/dist/{client-DS3Dz9l0.d.ts → client-Bp-JwL3p.d.ts} +2 -2
  41. package/dist/client.d.ts +1 -1
  42. package/dist/{connector-58XDGvc3.js → connector-CtZylXdk.js} +3 -603
  43. package/dist/connector-CtZylXdk.js.map +1 -0
  44. package/dist/{connector-Cl-VqPmA.d.ts → connector-DEXzVoaY.d.ts} +9 -374
  45. package/dist/{conversations-DH0ut_8n.d.ts → conversations-FjHDRZyD.d.ts} +4 -4
  46. package/dist/{current-agent-C07C5o5Y.d.ts → current-agent-CKgT5d1O.d.ts} +3 -5
  47. package/dist/current-agent-DhoDkSnH.js.map +1 -1
  48. package/dist/{durable-object-lifecycle-DRqp475_.d.ts → durable-object-lifecycle-DOI_bzCH.d.ts} +2 -2
  49. package/dist/experimental/channels/index.d.ts +2 -2
  50. package/dist/experimental/channels/index.js +2 -2
  51. package/dist/experimental/channels/web/index.d.ts +2 -2
  52. package/dist/experimental/channels/web/index.js +1 -1
  53. package/dist/{gateway-BDC07gYO.d.ts → gateway-BFO6vRDn.d.ts} +2 -2
  54. package/dist/{handler-stateless-VvrWSAVA.js → handler-stateless-Bly_nSH3.js} +12 -3
  55. package/dist/handler-stateless-Bly_nSH3.js.map +1 -0
  56. package/dist/harness/ai-sdk/index.d.ts +2 -2
  57. package/dist/harness/ai-sdk/index.js +1 -1
  58. package/dist/harness/container/index.d.ts +2 -2
  59. package/dist/harness/container/index.js +3 -3
  60. package/dist/harness/opencode/index.d.ts +183 -7
  61. package/dist/harness/opencode/index.js +355 -24
  62. package/dist/harness/opencode/index.js.map +1 -1
  63. package/dist/harness/pi/index.d.ts +2 -2
  64. package/dist/harness/pi/index.js +3 -3
  65. package/dist/harness/store/index.d.ts +1 -1
  66. package/dist/harness/store/index.js +1 -1
  67. package/dist/harness/think/index.d.ts +2 -2
  68. package/dist/harness/think/index.js +363 -171
  69. package/dist/harness/think/index.js.map +1 -1
  70. package/dist/{images-Ce9SCu3X.js → images-C4hiIexM.js} +46 -4
  71. package/dist/images-C4hiIexM.js.map +1 -0
  72. package/dist/{index-D0A5tbWu.d.ts → index-BEL3ZV-s.d.ts} +2 -6
  73. package/dist/{index-Ib_4dwOo.d.ts → index-CBt8oRJt.d.ts} +3 -5
  74. package/dist/index.d.ts +4 -4
  75. package/dist/index.js +2 -2
  76. package/dist/input-schema-BQykTEp_.js +20 -0
  77. package/dist/input-schema-BQykTEp_.js.map +1 -0
  78. package/dist/{input-schema-DNrpTu49.js → input-schema-xBofjBKC.js} +3 -3
  79. package/dist/input-schema-xBofjBKC.js.map +1 -0
  80. package/dist/internal_context.d.ts +1 -1
  81. package/dist/lifecycle/index.d.ts +3 -3
  82. package/dist/lifecycle/index.js +2 -2
  83. package/dist/{lifecycle-CFu6OV03.js → lifecycle-DGorpAmA.js} +2 -4
  84. package/dist/lifecycle-DGorpAmA.js.map +1 -0
  85. package/dist/mcp/client/index.d.ts +1 -1
  86. package/dist/mcp/client/index.js +1 -1
  87. package/dist/mcp/index.d.ts +1 -1
  88. package/dist/mcp/index.js +18 -4
  89. package/dist/mcp/index.js.map +1 -1
  90. package/dist/mcp/server/index.js +1 -1
  91. package/dist/models/ai-sdk/index.d.ts +45 -17
  92. package/dist/models/ai-sdk/index.js +1 -1
  93. package/dist/models/opencode/index.d.ts +2 -2
  94. package/dist/models/opencode/index.js +1 -1
  95. package/dist/models/pi-ai/index.d.ts +8 -3
  96. package/dist/models/pi-ai/index.js +6 -6
  97. package/dist/models/pi-ai/index.js.map +1 -1
  98. package/dist/{options-pwTNq9z6.d.ts → options-CiIsJHXR.d.ts} +2 -6
  99. package/dist/queue/index.d.ts +1 -1
  100. package/dist/queue/index.js +1 -1
  101. package/dist/{queue-BB-zfIYF.js → queue-CcIjVYTE.js} +2 -2
  102. package/dist/{queue-BB-zfIYF.js.map → queue-CcIjVYTE.js.map} +1 -1
  103. package/dist/react.d.ts +2 -2
  104. package/dist/routing/index.d.ts +2 -2
  105. package/dist/routing/index.js +1 -1
  106. package/dist/{scheduler-CrFCnv_J.d.ts → scheduler-BCLESHSC.d.ts} +2 -12
  107. package/dist/{scheduler-DZ3xQfeK.js → scheduler-FIHv2-kJ.js} +2 -4
  108. package/dist/scheduler-FIHv2-kJ.js.map +1 -0
  109. package/dist/schedules/index.d.ts +1 -1
  110. package/dist/schedules/index.js +1 -1
  111. package/dist/serializable.d.ts +1 -1
  112. package/dist/session-store-Do4xkDcf.js +606 -0
  113. package/dist/session-store-Do4xkDcf.js.map +1 -0
  114. package/dist/session-store-DoPY12xM.d.ts +383 -0
  115. package/dist/sessions/index.d.ts +1 -1
  116. package/dist/sessions/index.js +1 -1
  117. package/dist/{sessions-B9pNuxdT.js → sessions-_vN5BEZX.js} +2 -2
  118. package/dist/{sessions-B9pNuxdT.js.map → sessions-_vN5BEZX.js.map} +1 -1
  119. package/dist/{settings-C45hDliX.js → settings-BjAiPd6Z.js} +7 -4
  120. package/dist/settings-BjAiPd6Z.js.map +1 -0
  121. package/dist/{settings-NgGwF7Qt.d.ts → settings-DnD__xuE.d.ts} +22 -4
  122. package/dist/{src-DgCbZtIR.js → src-CQxJFv4l.js} +8 -8
  123. package/dist/src-CQxJFv4l.js.map +1 -0
  124. package/dist/state/index.d.ts +1 -1
  125. package/dist/state/index.js +1 -3
  126. package/dist/state/index.js.map +1 -1
  127. package/dist/{store-DLeqKuj3.d.ts → store-BKM4Xm9M.d.ts} +23 -1
  128. package/dist/{store-vgcPYo8K.js → store-CslVzfN7.js} +28 -2
  129. package/dist/store-CslVzfN7.js.map +1 -0
  130. package/dist/streams/index.d.ts +1 -1
  131. package/dist/streams/index.js +1 -1
  132. package/dist/{streams-CITClVer.js → streams-lsHMJhRW.js} +2 -2
  133. package/dist/{streams-CITClVer.js.map → streams-lsHMJhRW.js.map} +1 -1
  134. package/dist/{streams-fbG61qM8.d.ts → streams-vrCtbUIn.d.ts} +2 -2
  135. package/dist/sub-routing.d.ts +1 -1
  136. package/dist/tasks/index.d.ts +1 -1
  137. package/dist/tasks/index.js +1 -1
  138. package/dist/{tasks-CkTZNaV1.js → tasks-BN_5AWqI.js} +2 -2
  139. package/dist/{tasks-CkTZNaV1.js.map → tasks-BN_5AWqI.js.map} +1 -1
  140. package/dist/{tasks-PtlB4Uyn.d.ts → tasks-E89KdwkS.d.ts} +2 -2
  141. package/dist/{tool-BPJEbwaX.d.ts → tool-CTp72Jb_.d.ts} +4 -4
  142. package/dist/tool-CxKsvxjm.js +1126 -0
  143. package/dist/tool-CxKsvxjm.js.map +1 -0
  144. package/dist/tool-DoVberpN.d.ts +301 -0
  145. package/dist/{tool-3PA8xjB_.js → tool-VF0qiO7q.js} +7 -18
  146. package/dist/tool-VF0qiO7q.js.map +1 -0
  147. package/dist/tool-helpers-O5BDVEAY.js +58 -0
  148. package/dist/tool-helpers-O5BDVEAY.js.map +1 -0
  149. package/dist/{transport-k2mFrtL8.d.ts → transport-DCyarnwm.d.ts} +2 -2
  150. package/dist/voice/index.d.ts +2 -2
  151. package/dist/web/fetch/index.d.ts +89 -0
  152. package/dist/web/fetch/index.js +20 -0
  153. package/dist/web/fetch/index.js.map +1 -0
  154. package/dist/web/fetch/tools/ai-sdk.d.ts +80 -0
  155. package/dist/web/fetch/tools/ai-sdk.js +47 -0
  156. package/dist/web/fetch/tools/ai-sdk.js.map +1 -0
  157. package/dist/web/fetch/tools/pi.d.ts +84 -0
  158. package/dist/web/fetch/tools/pi.js +88 -0
  159. package/dist/web/fetch/tools/pi.js.map +1 -0
  160. package/dist/web/fetch/tools/tanstack-ai.d.ts +78 -0
  161. package/dist/web/fetch/tools/tanstack-ai.js +45 -0
  162. package/dist/web/fetch/tools/tanstack-ai.js.map +1 -0
  163. package/dist/{websearch → web/search}/index.d.ts +1 -1
  164. package/dist/{websearch → web/search}/index.js +1 -1
  165. package/dist/{websearch → web/search}/tools/ai-sdk.d.ts +2 -2
  166. package/dist/{websearch → web/search}/tools/ai-sdk.js +3 -3
  167. package/dist/web/search/tools/ai-sdk.js.map +1 -0
  168. package/dist/{websearch → web/search}/tools/pi.d.ts +3 -3
  169. package/dist/{websearch → web/search}/tools/pi.js +2 -2
  170. package/dist/web/search/tools/pi.js.map +1 -0
  171. package/dist/{websearch → web/search}/tools/tanstack-ai.d.ts +2 -2
  172. package/dist/{websearch → web/search}/tools/tanstack-ai.js +3 -3
  173. package/dist/web/search/tools/tanstack-ai.js.map +1 -0
  174. package/dist/websockets/index.d.ts +2 -2
  175. package/dist/websockets/index.js +1 -1
  176. package/dist/{websockets-CmENGb-Z.js → websockets-C3zy8YR0.js} +3 -5
  177. package/dist/websockets-C3zy8YR0.js.map +1 -0
  178. package/dist/workflow-types.d.ts +1 -1
  179. package/dist/workflows.d.ts +1 -1
  180. package/dist/workflows.js +1 -1
  181. package/docs/browse-the-web.md +26 -1
  182. package/docs/fetch-the-web.md +276 -0
  183. package/docs/harnesses/pi.md +25 -0
  184. package/docs/index.md +99 -76
  185. package/docs/lifecycle.md +2 -3
  186. package/docs/mcp-client.md +1 -1
  187. package/docs/mcp-servers.md +1 -1
  188. package/docs/models-pi-ai.md +11 -0
  189. package/docs/models.md +45 -3
  190. package/docs/queue.md +2 -3
  191. package/docs/scheduling.md +2 -6
  192. package/docs/search-the-web.md +2 -0
  193. package/package.json +52 -27
  194. package/dist/ai-fm7xx1BK.js +0 -312
  195. package/dist/ai-fm7xx1BK.js.map +0 -1
  196. package/dist/ai-sdk-OoGkFy3s.js.map +0 -1
  197. package/dist/browser/ai-sdk.js.map +0 -1
  198. package/dist/browser/index.js.map +0 -1
  199. package/dist/browser/tanstack-ai.js.map +0 -1
  200. package/dist/browser-tool-CBqs6hqa.js.map +0 -1
  201. package/dist/capability-B4WbF81e.js.map +0 -1
  202. package/dist/client-1tEQ1Oqz.js.map +0 -1
  203. package/dist/connector-58XDGvc3.js.map +0 -1
  204. package/dist/handler-stateless-VvrWSAVA.js.map +0 -1
  205. package/dist/images-Ce9SCu3X.js.map +0 -1
  206. package/dist/input-schema-DNrpTu49.js.map +0 -1
  207. package/dist/lifecycle-CFu6OV03.js.map +0 -1
  208. package/dist/scheduler-DZ3xQfeK.js.map +0 -1
  209. package/dist/settings-C45hDliX.js.map +0 -1
  210. package/dist/src-DgCbZtIR.js.map +0 -1
  211. package/dist/store-vgcPYo8K.js.map +0 -1
  212. package/dist/tool-3PA8xjB_.js.map +0 -1
  213. package/dist/websearch/tools/ai-sdk.js.map +0 -1
  214. package/dist/websearch/tools/pi.js.map +0 -1
  215. package/dist/websearch/tools/tanstack-ai.js.map +0 -1
  216. package/dist/websockets-CmENGb-Z.js.map +0 -1
@@ -1,11 +1,12 @@
1
1
  import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, r as _assertClassBrand, t as _classPrivateFieldGet2 } from "../../classPrivateFieldGet2-DZBYAB34.js";
2
2
  import { t as _classPrivateMethodInitSpec } from "../../classPrivateMethodInitSpec-qMjJ6sHQ.js";
3
- import { n as bindLifecycleCapability, t as LifecycleCapability } from "../../capability-B4WbF81e.js";
3
+ import { n as bindLifecycleCapability, t as LifecycleCapability } from "../../capability-DBAKc6UZ.js";
4
4
  import { n as STREAM_RESUME_NONE_REASONS, r as StreamAccumulator, t as CHAT_MESSAGE_TYPES } from "../../protocol-eXeJxhgu.js";
5
- import { n as Streams } from "../../streams-CITClVer.js";
5
+ import { n as Streams } from "../../streams-lsHMJhRW.js";
6
6
  import { i as createToolsFromClientSchemas, n as iterateWithStallWatchdog, r as parseProtocolMessage, t as ChatStreamStalledError } from "../../stall-watchdog-BpRF2uwG.js";
7
- import { t as Sessions } from "../../sessions-B9pNuxdT.js";
7
+ import { t as Sessions } from "../../sessions-_vN5BEZX.js";
8
8
  import { a as toTranscriptMessage, r as toResponseChunk, t as answerToolCall } from "../../turns-DCV3ycDl.js";
9
+ import { n as openHarnessStore } from "../../store-CslVzfN7.js";
9
10
  import { convertToModelMessages, stepCountIs, streamText, toUIMessageStream } from "ai";
10
11
  //#region src/harness/think/events.ts
11
12
  var _listeners = /* @__PURE__ */ new WeakMap();
@@ -111,193 +112,388 @@ async function _drain() {
111
112
  }
112
113
  //#endregion
113
114
  //#region src/harness/think/records.ts
114
- const STATUSES = /* @__PURE__ */ new Set([
115
- "queued",
116
- "running",
117
- "done",
118
- "unanswered"
119
- ]);
120
- function parseStatus(value) {
121
- if (!STATUSES.has(value)) throw new Error(`Unknown ThinkHarness operation status ${value}`);
115
+ /** The shared store's table prefix for ThinkHarness's records. */
116
+ const STORE_PREFIX = "cf_think_harness_store_";
117
+ /** The tables ThinkHarness kept its records in before the shared store. */
118
+ const LEGACY_SESSIONS = "cf_think_harness_sessions";
119
+ const LEGACY_OPERATIONS = "cf_think_harness_operations";
120
+ const LEGACY_TOOL_CALLS = "cf_think_harness_tool_calls";
121
+ const OPEN$1 = ["queued", "running"];
122
+ const EMPTY_STATE = {
123
+ clientTools: [],
124
+ toolCalls: {}
125
+ };
126
+ function isRecord$1(value) {
127
+ return typeof value === "object" && value !== null && !Array.isArray(value);
128
+ }
129
+ function stringOrNull(value) {
130
+ return typeof value === "string" ? value : null;
131
+ }
132
+ function count(value) {
133
+ return typeof value === "number" ? value : 0;
134
+ }
135
+ function parseMeta(value) {
136
+ const fields = isRecord$1(value) ? value : {};
137
+ return {
138
+ source: fields.source === "client" ? "client" : "server",
139
+ parentId: stringOrNull(fields.parentId),
140
+ messageId: stringOrNull(fields.messageId),
141
+ streamId: stringOrNull(fields.streamId),
142
+ pendingModel: fields.pendingModel === true,
143
+ steps: count(fields.steps),
144
+ interruptions: count(fields.interruptions),
145
+ overflowRetries: count(fields.overflowRetries),
146
+ abandonReason: stringOrNull(fields.abandonReason)
147
+ };
148
+ }
149
+ function newMeta(source) {
150
+ return {
151
+ source,
152
+ parentId: null,
153
+ messageId: null,
154
+ streamId: null,
155
+ pendingModel: false,
156
+ steps: 0,
157
+ interruptions: 0,
158
+ overflowRetries: 0,
159
+ abandonReason: null
160
+ };
161
+ }
162
+ function metaJson(meta) {
163
+ return { ...meta };
164
+ }
165
+ function withProgress(meta, change) {
166
+ return {
167
+ source: meta.source,
168
+ parentId: change.parentId === void 0 ? meta.parentId : change.parentId,
169
+ messageId: change.messageId === void 0 ? meta.messageId : change.messageId,
170
+ streamId: change.streamId === void 0 ? meta.streamId : change.streamId,
171
+ pendingModel: change.pendingModel ?? meta.pendingModel,
172
+ steps: change.steps ?? meta.steps,
173
+ interruptions: change.interruptions ?? meta.interruptions,
174
+ overflowRetries: change.overflowRetries ?? meta.overflowRetries,
175
+ abandonReason: change.abandonReason === void 0 ? meta.abandonReason : change.abandonReason
176
+ };
177
+ }
178
+ function inputJson(input) {
179
+ return input;
180
+ }
181
+ function parseInput(value) {
122
182
  return value;
123
183
  }
124
- function parseOperation(row) {
125
- const input = JSON.parse(row.input);
184
+ function parseText(result) {
185
+ return isRecord$1(result) && typeof result.text === "string" ? result.text : void 0;
186
+ }
187
+ function parseSessionState(value) {
188
+ if (!isRecord$1(value)) return EMPTY_STATE;
189
+ const toolCalls = Object.create(null);
190
+ const calls = value.toolCalls;
191
+ if (isRecord$1(calls)) {
192
+ for (const [toolCallId, call] of Object.entries(calls)) if (isRecord$1(call) && typeof call.operationId === "string" && typeof call.attempts === "number") toolCalls[toolCallId] = {
193
+ operationId: call.operationId,
194
+ attempts: call.attempts
195
+ };
196
+ }
126
197
  return {
127
- session: row.session_id,
128
- operationId: row.operation_id,
129
- seq: row.seq,
130
- input,
131
- status: parseStatus(row.status),
132
- source: row.source === "client" ? "client" : "server",
133
- parentId: row.parent_id ?? void 0,
134
- messageId: row.message_id ?? void 0,
135
- streamId: row.stream_id ?? void 0,
136
- pendingModel: row.pending_model === 1,
137
- steps: row.steps,
138
- interruptions: row.interruptions,
139
- overflowRetries: row.overflow_retries,
140
- reason: row.reason ?? void 0,
141
- text: row.text ?? void 0,
142
- abandonReason: row.abandon_reason ?? void 0,
143
- createdAt: row.created_at
198
+ clientTools: Array.isArray(value.clientTools) ? value.clientTools : [],
199
+ toolCalls
200
+ };
201
+ }
202
+ function sessionStateJson(state) {
203
+ return {
204
+ clientTools: state.clientTools,
205
+ toolCalls: { ...state.toolCalls }
144
206
  };
145
207
  }
146
- var _sql = /* @__PURE__ */ new WeakMap();
147
- var _ready = /* @__PURE__ */ new WeakMap();
208
+ function parseOperation(stored) {
209
+ const meta = parseMeta(stored.meta);
210
+ return {
211
+ session: stored.session,
212
+ operationId: stored.id,
213
+ seq: stored.seq,
214
+ input: parseInput(stored.input),
215
+ status: stored.status,
216
+ source: meta.source,
217
+ parentId: meta.parentId ?? void 0,
218
+ messageId: meta.messageId ?? void 0,
219
+ streamId: meta.streamId ?? void 0,
220
+ pendingModel: meta.pendingModel,
221
+ steps: meta.steps,
222
+ interruptions: meta.interruptions,
223
+ overflowRetries: meta.overflowRetries,
224
+ reason: stored.reason,
225
+ text: stored.status === "done" ? parseText(stored.result) : void 0,
226
+ abandonReason: meta.abandonReason ?? void 0,
227
+ createdAt: stored.createdAt
228
+ };
229
+ }
230
+ var _store = /* @__PURE__ */ new WeakMap();
231
+ var _OperationRecords_brand = /* @__PURE__ */ new WeakSet();
148
232
  /**
149
- * The harness's own tables, over the object's SQLite: sessions, the
150
- * operation queue, and started tool calls. Named apart from the shared
151
- * `agents/harness/store`, which is a different, harness-agnostic store.
233
+ * The harness's records, over the shared harness store: sessions, the
234
+ * operation queue, and started tool calls. Opening it moves records an
235
+ * earlier version left in its own tables into the store.
152
236
  */
153
237
  var OperationRecords = class {
154
- constructor(sql) {
155
- _classPrivateFieldInitSpec(this, _sql, void 0);
156
- _classPrivateFieldInitSpec(this, _ready, false);
157
- _classPrivateFieldSet2(_sql, this, sql);
158
- }
159
- /** Create the tables. Idempotent. */
160
- ensureTables() {
161
- if (_classPrivateFieldGet2(_ready, this)) return;
162
- _classPrivateFieldGet2(_sql, this).exec(`CREATE TABLE IF NOT EXISTS cf_think_harness_sessions (
163
- id TEXT PRIMARY KEY,
164
- parent TEXT,
165
- client_tools TEXT,
166
- created_at INTEGER NOT NULL
167
- )`);
168
- _classPrivateFieldGet2(_sql, this).exec(`CREATE TABLE IF NOT EXISTS cf_think_harness_operations (
169
- session_id TEXT NOT NULL,
170
- operation_id TEXT NOT NULL,
171
- seq INTEGER NOT NULL,
172
- input TEXT NOT NULL,
173
- status TEXT NOT NULL,
174
- source TEXT NOT NULL,
175
- parent_id TEXT,
176
- message_id TEXT,
177
- stream_id TEXT,
178
- pending_model INTEGER NOT NULL DEFAULT 0,
179
- steps INTEGER NOT NULL DEFAULT 0,
180
- interruptions INTEGER NOT NULL DEFAULT 0,
181
- overflow_retries INTEGER NOT NULL DEFAULT 0,
182
- reason TEXT,
183
- text TEXT,
184
- abandon_reason TEXT,
185
- created_at INTEGER NOT NULL,
186
- updated_at INTEGER NOT NULL,
187
- PRIMARY KEY (session_id, operation_id)
188
- )`);
189
- if (!new Set(_classPrivateFieldGet2(_sql, this).exec(`PRAGMA table_info(cf_think_harness_operations)`).toArray().map((column) => column.name)).has("abandon_reason")) _classPrivateFieldGet2(_sql, this).exec(`ALTER TABLE cf_think_harness_operations ADD COLUMN abandon_reason TEXT`);
190
- _classPrivateFieldGet2(_sql, this).exec(`CREATE INDEX IF NOT EXISTS cf_think_harness_operations_open
191
- ON cf_think_harness_operations (session_id, status, seq)`);
192
- _classPrivateFieldGet2(_sql, this).exec(`CREATE TABLE IF NOT EXISTS cf_think_harness_tool_calls (
193
- session_id TEXT NOT NULL,
194
- tool_call_id TEXT NOT NULL,
195
- operation_id TEXT NOT NULL,
196
- attempts INTEGER NOT NULL,
197
- PRIMARY KEY (session_id, tool_call_id)
198
- )`);
199
- _classPrivateFieldSet2(_ready, this, true);
200
- }
201
- /** Record a session, unless it exists. Returns whether it was new. */
238
+ /**
239
+ * Open the records, creating the store's tables and importing any legacy
240
+ * tables. Cheap after the first time: keep one per isolate.
241
+ *
242
+ * @param storage - The Durable Object's storage.
243
+ */
244
+ constructor(storage) {
245
+ _classPrivateMethodInitSpec(this, _OperationRecords_brand);
246
+ _classPrivateFieldInitSpec(this, _store, void 0);
247
+ _classPrivateFieldSet2(_store, this, openHarnessStore(storage, { prefix: STORE_PREFIX }));
248
+ importLegacyTables(storage, _classPrivateFieldGet2(_store, this));
249
+ }
250
+ /** Record a session, unless it exists. */
202
251
  ensureSession(id, parent) {
203
- return _classPrivateFieldGet2(_sql, this).exec(`INSERT OR IGNORE INTO cf_think_harness_sessions (id, parent, created_at)
204
- VALUES (?, ?, ?)`, id, parent ?? null, Date.now()).rowsWritten > 0;
252
+ _classPrivateFieldGet2(_store, this).createSession({
253
+ id,
254
+ ...parent !== void 0 && { parent },
255
+ state: sessionStateJson(EMPTY_STATE)
256
+ });
205
257
  }
206
258
  /** Every session, oldest first. */
207
259
  sessions() {
208
- return _classPrivateFieldGet2(_sql, this).exec(`SELECT id, parent, client_tools, created_at
209
- FROM cf_think_harness_sessions ORDER BY created_at, id`).toArray().map((row) => ({
210
- id: row.id,
211
- parent: row.parent ?? void 0,
212
- createdAt: row.created_at
260
+ return _classPrivateFieldGet2(_store, this).sessions().map((session) => ({
261
+ id: session.id,
262
+ parent: session.parent,
263
+ createdAt: session.createdAt
213
264
  }));
214
265
  }
215
266
  /** The client tools a session's client last declared. */
216
267
  clientTools(session) {
217
- const row = _classPrivateFieldGet2(_sql, this).exec(`SELECT client_tools FROM cf_think_harness_sessions WHERE id = ?`, session).toArray()[0];
218
- if (!row?.client_tools) return [];
219
- return JSON.parse(row.client_tools);
268
+ return [..._assertClassBrand(_OperationRecords_brand, this, _state).call(this, session).clientTools];
220
269
  }
221
270
  /** Replace the client tools a session's client declared. */
222
271
  setClientTools(session, tools) {
223
- _classPrivateFieldGet2(_sql, this).exec(`UPDATE cf_think_harness_sessions SET client_tools = ? WHERE id = ?`, JSON.stringify(tools), session);
272
+ _assertClassBrand(_OperationRecords_brand, this, _updateState).call(this, session, (state) => ({
273
+ ...state,
274
+ clientTools: tools
275
+ }));
224
276
  }
225
277
  /** Insert a queued operation. Returns false when the id already exists. */
226
278
  insert(session, operationId, input, source) {
227
- const now = Date.now();
228
- return _classPrivateFieldGet2(_sql, this).exec(`INSERT OR IGNORE INTO cf_think_harness_operations
229
- (session_id, operation_id, seq, input, status, source, created_at, updated_at)
230
- VALUES (?, ?,
231
- (SELECT COALESCE(MAX(seq), 0) + 1 FROM cf_think_harness_operations),
232
- ?, 'queued', ?, ?, ?)`, session, operationId, JSON.stringify(input), source, now, now).rowsWritten > 0;
279
+ return _classPrivateFieldGet2(_store, this).enqueue({
280
+ session,
281
+ id: operationId,
282
+ input: inputJson(input),
283
+ meta: metaJson(newMeta(source))
284
+ }).accepted;
233
285
  }
234
286
  /** One operation. */
235
287
  get(session, operationId) {
236
- const row = _classPrivateFieldGet2(_sql, this).exec(`SELECT * FROM cf_think_harness_operations
237
- WHERE session_id = ? AND operation_id = ?`, session, operationId).toArray()[0];
238
- return row ? parseOperation(row) : void 0;
288
+ const stored = _classPrivateFieldGet2(_store, this).operation(session, operationId);
289
+ return stored ? parseOperation(stored) : void 0;
239
290
  }
240
291
  /** Unsettled operations, oldest first; every session when none is given. */
241
292
  open(session) {
242
- return (session === void 0 ? _classPrivateFieldGet2(_sql, this).exec(`SELECT * FROM cf_think_harness_operations
243
- WHERE status IN ('queued', 'running') ORDER BY seq`) : _classPrivateFieldGet2(_sql, this).exec(`SELECT * FROM cf_think_harness_operations
244
- WHERE session_id = ? AND status IN ('queued', 'running')
245
- ORDER BY seq`, session)).toArray().map(parseOperation);
293
+ return _classPrivateFieldGet2(_store, this).operations({
294
+ ...session !== void 0 && { session },
295
+ status: OPEN$1
296
+ }).map(parseOperation);
246
297
  }
247
- /** Apply a change to an operation's fields. */
298
+ /** Change an operation's progress. */
248
299
  update(session, operationId, change) {
249
- const sets = [];
250
- const values = [];
251
- const set = (column, value) => {
252
- sets.push(`${column} = ?`);
253
- values.push(value);
254
- };
255
- if (change.status !== void 0) set("status", change.status);
256
- if (change.parentId !== void 0) set("parent_id", change.parentId);
257
- if (change.messageId !== void 0) set("message_id", change.messageId);
258
- if (change.streamId !== void 0) set("stream_id", change.streamId);
259
- if (change.pendingModel !== void 0) set("pending_model", change.pendingModel ? 1 : 0);
260
- if (change.steps !== void 0) set("steps", change.steps);
261
- if (change.interruptions !== void 0) set("interruptions", change.interruptions);
262
- if (change.overflowRetries !== void 0) set("overflow_retries", change.overflowRetries);
263
- if (change.reason !== void 0) set("reason", change.reason);
264
- if (change.text !== void 0) set("text", change.text);
265
- if (change.abandonReason !== void 0) set("abandon_reason", change.abandonReason);
266
- set("updated_at", Date.now());
267
- _classPrivateFieldGet2(_sql, this).exec(`UPDATE cf_think_harness_operations SET ${sets.join(", ")}
268
- WHERE session_id = ? AND operation_id = ?`, ...values, session, operationId);
300
+ _classPrivateFieldGet2(_store, this).transaction(() => {
301
+ const stored = _classPrivateFieldGet2(_store, this).operation(session, operationId);
302
+ if (!stored) return;
303
+ _classPrivateFieldGet2(_store, this).setOperationMeta(session, operationId, metaJson(withProgress(parseMeta(stored.meta), change)));
304
+ });
305
+ }
306
+ /**
307
+ * Move a queued operation to running, with its progress so far.
308
+ * Returns false when it was not queued.
309
+ */
310
+ start(session, operationId, change) {
311
+ return _classPrivateFieldGet2(_store, this).transaction(() => {
312
+ if (!_classPrivateFieldGet2(_store, this).start(session, operationId)) return false;
313
+ this.update(session, operationId, change);
314
+ return true;
315
+ });
316
+ }
317
+ /**
318
+ * Settle an open operation, with a last change to its progress. Returns
319
+ * false when it had already settled.
320
+ */
321
+ settle(session, operationId, outcome, change = {}) {
322
+ return _classPrivateFieldGet2(_store, this).transaction(() => {
323
+ const settled = _classPrivateFieldGet2(_store, this).settle(session, operationId, outcome.status === "done" ? {
324
+ status: "done",
325
+ result: { text: outcome.text }
326
+ } : outcome);
327
+ if (settled) this.update(session, operationId, change);
328
+ return settled;
329
+ });
269
330
  }
270
331
  /** Forget every settled operation in a session, for a reset. */
271
332
  deleteSettled(session) {
272
- _classPrivateFieldGet2(_sql, this).exec(`DELETE FROM cf_think_harness_operations
273
- WHERE session_id = ? AND status IN ('done', 'unanswered')`, session);
274
- _classPrivateFieldGet2(_sql, this).exec(`DELETE FROM cf_think_harness_tool_calls WHERE session_id = ?`, session);
333
+ _classPrivateFieldGet2(_store, this).transaction(() => {
334
+ _classPrivateFieldGet2(_store, this).deleteSettled(session);
335
+ _assertClassBrand(_OperationRecords_brand, this, _updateState).call(this, session, (state) => ({
336
+ ...state,
337
+ toolCalls: {}
338
+ }));
339
+ });
275
340
  }
276
341
  /** The record of a started tool call, if it was started. */
277
342
  toolCall(session, toolCallId) {
278
- const row = _classPrivateFieldGet2(_sql, this).exec(`SELECT * FROM cf_think_harness_tool_calls
279
- WHERE session_id = ? AND tool_call_id = ?`, session, toolCallId).toArray()[0];
280
- return row ? {
281
- session: row.session_id,
282
- toolCallId: row.tool_call_id,
283
- operationId: row.operation_id,
284
- attempts: row.attempts
285
- } : void 0;
343
+ const { toolCalls } = _assertClassBrand(_OperationRecords_brand, this, _state).call(this, session);
344
+ if (!Object.hasOwn(toolCalls, toolCallId)) return void 0;
345
+ const call = toolCalls[toolCallId];
346
+ return call && {
347
+ session,
348
+ toolCallId,
349
+ ...call
350
+ };
286
351
  }
287
352
  /** Record that a tool call is starting. Returns the attempt number. */
288
353
  startToolCall(session, toolCallId, operationId) {
289
354
  const attempts = (this.toolCall(session, toolCallId)?.attempts ?? 0) + 1;
290
- _classPrivateFieldGet2(_sql, this).exec(`INSERT OR REPLACE INTO cf_think_harness_tool_calls
291
- (session_id, tool_call_id, operation_id, attempts)
292
- VALUES (?, ?, ?, ?)`, session, toolCallId, operationId, attempts);
355
+ _assertClassBrand(_OperationRecords_brand, this, _updateState).call(this, session, (state) => ({
356
+ ...state,
357
+ toolCalls: {
358
+ ...state.toolCalls,
359
+ [toolCallId]: {
360
+ operationId,
361
+ attempts
362
+ }
363
+ }
364
+ }));
293
365
  return attempts;
294
366
  }
295
367
  /** Forget a tool call once its result is in the transcript. */
296
368
  finishToolCall(session, toolCallId) {
297
- _classPrivateFieldGet2(_sql, this).exec(`DELETE FROM cf_think_harness_tool_calls
298
- WHERE session_id = ? AND tool_call_id = ?`, session, toolCallId);
369
+ _assertClassBrand(_OperationRecords_brand, this, _updateState).call(this, session, (state) => {
370
+ const { [toolCallId]: _finished, ...toolCalls } = state.toolCalls;
371
+ return {
372
+ ...state,
373
+ toolCalls
374
+ };
375
+ });
299
376
  }
300
377
  };
378
+ function _state(session) {
379
+ return parseSessionState(_classPrivateFieldGet2(_store, this).session(session)?.state);
380
+ }
381
+ function _updateState(session, change) {
382
+ _classPrivateFieldGet2(_store, this).transaction(() => {
383
+ const stored = _classPrivateFieldGet2(_store, this).session(session);
384
+ if (!stored) return;
385
+ _classPrivateFieldGet2(_store, this).setSessionState(session, sessionStateJson(change(parseSessionState(stored.state))));
386
+ });
387
+ }
388
+ function parseJsonColumn(text) {
389
+ return JSON.parse(text);
390
+ }
391
+ /**
392
+ * Move the records an earlier version kept in its own tables into the
393
+ * store, then drop those tables, in one transaction: either every record
394
+ * moves or none does and the next start tries again. Operations keep their
395
+ * order, status and progress; sessions keep their creation time, client
396
+ * tools and started tool calls, so an operation that was in flight resumes
397
+ * and recovers as it would have.
398
+ */
399
+ function importLegacyTables(storage, store) {
400
+ const sql = storage.sql;
401
+ const present = new Set(sql.exec(`SELECT name FROM sqlite_master WHERE type = 'table' AND name IN (?, ?, ?)`, LEGACY_SESSIONS, LEGACY_OPERATIONS, LEGACY_TOOL_CALLS).toArray().map((row) => row.name));
402
+ if (present.size === 0) return;
403
+ storage.transactionSync(() => {
404
+ const states = /* @__PURE__ */ new Map();
405
+ if (present.has(LEGACY_SESSIONS)) {
406
+ const rows = sql.exec(`SELECT id, parent, client_tools, created_at FROM ${LEGACY_SESSIONS}
407
+ ORDER BY created_at, id`).toArray();
408
+ for (const row of rows) {
409
+ store.createSession({
410
+ id: row.id,
411
+ ...row.parent !== null && { parent: row.parent },
412
+ createdAt: row.created_at
413
+ });
414
+ states.set(row.id, parseSessionState({
415
+ clientTools: row.client_tools === null ? [] : parseJsonColumn(row.client_tools),
416
+ toolCalls: {}
417
+ }));
418
+ }
419
+ }
420
+ if (present.has(LEGACY_TOOL_CALLS)) {
421
+ const rows = sql.exec(`SELECT session_id, tool_call_id, operation_id, attempts
422
+ FROM ${LEGACY_TOOL_CALLS}`).toArray();
423
+ for (const row of rows) {
424
+ const state = states.get(row.session_id) ?? EMPTY_STATE;
425
+ states.set(row.session_id, {
426
+ ...state,
427
+ toolCalls: {
428
+ ...state.toolCalls,
429
+ [row.tool_call_id]: {
430
+ operationId: row.operation_id,
431
+ attempts: row.attempts
432
+ }
433
+ }
434
+ });
435
+ }
436
+ }
437
+ for (const [id, state] of states) {
438
+ store.createSession({ id });
439
+ store.setSessionState(id, sessionStateJson(state));
440
+ }
441
+ if (present.has(LEGACY_OPERATIONS)) {
442
+ const rows = sql.exec(`SELECT * FROM ${LEGACY_OPERATIONS} ORDER BY seq`).toArray();
443
+ for (const row of rows) importLegacyOperation(store, row);
444
+ }
445
+ for (const table of [
446
+ LEGACY_SESSIONS,
447
+ LEGACY_OPERATIONS,
448
+ LEGACY_TOOL_CALLS
449
+ ]) sql.exec(`DROP TABLE IF EXISTS ${table}`);
450
+ });
451
+ }
452
+ function importLegacyOperation(store, row) {
453
+ const session = row.session_id;
454
+ const id = row.operation_id;
455
+ if (!store.session(session)) store.createSession({
456
+ id: session,
457
+ state: sessionStateJson(EMPTY_STATE)
458
+ });
459
+ const meta = {
460
+ source: row.source === "client" ? "client" : "server",
461
+ parentId: row.parent_id,
462
+ messageId: row.message_id,
463
+ streamId: row.stream_id,
464
+ pendingModel: row.pending_model === 1,
465
+ steps: row.steps,
466
+ interruptions: row.interruptions,
467
+ overflowRetries: row.overflow_retries,
468
+ abandonReason: row.abandon_reason ?? null
469
+ };
470
+ store.deleteOperation(session, id);
471
+ store.enqueue({
472
+ session,
473
+ id,
474
+ input: parseJsonColumn(row.input),
475
+ meta: metaJson(meta)
476
+ });
477
+ switch (row.status) {
478
+ case "queued": return;
479
+ case "running":
480
+ store.start(session, id);
481
+ return;
482
+ case "done":
483
+ store.settle(session, id, {
484
+ status: "done",
485
+ result: { text: row.text ?? "" }
486
+ });
487
+ return;
488
+ case "unanswered":
489
+ store.settle(session, id, {
490
+ status: "unanswered",
491
+ reason: row.reason ?? "unanswered"
492
+ });
493
+ return;
494
+ default: throw new Error(`Unknown ThinkHarness operation status ${row.status} in ${LEGACY_OPERATIONS}`);
495
+ }
496
+ }
301
497
  //#endregion
302
498
  //#region src/harness/think/tools.ts
303
499
  /** The model-facing copy of a tool set, restricted to `activeTools` if given. */
@@ -753,7 +949,7 @@ var ThinkHarness = class extends LifecycleCapability {
753
949
  const live = _classPrivateFieldGet2(_live, this).get(session);
754
950
  if (live?.operationId === op.operationId) live.abort.abort();
755
951
  else if (op.status === "queued") {
756
- store.update(session, op.operationId, {
952
+ store.settle(session, op.operationId, {
757
953
  status: "unanswered",
758
954
  reason: "withdrawn"
759
955
  });
@@ -1081,7 +1277,7 @@ async function _steps(session, operationId, live) {
1081
1277
  case "await-input":
1082
1278
  case "end":
1083
1279
  await _assertClassBrand(_ThinkHarness_brand, this, _commit).call(this, session, void 0, () => {
1084
- _assertClassBrand(_ThinkHarness_brand, this, _tables).call(this).update(session, operationId, {
1280
+ _assertClassBrand(_ThinkHarness_brand, this, _tables).call(this).settle(session, operationId, {
1085
1281
  status: "done",
1086
1282
  text: textOf(message)
1087
1283
  });
@@ -1104,8 +1300,7 @@ async function _place(op) {
1104
1300
  const placed = [];
1105
1301
  let settledText;
1106
1302
  let unanswered;
1107
- const running = (change) => store.update(session, operationId, {
1108
- status: "running",
1303
+ const running = (change) => store.start(session, operationId, {
1109
1304
  parentId: change.parentId ?? null,
1110
1305
  messageId: change.messageId,
1111
1306
  pendingModel: true
@@ -1170,7 +1365,7 @@ async function _place(op) {
1170
1365
  put(answered);
1171
1366
  placed.push(answered);
1172
1367
  if (continues) running({ messageId: answered.id });
1173
- else store.update(session, operationId, {
1368
+ else store.settle(session, operationId, {
1174
1369
  status: "done",
1175
1370
  text: textOf(answered)
1176
1371
  });
@@ -1210,7 +1405,7 @@ async function _place(op) {
1210
1405
  operationId
1211
1406
  });
1212
1407
  if (unanswered !== void 0) {
1213
- store.update(session, operationId, {
1408
+ store.settle(session, operationId, {
1214
1409
  status: "unanswered",
1215
1410
  reason: unanswered
1216
1411
  });
@@ -1350,11 +1545,10 @@ async function _callModel(op, existing, tools, live) {
1350
1545
  if (live.abort.signal.aborted) {
1351
1546
  await _assertClassBrand(_ThinkHarness_brand, this, _commit).call(this, session, streamId, (put) => {
1352
1547
  if (keep) put(keep, { parentId: op.parentId });
1353
- _assertClassBrand(_ThinkHarness_brand, this, _tables).call(this).update(session, operationId, {
1548
+ _assertClassBrand(_ThinkHarness_brand, this, _tables).call(this).settle(session, operationId, {
1354
1549
  status: "unanswered",
1355
- reason: "aborted",
1356
- streamId: null
1357
- });
1550
+ reason: "aborted"
1551
+ }, { streamId: null });
1358
1552
  });
1359
1553
  await _assertClassBrand(_ThinkHarness_brand, this, _settled).call(this, session, operationId, keep);
1360
1554
  return {};
@@ -1387,11 +1581,10 @@ async function _callModel(op, existing, tools, live) {
1387
1581
  if (kind === "retry") return _assertClassBrand(_ThinkHarness_brand, this, _interrupted).call(this, op, streamId, keep);
1388
1582
  await _assertClassBrand(_ThinkHarness_brand, this, _commit).call(this, session, streamId, (put) => {
1389
1583
  if (keep) put(keep, { parentId: op.parentId });
1390
- _assertClassBrand(_ThinkHarness_brand, this, _tables).call(this).update(session, operationId, {
1584
+ _assertClassBrand(_ThinkHarness_brand, this, _tables).call(this).settle(session, operationId, {
1391
1585
  status: "unanswered",
1392
- reason: errorText(failure),
1393
- streamId: null
1394
- });
1586
+ reason: errorText(failure)
1587
+ }, { streamId: null });
1395
1588
  });
1396
1589
  await _assertClassBrand(_ThinkHarness_brand, this, _settled).call(this, session, operationId, keep);
1397
1590
  return {};
@@ -1449,14 +1642,15 @@ async function _interrupted(op, streamId, partial) {
1449
1642
  });
1450
1643
  await _assertClassBrand(_ThinkHarness_brand, this, _commit).call(this, session, streamId, (put) => {
1451
1644
  if (partial) put(partial, { parentId: op.parentId });
1452
- _assertClassBrand(_ThinkHarness_brand, this, _tables).call(this).update(session, operationId, {
1645
+ const progress = {
1453
1646
  streamId: null,
1454
- interruptions: attempt,
1455
- ...decision === "abandon" && {
1456
- status: "unanswered",
1457
- reason: "interrupted"
1458
- }
1459
- });
1647
+ interruptions: attempt
1648
+ };
1649
+ if (decision === "abandon") _assertClassBrand(_ThinkHarness_brand, this, _tables).call(this).settle(session, operationId, {
1650
+ status: "unanswered",
1651
+ reason: "interrupted"
1652
+ }, progress);
1653
+ else _assertClassBrand(_ThinkHarness_brand, this, _tables).call(this).update(session, operationId, progress);
1460
1654
  });
1461
1655
  if (partial) _classPrivateFieldGet2(_events, this).emit(session, {
1462
1656
  type: "message",
@@ -1629,11 +1823,10 @@ async function _abandon(op, reason) {
1629
1823
  const keep = message && hasContent(message) && message !== existing ? message : void 0;
1630
1824
  await _assertClassBrand(_ThinkHarness_brand, this, _commit).call(this, session, op.streamId, (put) => {
1631
1825
  if (keep) put(keep, { parentId: op.parentId });
1632
- _assertClassBrand(_ThinkHarness_brand, this, _tables).call(this).update(session, operationId, {
1826
+ _assertClassBrand(_ThinkHarness_brand, this, _tables).call(this).settle(session, operationId, {
1633
1827
  status: "unanswered",
1634
- reason,
1635
- streamId: null
1636
- });
1828
+ reason
1829
+ }, { streamId: null });
1637
1830
  });
1638
1831
  if (keep) _classPrivateFieldGet2(_events, this).emit(session, {
1639
1832
  type: "message",
@@ -1687,8 +1880,7 @@ function _result(op) {
1687
1880
  };
1688
1881
  }
1689
1882
  function _tables() {
1690
- _classPrivateFieldGet2(_records, this) ?? _classPrivateFieldSet2(_records, this, new OperationRecords(this.lifecycle.storage.sql));
1691
- _classPrivateFieldGet2(_records, this).ensureTables();
1883
+ _classPrivateFieldGet2(_records, this) ?? _classPrivateFieldSet2(_records, this, new OperationRecords(this.lifecycle.storage));
1692
1884
  return _classPrivateFieldGet2(_records, this);
1693
1885
  }
1694
1886
  /** The Sessions handle for a session, configured on first use. */