@agentshouse/mdruntime 0.1.0-c9b1e59e5baeb → 0.1.0-ca10e63188fc5

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 (226) hide show
  1. package/README.md +18 -15
  2. package/dist/adapter.d.ts +58 -32
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/attached-model.d.ts +5 -1
  5. package/dist/attached-model.d.ts.map +1 -1
  6. package/dist/attached-model.js +21 -4
  7. package/dist/binary.d.ts +0 -5
  8. package/dist/binary.d.ts.map +1 -1
  9. package/dist/binary.js +1 -1
  10. package/dist/bootstrap.d.ts +30 -8
  11. package/dist/bootstrap.d.ts.map +1 -1
  12. package/dist/bootstrap.js +187 -85
  13. package/dist/chain.d.ts +11 -0
  14. package/dist/chain.d.ts.map +1 -0
  15. package/dist/chain.js +64 -0
  16. package/dist/change-set.d.ts +6 -16
  17. package/dist/change-set.d.ts.map +1 -1
  18. package/dist/change-set.js +11 -94
  19. package/dist/change.d.ts +31 -1
  20. package/dist/change.d.ts.map +1 -1
  21. package/dist/change.js +10 -1
  22. package/dist/client.d.ts +9 -5
  23. package/dist/client.d.ts.map +1 -1
  24. package/dist/client.js +80 -6
  25. package/dist/collection.d.ts +11 -20
  26. package/dist/collection.d.ts.map +1 -1
  27. package/dist/collection.js +53 -354
  28. package/dist/compile.d.ts +16 -0
  29. package/dist/compile.d.ts.map +1 -0
  30. package/dist/compile.js +765 -0
  31. package/dist/connection.d.ts +17 -9
  32. package/dist/connection.d.ts.map +1 -1
  33. package/dist/connection.js +2431 -953
  34. package/dist/conversation.d.ts +4 -3
  35. package/dist/conversation.d.ts.map +1 -1
  36. package/dist/conversation.js +81 -68
  37. package/dist/digest.d.ts +7 -0
  38. package/dist/digest.d.ts.map +1 -0
  39. package/dist/digest.js +113 -0
  40. package/dist/durability.d.ts +3 -5
  41. package/dist/durability.d.ts.map +1 -1
  42. package/dist/durability.js +5 -0
  43. package/dist/entry.d.ts +3 -1
  44. package/dist/entry.d.ts.map +1 -1
  45. package/dist/entry.js +18 -24
  46. package/dist/file.d.ts +2 -19
  47. package/dist/file.d.ts.map +1 -1
  48. package/dist/file.js +7 -122
  49. package/dist/fulltext.d.ts +27 -0
  50. package/dist/fulltext.d.ts.map +1 -0
  51. package/dist/fulltext.js +368 -0
  52. package/dist/host.d.ts +4 -4
  53. package/dist/host.d.ts.map +1 -1
  54. package/dist/host.js +45 -15
  55. package/dist/identity.d.ts +0 -1
  56. package/dist/identity.d.ts.map +1 -1
  57. package/dist/identity.js +0 -3
  58. package/dist/index.d.ts +11 -9
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +4 -1
  61. package/dist/live.d.ts +22 -0
  62. package/dist/live.d.ts.map +1 -0
  63. package/dist/live.js +124 -0
  64. package/dist/media.d.ts +8 -0
  65. package/dist/media.d.ts.map +1 -0
  66. package/dist/media.js +205 -0
  67. package/dist/memory.d.ts +2 -1
  68. package/dist/memory.d.ts.map +1 -1
  69. package/dist/memory.js +63 -22
  70. package/dist/messages.d.ts +28 -0
  71. package/dist/messages.d.ts.map +1 -0
  72. package/dist/messages.js +90 -0
  73. package/dist/model.d.ts +6 -0
  74. package/dist/model.d.ts.map +1 -1
  75. package/dist/model.js +7 -1
  76. package/dist/name.d.ts +4 -0
  77. package/dist/name.d.ts.map +1 -0
  78. package/dist/name.js +122 -0
  79. package/dist/observation.d.ts +13 -0
  80. package/dist/observation.d.ts.map +1 -1
  81. package/dist/observation.js +84 -0
  82. package/dist/opened.d.ts +22 -0
  83. package/dist/opened.d.ts.map +1 -0
  84. package/dist/opened.js +107 -0
  85. package/dist/outcome.d.ts +40 -5
  86. package/dist/outcome.d.ts.map +1 -1
  87. package/dist/outcome.js +38 -2
  88. package/dist/overlay.d.ts +1 -4
  89. package/dist/overlay.d.ts.map +1 -1
  90. package/dist/overlay.js +22 -148
  91. package/dist/query.d.ts +11 -1
  92. package/dist/query.d.ts.map +1 -1
  93. package/dist/query.js +13 -1
  94. package/dist/reach.d.ts +11 -3
  95. package/dist/reach.d.ts.map +1 -1
  96. package/dist/reach.js +198 -69
  97. package/dist/readiness.d.ts +20 -9
  98. package/dist/readiness.d.ts.map +1 -1
  99. package/dist/readiness.js +6 -6
  100. package/dist/reads.d.ts.map +1 -1
  101. package/dist/reads.js +4 -2
  102. package/dist/recovery.d.ts +2 -2
  103. package/dist/recovery.d.ts.map +1 -1
  104. package/dist/recovery.js +8 -7
  105. package/dist/refresh.d.ts +15 -14
  106. package/dist/refresh.d.ts.map +1 -1
  107. package/dist/refresh.js +113 -75
  108. package/dist/replica.d.ts +56 -39
  109. package/dist/replica.d.ts.map +1 -1
  110. package/dist/replica.js +278 -197
  111. package/dist/room-draft.d.ts +4 -1
  112. package/dist/room-draft.d.ts.map +1 -1
  113. package/dist/room-draft.js +54 -13
  114. package/dist/rows.d.ts +38 -31
  115. package/dist/rows.d.ts.map +1 -1
  116. package/dist/rows.js +173 -101
  117. package/dist/save.d.ts +49 -14
  118. package/dist/save.d.ts.map +1 -1
  119. package/dist/save.js +352 -98
  120. package/dist/search.d.ts +11 -43
  121. package/dist/search.d.ts.map +1 -1
  122. package/dist/search.js +0 -213
  123. package/dist/shared.d.ts +4 -3
  124. package/dist/shared.d.ts.map +1 -1
  125. package/dist/shared.js +67 -34
  126. package/dist/store.d.ts +92 -96
  127. package/dist/store.d.ts.map +1 -1
  128. package/dist/store.js +329 -720
  129. package/dist/stored.d.ts +152 -0
  130. package/dist/stored.d.ts.map +1 -0
  131. package/dist/stored.js +571 -0
  132. package/dist/tables.d.ts +354 -0
  133. package/dist/tables.d.ts.map +1 -0
  134. package/dist/tables.js +624 -0
  135. package/dist/turn.d.ts +1 -1
  136. package/dist/turn.d.ts.map +1 -1
  137. package/dist/turn.js +31 -20
  138. package/dist/validation.d.ts +30 -0
  139. package/dist/validation.d.ts.map +1 -0
  140. package/dist/validation.js +162 -0
  141. package/dist/windows.d.ts +2 -6
  142. package/dist/windows.d.ts.map +1 -1
  143. package/dist/windows.js +30 -34
  144. package/dist/wire.d.ts +17 -1
  145. package/dist/wire.d.ts.map +1 -1
  146. package/dist/wire.js +5 -1
  147. package/dist/words.d.ts +19 -0
  148. package/dist/words.d.ts.map +1 -0
  149. package/dist/words.js +150 -0
  150. package/package.json +18 -19
  151. package/AGENTS.md +0 -299
  152. package/dist/chat/acts.d.ts +0 -33
  153. package/dist/chat/acts.d.ts.map +0 -1
  154. package/dist/chat/acts.js +0 -36
  155. package/dist/chat/context.d.ts +0 -3
  156. package/dist/chat/context.d.ts.map +0 -1
  157. package/dist/chat/context.js +0 -10
  158. package/dist/chat/earlier.d.ts +0 -10
  159. package/dist/chat/earlier.d.ts.map +0 -1
  160. package/dist/chat/earlier.js +0 -54
  161. package/dist/chat/input.d.ts +0 -9
  162. package/dist/chat/input.d.ts.map +0 -1
  163. package/dist/chat/input.js +0 -99
  164. package/dist/chat/kit.d.ts +0 -61
  165. package/dist/chat/kit.d.ts.map +0 -1
  166. package/dist/chat/kit.js +0 -123
  167. package/dist/chat/lasting.d.ts +0 -6
  168. package/dist/chat/lasting.d.ts.map +0 -1
  169. package/dist/chat/lasting.js +0 -19
  170. package/dist/chat/list.d.ts +0 -28
  171. package/dist/chat/list.d.ts.map +0 -1
  172. package/dist/chat/list.js +0 -99
  173. package/dist/chat/markdown.d.ts +0 -21
  174. package/dist/chat/markdown.d.ts.map +0 -1
  175. package/dist/chat/markdown.js +0 -246
  176. package/dist/chat/message.d.ts +0 -6
  177. package/dist/chat/message.d.ts.map +0 -1
  178. package/dist/chat/message.js +0 -199
  179. package/dist/chat/messages.d.ts +0 -22
  180. package/dist/chat/messages.d.ts.map +0 -1
  181. package/dist/chat/messages.js +0 -175
  182. package/dist/chat/name.d.ts +0 -6
  183. package/dist/chat/name.d.ts.map +0 -1
  184. package/dist/chat/name.js +0 -37
  185. package/dist/chat/opened.d.ts +0 -11
  186. package/dist/chat/opened.d.ts.map +0 -1
  187. package/dist/chat/opened.js +0 -17
  188. package/dist/chat/overlay.d.ts +0 -32
  189. package/dist/chat/overlay.d.ts.map +0 -1
  190. package/dist/chat/overlay.js +0 -107
  191. package/dist/chat/parts.d.ts +0 -57
  192. package/dist/chat/parts.d.ts.map +0 -1
  193. package/dist/chat/parts.js +0 -119
  194. package/dist/chat/pieces.d.ts +0 -62
  195. package/dist/chat/pieces.d.ts.map +0 -1
  196. package/dist/chat/pieces.js +0 -1110
  197. package/dist/chat/process.d.ts +0 -20
  198. package/dist/chat/process.d.ts.map +0 -1
  199. package/dist/chat/process.js +0 -32
  200. package/dist/chat/provider.d.ts +0 -64
  201. package/dist/chat/provider.d.ts.map +0 -1
  202. package/dist/chat/provider.js +0 -637
  203. package/dist/chat/question.d.ts +0 -9
  204. package/dist/chat/question.d.ts.map +0 -1
  205. package/dist/chat/question.js +0 -69
  206. package/dist/chat/questions.d.ts +0 -31
  207. package/dist/chat/questions.d.ts.map +0 -1
  208. package/dist/chat/questions.js +0 -111
  209. package/dist/chat/read.d.ts +0 -5
  210. package/dist/chat/read.d.ts.map +0 -1
  211. package/dist/chat/read.js +0 -13
  212. package/dist/chat/ready.d.ts +0 -34
  213. package/dist/chat/ready.d.ts.map +0 -1
  214. package/dist/chat/ready.js +0 -91
  215. package/dist/chat/steady.d.ts +0 -3
  216. package/dist/chat/steady.d.ts.map +0 -1
  217. package/dist/chat/steady.js +0 -26
  218. package/dist/chat/style.d.ts +0 -4
  219. package/dist/chat/style.d.ts.map +0 -1
  220. package/dist/chat/style.js +0 -302
  221. package/dist/chat.d.ts +0 -14
  222. package/dist/chat.d.ts.map +0 -1
  223. package/dist/chat.js +0 -8
  224. package/dist/read-side.d.ts +0 -27
  225. package/dist/read-side.d.ts.map +0 -1
  226. package/dist/read-side.js +0 -826
@@ -1 +1 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,gBAAgB,EAItB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KA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WAAW,CAAC;AACxD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EACL,cAAc,EACd,UAAU,EACV,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
package/dist/host.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { composeRuntime, } from './connection.js';
2
2
  import { queryKey } from './query.js';
3
3
  import { described } from './failure.js';
4
- import { removeRuntimeStore } from './store.js';
5
4
  import { AUTHORIZATION_ENDED, request, WIRE, } from './wire.js';
6
5
  const NARROWED = new Set(['within', 'whole']);
7
6
  function answered(md, app, writtenBy, member, input) {
@@ -20,18 +19,26 @@ function answered(md, app, writtenBy, member, input) {
20
19
  return md.saveParts(input[0], input[1], writtenBy);
21
20
  case 'history':
22
21
  return md.history(input[0], input[1], input[2]);
22
+ case 'resolve':
23
+ return md.resolve(input[0], input[1], input[2]);
23
24
  case 'binaryFile.read':
24
25
  return md.binaryFile.read(input[0], input[1], input[2]);
25
26
  case 'binaryFile.link':
26
27
  return md.binaryFile.link(input[0], input[1], input[2]);
27
- case 'binaryFile.readReference':
28
- return md.binaryFile.readReference(input[0]);
28
+ case 'binaryFile.show':
29
+ return md.binaryFile.show(input[0], input[1], input[2]);
30
+ case 'binaryFile.attach':
31
+ return md.binaryFile.attach(input[0], input[1]);
32
+ case 'binaryFile.part':
33
+ return md.binaryFile.part(input[0], input[1]);
29
34
  case 'call':
30
35
  return md.call(input[0], input[1]);
31
36
  case 'reached':
32
37
  return md.reached(input[0], input[1], input[2]);
33
38
  case 'log':
34
39
  return md.log();
40
+ case 'cleanUp':
41
+ return md.cleanUp();
35
42
  case 'persistence':
36
43
  return md.persistence();
37
44
  case 'retry':
@@ -43,7 +50,7 @@ function answered(md, app, writtenBy, member, input) {
43
50
  case 'roomDraft.read':
44
51
  return md.roomDraft.read(input[0], input[1]);
45
52
  case 'roomDraft.write':
46
- return md.roomDraft.write(input[0], input[1], input[2], input[3]);
53
+ return md.roomDraft.write(input[0], input[1], input[2], input[3], input[4]);
47
54
  case 'roomDraft.discard':
48
55
  return md.roomDraft.discard(input[0], input[1], input[2]);
49
56
  case 'presentation.read':
@@ -78,6 +85,14 @@ function answered(md, app, writtenBy, member, input) {
78
85
  return md.chatDraft.discard(input[0]);
79
86
  }
80
87
  }
88
+ function attempted(work) {
89
+ try {
90
+ return Promise.resolve(work());
91
+ }
92
+ catch (error) {
93
+ return Promise.reject(error);
94
+ }
95
+ }
81
96
  function answeredResult(value) {
82
97
  return typeof value === 'object' && value !== null && !('pending' in value);
83
98
  }
@@ -107,7 +122,7 @@ export function serveMdRuntime(options) {
107
122
  if (!authorized)
108
123
  throw new Error(AUTHORIZATION_ENDED);
109
124
  const writtenBy = release === undefined ? undefined : { app, release };
110
- let facts = { target: app, code, capacity: null, search };
125
+ let facts = { target: app, code, space: null, search };
111
126
  const view = runtime.within(reach ?? null, facts);
112
127
  const observations = new Map();
113
128
  const followed = new Set();
@@ -150,6 +165,20 @@ export function serveMdRuntime(options) {
150
165
  ? watchFacts(deliver)
151
166
  : (NARROWED.has(WIRE.topics[topic]) ? view : runtime).watch(topic, topic === 'presentation' ? [app] : input, deliver));
152
167
  };
168
+ const reply = async (id, query, pending) => {
169
+ try {
170
+ const value = await pending;
171
+ if (!serving)
172
+ return;
173
+ send({ kind: 'result', id, value });
174
+ if (query !== undefined && answeredResult(value))
175
+ answeredQuery(query);
176
+ }
177
+ catch (error) {
178
+ if (serving)
179
+ send({ kind: 'failure', id, ...described(error) });
180
+ }
181
+ };
153
182
  const serve = async (message) => {
154
183
  if (message.kind === 'hello')
155
184
  return;
@@ -166,17 +195,15 @@ export function serveMdRuntime(options) {
166
195
  observe(message.id, message.topic, message.input);
167
196
  return;
168
197
  }
169
- const value = await answered(NARROWED.has(WIRE.members[message.member].reach) ? view.md : md, app, writtenBy, message.member, message.input);
170
- if (!serving)
171
- return;
172
- send({ kind: 'result', id: message.id, value });
173
- if (message.member === 'query' && answeredResult(value))
174
- answeredQuery(message.input[0]);
175
198
  }
176
199
  catch (error) {
177
200
  if (serving)
178
201
  send({ kind: 'failure', id: message.id, ...described(error) });
202
+ return;
179
203
  }
204
+ const { id, member, input } = message;
205
+ const pending = attempted(() => answered(NARROWED.has(WIRE.members[member].reach) ? view.md : md, app, writtenBy, member, input));
206
+ return reply(id, member === 'query' ? input[0] : undefined, pending);
180
207
  };
181
208
  port.addEventListener('message', (event) => {
182
209
  if (!serving)
@@ -195,10 +222,10 @@ export function serveMdRuntime(options) {
195
222
  if (serving)
196
223
  view.narrow(next);
197
224
  },
198
- code(next, capacity) {
225
+ code(next, space) {
199
226
  if (!serving)
200
227
  return;
201
- facts = { ...facts, code: next, capacity };
228
+ facts = { ...facts, code: next, space };
202
229
  view.facts(facts);
203
230
  },
204
231
  search(next) {
@@ -238,6 +265,9 @@ export function serveMdRuntime(options) {
238
265
  persisted(answer) {
239
266
  runtime.persisted(answer);
240
267
  },
268
+ shown(onScreen) {
269
+ runtime.shown(onScreen);
270
+ },
241
271
  async endAuthorization(holder) {
242
272
  authorized = false;
243
273
  for (const [detach, send] of [...attachments]) {
@@ -245,8 +275,9 @@ export function serveMdRuntime(options) {
245
275
  detach();
246
276
  }
247
277
  close();
248
- if (!(await removeRuntimeStore(holder)))
278
+ if (!(await options.database.ask({ kind: 'authored.end', holder: holder ?? null }))) {
249
279
  await options.shell.dropGeneration();
280
+ }
250
281
  },
251
282
  lose(locators) {
252
283
  return runtime.lose(locators);
@@ -258,4 +289,3 @@ export function serveMdRuntime(options) {
258
289
  }
259
290
  export { entrySeedOf } from './seed.js';
260
291
  export { createRecovery, retryDelay, } from './recovery.js';
261
- export { AUTHORED_SCHEMA, authoredBinding, authoredBy, authoredHolder, bindAuthored, openDatabase, STORE_SCHEMA, transacted, } from './store.js';
@@ -3,6 +3,5 @@ export declare function identityTime(identity: string): number;
3
3
  export declare function roomDraftRevision(): string;
4
4
  export declare function chatDraftRevision(): string;
5
5
  export declare function transferIdentity(): string;
6
- export declare function indexGeneration(): string;
7
6
  export declare function binaryLocalId(): string;
8
7
  //# sourceMappingURL=identity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErD;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErD;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
package/dist/identity.js CHANGED
@@ -27,9 +27,6 @@ export function chatDraftRevision() {
27
27
  export function transferIdentity() {
28
28
  return randomIdentity();
29
29
  }
30
- export function indexGeneration() {
31
- return randomIdentity();
32
- }
33
30
  export function binaryLocalId() {
34
31
  return randomIdentity();
35
32
  }
package/dist/index.d.ts CHANGED
@@ -1,23 +1,25 @@
1
- export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BinaryFile, BinaryLinkResult, BinaryRequest, BinaryResult, ReferrerScope, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, DiscoveryScope, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldContent, HeldRoom, KeptReceipt, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, ServiceMode, ServiceModeSignal, StreamReceipts, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
2
- export type { Change, ChangeBatch, Precondition, WrittenBy } from './change.js';
1
+ export type { AcceptedMessage, AcceptedRoom, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, AttachRequest, AttachResult, Authorization, BinaryFile, BinaryLinkResult, BinaryRequest, BinaryResult, BootstrapInventory, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, DiscoveryScope, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldContent, HeldFile, HeldRevisions, HeldRoom, KeptReceipt, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, ServiceMode, ServiceModeSignal, StreamReceipts, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
2
+ export type { Change, ChangeBatch, Precondition, RoomMove, WrittenBy } from './change.js';
3
3
  export type { ChatDraft, ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
4
- export type { ChatDraftFile, FileDeclaration } from './file.js';
5
4
  export type { AppRoom, AppTypedSelection, BinaryFileSurface, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult, } from './connection.js';
6
5
  export type { Observation } from './observation.js';
7
- export type { BinaryAnswer, BinaryLinkAnswer, CallResult, Failure, HistoryAnswer, Offline, QueueEntry, Submission, } from './outcome.js';
8
- export type { BinaryFileRecord, BinaryReference } from './binary.js';
6
+ export type { AttachAnswer, BinaryAnswer, BinaryLinkAnswer, CallResult, DownloadAnswer, Failure, HistoryAnswer, Offline, QueueEntry, Resolution, Submission, } from './outcome.js';
7
+ export type { BinaryFileRecord } from './binary.js';
9
8
  export type { RuntimeError } from './failure.js';
10
9
  export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, TextParts, } from './room-draft.js';
11
10
  export type { SaveRefusal } from './save.js';
12
- export type { DocumentHit, DocumentPart, MessageHit, PendingConversation, SearchCoverage, SearchHits, SearchPending, SearchRequest, SearchResult, SearchUndeclared, } from './search.js';
11
+ export type { DocumentHit, DocumentPart, MessageHit, MessagePart, SearchCoverage, SearchHits, SearchPending, SearchRequest, SearchResult, SearchUndeclared, Snippet, } from './search.js';
13
12
  export { departure } from './change.js';
14
13
  export { partsAfter } from './room-draft.js';
15
- export { SESSION_STARTED } from './conversation.js';
14
+ export { cutName, nameFrom, transliterated } from './name.js';
15
+ export { HISTORY_CONVERSATIONS, SESSION_STARTED } from './conversation.js';
16
16
  export { changeBatchIdentity } from './identity.js';
17
+ export { paced, ROW_WEIGHT, stepped } from './turn.js';
18
+ export { entriesIn, patching, sortedKeys } from './shared.js';
17
19
  export { attempts, identities, intentOf, type Answered, type Attempt, type Attempts, type Identities, } from './attempt.js';
18
20
  export { expectedList, expecting, type ExpectedOf, type Expecting } from './expectation.js';
19
- export type { RuntimeShell, StorageEstimate } from './durability.js';
20
- export type { CapacityCause, CodeAvailability, ConnectionAvailability, ConversationCoverage, Durability, HouseOutcome, Persistence, Readiness, ReadinessStatus, RefusedRoom, RoomCoverage, RoomPreparation, SearchObligation, TargetCoverage, } from './readiness.js';
21
+ export type { RuntimeShell } from './durability.js';
22
+ export type { CodeAvailability, ConnectionAvailability, ConversationCoverage, Durability, HouseOutcome, Installation, InstallationAmount, InstallationPause, InstallationStep, Persistence, Readiness, ReadinessStatus, RefusedRoom, RoomCoverage, RoomPreparation, SearchObligation, Space, TargetCoverage, } from './readiness.js';
21
23
  export type { AttentionEntry, SyncStatus } from './status.js';
22
24
  export type { Awaits, Backlink, CoveredRoom, Direction, DocumentQuery, DocumentResult, Filter, GroupQuery, GroupResult, Key, LocalQuery, OrderOptions, PendingResult, PendingRoom, Predicate, QueryCoverage, QueryDocument, QueryGroup, QueryResult, QueryRows, Related, Select, Value, Where, } from './query.js';
23
25
  export type { MdType, ModelIdentity, ModelSnapshot, ModelState, ModelResult, TypesResult, ValidationReceipt, } from './model.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,E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AE,MAAM,aAAa,CAAC;AAC9D,YAAY,EACV,MAAM,EACN,QAAQ,EACR,WAAW,EACX,SAAS,EACT,aAAa,EACb,cAAc,EACd,MAAM,EACN,UAAU,EACV,WAAW,EACX,GAAG,EACH,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,SAAS,EACT,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,KAAK,EACL,KAAK,GACN,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACX,cAAc,EACd,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,MAAM,EACN,UAAU,EACV,WAAW,EACX,GAAG,EACH,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,SAAS,EACT,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,KAAK,EACL,KAAK,GACN,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  export { departure } from './change.js';
2
2
  export { partsAfter } from './room-draft.js';
3
- export { SESSION_STARTED } from './conversation.js';
3
+ export { cutName, nameFrom, transliterated } from './name.js';
4
+ export { HISTORY_CONVERSATIONS, SESSION_STARTED } from './conversation.js';
4
5
  export { changeBatchIdentity } from './identity.js';
6
+ export { paced, ROW_WEIGHT, stepped } from './turn.js';
7
+ export { entriesIn, patching, sortedKeys } from './shared.js';
5
8
  export { attempts, identities, intentOf, } from './attempt.js';
6
9
  export { expectedList, expecting } from './expectation.js';
package/dist/live.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import type { ChangeSet } from './change-set.js';
2
+ import { type KeyedResult, type QueryMessage } from './observation.js';
3
+ import type { PendingResult, Plan, QueryCoverage } from './query.js';
4
+ import type { QueryRoom } from './tables.js';
5
+ export type Cover = {
6
+ coverage: QueryCoverage;
7
+ rooms: readonly QueryRoom[];
8
+ } | PendingResult;
9
+ export type Ran = KeyedResult & {
10
+ readonly current: () => boolean;
11
+ };
12
+ export type Run = (plan: Plan, cover: () => Cover) => Promise<Ran>;
13
+ type Listener = (message: QueryMessage) => void;
14
+ export type LiveQueries = {
15
+ touched(set: ChangeSet): void;
16
+ recover(): void;
17
+ watch(plan: Plan, identity: string, cover: () => Cover, deliver: Listener): () => void;
18
+ close(): void;
19
+ };
20
+ export declare function createLiveQueries(run: Run): LiveQueries;
21
+ export {};
22
+ //# sourceMappingURL=live.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../src/live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAA;CAAE,GAAG,aAAa,CAAC;AAE7F,MAAM,MAAM,GAAG,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAA;CAAE,CAAC;AAEpE,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEnE,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;AAchD,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,IAAI,CAAC;IACvF,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAoCF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,WAAW,CAuFvD"}
package/dist/live.js ADDED
@@ -0,0 +1,124 @@
1
+ import { changeOf, digestOf, } from './observation.js';
2
+ import { roomOfKey } from './rows.js';
3
+ function narrowed(plan) {
4
+ return (plan.paths !== null &&
5
+ plan.hop === null &&
6
+ plan.backlinks === null &&
7
+ !(plan.shape.kind === 'documents' && plan.shape.backlinks));
8
+ }
9
+ function reads(plan, locator) {
10
+ if (plan.locked.includes(locator))
11
+ return false;
12
+ if (plan.rooms !== null && !plan.rooms.includes(locator))
13
+ return false;
14
+ if (plan.reach === null)
15
+ return true;
16
+ return (plan.reach.rooms.includes(locator) ||
17
+ plan.reach.documents.some((document) => roomOfKey(document) === locator) ||
18
+ plan.reach.areas.some((area) => area.room === locator && area.types.length > 0));
19
+ }
20
+ function affected(plan, set) {
21
+ if (set.rooms.some((locator) => reads(plan, locator)))
22
+ return true;
23
+ const paths = narrowed(plan) ? new Set(plan.paths) : null;
24
+ return set.documents.some(({ locator, path }) => reads(plan, locator) && (paths === null || path === null || paths.has(path)));
25
+ }
26
+ function shown(entry) {
27
+ const cover = entry.cover();
28
+ return JSON.stringify('pending' in cover ? cover : cover.coverage);
29
+ }
30
+ export function createLiveQueries(run) {
31
+ const entries = new Map();
32
+ let closed = false;
33
+ function deliver(entry, next) {
34
+ const previous = entry.digest;
35
+ entry.digest = digestOf(next);
36
+ entry.covered = JSON.stringify('pending' in next.result ? next.result : next.result.coverage);
37
+ const change = previous === undefined ? null : changeOf(previous, next);
38
+ if (change !== null) {
39
+ for (const listener of entry.ready)
40
+ listener(change);
41
+ }
42
+ for (const listener of entry.fresh) {
43
+ entry.ready.add(listener);
44
+ listener(next);
45
+ }
46
+ entry.fresh.clear();
47
+ }
48
+ function schedule(entry) {
49
+ if (closed || entry.listeners.size === 0)
50
+ return;
51
+ if (entry.running) {
52
+ entry.dirty = true;
53
+ return;
54
+ }
55
+ entry.running = true;
56
+ void (async () => {
57
+ try {
58
+ for (;;) {
59
+ entry.dirty = false;
60
+ const { current, ...next } = await run(entry.plan, entry.cover);
61
+ if (closed || entry.listeners.size === 0)
62
+ return;
63
+ deliver(entry, next);
64
+ if (!(entry.dirty && !current()) && shown(entry) === entry.covered)
65
+ break;
66
+ }
67
+ }
68
+ catch {
69
+ entry.dirty = false;
70
+ }
71
+ finally {
72
+ entry.running = false;
73
+ }
74
+ })();
75
+ }
76
+ return {
77
+ touched(set) {
78
+ for (const entry of entries.values()) {
79
+ if (affected(entry.plan, set))
80
+ schedule(entry);
81
+ }
82
+ },
83
+ recover() {
84
+ for (const entry of entries.values()) {
85
+ if (entry.running)
86
+ continue;
87
+ if (entry.digest === undefined || shown(entry) !== entry.covered)
88
+ schedule(entry);
89
+ }
90
+ },
91
+ watch(plan, identity, cover, listener) {
92
+ let entry = entries.get(identity);
93
+ if (entry === undefined) {
94
+ entry = {
95
+ plan,
96
+ cover,
97
+ listeners: new Set(),
98
+ fresh: new Set(),
99
+ ready: new Set(),
100
+ digest: undefined,
101
+ covered: '',
102
+ dirty: false,
103
+ running: false,
104
+ };
105
+ entries.set(identity, entry);
106
+ }
107
+ const held = entry;
108
+ held.listeners.add(listener);
109
+ held.fresh.add(listener);
110
+ schedule(held);
111
+ return () => {
112
+ held.listeners.delete(listener);
113
+ held.fresh.delete(listener);
114
+ held.ready.delete(listener);
115
+ if (held.listeners.size === 0 && entries.get(identity) === held)
116
+ entries.delete(identity);
117
+ };
118
+ },
119
+ close() {
120
+ closed = true;
121
+ entries.clear();
122
+ },
123
+ };
124
+ }
@@ -0,0 +1,8 @@
1
+ import type { MdRuntimeClient } from './client.js';
2
+ import type { ShownAnswer } from './outcome.js';
3
+ export declare const ROOM_MEDIA = "room-media";
4
+ type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
5
+ export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
6
+ export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient, registry?: CustomElementRegistry): void;
7
+ export {};
8
+ //# sourceMappingURL=media.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,eAAO,MAAM,UAAU,eAAe,CAAC;AAwBvC,KAAK,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAIpF,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,GAAG,eAAe,CAG5E;AAiBD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,EAClD,QAAQ,GAAE,qBAAsC,GAC/C,IAAI,CAqLN"}
package/dist/media.js ADDED
@@ -0,0 +1,205 @@
1
+ export const ROOM_MEDIA = 'room-media';
2
+ const ATTRIBUTES = ['room', 'path', 'revision', 'width', 'height', 'alt'];
3
+ const LOADING = new Set(['room', 'path', 'revision']);
4
+ const NEARING = '600px 0px';
5
+ const RELINKS = 2;
6
+ // The Room's stream brings a file seconds after the text that links it, and minutes after on a first open, so a file the Room does not hold yet is asked for again every three seconds.
7
+ const ABSENT_MS = 3_000;
8
+ const SHAPE = '16 / 9';
9
+ const STYLE = `:host{display:block}
10
+ [part=box]{position:relative;overflow:hidden}
11
+ [part=box]>img,[part=box]>video,[part=box]>audio{display:block;width:100%;height:100%;object-fit:contain}
12
+ [part=box]>slot{display:flex;align-items:center;justify-content:center;width:100%;height:100%;text-align:center}`;
13
+ const shows = new WeakMap();
14
+ export function shownBy(show, client) {
15
+ shows.set(client, show);
16
+ return client;
17
+ }
18
+ function ratioOf(width, height) {
19
+ const across = Number(width);
20
+ const down = Number(height);
21
+ return Number.isFinite(across) && Number.isFinite(down) && across > 0 && down > 0
22
+ ? `${across} / ${down}`
23
+ : SHAPE;
24
+ }
25
+ function drawnFor(mediaType) {
26
+ if (mediaType.startsWith('image/'))
27
+ return 'img';
28
+ if (mediaType.startsWith('video/'))
29
+ return 'video';
30
+ if (mediaType.startsWith('audio/'))
31
+ return 'audio';
32
+ return null;
33
+ }
34
+ export function defineRoomMedia(client, registry = customElements) {
35
+ if (registry.get(ROOM_MEDIA) !== undefined)
36
+ return;
37
+ const connected = Promise.resolve(client);
38
+ class RoomMedia extends HTMLElement {
39
+ static observedAttributes = ATTRIBUTES;
40
+ #root = this.attachShadow({ mode: 'open' });
41
+ #box = document.createElement('div');
42
+ #fallback = document.createElement('slot');
43
+ #watching = null;
44
+ #near = false;
45
+ #asked = 0;
46
+ #shown = null;
47
+ #drawn = null;
48
+ #loaded = false;
49
+ #relinked = 0;
50
+ constructor() {
51
+ super();
52
+ this.#box.setAttribute('part', 'box');
53
+ this.#root.append(Object.assign(document.createElement('style'), { textContent: STYLE }), this.#box);
54
+ this.#shape();
55
+ }
56
+ connectedCallback() {
57
+ this.#label();
58
+ this.#watching ??= new IntersectionObserver((seen) => {
59
+ if (!seen.some((entry) => entry.isIntersecting) || this.#near)
60
+ return;
61
+ this.#near = true;
62
+ void this.#load();
63
+ }, { rootMargin: NEARING });
64
+ this.#watching.observe(this);
65
+ }
66
+ disconnectedCallback() {
67
+ this.#watching?.disconnect();
68
+ this.#watching = null;
69
+ this.#near = false;
70
+ this.#asked += 1;
71
+ this.#show(null);
72
+ }
73
+ attributeChangedCallback(name, before, after) {
74
+ if (before === after)
75
+ return;
76
+ this.#shape();
77
+ if (this.isConnected)
78
+ this.#label();
79
+ if (!LOADING.has(name) || !this.#near)
80
+ return;
81
+ this.#relinked = 0;
82
+ void this.#load();
83
+ }
84
+ #shape() {
85
+ this.#box.style.aspectRatio = ratioOf(this.getAttribute('width'), this.getAttribute('height'));
86
+ }
87
+ #label() {
88
+ const alt = this.getAttribute('alt') ?? '';
89
+ const drawn = this.#drawn;
90
+ if (drawn instanceof HTMLMediaElement) {
91
+ this.removeAttribute('role');
92
+ this.removeAttribute('aria-label');
93
+ drawn.setAttribute('aria-label', alt);
94
+ return;
95
+ }
96
+ this.setAttribute('role', 'img');
97
+ this.setAttribute('aria-label', alt);
98
+ if (drawn !== null)
99
+ drawn.alt = '';
100
+ }
101
+ async #load() {
102
+ const asked = (this.#asked += 1);
103
+ this.#loaded = false;
104
+ const room = this.getAttribute('room');
105
+ const path = this.getAttribute('path');
106
+ const revision = this.getAttribute('revision') ?? undefined;
107
+ if (room === null || path === null) {
108
+ this.#unreadable();
109
+ return;
110
+ }
111
+ const show = shows.get(await connected);
112
+ const shown = show === undefined ? null : await show(room, path, revision);
113
+ if (asked !== this.#asked)
114
+ return;
115
+ if (shown?.kind === 'link') {
116
+ this.#draw({ url: shown.url, copy: false }, shown.mediaType);
117
+ return;
118
+ }
119
+ if (shown?.kind === 'absent') {
120
+ this.#unreadable();
121
+ setTimeout(() => {
122
+ if (asked === this.#asked && this.#near)
123
+ void this.#load();
124
+ }, ABSENT_MS);
125
+ return;
126
+ }
127
+ if (shown?.kind !== 'binary') {
128
+ this.#unreadable();
129
+ return;
130
+ }
131
+ const copy = await new Response(shown.stream, {
132
+ headers: { 'content-type': shown.mediaType },
133
+ }).blob();
134
+ if (asked !== this.#asked)
135
+ return;
136
+ this.#draw({ url: URL.createObjectURL(copy), copy: true }, shown.mediaType);
137
+ }
138
+ #show(shown, content = null) {
139
+ if (this.#shown?.copy === true)
140
+ URL.revokeObjectURL(this.#shown.url);
141
+ this.#shown = shown;
142
+ if (content !== this.#drawn)
143
+ this.#drawn = null;
144
+ if (content === null)
145
+ this.#box.replaceChildren();
146
+ else if (content.parentNode !== this.#box)
147
+ this.#box.replaceChildren(content);
148
+ this.#label();
149
+ }
150
+ #unreadable() {
151
+ this.#show(null, this.#fallback);
152
+ }
153
+ #draw(shown, mediaType) {
154
+ const tag = drawnFor(mediaType);
155
+ if (tag === null) {
156
+ if (shown.copy)
157
+ URL.revokeObjectURL(shown.url);
158
+ this.#unreadable();
159
+ return;
160
+ }
161
+ const kept = this.#drawn?.localName === tag ? this.#drawn : null;
162
+ const drawn = kept ?? document.createElement(tag);
163
+ if (kept === null) {
164
+ if (drawn instanceof HTMLImageElement)
165
+ drawn.decoding = 'async';
166
+ if (drawn instanceof HTMLMediaElement) {
167
+ drawn.controls = true;
168
+ drawn.preload = 'metadata';
169
+ if (drawn instanceof HTMLVideoElement)
170
+ drawn.playsInline = true;
171
+ }
172
+ drawn.addEventListener(drawn instanceof HTMLImageElement ? 'load' : 'loadedmetadata', () => {
173
+ if (drawn !== this.#drawn)
174
+ return;
175
+ this.#loaded = true;
176
+ this.#relinked = 0;
177
+ });
178
+ drawn.addEventListener('error', () => this.#failed(drawn));
179
+ }
180
+ this.#drawn = drawn;
181
+ this.#show(shown, drawn);
182
+ drawn.src = shown.url;
183
+ }
184
+ #failed(drawn) {
185
+ if (drawn !== this.#drawn)
186
+ return;
187
+ if (this.#shown?.copy !== false || !this.#loaded || this.#relinked >= RELINKS) {
188
+ this.#unreadable();
189
+ return;
190
+ }
191
+ this.#relinked += 1;
192
+ if (drawn instanceof HTMLMediaElement) {
193
+ const at = drawn.currentTime;
194
+ const playing = !drawn.paused;
195
+ drawn.addEventListener('loadedmetadata', () => {
196
+ drawn.currentTime = at;
197
+ if (playing)
198
+ void drawn.play().catch(() => undefined);
199
+ }, { once: true });
200
+ }
201
+ void this.#load();
202
+ }
203
+ }
204
+ registry.define(ROOM_MEDIA, RoomMedia);
205
+ }
package/dist/memory.d.ts CHANGED
@@ -2,12 +2,12 @@ import type { ModelResult } from './model.js';
2
2
  import { type AcceptedMessage, type ActionResult, type Adapter, type BinaryFile, type Capability, type ConversationAction, type ConversationEvent, type DiscoveryScope, type DiscoveredRoom, type HeadChange, type ListedConversation, type Member, type ProviderLimit, type Retention, type ServiceMode } from './adapter.js';
3
3
  export type MemoryRoom = DiscoveredRoom & {
4
4
  model?: ModelResult;
5
- selectionModel?: ModelResult;
6
5
  documents?: Readonly<Record<string, string>>;
7
6
  revisions?: Readonly<Record<string, string>>;
8
7
  fileIds?: Readonly<Record<string, string>>;
9
8
  changes?: Readonly<Record<string, HeadChange>>;
10
9
  binaryFiles?: Readonly<Record<string, BinaryFile>>;
10
+ folders?: readonly string[];
11
11
  blobs?: Readonly<Record<string, Blob>>;
12
12
  };
13
13
  export type MemoryConversation = {
@@ -27,6 +27,7 @@ export type MemoryAdapterOptions = {
27
27
  member?: Member;
28
28
  unopened?: boolean;
29
29
  exhaustiveDiscovery?: true;
30
+ roomTypes?: string;
30
31
  };
31
32
  export type MemoryAdapter = Adapter & {
32
33
  setRooms(rooms: readonly MemoryRoom[]): void;