@agentshouse/mdruntime-adapter 0.1.0-alpha.45 → 0.1.0-alpha.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"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"}
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,EAGvB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAkBtE,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
@@ -2,6 +2,7 @@ import { changeBatchIdentity } from '@agentshouse/mdruntime';
2
2
  import { doorRefusal } from './refusal.js';
3
3
  import { PRIVATE_LOCATOR } from './transport.js';
4
4
  const HISTORY_PAGE = 100;
5
+ const HISTORY_CONVERSATIONS = 64;
5
6
  const OCTET_STREAM = 'application/octet-stream';
6
7
  const CONVERSATION_ROUTES = new Map([
7
8
  [
@@ -348,46 +349,74 @@ export function acceptedMessage(entry) {
348
349
  message: structuredClone(entry)
349
350
  };
350
351
  }
351
- async function historyAction(transport, input) {
352
- const conversationId = text(input, 'conversation');
353
- if (conversationId === undefined) return malformed();
354
- const afterValue = text(input, 'after');
355
- const after = afterValue === undefined ? undefined : positionCursor(afterValue);
356
- if (after === null) return malformed();
357
- const answer = await transport.door('/door/conversations/history', {
358
- conversation_id: conversationId,
359
- ...after === undefined ? {} : {
360
- after
361
- },
362
- limit: HISTORY_PAGE
363
- });
364
- const outcome = actionOutcome(answer, 'conversation.history');
365
- if (outcome.kind !== 'action') return outcome;
366
- const held = record(outcome.result);
367
- if (!Array.isArray(held.messages)) return {
368
- kind: 'transport-uncertainty'
369
- };
352
+ function historyPage(entry) {
353
+ const held = record(entry);
354
+ const conversation = text(held, 'conversation_id');
355
+ if (conversation === undefined || !Array.isArray(held.messages)) return null;
370
356
  const messages = [];
371
- for (const entry of held.messages){
372
- const message = acceptedMessage(entry);
373
- if (message === null) return {
374
- kind: 'transport-uncertainty'
375
- };
357
+ for (const one of held.messages){
358
+ const message = acceptedMessage(one);
359
+ if (message === null) return null;
376
360
  messages.push(message);
377
361
  }
378
362
  const next = held.next === null || held.next === undefined ? undefined : historyCursor(held.next);
379
- if (next === null) return {
380
- kind: 'transport-uncertainty'
381
- };
382
- const page = {
363
+ if (next === null) return null;
364
+ return {
365
+ conversation,
383
366
  messages,
384
367
  ...next === undefined ? {} : {
385
368
  next: position(next)
386
369
  }
387
370
  };
371
+ }
372
+ function historyAsks(input) {
373
+ const asked = record(input).conversations;
374
+ if (!Array.isArray(asked) || asked.length === 0) return null;
375
+ const asks = [];
376
+ for (const entry of asked){
377
+ const conversationId = text(entry, 'conversation');
378
+ if (conversationId === undefined) return null;
379
+ const afterValue = text(entry, 'after');
380
+ const after = afterValue === undefined ? undefined : positionCursor(afterValue);
381
+ if (after === null) return null;
382
+ asks.push({
383
+ conversation_id: conversationId,
384
+ ...after === undefined ? {} : {
385
+ after
386
+ }
387
+ });
388
+ }
389
+ return asks;
390
+ }
391
+ async function historyAction(transport, input) {
392
+ const asks = historyAsks(input);
393
+ if (asks === null) return malformed();
394
+ const histories = [];
395
+ for(let at = 0; at < asks.length; at += HISTORY_CONVERSATIONS){
396
+ const answer = await transport.door('/door/conversations/history', {
397
+ conversations: asks.slice(at, at + HISTORY_CONVERSATIONS),
398
+ limit: HISTORY_PAGE
399
+ });
400
+ const outcome = actionOutcome(answer, 'conversation.history');
401
+ if (outcome.kind !== 'action') return outcome;
402
+ const answered = record(outcome.result).histories;
403
+ if (!Array.isArray(answered)) return {
404
+ kind: 'transport-uncertainty'
405
+ };
406
+ for (const entry of answered){
407
+ const page = historyPage(entry);
408
+ if (page === null) return {
409
+ kind: 'transport-uncertainty'
410
+ };
411
+ histories.push(page);
412
+ }
413
+ }
414
+ const result = {
415
+ histories
416
+ };
388
417
  return {
389
418
  kind: 'action',
390
- result: page
419
+ result
391
420
  };
392
421
  }
393
422
 
@@ -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 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,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,gBA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G,KAAc;IACpE,MAAMmG,iBAAiBjF,KAAKlB,OAAO;IACnC,IAAImG,mBAAmB1F,WAAW,OAAOF;IACzC,MAAM6F,aAAalF,KAAKlB,OAAO;IAC/B,MAAMqG,QAAQD,eAAe3F,YAAYA,YAAYqF,eAAeM;IACpE,IAAIC,UAAU,MAAM,OAAO9F;IAC3B,MAAMsB,SAAS,MAAMhC,UAAU0C,IAAI,CAAC,+BAA+B;QACjEZ,iBAAiBwE;QACjB,GAAIE,UAAU5F,YAAY,CAAC,IAAI;YAAE4F;QAAM,CAAC;QACxCC,OAAO9H;IACT;IACA,MAAMsG,UAAU3C,cAAcN,QAAQ;IACtC,IAAIiD,QAAQzD,IAAI,KAAK,UAAU,OAAOyD;IACtC,MAAM3D,OAAOH,OAAO8D,QAAQxC,MAAM;IAClC,IAAI,CAACe,MAAMC,OAAO,CAACnC,KAAKoF,QAAQ,GAAG,OAAO;QAAElF,MAAM;IAAwB;IAC1E,MAAMkF,WAA8B,EAAE;IACtC,KAAK,MAAM9D,SAAStB,KAAKoF,QAAQ,CAAE;QACjC,MAAMN,UAAUD,gBAAgBvD;QAChC,IAAIwD,YAAY,MAAM,OAAO;YAAE5E,MAAM;QAAwB;QAC7DkF,SAAS/C,IAAI,CAACyC;IAChB;IACA,MAAMO,OAAOrF,KAAKqF,IAAI,KAAK,QAAQrF,KAAKqF,IAAI,KAAK/F,YAAYA,YAAY4E,cAAclE,KAAKqF,IAAI;IAChG,IAAIA,SAAS,MAAM,OAAO;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"}
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 ConversationHistories,\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 HISTORY_CONVERSATIONS = 64;\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\nfunction historyPage(entry: unknown): ConversationHistoryPage | null {\n const held = record(entry);\n const conversation = text(held, 'conversation_id');\n if (conversation === undefined || !Array.isArray(held.messages)) return null;\n const messages: AcceptedMessage[] = [];\n for (const one of held.messages) {\n const message = acceptedMessage(one);\n if (message === null) return null;\n messages.push(message);\n }\n const next = held.next === null || held.next === undefined ? undefined : historyCursor(held.next);\n if (next === null) return null;\n return { conversation, messages, ...(next === undefined ? {} : { next: position(next) }) };\n}\n\nfunction historyAsks(input: unknown): Record<string, unknown>[] | null {\n const asked = record(input).conversations;\n if (!Array.isArray(asked) || asked.length === 0) return null;\n const asks: Record<string, unknown>[] = [];\n for (const entry of asked) {\n const conversationId = text(entry, 'conversation');\n if (conversationId === undefined) return null;\n const afterValue = text(entry, 'after');\n const after = afterValue === undefined ? undefined : positionCursor(afterValue);\n if (after === null) return null;\n asks.push({ conversation_id: conversationId, ...(after === undefined ? {} : { after }) });\n }\n return asks;\n}\n\nasync function historyAction(transport: HouseTransport, input: unknown): Promise<ActionResult> {\n const asks = historyAsks(input);\n if (asks === null) return malformed();\n const histories: ConversationHistoryPage[] = [];\n for (let at = 0; at < asks.length; at += HISTORY_CONVERSATIONS) {\n const answer = await transport.door('/door/conversations/history', {\n conversations: asks.slice(at, at + HISTORY_CONVERSATIONS),\n limit: HISTORY_PAGE,\n });\n const outcome = actionOutcome(answer, 'conversation.history');\n if (outcome.kind !== 'action') return outcome;\n const answered = record(outcome.result).histories;\n if (!Array.isArray(answered)) return { kind: 'transport-uncertainty' };\n for (const entry of answered) {\n const page = historyPage(entry);\n if (page === null) return { kind: 'transport-uncertainty' };\n histories.push(page);\n }\n }\n const result: ConversationHistories = { histories };\n return { kind: 'action', result };\n}\n"],"names":["changeBatchIdentity","doorRefusal","PRIVATE_LOCATOR","HISTORY_PAGE","HISTORY_CONVERSATIONS","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","historyPage","conversation","messages","one","next","historyAsks","asked","conversations","asks","conversationId","afterValue","after","histories","at","lim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}
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,OAAO,EACP,aAAa,EAad,MAAM,wBAAwB,CAAC;AAqChC,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAuBxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAiCjC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAsXpF"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,OAAO,EACP,aAAa,EAad,MAAM,wBAAwB,CAAC;AAqChC,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAuBxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAiCjC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA6WpF"}
package/dist/adapter.js CHANGED
@@ -370,12 +370,7 @@ export function createAgentsHouseAdapter(options) {
370
370
  return reachedVersion(version, target, authorityFor(locator)?.logEpoch);
371
371
  },
372
372
  async action (_authorization, request) {
373
- const result = withAt(await houseAction(transport, request));
374
- const answered = request.input?.conversation;
375
- if (request.name === 'conversation.answer' && result.kind === 'action' && typeof answered === 'string') {
376
- notifications.question(answered);
377
- }
378
- return result;
373
+ return withAt(await houseAction(transport, request));
379
374
  },
380
375
  roomVersions: notifications,
381
376
  conversations: notifications.conversations,
@@ -1 +1 @@
1
- {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/adapter.ts"],"sourcesContent":["import type {\n ActionRequest,\n ActionResult,\n Adapter,\n Authorization,\n BootstrapRequest,\n BootstrapResult,\n DiscoverResult,\n DiscoveredRoom,\n HistoryRequest,\n HistoryResult,\n ModelRequest,\n ModelResult,\n MutationRequest,\n MutationResult,\n RefreshRequest,\n RefreshResult,\n} from '@agentshouse/mdruntime';\nimport {\n DISCOVER_PREFIXES,\n HOUSE_SCHEMA,\n capabilities,\n discoveredRoom,\n locatorOf,\n mapDiscovery,\n parseDiscovery,\n providerSelection,\n trackedFrom,\n type HouseAuthority,\n type TrackedAuthority,\n} from './discovery.js';\nimport {\n MODEL_ABSENT,\n failedModel,\n heldModel,\n modelKey,\n modelShelf,\n type HeldModel,\n} from './model.js';\nimport { gathered, selections } from './gather.js';\nimport { createSiteAdapter } from './site.js';\nimport {\n bootstrapFrom,\n contentPrefixes,\n parseEnumeration,\n parseEnvelope,\n parseGrant,\n refreshFrom,\n schemaFrom,\n schemaPath,\n} from './read.js';\nimport { houseAction } from './actions.js';\nimport { classifyDoor, discoveryFailure, doorRefusal } from './refusal.js';\nimport { houseNotifications } from './stream.js';\nimport {\n DOOR_BATCH,\n DOOR_BATCH_UPLOAD,\n DOOR_BOOTSTRAP,\n DOOR_DISCOVER,\n DOOR_ENUMERATE,\n DOOR_REVISIONS,\n DOOR_SELECTION_MAX,\n PRIVATE_LOCATOR,\n type HouseSiteTransport,\n type HouseTransport,\n} from './transport.js';\nimport {\n batchPaths,\n deltaBody,\n deltaBytes,\n deltaDigest,\n historyOutcome,\n houseChanges,\n mutationOutcome,\n operationHead,\n rejectedMapping,\n revisionBody,\n uploadable,\n type OperationHead,\n} from './write.js';\nimport {\n logPosition,\n presented,\n reachedVersion,\n roomVersion,\n type LogPosition,\n} from './version.js';\n\nexport type AgentsHouseAdapterOptions =\n | {\n transport: HouseTransport;\n authorize(): Promise<Authorization>;\n }\n | { site: HouseSiteTransport };\n\nconst UNCERTAIN: MutationResult = { kind: 'transport-uncertainty' };\n\nconst UNCERTAIN_READ = { kind: 'transport-uncertainty' } as const;\n\ntype Enumerating = {\n entry: TrackedAuthority;\n from: LogPosition;\n fromRoomVersion: string;\n minPosition?: string;\n};\n\ntype Submission = { body: Record<string, unknown> } | { outcome: MutationResult };\n\ntype Upload = { url: string; operation: string; bytes: number; sha256: string };\n\ntype Keep = (upload: unknown) => Promise<void>;\n\nfunction lapsedGrant(outcome: MutationResult): boolean {\n return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';\n}\n\nfunction modelFailure(\n classified: ReturnType<typeof classifyDoor>,\n envelope: ReturnType<typeof parseEnvelope>,\n): ModelResult {\n if (classified === null) {\n return envelope === null ? { kind: 'transport-uncertainty' } : MODEL_ABSENT;\n }\n return failedModel(classified);\n}\n\nexport function createAgentsHouseAdapter(options: AgentsHouseAdapterOptions): Adapter {\n if ('site' in options) return createSiteAdapter(options.site);\n const transport = options.transport;\n const notifications = houseNotifications(transport, 'credential');\n const tracked = new Map<string, TrackedAuthority>();\n const 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 function modelPrefixes(entry: TrackedAuthority): readonly string[] {\n const own = schemaPath(entry.handle, entry.schema);\n return entry.locator === PRIVATE_LOCATOR ? [own, schemaPath(undefined, HOUSE_SCHEMA)] : [own];\n }\n\n async function acquireModels(\n entries: readonly TrackedAuthority[],\n ): Promise<Map<string, HeldModel>> {\n const acquired = new Map<string, HeldModel>();\n for (const part of selections(\n entries,\n (entry) => modelPrefixes(entry).length,\n DOOR_SELECTION_MAX,\n )) {\n const privateEntry = part.find((entry) => entry.locator === PRIVATE_LOCATOR);\n const answer = await transport.door(DOOR_BOOTSTRAP, {\n prefixes: part.flatMap((entry) => modelPrefixes(entry)),\n });\n const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);\n const envelope = classified === null ? parseEnvelope(await bundled(answer.body)) : null;\n const failure: ModelResult = modelFailure(classified, envelope);\n for (const entry of part) {\n acquired.set(\n modelKey(entry.locator, 'collection'),\n await held(envelope, entry, entry.schema, failure),\n );\n }\n if (privateEntry !== undefined) {\n acquired.set(\n modelKey(privateEntry.locator, 'typed-selection'),\n await held(envelope, privateEntry, HOUSE_SCHEMA, failure),\n );\n }\n }\n return acquired;\n }\n\n function roomOf(authority: HouseAuthority, acquired: Map<string, HeldModel>): DiscoveredRoom {\n const locator = locatorOf(authority);\n const key = modelKey(locator, 'collection');\n const collection = models.retain(key, acquired.get(key));\n if (authority.roomHandle !== null) {\n return discoveredRoom(authority, collection?.identity ?? null, undefined);\n }\n const selection = models.retain(\n modelKey(locator, 'typed-selection'),\n acquired.get(modelKey(locator, 'typed-selection')),\n );\n return discoveredRoom(\n authority,\n collection?.identity ?? null,\n providerSelection(selection?.identity ?? null),\n );\n }\n\n function authorityFor(locator: string): TrackedAuthority | undefined {\n return tracked.get(locator);\n }\n\n function withAt(result: ActionResult): ActionResult {\n if (result.kind !== 'action') return result;\n const body = result.result as Record<string, unknown> | null;\n if (typeof body !== 'object' || body === null) return result;\n const { authority, position, log_epoch: logEpoch } = body;\n if (typeof position !== 'string' || typeof logEpoch !== 'string') return result;\n const locator =\n authority === undefined\n ? PRIVATE_LOCATOR\n : [...tracked.values()].find((entry) => entry.authority === authority)?.locator;\n if (locator === undefined) return result;\n return { ...result, at: { locator, roomVersion: roomVersion({ position, logEpoch }) } };\n }\n\n async function bundled(body: unknown): Promise<unknown> {\n const grant = parseGrant(body);\n if (grant === null) return body;\n if (grant.method !== 'GET') return null;\n const answer = await transport.transfer({\n act: 'local_copy_bundle',\n method: 'GET',\n url: grant.url,\n answer: 'json',\n });\n return answer.status === 200 ? answer.body : null;\n }\n\n function weight(entry: TrackedAuthority): number {\n return contentPrefixes(entry).length;\n }\n\n async function bootstrapped(entries: readonly TrackedAuthority[]): Promise<BootstrapResult[]> {\n const answers: BootstrapResult[] = [];\n for (const part of selections(entries, weight, DOOR_SELECTION_MAX)) {\n const answer = await transport.door(DOOR_BOOTSTRAP, {\n prefixes: part.flatMap((entry) => contentPrefixes(entry)),\n });\n const classified = part.map((entry) =>\n classifyDoor(answer.status, answer.body, entry.locator),\n );\n const envelope = classified[0] === null ? parseEnvelope(await bundled(answer.body)) : null;\n part.forEach((entry, index) => {\n const failure = classified[index];\n if (failure === null || failure === undefined) {\n answers.push(envelope === null ? UNCERTAIN_READ : bootstrapFrom(envelope, entry));\n return;\n }\n answers.push(failure.kind === 'beyond-horizon' ? UNCERTAIN_READ : failure);\n });\n }\n return answers;\n }\n\n function layered(asks: readonly Enumerating[]): readonly (readonly Enumerating[])[] {\n const depths = new Map<string, number>();\n const layers: Enumerating[][] = [];\n for (const ask of asks) {\n const depth = depths.get(ask.entry.authority) ?? 0;\n depths.set(ask.entry.authority, depth + 1);\n (layers[depth] ??= []).push(ask);\n }\n return layers;\n }\n\n async function enumerated(asks: readonly Enumerating[]): Promise<RefreshResult[]> {\n const answers = new Map<Enumerating, RefreshResult>();\n const parts = layered(asks).flatMap((layer) =>\n selections(layer, (ask) => weight(ask.entry), DOOR_SELECTION_MAX),\n );\n for (const part of parts) {\n let open = [...part];\n while (open.length > 0) {\n const answer = await transport.door(DOOR_ENUMERATE, {\n prefixes: open.flatMap((ask) => contentPrefixes(ask.entry)),\n positions: open.map((ask) => ({\n ...presented(ask.entry.authority, ask.from),\n ...(ask.minPosition === undefined ? {} : { min_position: ask.minPosition }),\n })),\n });\n const refusal = doorRefusal(answer.body);\n if (refusal?.code === 'replica_behind') {\n const named = open.filter((ask) => ask.entry.authority === refusal.fields.authority);\n const behind = named.length === 0 ? open : named;\n for (const ask of behind) answers.set(ask, { kind: 'retryable-refusal', ...refusal });\n open = open.filter((ask) => !behind.includes(ask));\n continue;\n }\n const classified = open.map((ask) =>\n classifyDoor(answer.status, answer.body, ask.entry.locator),\n );\n if (classified[0]?.kind === 'beyond-horizon') {\n const named = doorRefusal(answer.body)?.fields.authority;\n const expired = open.filter((ask) => ask.entry.authority === named);\n const answered: RefreshResult =\n expired.length === 0 ? UNCERTAIN_READ : { kind: 'beyond-horizon' };\n const gone = expired.length === 0 ? open : expired;\n for (const ask of gone) answers.set(ask, answered);\n open = open.filter((ask) => !gone.includes(ask));\n continue;\n }\n const enumeration =\n classified[0] === null ? parseEnumeration(answer.body, 'credential') : null;\n open.forEach((ask, index) => {\n const failure = classified[index];\n if (failure !== null && failure !== undefined) {\n answers.set(ask, failure);\n return;\n }\n answers.set(\n ask,\n enumeration === null\n ? UNCERTAIN_READ\n : refreshFrom(enumeration, ask.entry, ask.fromRoomVersion),\n );\n });\n open = [];\n }\n }\n return asks.map((ask) => answers.get(ask) ?? UNCERTAIN_READ);\n }\n\n const bootstrapTogether = gathered(bootstrapped);\n\n const enumerateTogether = gathered(enumerated);\n\n async function uploaded(\n head: OperationHead,\n changes: readonly Readonly<Record<string, unknown>>[],\n delta: string,\n bytes: number,\n entry: TrackedAuthority,\n handed: Upload | undefined,\n keep: Keep,\n ): Promise<Submission> {\n const paths = batchPaths(changes);\n const sha256 = await deltaDigest(delta);\n if (handed !== undefined && handed.sha256 === sha256) {\n return { body: { ...head, paths, upload: handed } };\n }\n const minted = await transport.door(DOOR_BATCH_UPLOAD, { ...head, paths, bytes, sha256 });\n if (minted.status !== 200) {\n return { outcome: mutationOutcome(minted.status, minted.body, entry.locator, entry.handle) };\n }\n const grant = parseGrant(minted.body);\n if (grant === null || grant.method !== 'POST') return { outcome: UNCERTAIN };\n const delivered = await transport.transfer({\n act: 'authored_batch_upload',\n method: 'POST',\n url: grant.url,\n answer: 'json',\n body: `${grant.operation}\\n${delta}`,\n });\n if (delivered.status !== 200) return { outcome: UNCERTAIN };\n const holding = parseGrant(delivered.body);\n if (holding === null || holding.method !== 'POST') return { outcome: UNCERTAIN };\n const upload: Upload = { url: holding.url, operation: holding.operation, bytes, sha256 };\n await keep(upload);\n return { body: { ...head, paths, upload } };\n }\n\n async function submit(\n head: OperationHead,\n changes: readonly Readonly<Record<string, unknown>>[],\n delta: string,\n bytes: number,\n entry: TrackedAuthority,\n handed: Upload | undefined,\n keep: Keep,\n ): Promise<MutationResult> {\n const prepared: Submission = uploadable(bytes)\n ? await uploaded(head, changes, delta, bytes, entry, handed, keep)\n : { body: { ...head, changes } };\n if ('outcome' in prepared) return prepared.outcome;\n const answer = await transport.door(DOOR_BATCH, prepared.body);\n return mutationOutcome(answer.status, answer.body, entry.locator, entry.handle);\n }\n\n return {\n async authorize() {\n return options.authorize();\n },\n\n async model(_authorization: Authorization, request: ModelRequest): Promise<ModelResult> {\n return models.answer(request);\n },\n\n async discover(_authorization: Authorization): Promise<DiscoverResult> {\n const answer = await transport.door(DOOR_DISCOVER, { prefixes: [...DISCOVER_PREFIXES] });\n const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);\n if (classified !== null) return discoveryFailure(classified);\n const document = parseDiscovery(answer.body);\n if (document === null) return { kind: 'transport-uncertainty' };\n const entries = trackedFrom(document);\n tracked.clear();\n for (const entry of entries) tracked.set(entry.locator, entry);\n notifications.track(entries);\n const acquired = await acquireModels(entries);\n models.keep(entries.map((entry) => entry.locator));\n return mapDiscovery(\n document,\n document.authorities.map((authority) => roomOf(authority, acquired)),\n capabilities(document.actions),\n );\n },\n\n async bootstrap(\n _authorization: Authorization,\n request: BootstrapRequest,\n ): Promise<BootstrapResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return { kind: 'transport-uncertainty' };\n return bootstrapTogether(entry);\n },\n\n async refresh(_authorization: Authorization, request: RefreshRequest): Promise<RefreshResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return { kind: 'transport-uncertainty' };\n const from = logPosition(request.fromRoomVersion);\n if (from === null) return { kind: 'beyond-horizon' };\n const streamed = notifications.advance(entry, from);\n if (\n streamed !== null &&\n (request.minPosition === undefined ||\n reachedVersion(streamed.roomVersion, request.minPosition, entry.logEpoch))\n )\n return streamed;\n const minPosition =\n request.minPosition === undefined ? null : logPosition(request.minPosition);\n return enumerateTogether({\n entry,\n from,\n fromRoomVersion: request.fromRoomVersion,\n ...(minPosition?.logEpoch === from.logEpoch ? { minPosition: minPosition.position } : {}),\n });\n },\n\n async mutate(\n _authorization: Authorization,\n request: MutationRequest,\n keep: Keep,\n ): Promise<MutationResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n const mapped = houseChanges(request.changeBatch, entry.handle);\n if (mapped.kind === 'unmapped') return rejectedMapping(mapped);\n const head = operationHead(request.changeBatch);\n const delta = deltaBody(mapped.changes);\n const bytes = deltaBytes(delta);\n const handed = request.upload as Upload | undefined;\n const outcome = await submit(head, mapped.changes, delta, bytes, entry, handed, keep);\n if (handed === undefined || !lapsedGrant(outcome)) return outcome;\n return submit(head, mapped.changes, delta, bytes, entry, undefined, keep);\n },\n\n async history(_authorization: Authorization, request: HistoryRequest): Promise<HistoryResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n const answer = await transport.door(\n DOOR_REVISIONS,\n revisionBody({\n path: request.path,\n handle: entry.handle,\n ...(request.revision === undefined ? {} : { revision: request.revision }),\n ...(request.pageToken === undefined ? {} : { pageToken: request.pageToken }),\n }),\n );\n return historyOutcome(answer.status, answer.body, entry.locator, {\n path: request.path,\n ...(request.revision === undefined ? {} : { revision: request.revision }),\n });\n },\n\n reached(locator: string, version: string, target: string): boolean {\n return reachedVersion(version, target, authorityFor(locator)?.logEpoch);\n },\n\n async action(_authorization: Authorization, request: ActionRequest): Promise<ActionResult> {\n const result = withAt(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","gathered","selections","createSiteAdapter","bootstrapFrom","contentPrefixes","parseEnumeration","parseEnvelope","parseGrant","refreshFrom","schemaFrom","schemaPath","houseAction","classifyDoor","discoveryFailure","doorRefusal","houseNotifications","DOOR_BATCH","DOOR_BATCH_UPLOAD","DOOR_BOOTSTRAP","DOOR_DISCOVER","DOOR_ENUMERATE","DOOR_REVISIONS","DOOR_SELECTION_MAX","PRIVATE_LOCATOR","batchPaths","deltaBody","deltaBytes","deltaDigest","historyOutcome","houseChanges","mutationOutcome","operationHead","rejectedMapping","revisionBody","uploadable","logPosition","presented","reachedVersion","roomVersion","UNCERTAIN","kind","UNCERTAIN_READ","lapsedGrant","outcome","code","modelFailure","classified","envelope","createAgentsHouseAdapter","options","site","transport","notifications","tracked","Map","models","held","entry","schema","failure","handle","modelPrefixes","own","locator","undefined","acquireModels","entries","acquired","part","length","privateEntry","find","answer","door","prefixes","flatMap","status","body","bundled","set","roomOf","authority","key","collection","retain","get","roomHandle","identity","selection","authorityFor","withAt","result","position","log_epoch","logEpoch","values","at","grant","method","transfer","act","url","weight","bootstrapped","answers","map","forEach","index","push","layered","asks","depths","layers","ask","depth","enumerated","parts","layer","open","positions","from","minPosition","min_position","refusal","named","filter","fields","behind","includes","expired","answered","gone","enumeration","fromRoomVersion","bootstrapTogether","enumerateTogether","uploaded","head","changes","delta","bytes","handed","keep","paths","sha256","upload","minted","delivered","operation","holding","submit","prepared","authorize","model","_authorization","request","discover","document","clear","track","authorities","actions","bootstrap","pageToken","refresh","streamed","advance","mutate","mapped","changeBatch","history","path","revision","reached","version","target","action","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,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AACnD,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SACEC,aAAa,EACbC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,EACbC,UAAU,EACVC,WAAW,EACXC,UAAU,EACVC,UAAU,QACL,YAAY;AACnB,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,YAAY,EAAEC,gBAAgB,EAAEC,WAAW,QAAQ,eAAe;AAC3E,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SACEC,UAAU,EACVC,iBAAiB,EACjBC,cAAc,EACdC,aAAa,EACbC,cAAc,EACdC,cAAc,EACdC,kBAAkB,EAClBC,eAAe,QAGV,iBAAiB;AACxB,SACEC,UAAU,EACVC,SAAS,EACTC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,YAAY,EACZC,eAAe,EACfC,aAAa,EACbC,eAAe,EACfC,YAAY,EACZC,UAAU,QAEL,aAAa;AACpB,SACEC,WAAW,EACXC,SAAS,EACTC,cAAc,EACdC,WAAW,QAEN,eAAe;AAStB,MAAMC,YAA4B;IAAEC,MAAM;AAAwB;AAElE,MAAMC,iBAAiB;IAAED,MAAM;AAAwB;AAevD,SAASE,YAAYC,OAAuB;IAC1C,OAAOA,QAAQH,IAAI,KAAK,cAAcG,QAAQC,IAAI,KAAK;AACzD;AAEA,SAASC,aACPC,UAA2C,EAC3CC,QAA0C;IAE1C,IAAID,eAAe,MAAM;QACv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I,WAAW;IACxC;AACF"}
1
+ {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/adapter.ts"],"sourcesContent":["import type {\n ActionRequest,\n ActionResult,\n Adapter,\n Authorization,\n BootstrapRequest,\n BootstrapResult,\n DiscoverResult,\n DiscoveredRoom,\n HistoryRequest,\n HistoryResult,\n ModelRequest,\n ModelResult,\n MutationRequest,\n MutationResult,\n RefreshRequest,\n RefreshResult,\n} from '@agentshouse/mdruntime';\nimport {\n DISCOVER_PREFIXES,\n HOUSE_SCHEMA,\n capabilities,\n discoveredRoom,\n locatorOf,\n mapDiscovery,\n parseDiscovery,\n providerSelection,\n trackedFrom,\n type HouseAuthority,\n type TrackedAuthority,\n} from './discovery.js';\nimport {\n MODEL_ABSENT,\n failedModel,\n heldModel,\n modelKey,\n modelShelf,\n type HeldModel,\n} from './model.js';\nimport { gathered, selections } from './gather.js';\nimport { createSiteAdapter } from './site.js';\nimport {\n bootstrapFrom,\n contentPrefixes,\n parseEnumeration,\n parseEnvelope,\n parseGrant,\n refreshFrom,\n schemaFrom,\n schemaPath,\n} from './read.js';\nimport { houseAction } from './actions.js';\nimport { classifyDoor, discoveryFailure, doorRefusal } from './refusal.js';\nimport { houseNotifications } from './stream.js';\nimport {\n DOOR_BATCH,\n DOOR_BATCH_UPLOAD,\n DOOR_BOOTSTRAP,\n DOOR_DISCOVER,\n DOOR_ENUMERATE,\n DOOR_REVISIONS,\n DOOR_SELECTION_MAX,\n PRIVATE_LOCATOR,\n type HouseSiteTransport,\n type HouseTransport,\n} from './transport.js';\nimport {\n batchPaths,\n deltaBody,\n deltaBytes,\n deltaDigest,\n historyOutcome,\n houseChanges,\n mutationOutcome,\n operationHead,\n rejectedMapping,\n revisionBody,\n uploadable,\n type OperationHead,\n} from './write.js';\nimport {\n logPosition,\n presented,\n reachedVersion,\n roomVersion,\n type LogPosition,\n} from './version.js';\n\nexport type AgentsHouseAdapterOptions =\n | {\n transport: HouseTransport;\n authorize(): Promise<Authorization>;\n }\n | { site: HouseSiteTransport };\n\nconst UNCERTAIN: MutationResult = { kind: 'transport-uncertainty' };\n\nconst UNCERTAIN_READ = { kind: 'transport-uncertainty' } as const;\n\ntype Enumerating = {\n entry: TrackedAuthority;\n from: LogPosition;\n fromRoomVersion: string;\n minPosition?: string;\n};\n\ntype Submission = { body: Record<string, unknown> } | { outcome: MutationResult };\n\ntype Upload = { url: string; operation: string; bytes: number; sha256: string };\n\ntype Keep = (upload: unknown) => Promise<void>;\n\nfunction lapsedGrant(outcome: MutationResult): boolean {\n return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';\n}\n\nfunction modelFailure(\n classified: ReturnType<typeof classifyDoor>,\n envelope: ReturnType<typeof parseEnvelope>,\n): ModelResult {\n if (classified === null) {\n return envelope === null ? { kind: 'transport-uncertainty' } : MODEL_ABSENT;\n }\n return failedModel(classified);\n}\n\nexport function createAgentsHouseAdapter(options: AgentsHouseAdapterOptions): Adapter {\n if ('site' in options) return createSiteAdapter(options.site);\n const transport = options.transport;\n const notifications = houseNotifications(transport, 'credential');\n const tracked = new Map<string, TrackedAuthority>();\n const 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 function modelPrefixes(entry: TrackedAuthority): readonly string[] {\n const own = schemaPath(entry.handle, entry.schema);\n return entry.locator === PRIVATE_LOCATOR ? [own, schemaPath(undefined, HOUSE_SCHEMA)] : [own];\n }\n\n async function acquireModels(\n entries: readonly TrackedAuthority[],\n ): Promise<Map<string, HeldModel>> {\n const acquired = new Map<string, HeldModel>();\n for (const part of selections(\n entries,\n (entry) => modelPrefixes(entry).length,\n DOOR_SELECTION_MAX,\n )) {\n const privateEntry = part.find((entry) => entry.locator === PRIVATE_LOCATOR);\n const answer = await transport.door(DOOR_BOOTSTRAP, {\n prefixes: part.flatMap((entry) => modelPrefixes(entry)),\n });\n const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);\n const envelope = classified === null ? parseEnvelope(await bundled(answer.body)) : null;\n const failure: ModelResult = modelFailure(classified, envelope);\n for (const entry of part) {\n acquired.set(\n modelKey(entry.locator, 'collection'),\n await held(envelope, entry, entry.schema, failure),\n );\n }\n if (privateEntry !== undefined) {\n acquired.set(\n modelKey(privateEntry.locator, 'typed-selection'),\n await held(envelope, privateEntry, HOUSE_SCHEMA, failure),\n );\n }\n }\n return acquired;\n }\n\n function roomOf(authority: HouseAuthority, acquired: Map<string, HeldModel>): DiscoveredRoom {\n const locator = locatorOf(authority);\n const key = modelKey(locator, 'collection');\n const collection = models.retain(key, acquired.get(key));\n if (authority.roomHandle !== null) {\n return discoveredRoom(authority, collection?.identity ?? null, undefined);\n }\n const selection = models.retain(\n modelKey(locator, 'typed-selection'),\n acquired.get(modelKey(locator, 'typed-selection')),\n );\n return discoveredRoom(\n authority,\n collection?.identity ?? null,\n providerSelection(selection?.identity ?? null),\n );\n }\n\n function authorityFor(locator: string): TrackedAuthority | undefined {\n return tracked.get(locator);\n }\n\n function withAt(result: ActionResult): ActionResult {\n if (result.kind !== 'action') return result;\n const body = result.result as Record<string, unknown> | null;\n if (typeof body !== 'object' || body === null) return result;\n const { authority, position, log_epoch: logEpoch } = body;\n if (typeof position !== 'string' || typeof logEpoch !== 'string') return result;\n const locator =\n authority === undefined\n ? PRIVATE_LOCATOR\n : [...tracked.values()].find((entry) => entry.authority === authority)?.locator;\n if (locator === undefined) return result;\n return { ...result, at: { locator, roomVersion: roomVersion({ position, logEpoch }) } };\n }\n\n async function bundled(body: unknown): Promise<unknown> {\n const grant = parseGrant(body);\n if (grant === null) return body;\n if (grant.method !== 'GET') return null;\n const answer = await transport.transfer({\n act: 'local_copy_bundle',\n method: 'GET',\n url: grant.url,\n answer: 'json',\n });\n return answer.status === 200 ? answer.body : null;\n }\n\n function weight(entry: TrackedAuthority): number {\n return contentPrefixes(entry).length;\n }\n\n async function bootstrapped(entries: readonly TrackedAuthority[]): Promise<BootstrapResult[]> {\n const answers: BootstrapResult[] = [];\n for (const part of selections(entries, weight, DOOR_SELECTION_MAX)) {\n const answer = await transport.door(DOOR_BOOTSTRAP, {\n prefixes: part.flatMap((entry) => contentPrefixes(entry)),\n });\n const classified = part.map((entry) =>\n classifyDoor(answer.status, answer.body, entry.locator),\n );\n const envelope = classified[0] === null ? parseEnvelope(await bundled(answer.body)) : null;\n part.forEach((entry, index) => {\n const failure = classified[index];\n if (failure === null || failure === undefined) {\n answers.push(envelope === null ? UNCERTAIN_READ : bootstrapFrom(envelope, entry));\n return;\n }\n answers.push(failure.kind === 'beyond-horizon' ? UNCERTAIN_READ : failure);\n });\n }\n return answers;\n }\n\n function layered(asks: readonly Enumerating[]): readonly (readonly Enumerating[])[] {\n const depths = new Map<string, number>();\n const layers: Enumerating[][] = [];\n for (const ask of asks) {\n const depth = depths.get(ask.entry.authority) ?? 0;\n depths.set(ask.entry.authority, depth + 1);\n (layers[depth] ??= []).push(ask);\n }\n return layers;\n }\n\n async function enumerated(asks: readonly Enumerating[]): Promise<RefreshResult[]> {\n const answers = new Map<Enumerating, RefreshResult>();\n const parts = layered(asks).flatMap((layer) =>\n selections(layer, (ask) => weight(ask.entry), DOOR_SELECTION_MAX),\n );\n for (const part of parts) {\n let open = [...part];\n while (open.length > 0) {\n const answer = await transport.door(DOOR_ENUMERATE, {\n prefixes: open.flatMap((ask) => contentPrefixes(ask.entry)),\n positions: open.map((ask) => ({\n ...presented(ask.entry.authority, ask.from),\n ...(ask.minPosition === undefined ? {} : { min_position: ask.minPosition }),\n })),\n });\n const refusal = doorRefusal(answer.body);\n if (refusal?.code === 'replica_behind') {\n const named = open.filter((ask) => ask.entry.authority === refusal.fields.authority);\n const behind = named.length === 0 ? open : named;\n for (const ask of behind) answers.set(ask, { kind: 'retryable-refusal', ...refusal });\n open = open.filter((ask) => !behind.includes(ask));\n continue;\n }\n const classified = open.map((ask) =>\n classifyDoor(answer.status, answer.body, ask.entry.locator),\n );\n if (classified[0]?.kind === 'beyond-horizon') {\n const named = doorRefusal(answer.body)?.fields.authority;\n const expired = open.filter((ask) => ask.entry.authority === named);\n const answered: RefreshResult =\n expired.length === 0 ? UNCERTAIN_READ : { kind: 'beyond-horizon' };\n const gone = expired.length === 0 ? open : expired;\n for (const ask of gone) answers.set(ask, answered);\n open = open.filter((ask) => !gone.includes(ask));\n continue;\n }\n const enumeration =\n classified[0] === null ? parseEnumeration(answer.body, 'credential') : null;\n open.forEach((ask, index) => {\n const failure = classified[index];\n if (failure !== null && failure !== undefined) {\n answers.set(ask, failure);\n return;\n }\n answers.set(\n ask,\n enumeration === null\n ? UNCERTAIN_READ\n : refreshFrom(enumeration, ask.entry, ask.fromRoomVersion),\n );\n });\n open = [];\n }\n }\n return asks.map((ask) => answers.get(ask) ?? UNCERTAIN_READ);\n }\n\n const bootstrapTogether = gathered(bootstrapped);\n\n const enumerateTogether = gathered(enumerated);\n\n async function uploaded(\n head: OperationHead,\n changes: readonly Readonly<Record<string, unknown>>[],\n delta: string,\n bytes: number,\n entry: TrackedAuthority,\n handed: Upload | undefined,\n keep: Keep,\n ): Promise<Submission> {\n const paths = batchPaths(changes);\n const sha256 = await deltaDigest(delta);\n if (handed !== undefined && handed.sha256 === sha256) {\n return { body: { ...head, paths, upload: handed } };\n }\n const minted = await transport.door(DOOR_BATCH_UPLOAD, { ...head, paths, bytes, sha256 });\n if (minted.status !== 200) {\n return { outcome: mutationOutcome(minted.status, minted.body, entry.locator, entry.handle) };\n }\n const grant = parseGrant(minted.body);\n if (grant === null || grant.method !== 'POST') return { outcome: UNCERTAIN };\n const delivered = await transport.transfer({\n act: 'authored_batch_upload',\n method: 'POST',\n url: grant.url,\n answer: 'json',\n body: `${grant.operation}\\n${delta}`,\n });\n if (delivered.status !== 200) return { outcome: UNCERTAIN };\n const holding = parseGrant(delivered.body);\n if (holding === null || holding.method !== 'POST') return { outcome: UNCERTAIN };\n const upload: Upload = { url: holding.url, operation: holding.operation, bytes, sha256 };\n await keep(upload);\n return { body: { ...head, paths, upload } };\n }\n\n async function submit(\n head: OperationHead,\n changes: readonly Readonly<Record<string, unknown>>[],\n delta: string,\n bytes: number,\n entry: TrackedAuthority,\n handed: Upload | undefined,\n keep: Keep,\n ): Promise<MutationResult> {\n const prepared: Submission = uploadable(bytes)\n ? await uploaded(head, changes, delta, bytes, entry, handed, keep)\n : { body: { ...head, changes } };\n if ('outcome' in prepared) return prepared.outcome;\n const answer = await transport.door(DOOR_BATCH, prepared.body);\n return mutationOutcome(answer.status, answer.body, entry.locator, entry.handle);\n }\n\n return {\n async authorize() {\n return options.authorize();\n },\n\n async model(_authorization: Authorization, request: ModelRequest): Promise<ModelResult> {\n return models.answer(request);\n },\n\n async discover(_authorization: Authorization): Promise<DiscoverResult> {\n const answer = await transport.door(DOOR_DISCOVER, { prefixes: [...DISCOVER_PREFIXES] });\n const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);\n if (classified !== null) return discoveryFailure(classified);\n const document = parseDiscovery(answer.body);\n if (document === null) return { kind: 'transport-uncertainty' };\n const entries = trackedFrom(document);\n tracked.clear();\n for (const entry of entries) tracked.set(entry.locator, entry);\n notifications.track(entries);\n const acquired = await acquireModels(entries);\n models.keep(entries.map((entry) => entry.locator));\n return mapDiscovery(\n document,\n document.authorities.map((authority) => roomOf(authority, acquired)),\n capabilities(document.actions),\n );\n },\n\n async bootstrap(\n _authorization: Authorization,\n request: BootstrapRequest,\n ): Promise<BootstrapResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return { kind: 'transport-uncertainty' };\n return bootstrapTogether(entry);\n },\n\n async refresh(_authorization: Authorization, request: RefreshRequest): Promise<RefreshResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return { kind: 'transport-uncertainty' };\n const from = logPosition(request.fromRoomVersion);\n if (from === null) return { kind: 'beyond-horizon' };\n const streamed = notifications.advance(entry, from);\n if (\n streamed !== null &&\n (request.minPosition === undefined ||\n reachedVersion(streamed.roomVersion, request.minPosition, entry.logEpoch))\n )\n return streamed;\n const minPosition =\n request.minPosition === undefined ? null : logPosition(request.minPosition);\n return enumerateTogether({\n entry,\n from,\n fromRoomVersion: request.fromRoomVersion,\n ...(minPosition?.logEpoch === from.logEpoch ? { minPosition: minPosition.position } : {}),\n });\n },\n\n async mutate(\n _authorization: Authorization,\n request: MutationRequest,\n keep: Keep,\n ): Promise<MutationResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n const mapped = houseChanges(request.changeBatch, entry.handle);\n if (mapped.kind === 'unmapped') return rejectedMapping(mapped);\n const head = operationHead(request.changeBatch);\n const delta = deltaBody(mapped.changes);\n const bytes = deltaBytes(delta);\n const handed = request.upload as Upload | undefined;\n const outcome = await submit(head, mapped.changes, delta, bytes, entry, handed, keep);\n if (handed === undefined || !lapsedGrant(outcome)) return outcome;\n return submit(head, mapped.changes, delta, bytes, entry, undefined, keep);\n },\n\n async history(_authorization: Authorization, request: HistoryRequest): Promise<HistoryResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n const answer = await transport.door(\n DOOR_REVISIONS,\n revisionBody({\n path: request.path,\n handle: entry.handle,\n ...(request.revision === undefined ? {} : { revision: request.revision }),\n ...(request.pageToken === undefined ? {} : { pageToken: request.pageToken }),\n }),\n );\n return historyOutcome(answer.status, answer.body, entry.locator, {\n path: request.path,\n ...(request.revision === undefined ? {} : { revision: request.revision }),\n });\n },\n\n reached(locator: string, version: string, target: string): boolean {\n return reachedVersion(version, target, authorityFor(locator)?.logEpoch);\n },\n\n async action(_authorization: Authorization, request: ActionRequest): Promise<ActionResult> {\n return withAt(await houseAction(transport, request));\n },\n\n roomVersions: notifications,\n conversations: notifications.conversations,\n serviceMode: notifications.serviceMode,\n };\n}\n"],"names":["DISCOVER_PREFIXES","HOUSE_SCHEMA","capabilities","discoveredRoom","locatorOf","mapDiscovery","parseDiscovery","providerSelection","trackedFrom","MODEL_ABSENT","failedModel","heldModel","modelKey","modelShelf","gathered","selections","createSiteAdapter","bootstrapFrom","contentPrefixes","parseEnumeration","parseEnvelope","parseGrant","refreshFrom","schemaFrom","schemaPath","houseAction","classifyDoor","discoveryFailure","doorRefusal","houseNotifications","DOOR_BATCH","DOOR_BATCH_UPLOAD","DOOR_BOOTSTRAP","DOOR_DISCOVER","DOOR_ENUMERATE","DOOR_REVISIONS","DOOR_SELECTION_MAX","PRIVATE_LOCATOR","batchPaths","deltaBody","deltaBytes","deltaDigest","historyOutcome","houseChanges","mutationOutcome","operationHead","rejectedMapping","revisionBody","uploadable","logPosition","presented","reachedVersion","roomVersion","UNCERTAIN","kind","UNCERTAIN_READ","lapsedGrant","outcome","code","modelFailure","classified","envelope","createAgentsHouseAdapter","options","site","transport","notifications","tracked","Map","models","held","entry","schema","failure","handle","modelPrefixes","own","locator","undefined","acquireModels","entries","acquired","part","length","privateEntry","find","answer","door","prefixes","flatMap","status","body","bundled","set","roomOf","authority","key","collection","retain","get","roomHandle","identity","selection","authorityFor","withAt","result","position","log_epoch","logEpoch","values","at","grant","method","transfer","act","url","weight","bootstrapped","answers","map","forEach","index","push","layered","asks","depths","layers","ask","depth","enumerated","parts","layer","open","positions","from","minPosition","min_position","refusal","named","filter","fields","behind","includes","expired","answered","gone","enumeration","fromRoomVersion","bootstrapTogether","enumerateTogether","uploaded","head","changes","delta","bytes","handed","keep","paths","sha256","upload","minted","delivered","operation","holding","submit","prepared","authorize","model","_authorization","request","discover","document","clear","track","authorities","actions","bootstrap","pageToken","refresh","streamed","advance","mutate","mapped","changeBatch","history","path","revision","reached","version","target","action","roomVersions","conversations","serviceMode"],"mappings":"AAkBA,SACEA,iBAAiB,EACjBC,YAAY,EACZC,YAAY,EAC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AAqBuB,SAAS4F,QAAQ5F,OAAO;YAAC;YACtF,MAAMS,SAAS,MAAMrB,UAAUsB,IAAI,CACjCpD,gBACAY,aAAa;gBACX0I,MAAMhB,QAAQgB,IAAI;gBAClB/G,QAAQH,MAAMG,MAAM;gBACpB,GAAI+F,QAAQiB,QAAQ,KAAK5G,YAAY,CAAC,IAAI;oBAAE4G,UAAUjB,QAAQiB,QAAQ;gBAAC,CAAC;gBACxE,GAAIjB,QAAQQ,SAAS,KAAKnG,YAAY,CAAC,IAAI;oBAAEmG,WAAWR,QAAQQ,SAAS;gBAAC,CAAC;YAC7E;YAEF,OAAOvI,eAAe4C,OAAOI,MAAM,EAAEJ,OAAOK,IAAI,EAAEpB,MAAMM,OAAO,EAAE;gBAC/D4G,MAAMhB,QAAQgB,IAAI;gBAClB,GAAIhB,QAAQiB,QAAQ,KAAK5G,YAAY,CAAC,IAAI;oBAAE4G,UAAUjB,QAAQiB,QAAQ;gBAAC,CAAC;YAC1E;QACF;QAEAC,SAAQ9G,OAAe,EAAE+G,OAAe,EAAEC,MAAc;YACtD,OAAO1I,eAAeyI,SAASC,QAAQtF,aAAa1B,UAAU+B;QAChE;QAEA,MAAMkF,QAAOtB,cAA6B,EAAEC,OAAsB;YAChE,OAAOjE,OAAO,MAAM/E,YAAYwC,WAAWwG;QAC7C;QAEAsB,cAAc7H;QACd8H,eAAe9H,cAAc8H,aAAa;QAC1CC,aAAa/H,cAAc+H,WAAW;IACxC;AACF"}
package/dist/stream.d.ts CHANGED
@@ -1,13 +1,12 @@
1
1
  import type { ConversationStream, RefreshPage, SelectedRooms, ServiceModeSignal } from '@agentshouse/mdruntime';
2
2
  import type { TrackedAuthority } from './discovery.js';
3
- import { type HouseDoor, type HouseMode } from './transport.js';
3
+ import type { HouseDoor, HouseMode } from './transport.js';
4
4
  import { type LogPosition } from './version.js';
5
5
  export type HouseNotifications = SelectedRooms & {
6
6
  track(authorities: readonly TrackedAuthority[]): void;
7
7
  advance(tracked: TrackedAuthority, from: LogPosition): RefreshPage | null;
8
8
  conversations: ConversationStream;
9
9
  serviceMode: ServiceModeSignal;
10
- question(conversation: string): void;
11
10
  };
12
11
  export declare function houseNotifications(transport: HouseDoor, mode: HouseMode): HouseNotifications;
13
12
  //# sourceMappingURL=stream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,WAAW,EAEX,aAAa,EAEb,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,SAAS,EAGf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAgB7D,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtD,OAAO,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,WAAW,GAAG,IAAI,CAAC;IAC1E,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC,CAAC;AAOF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,CAkS5F"}
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,WAAW,EAEX,aAAa,EAEb,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAsC,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAc7D,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtD,OAAO,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,WAAW,GAAG,IAAI,CAAC;IAC1E,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAOF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,CAmQ5F"}
package/dist/stream.js CHANGED
@@ -1,9 +1,7 @@
1
- import { acceptedMessage, actionOutcome } from './actions.js';
1
+ import { acceptedMessage } from './actions.js';
2
2
  import { headChange, selects } from './read.js';
3
- import { PRIVATE_LOCATOR } from './transport.js';
4
3
  import { roomVersion } from './version.js';
5
4
  const HELD_POSITIONS_MAX = 256;
6
- const CONVERSATION_CARD = /^agents\/([^/]+)\.md$/;
7
5
  function position(value) {
8
6
  if (!/^(?:0|[1-9][0-9]*)$/.test(value)) return null;
9
7
  return BigInt(value);
@@ -17,10 +15,8 @@ export function houseNotifications(transport, mode) {
17
15
  const conversationObservers = new Set();
18
16
  const modeObservers = new Set();
19
17
  let replicated = [];
20
- let privateAuthority;
21
18
  const live = new Set();
22
19
  const noted = new Set();
23
- const asked = new Map();
24
20
  let listening = false;
25
21
  let catching = false;
26
22
  function listen() {
@@ -40,23 +36,6 @@ export function houseNotifications(transport, mode) {
40
36
  note: null
41
37
  });
42
38
  }
43
- async function question(conversation) {
44
- const sequence = (asked.get(conversation) ?? 0) + 1;
45
- asked.set(conversation, sequence);
46
- const answer = await transport.door('/door/conversations/interaction/read', {
47
- conversation_id: conversation
48
- });
49
- if (asked.get(conversation) !== sequence || !replicated.includes(conversation)) return;
50
- const outcome = actionOutcome(answer, 'conversations/interaction/read');
51
- if (outcome.kind !== 'action') return;
52
- const { interactions } = outcome.result;
53
- if (!Array.isArray(interactions)) return;
54
- emitConversation({
55
- kind: 'questions',
56
- conversation,
57
- questions: structuredClone(interactions)
58
- });
59
- }
60
39
  function reopened() {
61
40
  const gapped = new Set([
62
41
  ...replicated,
@@ -68,7 +47,6 @@ export function houseNotifications(transport, mode) {
68
47
  kind: 'gap',
69
48
  conversation
70
49
  });
71
- for (const conversation of replicated)void question(conversation);
72
50
  }
73
51
  function converse(frame) {
74
52
  const conversation = frame.conversation_id;
@@ -136,6 +114,14 @@ export function houseNotifications(transport, mode) {
136
114
  });
137
115
  return;
138
116
  }
117
+ if (frame.type === 'interactions') {
118
+ emitConversation({
119
+ kind: 'questions',
120
+ conversation,
121
+ questions: structuredClone(frame.interactions)
122
+ });
123
+ return;
124
+ }
139
125
  const message = acceptedMessage(frame.message);
140
126
  if (message === null) return;
141
127
  emitConversation({
@@ -175,20 +161,11 @@ export function houseNotifications(transport, mode) {
175
161
  for (const observer of modeObservers)observer(mode);
176
162
  return;
177
163
  }
178
- if (frame.type === 'draft' || frame.type === 'working-note' || frame.type === 'process' || frame.type === 'commands' || frame.type === 'options' || frame.type === 'message') {
164
+ if (frame.type === 'draft' || frame.type === 'working-note' || frame.type === 'process' || frame.type === 'commands' || frame.type === 'options' || frame.type === 'interactions' || frame.type === 'message') {
179
165
  converse(frame);
180
166
  return;
181
167
  }
182
168
  if (frame.type !== 'entries') return;
183
- if (frame.authority === privateAuthority) {
184
- for (const entry of frame.entries){
185
- const card = CONVERSATION_CARD.exec(entry.path);
186
- const conversation = card?.[1];
187
- if (conversation !== undefined && entry.kind === 'edited' && replicated.includes(conversation)) {
188
- void question(conversation);
189
- }
190
- }
191
- }
192
169
  const at = position(frame.position);
193
170
  if (at === null) {
194
171
  interrupt(frame.authority);
@@ -233,16 +210,11 @@ export function houseNotifications(transport, mode) {
233
210
  };
234
211
  }
235
212
  },
236
- question (conversation) {
237
- void question(conversation);
238
- },
239
213
  conversations: {
240
214
  replicate (next) {
241
- const entering = next.filter((conversation)=>!replicated.includes(conversation));
242
215
  replicated = [
243
216
  ...next
244
217
  ];
245
- for (const conversation of entering)void question(conversation);
246
218
  },
247
219
  observe (notify) {
248
220
  conversationObservers.add(notify);
@@ -259,7 +231,6 @@ export function houseNotifications(transport, mode) {
259
231
  track (entries) {
260
232
  locators.clear();
261
233
  schemas.clear();
262
- privateAuthority = entries.find((entry)=>entry.locator === PRIVATE_LOCATOR)?.authority;
263
234
  for (const entry of entries){
264
235
  locators.set(entry.authority, [
265
236
  ...locators.get(entry.authority) ?? [],
@@ -1 +1 @@
1
- {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/stream.ts"],"sourcesContent":["import type {\n ConversationEvent,\n ConversationStream,\n RefreshPage,\n RoomVersionNotification,\n SelectedRooms,\n ServiceMode,\n ServiceModeSignal,\n} from '@agentshouse/mdruntime';\nimport { acceptedMessage, actionOutcome } from './actions.js';\nimport type { TrackedAuthority } from './discovery.js';\nimport { headChange, selects, type HeadChange } from './read.js';\nimport {\n PRIVATE_LOCATOR,\n type HouseDoor,\n type HouseMode,\n type HouseStreamEntry,\n type HouseStreamFrame,\n} from './transport.js';\nimport { roomVersion, type LogPosition } from './version.js';\n\nconst HELD_POSITIONS_MAX = 256;\n\nconst CONVERSATION_CARD = /^agents\\/([^/]+)\\.md$/;\n\ntype HeldFrame = {\n position: bigint;\n entries: readonly HouseStreamEntry[];\n};\n\ntype HeldLine = {\n logEpoch: string;\n frames: readonly HeldFrame[];\n};\n\nexport type HouseNotifications = SelectedRooms & {\n track(authorities: readonly TrackedAuthority[]): void;\n advance(tracked: TrackedAuthority, from: LogPosition): RefreshPage | null;\n conversations: ConversationStream;\n serviceMode: ServiceModeSignal;\n question(conversation: string): void;\n};\n\nfunction position(value: string): bigint | null {\n if (!/^(?:0|[1-9][0-9]*)$/.test(value)) return null;\n return BigInt(value);\n}\n\nexport function houseNotifications(transport: HouseDoor, mode: HouseMode): HouseNotifications {\n const stream = transport.stream;\n const lines = new Map<string, HeldLine>();\n const locators = new Map<string, string[]>();\n const schemas = new Map<string, readonly string[]>();\n const observers = new Set<(notification: RoomVersionNotification) => void>();\n const conversationObservers = new Set<(event: ConversationEvent) => void>();\n const modeObservers = new Set<(mode: ServiceMode) => void>();\n let replicated: readonly string[] = [];\n let privateAuthority: string | undefined;\n const live = new Set<string>();\n const noted = new Set<string>();\n const asked = new Map<string, number>();\n let listening = false;\n let catching = false;\n\n function listen() {\n if (listening) return;\n listening = true;\n stream.observe(receive);\n }\n\n function emitConversation(event: ConversationEvent) {\n if (event.kind !== 'gap' && event.kind !== 'accepted-message') live.add(event.conversation);\n for (const observer of conversationObservers) observer(event);\n }\n\n function unnote(conversation: string) {\n if (!noted.delete(conversation)) return;\n emitConversation({ kind: 'working-note', conversation, note: null });\n }\n\n async function question(conversation: string) {\n const sequence = (asked.get(conversation) ?? 0) + 1;\n asked.set(conversation, sequence);\n const answer = await transport.door('/door/conversations/interaction/read', {\n conversation_id: conversation,\n });\n if (asked.get(conversation) !== sequence || !replicated.includes(conversation)) return;\n const outcome = actionOutcome(answer, 'conversations/interaction/read');\n if (outcome.kind !== 'action') return;\n const { interactions } = outcome.result as { interactions?: unknown };\n if (!Array.isArray(interactions)) return;\n emitConversation({\n kind: 'questions',\n conversation,\n questions: structuredClone(interactions),\n });\n }\n\n function reopened() {\n const gapped = new Set([...replicated, ...live]);\n live.clear();\n noted.clear();\n for (const conversation of gapped) emitConversation({ kind: 'gap', conversation });\n for (const conversation of replicated) void question(conversation);\n }\n\n function converse(frame: Exclude<HouseStreamFrame, { type: 'entries' | 'signal' }>) {\n const conversation = frame.conversation_id;\n if (frame.type === 'draft') {\n unnote(conversation);\n emitConversation({\n kind: 'growing-text',\n conversation,\n turn: frame.turn_id,\n text: frame.text,\n });\n emitConversation({\n kind: 'plan',\n conversation,\n turn: frame.turn_id,\n plan: structuredClone(frame.steps),\n });\n return;\n }\n if (frame.type === 'working-note') {\n noted.add(conversation);\n emitConversation({\n kind: 'working-note',\n conversation,\n note: { noteId: frame.note_id, text: frame.text },\n });\n return;\n }\n if (frame.type === 'process') {\n emitConversation({ kind: 'process', conversation, running: frame.running });\n if (frame.running) return;\n emitConversation({ kind: 'commands', conversation, commands: [] });\n emitConversation({ kind: 'options', conversation, options: [] });\n unnote(conversation);\n return;\n }\n if (frame.type === 'commands') {\n emitConversation({\n kind: 'commands',\n conversation,\n commands: structuredClone(frame.commands),\n });\n return;\n }\n if (frame.type === 'options') {\n emitConversation({ kind: 'options', conversation, options: structuredClone(frame.options) });\n return;\n }\n const message = acceptedMessage(frame.message);\n if (message === null) return;\n emitConversation({ kind: 'accepted-message', conversation, message });\n if ((frame.message as { role?: unknown }).role === 'user') return;\n unnote(conversation);\n }\n\n function announce(authority: string, at: LogPosition, modelChanged: boolean) {\n const version = roomVersion(at);\n for (const locator of locators.get(authority) ?? []) {\n for (const observer of observers) {\n observer(\n modelChanged\n ? { locator, roomVersion: version, modelChanged: true }\n : { locator, roomVersion: version },\n );\n }\n }\n }\n\n function interrupt(authority: string) {\n const line = lines.get(authority);\n if (line !== undefined) lines.set(authority, { logEpoch: line.logEpoch, frames: [] });\n }\n\n function receive(frame: HouseStreamFrame) {\n if (frame.type === 'signal') {\n const mode = frame.service_mode;\n if (mode !== 'open' && mode !== 'write-halted') return;\n for (const observer of modeObservers) observer(mode);\n return;\n }\n if (\n frame.type === 'draft' ||\n frame.type === 'working-note' ||\n frame.type === 'process' ||\n frame.type === 'commands' ||\n frame.type === 'options' ||\n frame.type === 'message'\n ) {\n converse(frame);\n return;\n }\n if (frame.type !== 'entries') return;\n if (frame.authority === privateAuthority) {\n for (const entry of frame.entries) {\n const card = CONVERSATION_CARD.exec(entry.path);\n const conversation = card?.[1];\n if (\n conversation !== undefined &&\n entry.kind === 'edited' &&\n replicated.includes(conversation)\n ) {\n void question(conversation);\n }\n }\n }\n const at = position(frame.position);\n if (at === null) {\n interrupt(frame.authority);\n return;\n }\n const line = lines.get(frame.authority);\n if (line?.logEpoch === frame.log_epoch) {\n const last = line.frames.at(-1);\n const continued = last !== undefined && last.position + 1n === at;\n const next = continued\n ? [...line.frames, { position: at, entries: frame.entries }]\n : [{ position: at, entries: frame.entries }];\n lines.set(frame.authority, {\n logEpoch: line.logEpoch,\n frames: next.length > HELD_POSITIONS_MAX ? [] : next,\n });\n } else {\n interrupt(frame.authority);\n }\n const addresses = schemas.get(frame.authority) ?? [];\n announce(\n frame.authority,\n { position: frame.position, logEpoch: frame.log_epoch },\n frame.entries.some((entry) => addresses.includes(entry.path)),\n );\n }\n\n return {\n serviceMode: {\n observe(notify) {\n modeObservers.add(notify);\n listen();\n return () => {\n modeObservers.delete(notify);\n };\n },\n },\n question(conversation) {\n void question(conversation);\n },\n conversations: {\n replicate(next) {\n const entering = next.filter((conversation) => !replicated.includes(conversation));\n replicated = [...next];\n for (const conversation of entering) void question(conversation);\n },\n observe(notify) {\n conversationObservers.add(notify);\n listen();\n if (!catching) {\n catching = true;\n stream.opened(reopened);\n }\n return () => {\n conversationObservers.delete(notify);\n };\n },\n },\n track(entries) {\n locators.clear();\n schemas.clear();\n privateAuthority = entries.find((entry) => entry.locator === PRIVATE_LOCATOR)?.authority;\n for (const entry of entries) {\n locators.set(entry.authority, [...(locators.get(entry.authority) ?? []), entry.locator]);\n schemas.set(entry.authority, entry.schemas);\n if (lines.get(entry.authority)?.logEpoch !== entry.logEpoch) {\n lines.set(entry.authority, { logEpoch: entry.logEpoch, frames: [] });\n }\n }\n for (const authority of lines.keys()) {\n if (!locators.has(authority)) lines.delete(authority);\n }\n },\n select() {},\n observe(notify) {\n observers.add(notify);\n listen();\n return () => {\n observers.delete(notify);\n };\n },\n advance(tracked, from) {\n const line = lines.get(tracked.authority);\n const start = position(from.position);\n if (line === undefined || start === null || line.logEpoch !== from.logEpoch) return null;\n const at = line.frames.findIndex((frame) => frame.position === start + 1n);\n if (at === -1) return null;\n const pending = line.frames.slice(at);\n const documents: Record<string, string> = {};\n const revisions: Record<string, string> = {};\n const changes: Record<string, HeadChange> = {};\n const removals: string[] = [];\n for (const frame of pending) {\n for (const entry of frame.entries) {\n if (!selects(tracked, entry.path)) continue;\n if (entry.kind === 'removed') {\n delete documents[entry.path];\n delete revisions[entry.path];\n delete changes[entry.path];\n if (!removals.includes(entry.path)) removals.push(entry.path);\n continue;\n }\n if (entry.text === undefined) return null;\n if (mode === 'credential' && entry.revision === undefined) return null;\n const head = headChange(entry);\n if (head === null) return null;\n documents[entry.path] = entry.text;\n if (entry.revision !== undefined) revisions[entry.path] = entry.revision;\n if (head === undefined) delete changes[entry.path];\n else changes[entry.path] = head;\n const removed = removals.indexOf(entry.path);\n if (removed !== -1) removals.splice(removed, 1);\n }\n }\n const last = pending.at(-1);\n if (last === undefined) return null;\n lines.set(tracked.authority, { logEpoch: line.logEpoch, frames: pending });\n return {\n kind: 'net-advancement',\n roomVersion: roomVersion({ position: last.position.toString(), logEpoch: line.logEpoch }),\n documents,\n revisions,\n changes,\n binaryTargets: [],\n removals: removals.sort(),\n };\n },\n };\n}\n"],"names":["acceptedMessage","actionOutcome","headChange","selects","PRIVATE_LOCATOR","roomVersion","HELD_POSITIONS_MAX","CONVERSATION_CARD","position","value","test","BigInt","houseNotifications","transport","mode","stream","lines","Map","locators","schemas","observers","Set","conversationObservers","modeObservers","replicated","privateAuthority","live","noted","asked","listening","catching","listen","observe","receive","emitConversation","event","kind","add","conversation","observer","unnote","delete","note","question","sequence","get","set","answer","door","conversation_id","includes","outcome","interactions","result","Array","isArray","questions","structuredClone","reopened","gapped","clear","converse","frame","type","turn","turn_id","text","plan","steps","noteId","note_id","running","commands","options","message","role","announce","authority","at","modelChanged","version","locator","interrupt","line","undefined","logEpoch","frames","service_mode","entry","entries","card","exec","path","log_epoch","last","continued","next","length","addresses","some","serviceMode","notify","conversations","replicate","entering","filter","opened","track","find","keys","has","select","advance","tracked","from","start","findIndex","pending","slice","documents","revisions","changes","removals","push","revision","head","removed","indexOf","splice","toString","binaryTargets","sort"],"mappings":"AASA,SAASA,eAAe,EAAEC,aAAa,QAAQ,eAAe;AAE9D,SAASC,UAAU,EAAEC,OAAO,QAAyB,YAAY;AACjE,SACEC,eAAe,QAKV,iBAAiB;AACxB,SAASC,WAAW,QAA0B,eAAe;AAE7D,MAAMC,qBAAqB;AAE3B,MAAMC,oBAAoB;AAoB1B,SAASC,SAASC,KAAa;IAC7B,IAAI,CAAC,sBAAsBC,IAAI,CAACD,QAAQ,OAAO;IAC/C,OAAOE,OAAOF;AAChB;AAEA,OAAO,SAASG,mBAAmBC,SAAoB,EAAEC,IAAe;IACtE,MAAMC,SAASF,UAAUE,MAAM;IAC/B,MAAMC,QAAQ,IAAIC;IAClB,MAAMC,WAAW,IAAID;IACrB,MAAME,UAAU,IAAIF;IACpB,MAAMG,YAAY,IAAIC;IACtB,MAAMC,wBAAwB,IAAID;IAClC,MAAME,gBAAgB,IAAIF;IAC1B,IAAIG,aAAgC,EAAE;IACtC,IAAIC;IACJ,MAAMC,OAAO,IAAIL;IACjB,MAAMM,QAAQ,IAAIN;IAClB,MAAMO,QAAQ,IAAIX;IAClB,IAAIY,YAAY;IAChB,IAAIC,WAAW;IAEf,SAASC;QACP,IAAIF,WAAW;QACfA,YAAY;QACZd,OAAOiB,OAAO,CAACC;IACjB;IAEA,SAASC,iBAAiBC,KAAwB;QAChD,IAAIA,MAAMC,IAAI,KAAK,SAASD,MAAMC,IAAI,KAAK,oBAAoBV,KAAKW,GAAG,CAACF,MAAMG,YAAY;QAC1F,KAAK,MAAMC,YAAYjB,sBAAuBiB,SAASJ;IACzD;IAEA,SAASK,OAAOF,YAAoB;QAClC,IAAI,CAACX,MAAMc,MAAM,CAACH,eAAe;QACjCJ,iBAAiB;YAAEE,MAAM;YAAgBE;YAAcI,MAAM;QAAK;IACpE;IAEA,eAAeC,SAASL,YAAoB;QAC1C,MAAMM,WAAW,AAAChB,CAAAA,MA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ACzB,IAAIgB,SAASV,WAAW,OAAO;YAC/BpE,MAAM8B,GAAG,CAACmE,QAAQpC,SAAS,EAAE;gBAAEQ,UAAUF,KAAKE,QAAQ;gBAAEC,QAAQ+B;YAAQ;YACxE,OAAO;gBACLjF,MAAM;gBACN/B,aAAaA,YAAY;oBAAEG,UAAUsF,KAAKtF,QAAQ,CAACyH,QAAQ;oBAAI5C,UAAUF,KAAKE,QAAQ;gBAAC;gBACvFkC;gBACAC;gBACAC;gBACAS,eAAe,EAAE;gBACjBR,UAAUA,SAASS,IAAI;YACzB;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/stream.ts"],"sourcesContent":["import type {\n ConversationEvent,\n ConversationStream,\n RefreshPage,\n RoomVersionNotification,\n SelectedRooms,\n ServiceMode,\n ServiceModeSignal,\n} from '@agentshouse/mdruntime';\nimport { acceptedMessage } from './actions.js';\nimport type { TrackedAuthority } from './discovery.js';\nimport { headChange, selects, type HeadChange } from './read.js';\nimport type { HouseDoor, HouseMode, HouseStreamEntry, HouseStreamFrame } from './transport.js';\nimport { roomVersion, type LogPosition } from './version.js';\n\nconst HELD_POSITIONS_MAX = 256;\n\ntype HeldFrame = {\n position: bigint;\n entries: readonly HouseStreamEntry[];\n};\n\ntype HeldLine = {\n logEpoch: string;\n frames: readonly HeldFrame[];\n};\n\nexport type HouseNotifications = SelectedRooms & {\n track(authorities: readonly TrackedAuthority[]): void;\n advance(tracked: TrackedAuthority, from: LogPosition): RefreshPage | null;\n conversations: ConversationStream;\n serviceMode: ServiceModeSignal;\n};\n\nfunction position(value: string): bigint | null {\n if (!/^(?:0|[1-9][0-9]*)$/.test(value)) return null;\n return BigInt(value);\n}\n\nexport function houseNotifications(transport: HouseDoor, mode: HouseMode): HouseNotifications {\n const stream = transport.stream;\n const lines = new Map<string, HeldLine>();\n const locators = new Map<string, string[]>();\n const schemas = new Map<string, readonly string[]>();\n const observers = new Set<(notification: RoomVersionNotification) => void>();\n const conversationObservers = new Set<(event: ConversationEvent) => void>();\n const modeObservers = new Set<(mode: ServiceMode) => void>();\n let replicated: readonly string[] = [];\n const live = new Set<string>();\n const noted = new Set<string>();\n let listening = false;\n let catching = false;\n\n function listen() {\n if (listening) return;\n listening = true;\n stream.observe(receive);\n }\n\n function emitConversation(event: ConversationEvent) {\n if (event.kind !== 'gap' && event.kind !== 'accepted-message') live.add(event.conversation);\n for (const observer of conversationObservers) observer(event);\n }\n\n function unnote(conversation: string) {\n if (!noted.delete(conversation)) return;\n emitConversation({ kind: 'working-note', conversation, note: null });\n }\n\n function reopened() {\n const gapped = new Set([...replicated, ...live]);\n live.clear();\n noted.clear();\n for (const conversation of gapped) emitConversation({ kind: 'gap', conversation });\n }\n\n function converse(frame: Exclude<HouseStreamFrame, { type: 'entries' | 'signal' }>) {\n const conversation = frame.conversation_id;\n if (frame.type === 'draft') {\n unnote(conversation);\n emitConversation({\n kind: 'growing-text',\n conversation,\n turn: frame.turn_id,\n text: frame.text,\n });\n emitConversation({\n kind: 'plan',\n conversation,\n turn: frame.turn_id,\n plan: structuredClone(frame.steps),\n });\n return;\n }\n if (frame.type === 'working-note') {\n noted.add(conversation);\n emitConversation({\n kind: 'working-note',\n conversation,\n note: { noteId: frame.note_id, text: frame.text },\n });\n return;\n }\n if (frame.type === 'process') {\n emitConversation({ kind: 'process', conversation, running: frame.running });\n if (frame.running) return;\n emitConversation({ kind: 'commands', conversation, commands: [] });\n emitConversation({ kind: 'options', conversation, options: [] });\n unnote(conversation);\n return;\n }\n if (frame.type === 'commands') {\n emitConversation({\n kind: 'commands',\n conversation,\n commands: structuredClone(frame.commands),\n });\n return;\n }\n if (frame.type === 'options') {\n emitConversation({ kind: 'options', conversation, options: structuredClone(frame.options) });\n return;\n }\n if (frame.type === 'interactions') {\n emitConversation({\n kind: 'questions',\n conversation,\n questions: structuredClone(frame.interactions),\n });\n return;\n }\n const message = acceptedMessage(frame.message);\n if (message === null) return;\n emitConversation({ kind: 'accepted-message', conversation, message });\n if ((frame.message as { role?: unknown }).role === 'user') return;\n unnote(conversation);\n }\n\n function announce(authority: string, at: LogPosition, modelChanged: boolean) {\n const version = roomVersion(at);\n for (const locator of locators.get(authority) ?? []) {\n for (const observer of observers) {\n observer(\n modelChanged\n ? { locator, roomVersion: version, modelChanged: true }\n : { locator, roomVersion: version },\n );\n }\n }\n }\n\n function interrupt(authority: string) {\n const line = lines.get(authority);\n if (line !== undefined) lines.set(authority, { logEpoch: line.logEpoch, frames: [] });\n }\n\n function receive(frame: HouseStreamFrame) {\n if (frame.type === 'signal') {\n const mode = frame.service_mode;\n if (mode !== 'open' && mode !== 'write-halted') return;\n for (const observer of modeObservers) observer(mode);\n return;\n }\n if (\n frame.type === 'draft' ||\n frame.type === 'working-note' ||\n frame.type === 'process' ||\n frame.type === 'commands' ||\n frame.type === 'options' ||\n frame.type === 'interactions' ||\n frame.type === 'message'\n ) {\n converse(frame);\n return;\n }\n if (frame.type !== 'entries') return;\n const at = position(frame.position);\n if (at === null) {\n interrupt(frame.authority);\n return;\n }\n const line = lines.get(frame.authority);\n if (line?.logEpoch === frame.log_epoch) {\n const last = line.frames.at(-1);\n const continued = last !== undefined && last.position + 1n === at;\n const next = continued\n ? [...line.frames, { position: at, entries: frame.entries }]\n : [{ position: at, entries: frame.entries }];\n lines.set(frame.authority, {\n logEpoch: line.logEpoch,\n frames: next.length > HELD_POSITIONS_MAX ? [] : next,\n });\n } else {\n interrupt(frame.authority);\n }\n const addresses = schemas.get(frame.authority) ?? [];\n announce(\n frame.authority,\n { position: frame.position, logEpoch: frame.log_epoch },\n frame.entries.some((entry) => addresses.includes(entry.path)),\n );\n }\n\n return {\n serviceMode: {\n observe(notify) {\n modeObservers.add(notify);\n listen();\n return () => {\n modeObservers.delete(notify);\n };\n },\n },\n conversations: {\n replicate(next) {\n replicated = [...next];\n },\n observe(notify) {\n conversationObservers.add(notify);\n listen();\n if (!catching) {\n catching = true;\n stream.opened(reopened);\n }\n return () => {\n conversationObservers.delete(notify);\n };\n },\n },\n track(entries) {\n locators.clear();\n schemas.clear();\n for (const entry of entries) {\n locators.set(entry.authority, [...(locators.get(entry.authority) ?? []), entry.locator]);\n schemas.set(entry.authority, entry.schemas);\n if (lines.get(entry.authority)?.logEpoch !== entry.logEpoch) {\n lines.set(entry.authority, { logEpoch: entry.logEpoch, frames: [] });\n }\n }\n for (const authority of lines.keys()) {\n if (!locators.has(authority)) lines.delete(authority);\n }\n },\n select() {},\n observe(notify) {\n observers.add(notify);\n listen();\n return () => {\n observers.delete(notify);\n };\n },\n advance(tracked, from) {\n const line = lines.get(tracked.authority);\n const start = position(from.position);\n if (line === undefined || start === null || line.logEpoch !== from.logEpoch) return null;\n const at = line.frames.findIndex((frame) => frame.position === start + 1n);\n if (at === -1) return null;\n const pending = line.frames.slice(at);\n const documents: Record<string, string> = {};\n const revisions: Record<string, string> = {};\n const changes: Record<string, HeadChange> = {};\n const removals: string[] = [];\n for (const frame of pending) {\n for (const entry of frame.entries) {\n if (!selects(tracked, entry.path)) continue;\n if (entry.kind === 'removed') {\n delete documents[entry.path];\n delete revisions[entry.path];\n delete changes[entry.path];\n if (!removals.includes(entry.path)) removals.push(entry.path);\n continue;\n }\n if (entry.text === undefined) return null;\n if (mode === 'credential' && entry.revision === undefined) return null;\n const head = headChange(entry);\n if (head === null) return null;\n documents[entry.path] = entry.text;\n if (entry.revision !== undefined) revisions[entry.path] = entry.revision;\n if (head === undefined) delete changes[entry.path];\n else changes[entry.path] = head;\n const removed = removals.indexOf(entry.path);\n if (removed !== -1) removals.splice(removed, 1);\n }\n }\n const last = pending.at(-1);\n if (last === undefined) return null;\n lines.set(tracked.authority, { logEpoch: line.logEpoch, frames: pending });\n return {\n kind: 'net-advancement',\n roomVersion: roomVersion({ position: last.position.toString(), logEpoch: line.logEpoch }),\n documents,\n revisions,\n changes,\n binaryTargets: [],\n removals: removals.sort(),\n };\n },\n };\n}\n"],"names":["acceptedMessage","headChange","selects","roomVersion","HELD_POSITIONS_MAX","position","value","test","BigInt","houseNotifications","transport","mode","stream","lines","Map","locators","schemas","observers","Set","conversationObservers","modeObservers","replicated","live","noted","listening","catching","listen","observe","receive","emitConversation","event","kind","add","conversation","observer","unnote","delete","note","reopened","gapped","clear","converse","frame","conversation_id","type","turn","turn_id","text","plan","structuredClone","steps","noteId","note_id","running","commands","options","questions","interactions","message","role","announce","authority","at","modelChanged","version","locator","get","interrupt","line","undefined","set","logEpoch","frames","service_mode","log_epoch","last","continued","next","entries","length","addresses","some","entry","includes","path","serviceMode","notify","conversations","replicate","opened","track","keys","has","select","advance","tracked","from","start","findIndex","pending","slice","documents","revisions","changes","removals","push","revision","head","removed","indexOf","splice","toString","binaryTargets","sort"],"mappings":"AASA,SAASA,eAAe,QAAQ,eAAe;AAE/C,SAASC,UAAU,EAAEC,OAAO,QAAyB,YAAY;AAEjE,SAASC,WAAW,QAA0B,eAAe;AAE7D,MAAMC,qBAAqB;AAmB3B,SAASC,SAASC,KAAa;IAC7B,IAAI,CAAC,sBAAsBC,IAAI,CAACD,QAAQ,OAAO;IAC/C,OAAOE,OAAOF;AAChB;AAEA,OAAO,SAASG,mBAAmBC,SAAoB,EAAEC,IAAe;IACtE,MAAMC,SAASF,UAAUE,MAAM;IAC/B,MAAMC,QAAQ,IAAIC;IAClB,MAAMC,WAAW,IAAID;IACrB,MAAME,UAAU,IAAIF;IACpB,MAAMG,YAAY,IAAIC;IACtB,MAAMC,wBAAwB,IAAID;IAClC,MAAME,gBAAgB,IAAIF;IAC1B,IAAIG,aAAgC,EAAE;IACtC,MAAMC,OAAO,IAAIJ;IACjB,MAAMK,QAAQ,IAAIL;IAClB,IAAIM,YAAY;IAChB,IAAIC,WAAW;IAEf,SAASC;QACP,IAAIF,WAAW;QACfA,YAAY;QACZZ,OAAOe,OAAO,CAACC;IACjB;IAEA,SAASC,iBAAiBC,KAAwB;QAChD,IAAIA,MAAMC,IAAI,KAAK,SAASD,MAAMC,IAAI,KAAK,oBAAoBT,KAAKU,GAAG,CAACF,MAA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BAClC,IAAImC,MAAMwB,QAAQ,KAAKrC,WAAWiC,SAAS,CAACpB,MAAME,IAAI,CAAC,GAAGF,MAAMwB,QAAQ;oBACxE,IAAIC,SAAStC,WAAW,OAAOkC,OAAO,CAACrB,MAAME,IAAI,CAAC;yBAC7CmB,OAAO,CAACrB,MAAME,IAAI,CAAC,GAAGuB;oBAC3B,MAAMC,UAAUJ,SAASK,OAAO,CAAC3B,MAAME,IAAI;oBAC3C,IAAIwB,YAAY,CAAC,GAAGJ,SAASM,MAAM,CAACF,SAAS;gBAC/C;YACF;YACA,MAAMjC,OAAOwB,QAAQrC,EAAE,CAAC,CAAC;YACzB,IAAIa,SAASN,WAAW,OAAO;YAC/BxD,MAAMyD,GAAG,CAACyB,QAAQlC,SAAS,EAAE;gBAAEU,UAAUH,KAAKG,QAAQ;gBAAEC,QAAQ2B;YAAQ;YACxE,OAAO;gBACLpE,MAAM;gBACN5B,aAAaA,YAAY;oBAAEE,UAAUsE,KAAKtE,QAAQ,CAAC0G,QAAQ;oBAAIxC,UAAUH,KAAKG,QAAQ;gBAAC;gBACvF8B;gBACAC;gBACAC;gBACAS,eAAe,EAAE;gBACjBR,UAAUA,SAASS,IAAI;YACzB;QACF;IACF;AACF"}
@@ -61,6 +61,10 @@ export type HouseStreamFrame = {
61
61
  type: 'message';
62
62
  conversation_id: string;
63
63
  message: unknown;
64
+ } | {
65
+ type: 'interactions';
66
+ conversation_id: string;
67
+ interactions: readonly unknown[];
64
68
  } | {
65
69
  type: 'working-note';
66
70
  conversation_id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,eAAO,MAAM,aAAa,mBAAmB,CAAC;AAE9C,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,UA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AI,EAAE,SAAS,CAAC;IAAC,eAAe,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAA;CAAE,GACrF;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7C,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAChE,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7D,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG;IACvC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG;IAC3C,MAAM,IAAI,OAAO,CAAC;IAClB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC/C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/transport.ts"],"sourcesContent":["import type { ConversationEvent } from '@agentshouse/mdruntime';\n\nexport const DOOR_DISCOVER = '/door/discover';\n\nexport const DOOR_BOOTSTRAP = '/door/bootstrap';\n\nexport const DOOR_ENUMERATE = '/door/enumerate';\n\nexport const DOOR_BATCH = '/door/batch';\n\nexport const DOOR_BATCH_UPLOAD = '/door/batch-upload';\n\nexport const DOOR_REVISIONS = '/door/revisions';\n\nexport const SITE_DOOR_DISCOVER = '/_house/door/discover';\n\nexport const SITE_DOOR_BOOTSTRAP = '/_house/door/bootstrap/';\n\nexport const SITE_DOOR_ENUMERATE = '/_house/door/enumerate';\n\nexport const SITE_DOOR_SUBMIT = '/_house/door/submit';\n\nexport const PRIVATE_LOCATOR = 'private';\n\nexport const DOOR_SELECTION_MAX = 256;\n\nexport type HouseMode = 'credential' | 'site';\n\nexport type HouseDoorAnswer = {\n status: number;\n body: unknown;\n};\n\nexport type HouseByteAct =\n | 'local_copy_bundle'\n | 'authored_batch_upload'\n | 'conversation_original_upload'\n | 'original_upload'\n | 'original_download';\n\nexport type HouseByteBody = string | ArrayBuffer | Uint8Array;\n\nexport type HouseByteAnswer = 'json' | 'bytes';\n\nexport type HouseByteTransfer = {\n act: HouseByteAct;\n method: 'GET' | 'POST';\n url: string;\n answer: HouseByteAnswer;\n body?: HouseByteBody;\n operation?: string;\n};\n\nexport type HouseStreamEntry = {\n path: string;\n kind: 'edited' | 'removed';\n revision?: string;\n text?: string;\n author?: { user: string; name: string } | { site: string; name: string };\n created_at?: string;\n};\n\ntype LiveFact<K extends ConversationEvent['kind']> = Extract<ConversationEvent, { kind: K }>;\n\nexport type HouseStreamFrame =\n | {\n type: 'entries';\n authority: string;\n position: string;\n log_epoch: string;\n entries: readonly HouseStreamEntry[];\n }\n | {\n type: 'draft';\n conversation_id: string;\n turn_id: string;\n text: string;\n blocks: readonly unknown[];\n steps: LiveFact<'plan'>['plan'];\n }\n | { type: 'message'; conversation_id: string; message: unknown }\n | { type: 'working-note'; conversation_id: string; note_id: string; text: string }\n | { type: 'process'; conversation_id: string; running: boolean }\n | { type: 'commands'; conversation_id: string; commands: LiveFact<'commands'>['commands'] }\n | { type: 'options'; conversation_id: string; options: LiveFact<'options'>['options'] }\n | { type: 'signal'; service_mode: string };\n\nexport type HouseStream = {\n observe(receive: (frame: HouseStreamFrame) => void): () => void;\n opened(notify: () => void): () => void;\n};\n\nexport type HouseDoor = {\n door(route: string, body: unknown): Promise<HouseDoorAnswer>;\n stream: HouseStream;\n};\n\nexport type HouseTransport = HouseDoor & {\n transfer(request: HouseByteTransfer): Promise<HouseDoorAnswer>;\n};\n\nexport type HouseSiteTransport = HouseDoor & {\n online(): boolean;\n read(route: string): Promise<HouseDoorAnswer>;\n};\n"],"names":["DOOR_DISCOVER","DOOR_BOOTSTRAP","DOOR_ENUMERATE","DOOR_BATCH","DOOR_BATCH_UPLOAD","DOOR_REVISIONS","SITE_DOOR_DISCOVER","SITE_DOOR_BOOTSTRAP","SITE_DOOR_ENUMERATE","SITE_DOOR_SUBMIT","PRIVATE_LOCATOR","DOOR_SELECTION_MAX"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,iBAAiB;AAE9C,OAAO,MAAMC,iBAAiB,kBAAkB;AAEhD,OAAO,MAAMC,iBAAiB,kBAAkB;AAEhD,OAAO,MAAMC,aAAa,cAAc;AAExC,OAAO,MAAMC,oBAAoB,qBAAqB;AAEtD,OAAO,MAAMC,iBAAiB,kBAAkB;AAEhD,OAAO,MAAMC,qBAAqB,wBAAwB;AAE1D,OAAO,MAAMC,sBAAsB,0BAA0B;AAE7D,OAAO,MAAMC,sBAAsB,yBAAyB;AAE5D,OAAO,MAAMC,mBAAmB,sBAAsB;AAEtD,OAAO,MAAMC,kBAAkB,UAAU;AAEzC,OAAO,MAAMC,qBAAqB,IAAI"}
1
+ {"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/transport.ts"],"sourcesContent":["import type { ConversationEvent } from '@agentshouse/mdruntime';\n\nexport const DOOR_DISCOVER = '/door/discover';\n\nexport const DOOR_BOOTSTRAP = '/door/bootstrap';\n\nexport const DOOR_ENUMERATE = '/door/enumerate';\n\nexport const DOOR_BATCH = '/door/batch';\n\nexport const DOOR_BATCH_UPLOAD = '/door/batch-upload';\n\nexport const DOOR_REVISIONS = '/door/revisions';\n\nexport const SITE_DOOR_DISCOVER = '/_house/door/discover';\n\nexport const SITE_DOOR_BOOTSTRAP = '/_house/door/bootstrap/';\n\nexport const SITE_DOOR_ENUMERATE = '/_house/door/enumerate';\n\nexport const SITE_DOOR_SUBMIT = '/_house/door/submit';\n\nexport const PRIVATE_LOCATOR = 'private';\n\nexport const DOOR_SELECTION_MAX = 256;\n\nexport type HouseMode = 'credential' | 'site';\n\nexport type HouseDoorAnswer = {\n status: number;\n body: unknown;\n};\n\nexport type HouseByteAct =\n | 'local_copy_bundle'\n | 'authored_batch_upload'\n | 'conversation_original_upload'\n | 'original_upload'\n | 'original_download';\n\nexport type HouseByteBody = string | ArrayBuffer | Uint8Array;\n\nexport type HouseByteAnswer = 'json' | 'bytes';\n\nexport type HouseByteTransfer = {\n act: HouseByteAct;\n method: 'GET' | 'POST';\n url: string;\n answer: HouseByteAnswer;\n body?: HouseByteBody;\n operation?: string;\n};\n\nexport type HouseStreamEntry = {\n path: string;\n kind: 'edited' | 'removed';\n revision?: string;\n text?: string;\n author?: { user: string; name: string } | { site: string; name: string };\n created_at?: string;\n};\n\ntype LiveFact<K extends ConversationEvent['kind']> = Extract<ConversationEvent, { kind: K }>;\n\nexport type HouseStreamFrame =\n | {\n type: 'entries';\n authority: string;\n position: string;\n log_epoch: string;\n entries: readonly HouseStreamEntry[];\n }\n | {\n type: 'draft';\n conversation_id: string;\n turn_id: string;\n text: string;\n blocks: readonly unknown[];\n steps: LiveFact<'plan'>['plan'];\n }\n | { type: 'message'; conversation_id: string; message: unknown }\n | { type: 'interactions'; conversation_id: string; interactions: readonly unknown[] }\n | { type: 'working-note'; conversation_id: string; note_id: string; text: string }\n | { type: 'process'; conversation_id: string; running: boolean }\n | { type: 'commands'; conversation_id: string; commands: LiveFact<'commands'>['commands'] }\n | { type: 'options'; conversation_id: string; options: LiveFact<'options'>['options'] }\n | { type: 'signal'; service_mode: string };\n\nexport type HouseStream = {\n observe(receive: (frame: HouseStreamFrame) => void): () => void;\n opened(notify: () => void): () => void;\n};\n\nexport type HouseDoor = {\n door(route: string, body: unknown): Promise<HouseDoorAnswer>;\n stream: HouseStream;\n};\n\nexport type HouseTransport = HouseDoor & {\n transfer(request: HouseByteTransfer): Promise<HouseDoorAnswer>;\n};\n\nexport type HouseSiteTransport = HouseDoor & {\n online(): boolean;\n read(route: string): Promise<HouseDoorAnswer>;\n};\n"],"names":["DOOR_DISCOVER","DOOR_BOOTSTRAP","DOOR_ENUMERATE","DOOR_BATCH","DOOR_BATCH_UPLOAD","DOOR_REVISIONS","SITE_DOOR_DISCOVER","SITE_DOOR_BOOTSTRAP","SITE_DOOR_ENUMERATE","SITE_DOOR_SUBMIT","PRIVATE_LOCATOR","DOOR_SELECTION_MAX"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,iBAAiB;AAE9C,OAAO,MAAMC,iBAAiB,kBAAkB;AAEhD,OAAO,MAAMC,iBAAiB,kBAAkB;AAEhD,OAAO,MAAMC,aAAa,cAAc;AAExC,OAAO,MAAMC,oBAAoB,qBAAqB;AAEtD,OAAO,MAAMC,iBAAiB,kBAAkB;AAEhD,OAAO,MAAMC,qBAAqB,wBAAwB;AAE1D,OAAO,MAAMC,sBAAsB,0BAA0B;AAE7D,OAAO,MAAMC,sBAAsB,yBAAyB;AAE5D,OAAO,MAAMC,mBAAmB,sBAAsB;AAEtD,OAAO,MAAMC,kBAAkB,UAAU;AAEzC,OAAO,MAAMC,qBAAqB,IAAI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime-adapter",
3
- "version": "0.1.0-alpha.45",
3
+ "version": "0.1.0-alpha.46",
4
4
  "description": "Agents House Adapter for the MD Runtime",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,6 +26,6 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@agentshouse/mdmodel": "0.1.0-alpha.19",
29
- "@agentshouse/mdruntime": "0.1.0-alpha.47"
29
+ "@agentshouse/mdruntime": "0.1.0-alpha.48"
30
30
  }
31
31
  }