@agentshouse/mdruntime 0.1.0-cd3486bd400ed → 0.1.0-cd35ccee27a19

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 (343) hide show
  1. package/README.md +22 -10
  2. package/dist/acceptance.d.ts +3 -0
  3. package/dist/acceptance.d.ts.map +1 -0
  4. package/dist/acceptance.js +308 -0
  5. package/dist/actions.d.ts +20 -0
  6. package/dist/actions.d.ts.map +1 -0
  7. package/dist/actions.js +251 -0
  8. package/dist/adapter.d.ts +195 -91
  9. package/dist/adapter.d.ts.map +1 -1
  10. package/dist/attached-model.d.ts +7 -10
  11. package/dist/attached-model.d.ts.map +1 -1
  12. package/dist/attached-model.js +40 -41
  13. package/dist/attempt.d.ts.map +1 -1
  14. package/dist/attempt.js +14 -1
  15. package/dist/binary.d.ts +18 -0
  16. package/dist/binary.d.ts.map +1 -0
  17. package/dist/binary.js +8 -0
  18. package/dist/bootstrap.d.ts +31 -11
  19. package/dist/bootstrap.d.ts.map +1 -1
  20. package/dist/bootstrap.js +311 -92
  21. package/dist/cell.d.ts +6 -0
  22. package/dist/cell.d.ts.map +1 -0
  23. package/dist/cell.js +9 -0
  24. package/dist/chain.d.ts +12 -0
  25. package/dist/chain.d.ts.map +1 -0
  26. package/dist/chain.js +64 -0
  27. package/dist/change-set.d.ts +13 -14
  28. package/dist/change-set.d.ts.map +1 -1
  29. package/dist/change-set.js +17 -62
  30. package/dist/change.d.ts +42 -0
  31. package/dist/change.d.ts.map +1 -1
  32. package/dist/change.js +36 -0
  33. package/dist/chat-types.d.ts +5 -0
  34. package/dist/chat-types.d.ts.map +1 -0
  35. package/dist/chat-types.js +13 -0
  36. package/dist/client.d.ts +49 -21
  37. package/dist/client.d.ts.map +1 -1
  38. package/dist/client.js +131 -17
  39. package/dist/collection.d.ts +31 -9
  40. package/dist/collection.d.ts.map +1 -1
  41. package/dist/collection.js +49 -80
  42. package/dist/compile.d.ts +16 -0
  43. package/dist/compile.d.ts.map +1 -0
  44. package/dist/compile.js +711 -0
  45. package/dist/connection.d.ts +8 -111
  46. package/dist/connection.d.ts.map +1 -1
  47. package/dist/connection.js +107 -2218
  48. package/dist/context.d.ts +2 -0
  49. package/dist/context.d.ts.map +1 -0
  50. package/dist/context.js +7 -0
  51. package/dist/conversation-live.d.ts +136 -0
  52. package/dist/conversation-live.d.ts.map +1 -0
  53. package/dist/conversation-live.js +249 -0
  54. package/dist/conversation-row.d.ts +33 -0
  55. package/dist/conversation-row.d.ts.map +1 -0
  56. package/dist/conversation-row.js +53 -0
  57. package/dist/conversation.d.ts +71 -42
  58. package/dist/conversation.d.ts.map +1 -1
  59. package/dist/conversation.js +1068 -586
  60. package/dist/declaration.d.ts +10 -0
  61. package/dist/declaration.d.ts.map +1 -0
  62. package/dist/declaration.js +24 -0
  63. package/dist/digest.d.ts +7 -0
  64. package/dist/digest.d.ts.map +1 -0
  65. package/dist/digest.js +113 -0
  66. package/dist/discovery.d.ts +10 -0
  67. package/dist/discovery.d.ts.map +1 -0
  68. package/dist/discovery.js +148 -0
  69. package/dist/durability.d.ts +19 -1
  70. package/dist/durability.d.ts.map +1 -1
  71. package/dist/durability.js +5 -0
  72. package/dist/entry.d.ts +20 -0
  73. package/dist/entry.d.ts.map +1 -0
  74. package/dist/entry.js +161 -0
  75. package/dist/expectation.d.ts +4 -2
  76. package/dist/expectation.d.ts.map +1 -1
  77. package/dist/expectation.js +33 -11
  78. package/dist/failure.d.ts +1 -0
  79. package/dist/failure.d.ts.map +1 -1
  80. package/dist/failure.js +3 -0
  81. package/dist/figures.d.ts +49 -0
  82. package/dist/figures.d.ts.map +1 -0
  83. package/dist/figures.js +197 -0
  84. package/dist/file.d.ts +2 -19
  85. package/dist/file.d.ts.map +1 -1
  86. package/dist/file.js +7 -122
  87. package/dist/holdings.d.ts +29 -0
  88. package/dist/holdings.d.ts.map +1 -0
  89. package/dist/holdings.js +95 -0
  90. package/dist/host.d.ts +28 -4
  91. package/dist/host.d.ts.map +1 -1
  92. package/dist/host.js +163 -19
  93. package/dist/identity.d.ts +1 -0
  94. package/dist/identity.d.ts.map +1 -1
  95. package/dist/identity.js +3 -0
  96. package/dist/index.d.ts +37 -10
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +15 -0
  99. package/dist/install.d.ts +54 -0
  100. package/dist/install.d.ts.map +1 -0
  101. package/dist/install.js +538 -0
  102. package/dist/lifecycle.d.ts +7 -0
  103. package/dist/lifecycle.d.ts.map +1 -0
  104. package/dist/lifecycle.js +272 -0
  105. package/dist/listing.d.ts +48 -0
  106. package/dist/listing.d.ts.map +1 -0
  107. package/dist/listing.js +139 -0
  108. package/dist/live.d.ts +23 -0
  109. package/dist/live.d.ts.map +1 -0
  110. package/dist/live.js +165 -0
  111. package/dist/locks.d.ts +7 -0
  112. package/dist/locks.d.ts.map +1 -0
  113. package/dist/locks.js +33 -0
  114. package/dist/log.d.ts +1 -0
  115. package/dist/log.d.ts.map +1 -1
  116. package/dist/lost.d.ts +5 -0
  117. package/dist/lost.d.ts.map +1 -0
  118. package/dist/lost.js +50 -0
  119. package/dist/media.d.ts +8 -0
  120. package/dist/media.d.ts.map +1 -0
  121. package/dist/media.js +218 -0
  122. package/dist/memory.d.ts +24 -8
  123. package/dist/memory.d.ts.map +1 -1
  124. package/dist/memory.js +289 -96
  125. package/dist/messages.d.ts +49 -0
  126. package/dist/messages.d.ts.map +1 -0
  127. package/dist/messages.js +150 -0
  128. package/dist/model.d.ts +11 -12
  129. package/dist/model.d.ts.map +1 -1
  130. package/dist/model.js +7 -15
  131. package/dist/models.d.ts +10 -0
  132. package/dist/models.d.ts.map +1 -0
  133. package/dist/models.js +156 -0
  134. package/dist/name.d.ts +4 -0
  135. package/dist/name.d.ts.map +1 -0
  136. package/dist/name.js +122 -0
  137. package/dist/observation.d.ts +22 -4
  138. package/dist/observation.d.ts.map +1 -1
  139. package/dist/observation.js +127 -26
  140. package/dist/opened.d.ts +22 -0
  141. package/dist/opened.d.ts.map +1 -0
  142. package/dist/opened.js +107 -0
  143. package/dist/opening.d.ts +4 -0
  144. package/dist/opening.d.ts.map +1 -0
  145. package/dist/opening.js +59 -0
  146. package/dist/outcome.d.ts +56 -5
  147. package/dist/outcome.d.ts.map +1 -1
  148. package/dist/outcome.js +49 -0
  149. package/dist/overlay.d.ts +17 -5
  150. package/dist/overlay.d.ts.map +1 -1
  151. package/dist/overlay.js +161 -187
  152. package/dist/page-metadata.d.ts +8 -0
  153. package/dist/page-metadata.d.ts.map +1 -0
  154. package/dist/page-metadata.js +19 -0
  155. package/dist/parts.d.ts +11 -0
  156. package/dist/parts.d.ts.map +1 -0
  157. package/dist/parts.js +21 -0
  158. package/dist/paths.d.ts +2 -0
  159. package/dist/paths.d.ts.map +1 -1
  160. package/dist/paths.js +26 -0
  161. package/dist/preparation.d.ts +20 -0
  162. package/dist/preparation.d.ts.map +1 -0
  163. package/dist/preparation.js +233 -0
  164. package/dist/presence.d.ts +52 -0
  165. package/dist/presence.d.ts.map +1 -0
  166. package/dist/presence.js +220 -0
  167. package/dist/queries.d.ts +16 -0
  168. package/dist/queries.d.ts.map +1 -0
  169. package/dist/queries.js +270 -0
  170. package/dist/query.d.ts +51 -183
  171. package/dist/query.d.ts.map +1 -1
  172. package/dist/query.js +3 -464
  173. package/dist/{chat/questions.d.ts → questions.d.ts} +5 -2
  174. package/dist/questions.d.ts.map +1 -0
  175. package/dist/{chat/questions.js → questions.js} +13 -2
  176. package/dist/queue.d.ts +40 -0
  177. package/dist/queue.d.ts.map +1 -0
  178. package/dist/queue.js +455 -0
  179. package/dist/reach.d.ts +21 -5
  180. package/dist/reach.d.ts.map +1 -1
  181. package/dist/reach.js +313 -72
  182. package/dist/react.d.ts +20 -6
  183. package/dist/react.d.ts.map +1 -1
  184. package/dist/react.js +17 -18
  185. package/dist/{chat/read.d.ts → read.d.ts} +2 -0
  186. package/dist/read.d.ts.map +1 -0
  187. package/dist/{chat/read.js → read.js} +4 -0
  188. package/dist/readiness.d.ts +49 -0
  189. package/dist/readiness.d.ts.map +1 -0
  190. package/dist/readiness.js +27 -0
  191. package/dist/reads.d.ts +37 -0
  192. package/dist/reads.d.ts.map +1 -0
  193. package/dist/reads.js +174 -0
  194. package/dist/recovery.d.ts +26 -0
  195. package/dist/recovery.d.ts.map +1 -0
  196. package/dist/recovery.js +232 -0
  197. package/dist/refresh.d.ts +17 -14
  198. package/dist/refresh.d.ts.map +1 -1
  199. package/dist/refresh.js +145 -58
  200. package/dist/refusal.d.ts +5 -0
  201. package/dist/refusal.d.ts.map +1 -0
  202. package/dist/refusal.js +57 -0
  203. package/dist/replica.d.ts +53 -33
  204. package/dist/replica.d.ts.map +1 -1
  205. package/dist/replica.js +348 -166
  206. package/dist/room-draft.d.ts +55 -9
  207. package/dist/room-draft.d.ts.map +1 -1
  208. package/dist/room-draft.js +262 -73
  209. package/dist/room-drafts.d.ts +24 -0
  210. package/dist/room-drafts.d.ts.map +1 -0
  211. package/dist/room-drafts.js +217 -0
  212. package/dist/rows.d.ts +30 -35
  213. package/dist/rows.d.ts.map +1 -1
  214. package/dist/rows.js +60 -126
  215. package/dist/runtime.d.ts +34 -0
  216. package/dist/runtime.d.ts.map +1 -0
  217. package/dist/runtime.js +1 -0
  218. package/dist/save.d.ts +44 -22
  219. package/dist/save.d.ts.map +1 -1
  220. package/dist/save.js +950 -169
  221. package/dist/saves.d.ts +32 -0
  222. package/dist/saves.d.ts.map +1 -0
  223. package/dist/saves.js +413 -0
  224. package/dist/search.d.ts +15 -55
  225. package/dist/search.d.ts.map +1 -1
  226. package/dist/search.js +10 -121
  227. package/dist/seed.d.ts +25 -0
  228. package/dist/seed.d.ts.map +1 -0
  229. package/dist/seed.js +145 -0
  230. package/dist/shared.d.ts +10 -0
  231. package/dist/shared.d.ts.map +1 -0
  232. package/dist/shared.js +339 -0
  233. package/dist/shown.d.ts +32 -0
  234. package/dist/shown.d.ts.map +1 -0
  235. package/dist/shown.js +290 -0
  236. package/dist/socket/admission.d.ts +7 -0
  237. package/dist/socket/admission.d.ts.map +1 -0
  238. package/dist/socket/admission.js +39 -0
  239. package/dist/socket/answers.d.ts +6 -0
  240. package/dist/socket/answers.d.ts.map +1 -0
  241. package/dist/socket/answers.js +20 -0
  242. package/dist/socket/lanes.d.ts +20 -0
  243. package/dist/socket/lanes.d.ts.map +1 -0
  244. package/dist/socket/lanes.js +77 -0
  245. package/dist/socket/reads.d.ts +10 -0
  246. package/dist/socket/reads.d.ts.map +1 -0
  247. package/dist/socket/reads.js +31 -0
  248. package/dist/socket/session.d.ts +38 -0
  249. package/dist/socket/session.d.ts.map +1 -0
  250. package/dist/socket/session.js +23 -0
  251. package/dist/socket.d.ts +67 -0
  252. package/dist/socket.d.ts.map +1 -0
  253. package/dist/socket.js +170 -0
  254. package/dist/source.d.ts +61 -0
  255. package/dist/source.d.ts.map +1 -0
  256. package/dist/source.js +82 -0
  257. package/dist/status.d.ts +5 -2
  258. package/dist/status.d.ts.map +1 -1
  259. package/dist/status.js +3 -7
  260. package/dist/store/installs.d.ts +30 -0
  261. package/dist/store/installs.d.ts.map +1 -0
  262. package/dist/store/installs.js +34 -0
  263. package/dist/store/readiness.d.ts +10 -0
  264. package/dist/store/readiness.d.ts.map +1 -0
  265. package/dist/store/readiness.js +52 -0
  266. package/dist/store/records.d.ts +212 -0
  267. package/dist/store/records.d.ts.map +1 -0
  268. package/dist/store/records.js +430 -0
  269. package/dist/store/room-held.d.ts +8 -0
  270. package/dist/store/room-held.d.ts.map +1 -0
  271. package/dist/store/room-held.js +17 -0
  272. package/dist/store/space.d.ts +11 -0
  273. package/dist/store/space.d.ts.map +1 -0
  274. package/dist/store/space.js +41 -0
  275. package/dist/store/watchers.d.ts +17 -0
  276. package/dist/store/watchers.d.ts.map +1 -0
  277. package/dist/store/watchers.js +56 -0
  278. package/dist/store/writes.d.ts +24 -0
  279. package/dist/store/writes.d.ts.map +1 -0
  280. package/dist/store/writes.js +125 -0
  281. package/dist/store.d.ts +109 -117
  282. package/dist/store.d.ts.map +1 -1
  283. package/dist/store.js +155 -494
  284. package/dist/stored.d.ts +156 -0
  285. package/dist/stored.d.ts.map +1 -0
  286. package/dist/stored.js +649 -0
  287. package/dist/surface.d.ts +88 -0
  288. package/dist/surface.d.ts.map +1 -0
  289. package/dist/surface.js +223 -0
  290. package/dist/sync.d.ts +19 -0
  291. package/dist/sync.d.ts.map +1 -0
  292. package/dist/sync.js +521 -0
  293. package/dist/tables.d.ts +412 -0
  294. package/dist/tables.d.ts.map +1 -0
  295. package/dist/tables.js +737 -0
  296. package/dist/tallies.d.ts +18 -0
  297. package/dist/tallies.d.ts.map +1 -0
  298. package/dist/tallies.js +129 -0
  299. package/dist/transfer.d.ts +0 -5
  300. package/dist/transfer.d.ts.map +1 -1
  301. package/dist/turn.d.ts +9 -0
  302. package/dist/turn.d.ts.map +1 -0
  303. package/dist/turn.js +75 -0
  304. package/dist/validation.d.ts +29 -0
  305. package/dist/validation.d.ts.map +1 -0
  306. package/dist/validation.js +104 -0
  307. package/dist/windows.d.ts +11 -0
  308. package/dist/windows.d.ts.map +1 -0
  309. package/dist/windows.js +16 -0
  310. package/dist/wire.d.ts +220 -34
  311. package/dist/wire.d.ts.map +1 -1
  312. package/dist/wire.js +73 -31
  313. package/package.json +27 -15
  314. package/AGENTS.md +0 -290
  315. package/dist/attachment.d.ts +0 -3
  316. package/dist/attachment.d.ts.map +0 -1
  317. package/dist/attachment.js +0 -8
  318. package/dist/chat/acts.d.ts +0 -34
  319. package/dist/chat/acts.d.ts.map +0 -1
  320. package/dist/chat/acts.js +0 -36
  321. package/dist/chat/messages.d.ts +0 -21
  322. package/dist/chat/messages.d.ts.map +0 -1
  323. package/dist/chat/messages.js +0 -151
  324. package/dist/chat/overlay.d.ts +0 -31
  325. package/dist/chat/overlay.d.ts.map +0 -1
  326. package/dist/chat/overlay.js +0 -97
  327. package/dist/chat/parts.d.ts +0 -57
  328. package/dist/chat/parts.d.ts.map +0 -1
  329. package/dist/chat/parts.js +0 -119
  330. package/dist/chat/process.d.ts +0 -20
  331. package/dist/chat/process.d.ts.map +0 -1
  332. package/dist/chat/process.js +0 -32
  333. package/dist/chat/provider.d.ts +0 -57
  334. package/dist/chat/provider.d.ts.map +0 -1
  335. package/dist/chat/provider.js +0 -637
  336. package/dist/chat/questions.d.ts.map +0 -1
  337. package/dist/chat/read.d.ts.map +0 -1
  338. package/dist/chat.d.ts +0 -7
  339. package/dist/chat.d.ts.map +0 -1
  340. package/dist/chat.js +0 -2
  341. package/dist/read-side.d.ts +0 -18
  342. package/dist/read-side.d.ts.map +0 -1
  343. package/dist/read-side.js +0 -433
package/README.md CHANGED
@@ -12,14 +12,14 @@ npm install @agentshouse/mdruntime
12
12
 
13
13
  ## Entries
14
14
 
15
- | Entry | For |
16
- | ------------------------------- | ---------------------------------------------------------------- |
17
- | `@agentshouse/mdruntime/client` | The host's client: `connectMdRuntime(port)` |
18
- | `@agentshouse/mdruntime/host` | The host that serves a Runtime: `serveMdRuntime` |
19
- | `@agentshouse/mdruntime` | Shared types |
20
- | `@agentshouse/mdruntime/memory` | Tests: `createMemoryAdapter`, an in-memory Adapter |
21
- | `@agentshouse/mdruntime/react` | React over the client: `useObserve`, `useSave`, `saveRoomDrafts` |
22
- | `@agentshouse/mdruntime/chat` | The Chat on assistant-ui: `ChatProvider`, `useChat` |
15
+ | Entry | For |
16
+ | ------------------------------- | ---------------------------------------------------------------------------------------------- |
17
+ | `@agentshouse/mdruntime/client` | The host's client: `connectMdRuntime(port)` |
18
+ | `@agentshouse/mdruntime/host` | The host that serves a Runtime: `serveMdRuntime` |
19
+ | `@agentshouse/mdruntime` | Shared types |
20
+ | `@agentshouse/mdruntime/memory` | Tests: `createMemoryAdapter`, an in-memory Adapter |
21
+ | `@agentshouse/mdruntime/tables` | The host's database: the Authored store's and opened files' tables, `answerRuntime` |
22
+ | `@agentshouse/mdruntime/react` | React over the client: `useObserve`, `useSave`; `useReading`, a reader of an expectation store |
23
23
 
24
24
  ## Usage
25
25
 
@@ -37,8 +37,20 @@ const notes = await runtime.query({ types: ['note'], select: 'all', limit: 20 })
37
37
  `storage-loss` when unsynchronized Room Drafts and Pending Changes were lost.
38
38
  The host supplies the user-facing wording.
39
39
 
40
- The rules an App's agent follows, including Local Query, Local Search, Room
41
- Draft and Save, are in [`AGENTS.md`](AGENTS.md).
40
+ In House the bridge object the page holds as `window.houseBridge` places the Chat, which
41
+ House serves with the page: install and bundle nothing for it. Mount it in an element,
42
+ themed by CSS custom properties on that element, docked at a third of the window:
43
+
44
+ ```ts
45
+ const chat = await window.houseBridge.chat.mount(element, { width: '1/3', showChats: true });
46
+ element.style.setProperty('--chat-accent', '#2a6cf0');
47
+ chat.update({ width: 'full', showChats: true });
48
+ chat.unmount();
49
+ ```
50
+
51
+ The rules an App's agent follows, including Local Query, search, Room
52
+ Draft, Save and the Chat, are the `apps/` pages of House's Guide, which House's
53
+ `guide/open` opens.
42
54
 
43
55
  ## License
44
56
 
@@ -0,0 +1,3 @@
1
+ import type { Runtime } from './runtime.js';
2
+ export declare function submitLater(runtime: Runtime, locator: string): void;
3
+ //# sourceMappingURL=acceptance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acceptance.d.ts","sourceRoot":"","sources":["../src/acceptance.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAiX5C,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAK5D"}
@@ -0,0 +1,308 @@
1
+ import { changeSet } from './change-set.js';
2
+ import { declared } from './declaration.js';
3
+ import { leaving as leavingIn, partnerOf } from './change.js';
4
+ import { olderThan, showing } from './install.js';
5
+ import { scoped } from './models.js';
6
+ import { answered, settle } from './queue.js';
7
+ import { refuse } from './refusal.js';
8
+ import { returnedPaths, returning, slicing } from './replica.js';
9
+ import { batchFile } from './saves.js';
10
+ import { rest, roomUnreadable, statusShown } from './shown.js';
11
+ import { advanced, withhold } from './sync.js';
12
+ import { unconfirmed } from './transfer.js';
13
+ import { stepped } from './turn.js';
14
+ async function mark(runtime, local, locator, batch, submission, lost) {
15
+ const { store, socket, presence } = runtime;
16
+ const partner = partnerOf(batch, locator);
17
+ for (const held of partner === null ? [locator] : [locator, partner]) {
18
+ const { state, room } = await local.pending(held, batch.id);
19
+ if (!socket.continuing() ||
20
+ state === undefined ||
21
+ (JSON.stringify(state.submission) === JSON.stringify(submission) && state.lost === lost)) {
22
+ continue;
23
+ }
24
+ await local.submit(held, batch.id, submission, lost);
25
+ if (presence.lost(held))
26
+ continue;
27
+ if (room)
28
+ store.changed(changeSet(held, { queue: true }));
29
+ }
30
+ statusShown(runtime);
31
+ }
32
+ async function keepUpload({ socket, presence }, local, locator, identifier, upload) {
33
+ if (!socket.continuing())
34
+ throw new Error();
35
+ await local.keepUpload(locator, identifier, upload);
36
+ if (presence.lost(locator))
37
+ throw new Error();
38
+ if (!socket.continuing())
39
+ throw new Error();
40
+ }
41
+ function logAccepted({ journal }, locator, submitted, accepted) {
42
+ journal.record(`outcome ${locator} ${submitted.id} accepted ${accepted.roomVersion}` +
43
+ (accepted.author === undefined ? '' : ` author ${accepted.author}`) +
44
+ (accepted.time === undefined ? '' : ` time ${accepted.time}`));
45
+ }
46
+ function restands(adoptions) {
47
+ return adoptions.flatMap((one) => (one === null || !('record' in one) ? [] : [one]));
48
+ }
49
+ async function adoption(runtime, room, current, local, submitted, accepted) {
50
+ const { store, socket } = runtime;
51
+ if (!socket.continuing())
52
+ return unconfirmed;
53
+ if (current === undefined || !current.queue.some((batch) => batch.id === submitted.id)) {
54
+ return null;
55
+ }
56
+ const held = current.record.roomVersion;
57
+ logAccepted(runtime, room.locator, submitted, accepted);
58
+ let record = current.record;
59
+ let adopted;
60
+ if (!socket.reads.reached(room.locator, held, accepted.roomVersion) &&
61
+ !olderThan(runtime, room.locator, accepted.roomVersion, held)) {
62
+ const paths = [...returnedPaths(submitted, accepted)];
63
+ const confirmedLayer = await stepped(slicing(await local.entries(record.key, 'confirmed', paths), paths));
64
+ adopted = await stepped(returning(confirmedLayer, submitted, accepted, accepted.roomVersion, store.composed(record)));
65
+ record = {
66
+ ...record,
67
+ roomVersion: socket.follows(room.locator, held, accepted.roomVersion)
68
+ ? accepted.roomVersion
69
+ : held,
70
+ };
71
+ }
72
+ const reached = record.roomVersion;
73
+ return {
74
+ locator: room.locator,
75
+ record,
76
+ accepted: submitted.id,
77
+ ...(adopted === undefined ? {} : { adopted }),
78
+ after() {
79
+ showing(runtime, room.locator, accepted.roomVersion, reached);
80
+ runtime.presence.readable(room.locator);
81
+ },
82
+ };
83
+ }
84
+ async function adopted(runtime, room, local, submitted, accepted) {
85
+ let kept = true;
86
+ await settle(runtime, [room.locator], async (held) => {
87
+ const adopting = await adoption(runtime, room, held.get(room.locator)?.replica, local, submitted, accepted);
88
+ kept = adopting !== unconfirmed;
89
+ return restands([adopting]);
90
+ });
91
+ return kept;
92
+ }
93
+ async function adoptedMove(runtime, room, partner, local, submitted, accepted) {
94
+ const other = runtime.presence.room(partner);
95
+ let kept = true;
96
+ await settle(runtime, [room.locator, partner], async (held) => {
97
+ const left = await adoption(runtime, room, held.get(room.locator)?.replica, local, submitted, accepted);
98
+ const there = held.get(partner)?.replica;
99
+ const arriving = there?.queue.find((batch) => batch.id === submitted.id);
100
+ const arrived = other === undefined || arriving === undefined || accepted.destination === undefined
101
+ ? null
102
+ : await adoption(runtime, other, there, local, arriving, {
103
+ kind: 'accepted',
104
+ ...accepted.destination,
105
+ });
106
+ kept = left !== unconfirmed;
107
+ return restands([left, arrived]);
108
+ });
109
+ submitLater(runtime, partner);
110
+ return kept;
111
+ }
112
+ async function behindIn({ store }, locator, batch) {
113
+ const local = await store.open();
114
+ const [order, { room }] = await Promise.all([
115
+ local.order(locator),
116
+ local.pending(locator, batch.id),
117
+ ]);
118
+ return room ? order.indexOf(batch.id) > 0 : order.length > 0;
119
+ }
120
+ async function submitRoom(runtime, room, local, authorized, progress, signal) {
121
+ const { store, socket, presence, journal } = runtime;
122
+ while (socket.continuing() &&
123
+ socket.session.now().authorization !== undefined &&
124
+ !signal.aborted) {
125
+ const headId = (await local.order(room.locator)).find((id) => store.landed.of(room.locator, id) === undefined);
126
+ if (headId === undefined)
127
+ return 'done';
128
+ const [head, pending] = await Promise.all([
129
+ local.batch(room.locator, headId),
130
+ local.pending(room.locator, headId),
131
+ ]);
132
+ if (head === null || !pending.room)
133
+ return 'done';
134
+ const { state } = pending;
135
+ const partner = partnerOf(head, room.locator);
136
+ if (partner !== null && !leavingIn(head, room.locator)) {
137
+ submitLater(runtime, partner);
138
+ return 'done';
139
+ }
140
+ if (partner !== null && (await behindIn(runtime, partner, head))) {
141
+ progress.complete = false;
142
+ return 'done';
143
+ }
144
+ const { submission, lost: earlier } = state ?? {
145
+ submission: { state: 'waiting' },
146
+ lost: false,
147
+ };
148
+ if (submission.state === 'reset' && Date.now() < Date.parse(submission.reset)) {
149
+ progress.complete = false;
150
+ return { at: Date.parse(submission.reset) };
151
+ }
152
+ if (socket.writesHeld()) {
153
+ progress.complete = false;
154
+ journal.record(`submission ${room.locator} ${head.id} held`);
155
+ return 'done';
156
+ }
157
+ const lost = earlier || submission.state === 'submitted';
158
+ let result;
159
+ journal.record(`submission ${room.locator} ${head.id}`);
160
+ await store.exclusive(() => mark(runtime, local, room.locator, head, { state: 'submitted' }, lost));
161
+ if (socket.session.now().paused || presence.lost(room.locator))
162
+ return 'done';
163
+ if (signal.aborted || socket.writesHeld()) {
164
+ await store.exclusive(() => mark(runtime, local, room.locator, head, submission, earlier));
165
+ if (signal.aborted)
166
+ return 'done';
167
+ progress.complete = false;
168
+ journal.record(`submission ${room.locator} ${head.id} held`);
169
+ return 'done';
170
+ }
171
+ const opensBefore = socket.session.now().openSignals;
172
+ const answeredHere = socket.awaitingAnswer(room.locator);
173
+ const answeredThere = partner === null ? () => { } : socket.awaitingAnswer(partner);
174
+ const heard = () => {
175
+ answeredHere();
176
+ answeredThere();
177
+ };
178
+ try {
179
+ result = await socket.mutate(authorized, {
180
+ locator: room.locator,
181
+ changeBatch: head,
182
+ file: batchFile(store, head),
183
+ ...(state?.upload === undefined ? {} : { upload: state.upload }),
184
+ }, (upload) => store.exclusive(() => keepUpload(runtime, local, room.locator, head.id, upload)));
185
+ }
186
+ catch {
187
+ heard();
188
+ progress.complete = false;
189
+ if (socket.continuing())
190
+ progress.reachable = false;
191
+ return 'again';
192
+ }
193
+ if (signal.aborted) {
194
+ heard();
195
+ return 'done';
196
+ }
197
+ if (result.kind !== 'accepted' || !socket.continuing())
198
+ heard();
199
+ if (!socket.continuing())
200
+ return 'done';
201
+ if (result.kind === 'transport-uncertainty') {
202
+ progress.complete = false;
203
+ progress.reachable = false;
204
+ return 'again';
205
+ }
206
+ if (result.kind === 'room-not-readable') {
207
+ progress.complete = false;
208
+ roomUnreadable(runtime, (presence.room(result.locator) ?? room).locator);
209
+ return 'done';
210
+ }
211
+ if (result.kind === 'revoked-authorization') {
212
+ await refuse(runtime, 'revoked-authorization');
213
+ return 'done';
214
+ }
215
+ if (result.kind === 'scoped-refusal') {
216
+ await scoped(runtime, result, room.locator, declared(room));
217
+ progress.complete = false;
218
+ return 'done';
219
+ }
220
+ if (result.kind === 'write-halted') {
221
+ journal.record(`outcome ${room.locator} ${head.id} write-halted`);
222
+ await store.exclusive(() => mark(runtime, local, room.locator, head, { state: 'waiting' }, lost));
223
+ if (!socket.haltedSince(opensBefore))
224
+ continue;
225
+ progress.complete = false;
226
+ return 'done';
227
+ }
228
+ const other = partner === null ? undefined : presence.room(partner);
229
+ if (result.kind === 'conflicted' ||
230
+ result.kind === 'rejected' ||
231
+ result.kind === 'retryable-refusal') {
232
+ journal.record(`outcome ${room.locator} ${head.id} ${result.kind}` +
233
+ (result.kind === 'conflicted' && result.roomVersion !== undefined
234
+ ? ` ${result.roomVersion}`
235
+ : ''));
236
+ journal.record(`refusal ${result.kind} ${result.code}`);
237
+ }
238
+ if (result.kind === 'retryable-refusal') {
239
+ const reset = result.reset;
240
+ progress.complete = false;
241
+ await store.exclusive(() => mark(runtime, local, room.locator, head, reset === undefined ? { state: 'waiting' } : { state: 'reset', reset }, lost));
242
+ return reset === undefined ? 'again' : { at: Date.parse(reset) };
243
+ }
244
+ if (result.kind === 'conflicted' || result.kind === 'rejected') {
245
+ const refreshed = async () => ({
246
+ there: other === undefined ? null : await advanced(runtime, other, local, authorized),
247
+ here: await advanced(runtime, room, local, authorized),
248
+ });
249
+ const judged = result.kind === 'conflicted' && other !== undefined ? await refreshed() : null;
250
+ if (judged !== null && (judged.there !== null || judged.here !== null)) {
251
+ await store.exclusive(() => mark(runtime, local, room.locator, head, { state: 'waiting' }, lost));
252
+ if (other !== undefined && judged.there !== null) {
253
+ await withhold(runtime, judged.there, other, local, progress);
254
+ }
255
+ if (judged.here !== null)
256
+ await withhold(runtime, judged.here, room, local, progress);
257
+ return 'done';
258
+ }
259
+ await answered(runtime, room.locator, head, result);
260
+ const { there, here } = judged ?? (await refreshed());
261
+ if (other !== undefined && there !== null) {
262
+ await withhold(runtime, there, other, local, progress);
263
+ }
264
+ if (here !== null) {
265
+ await withhold(runtime, here, room, local, progress);
266
+ return 'done';
267
+ }
268
+ continue;
269
+ }
270
+ const kept = await (partner === null
271
+ ? adopted(runtime, room, local, head, result)
272
+ : adoptedMove(runtime, room, partner, local, head, result)).finally(heard);
273
+ if (!kept) {
274
+ progress.complete = false;
275
+ return 'done';
276
+ }
277
+ }
278
+ return 'done';
279
+ }
280
+ export function submitLater(runtime, locator) {
281
+ if (runtime.localSaves)
282
+ return;
283
+ void runtime.recovery.attempt(`submit ${locator}`, (signal) => submitPass(runtime, locator, signal));
284
+ }
285
+ async function submitPass(runtime, locator, signal) {
286
+ const { store, socket, presence } = runtime;
287
+ const room = presence.room(locator);
288
+ if (!socket.continuing() || socket.stopping() || room === undefined) {
289
+ return 'done';
290
+ }
291
+ const progress = { complete: true, reachable: true };
292
+ let next;
293
+ try {
294
+ await socket.authorize();
295
+ const { authorization } = socket.session.now();
296
+ if (authorization === undefined)
297
+ return 'done';
298
+ next = await submitRoom(runtime, room, await store.open(), authorization, progress, signal);
299
+ }
300
+ catch {
301
+ progress.reachable = false;
302
+ next = 'again';
303
+ }
304
+ if (signal.aborted)
305
+ return 'done';
306
+ await rest(runtime, progress);
307
+ return next === 'again' && !socket.isOpen() ? 'done' : next;
308
+ }
@@ -0,0 +1,20 @@
1
+ import type { ConversationHistoryRequest } from './adapter.js';
2
+ import { type CallResult, type HistoryAnswer, type Resolution } from './outcome.js';
3
+ import type { Attempted } from './recovery.js';
4
+ import type { Runtime } from './runtime.js';
5
+ export type HistoryQuery = {
6
+ revision?: string;
7
+ pageToken?: string;
8
+ };
9
+ export declare function readHistory(runtime: Runtime, locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
10
+ export declare function located(runtime: Runtime, room: string, path: string, destination: string): Promise<{
11
+ room: string;
12
+ path: string;
13
+ } | null>;
14
+ export declare function resolveReference(runtime: Runtime, room: string, path: string, destination: string): Promise<Resolution>;
15
+ export declare function invokeAction(runtime: Runtime, name: string, input: unknown, dispatching?: () => Promise<void>): Promise<CallResult>;
16
+ export declare function readConversationHistory(runtime: Runtime, request: ConversationHistoryRequest): Promise<CallResult>;
17
+ export declare function called(runtime: Runtime, name: string, input: unknown): Promise<CallResult>;
18
+ export declare function resendCalls(runtime: Runtime, signal: AbortSignal): Promise<Attempted>;
19
+ export declare function resendLater(runtime: Runtime): void;
20
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAK/D,OAAO,EAUL,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAOF,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,YAAiB,GACvB,OAAO,CAAC,aAAa,CAAC,CAqCxB;AAED,wBAAsB,OAAO,CAC3B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAShD;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,CAAC,CAuBrB;AAwBD,wBAAsB,YAAY,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAChC,OAAO,CAAC,UAAU,CAAC,CA6BrB;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,UAAU,CAAC,CAiBrB;AAuCD,wBAAsB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAKhG;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAiB3F;AAiBD,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,QAG3C"}
@@ -0,0 +1,251 @@
1
+ import { roomTarget, target } from '@agentshouse/mdmodel';
2
+ import { resendConversations } from './conversation.js';
3
+ import { listingNow } from './listing.js';
4
+ import { locked, lockedRooms } from './locks.js';
5
+ import { scoped } from './models.js';
6
+ import { ABSENT_TARGET, calledResult, failure, historyAnswer, LOCKED_UNREADABLE, lockedRoom, undeclared, UNCERTAIN, UNREADABLE, } from './outcome.js';
7
+ import { refuse } from './refusal.js';
8
+ function operationOf(input) {
9
+ const operation = input?.operation_id;
10
+ return typeof operation === 'string' ? operation : null;
11
+ }
12
+ export async function readHistory(runtime, locator, path, query = {}) {
13
+ const { store, socket, presence, journal } = runtime;
14
+ const { session } = socket;
15
+ if (socket.closed() || session.now().refusal !== null)
16
+ return UNCERTAIN;
17
+ await socket.firstDiscovery;
18
+ if (!session.now().roomsNamed)
19
+ return UNCERTAIN;
20
+ try {
21
+ await socket.authorize();
22
+ }
23
+ catch {
24
+ return UNCERTAIN;
25
+ }
26
+ const { closed, authorization, refusal } = session.now();
27
+ if (closed || authorization === undefined || refusal !== null)
28
+ return UNCERTAIN;
29
+ const since = presence.losses();
30
+ const transfer = ['transfer', 'history', locator, path];
31
+ if (query.revision !== undefined)
32
+ transfer.push(query.revision);
33
+ if (query.pageToken !== undefined)
34
+ transfer.push(query.pageToken);
35
+ journal.record(transfer.join(' '));
36
+ try {
37
+ const result = await socket.history(authorization, {
38
+ locator,
39
+ path,
40
+ ...(query.revision === undefined ? {} : { revision: query.revision }),
41
+ ...(query.pageToken === undefined ? {} : { pageToken: query.pageToken }),
42
+ });
43
+ journal.record(`outcome history ${result.kind}`);
44
+ if (presence.lostSince(locator, since))
45
+ return failure({ kind: 'room-not-readable', locator });
46
+ if (result.kind === 'scoped-refusal') {
47
+ const room = await store.record(result.locator);
48
+ if (room !== undefined)
49
+ await scoped(runtime, result, room.locator, room.declaration);
50
+ }
51
+ if (result.kind === 'revoked-authorization')
52
+ await refuse(runtime, 'revoked-authorization');
53
+ return historyAnswer(result);
54
+ }
55
+ catch {
56
+ journal.record('outcome history transport-uncertainty');
57
+ return UNCERTAIN;
58
+ }
59
+ }
60
+ export async function located(runtime, room, path, destination) {
61
+ const crossing = roomTarget(destination);
62
+ const listing = await listingNow(runtime);
63
+ if (crossing === null) {
64
+ const named = target(path, destination);
65
+ return named === null || !listing.has(room) ? null : { room, path: named };
66
+ }
67
+ const held = [...listing.values()].find((listed) => listed.handle === crossing.handle);
68
+ return held === undefined ? null : { room: held.locator, path: crossing.path };
69
+ }
70
+ export async function resolveReference(runtime, room, path, destination) {
71
+ const { store } = runtime;
72
+ if (roomTarget(destination) === null && target(path, destination) === null) {
73
+ return ABSENT_TARGET;
74
+ }
75
+ const at = await located(runtime, room, path, destination);
76
+ if (at === null)
77
+ return UNREADABLE;
78
+ if (await locked(runtime, at.room))
79
+ return LOCKED_UNREADABLE;
80
+ const held = await store.record(at.room);
81
+ if (held !== undefined &&
82
+ (await (await store.open()).entries(held.key, 'visible', [at.path])).length > 0) {
83
+ return { kind: 'document', ...at };
84
+ }
85
+ const history = await readHistory(runtime, at.room, at.path);
86
+ if (history.kind === 'no-history' || history.kind === 'revision')
87
+ return ABSENT_TARGET;
88
+ if (history.kind !== 'history')
89
+ return history;
90
+ const [last] = history.revisions;
91
+ if (last === undefined)
92
+ return ABSENT_TARGET;
93
+ return history.deleted === true
94
+ ? { kind: 'deleted', ...at, revision: last }
95
+ : { kind: 'document', ...at };
96
+ }
97
+ async function declaredAction({ store }, name) {
98
+ for (const capability of (await (await store.open()).facts()).capabilities) {
99
+ for (const action of capability.actions ?? []) {
100
+ if (action.name === name)
101
+ return action;
102
+ }
103
+ }
104
+ return undefined;
105
+ }
106
+ async function calledRooms(runtime, name, input) {
107
+ const member = (await declaredAction(runtime, name))?.room;
108
+ if (member === undefined || input === null || typeof input !== 'object')
109
+ return [];
110
+ const named = input[member];
111
+ return (Array.isArray(named) ? named : [named]).filter((room) => typeof room === 'string');
112
+ }
113
+ export async function invokeAction(runtime, name, input, dispatching) {
114
+ const { store, socket, journal } = runtime;
115
+ const { session } = socket;
116
+ await socket.ready;
117
+ if (socket.closed() || session.now().refusal !== null)
118
+ return UNCERTAIN;
119
+ if ((await declaredAction(runtime, name)) === undefined)
120
+ return undeclared(name);
121
+ try {
122
+ await socket.authorize();
123
+ }
124
+ catch {
125
+ return UNCERTAIN;
126
+ }
127
+ const { closed, authorization, refusal } = session.now();
128
+ if (closed || authorization === undefined || refusal !== null)
129
+ return UNCERTAIN;
130
+ await dispatching?.();
131
+ journal.record(`transfer action ${name}`);
132
+ try {
133
+ const result = await socket.action(authorization, { name, input });
134
+ if (result.kind === 'scoped-refusal') {
135
+ const room = await store.record(result.locator);
136
+ if (room !== undefined)
137
+ await scoped(runtime, result, room.locator, room.declaration);
138
+ }
139
+ if (result.kind === 'revoked-authorization')
140
+ await refuse(runtime, 'revoked-authorization');
141
+ journal.record(`outcome action ${result.kind}`);
142
+ if (result.kind === 'rejected')
143
+ journal.record(`refusal rejected ${result.code}`);
144
+ return calledResult(result);
145
+ }
146
+ catch {
147
+ journal.record('outcome action transport-uncertainty');
148
+ return UNCERTAIN;
149
+ }
150
+ }
151
+ export async function readConversationHistory(runtime, request) {
152
+ const { socket, journal } = runtime;
153
+ await socket.ready;
154
+ const stream = socket.conversations();
155
+ if (socket.closed() || socket.session.now().refusal !== null || stream?.history === undefined) {
156
+ return UNCERTAIN;
157
+ }
158
+ journal.record('transfer conversation history');
159
+ try {
160
+ const result = await stream.history(request);
161
+ if (result.kind === 'revoked-authorization')
162
+ await refuse(runtime, 'revoked-authorization');
163
+ journal.record(`outcome conversation history ${result.kind}`);
164
+ return calledResult(result);
165
+ }
166
+ catch {
167
+ journal.record('outcome conversation history transport-uncertainty');
168
+ return UNCERTAIN;
169
+ }
170
+ }
171
+ function unsettled(result) {
172
+ if (result.kind === 'action')
173
+ return false;
174
+ return result.retryable && (result.kind !== 'rejected' || result.reset === undefined);
175
+ }
176
+ async function recoveredAction(runtime, name, input) {
177
+ const { store, socket, recovery } = runtime;
178
+ const { lanes } = socket;
179
+ const operation = operationOf(input);
180
+ if (operation === null)
181
+ return invokeAction(runtime, name, input);
182
+ const kept = async () => (await store.open()).keepCall({ operation, name, input });
183
+ lanes.call(operation);
184
+ try {
185
+ let result = await invokeAction(runtime, name, input, kept);
186
+ if (unsettled(result)) {
187
+ await recovery.attempt(`action ${operation}`, async () => {
188
+ if (socket.closed() || socket.session.now().refusal !== null)
189
+ return 'done';
190
+ if (!socket.isOpen())
191
+ return 'again';
192
+ result = await invokeAction(runtime, name, input, kept);
193
+ return unsettled(result) ? 'again' : 'done';
194
+ }, { again: true });
195
+ }
196
+ if (!unsettled(result))
197
+ await (await store.open()).dropCall(operation);
198
+ return result;
199
+ }
200
+ finally {
201
+ lanes.called(operation);
202
+ }
203
+ }
204
+ export async function called(runtime, name, input) {
205
+ await runtime.socket.ready;
206
+ const lockedNow = await lockedRooms(runtime);
207
+ const room = (await calledRooms(runtime, name, input)).find((one) => lockedNow.includes(one));
208
+ return room === undefined ? recoveredAction(runtime, name, input) : lockedRoom(room);
209
+ }
210
+ export async function resendCalls(runtime, signal) {
211
+ const { store, socket } = runtime;
212
+ const { lanes } = socket;
213
+ if (!socket.isOpen() || socket.closed() || socket.stopping())
214
+ return 'done';
215
+ const local = await store.open();
216
+ for (const held of await local.calls()) {
217
+ if (lanes.calling(held.operation))
218
+ continue;
219
+ if (socket.closed() || signal.aborted)
220
+ return 'done';
221
+ lanes.call(held.operation);
222
+ try {
223
+ if (unsettled(await invokeAction(runtime, held.name, held.input)))
224
+ return 'again';
225
+ await local.dropCall(held.operation);
226
+ }
227
+ finally {
228
+ lanes.called(held.operation);
229
+ }
230
+ }
231
+ return 'done';
232
+ }
233
+ async function resendPass({ socket, conversations }, signal) {
234
+ if (!socket.continuing() || !socket.isOpen() || socket.stopping())
235
+ return 'done';
236
+ const reading = { complete: true, reachable: true };
237
+ try {
238
+ await resendConversations(conversations, reading);
239
+ }
240
+ catch {
241
+ reading.reachable = false;
242
+ }
243
+ if (signal.aborted)
244
+ return 'done';
245
+ return reading.reachable && reading.complete ? 'done' : 'again';
246
+ }
247
+ export function resendLater(runtime) {
248
+ if (!runtime.socket.isOpen())
249
+ return;
250
+ void runtime.recovery.attempt('resend', (signal) => resendPass(runtime, signal), { again: true });
251
+ }