@agentshouse/mdruntime 0.1.0-ccbe92df1c4f6 → 0.1.0-ccd098ff75bbf

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 (131) hide show
  1. package/README.md +10 -8
  2. package/dist/adapter.d.ts +1 -1
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/attached-model.d.ts +2 -1
  5. package/dist/attached-model.d.ts.map +1 -1
  6. package/dist/attached-model.js +10 -3
  7. package/dist/bootstrap.d.ts +1 -2
  8. package/dist/bootstrap.d.ts.map +1 -1
  9. package/dist/bootstrap.js +7 -8
  10. package/dist/client.d.ts +2 -1
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/client.js +2 -1
  13. package/dist/collection.d.ts.map +1 -1
  14. package/dist/collection.js +1 -2
  15. package/dist/compile.d.ts.map +1 -1
  16. package/dist/compile.js +31 -12
  17. package/dist/connection.d.ts +1 -1
  18. package/dist/connection.d.ts.map +1 -1
  19. package/dist/connection.js +150 -157
  20. package/dist/conversation.d.ts.map +1 -1
  21. package/dist/conversation.js +5 -2
  22. package/dist/host.d.ts.map +1 -1
  23. package/dist/host.js +27 -7
  24. package/dist/memory.d.ts +1 -1
  25. package/dist/memory.d.ts.map +1 -1
  26. package/dist/memory.js +2 -6
  27. package/dist/model.d.ts.map +1 -1
  28. package/dist/model.js +1 -1
  29. package/dist/reach.d.ts.map +1 -1
  30. package/dist/reach.js +16 -9
  31. package/dist/readiness.d.ts +1 -0
  32. package/dist/readiness.d.ts.map +1 -1
  33. package/dist/readiness.js +4 -4
  34. package/dist/refresh.d.ts.map +1 -1
  35. package/dist/refresh.js +1 -5
  36. package/dist/replica.d.ts +1 -2
  37. package/dist/replica.d.ts.map +1 -1
  38. package/dist/replica.js +2 -2
  39. package/dist/room-draft.d.ts +1 -0
  40. package/dist/room-draft.d.ts.map +1 -1
  41. package/dist/room-draft.js +33 -0
  42. package/dist/rows.d.ts +11 -4
  43. package/dist/rows.d.ts.map +1 -1
  44. package/dist/rows.js +73 -54
  45. package/dist/store.d.ts +0 -1
  46. package/dist/store.d.ts.map +1 -1
  47. package/dist/stored.d.ts.map +1 -1
  48. package/dist/stored.js +6 -16
  49. package/dist/tables.d.ts +10 -0
  50. package/dist/tables.d.ts.map +1 -1
  51. package/dist/tables.js +46 -2
  52. package/package.json +10 -17
  53. package/AGENTS.md +0 -317
  54. package/dist/chat/acts.d.ts +0 -33
  55. package/dist/chat/acts.d.ts.map +0 -1
  56. package/dist/chat/acts.js +0 -36
  57. package/dist/chat/context.d.ts +0 -3
  58. package/dist/chat/context.d.ts.map +0 -1
  59. package/dist/chat/context.js +0 -10
  60. package/dist/chat/earlier.d.ts +0 -10
  61. package/dist/chat/earlier.d.ts.map +0 -1
  62. package/dist/chat/earlier.js +0 -54
  63. package/dist/chat/house.d.ts +0 -25
  64. package/dist/chat/house.d.ts.map +0 -1
  65. package/dist/chat/house.js +0 -38
  66. package/dist/chat/input.d.ts +0 -11
  67. package/dist/chat/input.d.ts.map +0 -1
  68. package/dist/chat/input.js +0 -92
  69. package/dist/chat/kit.d.ts +0 -61
  70. package/dist/chat/kit.d.ts.map +0 -1
  71. package/dist/chat/kit.js +0 -123
  72. package/dist/chat/lasting.d.ts +0 -6
  73. package/dist/chat/lasting.d.ts.map +0 -1
  74. package/dist/chat/lasting.js +0 -19
  75. package/dist/chat/list.d.ts +0 -28
  76. package/dist/chat/list.d.ts.map +0 -1
  77. package/dist/chat/list.js +0 -103
  78. package/dist/chat/markdown.d.ts +0 -20
  79. package/dist/chat/markdown.d.ts.map +0 -1
  80. package/dist/chat/markdown.js +0 -229
  81. package/dist/chat/message.d.ts +0 -7
  82. package/dist/chat/message.d.ts.map +0 -1
  83. package/dist/chat/message.js +0 -254
  84. package/dist/chat/messages.d.ts +0 -35
  85. package/dist/chat/messages.d.ts.map +0 -1
  86. package/dist/chat/messages.js +0 -210
  87. package/dist/chat/name.d.ts +0 -7
  88. package/dist/chat/name.d.ts.map +0 -1
  89. package/dist/chat/name.js +0 -37
  90. package/dist/chat/opened.d.ts +0 -12
  91. package/dist/chat/opened.d.ts.map +0 -1
  92. package/dist/chat/opened.js +0 -19
  93. package/dist/chat/overlay.d.ts +0 -32
  94. package/dist/chat/overlay.d.ts.map +0 -1
  95. package/dist/chat/overlay.js +0 -103
  96. package/dist/chat/parts.d.ts +0 -58
  97. package/dist/chat/parts.d.ts.map +0 -1
  98. package/dist/chat/parts.js +0 -120
  99. package/dist/chat/pieces.d.ts +0 -62
  100. package/dist/chat/pieces.d.ts.map +0 -1
  101. package/dist/chat/pieces.js +0 -1110
  102. package/dist/chat/process.d.ts +0 -20
  103. package/dist/chat/process.d.ts.map +0 -1
  104. package/dist/chat/process.js +0 -32
  105. package/dist/chat/provider.d.ts +0 -70
  106. package/dist/chat/provider.d.ts.map +0 -1
  107. package/dist/chat/provider.js +0 -635
  108. package/dist/chat/question.d.ts +0 -9
  109. package/dist/chat/question.d.ts.map +0 -1
  110. package/dist/chat/question.js +0 -69
  111. package/dist/chat/questions.d.ts +0 -31
  112. package/dist/chat/questions.d.ts.map +0 -1
  113. package/dist/chat/questions.js +0 -111
  114. package/dist/chat/read.d.ts +0 -5
  115. package/dist/chat/read.d.ts.map +0 -1
  116. package/dist/chat/read.js +0 -13
  117. package/dist/chat/ready.d.ts +0 -37
  118. package/dist/chat/ready.d.ts.map +0 -1
  119. package/dist/chat/ready.js +0 -93
  120. package/dist/chat/room-file.d.ts +0 -8
  121. package/dist/chat/room-file.d.ts.map +0 -1
  122. package/dist/chat/room-file.js +0 -72
  123. package/dist/chat/steady.d.ts +0 -3
  124. package/dist/chat/steady.d.ts.map +0 -1
  125. package/dist/chat/steady.js +0 -26
  126. package/dist/chat/style.d.ts +0 -4
  127. package/dist/chat/style.d.ts.map +0 -1
  128. package/dist/chat/style.js +0 -307
  129. package/dist/chat.d.ts +0 -15
  130. package/dist/chat.d.ts.map +0 -1
  131. package/dist/chat.js +0 -8
@@ -1,5 +1,5 @@
1
1
  import { escapePointer, parseFrontmatter, roomTarget, target } from '@agentshouse/mdmodel';
2
- import { attachedModel, NO_ROOM_TYPES, roomTypesOf } from './attached-model.js';
2
+ import { attachedModel, builtInModel, roomTypesOf } from './attached-model.js';
3
3
  import { cached, modelTypes, NO_MODEL, sameModel, } from './model.js';
4
4
  import { observing, whole } from './observation.js';
5
5
  import { filterOf, identityOf, planOf, plain, queryKey, } from './query.js';
@@ -23,7 +23,7 @@ import { doorReads } from './reads.js';
23
23
  import { advancement } from './refresh.js';
24
24
  import { buildBatch, buildMove, joined, limiting, queuedDocuments, requeuing, } from './save.js';
25
25
  import { compositionOf, entryAt, landed, movedBy, overlayOf, replaying, returning, returnedPaths, sameMembership, slicing, slicingWith, standing, storedRecord, touchedBy, } from './replica.js';
26
- import { binaryBase, changedParts, changesOf, held, heldFile, joinedDraft, moveTarget, readParts, returnedBy, returnedInto, staleWrite, underneath, withdrawnDrafts, } from './room-draft.js';
26
+ import { binaryBase, changedParts, changesOf, gatheredParts, held, heldFile, joinedDraft, moveTarget, readParts, returnedBy, returnedInto, staleWrite, underneath, withdrawnDrafts, } from './room-draft.js';
27
27
  import { same, saving, STARTING, transferring, } from './status.js';
28
28
  import { detectStorageLoss, nextGeneration, refusedForSpace, } from './durability.js';
29
29
  import { readinessOf, } from './readiness.js';
@@ -93,7 +93,7 @@ function pendingKey(locator, id) {
93
93
  }
94
94
  export function composeRuntime(options) {
95
95
  const localSaves = options.adapter.localSaves === true;
96
- const roomTypes = roomTypesOf(options.adapter.roomTypes);
96
+ const roomTypes = roomTypesOf(options.adapter.roomTypes, options.adapter.nameableRoomTypes);
97
97
  let authorization = options.authorization;
98
98
  let opening;
99
99
  const fences = new Map();
@@ -114,9 +114,9 @@ export function composeRuntime(options) {
114
114
  const rooms = new FencedMap(isFenced);
115
115
  const counted = new Map();
116
116
  const unreadable = new Set();
117
- const isModelFenced = (key) => isFenced(key.slice(key.indexOf(' ') + 1));
118
- const models = new FencedMap(isModelFenced);
119
- const liveModels = new FencedMap(isModelFenced);
117
+ const builtIn = builtInModel(roomTypes);
118
+ const models = new FencedMap(isFenced);
119
+ const liveModels = new FencedMap(isFenced);
120
120
  const invalidModels = new Set();
121
121
  const discovered = new Map();
122
122
  const reads = doorReads(options.adapter, (locator) => discovered.get(locator), () => generation);
@@ -124,23 +124,19 @@ export function composeRuntime(options) {
124
124
  const scopedRefusals = new Map();
125
125
  const sourceRefusals = new Map();
126
126
  const declarationRefusals = new Set();
127
- function modelKey(locator, attached) {
128
- return `${attached} ${locator}`;
127
+ function modelOf(locator) {
128
+ return models.get(locator) ?? NO_MODEL;
129
129
  }
130
- function modelOf(locator, attached = 'collection') {
131
- return models.get(modelKey(locator, attached)) ?? NO_MODEL;
132
- }
133
- function savedModel(locator, attached) {
134
- return invalidModels.has(modelKey(locator, attached))
130
+ function savedModel(locator) {
131
+ return invalidModels.has(locator)
135
132
  ? { status: 'unavailable', reason: 'revoked' }
136
- : modelOf(locator, attached);
133
+ : modelOf(locator);
134
+ }
135
+ function composed(record) {
136
+ return compositionOf(record, builtIn);
137
137
  }
138
138
  function compositionFor(record) {
139
- return compositionOf({
140
- ...record,
141
- model: savedModel(record.locator, 'collection'),
142
- selectionModel: savedModel(record.locator, 'typed-selection'),
143
- });
139
+ return composed({ ...record, model: savedModel(record.locator) });
144
140
  }
145
141
  let refusal = null;
146
142
  let storageLoss = null;
@@ -172,6 +168,7 @@ export function composeRuntime(options) {
172
168
  let roomReads = { generation, free: ROOM_READS, waiting: [] };
173
169
  const working = new Set();
174
170
  let mutations = Promise.resolve();
171
+ let gathering = null;
175
172
  const roomListeners = new Set();
176
173
  const refusalListeners = new Set();
177
174
  const storageLossListeners = new Set();
@@ -275,7 +272,7 @@ export function composeRuntime(options) {
275
272
  return undefined;
276
273
  const local = await openLocal();
277
274
  const slice = await stepped(slicing(await local.entries(held.record.key, 'visible', paths), paths));
278
- return { ...slice, collection: collectionOf(slice.documents, compositionOf(held.record)) };
275
+ return { ...slice, collection: collectionOf(slice.documents, composed(held.record)) };
279
276
  }
280
277
  function roomDraftOf(record, visible) {
281
278
  return structuredClone({
@@ -331,14 +328,38 @@ export function composeRuntime(options) {
331
328
  const value = presentations.get(app);
332
329
  return value === undefined ? null : structuredClone(value);
333
330
  }
334
- function keepPresentation(app, next) {
335
- return exclusive(async () => {
336
- const local = await openLocal();
337
- const stored = next(presentations.get(app));
338
- await local.present({ app, value: stored });
339
- presentations.set(app, stored);
340
- publishChangeSet(changeSet('', { presentation: app }));
341
- });
331
+ async function writtenRoomDraft(room, path, revision, input, next) {
332
+ const parts = readParts(input);
333
+ if (path === '' || normalize(path) !== path)
334
+ throw runtimeError('room-draft-malformed');
335
+ const local = await openLocal();
336
+ const current = roomDrafts.get(room)?.get(path);
337
+ if ((current?.revision ?? null) !== revision) {
338
+ return staleWrite(current === undefined ? null : ((await roomDraftsOf([current]))[0] ?? null));
339
+ }
340
+ const file = parts.file === undefined
341
+ ? undefined
342
+ : await heldFile(parts.file.blob, binaryBase(await visibleOf(room, [path]), path));
343
+ const record = {
344
+ locator: room,
345
+ path,
346
+ revision: next,
347
+ parts: held(current?.parts, parts, file),
348
+ returned: current?.returned ?? null,
349
+ };
350
+ await local.keepRoomDraft(record, parts.file === undefined || file === undefined
351
+ ? []
352
+ : [{ key: file.localId, blob: parts.file.blob }]);
353
+ rememberRoomDraft(record);
354
+ publishChangeSet(changeSet(room, { drafts: [path] }));
355
+ return { outcome: 'written', roomDraft: (await roomDraftsOf([record]))[0] ?? null };
356
+ }
357
+ async function keptPresentation(app, next) {
358
+ const local = await openLocal();
359
+ const stored = next(presentations.get(app));
360
+ await local.present({ app, value: stored });
361
+ presentations.set(app, stored);
362
+ publishChangeSet(changeSet('', { presentation: app }));
342
363
  }
343
364
  function emitPresentation(app) {
344
365
  if (closed)
@@ -458,7 +479,7 @@ export function composeRuntime(options) {
458
479
  const governed = governs(reach, room);
459
480
  const attached = [
460
481
  ...(governed.collection ? [modelOf(room.locator)] : []),
461
- ...(governed.selection ? [modelOf(room.locator, 'typed-selection')] : []),
482
+ ...(governed.selection ? [builtIn] : []),
462
483
  ];
463
484
  return {
464
485
  locator: room.locator,
@@ -691,6 +712,7 @@ export function composeRuntime(options) {
691
712
  return [
692
713
  {
693
714
  room,
715
+ name: discovered.get(room)?.name ?? room,
694
716
  file: typeof file === 'string' ? file : '',
695
717
  rule: held.code,
696
718
  location: typeof location === 'string' ? location : null,
@@ -1003,7 +1025,7 @@ export function composeRuntime(options) {
1003
1025
  const records = [...replicas].map(([locator, held]) => ({
1004
1026
  locator,
1005
1027
  held,
1006
- record: { ...held.record, model: revoked, selectionModel: revoked },
1028
+ record: { ...held.record, model: revoked },
1007
1029
  }));
1008
1030
  let answer = null;
1009
1031
  try {
@@ -1013,18 +1035,14 @@ export function composeRuntime(options) {
1013
1035
  locator,
1014
1036
  key: record.key,
1015
1037
  record: storedRecord(record),
1016
- composition: compositionOf(record),
1038
+ composition: composed(record),
1017
1039
  })),
1018
1040
  });
1019
1041
  }
1020
1042
  catch {
1021
1043
  journal.record('model revocation persistence failed');
1022
1044
  }
1023
- const keys = new Set(models.keys());
1024
- for (const locator of rooms.keys()) {
1025
- keys.add(modelKey(locator, 'collection'));
1026
- keys.add(modelKey(locator, 'typed-selection'));
1027
- }
1045
+ const keys = new Set([...models.keys(), ...rooms.keys()]);
1028
1046
  for (const key of keys) {
1029
1047
  invalidModels.add(key);
1030
1048
  models.set(key, revoked);
@@ -1079,7 +1097,7 @@ export function composeRuntime(options) {
1079
1097
  ? null
1080
1098
  : {
1081
1099
  roots: selection.roots,
1082
- model: modelTypes(modelOf(room.locator, 'typed-selection')),
1100
+ model: modelTypes(builtIn),
1083
1101
  },
1084
1102
  providerOwnedPaths: room.providerOwnedPaths,
1085
1103
  roomVersion: replicas.get(room.locator)?.record.roomVersion ?? null,
@@ -1179,12 +1197,9 @@ export function composeRuntime(options) {
1179
1197
  scopedRefusals.delete(locator);
1180
1198
  sourceRefusals.delete(locator);
1181
1199
  declarationRefusals.delete(locator);
1182
- for (const attached of ['collection', 'typed-selection']) {
1183
- const key = modelKey(locator, attached);
1184
- models.delete(key);
1185
- liveModels.delete(key);
1186
- invalidModels.delete(key);
1187
- }
1200
+ models.delete(locator);
1201
+ liveModels.delete(locator);
1202
+ invalidModels.delete(locator);
1188
1203
  journal.record(`room lost ${locator}`);
1189
1204
  }
1190
1205
  if (fresh.length === 0)
@@ -1232,7 +1247,14 @@ export function composeRuntime(options) {
1232
1247
  });
1233
1248
  await eraseFenced(fresh);
1234
1249
  }
1235
- function restored(key, persisted) {
1250
+ function retyped(persisted) {
1251
+ if (persisted.status === 'unavailable')
1252
+ return persisted;
1253
+ const { state } = attachedModel({ kind: 'model', snapshot: persisted.snapshot }, NO_MODEL, roomTypes);
1254
+ return state.status === 'unavailable' ? state : { ...persisted, types: state.types };
1255
+ }
1256
+ function restored(key, held) {
1257
+ const persisted = retyped(held);
1236
1258
  const prior = models.get(key);
1237
1259
  if (prior !== undefined &&
1238
1260
  prior.status !== 'unavailable' &&
@@ -1290,9 +1312,7 @@ export function composeRuntime(options) {
1290
1312
  records.forEach((stored, index) => {
1291
1313
  if (fences.has(stored.locator))
1292
1314
  return;
1293
- const model = restored(modelKey(stored.locator, 'collection'), stored.model);
1294
- const selectionModel = restored(modelKey(stored.locator, 'typed-selection'), stored.selectionModel);
1295
- const record = { ...stored, model, selectionModel };
1315
+ const record = { ...stored, model: restored(stored.locator, stored.model) };
1296
1316
  replicas.set(record.locator, {
1297
1317
  record,
1298
1318
  queue: queuedBatches.get(record.locator) ?? [],
@@ -1310,13 +1330,10 @@ export function composeRuntime(options) {
1310
1330
  roomVersion: record.roomVersion,
1311
1331
  operations: record.operations,
1312
1332
  replica: record.replica,
1313
- model: modelTypes(model),
1333
+ model: modelTypes(record.model),
1314
1334
  typedSelection: record.typedSelection === null
1315
1335
  ? null
1316
- : {
1317
- roots: record.typedSelection.roots,
1318
- model: modelTypes(selectionModel),
1319
- },
1336
+ : { roots: record.typedSelection.roots, model: modelTypes(builtIn) },
1320
1337
  });
1321
1338
  }
1322
1339
  });
@@ -1392,10 +1409,29 @@ export function composeRuntime(options) {
1392
1409
  return opening;
1393
1410
  }
1394
1411
  function exclusive(work) {
1412
+ gathering = null;
1395
1413
  const next = mutations.then(work, work);
1396
1414
  mutations = next.then(() => undefined, () => undefined);
1397
1415
  return next;
1398
1416
  }
1417
+ function gathered(key, input, merge, work) {
1418
+ const tail = gathering;
1419
+ if (tail !== null && tail.key === key) {
1420
+ const merged = merge(tail.input, input);
1421
+ if (merged !== null) {
1422
+ tail.input = merged;
1423
+ return tail.done;
1424
+ }
1425
+ }
1426
+ const entry = { key, input, done: Promise.resolve() };
1427
+ entry.done = exclusive(() => {
1428
+ if (gathering === entry)
1429
+ gathering = null;
1430
+ return work(entry.input);
1431
+ });
1432
+ gathering = entry;
1433
+ return entry.done;
1434
+ }
1399
1435
  function withdrawable(locator) {
1400
1436
  return (batch) => {
1401
1437
  const state = pendings.get(pendingKey(locator, batch.id));
@@ -1484,7 +1520,7 @@ export function composeRuntime(options) {
1484
1520
  return { count: answer.counts[locator] ?? replicas.get(locator)?.count ?? 0, indexed };
1485
1521
  }
1486
1522
  function replayed(record, confirmedLayer, queue) {
1487
- return stepped(replaying(confirmedLayer, queue, record.locator, compositionOf(record)));
1523
+ return stepped(replaying(confirmedLayer, queue, record.locator, composed(record)));
1488
1524
  }
1489
1525
  async function overlayDiff(record, before, visible, touched) {
1490
1526
  const kept = before !== undefined && before.record.key === record.key
@@ -1547,7 +1583,7 @@ export function composeRuntime(options) {
1547
1583
  const confirmedLayer = overrides === undefined
1548
1584
  ? read
1549
1585
  : await stepped(slicingWith(read, overrides.set, overrides.removed));
1550
- const composition = compositionOf(record);
1586
+ const composition = composed(record);
1551
1587
  const { withdrawn, kept } = await stepped(standing(confirmedLayer, queue, withdrawable(locator), localSaves, locator, composition));
1552
1588
  const founded = kept.filter((batch) => !queue.includes(batch));
1553
1589
  const queueChanged = kept.length !== previousQueue.length || founded.length > 0;
@@ -1653,35 +1689,25 @@ export function composeRuntime(options) {
1653
1689
  };
1654
1690
  }
1655
1691
  function adoptModels(locator, record) {
1656
- for (const [attached, model] of [
1657
- ['collection', record.model],
1658
- ['typed-selection', record.selectionModel],
1659
- ]) {
1660
- const key = modelKey(locator, attached);
1661
- models.set(key, model);
1662
- invalidModels.delete(key);
1663
- if (model.status === 'current')
1664
- liveModels.set(key, JSON.stringify(model.snapshot));
1665
- else if (model.status === 'unavailable')
1666
- liveModels.delete(key);
1667
- }
1692
+ const model = record.model;
1693
+ models.set(locator, model);
1694
+ invalidModels.delete(locator);
1695
+ if (model.status === 'current')
1696
+ liveModels.set(locator, JSON.stringify(model.snapshot));
1697
+ else if (model.status === 'unavailable')
1698
+ liveModels.delete(locator);
1668
1699
  }
1669
1700
  function remodel(locator, answers, held) {
1670
- const taken = (answer, previous, attached) => {
1671
- if (answer === undefined)
1672
- return previous;
1673
- const { state, refused } = attachedModel(answer, previous, attached === 'collection' ? roomTypes : NO_ROOM_TYPES);
1674
- if (refused !== null) {
1675
- const where = refused.location === undefined ? '' : ` ${refused.location}`;
1676
- journal.record(`model invalid ${locator} ${attached} ${refused.identity} ${refused.rule}${where}`);
1677
- }
1678
- models.set(modelKey(locator, attached), state);
1679
- return state;
1680
- };
1681
- return {
1682
- collection: taken(answers?.collection, held.collection, 'collection'),
1683
- selection: taken(answers?.selection, held.selection, 'typed-selection'),
1684
- };
1701
+ const answer = answers?.collection;
1702
+ if (answer === undefined)
1703
+ return held;
1704
+ const { state, refused } = attachedModel(answer, held.collection, roomTypes);
1705
+ if (refused !== null) {
1706
+ const where = refused.location === undefined ? '' : ` ${refused.location}`;
1707
+ journal.record(`model invalid ${locator} collection ${refused.identity} ${refused.rule}${where}`);
1708
+ }
1709
+ models.set(locator, state);
1710
+ return { collection: state };
1685
1711
  }
1686
1712
  function publish(local, room, record, landing, live) {
1687
1713
  const landed = exclusive(async () => {
@@ -1708,14 +1734,14 @@ export function composeRuntime(options) {
1708
1734
  ? {
1709
1735
  room: true,
1710
1736
  view: 'refreshed',
1711
- commit: { refreshed: true, composition: compositionOf(record) },
1737
+ commit: { refreshed: true, composition: composed(record) },
1712
1738
  }
1713
1739
  : {
1714
1740
  room: true,
1715
1741
  view: landing.refreshed ? 'refreshed' : 'confirmed',
1716
1742
  commit: {
1717
1743
  published: { from: prior?.record.key ?? null },
1718
- composition: compositionOf(record),
1744
+ composition: composed(record),
1719
1745
  ...(landing.refreshed ? { refreshed: true } : {}),
1720
1746
  },
1721
1747
  });
@@ -1825,7 +1851,7 @@ export function composeRuntime(options) {
1825
1851
  : (await local.referrers(record.key, 'confirmed', removed, CHECKED_LINKS)).map(({ path }) => path);
1826
1852
  const confirmedLayer = await sliceAt(record, 'confirmed', replica.queue, [...paths, ...referring], moved);
1827
1853
  const { visible } = await replayed(record, confirmedLayer, replica.queue);
1828
- const composition = compositionOf(record);
1854
+ const composition = composed(record);
1829
1855
  return {
1830
1856
  record,
1831
1857
  confirmed: confirmedLayer,
@@ -1841,13 +1867,7 @@ export function composeRuntime(options) {
1841
1867
  return false;
1842
1868
  const local = await openLocal();
1843
1869
  const roots = record.typedSelection?.roots ?? [];
1844
- if (composition.model.status === 'unavailable' &&
1845
- (await local.typedWithin(record.key, 'visible', roots, false))) {
1846
- return true;
1847
- }
1848
- return (composition.selection !== null &&
1849
- composition.selection.model.status === 'unavailable' &&
1850
- (await local.typedWithin(record.key, 'visible', roots, true)));
1870
+ return local.typedWithin(record.key, 'visible', roots, false);
1851
1871
  }
1852
1872
  function textDiffers(left, right) {
1853
1873
  return ((left?.content ?? undefined) !== (right?.content ?? undefined) ||
@@ -1952,7 +1972,7 @@ export function composeRuntime(options) {
1952
1972
  const lookup = overriddenLookup(lookupOf(local, record.key, 'confirmed'), overrides);
1953
1973
  const clean = available(composition) &&
1954
1974
  changed.length <= CLEAN_CHANGES &&
1955
- (await changedCleanly(changed, compositionOf(record), composition, {
1975
+ (await changedCleanly(changed, composed(record), composition, {
1956
1976
  lookup,
1957
1977
  texts: textsOf(local, record.key, 'confirmed'),
1958
1978
  referrers: referrersOf(local, record.key, 'confirmed'),
@@ -2709,8 +2729,8 @@ export function composeRuntime(options) {
2709
2729
  }
2710
2730
  }
2711
2731
  async function validatedRoom(local, record, view, previous, overrides = null) {
2712
- const composition = compositionOf(record);
2713
- const modeled = record.model.status !== 'unavailable' || record.selectionModel.status !== 'unavailable';
2732
+ const composition = composed(record);
2733
+ const modeled = record.model.status !== 'unavailable' || record.typedSelection !== null;
2714
2734
  const lookup = overrides === null
2715
2735
  ? lookupOf(local, record.key, view)
2716
2736
  : overriddenLookup(lookupOf(local, record.key, view), overrides);
@@ -2744,11 +2764,11 @@ export function composeRuntime(options) {
2744
2764
  }
2745
2765
  const named = changes === null ? null : changes.map(({ path }) => path);
2746
2766
  const textChanged = changes === null || changes.length > 0 || reshaped;
2747
- const modelsChanged = previous === null || !sameComposition(compositionOf(previous.record), composition);
2767
+ const modelsChanged = previous === null || !sameComposition(composed(previous.record), composition);
2748
2768
  if (modeled && (textChanged || modelsChanged)) {
2749
2769
  const clean = previous !== null &&
2750
2770
  changes !== null &&
2751
- (await changedCleanly(changes, compositionOf(previous.record), composition, {
2771
+ (await changedCleanly(changes, composed(previous.record), composition, {
2752
2772
  lookup,
2753
2773
  texts,
2754
2774
  referrers: referrersOf(local, record.key, 'confirmed'),
@@ -3061,10 +3081,7 @@ export function composeRuntime(options) {
3061
3081
  liveQueries.recover();
3062
3082
  }
3063
3083
  try {
3064
- const result = await bootstrapRoom(reads, authorized, room, {
3065
- collection: modelOf(room.locator),
3066
- selection: modelOf(room.locator, 'typed-selection'),
3067
- }, (models, held) => (liveness() ? remodel(room.locator, models, held) : held), liveness, staging(local, liveness), reusable(room, local));
3084
+ const result = await bootstrapRoom(reads, authorized, room, { collection: modelOf(room.locator) }, builtIn, (models, held) => (liveness() ? remodel(room.locator, models, held) : held), liveness, staging(local, liveness), reusable(room, local));
3068
3085
  const detail = result.kind === 'staged' ? result.record.roomVersion : result.kind;
3069
3086
  journal.record(`transfer bootstrap ${room.locator} ${detail}`);
3070
3087
  if (result.kind !== 'staged') {
@@ -3130,7 +3147,7 @@ export function composeRuntime(options) {
3130
3147
  options.adapter.reached(room.locator, now, refreshed.record.roomVersion);
3131
3148
  return reached ? null : advance(room, local, authorized, live);
3132
3149
  }
3133
- await retainModel(local, room, 'collection', modelOf(room.locator));
3150
+ await retainModel(local, room, modelOf(room.locator));
3134
3151
  return null;
3135
3152
  }
3136
3153
  if (refreshed.kind !== 'beyond-horizon')
@@ -3726,9 +3743,9 @@ export function composeRuntime(options) {
3726
3743
  release();
3727
3744
  };
3728
3745
  }
3729
- async function retainModel(local, room, attached, next) {
3730
- const key = modelKey(room.locator, attached);
3731
- const previous = modelOf(room.locator, attached);
3746
+ async function retainModel(local, room, next) {
3747
+ const key = room.locator;
3748
+ const previous = modelOf(room.locator);
3732
3749
  const heldBefore = replicas.get(room.locator)?.record;
3733
3750
  if (JSON.stringify(previous) === JSON.stringify(next) &&
3734
3751
  (heldBefore === undefined ||
@@ -3752,11 +3769,11 @@ export function composeRuntime(options) {
3752
3769
  operations: room.operations,
3753
3770
  replica: room.replica,
3754
3771
  typedSelection: room.typedSelection ?? null,
3755
- ...(attached === 'collection' ? { model: next } : { selectionModel: next }),
3772
+ model: next,
3756
3773
  };
3757
3774
  let read = 'staged';
3758
3775
  if (!sameMembership(declared, held.record)) {
3759
- const verdict = await validatedCollection(walkOf(local, held.record.key, 'confirmed'), lookupOf(local, held.record.key, 'confirmed'), compositionOf(declared));
3776
+ const verdict = await validatedCollection(walkOf(local, held.record.key, 'confirmed'), lookupOf(local, held.record.key, 'confirmed'), composed(declared));
3760
3777
  read =
3761
3778
  verdict.verdict !== 'refuse'
3762
3779
  ? 'staged'
@@ -3777,7 +3794,7 @@ export function composeRuntime(options) {
3777
3794
  key: record.key,
3778
3795
  record: storedRecord(record),
3779
3796
  roots: record.typedSelection?.roots ?? [],
3780
- composition: compositionOf(record),
3797
+ composition: composed(record),
3781
3798
  overlay: diff.overlay,
3782
3799
  },
3783
3800
  ],
@@ -3824,14 +3841,14 @@ export function composeRuntime(options) {
3824
3841
  });
3825
3842
  let scopedAway = room;
3826
3843
  if (result.scope === 'model')
3827
- await retainModel(local, room, 'collection', {
3844
+ await retainModel(local, room, {
3828
3845
  status: 'unavailable',
3829
3846
  reason: 'not-readable',
3830
3847
  });
3831
3848
  else if (result.scope !== 'operation') {
3832
3849
  unreadable.add(room.locator);
3833
3850
  scopedAway = { ...room, replica: { ...room.replica, admission: 'unavailable' } };
3834
- await retainModel(local, scopedAway, 'collection', modelOf(room.locator));
3851
+ await retainModel(local, scopedAway, modelOf(room.locator));
3835
3852
  }
3836
3853
  if (!continuing())
3837
3854
  return;
@@ -3881,7 +3898,7 @@ export function composeRuntime(options) {
3881
3898
  return false;
3882
3899
  }
3883
3900
  if (prior !== undefined)
3884
- await retainModel(local, room, 'collection', modelOf(room.locator));
3901
+ await retainModel(local, room, modelOf(room.locator));
3885
3902
  if (discoveryPaused || authorization === undefined)
3886
3903
  return false;
3887
3904
  return room.replica.admission === 'admitted';
@@ -3894,10 +3911,8 @@ export function composeRuntime(options) {
3894
3911
  await withhold(withheld, room, local, progress);
3895
3912
  }
3896
3913
  function revoked(locator) {
3897
- return ['collection', 'typed-selection'].some((attached) => {
3898
- const model = modelOf(locator, attached);
3899
- return model.status === 'unavailable' && model.reason === 'revoked';
3900
- });
3914
+ const model = modelOf(locator);
3915
+ return model.status === 'unavailable' && model.reason === 'revoked';
3901
3916
  }
3902
3917
  async function loadRoom(room, local, progress, live) {
3903
3918
  if (!live() || authorization === undefined)
@@ -3955,10 +3970,7 @@ export function composeRuntime(options) {
3955
3970
  journal.record(`connection discover ${result.kind}`);
3956
3971
  if (result.kind === 'transport-uncertainty') {
3957
3972
  for (const room of rooms.values()) {
3958
- await retainModel(local, room, 'collection', cached(modelOf(room.locator)));
3959
- if (room.typedSelection !== null) {
3960
- await retainModel(local, room, 'typed-selection', cached(modelOf(room.locator, 'typed-selection')));
3961
- }
3973
+ await retainModel(local, room, cached(modelOf(room.locator)));
3962
3974
  }
3963
3975
  progress.reachable = false;
3964
3976
  progress.complete = false;
@@ -4240,12 +4252,9 @@ export function composeRuntime(options) {
4240
4252
  }
4241
4253
  }
4242
4254
  async function confirmModels(room, local) {
4243
- for (const attached of ['collection', 'typed-selection']) {
4244
- const model = modelOf(room.locator, attached);
4245
- if (model.status === 'cached') {
4246
- await retainModel(local, room, attached, { ...model, status: 'current' });
4247
- }
4248
- }
4255
+ const model = modelOf(room.locator);
4256
+ if (model.status === 'cached')
4257
+ await retainModel(local, room, { ...model, status: 'current' });
4249
4258
  }
4250
4259
  function submitLater(locator) {
4251
4260
  if (localSaves)
@@ -4827,7 +4836,7 @@ export function composeRuntime(options) {
4827
4836
  typedSelection: rooms.get(locator)?.typedSelection === undefined ||
4828
4837
  rooms.get(locator)?.typedSelection === null
4829
4838
  ? null
4830
- : modelTypes(modelOf(locator, 'typed-selection')),
4839
+ : modelTypes(builtIn),
4831
4840
  };
4832
4841
  },
4833
4842
  roomDraft: {
@@ -4844,33 +4853,17 @@ export function composeRuntime(options) {
4844
4853
  const record = roomDrafts.get(room)?.get(path);
4845
4854
  return record === undefined ? null : ((await roomDraftsOf([record]))[0] ?? null);
4846
4855
  },
4847
- write(room, path, revision, input) {
4848
- return exclusive(async () => {
4849
- const parts = readParts(input);
4850
- if (path === '' || normalize(path) !== path)
4851
- throw runtimeError('room-draft-malformed');
4852
- const local = await openLocal();
4853
- const current = roomDrafts.get(room)?.get(path);
4854
- if ((current?.revision ?? null) !== revision) {
4855
- return staleWrite(current === undefined ? null : ((await roomDraftsOf([current]))[0] ?? null));
4856
- }
4857
- const file = parts.file === undefined
4858
- ? undefined
4859
- : await heldFile(parts.file.blob, binaryBase(await visibleOf(room, [path]), path));
4860
- const record = {
4861
- locator: room,
4862
- path,
4863
- revision: roomDraftRevision(),
4864
- parts: held(current?.parts, parts, file),
4865
- returned: current?.returned ?? null,
4866
- };
4867
- await local.keepRoomDraft(record, parts.file === undefined || file === undefined
4868
- ? []
4869
- : [{ key: file.localId, blob: parts.file.blob }]);
4870
- rememberRoomDraft(record);
4871
- publishChangeSet(changeSet(room, { drafts: [path] }));
4872
- return { outcome: 'written', roomDraft: (await roomDraftsOf([record]))[0] ?? null };
4873
- });
4856
+ write(room, path, revision, input, next = roomDraftRevision()) {
4857
+ if (typeof next !== 'string' || next === '')
4858
+ return Promise.reject(runtimeError('room-draft-malformed'));
4859
+ return gathered(`room-draft\u0000${room}\u0000${path}`, { revision, input, next }, (earlier, later) => {
4860
+ if (later.revision !== earlier.next)
4861
+ return null;
4862
+ const parts = gatheredParts(earlier.input, later.input);
4863
+ return parts === null
4864
+ ? null
4865
+ : { revision: earlier.revision, input: parts, next: later.next };
4866
+ }, (written) => writtenRoomDraft(room, path, written.revision, written.input, written.next));
4874
4867
  },
4875
4868
  discard(room, path, revision) {
4876
4869
  return exclusive(async () => {
@@ -4897,13 +4890,13 @@ export function composeRuntime(options) {
4897
4890
  });
4898
4891
  },
4899
4892
  write(app, value) {
4900
- return keepPresentation(app, () => structuredClone(value));
4893
+ return exclusive(() => keptPresentation(app, () => structuredClone(value)));
4901
4894
  },
4902
4895
  edit(app, members) {
4903
- return keepPresentation(app, (held) => Object.fromEntries([
4904
- ...Object.entries(plain(held) ? held : {}).filter(([member]) => !Object.hasOwn(members, member)),
4905
- ...Object.entries(structuredClone(members)).filter(([, value]) => value !== null),
4906
- ]));
4896
+ return gathered(`presentation\u0000${app}`, structuredClone(members), (earlier, later) => ({ ...earlier, ...later }), (edited) => keptPresentation(app, (held) => Object.fromEntries([
4897
+ ...Object.entries(plain(held) ? held : {}).filter(([member]) => !Object.hasOwn(edited, member)),
4898
+ ...Object.entries(edited).filter(([, value]) => value !== null),
4899
+ ])));
4907
4900
  },
4908
4901
  },
4909
4902
  save(room, named, writtenBy) {
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/convers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