@agentshouse/mdruntime-adapter 0.1.0-cc7fa1e066844 → 0.1.0-ccd2ccb1f7214

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 (51) hide show
  1. package/AGENTS.md +280 -188
  2. package/README.md +3 -3
  3. package/dist/actions.d.ts +63 -2
  4. package/dist/actions.d.ts.map +1 -1
  5. package/dist/actions.js +157 -138
  6. package/dist/adapter.d.ts +1 -0
  7. package/dist/adapter.d.ts.map +1 -1
  8. package/dist/adapter.js +359 -171
  9. package/dist/discovery.d.ts +6 -12
  10. package/dist/discovery.d.ts.map +1 -1
  11. package/dist/discovery.js +31 -35
  12. package/dist/gather.d.ts +1 -0
  13. package/dist/gather.d.ts.map +1 -1
  14. package/dist/gather.js +11 -6
  15. package/dist/handed.d.ts +15 -0
  16. package/dist/handed.d.ts.map +1 -0
  17. package/dist/handed.js +38 -0
  18. package/dist/index.d.ts +2 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +1 -0
  21. package/dist/model.d.ts +7 -18
  22. package/dist/model.d.ts.map +1 -1
  23. package/dist/model.js +60 -39
  24. package/dist/read.d.ts +35 -7
  25. package/dist/read.d.ts.map +1 -1
  26. package/dist/read.js +164 -86
  27. package/dist/referrer.d.ts +7 -0
  28. package/dist/referrer.d.ts.map +1 -0
  29. package/dist/referrer.js +35 -0
  30. package/dist/refusal.d.ts +5 -9
  31. package/dist/refusal.d.ts.map +1 -1
  32. package/dist/refusal.js +31 -17
  33. package/dist/site.d.ts +1 -1
  34. package/dist/site.d.ts.map +1 -1
  35. package/dist/site.js +208 -107
  36. package/dist/stream.d.ts +10 -4
  37. package/dist/stream.d.ts.map +1 -1
  38. package/dist/stream.js +413 -47
  39. package/dist/transport.d.ts +94 -11
  40. package/dist/transport.d.ts.map +1 -1
  41. package/dist/transport.js +3 -1
  42. package/dist/version.d.ts +2 -0
  43. package/dist/version.d.ts.map +1 -1
  44. package/dist/version.js +10 -1
  45. package/dist/write.d.ts +2 -1
  46. package/dist/write.d.ts.map +1 -1
  47. package/dist/write.js +97 -15
  48. package/package.json +3 -4
  49. package/dist/links.d.ts +0 -12
  50. package/dist/links.d.ts.map +0 -1
  51. package/dist/links.js +0 -66
package/dist/stream.js CHANGED
@@ -1,45 +1,133 @@
1
1
  import { acceptedMessage } from './actions.js';
2
- import { headChange } from './read.js';
2
+ import { sha256Hex } from './digest.js';
3
+ import { binaryFileOf, headChange, identities } from './read.js';
3
4
  import { roomVersion } from './version.js';
4
5
  const HELD_FRAMES_MAX = 256;
5
6
  function turnOperation(frame) {
6
7
  const { type: _type, conversation_id: _conversation, turn_id: _turn, ...operation } = frame;
7
8
  return structuredClone(operation);
8
9
  }
10
+ function listedConversation(listed) {
11
+ return {
12
+ conversation: listed.conversation_id,
13
+ agent: listed.agent_id,
14
+ name: listed.name,
15
+ created: listed.created_at,
16
+ finished: listed.finished_at,
17
+ outcome: listed.outcome,
18
+ };
19
+ }
9
20
  function position(value) {
10
21
  if (!/^(?:0|[1-9][0-9]*)$/.test(value))
11
22
  return null;
12
23
  return BigInt(value);
13
24
  }
25
+ function assembled(entries) {
26
+ const whole = [];
27
+ let open = null;
28
+ for (const entry of entries) {
29
+ if (entry.kind === 'piece') {
30
+ if (open === null || open.entry.path !== entry.path || entry.text === undefined)
31
+ return null;
32
+ open.texts.push(entry.text);
33
+ }
34
+ else {
35
+ if (open !== null)
36
+ return null;
37
+ if (entry.continued !== true) {
38
+ whole.push(entry);
39
+ continue;
40
+ }
41
+ if (entry.text === undefined)
42
+ return null;
43
+ open = { entry, texts: [entry.text] };
44
+ }
45
+ if (entry.continued === true)
46
+ continue;
47
+ const { continued: _continued, ...head } = open.entry;
48
+ whole.push({ ...head, text: open.texts.join('') });
49
+ open = null;
50
+ }
51
+ return open === null ? whole : null;
52
+ }
53
+ async function verified(entries) {
54
+ try {
55
+ for (const entry of entries) {
56
+ if (entry.text === undefined || entry.sha256 === undefined)
57
+ continue;
58
+ if ((await sha256Hex(entry.text)) !== entry.sha256)
59
+ return false;
60
+ }
61
+ return true;
62
+ }
63
+ catch {
64
+ return false;
65
+ }
66
+ }
67
+ function resumed(kept, frame) {
68
+ const last = frame.entries.at(-1);
69
+ const point = { parts: frame.index + 1, from: frame.from, target: frame.target };
70
+ if (last?.continued !== true)
71
+ return { ...point, handled: frame.handled, piece: null };
72
+ const text = last.text?.length ?? 0;
73
+ if (last.kind !== 'piece') {
74
+ return last.sha256 === undefined
75
+ ? kept.resume
76
+ : { ...point, handled: frame.handled, piece: { sha256: last.sha256, offset: text } };
77
+ }
78
+ const piece = kept.resume?.piece ?? null;
79
+ if (piece === null)
80
+ return kept.resume;
81
+ const pieces = frame.entries.reduce((sum, entry) => sum + (entry.kind === 'piece' ? (entry.text?.length ?? 0) : 0), 0);
82
+ return {
83
+ ...point,
84
+ handled: frame.handled,
85
+ piece: { sha256: piece.sha256, offset: piece.offset + pieces },
86
+ };
87
+ }
14
88
  export function houseNotifications(transport, mode) {
15
89
  const stream = transport.stream;
16
90
  const lines = new Map();
91
+ const kept = new Map();
92
+ let receipts = null;
93
+ let loaded = Promise.resolve();
94
+ let acknowledging = null;
95
+ let receiving = Promise.resolve();
96
+ let verifying = 0;
17
97
  const locators = new Map();
18
- const schemas = new Map();
19
98
  const observers = new Set();
20
99
  const conversationObservers = new Set();
21
100
  const modeObservers = new Set();
22
101
  let replicated = [];
23
102
  const live = new Set();
24
- let listening = false;
25
- let catching = false;
26
- function listen() {
27
- if (listening)
28
- return;
29
- listening = true;
30
- stream.observe(receive);
103
+ let opening = null;
104
+ const runtime = crypto.randomUUID();
105
+ function emit(event) {
106
+ for (const observer of observers)
107
+ observer(event);
31
108
  }
32
109
  function emitConversation(event) {
33
- if (event.kind !== 'gap' && event.kind !== 'accepted-message')
110
+ if (event.kind === 'turn' ||
111
+ event.kind === 'questions' ||
112
+ event.kind === 'process' ||
113
+ event.kind === 'commands' ||
114
+ event.kind === 'options' ||
115
+ event.kind === 'starting' ||
116
+ event.kind === 'link' ||
117
+ event.kind === 'deliveries') {
34
118
  live.add(event.conversation);
119
+ }
35
120
  for (const observer of conversationObservers)
36
121
  observer(event);
37
122
  }
38
- function reopened() {
123
+ function reopened(next) {
124
+ opening = next;
125
+ acknowledging = next;
39
126
  const gapped = new Set([...replicated, ...live]);
40
127
  live.clear();
41
128
  for (const conversation of gapped)
42
129
  emitConversation({ kind: 'gap', conversation });
130
+ emit({ kind: 'opened' });
43
131
  }
44
132
  function converse(frame) {
45
133
  const conversation = frame.conversation_id;
@@ -72,6 +160,18 @@ export function houseNotifications(transport, mode) {
72
160
  emitConversation({ kind: 'options', conversation, options: structuredClone(frame.options) });
73
161
  return;
74
162
  }
163
+ if (frame.type === 'starting') {
164
+ emitConversation({ kind: 'starting', conversation, step: frame.step });
165
+ return;
166
+ }
167
+ if (frame.type === 'link') {
168
+ emitConversation({ kind: 'link', conversation, connected: frame.connected });
169
+ return;
170
+ }
171
+ if (frame.type === 'deliveries') {
172
+ emitConversation({ kind: 'deliveries', conversation, unknown: [...frame.unknown] });
173
+ return;
174
+ }
75
175
  if (frame.type === 'interactions') {
76
176
  emitConversation({
77
177
  kind: 'questions',
@@ -85,14 +185,10 @@ export function houseNotifications(transport, mode) {
85
185
  return;
86
186
  emitConversation({ kind: 'accepted-message', conversation, message });
87
187
  }
88
- function announce(authority, at, modelChanged) {
188
+ function announce(authority, at) {
89
189
  const version = roomVersion(at);
90
190
  for (const locator of locators.get(authority) ?? []) {
91
- for (const observer of observers) {
92
- observer(modelChanged
93
- ? { locator, roomVersion: version, modelChanged: true }
94
- : { locator, roomVersion: version });
95
- }
191
+ emit({ kind: 'room-version', locator, roomVersion: version });
96
192
  }
97
193
  }
98
194
  function interrupt(authority) {
@@ -100,7 +196,162 @@ export function houseNotifications(transport, mode) {
100
196
  if (line !== undefined)
101
197
  lines.set(authority, { ...line, frames: [] });
102
198
  }
103
- function receive(frame) {
199
+ async function forget(carries) {
200
+ const held = carries.filter((carry) => kept.delete(carry));
201
+ if (held.length > 0)
202
+ await receipts?.drop(held).catch(() => { });
203
+ }
204
+ async function lost(authority, carry) {
205
+ interrupt(authority);
206
+ await forget([carry]);
207
+ }
208
+ async function stage(frame, via) {
209
+ await loaded;
210
+ const port = receipts;
211
+ if (port === null)
212
+ return;
213
+ const held = kept.get(frame.carry);
214
+ if (held === undefined && frame.index !== 0) {
215
+ interrupt(frame.authority);
216
+ return;
217
+ }
218
+ if (held !== undefined &&
219
+ (held.fenced !== null || frame.index > held.parts || frame.index < (held.resume?.parts ?? 0))) {
220
+ await lost(frame.authority, frame.carry);
221
+ return;
222
+ }
223
+ if (held === undefined) {
224
+ await forget([...kept.values()]
225
+ .filter((other) => other.authority === frame.authority && other.fenced === null)
226
+ .map((other) => other.carry));
227
+ }
228
+ const start = held ?? {
229
+ authority: frame.authority,
230
+ carry: frame.carry,
231
+ logEpoch: lines.get(frame.authority)?.logEpoch ?? null,
232
+ after: frame.after,
233
+ parts: 0,
234
+ resume: null,
235
+ fenced: null,
236
+ };
237
+ const next = { ...start, parts: frame.index + 1, resume: resumed(start, frame) };
238
+ const part = { entries: frame.entries };
239
+ try {
240
+ await port.keep(frame.carry, next, { index: frame.index, value: part });
241
+ }
242
+ catch {
243
+ await lost(frame.authority, frame.carry);
244
+ return;
245
+ }
246
+ kept.set(frame.carry, next);
247
+ via?.received(frame.authority, frame.carry, frame.index);
248
+ }
249
+ async function keptEntries(carry, parts) {
250
+ if (parts === 0)
251
+ return [];
252
+ if (receipts === null)
253
+ return null;
254
+ const read = (await receipts.parts(carry, parts));
255
+ if (read.length !== parts)
256
+ return null;
257
+ const entries = assembled(read.flatMap((part) => part.entries));
258
+ return entries !== null && (await verified(entries)) ? entries : null;
259
+ }
260
+ async function carried(frame) {
261
+ await loaded;
262
+ const held = kept.get(frame.carry);
263
+ if (frame.parts > 0 && held?.parts !== frame.parts) {
264
+ await lost(frame.authority, frame.carry);
265
+ return;
266
+ }
267
+ const entries = await keptEntries(frame.carry, frame.parts).catch(() => null);
268
+ if (entries === null) {
269
+ await lost(frame.authority, frame.carry);
270
+ return;
271
+ }
272
+ const fenced = {
273
+ ...(held ?? {
274
+ authority: frame.authority,
275
+ carry: frame.carry,
276
+ logEpoch: frame.log_epoch,
277
+ after: frame.after,
278
+ parts: 0,
279
+ resume: null,
280
+ }),
281
+ after: frame.after,
282
+ fenced: { position: frame.position, logEpoch: frame.log_epoch },
283
+ };
284
+ try {
285
+ await receipts?.keep(frame.carry, fenced);
286
+ }
287
+ catch {
288
+ await lost(frame.authority, frame.carry);
289
+ return;
290
+ }
291
+ kept.set(frame.carry, fenced);
292
+ publish(frame, entries);
293
+ }
294
+ async function load(port) {
295
+ try {
296
+ for (const { key, head } of await port.heads())
297
+ kept.set(key, head);
298
+ }
299
+ catch {
300
+ kept.clear();
301
+ }
302
+ }
303
+ async function restored(room) {
304
+ const line = lines.get(room.authority);
305
+ let at = room.position;
306
+ const chain = [];
307
+ for (;;) {
308
+ const next = [...kept.values()].find((carry) => carry.authority === room.authority &&
309
+ carry.after === at &&
310
+ carry.fenced?.logEpoch === room.log_epoch);
311
+ if (next?.fenced == null)
312
+ break;
313
+ const entries = await keptEntries(next.carry, next.parts).catch(() => null);
314
+ if (entries === null)
315
+ break;
316
+ chain.push({ carry: next, entries });
317
+ at = next.fenced.position;
318
+ }
319
+ const partial = [...kept.values()].find((carry) => carry.authority === room.authority &&
320
+ carry.fenced === null &&
321
+ carry.logEpoch === room.log_epoch &&
322
+ carry.after === at &&
323
+ carry.resume !== null &&
324
+ carry.resume.parts > 0);
325
+ const stale = [...kept.values()].filter((carry) => carry.authority === room.authority &&
326
+ carry !== partial &&
327
+ !chain.some((link) => link.carry === carry));
328
+ await forget(stale.map((carry) => carry.carry));
329
+ if (line !== undefined && line.logEpoch === room.log_epoch && chain.length > 0) {
330
+ const frames = chain.map(({ carry, entries }) => ({
331
+ after: BigInt(carry.after),
332
+ position: BigInt(carry.fenced.position),
333
+ entries,
334
+ }));
335
+ lines.set(room.authority, { ...line, frames: [...line.frames, ...frames] });
336
+ }
337
+ return {
338
+ ...room,
339
+ position: at,
340
+ ...(partial?.resume == null
341
+ ? {}
342
+ : {
343
+ carry: {
344
+ id: partial.carry,
345
+ parts: partial.resume.parts,
346
+ from: partial.resume.from,
347
+ target: partial.resume.target,
348
+ handled: partial.resume.handled,
349
+ ...(partial.resume.piece === null ? {} : { piece: partial.resume.piece }),
350
+ },
351
+ }),
352
+ };
353
+ }
354
+ function handle(frame, via) {
104
355
  if (frame.type === 'signal') {
105
356
  const mode = frame.service_mode;
106
357
  if (mode !== 'open' && mode !== 'write-halted')
@@ -109,17 +360,47 @@ export function houseNotifications(transport, mode) {
109
360
  observer(mode);
110
361
  return;
111
362
  }
363
+ if (frame.type === 'opening') {
364
+ emit({
365
+ kind: 'opening',
366
+ expired: frame.expired.flatMap((authority) => locators.get(authority) ?? []),
367
+ });
368
+ return;
369
+ }
370
+ if (frame.type === 'authority_changed') {
371
+ emit({ kind: 'authority-changed', scope: { authorities: frame.rooms } });
372
+ return;
373
+ }
374
+ if (frame.type === 'conversations') {
375
+ emitConversation({ kind: 'list', entries: frame.conversations.map(listedConversation) });
376
+ return;
377
+ }
378
+ if (frame.type === 'conversation') {
379
+ emitConversation({ kind: 'listed', entry: listedConversation(frame.conversation) });
380
+ return;
381
+ }
382
+ if (frame.type === 'conversation_deleted') {
383
+ emitConversation({ kind: 'unlisted', conversation: frame.conversation_id });
384
+ return;
385
+ }
112
386
  if (frame.type === 'turn' ||
113
387
  frame.type === 'process' ||
114
388
  frame.type === 'commands' ||
115
389
  frame.type === 'options' ||
390
+ frame.type === 'starting' ||
391
+ frame.type === 'link' ||
392
+ frame.type === 'deliveries' ||
116
393
  frame.type === 'interactions' ||
117
394
  frame.type === 'message') {
118
395
  converse(frame);
119
396
  return;
120
397
  }
121
- if (frame.type !== 'entries')
122
- return;
398
+ if (frame.type === 'part')
399
+ return stage(frame, via);
400
+ if (frame.type === 'carried')
401
+ return carried(frame);
402
+ }
403
+ function publish(frame, entries) {
123
404
  const at = position(frame.position);
124
405
  const after = position(frame.after);
125
406
  if (at === null || after === null || after >= at) {
@@ -133,21 +414,45 @@ export function houseNotifications(transport, mode) {
133
414
  const last = line.frames.at(-1);
134
415
  if (last !== undefined && at <= last.position)
135
416
  return;
136
- const held = { after, position: at, entries: frame.entries };
417
+ const held = { after, position: at, entries };
137
418
  const next = last !== undefined && after <= last.position ? [...line.frames, held] : [held];
138
419
  lines.set(frame.authority, { ...line, frames: next.length > HELD_FRAMES_MAX ? [] : next });
139
420
  }
140
421
  else {
141
422
  interrupt(frame.authority);
142
423
  }
143
- const addresses = schemas.get(frame.authority) ?? [];
144
- announce(frame.authority, { position: frame.position, logEpoch: frame.log_epoch }, frame.entries.some((entry) => addresses.includes(entry.path)));
424
+ announce(frame.authority, { position: frame.position, logEpoch: frame.log_epoch });
145
425
  }
426
+ stream.observe((frame) => {
427
+ const via = acknowledging;
428
+ if (verifying === 0) {
429
+ const handled = handle(frame, via);
430
+ if (handled === undefined)
431
+ return;
432
+ verifying += 1;
433
+ receiving = handled.finally(() => {
434
+ verifying -= 1;
435
+ });
436
+ return;
437
+ }
438
+ verifying += 1;
439
+ receiving = receiving
440
+ .then(() => handle(frame, via))
441
+ .finally(() => {
442
+ verifying -= 1;
443
+ });
444
+ });
445
+ stream.opened(reopened);
446
+ stream.closed(({ revoked, lost }) => {
447
+ opening = null;
448
+ acknowledging = null;
449
+ emit({ kind: 'closed', revoked, lost });
450
+ });
146
451
  return {
452
+ runtime,
147
453
  serviceMode: {
148
454
  observe(notify) {
149
455
  modeObservers.add(notify);
150
- listen();
151
456
  return () => {
152
457
  modeObservers.delete(notify);
153
458
  };
@@ -159,22 +464,71 @@ export function houseNotifications(transport, mode) {
159
464
  },
160
465
  observe(notify) {
161
466
  conversationObservers.add(notify);
162
- listen();
163
- if (!catching) {
164
- catching = true;
165
- stream.opened(reopened);
166
- }
167
467
  return () => {
168
468
  conversationObservers.delete(notify);
169
469
  };
170
470
  },
171
471
  },
472
+ observe(notify, port) {
473
+ observers.add(notify);
474
+ if (receipts === null) {
475
+ receipts = port;
476
+ loaded = load(port);
477
+ }
478
+ if (opening !== null) {
479
+ queueMicrotask(() => {
480
+ if (observers.has(notify))
481
+ notify({ kind: 'opened' });
482
+ });
483
+ }
484
+ return () => {
485
+ observers.delete(notify);
486
+ };
487
+ },
488
+ send(rooms) {
489
+ for (const room of rooms) {
490
+ const line = lines.get(room.authority);
491
+ const held = position(room.position);
492
+ if (line === undefined || held === null || line.logEpoch !== room.log_epoch)
493
+ continue;
494
+ lines.set(room.authority, { ...line, frames: [], held });
495
+ }
496
+ const current = opening;
497
+ opening = null;
498
+ if (current === null)
499
+ return;
500
+ void loaded
501
+ .then(() => Promise.all(rooms.map(restored)))
502
+ .then((presented) => {
503
+ current.hold(presented, runtime);
504
+ for (const [index, room] of presented.entries()) {
505
+ if (room.position === rooms[index].position)
506
+ continue;
507
+ announce(room.authority, { position: room.position, logEpoch: room.log_epoch });
508
+ }
509
+ });
510
+ },
511
+ published(locator, at) {
512
+ const authority = [...locators].find(([, held]) => held.includes(locator))?.[0];
513
+ const reached = position(at.position);
514
+ if (authority === undefined || reached === null)
515
+ return;
516
+ void forget([...kept.values()]
517
+ .filter((carry) => carry.authority === authority &&
518
+ carry.fenced !== null &&
519
+ carry.fenced.logEpoch === at.logEpoch &&
520
+ BigInt(carry.fenced.position) <= reached)
521
+ .map((carry) => carry.carry));
522
+ },
523
+ reopen() {
524
+ const current = opening;
525
+ opening = null;
526
+ current?.close();
527
+ },
172
528
  track(entries) {
173
529
  locators.clear();
174
- schemas.clear();
175
530
  for (const entry of entries) {
176
531
  locators.set(entry.authority, [...(locators.get(entry.authority) ?? []), entry.locator]);
177
- schemas.set(entry.authority, entry.schemas);
178
532
  if (lines.get(entry.authority)?.logEpoch !== entry.logEpoch) {
179
533
  lines.set(entry.authority, { logEpoch: entry.logEpoch, frames: [], held: null });
180
534
  }
@@ -183,21 +537,22 @@ export function houseNotifications(transport, mode) {
183
537
  if (!locators.has(authority))
184
538
  lines.delete(authority);
185
539
  }
540
+ void loaded.then(() => forget([...kept.values()]
541
+ .filter((carry) => !locators.has(carry.authority))
542
+ .map((carry) => carry.carry)));
186
543
  },
187
- select() { },
188
- observe(notify) {
189
- observers.add(notify);
190
- listen();
191
- return () => {
192
- observers.delete(notify);
193
- };
194
- },
195
- hold(authority, at) {
544
+ reach(authority, at) {
196
545
  const line = lines.get(authority);
197
546
  const held = position(at.position);
198
547
  if (line === undefined || held === null || line.logEpoch !== at.logEpoch)
199
548
  return;
200
- lines.set(authority, { ...line, held });
549
+ if (line.held !== null && held <= line.held)
550
+ return;
551
+ lines.set(authority, {
552
+ ...line,
553
+ frames: line.frames.filter((frame) => frame.position > held),
554
+ held,
555
+ });
201
556
  },
202
557
  advance(tracked, from, holds) {
203
558
  const line = lines.get(tracked.authority);
@@ -211,12 +566,15 @@ export function houseNotifications(transport, mode) {
211
566
  const documents = {};
212
567
  const revisions = {};
213
568
  const changes = {};
569
+ const binaryFiles = {};
214
570
  const removals = [];
215
571
  const applied = [];
572
+ const schemas = new Map();
216
573
  const forget = (path) => {
217
574
  delete documents[path];
218
575
  delete revisions[path];
219
576
  delete changes[path];
577
+ delete binaryFiles[path];
220
578
  const removed = removals.indexOf(path);
221
579
  if (removed !== -1)
222
580
  removals.splice(removed, 1);
@@ -224,19 +582,21 @@ export function houseNotifications(transport, mode) {
224
582
  for (const frame of pending) {
225
583
  for (const entry of frame.entries) {
226
584
  if (entry.kind === 'edited' &&
227
- entry.text === undefined &&
228
585
  entry.revision !== undefined &&
229
586
  holds?.(entry.path, entry.revision) === true) {
230
587
  forget(entry.path);
231
588
  continue;
232
589
  }
233
590
  applied.push(entry);
591
+ if (tracked.schemas.includes(entry.path))
592
+ schemas.set(entry.path, entry);
234
593
  if (entry.kind === 'removed') {
235
594
  forget(entry.path);
236
595
  removals.push(entry.path);
237
596
  continue;
238
597
  }
239
- if (entry.text === undefined)
598
+ const binary = binaryFileOf(entry);
599
+ if (binary === null || (binary === undefined && entry.text === undefined))
240
600
  return null;
241
601
  if (mode === 'credential' && entry.revision === undefined)
242
602
  return null;
@@ -244,9 +604,13 @@ export function houseNotifications(transport, mode) {
244
604
  if (head === null)
245
605
  return null;
246
606
  forget(entry.path);
247
- documents[entry.path] = entry.text;
248
- if (entry.revision !== undefined)
249
- revisions[entry.path] = entry.revision;
607
+ if (binary === undefined)
608
+ documents[entry.path] = entry.text;
609
+ else
610
+ binaryFiles[entry.path] = binary;
611
+ const revision = entry.revision ?? binary?.sha256;
612
+ if (revision !== undefined)
613
+ revisions[entry.path] = revision;
250
614
  if (head !== undefined)
251
615
  changes[entry.path] = head;
252
616
  }
@@ -259,11 +623,13 @@ export function houseNotifications(transport, mode) {
259
623
  roomVersion: roomVersion({ position: last.position.toString(), logEpoch: line.logEpoch }),
260
624
  documents,
261
625
  revisions,
626
+ ...identities(revisions),
262
627
  changes,
263
- binaryTargets: [],
628
+ binaryFiles,
264
629
  removals: removals.sort(),
265
630
  },
266
631
  entries: applied,
632
+ schemas,
267
633
  };
268
634
  },
269
635
  };