@agentshouse/mdruntime-adapter 0.1.0-c29c7d612b2d0 → 0.1.0-c2ae88cedfb65

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.
package/dist/stream.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { acceptedMessage } from './actions.js';
2
2
  import { sha256Hex } from './digest.js';
3
- import { binaryFileOf, headChange } from './read.js';
3
+ import { binaryFileOf, headChange, identities } from './read.js';
4
4
  import { roomVersion } from './version.js';
5
5
  const HELD_FRAMES_MAX = 256;
6
6
  function turnOperation(frame) {
@@ -15,6 +15,7 @@ function listedConversation(listed) {
15
15
  created: listed.created_at,
16
16
  finished: listed.finished_at,
17
17
  outcome: listed.outcome,
18
+ waiting: listed.waiting,
18
19
  };
19
20
  }
20
21
  function position(value) {
@@ -53,7 +54,9 @@ function assembled(entries) {
53
54
  async function verified(entries) {
54
55
  try {
55
56
  for (const entry of entries) {
56
- if ((await sha256Hex(entry.text ?? '')) !== entry.sha256)
57
+ if (entry.text === undefined || entry.sha256 === undefined)
58
+ continue;
59
+ if ((await sha256Hex(entry.text)) !== entry.sha256)
57
60
  return false;
58
61
  }
59
62
  return true;
@@ -62,10 +65,34 @@ async function verified(entries) {
62
65
  return false;
63
66
  }
64
67
  }
68
+ function resumed(kept, frame) {
69
+ const last = frame.entries.at(-1);
70
+ const point = { parts: frame.index + 1, from: frame.from, target: frame.target };
71
+ if (last?.continued !== true)
72
+ return { ...point, handled: frame.handled, piece: null };
73
+ const text = last.text?.length ?? 0;
74
+ if (last.kind !== 'piece') {
75
+ return last.sha256 === undefined
76
+ ? kept.resume
77
+ : { ...point, handled: frame.handled, piece: { sha256: last.sha256, offset: text } };
78
+ }
79
+ const piece = kept.resume?.piece ?? null;
80
+ if (piece === null)
81
+ return kept.resume;
82
+ const pieces = frame.entries.reduce((sum, entry) => sum + (entry.kind === 'piece' ? (entry.text?.length ?? 0) : 0), 0);
83
+ return {
84
+ ...point,
85
+ handled: frame.handled,
86
+ piece: { sha256: piece.sha256, offset: piece.offset + pieces },
87
+ };
88
+ }
65
89
  export function houseNotifications(transport, mode) {
66
90
  const stream = transport.stream;
67
91
  const lines = new Map();
68
- const staged = new Map();
92
+ const kept = new Map();
93
+ let receipts = null;
94
+ let loaded = Promise.resolve();
95
+ let acknowledging = null;
69
96
  let receiving = Promise.resolve();
70
97
  let verifying = 0;
71
98
  const locators = new Map();
@@ -85,7 +112,10 @@ export function houseNotifications(transport, mode) {
85
112
  event.kind === 'questions' ||
86
113
  event.kind === 'process' ||
87
114
  event.kind === 'commands' ||
88
- event.kind === 'options') {
115
+ event.kind === 'options' ||
116
+ event.kind === 'starting' ||
117
+ event.kind === 'link' ||
118
+ event.kind === 'deliveries') {
89
119
  live.add(event.conversation);
90
120
  }
91
121
  for (const observer of conversationObservers)
@@ -93,7 +123,7 @@ export function houseNotifications(transport, mode) {
93
123
  }
94
124
  function reopened(next) {
95
125
  opening = next;
96
- staged.clear();
126
+ acknowledging = next;
97
127
  const gapped = new Set([...replicated, ...live]);
98
128
  live.clear();
99
129
  for (const conversation of gapped)
@@ -131,6 +161,18 @@ export function houseNotifications(transport, mode) {
131
161
  emitConversation({ kind: 'options', conversation, options: structuredClone(frame.options) });
132
162
  return;
133
163
  }
164
+ if (frame.type === 'starting') {
165
+ emitConversation({ kind: 'starting', conversation, step: frame.step });
166
+ return;
167
+ }
168
+ if (frame.type === 'link') {
169
+ emitConversation({ kind: 'link', conversation, connected: frame.connected });
170
+ return;
171
+ }
172
+ if (frame.type === 'deliveries') {
173
+ emitConversation({ kind: 'deliveries', conversation, unknown: [...frame.unknown] });
174
+ return;
175
+ }
134
176
  if (frame.type === 'interactions') {
135
177
  emitConversation({
136
178
  kind: 'questions',
@@ -155,46 +197,162 @@ export function houseNotifications(transport, mode) {
155
197
  if (line !== undefined)
156
198
  lines.set(authority, { ...line, frames: [] });
157
199
  }
158
- function stage(frame) {
159
- const held = staged.get(frame.authority);
160
- if (frame.index === 0) {
161
- staged.set(frame.authority, { carry: frame.carry, parts: 1, entries: [...frame.entries] });
200
+ async function forget(carries) {
201
+ const held = carries.filter((carry) => kept.delete(carry));
202
+ if (held.length > 0)
203
+ await receipts?.drop(held).catch(() => { });
204
+ }
205
+ async function lost(authority, carry) {
206
+ interrupt(authority);
207
+ await forget([carry]);
208
+ }
209
+ async function stage(frame, via) {
210
+ await loaded;
211
+ const port = receipts;
212
+ if (port === null)
162
213
  return;
163
- }
164
- if (held?.carry !== frame.carry || held.parts !== frame.index) {
165
- staged.delete(frame.authority);
214
+ const held = kept.get(frame.carry);
215
+ if (held === undefined && frame.index !== 0) {
166
216
  interrupt(frame.authority);
167
217
  return;
168
218
  }
169
- held.parts += 1;
170
- held.entries.push(...frame.entries);
219
+ if (held !== undefined &&
220
+ (held.fenced !== null || frame.index > held.parts || frame.index < (held.resume?.parts ?? 0))) {
221
+ await lost(frame.authority, frame.carry);
222
+ return;
223
+ }
224
+ if (held === undefined) {
225
+ await forget([...kept.values()]
226
+ .filter((other) => other.authority === frame.authority && other.fenced === null)
227
+ .map((other) => other.carry));
228
+ }
229
+ const start = held ?? {
230
+ authority: frame.authority,
231
+ carry: frame.carry,
232
+ logEpoch: lines.get(frame.authority)?.logEpoch ?? null,
233
+ after: frame.after,
234
+ parts: 0,
235
+ resume: null,
236
+ fenced: null,
237
+ };
238
+ const next = { ...start, parts: frame.index + 1, resume: resumed(start, frame) };
239
+ const part = { entries: frame.entries };
240
+ try {
241
+ await port.keep(frame.carry, next, { index: frame.index, value: part });
242
+ }
243
+ catch {
244
+ await lost(frame.authority, frame.carry);
245
+ return;
246
+ }
247
+ kept.set(frame.carry, next);
248
+ via?.received(frame.authority, frame.carry, frame.index);
171
249
  }
172
- function carried(frame) {
173
- const held = staged.get(frame.authority);
174
- staged.delete(frame.authority);
175
- const parts = frame.parts === 0
176
- ? []
177
- : held?.carry === frame.carry && held.parts === frame.parts
178
- ? held.entries
179
- : null;
180
- const entries = parts === null ? null : assembled(parts);
250
+ async function keptEntries(carry, parts) {
251
+ if (parts === 0)
252
+ return [];
253
+ if (receipts === null)
254
+ return null;
255
+ const read = (await receipts.parts(carry, parts));
256
+ if (read.length !== parts)
257
+ return null;
258
+ const entries = assembled(read.flatMap((part) => part.entries));
259
+ return entries !== null && (await verified(entries)) ? entries : null;
260
+ }
261
+ async function carried(frame) {
262
+ await loaded;
263
+ const held = kept.get(frame.carry);
264
+ if (frame.parts > 0 && held?.parts !== frame.parts) {
265
+ await lost(frame.authority, frame.carry);
266
+ return;
267
+ }
268
+ const entries = await keptEntries(frame.carry, frame.parts).catch(() => null);
181
269
  if (entries === null) {
182
- interrupt(frame.authority);
270
+ await lost(frame.authority, frame.carry);
183
271
  return;
184
272
  }
185
- const digested = entries.filter((entry) => entry.text !== undefined && entry.sha256 !== undefined);
186
- if (digested.length === 0) {
187
- publish(frame, entries);
273
+ const fenced = {
274
+ ...(held ?? {
275
+ authority: frame.authority,
276
+ carry: frame.carry,
277
+ logEpoch: frame.log_epoch,
278
+ after: frame.after,
279
+ parts: 0,
280
+ resume: null,
281
+ }),
282
+ after: frame.after,
283
+ fenced: { position: frame.position, logEpoch: frame.log_epoch },
284
+ };
285
+ try {
286
+ await receipts?.keep(frame.carry, fenced);
287
+ }
288
+ catch {
289
+ await lost(frame.authority, frame.carry);
188
290
  return;
189
291
  }
190
- return verified(digested).then((whole) => {
191
- if (whole)
192
- publish(frame, entries);
193
- else
194
- interrupt(frame.authority);
195
- });
292
+ kept.set(frame.carry, fenced);
293
+ publish(frame, entries);
196
294
  }
197
- function handle(frame) {
295
+ async function load(port) {
296
+ try {
297
+ for (const { key, head } of await port.heads())
298
+ kept.set(key, head);
299
+ }
300
+ catch {
301
+ kept.clear();
302
+ }
303
+ }
304
+ async function restored(room) {
305
+ const line = lines.get(room.authority);
306
+ let at = room.position;
307
+ const chain = [];
308
+ for (;;) {
309
+ const next = [...kept.values()].find((carry) => carry.authority === room.authority &&
310
+ carry.after === at &&
311
+ carry.fenced?.logEpoch === room.log_epoch);
312
+ if (next?.fenced == null)
313
+ break;
314
+ const entries = await keptEntries(next.carry, next.parts).catch(() => null);
315
+ if (entries === null)
316
+ break;
317
+ chain.push({ carry: next, entries });
318
+ at = next.fenced.position;
319
+ }
320
+ const partial = [...kept.values()].find((carry) => carry.authority === room.authority &&
321
+ carry.fenced === null &&
322
+ carry.logEpoch === room.log_epoch &&
323
+ carry.after === at &&
324
+ carry.resume !== null &&
325
+ carry.resume.parts > 0);
326
+ const stale = [...kept.values()].filter((carry) => carry.authority === room.authority &&
327
+ carry !== partial &&
328
+ !chain.some((link) => link.carry === carry));
329
+ await forget(stale.map((carry) => carry.carry));
330
+ if (line !== undefined && line.logEpoch === room.log_epoch && chain.length > 0) {
331
+ const frames = chain.map(({ carry, entries }) => ({
332
+ after: BigInt(carry.after),
333
+ position: BigInt(carry.fenced.position),
334
+ entries,
335
+ }));
336
+ lines.set(room.authority, { ...line, frames: [...line.frames, ...frames] });
337
+ }
338
+ return {
339
+ ...room,
340
+ position: at,
341
+ ...(partial?.resume == null
342
+ ? {}
343
+ : {
344
+ carry: {
345
+ id: partial.carry,
346
+ parts: partial.resume.parts,
347
+ from: partial.resume.from,
348
+ target: partial.resume.target,
349
+ handled: partial.resume.handled,
350
+ ...(partial.resume.piece === null ? {} : { piece: partial.resume.piece }),
351
+ },
352
+ }),
353
+ };
354
+ }
355
+ function handle(frame, via) {
198
356
  if (frame.type === 'signal') {
199
357
  const mode = frame.service_mode;
200
358
  if (mode !== 'open' && mode !== 'write-halted')
@@ -210,6 +368,10 @@ export function houseNotifications(transport, mode) {
210
368
  });
211
369
  return;
212
370
  }
371
+ if (frame.type === 'authority_changed') {
372
+ emit({ kind: 'authority-changed', scope: { authorities: frame.rooms } });
373
+ return;
374
+ }
213
375
  if (frame.type === 'conversations') {
214
376
  emitConversation({ kind: 'list', entries: frame.conversations.map(listedConversation) });
215
377
  return;
@@ -226,15 +388,16 @@ export function houseNotifications(transport, mode) {
226
388
  frame.type === 'process' ||
227
389
  frame.type === 'commands' ||
228
390
  frame.type === 'options' ||
391
+ frame.type === 'starting' ||
392
+ frame.type === 'link' ||
393
+ frame.type === 'deliveries' ||
229
394
  frame.type === 'interactions' ||
230
395
  frame.type === 'message') {
231
396
  converse(frame);
232
397
  return;
233
398
  }
234
- if (frame.type === 'part') {
235
- stage(frame);
236
- return;
237
- }
399
+ if (frame.type === 'part')
400
+ return stage(frame, via);
238
401
  if (frame.type === 'carried')
239
402
  return carried(frame);
240
403
  }
@@ -262,8 +425,9 @@ export function houseNotifications(transport, mode) {
262
425
  announce(frame.authority, { position: frame.position, logEpoch: frame.log_epoch });
263
426
  }
264
427
  stream.observe((frame) => {
428
+ const via = acknowledging;
265
429
  if (verifying === 0) {
266
- const handled = handle(frame);
430
+ const handled = handle(frame, via);
267
431
  if (handled === undefined)
268
432
  return;
269
433
  verifying += 1;
@@ -274,16 +438,16 @@ export function houseNotifications(transport, mode) {
274
438
  }
275
439
  verifying += 1;
276
440
  receiving = receiving
277
- .then(() => handle(frame))
441
+ .then(() => handle(frame, via))
278
442
  .finally(() => {
279
443
  verifying -= 1;
280
444
  });
281
445
  });
282
446
  stream.opened(reopened);
283
- stream.closed((revoked) => {
447
+ stream.closed(({ revoked, lost }) => {
284
448
  opening = null;
285
- staged.clear();
286
- emit({ kind: 'closed', revoked });
449
+ acknowledging = null;
450
+ emit({ kind: 'closed', revoked, lost });
287
451
  });
288
452
  return {
289
453
  runtime,
@@ -306,8 +470,12 @@ export function houseNotifications(transport, mode) {
306
470
  };
307
471
  },
308
472
  },
309
- observe(notify) {
473
+ observe(notify, port) {
310
474
  observers.add(notify);
475
+ if (receipts === null) {
476
+ receipts = port;
477
+ loaded = load(port);
478
+ }
311
479
  if (opening !== null) {
312
480
  queueMicrotask(() => {
313
481
  if (observers.has(notify))
@@ -328,7 +496,30 @@ export function houseNotifications(transport, mode) {
328
496
  }
329
497
  const current = opening;
330
498
  opening = null;
331
- current?.hold(rooms, runtime);
499
+ if (current === null)
500
+ return;
501
+ void loaded
502
+ .then(() => Promise.all(rooms.map(restored)))
503
+ .then((presented) => {
504
+ current.hold(presented, runtime);
505
+ for (const [index, room] of presented.entries()) {
506
+ if (room.position === rooms[index].position)
507
+ continue;
508
+ announce(room.authority, { position: room.position, logEpoch: room.log_epoch });
509
+ }
510
+ });
511
+ },
512
+ published(locator, at) {
513
+ const authority = [...locators].find(([, held]) => held.includes(locator))?.[0];
514
+ const reached = position(at.position);
515
+ if (authority === undefined || reached === null)
516
+ return;
517
+ void forget([...kept.values()]
518
+ .filter((carry) => carry.authority === authority &&
519
+ carry.fenced !== null &&
520
+ carry.fenced.logEpoch === at.logEpoch &&
521
+ BigInt(carry.fenced.position) <= reached)
522
+ .map((carry) => carry.carry));
332
523
  },
333
524
  reopen() {
334
525
  const current = opening;
@@ -347,6 +538,9 @@ export function houseNotifications(transport, mode) {
347
538
  if (!locators.has(authority))
348
539
  lines.delete(authority);
349
540
  }
541
+ void loaded.then(() => forget([...kept.values()]
542
+ .filter((carry) => !locators.has(carry.authority))
543
+ .map((carry) => carry.carry)));
350
544
  },
351
545
  reach(authority, at) {
352
546
  const line = lines.get(authority);
@@ -430,6 +624,7 @@ export function houseNotifications(transport, mode) {
430
624
  roomVersion: roomVersion({ position: last.position.toString(), logEpoch: line.logEpoch }),
431
625
  documents,
432
626
  revisions,
627
+ ...identities(revisions),
433
628
  changes,
434
629
  binaryFiles,
435
630
  removals: removals.sort(),
@@ -58,12 +58,17 @@ export type HouseListedConversation = {
58
58
  created_at: string;
59
59
  finished_at: string | null;
60
60
  outcome: string | null;
61
+ waiting: boolean;
61
62
  };
62
63
  export type HouseStreamFrame = {
63
64
  type: 'part';
64
65
  authority: string;
65
66
  carry: string;
66
67
  index: number;
68
+ after: string;
69
+ from: string;
70
+ target: string;
71
+ handled: number;
67
72
  entries: readonly HouseStreamEntry[];
68
73
  } | {
69
74
  type: 'carried';
@@ -76,6 +81,9 @@ export type HouseStreamFrame = {
76
81
  } | {
77
82
  type: 'opening';
78
83
  expired: readonly string[];
84
+ } | {
85
+ type: 'authority_changed';
86
+ rooms: readonly string[];
79
87
  } | ({
80
88
  type: 'turn';
81
89
  conversation_id: string;
@@ -88,6 +96,10 @@ export type HouseStreamFrame = {
88
96
  type: 'interactions';
89
97
  conversation_id: string;
90
98
  interactions: readonly unknown[];
99
+ } | {
100
+ type: 'deliveries';
101
+ conversation_id: string;
102
+ unknown: readonly string[];
91
103
  } | {
92
104
  type: 'process';
93
105
  conversation_id: string;
@@ -100,6 +112,14 @@ export type HouseStreamFrame = {
100
112
  type: 'options';
101
113
  conversation_id: string;
102
114
  options: LiveFact<'options'>['options'];
115
+ } | {
116
+ type: 'starting';
117
+ conversation_id: string;
118
+ step: string | null;
119
+ } | {
120
+ type: 'link';
121
+ conversation_id: string;
122
+ connected: boolean;
103
123
  } | {
104
124
  type: 'conversations';
105
125
  conversations: readonly HouseListedConversation[];
@@ -113,19 +133,36 @@ export type HouseStreamFrame = {
113
133
  type: 'signal';
114
134
  service_mode: string;
115
135
  };
136
+ export type HouseHeldCarry = {
137
+ id: string;
138
+ parts: number;
139
+ from: string;
140
+ target: string;
141
+ handled: number;
142
+ piece?: {
143
+ sha256: string;
144
+ offset: number;
145
+ };
146
+ };
116
147
  export type HouseHeldRoom = {
117
148
  authority: string;
118
149
  position: string;
119
150
  log_epoch: string;
151
+ carry?: HouseHeldCarry;
120
152
  };
121
153
  export type HouseOpening = {
122
154
  hold(rooms: readonly HouseHeldRoom[], runtime: string): void;
155
+ received(authority: string, carry: string, index: number): void;
123
156
  close(): void;
124
157
  };
158
+ export type HouseClosing = {
159
+ revoked: boolean;
160
+ lost: boolean;
161
+ };
125
162
  export type HouseStream = {
126
163
  observe(receive: (frame: HouseStreamFrame) => void): () => void;
127
164
  opened(notify: (opening: HouseOpening) => void): () => void;
128
- closed(notify: (revoked: boolean) => void): () => void;
165
+ closed(notify: (closing: HouseClosing) => void): () => void;
129
166
  };
130
167
  export type HouseDoor = {
131
168
  door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CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACpD,CAAC"}
package/dist/version.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare function roomVersion(at: LogPosition): string;
11
11
  export declare function logPosition(version: string): LogPosition | null;
12
12
  export declare function readPosition(held: Readonly<Record<string, unknown>>): LogPosition | null;
13
13
  export declare function presented(authority: string, at: LogPosition): PresentedPosition;
14
+ export declare const DECIMAL: RegExp;
14
15
  export declare function reachedVersion(roomVersion: string, target: string, currentEpoch: string | undefined): boolean;
15
16
  export declare function followsVersion(roomVersion: string, next: string): boolean;
16
17
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAEnD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAI/D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,WAAW,GAAG,IAAI,CAKxF;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,iBAAiB,CAE/E;AAID,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,OAAO,CAQT;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMzE"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAEnD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAI/D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,WAAW,GAAG,IAAI,CAKxF;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,iBAAiB,CAE/E;AAED,eAAO,MAAM,OAAO,QAAwB,CAAC;AAE7C,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,OAAO,CAQT;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMzE"}
package/dist/version.js CHANGED
@@ -18,7 +18,7 @@ export function readPosition(held) {
18
18
  export function presented(authority, at) {
19
19
  return { authority, position: at.position, log_epoch: at.logEpoch };
20
20
  }
21
- const DECIMAL = /^(?:0|[1-9][0-9]*)$/;
21
+ export const DECIMAL = /^(?:0|[1-9][0-9]*)$/;
22
22
  export function reachedVersion(roomVersion, target, currentEpoch) {
23
23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,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;IAEjF,IAAI,EAAE,UAAU;IAChB,QAAQ;IACR,IAAI;IACJ,MAAM;QAAI,IAAI;;IACd,SAAS;EAEZ;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM1B;AA4BD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,aAAa,CAyDf"}
package/dist/write.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { departure, } from '@agentshouse/mdruntime';
2
- import { binaryFileOf, headChange } from './read.js';
2
+ import { binaryFileOf, headChange, identities } from './read.js';
3
3
  import { sha256Hex, textBytes } from './digest.js';
4
4
  import { nativePath, roomLocalPath } from './map.js';
5
5
  import { classifyDoor, doorRefusal, scopedRefusal } from './refusal.js';
@@ -194,8 +194,11 @@ export function mutationOutcome(status, body, locator, handle) {
194
194
  if (refusal !== null && refusal.code === 'service_mode_write_halted') {
195
195
  return { kind: 'write-halted' };
196
196
  }
197
- if (refusal !== null && refusal.code === 'expired')
198
- return { kind: 'expired' };
197
+ if (refusal !== null && refusal.code === 'expired') {
198
+ return refusal.fields.restored === true
199
+ ? { kind: 'expired', restored: true }
200
+ : { kind: 'expired' };
201
+ }
199
202
  if (refusal !== null && refusal.code === 'edit_conflict') {
200
203
  const { current, ...fields } = refusal.fields;
201
204
  const held = material(current, handle) ?? [];
@@ -269,6 +272,7 @@ export function mutationOutcome(status, body, locator, handle) {
269
272
  roomVersion: roomVersion(at),
270
273
  documents,
271
274
  revisions,
275
+ ...identities(revisions),
272
276
  changes,
273
277
  removals: removals.sort(),
274
278
  ...(Object.keys(binaryFiles).length === 0 ? {} : { binaryFiles }),
@@ -337,7 +341,7 @@ export function historyOutcome(status, body, locator, request) {
337
341
  return {
338
342
  kind: 'scoped-refusal',
339
343
  locator,
340
- scope: 'content',
344
+ scope: 'operation',
341
345
  code: 'retained_history_unavailable',
342
346
  fields: { path: request.path, revision: request.revision },
343
347
  retryable: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime-adapter",
3
- "version": "0.1.0-c29c7d612b2d0",
3
+ "version": "0.1.0-c2ae88cedfb65",
4
4
  "description": "Agents House Adapter for the MD Runtime",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,6 +25,6 @@
25
25
  "LICENSE"
26
26
  ],
27
27
  "dependencies": {
28
- "@agentshouse/mdruntime": "0.1.0-c69ca0e865e0b"
28
+ "@agentshouse/mdruntime": "0.1.0-cc5745cd9af96"
29
29
  }
30
30
  }