@agentshouse/mdruntime-adapter 0.1.0-alpha.40 → 0.1.0-alpha.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +22 -11
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +153 -49
- package/dist/adapter.js.map +1 -1
- package/dist/gather.d.ts +3 -0
- package/dist/gather.d.ts.map +1 -0
- package/dist/gather.js +41 -0
- package/dist/gather.js.map +1 -0
- package/dist/read.d.ts +7 -0
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +51 -5
- package/dist/read.js.map +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +19 -3
- package/dist/site.js.map +1 -1
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +8 -1
- package/dist/stream.js.map +1 -1
- package/dist/transport.d.ts +9 -0
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +1 -0
- package/dist/transport.js.map +1 -1
- package/dist/version.d.ts +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +10 -0
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
package/dist/read.js
CHANGED
|
@@ -41,23 +41,58 @@ export function parseGrant(body) {
|
|
|
41
41
|
url: transfer.url
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
+
function changeAuthor(value) {
|
|
45
|
+
if (typeof value !== 'object' || value === null) return null;
|
|
46
|
+
const { user, site, name } = value;
|
|
47
|
+
if (typeof name !== 'string') return null;
|
|
48
|
+
if (typeof user === 'string' && site === undefined) return {
|
|
49
|
+
kind: 'user',
|
|
50
|
+
id: user,
|
|
51
|
+
name
|
|
52
|
+
};
|
|
53
|
+
if (typeof site === 'string' && user === undefined) return {
|
|
54
|
+
kind: 'site',
|
|
55
|
+
id: site,
|
|
56
|
+
name
|
|
57
|
+
};
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
export function headChange(held) {
|
|
61
|
+
const author = held.author === undefined ? null : changeAuthor(held.author);
|
|
62
|
+
if (held.author !== undefined && author === null) return null;
|
|
63
|
+
if (held.created_at === undefined) return undefined;
|
|
64
|
+
if (typeof held.created_at !== 'string') return null;
|
|
65
|
+
return {
|
|
66
|
+
author,
|
|
67
|
+
time: held.created_at
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function headed(head) {
|
|
71
|
+
return head === undefined ? {} : {
|
|
72
|
+
head
|
|
73
|
+
};
|
|
74
|
+
}
|
|
44
75
|
function parseFile(value, mode) {
|
|
45
76
|
if (typeof value !== 'object' || value === null) return null;
|
|
46
77
|
const file = value;
|
|
47
78
|
if (typeof file.path !== 'string') return null;
|
|
79
|
+
const head = headChange(file);
|
|
80
|
+
if (head === null) return null;
|
|
48
81
|
if (mode === 'site') {
|
|
49
82
|
if (typeof file.sha256 !== 'string') return null;
|
|
50
83
|
return {
|
|
51
84
|
path: file.path,
|
|
52
85
|
revision: undefined,
|
|
53
|
-
version: file.sha256
|
|
86
|
+
version: file.sha256,
|
|
87
|
+
...headed(head)
|
|
54
88
|
};
|
|
55
89
|
}
|
|
56
90
|
if (typeof file.revision !== 'string') return null;
|
|
57
91
|
return {
|
|
58
92
|
path: file.path,
|
|
59
93
|
revision: file.revision,
|
|
60
|
-
version: file.revision
|
|
94
|
+
version: file.revision,
|
|
95
|
+
...headed(head)
|
|
61
96
|
};
|
|
62
97
|
}
|
|
63
98
|
function parseScope(value, mode) {
|
|
@@ -118,13 +153,16 @@ function parseChange(value, mode) {
|
|
|
118
153
|
path: held.path,
|
|
119
154
|
removed: true
|
|
120
155
|
};
|
|
156
|
+
const head = headChange(held);
|
|
157
|
+
if (head === null) return null;
|
|
121
158
|
if (mode === 'site') {
|
|
122
159
|
if (typeof held.content !== 'string' || typeof held.sha256 !== 'string') return null;
|
|
123
160
|
return {
|
|
124
161
|
path: held.path,
|
|
125
162
|
content: held.content,
|
|
126
163
|
revision: undefined,
|
|
127
|
-
version: held.sha256
|
|
164
|
+
version: held.sha256,
|
|
165
|
+
...headed(head)
|
|
128
166
|
};
|
|
129
167
|
}
|
|
130
168
|
if (typeof held.content === 'string' && typeof held.revision === 'string') {
|
|
@@ -132,7 +170,8 @@ function parseChange(value, mode) {
|
|
|
132
170
|
path: held.path,
|
|
133
171
|
content: held.content,
|
|
134
172
|
revision: held.revision,
|
|
135
|
-
version: held.revision
|
|
173
|
+
version: held.revision,
|
|
174
|
+
...headed(head)
|
|
136
175
|
};
|
|
137
176
|
}
|
|
138
177
|
if (typeof held.reference === 'object' && held.reference !== null) {
|
|
@@ -190,7 +229,8 @@ export function advancedScope(scope, view) {
|
|
|
190
229
|
files.set(change.path, {
|
|
191
230
|
path: change.path,
|
|
192
231
|
revision: change.revision,
|
|
193
|
-
version: change.version
|
|
232
|
+
version: change.version,
|
|
233
|
+
...headed(change.head)
|
|
194
234
|
});
|
|
195
235
|
contents.set(change.path, change.content);
|
|
196
236
|
continue;
|
|
@@ -242,10 +282,12 @@ export function bootstrapOf(scope, tracked) {
|
|
|
242
282
|
]));
|
|
243
283
|
const documents = {};
|
|
244
284
|
const revisions = {};
|
|
285
|
+
const changes = {};
|
|
245
286
|
const binaryTargets = [];
|
|
246
287
|
for (const file of scope.files){
|
|
247
288
|
if (!selects(tracked, file.path)) continue;
|
|
248
289
|
if (file.revision !== undefined) revisions[file.path] = file.revision;
|
|
290
|
+
if (file.head !== undefined) changes[file.path] = file.head;
|
|
249
291
|
const content = contents.get(file.path);
|
|
250
292
|
if (content === undefined) binaryTargets.push(file.path);
|
|
251
293
|
else documents[file.path] = content;
|
|
@@ -255,6 +297,7 @@ export function bootstrapOf(scope, tracked) {
|
|
|
255
297
|
roomVersion: roomVersion(scope),
|
|
256
298
|
documents,
|
|
257
299
|
revisions,
|
|
300
|
+
changes,
|
|
258
301
|
binaryTargets: binaryTargets.sort()
|
|
259
302
|
};
|
|
260
303
|
}
|
|
@@ -286,6 +329,7 @@ export function refreshFrom(enumeration, tracked, fromRoomVersion) {
|
|
|
286
329
|
};
|
|
287
330
|
const documents = {};
|
|
288
331
|
const revisions = {};
|
|
332
|
+
const changes = {};
|
|
289
333
|
const binaryTargets = [];
|
|
290
334
|
const removals = [];
|
|
291
335
|
for (const change of view.changes){
|
|
@@ -297,6 +341,7 @@ export function refreshFrom(enumeration, tracked, fromRoomVersion) {
|
|
|
297
341
|
if ('content' in change) {
|
|
298
342
|
documents[change.path] = change.content;
|
|
299
343
|
if (change.revision !== undefined) revisions[change.path] = change.revision;
|
|
344
|
+
if (change.head !== undefined) changes[change.path] = change.head;
|
|
300
345
|
continue;
|
|
301
346
|
}
|
|
302
347
|
binaryTargets.push(change.path);
|
|
@@ -307,6 +352,7 @@ export function refreshFrom(enumeration, tracked, fromRoomVersion) {
|
|
|
307
352
|
roomVersion: roomVersion(view),
|
|
308
353
|
documents,
|
|
309
354
|
revisions,
|
|
355
|
+
changes,
|
|
310
356
|
binaryTargets: binaryTargets.sort(),
|
|
311
357
|
removals: removals.sort()
|
|
312
358
|
};
|
package/dist/read.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/read.ts"],"sourcesContent":["import type { BootstrapPage, BootstrapResult, RefreshResult } from '@agentshouse/mdruntime';\nimport { PROVIDER_SELECTION_ROOTS, type TrackedAuthority } from './discovery.js';\nimport type { HouseMode } from './transport.js';\nimport { readPosition, roomVersion, type LogPosition } from './version.js';\n\nexport type HouseManifestFile = {\n path: string;\n revision: string | undefined;\n version: string;\n};\n\nexport type HouseContent = {\n path: string;\n content: string;\n};\n\nexport type HouseScope = LogPosition & {\n anchor: string;\n files: readonly HouseManifestFile[];\n contents: readonly HouseContent[];\n};\n\nexport type HouseEnvelope = {\n scopes: readonly HouseScope[];\n};\n\nexport type HouseGrant =\n | { method: 'GET'; url: string }\n | { method: 'POST'; operation: string; url: string };\n\nexport type HouseChange =\n | { path: string; removed: true }\n | { path: string; content: string; revision: string | undefined; version: string }\n | { path: string; reference: { revision: string } };\n\nexport type HouseEnumeration = {\n authorities: readonly (LogPosition & {\n authority: string;\n changes: readonly HouseChange[];\n })[];\n};\n\nexport function authorityRoot(handle: string | undefined): string {\n return handle === undefined ? '/private' : `/rooms/${handle}`;\n}\n\nexport const ROOM_README = 'ROOM.md';\n\nexport function selectionRoots(tracked: TrackedAuthority): readonly string[] {\n if (tracked.handle === undefined) {\n return [tracked.collectionRoot, ...PROVIDER_SELECTION_ROOTS];\n }\n return [ROOM_README, tracked.collectionRoot];\n}\n\nexport function contentPrefixes(tracked: TrackedAuthority): readonly string[] {\n const root = authorityRoot(tracked.handle);\n return selectionRoots(tracked)\n .filter((entry) => entry !== ROOM_README)\n .map((entry) => `${root}/${entry}`);\n}\n\nexport function schemaPath(handle: string | undefined, schema: string): string {\n return `${authorityRoot(handle)}/${schema}`;\n}\n\nexport function parseGrant(body: unknown): HouseGrant | null {\n if (typeof body !== 'object' || body === null) return null;\n if (!('transfer' in body) || typeof body.transfer !== 'object' || body.transfer === null) {\n return null;\n }\n const transfer = body.transfer as Record<string, unknown>;\n if (typeof transfer.url !== 'string') return null;\n if (transfer.method === 'GET') return { method: 'GET', url: transfer.url };\n if (transfer.method !== 'POST' || typeof transfer.operation !== 'string') return null;\n return { method: 'POST', operation: transfer.operation, url: transfer.url };\n}\n\nfunction parseFile(value: unknown, mode: HouseMode): HouseManifestFile | null {\n if (typeof value !== 'object' || value === null) return null;\n const file = value as Record<string, unknown>;\n if (typeof file.path !== 'string') return null;\n if (mode === 'site') {\n if (typeof file.sha256 !== 'string') return null;\n return { path: file.path, revision: undefined, version: file.sha256 };\n }\n if (typeof file.revision !== 'string') return null;\n return { path: file.path, revision: file.revision, version: file.revision };\n}\n\nfunction parseScope(value: unknown, mode: HouseMode): HouseScope | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n if (typeof held.manifest !== 'object' || held.manifest === null) return null;\n if (!Array.isArray(held.contents)) return null;\n const manifest = held.manifest as Record<string, unknown>;\n if (manifest.scope !== 'room') return null;\n const at = readPosition(manifest);\n if (typeof manifest.anchor !== 'string' || manifest.anchor.length === 0 || at === null)\n return null;\n if (\n manifest.room_handle !== null &&\n (typeof manifest.room_handle !== 'string' || manifest.room_handle.length === 0)\n )\n return null;\n if (!Array.isArray(manifest.files)) return null;\n const files: HouseManifestFile[] = [];\n for (const entry of manifest.files) {\n const file = parseFile(entry, mode);\n if (file === null) return null;\n files.push(file);\n }\n const contents: HouseContent[] = [];\n for (const entry of held.contents) {\n if (typeof entry !== 'object' || entry === null) return null;\n const content = entry as Record<string, unknown>;\n if (typeof content.path !== 'string' || typeof content.content !== 'string') return null;\n contents.push({ path: content.path, content: content.content });\n }\n return {\n anchor: manifest.anchor,\n ...at,\n files,\n contents,\n };\n}\n\nexport function parseEnvelope(body: unknown): HouseEnvelope | null {\n if (typeof body !== 'object' || body === null) return null;\n if (!('scopes' in body) || !Array.isArray(body.scopes)) return null;\n const scopes: HouseScope[] = [];\n for (const entry of body.scopes) {\n const scope = parseScope(entry, 'credential');\n if (scope === null) return null;\n scopes.push(scope);\n }\n return { scopes };\n}\n\nexport function parseSiteBootstrap(body: unknown): HouseScope | null {\n return parseScope(body, 'site');\n}\n\nfunction parseChange(value: unknown, mode: HouseMode): HouseChange | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n if (typeof held.path !== 'string') return null;\n if (held.removed === true) return { path: held.path, removed: true };\n if (mode === 'site') {\n if (typeof held.content !== 'string' || typeof held.sha256 !== 'string') return null;\n return { path: held.path, content: held.content, revision: undefined, version: held.sha256 };\n }\n if (typeof held.content === 'string' && typeof held.revision === 'string') {\n return {\n path: held.path,\n content: held.content,\n revision: held.revision,\n version: held.revision,\n };\n }\n if (typeof held.reference === 'object' && held.reference !== null) {\n const reference = held.reference as Record<string, unknown>;\n if (typeof reference.revision !== 'string') return null;\n return { path: held.path, reference: { revision: reference.revision } };\n }\n return null;\n}\n\nexport function parseEnumeration(body: unknown, mode: HouseMode): HouseEnumeration | null {\n if (typeof body !== 'object' || body === null) return null;\n if (!('authorities' in body) || !Array.isArray(body.authorities)) return null;\n const authorities: HouseEnumeration['authorities'][number][] = [];\n for (const entry of body.authorities) {\n if (typeof entry !== 'object' || entry === null) return null;\n const held = entry as Record<string, unknown>;\n const at = readPosition(held);\n if (typeof held.authority !== 'string' || at === null) return null;\n if (!Array.isArray(held.changes)) return null;\n const changes: HouseChange[] = [];\n for (const change of held.changes) {\n const mapped = parseChange(change, mode);\n if (mapped === null) return null;\n changes.push(mapped);\n }\n authorities.push({ authority: held.authority, ...at, changes });\n }\n return { authorities };\n}\n\nexport function advancedScope(\n scope: HouseScope,\n view: HouseEnumeration['authorities'][number],\n): HouseScope {\n const files = new Map(scope.files.map((file) => [file.path, file]));\n const contents = new Map(scope.contents.map((entry) => [entry.path, entry.content]));\n for (const change of view.changes) {\n files.delete(change.path);\n contents.delete(change.path);\n if ('removed' in change) continue;\n if ('content' in change) {\n files.set(change.path, {\n path: change.path,\n revision: change.revision,\n version: change.version,\n });\n contents.set(change.path, change.content);\n continue;\n }\n const { revision } = change.reference;\n files.set(change.path, { path: change.path, revision, version: revision });\n }\n return {\n ...scope,\n position: view.position,\n logEpoch: view.logEpoch,\n files: [...files.values()],\n contents: [...contents].map(([path, content]) => ({ path, content })),\n };\n}\n\nexport function matchesScope(scope: HouseScope, tracked: TrackedAuthority): boolean {\n return scope.anchor === tracked.authority;\n}\n\nexport function withinRoot(path: string, root: string): boolean {\n return path === root || path.startsWith(`${root}/`);\n}\n\nexport function selects(tracked: TrackedAuthority, path: string): boolean {\n if (tracked.schemas.includes(path)) return false;\n return selectionRoots(tracked).some((root) => withinRoot(path, root));\n}\n\nexport function bootstrapFrom(envelope: HouseEnvelope, tracked: TrackedAuthority): BootstrapResult {\n const scope = envelope.scopes.find((entry) => matchesScope(entry, tracked));\n if (scope === undefined) return { kind: 'room-not-readable', locator: tracked.locator };\n return bootstrapOf(scope, tracked);\n}\n\nexport function bootstrapOf(scope: HouseScope, tracked: TrackedAuthority): BootstrapPage {\n const contents = new Map(scope.contents.map((entry) => [entry.path, entry.content]));\n const documents: Record<string, string> = {};\n const revisions: Record<string, string> = {};\n const binaryTargets: string[] = [];\n for (const file of scope.files) {\n if (!selects(tracked, file.path)) continue;\n if (file.revision !== undefined) revisions[file.path] = file.revision;\n const content = contents.get(file.path);\n if (content === undefined) binaryTargets.push(file.path);\n else documents[file.path] = content;\n }\n return {\n kind: 'bootstrap',\n roomVersion: roomVersion(scope),\n documents,\n revisions,\n binaryTargets: binaryTargets.sort(),\n };\n}\n\nexport type HouseSchema = {\n schema: string | null;\n version: string | null;\n};\n\nexport function schemaFrom(\n envelope: HouseEnvelope,\n tracked: TrackedAuthority,\n schema: string,\n): HouseSchema | null {\n const scope = envelope.scopes.find((entry) => matchesScope(entry, tracked));\n if (scope === undefined) return null;\n return schemaOf(scope, schema);\n}\n\nexport function schemaOf(scope: HouseScope, schema: string): HouseSchema | null {\n const file = scope.files.find((entry) => entry.path === schema);\n if (file === undefined) return { schema: null, version: null };\n const content = scope.contents.find((entry) => entry.path === schema);\n return content === undefined ? null : { schema: content.content, version: file.version };\n}\n\nexport function refreshFrom(\n enumeration: HouseEnumeration,\n tracked: TrackedAuthority,\n fromRoomVersion: string,\n): RefreshResult {\n const view = enumeration.authorities.find((entry) => entry.authority === tracked.authority);\n if (view === undefined) return { kind: 'room-not-readable', locator: tracked.locator };\n if (roomVersion(view) === fromRoomVersion) return { kind: 'still-current' };\n const documents: Record<string, string> = {};\n const revisions: Record<string, string> = {};\n const binaryTargets: string[] = [];\n const removals: string[] = [];\n for (const change of view.changes) {\n if (!selects(tracked, change.path)) continue;\n if ('removed' in change) {\n removals.push(change.path);\n continue;\n }\n if ('content' in change) {\n documents[change.path] = change.content;\n if (change.revision !== undefined) revisions[change.path] = change.revision;\n continue;\n }\n binaryTargets.push(change.path);\n revisions[change.path] = change.reference.revision;\n }\n return {\n kind: 'net-advancement',\n roomVersion: roomVersion(view),\n documents,\n revisions,\n binaryTargets: binaryTargets.sort(),\n removals: removals.sort(),\n };\n}\n"],"names":["PROVIDER_SELECTION_ROOTS","readPosition","roomVersion","authorityRoot","handle","undefined","ROOM_README","selectionRoots","tracked","collectionRoot","contentPrefixes","root","filter","entry","map","schemaPath","schema","parseGrant","body","transfer","url","method","operation","parseFile","value","mode","file","path","sha256","revision","version","parseScope","held","manifest","Array","isArray","contents","scope","at","anchor","length","room_handle","files","push","content","parseEnvelope","scopes","parseSiteBootstrap","parseChange","removed","reference","parseEnumeration","authorities","authority","changes","change","mapped","advancedScope","view","Map","delete","set","position","logEpoch","values","matchesScope","withinRoot","startsWith","selects","schemas","includes","some","bootstrapFrom","envelope","find","kind","locator","bootstrapOf","documents","revisions","binaryTargets","get","sort","schemaFrom","schemaOf","refreshFrom","enumeration","fromRoomVersion","removals"],"mappings":"AACA,SAASA,wBAAwB,QAA+B,iBAAiB;AAEjF,SAASC,YAAY,EAAEC,WAAW,QAA0B,eAAe;AAuC3E,OAAO,SAASC,cAAcC,MAA0B;IACtD,OAAOA,WAAWC,YAAY,aAAa,CAAC,OAAO,EAAED,QAAQ;AAC/D;AAEA,OAAO,MAAME,cAAc,UAAU;AAErC,OAAO,SAASC,eAAeC,OAAyB;IACtD,IAAIA,QAAQJ,MAAM,KAAKC,WAAW;QAChC,OAAO;YAACG,QAAQC,cAAc;eAAKT;SAAyB;IAC9D;IACA,OAAO;QAACM;QAAaE,QAAQC,cAAc;KAAC;AAC9C;AAEA,OAAO,SAASC,gBAAgBF,OAAyB;IACvD,MAAMG,OAAOR,cAAcK,QAAQJ,MAAM;IACzC,OAAOG,eAAeC,SACnBI,MAAM,CAAC,CAACC,QAAUA,UAAUP,aAC5BQ,GAAG,CAAC,CAACD,QAAU,GAAGF,KAAK,CAAC,EAAEE,OAAO;AACtC;AAEA,OAAO,SAASE,WAAWX,MAA0B,EAAEY,MAAc;IACnE,OAAO,GAAGb,cAAcC,QAAQ,CAAC,EAAEY,QAAQ;AAC7C;AAEA,O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IAAI,CAAC,GAAG4B,OAAOL,SAAS,CAACrB,QAAQ;IACpD;IACA,OAAO;QACL8C,MAAM;QACNzE,aAAaA,YAAYwD;QACzBoB;QACAC;QACAC,eAAeA,cAAcE,IAAI;QACjCM,UAAUA,SAASN,IAAI;IACzB;AACF"}
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/read.ts"],"sourcesContent":["import type {\n BootstrapPage,\n BootstrapResult,\n ChangeAuthor,\n RefreshResult,\n} from '@agentshouse/mdruntime';\nimport { PROVIDER_SELECTION_ROOTS, type TrackedAuthority } from './discovery.js';\nimport type { HouseMode } from './transport.js';\nimport { readPosition, roomVersion, type LogPosition } from './version.js';\n\nexport type HeadChange = BootstrapPage['changes'][string];\n\nexport type HouseManifestFile = {\n path: string;\n revision: string | undefined;\n version: string;\n head?: HeadChange;\n};\n\nexport type HouseContent = {\n path: string;\n content: string;\n};\n\nexport type HouseScope = LogPosition & {\n anchor: string;\n files: readonly HouseManifestFile[];\n contents: readonly HouseContent[];\n};\n\nexport type HouseEnvelope = {\n scopes: readonly HouseScope[];\n};\n\nexport type HouseGrant =\n | { method: 'GET'; url: string }\n | { method: 'POST'; operation: string; url: string };\n\nexport type HouseChange =\n | { path: string; removed: true }\n | {\n path: string;\n content: string;\n revision: string | undefined;\n version: string;\n head?: HeadChange;\n }\n | { path: string; reference: { revision: string } };\n\nexport type HouseEnumeration = {\n authorities: readonly (LogPosition & {\n authority: string;\n changes: readonly HouseChange[];\n })[];\n};\n\nexport function authorityRoot(handle: string | undefined): string {\n return handle === undefined ? '/private' : `/rooms/${handle}`;\n}\n\nexport const ROOM_README = 'ROOM.md';\n\nexport function selectionRoots(tracked: TrackedAuthority): readonly string[] {\n if (tracked.handle === undefined) {\n return [tracked.collectionRoot, ...PROVIDER_SELECTION_ROOTS];\n }\n return [ROOM_README, tracked.collectionRoot];\n}\n\nexport function contentPrefixes(tracked: TrackedAuthority): readonly string[] {\n const root = authorityRoot(tracked.handle);\n return selectionRoots(tracked)\n .filter((entry) => entry !== ROOM_README)\n .map((entry) => `${root}/${entry}`);\n}\n\nexport function schemaPath(handle: string | undefined, schema: string): string {\n return `${authorityRoot(handle)}/${schema}`;\n}\n\nexport function parseGrant(body: unknown): HouseGrant | null {\n if (typeof body !== 'object' || body === null) return null;\n if (!('transfer' in body) || typeof body.transfer !== 'object' || body.transfer === null) {\n return null;\n }\n const transfer = body.transfer as Record<string, unknown>;\n if (typeof transfer.url !== 'string') return null;\n if (transfer.method === 'GET') return { method: 'GET', url: transfer.url };\n if (transfer.method !== 'POST' || typeof transfer.operation !== 'string') return null;\n return { method: 'POST', operation: transfer.operation, url: transfer.url };\n}\n\nfunction changeAuthor(value: unknown): ChangeAuthor | null {\n if (typeof value !== 'object' || value === null) return null;\n const { user, site, name } = value as Record<string, unknown>;\n if (typeof name !== 'string') return null;\n if (typeof user === 'string' && site === undefined) return { kind: 'user', id: user, name };\n if (typeof site === 'string' && user === undefined) return { kind: 'site', id: site, name };\n return null;\n}\n\nexport function headChange(held: {\n readonly author?: unknown;\n readonly created_at?: unknown;\n}): HeadChange | undefined | null {\n const author = held.author === undefined ? null : changeAuthor(held.author);\n if (held.author !== undefined && author === null) return null;\n if (held.created_at === undefined) return undefined;\n if (typeof held.created_at !== 'string') return null;\n return { author, time: held.created_at };\n}\n\nfunction headed(head: HeadChange | undefined) {\n return head === undefined ? {} : { head };\n}\n\nfunction parseFile(value: unknown, mode: HouseMode): HouseManifestFile | null {\n if (typeof value !== 'object' || value === null) return null;\n const file = value as Record<string, unknown>;\n if (typeof file.path !== 'string') return null;\n const head = headChange(file);\n if (head === null) return null;\n if (mode === 'site') {\n if (typeof file.sha256 !== 'string') return null;\n return { path: file.path, revision: undefined, version: file.sha256, ...headed(head) };\n }\n if (typeof file.revision !== 'string') return null;\n return { path: file.path, revision: file.revision, version: file.revision, ...headed(head) };\n}\n\nfunction parseScope(value: unknown, mode: HouseMode): HouseScope | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n if (typeof held.manifest !== 'object' || held.manifest === null) return null;\n if (!Array.isArray(held.contents)) return null;\n const manifest = held.manifest as Record<string, unknown>;\n if (manifest.scope !== 'room') return null;\n const at = readPosition(manifest);\n if (typeof manifest.anchor !== 'string' || manifest.anchor.length === 0 || at === null)\n return null;\n if (\n manifest.room_handle !== null &&\n (typeof manifest.room_handle !== 'string' || manifest.room_handle.length === 0)\n )\n return null;\n if (!Array.isArray(manifest.files)) return null;\n const files: HouseManifestFile[] = [];\n for (const entry of manifest.files) {\n const file = parseFile(entry, mode);\n if (file === null) return null;\n files.push(file);\n }\n const contents: HouseContent[] = [];\n for (const entry of held.contents) {\n if (typeof entry !== 'object' || entry === null) return null;\n const content = entry as Record<string, unknown>;\n if (typeof content.path !== 'string' || typeof content.content !== 'string') return null;\n contents.push({ path: content.path, content: content.content });\n }\n return {\n anchor: manifest.anchor,\n ...at,\n files,\n contents,\n };\n}\n\nexport function parseEnvelope(body: unknown): HouseEnvelope | null {\n if (typeof body !== 'object' || body === null) return null;\n if (!('scopes' in body) || !Array.isArray(body.scopes)) return null;\n const scopes: HouseScope[] = [];\n for (const entry of body.scopes) {\n const scope = parseScope(entry, 'credential');\n if (scope === null) return null;\n scopes.push(scope);\n }\n return { scopes };\n}\n\nexport function parseSiteBootstrap(body: unknown): HouseScope | null {\n return parseScope(body, 'site');\n}\n\nfunction parseChange(value: unknown, mode: HouseMode): HouseChange | null {\n if (typeof value !== 'object' || value === null) return null;\n const held = value as Record<string, unknown>;\n if (typeof held.path !== 'string') return null;\n if (held.removed === true) return { path: held.path, removed: true };\n const head = headChange(held);\n if (head === null) return null;\n if (mode === 'site') {\n if (typeof held.content !== 'string' || typeof held.sha256 !== 'string') return null;\n return {\n path: held.path,\n content: held.content,\n revision: undefined,\n version: held.sha256,\n ...headed(head),\n };\n }\n if (typeof held.content === 'string' && typeof held.revision === 'string') {\n return {\n path: held.path,\n content: held.content,\n revision: held.revision,\n version: held.revision,\n ...headed(head),\n };\n }\n if (typeof held.reference === 'object' && held.reference !== null) {\n const reference = held.reference as Record<string, unknown>;\n if (typeof reference.revision !== 'string') return null;\n return { path: held.path, reference: { revision: reference.revision } };\n }\n return null;\n}\n\nexport function parseEnumeration(body: unknown, mode: HouseMode): HouseEnumeration | null {\n if (typeof body !== 'object' || body === null) return null;\n if (!('authorities' in body) || !Array.isArray(body.authorities)) return null;\n const authorities: HouseEnumeration['authorities'][number][] = [];\n for (const entry of body.authorities) {\n if (typeof entry !== 'object' || entry === null) return null;\n const held = entry as Record<string, unknown>;\n const at = readPosition(held);\n if (typeof held.authority !== 'string' || at === null) return null;\n if (!Array.isArray(held.changes)) return null;\n const changes: HouseChange[] = [];\n for (const change of held.changes) {\n const mapped = parseChange(change, mode);\n if (mapped === null) return null;\n changes.push(mapped);\n }\n authorities.push({ authority: held.authority, ...at, changes });\n }\n return { authorities };\n}\n\nexport function advancedScope(\n scope: HouseScope,\n view: HouseEnumeration['authorities'][number],\n): HouseScope {\n const files = new Map(scope.files.map((file) => [file.path, file]));\n const contents = new Map(scope.contents.map((entry) => [entry.path, entry.content]));\n for (const change of view.changes) {\n files.delete(change.path);\n contents.delete(change.path);\n if ('removed' in change) continue;\n if ('content' in change) {\n files.set(change.path, {\n path: change.path,\n revision: change.revision,\n version: change.version,\n ...headed(change.head),\n });\n contents.set(change.path, change.content);\n continue;\n }\n const { revision } = change.reference;\n files.set(change.path, { path: change.path, revision, version: revision });\n }\n return {\n ...scope,\n position: view.position,\n logEpoch: view.logEpoch,\n files: [...files.values()],\n contents: [...contents].map(([path, content]) => ({ path, content })),\n };\n}\n\nexport function matchesScope(scope: HouseScope, tracked: TrackedAuthority): boolean {\n return scope.anchor === tracked.authority;\n}\n\nexport function withinRoot(path: string, root: string): boolean {\n return path === root || path.startsWith(`${root}/`);\n}\n\nexport function selects(tracked: TrackedAuthority, path: string): boolean {\n if (tracked.schemas.includes(path)) return false;\n return selectionRoots(tracked).some((root) => withinRoot(path, root));\n}\n\nexport function bootstrapFrom(envelope: HouseEnvelope, tracked: TrackedAuthority): BootstrapResult {\n const scope = envelope.scopes.find((entry) => matchesScope(entry, tracked));\n if (scope === undefined) return { kind: 'room-not-readable', locator: tracked.locator };\n return bootstrapOf(scope, tracked);\n}\n\nexport function bootstrapOf(scope: HouseScope, tracked: TrackedAuthority): BootstrapPage {\n const contents = new Map(scope.contents.map((entry) => [entry.path, entry.content]));\n const documents: Record<string, string> = {};\n const revisions: Record<string, string> = {};\n const changes: Record<string, HeadChange> = {};\n const binaryTargets: string[] = [];\n for (const file of scope.files) {\n if (!selects(tracked, file.path)) continue;\n if (file.revision !== undefined) revisions[file.path] = file.revision;\n if (file.head !== undefined) changes[file.path] = file.head;\n const content = contents.get(file.path);\n if (content === undefined) binaryTargets.push(file.path);\n else documents[file.path] = content;\n }\n return {\n kind: 'bootstrap',\n roomVersion: roomVersion(scope),\n documents,\n revisions,\n changes,\n binaryTargets: binaryTargets.sort(),\n };\n}\n\nexport type HouseSchema = {\n schema: string | null;\n version: string | null;\n};\n\nexport function schemaFrom(\n envelope: HouseEnvelope,\n tracked: TrackedAuthority,\n schema: string,\n): HouseSchema | null {\n const scope = envelope.scopes.find((entry) => matchesScope(entry, tracked));\n if (scope === undefined) return null;\n return schemaOf(scope, schema);\n}\n\nexport function schemaOf(scope: HouseScope, schema: string): HouseSchema | null {\n const file = scope.files.find((entry) => entry.path === schema);\n if (file === undefined) return { schema: null, version: null };\n const content = scope.contents.find((entry) => entry.path === schema);\n return content === undefined ? null : { schema: content.content, version: file.version };\n}\n\nexport function refreshFrom(\n enumeration: HouseEnumeration,\n tracked: TrackedAuthority,\n fromRoomVersion: string,\n): RefreshResult {\n const view = enumeration.authorities.find((entry) => entry.authority === tracked.authority);\n if (view === undefined) return { kind: 'room-not-readable', locator: tracked.locator };\n if (roomVersion(view) === fromRoomVersion) return { kind: 'still-current' };\n const documents: Record<string, string> = {};\n const revisions: Record<string, string> = {};\n const changes: Record<string, HeadChange> = {};\n const binaryTargets: string[] = [];\n const removals: string[] = [];\n for (const change of view.changes) {\n if (!selects(tracked, change.path)) continue;\n if ('removed' in change) {\n removals.push(change.path);\n continue;\n }\n if ('content' in change) {\n documents[change.path] = change.content;\n if (change.revision !== undefined) revisions[change.path] = change.revision;\n if (change.head !== undefined) changes[change.path] = change.head;\n continue;\n }\n binaryTargets.push(change.path);\n revisions[change.path] = change.reference.revision;\n }\n return {\n kind: 'net-advancement',\n roomVersion: roomVersion(view),\n documents,\n revisions,\n changes,\n binaryTargets: binaryTargets.sort(),\n removals: removals.sort(),\n };\n}\n"],"names":["PROVIDER_SELECTION_ROOTS","readPosition","roomVersion","authorityRoot","handle","undefined","ROOM_README","selectionRoots","tracked","collectionRoot","contentPrefixes","root","filter","entry","map","schemaPath","schema","parseGrant","body","transfer","url","method","operation","changeAuthor","value","user","site","name","kind","id","headChange","held","author","created_at","time","headed","head","parseFile","mode","file","path","sha256","revision","version","parseScope","manifest","Array","isArray","contents","scope","at","anchor","length","room_handle","files","push","content","parseEnvelope","scopes","parseSiteBootstrap","parseChange","removed","reference","parseEnumeration","authorities","authority","changes","change","mapped","advancedScope","view","Map","delete","set","position","logEpoch","values","matchesScope","withinRoot","startsWith","selects","schemas","includes","some","bootstrapFrom","envelope","find","locator","bootstrapOf","documents","revisions","binaryTargets","get","sort","schemaFrom","schemaOf","refreshFrom","enumeration","fromRoomVersion","removals"],"mappings":"AAMA,SAASA,wBAAwB,QAA+B,iBAAiB;AAEjF,SAASC,YAAY,EAAEC,WAAW,QAA0B,eAAe;AAgD3E,OAAO,SAASC,cAAcC,MAA0B;IACtD,OAAOA,WAAWC,YAAY,aAAa,CAAC,OAAO,EAAED,QAAQ;AAC/D;AAEA,OAAO,MAAME,cAAc,UAAU;AAErC,OAAO,SAASC,eAAeC,OAAyB;IACtD,IAAIA,QAAQJ,MAAM,KAAKC,WAAW;QAChC,OAAO;YAACG,QAAQC,cAAc;eAAKT;SAAyB;IAC9D;IACA,OAAO;QAACM;QAAaE,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S2D,OAAO3B,IAAI,GAAG;QACpC,IAAI,aAAa2B,QAAQ;YACvBgC,SAAS5C,IAAI,CAACY,OAAO3B,IAAI;YACzB;QACF;QACA,IAAI,aAAa2B,QAAQ;YACvBsB,SAAS,CAACtB,OAAO3B,IAAI,CAAC,GAAG2B,OAAOX,OAAO;YACvC,IAAIW,OAAOzB,QAAQ,KAAKrC,WAAWqF,SAAS,CAACvB,OAAO3B,IAAI,CAAC,GAAG2B,OAAOzB,QAAQ;YAC3E,IAAIyB,OAAO/B,IAAI,KAAK/B,WAAW6D,OAAO,CAACC,OAAO3B,IAAI,CAAC,GAAG2B,OAAO/B,IAAI;YACjE;QACF;QACAuD,cAAcpC,IAAI,CAACY,OAAO3B,IAAI;QAC9BkD,SAAS,CAACvB,OAAO3B,IAAI,CAAC,GAAG2B,OAAOL,SAAS,CAACpB,QAAQ;IACpD;IACA,OAAO;QACLd,MAAM;QACN1B,aAAaA,YAAYoE;QACzBmB;QACAC;QACAxB;QACAyB,eAAeA,cAAcE,IAAI;QACjCM,UAAUA,SAASN,IAAI;IACzB;AACF"}
|
package/dist/site.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,
|
|
1
|
+
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAQR,MAAM,wBAAwB,CAAC;AAgChC,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAwCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CA8JxE"}
|
package/dist/site.js
CHANGED
|
@@ -2,10 +2,10 @@ import { actionOutcome } from './actions.js';
|
|
|
2
2
|
import { mapDiscovery, parseSiteDiscovery, siteCapabilities, siteSlots, siteTracked } from './discovery.js';
|
|
3
3
|
import { MODEL_ABSENT, failedModel, heldModel, modelKey, modelShelf } from './model.js';
|
|
4
4
|
import { advancedScope, bootstrapOf, parseEnumeration, parseSiteBootstrap, refreshFrom, schemaOf, schemaPath, selectionRoots } from './read.js';
|
|
5
|
-
import { classifyDoor, discoveryFailure } from './refusal.js';
|
|
5
|
+
import { classifyDoor, discoveryFailure, doorRefusal } from './refusal.js';
|
|
6
6
|
import { houseNotifications } from './stream.js';
|
|
7
7
|
import { PRIVATE_LOCATOR, SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT } from './transport.js';
|
|
8
|
-
import { logPosition, presented, roomVersion } from './version.js';
|
|
8
|
+
import { logPosition, presented, reachedVersion, roomVersion } from './version.js';
|
|
9
9
|
const UNCERTAIN = {
|
|
10
10
|
kind: 'transport-uncertainty'
|
|
11
11
|
};
|
|
@@ -35,7 +35,7 @@ function siteRoom(tracked, attachedModel) {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
function settled(refused) {
|
|
38
|
-
return refused.kind === 'beyond-horizon' ? UNCERTAIN : refused;
|
|
38
|
+
return refused.kind === 'beyond-horizon' || refused.kind === 'retryable-refusal' ? UNCERTAIN : refused;
|
|
39
39
|
}
|
|
40
40
|
export function createSiteAdapter(transport) {
|
|
41
41
|
const notifications = houseNotifications(transport, 'site');
|
|
@@ -49,6 +49,11 @@ export function createSiteAdapter(transport) {
|
|
|
49
49
|
presented(entry.authority, from)
|
|
50
50
|
]
|
|
51
51
|
});
|
|
52
|
+
const behind = doorRefusal(answer.body);
|
|
53
|
+
if (behind?.code === 'replica_behind') return {
|
|
54
|
+
kind: 'retryable-refusal',
|
|
55
|
+
...behind
|
|
56
|
+
};
|
|
52
57
|
const classified = classifyDoor(answer.status, answer.body, entry.locator);
|
|
53
58
|
if (classified !== null) return classified;
|
|
54
59
|
return parseEnumeration(answer.body, 'site') ?? UNCERTAIN;
|
|
@@ -170,6 +175,14 @@ export function createSiteAdapter(transport) {
|
|
|
170
175
|
if (request.pageToken !== undefined) return UNCERTAIN;
|
|
171
176
|
const result = await refreshed(entry, request.fromRoomVersion);
|
|
172
177
|
if (result.kind === 'beyond-horizon') caught.delete(entry.authority);
|
|
178
|
+
const answered = result.kind === 'net-advancement' ? result.roomVersion : result.kind === 'still-current' ? request.fromRoomVersion : null;
|
|
179
|
+
if (request.reach !== undefined && answered !== null && !reachedVersion(answered, request.reach, entry.logEpoch)) {
|
|
180
|
+
return {
|
|
181
|
+
kind: 'retryable-refusal',
|
|
182
|
+
code: 'replica_behind',
|
|
183
|
+
fields: {}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
173
186
|
return result;
|
|
174
187
|
},
|
|
175
188
|
async mutate () {
|
|
@@ -185,6 +198,9 @@ export function createSiteAdapter(transport) {
|
|
|
185
198
|
kind: 'no-history'
|
|
186
199
|
};
|
|
187
200
|
},
|
|
201
|
+
reached (locator, version, target) {
|
|
202
|
+
return reachedVersion(version, target, tracked.get(locator)?.logEpoch);
|
|
203
|
+
},
|
|
188
204
|
async action (_authorization, request) {
|
|
189
205
|
if (request.name !== 'submit') {
|
|
190
206
|
return {
|
package/dist/site.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/site.ts"],"sourcesContent":["import type {\n Adapter,\n AdapterFailure,\n BootstrapResult,\n DiscoverResult,\n DiscoveredRoom,\n ModelResult,\n RefreshResult,\n} from '@agentshouse/mdruntime';\nimport { actionOutcome } from './actions.js';\nimport {\n mapDiscovery,\n parseSiteDiscovery,\n siteCapabilities,\n siteSlots,\n siteTracked,\n type SiteTracked,\n} from './discovery.js';\nimport {\n MODEL_ABSENT,\n failedModel,\n heldModel,\n modelKey,\n modelShelf,\n type HeldModel,\n} from './model.js';\nimport {\n advancedScope,\n bootstrapOf,\n parseEnumeration,\n parseSiteBootstrap,\n refreshFrom,\n schemaOf,\n schemaPath,\n selectionRoots,\n type HouseEnumeration,\n type HouseScope,\n} from './read.js';\nimport { classifyDoor, discoveryFailure } from './refusal.js';\nimport { houseNotifications } from './stream.js';\nimport {\n PRIVATE_LOCATOR,\n SITE_DOOR_BOOTSTRAP,\n SITE_DOOR_DISCOVER,\n SITE_DOOR_ENUMERATE,\n SITE_DOOR_SUBMIT,\n type HouseSiteTransport,\n} from './transport.js';\nimport { logPosition, presented, roomVersion, type LogPosition } from './version.js';\n\ntype Refused = AdapterFailure | { kind: 'beyond-horizon' };\n\ntype CaughtUp = { scope: HouseScope } | { failure: AdapterFailure };\n\ntype Acquired = { roomVersion: string; model: HeldModel };\n\nconst UNCERTAIN = { kind: 'transport-uncertainty' } as const;\n\nfunction siteRoom(\n tracked: SiteTracked,\n attachedModel: DiscoveredRoom['attachedModel'],\n): DiscoveredRoom {\n const read = selectionRoots(tracked);\n return {\n name: tracked.handle,\n locator: tracked.locator,\n collectionRoot: tracked.collectionRoot,\n roomVersion: roomVersion(tracked),\n operations: { read: [...read], sync: [...read], write: [], delete: [] },\n replica: { selection: tracked.locator, admission: 'admitted' },\n attachedModel,\n providerOwnedPaths: [],\n };\n}\n\nfunction settled(refused: Refused): AdapterFailure {\n return refused.kind === 'beyond-horizon' ? UNCERTAIN : refused;\n}\n\nexport function createSiteAdapter(transport: HouseSiteTransport): Adapter {\n const notifications = houseNotifications(transport, 'site');\n const tracked = new Map<string, SiteTracked>();\n const models = modelShelf();\n const acquired = new Map<string, Acquired>();\n let caught = new Map<string, CaughtUp>();\n\n async function enumeration(\n entry: SiteTracked,\n from: LogPosition,\n ): Promise<HouseEnumeration | Refused> {\n const answer = await transport.door(SITE_DOOR_ENUMERATE, {\n positions: [presented(entry.authority, from)],\n });\n const classified = classifyDoor(answer.status, answer.body, entry.locator);\n if (classified !== null) return classified;\n return parseEnumeration(answer.body, 'site') ?? UNCERTAIN;\n }\n\n async function caughtUp(entry: SiteTracked): Promise<CaughtUp> {\n const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}`);\n const classified = classifyDoor(answer.status, answer.body, entry.locator);\n if (classified !== null) return { failure: settled(classified) };\n const scope = parseSiteBootstrap(answer.body);\n if (scope === null) return { failure: UNCERTAIN };\n if (roomVersion(scope) === roomVersion(entry)) return { scope };\n const found = await enumeration(entry, scope);\n if ('kind' in found) return { failure: settled(found) };\n const view = found.authorities.find((held) => held.authority === entry.authority);\n if (view === undefined)\n return { failure: { kind: 'room-not-readable', locator: entry.locator } };\n return { scope: advancedScope(scope, view) };\n }\n\n async function refreshed(entry: SiteTracked, fromRoomVersion: string): Promise<RefreshResult> {\n const from = logPosition(fromRoomVersion);\n if (from === null) return { kind: 'beyond-horizon' };\n const streamed = notifications.advance(entry, from);\n if (streamed !== null) return streamed;\n const found = await enumeration(entry, from);\n if ('kind' in found) return found;\n return refreshFrom(found, entry, fromRoomVersion);\n }\n\n async function acquire(entry: SiteTracked, held: CaughtUp): Promise<HeldModel> {\n if ('failure' in held) return { snapshot: failedModel(held.failure), identity: null };\n const model = await heldModel(\n schemaOf(held.scope, entry.schema),\n schemaPath(entry.handle, entry.schema),\n MODEL_ABSENT,\n );\n acquired.set(entry.authority, { roomVersion: roomVersion(held.scope), model });\n return model;\n }\n\n return {\n async authorize() {\n return {};\n },\n\n async model(_authorization, request): Promise<ModelResult> {\n return models.answer(request);\n },\n\n async discover(): Promise<DiscoverResult> {\n const answer = await transport.read(SITE_DOOR_DISCOVER);\n const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);\n if (classified !== null) return discoveryFailure(classified);\n const document = parseSiteDiscovery(answer.body);\n if (document === null) return UNCERTAIN;\n const entries = siteTracked(document);\n tracked.clear();\n for (const entry of entries) tracked.set(entry.locator, entry);\n notifications.track(entries);\n const published = new Set(entries.map((entry) => entry.authority));\n for (const authority of [...acquired.keys()]) {\n if (!published.has(authority)) acquired.delete(authority);\n }\n const fresh = new Map<string, CaughtUp>();\n const current = new Map<string, HeldModel>();\n for (const entry of entries) {\n const kept = acquired.get(entry.authority);\n if (kept !== undefined && kept.roomVersion === roomVersion(entry)) {\n current.set(entry.authority, kept.model);\n continue;\n }\n const held = await caughtUp(entry);\n fresh.set(entry.authority, held);\n current.set(entry.authority, await acquire(entry, held));\n }\n caught = fresh;\n const rooms = entries.map((entry) => {\n const shelved = models.retain(\n modelKey(entry.locator, 'collection'),\n current.get(entry.authority),\n );\n return siteRoom(entry, shelved?.identity ?? null);\n });\n models.keep(entries.map((entry) => entry.locator));\n return { ...mapDiscovery(document, rooms, siteCapabilities()), slots: siteSlots(document) };\n },\n\n async bootstrap(_authorization, request): Promise<BootstrapResult> {\n const entry = tracked.get(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return UNCERTAIN;\n const held = caught.get(entry.authority) ?? (await caughtUp(entry));\n if ('failure' in held) return held.failure;\n return bootstrapOf(held.scope, entry);\n },\n\n async refresh(_authorization, request): Promise<RefreshResult> {\n const entry = tracked.get(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return UNCERTAIN;\n const result = await refreshed(entry, request.fromRoomVersion);\n if (result.kind === 'beyond-horizon') caught.delete(entry.authority);\n return result;\n },\n\n async mutate() {\n return { kind: 'rejected', affected: {}, code: 'write-grant', fields: {} };\n },\n\n async history() {\n return { kind: 'no-history' };\n },\n\n async action(_authorization, request) {\n if (request.name !== 'submit') {\n return { kind: 'rejected', code: 'action-unimplemented', fields: { name: request.name } };\n }\n if (!transport.online()) return UNCERTAIN;\n return actionOutcome(await transport.door(SITE_DOOR_SUBMIT, request.input), 'submit');\n },\n\n roomVersions: notifications,\n serviceMode: notifications.serviceMode,\n };\n}\n"],"names":["actionOutcome","mapDiscovery","parseSiteDiscovery","siteCapabilities","siteSlots","siteTracked","MODEL_ABSENT","failedModel","heldModel","modelKey","modelShelf","advancedScope","bootstrapOf","parseEnumeration","parseSiteBootstrap","refreshFrom","schemaOf","schemaPath","selectionRoots","classifyDoor","discoveryFailure","houseNotifications","PRIVATE_LOCATOR","SITE_DOOR_BOOTSTRAP","SITE_DOOR_DISCOVER","SITE_DOOR_ENUMERATE","SITE_DOOR_SUBMIT","logPosition","presented","roomVersion","UNCERTAIN","kind","siteRoom","tracked","attachedModel","read","name","handle","locator","collectionRoot","operations","sync","write","delete","replica","selection","admission","providerOwnedPaths","settled","refused","createSiteAdapter","transport","notifications","Map","models","acquired","caught","enumeration","entry","from","answer","door","positions","authority","classified","status","body","caughtUp","failure","scope","found","view","authorities","find","held","undefined","refreshed","fromRoomVersion","streamed","advance","acquire","snapshot","identity","model","schema","set","authorize","_authorization","request","discover","document","entries","clear","track","published","Set","map","keys","has","fresh","current","kept","get","rooms","shelved","retain","keep","slots","bootstrap","pageToken","refresh","result","mutate","affected","code","fields","history","action","online","input","roomVersions","serviceMode"],"mappings":"AASA,SAASA,aAAa,QAAQ,eAAe;AAC7C,SACEC,YAAY,EACZC,kBAAkB,EAClBC,gBAAgB,EAChBC,SAAS,EACTC,WAAW,QAEN,iBAAiB;AACxB,SACEC,YAAY,EACZC,WAAW,EACXC,SAAS,EACTC,QAAQ,EACRC,UAAU,QAEL,aAAa;AACpB,SACEC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,kBAAkB,EAClBC,WAAW,EACXC,QAAQ,EACRC,UAAU,EACVC,cAAc,QAGT,YAAY;AACnB,SAASC,YAAY,EAAEC,gBAAgB,QAAQ,eAAe;AAC9D,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SACEC,eAAe,EACfC,mBAAmB,EACnBC,kBAAkB,EAClBC,mBAAmB,EACnBC,gBAAgB,QAEX,iBAAiB;AACxB,SAASC,WAAW,EAAEC,SAAS,EAAEC,WAAW,QAA0B,eAAe;AAQrF,MAAMC,YAAY;IAAEC,MAAM;AAAwB;AAElD,SAASC,SACPC,OAAoB,EACpBC,aAA8C;IAE9C,MAAMC,OAAOjB,eAAee;IAC5B,OAAO;QACLG,MAAMH,QAAQI,MAAM;QACpB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AAU,CAAC;gBAAGC,MAAM;gBAAeC,QAAQ,CAAC;YAAE;QAC3E;QAEA,MAAMC;YACJ,OAAO;gBAAErF,MAAM;YAAa;QAC9B;QAEA,MAAMsF,QAAO9B,cAAc,EAAEC,OAAO;YAClC,IAAIA,QAAQpD,IAAI,KAAK,UAAU;gBAC7B,OAAO;oBAAEL,MAAM;oBAAYmF,MAAM;oBAAwBC,QAAQ;wBAAE/E,MAAMoD,QAAQpD,IAAI;oBAAC;gBAAE;YAC1F;YACA,IAAI,CAACe,UAAUmE,MAAM,IAAI,OAAOxF;YAChC,OAAO9B,cAAc,MAAMmD,UAAUU,IAAI,CAACnC,kBAAkB8D,QAAQ+B,KAAK,GAAG;QAC9E;QAEAC,cAAcpE;QACdqE,aAAarE,cAAcqE,WAAW;IACxC;AACF"}
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/site.ts"],"sourcesContent":["import type {\n Adapter,\n AdapterFailure,\n BootstrapResult,\n DiscoverResult,\n DiscoveredRoom,\n ModelResult,\n RefreshResult,\n RetryableRefusal,\n} from '@agentshouse/mdruntime';\nimport { actionOutcome } from './actions.js';\nimport {\n mapDiscovery,\n parseSiteDiscovery,\n siteCapabilities,\n siteSlots,\n siteTracked,\n type SiteTracked,\n} from './discovery.js';\nimport {\n MODEL_ABSENT,\n failedModel,\n heldModel,\n modelKey,\n modelShelf,\n type HeldModel,\n} from './model.js';\nimport {\n advancedScope,\n bootstrapOf,\n parseEnumeration,\n parseSiteBootstrap,\n refreshFrom,\n schemaOf,\n schemaPath,\n selectionRoots,\n type HouseEnumeration,\n type HouseScope,\n} from './read.js';\nimport { classifyDoor, discoveryFailure, doorRefusal } from './refusal.js';\nimport { houseNotifications } from './stream.js';\nimport {\n PRIVATE_LOCATOR,\n SITE_DOOR_BOOTSTRAP,\n SITE_DOOR_DISCOVER,\n SITE_DOOR_ENUMERATE,\n SITE_DOOR_SUBMIT,\n type HouseSiteTransport,\n} from './transport.js';\nimport {\n logPosition,\n presented,\n reachedVersion,\n roomVersion,\n type LogPosition,\n} from './version.js';\n\ntype Refused = AdapterFailure | RetryableRefusal | { kind: 'beyond-horizon' };\n\ntype CaughtUp = { scope: HouseScope } | { failure: AdapterFailure };\n\ntype Acquired = { roomVersion: string; model: HeldModel };\n\nconst UNCERTAIN = { kind: 'transport-uncertainty' } as const;\n\nfunction siteRoom(\n tracked: SiteTracked,\n attachedModel: DiscoveredRoom['attachedModel'],\n): DiscoveredRoom {\n const read = selectionRoots(tracked);\n return {\n name: tracked.handle,\n locator: tracked.locator,\n collectionRoot: tracked.collectionRoot,\n roomVersion: roomVersion(tracked),\n operations: { read: [...read], sync: [...read], write: [], delete: [] },\n replica: { selection: tracked.locator, admission: 'admitted' },\n attachedModel,\n providerOwnedPaths: [],\n };\n}\n\nfunction settled(refused: Refused): AdapterFailure {\n return refused.kind === 'beyond-horizon' || refused.kind === 'retryable-refusal'\n ? UNCERTAIN\n : refused;\n}\n\nexport function createSiteAdapter(transport: HouseSiteTransport): Adapter {\n const notifications = houseNotifications(transport, 'site');\n const tracked = new Map<string, SiteTracked>();\n const models = modelShelf();\n const acquired = new Map<string, Acquired>();\n let caught = new Map<string, CaughtUp>();\n\n async function enumeration(\n entry: SiteTracked,\n from: LogPosition,\n ): Promise<HouseEnumeration | Refused> {\n const answer = await transport.door(SITE_DOOR_ENUMERATE, {\n positions: [presented(entry.authority, from)],\n });\n const behind = doorRefusal(answer.body);\n if (behind?.code === 'replica_behind') return { kind: 'retryable-refusal', ...behind };\n const classified = classifyDoor(answer.status, answer.body, entry.locator);\n if (classified !== null) return classified;\n return parseEnumeration(answer.body, 'site') ?? UNCERTAIN;\n }\n\n async function caughtUp(entry: SiteTracked): Promise<CaughtUp> {\n const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}`);\n const classified = classifyDoor(answer.status, answer.body, entry.locator);\n if (classified !== null) return { failure: settled(classified) };\n const scope = parseSiteBootstrap(answer.body);\n if (scope === null) return { failure: UNCERTAIN };\n if (roomVersion(scope) === roomVersion(entry)) return { scope };\n const found = await enumeration(entry, scope);\n if ('kind' in found) return { failure: settled(found) };\n const view = found.authorities.find((held) => held.authority === entry.authority);\n if (view === undefined)\n return { failure: { kind: 'room-not-readable', locator: entry.locator } };\n return { scope: advancedScope(scope, view) };\n }\n\n async function refreshed(entry: SiteTracked, fromRoomVersion: string): Promise<RefreshResult> {\n const from = logPosition(fromRoomVersion);\n if (from === null) return { kind: 'beyond-horizon' };\n const streamed = notifications.advance(entry, from);\n if (streamed !== null) return streamed;\n const found = await enumeration(entry, from);\n if ('kind' in found) return found;\n return refreshFrom(found, entry, fromRoomVersion);\n }\n\n async function acquire(entry: SiteTracked, held: CaughtUp): Promise<HeldModel> {\n if ('failure' in held) return { snapshot: failedModel(held.failure), identity: null };\n const model = await heldModel(\n schemaOf(held.scope, entry.schema),\n schemaPath(entry.handle, entry.schema),\n MODEL_ABSENT,\n );\n acquired.set(entry.authority, { roomVersion: roomVersion(held.scope), model });\n return model;\n }\n\n return {\n async authorize() {\n return {};\n },\n\n async model(_authorization, request): Promise<ModelResult> {\n return models.answer(request);\n },\n\n async discover(): Promise<DiscoverResult> {\n const answer = await transport.read(SITE_DOOR_DISCOVER);\n const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);\n if (classified !== null) return discoveryFailure(classified);\n const document = parseSiteDiscovery(answer.body);\n if (document === null) return UNCERTAIN;\n const entries = siteTracked(document);\n tracked.clear();\n for (const entry of entries) tracked.set(entry.locator, entry);\n notifications.track(entries);\n const published = new Set(entries.map((entry) => entry.authority));\n for (const authority of [...acquired.keys()]) {\n if (!published.has(authority)) acquired.delete(authority);\n }\n const fresh = new Map<string, CaughtUp>();\n const current = new Map<string, HeldModel>();\n for (const entry of entries) {\n const kept = acquired.get(entry.authority);\n if (kept !== undefined && kept.roomVersion === roomVersion(entry)) {\n current.set(entry.authority, kept.model);\n continue;\n }\n const held = await caughtUp(entry);\n fresh.set(entry.authority, held);\n current.set(entry.authority, await acquire(entry, held));\n }\n caught = fresh;\n const rooms = entries.map((entry) => {\n const shelved = models.retain(\n modelKey(entry.locator, 'collection'),\n current.get(entry.authority),\n );\n return siteRoom(entry, shelved?.identity ?? null);\n });\n models.keep(entries.map((entry) => entry.locator));\n return { ...mapDiscovery(document, rooms, siteCapabilities()), slots: siteSlots(document) };\n },\n\n async bootstrap(_authorization, request): Promise<BootstrapResult> {\n const entry = tracked.get(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return UNCERTAIN;\n const held = caught.get(entry.authority) ?? (await caughtUp(entry));\n if ('failure' in held) return held.failure;\n return bootstrapOf(held.scope, entry);\n },\n\n async refresh(_authorization, request): Promise<RefreshResult> {\n const entry = tracked.get(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return UNCERTAIN;\n const result = await refreshed(entry, request.fromRoomVersion);\n if (result.kind === 'beyond-horizon') caught.delete(entry.authority);\n const answered =\n result.kind === 'net-advancement'\n ? result.roomVersion\n : result.kind === 'still-current'\n ? request.fromRoomVersion\n : null;\n if (\n request.reach !== undefined &&\n answered !== null &&\n !reachedVersion(answered, request.reach, entry.logEpoch)\n ) {\n return { kind: 'retryable-refusal', code: 'replica_behind', fields: {} };\n }\n return result;\n },\n\n async mutate() {\n return { kind: 'rejected', affected: {}, code: 'write-grant', fields: {} };\n },\n\n async history() {\n return { kind: 'no-history' };\n },\n\n reached(locator, version, target) {\n return reachedVersion(version, target, tracked.get(locator)?.logEpoch);\n },\n\n async action(_authorization, request) {\n if (request.name !== 'submit') {\n return { kind: 'rejected', code: 'action-unimplemented', fields: { name: request.name } };\n }\n if (!transport.online()) return UNCERTAIN;\n return actionOutcome(await transport.door(SITE_DOOR_SUBMIT, request.input), 'submit');\n },\n\n roomVersions: notifications,\n serviceMode: notifications.serviceMode,\n };\n}\n"],"names":["actionOutcome","mapDiscovery","parseSiteDiscovery","siteCapabilities","siteSlots","siteTracked","MODEL_ABSENT","failedModel","heldModel","modelKey","modelShelf","advancedScope","bootstrapOf","parseEnumeration","parseSiteBootstrap","refreshFrom","schemaOf","schemaPath","selectionRoots","classifyDoor","discoveryFailure","doorRefusal","houseNotifications","PRIVATE_LOCATOR","SITE_DOOR_BOOTSTRAP","SITE_DOOR_DISCOVER","SITE_DOOR_ENUMERATE","SITE_DOOR_SUBMIT","logPosition","presented","reachedVersion","roomVersion","UNCERTAIN","kind","siteRoom","tracked","attachedModel","read","name","handle","locator","collectionRoot","operations","sync","write","delete","replica","selection","admission","providerOwnedPaths","settled","refused","createSiteAdapter","transport","notifications","Map","models","acquired","caught","enumeration","entry","from","answer","door","positions","authority","behind","body","code","classified","status","caughtUp","failure","scope","found","view","authorities","find","held","undefined","refreshed","fromRoomVersion","streamed","advance","acquire","snapshot","identity","model","schema","set","authorize","_authorization","request","discover","document","entries","clear","track","published","Set","map","keys","has","fresh","current","kept","get","rooms","shelved","retain","keep","slots","bootstrap","pageToken","refresh","result","answered","reach","logEpoch","fields","mutate","affected","history","reached","version","target","action","online","input","roomVersions","serviceMode"],"mappings":"AAUA,SAASA,aAAa,QAAQ,eAAe;AAC7C,SACEC,YAAY,EACZC,kBAAkB,EAClBC,gBAAgB,EAChBC,SAAS,EACTC,WAAW,QAEN,iBAAiB;AACxB,SACEC,YAAY,EACZC,WAAW,EACXC,SAAS,EACTC,QAAQ,EACRC,UAAU,QAEL,aAAa;AACpB,SACEC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,kBAAkB,EAClBC,WAAW,EACXC,QAAQ,EACRC,UAAU,EACVC,cAAc,QAGT,YAAY;AACnB,SAASC,YAAY,EAAEC,gBAAgB,EAAEC,WAAW,QAAQ,eAAe;AAC3E,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SACEC,eAAe,EACfC,mBAAmB,EACnBC,kBAAkB,EAClBC,mBAAmB,EACnBC,gBAAgB,QAEX,iBAAiB;AACxB,SACEC,WAAW,EACX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AK,GAAG;QAC9E;QAEAC,cAAc3E;QACd4E,aAAa5E,cAAc4E,WAAW;IACxC;AACF"}
|
package/dist/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,WAAW,EAEX,aAAa,EAEb,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,SAAS,EAGf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAgB7D,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtD,OAAO,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,WAAW,GAAG,IAAI,CAAC;IAC1E,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC,CAAC;AAOF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,WAAW,EAEX,aAAa,EAEb,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,SAAS,EAGf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAgB7D,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtD,OAAO,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,WAAW,GAAG,IAAI,CAAC;IAC1E,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC,CAAC;AAOF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,CAkS5F"}
|
package/dist/stream.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { acceptedMessage, actionOutcome } from './actions.js';
|
|
2
|
-
import { selects } from './read.js';
|
|
2
|
+
import { headChange, selects } from './read.js';
|
|
3
3
|
import { PRIVATE_LOCATOR } from './transport.js';
|
|
4
4
|
import { roomVersion } from './version.js';
|
|
5
5
|
const HELD_POSITIONS_MAX = 256;
|
|
@@ -294,6 +294,7 @@ export function houseNotifications(transport, mode) {
|
|
|
294
294
|
const pending = line.frames.slice(at);
|
|
295
295
|
const documents = {};
|
|
296
296
|
const revisions = {};
|
|
297
|
+
const changes = {};
|
|
297
298
|
const removals = [];
|
|
298
299
|
for (const frame of pending){
|
|
299
300
|
for (const entry of frame.entries){
|
|
@@ -301,13 +302,18 @@ export function houseNotifications(transport, mode) {
|
|
|
301
302
|
if (entry.kind === 'removed') {
|
|
302
303
|
delete documents[entry.path];
|
|
303
304
|
delete revisions[entry.path];
|
|
305
|
+
delete changes[entry.path];
|
|
304
306
|
if (!removals.includes(entry.path)) removals.push(entry.path);
|
|
305
307
|
continue;
|
|
306
308
|
}
|
|
307
309
|
if (entry.text === undefined) return null;
|
|
308
310
|
if (mode === 'credential' && entry.revision === undefined) return null;
|
|
311
|
+
const head = headChange(entry);
|
|
312
|
+
if (head === null) return null;
|
|
309
313
|
documents[entry.path] = entry.text;
|
|
310
314
|
if (entry.revision !== undefined) revisions[entry.path] = entry.revision;
|
|
315
|
+
if (head === undefined) delete changes[entry.path];
|
|
316
|
+
else changes[entry.path] = head;
|
|
311
317
|
const removed = removals.indexOf(entry.path);
|
|
312
318
|
if (removed !== -1) removals.splice(removed, 1);
|
|
313
319
|
}
|
|
@@ -326,6 +332,7 @@ export function houseNotifications(transport, mode) {
|
|
|
326
332
|
}),
|
|
327
333
|
documents,
|
|
328
334
|
revisions,
|
|
335
|
+
changes,
|
|
329
336
|
binaryTargets: [],
|
|
330
337
|
removals: removals.sort()
|
|
331
338
|
};
|
package/dist/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/stream.ts"],"sourcesContent":["import type {\n ConversationEvent,\n ConversationStream,\n RefreshPage,\n RoomVersionNotification,\n SelectedRooms,\n ServiceMode,\n ServiceModeSignal,\n} from '@agentshouse/mdruntime';\nimport { acceptedMessage, actionOutcome } from './actions.js';\nimport type { TrackedAuthority } from './discovery.js';\nimport { selects } from './read.js';\nimport {\n PRIVATE_LOCATOR,\n type HouseDoor,\n type HouseMode,\n type HouseStreamEntry,\n type HouseStreamFrame,\n} from './transport.js';\nimport { roomVersion, type LogPosition } from './version.js';\n\nconst HELD_POSITIONS_MAX = 256;\n\nconst CONVERSATION_CARD = /^agents\\/([^/]+)\\.md$/;\n\ntype HeldFrame = {\n position: bigint;\n entries: readonly HouseStreamEntry[];\n};\n\ntype HeldLine = {\n logEpoch: string;\n frames: readonly HeldFrame[];\n};\n\nexport type HouseNotifications = SelectedRooms & {\n track(authorities: readonly TrackedAuthority[]): void;\n advance(tracked: TrackedAuthority, from: LogPosition): RefreshPage | null;\n conversations: ConversationStream;\n serviceMode: ServiceModeSignal;\n question(conversation: string): void;\n};\n\nfunction position(value: string): bigint | null {\n if (!/^(?:0|[1-9][0-9]*)$/.test(value)) return null;\n return BigInt(value);\n}\n\nexport function houseNotifications(transport: HouseDoor, mode: HouseMode): HouseNotifications {\n const stream = transport.stream;\n const lines = new Map<string, HeldLine>();\n const locators = new Map<string, string[]>();\n const schemas = new Map<string, readonly string[]>();\n const observers = new Set<(notification: RoomVersionNotification) => void>();\n const conversationObservers = new Set<(event: ConversationEvent) => void>();\n const modeObservers = new Set<(mode: ServiceMode) => void>();\n let replicated: readonly string[] = [];\n let privateAuthority: string | undefined;\n const live = new Set<string>();\n const noted = new Set<string>();\n const asked = new Map<string, number>();\n let listening = false;\n let catching = false;\n\n function listen() {\n if (listening) return;\n listening = true;\n stream.observe(receive);\n }\n\n function emitConversation(event: ConversationEvent) {\n if (event.kind !== 'gap' && event.kind !== 'accepted-message') live.add(event.conversation);\n for (const observer of conversationObservers) observer(event);\n }\n\n function unnote(conversation: string) {\n if (!noted.delete(conversation)) return;\n emitConversation({ kind: 'working-note', conversation, note: null });\n }\n\n async function question(conversation: string) {\n const sequence = (asked.get(conversation) ?? 0) + 1;\n asked.set(conversation, sequence);\n const answer = await transport.door('/door/conversations/interaction/read', {\n conversation_id: conversation,\n });\n if (asked.get(conversation) !== sequence || !replicated.includes(conversation)) return;\n const outcome = actionOutcome(answer, 'conversations/interaction/read');\n if (outcome.kind !== 'action') return;\n const { interactions } = outcome.result as { interactions?: unknown };\n if (!Array.isArray(interactions)) return;\n emitConversation({\n kind: 'questions',\n conversation,\n questions: structuredClone(interactions),\n });\n }\n\n function reopened() {\n const gapped = new Set([...replicated, ...live]);\n live.clear();\n noted.clear();\n for (const conversation of gapped) emitConversation({ kind: 'gap', conversation });\n for (const conversation of replicated) void question(conversation);\n }\n\n function converse(frame: Exclude<HouseStreamFrame, { type: 'entries' | 'signal' }>) {\n const conversation = frame.conversation_id;\n if (frame.type === 'draft') {\n unnote(conversation);\n emitConversation({\n kind: 'growing-text',\n conversation,\n turn: frame.turn_id,\n text: frame.text,\n });\n emitConversation({\n kind: 'plan',\n conversation,\n turn: frame.turn_id,\n plan: structuredClone(frame.steps),\n });\n return;\n }\n if (frame.type === 'working-note') {\n noted.add(conversation);\n emitConversation({\n kind: 'working-note',\n conversation,\n note: { noteId: frame.note_id, text: frame.text },\n });\n return;\n }\n if (frame.type === 'process') {\n emitConversation({ kind: 'process', conversation, running: frame.running });\n if (frame.running) return;\n emitConversation({ kind: 'commands', conversation, commands: [] });\n emitConversation({ kind: 'options', conversation, options: [] });\n unnote(conversation);\n return;\n }\n if (frame.type === 'commands') {\n emitConversation({\n kind: 'commands',\n conversation,\n commands: structuredClone(frame.commands),\n });\n return;\n }\n if (frame.type === 'options') {\n emitConversation({ kind: 'options', conversation, options: structuredClone(frame.options) });\n return;\n }\n const message = acceptedMessage(frame.message);\n if (message === null) return;\n emitConversation({ kind: 'accepted-message', conversation, message });\n if ((frame.message as { role?: unknown }).role === 'user') return;\n unnote(conversation);\n }\n\n function announce(authority: string, at: LogPosition, modelChanged: boolean) {\n const version = roomVersion(at);\n for (const locator of locators.get(authority) ?? []) {\n for (const observer of observers) {\n observer(\n modelChanged\n ? { locator, roomVersion: version, modelChanged: true }\n : { locator, roomVersion: version },\n );\n }\n }\n }\n\n function interrupt(authority: string) {\n const line = lines.get(authority);\n if (line !== undefined) lines.set(authority, { logEpoch: line.logEpoch, frames: [] });\n }\n\n function receive(frame: HouseStreamFrame) {\n if (frame.type === 'signal') {\n const mode = frame.service_mode;\n if (mode !== 'open' && mode !== 'write-halted') return;\n for (const observer of modeObservers) observer(mode);\n return;\n }\n if (\n frame.type === 'draft' ||\n frame.type === 'working-note' ||\n frame.type === 'process' ||\n frame.type === 'commands' ||\n frame.type === 'options' ||\n frame.type === 'message'\n ) {\n converse(frame);\n return;\n }\n if (frame.type !== 'entries') return;\n if (frame.authority === privateAuthority) {\n for (const entry of frame.entries) {\n const card = CONVERSATION_CARD.exec(entry.path);\n const conversation = card?.[1];\n if (\n conversation !== undefined &&\n entry.kind === 'edited' &&\n replicated.includes(conversation)\n ) {\n void question(conversation);\n }\n }\n }\n const at = position(frame.position);\n if (at === null) {\n interrupt(frame.authority);\n return;\n }\n const line = lines.get(frame.authority);\n if (line?.logEpoch === frame.log_epoch) {\n const last = line.frames.at(-1);\n const continued = last !== undefined && last.position + 1n === at;\n const next = continued\n ? [...line.frames, { position: at, entries: frame.entries }]\n : [{ position: at, entries: frame.entries }];\n lines.set(frame.authority, {\n logEpoch: line.logEpoch,\n frames: next.length > HELD_POSITIONS_MAX ? [] : next,\n });\n } else {\n interrupt(frame.authority);\n }\n const addresses = schemas.get(frame.authority) ?? [];\n announce(\n frame.authority,\n { position: frame.position, logEpoch: frame.log_epoch },\n frame.entries.some((entry) => addresses.includes(entry.path)),\n );\n }\n\n return {\n serviceMode: {\n observe(notify) {\n modeObservers.add(notify);\n listen();\n return () => {\n modeObservers.delete(notify);\n };\n },\n },\n question(conversation) {\n void question(conversation);\n },\n conversations: {\n replicate(next) {\n const entering = next.filter((conversation) => !replicated.includes(conversation));\n replicated = [...next];\n for (const conversation of entering) void question(conversation);\n },\n observe(notify) {\n conversationObservers.add(notify);\n listen();\n if (!catching) {\n catching = true;\n stream.opened(reopened);\n }\n return () => {\n conversationObservers.delete(notify);\n };\n },\n },\n track(entries) {\n locators.clear();\n schemas.clear();\n privateAuthority = entries.find((entry) => entry.locator === PRIVATE_LOCATOR)?.authority;\n for (const entry of entries) {\n locators.set(entry.authority, [...(locators.get(entry.authority) ?? []), entry.locator]);\n schemas.set(entry.authority, entry.schemas);\n if (lines.get(entry.authority)?.logEpoch !== entry.logEpoch) {\n lines.set(entry.authority, { logEpoch: entry.logEpoch, frames: [] });\n }\n }\n for (const authority of lines.keys()) {\n if (!locators.has(authority)) lines.delete(authority);\n }\n },\n select() {},\n observe(notify) {\n observers.add(notify);\n listen();\n return () => {\n observers.delete(notify);\n };\n },\n advance(tracked, from) {\n const line = lines.get(tracked.authority);\n const start = position(from.position);\n if (line === undefined || start === null || line.logEpoch !== from.logEpoch) return null;\n const at = line.frames.findIndex((frame) => frame.position === start + 1n);\n if (at === -1) return null;\n const pending = line.frames.slice(at);\n const documents: Record<string, string> = {};\n const revisions: Record<string, string> = {};\n const removals: string[] = [];\n for (const frame of pending) {\n for (const entry of frame.entries) {\n if (!selects(tracked, entry.path)) continue;\n if (entry.kind === 'removed') {\n delete documents[entry.path];\n delete revisions[entry.path];\n if (!removals.includes(entry.path)) removals.push(entry.path);\n continue;\n }\n if (entry.text === undefined) return null;\n if (mode === 'credential' && entry.revision === undefined) return null;\n documents[entry.path] = entry.text;\n if (entry.revision !== undefined) revisions[entry.path] = entry.revision;\n const removed = removals.indexOf(entry.path);\n if (removed !== -1) removals.splice(removed, 1);\n }\n }\n const last = pending.at(-1);\n if (last === undefined) return null;\n lines.set(tracked.authority, { logEpoch: line.logEpoch, frames: pending });\n return {\n kind: 'net-advancement',\n roomVersion: roomVersion({ position: last.position.toString(), logEpoch: line.logEpoch }),\n documents,\n revisions,\n binaryTargets: [],\n removals: removals.sort(),\n };\n },\n };\n}\n"],"names":["acceptedMessage","actionOutcome","selects","PRIVATE_LOCATOR","roomVersion","HELD_POSITIONS_MAX","CONVERSATION_CARD","position","value","test","BigInt","houseNotifications","transport","mode","stream","lines","Map","locators","schemas","observers","Set","conversationObservers","modeObservers","replicated","privateAuthority","live","noted","asked","listening","catching","listen","observe","receive","emitConversation","event","kind","add","conversation","observer","unnote","delete","note","question","sequence","get","set","answer","door","conversation_id","includes","outcome","interactions","result","Array","isArray","questions","structuredClone","reopened","gapped","clear","converse","frame","type","turn","turn_id","text","plan","steps","noteId","note_id","running","commands","options","message","role","announce","authority","at","modelChanged","version","locator","interrupt","line","undefined","logEpoch","frames","service_mode","entry","entries","card","exec","path","log_epoch","last","continued","next","length","addresses","some","serviceMode","notify","conversations","replicate","entering","filter","opened","track","find","keys","has","select","advance","tracked","from","start","findIndex","pending","slice","documents","revisions","removals","push","revision","removed","indexOf","splice","toString","binaryTargets","sort"],"m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;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/stream.ts"],"sourcesContent":["import type {\n ConversationEvent,\n ConversationStream,\n RefreshPage,\n RoomVersionNotification,\n SelectedRooms,\n ServiceMode,\n ServiceModeSignal,\n} from '@agentshouse/mdruntime';\nimport { acceptedMessage, actionOutcome } from './actions.js';\nimport type { TrackedAuthority } from './discovery.js';\nimport { headChange, selects, type HeadChange } from './read.js';\nimport {\n PRIVATE_LOCATOR,\n type HouseDoor,\n type HouseMode,\n type HouseStreamEntry,\n type HouseStreamFrame,\n} from './transport.js';\nimport { roomVersion, type LogPosition } from './version.js';\n\nconst HELD_POSITIONS_MAX = 256;\n\nconst CONVERSATION_CARD = /^agents\\/([^/]+)\\.md$/;\n\ntype HeldFrame = {\n position: bigint;\n entries: readonly HouseStreamEntry[];\n};\n\ntype HeldLine = {\n logEpoch: string;\n frames: readonly HeldFrame[];\n};\n\nexport type HouseNotifications = SelectedRooms & {\n track(authorities: readonly TrackedAuthority[]): void;\n advance(tracked: TrackedAuthority, from: LogPosition): RefreshPage | null;\n conversations: ConversationStream;\n serviceMode: ServiceModeSignal;\n question(conversation: string): void;\n};\n\nfunction position(value: string): bigint | null {\n if (!/^(?:0|[1-9][0-9]*)$/.test(value)) return null;\n return BigInt(value);\n}\n\nexport function houseNotifications(transport: HouseDoor, mode: HouseMode): HouseNotifications {\n const stream = transport.stream;\n const lines = new Map<string, HeldLine>();\n const locators = new Map<string, string[]>();\n const schemas = new Map<string, readonly string[]>();\n const observers = new Set<(notification: RoomVersionNotification) => void>();\n const conversationObservers = new Set<(event: ConversationEvent) => void>();\n const modeObservers = new Set<(mode: ServiceMode) => void>();\n let replicated: readonly string[] = [];\n let privateAuthority: string | undefined;\n const live = new Set<string>();\n const noted = new Set<string>();\n const asked = new Map<string, number>();\n let listening = false;\n let catching = false;\n\n function listen() {\n if (listening) return;\n listening = true;\n stream.observe(receive);\n }\n\n function emitConversation(event: ConversationEvent) {\n if (event.kind !== 'gap' && event.kind !== 'accepted-message') live.add(event.conversation);\n for (const observer of conversationObservers) observer(event);\n }\n\n function unnote(conversation: string) {\n if (!noted.delete(conversation)) return;\n emitConversation({ kind: 'working-note', conversation, note: null });\n }\n\n async function question(conversation: string) {\n const sequence = (asked.get(conversation) ?? 0) + 1;\n asked.set(conversation, sequence);\n const answer = await transport.door('/door/conversations/interaction/read', {\n conversation_id: conversation,\n });\n if (asked.get(conversation) !== sequence || !replicated.includes(conversation)) return;\n const outcome = actionOutcome(answer, 'conversations/interaction/read');\n if (outcome.kind !== 'action') return;\n const { interactions } = outcome.result as { interactions?: unknown };\n if (!Array.isArray(interactions)) return;\n emitConversation({\n kind: 'questions',\n conversation,\n questions: structuredClone(interactions),\n });\n }\n\n function reopened() {\n const gapped = new Set([...replicated, ...live]);\n live.clear();\n noted.clear();\n for (const conversation of gapped) emitConversation({ kind: 'gap', conversation });\n for (const conversation of replicated) void question(conversation);\n }\n\n function converse(frame: Exclude<HouseStreamFrame, { type: 'entries' | 'signal' }>) {\n const conversation = frame.conversation_id;\n if (frame.type === 'draft') {\n unnote(conversation);\n emitConversation({\n kind: 'growing-text',\n conversation,\n turn: frame.turn_id,\n text: frame.text,\n });\n emitConversation({\n kind: 'plan',\n conversation,\n turn: frame.turn_id,\n plan: structuredClone(frame.steps),\n });\n return;\n }\n if (frame.type === 'working-note') {\n noted.add(conversation);\n emitConversation({\n kind: 'working-note',\n conversation,\n note: { noteId: frame.note_id, text: frame.text },\n });\n return;\n }\n if (frame.type === 'process') {\n emitConversation({ kind: 'process', conversation, running: frame.running });\n if (frame.running) return;\n emitConversation({ kind: 'commands', conversation, commands: [] });\n emitConversation({ kind: 'options', conversation, options: [] });\n unnote(conversation);\n return;\n }\n if (frame.type === 'commands') {\n emitConversation({\n kind: 'commands',\n conversation,\n commands: structuredClone(frame.commands),\n });\n return;\n }\n if (frame.type === 'options') {\n emitConversation({ kind: 'options', conversation, options: structuredClone(frame.options) });\n return;\n }\n const message = acceptedMessage(frame.message);\n if (message === null) return;\n emitConversation({ kind: 'accepted-message', conversation, message });\n if ((frame.message as { role?: unknown }).role === 'user') return;\n unnote(conversation);\n }\n\n function announce(authority: string, at: LogPosition, modelChanged: boolean) {\n const version = roomVersion(at);\n for (const locator of locators.get(authority) ?? []) {\n for (const observer of observers) {\n observer(\n modelChanged\n ? { locator, roomVersion: version, modelChanged: true }\n : { locator, roomVersion: version },\n );\n }\n }\n }\n\n function interrupt(authority: string) {\n const line = lines.get(authority);\n if (line !== undefined) lines.set(authority, { logEpoch: line.logEpoch, frames: [] });\n }\n\n function receive(frame: HouseStreamFrame) {\n if (frame.type === 'signal') {\n const mode = frame.service_mode;\n if (mode !== 'open' && mode !== 'write-halted') return;\n for (const observer of modeObservers) observer(mode);\n return;\n }\n if (\n frame.type === 'draft' ||\n frame.type === 'working-note' ||\n frame.type === 'process' ||\n frame.type === 'commands' ||\n frame.type === 'options' ||\n frame.type === 'message'\n ) {\n converse(frame);\n return;\n }\n if (frame.type !== 'entries') return;\n if (frame.authority === privateAuthority) {\n for (const entry of frame.entries) {\n const card = CONVERSATION_CARD.exec(entry.path);\n const conversation = card?.[1];\n if (\n conversation !== undefined &&\n entry.kind === 'edited' &&\n replicated.includes(conversation)\n ) {\n void question(conversation);\n }\n }\n }\n const at = position(frame.position);\n if (at === null) {\n interrupt(frame.authority);\n return;\n }\n const line = lines.get(frame.authority);\n if (line?.logEpoch === frame.log_epoch) {\n const last = line.frames.at(-1);\n const continued = last !== undefined && last.position + 1n === at;\n const next = continued\n ? [...line.frames, { position: at, entries: frame.entries }]\n : [{ position: at, entries: frame.entries }];\n lines.set(frame.authority, {\n logEpoch: line.logEpoch,\n frames: next.length > HELD_POSITIONS_MAX ? [] : next,\n });\n } else {\n interrupt(frame.authority);\n }\n const addresses = schemas.get(frame.authority) ?? [];\n announce(\n frame.authority,\n { position: frame.position, logEpoch: frame.log_epoch },\n frame.entries.some((entry) => addresses.includes(entry.path)),\n );\n }\n\n return {\n serviceMode: {\n observe(notify) {\n modeObservers.add(notify);\n listen();\n return () => {\n modeObservers.delete(notify);\n };\n },\n },\n question(conversation) {\n void question(conversation);\n },\n conversations: {\n replicate(next) {\n const entering = next.filter((conversation) => !replicated.includes(conversation));\n replicated = [...next];\n for (const conversation of entering) void question(conversation);\n },\n observe(notify) {\n conversationObservers.add(notify);\n listen();\n if (!catching) {\n catching = true;\n stream.opened(reopened);\n }\n return () => {\n conversationObservers.delete(notify);\n };\n },\n },\n track(entries) {\n locators.clear();\n schemas.clear();\n privateAuthority = entries.find((entry) => entry.locator === PRIVATE_LOCATOR)?.authority;\n for (const entry of entries) {\n locators.set(entry.authority, [...(locators.get(entry.authority) ?? []), entry.locator]);\n schemas.set(entry.authority, entry.schemas);\n if (lines.get(entry.authority)?.logEpoch !== entry.logEpoch) {\n lines.set(entry.authority, { logEpoch: entry.logEpoch, frames: [] });\n }\n }\n for (const authority of lines.keys()) {\n if (!locators.has(authority)) lines.delete(authority);\n }\n },\n select() {},\n observe(notify) {\n observers.add(notify);\n listen();\n return () => {\n observers.delete(notify);\n };\n },\n advance(tracked, from) {\n const line = lines.get(tracked.authority);\n const start = position(from.position);\n if (line === undefined || start === null || line.logEpoch !== from.logEpoch) return null;\n const at = line.frames.findIndex((frame) => frame.position === start + 1n);\n if (at === -1) return null;\n const pending = line.frames.slice(at);\n const documents: Record<string, string> = {};\n const revisions: Record<string, string> = {};\n const changes: Record<string, HeadChange> = {};\n const removals: string[] = [];\n for (const frame of pending) {\n for (const entry of frame.entries) {\n if (!selects(tracked, entry.path)) continue;\n if (entry.kind === 'removed') {\n delete documents[entry.path];\n delete revisions[entry.path];\n delete changes[entry.path];\n if (!removals.includes(entry.path)) removals.push(entry.path);\n continue;\n }\n if (entry.text === undefined) return null;\n if (mode === 'credential' && entry.revision === undefined) return null;\n const head = headChange(entry);\n if (head === null) return null;\n documents[entry.path] = entry.text;\n if (entry.revision !== undefined) revisions[entry.path] = entry.revision;\n if (head === undefined) delete changes[entry.path];\n else changes[entry.path] = head;\n const removed = removals.indexOf(entry.path);\n if (removed !== -1) removals.splice(removed, 1);\n }\n }\n const last = pending.at(-1);\n if (last === undefined) return null;\n lines.set(tracked.authority, { logEpoch: line.logEpoch, frames: pending });\n return {\n kind: 'net-advancement',\n roomVersion: roomVersion({ position: last.position.toString(), logEpoch: line.logEpoch }),\n documents,\n revisions,\n changes,\n binaryTargets: [],\n removals: removals.sort(),\n };\n },\n };\n}\n"],"names":["acceptedMessage","actionOutcome","headChange","selects","PRIVATE_LOCATOR","roomVersion","HELD_POSITIONS_MAX","CONVERSATION_CARD","position","value","test","BigInt","houseNotifications","transport","mode","stream","lines","Map","locators","schemas","observers","Set","conversationObservers","modeObservers","replicated","privateAuthority","live","noted","asked","listening","catching","listen","observe","receive","emitConversation","event","kind","add","conversation","observer","unnote","delete","note","question","sequence","get","set","answer","door","conversation_id","includes","outcome","interactions","result","Array","isArray","questions","structuredClone","reopened","gapped","clear","converse","frame","type","turn","turn_id","text","plan","steps","noteId","note_id","running","commands","options","message","role","announce","authority","at","modelChanged","version","locator","interrupt","line","undefined","logEpoch","frames","service_mode","entry","entries","card","exec","path","log_epoch","last","continued","next","length","addresses","some","serviceMode","notify","conversations","replicate","entering","filter","opened","track","find","keys","has","select","advance","tracked","from","start","findIndex","pending","slice","documents","revisions","changes","removals","push","revision","head","removed","indexOf","splice","toString","binaryTargets","sort"],"mappings":"AASA,SAASA,eAAe,EAAEC,aAAa,QAAQ,eAAe;AAE9D,SAASC,UAAU,EAAEC,OAAO,QAAyB,YAAY;AACjE,SACEC,eAAe,QAKV,iBAAiB;AACxB,SAASC,WAAW,QAA0B,eAAe;AAE7D,MAAMC,qBAAqB;AAE3B,MAAMC,oBAAoB;AAoB1B,SAASC,SAASC,KAAa;IAC7B,IAAI,CAAC,sBAAsBC,IAAI,CAACD,QAAQ,OAAO;IAC/C,OAAOE,OAAOF;AAChB;AAEA,OAAO,SAASG,mBAAmBC,SAAoB,EAAEC,IAAe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_DOOR_BOOTSTRAP = "/_house/door/bootstrap/";
|
|
|
9
9
|
export declare const SITE_DOOR_ENUMERATE = "/_house/door/enumerate";
|
|
10
10
|
export declare const SITE_DOOR_SUBMIT = "/_house/door/submit";
|
|
11
11
|
export declare const PRIVATE_LOCATOR = "private";
|
|
12
|
+
export declare const DOOR_SELECTION_MAX = 256;
|
|
12
13
|
export type HouseMode = 'credential' | 'site';
|
|
13
14
|
export type HouseDoorAnswer = {
|
|
14
15
|
status: number;
|
|
@@ -30,6 +31,14 @@ export type HouseStreamEntry = {
|
|
|
30
31
|
kind: 'edited' | 'removed';
|
|
31
32
|
revision?: string;
|
|
32
33
|
text?: string;
|
|
34
|
+
author?: {
|
|
35
|
+
user: string;
|
|
36
|
+
name: string;
|
|
37
|
+
} | {
|
|
38
|
+
site: string;
|
|
39
|
+
name: string;
|
|
40
|
+
};
|
|
41
|
+
created_at?: string;
|
|
33
42
|
};
|
|
34
43
|
export type HouseStreamFrame = {
|
|
35
44
|
type: 'entries';
|
package/dist/transport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,mBAAmB,CAAC;AAE9C,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,UAAU,gBAAgB,CAAC;AAExC,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAE7D,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D,eAAO,MAAM,gBAAgB,wBAAwB,CAAC;AAEtD,eAAO,MAAM,eAAe,YAAY,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG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EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7D,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG;IACvC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG;IAC3C,MAAM,IAAI,OAAO,CAAC;IAClB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC/C,CAAC"}
|
package/dist/transport.js
CHANGED
|
@@ -9,5 +9,6 @@ export const SITE_DOOR_BOOTSTRAP = '/_house/door/bootstrap/';
|
|
|
9
9
|
export const SITE_DOOR_ENUMERATE = '/_house/door/enumerate';
|
|
10
10
|
export const SITE_DOOR_SUBMIT = '/_house/door/submit';
|
|
11
11
|
export const PRIVATE_LOCATOR = 'private';
|
|
12
|
+
export const DOOR_SELECTION_MAX = 256;
|
|
12
13
|
|
|
13
14
|
//# sourceMappingURL=transport.js.map
|