@agentshouse/mdruntime-adapter 0.1.0-alpha.3 → 0.1.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +122 -22
- package/dist/actions.d.ts +3 -11
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +119 -224
- package/dist/actions.js.map +1 -1
- package/dist/adapter.d.ts +3 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +48 -104
- package/dist/adapter.js.map +1 -1
- package/dist/discovery.d.ts +35 -8
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +136 -32
- package/dist/discovery.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model.d.ts +19 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +64 -0
- package/dist/model.js.map +1 -0
- package/dist/read.d.ts +20 -15
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +118 -39
- package/dist/read.js.map +1 -1
- package/dist/refusal.d.ts +4 -1
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +13 -0
- package/dist/refusal.js.map +1 -1
- package/dist/site.d.ts +4 -0
- package/dist/site.d.ts.map +1 -0
- package/dist/site.js +205 -0
- package/dist/site.js.map +1 -0
- package/dist/stream.d.ts +6 -5
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +107 -119
- package/dist/stream.js.map +1 -1
- package/dist/transport.d.ts +16 -25
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +5 -1
- package/dist/transport.js.map +1 -1
- package/dist/version.d.ts +14 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +29 -0
- package/dist/version.js.map +1 -0
- package/dist/write.d.ts +6 -0
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +24 -7
- package/dist/write.js.map +1 -1
- package/package.json +3 -3
package/dist/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/stream.ts"],"sourcesContent":["import type {\n ConversationEvent,\n RefreshPage,\n RoomVersionNotification,\n SelectedRooms,\n ViewedConversations,\n} from '@agentshouse/mdruntime';\nimport { actionOutcome, HISTORY_PAGE, readConversationHistory } from './actions.js';\nimport type { TrackedAuthority } from './discovery.js';\nimport { selects } from './read.js';\nimport { PRIVATE_AUTHORITY, type HouseStreamAuthority, type HouseTransport } from './transport.js';\nimport type { HouseStreamEntry, HouseStreamFrame } from './transport.js';\n\nconst HELD_POSITIONS_MAX = 256;\n\ntype HeldFrame = {\n position: bigint;\n entries: readonly HouseStreamEntry[];\n};\n\nexport type HouseNotifications = SelectedRooms & {\n track(authorities: readonly TrackedAuthority[]): void;\n advance(tracked: TrackedAuthority, fromRoomVersion: string): RefreshPage | null;\n conversations: ViewedConversations;\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\nfunction messageTurn(message: unknown): string | null {\n if (typeof message !== 'object' || message === null) return null;\n const turn = (message as { message_id?: unknown }).message_id;\n return typeof turn === 'string' ? turn : null;\n}\n\nexport function houseNotifications(transport: HouseTransport): HouseNotifications {\n const stream = transport.stream;\n const held = new Map<string, HeldFrame[]>();\n const locators = new Map<string, string>();\n const authorities = new Map<string, string>();\n const observers = new Set<(notification: RoomVersionNotification) => void>();\n const conversationObservers = new Set<(event: ConversationEvent) => void>();\n const subscribedConversations = new Set<string>();\n let selected: readonly string[] = [];\n let viewed: readonly string[] = [];\n let listening = false;\n\n function subscribe() {\n const named: HouseStreamAuthority[] = [];\n for (const locator of selected) {\n const authority = authorities.get(locator);\n if (authority === undefined || authority === PRIVATE_AUTHORITY) continue;\n named.push({ kind: 'room', room: authority });\n }\n if (authorities.has(PRIVATE_AUTHORITY)) named.push({ kind: 'private' });\n for (const conversation of viewed) {\n named.push({ kind: 'conversation', conversation });\n }\n stream.subscribe(named);\n }\n\n function emitConversation(event: ConversationEvent) {\n if (!viewed.includes(event.conversation)) return;\n for (const observer of conversationObservers) observer(event);\n }\n\n async function catchUp(conversation: string, history: boolean) {\n const viewedAnswer = await transport.door('/door/conversations/view', {\n conversation_id: conversation,\n });\n const summary = actionOutcome(viewedAnswer, 'conversations/view');\n if (\n summary.kind === 'action' &&\n typeof summary.result === 'object' &&\n summary.result !== null\n ) {\n emitConversation({\n kind: 'session-summary',\n conversation,\n summary: structuredClone('session' in summary.result ? summary.result.session : null),\n });\n }\n if (!history) return;\n const heldHistory = await readConversationHistory(transport, conversation);\n if ('outcome' in heldHistory) return;\n const newest = heldHistory.messages.slice(-HISTORY_PAGE);\n for (const entry of newest) {\n const turn = messageTurn(entry);\n if (turn === null) return;\n emitConversation({\n kind: 'accepted-message',\n conversation,\n message: { turn, message: structuredClone(entry) },\n });\n }\n }\n\n function receive(frame: HouseStreamFrame) {\n if (frame.type === 'draft') {\n emitConversation({\n kind: 'growing-text',\n conversation: frame.conversation_id,\n turn: frame.turn_id,\n text: frame.text,\n });\n return;\n }\n if (frame.type === 'message') {\n const turn = messageTurn(frame.message);\n if (turn === null) return;\n emitConversation({\n kind: 'accepted-message',\n conversation: frame.conversation_id,\n message: { turn, message: structuredClone(frame.message) },\n });\n return;\n }\n if (frame.type === 'session') {\n emitConversation({\n kind: 'session-summary',\n conversation: frame.conversation_id,\n summary: structuredClone(frame.summary),\n });\n return;\n }\n if (frame.type === 'subscribed' && viewed.includes(frame.authority)) {\n const reconnect = subscribedConversations.has(frame.authority);\n subscribedConversations.add(frame.authority);\n void catchUp(frame.authority, reconnect);\n return;\n }\n if (frame.type !== 'entries') {\n held.delete(frame.authority);\n return;\n }\n const at = position(frame.position);\n if (at === null) {\n held.delete(frame.authority);\n return;\n }\n const run = held.get(frame.authority) ?? [];\n const last = run.at(-1);\n const continued = last !== undefined && last.position + 1n === at;\n const next = continued\n ? [...run, { position: at, entries: frame.entries }]\n : [{ position: at, entries: frame.entries }];\n held.set(frame.authority, next.length > HELD_POSITIONS_MAX ? [] : next);\n const locator = locators.get(frame.authority);\n if (locator === undefined) return;\n for (const observer of observers) observer({ locator, roomVersion: frame.position });\n }\n\n return {\n conversations: {\n view(next) {\n const open = new Set(next);\n for (const conversation of subscribedConversations) {\n if (!open.has(conversation)) subscribedConversations.delete(conversation);\n }\n viewed = [...next];\n subscribe();\n },\n observe(notify) {\n conversationObservers.add(notify);\n if (!listening) {\n listening = true;\n stream.observe(receive);\n }\n return () => {\n conversationObservers.delete(notify);\n };\n },\n },\n track(entries) {\n locators.clear();\n authorities.clear();\n for (const entry of entries) {\n locators.set(entry.authority, entry.locator);\n authorities.set(entry.locator, entry.authority);\n }\n for (const authority of held.keys()) {\n if (!locators.has(authority)) held.delete(authority);\n }\n },\n select(named) {\n selected = [...named];\n subscribe();\n },\n observe(notify) {\n observers.add(notify);\n if (!listening) {\n listening = true;\n stream.observe(receive);\n }\n return () => {\n observers.delete(notify);\n };\n },\n advance(tracked, fromRoomVersion) {\n const run = held.get(tracked.authority);\n const from = position(fromRoomVersion);\n if (run === undefined || from === null) return null;\n const at = run.findIndex((frame) => frame.position === from + 1n);\n if (at === -1) return null;\n const pending = run.slice(at);\n const documents: Record<string, string> = {};\n const revisions: Record<string, string> = {};\n const removals: string[] = [];\n for (const frame of pending) {\n for (const entry of frame.entries) {\n if (!selects(tracked, entry.path)) continue;\n if (entry.kind === 'removed') {\n delete documents[entry.path];\n delete revisions[entry.path];\n if (!removals.includes(entry.path)) removals.push(entry.path);\n continue;\n }\n if (entry.text === undefined || entry.revision === undefined) return null;\n documents[entry.path] = entry.text;\n revisions[entry.path] = entry.revision;\n const removed = removals.indexOf(entry.path);\n if (removed !== -1) removals.splice(removed, 1);\n }\n }\n const last = pending.at(-1);\n if (last === undefined) return null;\n held.set(tracked.authority, pending);\n return {\n kind: 'net-advancement',\n roomVersion: last.position.toString(),\n documents,\n revisions,\n binaryTargets: [],\n removals: removals.sort(),\n };\n },\n };\n}\n"],"names":["actionOutcome","HISTORY_PAGE","readConversationHistory","selects","PRIVATE_AUTHORITY","HELD_POSITIONS_MAX","position","value","test","BigInt","messageTurn","message","turn","message_id","houseNotifications","transport","stream","held","Map","locators","authorities","observers","Set","conversationObservers","subscribedConversations","selected","viewed","listening","subscribe","named","locator","authority","get","undefined","push","kind","room","has","conversation","emitConversation","event","includes","observer","catchUp","history","viewedAnswer","door","conversation_id","summary","result","structuredClone","session","heldHistory","newest","messages","slice","entry","receive","frame","type","turn_id","text","reconnect","add","delete","at","run","last","continued","next","entries","set","length","roomVersion","conversations","view","open","observe","notify","track","clear","keys","select","advance","tracked","fromRoomVersion","from","findIndex","pending","documents","revisions","removals","path","revision","removed","indexOf","splice","toString","binaryTargets","sort"],"mappings":"AAOA,SAASA,aAAa,EAAEC,YAAY,EAAEC,uBAAuB,QAAQ,eAAe;AAEpF,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,iBAAiB,QAAwD,iBAAiB;AAGnG,MAAMC,qBAAqB;AAa3B,SAASC,SAASC,KAAa;IAC7B,IAAI,CAAC,sBAAsBC,IAAI,CAACD,QAAQ,OAAO;IAC/C,OAAOE,OAAOF;AAChB;AAEA,SAASG,YAAYC,OAAgB;IACnC,IAAI,OAAOA,YAAY,YAAYA,YAAY,MAAM,OAAO;IAC5D,MAAMC,OAAO,AAACD,QAAqCE,UAAU;IAC7D,OAAO,OAAOD,SAAS,WAAWA,OAAO;AAC3C;AAEA,OAAO,SAASE,mBAAmBC,SAAyB;IAC1D,MAAMC,SAASD,UAAUC,MAAM;IAC/B,MAAMC,OAAO,IAAIC;IACjB,MAAMC,WAAW,IAAID;IACrB,MAAME,cAAc,IAAIF;IACxB,MAAMG,YAAY,IAAIC;IACtB,MAAMC,wBAAwB,IAAID;IAClC,MAAME,0BAA0B,IAAIF;IACpC,IAAIG,WAA8B,EAAE;IACpC,IAAIC,SAA4B,EAAE;IAClC,IAAIC,YAAY;IAEhB,SAASC;QACP,MAAMC,QAA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,OAAO;oBACrEwD,SAAS,CAACjC,MAAMoC,IAAI,CAAC,GAAGpC,MAAMK,IAAI;oBAClC6B,SAAS,CAAClC,MAAMoC,IAAI,CAAC,GAAGpC,MAAMqC,QAAQ;oBACtC,MAAMC,UAAUH,SAASI,OAAO,CAACvC,MAAMoC,IAAI;oBAC3C,IAAIE,YAAY,CAAC,GAAGH,SAASK,MAAM,CAACF,SAAS;gBAC/C;YACF;YACA,MAAM3B,OAAOqB,QAAQvB,EAAE,CAAC,CAAC;YACzB,IAAIE,SAASlC,WAAW,OAAO;YAC/BhB,KAAKsD,GAAG,CAACa,QAAQrD,SAAS,EAAEyD;YAC5B,OAAO;gBACLrD,MAAM;gBACNsC,aAAaN,KAAK7D,QAAQ,CAAC2F,QAAQ;gBACnCR;gBACAC;gBACAQ,eAAe,EAAE;gBACjBP,UAAUA,SAASQ,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} from '@agentshouse/mdruntime';\nimport { acceptedMessage, actionOutcome } from './actions.js';\nimport type { TrackedAuthority } from './discovery.js';\nimport { selects } 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};\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 observers = new Set<(notification: RoomVersionNotification) => void>();\n const conversationObservers = new Set<(event: ConversationEvent) => void>();\n let replicated: readonly string[] = [];\n let viewed: readonly 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 const delivered =\n event.kind === 'accepted-message' || event.kind === 'gap' ? replicated : viewed;\n if (!delivered.includes(event.conversation)) return;\n for (const observer of conversationObservers) observer(event);\n }\n\n async function summarize(conversation: string) {\n const viewedAnswer = await transport.door('/door/conversations/view', {\n conversation_id: conversation,\n });\n const summary = actionOutcome(viewedAnswer, 'conversations/view');\n if (\n summary.kind === 'action' &&\n typeof summary.result === 'object' &&\n summary.result !== null\n ) {\n emitConversation({\n kind: 'session-summary',\n conversation,\n summary: structuredClone('session' in summary.result ? summary.result.session : null),\n });\n }\n }\n\n function reopened() {\n for (const conversation of replicated) emitConversation({ kind: 'gap', conversation });\n for (const conversation of viewed) void summarize(conversation);\n }\n\n function announce(authority: string, at: LogPosition) {\n const version = roomVersion(at);\n for (const locator of locators.get(authority) ?? []) {\n for (const observer of observers) observer({ locator, roomVersion: version });\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 === 'draft') {\n emitConversation({\n kind: 'growing-text',\n conversation: frame.conversation_id,\n turn: frame.turn_id,\n text: frame.text,\n });\n return;\n }\n if (frame.type === 'message') {\n const message = acceptedMessage(frame.message);\n if (message === null) return;\n emitConversation({ kind: 'accepted-message', conversation: frame.conversation_id, message });\n return;\n }\n if (frame.type === 'session') {\n emitConversation({\n kind: 'session-summary',\n conversation: frame.conversation_id,\n summary: structuredClone(frame.summary),\n });\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 announce(frame.authority, { position: frame.position, logEpoch: frame.log_epoch });\n }\n\n return {\n conversations: {\n replicate(next) {\n replicated = [...next];\n },\n view(next) {\n const entering = next.filter((conversation) => !viewed.includes(conversation));\n viewed = [...next];\n for (const conversation of entering) void summarize(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 for (const entry of entries) {\n locators.set(entry.authority, [...(locators.get(entry.authority) ?? []), entry.locator]);\n if (lines.get(entry.authority)?.logEpoch !== entry.logEpoch) {\n lines.set(entry.authority, { logEpoch: entry.logEpoch, frames: [] });\n }\n }\n for (const authority of lines.keys()) {\n if (!locators.has(authority)) lines.delete(authority);\n }\n },\n select() {},\n observe(notify) {\n observers.add(notify);\n listen();\n return () => {\n observers.delete(notify);\n };\n },\n advance(tracked, from) {\n const line = lines.get(tracked.authority);\n const start = position(from.position);\n if (line === undefined || start === null || line.logEpoch !== from.logEpoch) return null;\n const at = line.frames.findIndex((frame) => frame.position === start + 1n);\n if (at === -1) return null;\n const pending = line.frames.slice(at);\n const documents: Record<string, string> = {};\n const revisions: Record<string, string> = {};\n const removals: string[] = [];\n for (const frame of pending) {\n for (const entry of frame.entries) {\n if (!selects(tracked, entry.path)) continue;\n if (entry.kind === 'removed') {\n delete documents[entry.path];\n delete revisions[entry.path];\n if (!removals.includes(entry.path)) removals.push(entry.path);\n continue;\n }\n if (entry.text === undefined) return null;\n if (mode === 'credential' && entry.revision === undefined) return null;\n documents[entry.path] = entry.text;\n if (entry.revision !== undefined) revisions[entry.path] = entry.revision;\n const removed = removals.indexOf(entry.path);\n if (removed !== -1) removals.splice(removed, 1);\n }\n }\n const last = pending.at(-1);\n if (last === undefined) return null;\n lines.set(tracked.authority, { logEpoch: line.logEpoch, frames: pending });\n return {\n kind: 'net-advancement',\n roomVersion: roomVersion({ position: last.position.toString(), logEpoch: line.logEpoch }),\n documents,\n revisions,\n binaryTargets: [],\n removals: removals.sort(),\n };\n },\n };\n}\n"],"names":["acceptedMessage","actionOutcome","selects","roomVersion","HELD_POSITIONS_MAX","position","value","test","BigInt","houseNotifications","transport","mode","stream","lines","Map","locators","observers","Set","conversationObservers","replicated","viewed","listening","catching","listen","observe","receive","emitConversation","event","delivered","kind","includes","conversation","observer","summarize","viewedAnswer","door","conversation_id","summary","result","structuredClone","session","reopened","announce","authority","at","version","locator","get","interrupt","line","undefined","set","logEpoch","frames","frame","type","turn","turn_id","text","message","log_epoch","last","continued","next","entries","length","conversations","replicate","view","entering","filter","notify","add","opened","delete","track","clear","entry","keys","has","select","advance","tracked","from","start","findIndex","pending","slice","documents","revisions","removals","path","push","revision","removed","indexOf","splice","toString","binaryTargets","sort"],"mappings":"AAOA,SAASA,eAAe,EAAEC,aAAa,QAAQ,eAAe;AAE9D,SAASC,OAAO,QAAQ,YAAY;AAEpC,SAASC,WAAW,QAA0B,eAAe;AAE7D,MAAMC,qBAAqB;AAkB3B,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,YAAY,IAAIC;IACtB,MAAMC,wBAA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,CAACX,MAAMc,IAAI,CAAC,GAAGd,MAAMnB,IAAI;oBAClC,IAAImB,MAAMgB,QAAQ,KAAK3C,WAAWuC,SAAS,CAACZ,MAAMc,IAAI,CAAC,GAAGd,MAAMgB,QAAQ;oBACxE,MAAMC,UAAUJ,SAASK,OAAO,CAAClB,MAAMc,IAAI;oBAC3C,IAAIG,YAAY,CAAC,GAAGJ,SAASM,MAAM,CAACF,SAAS;gBAC/C;YACF;YACA,MAAMjC,OAAOyB,QAAQ1C,EAAE,CAAC,CAAC;YACzB,IAAIiB,SAASX,WAAW,OAAO;YAC/BrC,MAAMsC,GAAG,CAAC+B,QAAQvC,SAAS,EAAE;gBAAES,UAAUH,KAAKG,QAAQ;gBAAEC,QAAQiC;YAAQ;YACxE,OAAO;gBACLzD,MAAM;gBACN1B,aAAaA,YAAY;oBAAEE,UAAUwD,KAAKxD,QAAQ,CAAC4F,QAAQ;oBAAI7C,UAAUH,KAAKG,QAAQ;gBAAC;gBACvFoC;gBACAC;gBACAS,eAAe,EAAE;gBACjBR,UAAUA,SAASS,IAAI;YACzB;QACF;IACF;AACF"}
|
package/dist/transport.d.ts
CHANGED
|
@@ -4,7 +4,12 @@ export declare const DOOR_ENUMERATE = "/door/enumerate";
|
|
|
4
4
|
export declare const DOOR_BATCH = "/door/batch";
|
|
5
5
|
export declare const DOOR_BATCH_UPLOAD = "/door/batch-upload";
|
|
6
6
|
export declare const DOOR_REVISIONS = "/door/revisions";
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const SITE_DOOR_DISCOVER = "/_house/door/discover";
|
|
8
|
+
export declare const SITE_DOOR_BOOTSTRAP = "/_house/door/bootstrap/";
|
|
9
|
+
export declare const SITE_DOOR_ENUMERATE = "/_house/door/enumerate";
|
|
10
|
+
export declare const SITE_DOOR_SUBMIT = "/_house/door/submit";
|
|
11
|
+
export declare const PRIVATE_LOCATOR = "private";
|
|
12
|
+
export type HouseMode = 'credential' | 'site';
|
|
8
13
|
export type HouseDoorAnswer = {
|
|
9
14
|
status: number;
|
|
10
15
|
body: unknown;
|
|
@@ -18,15 +23,6 @@ export type HouseByteTransfer = {
|
|
|
18
23
|
body?: HouseByteBody;
|
|
19
24
|
operation?: string;
|
|
20
25
|
};
|
|
21
|
-
export type HouseStreamAuthority = {
|
|
22
|
-
kind: 'room';
|
|
23
|
-
room: string;
|
|
24
|
-
} | {
|
|
25
|
-
kind: 'private';
|
|
26
|
-
} | {
|
|
27
|
-
kind: 'conversation';
|
|
28
|
-
conversation: string;
|
|
29
|
-
};
|
|
30
26
|
export type HouseStreamEntry = {
|
|
31
27
|
path: string;
|
|
32
28
|
kind: 'edited' | 'removed';
|
|
@@ -37,19 +33,8 @@ export type HouseStreamFrame = {
|
|
|
37
33
|
type: 'entries';
|
|
38
34
|
authority: string;
|
|
39
35
|
position: string;
|
|
36
|
+
log_epoch: string;
|
|
40
37
|
entries: readonly HouseStreamEntry[];
|
|
41
|
-
} | {
|
|
42
|
-
type: 'subscribed';
|
|
43
|
-
authority: string;
|
|
44
|
-
position?: string;
|
|
45
|
-
} | {
|
|
46
|
-
type: 'refused';
|
|
47
|
-
authority: string;
|
|
48
|
-
code: string;
|
|
49
|
-
} | {
|
|
50
|
-
type: 'unsubscribed';
|
|
51
|
-
authority: string;
|
|
52
|
-
code?: string;
|
|
53
38
|
} | {
|
|
54
39
|
type: 'draft';
|
|
55
40
|
conversation_id: string;
|
|
@@ -66,12 +51,18 @@ export type HouseStreamFrame = {
|
|
|
66
51
|
summary: unknown;
|
|
67
52
|
};
|
|
68
53
|
export type HouseStream = {
|
|
69
|
-
subscribe(authorities: readonly HouseStreamAuthority[]): void;
|
|
70
54
|
observe(receive: (frame: HouseStreamFrame) => void): () => void;
|
|
55
|
+
opened(notify: () => void): () => void;
|
|
71
56
|
};
|
|
72
|
-
export type
|
|
57
|
+
export type HouseDoor = {
|
|
73
58
|
door(route: string, body: unknown): Promise<HouseDoorAnswer>;
|
|
74
|
-
transfer(request: HouseByteTransfer): Promise<HouseDoorAnswer>;
|
|
75
59
|
stream: HouseStream;
|
|
76
60
|
};
|
|
61
|
+
export type HouseTransport = HouseDoor & {
|
|
62
|
+
transfer(request: HouseByteTransfer): Promise<HouseDoorAnswer>;
|
|
63
|
+
};
|
|
64
|
+
export type HouseSiteTransport = HouseDoor & {
|
|
65
|
+
online(): boolean;
|
|
66
|
+
read(route: string): Promise<HouseDoorAnswer>;
|
|
67
|
+
};
|
|
77
68
|
//# sourceMappingURL=transport.d.ts.map
|
package/dist/transport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,mBAAmB,CAAC;AAE9C,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,UAAU,gBAAgB,CAAC;AAExC,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,mBAAmB,CAAC;AAE9C,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,UAAU,gBAAgB,CAAC;AAExC,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAE7D,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D,eAAO,MAAM,gBAAgB,wBAAwB,CAAC;AAEtD,eAAO,MAAM,eAAe,YAAY,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG,YAAY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A;CAAE,CAAC;AAEnE,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"}
|
package/dist/transport.js
CHANGED
|
@@ -4,6 +4,10 @@ export const DOOR_ENUMERATE = '/door/enumerate';
|
|
|
4
4
|
export const DOOR_BATCH = '/door/batch';
|
|
5
5
|
export const DOOR_BATCH_UPLOAD = '/door/batch-upload';
|
|
6
6
|
export const DOOR_REVISIONS = '/door/revisions';
|
|
7
|
-
export const
|
|
7
|
+
export const SITE_DOOR_DISCOVER = '/_house/door/discover';
|
|
8
|
+
export const SITE_DOOR_BOOTSTRAP = '/_house/door/bootstrap/';
|
|
9
|
+
export const SITE_DOOR_ENUMERATE = '/_house/door/enumerate';
|
|
10
|
+
export const SITE_DOOR_SUBMIT = '/_house/door/submit';
|
|
11
|
+
export const PRIVATE_LOCATOR = 'private';
|
|
8
12
|
|
|
9
13
|
//# sourceMappingURL=transport.js.map
|
package/dist/transport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/transport.ts"],"sourcesContent":["export 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
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/transport.ts"],"sourcesContent":["export 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 type HouseMode = 'credential' | 'site';\n\nexport type HouseDoorAnswer = {\n status: number;\n body: unknown;\n};\n\nexport type HouseByteAct =\n | 'working_copy_bundle'\n | 'authored_batch_upload'\n | 'conversation_original_upload';\n\nexport type HouseByteBody = string | ArrayBuffer | Uint8Array;\n\nexport type HouseByteTransfer = {\n act: HouseByteAct;\n method: 'GET' | 'POST';\n url: string;\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};\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 session_id: string;\n turn_id: string;\n text: string;\n }\n | { type: 'message'; conversation_id: string; message: unknown }\n | { type: 'session'; conversation_id: string; summary: unknown };\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"],"mappings":"AAAA,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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type LogPosition = {
|
|
2
|
+
position: string;
|
|
3
|
+
logEpoch: string;
|
|
4
|
+
};
|
|
5
|
+
export type PresentedPosition = {
|
|
6
|
+
authority: string;
|
|
7
|
+
position: string;
|
|
8
|
+
log_epoch: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function roomVersion(at: LogPosition): string;
|
|
11
|
+
export declare function logPosition(version: string): LogPosition | null;
|
|
12
|
+
export declare function readPosition(held: Readonly<Record<string, unknown>>): LogPosition | null;
|
|
13
|
+
export declare function presented(authority: string, at: LogPosition): PresentedPosition;
|
|
14
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAEnD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAI/D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,WAAW,GAAG,IAAI,CAKxF;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,iBAAiB,CAE/E"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function roomVersion(at) {
|
|
2
|
+
return `${at.logEpoch}:${at.position}`;
|
|
3
|
+
}
|
|
4
|
+
export function logPosition(version) {
|
|
5
|
+
const split = version.lastIndexOf(':');
|
|
6
|
+
if (split < 1 || split === version.length - 1) return null;
|
|
7
|
+
return {
|
|
8
|
+
logEpoch: version.slice(0, split),
|
|
9
|
+
position: version.slice(split + 1)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function readPosition(held) {
|
|
13
|
+
const { position, log_epoch: logEpoch } = held;
|
|
14
|
+
if (typeof position !== 'string' || position.length === 0) return null;
|
|
15
|
+
if (typeof logEpoch !== 'string' || logEpoch.length === 0) return null;
|
|
16
|
+
return {
|
|
17
|
+
position,
|
|
18
|
+
logEpoch
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function presented(authority, at) {
|
|
22
|
+
return {
|
|
23
|
+
authority,
|
|
24
|
+
position: at.position,
|
|
25
|
+
log_epoch: at.logEpoch
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/version.ts"],"sourcesContent":["export type LogPosition = {\n position: string;\n logEpoch: string;\n};\n\nexport type PresentedPosition = {\n authority: string;\n position: string;\n log_epoch: string;\n};\n\nexport function roomVersion(at: LogPosition): string {\n return `${at.logEpoch}:${at.position}`;\n}\n\nexport function logPosition(version: string): LogPosition | null {\n const split = version.lastIndexOf(':');\n if (split < 1 || split === version.length - 1) return null;\n return { logEpoch: version.slice(0, split), position: version.slice(split + 1) };\n}\n\nexport function readPosition(held: Readonly<Record<string, unknown>>): LogPosition | null {\n const { position, log_epoch: logEpoch } = held;\n if (typeof position !== 'string' || position.length === 0) return null;\n if (typeof logEpoch !== 'string' || logEpoch.length === 0) return null;\n return { position, logEpoch };\n}\n\nexport function presented(authority: string, at: LogPosition): PresentedPosition {\n return { authority, position: at.position, log_epoch: at.logEpoch };\n}\n"],"names":["roomVersion","at","logEpoch","position","logPosition","version","split","lastIndexOf","length","slice","readPosition","held","log_epoch","presented","authority"],"mappings":"AAWA,OAAO,SAASA,YAAYC,EAAe;IACzC,OAAO,GAAGA,GAAGC,QAAQ,CAAC,CAAC,EAAED,GAAGE,QAAQ,EAAE;AACxC;AAEA,OAAO,SAASC,YAAYC,OAAe;IACzC,MAAMC,QAAQD,QAAQE,WAAW,CAAC;IAClC,IAAID,QAAQ,KAAKA,UAAUD,QAAQG,MAAM,GAAG,GAAG,OAAO;IACtD,OAAO;QAAEN,UAAUG,QAAQI,KAAK,CAAC,GAAGH;QAAQH,UAAUE,QAAQI,KAAK,CAACH,QAAQ;IAAG;AACjF;AAEA,OAAO,SAASI,aAAaC,IAAuC;IAClE,MAAM,EAAER,QAAQ,EAAES,WAAWV,QAAQ,EAAE,GAAGS;IAC1C,IAAI,OAAOR,aAAa,YAAYA,SAASK,MAAM,KAAK,GAAG,OAAO;IAClE,IAAI,OAAON,aAAa,YAAYA,SAASM,MAAM,KAAK,GAAG,OAAO;IAClE,OAAO;QAAEL;QAAUD;IAAS;AAC9B;AAEA,OAAO,SAASW,UAAUC,SAAiB,EAAEb,EAAe;IAC1D,OAAO;QAAEa;QAAWX,UAAUF,GAAGE,QAAQ;QAAES,WAAWX,GAAGC,QAAQ;IAAC;AACpE"}
|
package/dist/write.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ export type ChangeMapping = {
|
|
|
12
12
|
rule: string;
|
|
13
13
|
};
|
|
14
14
|
export declare function houseChanges(batch: ChangeBatch, handle: string | undefined): ChangeMapping;
|
|
15
|
+
export type OperationHead = {
|
|
16
|
+
readonly operation_id: string;
|
|
17
|
+
readonly app_ref?: string;
|
|
18
|
+
readonly release?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function operationHead(batch: ChangeBatch): OperationHead;
|
|
15
21
|
export declare function batchPaths(changes: readonly HouseOperation[]): readonly string[];
|
|
16
22
|
export declare function deltaBody(changes: readonly HouseOperation[]): string;
|
|
17
23
|
export declare function deltaBytes(delta: string): number;
|
package/dist/write.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACX,aAAa,EAEb,cAAc,EAEf,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"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AE1D;AAqCD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,cAAc,CAsDhB;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;IAEjF,IAAI,EAAE,UAAU;IAChB,QAAQ;IACR,IAAI;IACJ,MAAM;QAAI,IAAI;;EAEjB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM1B;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,aAAa,CAoDf"}
|
package/dist/write.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { sha256Hex, textBytes } from './digest.js';
|
|
2
2
|
import { nativePath, roomLocalPath } from './map.js';
|
|
3
3
|
import { classifyDoor, doorRefusal, scopedRefusal } from './refusal.js';
|
|
4
|
+
import { readPosition, roomVersion } from './version.js';
|
|
4
5
|
export const INLINE_BODY_LIMIT_BYTES = 4 * 1024 * 1024;
|
|
5
6
|
export const UPLOAD_LINE_BYTES = 37;
|
|
6
7
|
export const UPLOAD_BYTES_MAX = 32 * 1024 * 1024 - UPLOAD_LINE_BYTES;
|
|
@@ -25,7 +26,12 @@ function priorExistence(batch, path) {
|
|
|
25
26
|
kind: 'presence'
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
+
function created(change, path) {
|
|
30
|
+
if ('content' in change) return {
|
|
31
|
+
op: 'create',
|
|
32
|
+
path,
|
|
33
|
+
content: change.content
|
|
34
|
+
};
|
|
29
35
|
const { type, ...fields } = change.fields;
|
|
30
36
|
if (typeof type !== 'string' || type.length === 0) return null;
|
|
31
37
|
return {
|
|
@@ -88,11 +94,11 @@ function operationOf(batch, change, handle) {
|
|
|
88
94
|
if (priorAbsence(batch, change.path) === undefined) return {
|
|
89
95
|
rule: 'precondition-missing'
|
|
90
96
|
};
|
|
91
|
-
const
|
|
92
|
-
return
|
|
97
|
+
const operation = created(change, path);
|
|
98
|
+
return operation === null ? {
|
|
93
99
|
rule: 'type-missing'
|
|
94
100
|
} : {
|
|
95
|
-
operation
|
|
101
|
+
operation
|
|
96
102
|
};
|
|
97
103
|
}
|
|
98
104
|
const existence = priorExistence(batch, change.path);
|
|
@@ -149,6 +155,16 @@ export function houseChanges(batch, handle) {
|
|
|
149
155
|
changes
|
|
150
156
|
};
|
|
151
157
|
}
|
|
158
|
+
export function operationHead(batch) {
|
|
159
|
+
const writer = batch.writtenBy;
|
|
160
|
+
return writer === undefined ? {
|
|
161
|
+
operation_id: batch.id
|
|
162
|
+
} : {
|
|
163
|
+
operation_id: batch.id,
|
|
164
|
+
app_ref: writer.app,
|
|
165
|
+
release: writer.release
|
|
166
|
+
};
|
|
167
|
+
}
|
|
152
168
|
export function batchPaths(changes) {
|
|
153
169
|
return [
|
|
154
170
|
...new Set(changes.flatMap((change)=>change.op === 'rename' ? [
|
|
@@ -235,7 +251,7 @@ export function mutationOutcome(status, body, locator, handle) {
|
|
|
235
251
|
const classified = classifyDoor(status, body, locator);
|
|
236
252
|
if (classified !== null && classified.kind !== 'scoped-refusal') {
|
|
237
253
|
return classified.kind === 'beyond-horizon' ? {
|
|
238
|
-
kind: '
|
|
254
|
+
kind: 'expired'
|
|
239
255
|
} : classified;
|
|
240
256
|
}
|
|
241
257
|
if (classified !== null && status === 403) return classified;
|
|
@@ -253,7 +269,8 @@ export function mutationOutcome(status, body, locator, handle) {
|
|
|
253
269
|
};
|
|
254
270
|
}
|
|
255
271
|
const held = body;
|
|
256
|
-
|
|
272
|
+
const at = readPosition(held);
|
|
273
|
+
if (at === null) return {
|
|
257
274
|
kind: 'transport-uncertainty'
|
|
258
275
|
};
|
|
259
276
|
const contents = material(held.contents, handle);
|
|
@@ -273,7 +290,7 @@ export function mutationOutcome(status, body, locator, handle) {
|
|
|
273
290
|
}
|
|
274
291
|
return {
|
|
275
292
|
kind: 'accepted',
|
|
276
|
-
roomVersion:
|
|
293
|
+
roomVersion: roomVersion(at),
|
|
277
294
|
documents,
|
|
278
295
|
revisions,
|
|
279
296
|
removals: removals.sort()
|
package/dist/write.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/write.ts"],"sourcesContent":["import type {\n Change,\n ChangeBatch,\n HistoryResult,\n HistoryRevision,\n MutationResult,\n Precondition,\n} from '@agentshouse/mdruntime';\nimport { sha256Hex, textBytes } from './digest.js';\nimport { nativePath, roomLocalPath } from './map.js';\nimport { classifyDoor, doorRefusal, scopedRefusal } from './refusal.js';\n\nexport const INLINE_BODY_LIMIT_BYTES = 4 * 1024 * 1024;\n\nexport const UPLOAD_LINE_BYTES = 37;\n\nexport const UPLOAD_BYTES_MAX = 32 * 1024 * 1024 - UPLOAD_LINE_BYTES;\n\nexport type HouseOperation = Readonly<Record<string, unknown>>;\n\nexport type ChangeMapping =\n | { kind: 'changes'; changes: readonly HouseOperation[] }\n | { kind: 'unmapped'; path: string; rule: string };\n\ntype Existence = { base: string } | { kind: 'presence' };\n\nfunction priorField(batch: ChangeBatch, path: string, name: string) {\n return batch.preconditions.find(\n (precondition): precondition is Extract<Precondition, { kind: 'field' }> =>\n precondition.kind === 'field' && precondition.path === path && precondition.name === name,\n );\n}\n\nfunction priorSection(batch: ChangeBatch, path: string, name: string) {\n return batch.preconditions.find(\n (precondition): precondition is Extract<Precondition, { kind: 'section' }> =>\n precondition.kind === 'section' && precondition.path === path && precondition.name === name,\n );\n}\n\nfunction priorPreamble(batch: ChangeBatch, path: string) {\n return batch.preconditions.find(\n (precondition): precondition is Extract<Precondition, { kind: 'preamble' }> =>\n precondition.kind === 'preamble' && precondition.path === path,\n );\n}\n\nfunction priorAbsence(batch: ChangeBatch, path: string) {\n return batch.preconditions.find(\n (precondition) => precondition.kind === 'absent' && precondition.path === path,\n );\n}\n\nfunction priorExistence(batch: ChangeBatch, path: string): Existence | undefined {\n const precondition = batch.preconditions.find(\n (held) => held.path === path && (held.kind === 'revision' || held.kind === 'present'),\n );\n if (precondition === undefined) return undefined;\n return precondition.kind === 'revision' ? { base: precondition.revision } : { kind: 'presence' };\n}\n\nfunction typedCreate(\n change: Extract<Change, { kind: 'create' }>,\n path: string,\n): HouseOperation | null {\n const { type, ...fields } = change.fields;\n if (typeof type !== 'string' || type.length === 0) return null;\n return { op: 'create_typed', path, type, fields, sections: change.sections };\n}\n\ntype MappedOperation = { operation: HouseOperation } | { rule: string };\n\nfunction operationOf(\n batch: ChangeBatch,\n change: Change,\n handle: string | undefined,\n): MappedOperation {\n const path = nativePath(change.path, handle);\n if (change.kind === 'field') {\n const prior = priorField(batch, change.path, change.name);\n if (prior === undefined) return { rule: 'precondition-missing' };\n return {\n operation: {\n op: 'set_field',\n path,\n field: change.name,\n value: change.value,\n ...(prior.value === undefined ? {} : { base: prior.value }),\n },\n };\n }\n if (change.kind === 'section') {\n const prior = priorSection(batch, change.path, change.name);\n if (prior === undefined) return { rule: 'precondition-missing' };\n return {\n operation: {\n op: 'replace_section',\n path,\n section: change.name,\n base: prior.value,\n content: change.value,\n },\n };\n }\n if (change.kind === 'preamble') {\n const prior = priorPreamble(batch, change.path);\n if (prior === undefined) return { rule: 'precondition-missing' };\n return {\n operation: { op: 'replace_preamble', path, base: prior.value, content: change.value },\n };\n }\n if (change.kind === 'create') {\n if (priorAbsence(batch, change.path) === undefined) return { rule: 'precondition-missing' };\n const created = typedCreate(change, path);\n return created === null ? { rule: 'type-missing' } : { operation: created };\n }\n const existence = priorExistence(batch, change.path);\n if (existence === undefined) return { rule: 'precondition-missing' };\n if (!('base' in existence)) return { rule: 'presence-base-unrepresentable' };\n if (change.kind === 'replace') {\n return { operation: { op: 'replace', path, base: existence.base, content: change.content } };\n }\n if (change.kind === 'move') {\n if (priorAbsence(batch, change.to) === undefined) return { rule: 'precondition-missing' };\n return {\n operation: { op: 'rename', path, to: nativePath(change.to, handle), base: existence.base },\n };\n }\n return { operation: { op: 'remove', path, base: existence.base } };\n}\n\nexport function houseChanges(batch: ChangeBatch, handle: string | undefined): ChangeMapping {\n const changes: HouseOperation[] = [];\n for (const change of batch.changes) {\n const mapped = operationOf(batch, change, handle);\n if ('rule' in mapped) return { kind: 'unmapped', path: change.path, rule: mapped.rule };\n changes.push(mapped.operation);\n }\n return { kind: 'changes', changes };\n}\n\nexport function batchPaths(changes: readonly HouseOperation[]): readonly string[] {\n return [\n ...new Set(\n changes.flatMap((change) =>\n change.op === 'rename' ? [String(change.path), String(change.to)] : [String(change.path)],\n ),\n ),\n ].sort();\n}\n\nexport function deltaBody(changes: readonly HouseOperation[]): string {\n return JSON.stringify({ changes });\n}\n\nexport function deltaBytes(delta: string): number {\n return textBytes(delta);\n}\n\nexport function uploadable(bytes: number): boolean {\n return bytes > INLINE_BODY_LIMIT_BYTES && bytes <= UPLOAD_BYTES_MAX;\n}\n\nexport function deltaDigest(delta: string): Promise<string> {\n return sha256Hex(delta);\n}\n\ntype Material = { path: string; content: string | null; revision: string | null };\n\nfunction material(value: unknown, handle: string | undefined): readonly Material[] | null {\n if (!Array.isArray(value)) return null;\n const held: Material[] = [];\n for (const entry of value) {\n if (typeof entry !== 'object' || entry === null) return null;\n const file = entry as Record<string, unknown>;\n if (typeof file.path !== 'string') return null;\n if (file.content !== null && typeof file.content !== 'string') return null;\n if (file.revision !== null && file.revision !== undefined && typeof file.revision !== 'string')\n return null;\n let path: string;\n try {\n path = roomLocalPath(file.path, handle);\n } catch {\n return null;\n }\n held.push({\n path,\n content: file.content,\n revision: typeof file.revision === 'string' ? file.revision : null,\n });\n }\n return held;\n}\n\nfunction affectedOf(held: readonly Material[]): Readonly<Record<string, string>> {\n const affected: Record<string, string> = {};\n for (const entry of held) {\n if (entry.content !== null) affected[entry.path] = entry.content;\n }\n return affected;\n}\n\nexport function mutationOutcome(\n status: number,\n body: unknown,\n locator: string,\n handle: string | undefined,\n): MutationResult {\n const refusal = doorRefusal(body);\n if (refusal !== null && refusal.code === 'rate_limited') {\n const reset = refusal.fields.retry_at;\n return {\n kind: 'retryable-refusal',\n code: refusal.code,\n fields: refusal.fields,\n ...(typeof reset === 'string' ? { reset } : {}),\n };\n }\n if (refusal !== null && refusal.code === 'operation_expired') return { kind: 'expired' };\n if (refusal !== null && refusal.code === 'edit_conflict') {\n const { current, ...fields } = refusal.fields;\n const held = material(current, handle) ?? [];\n return { kind: 'conflicted', affected: affectedOf(held), code: refusal.code, fields };\n }\n if (refusal !== null && status === 404) {\n return scopedRefusal(locator, 'undisclosed', refusal);\n }\n const classified = classifyDoor(status, body, locator);\n if (classified !== null && classified.kind !== 'scoped-refusal') {\n return classified.kind === 'beyond-horizon' ? { kind: 'transport-uncertainty' } : classified;\n }\n if (classified !== null && status === 403) return classified;\n if (refusal !== null && status >= 400) {\n return { kind: 'rejected', affected: {}, code: refusal.code, fields: refusal.fields };\n }\n if (status !== 200 || typeof body !== 'object' || body === null) {\n return { kind: 'transport-uncertainty' };\n }\n const held = body as Record<string, unknown>;\n if (typeof held.position !== 'string') return { kind: 'transport-uncertainty' };\n const contents = material(held.contents, handle);\n if (contents === null) return { kind: 'transport-uncertainty' };\n const documents: Record<string, string> = {};\n const revisions: Record<string, string> = {};\n const removals: string[] = [];\n for (const entry of contents) {\n if (entry.content === null || entry.revision === null) {\n removals.push(entry.path);\n continue;\n }\n documents[entry.path] = entry.content;\n revisions[entry.path] = entry.revision;\n }\n return {\n kind: 'accepted',\n roomVersion: held.position,\n documents,\n revisions,\n removals: removals.sort(),\n };\n}\n\nexport function rejectedMapping(mapping: Extract<ChangeMapping, { kind: 'unmapped' }>) {\n return {\n kind: 'rejected' as const,\n affected: {},\n code: mapping.rule,\n fields: { path: mapping.path },\n };\n}\n\nexport function revisionBody(input: {\n path: string;\n handle: string | undefined;\n revision?: string;\n pageToken?: string;\n}): Record<string, unknown> {\n return {\n path: nativePath(input.path, input.handle),\n ...(input.revision === undefined ? {} : { revision: input.revision }),\n ...(input.pageToken === undefined ? {} : { before: Number(input.pageToken) }),\n };\n}\n\nexport function historyOutcome(\n status: number,\n body: unknown,\n locator: string,\n request: { path: string; revision?: string },\n): HistoryResult {\n const classified = classifyDoor(status, body, locator);\n if (classified !== null) {\n return classified.kind === 'beyond-horizon' ? { kind: 'transport-uncertainty' } : classified;\n }\n if (status !== 200 || typeof body !== 'object' || body === null) {\n return { kind: 'transport-uncertainty' };\n }\n const held = body as Record<string, unknown>;\n if (!Array.isArray(held.revisions)) return { kind: 'transport-uncertainty' };\n const entries: Record<string, unknown>[] = [];\n for (const entry of held.revisions) {\n if (typeof entry !== 'object' || entry === null) return { kind: 'transport-uncertainty' };\n entries.push(entry as Record<string, unknown>);\n }\n if (request.revision !== undefined) {\n const named = entries[0];\n if (named === undefined) return { kind: 'no-history' };\n if (named.unavailable === true) {\n return {\n kind: 'scoped-refusal',\n locator,\n scope: 'content',\n code: 'retained_history_unavailable',\n fields: { path: request.path, revision: request.revision },\n };\n }\n if (typeof named.content !== 'string') return { kind: 'transport-uncertainty' };\n return { kind: 'revision', content: named.content };\n }\n if (entries.length === 0) return { kind: 'no-history' };\n const revisions: HistoryRevision[] = [];\n for (const entry of entries) {\n if (\n typeof entry.revision !== 'string' ||\n typeof entry.author_user !== 'string' ||\n typeof entry.created_at !== 'string'\n ) {\n return { kind: 'transport-uncertainty' };\n }\n revisions.push({\n revision: entry.revision,\n author: entry.author_user,\n time: entry.created_at,\n });\n }\n const next = held.next_before;\n return {\n kind: 'history',\n revisions,\n ...(typeof next === 'number' ? { pageToken: String(next) } : {}),\n };\n}\n"],"names":["sha256Hex","textBytes","nativePath","roomLocalPath","classifyDoor","doorRefusal","scopedRefusal","INLINE_BODY_LIMIT_BYTES","UPLOAD_LINE_BYTES","UPLOAD_BYTES_MAX","priorField","batch","path","name","preconditions","find","precondition","kind","priorSection","priorPreamble","priorAbsence","priorExistence","held","undefined","base","revision","typedCreate","change","type","fields","length","op","sections","operationOf","handle","prior","rule","operation","field","value","section","content","created","existence","to","houseChanges","changes","mapped","push","batchPaths","Set","flatMap","String","sort","deltaBody","JSON","stringify","deltaBytes","delta","uploadable","bytes","deltaDigest","material","Array","isArray","entry","file","affectedOf","affected","mutationOutcome","status","body","locator","refusal","code","reset","retry_at","current","classified","position","contents","documents","revisions","removals","roomVersion","rejectedMapping","mapping","revisionBody","input","pageToken","before","Number","historyOutcome","request","entries","named","unavailable","scope","author_user","created_at","author","time","next","next_before"],"mappings":"AAQA,SAASA,SAAS,EAAEC,SAAS,QAAQ,cAAc;AACnD,SAASC,UAAU,EAAEC,aAAa,QAAQ,WAAW;AACrD,SAASC,YAAY,EAAEC,WAAW,EAAEC,aAAa,QAAQ,eAAe;AAExE,OAAO,MAAMC,0BAA0B,IAAI,OAAO,KAAK;AAEvD,OAAO,MAAMC,oBAAoB,GAAG;AAEpC,OAAO,MAAMC,mBAAmB,KAAK,OAAO,OAAOD,kBAAkB;AAUrE,SAASE,WAAWC,KAAkB,EAAEC,IAAY,EAAEC,IAAY;IAChE,OAAOF,MAAMG,aAAa,CAACC,IAAI,CAC7B,CAACC,eACCA,aAAaC,IAAI,KAAK,WAAWD,aAAaJ,IAAI,KAAKA,QAAQI,aAAaH,IAAI,KAAKA;AAE3F;AAEA,SAASK,aAAaP,KAAkB,EAAEC,IAAY,EAAEC,IAAY;IAClE,OAAOF,MAAMG,aAAa,CAACC,IAAI,CAC7B,CAACC,eACCA,a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,KAAK,YAC1B,OAAOwC,MAAMiC,WAAW,KAAK,YAC7B,OAAOjC,MAAMkC,UAAU,KAAK,UAC5B;YACA,OAAO;gBAAElF,MAAM;YAAwB;QACzC;QACAiE,UAAUlC,IAAI,CAAC;YACbvB,UAAUwC,MAAMxC,QAAQ;YACxB2E,QAAQnC,MAAMiC,WAAW;YACzBG,MAAMpC,MAAMkC,UAAU;QACxB;IACF;IACA,MAAMG,OAAOhF,KAAKiF,WAAW;IAC7B,OAAO;QACLtF,MAAM;QACNiE;QACA,GAAI,OAAOoB,SAAS,WAAW;YAAEb,WAAWrC,OAAOkD;QAAM,IAAI,CAAC,CAAC;IACjE;AACF"}
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/write.ts"],"sourcesContent":["import type {\n Change,\n ChangeBatch,\n HistoryResult,\n HistoryRevision,\n MutationResult,\n Precondition,\n} from '@agentshouse/mdruntime';\nimport { sha256Hex, textBytes } from './digest.js';\nimport { nativePath, roomLocalPath } from './map.js';\nimport { classifyDoor, doorRefusal, scopedRefusal } from './refusal.js';\nimport { readPosition, roomVersion } from './version.js';\n\nexport const INLINE_BODY_LIMIT_BYTES = 4 * 1024 * 1024;\n\nexport const UPLOAD_LINE_BYTES = 37;\n\nexport const UPLOAD_BYTES_MAX = 32 * 1024 * 1024 - UPLOAD_LINE_BYTES;\n\nexport type HouseOperation = Readonly<Record<string, unknown>>;\n\nexport type ChangeMapping =\n | { kind: 'changes'; changes: readonly HouseOperation[] }\n | { kind: 'unmapped'; path: string; rule: string };\n\ntype Existence = { base: string } | { kind: 'presence' };\n\nfunction priorField(batch: ChangeBatch, path: string, name: string) {\n return batch.preconditions.find(\n (precondition): precondition is Extract<Precondition, { kind: 'field' }> =>\n precondition.kind === 'field' && precondition.path === path && precondition.name === name,\n );\n}\n\nfunction priorSection(batch: ChangeBatch, path: string, name: string) {\n return batch.preconditions.find(\n (precondition): precondition is Extract<Precondition, { kind: 'section' }> =>\n precondition.kind === 'section' && precondition.path === path && precondition.name === name,\n );\n}\n\nfunction priorPreamble(batch: ChangeBatch, path: string) {\n return batch.preconditions.find(\n (precondition): precondition is Extract<Precondition, { kind: 'preamble' }> =>\n precondition.kind === 'preamble' && precondition.path === path,\n );\n}\n\nfunction priorAbsence(batch: ChangeBatch, path: string) {\n return batch.preconditions.find(\n (precondition) => precondition.kind === 'absent' && precondition.path === path,\n );\n}\n\nfunction priorExistence(batch: ChangeBatch, path: string): Existence | undefined {\n const precondition = batch.preconditions.find(\n (held) => held.path === path && (held.kind === 'revision' || held.kind === 'present'),\n );\n if (precondition === undefined) return undefined;\n return precondition.kind === 'revision' ? { base: precondition.revision } : { kind: 'presence' };\n}\n\nfunction created(change: Extract<Change, { kind: 'create' }>, path: string): HouseOperation | null {\n if ('content' in change) return { op: 'create', path, content: change.content };\n const { type, ...fields } = change.fields;\n if (typeof type !== 'string' || type.length === 0) return null;\n return { op: 'create_typed', path, type, fields, sections: change.sections };\n}\n\ntype MappedOperation = { operation: HouseOperation } | { rule: string };\n\nfunction operationOf(\n batch: ChangeBatch,\n change: Change,\n handle: string | undefined,\n): MappedOperation {\n const path = nativePath(change.path, handle);\n if (change.kind === 'field') {\n const prior = priorField(batch, change.path, change.name);\n if (prior === undefined) return { rule: 'precondition-missing' };\n return {\n operation: {\n op: 'set_field',\n path,\n field: change.name,\n value: change.value,\n ...(prior.value === undefined ? {} : { base: prior.value }),\n },\n };\n }\n if (change.kind === 'section') {\n const prior = priorSection(batch, change.path, change.name);\n if (prior === undefined) return { rule: 'precondition-missing' };\n return {\n operation: {\n op: 'replace_section',\n path,\n section: change.name,\n base: prior.value,\n content: change.value,\n },\n };\n }\n if (change.kind === 'preamble') {\n const prior = priorPreamble(batch, change.path);\n if (prior === undefined) return { rule: 'precondition-missing' };\n return {\n operation: { op: 'replace_preamble', path, base: prior.value, content: change.value },\n };\n }\n if (change.kind === 'create') {\n if (priorAbsence(batch, change.path) === undefined) return { rule: 'precondition-missing' };\n const operation = created(change, path);\n return operation === null ? { rule: 'type-missing' } : { operation };\n }\n const existence = priorExistence(batch, change.path);\n if (existence === undefined) return { rule: 'precondition-missing' };\n if (!('base' in existence)) return { rule: 'presence-base-unrepresentable' };\n if (change.kind === 'replace') {\n return { operation: { op: 'replace', path, base: existence.base, content: change.content } };\n }\n if (change.kind === 'move') {\n if (priorAbsence(batch, change.to) === undefined) return { rule: 'precondition-missing' };\n return {\n operation: { op: 'rename', path, to: nativePath(change.to, handle), base: existence.base },\n };\n }\n return { operation: { op: 'remove', path, base: existence.base } };\n}\n\nexport function houseChanges(batch: ChangeBatch, handle: string | undefined): ChangeMapping {\n const changes: HouseOperation[] = [];\n for (const change of batch.changes) {\n const mapped = operationOf(batch, change, handle);\n if ('rule' in mapped) return { kind: 'unmapped', path: change.path, rule: mapped.rule };\n changes.push(mapped.operation);\n }\n return { kind: 'changes', changes };\n}\n\nexport type OperationHead = {\n readonly operation_id: string;\n readonly app_ref?: string;\n readonly release?: string;\n};\n\nexport function operationHead(batch: ChangeBatch): OperationHead {\n const writer = batch.writtenBy;\n return writer === undefined\n ? { operation_id: batch.id }\n : { operation_id: batch.id, app_ref: writer.app, release: writer.release };\n}\n\nexport function batchPaths(changes: readonly HouseOperation[]): readonly string[] {\n return [\n ...new Set(\n changes.flatMap((change) =>\n change.op === 'rename' ? [String(change.path), String(change.to)] : [String(change.path)],\n ),\n ),\n ].sort();\n}\n\nexport function deltaBody(changes: readonly HouseOperation[]): string {\n return JSON.stringify({ changes });\n}\n\nexport function deltaBytes(delta: string): number {\n return textBytes(delta);\n}\n\nexport function uploadable(bytes: number): boolean {\n return bytes > INLINE_BODY_LIMIT_BYTES && bytes <= UPLOAD_BYTES_MAX;\n}\n\nexport function deltaDigest(delta: string): Promise<string> {\n return sha256Hex(delta);\n}\n\ntype Material = { path: string; content: string | null; revision: string | null };\n\nfunction material(value: unknown, handle: string | undefined): readonly Material[] | null {\n if (!Array.isArray(value)) return null;\n const held: Material[] = [];\n for (const entry of value) {\n if (typeof entry !== 'object' || entry === null) return null;\n const file = entry as Record<string, unknown>;\n if (typeof file.path !== 'string') return null;\n if (file.content !== null && typeof file.content !== 'string') return null;\n if (file.revision !== null && file.revision !== undefined && typeof file.revision !== 'string')\n return null;\n let path: string;\n try {\n path = roomLocalPath(file.path, handle);\n } catch {\n return null;\n }\n held.push({\n path,\n content: file.content,\n revision: typeof file.revision === 'string' ? file.revision : null,\n });\n }\n return held;\n}\n\nfunction affectedOf(held: readonly Material[]): Readonly<Record<string, string>> {\n const affected: Record<string, string> = {};\n for (const entry of held) {\n if (entry.content !== null) affected[entry.path] = entry.content;\n }\n return affected;\n}\n\nexport function mutationOutcome(\n status: number,\n body: unknown,\n locator: string,\n handle: string | undefined,\n): MutationResult {\n const refusal = doorRefusal(body);\n if (refusal !== null && refusal.code === 'rate_limited') {\n const reset = refusal.fields.retry_at;\n return {\n kind: 'retryable-refusal',\n code: refusal.code,\n fields: refusal.fields,\n ...(typeof reset === 'string' ? { reset } : {}),\n };\n }\n if (refusal !== null && refusal.code === 'operation_expired') return { kind: 'expired' };\n if (refusal !== null && refusal.code === 'edit_conflict') {\n const { current, ...fields } = refusal.fields;\n const held = material(current, handle) ?? [];\n return { kind: 'conflicted', affected: affectedOf(held), code: refusal.code, fields };\n }\n if (refusal !== null && status === 404) {\n return scopedRefusal(locator, 'undisclosed', refusal);\n }\n const classified = classifyDoor(status, body, locator);\n if (classified !== null && classified.kind !== 'scoped-refusal') {\n return classified.kind === 'beyond-horizon' ? { kind: 'expired' } : classified;\n }\n if (classified !== null && status === 403) return classified;\n if (refusal !== null && status >= 400) {\n return { kind: 'rejected', affected: {}, code: refusal.code, fields: refusal.fields };\n }\n if (status !== 200 || typeof body !== 'object' || body === null) {\n return { kind: 'transport-uncertainty' };\n }\n const held = body as Record<string, unknown>;\n const at = readPosition(held);\n if (at === null) return { kind: 'transport-uncertainty' };\n const contents = material(held.contents, handle);\n if (contents === null) return { kind: 'transport-uncertainty' };\n const documents: Record<string, string> = {};\n const revisions: Record<string, string> = {};\n const removals: string[] = [];\n for (const entry of contents) {\n if (entry.content === null || entry.revision === null) {\n removals.push(entry.path);\n continue;\n }\n documents[entry.path] = entry.content;\n revisions[entry.path] = entry.revision;\n }\n return {\n kind: 'accepted',\n roomVersion: roomVersion(at),\n documents,\n revisions,\n removals: removals.sort(),\n };\n}\n\nexport function rejectedMapping(mapping: Extract<ChangeMapping, { kind: 'unmapped' }>) {\n return {\n kind: 'rejected' as const,\n affected: {},\n code: mapping.rule,\n fields: { path: mapping.path },\n };\n}\n\nexport function revisionBody(input: {\n path: string;\n handle: string | undefined;\n revision?: string;\n pageToken?: string;\n}): Record<string, unknown> {\n return {\n path: nativePath(input.path, input.handle),\n ...(input.revision === undefined ? {} : { revision: input.revision }),\n ...(input.pageToken === undefined ? {} : { before: Number(input.pageToken) }),\n };\n}\n\nexport function historyOutcome(\n status: number,\n body: unknown,\n locator: string,\n request: { path: string; revision?: string },\n): HistoryResult {\n const classified = classifyDoor(status, body, locator);\n if (classified !== null) {\n return classified.kind === 'beyond-horizon' ? { kind: 'transport-uncertainty' } : classified;\n }\n if (status !== 200 || typeof body !== 'object' || body === null) {\n return { kind: 'transport-uncertainty' };\n }\n const held = body as Record<string, unknown>;\n if (!Array.isArray(held.revisions)) return { kind: 'transport-uncertainty' };\n const entries: Record<string, unknown>[] = [];\n for (const entry of held.revisions) {\n if (typeof entry !== 'object' || entry === null) return { kind: 'transport-uncertainty' };\n entries.push(entry as Record<string, unknown>);\n }\n if (request.revision !== undefined) {\n const named = entries[0];\n if (named === undefined) return { kind: 'no-history' };\n if (named.unavailable === true) {\n return {\n kind: 'scoped-refusal',\n locator,\n scope: 'content',\n code: 'retained_history_unavailable',\n fields: { path: request.path, revision: request.revision },\n };\n }\n if (typeof named.content !== 'string') return { kind: 'transport-uncertainty' };\n return { kind: 'revision', content: named.content };\n }\n if (entries.length === 0) return { kind: 'no-history' };\n const revisions: HistoryRevision[] = [];\n for (const entry of entries) {\n if (\n typeof entry.revision !== 'string' ||\n typeof entry.author_user !== 'string' ||\n typeof entry.created_at !== 'string'\n ) {\n return { kind: 'transport-uncertainty' };\n }\n revisions.push({\n revision: entry.revision,\n author: entry.author_user,\n time: entry.created_at,\n });\n }\n const next = held.next_before;\n return {\n kind: 'history',\n revisions,\n ...(typeof next === 'number' ? { pageToken: String(next) } : {}),\n };\n}\n"],"names":["sha256Hex","textBytes","nativePath","roomLocalPath","classifyDoor","doorRefusal","scopedRefusal","readPosition","roomVersion","INLINE_BODY_LIMIT_BYTES","UPLOAD_LINE_BYTES","UPLOAD_BYTES_MAX","priorField","batch","path","name","preconditions","find","precondition","kind","priorSection","priorPreamble","priorAbsence","priorExistence","held","undefined","base","revision","created","change","op","content","type","fields","length","sections","operationOf","handle","prior","rule","operation","field","value","section","existence","to","houseChanges","changes","mapped","push","operationHead","writer","writtenBy","operation_id","id","app_ref","app","release","batchPaths","Set","flatMap","String","sort","deltaBody","JSON","stringify","deltaBytes","delta","uploadable","bytes","deltaDigest","material","Array","isArray","entry","file","affectedOf","affected","mutationOutcome","status","body","locator","refusal","code","reset","retry_at","current","classified","at","contents","documents","revisions","removals","rejectedMapping","mapping","revisionBody","input","pageToken","before","Number","historyOutcome","request","entries","named","unavailable","scope","author_user","created_at","author","time","next","next_before"],"mappings":"AAQA,SAASA,SAAS,EAAEC,SAAS,QAAQ,cAAc;AACnD,SAASC,UAAU,EAAEC,aAAa,QAAQ,WAAW;AACrD,SAASC,YAAY,EAAEC,WAAW,EAAEC,aAAa,QAAQ,eAAe;AACxE,SAASC,YAAY,EAAEC,WAAW,QAAQ,eAAe;AAEzD,OAAO,MAAMC,0BAA0B,IAAI,OAAO,KAAK;AAEvD,OAAO,MAAMC,oBAAoB,GAAG;AAEpC,OAAO,MAAMC,mBAAmB,KAAK,OAAO,OAAOD,kBAAkB;AAUrE,SAASE,WAAWC,KAAkB,EAAEC,IAAY,EAAEC,IAAY;IAChE,OAAOF,MAAMG,aAAa,CAACC,IAAI,CAC7B,CAACC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QACrD,IAAIoF,MAAMC,WAAW,KAAK,MAAM;YAC9B,OAAO;gBACLrF,MAAM;gBACN8D;gBACAwB,OAAO;gBACPtB,MAAM;gBACNlD,QAAQ;oBAAEnB,MAAMuF,QAAQvF,IAAI;oBAAEa,UAAU0E,QAAQ1E,QAAQ;gBAAC;YAC3D;QACF;QACA,IAAI,OAAO4E,MAAMxE,OAAO,KAAK,UAAU,OAAO;YAAEZ,MAAM;QAAwB;QAC9E,OAAO;YAAEA,MAAM;YAAYY,SAASwE,MAAMxE,OAAO;QAAC;IACpD;IACA,IAAIuE,QAAQpE,MAAM,KAAK,GAAG,OAAO;QAAEf,MAAM;IAAa;IACtD,MAAMwE,YAA+B,EAAE;IACvC,KAAK,MAAMjB,SAAS4B,QAAS;QAC3B,IACE,OAAO5B,MAAM/C,QAAQ,KAAK,YAC1B,OAAO+C,MAAMgC,WAAW,KAAK,YAC7B,OAAOhC,MAAMiC,UAAU,KAAK,UAC5B;YACA,OAAO;gBAAExF,MAAM;YAAwB;QACzC;QACAwE,UAAU1C,IAAI,CAAC;YACbtB,UAAU+C,MAAM/C,QAAQ;YACxBiF,QAAQlC,MAAMgC,WAAW;YACzBG,MAAMnC,MAAMiC,UAAU;QACxB;IACF;IACA,MAAMG,OAAOtF,KAAKuF,WAAW;IAC7B,OAAO;QACL5F,MAAM;QACNwE;QACA,GAAI,OAAOmB,SAAS,WAAW;YAAEb,WAAWpC,OAAOiD;QAAM,IAAI,CAAC,CAAC;IACjE;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/mdruntime-adapter",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.30",
|
|
4
4
|
"description": "Agents House Adapter for the MD Runtime",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"url": "https://github.com/agentshouse/mdruntime/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@agentshouse/mdmodel": "0.1.0-alpha.
|
|
37
|
-
"@agentshouse/mdruntime": "0.1.0-alpha.
|
|
36
|
+
"@agentshouse/mdmodel": "0.1.0-alpha.15",
|
|
37
|
+
"@agentshouse/mdruntime": "0.1.0-alpha.34"
|
|
38
38
|
}
|
|
39
39
|
}
|