@agentshouse/mdruntime-adapter 0.1.0-cd028205a5103 → 0.1.0-cd23c45caa798

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 (53) hide show
  1. package/AGENTS.md +285 -225
  2. package/dist/actions.d.ts +68 -1
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +196 -193
  5. package/dist/adapter.d.ts +1 -0
  6. package/dist/adapter.d.ts.map +1 -1
  7. package/dist/adapter.js +384 -103
  8. package/dist/discovery.d.ts +7 -4
  9. package/dist/discovery.d.ts.map +1 -1
  10. package/dist/discovery.js +46 -13
  11. package/dist/gather.d.ts +2 -1
  12. package/dist/gather.d.ts.map +1 -1
  13. package/dist/gather.js +15 -20
  14. package/dist/handed.d.ts +15 -0
  15. package/dist/handed.d.ts.map +1 -0
  16. package/dist/handed.js +45 -0
  17. package/dist/index.d.ts +2 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1 -0
  20. package/dist/model.d.ts +1 -1
  21. package/dist/model.d.ts.map +1 -1
  22. package/dist/model.js +6 -2
  23. package/dist/part.d.ts +13 -0
  24. package/dist/part.d.ts.map +1 -0
  25. package/dist/part.js +80 -0
  26. package/dist/read.d.ts +53 -16
  27. package/dist/read.d.ts.map +1 -1
  28. package/dist/read.js +265 -147
  29. package/dist/referrer.d.ts +7 -0
  30. package/dist/referrer.d.ts.map +1 -0
  31. package/dist/referrer.js +33 -0
  32. package/dist/refusal.d.ts +2 -5
  33. package/dist/refusal.d.ts.map +1 -1
  34. package/dist/refusal.js +6 -9
  35. package/dist/site.d.ts +1 -1
  36. package/dist/site.d.ts.map +1 -1
  37. package/dist/site.js +175 -58
  38. package/dist/stream.d.ts +4 -4
  39. package/dist/stream.d.ts.map +1 -1
  40. package/dist/stream.js +340 -42
  41. package/dist/transport.d.ts +64 -10
  42. package/dist/transport.d.ts.map +1 -1
  43. package/dist/transport.js +3 -0
  44. package/dist/version.d.ts +1 -0
  45. package/dist/version.d.ts.map +1 -1
  46. package/dist/version.js +1 -1
  47. package/dist/write.d.ts +14 -9
  48. package/dist/write.d.ts.map +1 -1
  49. package/dist/write.js +156 -37
  50. package/package.json +3 -4
  51. package/dist/links.d.ts +0 -20
  52. package/dist/links.d.ts.map +0 -1
  53. package/dist/links.js +0 -104
@@ -1,4 +1,4 @@
1
- import type { Capability, DiscoveredRoom, Discovery, ProviderLimit, Retention } from '@agentshouse/mdruntime';
1
+ import type { Capability, DiscoveredRoom, Discovery, Member, ProviderLimit, Retention } from '@agentshouse/mdruntime';
2
2
  import { type LogPosition } from './version.js';
3
3
  export declare const PROVIDER_ACTIONS = "provider-actions";
4
4
  export declare const DISCOVER_PREFIXES: readonly string[];
@@ -13,15 +13,16 @@ export type HouseBounds = {
13
13
  max_inline_body_bytes: number;
14
14
  max_upload_bytes: number;
15
15
  max_prefixes: number;
16
+ max_held_files: number;
16
17
  change_retention_seconds: number;
17
18
  operation_retention_seconds: number;
19
+ max_move_documents?: number;
18
20
  };
19
21
  export type HouseOperations = {
20
- read: readonly string[];
21
- sync: readonly string[];
22
22
  write: readonly string[];
23
23
  delete: readonly string[];
24
24
  };
25
+ export type HouseReadLevel = 'mcp' | 'online' | 'local';
25
26
  export type HouseModel = {
26
27
  root: string;
27
28
  paths: readonly string[];
@@ -34,9 +35,11 @@ export type HouseAuthority = LogPosition & {
34
35
  houseModel: HouseModel | null;
35
36
  managedReplication: 'admitted' | 'unavailable';
36
37
  protectedPaths: readonly string[];
38
+ read: HouseReadLevel;
37
39
  operations: HouseOperations;
38
40
  };
39
41
  export type HouseDiscoveryDocument = {
42
+ member: Member;
40
43
  bounds: HouseBounds;
41
44
  authorities: readonly HouseAuthority[];
42
45
  actions: readonly string[];
@@ -64,7 +67,7 @@ export declare function siteTracked(document: HouseSiteDiscovery): TrackedAuthor
64
67
  export declare function trackedFrom(document: HouseDiscoveryDocument): TrackedAuthority[];
65
68
  export declare function providerLimits(bounds: HouseBounds): readonly ProviderLimit[];
66
69
  export declare function declaredRetention(bounds: HouseBounds): Retention;
67
- export declare function capabilities(document: HouseDiscoveryDocument): readonly Capability[];
70
+ export declare function capabilities(actions: HouseDiscoveryDocument['actions'], rooms: readonly Pick<TrackedAuthority, 'authority' | 'houseModel'>[]): readonly Capability[];
68
71
  export declare function siteCapabilities(): readonly Capability[];
69
72
  export declare function discoveredRoom(authority: HouseAuthority): DiscoveredRoom;
70
73
  export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,SAAS,EACV,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAU,CAAC;AAE1D,MAAM,MAAM,WAAW,GAAG;IACxB,uBAAuB,EAAE,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,wBAAwB,EAAE,MAAM,CAAC;IACjC,2BAA2B,EAAE,MAAM,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,IAAI,EAAE,SAAS,MAAM,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AED,wBAAgB,gBAAgB,IAAI,SAAS,UAAU,EAAE,CAOxD;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,cAAc,GAAG,cAAc,CAqBxE;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAC,EAChD,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,QAAQ,EAAE,SAAS,UAAU,EAAE,GAC9B,SAAS,CAQX"}
package/dist/discovery.js CHANGED
@@ -1,4 +1,4 @@
1
- import { declaredActions, houseConversationAgents } from './actions.js';
1
+ import { declaredActions, houseConversationAgents, SITE_SUBMIT } from './actions.js';
2
2
  import { readPosition, roomVersion } from './version.js';
3
3
  export const PROVIDER_ACTIONS = 'provider-actions';
4
4
  export const DISCOVER_PREFIXES = ['/'];
@@ -13,10 +13,12 @@ const BOUND_KEYS = [
13
13
  'max_inline_body_bytes',
14
14
  'max_upload_bytes',
15
15
  'max_prefixes',
16
+ 'max_held_files',
16
17
  'change_retention_seconds',
17
18
  'operation_retention_seconds',
18
19
  ];
19
- const OPERATION_KEYS = ['read', 'sync', 'write', 'delete'];
20
+ const OPERATION_KEYS = ['write', 'delete'];
21
+ const READ_LEVELS = ['mcp', 'online', 'local'];
20
22
  function stringList(value) {
21
23
  if (!Array.isArray(value))
22
24
  return null;
@@ -33,6 +35,12 @@ function parseBounds(value) {
33
35
  return null;
34
36
  bounds[key] = amount;
35
37
  }
38
+ const moves = held.max_move_documents;
39
+ if (moves !== undefined) {
40
+ if (typeof moves !== 'number' || !Number.isFinite(moves))
41
+ return null;
42
+ bounds.max_move_documents = moves;
43
+ }
36
44
  return bounds;
37
45
  }
38
46
  function parseHouseModel(value) {
@@ -46,6 +54,14 @@ function parseHouseModel(value) {
46
54
  return undefined;
47
55
  return { root: held.root, paths };
48
56
  }
57
+ function parseMember(value) {
58
+ if (typeof value !== 'object' || value === null)
59
+ return null;
60
+ const { user, name } = value;
61
+ if (typeof user !== 'string' || typeof name !== 'string')
62
+ return null;
63
+ return { kind: 'user', id: user, name };
64
+ }
49
65
  function parseOperations(value) {
50
66
  if (typeof value !== 'object' || value === null)
51
67
  return null;
@@ -76,7 +92,12 @@ function parseAuthority(value) {
76
92
  const houseModel = parseHouseModel(held.house_model);
77
93
  const protectedPaths = stringList(held.protected_paths);
78
94
  const operations = parseOperations(held.operations);
79
- if (at === null || houseModel === undefined || protectedPaths === null || operations === null)
95
+ const read = READ_LEVELS.find((level) => level === held.read);
96
+ if (at === null ||
97
+ houseModel === undefined ||
98
+ protectedPaths === null ||
99
+ read === undefined ||
100
+ operations === null)
80
101
  return null;
81
102
  if (typeof held.room_ref !== 'string' || held.room_ref.length === 0)
82
103
  return null;
@@ -90,6 +111,7 @@ function parseAuthority(value) {
90
111
  houseModel,
91
112
  managedReplication: held.managed_replication,
92
113
  protectedPaths,
114
+ read,
93
115
  operations,
94
116
  ...at,
95
117
  };
@@ -98,6 +120,9 @@ export function parseDiscovery(body) {
98
120
  if (typeof body !== 'object' || body === null)
99
121
  return null;
100
122
  const held = body;
123
+ const member = parseMember(held.member);
124
+ if (member === null)
125
+ return null;
101
126
  const bounds = parseBounds(held.bounds);
102
127
  if (bounds === null)
103
128
  return null;
@@ -115,7 +140,7 @@ export function parseDiscovery(body) {
115
140
  return null;
116
141
  authorities.push(authority);
117
142
  }
118
- return { bounds, authorities, actions };
143
+ return { member, bounds, authorities, actions };
119
144
  }
120
145
  function parseSiteAuthority(value) {
121
146
  if (typeof value !== 'object' || value === null)
@@ -193,8 +218,11 @@ export function providerLimits(bounds) {
193
218
  { name: 'change-documents', value: bounds.max_batch_documents },
194
219
  { name: 'path-length', value: bounds.max_path_length },
195
220
  { name: 'path-depth', value: bounds.max_path_depth },
221
+ ...(bounds.max_move_documents === undefined
222
+ ? []
223
+ : [{ name: 'move-documents', value: bounds.max_move_documents }]),
196
224
  { name: 'write-rate' },
197
- { name: 'content-ceiling' },
225
+ { name: 'storage-limit' },
198
226
  ];
199
227
  }
200
228
  export function declaredRetention(bounds) {
@@ -204,21 +232,24 @@ export function declaredRetention(bounds) {
204
232
  refreshHorizon: bounds.change_retention_seconds,
205
233
  };
206
234
  }
207
- export function capabilities(document) {
208
- const house = document.authorities.find((authority) => authority.houseModel !== null);
235
+ export function capabilities(actions, rooms) {
236
+ const house = rooms.find((room) => room.houseModel !== null);
209
237
  return [
210
238
  {
211
239
  name: PROVIDER_ACTIONS,
212
- actions: declaredActions(document.actions),
240
+ actions: declaredActions(actions),
213
241
  ...(house === undefined
214
242
  ? {}
215
- : { conversationAgents: houseConversationAgents(house.roomRef) }),
243
+ : { conversationAgents: houseConversationAgents(house.authority) }),
216
244
  },
217
245
  ];
218
246
  }
219
247
  export function siteCapabilities() {
220
248
  return [
221
- { name: PROVIDER_ACTIONS, actions: [{ name: 'submit', inputShape: {}, resultKind: 'house' }] },
249
+ {
250
+ name: PROVIDER_ACTIONS,
251
+ actions: [{ name: SITE_SUBMIT, inputShape: {}, resultKind: 'house' }],
252
+ },
222
253
  ];
223
254
  }
224
255
  export function discoveredRoom(authority) {
@@ -229,12 +260,14 @@ export function discoveredRoom(authority) {
229
260
  handle: authority.roomHandle,
230
261
  roomVersion: roomVersion(authority),
231
262
  operations: {
232
- read: [...authority.operations.read],
233
- sync: [...authority.operations.sync],
234
263
  write: [...authority.operations.write],
235
264
  delete: [...authority.operations.delete],
236
265
  },
237
- replica: { selection: locator, admission: authority.managedReplication },
266
+ replica: {
267
+ selection: locator,
268
+ admission: authority.managedReplication,
269
+ offline: authority.read === 'online' ? 'locked' : 'open',
270
+ },
238
271
  ...(authority.houseModel === null
239
272
  ? {}
240
273
  : { typedSelection: { roots: [...authority.houseModel.paths] } }),
package/dist/gather.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export declare function gatheredEach<A, R>(send: (asks: readonly A[], answer: (ask: number, result: R) => void) => Promise<void>): (ask: A) => Promise<R>;
1
2
  export declare function gathered<A, R>(send: (asks: readonly A[]) => Promise<readonly R[]>): (ask: A) => Promise<R>;
2
- export declare function selections<T>(items: readonly T[], weight: (item: T) => number, limit: number): readonly (readonly T[])[];
3
+ export declare function selections<T>(items: readonly T[], limit: number): readonly (readonly T[])[];
3
4
  //# sourceMappingURL=gather.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gather.d.ts","sourceRoot":"","sources":["../src/gather.ts"],"names":[],"mappings":"AAMA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAC3B,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,GAClD,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CA0BxB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAC1B,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,EAC3B,KAAK,EAAE,MAAM,GACZ,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAgB3B"}
1
+ {"version":3,"file":"gather.d.ts","sourceRoot":"","sources":["../src/gather.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAC/B,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,GACpF,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAwBxB;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAC3B,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,GAClD,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAMxB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAO3F"}
package/dist/gather.js CHANGED
@@ -1,13 +1,11 @@
1
- export function gathered(send) {
1
+ export function gatheredEach(send) {
2
2
  let held = [];
3
3
  function flush() {
4
4
  const taken = held;
5
5
  held = [];
6
- send(taken.map((entry) => entry.ask)).then((answers) => {
7
- taken.forEach((entry, index) => {
8
- entry.resolve(answers[index]);
9
- });
10
- }, (reason) => {
6
+ send(taken.map((entry) => entry.ask), (ask, result) => {
7
+ taken[ask]?.resolve(result);
8
+ }).catch((reason) => {
11
9
  for (const entry of taken)
12
10
  entry.reject(reason);
13
11
  });
@@ -20,21 +18,18 @@ export function gathered(send) {
20
18
  held.push({ ask, resolve, reject });
21
19
  });
22
20
  }
23
- export function selections(items, weight, limit) {
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);
24
30
  const parts = [];
25
- let part = [];
26
- let carried = 0;
27
- for (const item of items) {
28
- const weighed = weight(item);
29
- if (part.length > 0 && carried + weighed > limit) {
30
- parts.push(part);
31
- part = [];
32
- carried = 0;
33
- }
34
- part.push(item);
35
- carried += weighed;
31
+ for (let start = 0; start < items.length; start += size) {
32
+ parts.push(items.slice(start, start + size));
36
33
  }
37
- if (part.length > 0)
38
- parts.push(part);
39
34
  return parts;
40
35
  }
@@ -0,0 +1,15 @@
1
+ import { type HeldRoom, type MutationResult } from '@agentshouse/mdruntime';
2
+ import type { HouseScope, HouseView } from './read.js';
3
+ import type { StreamedAdvancement } from './stream.js';
4
+ export type HandedRoom = {
5
+ roomVersion: string;
6
+ revisions: Readonly<Record<string, string>>;
7
+ };
8
+ export declare function scopeHanded(scope: HouseScope): Generator<number, HandedRoom, void>;
9
+ export declare function heldHanded(held: HeldRoom): HandedRoom;
10
+ export declare function acceptedHanded(held: HandedRoom, accepted: Extract<MutationResult, {
11
+ kind: 'accepted';
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
+ //# sourceMappingURL=handed.d.ts.map
@@ -0,0 +1 @@
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 ADDED
@@ -0,0 +1,45 @@
1
+ import { entriesIn, patching } from '@agentshouse/mdruntime';
2
+ import { roomVersion } from './version.js';
3
+ function* revised(files) {
4
+ for (const { path, revision } of files)
5
+ if (revision !== undefined)
6
+ yield [path, revision];
7
+ }
8
+ export function* scopeHanded(scope) {
9
+ return { roomVersion: roomVersion(scope), revisions: yield* patching({}, revised(scope.files)) };
10
+ }
11
+ export function heldHanded(held) {
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) {
21
+ for (const change of view.changes) {
22
+ if (!('removed' in change) && change.revision !== undefined) {
23
+ yield [change.path, change.revision];
24
+ }
25
+ }
26
+ }
27
+ function* dropped(view) {
28
+ for (const change of view.changes) {
29
+ if ('removed' in change || change.revision === undefined)
30
+ yield change.path;
31
+ }
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
+ };
45
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
2
- export type { HouseByteAct, HouseByteAnswer, HouseByteTransfer, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
2
+ export { HOUSE_APP_ACTS, HOUSE_APP_BATCHES, HOUSE_SITE_ACTS } from './actions.js';
3
+ export type { HouseByteAct, HouseByteTransfer, HouseBytesAnswer, HouseClosing, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
3
4
  //# 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,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"}
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,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAClF,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 +1,2 @@
1
1
  export { createAgentsHouseAdapter } from './adapter.js';
2
+ export { HOUSE_APP_ACTS, HOUSE_APP_BATCHES, HOUSE_SITE_ACTS } from './actions.js';
package/dist/model.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { RoomModels } from '@agentshouse/mdruntime';
2
2
  import type { TrackedAuthority } from './discovery.js';
3
3
  import { type HouseScope, type HouseView } from './read.js';
4
4
  import type { HouseMode, HouseStreamEntry } from './transport.js';
5
- export declare function scopeModels(scope: HouseScope, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
5
+ export declare function partModels(scope: HouseScope, tracked: TrackedAuthority, seen: ReadonlySet<string>, final: boolean): Promise<RoomModels | undefined>;
6
6
  export declare function viewModels(view: HouseView, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
7
7
  export declare function streamedModels(schemas: ReadonlyMap<string, HouseStreamEntry>, tracked: TrackedAuthority, mode: HouseMode): Promise<RoomModels | undefined>;
8
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,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,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,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"}
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
@@ -26,8 +26,12 @@ async function modelsOf(tracked, read) {
26
26
  }
27
27
  return models.collection === undefined && models.selection === undefined ? undefined : models;
28
28
  }
29
- export function scopeModels(scope, tracked) {
30
- return modelsOf(tracked, (schema) => schemaOf(scope, schema));
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
+ });
31
35
  }
32
36
  export function viewModels(view, tracked) {
33
37
  return modelsOf(tracked, (schema) => {
package/dist/part.d.ts ADDED
@@ -0,0 +1,13 @@
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 checkedPayload(body: unknown, listed: HousePart): Promise<Uint8Array<ArrayBuffer> | null>;
11
+ export declare function gunzipped(payload: Uint8Array<ArrayBuffer>): Promise<string | null>;
12
+ export declare function unverifiedPart(locator: string): ScopedRefusal;
13
+ //# 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,wBAAsB,cAAc,CAClC,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAiBzC;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,80 @@
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 async function checkedPayload(body, listed) {
39
+ if (typeof body !== 'object' || body === null)
40
+ return null;
41
+ const { part } = body;
42
+ if (typeof part !== 'string')
43
+ return null;
44
+ const frame = decoded(part);
45
+ if (frame === null || frame.length !== listed.bytes)
46
+ return null;
47
+ if (frame.length < PART_HEAD_BYTES + PART_DIGEST_BYTES)
48
+ return null;
49
+ const view = new DataView(frame.buffer, frame.byteOffset, frame.byteLength);
50
+ if (view.getUint32(0) !== PART_MAGIC)
51
+ return null;
52
+ const length = view.getUint32(4);
53
+ if (PART_HEAD_BYTES + length + PART_DIGEST_BYTES !== frame.length)
54
+ return null;
55
+ const payload = frame.subarray(PART_HEAD_BYTES, PART_HEAD_BYTES + length);
56
+ const digest = hex(new Uint8Array(await crypto.subtle.digest('SHA-256', payload)));
57
+ if (digest !== listed.sha256 || hex(frame.subarray(PART_HEAD_BYTES + length)) !== digest) {
58
+ return null;
59
+ }
60
+ return payload;
61
+ }
62
+ export async function gunzipped(payload) {
63
+ try {
64
+ const stream = new Blob([payload]).stream().pipeThrough(new DecompressionStream('gzip'));
65
+ return await new Response(stream).text();
66
+ }
67
+ catch {
68
+ return null;
69
+ }
70
+ }
71
+ export function unverifiedPart(locator) {
72
+ return {
73
+ kind: 'scoped-refusal',
74
+ locator,
75
+ scope: 'undisclosed',
76
+ code: PART_UNVERIFIED,
77
+ fields: {},
78
+ retryable: true,
79
+ };
80
+ }
package/dist/read.d.ts CHANGED
@@ -1,13 +1,35 @@
1
- import type { BootstrapPage, RefreshResult, RoomAttachment } from '@agentshouse/mdruntime';
1
+ import { type AdapterFailure, type BinaryFile, type BootstrapPage, type RefreshResult, type TransportUncertainty } from '@agentshouse/mdruntime';
2
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';
5
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
+ };
15
+ export declare function answering(): Answered;
16
+ export declare function revised(answer: Answered, path: string, revision: string): void;
17
+ export declare function forgotten(answer: Answered, path: string): void;
18
+ export declare function answered(answer: Answered): Generator<number, {
19
+ documents: Readonly<Record<string, string>>;
20
+ revisions: Readonly<Record<string, string>>;
21
+ fileIds?: Readonly<Record<string, string>>;
22
+ changes: Readonly<Record<string, HeadChange>>;
23
+ binaryFiles: Readonly<Record<string, BinaryFile>>;
24
+ removals: readonly string[];
25
+ }, void>;
6
26
  export type HouseManifestFile = {
7
27
  path: string;
8
28
  revision: string | undefined;
9
29
  version: string;
30
+ sha256?: string;
10
31
  head?: HeadChange;
32
+ binary?: BinaryFile;
11
33
  };
12
34
  export type HouseContent = {
13
35
  path: string;
@@ -17,10 +39,14 @@ export type HouseScope = LogPosition & {
17
39
  anchor: string;
18
40
  files: readonly HouseManifestFile[];
19
41
  contents: readonly HouseContent[];
20
- attachments?: readonly RoomAttachment[];
21
42
  };
22
- export type HouseEnvelope = {
23
- scopes: readonly HouseScope[];
43
+ export type HouseRoomParts = LogPosition & {
44
+ anchor: string;
45
+ parts: readonly HousePart[];
46
+ };
47
+ export type HouseParted = {
48
+ rooms: readonly HouseRoomParts[];
49
+ next?: string;
24
50
  };
25
51
  export type HouseGrant = {
26
52
  method: 'GET';
@@ -41,33 +67,43 @@ export type HouseChange = {
41
67
  head?: HeadChange;
42
68
  } | {
43
69
  path: string;
44
- reference: {
45
- revision: string;
46
- };
70
+ binary: BinaryFile;
71
+ revision: string | undefined;
72
+ version: string;
73
+ head?: HeadChange;
74
+ };
75
+ export type HousePage = {
76
+ after: string;
77
+ through: string;
78
+ read: number;
47
79
  };
48
80
  export type HouseView = LogPosition & {
49
81
  authority: string;
50
82
  changes: readonly HouseChange[];
51
- attachments?: readonly RoomAttachment[];
83
+ next?: HousePage;
84
+ };
85
+ type PageFailure = AdapterFailure | {
86
+ kind: 'beyond-horizon';
52
87
  };
53
88
  export type HouseEnumeration = {
54
89
  authorities: readonly HouseView[];
55
90
  };
56
91
  export declare function authorityRoot(handle: string): string;
57
- export declare function contentPrefixes(tracked: TrackedAuthority): readonly string[];
58
92
  export declare function schemaPath(handle: string, schema: string): string;
59
93
  export declare function parseGrant(body: unknown): HouseGrant | null;
60
94
  export declare function headChange(held: {
61
95
  readonly author?: unknown;
62
96
  readonly created_at?: unknown;
63
97
  }): HeadChange | undefined | null;
64
- export declare function parseOriginals(value: unknown): readonly RoomAttachment[] | null;
65
- export declare function parseEnvelope(body: unknown): HouseEnvelope | null;
66
- export declare function parseSiteBootstrap(body: unknown): HouseScope | null;
98
+ export declare function binaryFileOf(held: Readonly<Record<string, unknown>>): BinaryFile | undefined | null;
99
+ export declare function parseParted(body: unknown): HouseParted | null;
100
+ export declare function parseSiteParted(body: unknown): HouseRoomParts | null;
101
+ export declare function emptyScope(room: HouseRoomParts): HouseScope;
102
+ export declare function housePart(room: HouseRoomParts, body: unknown, listed: HousePart, mode: HouseMode): Promise<HouseScope | TransportUncertainty | null>;
67
103
  export declare function parseEnumeration(body: unknown, mode: HouseMode): HouseEnumeration | null;
68
- export declare function advancedScope(scope: HouseScope, view: HouseView): HouseScope;
69
- export declare function matchesScope(scope: HouseScope, tracked: TrackedAuthority): boolean;
70
- export declare function bootstrapOf(scope: HouseScope): BootstrapPage;
104
+ export declare function wholeView(first: HouseView, more: (page: HousePage) => Promise<HouseView | PageFailure>): Promise<HouseView | PageFailure>;
105
+ export declare function advancedScope(scope: HouseScope, view: HouseView): Generator<number, HouseScope, void>;
106
+ export declare function bootstrapping(scope: HouseScope): Generator<number, BootstrapPage, void>;
71
107
  export type HouseSchema = {
72
108
  schema: string | null;
73
109
  version: string | null;
@@ -75,5 +111,6 @@ export type HouseSchema = {
75
111
  };
76
112
  export declare function schemaOf(scope: HouseScope, schema: string): HouseSchema | null;
77
113
  export declare function viewOf(enumeration: HouseEnumeration, tracked: TrackedAuthority): HouseView | undefined;
78
- export declare function refreshFrom(view: HouseView, fromRoomVersion: string): RefreshResult;
114
+ export declare function refreshFrom(view: HouseView, fromRoomVersion: string): Promise<RefreshResult>;
115
+ export {};
79
116
  //# 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,aAAa,EAEb,aAAa,EACb,cAAc,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS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