@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,20 +1,19 @@
1
- import type { Capability, DiscoveredRoom, Discovery, ProviderLimit, Retention, TypedSelection } from '@agentshouse/mdruntime';
1
+ import type { Capability, DiscoveredRoom, Discovery, ProviderLimit, Retention } from '@agentshouse/mdruntime';
2
2
  import { type LogPosition } from './version.js';
3
- export declare const ROOM_CONTRACT_VERSION = 1;
4
- export declare const MD_MODEL_IDENTITY = "@agentshouse/mdmodel";
5
- export declare const ROOM_VERSION_NOTIFICATIONS = "room-version-notifications";
6
3
  export declare const PROVIDER_ACTIONS = "provider-actions";
7
- export declare const MOVE_REFERENCE_REWRITES = "move-reference-rewrites";
8
4
  export declare const DISCOVER_PREFIXES: readonly string[];
9
- export declare const PROVIDER_SELECTION_ROOTS: readonly string[];
10
- export declare const PROVIDER_SELECTION_MODEL_ROOT = "house/settings/model";
5
+ export declare const PRIVATE_HANDLE = "private";
11
6
  export type HouseBounds = {
12
7
  max_authored_file_bytes: number;
13
8
  max_batch_operations: number;
9
+ max_batch_documents: number;
14
10
  max_path_length: number;
15
11
  max_path_depth: number;
16
12
  max_mount_files: number;
17
13
  max_mount_bytes: number;
14
+ max_inline_body_bytes: number;
15
+ max_upload_bytes: number;
16
+ max_prefixes: number;
18
17
  change_retention_seconds: number;
19
18
  operation_retention_seconds: number;
20
19
  };
@@ -24,60 +23,51 @@ export type HouseOperations = {
24
23
  write: readonly string[];
25
24
  delete: readonly string[];
26
25
  };
26
+ export type HouseModel = {
27
+ root: string;
28
+ paths: readonly string[];
29
+ };
27
30
  export type HouseAuthority = LogPosition & {
28
- kind: 'room' | 'private';
29
31
  roomRef: string;
30
- roomHandle: string | null;
32
+ roomHandle: string;
31
33
  name: string;
32
- collectionRoot: string;
33
- modelRoot: string;
34
+ schema: string;
35
+ houseModel: HouseModel | null;
34
36
  managedReplication: 'admitted' | 'unavailable';
35
37
  protectedPaths: readonly string[];
36
38
  operations: HouseOperations;
37
39
  };
38
40
  export type HouseDiscoveryDocument = {
39
41
  bounds: HouseBounds;
40
- mdModelVersion: string;
41
42
  authorities: readonly HouseAuthority[];
43
+ actions: readonly string[];
42
44
  };
43
45
  export type TrackedAuthority = LogPosition & {
44
46
  locator: string;
45
47
  authority: string;
46
- handle: string | undefined;
47
- collectionRoot: string;
48
- modelRoot: string;
49
- modelRoots: readonly string[];
50
- };
51
- export type HouseSiteSlot = {
52
- slot: string;
53
- roomRef: string | null;
48
+ handle: string;
49
+ schema: string;
50
+ houseModel: HouseModel | null;
51
+ schemas: readonly string[];
54
52
  };
55
53
  export type HouseSiteAuthority = LogPosition & {
56
54
  roomRef: string;
57
55
  roomHandle: string;
58
- collectionRoot: string;
59
- modelRoot: string;
56
+ schema: string;
60
57
  };
61
58
  export type HouseSiteDiscovery = {
62
59
  bounds: HouseBounds;
63
- mdModelVersion: string;
64
- slots: readonly HouseSiteSlot[];
65
60
  authorities: readonly HouseSiteAuthority[];
66
61
  };
67
- export type SiteTracked = TrackedAuthority & {
68
- slot: string;
69
- };
70
62
  export declare function parseDiscovery(body: unknown): HouseDiscoveryDocument | null;
71
63
  export declare function parseSiteDiscovery(body: unknown): HouseSiteDiscovery | null;
72
- export declare function siteLocator(slot: string, roomRef: string): string;
73
- export declare function siteTracked(document: HouseSiteDiscovery): SiteTracked[];
64
+ export declare function siteTracked(document: HouseSiteDiscovery): TrackedAuthority[];
74
65
  export declare function locatorOf(authority: HouseAuthority): string;
75
66
  export declare function trackedFrom(document: HouseDiscoveryDocument): TrackedAuthority[];
76
67
  export declare function providerLimits(bounds: HouseBounds): readonly ProviderLimit[];
77
68
  export declare function declaredRetention(bounds: HouseBounds): Retention;
78
- export declare function capabilities(): readonly Capability[];
69
+ export declare function capabilities(actions: readonly string[]): readonly Capability[];
79
70
  export declare function siteCapabilities(): readonly Capability[];
80
- export declare function providerSelection(attachedModel: TypedSelection['attachedModel']): TypedSelection;
81
- export declare function discoveredRoom(authority: HouseAuthority, attachedModel: DiscoveredRoom['attachedModel'], typedSelection: TypedSelection | undefined): DiscoveredRoom;
82
- export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds' | 'mdModelVersion'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
71
+ export declare function discoveredRoom(authority: HouseAuthority): DiscoveredRoom;
72
+ export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
83
73
  //# sourceMappingURL=discovery.d.ts.map
@@ -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,EACT,cAAc,EACf,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,eAAO,MAAM,iBAAiB,yBAAyB,CAAC;AAExD,eAAO,MAAM,0BAA0B,+BAA+B,CAAC;AAEvE,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AAEjE,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAU,CAAC;AAE1D,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAAwB,CAAC;AAE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HORITY } from './transport.js';
1
+ import { declaredActions, HOUSE_CONVERSATION_AGENTS } from './actions.js';
2
+ import { PRIVATE_LOCATOR } from './transport.js';
3
3
  import { readPosition, roomVersion } from './version.js';
4
- export const ROOM_CONTRACT_VERSION = 1;
5
- export const MD_MODEL_IDENTITY = '@agentshouse/mdmodel';
6
- export const ROOM_VERSION_NOTIFICATIONS = 'room-version-notifications';
7
4
  export const PROVIDER_ACTIONS = 'provider-actions';
8
- export const MOVE_REFERENCE_REWRITES = 'move-reference-rewrites';
9
- export const DISCOVER_PREFIXES = [
10
- '/'
11
- ];
12
- export const PROVIDER_SELECTION_ROOTS = [
13
- 'agents',
14
- 'house'
15
- ];
16
- export const PROVIDER_SELECTION_MODEL_ROOT = 'house/settings/model';
5
+ export const DISCOVER_PREFIXES = ['/'];
6
+ export const PRIVATE_HANDLE = 'private';
17
7
  const BOUND_KEYS = [
18
8
  'max_authored_file_bytes',
19
9
  'max_batch_operations',
10
+ 'max_batch_documents',
20
11
  'max_path_length',
21
12
  'max_path_depth',
22
13
  'max_mount_files',
23
14
  'max_mount_bytes',
15
+ 'max_inline_body_bytes',
16
+ 'max_upload_bytes',
17
+ 'max_prefixes',
24
18
  'change_retention_seconds',
25
- 'operation_retention_seconds'
26
- ];
27
- const OPERATION_KEYS = [
28
- 'read',
29
- 'sync',
30
- 'write',
31
- 'delete'
19
+ 'operation_retention_seconds',
32
20
  ];
21
+ const OPERATION_KEYS = ['read', 'sync', 'write', 'delete'];
33
22
  function stringList(value) {
34
- if (!Array.isArray(value)) return null;
35
- return value.every((entry)=>typeof entry === 'string') ? value : null;
23
+ if (!Array.isArray(value))
24
+ return null;
25
+ return value.every((entry) => typeof entry === 'string') ? value : null;
36
26
  }
37
27
  function parseBounds(value) {
38
- if (typeof value !== 'object' || value === null) return null;
28
+ if (typeof value !== 'object' || value === null)
29
+ return null;
39
30
  const held = value;
40
31
  const bounds = {};
41
- for (const key of BOUND_KEYS){
32
+ for (const key of BOUND_KEYS) {
42
33
  const amount = held[key];
43
- if (typeof amount !== 'number' || !Number.isFinite(amount)) return null;
34
+ if (typeof amount !== 'number' || !Number.isFinite(amount))
35
+ return null;
44
36
  bounds[key] = amount;
45
37
  }
46
38
  return bounds;
47
39
  }
40
+ function parseHouseModel(value) {
41
+ if (value === undefined)
42
+ return null;
43
+ if (typeof value !== 'object' || value === null)
44
+ return undefined;
45
+ const held = value;
46
+ const paths = stringList(held.paths);
47
+ if (typeof held.root !== 'string' || held.root.length === 0 || paths === null)
48
+ return undefined;
49
+ return { root: held.root, paths };
50
+ }
48
51
  function parseOperations(value) {
49
- if (typeof value !== 'object' || value === null) return null;
52
+ if (typeof value !== 'object' || value === null)
53
+ return null;
50
54
  const held = value;
51
55
  const operations = {};
52
- for (const key of OPERATION_KEYS){
56
+ for (const key of OPERATION_KEYS) {
53
57
  const scopes = stringList(held[key]);
54
- if (scopes === null) return null;
58
+ if (scopes === null)
59
+ return null;
55
60
  operations[key] = scopes;
56
61
  }
57
62
  return operations;
58
63
  }
59
64
  function parseAuthority(value) {
60
- if (typeof value !== 'object' || value === null) return null;
65
+ if (typeof value !== 'object' || value === null)
66
+ return null;
61
67
  const held = value;
62
- if (held.kind !== 'room' && held.kind !== 'private') return null;
63
- if (typeof held.name !== 'string' || held.name.length === 0) return null;
64
- if (typeof held.collection_root !== 'string' || typeof held.model_root !== 'string') return null;
68
+ if (held.kind !== 'room')
69
+ return null;
70
+ if (typeof held.name !== 'string' || held.name.length === 0)
71
+ return null;
72
+ if (typeof held.model_root !== 'string')
73
+ return null;
65
74
  if (held.managed_replication !== 'admitted' && held.managed_replication !== 'unavailable') {
66
75
  return null;
67
76
  }
68
77
  const at = readPosition(held);
78
+ const houseModel = parseHouseModel(held.house_model);
69
79
  const protectedPaths = stringList(held.protected_paths);
70
80
  const operations = parseOperations(held.operations);
71
- if (at === null || protectedPaths === null || operations === null) return null;
72
- if (held.kind === 'private') {
73
- return {
74
- kind: 'private',
75
- roomRef: PRIVATE_AUTHORITY,
76
- roomHandle: null,
77
- name: held.name,
78
- collectionRoot: held.collection_root,
79
- modelRoot: held.model_root,
80
- managedReplication: held.managed_replication,
81
- protectedPaths,
82
- operations,
83
- ...at
84
- };
85
- }
86
- if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;
87
- if (typeof held.room_handle !== 'string' || held.room_handle.length === 0) return null;
81
+ if (at === null || houseModel === undefined || protectedPaths === null || operations === null)
82
+ return null;
83
+ if (typeof held.room_ref !== 'string' || held.room_ref.length === 0)
84
+ return null;
85
+ if (typeof held.room_handle !== 'string' || held.room_handle.length === 0)
86
+ return null;
88
87
  return {
89
- kind: 'room',
90
88
  roomRef: held.room_ref,
91
89
  roomHandle: held.room_handle,
92
90
  name: held.name,
93
- collectionRoot: held.collection_root,
94
- modelRoot: held.model_root,
91
+ schema: held.model_root,
92
+ houseModel,
95
93
  managedReplication: held.managed_replication,
96
94
  protectedPaths,
97
95
  operations,
98
- ...at
96
+ ...at,
99
97
  };
100
98
  }
101
99
  export function parseDiscovery(body) {
102
- if (typeof body !== 'object' || body === null) return null;
100
+ if (typeof body !== 'object' || body === null)
101
+ return null;
103
102
  const held = body;
104
103
  const bounds = parseBounds(held.bounds);
105
- if (bounds === null) return null;
106
- if (typeof held.md_model_version !== 'string' || held.md_model_version.length === 0) return null;
107
- if (!Array.isArray(held.authorities)) return null;
104
+ if (bounds === null)
105
+ return null;
106
+ const actions = stringList(held.actions);
107
+ if (actions === null ||
108
+ new Set(actions).size !== actions.length ||
109
+ actions.some((name) => name.length === 0))
110
+ return null;
111
+ if (!Array.isArray(held.authorities))
112
+ return null;
108
113
  const authorities = [];
109
- for (const entry of held.authorities){
114
+ for (const entry of held.authorities) {
110
115
  const authority = parseAuthority(entry);
111
- if (authority === null) return null;
116
+ if (authority === null)
117
+ return null;
112
118
  authorities.push(authority);
113
119
  }
114
- return {
115
- bounds,
116
- mdModelVersion: held.md_model_version,
117
- authorities
118
- };
119
- }
120
- function parseSiteSlot(value) {
121
- if (typeof value !== 'object' || value === null) return null;
122
- const held = value;
123
- if (typeof held.slot !== 'string' || held.slot.length === 0) return null;
124
- if (held.room_ref === null) return {
125
- slot: held.slot,
126
- roomRef: null
127
- };
128
- if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;
129
- return {
130
- slot: held.slot,
131
- roomRef: held.room_ref
132
- };
120
+ return { bounds, authorities, actions };
133
121
  }
134
122
  function parseSiteAuthority(value) {
135
- if (typeof value !== 'object' || value === null) return null;
123
+ if (typeof value !== 'object' || value === null)
124
+ return null;
136
125
  const held = value;
137
- if (held.kind !== 'room') return null;
138
- if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;
139
- if (typeof held.room_handle !== 'string' || held.room_handle.length === 0) return null;
140
- if (typeof held.collection_root !== 'string' || typeof held.model_root !== 'string') return null;
126
+ if (held.kind !== 'room')
127
+ return null;
128
+ if (typeof held.room_ref !== 'string' || held.room_ref.length === 0)
129
+ return null;
130
+ if (typeof held.room_handle !== 'string' || held.room_handle.length === 0)
131
+ return null;
132
+ if (typeof held.model_root !== 'string')
133
+ return null;
141
134
  const at = readPosition(held);
142
- if (at === null) return null;
135
+ if (at === null)
136
+ return null;
143
137
  return {
144
138
  roomRef: held.room_ref,
145
139
  roomHandle: held.room_handle,
146
- collectionRoot: held.collection_root,
147
- modelRoot: held.model_root,
148
- ...at
140
+ schema: held.model_root,
141
+ ...at,
149
142
  };
150
143
  }
151
144
  export function parseSiteDiscovery(body) {
152
- if (typeof body !== 'object' || body === null) return null;
145
+ if (typeof body !== 'object' || body === null)
146
+ return null;
153
147
  const held = body;
154
148
  const bounds = parseBounds(held.bounds);
155
- if (bounds === null) return null;
156
- if (typeof held.md_model_version !== 'string' || held.md_model_version.length === 0) return null;
157
- if (!Array.isArray(held.slots) || !Array.isArray(held.authorities)) return null;
158
- const slots = [];
159
- for (const entry of held.slots){
160
- const slot = parseSiteSlot(entry);
161
- if (slot === null) return null;
162
- slots.push(slot);
163
- }
149
+ if (bounds === null)
150
+ return null;
151
+ if (!Array.isArray(held.authorities))
152
+ return null;
164
153
  const authorities = [];
165
- for (const entry of held.authorities){
154
+ for (const entry of held.authorities) {
166
155
  const authority = parseSiteAuthority(entry);
167
- if (authority === null) return null;
156
+ if (authority === null)
157
+ return null;
168
158
  authorities.push(authority);
169
159
  }
170
- return {
171
- bounds,
172
- mdModelVersion: held.md_model_version,
173
- slots,
174
- authorities
175
- };
176
- }
177
- export function siteLocator(slot, roomRef) {
178
- return `${slot}:${roomRef}`;
160
+ return { bounds, authorities };
179
161
  }
180
162
  export function siteTracked(document) {
181
- const published = new Map(document.authorities.map((entry)=>[
182
- entry.roomRef,
183
- entry
184
- ]));
185
- return document.slots.flatMap(({ slot, roomRef })=>{
186
- const authority = roomRef === null ? undefined : published.get(roomRef);
187
- if (authority === undefined) return [];
188
- return [
189
- {
190
- slot,
191
- locator: siteLocator(slot, authority.roomRef),
192
- authority: authority.roomRef,
193
- handle: authority.roomHandle,
194
- collectionRoot: authority.collectionRoot,
195
- modelRoot: authority.modelRoot,
196
- modelRoots: [
197
- authority.modelRoot
198
- ],
199
- position: authority.position,
200
- logEpoch: authority.logEpoch
201
- }
202
- ];
203
- });
163
+ return document.authorities.map((authority) => ({
164
+ locator: authority.roomRef,
165
+ authority: authority.roomRef,
166
+ handle: authority.roomHandle,
167
+ schema: authority.schema,
168
+ houseModel: null,
169
+ schemas: [authority.schema],
170
+ position: authority.position,
171
+ logEpoch: authority.logEpoch,
172
+ }));
204
173
  }
205
174
  export function locatorOf(authority) {
206
- return authority.roomHandle ?? PRIVATE_AUTHORITY;
175
+ return authority.roomHandle === PRIVATE_HANDLE ? PRIVATE_LOCATOR : authority.roomRef;
176
+ }
177
+ function schemasOf(authority) {
178
+ return authority.houseModel === null
179
+ ? [authority.schema]
180
+ : [authority.schema, authority.houseModel.root];
207
181
  }
208
182
  export function trackedFrom(document) {
209
- return document.authorities.map((authority)=>({
210
- locator: locatorOf(authority),
211
- authority: authority.roomRef,
212
- handle: authority.roomHandle ?? undefined,
213
- collectionRoot: authority.collectionRoot,
214
- modelRoot: authority.modelRoot,
215
- modelRoots: authority.kind === 'private' ? [
216
- authority.modelRoot,
217
- PROVIDER_SELECTION_MODEL_ROOT
218
- ] : [
219
- authority.modelRoot
220
- ],
221
- position: authority.position,
222
- logEpoch: authority.logEpoch
223
- }));
183
+ return document.authorities.map((authority) => ({
184
+ locator: locatorOf(authority),
185
+ authority: authority.roomRef,
186
+ handle: authority.roomHandle,
187
+ schema: authority.schema,
188
+ houseModel: authority.houseModel,
189
+ schemas: schemasOf(authority),
190
+ position: authority.position,
191
+ logEpoch: authority.logEpoch,
192
+ }));
224
193
  }
225
194
  export function providerLimits(bounds) {
226
195
  return [
227
- {
228
- name: 'document-size',
229
- value: bounds.max_authored_file_bytes
230
- },
231
- {
232
- name: 'change-batch-operations',
233
- value: bounds.max_batch_operations
234
- },
235
- {
236
- name: 'path-length',
237
- value: bounds.max_path_length
238
- },
239
- {
240
- name: 'path-depth',
241
- value: bounds.max_path_depth
242
- },
243
- {
244
- name: 'write-rate'
245
- },
246
- {
247
- name: 'content-ceiling'
248
- }
196
+ { name: 'document-size', value: bounds.max_authored_file_bytes },
197
+ { name: 'change-batch-operations', value: bounds.max_batch_operations },
198
+ { name: 'change-documents', value: bounds.max_batch_documents },
199
+ { name: 'path-length', value: bounds.max_path_length },
200
+ { name: 'path-depth', value: bounds.max_path_depth },
201
+ { name: 'write-rate' },
202
+ { name: 'content-ceiling' },
249
203
  ];
250
204
  }
251
205
  export function declaredRetention(bounds) {
252
206
  return {
253
- history: {
254
- kind: 'no-declared-time-bound'
255
- },
207
+ history: { kind: 'no-declared-time-bound' },
256
208
  outcome: bounds.operation_retention_seconds,
257
- refreshHorizon: bounds.change_retention_seconds
209
+ refreshHorizon: bounds.change_retention_seconds,
258
210
  };
259
211
  }
260
- export function capabilities() {
212
+ export function capabilities(actions) {
261
213
  return [
262
- {
263
- name: ROOM_VERSION_NOTIFICATIONS
264
- },
265
214
  {
266
215
  name: PROVIDER_ACTIONS,
267
- actions: declaredActions(),
268
- conversationCards: HOUSE_CONVERSATION_CARDS
216
+ actions: declaredActions(actions),
217
+ conversationAgents: HOUSE_CONVERSATION_AGENTS,
269
218
  },
270
- {
271
- name: MOVE_REFERENCE_REWRITES
272
- }
273
219
  ];
274
220
  }
275
221
  export function siteCapabilities() {
276
222
  return [
277
- {
278
- name: ROOM_VERSION_NOTIFICATIONS
279
- }
223
+ { name: PROVIDER_ACTIONS, actions: [{ name: 'submit', inputShape: {}, resultKind: 'house' }] },
280
224
  ];
281
225
  }
282
- export function providerSelection(attachedModel) {
283
- return {
284
- roots: [
285
- ...PROVIDER_SELECTION_ROOTS
286
- ],
287
- attachedModel
288
- };
289
- }
290
- export function discoveredRoom(authority, attachedModel, typedSelection) {
226
+ export function discoveredRoom(authority) {
227
+ const locator = locatorOf(authority);
291
228
  return {
292
229
  name: authority.name,
293
- locator: locatorOf(authority),
294
- collectionRoot: authority.collectionRoot,
230
+ locator,
295
231
  roomVersion: roomVersion(authority),
296
232
  operations: {
297
- read: [
298
- ...authority.operations.read
299
- ],
300
- sync: [
301
- ...authority.operations.sync
302
- ],
303
- write: [
304
- ...authority.operations.write
305
- ],
306
- delete: [
307
- ...authority.operations.delete
308
- ]
309
- },
310
- replica: {
311
- selection: locatorOf(authority),
312
- admission: authority.managedReplication
233
+ read: [...authority.operations.read],
234
+ sync: [...authority.operations.sync],
235
+ write: [...authority.operations.write],
236
+ delete: [...authority.operations.delete],
313
237
  },
314
- attachedModel,
315
- ...typedSelection === undefined ? {} : {
316
- typedSelection
317
- },
318
- providerOwnedPaths: [
319
- ...authority.protectedPaths
320
- ]
238
+ replica: { selection: locator, admission: authority.managedReplication },
239
+ ...(authority.houseModel === null
240
+ ? {}
241
+ : { typedSelection: { roots: [...authority.houseModel.paths] } }),
242
+ providerOwnedPaths: [...authority.protectedPaths, ...schemasOf(authority)],
321
243
  };
322
244
  }
323
245
  export function mapDiscovery(document, rooms, declared) {
324
246
  return {
325
247
  kind: 'discovery',
326
- supportedVersions: [
327
- ROOM_CONTRACT_VERSION
328
- ],
329
- mdModel: {
330
- identity: MD_MODEL_IDENTITY,
331
- version: document.mdModelVersion
332
- },
333
248
  rooms,
334
249
  capabilities: declared,
335
250
  providerLimits: providerLimits(document.bounds),
336
- retention: declaredRetention(document.bounds)
251
+ retention: declaredRetention(document.bounds),
337
252
  };
338
253
  }
339
-
340
- //# sourceMappingURL=discovery.js.map
@@ -0,0 +1,3 @@
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[])[];
3
+ //# sourceMappingURL=gather.d.ts.map
@@ -0,0 +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"}
package/dist/gather.js ADDED
@@ -0,0 +1,40 @@
1
+ export function gathered(send) {
2
+ let held = [];
3
+ function flush() {
4
+ const taken = held;
5
+ held = [];
6
+ send(taken.map((entry) => entry.ask)).then((answers) => {
7
+ taken.forEach((entry, index) => {
8
+ entry.resolve(answers[index]);
9
+ });
10
+ }, (reason) => {
11
+ for (const entry of taken)
12
+ entry.reject(reason);
13
+ });
14
+ }
15
+ return (ask) => new Promise((resolve, reject) => {
16
+ if (held.length === 0) {
17
+ // Asks made in one task wait a single event-loop turn so they leave as one batch.
18
+ setTimeout(flush, 0);
19
+ }
20
+ held.push({ ask, resolve, reject });
21
+ });
22
+ }
23
+ export function selections(items, weight, limit) {
24
+ 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;
36
+ }
37
+ if (part.length > 0)
38
+ parts.push(part);
39
+ return parts;
40
+ }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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 { PRIVATE_LOCATOR } from './transport.js';
3
+ export type { HouseByteAct, HouseByteAnswer, HouseByteTransfer, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
4
4
  //# sourceMappingURL=index.d.ts.map