@agentshouse/mdruntime-adapter 0.1.0-alpha.5 → 0.1.0-alpha.6

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.
package/dist/discovery.js CHANGED
@@ -116,6 +116,89 @@ export function parseDiscovery(body) {
116
116
  authorities
117
117
  };
118
118
  }
119
+ function parseSiteSlot(value) {
120
+ if (typeof value !== 'object' || value === null) return null;
121
+ const held = value;
122
+ if (typeof held.slot !== 'string' || held.slot.length === 0) return null;
123
+ if (held.room_ref === null) return {
124
+ slot: held.slot,
125
+ roomRef: null
126
+ };
127
+ if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;
128
+ return {
129
+ slot: held.slot,
130
+ roomRef: held.room_ref
131
+ };
132
+ }
133
+ function parseSiteAuthority(value) {
134
+ if (typeof value !== 'object' || value === null) return null;
135
+ const held = value;
136
+ if (held.kind !== 'room') return null;
137
+ if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;
138
+ if (typeof held.room_handle !== 'string' || held.room_handle.length === 0) return null;
139
+ if (typeof held.collection_root !== 'string' || typeof held.model_root !== 'string') return null;
140
+ if (typeof held.position !== 'string' || held.position.length === 0) return null;
141
+ return {
142
+ roomRef: held.room_ref,
143
+ roomHandle: held.room_handle,
144
+ collectionRoot: held.collection_root,
145
+ modelRoot: held.model_root,
146
+ position: held.position
147
+ };
148
+ }
149
+ export function parseSiteDiscovery(body) {
150
+ if (typeof body !== 'object' || body === null) return null;
151
+ const held = body;
152
+ const bounds = parseBounds(held.bounds);
153
+ if (bounds === null) return null;
154
+ if (typeof held.md_model_version !== 'string' || held.md_model_version.length === 0) return null;
155
+ if (!Array.isArray(held.slots) || !Array.isArray(held.authorities)) return null;
156
+ const slots = [];
157
+ for (const entry of held.slots){
158
+ const slot = parseSiteSlot(entry);
159
+ if (slot === null) return null;
160
+ slots.push(slot);
161
+ }
162
+ const authorities = [];
163
+ for (const entry of held.authorities){
164
+ const authority = parseSiteAuthority(entry);
165
+ if (authority === null) return null;
166
+ authorities.push(authority);
167
+ }
168
+ return {
169
+ bounds,
170
+ mdModelVersion: held.md_model_version,
171
+ slots,
172
+ authorities
173
+ };
174
+ }
175
+ export function siteLocator(slot, roomRef) {
176
+ return `${slot}:${roomRef}`;
177
+ }
178
+ export function siteTracked(document) {
179
+ const published = new Map(document.authorities.map((entry)=>[
180
+ entry.roomRef,
181
+ entry
182
+ ]));
183
+ return document.slots.flatMap(({ slot, roomRef })=>{
184
+ const authority = roomRef === null ? undefined : published.get(roomRef);
185
+ if (authority === undefined) return [];
186
+ return [
187
+ {
188
+ slot,
189
+ locator: siteLocator(slot, authority.roomRef),
190
+ authority: authority.roomRef,
191
+ handle: authority.roomHandle,
192
+ collectionRoot: authority.collectionRoot,
193
+ modelRoot: authority.modelRoot,
194
+ modelRoots: [
195
+ authority.modelRoot
196
+ ],
197
+ roomVersion: authority.position
198
+ }
199
+ ];
200
+ });
201
+ }
119
202
  export function locatorOf(authority) {
120
203
  return authority.roomHandle ?? PRIVATE_AUTHORITY;
121
204
  }
@@ -185,6 +268,13 @@ export function capabilities() {
185
268
  }
186
269
  ];
187
270
  }
271
+ export function siteCapabilities() {
272
+ return [
273
+ {
274
+ name: ROOM_VERSION_NOTIFICATIONS
275
+ }
276
+ ];
277
+ }
188
278
  export function providerSelection(attachedModel) {
189
279
  return {
190
280
  roots: [
@@ -226,7 +316,7 @@ export function discoveredRoom(authority, attachedModel, typedSelection) {
226
316
  ]
227
317
  };
228
318
  }
229
- export function mapDiscovery(document, rooms) {
319
+ export function mapDiscovery(document, rooms, declared) {
230
320
  return {
231
321
  kind: 'discovery',
232
322
  supportedVersions: [
@@ -237,7 +327,7 @@ export function mapDiscovery(document, rooms) {
237
327
  version: document.mdModelVersion
238
328
  },
239
329
  rooms,
240
- capabilities: capabilities(),
330
+ capabilities: declared,
241
331
  providerLimits: providerLimits(document.bounds),
242
332
  retention: declaredRetention(document.bounds)
243
333
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/discovery.ts"],"sourcesContent":["import type {\n Capability,\n DiscoveredRoom,\n Discovery,\n ProviderLimit,\n Retention,\n TypedSelection,\n} from '@agentshouse/mdruntime';\nimport { declaredActions, HOUSE_CONVERSATION_CARDS } from './actions.js';\nimport { PRIVATE_AUTHORITY } from './transport.js';\n\nexport const ROOM_CONTRACT_VERSION = 1;\n\nexport const MD_MODEL_IDENTITY = '@agentshouse/mdmodel';\n\nexport const ROOM_VERSION_NOTIFICATIONS = 'room-version-notifications';\n\nexport const PROVIDER_ACTIONS = 'provider-actions';\n\nexport const MOVE_REFERENCE_REWRITES = 'move-reference-rewrites';\n\nexport const DISCOVER_PREFIXES: readonly string[] = ['/'];\n\nexport const PROVIDER_SELECTION_ROOTS: readonly string[] = ['agents', 'house'];\n\nexport const PROVIDER_SELECTION_MODEL_ROOT = 'house/settings/model';\n\nexport type HouseBounds = {\n max_authored_file_bytes: number;\n max_batch_operations: number;\n max_path_length: number;\n max_path_depth: number;\n max_mount_files: number;\n max_mount_bytes: number;\n change_retention_seconds: number;\n operation_retention_seconds: number;\n};\n\nexport type HouseOperations = {\n read: readonly string[];\n sync: readonly string[];\n write: readonly string[];\n delete: readonly string[];\n};\n\nexport type HouseAuthority = {\n kind: 'room' | 'private';\n roomRef: string;\n roomHandle: string | null;\n name: string;\n collectionRoot: string;\n modelRoot: string;\n managedReplication: 'admitted' | 'unavailable';\n protectedPaths: readonly string[];\n operations: HouseOperations;\n position: string;\n};\n\nexport type HouseDiscoveryDocument = {\n bounds: HouseBounds;\n mdModelVersion: string;\n authorities: readonly HouseAuthority[];\n};\n\nexport type TrackedAuthority = {\n locator: string;\n authority: string;\n handle: string | undefined;\n collectionRoot: string;\n modelRoot: string;\n modelRoots: readonly string[];\n roomVersion: string;\n};\n\nconst BOUND_KEYS: readonly (keyof HouseBounds)[] = [\n 'max_authored_file_bytes',\n 'max_batch_operations',\n 'max_path_length',\n 'max_path_depth',\n 'max_mount_files',\n 'max_mount_bytes',\n 'change_retention_seconds',\n 'operation_retention_seconds',\n];\n\nconst OPERATION_KEYS: readonly (keyof HouseOperations)[] = ['read', 'sync', 'write', 'delete'];\n\nfunction stringList(value: unknown): readonly string[] | null {\n if (!Array.isArray(value)) return null;\n return value.every((entry) => typeof entry === 'string') ? (value as string[]) : null;\n}\n\nfunction parseBounds(value: unknown): HouseBounds | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n const bounds: Partial<HouseBounds> = {};\n for (const key of BOUND_KEYS) {\n const amount = held[key];\n if (typeof amount !== 'number' || !Number.isFinite(amount)) return null;\n bounds[key] = amount;\n }\n return bounds as HouseBounds;\n}\n\nfunction parseOperations(value: unknown): HouseOperations | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n const operations: Partial<Record<keyof HouseOperations, readonly string[]>> = {};\n for (const key of OPERATION_KEYS) {\n const scopes = stringList(held[key]);\n if (scopes === null) return null;\n operations[key] = scopes;\n }\n return operations as HouseOperations;\n}\n\nfunction parseAuthority(value: unknown): HouseAuthority | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n if (held.kind !== 'room' && held.kind !== 'private') return null;\n if (typeof held.name !== 'string' || held.name.length === 0) return null;\n if (typeof held.collection_root !== 'string' || typeof held.model_root !== 'string') return null;\n if (held.managed_replication !== 'admitted' && held.managed_replication !== 'unavailable') {\n return null;\n }\n if (typeof held.position !== 'string' || held.position.length === 0) return null;\n const protectedPaths = stringList(held.protected_paths);\n const operations = parseOperations(held.operations);\n if (protectedPaths === null || operations === null) return null;\n if (held.kind === 'private') {\n return {\n kind: 'private',\n roomRef: PRIVATE_AUTHORITY,\n roomHandle: null,\n name: held.name,\n collectionRoot: held.collection_root,\n modelRoot: held.model_root,\n managedReplication: held.managed_replication,\n protectedPaths,\n operations,\n position: held.position,\n };\n }\n if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;\n if (typeof held.room_handle !== 'string' || held.room_handle.length === 0) return null;\n return {\n kind: 'room',\n roomRef: held.room_ref,\n roomHandle: held.room_handle,\n name: held.name,\n collectionRoot: held.collection_root,\n modelRoot: held.model_root,\n managedReplication: held.managed_replication,\n protectedPaths,\n operations,\n position: held.position,\n };\n}\n\nexport function parseDiscovery(body: unknown): HouseDiscoveryDocument | null {\n if (typeof body !== 'object' || body === null) return null;\n const held = body as Record<string, unknown>;\n const bounds = parseBounds(held.bounds);\n if (bounds === null) return null;\n if (typeof held.md_model_version !== 'string' || held.md_model_version.length === 0) return null;\n if (!Array.isArray(held.authorities)) return null;\n const authorities: HouseAuthority[] = [];\n for (const entry of held.authorities) {\n const authority = parseAuthority(entry);\n if (authority === null) return null;\n authorities.push(authority);\n }\n return { bounds, mdModelVersion: held.md_model_version, authorities };\n}\n\nexport function locatorOf(authority: HouseAuthority): string {\n return authority.roomHandle ?? PRIVATE_AUTHORITY;\n}\n\nexport function trackedFrom(document: HouseDiscoveryDocument): TrackedAuthority[] {\n return document.authorities.map((authority) => ({\n locator: locatorOf(authority),\n authority: authority.roomRef,\n handle: authority.roomHandle ?? undefined,\n collectionRoot: authority.collectionRoot,\n modelRoot: authority.modelRoot,\n modelRoots:\n authority.kind === 'private'\n ? [authority.modelRoot, PROVIDER_SELECTION_MODEL_ROOT]\n : [authority.modelRoot],\n roomVersion: authority.position,\n }));\n}\n\nexport function providerLimits(bounds: HouseBounds): readonly ProviderLimit[] {\n return [\n { name: 'document-size', value: bounds.max_authored_file_bytes },\n { name: 'change-batch-operations', value: bounds.max_batch_operations },\n { name: 'path-length', value: bounds.max_path_length },\n { name: 'path-depth', value: bounds.max_path_depth },\n { name: 'write-rate' },\n { name: 'content-ceiling' },\n ];\n}\n\nexport function declaredRetention(bounds: HouseBounds): Retention {\n return {\n history: { kind: 'no-declared-time-bound' },\n outcome: bounds.operation_retention_seconds,\n refreshHorizon: bounds.change_retention_seconds,\n };\n}\n\nexport function capabilities(): readonly Capability[] {\n return [\n { name: ROOM_VERSION_NOTIFICATIONS },\n {\n name: PROVIDER_ACTIONS,\n actions: declaredActions(),\n conversationCards: HOUSE_CONVERSATION_CARDS,\n },\n { name: MOVE_REFERENCE_REWRITES },\n ];\n}\n\nexport function providerSelection(attachedModel: TypedSelection['attachedModel']): TypedSelection {\n return { roots: [...PROVIDER_SELECTION_ROOTS], attachedModel };\n}\n\nexport function discoveredRoom(\n authority: HouseAuthority,\n attachedModel: DiscoveredRoom['attachedModel'],\n typedSelection: TypedSelection | undefined,\n): DiscoveredRoom {\n return {\n name: authority.name,\n locator: locatorOf(authority),\n collectionRoot: authority.collectionRoot,\n roomVersion: authority.position,\n operations: {\n read: [...authority.operations.read],\n sync: [...authority.operations.sync],\n write: [...authority.operations.write],\n delete: [...authority.operations.delete],\n },\n replica: { selection: locatorOf(authority), admission: authority.managedReplication },\n attachedModel,\n ...(typedSelection === undefined ? {} : { typedSelection }),\n providerOwnedPaths: [...authority.protectedPaths],\n };\n}\n\nexport function mapDiscovery(\n document: HouseDiscoveryDocument,\n rooms: readonly DiscoveredRoom[],\n): Discovery {\n return {\n kind: 'discovery',\n supportedVersions: [ROOM_CONTRACT_VERSION],\n mdModel: { identity: MD_MODEL_IDENTITY, version: document.mdModelVersion },\n rooms,\n capabilities: capabilities(),\n providerLimits: providerLimits(document.bounds),\n retention: declaredRetention(document.bounds),\n };\n}\n"],"names":["declaredActions","HOUSE_CONVERSATION_CARDS","PRIVATE_AUTHORITY","ROOM_CONTRACT_VERSION","MD_MODEL_IDENTITY","ROOM_VERSION_NOTIFICATIONS","PROVIDER_ACTIONS","MOVE_REFERENCE_REWRITES","DISCOVER_PREFIXES","PROVIDER_SELECTION_ROOTS","PROVIDER_SELECTION_MODEL_ROOT","BOUND_KEYS","OPERATION_KEYS","stringList","value","Array","isArray","every","entry","parseBounds","held","bounds","key","amount","Number","isFinite","parseOperations","operations","scopes","parseAuthority","kind","name","length","collection_root","model_root","managed_replication","position","protectedPaths","protected_paths","roomRef","roomHandle","collectionRoot","modelRoot","managedReplication","room_ref","room_handle","parseDiscovery","body","md_model_version","authorities","authority","push","mdModelVersion","locatorOf","trackedFrom","document","map","locator","handle","undefined","modelRoots","roomVersion","providerLimits","max_authored_file_bytes","max_batch_operations","max_path_length","max_path_depth","declaredRetention","history","outcome","operation_retention_seconds","refreshHorizon","change_retention_seconds","capabilities","actions","conversationCards","providerSelection","attachedModel","roots","discoveredRoom","typedSelection","read","sync","write","delete","replica","selection","admission","providerOwnedPaths","mapDiscovery","rooms","supportedVersions","mdModel","identity","version","retention"],"mappings":"AAQA,SAASA,eAAe,EAAEC,wBAAwB,QAAQ,eAAe;AACzE,SAASC,iBAAiB,QAAQ,iBAAiB;AAEnD,OAAO,MAAMC,wBAAwB,EAAE;AAEvC,OAAO,MAAMC,oBAAoB,uBAAuB;AAExD,OAAO,MAAMC,6BAA6B,6BAA6B;AAEvE,OAAO,MAAMC,mBAAmB,mBAAmB;AAEnD,OAAO,MAAMC,0BAA0B,0BAA0B;AAEjE,OAAO,MAAMC,oBAAuC;IAAC;CAAI,CAAC;AAE1D,OAAO,MAAMC,2BAA8C;IAAC;IAAU;CAAQ,CAAC;AAE/E,OAAO,MAAMC,gCAAgC,uBAAuB;AAiDpE,MAAMC,aAA6C;IACjD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,iBAAqD;IAAC;IAAQ;IAAQ;IAAS;CAAS;AAE9F,SAASC,WAAWC,KAAc;IAChC,IAAI,CAACC,MAAMC,OAAO,CAACF,QAAQ,OAAO;IAClC,OAAOA,MAAMG,KAAK,CAAC,CAACC,QAAU,OAAOA,UAAU,YAAaJ,QAAqB;AACnF;AAEA,SAASK,YAAYL,KAAc;IACjC,IAAI,OAAOA,UAAU,YAAYA,UAAU,MAAM,OAAO;IACxD,MAAMM,OAAON;IACb,MAAMO,SAA+B,CAAC;IACtC,KAAK,MAAMC,OAAOX,WAAY;QAC5B,MAAMY,SAASH,IAAI,CAACE,IAAI;QACxB,IAAI,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,MAAMmB,UAAUnB,IAAI;QACpB0B,SAASJ,UAAUH;QACnBT,gBAAgBS,UAAUT,cAAc;QACxCoB,aAAaX,UAAUd,QAAQ;QAC/BT,YAAY;YACVsD,MAAM;mBAAI/B,UAAUvB,UAAU,CAACsD,IAAI;aAAC;YACpCC,MAAM;mBAAIhC,UAAUvB,UAAU,CAACuD,IAAI;aAAC;YACpCC,OAAO;mBAAIjC,UAAUvB,UAAU,CAACwD,KAAK;aAAC;YACtCC,QAAQ;mBAAIlC,UAAUvB,UAAU,CAACyD,MAAM;aAAC;QAC1C;QACAC,SAAS;YAAEC,WAAWjC,UAAUH;YAAYqC,WAAWrC,UAAUP,kBAAkB;QAAC;QACpFkC;QACA,GAAIG,mBAAmBrB,YAAY,CAAC,IAAI;YAAEqB;QAAe,CAAC;QAC1DQ,oBAAoB;eAAItC,UAAUb,cAAc;SAAC;IACnD;AACF;AAEA,OAAO,SAASoD,aACdlC,QAAgC,EAChCmC,KAAgC;IAEhC,OAAO;QACL5D,MAAM;QACN6D,mBAAmB;YAACxF;SAAsB;QAC1CyF,SAAS;YAAEC,UAAUzF;YAAmB0F,SAASvC,SAASH,cAAc;QAAC;QACzEsC;QACAjB,cAAcA;QACdX,gBAAgBA,eAAeP,SAASlC,MAAM;QAC9C0E,WAAW5B,kBAAkBZ,SAASlC,MAAM;IAC9C;AACF"}
1
+ {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/discovery.ts"],"sourcesContent":["import type {\n Capability,\n DiscoveredRoom,\n Discovery,\n ProviderLimit,\n Retention,\n TypedSelection,\n} from '@agentshouse/mdruntime';\nimport { declaredActions, HOUSE_CONVERSATION_CARDS } from './actions.js';\nimport { PRIVATE_AUTHORITY } from './transport.js';\n\nexport const ROOM_CONTRACT_VERSION = 1;\n\nexport const MD_MODEL_IDENTITY = '@agentshouse/mdmodel';\n\nexport const ROOM_VERSION_NOTIFICATIONS = 'room-version-notifications';\n\nexport const PROVIDER_ACTIONS = 'provider-actions';\n\nexport const MOVE_REFERENCE_REWRITES = 'move-reference-rewrites';\n\nexport const DISCOVER_PREFIXES: readonly string[] = ['/'];\n\nexport const PROVIDER_SELECTION_ROOTS: readonly string[] = ['agents', 'house'];\n\nexport const PROVIDER_SELECTION_MODEL_ROOT = 'house/settings/model';\n\nexport type HouseBounds = {\n max_authored_file_bytes: number;\n max_batch_operations: number;\n max_path_length: number;\n max_path_depth: number;\n max_mount_files: number;\n max_mount_bytes: number;\n change_retention_seconds: number;\n operation_retention_seconds: number;\n};\n\nexport type HouseOperations = {\n read: readonly string[];\n sync: readonly string[];\n write: readonly string[];\n delete: readonly string[];\n};\n\nexport type HouseAuthority = {\n kind: 'room' | 'private';\n roomRef: string;\n roomHandle: string | null;\n name: string;\n collectionRoot: string;\n modelRoot: string;\n managedReplication: 'admitted' | 'unavailable';\n protectedPaths: readonly string[];\n operations: HouseOperations;\n position: string;\n};\n\nexport type HouseDiscoveryDocument = {\n bounds: HouseBounds;\n mdModelVersion: string;\n authorities: readonly HouseAuthority[];\n};\n\nexport type TrackedAuthority = {\n locator: string;\n authority: string;\n handle: string | undefined;\n collectionRoot: string;\n modelRoot: string;\n modelRoots: readonly string[];\n roomVersion: string;\n};\n\nexport type HouseSiteSlot = {\n slot: string;\n roomRef: string | null;\n};\n\nexport type HouseSiteAuthority = {\n roomRef: string;\n roomHandle: string;\n collectionRoot: string;\n modelRoot: string;\n position: string;\n};\n\nexport type HouseSiteDiscovery = {\n bounds: HouseBounds;\n mdModelVersion: string;\n slots: readonly HouseSiteSlot[];\n authorities: readonly HouseSiteAuthority[];\n};\n\nexport type SiteTracked = TrackedAuthority & { slot: string };\n\nconst BOUND_KEYS: readonly (keyof HouseBounds)[] = [\n 'max_authored_file_bytes',\n 'max_batch_operations',\n 'max_path_length',\n 'max_path_depth',\n 'max_mount_files',\n 'max_mount_bytes',\n 'change_retention_seconds',\n 'operation_retention_seconds',\n];\n\nconst OPERATION_KEYS: readonly (keyof HouseOperations)[] = ['read', 'sync', 'write', 'delete'];\n\nfunction stringList(value: unknown): readonly string[] | null {\n if (!Array.isArray(value)) return null;\n return value.every((entry) => typeof entry === 'string') ? (value as string[]) : null;\n}\n\nfunction parseBounds(value: unknown): HouseBounds | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n const bounds: Partial<HouseBounds> = {};\n for (const key of BOUND_KEYS) {\n const amount = held[key];\n if (typeof amount !== 'number' || !Number.isFinite(amount)) return null;\n bounds[key] = amount;\n }\n return bounds as HouseBounds;\n}\n\nfunction parseOperations(value: unknown): HouseOperations | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n const operations: Partial<Record<keyof HouseOperations, readonly string[]>> = {};\n for (const key of OPERATION_KEYS) {\n const scopes = stringList(held[key]);\n if (scopes === null) return null;\n operations[key] = scopes;\n }\n return operations as HouseOperations;\n}\n\nfunction parseAuthority(value: unknown): HouseAuthority | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n if (held.kind !== 'room' && held.kind !== 'private') return null;\n if (typeof held.name !== 'string' || held.name.length === 0) return null;\n if (typeof held.collection_root !== 'string' || typeof held.model_root !== 'string') return null;\n if (held.managed_replication !== 'admitted' && held.managed_replication !== 'unavailable') {\n return null;\n }\n if (typeof held.position !== 'string' || held.position.length === 0) return null;\n const protectedPaths = stringList(held.protected_paths);\n const operations = parseOperations(held.operations);\n if (protectedPaths === null || operations === null) return null;\n if (held.kind === 'private') {\n return {\n kind: 'private',\n roomRef: PRIVATE_AUTHORITY,\n roomHandle: null,\n name: held.name,\n collectionRoot: held.collection_root,\n modelRoot: held.model_root,\n managedReplication: held.managed_replication,\n protectedPaths,\n operations,\n position: held.position,\n };\n }\n if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;\n if (typeof held.room_handle !== 'string' || held.room_handle.length === 0) return null;\n return {\n kind: 'room',\n roomRef: held.room_ref,\n roomHandle: held.room_handle,\n name: held.name,\n collectionRoot: held.collection_root,\n modelRoot: held.model_root,\n managedReplication: held.managed_replication,\n protectedPaths,\n operations,\n position: held.position,\n };\n}\n\nexport function parseDiscovery(body: unknown): HouseDiscoveryDocument | null {\n if (typeof body !== 'object' || body === null) return null;\n const held = body as Record<string, unknown>;\n const bounds = parseBounds(held.bounds);\n if (bounds === null) return null;\n if (typeof held.md_model_version !== 'string' || held.md_model_version.length === 0) return null;\n if (!Array.isArray(held.authorities)) return null;\n const authorities: HouseAuthority[] = [];\n for (const entry of held.authorities) {\n const authority = parseAuthority(entry);\n if (authority === null) return null;\n authorities.push(authority);\n }\n return { bounds, mdModelVersion: held.md_model_version, authorities };\n}\n\nfunction parseSiteSlot(value: unknown): HouseSiteSlot | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n if (typeof held.slot !== 'string' || held.slot.length === 0) return null;\n if (held.room_ref === null) return { slot: held.slot, roomRef: null };\n if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;\n return { slot: held.slot, roomRef: held.room_ref };\n}\n\nfunction parseSiteAuthority(value: unknown): HouseSiteAuthority | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n if (held.kind !== 'room') return null;\n if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;\n if (typeof held.room_handle !== 'string' || held.room_handle.length === 0) return null;\n if (typeof held.collection_root !== 'string' || typeof held.model_root !== 'string') return null;\n if (typeof held.position !== 'string' || held.position.length === 0) return null;\n return {\n roomRef: held.room_ref,\n roomHandle: held.room_handle,\n collectionRoot: held.collection_root,\n modelRoot: held.model_root,\n position: held.position,\n };\n}\n\nexport function parseSiteDiscovery(body: unknown): HouseSiteDiscovery | null {\n if (typeof body !== 'object' || body === null) return null;\n const held = body as Record<string, unknown>;\n const bounds = parseBounds(held.bounds);\n if (bounds === null) return null;\n if (typeof held.md_model_version !== 'string' || held.md_model_version.length === 0) return null;\n if (!Array.isArray(held.slots) || !Array.isArray(held.authorities)) return null;\n const slots: HouseSiteSlot[] = [];\n for (const entry of held.slots) {\n const slot = parseSiteSlot(entry);\n if (slot === null) return null;\n slots.push(slot);\n }\n const authorities: HouseSiteAuthority[] = [];\n for (const entry of held.authorities) {\n const authority = parseSiteAuthority(entry);\n if (authority === null) return null;\n authorities.push(authority);\n }\n return { bounds, mdModelVersion: held.md_model_version, slots, authorities };\n}\n\nexport function siteLocator(slot: string, roomRef: string): string {\n return `${slot}:${roomRef}`;\n}\n\nexport function siteTracked(document: HouseSiteDiscovery): SiteTracked[] {\n const published = new Map(document.authorities.map((entry) => [entry.roomRef, entry]));\n return document.slots.flatMap(({ slot, roomRef }) => {\n const authority = roomRef === null ? undefined : published.get(roomRef);\n if (authority === undefined) return [];\n return [\n {\n slot,\n locator: siteLocator(slot, authority.roomRef),\n authority: authority.roomRef,\n handle: authority.roomHandle,\n collectionRoot: authority.collectionRoot,\n modelRoot: authority.modelRoot,\n modelRoots: [authority.modelRoot],\n roomVersion: authority.position,\n },\n ];\n });\n}\n\nexport function locatorOf(authority: HouseAuthority): string {\n return authority.roomHandle ?? PRIVATE_AUTHORITY;\n}\n\nexport function trackedFrom(document: HouseDiscoveryDocument): TrackedAuthority[] {\n return document.authorities.map((authority) => ({\n locator: locatorOf(authority),\n authority: authority.roomRef,\n handle: authority.roomHandle ?? undefined,\n collectionRoot: authority.collectionRoot,\n modelRoot: authority.modelRoot,\n modelRoots:\n authority.kind === 'private'\n ? [authority.modelRoot, PROVIDER_SELECTION_MODEL_ROOT]\n : [authority.modelRoot],\n roomVersion: authority.position,\n }));\n}\n\nexport function providerLimits(bounds: HouseBounds): readonly ProviderLimit[] {\n return [\n { name: 'document-size', value: bounds.max_authored_file_bytes },\n { name: 'change-batch-operations', value: bounds.max_batch_operations },\n { name: 'path-length', value: bounds.max_path_length },\n { name: 'path-depth', value: bounds.max_path_depth },\n { name: 'write-rate' },\n { name: 'content-ceiling' },\n ];\n}\n\nexport function declaredRetention(bounds: HouseBounds): Retention {\n return {\n history: { kind: 'no-declared-time-bound' },\n outcome: bounds.operation_retention_seconds,\n refreshHorizon: bounds.change_retention_seconds,\n };\n}\n\nexport function capabilities(): readonly Capability[] {\n return [\n { name: ROOM_VERSION_NOTIFICATIONS },\n {\n name: PROVIDER_ACTIONS,\n actions: declaredActions(),\n conversationCards: HOUSE_CONVERSATION_CARDS,\n },\n { name: MOVE_REFERENCE_REWRITES },\n ];\n}\n\nexport function siteCapabilities(): readonly Capability[] {\n return [{ name: ROOM_VERSION_NOTIFICATIONS }];\n}\n\nexport function providerSelection(attachedModel: TypedSelection['attachedModel']): TypedSelection {\n return { roots: [...PROVIDER_SELECTION_ROOTS], attachedModel };\n}\n\nexport function discoveredRoom(\n authority: HouseAuthority,\n attachedModel: DiscoveredRoom['attachedModel'],\n typedSelection: TypedSelection | undefined,\n): DiscoveredRoom {\n return {\n name: authority.name,\n locator: locatorOf(authority),\n collectionRoot: authority.collectionRoot,\n roomVersion: authority.position,\n operations: {\n read: [...authority.operations.read],\n sync: [...authority.operations.sync],\n write: [...authority.operations.write],\n delete: [...authority.operations.delete],\n },\n replica: { selection: locatorOf(authority), admission: authority.managedReplication },\n attachedModel,\n ...(typedSelection === undefined ? {} : { typedSelection }),\n providerOwnedPaths: [...authority.protectedPaths],\n };\n}\n\nexport function mapDiscovery(\n document: Pick<HouseDiscoveryDocument, 'bounds' | 'mdModelVersion'>,\n rooms: readonly DiscoveredRoom[],\n declared: readonly Capability[],\n): Discovery {\n return {\n kind: 'discovery',\n supportedVersions: [ROOM_CONTRACT_VERSION],\n mdModel: { identity: MD_MODEL_IDENTITY, version: document.mdModelVersion },\n rooms,\n capabilities: declared,\n providerLimits: providerLimits(document.bounds),\n retention: declaredRetention(document.bounds),\n };\n}\n"],"names":["declaredActions","HOUSE_CONVERSATION_CARDS","PRIVATE_AUTHORITY","ROOM_CONTRACT_VERSION","MD_MODEL_IDENTITY","ROOM_VERSION_NOTIFICATIONS","PROVIDER_ACTIONS","MOVE_REFERENCE_REWRITES","DISCOVER_PREFIXES","PROVIDER_SELECTION_ROOTS","PROVIDER_SELECTION_MODEL_ROOT","BOUND_KEYS","OPERATION_KEYS","stringList","value","Array","isArray","every","entry","parseBounds","held","bounds","key","amount","Number","isFinite","parseOperations","operations","scopes","parseAuthority","kind","name","length","collection_root","model_root","managed_replication","position","protectedPaths","protected_paths","roomRef","roomHandle","collectionRoot","modelRoot","managedReplication","room_ref","room_handle","parseDiscovery","body","md_model_version","authorities","authority","push","mdModelVersion","parseSiteSlot","slot","parseSiteAuthority","parseSiteDiscovery","slots","siteLocator","siteTracked","document","published","Map","map","flatMap","undefined","get","locator","handle","modelRoots","roomVersion","locatorOf","trackedFrom","providerLimits","max_authored_file_bytes","max_batch_operations","max_path_length","max_path_depth","declaredRetention","history","outcome","operation_retention_seconds","refreshHorizon","change_retention_seconds","capabilities","actions","conversationCards","siteCapabilities","providerSelection","attachedModel","roots","discoveredRoom","typedSelection","read","sync","write","delete","replica","selection","admission","providerOwnedPaths","mapDiscovery","rooms","declared","supportedVersions","mdModel","identity","version","retention"],"mappings":"AAQA,SAASA,eAAe,EAAEC,wBAAwB,QAAQ,eAAe;AACzE,SAASC,iBAAiB,QAAQ,iBAAiB;AAEnD,OAAO,MAAMC,wBAAwB,EAAE;AAEvC,OAAO,MAAMC,oBAAoB,uBAAuB;AAExD,OAAO,MAAMC,6BAA6B,6BAA6B;AAEvE,OAAO,MAAMC,mBAAmB,mBAAmB;AAEnD,OAAO,MAAMC,0BAA0B,0BAA0B;AAEjE,OAAO,MAAMC,oBAAuC;IAAC;CAAI,CAAC;AAE1D,OAAO,MAAMC,2BAA8C;IAAC;IAAU;CAAQ,CAAC;AAE/E,OAAO,MAAMC,gCAAgC,uBAAuB;AAuEpE,MAAMC,aAA6C;IACjD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,iBAAqD;IAAC;IAAQ;IAAQ;IAAS;CAAS;AAE9F,SAASC,WAAWC,KAAc;IAChC,IAAI,CAACC,MAAMC,OAAO,CAACF,QAA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A+B;IAE/B,OAAO;QACLzE,MAAM;QACN0E,mBAAmB;YAACrG;SAAsB;QAC1CsG,SAAS;YAAEC,UAAUtG;YAAmBuG,SAAS/C,SAASR,cAAc;QAAC;QACzEkD;QACAlB,cAAcmB;QACd9B,gBAAgBA,eAAeb,SAASvC,MAAM;QAC9CuF,WAAW9B,kBAAkBlB,SAASvC,MAAM;IAC9C;AACF"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
2
2
  export { nativePath, roomLocalPath } from './map.js';
3
- export type { HouseByteAct, HouseByteTransfer, HouseDoorAnswer, HouseStream, HouseStreamAuthority, HouseStreamEntry, HouseStreamFrame, HouseTransport, } from './transport.js';
3
+ export type { HouseByteAct, HouseByteTransfer, HouseDoorAnswer, HouseStream, HouseStreamAuthority, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
4
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,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,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,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"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/index.ts"],"sourcesContent":["export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';\nexport { nativePath, roomLocalPath } from './map.js';\nexport type {\n HouseByteAct,\n HouseByteTransfer,\n HouseDoorAnswer,\n HouseStream,\n HouseStreamAuthority,\n HouseStreamEntry,\n HouseStreamFrame,\n HouseTransport,\n} from './transport.js';\n"],"names":["createAgentsHouseAdapter","nativePath","roomLocalPath"],"mappings":"AAAA,SAASA,wBAAwB,QAAwC,eAAe;AACxF,SAASC,UAAU,EAAEC,aAAa,QAAQ,WAAW"}
1
+ {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/index.ts"],"sourcesContent":["export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';\nexport { nativePath, roomLocalPath } from './map.js';\nexport type {\n HouseByteAct,\n HouseByteTransfer,\n HouseDoorAnswer,\n HouseStream,\n HouseStreamAuthority,\n HouseStreamEntry,\n HouseStreamFrame,\n HouseSiteTransport,\n HouseTransport,\n} from './transport.js';\n"],"names":["createAgentsHouseAdapter","nativePath","roomLocalPath"],"mappings":"AAAA,SAASA,wBAAwB,QAAwC,eAAe;AACxF,SAASC,UAAU,EAAEC,aAAa,QAAQ,WAAW"}
@@ -0,0 +1,19 @@
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;
19
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +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"}
package/dist/model.js ADDED
@@ -0,0 +1,64 @@
1
+ import { sha256Hex } from './digest.js';
2
+ export const MODEL_ABSENT = {
3
+ kind: 'model-unavailable',
4
+ reason: 'not-readable'
5
+ };
6
+ export function failedModel(failure) {
7
+ if (failure.kind === 'revoked-authorization') return {
8
+ kind: 'revoked-authorization'
9
+ };
10
+ if (failure.kind === 'transport-uncertainty') return {
11
+ kind: 'transport-uncertainty'
12
+ };
13
+ return MODEL_ABSENT;
14
+ }
15
+ export function modelKey(locator, attached) {
16
+ return `${locator} ${attached}`;
17
+ }
18
+ export async function heldModel(read, identity, failure) {
19
+ if (read === null) return {
20
+ snapshot: failure,
21
+ identity: null
22
+ };
23
+ const version = await sha256Hex(JSON.stringify(read.versions));
24
+ return {
25
+ snapshot: {
26
+ kind: 'model',
27
+ snapshot: {
28
+ identity,
29
+ version,
30
+ definitions: read.definitions
31
+ }
32
+ },
33
+ identity: {
34
+ identity,
35
+ version
36
+ }
37
+ };
38
+ }
39
+ export function modelShelf() {
40
+ const models = new Map();
41
+ return {
42
+ retain (key, acquired) {
43
+ if (acquired === undefined) return models.get(key);
44
+ if (acquired.snapshot.kind === 'transport-uncertainty') {
45
+ const previous = models.get(key);
46
+ if (previous !== undefined && previous.identity !== null) return previous;
47
+ }
48
+ models.set(key, acquired);
49
+ return acquired;
50
+ },
51
+ answer (request) {
52
+ return models.get(modelKey(request.locator, request.attached))?.snapshot ?? MODEL_ABSENT;
53
+ },
54
+ keep (locators) {
55
+ for (const key of [
56
+ ...models.keys()
57
+ ]){
58
+ if (!locators.some((locator)=>key.startsWith(`${locator} `))) models.delete(key);
59
+ }
60
+ }
61
+ };
62
+ }
63
+
64
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/model.ts"],"sourcesContent":["import type {\n AdapterFailure,\n ModelIdentity,\n ModelRequest,\n ModelResult,\n} from '@agentshouse/mdruntime';\nimport { sha256Hex } from './digest.js';\nimport type { HouseDefinitions } from './read.js';\n\nexport type HeldModel = { snapshot: ModelResult; identity: ModelIdentity | null };\n\nexport const MODEL_ABSENT: ModelResult = { kind: 'model-unavailable', reason: 'not-readable' };\n\nexport function failedModel(failure: AdapterFailure | { kind: 'beyond-horizon' }): ModelResult {\n if (failure.kind === 'revoked-authorization') return { kind: 'revoked-authorization' };\n if (failure.kind === 'transport-uncertainty') return { kind: 'transport-uncertainty' };\n return MODEL_ABSENT;\n}\n\nexport function modelKey(locator: string, attached: ModelRequest['attached']): string {\n return `${locator} ${attached}`;\n}\n\nexport async function heldModel(\n read: HouseDefinitions | null,\n identity: string,\n failure: ModelResult,\n): Promise<HeldModel> {\n if (read === null) return { snapshot: failure, identity: null };\n const version = await sha256Hex(JSON.stringify(read.versions));\n return {\n snapshot: { kind: 'model', snapshot: { identity, version, definitions: read.definitions } },\n identity: { identity, version },\n };\n}\n\nexport type ModelShelf = {\n retain(key: string, acquired: HeldModel | undefined): HeldModel | undefined;\n answer(request: ModelRequest): ModelResult;\n keep(locators: readonly string[]): void;\n};\n\nexport function modelShelf(): ModelShelf {\n const models = new Map<string, HeldModel>();\n return {\n retain(key, acquired) {\n if (acquired === undefined) return models.get(key);\n if (acquired.snapshot.kind === 'transport-uncertainty') {\n const previous = models.get(key);\n if (previous !== undefined && previous.identity !== null) return previous;\n }\n models.set(key, acquired);\n return acquired;\n },\n answer(request) {\n return models.get(modelKey(request.locator, request.attached))?.snapshot ?? MODEL_ABSENT;\n },\n keep(locators) {\n for (const key of [...models.keys()]) {\n if (!locators.some((locator) => key.startsWith(`${locator} `))) models.delete(key);\n }\n },\n };\n}\n"],"names":["sha256Hex","MODEL_ABSENT","kind","reason","failedModel","failure","modelKey","locator","attached","heldModel","read","identity","snapshot","version","JSON","stringify","versions","definitions","modelShelf","models","Map","retain","key","acquired","undefined","get","previous","set","answer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YAAYX;QAC9E;QACA6B,MAAKC,QAAQ;YACX,KAAK,MAAMT,OAAO;mBAAIH,OAAOa,IAAI;aAAG,CAAE;gBACpC,IAAI,CAACD,SAASE,IAAI,CAAC,CAAC1B,UAAYe,IAAIY,UAAU,CAAC,GAAG3B,QAAQ,CAAC,CAAC,IAAIY,OAAOgB,MAAM,CAACb;YAChF;QACF;IACF;AACF"}
package/dist/read.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- import type { BootstrapResult, RefreshResult } from '@agentshouse/mdruntime';
1
+ import type { BootstrapPage, BootstrapResult, RefreshResult } from '@agentshouse/mdruntime';
2
2
  import { type TrackedAuthority } from './discovery.js';
3
+ import type { HouseMode } from './transport.js';
3
4
  export type HouseManifestFile = {
4
5
  path: string;
5
- revision: string;
6
+ revision: string | undefined;
7
+ version: string;
6
8
  };
7
9
  export type HouseContent = {
8
10
  path: string;
@@ -30,7 +32,8 @@ export type HouseChange = {
30
32
  } | {
31
33
  path: string;
32
34
  content: string;
33
- revision: string;
35
+ revision: string | undefined;
36
+ version: string;
34
37
  } | {
35
38
  path: string;
36
39
  reference: {
@@ -51,17 +54,21 @@ export declare function contentPrefixes(tracked: TrackedAuthority): readonly str
51
54
  export declare function modelPrefix(tracked: TrackedAuthority, modelRoot: string): string;
52
55
  export declare function parseGrant(body: unknown): HouseGrant | null;
53
56
  export declare function parseEnvelope(body: unknown): HouseEnvelope | null;
54
- export declare function parseEnumeration(body: unknown): HouseEnumeration | null;
57
+ export declare function parseSiteBootstrap(body: unknown): HouseScope | null;
58
+ export declare function parseEnumeration(body: unknown, mode: HouseMode): HouseEnumeration | null;
59
+ export declare function advancedScope(scope: HouseScope, view: HouseEnumeration['authorities'][number]): HouseScope;
55
60
  export declare function matchesScope(scope: HouseScope, tracked: TrackedAuthority): boolean;
56
61
  export declare function withinRoot(path: string, root: string): boolean;
57
62
  export declare function selects(tracked: TrackedAuthority, path: string): boolean;
58
63
  export declare function bootstrapFrom(envelope: HouseEnvelope, tracked: TrackedAuthority): BootstrapResult;
64
+ export declare function bootstrapOf(scope: HouseScope, tracked: TrackedAuthority): BootstrapPage;
59
65
  export type HouseDefinitions = {
60
66
  definitions: Readonly<Record<string, string>>;
61
- revisions: readonly string[];
67
+ versions: readonly string[];
62
68
  };
63
69
  export declare const MODEL_DEFINITION_ADDRESS = "types";
64
70
  export declare function definitionAddress(path: string): string;
65
71
  export declare function definitionsFrom(envelope: HouseEnvelope, tracked: TrackedAuthority, modelRoot: string): HouseDefinitions | null;
72
+ export declare function definitionsOf(scope: HouseScope, modelRoot: string): HouseDefinitions | null;
66
73
  export declare function refreshFrom(enumeration: HouseEnumeration, tracked: TrackedAuthority, fromRoomVersion: string): RefreshResult;
67
74
  //# 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,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAA4B,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEjF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACpC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,SAAS,UAAU,EAAE,C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AAE,gBAAgB,GAAG,aAAa,CAmBvF;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9C,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,wBAAwB,UAAU,CAAC;AAEhD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,gBAAgB,EACzB,SAAS,EAAE,MAAM,GAChB,gBAAgB,GAAG,IAAI,CAIzB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAa3F;AAED,wBAAgB,WAAW,CACzB,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,gBAAgB,EACzB,eAAe,EAAE,MAAM,GACtB,aAAa,CA8Bf"}
package/dist/read.js CHANGED
@@ -36,7 +36,26 @@ export function parseGrant(body) {
36
36
  url: transfer.url
37
37
  };
38
38
  }
39
- function parseScope(value) {
39
+ function parseFile(value, mode) {
40
+ if (typeof value !== 'object' || value === null) return null;
41
+ const file = value;
42
+ if (typeof file.path !== 'string') return null;
43
+ if (mode === 'site') {
44
+ if (typeof file.sha256 !== 'string') return null;
45
+ return {
46
+ path: file.path,
47
+ revision: undefined,
48
+ version: file.sha256
49
+ };
50
+ }
51
+ if (typeof file.revision !== 'string') return null;
52
+ return {
53
+ path: file.path,
54
+ revision: file.revision,
55
+ version: file.revision
56
+ };
57
+ }
58
+ function parseScope(value, mode) {
40
59
  if (typeof value !== 'object' || value === null) return null;
41
60
  const held = value;
42
61
  if (typeof held.manifest !== 'object' || held.manifest === null) return null;
@@ -47,13 +66,9 @@ function parseScope(value) {
47
66
  if (!Array.isArray(manifest.files)) return null;
48
67
  const files = [];
49
68
  for (const entry of manifest.files){
50
- if (typeof entry !== 'object' || entry === null) return null;
51
- const file = entry;
52
- if (typeof file.path !== 'string' || typeof file.revision !== 'string') return null;
53
- files.push({
54
- path: file.path,
55
- revision: file.revision
56
- });
69
+ const file = parseFile(entry, mode);
70
+ if (file === null) return null;
71
+ files.push(file);
57
72
  }
58
73
  const contents = [];
59
74
  for (const entry of held.contents){
@@ -79,7 +94,7 @@ export function parseEnvelope(body) {
79
94
  if (!('scopes' in body) || !Array.isArray(body.scopes)) return null;
80
95
  const scopes = [];
81
96
  for (const entry of body.scopes){
82
- const scope = parseScope(entry);
97
+ const scope = parseScope(entry, 'credential');
83
98
  if (scope === null) return null;
84
99
  scopes.push(scope);
85
100
  }
@@ -87,7 +102,11 @@ export function parseEnvelope(body) {
87
102
  scopes
88
103
  };
89
104
  }
90
- function parseChange(value) {
105
+ export function parseSiteBootstrap(body) {
106
+ const scope = parseScope(body, 'site');
107
+ return scope !== null && scope.scope === 'room' ? scope : null;
108
+ }
109
+ function parseChange(value, mode) {
91
110
  if (typeof value !== 'object' || value === null) return null;
92
111
  const held = value;
93
112
  if (typeof held.path !== 'string') return null;
@@ -95,11 +114,21 @@ function parseChange(value) {
95
114
  path: held.path,
96
115
  removed: true
97
116
  };
117
+ if (mode === 'site') {
118
+ if (typeof held.content !== 'string' || typeof held.sha256 !== 'string') return null;
119
+ return {
120
+ path: held.path,
121
+ content: held.content,
122
+ revision: undefined,
123
+ version: held.sha256
124
+ };
125
+ }
98
126
  if (typeof held.content === 'string' && typeof held.revision === 'string') {
99
127
  return {
100
128
  path: held.path,
101
129
  content: held.content,
102
- revision: held.revision
130
+ revision: held.revision,
131
+ version: held.revision
103
132
  };
104
133
  }
105
134
  if (typeof held.reference === 'object' && held.reference !== null) {
@@ -114,7 +143,7 @@ function parseChange(value) {
114
143
  }
115
144
  return null;
116
145
  }
117
- export function parseEnumeration(body) {
146
+ export function parseEnumeration(body, mode) {
118
147
  if (typeof body !== 'object' || body === null) return null;
119
148
  if (!('authorities' in body) || !Array.isArray(body.authorities)) return null;
120
149
  const authorities = [];
@@ -125,7 +154,7 @@ export function parseEnumeration(body) {
125
154
  if (!Array.isArray(held.changes)) return null;
126
155
  const changes = [];
127
156
  for (const change of held.changes){
128
- const mapped = parseChange(change);
157
+ const mapped = parseChange(change, mode);
129
158
  if (mapped === null) return null;
130
159
  changes.push(mapped);
131
160
  }
@@ -139,6 +168,49 @@ export function parseEnumeration(body) {
139
168
  authorities
140
169
  };
141
170
  }
171
+ export function advancedScope(scope, view) {
172
+ const files = new Map(scope.files.map((file)=>[
173
+ file.path,
174
+ file
175
+ ]));
176
+ const contents = new Map(scope.contents.map((entry)=>[
177
+ entry.path,
178
+ entry.content
179
+ ]));
180
+ for (const change of view.changes){
181
+ files.delete(change.path);
182
+ contents.delete(change.path);
183
+ if ('removed' in change) continue;
184
+ if ('content' in change) {
185
+ files.set(change.path, {
186
+ path: change.path,
187
+ revision: change.revision,
188
+ version: change.version
189
+ });
190
+ contents.set(change.path, change.content);
191
+ continue;
192
+ }
193
+ const { revision } = change.reference;
194
+ files.set(change.path, {
195
+ path: change.path,
196
+ revision,
197
+ version: revision
198
+ });
199
+ }
200
+ return {
201
+ ...scope,
202
+ position: view.position,
203
+ files: [
204
+ ...files.values()
205
+ ],
206
+ contents: [
207
+ ...contents
208
+ ].map(([path, content])=>({
209
+ path,
210
+ content
211
+ }))
212
+ };
213
+ }
142
214
  export function matchesScope(scope, tracked) {
143
215
  if (tracked.handle === undefined) return scope.scope === 'private';
144
216
  return scope.roomHandle === tracked.handle || scope.anchor === tracked.authority;
@@ -156,6 +228,9 @@ export function bootstrapFrom(envelope, tracked) {
156
228
  kind: 'room-not-readable',
157
229
  locator: tracked.locator
158
230
  };
231
+ return bootstrapOf(scope, tracked);
232
+ }
233
+ export function bootstrapOf(scope, tracked) {
159
234
  const contents = new Map(scope.contents.map((entry)=>[
160
235
  entry.path,
161
236
  entry.content
@@ -165,7 +240,7 @@ export function bootstrapFrom(envelope, tracked) {
165
240
  const binaryTargets = [];
166
241
  for (const file of scope.files){
167
242
  if (!selects(tracked, file.path)) continue;
168
- revisions[file.path] = file.revision;
243
+ if (file.revision !== undefined) revisions[file.path] = file.revision;
169
244
  const content = contents.get(file.path);
170
245
  if (content === undefined) binaryTargets.push(file.path);
171
246
  else documents[file.path] = content;
@@ -185,23 +260,26 @@ export function definitionAddress(path) {
185
260
  export function definitionsFrom(envelope, tracked, modelRoot) {
186
261
  const scope = envelope.scopes.find((entry)=>matchesScope(entry, tracked));
187
262
  if (scope === undefined) return null;
263
+ return definitionsOf(scope, modelRoot);
264
+ }
265
+ export function definitionsOf(scope, modelRoot) {
188
266
  const contents = new Map(scope.contents.map((entry)=>[
189
267
  entry.path,
190
268
  entry.content
191
269
  ]));
192
270
  const definitions = {};
193
- const revisions = [];
271
+ const versions = [];
194
272
  for (const file of scope.files){
195
273
  if (!withinRoot(file.path, modelRoot)) continue;
196
274
  const content = contents.get(file.path);
197
275
  const address = definitionAddress(file.path);
198
276
  if (content === undefined || Object.hasOwn(definitions, address)) return null;
199
277
  definitions[address] = content;
200
- revisions.push(`${file.path} ${file.revision}`);
278
+ versions.push(`${file.path} ${file.version}`);
201
279
  }
202
280
  return {
203
281
  definitions,
204
- revisions: revisions.sort()
282
+ versions: versions.sort()
205
283
  };
206
284
  }
207
285
  export function refreshFrom(enumeration, tracked, fromRoomVersion) {
@@ -225,7 +303,7 @@ export function refreshFrom(enumeration, tracked, fromRoomVersion) {
225
303
  }
226
304
  if ('content' in change) {
227
305
  documents[change.path] = change.content;
228
- revisions[change.path] = change.revision;
306
+ if (change.revision !== undefined) revisions[change.path] = change.revision;
229
307
  continue;
230
308
  }
231
309
  binaryTargets.push(change.path);