@agentshouse/mdruntime-adapter 0.1.0-cda5b3be3317e → 0.1.0-ce1149641691d

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/read.js CHANGED
@@ -1,21 +1,52 @@
1
+ import { patching, ROW_WEIGHT, stepped, } from '@agentshouse/mdruntime';
2
+ import { checkedPayload, gunzipped, parsePart } from './part.js';
1
3
  import { DECIMAL, readPosition, roomVersion } from './version.js';
2
4
  const REVISION_FILE = /^fr_([0-9a-z]+)\.[0-9a-z]+\.[0-9a-z]$/u;
3
- export function identities(revisions) {
4
- const fileIds = Object.fromEntries(Object.entries(revisions).flatMap(([path, revision]) => {
5
- const file = REVISION_FILE.exec(revision)?.[1];
6
- return file === undefined ? [] : [[path, file]];
7
- }));
8
- return Object.keys(fileIds).length === 0 ? {} : { fileIds };
5
+ function fileOf(revision) {
6
+ return REVISION_FILE.exec(revision)?.[1];
7
+ }
8
+ export function answering() {
9
+ return {
10
+ documents: new Map(),
11
+ revisions: new Map(),
12
+ fileIds: new Map(),
13
+ changes: new Map(),
14
+ binaryFiles: new Map(),
15
+ removals: new Set(),
16
+ };
17
+ }
18
+ export function revised(answer, path, revision) {
19
+ answer.revisions.set(path, revision);
20
+ const file = fileOf(revision);
21
+ if (file !== undefined)
22
+ answer.fileIds.set(path, file);
23
+ }
24
+ export function forgotten(answer, path) {
25
+ answer.documents.delete(path);
26
+ answer.revisions.delete(path);
27
+ answer.fileIds.delete(path);
28
+ answer.changes.delete(path);
29
+ answer.binaryFiles.delete(path);
30
+ answer.removals.delete(path);
31
+ }
32
+ export function* answered(answer) {
33
+ const removals = [];
34
+ for (const path of answer.removals) {
35
+ removals.push(path);
36
+ yield ROW_WEIGHT;
37
+ }
38
+ return {
39
+ documents: yield* patching({}, answer.documents),
40
+ revisions: yield* patching({}, answer.revisions),
41
+ ...(answer.fileIds.size === 0 ? {} : { fileIds: yield* patching({}, answer.fileIds) }),
42
+ changes: yield* patching({}, answer.changes),
43
+ binaryFiles: yield* patching({}, answer.binaryFiles),
44
+ removals,
45
+ };
9
46
  }
10
47
  export function authorityRoot(handle) {
11
48
  return `/rooms/${handle}`;
12
49
  }
13
- export function contentPrefixes(tracked) {
14
- return [
15
- authorityRoot(tracked.handle),
16
- ...tracked.schemas.map((schema) => schemaPath(tracked.handle, schema)),
17
- ];
18
- }
19
50
  export function schemaPath(handle, schema) {
20
51
  return `${authorityRoot(handle)}/${schema}`;
21
52
  }
@@ -105,13 +136,13 @@ function parseFile(value, mode) {
105
136
  ...binaried(binary),
106
137
  };
107
138
  }
108
- function parseScope(value, mode) {
139
+ function parseRoomParts(value) {
109
140
  if (typeof value !== 'object' || value === null)
110
141
  return null;
111
142
  const held = value;
112
143
  if (typeof held.manifest !== 'object' || held.manifest === null)
113
144
  return null;
114
- if (!Array.isArray(held.contents))
145
+ if (!Array.isArray(held.parts))
115
146
  return null;
116
147
  const manifest = held.manifest;
117
148
  if (manifest.scope !== 'room')
@@ -121,78 +152,89 @@ function parseScope(value, mode) {
121
152
  return null;
122
153
  if (typeof manifest.room_handle !== 'string' || manifest.room_handle.length === 0)
123
154
  return null;
124
- if (!Array.isArray(manifest.files))
125
- return null;
126
- const files = [];
127
- for (const entry of manifest.files) {
128
- const file = parseFile(entry, mode);
129
- if (file === null)
130
- return null;
131
- files.push(file);
132
- }
133
- const contents = [];
134
- for (const entry of held.contents) {
135
- if (typeof entry !== 'object' || entry === null)
155
+ const parts = [];
156
+ for (const entry of held.parts) {
157
+ const part = parsePart(entry);
158
+ if (part === null)
136
159
  return null;
137
- const content = entry;
138
- if (typeof content.path !== 'string' || typeof content.content !== 'string')
139
- return null;
140
- contents.push({ path: content.path, content: content.content });
160
+ parts.push(part);
141
161
  }
142
- return { anchor: manifest.anchor, ...at, files, contents };
143
- }
144
- function parseCut(value) {
145
- if (value === undefined)
146
- return undefined;
147
- if (typeof value !== 'object' || value === null)
148
- return null;
149
- const { position, log_epoch: logEpoch } = value;
150
- if (typeof position !== 'string' || typeof logEpoch !== 'string')
151
- return null;
152
- return { position, log_epoch: logEpoch };
162
+ return { anchor: manifest.anchor, ...at, parts };
153
163
  }
154
- function parseCursor(value) {
155
- if (typeof value !== 'object' || value === null)
156
- return null;
157
- const { room, path, cut } = value;
158
- if (typeof room !== 'string' || (path !== null && typeof path !== 'string'))
159
- return null;
160
- const parsed = parseCut(cut);
161
- if (parsed === null)
162
- return null;
163
- return { room, path, ...(parsed === undefined ? {} : { cut: parsed }) };
164
- }
165
- export function parseEnvelope(body) {
164
+ export function parseParted(body) {
166
165
  if (typeof body !== 'object' || body === null)
167
166
  return null;
168
167
  if (!('scopes' in body) || !Array.isArray(body.scopes))
169
168
  return null;
170
- const scopes = [];
169
+ const rooms = [];
171
170
  for (const entry of body.scopes) {
172
- const scope = parseScope(entry, 'credential');
173
- if (scope === null)
171
+ const room = parseRoomParts(entry);
172
+ if (room === null)
174
173
  return null;
175
- scopes.push(scope);
174
+ rooms.push(room);
176
175
  }
177
176
  if (!('next' in body) || body.next === undefined)
178
- return { scopes };
179
- const next = parseCursor(body.next);
180
- return next === null ? null : { scopes, next };
177
+ return { rooms };
178
+ const next = body.next;
179
+ if (typeof next !== 'object' || next === null || typeof next.room !== 'string')
180
+ return null;
181
+ return { rooms, next: next.room };
181
182
  }
182
- export function parseSiteBootstrap(body) {
183
- return parseScope(body, 'site');
183
+ export function parseSiteParted(body) {
184
+ return parseRoomParts(body);
184
185
  }
185
- export function siteBootstrapNext(body) {
186
- if (typeof body !== 'object' || body === null || !('next' in body))
187
- return null;
188
- return typeof body.next === 'string' && body.next.length > 0 ? body.next : null;
186
+ export function emptyScope(room) {
187
+ return {
188
+ anchor: room.anchor,
189
+ position: room.position,
190
+ logEpoch: room.logEpoch,
191
+ files: [],
192
+ contents: [],
193
+ };
194
+ }
195
+ function* partLines(text, mode) {
196
+ const files = [];
197
+ const contents = [];
198
+ let start = 0;
199
+ while (start < text.length) {
200
+ const end = text.indexOf('\n', start);
201
+ if (end === -1)
202
+ return null;
203
+ let entry;
204
+ try {
205
+ entry = JSON.parse(text.slice(start, end));
206
+ }
207
+ catch {
208
+ return null;
209
+ }
210
+ start = end + 1;
211
+ if (folderLine(entry))
212
+ continue;
213
+ const file = parseFile(entry, mode);
214
+ if (file === null)
215
+ return null;
216
+ files.push(file);
217
+ const { content } = entry;
218
+ if (typeof content === 'string')
219
+ contents.push({ path: file.path, content });
220
+ else if (content !== undefined)
221
+ return null;
222
+ yield ROW_WEIGHT;
223
+ }
224
+ return { files, contents };
225
+ }
226
+ function folderLine(entry) {
227
+ if (typeof entry !== 'object' || entry === null || !('folder' in entry))
228
+ return false;
229
+ return typeof entry.folder === 'string' && Object.keys(entry).length === 1;
189
230
  }
190
- export function siteBootstrapOffset(body) {
191
- if (typeof body !== 'object' || body === null || !('offset' in body))
231
+ export async function housePart(room, body, listed, mode) {
232
+ const payload = await checkedPayload(body, listed);
233
+ if (payload === null)
192
234
  return null;
193
- return Number.isSafeInteger(body.offset) && body.offset > 0
194
- ? body.offset
195
- : null;
235
+ const text = await gunzipped(payload);
236
+ const read = text === null ? null : await stepped(partLines(text, mode));
237
+ return read === null ? { kind: 'transport-uncertainty' } : { ...emptyScope(room), ...read };
196
238
  }
197
239
  function parseChange(value, mode) {
198
240
  if (typeof value !== 'object' || value === null)
@@ -310,12 +352,21 @@ export async function wholeView(first, more) {
310
352
  changes: [...changes.values()],
311
353
  };
312
354
  }
313
- export function advancedScope(scope, view) {
314
- const files = new Map(scope.files.map((file) => [file.path, file]));
315
- const contents = new Map(scope.contents.map((entry) => [entry.path, entry.content]));
355
+ export function* advancedScope(scope, view) {
356
+ const files = new Map();
357
+ for (const file of scope.files) {
358
+ files.set(file.path, file);
359
+ yield ROW_WEIGHT;
360
+ }
361
+ const contents = new Map();
362
+ for (const entry of scope.contents) {
363
+ contents.set(entry.path, entry.content);
364
+ yield ROW_WEIGHT;
365
+ }
316
366
  for (const change of view.changes) {
317
367
  files.delete(change.path);
318
368
  contents.delete(change.path);
369
+ yield ROW_WEIGHT;
319
370
  if ('removed' in change)
320
371
  continue;
321
372
  files.set(change.path, {
@@ -328,43 +379,40 @@ export function advancedScope(scope, view) {
328
379
  if ('content' in change)
329
380
  contents.set(change.path, change.content);
330
381
  }
382
+ const listed = [];
383
+ for (const [path, content] of contents) {
384
+ listed.push({ path, content });
385
+ yield ROW_WEIGHT;
386
+ }
331
387
  return {
332
388
  ...scope,
333
389
  position: view.position,
334
390
  logEpoch: view.logEpoch,
335
391
  files: [...files.values()],
336
- contents: [...contents].map(([path, content]) => ({ path, content })),
392
+ contents: listed,
337
393
  };
338
394
  }
339
- export function matchesScope(scope, tracked) {
340
- return scope.anchor === tracked.authority;
341
- }
342
- export function bootstrapOf(scope) {
343
- const contents = new Map(scope.contents.map((entry) => [entry.path, entry.content]));
344
- const documents = {};
345
- const revisions = {};
346
- const changes = {};
347
- const binaryFiles = {};
395
+ export function* bootstrapping(scope) {
396
+ const contents = new Map();
397
+ for (const entry of scope.contents) {
398
+ contents.set(entry.path, entry.content);
399
+ yield ROW_WEIGHT;
400
+ }
401
+ const answer = answering();
348
402
  for (const file of scope.files) {
349
- if (file.revision !== undefined)
350
- revisions[file.path] = file.revision;
403
+ yield ROW_WEIGHT;
351
404
  if (file.head !== undefined)
352
- changes[file.path] = file.head;
405
+ answer.changes.set(file.path, file.head);
353
406
  const content = contents.get(file.path);
354
407
  if (file.binary !== undefined)
355
- binaryFiles[file.path] = file.binary;
408
+ answer.binaryFiles.set(file.path, file.binary);
356
409
  else if (content !== undefined)
357
- documents[file.path] = content;
410
+ answer.documents.set(file.path, content);
411
+ if (file.revision !== undefined)
412
+ revised(answer, file.path, file.revision);
358
413
  }
359
- return {
360
- kind: 'bootstrap',
361
- roomVersion: roomVersion(scope),
362
- documents,
363
- revisions,
364
- ...identities(revisions),
365
- changes,
366
- binaryFiles,
367
- };
414
+ const { removals: _removals, ...page } = yield* answered(answer);
415
+ return { kind: 'bootstrap', roomVersion: roomVersion(scope), ...page };
368
416
  }
369
417
  export function schemaOf(scope, schema) {
370
418
  const file = scope.files.find((entry) => entry.path === schema);
@@ -378,36 +426,27 @@ export function schemaOf(scope, schema) {
378
426
  export function viewOf(enumeration, tracked) {
379
427
  return enumeration.authorities.find((entry) => entry.authority === tracked.authority);
380
428
  }
381
- export function refreshFrom(view, fromRoomVersion) {
429
+ function* refreshing(view, fromRoomVersion) {
382
430
  if (roomVersion(view) === fromRoomVersion)
383
431
  return { kind: 'still-current' };
384
- const documents = {};
385
- const revisions = {};
386
- const changes = {};
387
- const binaryFiles = {};
388
- const removals = [];
432
+ const answer = answering();
389
433
  for (const change of view.changes) {
434
+ yield ROW_WEIGHT;
390
435
  if ('removed' in change) {
391
- removals.push(change.path);
436
+ answer.removals.add(change.path);
392
437
  continue;
393
438
  }
394
439
  if ('content' in change)
395
- documents[change.path] = change.content;
440
+ answer.documents.set(change.path, change.content);
396
441
  else
397
- binaryFiles[change.path] = change.binary;
398
- if (change.revision !== undefined)
399
- revisions[change.path] = change.revision;
442
+ answer.binaryFiles.set(change.path, change.binary);
400
443
  if (change.head !== undefined)
401
- changes[change.path] = change.head;
444
+ answer.changes.set(change.path, change.head);
445
+ if (change.revision !== undefined)
446
+ revised(answer, change.path, change.revision);
402
447
  }
403
- return {
404
- kind: 'net-advancement',
405
- roomVersion: roomVersion(view),
406
- documents,
407
- revisions,
408
- ...identities(revisions),
409
- changes,
410
- binaryFiles,
411
- removals: removals.sort(),
412
- };
448
+ return { kind: 'net-advancement', roomVersion: roomVersion(view), ...(yield* answered(answer)) };
449
+ }
450
+ export async function refreshFrom(view, fromRoomVersion) {
451
+ return stepped(refreshing(view, fromRoomVersion));
413
452
  }
@@ -1 +1 @@
1
- {"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAUR,MAAM,wBAAwB,CAAC;AA2BhC,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAyCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,QAAQ,UAAQ,GAAG,OAAO,CAwR1F"}
1
+ {"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAUR,MAAM,wBAAwB,CAAC;AA6BhC,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAuCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,QAAQ,UAAQ,GAAG,OAAO,CAkQ1F"}
package/dist/site.js CHANGED
@@ -1,8 +1,9 @@
1
+ import { stepped } from '@agentshouse/mdruntime';
1
2
  import { actionOutcome, SITE_SUBMIT } from './actions.js';
2
3
  import { mapDiscovery, parseSiteDiscovery, siteCapabilities, siteTracked, } from './discovery.js';
3
4
  import { partModels, streamedModels, viewModels } from './model.js';
4
- import { advancedScope, bootstrapOf, parseEnumeration, parseSiteBootstrap, refreshFrom, siteBootstrapNext, siteBootstrapOffset, viewOf, wholeView, } from './read.js';
5
- import { sha256Hex } from './digest.js';
5
+ import { advancedScope, bootstrapping, emptyScope, housePart, parseEnumeration, parseSiteParted, refreshFrom, viewOf, wholeView, } from './read.js';
6
+ import { PART_ATTEMPTS, unverifiedPart } from './part.js';
6
7
  import { classifyDoor, classifyRead, discoveryFailure } from './refusal.js';
7
8
  import { houseNotifications } from './stream.js';
8
9
  import { SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT, SITE_FILE_RECORD, SITE_FILES, } from './transport.js';
@@ -18,8 +19,8 @@ function siteRoom(tracked) {
18
19
  locator: tracked.locator,
19
20
  handle: tracked.handle,
20
21
  roomVersion: roomVersion(tracked),
21
- operations: { read: [''], sync: [''], write: [], delete: [] },
22
- replica: { selection: tracked.locator, admission: 'admitted' },
22
+ operations: { write: [], delete: [] },
23
+ replica: { selection: tracked.locator, admission: 'admitted', offline: 'open' },
23
24
  providerOwnedPaths: [],
24
25
  };
25
26
  }
@@ -29,6 +30,7 @@ function settled(refused) {
29
30
  export function createSiteAdapter(transport, snapshot = false) {
30
31
  const notifications = houseNotifications(transport, 'site');
31
32
  const tracked = new Map();
33
+ const expired = new Map();
32
34
  function published(referrer) {
33
35
  const named = houseReferrer(referrer, tracked);
34
36
  return named === null || !tracked.has(named.locator) ? null : named;
@@ -68,73 +70,48 @@ export function createSiteAdapter(transport, snapshot = false) {
68
70
  const first = await enumerated(entry, from);
69
71
  return 'kind' in first ? first : wholeView(first, (page) => enumerated(entry, from, page));
70
72
  }
71
- async function bootstrapPart(entry, after, offset) {
72
- const query = [
73
- ...(after === null ? [] : [`after=${encodeURIComponent(after)}`]),
74
- ...(offset === null ? [] : [`offset=${offset}`]),
75
- ];
76
- const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}${query.length === 0 ? '' : `?${query.join('&')}`}`);
73
+ async function partedRoom(entry) {
74
+ const cut = expired.get(entry.locator);
75
+ const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}${cut === undefined ? '' : `?expired=${cut}`}`);
77
76
  const classified = classifyDoor(answer.status, answer.body, entry.locator);
78
77
  if (classified !== null)
79
- return { failure: classified };
80
- const scope = parseSiteBootstrap(answer.body);
81
- return scope === null ? { failure: UNCERTAIN } : { body: answer.body, scope };
78
+ return classified;
79
+ const room = parseSiteParted(answer.body);
80
+ return room === null || room.anchor !== entry.authority ? UNCERTAIN : room;
82
81
  }
83
- async function assembled(entry, scope, path, offset) {
84
- const opened = scope.contents.at(-1);
85
- if (opened === undefined || opened.path !== path || opened.content.length !== offset) {
86
- return UNCERTAIN;
87
- }
88
- let text = opened.content;
89
- for (;;) {
90
- const part = await bootstrapPart(entry, path, text.length);
91
- if ('failure' in part)
92
- return part.failure;
93
- const [piece] = part.scope.contents;
94
- if (piece === undefined ||
95
- part.scope.contents.length !== 1 ||
96
- piece.path !== path ||
97
- piece.content.length === 0) {
98
- return UNCERTAIN;
99
- }
100
- text += piece.content;
101
- const more = siteBootstrapOffset(part.body);
102
- if (more === null)
103
- break;
104
- if (more !== text.length)
105
- return UNCERTAIN;
82
+ async function fetchedPart(entry, room, listed) {
83
+ for (let attempt = 0; attempt < PART_ATTEMPTS; attempt += 1) {
84
+ const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}?part=${encodeURIComponent(listed.part)}`);
85
+ const failure = classifyRead(answer.status, answer.body, entry.locator);
86
+ if (failure?.kind === 'beyond-horizon')
87
+ expired.set(entry.locator, room.position);
88
+ if (failure !== null)
89
+ return failure;
90
+ const scope = await housePart(room, answer.body, listed, 'site');
91
+ if (scope !== null)
92
+ return scope;
106
93
  }
107
- const file = scope.files.find((held) => held.path === path);
108
- if (file === undefined || (await sha256Hex(text)) !== file.version)
109
- return UNCERTAIN;
110
- return { ...scope, contents: [...scope.contents.slice(0, -1), { path, content: text }] };
94
+ return unverifiedPart(entry.locator);
111
95
  }
112
- async function caughtUp(entry, after) {
113
- const part = await bootstrapPart(entry, after, null);
114
- if ('failure' in part)
115
- return part;
116
- const next = siteBootstrapNext(part.body);
117
- const offset = siteBootstrapOffset(part.body);
118
- if (offset !== null) {
119
- if (next === null)
120
- return { failure: UNCERTAIN };
121
- const scope = await assembled(entry, part.scope, next, offset);
122
- return 'kind' in scope ? { failure: scope } : { scope, next };
123
- }
124
- const { scope } = part;
125
- if (after !== null || next !== null || roomVersion(scope) === roomVersion(entry)) {
126
- return { scope, next };
127
- }
96
+ async function caughtUp(entry, continued) {
97
+ const listed = continued.room.parts[continued.next];
98
+ const scope = listed === undefined
99
+ ? emptyScope(continued.room)
100
+ : await fetchedPart(entry, continued.room, listed);
101
+ if ('kind' in scope)
102
+ return scope;
103
+ if (continued.room.parts.length > 1 || roomVersion(scope) === roomVersion(entry))
104
+ return scope;
128
105
  const view = await enumeration(entry, scope);
129
106
  if ('kind' in view)
130
- return { failure: settled(view) };
131
- return { scope: advancedScope(scope, view), next: null };
107
+ return settled(view);
108
+ return stepped(advancedScope(scope, view));
132
109
  }
133
110
  async function refreshed(entry, fromRoomVersion) {
134
111
  const from = logPosition(fromRoomVersion);
135
112
  if (from === null)
136
113
  return { kind: 'beyond-horizon' };
137
- const streamed = notifications.advance(entry, from);
114
+ const streamed = await stepped(notifications.advance(entry, from));
138
115
  if (streamed !== null) {
139
116
  const models = await streamedModels(streamed.schemas, entry, 'site');
140
117
  return models === undefined ? streamed.page : { ...streamed.page, models };
@@ -143,7 +120,7 @@ export function createSiteAdapter(transport, snapshot = false) {
143
120
  if ('kind' in view)
144
121
  return view;
145
122
  notifications.reach(entry.authority, view);
146
- const answer = refreshFrom(view, fromRoomVersion);
123
+ const answer = await refreshFrom(view, fromRoomVersion);
147
124
  if (answer.kind !== 'net-advancement')
148
125
  return answer;
149
126
  const models = await viewModels(view, entry);
@@ -174,23 +151,30 @@ export function createSiteAdapter(transport, snapshot = false) {
174
151
  const entry = tracked.get(request.locator);
175
152
  if (entry === undefined)
176
153
  return { kind: 'room-not-readable', locator: request.locator };
177
- const continued = request.pageToken === undefined
178
- ? null
179
- : JSON.parse(request.pageToken);
180
- const held = await caughtUp(entry, continued?.after ?? null);
181
- if ('failure' in held)
182
- return held.failure;
183
- notifications.reach(entry.authority, held.scope);
154
+ let continued;
155
+ if (request.pageToken === undefined) {
156
+ const room = await partedRoom(entry);
157
+ if ('kind' in room)
158
+ return room;
159
+ continued = { room, next: 0, seen: [] };
160
+ }
161
+ else
162
+ continued = JSON.parse(request.pageToken);
163
+ const scope = await caughtUp(entry, continued);
164
+ if ('kind' in scope)
165
+ return scope;
166
+ notifications.reach(entry.authority, scope);
167
+ const next = continued.next + 1;
168
+ const more = next < continued.room.parts.length;
184
169
  const seen = [
185
- ...(continued?.seen ?? []),
186
- ...entry.schemas.filter((schema) => held.scope.files.some((file) => file.path === schema)),
170
+ ...continued.seen,
171
+ ...entry.schemas.filter((schema) => scope.files.some((file) => file.path === schema)),
187
172
  ];
188
- const models = await partModels(held.scope, entry, new Set(seen), held.next === null);
189
- const continuation = held.next === null ? null : { after: held.next, seen };
173
+ const models = await partModels(scope, entry, new Set(seen), !more);
190
174
  return {
191
- ...bootstrapOf(held.scope),
175
+ ...(await stepped(bootstrapping(scope))),
192
176
  ...(models === undefined ? {} : { models }),
193
- ...(continuation === null ? {} : { pageToken: JSON.stringify(continuation) }),
177
+ ...(more ? { pageToken: JSON.stringify({ ...continued, next, seen }) } : {}),
194
178
  };
195
179
  },
196
180
  async refresh(_authorization, request) {
package/dist/stream.d.ts CHANGED
@@ -1,11 +1,10 @@
1
- import type { ConversationStream, RefreshPage, RoomStreamEvent, ServiceModeSignal, StreamReceipts } from '@agentshouse/mdruntime';
1
+ import { type ConversationStream, type RefreshPage, type RoomStreamEvent, type ServiceModeSignal, type StreamReceipts } from '@agentshouse/mdruntime';
2
2
  import type { TrackedAuthority } from './discovery.js';
3
3
  import type { HouseDoor, HouseHeldRoom, HouseMode, HouseStreamEntry } from './transport.js';
4
4
  import { type LogPosition } from './version.js';
5
5
  export type HeldRevision = (path: string, revision: string) => boolean;
6
6
  export type StreamedAdvancement = {
7
7
  page: RefreshPage;
8
- entries: readonly HouseStreamEntry[];
9
8
  schemas: ReadonlyMap<string, HouseStreamEntry>;
10
9
  };
11
10
  export type HouseNotifications = {
@@ -16,7 +15,7 @@ export type HouseNotifications = {
16
15
  reopen(): void;
17
16
  track(authorities: readonly TrackedAuthority[]): void;
18
17
  reach(authority: string, at: LogPosition): void;
19
- advance(tracked: TrackedAuthority, from: LogPosition, holds?: HeldRevision): StreamedAdvancement | null;
18
+ advance(tracked: TrackedAuthority, from: LogPosition, holds?: HeldRevision): Generator<number, StreamedAdvancement | null, void>;
20
19
  conversations: ConversationStream;
21
20
  serviceMode: ServiceModeSignal;
22
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,K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