@agentshouse/mdruntime 0.1.0-cefbc8bb8a1c0 → 0.1.0-cf08ada271a7f

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 (303) hide show
  1. package/README.md +10 -10
  2. package/dist/acceptance.d.ts +3 -0
  3. package/dist/acceptance.d.ts.map +1 -0
  4. package/dist/acceptance.js +309 -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 +95 -104
  9. package/dist/adapter.d.ts.map +1 -1
  10. package/dist/attached-model.d.ts +3 -10
  11. package/dist/attached-model.d.ts.map +1 -1
  12. package/dist/attached-model.js +21 -56
  13. package/dist/bootstrap.d.ts +11 -10
  14. package/dist/bootstrap.d.ts.map +1 -1
  15. package/dist/bootstrap.js +205 -88
  16. package/dist/cell.d.ts +6 -0
  17. package/dist/cell.d.ts.map +1 -0
  18. package/dist/cell.js +9 -0
  19. package/dist/chain.d.ts +2 -1
  20. package/dist/chain.d.ts.map +1 -1
  21. package/dist/change-set.d.ts +4 -0
  22. package/dist/change-set.d.ts.map +1 -1
  23. package/dist/change-set.js +6 -0
  24. package/dist/change.d.ts +1 -0
  25. package/dist/change.d.ts.map +1 -1
  26. package/dist/change.js +4 -2
  27. package/dist/chat-types.d.ts +5 -0
  28. package/dist/chat-types.d.ts.map +1 -0
  29. package/dist/chat-types.js +13 -0
  30. package/dist/client.d.ts +24 -7
  31. package/dist/client.d.ts.map +1 -1
  32. package/dist/client.js +9 -5
  33. package/dist/collection.d.ts +23 -7
  34. package/dist/collection.d.ts.map +1 -1
  35. package/dist/collection.js +13 -19
  36. package/dist/compile.d.ts +6 -6
  37. package/dist/compile.d.ts.map +1 -1
  38. package/dist/compile.js +272 -334
  39. package/dist/connection.d.ts +5 -143
  40. package/dist/connection.d.ts.map +1 -1
  41. package/dist/connection.js +101 -5310
  42. package/dist/context.d.ts +2 -0
  43. package/dist/context.d.ts.map +1 -0
  44. package/dist/context.js +7 -0
  45. package/dist/conversation-live.d.ts +135 -0
  46. package/dist/conversation-live.d.ts.map +1 -0
  47. package/dist/conversation-live.js +247 -0
  48. package/dist/conversation-row.d.ts +33 -0
  49. package/dist/conversation-row.d.ts.map +1 -0
  50. package/dist/conversation-row.js +53 -0
  51. package/dist/conversation.d.ts +41 -47
  52. package/dist/conversation.d.ts.map +1 -1
  53. package/dist/conversation.js +873 -912
  54. package/dist/declaration.d.ts +10 -0
  55. package/dist/declaration.d.ts.map +1 -0
  56. package/dist/declaration.js +24 -0
  57. package/dist/discovery.d.ts +10 -0
  58. package/dist/discovery.d.ts.map +1 -0
  59. package/dist/discovery.js +177 -0
  60. package/dist/durability.d.ts +15 -1
  61. package/dist/durability.d.ts.map +1 -1
  62. package/dist/entry.d.ts +2 -2
  63. package/dist/entry.d.ts.map +1 -1
  64. package/dist/entry.js +17 -7
  65. package/dist/expectation.d.ts +4 -2
  66. package/dist/expectation.d.ts.map +1 -1
  67. package/dist/expectation.js +33 -11
  68. package/dist/failure.d.ts +1 -0
  69. package/dist/failure.d.ts.map +1 -1
  70. package/dist/failure.js +3 -0
  71. package/dist/figures.d.ts +49 -0
  72. package/dist/figures.d.ts.map +1 -0
  73. package/dist/figures.js +197 -0
  74. package/dist/holdings.d.ts +29 -0
  75. package/dist/holdings.d.ts.map +1 -0
  76. package/dist/holdings.js +95 -0
  77. package/dist/host.d.ts +20 -8
  78. package/dist/host.d.ts.map +1 -1
  79. package/dist/host.js +38 -33
  80. package/dist/identity.d.ts +0 -1
  81. package/dist/identity.d.ts.map +1 -1
  82. package/dist/identity.js +0 -3
  83. package/dist/index.d.ts +27 -8
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +9 -1
  86. package/dist/install.d.ts +55 -0
  87. package/dist/install.d.ts.map +1 -0
  88. package/dist/install.js +543 -0
  89. package/dist/job.d.ts +5 -0
  90. package/dist/job.d.ts.map +1 -0
  91. package/dist/job.js +7 -0
  92. package/dist/lifecycle.d.ts +7 -0
  93. package/dist/lifecycle.d.ts.map +1 -0
  94. package/dist/lifecycle.js +271 -0
  95. package/dist/listing.d.ts +53 -0
  96. package/dist/listing.d.ts.map +1 -0
  97. package/dist/listing.js +169 -0
  98. package/dist/live.d.ts +5 -4
  99. package/dist/live.d.ts.map +1 -1
  100. package/dist/live.js +64 -23
  101. package/dist/locks.d.ts +9 -0
  102. package/dist/locks.d.ts.map +1 -0
  103. package/dist/locks.js +62 -0
  104. package/dist/log.d.ts +1 -0
  105. package/dist/log.d.ts.map +1 -1
  106. package/dist/lost.d.ts +5 -0
  107. package/dist/lost.d.ts.map +1 -0
  108. package/dist/lost.js +61 -0
  109. package/dist/media.d.ts +1 -1
  110. package/dist/media.d.ts.map +1 -1
  111. package/dist/media.js +3 -3
  112. package/dist/memory.d.ts +14 -5
  113. package/dist/memory.d.ts.map +1 -1
  114. package/dist/memory.js +177 -85
  115. package/dist/messages.d.ts +24 -3
  116. package/dist/messages.d.ts.map +1 -1
  117. package/dist/messages.js +89 -31
  118. package/dist/model.d.ts +2 -11
  119. package/dist/model.d.ts.map +1 -1
  120. package/dist/model.js +0 -23
  121. package/dist/models.d.ts +10 -0
  122. package/dist/models.d.ts.map +1 -0
  123. package/dist/models.js +170 -0
  124. package/dist/observation.d.ts +2 -2
  125. package/dist/observation.d.ts.map +1 -1
  126. package/dist/observation.js +14 -14
  127. package/dist/opened.js +3 -3
  128. package/dist/opening.d.ts +4 -0
  129. package/dist/opening.d.ts.map +1 -0
  130. package/dist/opening.js +59 -0
  131. package/dist/outcome.d.ts +4 -4
  132. package/dist/outcome.d.ts.map +1 -1
  133. package/dist/outcome.js +3 -0
  134. package/dist/overlay.d.ts +3 -1
  135. package/dist/overlay.d.ts.map +1 -1
  136. package/dist/overlay.js +43 -21
  137. package/dist/parts.d.ts +11 -0
  138. package/dist/parts.d.ts.map +1 -0
  139. package/dist/parts.js +21 -0
  140. package/dist/paths.d.ts +1 -0
  141. package/dist/paths.d.ts.map +1 -1
  142. package/dist/paths.js +22 -0
  143. package/dist/preparation.d.ts +20 -0
  144. package/dist/preparation.d.ts.map +1 -0
  145. package/dist/preparation.js +233 -0
  146. package/dist/queries.d.ts +16 -0
  147. package/dist/queries.d.ts.map +1 -0
  148. package/dist/queries.js +272 -0
  149. package/dist/query.d.ts +14 -210
  150. package/dist/query.d.ts.map +1 -1
  151. package/dist/query.js +3 -505
  152. package/dist/questions.d.ts +34 -0
  153. package/dist/questions.d.ts.map +1 -0
  154. package/dist/questions.js +122 -0
  155. package/dist/queue.d.ts +39 -0
  156. package/dist/queue.d.ts.map +1 -0
  157. package/dist/queue.js +455 -0
  158. package/dist/reach.d.ts +15 -13
  159. package/dist/reach.d.ts.map +1 -1
  160. package/dist/reach.js +187 -140
  161. package/dist/react.d.ts +14 -2
  162. package/dist/react.d.ts.map +1 -1
  163. package/dist/react.js +10 -1
  164. package/dist/read.d.ts +7 -0
  165. package/dist/read.d.ts.map +1 -0
  166. package/dist/read.js +17 -0
  167. package/dist/readiness.d.ts +2 -16
  168. package/dist/readiness.d.ts.map +1 -1
  169. package/dist/readiness.js +4 -10
  170. package/dist/reads.d.ts +36 -10
  171. package/dist/reads.d.ts.map +1 -1
  172. package/dist/reads.js +160 -77
  173. package/dist/recovery.d.ts.map +1 -1
  174. package/dist/recovery.js +9 -1
  175. package/dist/refresh.d.ts +7 -5
  176. package/dist/refresh.d.ts.map +1 -1
  177. package/dist/refresh.js +35 -7
  178. package/dist/refusal.d.ts +5 -0
  179. package/dist/refusal.d.ts.map +1 -0
  180. package/dist/refusal.js +57 -0
  181. package/dist/replica.d.ts +11 -17
  182. package/dist/replica.d.ts.map +1 -1
  183. package/dist/replica.js +64 -34
  184. package/dist/room-draft.d.ts +7 -8
  185. package/dist/room-draft.d.ts.map +1 -1
  186. package/dist/room-draft.js +100 -103
  187. package/dist/room-drafts.d.ts +24 -0
  188. package/dist/room-drafts.d.ts.map +1 -0
  189. package/dist/room-drafts.js +217 -0
  190. package/dist/rows.d.ts +14 -21
  191. package/dist/rows.d.ts.map +1 -1
  192. package/dist/rows.js +49 -186
  193. package/dist/runtime.d.ts +32 -0
  194. package/dist/runtime.d.ts.map +1 -0
  195. package/dist/runtime.js +1 -0
  196. package/dist/save.d.ts +41 -86
  197. package/dist/save.d.ts.map +1 -1
  198. package/dist/save.js +239 -116
  199. package/dist/saves.d.ts +32 -0
  200. package/dist/saves.d.ts.map +1 -0
  201. package/dist/saves.js +413 -0
  202. package/dist/search.d.ts +12 -63
  203. package/dist/search.d.ts.map +1 -1
  204. package/dist/search.js +9 -52
  205. package/dist/seed.d.ts +11 -2
  206. package/dist/seed.d.ts.map +1 -1
  207. package/dist/seed.js +71 -1
  208. package/dist/shared.d.ts +1 -7
  209. package/dist/shared.d.ts.map +1 -1
  210. package/dist/shared.js +13 -105
  211. package/dist/shown.d.ts +32 -0
  212. package/dist/shown.d.ts.map +1 -0
  213. package/dist/shown.js +299 -0
  214. package/dist/socket/admission.d.ts +7 -0
  215. package/dist/socket/admission.d.ts.map +1 -0
  216. package/dist/socket/admission.js +39 -0
  217. package/dist/socket/answers.d.ts +6 -0
  218. package/dist/socket/answers.d.ts.map +1 -0
  219. package/dist/socket/answers.js +20 -0
  220. package/dist/socket/lanes.d.ts +20 -0
  221. package/dist/socket/lanes.d.ts.map +1 -0
  222. package/dist/socket/lanes.js +77 -0
  223. package/dist/socket/reads.d.ts +10 -0
  224. package/dist/socket/reads.d.ts.map +1 -0
  225. package/dist/socket/reads.js +31 -0
  226. package/dist/socket/rooms.d.ts +41 -0
  227. package/dist/socket/rooms.d.ts.map +1 -0
  228. package/dist/socket/rooms.js +90 -0
  229. package/dist/socket/session.d.ts +38 -0
  230. package/dist/socket/session.d.ts.map +1 -0
  231. package/dist/socket/session.js +23 -0
  232. package/dist/socket.d.ts +69 -0
  233. package/dist/socket.d.ts.map +1 -0
  234. package/dist/socket.js +175 -0
  235. package/dist/source.d.ts +61 -0
  236. package/dist/source.d.ts.map +1 -0
  237. package/dist/source.js +82 -0
  238. package/dist/status.d.ts +0 -6
  239. package/dist/status.d.ts.map +1 -1
  240. package/dist/status.js +0 -6
  241. package/dist/store/fences.d.ts +16 -0
  242. package/dist/store/fences.d.ts.map +1 -0
  243. package/dist/store/fences.js +26 -0
  244. package/dist/store/installs.d.ts +30 -0
  245. package/dist/store/installs.d.ts.map +1 -0
  246. package/dist/store/installs.js +34 -0
  247. package/dist/store/readiness.d.ts +10 -0
  248. package/dist/store/readiness.d.ts.map +1 -0
  249. package/dist/store/readiness.js +52 -0
  250. package/dist/store/records.d.ts +210 -0
  251. package/dist/store/records.d.ts.map +1 -0
  252. package/dist/store/records.js +428 -0
  253. package/dist/store/room-held.d.ts +8 -0
  254. package/dist/store/room-held.d.ts.map +1 -0
  255. package/dist/store/room-held.js +17 -0
  256. package/dist/store/space.d.ts +11 -0
  257. package/dist/store/space.d.ts.map +1 -0
  258. package/dist/store/space.js +41 -0
  259. package/dist/store/watchers.d.ts +17 -0
  260. package/dist/store/watchers.d.ts.map +1 -0
  261. package/dist/store/watchers.js +56 -0
  262. package/dist/store/writes.d.ts +24 -0
  263. package/dist/store/writes.d.ts.map +1 -0
  264. package/dist/store/writes.js +125 -0
  265. package/dist/store.d.ts +107 -157
  266. package/dist/store.d.ts.map +1 -1
  267. package/dist/store.js +143 -395
  268. package/dist/stored.d.ts +59 -38
  269. package/dist/stored.d.ts.map +1 -1
  270. package/dist/stored.js +279 -210
  271. package/dist/surface.d.ts +88 -0
  272. package/dist/surface.d.ts.map +1 -0
  273. package/dist/surface.js +224 -0
  274. package/dist/sync.d.ts +19 -0
  275. package/dist/sync.d.ts.map +1 -0
  276. package/dist/sync.js +530 -0
  277. package/dist/tables.d.ts +116 -56
  278. package/dist/tables.d.ts.map +1 -1
  279. package/dist/tables.js +214 -98
  280. package/dist/tallies.d.ts +18 -0
  281. package/dist/tallies.d.ts.map +1 -0
  282. package/dist/tallies.js +129 -0
  283. package/dist/transfer.d.ts +0 -5
  284. package/dist/transfer.d.ts.map +1 -1
  285. package/dist/validation.d.ts +3 -4
  286. package/dist/validation.d.ts.map +1 -1
  287. package/dist/validation.js +42 -100
  288. package/dist/windows.d.ts +1 -12
  289. package/dist/windows.d.ts.map +1 -1
  290. package/dist/windows.js +2 -75
  291. package/dist/wire.d.ts +21 -9
  292. package/dist/wire.d.ts.map +1 -1
  293. package/dist/wire.js +10 -4
  294. package/package.json +3 -2
  295. package/dist/fence.d.ts +0 -6
  296. package/dist/fence.d.ts.map +0 -1
  297. package/dist/fence.js +0 -10
  298. package/dist/fulltext.d.ts +0 -27
  299. package/dist/fulltext.d.ts.map +0 -1
  300. package/dist/fulltext.js +0 -370
  301. package/dist/words.d.ts +0 -19
  302. package/dist/words.d.ts.map +0 -1
  303. package/dist/words.js +0 -156
package/dist/bootstrap.js CHANGED
@@ -1,54 +1,34 @@
1
+ import { declared } from './declaration.js';
1
2
  import { transferIdentity } from './identity.js';
2
3
  import { advancement, pageEntries } from './refresh.js';
3
4
  import { entriesIn } from './shared.js';
5
+ import { compositionOf } from './replica.js';
4
6
  import { unconfirmed } from './transfer.js';
5
7
  const NOTHING_PRIOR = () => Promise.resolve(new Map());
8
+ const PARTS_IN_FLIGHT = 6;
6
9
  function textOf(page) {
7
10
  let text = 0;
8
11
  for (const [, content] of entriesIn(page.documents))
9
12
  text += content.length;
10
13
  return text;
11
14
  }
12
- async function pageOf(page) {
15
+ async function pageOf(page, part) {
13
16
  return {
14
17
  entries: await pageEntries(page, [], page.roomVersion, NOTHING_PRIOR),
15
18
  folders: page.folders ?? [],
19
+ ...(part === undefined ? {} : { part }),
16
20
  };
17
21
  }
18
- function heldTogether(first, second) {
19
- if (first === null)
20
- return second;
21
- return {
22
- async files(after, limit) {
23
- const [left, right] = await Promise.all([
24
- first.files(after, limit),
25
- second.files(after, limit),
26
- ]);
27
- const merged = new Map([...left, ...right].map((file) => [file.path, file]));
28
- return [...merged.values()]
29
- .sort((one, other) => (one.path < other.path ? -1 : one.path > other.path ? 1 : 0))
30
- .slice(0, limit);
31
- },
32
- async contents(paths) {
33
- const [left, right] = await Promise.all([first.contents(paths), second.contents(paths)]);
34
- return new Map([...left, ...right]);
35
- },
36
- };
37
- }
38
- const NO_CONTENT = {
39
- files: () => Promise.resolve([]),
40
- contents: () => Promise.resolve(new Map()),
41
- };
42
- export async function bootstrapRoom(adapter, authorization, room, held, builtIn, remodel, continuing, staging, reuse) {
22
+ export async function bootstrapRoom(adapter, authorization, room, held, builtIn, typedPaths, remodel, continuing, staging) {
43
23
  if (staging.held(room.locator) !== null)
44
24
  await staging.abandon(room.locator);
45
- const begun = (pool) => started(adapter, authorization, room, held, builtIn, remodel, continuing, staging, pool);
46
- const first = await begun(reuse);
25
+ const begun = () => started(adapter, authorization, room, held, builtIn, typedPaths, remodel, continuing, staging);
26
+ const first = await begun();
47
27
  if (first.kind !== 'expired')
48
28
  return first;
49
29
  await staging.setAside(room.locator);
50
30
  try {
51
- const replacement = await begun(heldTogether(reuse, first.held));
31
+ const replacement = await begun();
52
32
  if (replacement.kind !== 'expired')
53
33
  return replacement;
54
34
  await staging.abandon(room.locator);
@@ -65,29 +45,25 @@ function dropped(ahead) {
65
45
  dropped(next);
66
46
  }, () => { });
67
47
  }
68
- function compositionFor(room, models, builtIn) {
69
- return {
70
- model: models.collection,
71
- selection: room.typedSelection === undefined
72
- ? null
73
- : { roots: room.typedSelection.roots, model: builtIn },
74
- };
75
- }
76
- async function started(adapter, authorization, room, held, builtIn, remodel, continuing, staging, pool) {
48
+ async function started(adapter, authorization, room, held, builtIn, typedPaths, remodel, continuing, staging) {
49
+ const mode = { paged: false };
77
50
  let outcome;
78
51
  try {
79
- outcome = await bundle(adapter, authorization, room, held, builtIn, remodel, continuing, staging, pool);
52
+ outcome = await bundle(adapter, authorization, room, held, builtIn, typedPaths, remodel, continuing, staging, mode);
80
53
  }
81
54
  catch (error) {
82
- await staging.abandon(room.locator).catch(() => { });
55
+ await stopped(staging, room.locator, mode).catch(() => { });
83
56
  throw error;
84
57
  }
85
58
  if (outcome.kind !== 'staged' && outcome.kind !== 'expired') {
86
- await staging.abandon(room.locator);
59
+ await stopped(staging, room.locator, mode);
87
60
  }
88
61
  return outcome;
89
62
  }
90
- async function bundle(adapter, authorization, room, held, builtIn, remodel, continuing, staging, pool) {
63
+ function stopped(staging, locator, mode) {
64
+ return mode.paged ? staging.abandon(locator) : staging.setAside(locator);
65
+ }
66
+ async function bundle(adapter, authorization, room, held, builtIn, typedPaths, remodel, continuing, staging, mode) {
91
67
  const locator = room.locator;
92
68
  const selection = room.replica.selection;
93
69
  const ending = new AbortController();
@@ -100,7 +76,6 @@ async function bundle(adapter, authorization, room, held, builtIn, remodel, cont
100
76
  ...(token === null
101
77
  ? { arriving: (bytes) => arriving.at(bytes) }
102
78
  : { pageToken: token }),
103
- ...(pool === null ? {} : { held: pool }),
104
79
  });
105
80
  const fetching = (token) => {
106
81
  const fetched = (async () => {
@@ -109,9 +84,8 @@ async function bundle(adapter, authorization, room, held, builtIn, remodel, cont
109
84
  if (page.kind !== 'bootstrap')
110
85
  return { page, next: null, written: () => { } };
111
86
  const written = staging.queued(textOf(page));
112
- arriving.part();
113
87
  const later = page.pageToken;
114
- if (later === undefined) {
88
+ if (later === undefined && page.parts === undefined) {
115
89
  downloaded();
116
90
  arriving.end();
117
91
  }
@@ -132,12 +106,19 @@ async function bundle(adapter, authorization, room, held, builtIn, remodel, cont
132
106
  if (!continuing())
133
107
  return unconfirmed;
134
108
  const page = fetched.page;
135
- if (page.kind === 'beyond-horizon') {
136
- const key = transfer?.key ?? null;
137
- return { kind: 'expired', held: key === null ? NO_CONTENT : staging.content(key), key };
138
- }
109
+ if (page.kind === 'beyond-horizon')
110
+ return { kind: 'expired', key: transfer?.key ?? null };
139
111
  if (page.kind !== 'bootstrap')
140
112
  return page;
113
+ if (transfer === null && page.parts !== undefined) {
114
+ const parted = await parts(page, page.parts);
115
+ if (parted.kind !== 'parted')
116
+ return parted;
117
+ transfer = parted.transfer;
118
+ continue;
119
+ }
120
+ if (transfer === null)
121
+ mode.paged = true;
141
122
  const models = remodel(page.models, transfer?.models ?? held);
142
123
  const staged = await staging.stage({
143
124
  locator,
@@ -149,13 +130,10 @@ async function bundle(adapter, authorization, room, held, builtIn, remodel, cont
149
130
  last: transfer !== null && !adapter.reached(locator, page.roomVersion, transfer.last)
150
131
  ? transfer.last
151
132
  : page.roomVersion,
152
- done: {
153
- parts: (transfer?.done.parts ?? 0) + 1,
154
- bytes: (transfer?.done.bytes ?? 0) + (page.bytes ?? 0),
155
- },
133
+ done: { bytes: (transfer?.done.bytes ?? 0) + (page.bytes ?? 0) },
156
134
  models,
157
135
  key: transfer?.key ?? null,
158
- }, await pageOf(page), compositionFor(room, models, builtIn));
136
+ }, await pageOf(page), compositionOf(models.collection, room.typedSelection, builtIn, typedPaths));
159
137
  if (staged === null)
160
138
  return unconfirmed;
161
139
  transfer = staged;
@@ -173,40 +151,179 @@ async function bundle(adapter, authorization, room, held, builtIn, remodel, cont
173
151
  }
174
152
  if (transfer === null)
175
153
  return unconfirmed;
176
- const installed = transfer;
177
- const composition = compositionFor(room, installed.models, builtIn);
178
- if (!(await staging.derive(locator, installed.key, composition)))
179
- return unconfirmed;
180
- await staging.turn(locator, 'replaying');
181
- if (!continuing())
182
- return unconfirmed;
183
- const record = {
184
- locator,
185
- name: room.name,
186
- handle: room.handle,
187
- operations: room.operations,
188
- replica: room.replica,
189
- model: installed.models.collection,
190
- typedSelection: room.typedSelection ?? null,
191
- providerOwnedPaths: room.providerOwnedPaths,
192
- roomVersion: installed.from,
193
- transfer: installed.transfer,
194
- inventory: installed.done,
195
- key: installed.key,
196
- };
197
- const due = [room.roomVersion, ...staging.announced(locator)];
198
- const last = installed.last;
199
- const reconciled = last === installed.from && due.every((version) => adapter.reached(locator, last, version))
200
- ? { kind: 'still-current' }
201
- : await advancement(adapter, authorization, record, remodel, continuing, await staging.refreshing(locator, record.key, composition));
202
- if (reconciled.kind === 'advanced' || reconciled.kind === 'still-current') {
203
- const refreshed = reconciled.kind === 'advanced';
204
- const result = refreshed ? reconciled.record : record;
205
- const refused = await staging.validate(result, refreshed ? 'refreshed' : 'confirmed');
206
- return refused ?? { kind: 'staged', record: result, refreshed };
154
+ return installed(transfer);
155
+ async function parts(head, listed) {
156
+ const models = remodel(head.models, held);
157
+ const composition = compositionOf(models.collection, room.typedSelection, builtIn, typedPaths);
158
+ const resumed = await staging.resume({
159
+ locator,
160
+ transfer: transferIdentity(),
161
+ selection,
162
+ from: head.roomVersion,
163
+ last: head.roomVersion,
164
+ done: { bytes: 0 },
165
+ models,
166
+ key: null,
167
+ }, listed, composition);
168
+ if (resumed === null)
169
+ return unconfirmed;
170
+ let staged = resumed.record ?? {
171
+ locator,
172
+ transfer: transferIdentity(),
173
+ selection,
174
+ from: head.roomVersion,
175
+ last: head.roomVersion,
176
+ done: { bytes: 0 },
177
+ models,
178
+ key: null,
179
+ };
180
+ const wanted = listed.filter((part) => !resumed.staged.has(part.id));
181
+ let arrived = staged.done.bytes;
182
+ const partial = new Map();
183
+ const report = () => {
184
+ let bytes = arrived;
185
+ for (const held of partial.values())
186
+ bytes += held;
187
+ arriving.at(bytes);
188
+ };
189
+ report();
190
+ const arrivals = [];
191
+ let woken = null;
192
+ let next = 0;
193
+ let flying = 0;
194
+ let halted = false;
195
+ let stopped = false;
196
+ let admitted = Promise.resolve();
197
+ const fetched = () => {
198
+ if ((next < wanted.length && !halted) || flying > 0)
199
+ return;
200
+ downloaded();
201
+ arriving.end();
202
+ };
203
+ const landed = (one) => {
204
+ flying -= 1;
205
+ if (stopped)
206
+ one.written();
207
+ else
208
+ arrivals.push(one);
209
+ woken?.();
210
+ ask();
211
+ fetched();
212
+ };
213
+ const fetch = async (part) => {
214
+ let written = () => { };
215
+ const admission = admitted.then(async () => {
216
+ await staging.unqueued();
217
+ written = staging.queued(part.bytes);
218
+ });
219
+ admitted = admission;
220
+ await admission;
221
+ const page = continuing()
222
+ ? await adapter.bootstrap(authorization, {
223
+ locator,
224
+ selection,
225
+ signal: ending.signal,
226
+ pageToken: part.id,
227
+ arriving: (bytes) => {
228
+ partial.set(part.id, Math.min(bytes, part.bytes));
229
+ report();
230
+ },
231
+ })
232
+ : unconfirmed;
233
+ landed({ part, page, written });
234
+ };
235
+ const ask = () => {
236
+ while (!stopped && !halted && flying < PARTS_IN_FLIGHT && next < wanted.length) {
237
+ const part = wanted[next];
238
+ next += 1;
239
+ flying += 1;
240
+ fetch(part).catch((error) => landed({ part, page: unconfirmed, written: () => { }, error }));
241
+ }
242
+ };
243
+ let failed = null;
244
+ ask();
245
+ fetched();
246
+ try {
247
+ for (;;) {
248
+ while (arrivals.length === 0) {
249
+ if (flying === 0 && (halted || next >= wanted.length))
250
+ break;
251
+ await new Promise((wake) => (woken = wake));
252
+ woken = null;
253
+ }
254
+ const one = arrivals.shift();
255
+ if (one === undefined)
256
+ break;
257
+ const { part, page, written, error } = one;
258
+ try {
259
+ if (error !== undefined)
260
+ throw error;
261
+ if (!continuing())
262
+ return unconfirmed;
263
+ if (page.kind !== 'bootstrap') {
264
+ halted = true;
265
+ failed ??= page.kind === 'beyond-horizon' ? unconfirmed : page;
266
+ continue;
267
+ }
268
+ partial.delete(part.id);
269
+ arrived += part.bytes;
270
+ report();
271
+ const kept = await staging.stage({ ...staged, done: { bytes: staged.done.bytes + part.bytes } }, await pageOf({ ...page, roomVersion: head.roomVersion }, part.id), composition);
272
+ if (kept === null)
273
+ return unconfirmed;
274
+ staged = kept;
275
+ }
276
+ finally {
277
+ written();
278
+ }
279
+ }
280
+ }
281
+ finally {
282
+ stopped = true;
283
+ for (const one of arrivals.splice(0))
284
+ one.written();
285
+ }
286
+ if (failed !== null)
287
+ return failed;
288
+ if (staged.key === null) {
289
+ const empty = await staging.stage(staged, { entries: [], folders: [] }, composition);
290
+ if (empty === null)
291
+ return unconfirmed;
292
+ staged = empty;
293
+ }
294
+ return { kind: 'parted', transfer: staged };
207
295
  }
208
- if (reconciled.kind === 'beyond-horizon') {
209
- return { kind: 'expired', held: staging.content(record.key), key: record.key };
296
+ async function installed(transfer) {
297
+ const composition = compositionOf(transfer.models.collection, room.typedSelection, builtIn, typedPaths);
298
+ if (!(await staging.derive(locator, transfer.key, composition)))
299
+ return unconfirmed;
300
+ await staging.turn(locator, 'replaying');
301
+ if (!continuing())
302
+ return unconfirmed;
303
+ const record = {
304
+ locator,
305
+ declaration: declared(room),
306
+ model: transfer.models.collection,
307
+ roomVersion: transfer.from,
308
+ transfer: transfer.transfer,
309
+ inventory: transfer.done,
310
+ key: transfer.key,
311
+ };
312
+ const last = transfer.last;
313
+ const refresh = adapter.refresh;
314
+ const reconciled = last === transfer.from &&
315
+ (staging.streamed || adapter.reached(locator, last, room.roomVersion))
316
+ ? { kind: 'still-current' }
317
+ : refresh === undefined
318
+ ? unconfirmed
319
+ : await advancement(refresh, authorization, record, remodel, continuing, await staging.refreshing(locator, record.key, composition));
320
+ if (reconciled.kind === 'advanced') {
321
+ return { kind: 'staged', record: reconciled.record, refreshed: true };
322
+ }
323
+ if (reconciled.kind === 'still-current')
324
+ return { kind: 'staged', record, refreshed: false };
325
+ if (reconciled.kind === 'beyond-horizon')
326
+ return { kind: 'expired', key: record.key };
327
+ return reconciled;
210
328
  }
211
- return reconciled;
212
329
  }
package/dist/cell.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export type Cell<T> = {
2
+ now(): T;
3
+ set(change: Partial<T>): void;
4
+ };
5
+ export declare function createCell<T extends object>(first: T): Cell<T>;
6
+ //# sourceMappingURL=cell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cell.d.ts","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI;IACpB,GAAG,IAAI,CAAC,CAAC;IACT,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAQ9D"}
package/dist/cell.js ADDED
@@ -0,0 +1,9 @@
1
+ export function createCell(first) {
2
+ let held = first;
3
+ return {
4
+ now: () => held,
5
+ set(change) {
6
+ held = { ...held, ...change };
7
+ },
8
+ };
9
+ }
package/dist/chain.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
1
2
  import type { MdRuntimeClient } from './client.js';
2
- import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
3
+ import type { DocumentResult, GroupResult, PendingResult } from './query.js';
3
4
  type Rows = DocumentResult | GroupResult;
4
5
  export type WindowAnswer = Rows | PendingResult;
5
6
  export type WindowChain = {
@@ -1 +1 @@
1
- {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,WAAW,EACX,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,KAAK,IAAI,GAAG,cAAc,GAAG,WAAW,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,aAAa,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAaF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,aAAa,GAAG,UAAU,EACjC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,GAC7E,WAAW,CAkEb"}
1
+ {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7E,KAAK,IAAI,GAAG,cAAc,GAAG,WAAW,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,aAAa,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAaF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,aAAa,GAAG,UAAU,EACjC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,GAC7E,WAAW,CAkEb"}
@@ -12,6 +12,8 @@ export type ChangeSet = {
12
12
  queues: readonly string[];
13
13
  presentations: readonly string[];
14
14
  conversations: readonly string[];
15
+ unindexed: readonly string[];
16
+ due: readonly string[];
15
17
  };
16
18
  type Changed = {
17
19
  documents?: readonly string[] | null;
@@ -19,6 +21,8 @@ type Changed = {
19
21
  room?: boolean;
20
22
  queue?: boolean;
21
23
  presentation?: string;
24
+ unindexed?: boolean;
25
+ due?: boolean;
22
26
  };
23
27
  export declare function changeSet(locator: string, changed?: Changed): ChangeSet;
24
28
  export declare function conversationChangeSet(conversations: readonly string[]): ChangeSet;
@@ -1 +1 @@
1
- {"version":3,"file":"change-set.d.ts","sourceRoot":"","sources":["../src/change-set.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAAE,QAAQ,CAAC,OAAO,EAA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CAAA;CAAE,CAAC;AAExF,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,SAAS,cAAc,EAAE,CAAC;IACrC,MAAM,EAAE,SAAS;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrD,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IACrC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,OAAY,GAAG,SAAS,CAiB3E;AAED,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAWjF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAWrE;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAI9E"}
@@ -11,6 +11,8 @@ export function changeSet(locator, changed = {}) {
11
11
  queues: changed.queue ? [locator] : [],
12
12
  presentations: changed.presentation === undefined ? [] : [changed.presentation],
13
13
  conversations: [],
14
+ unindexed: changed.unindexed ? [locator] : [],
15
+ due: changed.due ? [locator] : [],
14
16
  };
15
17
  }
16
18
  export function conversationChangeSet(conversations) {
@@ -21,6 +23,8 @@ export function conversationChangeSet(conversations) {
21
23
  queues: [],
22
24
  presentations: [],
23
25
  conversations: [...new Set(conversations)],
26
+ unindexed: [],
27
+ due: [],
24
28
  };
25
29
  }
26
30
  export function mergeChangeSets(sets) {
@@ -31,6 +35,8 @@ export function mergeChangeSets(sets) {
31
35
  queues: [...new Set(sets.flatMap((set) => set.queues))],
32
36
  presentations: [...new Set(sets.flatMap((set) => set.presentations))],
33
37
  conversations: [...new Set(sets.flatMap((set) => set.conversations))],
38
+ unindexed: [...new Set(sets.flatMap((set) => set.unindexed))],
39
+ due: [...new Set(sets.flatMap((set) => set.due))],
34
40
  };
35
41
  }
36
42
  export function touches(set, locator, path) {
package/dist/change.d.ts CHANGED
@@ -50,6 +50,7 @@ type Arriving = {
50
50
  readonly path: string;
51
51
  readonly revision?: string;
52
52
  readonly fileId?: string;
53
+ readonly created?: string;
53
54
  readonly change?: HeadChange;
54
55
  };
55
56
  export type RoomMove = {
@@ -1 +1 @@
1
- {"version":3,"file":"change.d.ts","sourceRoot":"","sources":["../src/change.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE3D,MAAM,MAAM,MAAM,GACd;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,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CAAC;AAUF,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAEzD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI5E;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEpE;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS9F;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAO3E;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAOpF"}
package/dist/change.js CHANGED
@@ -22,7 +22,8 @@ export function leaving(batch, locator) {
22
22
  }
23
23
  export function landing(changes, index, path) {
24
24
  let at = path;
25
- for (const change of changes.slice(index + 1)) {
25
+ for (let next = index + 1; next < changes.length; next += 1) {
26
+ const change = changes[next];
26
27
  if (change.path !== at)
27
28
  continue;
28
29
  if (change.kind === 'remove')
@@ -34,7 +35,8 @@ export function landing(changes, index, path) {
34
35
  }
35
36
  export function departure(changes, index) {
36
37
  let at = changes[index].path;
37
- for (const change of changes.slice(0, index).reverse()) {
38
+ for (let earlier = index - 1; earlier >= 0; earlier -= 1) {
39
+ const change = changes[earlier];
38
40
  if (change.kind === 'move' && change.to === at)
39
41
  at = change.path;
40
42
  }
@@ -0,0 +1,5 @@
1
+ export declare const CHAT_TYPE = "chat";
2
+ export declare const CHAT_MESSAGE_TYPE = "chat-message";
3
+ export declare function keptFile(line: string): string | null;
4
+ export declare function keptLines(body: string): string[];
5
+ //# sourceMappingURL=chat-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-types.d.ts","sourceRoot":"","sources":["../src/chat-types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,SAAS,CAAC;AAEhC,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAMhD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEpD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAKhD"}
@@ -0,0 +1,13 @@
1
+ export const CHAT_TYPE = 'chat';
2
+ export const CHAT_MESSAGE_TYPE = 'chat-message';
3
+ const KEPT_LINE = /^\[([^\]\n]+)\]\(\1\)$/u;
4
+ const TOO_BIG_LINE = /^\[too big to keep: [^\n]*\]$/u;
5
+ export function keptFile(line) {
6
+ return KEPT_LINE.exec(line)?.[1] ?? null;
7
+ }
8
+ export function keptLines(body) {
9
+ const trimmed = body.replace(/\n+$/u, '');
10
+ const at = trimmed.lastIndexOf('\n\n');
11
+ const lines = (at === -1 ? trimmed : trimmed.slice(at + 2)).split('\n');
12
+ return lines.every((line) => keptFile(line) !== null || TOO_BIG_LINE.test(line)) ? lines : [];
13
+ }
package/dist/client.d.ts CHANGED
@@ -1,15 +1,26 @@
1
- import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult } from './connection.js';
1
+ import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
2
+ import type { HistoryQuery } from './actions.js';
3
+ import type { AppRoom } from './listing.js';
4
+ import type { ConnectionRefusal } from './socket.js';
5
+ import type { RoomSchemas } from './surface.js';
6
+ import type { SavedParts, SavedRoomDraft, SaveResult } from './saves.js';
2
7
  import type { Member, ServiceMode } from './adapter.js';
3
- import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
8
+ import type { UnsentWork } from './durability.js';
9
+ import type { ChatDraft, ConversationAgent, ConversationAnswer, ConversationEntry, ConversationOptions, ConversationRead, ConversationView } from './conversation.js';
4
10
  import { type Observation } from './observation.js';
5
11
  import type { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
6
- import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
12
+ import type { FiguresResult } from './figures.js';
13
+ import type { Holdings } from './holdings.js';
14
+ import type { DocumentResult, GroupResult, PendingResult } from './query.js';
7
15
  import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
8
16
  import type { SearchRequest, SearchResult } from './search.js';
9
17
  import type { Readiness } from './readiness.js';
18
+ import type { ObservedRead } from './reads.js';
10
19
  import type { SyncStatus } from './status.js';
11
20
  import { type RuntimePort } from './wire.js';
21
+ export type BuildFile = (name: string) => Promise<Blob | null>;
12
22
  export type MdRuntimeClient = {
23
+ buildFile(name: string): Promise<Blob | null>;
13
24
  rooms(): Promise<readonly AppRoom[]>;
14
25
  query: {
15
26
  (query: DocumentQuery): Promise<DocumentResult | PendingResult>;
@@ -32,13 +43,12 @@ export type MdRuntimeClient = {
32
43
  };
33
44
  conversation: {
34
45
  list(): Promise<readonly ConversationEntry[]>;
35
- read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
46
+ read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
36
47
  create(input: unknown): Promise<CallResult>;
37
48
  send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
38
- answer(conversation: string, answer: unknown): Promise<CallResult>;
49
+ answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
39
50
  interrupt(conversation: string): Promise<CallResult>;
40
51
  kill(conversation: string): Promise<CallResult>;
41
- cancel(conversation: string, turn: string): Promise<CallResult>;
42
52
  delete(conversation: string): Promise<CallResult>;
43
53
  };
44
54
  chatDraft: {
@@ -59,6 +69,9 @@ export type MdRuntimeClient = {
59
69
  persistence(): Promise<boolean>;
60
70
  retry(): Promise<void>;
61
71
  cleanUp(): Promise<number>;
72
+ unsent(): Promise<readonly UnsentWork[]>;
73
+ reset(): Promise<void>;
74
+ readAgain(): Promise<void>;
62
75
  observe: {
63
76
  (topic: 'deployment-facts'): Promise<Observation<unknown>>;
64
77
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
@@ -68,6 +81,7 @@ export type MdRuntimeClient = {
68
81
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
69
82
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
70
83
  (topic: 'member'): Promise<Observation<Member | null>>;
84
+ (topic: 'authority-changes'): Promise<Observation<number>>;
71
85
  (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
72
86
  (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
73
87
  (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
@@ -76,11 +90,14 @@ export type MdRuntimeClient = {
76
90
  (topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
77
91
  (topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
78
92
  (topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
93
+ (topic: 'figures'): Promise<Observation<FiguresResult>>;
94
+ (topic: 'holdings'): Promise<Observation<Holdings>>;
95
+ (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
79
96
  };
80
97
  reauthorize(): Promise<void>;
81
98
  settled(): Promise<void>;
82
99
  };
83
- export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
100
+ export declare function connectMdRuntime(port: RuntimePort, buildFile?: BuildFile): MdRuntimeClient;
84
101
  export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
85
102
  export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
86
103
  export { roomDraftRevision } from './identity.js';