@agentshouse/mdruntime-adapter 0.1.0-cedab65f24a09 → 0.1.0-cedb8e57837a7

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/gather.js CHANGED
@@ -25,21 +25,11 @@ export function gathered(send) {
25
25
  });
26
26
  });
27
27
  }
28
- export function selections(items, weight, limit) {
28
+ export function selections(items, limit) {
29
+ const size = Math.max(1, limit);
29
30
  const parts = [];
30
- let part = [];
31
- let carried = 0;
32
- for (const item of items) {
33
- const weighed = weight(item);
34
- if (part.length > 0 && carried + weighed > limit) {
35
- parts.push(part);
36
- part = [];
37
- carried = 0;
38
- }
39
- part.push(item);
40
- carried += weighed;
31
+ for (let start = 0; start < items.length; start += size) {
32
+ parts.push(items.slice(start, start + size));
41
33
  }
42
- if (part.length > 0)
43
- parts.push(part);
44
34
  return parts;
45
35
  }
package/dist/handed.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- import type { HeldRoom, MutationResult } from '@agentshouse/mdruntime';
1
+ import { type HeldRoom, type MutationResult } from '@agentshouse/mdruntime';
2
2
  import type { HouseScope, HouseView } from './read.js';
3
3
  import type { StreamedAdvancement } from './stream.js';
4
4
  export type HandedRoom = {
5
5
  roomVersion: string;
6
- revisions: ReadonlyMap<string, string>;
6
+ revisions: Readonly<Record<string, string>>;
7
7
  };
8
- export declare function scopeHanded(scope: HouseScope): HandedRoom;
8
+ export declare function scopeHanded(scope: HouseScope): Generator<number, HandedRoom, void>;
9
9
  export declare function heldHanded(held: HeldRoom): HandedRoom;
10
10
  export declare function acceptedHanded(held: HandedRoom, accepted: Extract<MutationResult, {
11
11
  kind: 'accepted';
12
- }>, roomVersion: string): HandedRoom;
13
- export declare function enumeratedHanded(view: HouseView, earlier: HandedRoom | undefined): HandedRoom;
14
- export declare function streamedHanded(held: HandedRoom, advanced: StreamedAdvancement): HandedRoom;
12
+ }>, roomVersion: string): Generator<number, HandedRoom, void>;
13
+ export declare function enumeratedHanded(view: HouseView, earlier: HandedRoom | undefined): Generator<number, HandedRoom, void>;
14
+ export declare function streamedHanded(held: HandedRoom, advanced: StreamedAdvancement): Generator<number, HandedRoom, void>;
15
15
  //# sourceMappingURL=handed.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handed.d.ts","sourceRoot":"","sources":["../src/handed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGvD,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CASzD;AAOD,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAErD;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,EACvD,WAAW,EAAE,MAAM,GAClB,UAAU,CAKZ;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,CAM7F;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,mBAAmB,GAAG,UAAU,CAM1F"}
1
+ {"version":3,"file":"handed.d.ts","sourceRoot":"","sources":["../src/handed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACjG,OAAO,KAAK,EAAqB,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGvD,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC7C,CAAC;AAMF,wBAAiB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAEnF;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAErD;AAED,wBAAiB,cAAc,CAC7B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,EACvD,WAAW,EAAE,MAAM,GAClB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAKrC;AAgBD,wBAAiB,gBAAgB,CAC/B,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,UAAU,GAAG,SAAS,GAC9B,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAKrC;AAED,wBAAiB,cAAc,CAC7B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,mBAAmB,GAC5B,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAMrC"}
package/dist/handed.js CHANGED
@@ -1,38 +1,45 @@
1
+ import { entriesIn, patching } from '@agentshouse/mdruntime';
1
2
  import { roomVersion } from './version.js';
2
- export function scopeHanded(scope) {
3
- return {
4
- roomVersion: roomVersion(scope),
5
- revisions: new Map(scope.files.flatMap(({ path, revision }) => revision === undefined ? [] : [[path, revision]])),
6
- };
3
+ function* revised(files) {
4
+ for (const { path, revision } of files)
5
+ if (revision !== undefined)
6
+ yield [path, revision];
7
7
  }
8
- function revised(revisions, path, revision) {
9
- if (revision === undefined)
10
- revisions.delete(path);
11
- else
12
- revisions.set(path, revision);
8
+ export function* scopeHanded(scope) {
9
+ return { roomVersion: roomVersion(scope), revisions: yield* patching({}, revised(scope.files)) };
13
10
  }
14
11
  export function heldHanded(held) {
15
- return { roomVersion: held.roomVersion, revisions: new Map(Object.entries(held.revisions)) };
16
- }
17
- export function acceptedHanded(held, accepted, roomVersion) {
18
- const revisions = new Map(held.revisions);
19
- for (const [path, revision] of Object.entries(accepted.revisions))
20
- revisions.set(path, revision);
21
- for (const path of accepted.removals)
22
- revisions.delete(path);
23
- return { roomVersion, revisions };
24
- }
25
- export function enumeratedHanded(view, earlier) {
26
- const revisions = new Map(earlier?.revisions);
12
+ return { roomVersion: held.roomVersion, revisions: held.revisions };
13
+ }
14
+ export function* acceptedHanded(held, accepted, roomVersion) {
15
+ return {
16
+ roomVersion,
17
+ revisions: yield* patching(held.revisions, entriesIn(accepted.revisions), accepted.removals),
18
+ };
19
+ }
20
+ function* kept(view) {
27
21
  for (const change of view.changes) {
28
- revised(revisions, change.path, 'removed' in change ? undefined : change.revision);
22
+ if (!('removed' in change) && change.revision !== undefined) {
23
+ yield [change.path, change.revision];
24
+ }
29
25
  }
30
- return { roomVersion: roomVersion(view), revisions };
31
26
  }
32
- export function streamedHanded(held, advanced) {
33
- const revisions = new Map(held.revisions);
34
- for (const entry of advanced.entries) {
35
- revised(revisions, entry.path, entry.kind === 'removed' ? undefined : entry.revision);
27
+ function* dropped(view) {
28
+ for (const change of view.changes) {
29
+ if ('removed' in change || change.revision === undefined)
30
+ yield change.path;
36
31
  }
37
- return { roomVersion: advanced.page.roomVersion, revisions };
32
+ }
33
+ export function* enumeratedHanded(view, earlier) {
34
+ return {
35
+ roomVersion: roomVersion(view),
36
+ revisions: yield* patching(earlier?.revisions ?? {}, kept(view), dropped(view)),
37
+ };
38
+ }
39
+ export function* streamedHanded(held, advanced) {
40
+ const { page } = advanced;
41
+ return {
42
+ roomVersion: page.roomVersion,
43
+ revisions: yield* patching(held.revisions, entriesIn(page.revisions), page.removals),
44
+ };
38
45
  }
package/dist/read.d.ts CHANGED
@@ -1,11 +1,27 @@
1
- import type { AdapterFailure, BinaryFile, BootstrapPage, RefreshResult } from '@agentshouse/mdruntime';
1
+ import { type AdapterFailure, type BinaryFile, type BootstrapPage, type RefreshResult } from '@agentshouse/mdruntime';
2
2
  import type { TrackedAuthority } from './discovery.js';
3
3
  import type { HouseMode } from './transport.js';
4
4
  import { type LogPosition } from './version.js';
5
5
  export type HeadChange = BootstrapPage['changes'][string];
6
- export declare function identities(revisions: Readonly<Record<string, string>>): {
7
- fileIds?: Record<string, string>;
6
+ export type Answered = {
7
+ readonly documents: Map<string, string>;
8
+ readonly revisions: Map<string, string>;
9
+ readonly fileIds: Map<string, string>;
10
+ readonly changes: Map<string, HeadChange>;
11
+ readonly binaryFiles: Map<string, BinaryFile>;
12
+ readonly removals: Set<string>;
8
13
  };
14
+ export declare function answering(): Answered;
15
+ export declare function revised(answer: Answered, path: string, revision: string): void;
16
+ export declare function forgotten(answer: Answered, path: string): void;
17
+ export declare function answered(answer: Answered): Generator<number, {
18
+ documents: Readonly<Record<string, string>>;
19
+ revisions: Readonly<Record<string, string>>;
20
+ fileIds?: Readonly<Record<string, string>>;
21
+ changes: Readonly<Record<string, HeadChange>>;
22
+ binaryFiles: Readonly<Record<string, BinaryFile>>;
23
+ removals: readonly string[];
24
+ }, void>;
9
25
  export type HouseManifestFile = {
10
26
  path: string;
11
27
  revision: string | undefined;
@@ -77,7 +93,6 @@ export type HouseEnumeration = {
77
93
  authorities: readonly HouseView[];
78
94
  };
79
95
  export declare function authorityRoot(handle: string): string;
80
- export declare function contentPrefixes(tracked: TrackedAuthority): readonly string[];
81
96
  export declare function schemaPath(handle: string, schema: string): string;
82
97
  export declare function parseGrant(body: unknown): HouseGrant | null;
83
98
  export declare function headChange(held: {
@@ -85,15 +100,15 @@ export declare function headChange(held: {
85
100
  readonly created_at?: unknown;
86
101
  }): HeadChange | undefined | null;
87
102
  export declare function binaryFileOf(held: Readonly<Record<string, unknown>>): BinaryFile | undefined | null;
88
- export declare function parseEnvelope(body: unknown): HouseEnvelope | null;
89
- export declare function parseSiteBootstrap(body: unknown): HouseScope | null;
103
+ export declare function parseEnvelope(body: unknown): Generator<number, HouseEnvelope | null, void>;
104
+ export declare function parseSiteBootstrap(body: unknown): Generator<number, HouseScope | null, void>;
90
105
  export declare function siteBootstrapNext(body: unknown): string | null;
91
106
  export declare function siteBootstrapOffset(body: unknown): number | null;
92
107
  export declare function parseEnumeration(body: unknown, mode: HouseMode): HouseEnumeration | null;
93
108
  export declare function wholeView(first: HouseView, more: (page: HousePage) => Promise<HouseView | PageFailure>): Promise<HouseView | PageFailure>;
94
- export declare function advancedScope(scope: HouseScope, view: HouseView): HouseScope;
109
+ export declare function advancedScope(scope: HouseScope, view: HouseView): Generator<number, HouseScope, void>;
95
110
  export declare function matchesScope(scope: HouseScope, tracked: TrackedAuthority): boolean;
96
- export declare function bootstrapOf(scope: HouseScope): BootstrapPage;
111
+ export declare function bootstrapping(scope: HouseScope): Generator<number, BootstrapPage, void>;
97
112
  export type HouseSchema = {
98
113
  schema: string | null;
99
114
  version: string | null;
@@ -101,6 +116,6 @@ export type HouseSchema = {
101
116
  };
102
117
  export declare function schemaOf(scope: HouseScope, schema: string): HouseSchema | null;
103
118
  export declare function viewOf(enumeration: HouseEnumeration, tracked: TrackedAuthority): HouseView | undefined;
104
- export declare function refreshFrom(view: HouseView, fromRoomVersion: string): RefreshResult;
119
+ export declare function refreshFrom(view: HouseView, fromRoomVersion: string): Promise<RefreshResult>;
105
120
  export {};
106
121
  //# sourceMappingURL=read.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,aAAa,EAEb,aAAa,EACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MA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,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAO9E;AAED,wBAAgB,MAAM,CACpB,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,gBAAgB,GACxB,SAAS,GAAG,SAAS,CAEvB;AAsBD,wBAAsB,WAAW,CAC/B,IAAI,EAAE,SAAS,EACf,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,aAAa,CAAC,CAExB"}
package/dist/read.js CHANGED
@@ -1,21 +1,51 @@
1
+ import { patching, ROW_WEIGHT, stepped, } from '@agentshouse/mdruntime';
1
2
  import { DECIMAL, readPosition, roomVersion } from './version.js';
2
3
  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 };
4
+ function fileOf(revision) {
5
+ return REVISION_FILE.exec(revision)?.[1];
6
+ }
7
+ export function answering() {
8
+ return {
9
+ documents: new Map(),
10
+ revisions: new Map(),
11
+ fileIds: new Map(),
12
+ changes: new Map(),
13
+ binaryFiles: new Map(),
14
+ removals: new Set(),
15
+ };
16
+ }
17
+ export function revised(answer, path, revision) {
18
+ answer.revisions.set(path, revision);
19
+ const file = fileOf(revision);
20
+ if (file !== undefined)
21
+ answer.fileIds.set(path, file);
22
+ }
23
+ export function forgotten(answer, path) {
24
+ answer.documents.delete(path);
25
+ answer.revisions.delete(path);
26
+ answer.fileIds.delete(path);
27
+ answer.changes.delete(path);
28
+ answer.binaryFiles.delete(path);
29
+ answer.removals.delete(path);
30
+ }
31
+ export function* answered(answer) {
32
+ const removals = [];
33
+ for (const path of answer.removals) {
34
+ removals.push(path);
35
+ yield ROW_WEIGHT;
36
+ }
37
+ return {
38
+ documents: yield* patching({}, answer.documents),
39
+ revisions: yield* patching({}, answer.revisions),
40
+ ...(answer.fileIds.size === 0 ? {} : { fileIds: yield* patching({}, answer.fileIds) }),
41
+ changes: yield* patching({}, answer.changes),
42
+ binaryFiles: yield* patching({}, answer.binaryFiles),
43
+ removals,
44
+ };
9
45
  }
10
46
  export function authorityRoot(handle) {
11
47
  return `/rooms/${handle}`;
12
48
  }
13
- export function contentPrefixes(tracked) {
14
- return [
15
- authorityRoot(tracked.handle),
16
- ...tracked.schemas.map((schema) => schemaPath(tracked.handle, schema)),
17
- ];
18
- }
19
49
  export function schemaPath(handle, schema) {
20
50
  return `${authorityRoot(handle)}/${schema}`;
21
51
  }
@@ -105,7 +135,7 @@ function parseFile(value, mode) {
105
135
  ...binaried(binary),
106
136
  };
107
137
  }
108
- function parseScope(value, mode) {
138
+ function* parseScope(value, mode) {
109
139
  if (typeof value !== 'object' || value === null)
110
140
  return null;
111
141
  const held = value;
@@ -129,6 +159,7 @@ function parseScope(value, mode) {
129
159
  if (file === null)
130
160
  return null;
131
161
  files.push(file);
162
+ yield ROW_WEIGHT;
132
163
  }
133
164
  const contents = [];
134
165
  for (const entry of held.contents) {
@@ -138,6 +169,7 @@ function parseScope(value, mode) {
138
169
  if (typeof content.path !== 'string' || typeof content.content !== 'string')
139
170
  return null;
140
171
  contents.push({ path: content.path, content: content.content });
172
+ yield ROW_WEIGHT;
141
173
  }
142
174
  return { anchor: manifest.anchor, ...at, files, contents };
143
175
  }
@@ -162,14 +194,14 @@ function parseCursor(value) {
162
194
  return null;
163
195
  return { room, path, ...(parsed === undefined ? {} : { cut: parsed }) };
164
196
  }
165
- export function parseEnvelope(body) {
197
+ export function* parseEnvelope(body) {
166
198
  if (typeof body !== 'object' || body === null)
167
199
  return null;
168
200
  if (!('scopes' in body) || !Array.isArray(body.scopes))
169
201
  return null;
170
202
  const scopes = [];
171
203
  for (const entry of body.scopes) {
172
- const scope = parseScope(entry, 'credential');
204
+ const scope = yield* parseScope(entry, 'credential');
173
205
  if (scope === null)
174
206
  return null;
175
207
  scopes.push(scope);
@@ -179,8 +211,8 @@ export function parseEnvelope(body) {
179
211
  const next = parseCursor(body.next);
180
212
  return next === null ? null : { scopes, next };
181
213
  }
182
- export function parseSiteBootstrap(body) {
183
- return parseScope(body, 'site');
214
+ export function* parseSiteBootstrap(body) {
215
+ return yield* parseScope(body, 'site');
184
216
  }
185
217
  export function siteBootstrapNext(body) {
186
218
  if (typeof body !== 'object' || body === null || !('next' in body))
@@ -310,12 +342,21 @@ export async function wholeView(first, more) {
310
342
  changes: [...changes.values()],
311
343
  };
312
344
  }
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]));
345
+ export function* advancedScope(scope, view) {
346
+ const files = new Map();
347
+ for (const file of scope.files) {
348
+ files.set(file.path, file);
349
+ yield ROW_WEIGHT;
350
+ }
351
+ const contents = new Map();
352
+ for (const entry of scope.contents) {
353
+ contents.set(entry.path, entry.content);
354
+ yield ROW_WEIGHT;
355
+ }
316
356
  for (const change of view.changes) {
317
357
  files.delete(change.path);
318
358
  contents.delete(change.path);
359
+ yield ROW_WEIGHT;
319
360
  if ('removed' in change)
320
361
  continue;
321
362
  files.set(change.path, {
@@ -328,43 +369,43 @@ export function advancedScope(scope, view) {
328
369
  if ('content' in change)
329
370
  contents.set(change.path, change.content);
330
371
  }
372
+ const listed = [];
373
+ for (const [path, content] of contents) {
374
+ listed.push({ path, content });
375
+ yield ROW_WEIGHT;
376
+ }
331
377
  return {
332
378
  ...scope,
333
379
  position: view.position,
334
380
  logEpoch: view.logEpoch,
335
381
  files: [...files.values()],
336
- contents: [...contents].map(([path, content]) => ({ path, content })),
382
+ contents: listed,
337
383
  };
338
384
  }
339
385
  export function matchesScope(scope, tracked) {
340
386
  return scope.anchor === tracked.authority;
341
387
  }
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 = {};
388
+ export function* bootstrapping(scope) {
389
+ const contents = new Map();
390
+ for (const entry of scope.contents) {
391
+ contents.set(entry.path, entry.content);
392
+ yield ROW_WEIGHT;
393
+ }
394
+ const answer = answering();
348
395
  for (const file of scope.files) {
349
- if (file.revision !== undefined)
350
- revisions[file.path] = file.revision;
396
+ yield ROW_WEIGHT;
351
397
  if (file.head !== undefined)
352
- changes[file.path] = file.head;
398
+ answer.changes.set(file.path, file.head);
353
399
  const content = contents.get(file.path);
354
400
  if (file.binary !== undefined)
355
- binaryFiles[file.path] = file.binary;
401
+ answer.binaryFiles.set(file.path, file.binary);
356
402
  else if (content !== undefined)
357
- documents[file.path] = content;
403
+ answer.documents.set(file.path, content);
404
+ if (file.revision !== undefined)
405
+ revised(answer, file.path, file.revision);
358
406
  }
359
- return {
360
- kind: 'bootstrap',
361
- roomVersion: roomVersion(scope),
362
- documents,
363
- revisions,
364
- ...identities(revisions),
365
- changes,
366
- binaryFiles,
367
- };
407
+ const { removals: _removals, ...page } = yield* answered(answer);
408
+ return { kind: 'bootstrap', roomVersion: roomVersion(scope), ...page };
368
409
  }
369
410
  export function schemaOf(scope, schema) {
370
411
  const file = scope.files.find((entry) => entry.path === schema);
@@ -378,36 +419,27 @@ export function schemaOf(scope, schema) {
378
419
  export function viewOf(enumeration, tracked) {
379
420
  return enumeration.authorities.find((entry) => entry.authority === tracked.authority);
380
421
  }
381
- export function refreshFrom(view, fromRoomVersion) {
422
+ function* refreshing(view, fromRoomVersion) {
382
423
  if (roomVersion(view) === fromRoomVersion)
383
424
  return { kind: 'still-current' };
384
- const documents = {};
385
- const revisions = {};
386
- const changes = {};
387
- const binaryFiles = {};
388
- const removals = [];
425
+ const answer = answering();
389
426
  for (const change of view.changes) {
427
+ yield ROW_WEIGHT;
390
428
  if ('removed' in change) {
391
- removals.push(change.path);
429
+ answer.removals.add(change.path);
392
430
  continue;
393
431
  }
394
432
  if ('content' in change)
395
- documents[change.path] = change.content;
433
+ answer.documents.set(change.path, change.content);
396
434
  else
397
- binaryFiles[change.path] = change.binary;
398
- if (change.revision !== undefined)
399
- revisions[change.path] = change.revision;
435
+ answer.binaryFiles.set(change.path, change.binary);
400
436
  if (change.head !== undefined)
401
- changes[change.path] = change.head;
437
+ answer.changes.set(change.path, change.head);
438
+ if (change.revision !== undefined)
439
+ revised(answer, change.path, change.revision);
402
440
  }
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
- };
441
+ return { kind: 'net-advancement', roomVersion: roomVersion(view), ...(yield* answered(answer)) };
442
+ }
443
+ export async function refreshFrom(view, fromRoomVersion) {
444
+ return stepped(refreshing(view, fromRoomVersion));
413
445
  }
@@ -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;AA4BhC,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAyCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,QAAQ,UAAQ,GAAG,OAAO,CAwR1F"}
package/dist/site.js CHANGED
@@ -1,7 +1,8 @@
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 { advancedScope, bootstrapping, parseEnumeration, parseSiteBootstrap, refreshFrom, siteBootstrapNext, siteBootstrapOffset, viewOf, wholeView, } from './read.js';
5
6
  import { sha256Hex } from './digest.js';
6
7
  import { classifyDoor, classifyRead, discoveryFailure } from './refusal.js';
7
8
  import { houseNotifications } from './stream.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
  }
@@ -77,7 +78,7 @@ export function createSiteAdapter(transport, snapshot = false) {
77
78
  const classified = classifyDoor(answer.status, answer.body, entry.locator);
78
79
  if (classified !== null)
79
80
  return { failure: classified };
80
- const scope = parseSiteBootstrap(answer.body);
81
+ const scope = await stepped(parseSiteBootstrap(answer.body));
81
82
  return scope === null ? { failure: UNCERTAIN } : { body: answer.body, scope };
82
83
  }
83
84
  async function assembled(entry, scope, path, offset) {
@@ -128,13 +129,13 @@ export function createSiteAdapter(transport, snapshot = false) {
128
129
  const view = await enumeration(entry, scope);
129
130
  if ('kind' in view)
130
131
  return { failure: settled(view) };
131
- return { scope: advancedScope(scope, view), next: null };
132
+ return { scope: await stepped(advancedScope(scope, view)), next: null };
132
133
  }
133
134
  async function refreshed(entry, fromRoomVersion) {
134
135
  const from = logPosition(fromRoomVersion);
135
136
  if (from === null)
136
137
  return { kind: 'beyond-horizon' };
137
- const streamed = notifications.advance(entry, from);
138
+ const streamed = await stepped(notifications.advance(entry, from));
138
139
  if (streamed !== null) {
139
140
  const models = await streamedModels(streamed.schemas, entry, 'site');
140
141
  return models === undefined ? streamed.page : { ...streamed.page, models };
@@ -143,7 +144,7 @@ export function createSiteAdapter(transport, snapshot = false) {
143
144
  if ('kind' in view)
144
145
  return view;
145
146
  notifications.reach(entry.authority, view);
146
- const answer = refreshFrom(view, fromRoomVersion);
147
+ const answer = await refreshFrom(view, fromRoomVersion);
147
148
  if (answer.kind !== 'net-advancement')
148
149
  return answer;
149
150
  const models = await viewModels(view, entry);
@@ -188,7 +189,7 @@ export function createSiteAdapter(transport, snapshot = false) {
188
189
  const models = await partModels(held.scope, entry, new Set(seen), held.next === null);
189
190
  const continuation = held.next === null ? null : { after: held.next, seen };
190
191
  return {
191
- ...bootstrapOf(held.scope),
192
+ ...(await stepped(bootstrapping(held.scope))),
192
193
  ...(models === undefined ? {} : { models }),
193
194
  ...(continuation === null ? {} : { pageToken: JSON.stringify(continuation) }),
194
195
  };
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,KAAK,EAGV,kBAAkB,EAElB,WAAW,EACX,eAAe,EAEf,iBAAiB,EACjB,cAAc,EAEf,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EAEb,SAAS,EAET,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AA0C7D,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;AAEvE,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACrC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,EAAE,QAAQ,EAAE,cAAc,GAAG,MAAM,IAAI,CAAC;IACxF,IAAI,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI,CAAC;IAC5C,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,CAAC;IAClD,MAAM,IAAI,IAAI,CAAC;IACf,KAAK,CAAC,WA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