@agentshouse/mdruntime-adapter 0.1.0-alpha.47 → 0.1.0-alpha.49

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.
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,OAAO,EACP,aAAa,EAad,MAAM,wBAAwB,CAAC;AAqChC,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAuBxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAmCjC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAsYpF"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,OAAO,EACP,aAAa,EAad,MAAM,wBAAwB,CAAC;AA0ChC,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAuBxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAiCjC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA4YpF"}
package/dist/adapter.js CHANGED
@@ -2,7 +2,8 @@ import { DISCOVER_PREFIXES, HOUSE_SCHEMA, capabilities, discoveredRoom, locatorO
2
2
  import { MODEL_ABSENT, failedModel, heldModel, modelKey, modelShelf } from './model.js';
3
3
  import { gathered, selections } from './gather.js';
4
4
  import { createSiteAdapter } from './site.js';
5
- import { bootstrapFrom, contentPrefixes, parseEnumeration, parseEnvelope, parseGrant, refreshFrom, schemaFrom, schemaPath } from './read.js';
5
+ import { bootstrapOf, contentPrefixes, matchesScope, parseEnumeration, parseEnvelope, parseGrant, refreshFrom, schemaFrom, schemaPath, viewOf } from './read.js';
6
+ import { enumeratedLinks, scopeLinks, streamedLinks } from './links.js';
6
7
  import { houseAction } from './actions.js';
7
8
  import { classifyDoor, discoveryFailure, doorRefusal } from './refusal.js';
8
9
  import { houseNotifications } from './stream.js';
@@ -15,7 +16,6 @@ const UNCERTAIN = {
15
16
  const UNCERTAIN_READ = {
16
17
  kind: 'transport-uncertainty'
17
18
  };
18
- const NO_ATTACHMENTS = new Set();
19
19
  function lapsedGrant(outcome) {
20
20
  return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';
21
21
  }
@@ -34,23 +34,43 @@ export function createAgentsHouseAdapter(options) {
34
34
  const tracked = new Map();
35
35
  const handed = new Map();
36
36
  const models = modelShelf();
37
- function handing(entry, answer) {
38
- if ((answer.kind === 'bootstrap' || answer.kind === 'net-advancement') && answer.attachments !== undefined) {
39
- handed.set(entry.locator, new Set(answer.attachments.map((attachment)=>attachment.reference)));
37
+ function bootstrappedRoom(envelope, entry) {
38
+ const scope = envelope.scopes.find((candidate)=>matchesScope(candidate, entry));
39
+ if (scope === undefined) return {
40
+ kind: 'room-not-readable',
41
+ locator: entry.locator
42
+ };
43
+ handed.set(entry.locator, scopeLinks(scope));
44
+ return bootstrapOf(scope, entry);
45
+ }
46
+ function enumeratedRoom(enumeration, ask) {
47
+ const view = viewOf(enumeration, ask.entry);
48
+ if (view === undefined) return {
49
+ kind: 'room-not-readable',
50
+ locator: ask.entry.locator
51
+ };
52
+ const answer = refreshFrom(view, ask.entry, ask.fromRoomVersion);
53
+ if (answer.kind === 'net-advancement') {
54
+ handed.set(ask.entry.locator, enumeratedLinks(view, handed.get(ask.entry.locator)));
40
55
  }
41
56
  return answer;
42
57
  }
58
+ function streamed(entry, request, from) {
59
+ const links = handed.get(entry.locator);
60
+ if (links?.roomVersion !== request.fromRoomVersion) return null;
61
+ const advanced = notifications.advance(entry, from);
62
+ if (advanced === null) return null;
63
+ if (request.minPosition !== undefined && !reachedVersion(advanced.page.roomVersion, request.minPosition, entry.logEpoch)) return null;
64
+ const relinked = streamedLinks(links, advanced);
65
+ if (relinked === null) return null;
66
+ handed.set(entry.locator, relinked);
67
+ return advanced.page;
68
+ }
43
69
  function held(envelope, entry, schema, failure) {
44
70
  return heldModel(envelope === null ? null : schemaFrom(envelope, entry, schema), schemaPath(entry.handle, schema), failure);
45
71
  }
46
72
  function modelPrefixes(entry) {
47
- const own = schemaPath(entry.handle, entry.schema);
48
- return entry.locator === PRIVATE_LOCATOR ? [
49
- own,
50
- schemaPath(undefined, HOUSE_SCHEMA)
51
- ] : [
52
- own
53
- ];
73
+ return entry.schemas.map((schema)=>schemaPath(entry.handle, schema));
54
74
  }
55
75
  async function acquireModels(entries) {
56
76
  const acquired = new Map();
@@ -75,7 +95,7 @@ export function createAgentsHouseAdapter(options) {
75
95
  const locator = locatorOf(authority);
76
96
  const key = modelKey(locator, 'collection');
77
97
  const collection = models.retain(key, acquired.get(key));
78
- if (authority.roomHandle !== null) {
98
+ if (locator !== PRIVATE_LOCATOR) {
79
99
  return discoveredRoom(authority, collection?.identity ?? null, undefined);
80
100
  }
81
101
  const selection = models.retain(modelKey(locator, 'typed-selection'), acquired.get(modelKey(locator, 'typed-selection')));
@@ -131,7 +151,7 @@ export function createAgentsHouseAdapter(options) {
131
151
  part.forEach((entry, index)=>{
132
152
  const failure = classified[index];
133
153
  if (failure === null || failure === undefined) {
134
- answers.push(envelope === null ? UNCERTAIN_READ : bootstrapFrom(envelope, entry));
154
+ answers.push(envelope === null ? UNCERTAIN_READ : bootstrappedRoom(envelope, entry));
135
155
  return;
136
156
  }
137
157
  answers.push(failure.kind === 'beyond-horizon' ? UNCERTAIN_READ : failure);
@@ -196,7 +216,7 @@ export function createAgentsHouseAdapter(options) {
196
216
  answers.set(ask, failure);
197
217
  return;
198
218
  }
199
- answers.set(ask, enumeration === null ? UNCERTAIN_READ : refreshFrom(enumeration, ask.entry, ask.fromRoomVersion));
219
+ answers.set(ask, enumeration === null ? UNCERTAIN_READ : enumeratedRoom(enumeration, ask));
200
220
  });
201
221
  open = [];
202
222
  }
@@ -309,7 +329,7 @@ export function createAgentsHouseAdapter(options) {
309
329
  if (request.pageToken !== undefined) return {
310
330
  kind: 'transport-uncertainty'
311
331
  };
312
- return handing(entry, await bootstrapTogether(entry));
332
+ return bootstrapTogether(entry);
313
333
  },
314
334
  async refresh (_authorization, request) {
315
335
  const entry = authorityFor(request.locator);
@@ -324,17 +344,17 @@ export function createAgentsHouseAdapter(options) {
324
344
  if (from === null) return {
325
345
  kind: 'beyond-horizon'
326
346
  };
327
- const streamed = notifications.advance(entry, from, handed.get(entry.locator) ?? NO_ATTACHMENTS);
328
- if (streamed !== null && (request.minPosition === undefined || reachedVersion(streamed.roomVersion, request.minPosition, entry.logEpoch))) return streamed;
347
+ const answered = streamed(entry, request, from);
348
+ if (answered !== null) return answered;
329
349
  const minPosition = request.minPosition === undefined ? null : logPosition(request.minPosition);
330
- return handing(entry, await enumerateTogether({
350
+ return enumerateTogether({
331
351
  entry,
332
352
  from,
333
353
  fromRoomVersion: request.fromRoomVersion,
334
354
  ...minPosition?.logEpoch === from.logEpoch ? {
335
355
  minPosition: minPosition.position
336
356
  } : {}
337
- }));
357
+ });
338
358
  },
339
359
  async mutate (_authorization, request, keep) {
340
360
  const entry = authorityFor(request.locator);
@@ -1 +1 @@
1
- {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/adapter.ts"],"sourcesContent":["import type {\n ActionRequest,\n ActionResult,\n Adapter,\n Authorization,\n BootstrapRequest,\n BootstrapResult,\n DiscoverResult,\n DiscoveredRoom,\n HistoryRequest,\n HistoryResult,\n ModelRequest,\n ModelResult,\n MutationRequest,\n MutationResult,\n RefreshRequest,\n RefreshResult,\n} from '@agentshouse/mdruntime';\nimport {\n DISCOVER_PREFIXES,\n HOUSE_SCHEMA,\n capabilities,\n discoveredRoom,\n locatorOf,\n mapDiscovery,\n parseDiscovery,\n providerSelection,\n trackedFrom,\n type HouseAuthority,\n type TrackedAuthority,\n} from './discovery.js';\nimport {\n MODEL_ABSENT,\n failedModel,\n heldModel,\n modelKey,\n modelShelf,\n type HeldModel,\n} from './model.js';\nimport { gathered, selections } from './gather.js';\nimport { createSiteAdapter } from './site.js';\nimport {\n bootstrapFrom,\n contentPrefixes,\n parseEnumeration,\n parseEnvelope,\n parseGrant,\n refreshFrom,\n schemaFrom,\n schemaPath,\n} from './read.js';\nimport { houseAction } from './actions.js';\nimport { classifyDoor, discoveryFailure, doorRefusal } from './refusal.js';\nimport { houseNotifications } from './stream.js';\nimport {\n DOOR_BATCH,\n DOOR_BATCH_UPLOAD,\n DOOR_BOOTSTRAP,\n DOOR_DISCOVER,\n DOOR_ENUMERATE,\n DOOR_REVISIONS,\n DOOR_SELECTION_MAX,\n PRIVATE_LOCATOR,\n type HouseSiteTransport,\n type HouseTransport,\n} from './transport.js';\nimport {\n batchPaths,\n deltaBody,\n deltaBytes,\n deltaDigest,\n historyOutcome,\n houseChanges,\n mutationOutcome,\n operationHead,\n rejectedMapping,\n revisionBody,\n uploadable,\n type OperationHead,\n} from './write.js';\nimport {\n logPosition,\n presented,\n reachedVersion,\n roomVersion,\n type LogPosition,\n} from './version.js';\n\nexport type AgentsHouseAdapterOptions =\n | {\n transport: HouseTransport;\n authorize(): Promise<Authorization>;\n }\n | { site: HouseSiteTransport };\n\nconst UNCERTAIN: MutationResult = { kind: 'transport-uncertainty' };\n\nconst UNCERTAIN_READ = { kind: 'transport-uncertainty' } as const;\n\nconst NO_ATTACHMENTS: ReadonlySet<string> = new Set();\n\ntype Enumerating = {\n entry: TrackedAuthority;\n from: LogPosition;\n fromRoomVersion: string;\n minPosition?: string;\n};\n\ntype Submission = { body: Record<string, unknown> } | { outcome: MutationResult };\n\ntype Upload = { url: string; operation: string; bytes: number; sha256: string };\n\ntype Keep = (upload: unknown) => Promise<void>;\n\nfunction lapsedGrant(outcome: MutationResult): boolean {\n return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';\n}\n\nfunction modelFailure(\n classified: ReturnType<typeof classifyDoor>,\n envelope: ReturnType<typeof parseEnvelope>,\n): ModelResult {\n if (classified === null) {\n return envelope === null ? { kind: 'transport-uncertainty' } : MODEL_ABSENT;\n }\n return failedModel(classified);\n}\n\nexport function createAgentsHouseAdapter(options: AgentsHouseAdapterOptions): Adapter {\n if ('site' in options) return createSiteAdapter(options.site);\n const transport = options.transport;\n const notifications = houseNotifications(transport, 'credential');\n const tracked = new Map<string, TrackedAuthority>();\n const handed = new Map<string, ReadonlySet<string>>();\n const models = modelShelf();\n\n function handing<T extends BootstrapResult | RefreshResult>(\n entry: TrackedAuthority,\n answer: T,\n ): T {\n if (\n (answer.kind === 'bootstrap' || answer.kind === 'net-advancement') &&\n answer.attachments !== undefined\n ) {\n handed.set(\n entry.locator,\n new Set(answer.attachments.map((attachment) => attachment.reference)),\n );\n }\n return answer;\n }\n\n function held(\n envelope: ReturnType<typeof parseEnvelope>,\n entry: TrackedAuthority,\n schema: string,\n failure: ModelResult,\n ): Promise<HeldModel> {\n return heldModel(\n envelope === null ? null : schemaFrom(envelope, entry, schema),\n schemaPath(entry.handle, schema),\n failure,\n );\n }\n\n function modelPrefixes(entry: TrackedAuthority): readonly string[] {\n const own = schemaPath(entry.handle, entry.schema);\n return entry.locator === PRIVATE_LOCATOR ? [own, schemaPath(undefined, HOUSE_SCHEMA)] : [own];\n }\n\n async function acquireModels(\n entries: readonly TrackedAuthority[],\n ): Promise<Map<string, HeldModel>> {\n const acquired = new Map<string, HeldModel>();\n for (const part of selections(\n entries,\n (entry) => modelPrefixes(entry).length,\n DOOR_SELECTION_MAX,\n )) {\n const privateEntry = part.find((entry) => entry.locator === PRIVATE_LOCATOR);\n const answer = await transport.door(DOOR_BOOTSTRAP, {\n prefixes: part.flatMap((entry) => modelPrefixes(entry)),\n });\n const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);\n const envelope = classified === null ? parseEnvelope(await bundled(answer.body)) : null;\n const failure: ModelResult = modelFailure(classified, envelope);\n for (const entry of part) {\n acquired.set(\n modelKey(entry.locator, 'collection'),\n await held(envelope, entry, entry.schema, failure),\n );\n }\n if (privateEntry !== undefined) {\n acquired.set(\n modelKey(privateEntry.locator, 'typed-selection'),\n await held(envelope, privateEntry, HOUSE_SCHEMA, failure),\n );\n }\n }\n return acquired;\n }\n\n function roomOf(authority: HouseAuthority, acquired: Map<string, HeldModel>): DiscoveredRoom {\n const locator = locatorOf(authority);\n const key = modelKey(locator, 'collection');\n const collection = models.retain(key, acquired.get(key));\n if (authority.roomHandle !== null) {\n return discoveredRoom(authority, collection?.identity ?? null, undefined);\n }\n const selection = models.retain(\n modelKey(locator, 'typed-selection'),\n acquired.get(modelKey(locator, 'typed-selection')),\n );\n return discoveredRoom(\n authority,\n collection?.identity ?? null,\n providerSelection(selection?.identity ?? null),\n );\n }\n\n function authorityFor(locator: string): TrackedAuthority | undefined {\n return tracked.get(locator);\n }\n\n function withAt(result: ActionResult): ActionResult {\n if (result.kind !== 'action') return result;\n const body = result.result as Record<string, unknown> | null;\n if (typeof body !== 'object' || body === null) return result;\n const { authority, position, log_epoch: logEpoch } = body;\n if (typeof position !== 'string' || typeof logEpoch !== 'string') return result;\n const locator =\n authority === undefined\n ? PRIVATE_LOCATOR\n : [...tracked.values()].find((entry) => entry.authority === authority)?.locator;\n if (locator === undefined) return result;\n return { ...result, at: { locator, roomVersion: roomVersion({ position, logEpoch }) } };\n }\n\n async function bundled(body: unknown): Promise<unknown> {\n const grant = parseGrant(body);\n if (grant === null) return body;\n if (grant.method !== 'GET') return null;\n const answer = await transport.transfer({\n act: 'local_copy_bundle',\n method: 'GET',\n url: grant.url,\n answer: 'json',\n });\n return answer.status === 200 ? answer.body : null;\n }\n\n function weight(entry: TrackedAuthority): number {\n return contentPrefixes(entry).length;\n }\n\n async function bootstrapped(entries: readonly TrackedAuthority[]): Promise<BootstrapResult[]> {\n const answers: BootstrapResult[] = [];\n for (const part of selections(entries, weight, DOOR_SELECTION_MAX)) {\n const answer = await transport.door(DOOR_BOOTSTRAP, {\n prefixes: part.flatMap((entry) => contentPrefixes(entry)),\n });\n const classified = part.map((entry) =>\n classifyDoor(answer.status, answer.body, entry.locator),\n );\n const envelope = classified[0] === null ? parseEnvelope(await bundled(answer.body)) : null;\n part.forEach((entry, index) => {\n const failure = classified[index];\n if (failure === null || failure === undefined) {\n answers.push(envelope === null ? UNCERTAIN_READ : bootstrapFrom(envelope, entry));\n return;\n }\n answers.push(failure.kind === 'beyond-horizon' ? UNCERTAIN_READ : failure);\n });\n }\n return answers;\n }\n\n function layered(asks: readonly Enumerating[]): readonly (readonly Enumerating[])[] {\n const depths = new Map<string, number>();\n const layers: Enumerating[][] = [];\n for (const ask of asks) {\n const depth = depths.get(ask.entry.authority) ?? 0;\n depths.set(ask.entry.authority, depth + 1);\n (layers[depth] ??= []).push(ask);\n }\n return layers;\n }\n\n async function enumerated(asks: readonly Enumerating[]): Promise<RefreshResult[]> {\n const answers = new Map<Enumerating, RefreshResult>();\n const parts = layered(asks).flatMap((layer) =>\n selections(layer, (ask) => weight(ask.entry), DOOR_SELECTION_MAX),\n );\n for (const part of parts) {\n let open = [...part];\n while (open.length > 0) {\n const answer = await transport.door(DOOR_ENUMERATE, {\n prefixes: open.flatMap((ask) => contentPrefixes(ask.entry)),\n positions: open.map((ask) => ({\n ...presented(ask.entry.authority, ask.from),\n ...(ask.minPosition === undefined ? {} : { min_position: ask.minPosition }),\n })),\n });\n const refusal = doorRefusal(answer.body);\n if (refusal?.code === 'replica_behind') {\n const named = open.filter((ask) => ask.entry.authority === refusal.fields.authority);\n const behind = named.length === 0 ? open : named;\n for (const ask of behind) answers.set(ask, { kind: 'retryable-refusal', ...refusal });\n open = open.filter((ask) => !behind.includes(ask));\n continue;\n }\n const classified = open.map((ask) =>\n classifyDoor(answer.status, answer.body, ask.entry.locator),\n );\n if (classified[0]?.kind === 'beyond-horizon') {\n const named = doorRefusal(answer.body)?.fields.authority;\n const expired = open.filter((ask) => ask.entry.authority === named);\n const answered: RefreshResult =\n expired.length === 0 ? UNCERTAIN_READ : { kind: 'beyond-horizon' };\n const gone = expired.length === 0 ? open : expired;\n for (const ask of gone) answers.set(ask, answered);\n open = open.filter((ask) => !gone.includes(ask));\n continue;\n }\n const enumeration =\n classified[0] === null ? parseEnumeration(answer.body, 'credential') : null;\n open.forEach((ask, index) => {\n const failure = classified[index];\n if (failure !== null && failure !== undefined) {\n answers.set(ask, failure);\n return;\n }\n answers.set(\n ask,\n enumeration === null\n ? UNCERTAIN_READ\n : refreshFrom(enumeration, ask.entry, ask.fromRoomVersion),\n );\n });\n open = [];\n }\n }\n return asks.map((ask) => answers.get(ask) ?? UNCERTAIN_READ);\n }\n\n const bootstrapTogether = gathered(bootstrapped);\n\n const enumerateTogether = gathered(enumerated);\n\n async function uploaded(\n head: OperationHead,\n changes: readonly Readonly<Record<string, unknown>>[],\n delta: string,\n bytes: number,\n entry: TrackedAuthority,\n handed: Upload | undefined,\n keep: Keep,\n ): Promise<Submission> {\n const paths = batchPaths(changes);\n const sha256 = await deltaDigest(delta);\n if (handed !== undefined && handed.sha256 === sha256) {\n return { body: { ...head, paths, upload: handed } };\n }\n const minted = await transport.door(DOOR_BATCH_UPLOAD, { ...head, paths, bytes, sha256 });\n if (minted.status !== 200) {\n return { outcome: mutationOutcome(minted.status, minted.body, entry.locator, entry.handle) };\n }\n const grant = parseGrant(minted.body);\n if (grant === null || grant.method !== 'POST') return { outcome: UNCERTAIN };\n const delivered = await transport.transfer({\n act: 'authored_batch_upload',\n method: 'POST',\n url: grant.url,\n answer: 'json',\n body: `${grant.operation}\\n${delta}`,\n });\n if (delivered.status !== 200) return { outcome: UNCERTAIN };\n const holding = parseGrant(delivered.body);\n if (holding === null || holding.method !== 'POST') return { outcome: UNCERTAIN };\n const upload: Upload = { url: holding.url, operation: holding.operation, bytes, sha256 };\n await keep(upload);\n return { body: { ...head, paths, upload } };\n }\n\n async function submit(\n head: OperationHead,\n changes: readonly Readonly<Record<string, unknown>>[],\n delta: string,\n bytes: number,\n entry: TrackedAuthority,\n handed: Upload | undefined,\n keep: Keep,\n ): Promise<MutationResult> {\n const prepared: Submission = uploadable(bytes)\n ? await uploaded(head, changes, delta, bytes, entry, handed, keep)\n : { body: { ...head, changes } };\n if ('outcome' in prepared) return prepared.outcome;\n const answer = await transport.door(DOOR_BATCH, prepared.body);\n return mutationOutcome(answer.status, answer.body, entry.locator, entry.handle);\n }\n\n return {\n async authorize() {\n return options.authorize();\n },\n\n async model(_authorization: Authorization, request: ModelRequest): Promise<ModelResult> {\n return models.answer(request);\n },\n\n async discover(_authorization: Authorization): Promise<DiscoverResult> {\n const answer = await transport.door(DOOR_DISCOVER, { prefixes: [...DISCOVER_PREFIXES] });\n const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);\n if (classified !== null) return discoveryFailure(classified);\n const document = parseDiscovery(answer.body);\n if (document === null) return { kind: 'transport-uncertainty' };\n const entries = trackedFrom(document);\n tracked.clear();\n for (const entry of entries) tracked.set(entry.locator, entry);\n for (const locator of handed.keys()) if (!tracked.has(locator)) handed.delete(locator);\n notifications.track(entries);\n const acquired = await acquireModels(entries);\n models.keep(entries.map((entry) => entry.locator));\n return mapDiscovery(\n document,\n document.authorities.map((authority) => roomOf(authority, acquired)),\n capabilities(document.actions),\n );\n },\n\n async bootstrap(\n _authorization: Authorization,\n request: BootstrapRequest,\n ): Promise<BootstrapResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return { kind: 'transport-uncertainty' };\n return handing(entry, await bootstrapTogether(entry));\n },\n\n async refresh(_authorization: Authorization, request: RefreshRequest): Promise<RefreshResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return { kind: 'transport-uncertainty' };\n const from = logPosition(request.fromRoomVersion);\n if (from === null) return { kind: 'beyond-horizon' };\n const streamed = notifications.advance(\n entry,\n from,\n handed.get(entry.locator) ?? NO_ATTACHMENTS,\n );\n if (\n streamed !== null &&\n (request.minPosition === undefined ||\n reachedVersion(streamed.roomVersion, request.minPosition, entry.logEpoch))\n )\n return streamed;\n const minPosition =\n request.minPosition === undefined ? null : logPosition(request.minPosition);\n return handing(\n entry,\n await enumerateTogether({\n entry,\n from,\n fromRoomVersion: request.fromRoomVersion,\n ...(minPosition?.logEpoch === from.logEpoch ? { minPosition: minPosition.position } : {}),\n }),\n );\n },\n\n async mutate(\n _authorization: Authorization,\n request: MutationRequest,\n keep: Keep,\n ): Promise<MutationResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n const mapped = houseChanges(request.changeBatch, entry.handle);\n if (mapped.kind === 'unmapped') return rejectedMapping(mapped);\n const head = operationHead(request.changeBatch);\n const delta = deltaBody(mapped.changes);\n const bytes = deltaBytes(delta);\n const handed = request.upload as Upload | undefined;\n const outcome = await submit(head, mapped.changes, delta, bytes, entry, handed, keep);\n if (handed === undefined || !lapsedGrant(outcome)) return outcome;\n return submit(head, mapped.changes, delta, bytes, entry, undefined, keep);\n },\n\n async history(_authorization: Authorization, request: HistoryRequest): Promise<HistoryResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n const answer = await transport.door(\n DOOR_REVISIONS,\n revisionBody({\n path: request.path,\n handle: entry.handle,\n ...(request.revision === undefined ? {} : { revision: request.revision }),\n ...(request.pageToken === undefined ? {} : { pageToken: request.pageToken }),\n }),\n );\n return historyOutcome(answer.status, answer.body, entry.locator, {\n path: request.path,\n ...(request.revision === undefined ? {} : { revision: request.revision }),\n });\n },\n\n reached(locator: string, version: string, target: string): boolean {\n return reachedVersion(version, target, authorityFor(locator)?.logEpoch);\n },\n\n async action(_authorization: Authorization, request: ActionRequest): Promise<ActionResult> {\n return withAt(await houseAction(transport, request));\n },\n\n roomVersions: notifications,\n conversations: notifications.conversations,\n serviceMode: notifications.serviceMode,\n };\n}\n"],"names":["DISCOVER_PREFIXES","HOUSE_SCHEMA","capabilities","discoveredRoom","locatorOf","mapDiscovery","parseDiscovery","providerSelection","trackedFrom","MODEL_ABSENT","failedModel","heldModel","modelKey","modelShelf","gathered","selections","createSiteAdapter","bootstrapFrom","contentPrefixes","parseEnumeration","parseEnvelope","parseGrant","refreshFrom","schemaFrom","schemaPath","houseAction","classifyDoor","discoveryFailure","doorRefusal","houseNotifications","DOOR_BATCH","DOOR_BATCH_UPLOAD","DOOR_BOOTSTRAP","DOOR_DISCOVER","DOOR_ENUMERATE","DOOR_REVISIONS","DOOR_SELECTION_MAX","PRIVATE_LOCATOR","batchPaths","deltaBody","deltaBytes","deltaDigest","historyOutcome","houseChanges","mutationOutcome","operationHead","rejectedMapping","revisionBody","uploadable","logPosition","presented","reachedVersion","roomVersion","UNCERTAIN","kind","UNCERTAIN_READ","NO_ATTACHMENTS","Set","lapsedGrant","outcome","code","modelFailure","classified","envelope","createAgentsHouseAdapter","options","site","transport","notifications","tracked","Map","handed","models","handing","entry","answer","attachments","undefined","set","locator","map","attachment","reference","held","schema","failure","handle","modelPrefixes","own","acquireModels","entries","acquired","part","length","privateEntry","find","door","prefixes","flatMap","status","body","bundled","roomOf","authority","key","collection","retain","get","roomHandle","identity","selection","authorityFor","withAt","result","position","log_epoch","logEpoch","values","at","grant","method","transfer","act","url","weight","bootstrapped","answers","forEach","index","push","layered","asks","depths","layers","ask","depth","enumerated","parts","layer","open","positions","from","minPosition","min_position","refusal","named","filter","fields","behind","includes","expired","answered","gone","enumeration","fromRoomVersion","bootstrapTogether","enumerateTogether","uploaded","head","changes","delta","bytes","keep","paths","sha256","upload","minted","delivered","operation","holding","submit","prepared","authorize","model","_authorization","request","discover","document","clear","keys","has","delete","track","authorities","actions","bootstrap","pageToken","refresh","streamed","advance","mutate","mapped","changeBatch","history","path","revision","reached","version","target","action","roomVersions","conversations","serviceMode"],"mappings":"AAkBA,SACEA,iBAAiB,EACjBC,YAAY,EACZC,YAAY,EACZC,cAAc,EACdC,SAAS,EACTC,YAAY,EACZC,cAAc,EACdC,iBAAiB,EACjBC,WAAW,QAGN,iBAAiB;AACxB,SACEC,YAAY,EACZC,WAAW,EACXC,SAAS,EACTC,QAAQ,EACRC,UAAU,QAEL,aAAa;AACpB,SAASC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AACnD,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SACEC,aAAa,EACbC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,EACbC,UAAU,EACVC,WAAW,EACXC,UAAU,EACVC,UAAU,QACL,YAAY;AACnB,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,YAAY,EAAEC,gBAAgB,EAAEC,WAAW,QAAQ,eAAe;AAC3E,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SACEC,UAAU,EACVC,iBAAiB,EACjBC,cAAc,EACdC,aAAa,EACbC,cAAc,EACdC,cAAc,EACdC,kBAAkB,EAClBC,eAAe,QAGV,iBAAiB;AACxB,SACEC,UAAU,EACVC,SAAS,EACTC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,YAAY,EACZC,eAAe,EACfC,aAAa,EACbC,eAAe,EACfC,YAAY,EACZC,UAAU,QAEL,aAAa;AACpB,SACEC,WAAW,EACXC,SAAS,EACTC,cAAc,EACdC,WAAW,QAEN,eAAe;AAStB,MAAMC,YAA4B;IAAEC,MAAM;AAAwB;AAElE,MAAMC,iBAAiB;IAAED,MAAM;AAAwB;AAEvD,MAAME,iBAAsC,IAAIC;AAehD,SAASC,YAAYC,OAAuB;IAC1C,OAAOA,QAAQL,IAAI,KAAK,cAAcK,QAAQC,IAAI,KAAK;AACzD;AAE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MAAMK,OAAO,EAAE;gBAC/DmH,MAAMnB,QAAQmB,IAAI;gBAClB,GAAInB,QAAQoB,QAAQ,KAAKtH,YAAY,CAAC,IAAI;oBAAEsH,UAAUpB,QAAQoB,QAAQ;gBAAC,CAAC;YAC1E;QACF;QAEAC,SAAQrH,OAAe,EAAEsH,OAAe,EAAEC,MAAc;YACtD,OAAOnJ,eAAekJ,SAASC,QAAQvF,aAAahC,UAAUqC;QAChE;QAEA,MAAMmF,QAAOzB,cAA6B,EAAEC,OAAsB;YAChE,OAAO/D,OAAO,MAAMvF,YAAY0C,WAAW4G;QAC7C;QAEAyB,cAAcpI;QACdqI,eAAerI,cAAcqI,aAAa;QAC1CC,aAAatI,cAAcsI,WAAW;IACxC;AACF"}
1
+ {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/adapter.ts"],"sourcesContent":["import type {\n ActionRequest,\n ActionResult,\n Adapter,\n Authorization,\n BootstrapRequest,\n BootstrapResult,\n DiscoverResult,\n DiscoveredRoom,\n HistoryRequest,\n HistoryResult,\n ModelRequest,\n ModelResult,\n MutationRequest,\n MutationResult,\n RefreshRequest,\n RefreshResult,\n} from '@agentshouse/mdruntime';\nimport {\n DISCOVER_PREFIXES,\n HOUSE_SCHEMA,\n capabilities,\n discoveredRoom,\n locatorOf,\n mapDiscovery,\n parseDiscovery,\n providerSelection,\n trackedFrom,\n type HouseAuthority,\n type TrackedAuthority,\n} from './discovery.js';\nimport {\n MODEL_ABSENT,\n failedModel,\n heldModel,\n modelKey,\n modelShelf,\n type HeldModel,\n} from './model.js';\nimport { gathered, selections } from './gather.js';\nimport { createSiteAdapter } from './site.js';\nimport {\n bootstrapOf,\n contentPrefixes,\n matchesScope,\n parseEnumeration,\n parseEnvelope,\n parseGrant,\n refreshFrom,\n schemaFrom,\n schemaPath,\n viewOf,\n type HouseEnumeration,\n type HouseEnvelope,\n} from './read.js';\nimport { enumeratedLinks, scopeLinks, streamedLinks, type RoomLinks } from './links.js';\nimport { houseAction } from './actions.js';\nimport { classifyDoor, discoveryFailure, doorRefusal } from './refusal.js';\nimport { houseNotifications } from './stream.js';\nimport {\n DOOR_BATCH,\n DOOR_BATCH_UPLOAD,\n DOOR_BOOTSTRAP,\n DOOR_DISCOVER,\n DOOR_ENUMERATE,\n DOOR_REVISIONS,\n DOOR_SELECTION_MAX,\n PRIVATE_LOCATOR,\n type HouseSiteTransport,\n type HouseTransport,\n} from './transport.js';\nimport {\n batchPaths,\n deltaBody,\n deltaBytes,\n deltaDigest,\n historyOutcome,\n houseChanges,\n mutationOutcome,\n operationHead,\n rejectedMapping,\n revisionBody,\n uploadable,\n type OperationHead,\n} from './write.js';\nimport {\n logPosition,\n presented,\n reachedVersion,\n roomVersion,\n type LogPosition,\n} from './version.js';\n\nexport type AgentsHouseAdapterOptions =\n | {\n transport: HouseTransport;\n authorize(): Promise<Authorization>;\n }\n | { site: HouseSiteTransport };\n\nconst UNCERTAIN: MutationResult = { kind: 'transport-uncertainty' };\n\nconst UNCERTAIN_READ = { kind: 'transport-uncertainty' } as const;\n\ntype Enumerating = {\n entry: TrackedAuthority;\n from: LogPosition;\n fromRoomVersion: string;\n minPosition?: string;\n};\n\ntype Submission = { body: Record<string, unknown> } | { outcome: MutationResult };\n\ntype Upload = { url: string; operation: string; bytes: number; sha256: string };\n\ntype Keep = (upload: unknown) => Promise<void>;\n\nfunction lapsedGrant(outcome: MutationResult): boolean {\n return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';\n}\n\nfunction modelFailure(\n classified: ReturnType<typeof classifyDoor>,\n envelope: ReturnType<typeof parseEnvelope>,\n): ModelResult {\n if (classified === null) {\n return envelope === null ? { kind: 'transport-uncertainty' } : MODEL_ABSENT;\n }\n return failedModel(classified);\n}\n\nexport function createAgentsHouseAdapter(options: AgentsHouseAdapterOptions): Adapter {\n if ('site' in options) return createSiteAdapter(options.site);\n const transport = options.transport;\n const notifications = houseNotifications(transport, 'credential');\n const tracked = new Map<string, TrackedAuthority>();\n const handed = new Map<string, RoomLinks>();\n const models = modelShelf();\n\n function bootstrappedRoom(envelope: HouseEnvelope, entry: TrackedAuthority): BootstrapResult {\n const scope = envelope.scopes.find((candidate) => matchesScope(candidate, entry));\n if (scope === undefined) return { kind: 'room-not-readable', locator: entry.locator };\n handed.set(entry.locator, scopeLinks(scope));\n return bootstrapOf(scope, entry);\n }\n\n function enumeratedRoom(enumeration: HouseEnumeration, ask: Enumerating): RefreshResult {\n const view = viewOf(enumeration, ask.entry);\n if (view === undefined) return { kind: 'room-not-readable', locator: ask.entry.locator };\n const answer = refreshFrom(view, ask.entry, ask.fromRoomVersion);\n if (answer.kind === 'net-advancement') {\n handed.set(ask.entry.locator, enumeratedLinks(view, handed.get(ask.entry.locator)));\n }\n return answer;\n }\n\n function streamed(\n entry: TrackedAuthority,\n request: RefreshRequest,\n from: LogPosition,\n ): RefreshResult | null {\n const links = handed.get(entry.locator);\n if (links?.roomVersion !== request.fromRoomVersion) return null;\n const advanced = notifications.advance(entry, from);\n if (advanced === null) return null;\n if (\n request.minPosition !== undefined &&\n !reachedVersion(advanced.page.roomVersion, request.minPosition, entry.logEpoch)\n )\n return null;\n const relinked = streamedLinks(links, advanced);\n if (relinked === null) return null;\n handed.set(entry.locator, relinked);\n return advanced.page;\n }\n\n function held(\n envelope: ReturnType<typeof parseEnvelope>,\n entry: TrackedAuthority,\n schema: string,\n failure: ModelResult,\n ): Promise<HeldModel> {\n return heldModel(\n envelope === null ? null : schemaFrom(envelope, entry, schema),\n schemaPath(entry.handle, schema),\n failure,\n );\n }\n\n function modelPrefixes(entry: TrackedAuthority): readonly string[] {\n return entry.schemas.map((schema) => schemaPath(entry.handle, schema));\n }\n\n async function acquireModels(\n entries: readonly TrackedAuthority[],\n ): Promise<Map<string, HeldModel>> {\n const acquired = new Map<string, HeldModel>();\n for (const part of selections(\n entries,\n (entry) => modelPrefixes(entry).length,\n DOOR_SELECTION_MAX,\n )) {\n const privateEntry = part.find((entry) => entry.locator === PRIVATE_LOCATOR);\n const answer = await transport.door(DOOR_BOOTSTRAP, {\n prefixes: part.flatMap((entry) => modelPrefixes(entry)),\n });\n const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);\n const envelope = classified === null ? parseEnvelope(await bundled(answer.body)) : null;\n const failure: ModelResult = modelFailure(classified, envelope);\n for (const entry of part) {\n acquired.set(\n modelKey(entry.locator, 'collection'),\n await held(envelope, entry, entry.schema, failure),\n );\n }\n if (privateEntry !== undefined) {\n acquired.set(\n modelKey(privateEntry.locator, 'typed-selection'),\n await held(envelope, privateEntry, HOUSE_SCHEMA, failure),\n );\n }\n }\n return acquired;\n }\n\n function roomOf(authority: HouseAuthority, acquired: Map<string, HeldModel>): DiscoveredRoom {\n const locator = locatorOf(authority);\n const key = modelKey(locator, 'collection');\n const collection = models.retain(key, acquired.get(key));\n if (locator !== PRIVATE_LOCATOR) {\n return discoveredRoom(authority, collection?.identity ?? null, undefined);\n }\n const selection = models.retain(\n modelKey(locator, 'typed-selection'),\n acquired.get(modelKey(locator, 'typed-selection')),\n );\n return discoveredRoom(\n authority,\n collection?.identity ?? null,\n providerSelection(selection?.identity ?? null),\n );\n }\n\n function authorityFor(locator: string): TrackedAuthority | undefined {\n return tracked.get(locator);\n }\n\n function withAt(result: ActionResult): ActionResult {\n if (result.kind !== 'action') return result;\n const body = result.result as Record<string, unknown> | null;\n if (typeof body !== 'object' || body === null) return result;\n const { authority, position, log_epoch: logEpoch } = body;\n if (typeof position !== 'string' || typeof logEpoch !== 'string') return result;\n const locator =\n authority === undefined\n ? PRIVATE_LOCATOR\n : [...tracked.values()].find((entry) => entry.authority === authority)?.locator;\n if (locator === undefined) return result;\n return { ...result, at: { locator, roomVersion: roomVersion({ position, logEpoch }) } };\n }\n\n async function bundled(body: unknown): Promise<unknown> {\n const grant = parseGrant(body);\n if (grant === null) return body;\n if (grant.method !== 'GET') return null;\n const answer = await transport.transfer({\n act: 'local_copy_bundle',\n method: 'GET',\n url: grant.url,\n answer: 'json',\n });\n return answer.status === 200 ? answer.body : null;\n }\n\n function weight(entry: TrackedAuthority): number {\n return contentPrefixes(entry).length;\n }\n\n async function bootstrapped(entries: readonly TrackedAuthority[]): Promise<BootstrapResult[]> {\n const answers: BootstrapResult[] = [];\n for (const part of selections(entries, weight, DOOR_SELECTION_MAX)) {\n const answer = await transport.door(DOOR_BOOTSTRAP, {\n prefixes: part.flatMap((entry) => contentPrefixes(entry)),\n });\n const classified = part.map((entry) =>\n classifyDoor(answer.status, answer.body, entry.locator),\n );\n const envelope = classified[0] === null ? parseEnvelope(await bundled(answer.body)) : null;\n part.forEach((entry, index) => {\n const failure = classified[index];\n if (failure === null || failure === undefined) {\n answers.push(envelope === null ? UNCERTAIN_READ : bootstrappedRoom(envelope, entry));\n return;\n }\n answers.push(failure.kind === 'beyond-horizon' ? UNCERTAIN_READ : failure);\n });\n }\n return answers;\n }\n\n function layered(asks: readonly Enumerating[]): readonly (readonly Enumerating[])[] {\n const depths = new Map<string, number>();\n const layers: Enumerating[][] = [];\n for (const ask of asks) {\n const depth = depths.get(ask.entry.authority) ?? 0;\n depths.set(ask.entry.authority, depth + 1);\n (layers[depth] ??= []).push(ask);\n }\n return layers;\n }\n\n async function enumerated(asks: readonly Enumerating[]): Promise<RefreshResult[]> {\n const answers = new Map<Enumerating, RefreshResult>();\n const parts = layered(asks).flatMap((layer) =>\n selections(layer, (ask) => weight(ask.entry), DOOR_SELECTION_MAX),\n );\n for (const part of parts) {\n let open = [...part];\n while (open.length > 0) {\n const answer = await transport.door(DOOR_ENUMERATE, {\n prefixes: open.flatMap((ask) => contentPrefixes(ask.entry)),\n positions: open.map((ask) => ({\n ...presented(ask.entry.authority, ask.from),\n ...(ask.minPosition === undefined ? {} : { min_position: ask.minPosition }),\n })),\n });\n const refusal = doorRefusal(answer.body);\n if (refusal?.code === 'replica_behind') {\n const named = open.filter((ask) => ask.entry.authority === refusal.fields.authority);\n const behind = named.length === 0 ? open : named;\n for (const ask of behind) answers.set(ask, { kind: 'retryable-refusal', ...refusal });\n open = open.filter((ask) => !behind.includes(ask));\n continue;\n }\n const classified = open.map((ask) =>\n classifyDoor(answer.status, answer.body, ask.entry.locator),\n );\n if (classified[0]?.kind === 'beyond-horizon') {\n const named = doorRefusal(answer.body)?.fields.authority;\n const expired = open.filter((ask) => ask.entry.authority === named);\n const answered: RefreshResult =\n expired.length === 0 ? UNCERTAIN_READ : { kind: 'beyond-horizon' };\n const gone = expired.length === 0 ? open : expired;\n for (const ask of gone) answers.set(ask, answered);\n open = open.filter((ask) => !gone.includes(ask));\n continue;\n }\n const enumeration =\n classified[0] === null ? parseEnumeration(answer.body, 'credential') : null;\n open.forEach((ask, index) => {\n const failure = classified[index];\n if (failure !== null && failure !== undefined) {\n answers.set(ask, failure);\n return;\n }\n answers.set(\n ask,\n enumeration === null ? UNCERTAIN_READ : enumeratedRoom(enumeration, ask),\n );\n });\n open = [];\n }\n }\n return asks.map((ask) => answers.get(ask) ?? UNCERTAIN_READ);\n }\n\n const bootstrapTogether = gathered(bootstrapped);\n\n const enumerateTogether = gathered(enumerated);\n\n async function uploaded(\n head: OperationHead,\n changes: readonly Readonly<Record<string, unknown>>[],\n delta: string,\n bytes: number,\n entry: TrackedAuthority,\n handed: Upload | undefined,\n keep: Keep,\n ): Promise<Submission> {\n const paths = batchPaths(changes);\n const sha256 = await deltaDigest(delta);\n if (handed !== undefined && handed.sha256 === sha256) {\n return { body: { ...head, paths, upload: handed } };\n }\n const minted = await transport.door(DOOR_BATCH_UPLOAD, { ...head, paths, bytes, sha256 });\n if (minted.status !== 200) {\n return { outcome: mutationOutcome(minted.status, minted.body, entry.locator, entry.handle) };\n }\n const grant = parseGrant(minted.body);\n if (grant === null || grant.method !== 'POST') return { outcome: UNCERTAIN };\n const delivered = await transport.transfer({\n act: 'authored_batch_upload',\n method: 'POST',\n url: grant.url,\n answer: 'json',\n body: `${grant.operation}\\n${delta}`,\n });\n if (delivered.status !== 200) return { outcome: UNCERTAIN };\n const holding = parseGrant(delivered.body);\n if (holding === null || holding.method !== 'POST') return { outcome: UNCERTAIN };\n const upload: Upload = { url: holding.url, operation: holding.operation, bytes, sha256 };\n await keep(upload);\n return { body: { ...head, paths, upload } };\n }\n\n async function submit(\n head: OperationHead,\n changes: readonly Readonly<Record<string, unknown>>[],\n delta: string,\n bytes: number,\n entry: TrackedAuthority,\n handed: Upload | undefined,\n keep: Keep,\n ): Promise<MutationResult> {\n const prepared: Submission = uploadable(bytes)\n ? await uploaded(head, changes, delta, bytes, entry, handed, keep)\n : { body: { ...head, changes } };\n if ('outcome' in prepared) return prepared.outcome;\n const answer = await transport.door(DOOR_BATCH, prepared.body);\n return mutationOutcome(answer.status, answer.body, entry.locator, entry.handle);\n }\n\n return {\n async authorize() {\n return options.authorize();\n },\n\n async model(_authorization: Authorization, request: ModelRequest): Promise<ModelResult> {\n return models.answer(request);\n },\n\n async discover(_authorization: Authorization): Promise<DiscoverResult> {\n const answer = await transport.door(DOOR_DISCOVER, { prefixes: [...DISCOVER_PREFIXES] });\n const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);\n if (classified !== null) return discoveryFailure(classified);\n const document = parseDiscovery(answer.body);\n if (document === null) return { kind: 'transport-uncertainty' };\n const entries = trackedFrom(document);\n tracked.clear();\n for (const entry of entries) tracked.set(entry.locator, entry);\n for (const locator of handed.keys()) if (!tracked.has(locator)) handed.delete(locator);\n notifications.track(entries);\n const acquired = await acquireModels(entries);\n models.keep(entries.map((entry) => entry.locator));\n return mapDiscovery(\n document,\n document.authorities.map((authority) => roomOf(authority, acquired)),\n capabilities(document.actions),\n );\n },\n\n async bootstrap(\n _authorization: Authorization,\n request: BootstrapRequest,\n ): Promise<BootstrapResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return { kind: 'transport-uncertainty' };\n return bootstrapTogether(entry);\n },\n\n async refresh(_authorization: Authorization, request: RefreshRequest): Promise<RefreshResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return { kind: 'transport-uncertainty' };\n const from = logPosition(request.fromRoomVersion);\n if (from === null) return { kind: 'beyond-horizon' };\n const answered = streamed(entry, request, from);\n if (answered !== null) return answered;\n const minPosition =\n request.minPosition === undefined ? null : logPosition(request.minPosition);\n return enumerateTogether({\n entry,\n from,\n fromRoomVersion: request.fromRoomVersion,\n ...(minPosition?.logEpoch === from.logEpoch ? { minPosition: minPosition.position } : {}),\n });\n },\n\n async mutate(\n _authorization: Authorization,\n request: MutationRequest,\n keep: Keep,\n ): Promise<MutationResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n const mapped = houseChanges(request.changeBatch, entry.handle);\n if (mapped.kind === 'unmapped') return rejectedMapping(mapped);\n const head = operationHead(request.changeBatch);\n const delta = deltaBody(mapped.changes);\n const bytes = deltaBytes(delta);\n const handed = request.upload as Upload | undefined;\n const outcome = await submit(head, mapped.changes, delta, bytes, entry, handed, keep);\n if (handed === undefined || !lapsedGrant(outcome)) return outcome;\n return submit(head, mapped.changes, delta, bytes, entry, undefined, keep);\n },\n\n async history(_authorization: Authorization, request: HistoryRequest): Promise<HistoryResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n const answer = await transport.door(\n DOOR_REVISIONS,\n revisionBody({\n path: request.path,\n handle: entry.handle,\n ...(request.revision === undefined ? {} : { revision: request.revision }),\n ...(request.pageToken === undefined ? {} : { pageToken: request.pageToken }),\n }),\n );\n return historyOutcome(answer.status, answer.body, entry.locator, {\n path: request.path,\n ...(request.revision === undefined ? {} : { revision: request.revision }),\n });\n },\n\n reached(locator: string, version: string, target: string): boolean {\n return reachedVersion(version, target, authorityFor(locator)?.logEpoch);\n },\n\n async action(_authorization: Authorization, request: ActionRequest): Promise<ActionResult> {\n return withAt(await houseAction(transport, request));\n },\n\n roomVersions: notifications,\n conversations: notifications.conversations,\n serviceMode: notifications.serviceMode,\n };\n}\n"],"names":["DISCOVER_PREFIXES","HOUSE_SCHEMA","capabilities","discoveredRoom","locatorOf","mapDiscovery","parseDiscovery","providerSelection","trackedFrom","MODEL_ABSENT","failedModel","heldModel","modelKey","modelShelf","gathered","selections","createSiteAdapter","bootstrapOf","contentPrefixes","matchesScope","parseEnumeration","parseEnvelope","parseGrant","refreshFrom","schemaFrom","schemaPath","viewOf","enumeratedLinks","scopeLinks","streamedLinks","houseAction","classifyDoor","discoveryFailure","doorRefusal","houseNotifications","DOOR_BATCH","DOOR_BATCH_UPLOAD","DOOR_BOOTSTRAP","DOOR_DISCOVER","DOOR_ENUMERATE","DOOR_REVISIONS","DOOR_SELECTION_MAX","PRIVATE_LOCATOR","batchPaths","deltaBody","deltaBytes","deltaDigest","historyOutcome","houseChanges","mutationOutcome","operationHead","rejectedMapping","revisionBody","uploadable","logPosition","presented","reachedVersion","roomVersion","UNCERTAIN","kind","UNCERTAIN_READ","lapsedGrant","outcome","code","modelFailure","classified","envelope","createAgentsHouseAdapter","options","site","transport","notifications","tracked","Map","handed","models","bootstrappedRoom","entry","scope","scopes","find","candidate","undefined","locator","set","enumeratedRoom","enumeration","ask","view","answer","fromRoomVersion","get","streamed","request","from","links","advanced","advance","minPosition","page","logEpoch","relinked","held","schema","failure","handle","modelPrefixes","schemas","map","acquireModels","entries","acquired","part","length","privateEntry","door","prefixes","flatMap","status","body","bundled","roomOf","authority","key","collection","retain","identity","selection","authorityFor","withAt","result","position","log_epoch","values","at","grant","method","transfer","act","url","weight","bootstrapped","answers","forEach","index","push","layered","asks","depths","layers","depth","enumerated","parts","layer","open","positions","min_position","refusal","named","filter","fields","behind","includes","expired","answered","gone","bootstrapTogether","enumerateTogether","uploaded","head","changes","delta","bytes","keep","paths","sha256","upload","minted","delivered","operation","holding","submit","prepared","authorize","model","_authorization","discover","document","clear","keys","has","delete","track","authorities","actions","bootstrap","pageToken","refresh","mutate","mapped","changeBatch","history","path","revision","reached","version","target","action","roomVersions","conversations","serviceMode"],"mappings":"AAkBA,SACEA,iBAAiB,EACjBC,YAAY,EACZC,YAAY,EACZC,cAAc,EACdC,SAAS,EACTC,YAAY,EACZC,cAAc,EACdC,iBAAiB,EACjBC,WAAW,QAGN,iBAAiB;AACxB,SACEC,YAAY,EACZC,WAAW,EACXC,SAAS,EACTC,QAAQ,EACRC,UAAU,QAEL,aAAa;AACpB,SAASC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AACnD,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SACEC,WAAW,EACXC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,aAAa,EACbC,UAAU,EACVC,WAAW,EACXC,UAAU,EACVC,UAAU,EACVC,MAAM,QAGD,YAAY;AACnB,SAASC,eAAe,EAAEC,UAAU,EAAEC,aAAa,QAAwB,aAAa;AACxF,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,YAAY,EAAEC,gBAAgB,EAAEC,WAAW,QAAQ,eAAe;AAC3E,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SACEC,UAAU,EACVC,iBAAiB,EACjBC,cAAc,EACdC,aAAa,EACbC,cAAc,EACdC,cAAc,EACdC,kBAAkB,EAClBC,eAAe,QAGV,iBAAiB;AACxB,SACEC,UAAU,EACVC,SAAS,EACTC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,YAAY,EACZC,eAAe,EACfC,aAAa,EACbC,eAAe,EACfC,YAAY,EACZC,UAAU,QAEL,aAAa;AACpB,SACEC,WAAW,EACXC,SAAS,EACTC,cAAc,EACdC,WAAW,QAEN,eAAe;AAStB,MAAMC,YAA4B;IAAEC,MAAM;AAAwB;AAElE,MAAMC,iBAAiB;IAAED,MAAM;AAAwB;AAevD,SAASE,YAAYC,OAAuB;IAC1C,OAAOA,QAAQH,IAAI,KAAK,cAAcG,QAAQC,IAAI,KAAK;AACzD;AAEA,SAASC,aACPC,UAA2C,EAC3CC,QAA0C;IAE1C,IAAID,eAA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only string[];
11
11
  export declare const RESERVED_NAMES: readonly string[];
12
12
  export declare const HOUSE_SCHEMA = "house/schema.yaml";
13
+ export declare const PRIVATE_HANDLE = "private";
13
14
  export type HouseBounds = {
14
15
  max_authored_file_bytes: number;
15
16
  max_batch_operations: number;
@@ -29,7 +30,7 @@ export type HouseOperations = {
29
30
  };
30
31
  export type HouseAuthority = LogPosition & {
31
32
  roomRef: string;
32
- roomHandle: string | null;
33
+ roomHandle: string;
33
34
  name: string;
34
35
  schema: string;
35
36
  managedReplication: 'admitted' | 'unavailable';
@@ -45,7 +46,7 @@ export type HouseDiscoveryDocument = {
45
46
  export type TrackedAuthority = LogPosition & {
46
47
  locator: string;
47
48
  authority: string;
48
- handle: string | undefined;
49
+ handle: string;
49
50
  schema: string;
50
51
  schemas: readonly string[];
51
52
  };
@@ -68,12 +69,9 @@ export type HouseSiteDiscovery = {
68
69
  slots: readonly HouseSiteSlot[];
69
70
  authorities: readonly HouseSiteAuthority[];
70
71
  };
71
- export type SiteTracked = TrackedAuthority & {
72
- handle: string;
73
- };
74
72
  export declare function parseDiscovery(body: unknown): HouseDiscoveryDocument | null;
75
73
  export declare function parseSiteDiscovery(body: unknown): HouseSiteDiscovery | null;
76
- export declare function siteTracked(document: HouseSiteDiscovery): SiteTracked[];
74
+ export declare function siteTracked(document: HouseSiteDiscovery): TrackedAuthority[];
77
75
  export declare function siteSlots(document: HouseSiteDiscovery): Discovery['slots'];
78
76
  export declare function locatorOf(authority: HouseAuthority): string;
79
77
  export declare function trackedFrom(document: HouseDiscoveryDocument): TrackedAuthority[];
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,SAAS,EACT,cAAc,EACf,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,e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E;AAyCD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI,CAoB3E;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,kBAAkB,GAAG,gBAAgB,EAAE,CAU5E;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,CAAC,OAAO,CAAC,CAK1E;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,cAAc,GAAG,MAAM,CAE3D;AAQD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,sBAAsB,GAAG,gBAAgB,EAAE,CAUhF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,aAAa,EAAE,CAU5E;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAMhE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,UAAU,EAAE,CAU9E;AAED,wBAAgB,gBAAgB,IAAI,SAAS,UAAU,EAAE,CAKxD;AAED,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,cAAc,CAAC,eAAe,CAAC,GAAG,cAAc,CAEhG;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,cAAc,EACzB,aAAa,EAAE,cAAc,CAAC,eAAe,CAAC,EAC9C,cAAc,EAAE,cAAc,GAAG,SAAS,GACzC,cAAc,CAiBhB;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,IAAI,CAAC,sBAAsB,EAAE,QAAQ,GAAG,gBAAgB,CAAC,EACnE,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,QAAQ,EAAE,SAAS,UAAU,EAAE,GAC9B,SAAS,CAUX"}
package/dist/discovery.js CHANGED
@@ -33,6 +33,7 @@ export const RESERVED_NAMES = [
33
33
  'commitments'
34
34
  ];
35
35
  export const HOUSE_SCHEMA = 'house/schema.yaml';
36
+ export const PRIVATE_HANDLE = 'private';
36
37
  const BOUND_KEYS = [
37
38
  'max_authored_file_bytes',
38
39
  'max_batch_operations',
@@ -90,7 +91,7 @@ function parseAuthority(value) {
90
91
  const operations = parseOperations(held.operations);
91
92
  if (at === null || protectedPaths === null || operations === null) return null;
92
93
  if (typeof held.room_ref !== 'string' || held.room_ref.length === 0) return null;
93
- if (held.room_handle !== null && (typeof held.room_handle !== 'string' || held.room_handle.length === 0)) return null;
94
+ if (typeof held.room_handle !== 'string' || held.room_handle.length === 0) return null;
94
95
  return {
95
96
  roomRef: held.room_ref,
96
97
  roomHandle: held.room_handle,
@@ -215,10 +216,10 @@ export function siteSlots(document) {
215
216
  }));
216
217
  }
217
218
  export function locatorOf(authority) {
218
- return authority.roomHandle === null ? PRIVATE_LOCATOR : authority.roomRef;
219
+ return authority.roomHandle === PRIVATE_HANDLE ? PRIVATE_LOCATOR : authority.roomRef;
219
220
  }
220
221
  function schemasOf(authority) {
221
- return authority.roomHandle === null ? [
222
+ return authority.roomHandle === PRIVATE_HANDLE ? [
222
223
  authority.schema,
223
224
  HOUSE_SCHEMA
224
225
  ] : [
@@ -229,7 +230,7 @@ export function trackedFrom(document) {
229
230
  return document.authorities.map((authority)=>({
230
231
  locator: locatorOf(authority),
231
232
  authority: authority.roomRef,
232
- handle: authority.roomHandle ?? undefined,
233
+ handle: authority.roomHandle,
233
234
  schema: authority.schema,
234
235
  schemas: schemasOf(authority),
235
236
  position: authority.position,
@@ -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_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 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 | null;\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 | undefined;\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\nexport type SiteTracked = TrackedAuthority & { handle: string };\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 (\n held.room_handle !== null &&\n (typeof held.room_handle !== 'string' || held.room_handle.length === 0)\n )\n 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): SiteTracked[] {\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 === null ? PRIVATE_LOCATOR : authority.roomRef;\n}\n\nfunction schemasOf(authority: HouseAuthority): readonly string[] {\n return authority.roomHandle === null ? [authority.schema, HOUSE_SCHEMA] : [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 ?? undefined,\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","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","undefined","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","untypedFolders","providerOwnedPaths","mapDiscovery","rooms","declared","supportedVersions","mdModel","identity","version","retention"],"mappings":"AAQA,SAASA,eAAe,EAAEC,wBAAwB,QAAQ,eAAe;AACzE,SAASC,eAAe,QAAQ,iBAAiB;AACjD,SA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/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,IAAI,OAAOA,UAAU,YAAYA,UAAU,MAAM,OAAO;IACxD,MAAMM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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,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,IAAI,EAAEC,OAAO,EAAE,GAAK;gBAACD;gBAAMnB,SAASoB;aAAS;IACpF;AACF;AAEA,OAAO,SAASC,gBAAgBC,IAAe,EAAEC,OAA8B;IAC7E,MAAMP,QAAQ,IAAIC,IAAIM,SAASP;IAC/B,KAAK,MAAMQ,UAAUF,KAAKG,OAAO,CAAE;QACjCT,MAAMU,GAAG,CAACF,OAAOL,IAAI,EAAEnB,SAAS,aAAawB,SAASA,OAAOJ,OAAO,GAAG;IACzE;IACA,OAAO;QAAExB,aAAaA,YAAY0B;QAAOP,QAAQP,SAASc,KAAKb,WAAW;QAAGO;IAAM;AACrF;AAEA,OAAO,SAASW,cAAcC,IAAe,EAAEC,QAA6B;IAC1E,MAAMb,QAAQ,IAAIC,IAAIW,KAAKZ,KAAK;IAChC,MAAMc,UAAU,IAAI/B;IACpB,KAAK,MAAMgC,SAASF,SAASG,OAAO,CAAE;QACpC,MAAM/B,OAAO8B,MAAME,IAAI,KAAK,YAAY,OAAOF,MAAM9B,IAAI;QACzD,IAAIA,SAASiC,WAAW,OAAO;QAC/B,MAAMC,SAASnC,SAASC;QACxB,KAAK,MAAMW,aAAauB,OAAQ,IAAI,CAACP,KAAKb,MAAM,CAACqB,GAAG,CAACxB,YAAY,OAAO;QACxE,KAAK,MAAMA,aAAaI,MAAMqB,GAAG,CAACN,MAAMZ,IAAI,KAAKS,KAAKb,MAAM,CAAE;YAC5D,IAAIa,KAAKb,MAAM,CAACqB,GAAG,CAACxB,cAAc,CAACuB,OAAOC,GAAG,CAACxB,YAAYkB,QAAQQ,GAAG,CAAC1B;QACxE;QACAI,MAAMU,GAAG,CAACK,MAAMZ,IAAI,EAAEgB;IACxB;IACA,KAAK,MAAMjC,cAAcc,MAAMuB,MAAM,GAAI;QACvC,KAAK,MAAM3B,aAAaV,WAAY4B,QAAQU,MAAM,CAAC5B;IACrD;IACA,IAAIkB,QAAQvB,IAAI,GAAG,GAAG,OAAO;IAC7B,OAAO;QAAEX,aAAaiC,SAASY,IAAI,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