@agentshouse/mdruntime-adapter 0.1.0-alpha.17 → 0.1.0-alpha.18

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 CHANGED
@@ -7,7 +7,7 @@ enforcement.
7
7
  ## The MD Runtime API
8
8
 
9
9
  App code reaches the MD Runtime through the remote client. The surfaces are
10
- Rooms, Slots, Query, Observe, Types, Draft, Save, Queue, History, Call, Log,
10
+ Rooms, Slots, Query, Observe, Types, Room Draft, Save, History, Call, Log,
11
11
  storage loss, the reported persistence answer, deployment facts, Sync Status, reauthorization,
12
12
  conversation, the chat draft, and Presentation State.
13
13
 
@@ -22,7 +22,7 @@ queued.
22
22
  Slots answers each Slot the Provider declares, in its order, with its entries
23
23
  in order, each a Room and its segment; a Room two Slots list is the same Room.
24
24
 
25
- Rooms, Slots, Query, Observe, Types, Draft, and Save never touch the network.
25
+ Rooms, Slots, Query, Observe, Types, Room Draft, and Save never touch the network.
26
26
  History and Call go to the Provider through the Adapter. Every member of the
27
27
  client is asynchronous. Results are detached snapshots. Nothing in this
28
28
  surface returns the authorization, performs a request the App's code
@@ -36,24 +36,40 @@ owns their boundary.
36
36
  The in-memory Adapter at `@agentshouse/mdruntime/memory` is for tests and
37
37
  ships in no bundle.
38
38
 
39
- ## Draft, Save, and outcome rules
40
-
41
- A Draft is durable: it survives reload and navigation. A Room that Discovery
42
- stops listing takes its Drafts, its queue and their outcomes with it. Save takes structured
43
- changes, validates locally, and on success appends one Change Batch to that
44
- Room's queue. A local validation failure leaves the Draft and creates
45
- nothing.
39
+ ## Room Draft, Save, and outcome rules
40
+
41
+ The MD Runtime owns one Room Draft per Room and Path, shared by every App and
42
+ tab. It is durable: it survives reload and navigation. A Room that Discovery
43
+ stops listing takes its Room Drafts, its queue and their outcomes with it.
44
+ Write a Room Draft with `roomDraft.write(room, path, revision, parts)`, naming
45
+ the revision you read, or `null` when there was none, and every part it should
46
+ now change: fields, sections and the preamble, or the whole Markdown, a
47
+ creation, a move, or a removal. A part new to the Room Draft names its base,
48
+ the value you showed when it was opened; the MD Runtime keeps a part's first
49
+ base. A write or a discard from an older revision is refused as `stale` with
50
+ the current Room Draft; read it and write again.
51
+
52
+ Save takes one Room and the Room Drafts of it to save, each with its revision,
53
+ validates locally, and on success appends one Change Batch to that Room's
54
+ queue and removes those Room Drafts. It is refused as `stale`, as
55
+ `changed-underneath` naming each part whose base no longer matches the visible
56
+ state, or by a local validation rule, and then creates nothing and leaves every
57
+ Room Draft in place. A directory move is a move part on each Document beneath
58
+ it, saved together.
46
59
 
47
60
  Outcomes follow the Provider's answer. Accepted advances the confirmed
48
- layer. Conflicted and Rejected leave the head in place, carry the affected
49
- current state and the Provider's structured refusal code and fields as
50
- returned, and block that Room's queue. The App's code resolves a head by
51
- discarding it or by saving a corrected Change Batch that replaces it in
52
- place. Transport failure and Provider unavailability keep work Pending and
53
- do not infer a rejection. A refusal the Provider marks retryable stays
54
- Pending until the reset it names; the MD Runtime retries the same Change
55
- Batch identity and payload and never infers an outcome from transport
56
- uncertainty. The MD Runtime never combines, reorders, or rebases.
61
+ layer. Conflicted and Rejected, an expired outcome record, and a change that no
62
+ longer applies over the Room each leave the queue and return as Room Drafts on
63
+ the Documents they changed, marked with why: the Provider's structured refusal
64
+ code and fields as returned, not known to have applied, or withdrawn locally.
65
+ The rest of the queue keeps synchronizing, and Sync Status requires attention
66
+ until each returned Room Draft is saved again or discarded. `outcome` answers
67
+ the saved Change Batch's outcome, and `null` while it is Pending. Transport
68
+ failure and Provider unavailability keep work Pending and do not infer a
69
+ rejection. A refusal the Provider marks retryable stays Pending until the reset
70
+ it names; the MD Runtime retries the same Change Batch identity and payload and
71
+ never infers an outcome from transport uncertainty. The MD Runtime never
72
+ combines, reorders, or rebases.
57
73
 
58
74
  ## The neutrality rule
59
75
 
@@ -1 +1 @@
1
- {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO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b,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
@@ -26,7 +26,12 @@ function priorExistence(batch, path) {
26
26
  kind: 'presence'
27
27
  };
28
28
  }
29
- function typedCreate(change, path) {
29
+ function created(change, path) {
30
+ if ('content' in change) return {
31
+ op: 'create',
32
+ path,
33
+ content: change.content
34
+ };
30
35
  const { type, ...fields } = change.fields;
31
36
  if (typeof type !== 'string' || type.length === 0) return null;
32
37
  return {
@@ -89,11 +94,11 @@ function operationOf(batch, change, handle) {
89
94
  if (priorAbsence(batch, change.path) === undefined) return {
90
95
  rule: 'precondition-missing'
91
96
  };
92
- const created = typedCreate(change, path);
93
- return created === null ? {
97
+ const operation = created(change, path);
98
+ return operation === null ? {
94
99
  rule: 'type-missing'
95
100
  } : {
96
- operation: created
101
+ operation
97
102
  };
98
103
  }
99
104
  const existence = priorExistence(batch, change.path);
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';\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 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 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","typedCreate","change","type","fields","length","op","sections","operationOf","handle","prior","rule","operation","field","value","section","content","created","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,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,aAAaC,IAAI,KAAK,aAAaD,aAAaJ,IAAI,KAAKA,QAAQI,aAAaH,IAAI,KAAKA;AAE7F;AAEA,SAASM,cAAcR,KAAkB,EAAEC,IAAY;IACrD,OAAOD,MAAMG,aAAa,CAACC,IAAI,CAC7B,CAACC,eACCA,aAAaC,IAAI,KAAK,cAAcD,aAAaJ,IAAI,KAAKA;AAEhE;AAEA,SAASQ,aAAaT,KAAkB,EAAEC,IAAY;IACpD,OAAOD,MAAMG,aAAa,CAACC,IAAI,CAC7B,CAACC,eAAiBA,aAAaC,IAAI,KAAK,YAAYD,aAAaJ,IAAI,KAAKA;AAE9E;AAEA,SAASS,eAAeV,KAAkB,EAAEC,IAAY;IACtD,MAAMI,eAAeL,MAAMG,aAAa,CAACC,IAAI,CAC3C,CAACO,OAASA,KAAKV,IAAI,KAAKA,QAASU,CAAAA,KAAKL,IAAI,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AM;QACNyE;QACA,GAAI,OAAOmB,SAAS,WAAW;YAAEb,WAAWpC,OAAOiD;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,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,aAAaC,IAAI,KAAK,aAAaD,aAAaJ,IAAI,KAAKA,QAAQI,aAAaH,IAAI,KAAKA;AAE7F;AAEA,SAASM,cAAcR,KAAkB,EAAEC,IAA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AAMxE,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.17",
3
+ "version": "0.1.0-alpha.18",
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.13",
37
- "@agentshouse/mdruntime": "0.1.0-alpha.22"
36
+ "@agentshouse/mdmodel": "0.1.0-alpha.14",
37
+ "@agentshouse/mdruntime": "0.1.0-alpha.24"
38
38
  }
39
39
  }