@agentshouse/mdruntime-adapter 0.1.0-alpha.9 → 0.1.0-c055ce6f0fdd0

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 (61) hide show
  1. package/AGENTS.md +186 -34
  2. package/README.md +32 -0
  3. package/dist/actions.d.ts +5 -13
  4. package/dist/actions.d.ts.map +1 -1
  5. package/dist/actions.js +241 -334
  6. package/dist/adapter.d.ts.map +1 -1
  7. package/dist/adapter.js +255 -215
  8. package/dist/digest.js +1 -5
  9. package/dist/discovery.d.ts +23 -33
  10. package/dist/discovery.d.ts.map +1 -1
  11. package/dist/discovery.js +143 -230
  12. package/dist/gather.d.ts +3 -0
  13. package/dist/gather.d.ts.map +1 -0
  14. package/dist/gather.js +40 -0
  15. package/dist/index.d.ts +2 -2
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +1 -3
  18. package/dist/links.d.ts +20 -0
  19. package/dist/links.d.ts.map +1 -0
  20. package/dist/links.js +104 -0
  21. package/dist/map.d.ts +2 -2
  22. package/dist/map.d.ts.map +1 -1
  23. package/dist/map.js +6 -7
  24. package/dist/model.d.ts +7 -18
  25. package/dist/model.d.ts.map +1 -1
  26. package/dist/model.js +48 -59
  27. package/dist/read.d.ts +31 -26
  28. package/dist/read.d.ts.map +1 -1
  29. package/dist/read.js +205 -199
  30. package/dist/refusal.d.ts +3 -1
  31. package/dist/refusal.d.ts.map +1 -1
  32. package/dist/refusal.js +27 -62
  33. package/dist/site.d.ts.map +1 -1
  34. package/dist/site.js +103 -151
  35. package/dist/stream.d.ts +16 -6
  36. package/dist/stream.d.ts.map +1 -1
  37. package/dist/stream.js +238 -214
  38. package/dist/transport.d.ts +69 -30
  39. package/dist/transport.d.ts.map +1 -1
  40. package/dist/transport.js +2 -3
  41. package/dist/version.d.ts +2 -0
  42. package/dist/version.d.ts.map +1 -1
  43. package/dist/version.js +32 -18
  44. package/dist/write.d.ts +13 -8
  45. package/dist/write.d.ts.map +1 -1
  46. package/dist/write.js +132 -215
  47. package/package.json +4 -12
  48. package/dist/actions.js.map +0 -1
  49. package/dist/adapter.js.map +0 -1
  50. package/dist/digest.js.map +0 -1
  51. package/dist/discovery.js.map +0 -1
  52. package/dist/index.js.map +0 -1
  53. package/dist/map.js.map +0 -1
  54. package/dist/model.js.map +0 -1
  55. package/dist/read.js.map +0 -1
  56. package/dist/refusal.js.map +0 -1
  57. package/dist/site.js.map +0 -1
  58. package/dist/stream.js.map +0 -1
  59. package/dist/transport.js.map +0 -1
  60. package/dist/version.js.map +0 -1
  61. package/dist/write.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACrD,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EACV,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,2 @@
1
1
  export { createAgentsHouseAdapter } from './adapter.js';
2
- export { nativePath, roomLocalPath } from './map.js';
3
-
4
- //# sourceMappingURL=index.js.map
2
+ export { PRIVATE_LOCATOR } from './transport.js';
@@ -0,0 +1,20 @@
1
+ import type { HeldRoom, MutationResult, RoomAttachment } from '@agentshouse/mdruntime';
2
+ import type { HouseScope, HouseView } from './read.js';
3
+ import type { StreamedAdvancement } from './stream.js';
4
+ export type RoomLinks = {
5
+ roomVersion: string;
6
+ handed: ReadonlyMap<string, RoomAttachment>;
7
+ paths: ReadonlyMap<string, ReadonlySet<string>>;
8
+ revisions: ReadonlyMap<string, string>;
9
+ };
10
+ export declare function scopeLinks(scope: HouseScope): RoomLinks;
11
+ export declare function heldLinks(held: HeldRoom): RoomLinks;
12
+ export declare function acceptedLinks(held: RoomLinks, accepted: Extract<MutationResult, {
13
+ kind: 'accepted';
14
+ }>, roomVersion: string, originals: readonly RoomAttachment[]): {
15
+ links: RoomLinks;
16
+ attachments?: readonly RoomAttachment[];
17
+ };
18
+ export declare function enumeratedLinks(view: HouseView, earlier: RoomLinks | undefined): RoomLinks;
19
+ export declare function streamedLinks(held: RoomLinks, advanced: StreamedAdvancement): RoomLinks | null;
20
+ //# sourceMappingURL=links.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOvD,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5C,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAcF,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAWvD;AAOD,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,CAOnD;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,EACvD,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,SAAS,cAAc,EAAE,GACnC;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,WAAW,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;CAAE,CA2B/D;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAgB1F;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,GAAG,SAAS,GAAG,IAAI,CAoB9F"}
package/dist/links.js ADDED
@@ -0,0 +1,104 @@
1
+ import { roomVersion } from './version.js';
2
+ const ATTACHMENT_REFERENCE = /at_[1-9a-hjkmnp-tv-z][0-9a-hjkmnp-tv-z]*\.[0-9a-hjkmnp-tv-z]/g;
3
+ const NONE = new Set();
4
+ function linkedBy(text) {
5
+ if (text === null)
6
+ return NONE;
7
+ const references = new Set(Array.from(text.matchAll(ATTACHMENT_REFERENCE), ([found]) => found));
8
+ return references.size === 0 ? NONE : references;
9
+ }
10
+ function handedOf(attachments) {
11
+ return new Map((attachments ?? []).map((attachment) => [attachment.reference, attachment]));
12
+ }
13
+ export function scopeLinks(scope) {
14
+ return {
15
+ roomVersion: roomVersion(scope),
16
+ handed: handedOf(scope.attachments),
17
+ paths: new Map(scope.contents.map(({ path, content }) => [path, linkedBy(content)])),
18
+ revisions: new Map(scope.files.flatMap(({ path, revision }) => revision === undefined ? [] : [[path, revision]])),
19
+ };
20
+ }
21
+ function revised(revisions, path, revision) {
22
+ if (revision === undefined)
23
+ revisions.delete(path);
24
+ else
25
+ revisions.set(path, revision);
26
+ }
27
+ export function heldLinks(held) {
28
+ return {
29
+ roomVersion: held.roomVersion,
30
+ handed: handedOf(held.attachments),
31
+ paths: new Map(Object.entries(held.documents).map(([path, text]) => [path, linkedBy(text)])),
32
+ revisions: new Map(Object.entries(held.revisions)),
33
+ };
34
+ }
35
+ export function acceptedLinks(held, accepted, roomVersion, originals) {
36
+ const paths = new Map(held.paths);
37
+ const revisions = new Map(held.revisions);
38
+ const handed = new Map(held.handed);
39
+ const answered = handedOf(originals);
40
+ for (const [path, text] of Object.entries(accepted.documents)) {
41
+ const linked = linkedBy(text);
42
+ for (const reference of linked) {
43
+ const original = answered.get(reference);
44
+ if (!handed.has(reference) && original !== undefined)
45
+ handed.set(reference, original);
46
+ }
47
+ paths.set(path, linked);
48
+ }
49
+ for (const [path, revision] of Object.entries(accepted.revisions))
50
+ revisions.set(path, revision);
51
+ for (const path of accepted.removals) {
52
+ paths.delete(path);
53
+ revisions.delete(path);
54
+ }
55
+ const linked = new Set([...paths.values()].flatMap((references) => [...references]));
56
+ for (const reference of held.handed.keys()) {
57
+ const before = [...held.paths.values()].some((references) => references.has(reference));
58
+ if (before && !linked.has(reference))
59
+ handed.delete(reference);
60
+ }
61
+ const links = { roomVersion, handed, paths, revisions };
62
+ const changed = handed.size !== held.handed.size || [...handed.keys()].some((key) => !held.handed.has(key));
63
+ return changed ? { links, attachments: [...handed.values()] } : { links };
64
+ }
65
+ export function enumeratedLinks(view, earlier) {
66
+ const paths = new Map(earlier?.paths);
67
+ const revisions = new Map(earlier?.revisions);
68
+ for (const change of view.changes) {
69
+ paths.set(change.path, linkedBy('content' in change ? change.content : null));
70
+ revised(revisions, change.path, 'removed' in change
71
+ ? undefined
72
+ : 'reference' in change
73
+ ? change.reference.revision
74
+ : change.revision);
75
+ }
76
+ return { roomVersion: roomVersion(view), handed: handedOf(view.attachments), paths, revisions };
77
+ }
78
+ export function streamedLinks(held, advanced) {
79
+ const paths = new Map(held.paths);
80
+ const revisions = new Map(held.revisions);
81
+ const dropped = new Set();
82
+ for (const entry of advanced.entries) {
83
+ revised(revisions, entry.path, entry.kind === 'removed' ? undefined : entry.revision);
84
+ const text = entry.kind === 'removed' ? null : entry.text;
85
+ if (text === undefined)
86
+ return null;
87
+ const linked = linkedBy(text);
88
+ for (const reference of linked)
89
+ if (!held.handed.has(reference))
90
+ return null;
91
+ for (const reference of paths.get(entry.path) ?? held.handed.keys()) {
92
+ if (held.handed.has(reference) && !linked.has(reference))
93
+ dropped.add(reference);
94
+ }
95
+ paths.set(entry.path, linked);
96
+ }
97
+ for (const references of paths.values()) {
98
+ for (const reference of references)
99
+ dropped.delete(reference);
100
+ }
101
+ if (dropped.size > 0)
102
+ return null;
103
+ return { roomVersion: advanced.page.roomVersion, handed: held.handed, paths, revisions };
104
+ }
package/dist/map.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare function roomLocalPath(path: string, handle?: string): string;
2
- export declare function nativePath(path: string, handle?: string): string;
1
+ export declare function roomLocalPath(path: string, handle: string): string;
2
+ export declare function nativePath(path: string, handle: string): string;
3
3
  //# sourceMappingURL=map.d.ts.map
package/dist/map.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAUnE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAIhE"}
1
+ {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAUlE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAG/D"}
package/dist/map.js CHANGED
@@ -1,15 +1,14 @@
1
1
  export function roomLocalPath(path, handle) {
2
- const prefix = handle === undefined ? '/private/' : `/rooms/${handle}/`;
2
+ const prefix = `/rooms/${handle}/`;
3
3
  const local = path.startsWith(prefix) ? path.slice(prefix.length) : path;
4
- if (local === '' || local.split('/').some((part)=>part === '' || part === '.' || part === '..')) {
4
+ if (local === '' ||
5
+ local.split('/').some((part) => part === '' || part === '.' || part === '..')) {
5
6
  throw new Error('invalid authority-relative path');
6
7
  }
7
8
  return local;
8
9
  }
9
10
  export function nativePath(path, handle) {
10
- if (path.startsWith('/')) throw new Error('canonical Room path required');
11
- const local = roomLocalPath(path);
12
- return handle === undefined ? `/private/${local}` : `/rooms/${handle}/${local}`;
11
+ if (path.startsWith('/'))
12
+ throw new Error('canonical Room path required');
13
+ return `/rooms/${handle}/${roomLocalPath(path, handle)}`;
13
14
  }
14
-
15
- //# sourceMappingURL=map.js.map
package/dist/model.d.ts CHANGED
@@ -1,19 +1,8 @@
1
- import type { AdapterFailure, ModelIdentity, ModelRequest, ModelResult } from '@agentshouse/mdruntime';
2
- import type { HouseDefinitions } from './read.js';
3
- export type HeldModel = {
4
- snapshot: ModelResult;
5
- identity: ModelIdentity | null;
6
- };
7
- export declare const MODEL_ABSENT: ModelResult;
8
- export declare function failedModel(failure: AdapterFailure | {
9
- kind: 'beyond-horizon';
10
- }): ModelResult;
11
- export declare function modelKey(locator: string, attached: ModelRequest['attached']): string;
12
- export declare function heldModel(read: HouseDefinitions | null, identity: string, failure: ModelResult): Promise<HeldModel>;
13
- export type ModelShelf = {
14
- retain(key: string, acquired: HeldModel | undefined): HeldModel | undefined;
15
- answer(request: ModelRequest): ModelResult;
16
- keep(locators: readonly string[]): void;
17
- };
18
- export declare function modelShelf(): ModelShelf;
1
+ import type { RoomModels } from '@agentshouse/mdruntime';
2
+ import type { TrackedAuthority } from './discovery.js';
3
+ import { type HouseScope, type HouseView } from './read.js';
4
+ import type { HouseMode, HouseStreamEntry } from './transport.js';
5
+ export declare function scopeModels(scope: HouseScope, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
6
+ export declare function viewModels(view: HouseView, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
7
+ export declare function streamedModels(schemas: ReadonlyMap<string, HouseStreamEntry>, tracked: TrackedAuthority, mode: HouseMode): Promise<RoomModels | undefined>;
19
8
  //# sourceMappingURL=model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,CAAC;AAElF,eAAO,MAAM,YAAY,EAAE,WAAmE,CAAC;AAE/F,wBAAgB,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAAG,WAAW,CAI7F;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,GAAG,MAAM,CAEpF;AAED,wBAAsB,SAAS,CAC7B,IAAI,EAAE,gBAAgB,GAAG,IAAI,EAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,SAAS,CAAC,CAOpB;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAC5E,MAAM,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,CAAC;IAC3C,IAAI,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;CACzC,CAAC;AAEF,wBAAgB,UAAU,IAAI,UAAU,CAqBvC"}
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAA0C,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAiClE,wBAAgB,WAAW,CACzB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAEjC;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAQjC;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAC9C,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CASjC"}
package/dist/model.js CHANGED
@@ -1,64 +1,53 @@
1
1
  import { sha256Hex } from './digest.js';
2
- export const MODEL_ABSENT = {
3
- kind: 'model-unavailable',
4
- reason: 'not-readable'
5
- };
6
- export function failedModel(failure) {
7
- if (failure.kind === 'revoked-authorization') return {
8
- kind: 'revoked-authorization'
9
- };
10
- if (failure.kind === 'transport-uncertainty') return {
11
- kind: 'transport-uncertainty'
12
- };
13
- return MODEL_ABSENT;
2
+ import { schemaOf, schemaPath } from './read.js';
3
+ const MODEL_ABSENT = { kind: 'model-unavailable', reason: 'not-readable' };
4
+ const ABSENT_SCHEMA = { schema: null, version: null };
5
+ async function heldModel(read, identity) {
6
+ if (read === null)
7
+ return MODEL_ABSENT;
8
+ const version = await sha256Hex(JSON.stringify(read.version));
9
+ return { kind: 'model', snapshot: { identity, version, schema: read.schema } };
14
10
  }
15
- export function modelKey(locator, attached) {
16
- return `${locator} ${attached}`;
17
- }
18
- export async function heldModel(read, identity, failure) {
19
- if (read === null) return {
20
- snapshot: failure,
21
- identity: null
22
- };
23
- const version = await sha256Hex(JSON.stringify(read.versions));
24
- return {
25
- snapshot: {
26
- kind: 'model',
27
- snapshot: {
28
- identity,
29
- version,
30
- definitions: read.definitions
31
- }
32
- },
33
- identity: {
34
- identity,
35
- version
11
+ async function modelsOf(tracked, read) {
12
+ const models = {};
13
+ const collection = read(tracked.schema);
14
+ if (collection !== undefined) {
15
+ models.collection = await heldModel(collection, schemaPath(tracked.handle, tracked.schema));
16
+ }
17
+ if (tracked.houseModel !== null) {
18
+ const root = tracked.houseModel.root;
19
+ const selection = read(root);
20
+ if (selection !== undefined) {
21
+ models.selection = await heldModel(selection, schemaPath(tracked.handle, root));
36
22
  }
37
- };
23
+ }
24
+ return models.collection === undefined && models.selection === undefined ? undefined : models;
38
25
  }
39
- export function modelShelf() {
40
- const models = new Map();
41
- return {
42
- retain (key, acquired) {
43
- if (acquired === undefined) return models.get(key);
44
- if (acquired.snapshot.kind === 'transport-uncertainty') {
45
- const previous = models.get(key);
46
- if (previous !== undefined && previous.identity !== null) return previous;
47
- }
48
- models.set(key, acquired);
49
- return acquired;
50
- },
51
- answer (request) {
52
- return models.get(modelKey(request.locator, request.attached))?.snapshot ?? MODEL_ABSENT;
53
- },
54
- keep (locators) {
55
- for (const key of [
56
- ...models.keys()
57
- ]){
58
- if (!locators.some((locator)=>key.startsWith(`${locator} `))) models.delete(key);
59
- }
60
- }
61
- };
26
+ export function scopeModels(scope, tracked) {
27
+ return modelsOf(tracked, (schema) => schemaOf(scope, schema));
28
+ }
29
+ export function viewModels(view, tracked) {
30
+ return modelsOf(tracked, (schema) => {
31
+ const change = view.changes.find((candidate) => candidate.path === schema);
32
+ if (change === undefined)
33
+ return undefined;
34
+ if ('removed' in change)
35
+ return ABSENT_SCHEMA;
36
+ if ('content' in change)
37
+ return { schema: change.content, version: change.version };
38
+ return null;
39
+ });
40
+ }
41
+ export function streamedModels(schemas, tracked, mode) {
42
+ return modelsOf(tracked, (schema) => {
43
+ const entry = schemas.get(schema);
44
+ if (entry === undefined)
45
+ return undefined;
46
+ if (entry.kind === 'removed')
47
+ return ABSENT_SCHEMA;
48
+ if (entry.text === undefined)
49
+ return null;
50
+ const version = mode === 'site' ? entry.sha256 : entry.revision;
51
+ return version === undefined ? null : { schema: entry.text, version };
52
+ });
62
53
  }
63
-
64
- //# sourceMappingURL=model.js.map
package/dist/read.d.ts CHANGED
@@ -1,28 +1,32 @@
1
- import type { BootstrapPage, BootstrapResult, RefreshResult } from '@agentshouse/mdruntime';
2
- import { type TrackedAuthority } from './discovery.js';
1
+ import type { BootstrapPage, RefreshResult, RoomAttachment } from '@agentshouse/mdruntime';
2
+ import type { TrackedAuthority } from './discovery.js';
3
3
  import type { HouseMode } from './transport.js';
4
4
  import { type LogPosition } from './version.js';
5
+ export type HeadChange = BootstrapPage['changes'][string];
5
6
  export type HouseManifestFile = {
6
7
  path: string;
7
8
  revision: string | undefined;
8
9
  version: string;
10
+ head?: HeadChange;
9
11
  };
10
12
  export type HouseContent = {
11
13
  path: string;
12
14
  content: string;
13
15
  };
14
16
  export type HouseScope = LogPosition & {
15
- scope: 'room' | 'private';
16
17
  anchor: string;
17
- roomHandle: string | undefined;
18
18
  files: readonly HouseManifestFile[];
19
19
  contents: readonly HouseContent[];
20
+ attachments?: readonly RoomAttachment[];
20
21
  };
21
22
  export type HouseEnvelope = {
22
23
  scopes: readonly HouseScope[];
23
24
  };
24
25
  export type HouseGrant = {
25
- method: 'GET' | 'POST';
26
+ method: 'GET';
27
+ url: string;
28
+ } | {
29
+ method: 'POST';
26
30
  operation: string;
27
31
  url: string;
28
32
  };
@@ -34,40 +38,41 @@ export type HouseChange = {
34
38
  content: string;
35
39
  revision: string | undefined;
36
40
  version: string;
41
+ head?: HeadChange;
37
42
  } | {
38
43
  path: string;
39
44
  reference: {
40
45
  revision: string;
41
46
  };
42
47
  };
48
+ export type HouseView = LogPosition & {
49
+ authority: string;
50
+ changes: readonly HouseChange[];
51
+ attachments?: readonly RoomAttachment[];
52
+ };
43
53
  export type HouseEnumeration = {
44
- authorities: readonly (LogPosition & {
45
- authority: string;
46
- changes: readonly HouseChange[];
47
- })[];
54
+ authorities: readonly HouseView[];
48
55
  };
49
- export declare function authorityRoot(handle: string | undefined): string;
50
- export declare const ROOM_README = "ROOM.md";
51
- export declare function selectionRoots(tracked: TrackedAuthority): readonly string[];
56
+ export declare function authorityRoot(handle: string): string;
52
57
  export declare function contentPrefixes(tracked: TrackedAuthority): readonly string[];
53
- export declare function modelPrefix(tracked: TrackedAuthority, modelRoot: string): string;
58
+ export declare function schemaPath(handle: string, schema: string): string;
54
59
  export declare function parseGrant(body: unknown): HouseGrant | null;
60
+ export declare function headChange(held: {
61
+ readonly author?: unknown;
62
+ readonly created_at?: unknown;
63
+ }): HeadChange | undefined | null;
64
+ export declare function parseOriginals(value: unknown): readonly RoomAttachment[] | null;
55
65
  export declare function parseEnvelope(body: unknown): HouseEnvelope | null;
56
66
  export declare function parseSiteBootstrap(body: unknown): HouseScope | null;
57
67
  export declare function parseEnumeration(body: unknown, mode: HouseMode): HouseEnumeration | null;
58
- export declare function advancedScope(scope: HouseScope, view: HouseEnumeration['authorities'][number]): HouseScope;
68
+ export declare function advancedScope(scope: HouseScope, view: HouseView): HouseScope;
59
69
  export declare function matchesScope(scope: HouseScope, tracked: TrackedAuthority): boolean;
60
- export declare function withinRoot(path: string, root: string): boolean;
61
- export declare function selects(tracked: TrackedAuthority, path: string): boolean;
62
- export declare function bootstrapFrom(envelope: HouseEnvelope, tracked: TrackedAuthority): BootstrapResult;
63
- export declare function bootstrapOf(scope: HouseScope, tracked: TrackedAuthority): BootstrapPage;
64
- export type HouseDefinitions = {
65
- definitions: Readonly<Record<string, string>>;
66
- versions: readonly string[];
70
+ export declare function bootstrapOf(scope: HouseScope): BootstrapPage;
71
+ export type HouseSchema = {
72
+ schema: string | null;
73
+ version: string | null;
67
74
  };
68
- export declare const MODEL_DEFINITION_ADDRESS = "types";
69
- export declare function definitionAddress(path: string): string;
70
- export declare function definitionsFrom(envelope: HouseEnvelope, tracked: TrackedAuthority, modelRoot: string): HouseDefinitions | null;
71
- export declare function definitionsOf(scope: HouseScope, modelRoot: string): HouseDefinitions | null;
72
- export declare function refreshFrom(enumeration: HouseEnumeration, tracked: TrackedAuthority, fromRoomVersion: string): RefreshResult;
75
+ export declare function schemaOf(scope: HouseScope, schema: string): HouseSchema | null;
76
+ export declare function viewOf(enumeration: HouseEnumeration, tracked: TrackedAuthority): HouseView | undefined;
77
+ export declare function refreshFrom(view: HouseView, fromRoomVersion: string): RefreshResult;
73
78
  //# sourceMappingURL=read.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5F,OAAO,EAA4B,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACj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