@alma-harness/conversation 0.9.0 → 0.10.1
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/README.md +9 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -263,3 +263,12 @@ maps all remaining legacy cases and their explicitly superseded contracts.
|
|
|
263
263
|
Malformed cap configuration rejects with TypeError from the canonical financial
|
|
264
264
|
normalizer, replacing legacy AgentConfigError. Invalid path scope rejects with
|
|
265
265
|
InvalidScopeError before admission. Neither error authorizes execution.
|
|
266
|
+
|
|
267
|
+
Tool selection remains host-owned at the model-request boundary. The governed
|
|
268
|
+
step projection retains `toolChoice` in execution controls, while `step:pre`
|
|
269
|
+
cannot inject or change it, on parent or delegated steps. No global conversation
|
|
270
|
+
selection setting is added: one-call structured extraction uses the existing
|
|
271
|
+
`createGovernedStepRunner` from `@alma-harness/single-call` without session append,
|
|
272
|
+
recall or automatic memory extraction.
|
|
273
|
+
The text-only `ctx.models.direct` gateway rejects a supplied toolChoice rather
|
|
274
|
+
than discarding it; invalid child work retains the normal uncertain lifecycle.
|
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ function execution(c, root, fence, signal, lifecycle, observer) {
|
|
|
72
72
|
await preflight();
|
|
73
73
|
lifecycle.check();
|
|
74
74
|
const slot = String(++sequence), callId = crypto.randomUUID(), operationKey = crypto.randomUUID();
|
|
75
|
-
const controls = { maxTokens: request.maxTokens, ...request.reasoning ? { reasoning: request.reasoning } : {}, ...request.cache !== void 0 ? { cache: request.cache } : {}, ...request.temperature !== void 0 ? { temperature: request.temperature } : {} };
|
|
75
|
+
const controls = { maxTokens: request.maxTokens, ...request.toolChoice !== void 0 ? { toolChoice: request.toolChoice } : {}, ...request.reasoning ? { reasoning: request.reasoning } : {}, ...request.cache !== void 0 ? { cache: request.cache } : {}, ...request.temperature !== void 0 ? { temperature: request.temperature } : {} };
|
|
76
76
|
const v = await runner.run({
|
|
77
77
|
fence,
|
|
78
78
|
signal,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/config.ts","../src/execution.ts","../src/input.ts","../src/observation.ts","../src/stream.ts"],"sourcesContent":["import { equalExecution, ExecutionConflictError, ExecutionResultPolicyError, normalizeExecutionEvidence, settlementIdentifier, settlementScope, type ExecutionResultRecord, type Scope } from \"@alma-harness/core\";\nimport { normalizeOperationRoot, type OperationRootInput, type OperationSessionFence } from \"@alma-harness/execution\";\nimport { createInternals, NO_EMIT, runTurnBody } from \"@alma-harness/loop/internal\";\nimport type { TurnResult } from \"@alma-harness/loop\";\nimport { engineConfig, config } from \"./config\";\nimport { execution } from \"./execution\";\nimport { claimCanonical, existingAdmission, normalizeTurnInput } from \"./input\";\nimport type { ModelChoice } from \"@alma-harness/core\";\nexport { conversationRootKey, createConversationDescriptor, type ConversationDescriptorConfig } from \"./input\";\nimport type { ConversationConfig, ConversationInput, ConversationRunner, ConversationView } from \"./types\";\nexport type { SimpleConversationInput, ConversationConfig, ConversationInput, ConversationRunner, ConversationView, ConversationTool, ConversationToolCtx } from \"./types\";\nimport { observation, type Observation } from \"./observation\";\nexport { ConversationStreamResyncError } from \"./stream\";\nexport type { ConversationEvent, ConversationStream } from \"./types\";\nconst pending = (): ConversationView => ({ status:\"reconciliation_required\" });\nconst interrupted = () => new Error(\"Conversation requires reconciliation\");\nexport function createConversationRunner(value: ConversationConfig): ConversationRunner {\n const c = config(value);\n const binding = (root:OperationRootInput) => ({ scope:root.scope,callId:root.key,sessionId:root.sessionId,sensitivity:root.maxSensitivity,retentionMs:root.request!.resultRetentionMs });\n async function read(scope:Scope, key:string): Promise<ConversationView|null> {\n const s = settlementScope(scope), k = settlementIdentifier(key), a = await c.admissions.get(s,k);\n if (!a) return null;\n if (a.status !== \"released\") return { status:a.status === \"active\" && a.input.deadlineAt > new Date().toISOString() ? \"in_progress\" : \"reconciliation_required\" };\n if (a.resolutionId || !a.input.request) return pending();\n const root = await c.step.trees.get(s,k);\n if (!root || root.status !== \"closed\" || !equalExecution(root.input,a.input)) return pending();\n let stored:ExecutionResultRecord|null;\n try { stored = await c.rootResults.get(s,k); } catch (e) { if (e instanceof ExecutionResultPolicyError) return { status:\"unavailable\" }; throw e; }\n if (!stored || stored.state !== \"available\" || !equalExecution(stored.binding,binding(root.input)) || stored.result?.outcome !== \"success\" || stored.result.output.format !== \"json\") return { status:\"unavailable\" };\n const financial = await c.step.accounting.get(s,k);\n if (!financial || financial.reservedCalls !== financial.settledCalls || financial.rootStatus !== \"closed\") return pending();\n try {\n const data = JSON.parse(stored.result.output.text) as { version:string; rootId:string; contract:string; result:TurnResult };\n const r = data.result;\n if (data.version !== \"governed-conversation-v1\" || data.rootId !== root.input.id || data.contract !== root.input.request!.resultContractVersion || !r || r.turnId !== root.input.id || r.costUsd !== financial.costUsd || ![\"completed\",\"budget_exceeded\"].includes(r.terminalReason) || r.reply?.role !== \"assistant\" || !Array.isArray(r.reply.blocks) || r.reply.blocks.some(b => b.type === \"reasoning\") || !Number.isSafeInteger(r.steps) || r.steps < 0 || !Number.isFinite(r.durationMs) || r.durationMs < 0) return { status:\"unavailable\" };\n normalizeExecutionEvidence({ status:\"known\",usage:r.usage });\n return { status:\"completed\",result:{ ...r,replayed:true },replayed:true };\n } catch { return { status:\"unavailable\" }; }\n }\n function run(input:ConversationInput, mode: \"exact\" | \"canonical\", observer?: Observation): Promise<ConversationView> {\n const root = normalizeOperationRoot(input.root), req = root.request;\n const opts = { intent:structuredClone(input.intent),...(input.trigger ? {trigger:input.trigger} : {}),...(input.toolProfile ? {toolProfile:input.toolProfile} : {}) }, load = input.loadInput, external = input.signal;\n if (!req || req.configRevision !== c.configRevision || req.resultContractVersion !== c.resultContractVersion || req.resultRetentionMs !== c.resultRetentionMs || root.policyVersion !== c.policyVersion || !equalExecution(root.caps,c.caps) || root.maxCalls > c.maxCalls || root.maxSensitivity !== opts.intent.sensitivity || typeof load !== \"function\") throw new ExecutionConflictError();\n const controller = new AbortController(); let uncertain = false, children = 0, sealed = false, admission:OperationSessionFence|undefined;\n const poison = () => { uncertain = true; controller.abort(); };\n const check = () => { if (uncertain || sealed || controller.signal.aborted || (admission && Date.now() >= Date.parse(root.deadlineAt))) throw interrupted(); };\n function track<T>(fn:()=>Promise<T>):Promise<T> {\n const p = (async () => { check(); children++; try { return await fn(); } catch (e) { poison(); throw e; } finally { children--; } })();\n void p.catch(() => {}); return p;\n }\n const abort = () => poison();\n const timer = setTimeout(abort,c.runTimeoutMs); let deadline:ReturnType<typeof setTimeout>|undefined;\n const cancelled = new Promise<ConversationView>(resolve => controller.signal.addEventListener(\"abort\",() => resolve(pending()),{once:true}));\n external?.addEventListener(\"abort\",abort,{once:true}); if (external?.aborted) abort();\n const work = execute(); void work.catch(() => {});\n return Promise.race([work,cancelled]).finally(() => { sealed = true; clearTimeout(timer); clearTimeout(deadline); external?.removeEventListener(\"abort\",abort); });\n async function uncertainAdmission() { if (admission) { try { await c.admissions.markUncertain(admission); } catch { /* Occupancy survives this failed acknowledgement. */ } } }\n async function execute():Promise<ConversationView> {\n try {\n check();\n let mainChoice: ModelChoice | undefined;\n {\n const existing = () => existingAdmission(c.admissions, root, mode === \"canonical\", check);\n if (await existing()) return (await read(root.scope,root.key)) ?? pending();\n try {\n mainChoice = structuredClone(c.policy.resolve(structuredClone(opts.intent)));\n if (!Object.hasOwn(c.step.clients, mainChoice.model.provider) || !c.step.clients[mainChoice.model.provider]) mainChoice = undefined;\n } catch { mainChoice = undefined; }\n check();\n if (!mainChoice) {\n if (await existing()) return (await read(root.scope,root.key)) ?? pending();\n return { status:\"not_admitted\",reason:\"routing_unavailable\" };\n }\n }\n const a = mode === \"canonical\" ? await claimCanonical(c.admissions, root, check) : await c.admissions.claim(root);\n if (a.status === \"claimed\") admission = a.fence;\n check();\n if (a.status === \"busy\") return { status:\"busy\",rootKey:a.rootKey };\n if (a.status === \"existing\") return (await read(root.scope,root.key)) ?? pending();\n deadline = setTimeout(abort,Math.max(0,Date.parse(root.deadlineAt)-Date.now()));\n const claim = await c.step.trees.claim(root); check();\n if (claim.status !== \"claimed\" || !equalExecution(claim.record.input,root)) throw interrupted();\n const prepared = await c.rootResults.prepare(binding(root)); check();\n if (prepared.state !== \"pending\") throw interrupted();\n const message = structuredClone(await load()); check();\n if (message.role !== \"user\" || JSON.stringify(message).length > c.maxInputChars) throw new TypeError(\"Invalid conversation input\");\n const base = engineConfig(c), sessionStore = c.sessions;\n const guarded = async <T>(fn:()=>Promise<T>):Promise<T> => { check(); try { const result = await fn(); check(); return result; } catch (e) { poison(); throw e; } };\n // Every effect-capable hook and all asynchronous context sources are per-turn closures.\n base.hooks = (base.hooks ?? []).map(h => Object.fromEntries(Object.entries(h).filter(([,fn]) => typeof fn === \"function\").map(([key,fn]) => [key,async (...args:unknown[]) => { check(); try { const r = await (fn as (...a:unknown[])=>unknown)(...args); check(); return r; } catch (e) { poison(); throw e; } }])));\n base.sessions = { ...sessionStore, load:(s,id) => guarded(() => sessionStore.load(s,id)), append:(s,id,msgs) => guarded(() => sessionStore.append(s,id,msgs)), erase:(s,id) => sessionStore.erase(s,id), expireToolTraffic:(s,id,opts) => sessionStore.expireToolTraffic(s,id,opts) };\n // assembleRecall owns the deadline and clears it on abort, even if the source never settles.\n if (c.recall) base.recall = { build:(...args) => guarded(() => c.recall!.build(...args)) };\n if (c.media?.source) base.media = { ...c.media,source:{load:(...args) => guarded(() => c.media!.source!.load(...args))} };\n const runtime = execution(c,root,claim.fence,controller.signal,{check,poison,track,mainChoice},observer);\n const body = await runTurnBody(createInternals(base), { scope:root.scope,sessionId:root.sessionId,input:message,...opts,signal:controller.signal },observer?.emit ?? NO_EMIT,runtime);\n check();\n if (children !== 0 || ![\"completed\",\"budget_exceeded\"].includes(body.terminalReason)) throw interrupted();\n const totals = await c.step.accounting.get(root.scope,root.key); check();\n if (!totals || totals.reservedCalls !== totals.settledCalls || totals.costUsd !== body.costUsd) throw interrupted();\n await c.step.trees.close(claim.fence); check();\n const result = { outcome:\"success\" as const,stopReason:body.stopReason,output:{format:\"json\" as const,text:JSON.stringify({version:\"governed-conversation-v1\",rootId:root.id,contract:req!.resultContractVersion,result:body})} };\n await c.rootResults.put(root.scope,root.key,result); check();\n const final = await c.rootResults.get(root.scope,root.key); check();\n if (final?.state !== \"available\" || !equalExecution(final.binding,binding(root)) || !equalExecution(final.result,result)) throw interrupted();\n try { await c.admissions.finish(admission!); }\n catch {\n // Finish is attempted only AFTER proven local quiescence and durable writes.\n const released = await c.admissions.get(root.scope,root.key);\n if (!released || released.status !== \"released\" || released.resolutionId || !equalExecution(released.input,root)) throw interrupted();\n }\n return {status:\"completed\",result:body,replayed:false};\n } catch (e) {\n if (!admission && e instanceof ExecutionConflictError) throw e;\n poison(); await uncertainAdmission(); return pending();\n }\n }\n }\n return {read,streamTurn(value) {\n const normalized = normalizeTurnInput(c, value);\n const observer = observation(c, normalized.input.root, read);\n return observer.start(run(normalized.input, normalized.canonical ? \"canonical\" : \"exact\", observer));\n },async runTurn(value) {\n const normalized = normalizeTurnInput(c, value);\n return run(normalized.input, normalized.canonical ? \"canonical\" : \"exact\");\n }};\n}\n","import { normalizeBudgetCaps, settlementIdentifier as id, type ToolDefinition } from \"@alma-harness/core\";\nimport { createInternals } from \"@alma-harness/loop/internal\";\nimport type { LoopConfig } from \"@alma-harness/loop/internal\";\nimport { createGovernedStepRunner } from \"@alma-harness/single-call\";\nimport type { ConversationConfig } from \"./types\";\nexport function config(value: ConversationConfig): ConversationConfig {\n if (typeof value.step.spend?.peek !== \"function\") throw new TypeError(\"Conversation requires a spend reader\");\n if (value.rootResults === value.step.results) throw new TypeError(\"Conversation results require a separate physical namespace\");\n for (const [key, max] of Object.entries({ runTimeoutMs: 300000, resultRetentionMs: 31536000000, maxCalls: 512, maxInputChars: 64000000 })) {\n const n = value[key as keyof ConversationConfig]; if (!Number.isSafeInteger(n) || Number(n) < 1 || Number(n) > max) throw new TypeError(`Invalid conversation ${key}`);\n }\n for (const n of [value.maxSteps ?? 24, value.maxDelegateDepth ?? 2, value.maxTokens ?? 8192]) if (!Number.isSafeInteger(n) || n < 1) throw new TypeError(\"Invalid conversation technical limit\");\n for (const key of [\"policyVersion\", \"priceVersion\", \"configRevision\", \"resultContractVersion\"] as const) id(value[key]);\n if (!Array.isArray(value.consumers) || value.consumers.length > 16) throw new TypeError(\"Invalid consumers\");\n for (const client of Object.values(value.step.clients)) if (!client || client.dispatchPolicy !== \"single\" || typeof client.validate !== \"function\") throw new TypeError(\"Conversation requires single-dispatch clients\");\n const c = { ...value, caps: normalizeBudgetCaps(value.caps), prices: structuredClone(value.prices), consumers: [...new Set(value.consumers.map(id))].sort(),\n system: structuredClone(value.system), step: { ...value.step, clients: { ...value.step.clients } },\n ...(value.providerTools ? { providerTools: structuredClone(value.providerTools) } : {}),\n ...(value.profiles ? { profiles: structuredClone(value.profiles) } : {}),\n ...(value.tools ? { tools: value.tools.map(t => ({ ...t, ...(t.jsonSchema ? { jsonSchema: structuredClone(t.jsonSchema) } : {}) })) } : {}),\n ...(value.hooks ? { hooks: value.hooks.map(h => ({ ...h })) } : {}),\n ...(value.longContext ? { longContext: { ...value.longContext } } : {}), ...(value.media ? { media: { ...value.media } } : {}) };\n createGovernedStepRunner(c.step);\n createInternals(engineConfig(c)); // Registry/config errors precede claims.\n return c;\n}\nexport function engineConfig(c: ConversationConfig): LoopConfig {\n // The internal governed dispatch branch supplies the declared extended gateway.\n return { ...c, ...(c.tools ? { tools: c.tools as ToolDefinition[] } : {}), clients: c.step.clients, audit: c.step.audit };\n}\n","import { BudgetExceededError, equalExecution, normalizeSpendTotals, type Block, type BudgetCapName, type ModelRequest } from \"@alma-harness/core\";\nimport type { OperationFence, OperationRootInput } from \"@alma-harness/execution\";\nimport type { StepOutcome, TurnExecution } from \"@alma-harness/loop/internal\";\nimport { createGovernedStepRunner, type GovernedStepOutput } from \"@alma-harness/single-call\";\nimport type { ConversationConfig } from \"./types\";\nimport type { Observation } from \"./observation\";\nexport function ordered(step: GovernedStepOutput): Block[] {\n return step.order.map(p => p.type === \"text\" ? { type: \"text\", text: step.text.slice(p.start,p.end) }\n : p.type === \"reasoning\" ? step.reasoning[p.index]!\n : p.type === \"provider_block\" ? step.providerBlocks[p.index]!\n : { type: \"tool_call\", id: step.toolCalls[p.index]!.id, name: step.toolCalls[p.index]!.name, input: step.toolCalls[p.index]!.input });\n}\nexport function execution(c: ConversationConfig, root: OperationRootInput, fence: OperationFence, signal: AbortSignal,\n lifecycle: Pick<TurnExecution,\"check\"|\"poison\"|\"track\"|\"mainChoice\">, observer?: Observation): TurnExecution {\n const runner = createGovernedStepRunner(c.step); let sequence = 0, spent = 0; const warnings = new Set<BudgetCapName>();\n async function preflight() {\n lifecycle.check();\n const configured = Object.entries(root.caps).filter(([,v]) => typeof v === \"object\" && v.onExceeded === \"block\");\n if (!configured.length) return;\n const totals = configured.some(([k]) => k !== \"perTurnUsd\") ? normalizeSpendTotals(await c.step.spend.peek({ scope: root.scope, sessionId: root.sessionId, at: new Date().toISOString() })) : { sessionUsd:0,tenantDayUsd:0 };\n lifecycle.check();\n for (const [key,cap] of configured) { const usd = key === \"perTurnUsd\" ? spent : key === \"perSessionUsd\" ? totals.sessionUsd : totals.tenantDayUsd;\n if (usd >= (cap as {usd:number}).usd) throw new BudgetExceededError(key as BudgetCapName,(cap as {usd:number}).usd,usd); }\n }\n return { ...lifecycle, turnId: root.id, ...(observer ? { observedStep: observer.main } : {}),\n guard: { preflight, spentUsd: () => spent, capsCrossed: () => [...warnings] },\n async run(request: ModelRequest, meta): Promise<StepOutcome> {\n try {\n lifecycle.check(); await preflight(); lifecycle.check();\n const slot = String(++sequence), callId = crypto.randomUUID(), operationKey = crypto.randomUUID();\n const controls = { maxTokens: request.maxTokens, ...(request.reasoning ? { reasoning: request.reasoning } : {}), ...(request.cache !== undefined ? { cache: request.cache } : {}), ...(request.temperature !== undefined ? { temperature: request.temperature } : {}) };\n const v = await runner.run({ fence, signal, rationale: meta.rationale,\n call: { slot, kind: meta.kind, ...(meta.parentCallId ? { parentCallId: meta.parentCallId } : {}), execution: {\n scope: root.scope, sessionId: root.sessionId, operationKey, operationId: crypto.randomUUID(), attemptId: crypto.randomUUID(), callId, settlementId: crypto.randomUUID(),\n inputRevision: root.request!.inputRevision, policyVersion: root.policyVersion, outputContractVersion: \"governed-step-v1\", intent: {tier:meta.intent.tier,sensitivity:meta.intent.sensitivity},\n model: request.model, requestedTier: request.serviceTier ?? \"standard\", priceVersion: c.priceVersion,\n prices: c.prices.filter(p => p.model.provider === request.model.provider && p.model.id === request.model.id), controls,\n occurredAt: new Date().toISOString(), deadlineAt: root.deadlineAt, governance: { caps: root.caps, consumers: c.consumers, resultRetentionMs: c.resultRetentionMs } } },\n loadRequest: async () => { lifecycle.check(); return request; } });\n lifecycle.check();\n if (v.status !== \"completed\") throw new Error(\"Model step requires reconciliation\");\n spent = Math.max(spent, v.rootReceipt.currentUsd); for (const cap of v.rootReceipt.newWarnings) warnings.add(cap);\n if (meta.kind === \"main\") observer?.bind({operationKey,callId});\n const usage = v.receipt.receipt.settlement.usage;\n const decision = v.rootReceipt.decisions.find(d => d.exceeded && d.onExceeded === \"block\");\n if (v.result.outcome === \"blocked\" && decision) return { callId, usage, text:\"\", toolCalls:[], reasoning:[], providerBlocks:[], blocks:[], stop: v.result.stopReason,\n error: new BudgetExceededError(decision.cap,decision.thresholdUsd,decision.currentUsd) };\n const evidence = v.record.evidence;\n if (meta.kind === \"main\" && evidence?.status === \"known\" && evidence.rejection) {\n const stored = await c.step.results.get(root.scope, callId); lifecycle.check();\n if (v.result.outcome !== \"refusal\" || v.result.stopReason !== \"context_window_exceeded\" ||\n !equalExecution(v.record.completion,{outcome:\"refusal\",stopReason:\"context_window_exceeded\"}) ||\n v.receipt.receipt.settlement.costUsd !== 0 || v.rootReceipt.costUsd !== 0 ||\n !stored || stored.state !== \"available\" || !equalExecution(stored.result,v.result) ||\n !equalExecution(stored.binding,{scope:root.scope,callId,sessionId:root.sessionId,sensitivity:meta.intent.sensitivity,retentionMs:c.resultRetentionMs})) throw new Error(\"Context refusal is unavailable\");\n return {callId,usage,text:\"\",toolCalls:[],reasoning:[],providerBlocks:[],blocks:[],stop:v.result.stopReason,contextRejected:true};\n }\n if (meta.kind === \"summary\" && (v.result.outcome !== \"success\" || !v.step?.text.trim())) throw new Error(\"Summary output is unusable\");\n if (v.result.outcome === \"refusal\" || v.result.outcome === \"truncated\") return { callId,usage,text:\"\",toolCalls:[],reasoning:[],providerBlocks:[],blocks:[],stop:v.result.stopReason };\n if (!v.step || v.result.outcome !== \"success\") throw new Error(\"Model output is unavailable\");\n return { callId, usage, text:v.step.text, stop:v.step.stop, reasoning:v.step.reasoning, providerBlocks:v.step.providerBlocks, blocks:ordered(v.step),\n toolCalls:v.step.toolCalls.map(t => ({ id:t.id,name:t.name,input:t.input, ...(t.malformed ? { malformed:\"Invalid JSON\" } : {}) })) };\n } catch (e) { if (!(e instanceof BudgetExceededError)) lifecycle.poison(); throw e; }\n },\n };\n}\n","import { createHash } from \"node:crypto\";\nimport { equalExecution, ExecutionConflictError, settlementIdentifier, settlementInstant, settlementScope, type Msg, type Scope } from \"@alma-harness/core\";\nimport { normalizeOperationRoot, type OperationRootInput, type OperationSessionClaim, type OperationSessionStore } from \"@alma-harness/execution\";\nimport type { ConversationConfig, ConversationInput, SimpleConversationInput } from \"./types\";\nexport type ConversationDescriptorConfig = Pick<ConversationConfig, \"caps\" | \"policyVersion\" | \"configRevision\" | \"resultContractVersion\" | \"resultRetentionMs\" | \"maxCalls\" | \"maxInputChars\" | \"runTimeoutMs\">;\nconst prefix = \"conversation-v1:\", revisionPrefix = \"conversation-input-v1:\";\nconst hash = (value: unknown) => createHash(\"sha256\").update(JSON.stringify(value)).digest(\"hex\");\nconst one = (value: unknown, choices: readonly string[]): boolean => typeof value === \"string\" && choices.includes(value);\nfunction invalid(): never { throw new TypeError(\"Invalid canonical conversation input\"); }\n\n/** Inspect descriptors before reading values: accessors must not run during normalization. */\nfunction fields(value: unknown, allowed?: readonly string[]): Record<string, unknown> {\n if (!value || typeof value !== \"object\" || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) invalid();\n const entries = Reflect.ownKeys(value).map(k => {\n const d = Object.getOwnPropertyDescriptor(value, k)!;\n if (typeof k !== \"string\" || !d.enumerable || !(\"value\" in d) || (allowed && !allowed.includes(k))) invalid();\n return [k, d.value] as const;\n });\n return Object.fromEntries(entries);\n}\n/** Canonical JSON only; limits apply while traversing, not after cloning an unbounded graph. */\nfunction jsonSnapshot(value: unknown, max: number): unknown {\n let nodes = 0, size = 0; const ancestors = new Set<object>();\n function add(n: number) { size += n; if (size > max) invalid(); }\n function visit(v: unknown, depth: number): unknown {\n if (++nodes > 100_000 || depth > 64) invalid();\n if (v === null || typeof v === \"string\" || typeof v === \"boolean\" || (typeof v === \"number\" && Number.isFinite(v))) {\n if (typeof v === \"string\" && v.length > max) invalid();\n add(JSON.stringify(v).length); return Object.is(v, -0) ? 0 : v;\n }\n if (!v || typeof v !== \"object\" || ancestors.has(v)) invalid();\n ancestors.add(v);\n try {\n add(2);\n if (Array.isArray(v)) {\n if (v.length > 100_000 || Reflect.ownKeys(v).length !== v.length + 1) invalid();\n return Array.from({ length: v.length }, (_, i) => {\n const d = Object.getOwnPropertyDescriptor(v, String(i));\n if (!d || !(\"value\" in d) || !d.enumerable) invalid();\n if (i) add(1); return visit(d.value, depth + 1);\n });\n }\n const object = fields(v), entries = Object.keys(object).sort().filter(k => object[k] !== undefined);\n return Object.fromEntries(entries.map((k, i) => {\n if (k.length > max) invalid(); add(JSON.stringify(k).length + 1 + (i ? 1 : 0));\n return [k, visit(object[k], depth + 1)];\n }));\n } finally { ancestors.delete(v); }\n }\n return visit(value, 0);\n}\nexport function conversationRootKey(scope: Scope, sessionId: string, idempotencyKey: string): string {\n const s = settlementScope(scope);\n return prefix + hash([\"conversation-v1\", s.org, s.uid, settlementIdentifier(sessionId), settlementIdentifier(idempotencyKey)]);\n}\nfunction snapshot(c: ConversationDescriptorConfig, input: SimpleConversationInput): SimpleConversationInput {\n if (!Number.isSafeInteger(c.maxInputChars) || c.maxInputChars < 1 || c.maxInputChars > 64_000_000 || !Number.isSafeInteger(c.runTimeoutMs) || c.runTimeoutMs < 1 || c.runTimeoutMs > 300_000) invalid();\n const f = fields(input, [\"scope\", \"sessionId\", \"idempotencyKey\", \"input\", \"intent\", \"toolProfile\", \"trigger\", \"signal\"]);\n const data = jsonSnapshot(Object.fromEntries(Object.entries(f).filter(([k]) => k !== \"signal\")), c.maxInputChars + 4096) as SimpleConversationInput;\n data.scope = settlementScope(data.scope); data.sessionId = settlementIdentifier(data.sessionId); data.idempotencyKey = settlementIdentifier(data.idempotencyKey);\n const intent = fields(data.intent, [\"tier\", \"sensitivity\", \"task\"]);\n if (!one(intent.tier, [\"mechanical\", \"standard\", \"complex\"]) || !one(intent.sensitivity, [\"public\", \"internal\", \"personal\", \"health\"]) || (intent.task !== undefined && (typeof intent.task !== \"string\" || intent.task.length > 1000))) invalid();\n if (data.toolProfile !== undefined) settlementIdentifier(data.toolProfile);\n data.trigger ??= \"user\"; if (![\"user\", \"routine\", \"system\"].includes(data.trigger)) invalid();\n const message = fields(data.input, [\"role\", \"blocks\", \"meta\"]);\n if (message.role !== \"user\" || !Array.isArray(message.blocks) || JSON.stringify(message).length > c.maxInputChars) invalid();\n for (const block of message.blocks) validateBlock(block);\n if (message.meta !== undefined) {\n const meta = fields(message.meta, [\"at\", \"channel\", \"model\", \"rotation\"]);\n settlementInstant(meta.at);\n for (const key of [\"channel\", \"model\"]) if (meta[key] !== undefined && typeof meta[key] !== \"string\") invalid();\n if (meta.rotation !== undefined) {\n const r = fields(meta.rotation, [\"summarized\", \"keep\", \"reason\"]);\n if (![r.summarized, r.keep].every(n => Number.isSafeInteger(n) && Number(n) >= 0) || !one(r.reason, [\"cold_start\", \"context_window\"])) invalid();\n }\n }\n if (f.signal !== undefined) {\n if (!(f.signal instanceof AbortSignal)) invalid(); data.signal = f.signal;\n }\n return data;\n}\nfunction validateBlock(value: unknown): void {\n const b = fields(value), strings = (...keys: string[]) => { for (const k of keys) if (typeof b[k] !== \"string\") invalid(); };\n const provider = () => { if (!one(b.provider, [\"anthropic\", \"openai\", \"openrouter\"])) invalid(); };\n switch (b.type) {\n case \"text\": strings(\"text\"); if (b.origin !== undefined && b.origin !== \"harness\") invalid(); break;\n case \"media\": {\n if (b.content !== undefined || !one(b.kind, [\"image\", \"audio\", \"document\"])) invalid();\n const ref = fields(b.ref, [\"uri\", \"contentType\", \"bytes\", \"filename\"]);\n if (typeof ref.uri !== \"string\") invalid();\n for (const key of [\"contentType\", \"filename\"]) if (ref[key] !== undefined && typeof ref[key] !== \"string\") invalid();\n if (ref.bytes !== undefined && (!Number.isSafeInteger(ref.bytes) || Number(ref.bytes) < 0)) invalid();\n break;\n }\n case \"tool_call\": strings(\"id\", \"name\"); if (!(\"input\" in b)) invalid(); break;\n case \"tool_result\": strings(\"callId\"); if (!(\"output\" in b) || (b.isError !== undefined && typeof b.isError !== \"boolean\")) invalid(); break;\n case \"reasoning\": provider(); if (b.text !== undefined) strings(\"text\"); break;\n case \"provider_tool_call\": provider(); strings(\"id\"); if (b.name !== \"web_search\" || !(\"input\" in b)) invalid(); break;\n case \"provider_tool_result\":\n provider(); strings(\"callId\"); if (b.name !== \"web_search\" || !Array.isArray(b.results)) invalid();\n for (const item of b.results) { const r = fields(item); if (typeof r.url !== \"string\" || [r.title, r.pageAge].some(v => v !== undefined && typeof v !== \"string\")) invalid(); }\n if (b.error !== undefined) strings(\"error\"); break;\n default: invalid();\n }\n}\nfunction descriptor(c: ConversationDescriptorConfig, i: SimpleConversationInput, deadlineAt: string): OperationRootInput {\n const key = conversationRootKey(i.scope, i.sessionId, i.idempotencyKey);\n return normalizeOperationRoot({ scope: i.scope, sessionId: i.sessionId, key, id: key, deadlineAt,\n policyVersion: c.policyVersion, caps: c.caps, maxCalls: c.maxCalls, maxSensitivity: i.intent.sensitivity,\n request: { inputRevision: revisionPrefix + hash([\"conversation-input-v1\", i.input, i.intent, i.toolProfile ?? null, i.trigger, c.runTimeoutMs]),\n configRevision: c.configRevision, resultContractVersion: c.resultContractVersion, resultRetentionMs: c.resultRetentionMs } });\n}\n/** Pure helper for hosts binding lazy input to the same canonical identity. */\nexport function createConversationDescriptor(c: ConversationDescriptorConfig, input: SimpleConversationInput, deadlineAt: string): OperationRootInput {\n return descriptor(c, snapshot(c, input), deadlineAt);\n}\nexport function normalizeTurnInput(c: ConversationDescriptorConfig, value: SimpleConversationInput | ConversationInput): { input: ConversationInput; canonical: boolean } {\n const f = fields(value);\n if (\"root\" in f) {\n fields(value, [\"root\", \"intent\", \"loadInput\", \"toolProfile\", \"trigger\", \"signal\"]);\n const root = normalizeOperationRoot(f.root), canonical = root.key.startsWith(prefix);\n if (canonical && (root.id !== root.key || !/^conversation-v1:[a-f0-9]{64}$/.test(root.key) || !/^conversation-input-v1:[a-f0-9]{64}$/.test(root.request?.inputRevision ?? \"\"))) invalid();\n return { input: { ...(f as unknown as ConversationInput), root }, canonical };\n }\n const i = snapshot(c, value as SimpleConversationInput);\n return { canonical: true, input: { root: descriptor(c, i, new Date(Date.now() + c.runTimeoutMs).toISOString()), intent: i.intent,\n trigger: i.trigger!, ...(i.toolProfile !== undefined ? { toolProfile: i.toolProfile } : {}), ...(i.signal ? { signal: i.signal } : {}),\n loadInput: async (): Promise<Msg> => i.input } };\n}\n/** Exact store claims stay unchanged; a race loser never obtains or reconstructs a fence. */\nexport async function existingAdmission(store: OperationSessionStore, root: OperationRootInput, canonical: boolean, check: () => void): Promise<Extract<OperationSessionClaim, {status:\"existing\"}> | null> {\n const record = await store.get(root.scope, root.key); check();\n if (!record) return null;\n if (!equalExecution(canonical ? { ...record.input, deadlineAt: root.deadlineAt } : record.input, root)) throw new ExecutionConflictError();\n return { status: \"existing\", record };\n}\nexport async function claimCanonical(store: OperationSessionStore, root: OperationRootInput, check: () => void): Promise<OperationSessionClaim> {\n const old = await existingAdmission(store, root, true, check);\n if (old) return old;\n try { return await store.claim(root); }\n catch (e) {\n if (!(e instanceof ExecutionConflictError)) throw e;\n check(); const saved = await existingAdmission(store, root, true, check);\n if (!saved) throw e;\n return saved;\n }\n}\n","import { equalExecution, ExecutionResultPolicyError, type Scope } from \"@alma-harness/core\";\nimport type { OperationRootInput } from \"@alma-harness/execution\";\nimport type { StepOutcome } from \"@alma-harness/loop/internal\";\nimport type { TurnEvent } from \"@alma-harness/loop\";\nimport { createGovernedStepRunner } from \"@alma-harness/single-call\";\nimport type { ConversationConfig, ConversationView } from \"./types\";\nimport { ConversationStreamResyncError, observerQueue } from \"./stream\";\ntype Key = { operationKey: string; callId: string };\ntype Ref = { type: \"final\"; view: Exclude<ConversationView, {status:\"completed\"}> | {status:\"completed\";replayed:boolean} }\n | (Key & { type: \"block\" | \"usage\"; step: number; index?: number })\n | (Key & { type: \"tool_result\"; step: number; id: string; isError: boolean });\nconst unavailable = (): never => { throw new ConversationStreamResyncError(\"unavailable\"); };\n/** One main call's identity, never a retained step payload or user callback. */\nexport function observation(c: ConversationConfig, root: OperationRootInput, read: (scope: Scope, key: string) => Promise<ConversationView | null>) {\n const steps = createGovernedStepRunner(c.step);\n let current: Key | undefined;\n const queue = observerQueue<Ref>(async ref => {\n if (ref.type === \"final\") {\n if (ref.view.status !== \"completed\") return { type: \"result\", view: ref.view };\n const fresh = await read(root.scope, root.key) ?? {status:\"unavailable\" as const};\n if (fresh.status !== \"completed\") return {type:\"result\",view:fresh};\n const result = { ...fresh.result }; delete result.replayed;\n if (ref.view.replayed) result.replayed = true;\n return {type:\"result\",view:{...fresh,result,replayed:ref.view.replayed}};\n }\n const fresh = await steps.read({scope:root.scope,rootKey:root.key,operationKey:ref.operationKey});\n if (!fresh || fresh.status !== \"completed\" || fresh.record.input.callId !== ref.callId ||\n fresh.record.input.operationKey !== ref.operationKey || !equalExecution(fresh.record.input.scope,root.scope) ||\n fresh.rootReceipt.rootId !== root.id || fresh.rootReceipt.callId !== ref.callId) return unavailable();\n const source = fresh.receipt.receipt.settlement;\n if (ref.type === \"usage\") return {type:\"usage\",step:ref.step,model:structuredClone(fresh.record.input.model),usage:structuredClone(source.usage),costUsd:source.costUsd};\n if (fresh.result.outcome !== \"success\" || !fresh.step) return unavailable();\n // The step reader establishes financial lineage; bind the final content read too.\n // Do not let an adapter return another call's otherwise valid envelope.\n const input = fresh.record.input;\n let stored;\n try { stored = await c.step.results.get(root.scope, ref.callId); }\n catch(error) { if(error instanceof ExecutionResultPolicyError)return unavailable();throw error; }\n if(!stored || stored.state!==\"available\" || !equalExecution(stored.binding, {\n scope:root.scope,callId:ref.callId,sessionId:input.sessionId,sensitivity:input.intent.sensitivity,\n retentionMs:input.governance!.resultRetentionMs,\n }) || !equalExecution(stored.result,fresh.result))return unavailable();\n const step = fresh.step;\n if (ref.type === \"tool_result\") {\n const call = step.toolCalls.find(t=>t.id===ref.id); if (!call) return unavailable();\n return {type:\"tool_result\",step:ref.step,id:call.id,name:call.name,isError:ref.isError};\n }\n const position=step.order[ref.index!];if(!position || position.type===\"reasoning\")return unavailable();\n if(position.type===\"text\")return {type:\"text\",step:ref.step,text:step.text.slice(position.start,position.end).toWellFormed()};\n if (position.type === \"tool_call\") {\n const call=step.toolCalls[position.index]; if(!call)return unavailable();\n return {type:\"tool_call\",step:ref.step,id:call.id,name:call.name};\n }\n const block=step.providerBlocks[position.index]; if(!block)return unavailable();\n return block.type === \"provider_tool_call\" ? {type:\"provider_tool_call\",step:ref.step,id:block.id,name:block.name}\n : {type:\"provider_tool_result\",step:ref.step,id:block.callId,name:block.name,results:block.results.length,isError:block.error!==undefined};\n });\n return {\n bind(key: Key) { if(queue.active())current=key; },\n main(step: number, outcome: StepOutcome) {\n if(!current || !queue.active() || current.callId!==outcome.callId)return;\n // ordered(outcome) preserves the persisted step.order indices, including reasoning.\n for(let index=0;index<outcome.blocks!.length && queue.active();index++)\n if(outcome.blocks![index]!.type!==\"reasoning\")queue.push({...current,type:\"block\",step,index});\n queue.push({...current,type:\"usage\",step});\n if(!queue.active())current=undefined;\n },\n emit(event: TurnEvent) {\n if(event.type===\"tool_result\" && current && queue.active())queue.push({...current,type:\"tool_result\",step:event.step,id:event.id,isError:event.isError});\n if(!queue.active())current=undefined;\n },\n start(result: Promise<ConversationView>) {\n // Install before the caller can await result; never retain its content in the queue.\n void result.then(view=>{current=undefined;queue.finish({type:\"final\",view:view.status===\"completed\" ? {status:\"completed\",replayed:view.replayed} : view});},error=>{current=undefined;queue.fail(error);});\n return queue.stream(result);\n },\n };\n}\nexport type Observation = ReturnType<typeof observation>;\n","import type { ConversationEvent, ConversationStream, ConversationView } from \"./types\";\nexport class ConversationStreamResyncError extends Error {\n constructor(readonly reason: \"overflow\" | \"unavailable\" | \"read_failed\") {\n super(`Conversation observer requires resynchronization: ${reason}`);\n this.name = \"ConversationStreamResyncError\";\n }\n}\nconst done = (): IteratorResult<ConversationEvent> => ({ done: true, value: undefined });\n/** Content-free references only. No producer operation waits for this single reader. */\nexport function observerQueue<R>(authorize: (ref: R) => Promise<ConversationEvent>) {\n let queue: { ref: R; bytes: number }[] = [], bytes = 0, reading = false;\n let attached = false, closed = false, settled = false, generation = 0;\n let failure: unknown, failed = false;\n let waiting: { resolve(value: IteratorResult<ConversationEvent>): void; reject(error: unknown): void } | undefined;\n function detach(error?: unknown) {\n if (closed) return;\n closed = true; generation++; queue = []; bytes = 0;\n failed = error !== undefined; failure = error;\n const w = waiting; waiting = undefined;\n if (failed) w?.reject(error); else w?.resolve(done());\n }\n function pump() {\n if (!waiting || reading || closed) return;\n const item = queue.shift();\n if (!item) { if (settled) detach(); return; }\n reading = true; const version = generation;\n // The in-flight reference stays in the byte/count budget until delivered.\n void Promise.resolve().then(() => authorize(item.ref)).then(event => {\n if (closed || version !== generation) return;\n bytes -= item.bytes; reading = false;\n const w = waiting; waiting = undefined;\n w?.resolve({ done: false, value: event });\n }, error => {\n if (closed || version !== generation) return;\n reading = false;\n detach(error instanceof ConversationStreamResyncError ? error : new ConversationStreamResyncError(\"read_failed\"));\n });\n }\n function push(ref: R) {\n if (closed) return;\n // Conservative UTF-16 storage estimate plus object overhead, bounded before retention.\n const size = JSON.stringify(ref).length * 2 + 256;\n if (queue.length + Number(reading) >= 128 || bytes + size > 256 * 1024) {\n detach(new ConversationStreamResyncError(\"overflow\")); return;\n }\n queue.push({ ref, bytes: size }); bytes += size; pump();\n }\n const iterator: AsyncIterableIterator<ConversationEvent> = {\n [Symbol.asyncIterator]() { return this; },\n next() {\n if (closed) return failed ? Promise.reject(failure) : Promise.resolve(done());\n if (waiting || reading) return Promise.reject(new TypeError(\"Only one pending observer next is supported\"));\n return new Promise((resolve, reject) => { waiting = { resolve, reject }; pump(); });\n },\n return() { detach(); return Promise.resolve(done()); },\n throw() { detach(); return Promise.resolve(done()); },\n };\n return {\n push, active: () => !closed,\n finish(ref: R) {\n if (closed) return;\n if (!attached) { queue = []; bytes = 0; }\n push(ref); settled = true; pump();\n },\n fail: detach,\n stream(result: Promise<ConversationView>): ConversationStream {\n return { result, [Symbol.asyncIterator]() {\n if (attached) throw new TypeError(\"This conversation stream already has an iterator\");\n attached = true; return iterator;\n } };\n },\n };\n}\n"],"mappings":";AAAA,SAAS,kBAAAA,iBAAgB,0BAAAC,yBAAwB,8BAAAC,6BAA4B,4BAA4B,wBAAAC,uBAAsB,mBAAAC,wBAA+D;AAC9L,SAAS,0BAAAC,+BAAmF;AAC5F,SAAS,mBAAAC,kBAAiB,SAAS,mBAAmB;;;ACFtD,SAAS,qBAAqB,wBAAwB,UAA+B;AACrF,SAAS,uBAAuB;AAEhC,SAAS,gCAAgC;AAElC,SAAS,OAAO,OAA+C;AACpE,MAAI,OAAO,MAAM,KAAK,OAAO,SAAS,WAAY,OAAM,IAAI,UAAU,sCAAsC;AAC5G,MAAI,MAAM,gBAAgB,MAAM,KAAK,QAAS,OAAM,IAAI,UAAU,4DAA4D;AAC9H,aAAW,CAAC,KAAK,GAAG,KAAK,OA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ACH;","names":["equalExecution","ExecutionConflictError","ExecutionResultPolicyError","settlementIdentifier","settlementScope","normalizeOperationRoot","createInternals","createGovernedStepRunner","equalExecution","equalExecution","createGovernedStepRunner","createGovernedStepRunner","fresh","equalExecution","settlementScope","settlementIdentifier","equalExecution","ExecutionResultPolicyError","normalizeOperationRoot","ExecutionConflictError","result","id","opts","createInternals","value"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/config.ts","../src/execution.ts","../src/input.ts","../src/observation.ts","../src/stream.ts"],"sourcesContent":["import { equalExecution, ExecutionConflictError, ExecutionResultPolicyError, normalizeExecutionEvidence, settlementIdentifier, settlementScope, type ExecutionResultRecord, type Scope } from \"@alma-harness/core\";\nimport { normalizeOperationRoot, type OperationRootInput, type OperationSessionFence } from \"@alma-harness/execution\";\nimport { createInternals, NO_EMIT, runTurnBody } from \"@alma-harness/loop/internal\";\nimport type { TurnResult } from \"@alma-harness/loop\";\nimport { engineConfig, config } from \"./config\";\nimport { execution } from \"./execution\";\nimport { claimCanonical, existingAdmission, normalizeTurnInput } from \"./input\";\nimport type { ModelChoice } from \"@alma-harness/core\";\nexport { conversationRootKey, createConversationDescriptor, type ConversationDescriptorConfig } from \"./input\";\nimport type { ConversationConfig, ConversationInput, ConversationRunner, ConversationView } from \"./types\";\nexport type { SimpleConversationInput, ConversationConfig, ConversationInput, ConversationRunner, ConversationView, ConversationTool, ConversationToolCtx } from \"./types\";\nimport { observation, type Observation } from \"./observation\";\nexport { ConversationStreamResyncError } from \"./stream\";\nexport type { ConversationEvent, ConversationStream } from \"./types\";\nconst pending = (): ConversationView => ({ status:\"reconciliation_required\" });\nconst interrupted = () => new Error(\"Conversation requires reconciliation\");\nexport function createConversationRunner(value: ConversationConfig): ConversationRunner {\n const c = config(value);\n const binding = (root:OperationRootInput) => ({ scope:root.scope,callId:root.key,sessionId:root.sessionId,sensitivity:root.maxSensitivity,retentionMs:root.request!.resultRetentionMs });\n async function read(scope:Scope, key:string): Promise<ConversationView|null> {\n const s = settlementScope(scope), k = settlementIdentifier(key), a = await c.admissions.get(s,k);\n if (!a) return null;\n if (a.status !== \"released\") return { status:a.status === \"active\" && a.input.deadlineAt > new Date().toISOString() ? \"in_progress\" : \"reconciliation_required\" };\n if (a.resolutionId || !a.input.request) return pending();\n const root = await c.step.trees.get(s,k);\n if (!root || root.status !== \"closed\" || !equalExecution(root.input,a.input)) return pending();\n let stored:ExecutionResultRecord|null;\n try { stored = await c.rootResults.get(s,k); } catch (e) { if (e instanceof ExecutionResultPolicyError) return { status:\"unavailable\" }; throw e; }\n if (!stored || stored.state !== \"available\" || !equalExecution(stored.binding,binding(root.input)) || stored.result?.outcome !== \"success\" || stored.result.output.format !== \"json\") return { status:\"unavailable\" };\n const financial = await c.step.accounting.get(s,k);\n if (!financial || financial.reservedCalls !== financial.settledCalls || financial.rootStatus !== \"closed\") return pending();\n try {\n const data = JSON.parse(stored.result.output.text) as { version:string; rootId:string; contract:string; result:TurnResult };\n const r = data.result;\n if (data.version !== \"governed-conversation-v1\" || data.rootId !== root.input.id || data.contract !== root.input.request!.resultContractVersion || !r || r.turnId !== root.input.id || r.costUsd !== financial.costUsd || ![\"completed\",\"budget_exceeded\"].includes(r.terminalReason) || r.reply?.role !== \"assistant\" || !Array.isArray(r.reply.blocks) || r.reply.blocks.some(b => b.type === \"reasoning\") || !Number.isSafeInteger(r.steps) || r.steps < 0 || !Number.isFinite(r.durationMs) || r.durationMs < 0) return { status:\"unavailable\" };\n normalizeExecutionEvidence({ status:\"known\",usage:r.usage });\n return { status:\"completed\",result:{ ...r,replayed:true },replayed:true };\n } catch { return { status:\"unavailable\" }; }\n }\n function run(input:ConversationInput, mode: \"exact\" | \"canonical\", observer?: Observation): Promise<ConversationView> {\n const root = normalizeOperationRoot(input.root), req = root.request;\n const opts = { intent:structuredClone(input.intent),...(input.trigger ? {trigger:input.trigger} : {}),...(input.toolProfile ? {toolProfile:input.toolProfile} : {}) }, load = input.loadInput, external = input.signal;\n if (!req || req.configRevision !== c.configRevision || req.resultContractVersion !== c.resultContractVersion || req.resultRetentionMs !== c.resultRetentionMs || root.policyVersion !== c.policyVersion || !equalExecution(root.caps,c.caps) || root.maxCalls > c.maxCalls || root.maxSensitivity !== opts.intent.sensitivity || typeof load !== \"function\") throw new ExecutionConflictError();\n const controller = new AbortController(); let uncertain = false, children = 0, sealed = false, admission:OperationSessionFence|undefined;\n const poison = () => { uncertain = true; controller.abort(); };\n const check = () => { if (uncertain || sealed || controller.signal.aborted || (admission && Date.now() >= Date.parse(root.deadlineAt))) throw interrupted(); };\n function track<T>(fn:()=>Promise<T>):Promise<T> {\n const p = (async () => { check(); children++; try { return await fn(); } catch (e) { poison(); throw e; } finally { children--; } })();\n void p.catch(() => {}); return p;\n }\n const abort = () => poison();\n const timer = setTimeout(abort,c.runTimeoutMs); let deadline:ReturnType<typeof setTimeout>|undefined;\n const cancelled = new Promise<ConversationView>(resolve => controller.signal.addEventListener(\"abort\",() => resolve(pending()),{once:true}));\n external?.addEventListener(\"abort\",abort,{once:true}); if (external?.aborted) abort();\n const work = execute(); void work.catch(() => {});\n return Promise.race([work,cancelled]).finally(() => { sealed = true; clearTimeout(timer); clearTimeout(deadline); external?.removeEventListener(\"abort\",abort); });\n async function uncertainAdmission() { if (admission) { try { await c.admissions.markUncertain(admission); } catch { /* Occupancy survives this failed acknowledgement. */ } } }\n async function execute():Promise<ConversationView> {\n try {\n check();\n let mainChoice: ModelChoice | undefined;\n {\n const existing = () => existingAdmission(c.admissions, root, mode === \"canonical\", check);\n if (await existing()) return (await read(root.scope,root.key)) ?? pending();\n try {\n mainChoice = structuredClone(c.policy.resolve(structuredClone(opts.intent)));\n if (!Object.hasOwn(c.step.clients, mainChoice.model.provider) || !c.step.clients[mainChoice.model.provider]) mainChoice = undefined;\n } catch { mainChoice = undefined; }\n check();\n if (!mainChoice) {\n if (await existing()) return (await read(root.scope,root.key)) ?? pending();\n return { status:\"not_admitted\",reason:\"routing_unavailable\" };\n }\n }\n const a = mode === \"canonical\" ? await claimCanonical(c.admissions, root, check) : await c.admissions.claim(root);\n if (a.status === \"claimed\") admission = a.fence;\n check();\n if (a.status === \"busy\") return { status:\"busy\",rootKey:a.rootKey };\n if (a.status === \"existing\") return (await read(root.scope,root.key)) ?? pending();\n deadline = setTimeout(abort,Math.max(0,Date.parse(root.deadlineAt)-Date.now()));\n const claim = await c.step.trees.claim(root); check();\n if (claim.status !== \"claimed\" || !equalExecution(claim.record.input,root)) throw interrupted();\n const prepared = await c.rootResults.prepare(binding(root)); check();\n if (prepared.state !== \"pending\") throw interrupted();\n const message = structuredClone(await load()); check();\n if (message.role !== \"user\" || JSON.stringify(message).length > c.maxInputChars) throw new TypeError(\"Invalid conversation input\");\n const base = engineConfig(c), sessionStore = c.sessions;\n const guarded = async <T>(fn:()=>Promise<T>):Promise<T> => { check(); try { const result = await fn(); check(); return result; } catch (e) { poison(); throw e; } };\n // Every effect-capable hook and all asynchronous context sources are per-turn closures.\n base.hooks = (base.hooks ?? []).map(h => Object.fromEntries(Object.entries(h).filter(([,fn]) => typeof fn === \"function\").map(([key,fn]) => [key,async (...args:unknown[]) => { check(); try { const r = await (fn as (...a:unknown[])=>unknown)(...args); check(); return r; } catch (e) { poison(); throw e; } }])));\n base.sessions = { ...sessionStore, load:(s,id) => guarded(() => sessionStore.load(s,id)), append:(s,id,msgs) => guarded(() => sessionStore.append(s,id,msgs)), erase:(s,id) => sessionStore.erase(s,id), expireToolTraffic:(s,id,opts) => sessionStore.expireToolTraffic(s,id,opts) };\n // assembleRecall owns the deadline and clears it on abort, even if the source never settles.\n if (c.recall) base.recall = { build:(...args) => guarded(() => c.recall!.build(...args)) };\n if (c.media?.source) base.media = { ...c.media,source:{load:(...args) => guarded(() => c.media!.source!.load(...args))} };\n const runtime = execution(c,root,claim.fence,controller.signal,{check,poison,track,mainChoice},observer);\n const body = await runTurnBody(createInternals(base), { scope:root.scope,sessionId:root.sessionId,input:message,...opts,signal:controller.signal },observer?.emit ?? NO_EMIT,runtime);\n check();\n if (children !== 0 || ![\"completed\",\"budget_exceeded\"].includes(body.terminalReason)) throw interrupted();\n const totals = await c.step.accounting.get(root.scope,root.key); check();\n if (!totals || totals.reservedCalls !== totals.settledCalls || totals.costUsd !== body.costUsd) throw interrupted();\n await c.step.trees.close(claim.fence); check();\n const result = { outcome:\"success\" as const,stopReason:body.stopReason,output:{format:\"json\" as const,text:JSON.stringify({version:\"governed-conversation-v1\",rootId:root.id,contract:req!.resultContractVersion,result:body})} };\n await c.rootResults.put(root.scope,root.key,result); check();\n const final = await c.rootResults.get(root.scope,root.key); check();\n if (final?.state !== \"available\" || !equalExecution(final.binding,binding(root)) || !equalExecution(final.result,result)) throw interrupted();\n try { await c.admissions.finish(admission!); }\n catch {\n // Finish is attempted only AFTER proven local quiescence and durable writes.\n const released = await c.admissions.get(root.scope,root.key);\n if (!released || released.status !== \"released\" || released.resolutionId || !equalExecution(released.input,root)) throw interrupted();\n }\n return {status:\"completed\",result:body,replayed:false};\n } catch (e) {\n if (!admission && e instanceof ExecutionConflictError) throw e;\n poison(); await uncertainAdmission(); return pending();\n }\n }\n }\n return {read,streamTurn(value) {\n const normalized = normalizeTurnInput(c, value);\n const observer = observation(c, normalized.input.root, read);\n return observer.start(run(normalized.input, normalized.canonical ? \"canonical\" : \"exact\", observer));\n },async runTurn(value) {\n const normalized = normalizeTurnInput(c, value);\n return run(normalized.input, normalized.canonical ? \"canonical\" : \"exact\");\n }};\n}\n","import { normalizeBudgetCaps, settlementIdentifier as id, type ToolDefinition } from \"@alma-harness/core\";\nimport { createInternals } from \"@alma-harness/loop/internal\";\nimport type { LoopConfig } from \"@alma-harness/loop/internal\";\nimport { createGovernedStepRunner } from \"@alma-harness/single-call\";\nimport type { ConversationConfig } from \"./types\";\nexport function config(value: ConversationConfig): ConversationConfig {\n if (typeof value.step.spend?.peek !== \"function\") throw new TypeError(\"Conversation requires a spend reader\");\n if (value.rootResults === value.step.results) throw new TypeError(\"Conversation results require a separate physical namespace\");\n for (const [key, max] of Object.entries({ runTimeoutMs: 300000, resultRetentionMs: 31536000000, maxCalls: 512, maxInputChars: 64000000 })) {\n const n = value[key as keyof ConversationConfig]; if (!Number.isSafeInteger(n) || Number(n) < 1 || Number(n) > max) throw new TypeError(`Invalid conversation ${key}`);\n }\n for (const n of [value.maxSteps ?? 24, value.maxDelegateDepth ?? 2, value.maxTokens ?? 8192]) if (!Number.isSafeInteger(n) || n < 1) throw new TypeError(\"Invalid conversation technical limit\");\n for (const key of [\"policyVersion\", \"priceVersion\", \"configRevision\", \"resultContractVersion\"] as const) id(value[key]);\n if (!Array.isArray(value.consumers) || value.consumers.length > 16) throw new TypeError(\"Invalid consumers\");\n for (const client of Object.values(value.step.clients)) if (!client || client.dispatchPolicy !== \"single\" || typeof client.validate !== \"function\") throw new TypeError(\"Conversation requires single-dispatch clients\");\n const c = { ...value, caps: normalizeBudgetCaps(value.caps), prices: structuredClone(value.prices), consumers: [...new Set(value.consumers.map(id))].sort(),\n system: structuredClone(value.system), step: { ...value.step, clients: { ...value.step.clients } },\n ...(value.providerTools ? { providerTools: structuredClone(value.providerTools) } : {}),\n ...(value.profiles ? { profiles: structuredClone(value.profiles) } : {}),\n ...(value.tools ? { tools: value.tools.map(t => ({ ...t, ...(t.jsonSchema ? { jsonSchema: structuredClone(t.jsonSchema) } : {}) })) } : {}),\n ...(value.hooks ? { hooks: value.hooks.map(h => ({ ...h })) } : {}),\n ...(value.longContext ? { longContext: { ...value.longContext } } : {}), ...(value.media ? { media: { ...value.media } } : {}) };\n createGovernedStepRunner(c.step);\n createInternals(engineConfig(c)); // Registry/config errors precede claims.\n return c;\n}\nexport function engineConfig(c: ConversationConfig): LoopConfig {\n // The internal governed dispatch branch supplies the declared extended gateway.\n return { ...c, ...(c.tools ? { tools: c.tools as ToolDefinition[] } : {}), clients: c.step.clients, audit: c.step.audit };\n}\n","import { BudgetExceededError, equalExecution, normalizeSpendTotals, type Block, type BudgetCapName, type ModelRequest } from \"@alma-harness/core\";\nimport type { OperationFence, OperationRootInput } from \"@alma-harness/execution\";\nimport type { StepOutcome, TurnExecution } from \"@alma-harness/loop/internal\";\nimport { createGovernedStepRunner, type GovernedStepOutput } from \"@alma-harness/single-call\";\nimport type { ConversationConfig } from \"./types\";\nimport type { Observation } from \"./observation\";\nexport function ordered(step: GovernedStepOutput): Block[] {\n return step.order.map(p => p.type === \"text\" ? { type: \"text\", text: step.text.slice(p.start,p.end) }\n : p.type === \"reasoning\" ? step.reasoning[p.index]!\n : p.type === \"provider_block\" ? step.providerBlocks[p.index]!\n : { type: \"tool_call\", id: step.toolCalls[p.index]!.id, name: step.toolCalls[p.index]!.name, input: step.toolCalls[p.index]!.input });\n}\nexport function execution(c: ConversationConfig, root: OperationRootInput, fence: OperationFence, signal: AbortSignal,\n lifecycle: Pick<TurnExecution,\"check\"|\"poison\"|\"track\"|\"mainChoice\">, observer?: Observation): TurnExecution {\n const runner = createGovernedStepRunner(c.step); let sequence = 0, spent = 0; const warnings = new Set<BudgetCapName>();\n async function preflight() {\n lifecycle.check();\n const configured = Object.entries(root.caps).filter(([,v]) => typeof v === \"object\" && v.onExceeded === \"block\");\n if (!configured.length) return;\n const totals = configured.some(([k]) => k !== \"perTurnUsd\") ? normalizeSpendTotals(await c.step.spend.peek({ scope: root.scope, sessionId: root.sessionId, at: new Date().toISOString() })) : { sessionUsd:0,tenantDayUsd:0 };\n lifecycle.check();\n for (const [key,cap] of configured) { const usd = key === \"perTurnUsd\" ? spent : key === \"perSessionUsd\" ? totals.sessionUsd : totals.tenantDayUsd;\n if (usd >= (cap as {usd:number}).usd) throw new BudgetExceededError(key as BudgetCapName,(cap as {usd:number}).usd,usd); }\n }\n return { ...lifecycle, turnId: root.id, ...(observer ? { observedStep: observer.main } : {}),\n guard: { preflight, spentUsd: () => spent, capsCrossed: () => [...warnings] },\n async run(request: ModelRequest, meta): Promise<StepOutcome> {\n try {\n lifecycle.check(); await preflight(); lifecycle.check();\n const slot = String(++sequence), callId = crypto.randomUUID(), operationKey = crypto.randomUUID();\n const controls = { maxTokens: request.maxTokens, ...(request.toolChoice !== undefined ? { toolChoice: request.toolChoice } : {}), ...(request.reasoning ? { reasoning: request.reasoning } : {}), ...(request.cache !== undefined ? { cache: request.cache } : {}), ...(request.temperature !== undefined ? { temperature: request.temperature } : {}) };\n const v = await runner.run({ fence, signal, rationale: meta.rationale,\n call: { slot, kind: meta.kind, ...(meta.parentCallId ? { parentCallId: meta.parentCallId } : {}), execution: {\n scope: root.scope, sessionId: root.sessionId, operationKey, operationId: crypto.randomUUID(), attemptId: crypto.randomUUID(), callId, settlementId: crypto.randomUUID(),\n inputRevision: root.request!.inputRevision, policyVersion: root.policyVersion, outputContractVersion: \"governed-step-v1\", intent: {tier:meta.intent.tier,sensitivity:meta.intent.sensitivity},\n model: request.model, requestedTier: request.serviceTier ?? \"standard\", priceVersion: c.priceVersion,\n prices: c.prices.filter(p => p.model.provider === request.model.provider && p.model.id === request.model.id), controls,\n occurredAt: new Date().toISOString(), deadlineAt: root.deadlineAt, governance: { caps: root.caps, consumers: c.consumers, resultRetentionMs: c.resultRetentionMs } } },\n loadRequest: async () => { lifecycle.check(); return request; } });\n lifecycle.check();\n if (v.status !== \"completed\") throw new Error(\"Model step requires reconciliation\");\n spent = Math.max(spent, v.rootReceipt.currentUsd); for (const cap of v.rootReceipt.newWarnings) warnings.add(cap);\n if (meta.kind === \"main\") observer?.bind({operationKey,callId});\n const usage = v.receipt.receipt.settlement.usage;\n const decision = v.rootReceipt.decisions.find(d => d.exceeded && d.onExceeded === \"block\");\n if (v.result.outcome === \"blocked\" && decision) return { callId, usage, text:\"\", toolCalls:[], reasoning:[], providerBlocks:[], blocks:[], stop: v.result.stopReason,\n error: new BudgetExceededError(decision.cap,decision.thresholdUsd,decision.currentUsd) };\n const evidence = v.record.evidence;\n if (meta.kind === \"main\" && evidence?.status === \"known\" && evidence.rejection) {\n const stored = await c.step.results.get(root.scope, callId); lifecycle.check();\n if (v.result.outcome !== \"refusal\" || v.result.stopReason !== \"context_window_exceeded\" ||\n !equalExecution(v.record.completion,{outcome:\"refusal\",stopReason:\"context_window_exceeded\"}) ||\n v.receipt.receipt.settlement.costUsd !== 0 || v.rootReceipt.costUsd !== 0 ||\n !stored || stored.state !== \"available\" || !equalExecution(stored.result,v.result) ||\n !equalExecution(stored.binding,{scope:root.scope,callId,sessionId:root.sessionId,sensitivity:meta.intent.sensitivity,retentionMs:c.resultRetentionMs})) throw new Error(\"Context refusal is unavailable\");\n return {callId,usage,text:\"\",toolCalls:[],reasoning:[],providerBlocks:[],blocks:[],stop:v.result.stopReason,contextRejected:true};\n }\n if (meta.kind === \"summary\" && (v.result.outcome !== \"success\" || !v.step?.text.trim())) throw new Error(\"Summary output is unusable\");\n if (v.result.outcome === \"refusal\" || v.result.outcome === \"truncated\") return { callId,usage,text:\"\",toolCalls:[],reasoning:[],providerBlocks:[],blocks:[],stop:v.result.stopReason };\n if (!v.step || v.result.outcome !== \"success\") throw new Error(\"Model output is unavailable\");\n return { callId, usage, text:v.step.text, stop:v.step.stop, reasoning:v.step.reasoning, providerBlocks:v.step.providerBlocks, blocks:ordered(v.step),\n toolCalls:v.step.toolCalls.map(t => ({ id:t.id,name:t.name,input:t.input, ...(t.malformed ? { malformed:\"Invalid JSON\" } : {}) })) };\n } catch (e) { if (!(e instanceof BudgetExceededError)) lifecycle.poison(); throw e; }\n },\n };\n}\n","import { createHash } from \"node:crypto\";\nimport { equalExecution, ExecutionConflictError, settlementIdentifier, settlementInstant, settlementScope, type Msg, type Scope } from \"@alma-harness/core\";\nimport { normalizeOperationRoot, type OperationRootInput, type OperationSessionClaim, type OperationSessionStore } from \"@alma-harness/execution\";\nimport type { ConversationConfig, ConversationInput, SimpleConversationInput } from \"./types\";\nexport type ConversationDescriptorConfig = Pick<ConversationConfig, \"caps\" | \"policyVersion\" | \"configRevision\" | \"resultContractVersion\" | \"resultRetentionMs\" | \"maxCalls\" | \"maxInputChars\" | \"runTimeoutMs\">;\nconst prefix = \"conversation-v1:\", revisionPrefix = \"conversation-input-v1:\";\nconst hash = (value: unknown) => createHash(\"sha256\").update(JSON.stringify(value)).digest(\"hex\");\nconst one = (value: unknown, choices: readonly string[]): boolean => typeof value === \"string\" && choices.includes(value);\nfunction invalid(): never { throw new TypeError(\"Invalid canonical conversation input\"); }\n\n/** Inspect descriptors before reading values: accessors must not run during normalization. */\nfunction fields(value: unknown, allowed?: readonly string[]): Record<string, unknown> {\n if (!value || typeof value !== \"object\" || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) invalid();\n const entries = Reflect.ownKeys(value).map(k => {\n const d = Object.getOwnPropertyDescriptor(value, k)!;\n if (typeof k !== \"string\" || !d.enumerable || !(\"value\" in d) || (allowed && !allowed.includes(k))) invalid();\n return [k, d.value] as const;\n });\n return Object.fromEntries(entries);\n}\n/** Canonical JSON only; limits apply while traversing, not after cloning an unbounded graph. */\nfunction jsonSnapshot(value: unknown, max: number): unknown {\n let nodes = 0, size = 0; const ancestors = new Set<object>();\n function add(n: number) { size += n; if (size > max) invalid(); }\n function visit(v: unknown, depth: number): unknown {\n if (++nodes > 100_000 || depth > 64) invalid();\n if (v === null || typeof v === \"string\" || typeof v === \"boolean\" || (typeof v === \"number\" && Number.isFinite(v))) {\n if (typeof v === \"string\" && v.length > max) invalid();\n add(JSON.stringify(v).length); return Object.is(v, -0) ? 0 : v;\n }\n if (!v || typeof v !== \"object\" || ancestors.has(v)) invalid();\n ancestors.add(v);\n try {\n add(2);\n if (Array.isArray(v)) {\n if (v.length > 100_000 || Reflect.ownKeys(v).length !== v.length + 1) invalid();\n return Array.from({ length: v.length }, (_, i) => {\n const d = Object.getOwnPropertyDescriptor(v, String(i));\n if (!d || !(\"value\" in d) || !d.enumerable) invalid();\n if (i) add(1); return visit(d.value, depth + 1);\n });\n }\n const object = fields(v), entries = Object.keys(object).sort().filter(k => object[k] !== undefined);\n return Object.fromEntries(entries.map((k, i) => {\n if (k.length > max) invalid(); add(JSON.stringify(k).length + 1 + (i ? 1 : 0));\n return [k, visit(object[k], depth + 1)];\n }));\n } finally { ancestors.delete(v); }\n }\n return visit(value, 0);\n}\nexport function conversationRootKey(scope: Scope, sessionId: string, idempotencyKey: string): string {\n const s = settlementScope(scope);\n return prefix + hash([\"conversation-v1\", s.org, s.uid, settlementIdentifier(sessionId), settlementIdentifier(idempotencyKey)]);\n}\nfunction snapshot(c: ConversationDescriptorConfig, input: SimpleConversationInput): SimpleConversationInput {\n if (!Number.isSafeInteger(c.maxInputChars) || c.maxInputChars < 1 || c.maxInputChars > 64_000_000 || !Number.isSafeInteger(c.runTimeoutMs) || c.runTimeoutMs < 1 || c.runTimeoutMs > 300_000) invalid();\n const f = fields(input, [\"scope\", \"sessionId\", \"idempotencyKey\", \"input\", \"intent\", \"toolProfile\", \"trigger\", \"signal\"]);\n const data = jsonSnapshot(Object.fromEntries(Object.entries(f).filter(([k]) => k !== \"signal\")), c.maxInputChars + 4096) as SimpleConversationInput;\n data.scope = settlementScope(data.scope); data.sessionId = settlementIdentifier(data.sessionId); data.idempotencyKey = settlementIdentifier(data.idempotencyKey);\n const intent = fields(data.intent, [\"tier\", \"sensitivity\", \"task\"]);\n if (!one(intent.tier, [\"mechanical\", \"standard\", \"complex\"]) || !one(intent.sensitivity, [\"public\", \"internal\", \"personal\", \"health\"]) || (intent.task !== undefined && (typeof intent.task !== \"string\" || intent.task.length > 1000))) invalid();\n if (data.toolProfile !== undefined) settlementIdentifier(data.toolProfile);\n data.trigger ??= \"user\"; if (![\"user\", \"routine\", \"system\"].includes(data.trigger)) invalid();\n const message = fields(data.input, [\"role\", \"blocks\", \"meta\"]);\n if (message.role !== \"user\" || !Array.isArray(message.blocks) || JSON.stringify(message).length > c.maxInputChars) invalid();\n for (const block of message.blocks) validateBlock(block);\n if (message.meta !== undefined) {\n const meta = fields(message.meta, [\"at\", \"channel\", \"model\", \"rotation\"]);\n settlementInstant(meta.at);\n for (const key of [\"channel\", \"model\"]) if (meta[key] !== undefined && typeof meta[key] !== \"string\") invalid();\n if (meta.rotation !== undefined) {\n const r = fields(meta.rotation, [\"summarized\", \"keep\", \"reason\"]);\n if (![r.summarized, r.keep].every(n => Number.isSafeInteger(n) && Number(n) >= 0) || !one(r.reason, [\"cold_start\", \"context_window\"])) invalid();\n }\n }\n if (f.signal !== undefined) {\n if (!(f.signal instanceof AbortSignal)) invalid(); data.signal = f.signal;\n }\n return data;\n}\nfunction validateBlock(value: unknown): void {\n const b = fields(value), strings = (...keys: string[]) => { for (const k of keys) if (typeof b[k] !== \"string\") invalid(); };\n const provider = () => { if (!one(b.provider, [\"anthropic\", \"openai\", \"openrouter\"])) invalid(); };\n switch (b.type) {\n case \"text\": strings(\"text\"); if (b.origin !== undefined && b.origin !== \"harness\") invalid(); break;\n case \"media\": {\n if (b.content !== undefined || !one(b.kind, [\"image\", \"audio\", \"document\"])) invalid();\n const ref = fields(b.ref, [\"uri\", \"contentType\", \"bytes\", \"filename\"]);\n if (typeof ref.uri !== \"string\") invalid();\n for (const key of [\"contentType\", \"filename\"]) if (ref[key] !== undefined && typeof ref[key] !== \"string\") invalid();\n if (ref.bytes !== undefined && (!Number.isSafeInteger(ref.bytes) || Number(ref.bytes) < 0)) invalid();\n break;\n }\n case \"tool_call\": strings(\"id\", \"name\"); if (!(\"input\" in b)) invalid(); break;\n case \"tool_result\": strings(\"callId\"); if (!(\"output\" in b) || (b.isError !== undefined && typeof b.isError !== \"boolean\")) invalid(); break;\n case \"reasoning\": provider(); if (b.text !== undefined) strings(\"text\"); break;\n case \"provider_tool_call\": provider(); strings(\"id\"); if (b.name !== \"web_search\" || !(\"input\" in b)) invalid(); break;\n case \"provider_tool_result\":\n provider(); strings(\"callId\"); if (b.name !== \"web_search\" || !Array.isArray(b.results)) invalid();\n for (const item of b.results) { const r = fields(item); if (typeof r.url !== \"string\" || [r.title, r.pageAge].some(v => v !== undefined && typeof v !== \"string\")) invalid(); }\n if (b.error !== undefined) strings(\"error\"); break;\n default: invalid();\n }\n}\nfunction descriptor(c: ConversationDescriptorConfig, i: SimpleConversationInput, deadlineAt: string): OperationRootInput {\n const key = conversationRootKey(i.scope, i.sessionId, i.idempotencyKey);\n return normalizeOperationRoot({ scope: i.scope, sessionId: i.sessionId, key, id: key, deadlineAt,\n policyVersion: c.policyVersion, caps: c.caps, maxCalls: c.maxCalls, maxSensitivity: i.intent.sensitivity,\n request: { inputRevision: revisionPrefix + hash([\"conversation-input-v1\", i.input, i.intent, i.toolProfile ?? null, i.trigger, c.runTimeoutMs]),\n configRevision: c.configRevision, resultContractVersion: c.resultContractVersion, resultRetentionMs: c.resultRetentionMs } });\n}\n/** Pure helper for hosts binding lazy input to the same canonical identity. */\nexport function createConversationDescriptor(c: ConversationDescriptorConfig, input: SimpleConversationInput, deadlineAt: string): OperationRootInput {\n return descriptor(c, snapshot(c, input), deadlineAt);\n}\nexport function normalizeTurnInput(c: ConversationDescriptorConfig, value: SimpleConversationInput | ConversationInput): { input: ConversationInput; canonical: boolean } {\n const f = fields(value);\n if (\"root\" in f) {\n fields(value, [\"root\", \"intent\", \"loadInput\", \"toolProfile\", \"trigger\", \"signal\"]);\n const root = normalizeOperationRoot(f.root), canonical = root.key.startsWith(prefix);\n if (canonical && (root.id !== root.key || !/^conversation-v1:[a-f0-9]{64}$/.test(root.key) || !/^conversation-input-v1:[a-f0-9]{64}$/.test(root.request?.inputRevision ?? \"\"))) invalid();\n return { input: { ...(f as unknown as ConversationInput), root }, canonical };\n }\n const i = snapshot(c, value as SimpleConversationInput);\n return { canonical: true, input: { root: descriptor(c, i, new Date(Date.now() + c.runTimeoutMs).toISOString()), intent: i.intent,\n trigger: i.trigger!, ...(i.toolProfile !== undefined ? { toolProfile: i.toolProfile } : {}), ...(i.signal ? { signal: i.signal } : {}),\n loadInput: async (): Promise<Msg> => i.input } };\n}\n/** Exact store claims stay unchanged; a race loser never obtains or reconstructs a fence. */\nexport async function existingAdmission(store: OperationSessionStore, root: OperationRootInput, canonical: boolean, check: () => void): Promise<Extract<OperationSessionClaim, {status:\"existing\"}> | null> {\n const record = await store.get(root.scope, root.key); check();\n if (!record) return null;\n if (!equalExecution(canonical ? { ...record.input, deadlineAt: root.deadlineAt } : record.input, root)) throw new ExecutionConflictError();\n return { status: \"existing\", record };\n}\nexport async function claimCanonical(store: OperationSessionStore, root: OperationRootInput, check: () => void): Promise<OperationSessionClaim> {\n const old = await existingAdmission(store, root, true, check);\n if (old) return old;\n try { return await store.claim(root); }\n catch (e) {\n if (!(e instanceof ExecutionConflictError)) throw e;\n check(); const saved = await existingAdmission(store, root, true, check);\n if (!saved) throw e;\n return saved;\n }\n}\n","import { equalExecution, ExecutionResultPolicyError, type Scope } from \"@alma-harness/core\";\nimport type { OperationRootInput } from \"@alma-harness/execution\";\nimport type { StepOutcome } from \"@alma-harness/loop/internal\";\nimport type { TurnEvent } from \"@alma-harness/loop\";\nimport { createGovernedStepRunner } from \"@alma-harness/single-call\";\nimport type { ConversationConfig, ConversationView } from \"./types\";\nimport { ConversationStreamResyncError, observerQueue } from \"./stream\";\ntype Key = { operationKey: string; callId: string };\ntype Ref = { type: \"final\"; view: Exclude<ConversationView, {status:\"completed\"}> | {status:\"completed\";replayed:boolean} }\n | (Key & { type: \"block\" | \"usage\"; step: number; index?: number })\n | (Key & { type: \"tool_result\"; step: number; id: string; isError: boolean });\nconst unavailable = (): never => { throw new ConversationStreamResyncError(\"unavailable\"); };\n/** One main call's identity, never a retained step payload or user callback. */\nexport function observation(c: ConversationConfig, root: OperationRootInput, read: (scope: Scope, key: string) => Promise<ConversationView | null>) {\n const steps = createGovernedStepRunner(c.step);\n let current: Key | undefined;\n const queue = observerQueue<Ref>(async ref => {\n if (ref.type === \"final\") {\n if (ref.view.status !== \"completed\") return { type: \"result\", view: ref.view };\n const fresh = await read(root.scope, root.key) ?? {status:\"unavailable\" as const};\n if (fresh.status !== \"completed\") return {type:\"result\",view:fresh};\n const result = { ...fresh.result }; delete result.replayed;\n if (ref.view.replayed) result.replayed = true;\n return {type:\"result\",view:{...fresh,result,replayed:ref.view.replayed}};\n }\n const fresh = await steps.read({scope:root.scope,rootKey:root.key,operationKey:ref.operationKey});\n if (!fresh || fresh.status !== \"completed\" || fresh.record.input.callId !== ref.callId ||\n fresh.record.input.operationKey !== ref.operationKey || !equalExecution(fresh.record.input.scope,root.scope) ||\n fresh.rootReceipt.rootId !== root.id || fresh.rootReceipt.callId !== ref.callId) return unavailable();\n const source = fresh.receipt.receipt.settlement;\n if (ref.type === \"usage\") return {type:\"usage\",step:ref.step,model:structuredClone(fresh.record.input.model),usage:structuredClone(source.usage),costUsd:source.costUsd};\n if (fresh.result.outcome !== \"success\" || !fresh.step) return unavailable();\n // The step reader establishes financial lineage; bind the final content read too.\n // Do not let an adapter return another call's otherwise valid envelope.\n const input = fresh.record.input;\n let stored;\n try { stored = await c.step.results.get(root.scope, ref.callId); }\n catch(error) { if(error instanceof ExecutionResultPolicyError)return unavailable();throw error; }\n if(!stored || stored.state!==\"available\" || !equalExecution(stored.binding, {\n scope:root.scope,callId:ref.callId,sessionId:input.sessionId,sensitivity:input.intent.sensitivity,\n retentionMs:input.governance!.resultRetentionMs,\n }) || !equalExecution(stored.result,fresh.result))return unavailable();\n const step = fresh.step;\n if (ref.type === \"tool_result\") {\n const call = step.toolCalls.find(t=>t.id===ref.id); if (!call) return unavailable();\n return {type:\"tool_result\",step:ref.step,id:call.id,name:call.name,isError:ref.isError};\n }\n const position=step.order[ref.index!];if(!position || position.type===\"reasoning\")return unavailable();\n if(position.type===\"text\")return {type:\"text\",step:ref.step,text:step.text.slice(position.start,position.end).toWellFormed()};\n if (position.type === \"tool_call\") {\n const call=step.toolCalls[position.index]; if(!call)return unavailable();\n return {type:\"tool_call\",step:ref.step,id:call.id,name:call.name};\n }\n const block=step.providerBlocks[position.index]; if(!block)return unavailable();\n return block.type === \"provider_tool_call\" ? {type:\"provider_tool_call\",step:ref.step,id:block.id,name:block.name}\n : {type:\"provider_tool_result\",step:ref.step,id:block.callId,name:block.name,results:block.results.length,isError:block.error!==undefined};\n });\n return {\n bind(key: Key) { if(queue.active())current=key; },\n main(step: number, outcome: StepOutcome) {\n if(!current || !queue.active() || current.callId!==outcome.callId)return;\n // ordered(outcome) preserves the persisted step.order indices, including reasoning.\n for(let index=0;index<outcome.blocks!.length && queue.active();index++)\n if(outcome.blocks![index]!.type!==\"reasoning\")queue.push({...current,type:\"block\",step,index});\n queue.push({...current,type:\"usage\",step});\n if(!queue.active())current=undefined;\n },\n emit(event: TurnEvent) {\n if(event.type===\"tool_result\" && current && queue.active())queue.push({...current,type:\"tool_result\",step:event.step,id:event.id,isError:event.isError});\n if(!queue.active())current=undefined;\n },\n start(result: Promise<ConversationView>) {\n // Install before the caller can await result; never retain its content in the queue.\n void result.then(view=>{current=undefined;queue.finish({type:\"final\",view:view.status===\"completed\" ? {status:\"completed\",replayed:view.replayed} : view});},error=>{current=undefined;queue.fail(error);});\n return queue.stream(result);\n },\n };\n}\nexport type Observation = ReturnType<typeof observation>;\n","import type { ConversationEvent, ConversationStream, ConversationView } from \"./types\";\nexport class ConversationStreamResyncError extends Error {\n constructor(readonly reason: \"overflow\" | \"unavailable\" | \"read_failed\") {\n super(`Conversation observer requires resynchronization: ${reason}`);\n this.name = \"ConversationStreamResyncError\";\n }\n}\nconst done = (): IteratorResult<ConversationEvent> => ({ done: true, value: undefined });\n/** Content-free references only. No producer operation waits for this single reader. */\nexport function observerQueue<R>(authorize: (ref: R) => Promise<ConversationEvent>) {\n let queue: { ref: R; bytes: number }[] = [], bytes = 0, reading = false;\n let attached = false, closed = false, settled = false, generation = 0;\n let failure: unknown, failed = false;\n let waiting: { resolve(value: IteratorResult<ConversationEvent>): void; reject(error: unknown): void } | undefined;\n function detach(error?: unknown) {\n if (closed) return;\n closed = true; generation++; queue = []; bytes = 0;\n failed = error !== undefined; failure = error;\n const w = waiting; waiting = undefined;\n if (failed) w?.reject(error); else w?.resolve(done());\n }\n function pump() {\n if (!waiting || reading || closed) return;\n const item = queue.shift();\n if (!item) { if (settled) detach(); return; }\n reading = true; const version = generation;\n // The in-flight reference stays in the byte/count budget until delivered.\n void Promise.resolve().then(() => authorize(item.ref)).then(event => {\n if (closed || version !== generation) return;\n bytes -= item.bytes; reading = false;\n const w = waiting; waiting = undefined;\n w?.resolve({ done: false, value: event });\n }, error => {\n if (closed || version !== generation) return;\n reading = false;\n detach(error instanceof ConversationStreamResyncError ? error : new ConversationStreamResyncError(\"read_failed\"));\n });\n }\n function push(ref: R) {\n if (closed) return;\n // Conservative UTF-16 storage estimate plus object overhead, bounded before retention.\n const size = JSON.stringify(ref).length * 2 + 256;\n if (queue.length + Number(reading) >= 128 || bytes + size > 256 * 1024) {\n detach(new ConversationStreamResyncError(\"overflow\")); return;\n }\n queue.push({ ref, bytes: size }); bytes += size; pump();\n }\n const iterator: AsyncIterableIterator<ConversationEvent> = {\n [Symbol.asyncIterator]() { return this; },\n next() {\n if (closed) return failed ? Promise.reject(failure) : Promise.resolve(done());\n if (waiting || reading) return Promise.reject(new TypeError(\"Only one pending observer next is supported\"));\n return new Promise((resolve, reject) => { waiting = { resolve, reject }; pump(); });\n },\n return() { detach(); return Promise.resolve(done()); },\n throw() { detach(); return Promise.resolve(done()); },\n };\n return {\n push, active: () => !closed,\n finish(ref: R) {\n if (closed) return;\n if (!attached) { queue = []; bytes = 0; }\n push(ref); settled = true; pump();\n },\n fail: detach,\n stream(result: Promise<ConversationView>): ConversationStream {\n return { result, [Symbol.asyncIterator]() {\n if (attached) throw new TypeError(\"This conversation stream already has an iterator\");\n attached = true; return iterator;\n } };\n },\n };\n}\n"],"mappings":";AAAA,SAAS,kBAAAA,iBAAgB,0BAAAC,yBAAwB,8BAAAC,6BAA4B,4BAA4B,wBAAAC,uBAAsB,mBAAAC,wBAA+D;AAC9L,SAAS,0BAAAC,+BAAmF;AAC5F,SAAS,mBAAAC,kBAAiB,SAAS,mBAAmB;;;ACFtD,SAAS,qBAAqB,wBAAwB,UAA+B;AACrF,SAAS,uBAAuB;AAEhC,SAAS,gCAAgC;AAElC,SAAS,OAAO,OAA+C;A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,MAAM,MAAM,IAAI;AAC3D,WAAO,SAAS,MAAM,IAAI,WAAW,OAAO,WAAW,YAAY,cAAc,SAAS,QAAQ,CAAC;AAAA,EACrG,GAAE,MAAM,QAAQA,QAAO;AACrB,UAAM,aAAa,mBAAmB,GAAGA,MAAK;AAC9C,WAAO,IAAI,WAAW,OAAO,WAAW,YAAY,cAAc,OAAO;AAAA,EAC3E,EAAC;AACH;","names":["equalExecution","ExecutionConflictError","ExecutionResultPolicyError","settlementIdentifier","settlementScope","normalizeOperationRoot","createInternals","createGovernedStepRunner","equalExecution","equalExecution","createGovernedStepRunner","createGovernedStepRunner","fresh","equalExecution","settlementScope","settlementIdentifier","equalExecution","ExecutionResultPolicyError","normalizeOperationRoot","ExecutionConflictError","result","id","opts","createInternals","value"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alma-harness/conversation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Governed buffered and settled-step streaming conversations for Alma.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"directory": "packages/conversation"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@alma-harness/core": "^0.
|
|
23
|
-
"@alma-harness/execution": "^0.
|
|
24
|
-
"@alma-harness/loop": "^0.
|
|
25
|
-
"@alma-harness/single-call": "^0.
|
|
22
|
+
"@alma-harness/core": "^0.10.1",
|
|
23
|
+
"@alma-harness/execution": "^0.10.1",
|
|
24
|
+
"@alma-harness/loop": "^0.10.1",
|
|
25
|
+
"@alma-harness/single-call": "^0.10.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^24.1.0",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"vitest": "^3.2.4",
|
|
31
31
|
"pg": "^8.16.3",
|
|
32
32
|
"@types/pg": "^8.15.4",
|
|
33
|
-
"@alma-harness/
|
|
34
|
-
"@alma-harness/
|
|
35
|
-
"@alma-harness/
|
|
36
|
-
"@alma-harness/postgres
|
|
37
|
-
"@alma-harness/
|
|
38
|
-
"@alma-harness/
|
|
39
|
-
"@alma-harness/
|
|
33
|
+
"@alma-harness/core": "^0.10.1",
|
|
34
|
+
"@alma-harness/execution": "^0.10.1",
|
|
35
|
+
"@alma-harness/memory": "^0.10.1",
|
|
36
|
+
"@alma-harness/postgres": "^0.10.1",
|
|
37
|
+
"@alma-harness/postgres-execution": "^0.10.1",
|
|
38
|
+
"@alma-harness/loop": "^0.10.1",
|
|
39
|
+
"@alma-harness/single-call": "^0.10.1"
|
|
40
40
|
},
|
|
41
41
|
"files": [
|
|
42
42
|
"dist"
|