@agentshouse/mdruntime-adapter 0.1.0-cea44707d3919 → 0.1.0-ceda07a375a48

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 (66) hide show
  1. package/README.md +2 -2
  2. package/dist/actions.d.ts +163 -2
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +123 -214
  5. package/dist/adapter.d.ts +1 -0
  6. package/dist/adapter.d.ts.map +1 -1
  7. package/dist/adapter.js +333 -109
  8. package/dist/app-reference.d.ts +2 -0
  9. package/dist/app-reference.d.ts.map +1 -0
  10. package/dist/app-reference.js +2 -0
  11. package/dist/crockford.d.ts +4 -0
  12. package/dist/crockford.d.ts.map +1 -0
  13. package/dist/crockford.js +3 -0
  14. package/dist/discovery.d.ts +7 -10
  15. package/dist/discovery.d.ts.map +1 -1
  16. package/dist/discovery.js +44 -36
  17. package/dist/gather.d.ts +1 -1
  18. package/dist/gather.d.ts.map +1 -1
  19. package/dist/gather.js +15 -20
  20. package/dist/house-model.d.ts +2935 -0
  21. package/dist/house-model.d.ts.map +1 -0
  22. package/dist/house-model.js +1613 -0
  23. package/dist/index.d.ts +8 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +7 -0
  26. package/dist/model.d.ts +6 -2
  27. package/dist/model.d.ts.map +1 -1
  28. package/dist/model.js +17 -15
  29. package/dist/part.d.ts +14 -0
  30. package/dist/part.d.ts.map +1 -0
  31. package/dist/part.js +90 -0
  32. package/dist/read.d.ts +73 -20
  33. package/dist/read.d.ts.map +1 -1
  34. package/dist/read.js +349 -166
  35. package/dist/refusal.d.ts +2 -5
  36. package/dist/refusal.d.ts.map +1 -1
  37. package/dist/refusal.js +6 -9
  38. package/dist/room-stream.d.ts +19 -0
  39. package/dist/room-stream.d.ts.map +1 -0
  40. package/dist/room-stream.js +57 -0
  41. package/dist/room-types.d.ts +7 -0
  42. package/dist/room-types.d.ts.map +1 -0
  43. package/dist/room-types.js +126 -0
  44. package/dist/site.d.ts +1 -1
  45. package/dist/site.d.ts.map +1 -1
  46. package/dist/site.js +131 -63
  47. package/dist/stream.d.ts +5 -4
  48. package/dist/stream.d.ts.map +1 -1
  49. package/dist/stream.js +361 -44
  50. package/dist/transport.d.ts +75 -11
  51. package/dist/transport.d.ts.map +1 -1
  52. package/dist/transport.js +4 -0
  53. package/dist/upload.d.ts +12 -0
  54. package/dist/upload.d.ts.map +1 -0
  55. package/dist/upload.js +63 -0
  56. package/dist/version.d.ts +1 -0
  57. package/dist/version.d.ts.map +1 -1
  58. package/dist/version.js +1 -1
  59. package/dist/write.d.ts +18 -9
  60. package/dist/write.d.ts.map +1 -1
  61. package/dist/write.js +164 -41
  62. package/package.json +9 -6
  63. package/AGENTS.md +0 -253
  64. package/dist/links.d.ts +0 -20
  65. package/dist/links.d.ts.map +0 -1
  66. package/dist/links.js +0 -104
@@ -13,27 +13,25 @@ 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 HouseModel = {
26
- root: string;
27
- paths: readonly string[];
28
- };
25
+ export type HouseAccessLevel = 'search' | 'open' | 'keep';
29
26
  export type HouseAuthority = LogPosition & {
30
27
  roomRef: string;
31
28
  roomHandle: string;
32
29
  name: string;
33
30
  schema: string;
34
- houseModel: HouseModel | null;
31
+ typedSelection: readonly string[] | null;
35
32
  managedReplication: 'admitted' | 'unavailable';
36
33
  protectedPaths: readonly string[];
34
+ level: HouseAccessLevel;
37
35
  operations: HouseOperations;
38
36
  };
39
37
  export type HouseDiscoveryDocument = {
@@ -47,8 +45,7 @@ export type TrackedAuthority = LogPosition & {
47
45
  authority: string;
48
46
  handle: string;
49
47
  schema: string;
50
- houseModel: HouseModel | null;
51
- schemas: readonly string[];
48
+ typedSelection: readonly string[] | null;
52
49
  };
53
50
  export type HouseSiteAuthority = LogPosition & {
54
51
  roomRef: string;
@@ -65,7 +62,7 @@ export declare function siteTracked(document: HouseSiteDiscovery): TrackedAuthor
65
62
  export declare function trackedFrom(document: HouseDiscoveryDocument): TrackedAuthority[];
66
63
  export declare function providerLimits(bounds: HouseBounds): readonly ProviderLimit[];
67
64
  export declare function declaredRetention(bounds: HouseBounds): Retention;
68
- export declare function capabilities(document: HouseDiscoveryDocument): readonly Capability[];
65
+ export declare function capabilities(actions: HouseDiscoveryDocument['actions'], rooms: readonly Pick<TrackedAuthority, 'authority' | 'handle'>[]): readonly Capability[];
69
66
  export declare function siteCapabilities(): readonly Capability[];
70
67
  export declare function discoveredRoom(authority: HouseAuthority): DiscoveredRoom;
71
68
  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,MAAM,EACN,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,MAA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MhE;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC,EAC1C,KAAK,EAAE,SAAS,IAAI,CAAC,gBAAgB,EAAE,WAAW,GAAG,QAAQ,CAAC,EAAE,GAC/D,SAAS,UAAU,EAAE,CASvB;AAED,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,7 +1,8 @@
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 = ['/'];
5
+ const PRIVATE_HANDLE = 'private';
5
6
  const BOUND_KEYS = [
6
7
  'max_authored_file_bytes',
7
8
  'max_batch_operations',
@@ -13,10 +14,12 @@ const BOUND_KEYS = [
13
14
  'max_inline_body_bytes',
14
15
  'max_upload_bytes',
15
16
  'max_prefixes',
17
+ 'max_held_files',
16
18
  'change_retention_seconds',
17
19
  'operation_retention_seconds',
18
20
  ];
19
- const OPERATION_KEYS = ['read', 'sync', 'write', 'delete'];
21
+ const OPERATION_KEYS = ['write', 'delete'];
22
+ const ACCESS_LEVELS = ['search', 'open', 'keep'];
20
23
  function stringList(value) {
21
24
  if (!Array.isArray(value))
22
25
  return null;
@@ -33,18 +36,18 @@ function parseBounds(value) {
33
36
  return null;
34
37
  bounds[key] = amount;
35
38
  }
39
+ const moves = held.max_move_documents;
40
+ if (moves !== undefined) {
41
+ if (typeof moves !== 'number' || !Number.isFinite(moves))
42
+ return null;
43
+ bounds.max_move_documents = moves;
44
+ }
36
45
  return bounds;
37
46
  }
38
- function parseHouseModel(value) {
47
+ function parseTypedSelection(value) {
39
48
  if (value === undefined)
40
49
  return null;
41
- if (typeof value !== 'object' || value === null)
42
- return undefined;
43
- const held = value;
44
- const paths = stringList(held.paths);
45
- if (typeof held.root !== 'string' || held.root.length === 0 || paths === null)
46
- return undefined;
47
- return { root: held.root, paths };
50
+ return stringList(value) ?? undefined;
48
51
  }
49
52
  function parseMember(value) {
50
53
  if (typeof value !== 'object' || value === null)
@@ -81,10 +84,15 @@ function parseAuthority(value) {
81
84
  return null;
82
85
  }
83
86
  const at = readPosition(held);
84
- const houseModel = parseHouseModel(held.house_model);
87
+ const typedSelection = parseTypedSelection(held.typed_selection);
85
88
  const protectedPaths = stringList(held.protected_paths);
86
89
  const operations = parseOperations(held.operations);
87
- if (at === null || houseModel === undefined || protectedPaths === null || operations === null)
90
+ const level = ACCESS_LEVELS.find((one) => one === held.level);
91
+ if (at === null ||
92
+ typedSelection === undefined ||
93
+ protectedPaths === null ||
94
+ level === undefined ||
95
+ operations === null)
88
96
  return null;
89
97
  if (typeof held.room_ref !== 'string' || held.room_ref.length === 0)
90
98
  return null;
@@ -95,9 +103,10 @@ function parseAuthority(value) {
95
103
  roomHandle: held.room_handle,
96
104
  name: held.name,
97
105
  schema: held.model_root,
98
- houseModel,
106
+ typedSelection,
99
107
  managedReplication: held.managed_replication,
100
108
  protectedPaths,
109
+ level,
101
110
  operations,
102
111
  ...at,
103
112
  };
@@ -174,25 +183,18 @@ export function siteTracked(document) {
174
183
  authority: authority.roomRef,
175
184
  handle: authority.roomHandle,
176
185
  schema: authority.schema,
177
- houseModel: null,
178
- schemas: [authority.schema],
186
+ typedSelection: null,
179
187
  position: authority.position,
180
188
  logEpoch: authority.logEpoch,
181
189
  }));
182
190
  }
183
- function schemasOf(authority) {
184
- return authority.houseModel === null
185
- ? [authority.schema]
186
- : [authority.schema, authority.houseModel.root];
187
- }
188
191
  export function trackedFrom(document) {
189
192
  return document.authorities.map((authority) => ({
190
193
  locator: authority.roomRef,
191
194
  authority: authority.roomRef,
192
195
  handle: authority.roomHandle,
193
196
  schema: authority.schema,
194
- houseModel: authority.houseModel,
195
- schemas: schemasOf(authority),
197
+ typedSelection: authority.typedSelection,
196
198
  position: authority.position,
197
199
  logEpoch: authority.logEpoch,
198
200
  }));
@@ -204,8 +206,11 @@ export function providerLimits(bounds) {
204
206
  { name: 'change-documents', value: bounds.max_batch_documents },
205
207
  { name: 'path-length', value: bounds.max_path_length },
206
208
  { name: 'path-depth', value: bounds.max_path_depth },
209
+ ...(bounds.max_move_documents === undefined
210
+ ? []
211
+ : [{ name: 'move-documents', value: bounds.max_move_documents }]),
207
212
  { name: 'write-rate' },
208
- { name: 'content-ceiling' },
213
+ { name: 'storage-limit' },
209
214
  ];
210
215
  }
211
216
  export function declaredRetention(bounds) {
@@ -215,21 +220,22 @@ export function declaredRetention(bounds) {
215
220
  refreshHorizon: bounds.change_retention_seconds,
216
221
  };
217
222
  }
218
- export function capabilities(document) {
219
- const house = document.authorities.find((authority) => authority.houseModel !== null);
223
+ export function capabilities(actions, rooms) {
224
+ const own = rooms.find((room) => room.handle === PRIVATE_HANDLE);
220
225
  return [
221
226
  {
222
227
  name: PROVIDER_ACTIONS,
223
- actions: declaredActions(document.actions),
224
- ...(house === undefined
225
- ? {}
226
- : { conversationAgents: houseConversationAgents(house.roomRef) }),
228
+ actions: declaredActions(actions),
229
+ ...(own === undefined ? {} : { conversationAgents: houseConversationAgents(own.authority) }),
227
230
  },
228
231
  ];
229
232
  }
230
233
  export function siteCapabilities() {
231
234
  return [
232
- { name: PROVIDER_ACTIONS, actions: [{ name: 'submit', inputShape: {}, resultKind: 'house' }] },
235
+ {
236
+ name: PROVIDER_ACTIONS,
237
+ actions: [{ name: SITE_SUBMIT, inputShape: {}, resultKind: 'house' }],
238
+ },
233
239
  ];
234
240
  }
235
241
  export function discoveredRoom(authority) {
@@ -240,16 +246,18 @@ export function discoveredRoom(authority) {
240
246
  handle: authority.roomHandle,
241
247
  roomVersion: roomVersion(authority),
242
248
  operations: {
243
- read: [...authority.operations.read],
244
- sync: [...authority.operations.sync],
245
249
  write: [...authority.operations.write],
246
250
  delete: [...authority.operations.delete],
247
251
  },
248
- replica: { selection: locator, admission: authority.managedReplication },
249
- ...(authority.houseModel === null
252
+ replica: {
253
+ selection: locator,
254
+ admission: authority.managedReplication,
255
+ offline: authority.level === 'open' ? 'locked' : 'open',
256
+ },
257
+ ...(authority.typedSelection === null
250
258
  ? {}
251
- : { typedSelection: { roots: [...authority.houseModel.paths] } }),
252
- providerOwnedPaths: [...authority.protectedPaths, ...schemasOf(authority)],
259
+ : { typedSelection: { roots: [...authority.typedSelection] } }),
260
+ providerOwnedPaths: [...authority.protectedPaths, authority.schema],
253
261
  };
254
262
  }
255
263
  export function mapDiscovery(document, rooms, declared) {
package/dist/gather.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  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[])[];
2
+ export declare function selections<T>(items: readonly T[], limit: number): readonly (readonly T[])[];
3
3
  //# 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":"AAkCA,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
+ 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
  }