@agentshouse/mdruntime-adapter 0.1.0-alpha.36 → 0.1.0-alpha.38
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 +19 -5
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +62 -5
- package/dist/actions.js.map +1 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +11 -3
- package/dist/adapter.js.map +1 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +2 -1
- package/dist/discovery.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +0 -1
- package/dist/refusal.js.map +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +2 -1
- package/dist/site.js.map +1 -1
- package/dist/stream.d.ts +4 -2
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +144 -45
- package/dist/stream.js.map +1 -1
- package/dist/transport.d.ts +23 -4
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js.map +1 -1
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +27 -2
- package/dist/write.js.map +1 -1
- package/package.json +2 -2
package/AGENTS.md
CHANGED
|
@@ -8,8 +8,8 @@ enforcement.
|
|
|
8
8
|
|
|
9
9
|
App code reaches the MD Runtime through the remote client. The surfaces are
|
|
10
10
|
Rooms, Slots, Query, Search, Observe, Types, Room Draft, Save, History, Call, Log,
|
|
11
|
-
storage loss, the reported persistence answer, deployment facts, Sync Status,
|
|
12
|
-
conversation, the chat draft, and Presentation State.
|
|
11
|
+
storage loss, the reported persistence answer, deployment facts, Sync Status, the Service Mode,
|
|
12
|
+
reauthorization, conversation, the chat draft, and Presentation State.
|
|
13
13
|
|
|
14
14
|
Every `observe` resolves, once its first value has arrived, to a handle:
|
|
15
15
|
`current()` is the latest complete value, `subscribe(listener)` hears each later
|
|
@@ -19,8 +19,13 @@ observation; a client that reconnects observes again.
|
|
|
19
19
|
|
|
20
20
|
Each conversation a Provider card names is held complete in the browser.
|
|
21
21
|
Observe one with `observe('conversation', id, { limit })`: the view
|
|
22
|
-
holds its latest `limit` messages, or all of them, oldest first,
|
|
23
|
-
|
|
22
|
+
holds its latest `limit` messages, or all of them, oldest first, its chat
|
|
23
|
+
draft, and what the Provider streams for it whether or not anything views it:
|
|
24
|
+
the growing text and plan of the running turn, the open questions, the process
|
|
25
|
+
state, the CLI's commands and options, and the latest `workingNote`. These live
|
|
26
|
+
only in memory: the turn's accepted message replaces its growing text and plan,
|
|
27
|
+
a working note is never part of a message, and none of them is stored or
|
|
28
|
+
searchable.
|
|
24
29
|
`chatDraft.write` and `chatDraft.discard` keep what the App Creator composes;
|
|
25
30
|
sending it is a Provider Action that needs the Provider reachable and is never
|
|
26
31
|
queued.
|
|
@@ -30,7 +35,9 @@ in order, each a Room and its segment; a Room two Slots list is the same Room.
|
|
|
30
35
|
|
|
31
36
|
Rooms, Slots, Query, Search, Observe, Types, Room Draft, and Save never touch the
|
|
32
37
|
network.
|
|
33
|
-
History and Call go to the Provider through the Adapter.
|
|
38
|
+
History and Call go to the Provider through the Adapter. Each History revision
|
|
39
|
+
names its author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`. Every
|
|
40
|
+
member of the
|
|
34
41
|
client is asynchronous. Results are detached snapshots. Nothing in this
|
|
35
42
|
surface returns the authorization, performs a request the App's code
|
|
36
43
|
composes, or exposes the browser store.
|
|
@@ -137,6 +144,13 @@ it names; the MD Runtime retries the same Change Batch identity and payload and
|
|
|
137
144
|
never infers an outcome from transport uncertainty. The MD Runtime never
|
|
138
145
|
combines, reorders, or rebases.
|
|
139
146
|
|
|
147
|
+
`serviceMode()` and `observe('service-mode')` answer the Provider's Service
|
|
148
|
+
Mode, `open` or `write-halted`. While writes are halted, Save still succeeds,
|
|
149
|
+
its Change Batch waits unsent, and the queue is submitted in order once the
|
|
150
|
+
Provider reopens writes. An Action is never held: a write the Provider refuses
|
|
151
|
+
for the halt returns that refusal to its caller. Show the Provider as read-only
|
|
152
|
+
instead of retrying.
|
|
153
|
+
|
|
140
154
|
## The neutrality rule
|
|
141
155
|
|
|
142
156
|
No module outside an Adapter package imports, names, or special-cases a
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EAEvB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAgBtE,eAAO,MAAM,wBAAwB,EAAE,iBAKtC,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CASvF;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,cAAc,EACzB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EAEvB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAgBtE,eAAO,MAAM,wBAAwB,EAAE,iBAKtC,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CASvF;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,cAAc,EACzB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAQvB;AA4DD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAWjF;AAuLD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAUtE"}
|
package/dist/actions.js
CHANGED
|
@@ -55,6 +55,8 @@ export function declaredActions(routes) {
|
|
|
55
55
|
export function houseAction(transport, request) {
|
|
56
56
|
if (request.name === 'conversation.send') return sendAction(transport, request.input);
|
|
57
57
|
if (request.name === 'conversation.history') return historyAction(transport, request.input);
|
|
58
|
+
if (request.name === 'attachments/upload') return attachAction(transport, request.input);
|
|
59
|
+
if (request.name === 'attachments/get') return openAction(transport, request.input);
|
|
58
60
|
const route = routeOf(request.name);
|
|
59
61
|
if (route === null) return Promise.resolve(malformed());
|
|
60
62
|
return carry(transport, route, request.name, request.input);
|
|
@@ -209,6 +211,9 @@ async function fileBytes(file) {
|
|
|
209
211
|
if (!('arrayBuffer' in blob) || typeof blob.arrayBuffer !== 'function') return null;
|
|
210
212
|
return new Uint8Array(await blob.arrayBuffer());
|
|
211
213
|
}
|
|
214
|
+
function delivered(answer, name) {
|
|
215
|
+
return answer.status === 200 ? null : actionOutcome(answer, name);
|
|
216
|
+
}
|
|
212
217
|
function uploadGrant(entry) {
|
|
213
218
|
if (!('upload' in record(entry))) return 'absent';
|
|
214
219
|
const upload = record(record(entry).upload);
|
|
@@ -236,18 +241,70 @@ async function uploadOriginals(transport, input, result) {
|
|
|
236
241
|
fields: {}
|
|
237
242
|
};
|
|
238
243
|
}
|
|
239
|
-
const
|
|
244
|
+
const failed = delivered(await transport.transfer({
|
|
240
245
|
act: 'conversation_original_upload',
|
|
241
246
|
method: 'POST',
|
|
242
247
|
url: grant.url,
|
|
248
|
+
answer: 'json',
|
|
243
249
|
body: bytes,
|
|
244
250
|
operation: grant.operation
|
|
245
|
-
});
|
|
246
|
-
if (
|
|
247
|
-
return actionOutcome(delivered, 'conversation.send');
|
|
251
|
+
}), 'conversation.send');
|
|
252
|
+
if (failed !== null) return failed;
|
|
248
253
|
}
|
|
249
254
|
return null;
|
|
250
255
|
}
|
|
256
|
+
async function attachAction(transport, input) {
|
|
257
|
+
const { blob, ...descriptor } = record(input);
|
|
258
|
+
const bytes = await fileBytes({
|
|
259
|
+
blob
|
|
260
|
+
});
|
|
261
|
+
if (bytes === null) return malformed();
|
|
262
|
+
const answer = await transport.door('/door/attachments/upload', descriptor);
|
|
263
|
+
const outcome = actionOutcome(answer, 'attachments/upload');
|
|
264
|
+
if (outcome.kind !== 'action') return outcome;
|
|
265
|
+
const grant = uploadGrant(outcome.result);
|
|
266
|
+
if (grant === 'absent') return outcome;
|
|
267
|
+
if (grant === null) return malformed();
|
|
268
|
+
const stored = await transport.transfer({
|
|
269
|
+
act: 'original_upload',
|
|
270
|
+
method: 'POST',
|
|
271
|
+
url: grant.url,
|
|
272
|
+
answer: 'json',
|
|
273
|
+
body: bytes,
|
|
274
|
+
operation: grant.operation
|
|
275
|
+
});
|
|
276
|
+
return delivered(stored, 'attachments/upload') ?? {
|
|
277
|
+
kind: 'action',
|
|
278
|
+
result: stored.body
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
async function openAction(transport, input) {
|
|
282
|
+
const answer = await transport.door('/door/attachments/get', input);
|
|
283
|
+
const outcome = actionOutcome(answer, 'attachments/get');
|
|
284
|
+
if (outcome.kind !== 'action') return outcome;
|
|
285
|
+
const { download, ...opened } = record(outcome.result);
|
|
286
|
+
if (download === undefined) return outcome;
|
|
287
|
+
const grant = record(download);
|
|
288
|
+
if (grant.method !== 'GET' || typeof grant.url !== 'string') return malformed();
|
|
289
|
+
const read = await transport.transfer({
|
|
290
|
+
act: 'original_download',
|
|
291
|
+
method: 'GET',
|
|
292
|
+
url: grant.url,
|
|
293
|
+
answer: 'bytes'
|
|
294
|
+
});
|
|
295
|
+
const failed = delivered(read, 'attachments/get');
|
|
296
|
+
if (failed !== null) return failed;
|
|
297
|
+
if (!(read.body instanceof Blob)) return {
|
|
298
|
+
kind: 'transport-uncertainty'
|
|
299
|
+
};
|
|
300
|
+
return {
|
|
301
|
+
kind: 'action',
|
|
302
|
+
result: {
|
|
303
|
+
...opened,
|
|
304
|
+
blob: read.body
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
}
|
|
251
308
|
async function sendAction(transport, input) {
|
|
252
309
|
const body = sendBody(input);
|
|
253
310
|
if (body === null) return malformed();
|
|
@@ -285,7 +342,7 @@ export function acceptedMessage(entry) {
|
|
|
285
342
|
if (cursor === null) return null;
|
|
286
343
|
return {
|
|
287
344
|
identity: cursor.message_id,
|
|
288
|
-
turn: cursor.message_id,
|
|
345
|
+
turn: text(entry, 'turn_id') ?? cursor.message_id,
|
|
289
346
|
position: position(cursor),
|
|
290
347
|
text: text(entry, 'text') ?? '',
|
|
291
348
|
message: structuredClone(entry)
|
package/dist/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/actions.ts"],"sourcesContent":["import {\n changeBatchIdentity,\n type AcceptedMessage,\n type ActionDeclaration,\n type ActionRequest,\n type ActionResult,\n type ConversationCards,\n type ConversationHistoryPage,\n} from '@agentshouse/mdruntime';\nimport { doorRefusal } from './refusal.js';\nimport { PRIVATE_LOCATOR } from './transport.js';\nimport type { HouseDoorAnswer, HouseTransport } from './transport.js';\n\nconst HISTORY_PAGE = 100;\n\nconst OCTET_STREAM = 'application/octet-stream';\n\nconst CONVERSATION_ROUTES: ReadonlyMap<string, string> = new Map([\n ['conversation.create', '/door/conversations/create'],\n ['conversation.send', '/door/conversations/send'],\n ['conversation.answer', '/door/conversations/interaction/answer'],\n ['conversation.interrupt', '/door/conversations/interrupt'],\n ['conversation.kill', '/door/conversations/kill'],\n ['conversation.delete', '/door/conversations/delete'],\n ['conversation.history', '/door/conversations/history'],\n]);\n\nexport const HOUSE_CONVERSATION_CARDS: ConversationCards = {\n locator: PRIVATE_LOCATOR,\n type: 'house-conversation',\n identity: 'conversation',\n agent: 'agent',\n};\n\nexport function declaredActions(routes: readonly string[]): readonly ActionDeclaration[] {\n const mapped = new Map(\n [...CONVERSATION_ROUTES].map(([name, route]) => [route.slice('/door/'.length), name]),\n );\n return routes.map((route) => ({\n name: mapped.get(route) ?? route,\n inputShape: {},\n resultKind: 'house',\n }));\n}\n\nexport function houseAction(\n transport: HouseTransport,\n request: ActionRequest,\n): Promise<ActionResult> {\n if (request.name === 'conversation.send') return sendAction(transport, request.input);\n if (request.name === 'conversation.history') return historyAction(transport, request.input);\n const route = routeOf(request.name);\n if (route === null) return Promise.resolve(malformed());\n return carry(transport, route, request.name, request.input);\n}\n\nfunction routeOf(name: string): string | null {\n const mapped = CONVERSATION_ROUTES.get(name);\n if (mapped !== undefined) return mapped;\n const parts = name.split('/');\n if (parts.some((part) => part === '.' || part === '..')) return null;\n try {\n return `/door/${parts.map(encodeURIComponent).join('/')}`;\n } catch {\n return null;\n }\n}\n\nfunction record(value: unknown): Record<string, unknown> {\n return typeof value === 'object' && value !== null ? (value as Record<string, unknown>) : {};\n}\n\nfunction text(value: unknown, name: string): string | undefined {\n const held = record(value)[name];\n return typeof held === 'string' ? held : undefined;\n}\n\nfunction operationId(input: unknown): string {\n return text(input, 'operation_id') ?? changeBatchIdentity();\n}\n\nfunction malformed(): ActionResult {\n return { kind: 'rejected', code: 'invalid_request', fields: {} };\n}\n\nfunction bodyOf(name: string, input: unknown): unknown {\n if (name === 'conversation.create') {\n return { agent_id: text(input, 'agent_id'), operation_id: operationId(input) };\n }\n if (\n name === 'conversation.interrupt' ||\n name === 'conversation.kill' ||\n name === 'conversation.delete'\n ) {\n return { conversation_id: text(input, 'conversation'), operation_id: operationId(input) };\n }\n if (name === 'conversation.answer') {\n const nested = record(record(input).answer);\n return {\n conversation_id: text(input, 'conversation'),\n operation_id: operationId(input),\n interaction_id: text(nested, 'interaction_id'),\n response: nested.response,\n };\n }\n return input;\n}\n\nfunction withTurn(body: unknown): unknown {\n const held = record(body);\n const turn = text(held, 'message_id');\n return turn === undefined ? body : { ...held, turn };\n}\n\nexport function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult {\n if (answer.status === 401) return { kind: 'revoked-authorization' };\n const refusal = doorRefusal(answer.body);\n if (refusal !== null) {\n return { kind: 'rejected', code: refusal.code, fields: refusal.fields };\n }\n if (answer.status === 404)\n return { kind: 'rejected', code: 'action-unimplemented', fields: { name } };\n if (answer.status === 0 || answer.status >= 400) return { kind: 'transport-uncertainty' };\n if (name === 'conversation.send') return { kind: 'action', result: withTurn(answer.body) };\n return { kind: 'action', result: answer.body };\n}\n\nasync function carry(\n transport: HouseTransport,\n route: string,\n name: string,\n input: unknown,\n): Promise<ActionResult> {\n const answer = await transport.door(route, bodyOf(name, input));\n return actionOutcome(answer, name);\n}\n\nfunction sendFile(entry: unknown): Record<string, unknown> | null {\n const file = record(entry);\n const name = text(file, 'name');\n const bytes = file.byteLength;\n const sha256 = text(file, 'contentHash');\n if (name === undefined || typeof bytes !== 'number' || sha256 === undefined) return null;\n const mediaType = text(file, 'mediaType');\n const width = file.width;\n const height = file.height;\n return {\n name,\n media_type: mediaType !== undefined && mediaType.length > 0 ? mediaType : OCTET_STREAM,\n bytes,\n sha256,\n ...(typeof width === 'number' && typeof height === 'number'\n ? { dimensions: { width, height } }\n : {}),\n };\n}\n\nfunction sendFiles(input: unknown): readonly Record<string, unknown>[] | null {\n const files = record(input).files;\n if (files === undefined) return [];\n if (!Array.isArray(files)) return null;\n const declared: Record<string, unknown>[] = [];\n for (const entry of files) {\n const file = sendFile(entry);\n if (file === null) return null;\n declared.push(file);\n }\n return declared;\n}\n\nfunction sendBody(input: unknown): Record<string, unknown> | null {\n const files = sendFiles(input);\n if (files === null) return null;\n const textValue = text(input, 'text');\n return {\n conversation_id: text(input, 'conversation'),\n operation_id: operationId(input),\n ...(textValue !== undefined && textValue.length > 0 ? { text: textValue } : {}),\n ...(files.length === 0 ? {} : { files }),\n };\n}\n\nasync function fileBytes(file: unknown): Promise<Uint8Array | null> {\n const blob = record(file).blob;\n if (blob === undefined || typeof blob !== 'object' || blob === null) return null;\n if (!('arrayBuffer' in blob) || typeof blob.arrayBuffer !== 'function') return null;\n return new Uint8Array(await (blob as Blob).arrayBuffer());\n}\n\nfunction uploadGrant(\n entry: unknown,\n): { method: 'POST'; operation: string; url: string } | 'absent' | null {\n if (!('upload' in record(entry))) return 'absent';\n const upload = record(record(entry).upload);\n if (upload.method !== 'POST') return null;\n if (typeof upload.operation !== 'string' || typeof upload.url !== 'string') return null;\n return { method: 'POST', operation: upload.operation, url: upload.url };\n}\n\nasync function uploadOriginals(\n transport: HouseTransport,\n input: unknown,\n result: unknown,\n): Promise<ActionResult | null> {\n const originals = record(result).originals;\n if (!Array.isArray(originals) || originals.length === 0) return null;\n const files = Array.isArray(record(input).files) ? (record(input).files as unknown[]) : [];\n for (const [index, entry] of originals.entries()) {\n const grant = uploadGrant(entry);\n if (grant === 'absent') continue;\n if (grant === null) return malformed();\n const bytes = index < files.length ? await fileBytes(files[index]) : null;\n if (bytes === null) {\n return { kind: 'rejected', code: 'conversation_original_descriptor_required', fields: {} };\n }\n const delivered = await transport.transfer({\n act: 'conversation_original_upload',\n method: 'POST',\n url: grant.url,\n body: bytes,\n operation: grant.operation,\n });\n if (delivered.status === 200) continue;\n return actionOutcome(delivered, 'conversation.send');\n }\n return null;\n}\n\nasync function sendAction(transport: HouseTransport, input: unknown): Promise<ActionResult> {\n const body = sendBody(input);\n if (body === null) return malformed();\n const answer = await transport.door('/door/conversations/send', body);\n const outcome = actionOutcome(answer, 'conversation.send');\n if (outcome.kind !== 'action') return outcome;\n const uploaded = await uploadOriginals(transport, input, outcome.result);\n if (uploaded !== null) return uploaded;\n return outcome;\n}\n\ntype HistoryCursor = { accepted_at: string; message_id: string };\n\nfunction historyCursor(value: unknown): HistoryCursor | null {\n const acceptedAt = text(value, 'accepted_at');\n const messageId = text(value, 'message_id');\n if (acceptedAt === undefined || messageId === undefined) return null;\n return { accepted_at: acceptedAt, message_id: messageId };\n}\n\nfunction position(cursor: HistoryCursor): string {\n return JSON.stringify({ accepted_at: cursor.accepted_at, message_id: cursor.message_id });\n}\n\nfunction positionCursor(value: string): HistoryCursor | null {\n try {\n return historyCursor(JSON.parse(value) as unknown);\n } catch {\n return null;\n }\n}\n\nexport function acceptedMessage(entry: unknown): AcceptedMessage | null {\n const cursor = historyCursor(entry);\n if (cursor === null) return null;\n return {\n identity: cursor.message_id,\n turn: cursor.message_id,\n position: position(cursor),\n text: text(entry, 'text') ?? '',\n message: structuredClone(entry),\n };\n}\n\nasync function historyAction(transport: HouseTransport, input: unknown): Promise<ActionResult> {\n const conversationId = text(input, 'conversation');\n if (conversationId === undefined) return malformed();\n const afterValue = text(input, 'after');\n const after = afterValue === undefined ? undefined : positionCursor(afterValue);\n if (after === null) return malformed();\n const answer = await transport.door('/door/conversations/history', {\n conversation_id: conversationId,\n ...(after === undefined ? {} : { after }),\n limit: HISTORY_PAGE,\n });\n const outcome = actionOutcome(answer, 'conversation.history');\n if (outcome.kind !== 'action') return outcome;\n const held = record(outcome.result);\n if (!Array.isArray(held.messages)) return { kind: 'transport-uncertainty' };\n const messages: AcceptedMessage[] = [];\n for (const entry of held.messages) {\n const message = acceptedMessage(entry);\n if (message === null) return { kind: 'transport-uncertainty' };\n messages.push(message);\n }\n const next = held.next === null || held.next === undefined ? undefined : historyCursor(held.next);\n if (next === null) return { kind: 'transport-uncertainty' };\n const page: ConversationHistoryPage = {\n messages,\n ...(next === undefined ? {} : { next: position(next) }),\n };\n return { kind: 'action', result: page };\n}\n"],"names":["changeBatchIdentity","doorRefusal","PRIVATE_LOCATOR","HISTORY_PAGE","OCTET_STREAM","CONVERSATION_ROUTES","Map","HOUSE_CONVERSATION_CARDS","locator","type","identity","agent","declaredActions","routes","mapped","map","name","route","slice","length","get","inputShape","resultKind","houseAction","transport","request","sendAction","input","historyAction","routeOf","Promise","resolve","malformed","carry","undefined","parts","split","some","part","encodeURIComponent","join","record","value","text","held","operationId","kind","code","fields","bodyOf","agent_id","operation_id","conversation_id","nested","answer","interaction_id","response","withTurn","body","turn","actionOutcome","status","refusal","result","door","sendFile","entry","file","bytes","byteLength","sha256","mediaType","width","height","media_type","dimensions","sendFiles","files","Array","isArray","declared","push","sendBody","textValue","fileBytes","blob","arrayBuffer","Uint8Array","uploadGrant","upload","method","operation","url","uploadOriginals","originals","index","entries","grant","delivered","transfer","act","outcome","uploaded","historyCursor","acceptedAt","messageId","accepted_at","message_id","position","cursor","JSON","stringify","positionCursor","parse","acceptedMessage","message","structuredClone","conversationId","afterValue","after","limit","messages","next","page"],"mappings":"AAAA,SACEA,mBAAmB,QAOd,yBAAyB;AAChC,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,eAAe,QAAQ,iBAAiB;AAGjD,MAAMC,eAAe;AAErB,MAAMC,eAAe;AAErB,MAAMC,sBAAmD,IAAIC,IAAI;IAC/D;QAAC;QAAuB;KAA6B;IACrD;QAAC;QAAqB;KAA2B;IACjD;QAAC;QAAuB;KAAyC;IACjE;QAAC;QAA0B;KAAgC;IAC3D;QAAC;QAAqB;KAA2B;IACjD;QAAC;QAAuB;KAA6B;IACrD;QAAC;QAAwB;KAA8B;CACxD;AAED,OAAO,MAAMC,2BAA8C;IACzDC,SAASN;IACTO,MAAM;IACNC,UAAU;IACVC,OAAO;AACT,EAAE;AAEF,OAAO,SAASC,gBAAgBC,MAAyB;IACvD,MAAMC,SAAS,IAAIR,IACjB;WAAID;KAAoB,CAACU,GAAG,CAAC,CAAC,CAACC,MAAMC,MAAM,GAAK;YAACA,MAAMC,KAAK,CAAC,SAASC,MAAM;YAAGH;SAAK;IAEtF,OAAOH,OAAOE,GAAG,CAAC,CAACE,QAAW,CAAA;YAC5BD,MAAMF,OAAOM,GAAG,CAACH,UAAUA;YAC3BI,YAAY,CAAC;YACbC,YAAY;QACd,CAAA;AACF;AAEA,OAAO,SAASC,YACd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3D,KAAK8E,IAAI;IAChG,IAAIA,SAAS,MAAM,OAAO;QAAE5E,MAAM;IAAwB;IAC1D,MAAM6E,OAAgC;QACpCF;QACA,GAAIC,SAASxF,YAAY,CAAC,IAAI;YAAEwF,MAAMd,SAASc;QAAM,CAAC;IACxD;IACA,OAAO;QAAE5E,MAAM;QAAUiB,QAAQ4D;IAAK;AACxC"}
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/actions.ts"],"sourcesContent":["import {\n changeBatchIdentity,\n type AcceptedMessage,\n type ActionDeclaration,\n type ActionRequest,\n type ActionResult,\n type ConversationCards,\n type ConversationHistoryPage,\n} from '@agentshouse/mdruntime';\nimport { doorRefusal } from './refusal.js';\nimport { PRIVATE_LOCATOR } from './transport.js';\nimport type { HouseDoorAnswer, HouseTransport } from './transport.js';\n\nconst HISTORY_PAGE = 100;\n\nconst OCTET_STREAM = 'application/octet-stream';\n\nconst CONVERSATION_ROUTES: ReadonlyMap<string, string> = new Map([\n ['conversation.create', '/door/conversations/create'],\n ['conversation.send', '/door/conversations/send'],\n ['conversation.answer', '/door/conversations/interaction/answer'],\n ['conversation.interrupt', '/door/conversations/interrupt'],\n ['conversation.kill', '/door/conversations/kill'],\n ['conversation.delete', '/door/conversations/delete'],\n ['conversation.history', '/door/conversations/history'],\n]);\n\nexport const HOUSE_CONVERSATION_CARDS: ConversationCards = {\n locator: PRIVATE_LOCATOR,\n type: 'house-conversation',\n identity: 'conversation',\n agent: 'agent',\n};\n\nexport function declaredActions(routes: readonly string[]): readonly ActionDeclaration[] {\n const mapped = new Map(\n [...CONVERSATION_ROUTES].map(([name, route]) => [route.slice('/door/'.length), name]),\n );\n return routes.map((route) => ({\n name: mapped.get(route) ?? route,\n inputShape: {},\n resultKind: 'house',\n }));\n}\n\nexport function houseAction(\n transport: HouseTransport,\n request: ActionRequest,\n): Promise<ActionResult> {\n if (request.name === 'conversation.send') return sendAction(transport, request.input);\n if (request.name === 'conversation.history') return historyAction(transport, request.input);\n if (request.name === 'attachments/upload') return attachAction(transport, request.input);\n if (request.name === 'attachments/get') return openAction(transport, request.input);\n const route = routeOf(request.name);\n if (route === null) return Promise.resolve(malformed());\n return carry(transport, route, request.name, request.input);\n}\n\nfunction routeOf(name: string): string | null {\n const mapped = CONVERSATION_ROUTES.get(name);\n if (mapped !== undefined) return mapped;\n const parts = name.split('/');\n if (parts.some((part) => part === '.' || part === '..')) return null;\n try {\n return `/door/${parts.map(encodeURIComponent).join('/')}`;\n } catch {\n return null;\n }\n}\n\nfunction record(value: unknown): Record<string, unknown> {\n return typeof value === 'object' && value !== null ? (value as Record<string, unknown>) : {};\n}\n\nfunction text(value: unknown, name: string): string | undefined {\n const held = record(value)[name];\n return typeof held === 'string' ? held : undefined;\n}\n\nfunction operationId(input: unknown): string {\n return text(input, 'operation_id') ?? changeBatchIdentity();\n}\n\nfunction malformed(): ActionResult {\n return { kind: 'rejected', code: 'invalid_request', fields: {} };\n}\n\nfunction bodyOf(name: string, input: unknown): unknown {\n if (name === 'conversation.create') {\n return { agent_id: text(input, 'agent_id'), operation_id: operationId(input) };\n }\n if (\n name === 'conversation.interrupt' ||\n name === 'conversation.kill' ||\n name === 'conversation.delete'\n ) {\n return { conversation_id: text(input, 'conversation'), operation_id: operationId(input) };\n }\n if (name === 'conversation.answer') {\n const nested = record(record(input).answer);\n return {\n conversation_id: text(input, 'conversation'),\n operation_id: operationId(input),\n interaction_id: text(nested, 'interaction_id'),\n response: nested.response,\n };\n }\n return input;\n}\n\nfunction withTurn(body: unknown): unknown {\n const held = record(body);\n const turn = text(held, 'message_id');\n return turn === undefined ? body : { ...held, turn };\n}\n\nexport function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult {\n if (answer.status === 401) return { kind: 'revoked-authorization' };\n const refusal = doorRefusal(answer.body);\n if (refusal !== null) {\n return { kind: 'rejected', code: refusal.code, fields: refusal.fields };\n }\n if (answer.status === 404)\n return { kind: 'rejected', code: 'action-unimplemented', fields: { name } };\n if (answer.status === 0 || answer.status >= 400) return { kind: 'transport-uncertainty' };\n if (name === 'conversation.send') return { kind: 'action', result: withTurn(answer.body) };\n return { kind: 'action', result: answer.body };\n}\n\nasync function carry(\n transport: HouseTransport,\n route: string,\n name: string,\n input: unknown,\n): Promise<ActionResult> {\n const answer = await transport.door(route, bodyOf(name, input));\n return actionOutcome(answer, name);\n}\n\nfunction sendFile(entry: unknown): Record<string, unknown> | null {\n const file = record(entry);\n const name = text(file, 'name');\n const bytes = file.byteLength;\n const sha256 = text(file, 'contentHash');\n if (name === undefined || typeof bytes !== 'number' || sha256 === undefined) return null;\n const mediaType = text(file, 'mediaType');\n const width = file.width;\n const height = file.height;\n return {\n name,\n media_type: mediaType !== undefined && mediaType.length > 0 ? mediaType : OCTET_STREAM,\n bytes,\n sha256,\n ...(typeof width === 'number' && typeof height === 'number'\n ? { dimensions: { width, height } }\n : {}),\n };\n}\n\nfunction sendFiles(input: unknown): readonly Record<string, unknown>[] | null {\n const files = record(input).files;\n if (files === undefined) return [];\n if (!Array.isArray(files)) return null;\n const declared: Record<string, unknown>[] = [];\n for (const entry of files) {\n const file = sendFile(entry);\n if (file === null) return null;\n declared.push(file);\n }\n return declared;\n}\n\nfunction sendBody(input: unknown): Record<string, unknown> | null {\n const files = sendFiles(input);\n if (files === null) return null;\n const textValue = text(input, 'text');\n return {\n conversation_id: text(input, 'conversation'),\n operation_id: operationId(input),\n ...(textValue !== undefined && textValue.length > 0 ? { text: textValue } : {}),\n ...(files.length === 0 ? {} : { files }),\n };\n}\n\nasync function fileBytes(file: unknown): Promise<Uint8Array | null> {\n const blob = record(file).blob;\n if (blob === undefined || typeof blob !== 'object' || blob === null) return null;\n if (!('arrayBuffer' in blob) || typeof blob.arrayBuffer !== 'function') return null;\n return new Uint8Array(await (blob as Blob).arrayBuffer());\n}\n\nfunction delivered(answer: HouseDoorAnswer, name: string): ActionResult | null {\n return answer.status === 200 ? null : actionOutcome(answer, name);\n}\n\nfunction uploadGrant(\n entry: unknown,\n): { method: 'POST'; operation: string; url: string } | 'absent' | null {\n if (!('upload' in record(entry))) return 'absent';\n const upload = record(record(entry).upload);\n if (upload.method !== 'POST') return null;\n if (typeof upload.operation !== 'string' || typeof upload.url !== 'string') return null;\n return { method: 'POST', operation: upload.operation, url: upload.url };\n}\n\nasync function uploadOriginals(\n transport: HouseTransport,\n input: unknown,\n result: unknown,\n): Promise<ActionResult | null> {\n const originals = record(result).originals;\n if (!Array.isArray(originals) || originals.length === 0) return null;\n const files = Array.isArray(record(input).files) ? (record(input).files as unknown[]) : [];\n for (const [index, entry] of originals.entries()) {\n const grant = uploadGrant(entry);\n if (grant === 'absent') continue;\n if (grant === null) return malformed();\n const bytes = index < files.length ? await fileBytes(files[index]) : null;\n if (bytes === null) {\n return { kind: 'rejected', code: 'conversation_original_descriptor_required', fields: {} };\n }\n const failed = delivered(\n await transport.transfer({\n act: 'conversation_original_upload',\n method: 'POST',\n url: grant.url,\n answer: 'json',\n body: bytes,\n operation: grant.operation,\n }),\n 'conversation.send',\n );\n if (failed !== null) return failed;\n }\n return null;\n}\n\nasync function attachAction(transport: HouseTransport, input: unknown): Promise<ActionResult> {\n const { blob, ...descriptor } = record(input);\n const bytes = await fileBytes({ blob });\n if (bytes === null) return malformed();\n const answer = await transport.door('/door/attachments/upload', descriptor);\n const outcome = actionOutcome(answer, 'attachments/upload');\n if (outcome.kind !== 'action') return outcome;\n const grant = uploadGrant(outcome.result);\n if (grant === 'absent') return outcome;\n if (grant === null) return malformed();\n const stored = await transport.transfer({\n act: 'original_upload',\n method: 'POST',\n url: grant.url,\n answer: 'json',\n body: bytes,\n operation: grant.operation,\n });\n return delivered(stored, 'attachments/upload') ?? { kind: 'action', result: stored.body };\n}\n\nasync function openAction(transport: HouseTransport, input: unknown): Promise<ActionResult> {\n const answer = await transport.door('/door/attachments/get', input);\n const outcome = actionOutcome(answer, 'attachments/get');\n if (outcome.kind !== 'action') return outcome;\n const { download, ...opened } = record(outcome.result);\n if (download === undefined) return outcome;\n const grant = record(download);\n if (grant.method !== 'GET' || typeof grant.url !== 'string') return malformed();\n const read = await transport.transfer({\n act: 'original_download',\n method: 'GET',\n url: grant.url,\n answer: 'bytes',\n });\n const failed = delivered(read, 'attachments/get');\n if (failed !== null) return failed;\n if (!(read.body instanceof Blob)) return { kind: 'transport-uncertainty' };\n return { kind: 'action', result: { ...opened, blob: read.body } };\n}\n\nasync function sendAction(transport: HouseTransport, input: unknown): Promise<ActionResult> {\n const body = sendBody(input);\n if (body === null) return malformed();\n const answer = await transport.door('/door/conversations/send', body);\n const outcome = actionOutcome(answer, 'conversation.send');\n if (outcome.kind !== 'action') return outcome;\n const uploaded = await uploadOriginals(transport, input, outcome.result);\n if (uploaded !== null) return uploaded;\n return outcome;\n}\n\ntype HistoryCursor = { accepted_at: string; message_id: string };\n\nfunction historyCursor(value: unknown): HistoryCursor | null {\n const acceptedAt = text(value, 'accepted_at');\n const messageId = text(value, 'message_id');\n if (acceptedAt === undefined || messageId === undefined) return null;\n return { accepted_at: acceptedAt, message_id: messageId };\n}\n\nfunction position(cursor: HistoryCursor): string {\n return JSON.stringify({ accepted_at: cursor.accepted_at, message_id: cursor.message_id });\n}\n\nfunction positionCursor(value: string): HistoryCursor | null {\n try {\n return historyCursor(JSON.parse(value) as unknown);\n } catch {\n return null;\n }\n}\n\nexport function acceptedMessage(entry: unknown): AcceptedMessage | null {\n const cursor = historyCursor(entry);\n if (cursor === null) return null;\n return {\n identity: cursor.message_id,\n turn: text(entry, 'turn_id') ?? cursor.message_id,\n position: position(cursor),\n text: text(entry, 'text') ?? '',\n message: structuredClone(entry),\n };\n}\n\nasync function historyAction(transport: HouseTransport, input: unknown): Promise<ActionResult> {\n const conversationId = text(input, 'conversation');\n if (conversationId === undefined) return malformed();\n const afterValue = text(input, 'after');\n const after = afterValue === undefined ? undefined : positionCursor(afterValue);\n if (after === null) return malformed();\n const answer = await transport.door('/door/conversations/history', {\n conversation_id: conversationId,\n ...(after === undefined ? {} : { after }),\n limit: HISTORY_PAGE,\n });\n const outcome = actionOutcome(answer, 'conversation.history');\n if (outcome.kind !== 'action') return outcome;\n const held = record(outcome.result);\n if (!Array.isArray(held.messages)) return { kind: 'transport-uncertainty' };\n const messages: AcceptedMessage[] = [];\n for (const entry of held.messages) {\n const message = acceptedMessage(entry);\n if (message === null) return { kind: 'transport-uncertainty' };\n messages.push(message);\n }\n const next = held.next === null || held.next === undefined ? undefined : historyCursor(held.next);\n if (next === null) return { kind: 'transport-uncertainty' };\n const page: ConversationHistoryPage = {\n messages,\n ...(next === undefined ? {} : { next: position(next) }),\n };\n return { kind: 'action', result: page };\n}\n"],"names":["changeBatchIdentity","doorRefusal","PRIVATE_LOCATOR","HISTORY_PAGE","OCTET_STREAM","CONVERSATION_ROUTES","Map","HOUSE_CONVERSATION_CARDS","locator","type","identity","agent","declaredActions","routes","mapped","map","name","route","slice","length","get","inputShape","resultKind","houseAction","transport","request","sendAction","input","historyAction","attachAction","openAction","routeOf","Promise","resolve","malformed","carry","undefined","parts","split","some","part","encodeURIComponent","join","record","value","text","held","operationId","kind","code","fields","bodyOf","agent_id","operation_id","conversation_id","nested","answer","interaction_id","response","withTurn","body","turn","actionOutcome","status","refusal","result","door","sendFile","entry","file","bytes","byteLength","sha256","mediaType","width","height","media_type","dimensions","sendFiles","files","Array","isArray","declared","push","sendBody","textValue","fileBytes","blob","arrayBuffer","Uint8Array","delivered","uploadGrant","upload","method","operation","url","uploadOriginals","originals","index","entries","grant","failed","transfer","act","descriptor","outcome","stored","download","opened","read","Blob","uploaded","historyCursor","acceptedAt","messageId","accepted_at","message_id","position","cursor","JSON","stringify","positionCursor","parse","acceptedMessage","message","structuredClone","conversationId","afterValue","after","limit","messages","next","page"],"mappings":"AAAA,SACEA,mBAAmB,QAOd,yBAAyB;AAChC,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,eAAe,QAAQ,iBAAiB;AAGjD,MAAMC,eAAe;AAErB,MAAMC,eAAe;AAErB,MAAMC,sBAAmD,IAAIC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AO;QAAEnF,MAAM;IAAwB;IAC1D,MAAMoF,OAAgC;QACpCF;QACA,GAAIC,SAAS/F,YAAY,CAAC,IAAI;YAAE+F,MAAMd,SAASc;QAAM,CAAC;IACxD;IACA,OAAO;QAAEnF,MAAM;QAAUiB,QAAQmE;IAAK;AACxC"}
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -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;AAoChC,OAAO,EAQL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAiBxB,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;AAwBjC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,
|
|
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;AAoChC,OAAO,EAQL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAiBxB,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;AAwBjC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA8PpF"}
|
package/dist/adapter.js
CHANGED
|
@@ -70,7 +70,8 @@ export function createAgentsHouseAdapter(options) {
|
|
|
70
70
|
const answer = await transport.transfer({
|
|
71
71
|
act: 'working_copy_bundle',
|
|
72
72
|
method: 'GET',
|
|
73
|
-
url: grant.url
|
|
73
|
+
url: grant.url,
|
|
74
|
+
answer: 'json'
|
|
74
75
|
});
|
|
75
76
|
return answer.status === 200 ? answer.body : null;
|
|
76
77
|
}
|
|
@@ -105,6 +106,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
105
106
|
act: 'authored_batch_upload',
|
|
106
107
|
method: 'POST',
|
|
107
108
|
url: grant.url,
|
|
109
|
+
answer: 'json',
|
|
108
110
|
body: `${grant.operation}\n${delta}`
|
|
109
111
|
});
|
|
110
112
|
if (delivered.status !== 200) return {
|
|
@@ -264,10 +266,16 @@ export function createAgentsHouseAdapter(options) {
|
|
|
264
266
|
});
|
|
265
267
|
},
|
|
266
268
|
async action (_authorization, request) {
|
|
267
|
-
|
|
269
|
+
const result = await houseAction(transport, request);
|
|
270
|
+
const answered = request.input?.conversation;
|
|
271
|
+
if (request.name === 'conversation.answer' && result.kind === 'action' && typeof answered === 'string') {
|
|
272
|
+
notifications.question(answered);
|
|
273
|
+
}
|
|
274
|
+
return result;
|
|
268
275
|
},
|
|
269
276
|
roomVersions: notifications,
|
|
270
|
-
conversations: notifications.conversations
|
|
277
|
+
conversations: notifications.conversations,
|
|
278
|
+
serviceMode: notifications.serviceMode
|
|
271
279
|
};
|
|
272
280
|
}
|
|
273
281
|
|
package/dist/adapter.js.map
CHANGED
|
@@ -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 { 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 } 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 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 { logPosition, presented } 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\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 models = modelShelf();\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 async function acquireModels(\n entries: readonly TrackedAuthority[],\n ): Promise<Map<string, HeldModel>> {\n const acquired = new Map<string, HeldModel>();\n const privateEntry = entries.find((entry) => entry.locator === PRIVATE_LOCATOR);\n const prefixes = entries.map((entry) => schemaPath(entry.handle, entry.schema));\n if (privateEntry !== undefined) prefixes.push(schemaPath(undefined, HOUSE_SCHEMA));\n const answer = await transport.door(DOOR_BOOTSTRAP, { prefixes });\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 entries) {\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 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 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: 'working_copy_bundle',\n method: 'GET',\n url: grant.url,\n });\n return answer.status === 200 ? answer.body : null;\n }\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 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 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 const answer = await transport.door(DOOR_BOOTSTRAP, {\n prefixes: [...contentPrefixes(entry)],\n });\n const classified = classifyDoor(answer.status, answer.body, entry.locator);\n if (classified !== null) {\n return classified.kind === 'beyond-horizon'\n ? { kind: 'transport-uncertainty' }\n : classified;\n }\n const envelope = parseEnvelope(await bundled(answer.body));\n if (envelope === null) return { kind: 'transport-uncertainty' };\n return bootstrapFrom(envelope, 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(entry, from);\n if (streamed !== null) return streamed;\n const answer = await transport.door(DOOR_ENUMERATE, {\n prefixes: [...contentPrefixes(entry)],\n positions: [presented(entry.authority, from)],\n });\n const classified = classifyDoor(answer.status, answer.body, entry.locator);\n if (classified !== null) return classified;\n const enumeration = parseEnumeration(answer.body, 'credential');\n if (enumeration === null) return { kind: 'transport-uncertainty' };\n return refreshFrom(enumeration, entry, request.fromRoomVersion);\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 async action(_authorization: Authorization, request: ActionRequest): Promise<ActionResult> {\n return houseAction(transport, request);\n },\n\n roomVersions: notifications,\n conversations: notifications.conversations,\n };\n}\n"],"names":["DISCOVER_PREFIXES","HOUSE_SCHEMA","capabilities","discoveredRoom","locatorOf","mapDiscovery","parseDiscovery","providerSelection","trackedFrom","MODEL_ABSENT","failedModel","heldModel","modelKey","modelShelf","createSiteAdapter","bootstrapFrom","contentPrefixes","parseEnumeration","parseEnvelope","parseGrant","refreshFrom","schemaFrom","schemaPath","houseAction","classifyDoor","discoveryFailure","houseNotifications","DOOR_BATCH","DOOR_BATCH_UPLOAD","DOOR_BOOTSTRAP","DOOR_DISCOVER","DOOR_ENUMERATE","DOOR_REVISIONS","PRIVATE_LOCATOR","batchPaths","deltaBody","deltaBytes","deltaDigest","historyOutcome","houseChanges","mutationOutcome","operationHead","rejectedMapping","revisionBody","uploadable","logPosition","presented","UNCERTAIN","kind","lapsedGrant","outcome","code","modelFailure","classified","envelope","createAgentsHouseAdapter","options","site","transport","notifications","tracked","Map","models","held","entry","schema","failure","handle","acquireModels","entries","acquired","privateEntry","find","locator","prefixes","map","undefined","push","answer","door","status","body","bundled","set","roomOf","authority","key","collection","retain","get","roomHandle","identity","selection","authorityFor","grant","method","transfer","act","url","uploaded","head","changes","delta","bytes","handed","keep","paths","sha256","upload","minted","delivered","operation","holding","submit","prepared","authorize","model","_authorization","request","discover","document","clear","track","authorities","actions","bootstrap","pageToken","refresh","from","fromRoomVersion","streamed","advance","positions","enumeration","mutate","mapped","changeBatch","history","path","revision","action","roomVersions","conversations"],"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,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,QAAQ,eAAe;AAC9D,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SACEC,UAAU,EACVC,iBAAiB,EACjBC,cAAc,EACdC,aAAa,EACbC,cAAc,EACdC,cAAc,EACdC,eAAe,QAGV,iB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,OAAOwC,QAAQC;YAChF,IAAID,WAAW5B,aAAa,CAAC3B,YAAYC,UAAU,OAAOA;YAC1D,OAAO+D,OAAOb,MAAMmC,OAAOlC,OAAO,EAAEC,OAAOC,OAAOvC,OAAOY,WAAW6B;QACtE;QAEA,MAAMgC,SAAQpB,cAA6B,EAAEC,OAAuB;YAClE,MAAMtD,QAAQ6B,aAAayB,QAAQ7C,OAAO;YAC1C,IAAIT,UAAUY,WAAW,OAAO;gBAAE5B,MAAM;gBAAqByB,SAAS6C,QAAQ7C,OAAO;YAAC;YACtF,MAAMK,SAAS,MAAMpB,UAAUqB,IAAI,CACjC/C,gBACAW,aAAa;gBACX+F,MAAMpB,QAAQoB,IAAI;gBAClBvE,QAAQH,MAAMG,MAAM;gBACpB,GAAImD,QAAQqB,QAAQ,KAAK/D,YAAY,CAAC,IAAI;oBAAE+D,UAAUrB,QAAQqB,QAAQ;gBAAC,CAAC;gBACxE,GAAIrB,QAAQQ,SAAS,KAAKlD,YAAY,CAAC,IAAI;oBAAEkD,WAAWR,QAAQQ,SAAS;gBAAC,CAAC;YAC7E;YAEF,OAAOxF,eAAewC,OAAOE,MAAM,EAAEF,OAAOG,IAAI,EAAEjB,MAAMS,OAAO,EAAE;gBAC/DiE,MAAMpB,QAAQoB,IAAI;gBAClB,GAAIpB,QAAQqB,QAAQ,KAAK/D,YAAY,CAAC,IAAI;oBAAE+D,UAAUrB,QAAQqB,QAAQ;gBAAC,CAAC;YAC1E;QACF;QAEA,MAAMC,QAAOvB,cAA6B,EAAEC,OAAsB;YAChE,OAAO/F,YAAYmC,WAAW4D;QAChC;QAEAuB,cAAclF;QACdmF,eAAenF,cAAcmF,aAAa;IAC5C;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 { 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 } 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 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 { logPosition, presented } 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\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 models = modelShelf();\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 async function acquireModels(\n entries: readonly TrackedAuthority[],\n ): Promise<Map<string, HeldModel>> {\n const acquired = new Map<string, HeldModel>();\n const privateEntry = entries.find((entry) => entry.locator === PRIVATE_LOCATOR);\n const prefixes = entries.map((entry) => schemaPath(entry.handle, entry.schema));\n if (privateEntry !== undefined) prefixes.push(schemaPath(undefined, HOUSE_SCHEMA));\n const answer = await transport.door(DOOR_BOOTSTRAP, { prefixes });\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 entries) {\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 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 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: 'working_copy_bundle',\n method: 'GET',\n url: grant.url,\n answer: 'json',\n });\n return answer.status === 200 ? answer.body : null;\n }\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 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 const answer = await transport.door(DOOR_BOOTSTRAP, {\n prefixes: [...contentPrefixes(entry)],\n });\n const classified = classifyDoor(answer.status, answer.body, entry.locator);\n if (classified !== null) {\n return classified.kind === 'beyond-horizon'\n ? { kind: 'transport-uncertainty' }\n : classified;\n }\n const envelope = parseEnvelope(await bundled(answer.body));\n if (envelope === null) return { kind: 'transport-uncertainty' };\n return bootstrapFrom(envelope, 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(entry, from);\n if (streamed !== null) return streamed;\n const answer = await transport.door(DOOR_ENUMERATE, {\n prefixes: [...contentPrefixes(entry)],\n positions: [presented(entry.authority, from)],\n });\n const classified = classifyDoor(answer.status, answer.body, entry.locator);\n if (classified !== null) return classified;\n const enumeration = parseEnumeration(answer.body, 'credential');\n if (enumeration === null) return { kind: 'transport-uncertainty' };\n return refreshFrom(enumeration, entry, request.fromRoomVersion);\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 async action(_authorization: Authorization, request: ActionRequest): Promise<ActionResult> {\n const result = await houseAction(transport, request);\n const answered = (request.input as { conversation?: unknown } | null)?.conversation;\n if (\n request.name === 'conversation.answer' &&\n result.kind === 'action' &&\n typeof answered === 'string'\n ) {\n notifications.question(answered);\n }\n return result;\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","createSiteAdapter","bootstrapFrom","contentPrefixes","parseEnumeration","parseEnvelope","parseGrant","refreshFrom","schemaFrom","schemaPath","houseAction","classifyDoor","discoveryFailure","houseNotifications","DOOR_BATCH","DOOR_BATCH_UPLOAD","DOOR_BOOTSTRAP","DOOR_DISCOVER","DOOR_ENUMERATE","DOOR_REVISIONS","PRIVATE_LOCATOR","batchPaths","deltaBody","deltaBytes","deltaDigest","historyOutcome","houseChanges","mutationOutcome","operationHead","rejectedMapping","revisionBody","uploadable","logPosition","presented","UNCERTAIN","kind","lapsedGrant","outcome","code","modelFailure","classified","envelope","createAgentsHouseAdapter","options","site","transport","notifications","tracked","Map","models","held","entry","schema","failure","handle","acquireModels","entries","acquired","privateEntry","find","locator","prefixes","map","undefined","push","answer","door","status","body","bundled","set","roomOf","authority","key","collection","retain","get","roomHandle","identity","selection","authorityFor","grant","method","transfer","act","url","uploaded","head","changes","delta","bytes","handed","keep","paths","sha256","upload","minted","delivered","operation","holding","submit","prepared","authorize","model","_authorization","request","discover","document","clear","track","authorities","actions","bootstrap","pageToken","refresh","from","fromRoomVersion","streamed","advance","positions","enumeration","mutate","mapped","changeBatch","history","path","revision","action","result","answered","input","conversation","name","question","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,iBAAiB,QAAQ,YAAY;AAC9C,SACE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AQ;gBAAC,CAAC;YAC1E;QACF;QAEA,MAAMC,QAAOvB,cAA6B,EAAEC,OAAsB;YAChE,MAAMuB,SAAS,MAAMtH,YAAYmC,WAAW4D;YAC5C,MAAMwB,WAAYxB,QAAQyB,KAAK,EAAwCC;YACvE,IACE1B,QAAQ2B,IAAI,KAAK,yBACjBJ,OAAO7F,IAAI,KAAK,YAChB,OAAO8F,aAAa,UACpB;gBACAnF,cAAcuF,QAAQ,CAACJ;YACzB;YACA,OAAOD;QACT;QAEAM,cAAcxF;QACdyF,eAAezF,cAAcyF,aAAa;QAC1CC,aAAa1F,cAAc0F,WAAW;IACxC;AACF"}
|
package/dist/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,SAAS,EACT,cAAc,EACf,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,eAAO,MAAM,iBAAiB,yBAAyB,CAAC;AAExD,eAAO,MAAM,0BAA0B,+BAA+B,CAAC;AAEvE,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AAEjE,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAU,CAAC;AAE1D,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,
|
|
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,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0CD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI,CAoB3E;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,kBAAkB,GAAG,WAAW,EAAE,CAWvE;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,CAAC,OAAO,CAAC,CAK1E;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,cAAc,GAAG,MAAM,CAE3D;AAMD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,sBAAsB,GAAG,gBAAgB,EAAE,CAWhF;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
package/dist/discovery.js.map
CHANGED
|
@@ -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[] = ['agents', 'house', 'settings/apps'];\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 collectionRoot: 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 collectionRoot: 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 collectionRoot: 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.collection_root !== 'string' || typeof held.model_root !== 'string') return null;\n if (held.managed_replication !== 'admitted' && held.managed_replication !== 'unavailable') {\n return null;\n }\n 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 collectionRoot: held.collection_root,\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.collection_root !== 'string' || 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 collectionRoot: held.collection_root,\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 collectionRoot: authority.collectionRoot,\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 collectionRoot: authority.collectionRoot,\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 collectionRoot: authority.collectionRoot,\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 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","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","collection_root","model_root","managed_replication","at","protectedPaths","protected_paths","room_ref","room_handle","roomRef","roomHandle","collectionRoot","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","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;IAAC;IAAU;IAAS;CAAgB,CAAC;AAEhG,OAAO,MAAMC,eAAe,oBAAoB;AA0EhD,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,OAAON;IACb,MAAMO,SAA+B,CAAC;IACtC,KAAK,MAAMC,OAAOX,WAAY;QAC5B,MAAMY,SAASH,IAAI,CAACE,IAAI;QACxB,IAAI,OAAOC,WAAW,YAAY,CAACC,OAAOC,QAAQ,CAACF,SAAS,OAAO;QACnEF,MAAM,CAACC,IAAI,GAAGC;IAChB;IACA,OAAOF;AACT;AAEA,SAASK,gBAAgBZ,KAAc;IACrC,IAAI,OAAOA,UAAU,YAAYA,UAAU,MAAM,OAAO;IACxD,MAAMM,OAAON;IACb,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B;QAC1C8G,SAAS;YAAEC,UAAU9G;YAAmB+G,SAAShD,SAASX,cAAc;QAAC;QACzEsD;QACAnB,cAAcoB;QACdhC,gBAAgBA,eAAeZ,SAAS9C,MAAM;QAC9C+F,WAAW/B,kBAAkBlB,SAAS9C,MAAM;IAC9C;AACF"}
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/discovery.ts"],"sourcesContent":["import type {\n Capability,\n DiscoveredRoom,\n Discovery,\n ProviderLimit,\n Retention,\n TypedSelection,\n} from '@agentshouse/mdruntime';\nimport { declaredActions, HOUSE_CONVERSATION_CARDS } from './actions.js';\nimport { PRIVATE_LOCATOR } from './transport.js';\nimport { readPosition, roomVersion, type LogPosition } from './version.js';\n\nexport const ROOM_CONTRACT_VERSION = 1;\n\nexport const MD_MODEL_IDENTITY = '@agentshouse/mdmodel';\n\nexport const ROOM_VERSION_NOTIFICATIONS = 'room-version-notifications';\n\nexport const PROVIDER_ACTIONS = 'provider-actions';\n\nexport const MOVE_REFERENCE_REWRITES = 'move-reference-rewrites';\n\nexport const DISCOVER_PREFIXES: readonly string[] = ['/'];\n\nexport const PROVIDER_SELECTION_ROOTS: readonly string[] = [\n 'agents',\n 'house',\n 'settings/apps',\n 'settings/panel.md',\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 collectionRoot: 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 collectionRoot: 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 collectionRoot: 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.collection_root !== 'string' || typeof held.model_root !== 'string') return null;\n if (held.managed_replication !== 'admitted' && held.managed_replication !== 'unavailable') {\n return null;\n }\n 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 collectionRoot: held.collection_root,\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.collection_root !== 'string' || 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 collectionRoot: held.collection_root,\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 collectionRoot: authority.collectionRoot,\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 collectionRoot: authority.collectionRoot,\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 collectionRoot: authority.collectionRoot,\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 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","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","collection_root","model_root","managed_replication","at","protectedPaths","protected_paths","room_ref","room_handle","roomRef","roomHandle","collectionRoot","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","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;CACD,CAAC;AAEF,OAAO,MAAMC,eAAe,oBAAoB;AA0EhD,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,OAAON;IACb,MAAMO,SA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UAAUrB;YAAYqD,WAAWrD,UAAUT,kBAAkB;QAAC;QACpFoD;QACA,GAAIG,mBAAmBtB,YAAY,CAAC,IAAI;YAAEsB;QAAe,CAAC;QAC1DQ,oBAAoB;eAAItD,UAAUjB,cAAc;eAAKuC,UAAUtB;SAAW;IAC5E;AACF;AAEA,OAAO,SAASuD,aACd1C,QAAmE,EACnE2C,KAAgC,EAChCC,QAA+B;IAE/B,OAAO;QACLjF,MAAM;QACNkF,mBAAmB;YAAC7G;SAAsB;QAC1C8G,SAAS;YAAEC,UAAU9G;YAAmB+G,SAAShD,SAASX,cAAc;QAAC;QACzEsD;QACAnB,cAAcoB;QACdhC,gBAAgBA,eAAeZ,SAAS9C,MAAM;QAC9C+F,WAAW/B,kBAAkBlB,SAAS9C,MAAM;IAC9C;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
|
|
2
2
|
export { nativePath, roomLocalPath } from './map.js';
|
|
3
|
-
export type { HouseByteAct, HouseByteTransfer, HouseDoorAnswer, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
|
|
3
|
+
export type { HouseByteAct, HouseByteAnswer, HouseByteTransfer, HouseDoorAnswer, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACrD,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACrD,YAAY,EACV,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/index.ts"],"sourcesContent":["export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';\nexport { nativePath, roomLocalPath } from './map.js';\nexport type {\n HouseByteAct,\n HouseByteTransfer,\n HouseDoorAnswer,\n HouseStream,\n HouseStreamEntry,\n HouseStreamFrame,\n HouseSiteTransport,\n HouseTransport,\n} from './transport.js';\n"],"names":["createAgentsHouseAdapter","nativePath","roomLocalPath"],"mappings":"AAAA,SAASA,wBAAwB,QAAwC,eAAe;AACxF,SAASC,UAAU,EAAEC,aAAa,QAAQ,WAAW"}
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/index.ts"],"sourcesContent":["export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';\nexport { nativePath, roomLocalPath } from './map.js';\nexport type {\n HouseByteAct,\n HouseByteAnswer,\n HouseByteTransfer,\n HouseDoorAnswer,\n HouseStream,\n HouseStreamEntry,\n HouseStreamFrame,\n HouseSiteTransport,\n HouseTransport,\n} from './transport.js';\n"],"names":["createAgentsHouseAdapter","nativePath","roomLocalPath"],"mappings":"AAAA,SAASA,wBAAwB,QAAwC,eAAe;AACxF,SAASC,UAAU,EAAEC,aAAa,QAAQ,WAAW"}
|
package/dist/refusal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACd,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACd,MAAM,wBAAwB,CAAC;AAehC,MAAM,MAAM,WAAW,GAAG,eAAe,CAAC;AAE1C,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAO7D;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,aAAa,CAEf;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAAG,IAAI,CAepD;AAED,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GACtD,cAAc,CAMhB"}
|