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

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 (69) hide show
  1. package/AGENTS.md +312 -74
  2. package/README.md +32 -0
  3. package/dist/actions.d.ts +57 -13
  4. package/dist/actions.d.ts.map +1 -1
  5. package/dist/actions.js +274 -397
  6. package/dist/adapter.d.ts +1 -0
  7. package/dist/adapter.d.ts.map +1 -1
  8. package/dist/adapter.js +525 -216
  9. package/dist/digest.js +1 -5
  10. package/dist/discovery.d.ts +27 -36
  11. package/dist/discovery.d.ts.map +1 -1
  12. package/dist/discovery.js +173 -228
  13. package/dist/gather.d.ts +4 -0
  14. package/dist/gather.d.ts.map +1 -0
  15. package/dist/gather.js +35 -0
  16. package/dist/index.d.ts +4 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +3 -3
  19. package/dist/map.d.ts +2 -2
  20. package/dist/map.d.ts.map +1 -1
  21. package/dist/map.js +6 -7
  22. package/dist/model.d.ts +7 -18
  23. package/dist/model.d.ts.map +1 -1
  24. package/dist/model.js +60 -57
  25. package/dist/part.d.ts +15 -0
  26. package/dist/part.d.ts.map +1 -0
  27. package/dist/part.js +85 -0
  28. package/dist/read.d.ts +93 -35
  29. package/dist/read.d.ts.map +1 -1
  30. package/dist/read.js +415 -245
  31. package/dist/refusal.d.ts +5 -7
  32. package/dist/refusal.d.ts.map +1 -1
  33. package/dist/refusal.js +47 -68
  34. package/dist/room-types.d.ts +6 -0
  35. package/dist/room-types.d.ts.map +1 -0
  36. package/dist/room-types.js +66 -0
  37. package/dist/site.d.ts +1 -1
  38. package/dist/site.d.ts.map +1 -1
  39. package/dist/site.js +219 -161
  40. package/dist/stream.d.ts +18 -6
  41. package/dist/stream.d.ts.map +1 -1
  42. package/dist/stream.js +556 -214
  43. package/dist/transport.d.ts +131 -38
  44. package/dist/transport.d.ts.map +1 -1
  45. package/dist/transport.js +4 -3
  46. package/dist/upload.d.ts +12 -0
  47. package/dist/upload.d.ts.map +1 -0
  48. package/dist/upload.js +52 -0
  49. package/dist/version.d.ts +3 -0
  50. package/dist/version.d.ts.map +1 -1
  51. package/dist/version.js +32 -18
  52. package/dist/write.d.ts +18 -8
  53. package/dist/write.d.ts.map +1 -1
  54. package/dist/write.js +259 -228
  55. package/package.json +4 -13
  56. package/dist/actions.js.map +0 -1
  57. package/dist/adapter.js.map +0 -1
  58. package/dist/digest.js.map +0 -1
  59. package/dist/discovery.js.map +0 -1
  60. package/dist/index.js.map +0 -1
  61. package/dist/map.js.map +0 -1
  62. package/dist/model.js.map +0 -1
  63. package/dist/read.js.map +0 -1
  64. package/dist/refusal.js.map +0 -1
  65. package/dist/site.js.map +0 -1
  66. package/dist/stream.js.map +0 -1
  67. package/dist/transport.js.map +0 -1
  68. package/dist/version.js.map +0 -1
  69. package/dist/write.js.map +0 -1
package/dist/gather.js ADDED
@@ -0,0 +1,35 @@
1
+ export function gatheredEach(send) {
2
+ let held = [];
3
+ function flush() {
4
+ const taken = held;
5
+ held = [];
6
+ send(taken.map((entry) => entry.ask), (ask, result) => {
7
+ taken[ask]?.resolve(result);
8
+ }).catch((reason) => {
9
+ for (const entry of taken)
10
+ entry.reject(reason);
11
+ });
12
+ }
13
+ return (ask) => new Promise((resolve, reject) => {
14
+ if (held.length === 0) {
15
+ // Asks made in one task wait a single event-loop turn so they leave as one batch.
16
+ setTimeout(flush, 0);
17
+ }
18
+ held.push({ ask, resolve, reject });
19
+ });
20
+ }
21
+ export function gathered(send) {
22
+ return gatheredEach(async (asks, answer) => {
23
+ (await send(asks)).forEach((result, ask) => {
24
+ answer(ask, result);
25
+ });
26
+ });
27
+ }
28
+ export function selections(items, limit) {
29
+ const size = Math.max(1, limit);
30
+ const parts = [];
31
+ for (let start = 0; start < items.length; start += size) {
32
+ parts.push(items.slice(start, start + size));
33
+ }
34
+ return parts;
35
+ }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
2
- export { nativePath, roomLocalPath } from './map.js';
3
- export type { HouseByteAct, HouseByteTransfer, HouseDoorAnswer, HouseStream, HouseStreamAuthority, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
2
+ export { finishedUpload, houseUpload, type HouseUpload } from './upload.js';
3
+ export { HOUSE_APP_ACTS, HOUSE_APP_BATCHES, HOUSE_SITE_ACTS } from './actions.js';
4
+ export { HOUSE_ROOM_TYPES, INBOX_CHANNEL_KINDS, INBOX_CHAT_TYPE, INBOX_MESSAGE_TYPE, type InboxChannelKind, } from './room-types.js';
5
+ export type { HouseByteAct, HouseByteTransfer, HouseBytesAnswer, HouseClosing, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -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,cAAc,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,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,4 @@
1
1
  export { createAgentsHouseAdapter } from './adapter.js';
2
- export { nativePath, roomLocalPath } from './map.js';
3
-
4
- //# sourceMappingURL=index.js.map
2
+ export { finishedUpload, houseUpload } from './upload.js';
3
+ export { HOUSE_APP_ACTS, HOUSE_APP_BATCHES, HOUSE_SITE_ACTS } from './actions.js';
4
+ export { HOUSE_ROOM_TYPES, INBOX_CHANNEL_KINDS, INBOX_CHAT_TYPE, INBOX_MESSAGE_TYPE, } from './room-types.js';
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 partModels(scope: HouseScope, tracked: TrackedAuthority, seen: ReadonlySet<string>, final: boolean): 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;AAoClE,wBAAgB,UAAU,CACxB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EACzB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAKjC;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAcjC;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,CAWjC"}
package/dist/model.js CHANGED
@@ -1,64 +1,67 @@
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'
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, revision: 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 {
10
+ kind: 'model',
11
+ snapshot: { identity, version, schema: read.schema, revision: read.revision },
12
12
  };
13
- return MODEL_ABSENT;
14
- }
15
- export function modelKey(locator, attached) {
16
- return `${locator} ${attached}`;
17
13
  }
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
14
+ async function modelsOf(tracked, read) {
15
+ const models = {};
16
+ const collection = read(tracked.schema);
17
+ if (collection !== undefined) {
18
+ models.collection = await heldModel(collection, schemaPath(tracked.handle, tracked.schema));
19
+ }
20
+ if (tracked.houseModel !== null) {
21
+ const root = tracked.houseModel.root;
22
+ const selection = read(root);
23
+ if (selection !== undefined) {
24
+ models.selection = await heldModel(selection, schemaPath(tracked.handle, root));
36
25
  }
37
- };
26
+ }
27
+ return models.collection === undefined && models.selection === undefined ? undefined : models;
38
28
  }
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
- }
29
+ export function partModels(scope, tracked, seen, final) {
30
+ return modelsOf(tracked, (schema) => {
31
+ if (scope.files.some((file) => file.path === schema))
32
+ return schemaOf(scope, schema);
33
+ return final && !seen.has(schema) ? ABSENT_SCHEMA : undefined;
34
+ });
35
+ }
36
+ export function viewModels(view, tracked) {
37
+ return modelsOf(tracked, (schema) => {
38
+ const change = view.changes.find((candidate) => candidate.path === schema);
39
+ if (change === undefined)
40
+ return undefined;
41
+ if ('removed' in change)
42
+ return ABSENT_SCHEMA;
43
+ if ('content' in change) {
44
+ return {
45
+ schema: change.content,
46
+ version: change.version,
47
+ revision: change.revision ?? null,
48
+ };
60
49
  }
61
- };
50
+ return null;
51
+ });
52
+ }
53
+ export function streamedModels(schemas, tracked, mode) {
54
+ return modelsOf(tracked, (schema) => {
55
+ const entry = schemas.get(schema);
56
+ if (entry === undefined)
57
+ return undefined;
58
+ if (entry.kind === 'removed')
59
+ return ABSENT_SCHEMA;
60
+ if (entry.text === undefined)
61
+ return null;
62
+ const version = mode === 'site' ? entry.sha256 : entry.revision;
63
+ return version === undefined
64
+ ? null
65
+ : { schema: entry.text, version, revision: mode === 'site' ? null : version };
66
+ });
62
67
  }
63
-
64
- //# sourceMappingURL=model.js.map
package/dist/part.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import type { ScopedRefusal } from '@agentshouse/mdruntime';
2
+ export declare const PART_ATTEMPTS = 3;
3
+ export declare const PART_UNVERIFIED = "part_unverified";
4
+ export type HousePart = {
5
+ part: string;
6
+ bytes: number;
7
+ sha256: string;
8
+ };
9
+ export declare function parsePart(value: unknown): HousePart | null;
10
+ export declare function partArrival(listed: HousePart, arriving: ((bytes: number) => void) | undefined): ((answered: number) => void) | undefined;
11
+ export declare function partFrame(body: unknown): Uint8Array<ArrayBuffer> | null;
12
+ export declare function checkedPayload(frame: Uint8Array<ArrayBuffer>, listed: HousePart): Promise<Uint8Array<ArrayBuffer> | null>;
13
+ export declare function gunzipped(payload: Uint8Array<ArrayBuffer>): Promise<string | null>;
14
+ export declare function unverifiedPart(locator: string): ScopedRefusal;
15
+ //# sourceMappingURL=part.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"part.d.ts","sourceRoot":"","sources":["../src/part.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAU5D,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAEjD,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAO1D;AAoBD,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,GAC9C,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAG1C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAIvE;AAED,wBAAsB,cAAc,CAClC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,EAC9B,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAazC;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAOxF;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAS7D"}
package/dist/part.js ADDED
@@ -0,0 +1,85 @@
1
+ const PART_MAGIC = 0x48505431;
2
+ const PART_HEAD_BYTES = 8;
3
+ const PART_DIGEST_BYTES = 32;
4
+ const PART_SHA256 = /^[0-9a-f]{64}$/u;
5
+ export const PART_ATTEMPTS = 3;
6
+ export const PART_UNVERIFIED = 'part_unverified';
7
+ export function parsePart(value) {
8
+ if (typeof value !== 'object' || value === null)
9
+ return null;
10
+ const { part, bytes, sha256 } = value;
11
+ if (typeof part !== 'string' || part.length === 0)
12
+ return null;
13
+ if (typeof bytes !== 'number' || !Number.isSafeInteger(bytes) || bytes <= 0)
14
+ return null;
15
+ if (typeof sha256 !== 'string' || !PART_SHA256.test(sha256))
16
+ return null;
17
+ return { part, bytes, sha256 };
18
+ }
19
+ function decoded(text) {
20
+ let binary;
21
+ try {
22
+ binary = atob(text);
23
+ }
24
+ catch {
25
+ return null;
26
+ }
27
+ const bytes = new Uint8Array(binary.length);
28
+ for (let at = 0; at < binary.length; at += 1)
29
+ bytes[at] = binary.charCodeAt(at);
30
+ return bytes;
31
+ }
32
+ function hex(bytes) {
33
+ let text = '';
34
+ for (const byte of bytes)
35
+ text += byte.toString(16).padStart(2, '0');
36
+ return text;
37
+ }
38
+ export function partArrival(listed, arriving) {
39
+ if (arriving === undefined)
40
+ return undefined;
41
+ return (answered) => arriving(Math.min(listed.bytes, Math.floor((answered * 3) / 4)));
42
+ }
43
+ export function partFrame(body) {
44
+ if (typeof body !== 'object' || body === null)
45
+ return null;
46
+ const { part } = body;
47
+ return typeof part === 'string' ? decoded(part) : null;
48
+ }
49
+ export async function checkedPayload(frame, listed) {
50
+ if (frame.length !== listed.bytes)
51
+ return null;
52
+ if (frame.length < PART_HEAD_BYTES + PART_DIGEST_BYTES)
53
+ return null;
54
+ const view = new DataView(frame.buffer, frame.byteOffset, frame.byteLength);
55
+ if (view.getUint32(0) !== PART_MAGIC)
56
+ return null;
57
+ const length = view.getUint32(4);
58
+ if (PART_HEAD_BYTES + length + PART_DIGEST_BYTES !== frame.length)
59
+ return null;
60
+ const payload = frame.subarray(PART_HEAD_BYTES, PART_HEAD_BYTES + length);
61
+ const digest = hex(new Uint8Array(await crypto.subtle.digest('SHA-256', payload)));
62
+ if (digest !== listed.sha256 || hex(frame.subarray(PART_HEAD_BYTES + length)) !== digest) {
63
+ return null;
64
+ }
65
+ return payload;
66
+ }
67
+ export async function gunzipped(payload) {
68
+ try {
69
+ const stream = new Blob([payload]).stream().pipeThrough(new DecompressionStream('gzip'));
70
+ return await new Response(stream).text();
71
+ }
72
+ catch {
73
+ return null;
74
+ }
75
+ }
76
+ export function unverifiedPart(locator) {
77
+ return {
78
+ kind: 'scoped-refusal',
79
+ locator,
80
+ scope: 'undisclosed',
81
+ code: PART_UNVERIFIED,
82
+ fields: {},
83
+ retryable: true,
84
+ };
85
+ }
package/dist/read.d.ts CHANGED
@@ -1,31 +1,69 @@
1
- import type { BootstrapPage, BootstrapResult, RefreshResult } from '@agentshouse/mdruntime';
2
- import { type TrackedAuthority } from './discovery.js';
1
+ import { type AdapterFailure, type BinaryFile, type BootstrapInventory, type BootstrapPage, type RefreshResult, type TransportUncertainty } from '@agentshouse/mdruntime';
2
+ import type { TrackedAuthority } from './discovery.js';
3
+ import { type HousePart } from './part.js';
3
4
  import type { HouseMode } from './transport.js';
4
5
  import { type LogPosition } from './version.js';
6
+ export type HeadChange = BootstrapPage['changes'][string];
7
+ export type Answered = {
8
+ readonly documents: Map<string, string>;
9
+ readonly revisions: Map<string, string>;
10
+ readonly fileIds: Map<string, string>;
11
+ readonly changes: Map<string, HeadChange>;
12
+ readonly binaryFiles: Map<string, BinaryFile>;
13
+ readonly removals: Set<string>;
14
+ readonly folders: Set<string>;
15
+ readonly folderRemovals: Set<string>;
16
+ };
17
+ export declare function answering(): Answered;
18
+ export declare function revised(answer: Answered, path: string, revision: string): void;
19
+ export declare function forgotten(answer: Answered, path: string): void;
20
+ export declare function folded(answer: Answered, path: string, removed: boolean): void;
21
+ export declare function answered(answer: Answered): Generator<number, {
22
+ documents: Readonly<Record<string, string>>;
23
+ revisions: Readonly<Record<string, string>>;
24
+ fileIds?: Readonly<Record<string, string>>;
25
+ changes: Readonly<Record<string, HeadChange>>;
26
+ binaryFiles: Readonly<Record<string, BinaryFile>>;
27
+ removals: readonly string[];
28
+ folders?: readonly string[];
29
+ folderRemovals?: readonly string[];
30
+ }, void>;
5
31
  export type HouseManifestFile = {
6
32
  path: string;
7
33
  revision: string | undefined;
8
34
  version: string;
35
+ sha256?: string;
36
+ head?: HeadChange;
37
+ binary?: BinaryFile;
9
38
  };
10
39
  export type HouseContent = {
11
40
  path: string;
12
41
  content: string;
13
42
  };
14
43
  export type HouseScope = LogPosition & {
15
- scope: 'room' | 'private';
16
44
  anchor: string;
17
- roomHandle: string | undefined;
18
45
  files: readonly HouseManifestFile[];
19
46
  contents: readonly HouseContent[];
47
+ folders?: readonly string[];
48
+ };
49
+ export type HouseRoomParts = LogPosition & {
50
+ anchor: string;
51
+ parts: readonly HousePart[];
20
52
  };
21
- export type HouseEnvelope = {
22
- scopes: readonly HouseScope[];
53
+ export type HouseParted = {
54
+ rooms: readonly HouseRoomParts[];
55
+ next?: string;
23
56
  };
24
57
  export type HouseGrant = {
25
- method: 'GET' | 'POST';
26
58
  operation: string;
27
59
  url: string;
28
60
  };
61
+ export type HouseFileAddress = {
62
+ url: string;
63
+ name: string;
64
+ sha256: string;
65
+ mediaType: string;
66
+ };
29
67
  export type HouseChange = {
30
68
  path: string;
31
69
  removed: true;
@@ -34,40 +72,60 @@ export type HouseChange = {
34
72
  content: string;
35
73
  revision: string | undefined;
36
74
  version: string;
75
+ head?: HeadChange;
37
76
  } | {
38
77
  path: string;
39
- reference: {
40
- revision: string;
41
- };
78
+ binary: BinaryFile;
79
+ revision: string | undefined;
80
+ version: string;
81
+ head?: HeadChange;
82
+ };
83
+ export type HousePage = {
84
+ after: string;
85
+ through: string;
86
+ read: number;
87
+ };
88
+ export type HouseFolder = {
89
+ path: string;
90
+ removed: boolean;
91
+ };
92
+ export type HouseView = LogPosition & {
93
+ authority: string;
94
+ changes: readonly HouseChange[];
95
+ folders?: readonly HouseFolder[];
96
+ next?: HousePage;
97
+ };
98
+ type PageFailure = AdapterFailure | {
99
+ kind: 'beyond-horizon';
42
100
  };
43
101
  export type HouseEnumeration = {
44
- authorities: readonly (LogPosition & {
45
- authority: string;
46
- changes: readonly HouseChange[];
47
- })[];
102
+ authorities: readonly HouseView[];
48
103
  };
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[];
52
- export declare function contentPrefixes(tracked: TrackedAuthority): readonly string[];
53
- export declare function modelPrefix(tracked: TrackedAuthority, modelRoot: string): string;
104
+ export declare function authorityRoot(handle: string): string;
105
+ export declare function schemaPath(handle: string, schema: string): string;
54
106
  export declare function parseGrant(body: unknown): HouseGrant | null;
55
- export declare function parseEnvelope(body: unknown): HouseEnvelope | null;
56
- export declare function parseSiteBootstrap(body: unknown): HouseScope | null;
107
+ export declare function parseFileAddress(body: unknown): HouseFileAddress | null;
108
+ export declare function headChange(held: {
109
+ readonly author?: unknown;
110
+ readonly created_at?: unknown;
111
+ }): HeadChange | undefined | null;
112
+ export declare function binaryFileOf(held: Readonly<Record<string, unknown>>): BinaryFile | undefined | null;
113
+ export declare function parseParted(body: unknown): HouseParted | null;
114
+ export declare function parseSiteParted(body: unknown): HouseRoomParts | null;
115
+ export declare function partInventory(room: HouseRoomParts): BootstrapInventory;
116
+ export declare function manifested(room: HouseRoomParts, inventory: BootstrapInventory, pageToken: string): BootstrapPage;
117
+ export declare function emptyScope(room: HouseRoomParts): HouseScope;
118
+ export declare function housePart(room: HouseRoomParts, frame: Uint8Array<ArrayBuffer>, listed: HousePart, mode: HouseMode): Promise<HouseScope | TransportUncertainty | null>;
57
119
  export declare function parseEnumeration(body: unknown, mode: HouseMode): HouseEnumeration | null;
58
- export declare function advancedScope(scope: HouseScope, view: HouseEnumeration['authorities'][number]): HouseScope;
59
- 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[];
120
+ export declare function wholeView(first: HouseView, more: (page: HousePage) => Promise<HouseView | PageFailure>): Promise<HouseView | PageFailure>;
121
+ export declare function bootstrapping(scope: HouseScope): Generator<number, BootstrapPage, void>;
122
+ export type HouseSchema = {
123
+ schema: string | null;
124
+ version: string | null;
125
+ revision: string | null;
67
126
  };
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;
127
+ export declare function schemaOf(scope: HouseScope, schema: string): HouseSchema | null;
128
+ export declare function viewOf(enumeration: HouseEnumeration, tracked: TrackedAuthority): HouseView | undefined;
129
+ export declare function refreshFrom(view: HouseView, fromRoomVersion: string): Promise<RefreshResult>;
130
+ export {};
73
131
  //# 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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