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

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 (62) hide show
  1. package/AGENTS.md +157 -25
  2. package/README.md +32 -0
  3. package/dist/actions.d.ts +3 -11
  4. package/dist/actions.d.ts.map +1 -1
  5. package/dist/actions.js +201 -232
  6. package/dist/actions.js.map +1 -1
  7. package/dist/adapter.d.ts +3 -1
  8. package/dist/adapter.d.ts.map +1 -1
  9. package/dist/adapter.js +242 -173
  10. package/dist/adapter.js.map +1 -1
  11. package/dist/discovery.d.ts +39 -15
  12. package/dist/discovery.d.ts.map +1 -1
  13. package/dist/discovery.js +169 -43
  14. package/dist/discovery.js.map +1 -1
  15. package/dist/gather.d.ts +3 -0
  16. package/dist/gather.d.ts.map +1 -0
  17. package/dist/gather.js +41 -0
  18. package/dist/gather.js.map +1 -0
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/links.d.ts +11 -0
  23. package/dist/links.d.ts.map +1 -0
  24. package/dist/links.js +57 -0
  25. package/dist/links.js.map +1 -0
  26. package/dist/map.d.ts +2 -2
  27. package/dist/map.d.ts.map +1 -1
  28. package/dist/map.js +2 -3
  29. package/dist/map.js.map +1 -1
  30. package/dist/model.d.ts +19 -0
  31. package/dist/model.d.ts.map +1 -0
  32. package/dist/model.js +64 -0
  33. package/dist/model.js.map +1 -0
  34. package/dist/read.d.ts +39 -27
  35. package/dist/read.d.ts.map +1 -1
  36. package/dist/read.js +246 -91
  37. package/dist/read.js.map +1 -1
  38. package/dist/refusal.d.ts +4 -1
  39. package/dist/refusal.d.ts.map +1 -1
  40. package/dist/refusal.js +13 -1
  41. package/dist/refusal.js.map +1 -1
  42. package/dist/site.d.ts +4 -0
  43. package/dist/site.d.ts.map +1 -0
  44. package/dist/site.js +228 -0
  45. package/dist/site.js.map +1 -0
  46. package/dist/stream.d.ts +11 -5
  47. package/dist/stream.d.ts.map +1 -1
  48. package/dist/stream.js +220 -142
  49. package/dist/stream.js.map +1 -1
  50. package/dist/transport.d.ts +57 -29
  51. package/dist/transport.d.ts.map +1 -1
  52. package/dist/transport.js +6 -1
  53. package/dist/transport.js.map +1 -1
  54. package/dist/version.d.ts +15 -0
  55. package/dist/version.d.ts.map +1 -0
  56. package/dist/version.js +39 -0
  57. package/dist/version.js.map +1 -0
  58. package/dist/write.d.ts +9 -3
  59. package/dist/write.d.ts.map +1 -1
  60. package/dist/write.js +51 -9
  61. package/dist/write.js.map +1 -1
  62. package/package.json +4 -12
@@ -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;IAC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AkBZ,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_LOCATOR } from './transport.js';\nimport { readPosition, roomVersion, type LogPosition } from './version.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[] = [\n 'agents',\n 'collaboration/routines',\n 'house',\n 'settings/apps',\n 'settings/panel.md',\n];\n\nexport const UNTYPED_FOLDERS: readonly string[] = ['capture'];\n\nexport const RESERVED_NAMES: readonly string[] = [\n 'ROOM.md',\n 'capture',\n 'settings',\n 'collaboration',\n 'rooms',\n 'agents',\n 'house',\n 'work',\n 'entities',\n 'schema',\n 'commitments',\n];\n\nexport const HOUSE_SCHEMA = 'house/schema.yaml';\n\nexport const PRIVATE_HANDLE = 'private';\n\nexport type HouseBounds = {\n max_authored_file_bytes: number;\n max_batch_operations: number;\n max_batch_documents: 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 = LogPosition & {\n roomRef: string;\n roomHandle: string;\n name: string;\n schema: string;\n managedReplication: 'admitted' | 'unavailable';\n protectedPaths: readonly string[];\n operations: HouseOperations;\n};\n\nexport type HouseDiscoveryDocument = {\n bounds: HouseBounds;\n mdModelVersion: string;\n authorities: readonly HouseAuthority[];\n actions: readonly string[];\n};\n\nexport type TrackedAuthority = LogPosition & {\n locator: string;\n authority: string;\n handle: string;\n schema: string;\n schemas: readonly string[];\n};\n\nexport type HouseSiteEntry = {\n roomRef: string;\n segment: string;\n};\n\nexport type HouseSiteSlot = {\n slot: string;\n entries: readonly HouseSiteEntry[];\n};\n\nexport type HouseSiteAuthority = LogPosition & {\n roomRef: string;\n roomHandle: string;\n schema: string;\n};\n\nexport type HouseSiteDiscovery = {\n bounds: HouseBounds;\n mdModelVersion: string;\n slots: readonly HouseSiteSlot[];\n authorities: readonly HouseSiteAuthority[];\n};\n\nconst BOUND_KEYS: readonly (keyof HouseBounds)[] = [\n 'max_authored_file_bytes',\n 'max_batch_operations',\n 'max_batch_documents',\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') return null;\n if (typeof held.name !== 'string' || held.name.length === 0) return null;\n if (typeof held.model_root !== 'string') return null;\n if (held.managed_replication !== 'admitted' && held.managed_replication !== 'unavailable') {\n return null;\n }\n const at = readPosition(held);\n const protectedPaths = stringList(held.protected_paths);\n const operations = parseOperations(held.operations);\n if (at === null || protectedPaths === null || operations === null) 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 return {\n roomRef: held.room_ref,\n roomHandle: held.room_handle,\n name: held.name,\n schema: held.model_root,\n managedReplication: held.managed_replication,\n protectedPaths,\n operations,\n ...at,\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 const actions = stringList(held.actions);\n if (\n actions === null ||\n new Set(actions).size !== actions.length ||\n actions.some((name) => name.length === 0)\n )\n 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, actions };\n}\n\nfunction parseSiteEntry(value: unknown): HouseSiteEntry | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;\n if (typeof held.segment !== 'string' || held.segment.length === 0) return null;\n return { roomRef: held.room_ref, segment: held.segment };\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 (!Array.isArray(held.entries)) return null;\n const entries: HouseSiteEntry[] = [];\n for (const entry of held.entries) {\n const parsed = parseSiteEntry(entry);\n if (parsed === null) return null;\n entries.push(parsed);\n }\n return { slot: held.slot, entries };\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.model_root !== 'string') return null;\n const at = readPosition(held);\n if (at === null) return null;\n return {\n roomRef: held.room_ref,\n roomHandle: held.room_handle,\n schema: held.model_root,\n ...at,\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 siteTracked(document: HouseSiteDiscovery): TrackedAuthority[] {\n return document.authorities.map((authority) => ({\n locator: authority.roomRef,\n authority: authority.roomRef,\n handle: authority.roomHandle,\n schema: authority.schema,\n schemas: [authority.schema],\n position: authority.position,\n logEpoch: authority.logEpoch,\n }));\n}\n\nexport function siteSlots(document: HouseSiteDiscovery): Discovery['slots'] {\n return document.slots.map(({ slot, entries }) => ({\n slot,\n entries: entries.map(({ roomRef, segment }) => ({ locator: roomRef, segment })),\n }));\n}\n\nexport function locatorOf(authority: HouseAuthority): string {\n return authority.roomHandle === PRIVATE_HANDLE ? PRIVATE_LOCATOR : authority.roomRef;\n}\n\nfunction schemasOf(authority: HouseAuthority): readonly string[] {\n return authority.roomHandle === PRIVATE_HANDLE\n ? [authority.schema, HOUSE_SCHEMA]\n : [authority.schema];\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,\n schema: authority.schema,\n schemas: schemasOf(authority),\n position: authority.position,\n logEpoch: authority.logEpoch,\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: 'change-documents', value: bounds.max_batch_documents },\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(actions: readonly string[]): readonly Capability[] {\n return [\n { name: ROOM_VERSION_NOTIFICATIONS },\n {\n name: PROVIDER_ACTIONS,\n actions: declaredActions(actions),\n conversationCards: HOUSE_CONVERSATION_CARDS,\n },\n { name: MOVE_REFERENCE_REWRITES },\n ];\n}\n\nexport function siteCapabilities(): readonly Capability[] {\n return [\n { name: ROOM_VERSION_NOTIFICATIONS },\n { name: PROVIDER_ACTIONS, actions: [{ name: 'submit', inputShape: {}, resultKind: 'house' }] },\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 roomVersion: roomVersion(authority),\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 untypedFolders: [...UNTYPED_FOLDERS],\n providerOwnedPaths: [...authority.protectedPaths, ...schemasOf(authority)],\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_LOCATOR","readPosition","roomVersion","ROOM_CONTRACT_VERSION","MD_MODEL_IDENTITY","ROOM_VERSION_NOTIFICATIONS","PROVIDER_ACTIONS","MOVE_REFERENCE_REWRITES","DISCOVER_PREFIXES","PROVIDER_SELECTION_ROOTS","UNTYPED_FOLDERS","RESERVED_NAMES","HOUSE_SCHEMA","PRIVATE_HANDLE","BOUND_KEYS","OPERATION_KEYS","stringList","value","Array","isArray","every","entry","parseBounds","held","bounds","key","amount","Number","isFinite","parseOperations","operations","scopes","parseAuthority","kind","name","length","model_root","managed_replication","at","protectedPaths","protected_paths","room_ref","room_handle","roomRef","roomHandle","schema","managedReplication","parseDiscovery","body","md_model_version","actions","Set","size","some","authorities","authority","push","mdModelVersion","parseSiteEntry","segment","parseSiteSlot","slot","entries","parsed","parseSiteAuthority","parseSiteDiscovery","slots","siteTracked","document","map","locator","handle","schemas","position","logEpoch","siteSlots","locatorOf","schemasOf","trackedFrom","providerLimits","max_authored_file_bytes","max_batch_operations","max_batch_documents","max_path_length","max_path_depth","declaredRetention","history","outcome","operation_retention_seconds","refreshHorizon","change_retention_seconds","capabilities","conversationCards","siteCapabilities","inputShape","resultKind","providerSelection","attachedModel","roots","discoveredRoom","typedSelection","read","sync","write","delete","replica","selection","admission","undefined","untypedFolders","providerOwnedPaths","mapDiscovery","rooms","declared","supportedVersions","mdModel","identity","version","retention"],"mappings":"AAQA,SAASA,eAAe,EAAEC,wBAAwB,QAAQ,eAAe;AACzE,SAASC,eAAe,QAAQ,iBAAiB;AACjD,SAASC,YAAY,EAAEC,WAAW,QAA0B,eAAe;AAE3E,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;IACzD;IACA;IACA;IACA;IACA;CACD,CAAC;AAEF,OAAO,MAAMC,kBAAqC;IAAC;CAAU,CAAC;AAE9D,OAAO,MAAMC,iBAAoC;IAC/C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAC;AAEF,OAAO,MAAMC,eAAe,oBAAoB;AAEhD,OAAO,MAAMC,iBAAiB,UAAU;AAqExC,MAAMC,aAA6C;IACjD;IACA;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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Ac;eAAKsC,UAAUtB;SAAW;IAC5E;AACF;AAEA,OAAO,SAASwD,aACd3C,QAAmE,EACnE4C,KAAgC,EAChCC,QAA+B;IAE/B,OAAO;QACLhF,MAAM;QACNiF,mBAAmB;YAAC/G;SAAsB;QAC1CgH,SAAS;YAAEC,UAAUhH;YAAmBiH,SAASjD,SAASX,cAAc;QAAC;QACzEuD;QACArB,cAAcsB;QACdlC,gBAAgBA,eAAeX,SAAS5C,MAAM;QAC9C8F,WAAWjC,kBAAkBjB,SAAS5C,MAAM;IAC9C;AACF"}
@@ -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,CAuBxB;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,41 @@
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)entry.reject(reason);
12
+ });
13
+ }
14
+ return (ask)=>new Promise((resolve, reject)=>{
15
+ if (held.length === 0) setTimeout(flush, 0);
16
+ held.push({
17
+ ask,
18
+ resolve,
19
+ reject
20
+ });
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) parts.push(part);
38
+ return parts;
39
+ }
40
+
41
+ //# sourceMappingURL=gather.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/gather.ts"],"sourcesContent":["type Held<A, R> = {\n ask: A;\n resolve: (answer: R) => void;\n reject: (reason: unknown) => void;\n};\n\nexport function gathered<A, R>(\n send: (asks: readonly A[]) => Promise<readonly R[]>,\n): (ask: A) => Promise<R> {\n let held: Held<A, R>[] = [];\n\n function flush() {\n const taken = held;\n held = [];\n send(taken.map((entry) => entry.ask)).then(\n (answers) => {\n taken.forEach((entry, index) => {\n entry.resolve(answers[index] as R);\n });\n },\n (reason: unknown) => {\n for (const entry of taken) entry.reject(reason);\n },\n );\n }\n\n return (ask) =>\n new Promise<R>((resolve, reject) => {\n if (held.length === 0) setTimeout(flush, 0);\n held.push({ ask, resolve, reject });\n });\n}\n\nexport function selections<T>(\n items: readonly T[],\n weight: (item: T) => number,\n limit: number,\n): readonly (readonly T[])[] {\n const parts: T[][] = [];\n let part: T[] = [];\n let carried = 0;\n for (const item of items) {\n const weighed = weight(item);\n if (part.length > 0 && carried + weighed > limit) {\n parts.push(part);\n part = [];\n carried = 0;\n }\n part.push(item);\n carried += weighed;\n }\n if (part.length > 0) parts.push(part);\n return parts;\n}\n"],"names":["gathered","send","held","flush","taken","map","entry","ask","then","answers","forEach","index","resolve","reason","reject","Promise","length","setTimeout","push","selections","items","weight","limit","parts","part","carried","item","weighed"],"mappings":"AAMA,OAAO,SAASA,SACdC,IAAmD;IAEnD,IAAIC,OAAqB,EAAE;IAE3B,SAASC;QACP,MAAMC,QAAQF;QACdA,OAAO,EAAE;QACTD,KAAKG,MAAMC,GAAG,CAAC,CAACC,QAAUA,MAAMC,GAAG,GAAGC,IAAI,CACxC,CAACC;YACCL,MAAMM,OAAO,CAAC,CAACJ,OAAOK;gBACpBL,MAAMM,OAAO,CAACH,OAAO,CAACE,MAAM;YAC9B;QACF,GACA,CAACE;YACC,KAAK,MAAMP,SAASF,MAAOE,MAAMQ,MAAM,CAACD;QAC1C;IAEJ;IAEA,OAAO,CAACN,MACN,IAAIQ,QAAW,CAACH,SAASE;YACvB,IAAIZ,KAAKc,MAAM,KAAK,GAAGC,WAAWd,OAAO;YACzCD,KAAKgB,IAAI,CAAC;gBAAEX;gBAAKK;gBAASE;YAAO;QACnC;AACJ;AAEA,OAAO,SAASK,WACdC,KAAmB,EACnBC,MAA2B,EAC3BC,KAAa;IAEb,MAAMC,QAAe,EAAE;IACvB,IAAIC,OAAY,EAAE;IAClB,IAAIC,UAAU;IACd,KAAK,MAAMC,QAAQN,MAAO;QACxB,MAAMO,UAAUN,OAAOK;QACvB,IAAIF,KAAKR,MAAM,GAAG,KAAKS,UAAUE,UAAUL,OAAO;YAChDC,MAAML,IAAI,CAACM;YACXA,OAAO,EAAE;YACTC,UAAU;QACZ;QACAD,KAAKN,IAAI,CAACQ;QACVD,WAAWE;IACb;IACA,IAAIH,KAAKR,MAAM,GAAG,GAAGO,MAAML,IAAI,CAACM;IAChC,OAAOD;AACT"}
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, HouseByteAnswer, HouseByteTransfer, HouseDoorAnswer, HouseStream, 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,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,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 HouseByteAnswer,\n HouseByteTransfer,\n HouseDoorAnswer,\n HouseStream,\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,11 @@
1
+ import type { HouseScope, HouseView } from './read.js';
2
+ import type { StreamedAdvancement } from './stream.js';
3
+ export type RoomLinks = {
4
+ roomVersion: string;
5
+ handed: ReadonlySet<string>;
6
+ paths: ReadonlyMap<string, ReadonlySet<string>>;
7
+ };
8
+ export declare function scopeLinks(scope: HouseScope): RoomLinks;
9
+ export declare function enumeratedLinks(view: HouseView, earlier: RoomLinks | undefined): RoomLinks;
10
+ export declare function streamedLinks(held: RoomLinks, advanced: StreamedAdvancement): RoomLinks | null;
11
+ //# sourceMappingURL=links.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOvD,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5B,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;CACjD,CAAC;AAYF,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAMvD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAM1F;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,GAAG,SAAS,GAAG,IAAI,CAkB9F"}
package/dist/links.js ADDED
@@ -0,0 +1,57 @@
1
+ import { roomVersion } from './version.js';
2
+ const ATTACHMENT_REFERENCE = /at_[1-9a-hjkmnp-tv-z][0-9a-hjkmnp-tv-z]*\.[0-9a-hjkmnp-tv-z]/g;
3
+ const NONE = new Set();
4
+ function linkedBy(text) {
5
+ if (text === null) return NONE;
6
+ const references = new Set(Array.from(text.matchAll(ATTACHMENT_REFERENCE), ([found])=>found));
7
+ return references.size === 0 ? NONE : references;
8
+ }
9
+ function handedOf(attachments) {
10
+ return new Set((attachments ?? []).map((attachment)=>attachment.reference));
11
+ }
12
+ export function scopeLinks(scope) {
13
+ return {
14
+ roomVersion: roomVersion(scope),
15
+ handed: handedOf(scope.attachments),
16
+ paths: new Map(scope.contents.map(({ path, content })=>[
17
+ path,
18
+ linkedBy(content)
19
+ ]))
20
+ };
21
+ }
22
+ export function enumeratedLinks(view, earlier) {
23
+ const paths = new Map(earlier?.paths);
24
+ for (const change of view.changes){
25
+ paths.set(change.path, linkedBy('content' in change ? change.content : null));
26
+ }
27
+ return {
28
+ roomVersion: roomVersion(view),
29
+ handed: handedOf(view.attachments),
30
+ paths
31
+ };
32
+ }
33
+ export function streamedLinks(held, advanced) {
34
+ const paths = new Map(held.paths);
35
+ const dropped = new Set();
36
+ for (const entry of advanced.entries){
37
+ const text = entry.kind === 'removed' ? null : entry.text;
38
+ if (text === undefined) return null;
39
+ const linked = linkedBy(text);
40
+ for (const reference of linked)if (!held.handed.has(reference)) return null;
41
+ for (const reference of paths.get(entry.path) ?? held.handed){
42
+ if (held.handed.has(reference) && !linked.has(reference)) dropped.add(reference);
43
+ }
44
+ paths.set(entry.path, linked);
45
+ }
46
+ for (const references of paths.values()){
47
+ for (const reference of references)dropped.delete(reference);
48
+ }
49
+ if (dropped.size > 0) return null;
50
+ return {
51
+ roomVersion: advanced.page.roomVersion,
52
+ handed: held.handed,
53
+ paths
54
+ };
55
+ }
56
+
57
+ //# sourceMappingURL=links.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/links.ts"],"sourcesContent":["import type { RoomAttachment } from '@agentshouse/mdruntime';\nimport type { HouseScope, HouseView } from './read.js';\nimport type { StreamedAdvancement } from './stream.js';\nimport { roomVersion } from './version.js';\n\nconst ATTACHMENT_REFERENCE = /at_[1-9a-hjkmnp-tv-z][0-9a-hjkmnp-tv-z]*\\.[0-9a-hjkmnp-tv-z]/g;\n\nconst NONE: ReadonlySet<string> = new Set();\n\nexport type RoomLinks = {\n roomVersion: string;\n handed: ReadonlySet<string>;\n paths: ReadonlyMap<string, ReadonlySet<string>>;\n};\n\nfunction linkedBy(text: string | null): ReadonlySet<string> {\n if (text === null) return NONE;\n const references = new Set(Array.from(text.matchAll(ATTACHMENT_REFERENCE), ([found]) => found));\n return references.size === 0 ? NONE : references;\n}\n\nfunction handedOf(attachments: readonly RoomAttachment[] | undefined): ReadonlySet<string> {\n return new Set((attachments ?? []).map((attachment) => attachment.reference));\n}\n\nexport function scopeLinks(scope: HouseScope): RoomLinks {\n return {\n roomVersion: roomVersion(scope),\n handed: handedOf(scope.attachments),\n paths: new Map(scope.contents.map(({ path, content }) => [path, linkedBy(content)])),\n };\n}\n\nexport function enumeratedLinks(view: HouseView, earlier: RoomLinks | undefined): RoomLinks {\n const paths = new Map(earlier?.paths);\n for (const change of view.changes) {\n paths.set(change.path, linkedBy('content' in change ? change.content : null));\n }\n return { roomVersion: roomVersion(view), handed: handedOf(view.attachments), paths };\n}\n\nexport function streamedLinks(held: RoomLinks, advanced: StreamedAdvancement): RoomLinks | null {\n const paths = new Map(held.paths);\n const dropped = new Set<string>();\n for (const entry of advanced.entries) {\n const text = entry.kind === 'removed' ? null : entry.text;\n if (text === undefined) return null;\n const linked = linkedBy(text);\n for (const reference of linked) if (!held.handed.has(reference)) return null;\n for (const reference of paths.get(entry.path) ?? held.handed) {\n if (held.handed.has(reference) && !linked.has(reference)) dropped.add(reference);\n }\n paths.set(entry.path, linked);\n }\n for (const references of paths.values()) {\n for (const reference of references) dropped.delete(reference);\n }\n if (dropped.size > 0) return null;\n return { roomVersion: advanced.page.roomVersion, handed: held.handed, paths };\n}\n"],"names":["roomVersion","ATTACHMENT_REFERENCE","NONE","Set","linkedBy","text","references","Array","from","matchAll","found","size","handedOf","attachments","map","attachment","reference","scopeLinks","scope","handed","paths","Map","contents","path","content","enumeratedLinks","view","earlier","change","changes","set","streamedLinks","held","advanced","dropped","entry","entries","kind","undefined","linked","has","get","add","values","delete","page"],"mappings":"AAGA,SAASA,WAAW,QAAQ,eAAe;AAE3C,MAAMC,uBAAuB;AAE7B,MAAMC,OAA4B,IAAIC;AAQtC,SAASC,SAASC,IAAmB;IACnC,IAAIA,SAAS,MAAM,OAAOH;IAC1B,MAAMI,aAAa,IAAIH,IAAII,MAAMC,IAAI,CAACH,KAAKI,QAAQ,CAACR,uBAAuB,CAAC,CAACS,MAAM,GAAKA;IACxF,OAAOJ,WAAWK,IAAI,KAAK,IAAIT,OAAOI;AACxC;AAEA,SAASM,SAASC,WAAkD;IAClE,OAAO,IAAIV,IAAI,AAACU,CAAAA,eAAe,EAAE,AAAD,EAAGC,GAAG,CAAC,CAACC,aAAeA,WAAWC,SAAS;AAC7E;AAEA,OAAO,SAASC,WAAWC,KAAiB;IAC1C,OAAO;QACLlB,aAAaA,YAAYkB;QACzBC,QAAQP,SAASM,MAAML,WAAW;QAClCO,OAAO,IAAIC,IAAIH,MAAMI,QAAQ,CAACR,GAAG,CAAC,CAAC,EAAES,IAA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I,CAAC7C,WAAW;QAAEmB,QAAQa,KAAKb,MAAM;QAAEC;IAAM;AAC9E"}
package/dist/map.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare function roomLocalPath(path: string, handle?: string): string;
2
- export declare function nativePath(path: string, handle?: string): string;
1
+ export declare function roomLocalPath(path: string, handle: string): string;
2
+ export declare function nativePath(path: string, handle: string): string;
3
3
  //# sourceMappingURL=map.d.ts.map
package/dist/map.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAUnE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAIhE"}
1
+ {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAUlE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAG/D"}
package/dist/map.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export function roomLocalPath(path, handle) {
2
- const prefix = handle === undefined ? '/private/' : `/rooms/${handle}/`;
2
+ const prefix = `/rooms/${handle}/`;
3
3
  const local = path.startsWith(prefix) ? path.slice(prefix.length) : path;
4
4
  if (local === '' || local.split('/').some((part)=>part === '' || part === '.' || part === '..')) {
5
5
  throw new Error('invalid authority-relative path');
@@ -8,8 +8,7 @@ export function roomLocalPath(path, handle) {
8
8
  }
9
9
  export function nativePath(path, handle) {
10
10
  if (path.startsWith('/')) throw new Error('canonical Room path required');
11
- const local = roomLocalPath(path);
12
- return handle === undefined ? `/private/${local}` : `/rooms/${handle}/${local}`;
11
+ return `/rooms/${handle}/${roomLocalPath(path, handle)}`;
13
12
  }
14
13
 
15
14
  //# sourceMappingURL=map.js.map
package/dist/map.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/map.ts"],"sourcesContent":["export function roomLocalPath(path: string, handle?: string): string {\n const prefix = handle === undefined ? '/private/' : `/rooms/${handle}/`;\n const local = path.startsWith(prefix) ? path.slice(prefix.length) : path;\n if (\n local === '' ||\n local.split('/').some((part) => part === '' || part === '.' || part === '..')\n ) {\n throw new Error('invalid authority-relative path');\n }\n return local;\n}\n\nexport function nativePath(path: string, handle?: string): string {\n if (path.startsWith('/')) throw new Error('canonical Room path required');\n const local = roomLocalPath(path);\n return handle === undefined ? `/private/${local}` : `/rooms/${handle}/${local}`;\n}\n"],"names":["roomLocalPath","path","handle","prefix","undefined","local","startsWith","slice","length","split","some","part","Error","nativePath"],"mappings":"AAAA,OAAO,SAASA,cAAcC,IAAY,EAAEC,MAAe;IACzD,MAAMC,SAASD,WAAWE,YAAY,cAAc,CAAC,OAAO,EAAEF,OAAO,CAAC,CAAC;IACvE,MAAMG,QAAQJ,KAAKK,UAAU,CAACH,UAAUF,KAAKM,KAAK,CAACJ,OAAOK,MAAM,IAAIP;IACpE,IACEI,UAAU,MACVA,MAAMI,KAAK,CAAC,KAAKC,IAAI,CAAC,CAACC,OAASA,SAAS,MAAMA,SAAS,OAAOA,SAAS,OACxE;QACA,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOP;AACT;AAEA,OAAO,SAASQ,WAAWZ,IAAY,EAAEC,MAAe;IACtD,IAAID,KAAKK,UAAU,CAAC,MAAM,MAAM,IAAIM,MAAM;IAC1C,MAAMP,QAAQL,cAAcC;IAC5B,OAAOC,WAAWE,YAAY,CAAC,SAAS,EAAEC,OAAO,GAAG,CAAC,OAAO,EAAEH,OAAO,CAAC,EAAEG,OAAO;AACjF"}
1
+ {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/map.ts"],"sourcesContent":["export function roomLocalPath(path: string, handle: string): string {\n const prefix = `/rooms/${handle}/`;\n const local = path.startsWith(prefix) ? path.slice(prefix.length) : path;\n if (\n local === '' ||\n local.split('/').some((part) => part === '' || part === '.' || part === '..')\n ) {\n throw new Error('invalid authority-relative path');\n }\n return local;\n}\n\nexport function nativePath(path: string, handle: string): string {\n if (path.startsWith('/')) throw new Error('canonical Room path required');\n return `/rooms/${handle}/${roomLocalPath(path, handle)}`;\n}\n"],"names":["roomLocalPath","path","handle","prefix","local","startsWith","slice","length","split","some","part","Error","nativePath"],"mappings":"AAAA,OAAO,SAASA,cAAcC,IAAY,EAAEC,MAAc;IACxD,MAAMC,SAAS,CAAC,OAAO,EAAED,OAAO,CAAC,CAAC;IAClC,MAAME,QAAQH,KAAKI,UAAU,CAACF,UAAUF,KAAKK,KAAK,CAACH,OAAOI,MAAM,IAAIN;IACpE,IACEG,UAAU,MACVA,MAAMI,KAAK,CAAC,KAAKC,IAAI,CAAC,CAACC,OAASA,SAAS,MAAMA,SAAS,OAAOA,SAAS,OACxE;QACA,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOP;AACT;AAEA,OAAO,SAASQ,WAAWX,IAAY,EAAEC,MAAc;IACrD,IAAID,KAAKI,UAAU,CAAC,MAAM,MAAM,IAAIM,MAAM;IAC1C,OAAO,CAAC,OAAO,EAAET,OAAO,CAAC,EAAEF,cAAcC,MAAMC,SAAS;AAC1D"}
@@ -0,0 +1,19 @@
1
+ import type { AdapterFailure, ModelIdentity, ModelRequest, ModelResult } from '@agentshouse/mdruntime';
2
+ import type { HouseSchema } 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: HouseSchema | 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,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,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,WAAW,GAAG,IAAI,EACxB,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.version));
24
+ return {
25
+ snapshot: {
26
+ kind: 'model',
27
+ snapshot: {
28
+ identity,
29
+ version,
30
+ schema: read.schema
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 { HouseSchema } 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: HouseSchema | 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.version));\n return {\n snapshot: { kind: 'model', snapshot: { identity, version, schema: read.schema } },\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","schema","modelShelf","models","Map","retain","key","acquired","undefined","get","previous","set","answer","request","keep","locators","keys","some","startsWith","delete"],"mappings":"AAMA,SAASA,SAAS,QAAQ,cAAc;A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Oa,IAAI;aAAG,CAAE;gBACpC,IAAI,CAACD,SAASE,IAAI,CAAC,CAACzB,UAAYc,IAAIY,UAAU,CAAC,GAAG1B,QAAQ,CAAC,CAAC,IAAIW,OAAOgB,MAAM,CAACb;YAChF;QACF;IACF;AACF"}
package/dist/read.d.ts CHANGED
@@ -1,26 +1,32 @@
1
- import type { BootstrapResult, RefreshResult } from '@agentshouse/mdruntime';
1
+ import type { BootstrapPage, RefreshResult, RoomAttachment } from '@agentshouse/mdruntime';
2
2
  import { type TrackedAuthority } from './discovery.js';
3
+ import type { HouseMode } from './transport.js';
4
+ import { type LogPosition } from './version.js';
5
+ export type HeadChange = BootstrapPage['changes'][string];
3
6
  export type HouseManifestFile = {
4
7
  path: string;
5
- revision: string;
8
+ revision: string | undefined;
9
+ version: string;
10
+ head?: HeadChange;
6
11
  };
7
12
  export type HouseContent = {
8
13
  path: string;
9
14
  content: string;
10
15
  };
11
- export type HouseScope = {
12
- scope: 'room' | 'private';
16
+ export type HouseScope = LogPosition & {
13
17
  anchor: string;
14
- roomHandle: string | undefined;
15
- position: string;
16
18
  files: readonly HouseManifestFile[];
17
19
  contents: readonly HouseContent[];
20
+ attachments?: readonly RoomAttachment[];
18
21
  };
19
22
  export type HouseEnvelope = {
20
23
  scopes: readonly HouseScope[];
21
24
  };
22
25
  export type HouseGrant = {
23
- method: 'GET' | 'POST';
26
+ method: 'GET';
27
+ url: string;
28
+ } | {
29
+ method: 'POST';
24
30
  operation: string;
25
31
  url: string;
26
32
  };
@@ -30,38 +36,44 @@ export type HouseChange = {
30
36
  } | {
31
37
  path: string;
32
38
  content: string;
33
- revision: string;
39
+ revision: string | undefined;
40
+ version: string;
41
+ head?: HeadChange;
34
42
  } | {
35
43
  path: string;
36
44
  reference: {
37
45
  revision: string;
38
46
  };
39
47
  };
48
+ export type HouseView = LogPosition & {
49
+ authority: string;
50
+ changes: readonly HouseChange[];
51
+ attachments?: readonly RoomAttachment[];
52
+ };
40
53
  export type HouseEnumeration = {
41
- authorities: readonly {
42
- authority: string;
43
- position: string;
44
- changes: readonly HouseChange[];
45
- }[];
54
+ authorities: readonly HouseView[];
46
55
  };
47
- export declare function authorityRoot(handle: string | undefined): string;
48
- export declare const ROOM_README = "ROOM.md";
49
- export declare function selectionRoots(tracked: TrackedAuthority): readonly string[];
56
+ export declare function authorityRoot(handle: string): string;
50
57
  export declare function contentPrefixes(tracked: TrackedAuthority): readonly string[];
51
- export declare function modelPrefix(tracked: TrackedAuthority, modelRoot: string): string;
58
+ export declare function schemaPath(handle: string, schema: string): string;
52
59
  export declare function parseGrant(body: unknown): HouseGrant | null;
60
+ export declare function headChange(held: {
61
+ readonly author?: unknown;
62
+ readonly created_at?: unknown;
63
+ }): HeadChange | undefined | null;
53
64
  export declare function parseEnvelope(body: unknown): HouseEnvelope | null;
54
- export declare function parseEnumeration(body: unknown): HouseEnumeration | null;
65
+ export declare function parseSiteBootstrap(body: unknown): HouseScope | null;
66
+ export declare function parseEnumeration(body: unknown, mode: HouseMode): HouseEnumeration | null;
67
+ export declare function advancedScope(scope: HouseScope, view: HouseView): HouseScope;
55
68
  export declare function matchesScope(scope: HouseScope, tracked: TrackedAuthority): boolean;
56
- export declare function withinRoot(path: string, root: string): boolean;
57
69
  export declare function selects(tracked: TrackedAuthority, path: string): boolean;
58
- export declare function bootstrapFrom(envelope: HouseEnvelope, tracked: TrackedAuthority): BootstrapResult;
59
- export type HouseDefinitions = {
60
- definitions: Readonly<Record<string, string>>;
61
- revisions: readonly string[];
70
+ export declare function bootstrapOf(scope: HouseScope, tracked: TrackedAuthority): BootstrapPage;
71
+ export type HouseSchema = {
72
+ schema: string | null;
73
+ version: string | null;
62
74
  };
63
- export declare const MODEL_DEFINITION_ADDRESS = "types";
64
- export declare function definitionAddress(path: string): string;
65
- export declare function definitionsFrom(envelope: HouseEnvelope, tracked: TrackedAuthority, modelRoot: string): HouseDefinitions | null;
66
- export declare function refreshFrom(enumeration: HouseEnumeration, tracked: TrackedAuthority, fromRoomVersion: string): RefreshResult;
75
+ export declare function schemaFrom(envelope: HouseEnvelope, tracked: TrackedAuthority, schema: string): HouseSchema | null;
76
+ export declare function schemaOf(scope: HouseScope, schema: string): HouseSchema | null;
77
+ export declare function viewOf(enumeration: HouseEnumeration, tracked: TrackedAuthority): HouseView | undefined;
78
+ export declare function refreshFrom(view: HouseView, tracked: TrackedAuthority, fromRoomVersion: string): RefreshResult;
67
79
  //# 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,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,WAAW,GACn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