@tangle-network/agent-runtime 10.0.17 → 10.0.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/CHANGELOG.md +8 -0
- package/dist/{activation-BSyIPZNw.d.ts → activation-BrKEOt0o.d.ts} +2 -2
- package/dist/{activation-CxTZHC70.js → activation-QvaQ62ub.js} +2 -2
- package/dist/{activation-CxTZHC70.js.map → activation-QvaQ62ub.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +3 -3
- package/dist/{delegate-DGeAiukN.js → delegate-CeDlbkv1.js} +2 -2
- package/dist/{delegate-DGeAiukN.js.map → delegate-CeDlbkv1.js.map} +1 -1
- package/dist/{driver-control-acknowledgers-Q4c0RMoG.js → driver-control-acknowledgers-C6WDdngb.js} +7 -7
- package/dist/{driver-control-acknowledgers-Q4c0RMoG.js.map → driver-control-acknowledgers-C6WDdngb.js.map} +1 -1
- package/dist/durable-writer-thread.js +2 -2
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +11 -11
- package/dist/{failure-cause-DeSINrKC.js → failure-cause-C96rzF-d.js} +12 -2
- package/dist/{failure-cause-DeSINrKC.js.map → failure-cause-C96rzF-d.js.map} +1 -1
- package/dist/{graph-qm8N8-Jg.js → graph-icQyDLuE.js} +6 -6
- package/dist/{graph-qm8N8-Jg.js.map → graph-icQyDLuE.js.map} +1 -1
- package/dist/{improve-BIgddUb2.js → improve-BkmELSLf.js} +5 -5
- package/dist/{improve-BIgddUb2.js.map → improve-BkmELSLf.js.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -10
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +4 -4
- package/dist/kernel.d.ts +1 -1
- package/dist/kernel.js +15 -15
- package/dist/{loop-runner-CG8rMjSU.d.ts → loop-runner-1JaJldwD.d.ts} +2 -2
- package/dist/{loop-runner-CARBEmJ-.js → loop-runner-DA7j6lcP.js} +2 -2
- package/dist/{loop-runner-CARBEmJ-.js.map → loop-runner-DA7j6lcP.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +6 -6
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{provision-supervisor-bnP_5YKO.js → provision-supervisor-C9Hbntgv.js} +5 -5
- package/dist/{provision-supervisor-bnP_5YKO.js.map → provision-supervisor-C9Hbntgv.js.map} +1 -1
- package/dist/{result-blob-store-hfSuzvWt.js → result-blob-store-Dke805sV.js} +2 -2
- package/dist/{result-blob-store-hfSuzvWt.js.map → result-blob-store-Dke805sV.js.map} +1 -1
- package/dist/{run-cancellation-3JALg48v.js → run-cancellation-ewCqEeaB.js} +2 -2
- package/dist/{run-cancellation-3JALg48v.js.map → run-cancellation-ewCqEeaB.js.map} +1 -1
- package/dist/{run-reopen-CrlP610D.js → run-reopen-D0j0fxLA.js} +6 -6
- package/dist/{run-reopen-CrlP610D.js.map → run-reopen-D0j0fxLA.js.map} +1 -1
- package/dist/{run-state-CdmftIyV.js → run-state-YgNw0e6m.js} +5 -5
- package/dist/{run-state-CdmftIyV.js.map → run-state-YgNw0e6m.js.map} +1 -1
- package/dist/{runtime-BJfxfru1.js → runtime-CvEV00cw.js} +15 -15
- package/dist/{runtime-BJfxfru1.js.map → runtime-CvEV00cw.js.map} +1 -1
- package/dist/{search-executor-B0XqNpI1.js → search-executor-obtQ1gad.js} +4 -4
- package/dist/{search-executor-B0XqNpI1.js.map → search-executor-obtQ1gad.js.map} +1 -1
- package/dist/{server-BL1KHd0N.js → server-Cytht_rG.js} +4 -4
- package/dist/{server-BL1KHd0N.js.map → server-Cytht_rG.js.map} +1 -1
- package/dist/{settle-record-CWixHcZl.js → settle-record-wvANhoy8.js} +2 -2
- package/dist/{settle-record-CWixHcZl.js.map → settle-record-wvANhoy8.js.map} +1 -1
- package/dist/{structural-rollout-PkvuJbEk.js → structural-rollout-srl_no2J.js} +4 -4
- package/dist/{structural-rollout-PkvuJbEk.js.map → structural-rollout-srl_no2J.js.map} +1 -1
- package/dist/{supervise-identity-BAOmWwLn.js → supervise-identity-CAxifVzJ.js} +2 -2
- package/dist/{supervise-identity-BAOmWwLn.js.map → supervise-identity-CAxifVzJ.js.map} +1 -1
- package/dist/{supervise-CPMm88sh.js → supervise-x-0LPDZh.js} +67 -39
- package/dist/supervise-x-0LPDZh.js.map +1 -0
- package/dist/{supervision-discovery-B6fyGpHe.js → supervision-discovery-CikJuonO.js} +3 -3
- package/dist/{supervision-discovery-B6fyGpHe.js.map → supervision-discovery-CikJuonO.js.map} +1 -1
- package/dist/{supervisor-BOYyb8eL.js → supervisor-9_oKaGd_.js} +6 -6
- package/dist/{supervisor-BOYyb8eL.js.map → supervisor-9_oKaGd_.js.map} +1 -1
- package/dist/{supervisor-accounting-BmY9xWOW.js → supervisor-accounting-DLjKVPwf.js} +1771 -1729
- package/dist/supervisor-accounting-DLjKVPwf.js.map +1 -0
- package/dist/{supervisor-root-contract-DIMbL04L.js → supervisor-root-contract-BUrTzojJ.js} +3 -3
- package/dist/{supervisor-root-contract-DIMbL04L.js.map → supervisor-root-contract-BUrTzojJ.js.map} +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +11 -11
- package/dist/{tool-server--58hhIKE.js → tool-server-BhsyVDj2.js} +2 -2
- package/dist/{tool-server--58hhIKE.js.map → tool-server-BhsyVDj2.js.map} +1 -1
- package/dist/{top-web-CPzT4hJX.js → top-web-C_VALyaB.js} +7 -7
- package/dist/{top-web-CPzT4hJX.js.map → top-web-C_VALyaB.js.map} +1 -1
- package/dist/tui/bin.js +3 -3
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/{types-C477vlPv.d.ts → types-eWuTelLM.d.ts} +45 -36
- package/package.json +2 -2
- package/dist/supervise-CPMm88sh.js.map +0 -1
- package/dist/supervisor-accounting-BmY9xWOW.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { rt as deriveNodeExecutionIdentity } from "./supervisor-accounting-
|
|
1
|
+
import { rt as deriveNodeExecutionIdentity } from "./supervisor-accounting-DLjKVPwf.js";
|
|
2
2
|
import { m as ValidationError } from "./errors-DG8yufqX.js";
|
|
3
3
|
import { l as appendCommittedJsonLine, o as readCommittedJsonLines } from "./jsonl-file-B8xfYz9M.js";
|
|
4
4
|
import { n as detachedSnapshot } from "./snapshot-BKLziJ5K.js";
|
|
@@ -207,4 +207,4 @@ function coordinationEventId(context, event) {
|
|
|
207
207
|
}
|
|
208
208
|
export { freezeDetached as a, supervisionRunNamespace as c, foldCoordinationRecords as d, externalExecutionId as i, workerAssignmentNamespace as l, childCoordinationOwner as n, freezeDetachedProfile as o, coordinationEventId as r, rootCoordinationOwner as s, canonicalExecution as t, FileCoordinationLog as u };
|
|
209
209
|
|
|
210
|
-
//# sourceMappingURL=supervise-identity-
|
|
210
|
+
//# sourceMappingURL=supervise-identity-CAxifVzJ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervise-identity-BAOmWwLn.js","names":[],"sources":["../src/runtime/supervise/coordination-log.ts","../src/runtime/supervise/supervise-identity.ts"],"sourcesContent":["/**\n * Durable side-log for coordination evidence the spawn journal does not own: questions, analyst\n * findings, answer decisions, authorized continuation receipts, delivery-attempt markers, and\n * delivery outcomes. A durable run\n * (`supervise({ runDir })`) appends them as they publish and loads them on resume, so a restarted\n * coordinator retains the exact evidence produced by prior processes.\n *\n * Answer down-events also fold status on load: a question answered before the crash reloads as\n * `answered`, not as a re-blocking `open`. Settled events are skipped (the spawn journal is their\n * ledger). A receipt followed by an attempt but no outcome proves the process died in the delivery\n * window; that outcome remains unknown and no prior instruction is auto-delivered.\n *\n * JSONL, one fsynced record per event, keyed by `runId` — several runs may share one log file\n * exactly as they share one spawn-journal file.\n *\n * @experimental\n */\n\nimport { appendCommittedJsonLine, readCommittedJsonLines } from '../../durable/jsonl-file'\nimport { captureRunWriteContext } from '../../durable/run-fence'\nimport type {\n AnalystFindingEvent,\n DefinedAnalystRecord,\n} from '../../mcp/tools/coordination-analysts'\nimport type { CoordinationEvent } from '../../mcp/tools/coordination-events'\nimport type { ContinuationInstruction } from '../../mcp/tools/coordination-messages'\nimport type {\n QuestionEscalationRecord,\n QuestionRecord,\n} from '../../mcp/tools/coordination-questions'\nimport type { BusRecord } from './event-bus'\nimport type { PeerMailEvent } from './peer-mail'\n\n/** Stable identity of the supervisor that owns one coordination stream. High-level supervision\n * derives it from the exact root/child execution identity plus its parent assignment. */\nexport type CoordinationOwnerId = string\n\n/** Durable delivery evidence retained in commit order. An attempt without a later event carrying\n * the same `receiptId` has an unknown outcome after a crash and is never replayed. */\nexport type CoordinationDeliveryEvidence = Extract<\n CoordinationEvent,\n { readonly type: 'delivery-attempt' | 'steer' | 'answer' }\n>\n\n/** Coordination evidence loaded from prior processes of one durable supervised run. */\nexport interface PriorCoordination {\n /** The owner filter used for this replay. Omitted only for the compatibility all-owner read. */\n readonly ownerId?: CoordinationOwnerId\n /** Every question the prior process raised, with answer-status folded in, raise order. */\n readonly questions: ReadonlyArray<QuestionRecord>\n /** Every analyst finding the prior process published, publish order. */\n readonly findings: ReadonlyArray<AnalystFindingEvent>\n /** Every `ask_parent` escalation the prior process made, raise order. An undelivered one names a\n * question the run raised that nothing above it received — retained so a resuming operator sees\n * it, never auto-redelivered. */\n readonly escalations: ReadonlyArray<QuestionEscalationRecord>\n /** Every lens the prior process DEFINED at run time, definition order. The exact authored bytes\n * and their digest, so an invented lens can be re-registered and any finding it produced can be\n * traced to the words that produced it. Re-registration is the owner's decision, never automatic:\n * the registry may have changed between processes. */\n readonly analystDefinitions: ReadonlyArray<DefinedAnalystRecord>\n /** Every authorized continuation, in commit order. These are evidence, never replayed to a new\n * worker automatically. */\n readonly continuations: ReadonlyArray<ContinuationInstruction>\n /** Delivery intent and result records in commit order, linked to receipts by `receiptId`. */\n readonly deliveryEvidence: ReadonlyArray<CoordinationDeliveryEvidence>\n /** Every peer-mail attempt the prior process made, delivered and refused alike, in commit order.\n * Evidence of what siblings told each other; never replayed into a new worker's inbox. */\n readonly mail: ReadonlyArray<PeerMailEvent>\n /** Exact source-bus stamps in durable append order. Bus `seq` restarts with each process; append\n * order remains the cross-process replay order. */\n readonly records: ReadonlyArray<BusRecord<CoordinationEvent>>\n}\n\n/** The durable coordination side-log seam. `append` records one bus event (kinds it does not\n * persist are ignored); `load` replays a run's prior records folded into `PriorCoordination`. */\nexport interface CoordinationLog {\n append(\n runId: string,\n record: BusRecord<CoordinationEvent>,\n ownerId?: CoordinationOwnerId,\n ): Promise<void>\n load(runId: string, ownerId?: CoordinationOwnerId): Promise<PriorCoordination>\n}\n\ntype CoordinationLogRecord = {\n readonly runId: string\n readonly ownerId?: CoordinationOwnerId\n readonly seq: number\n readonly at: number\n readonly priority: number\n readonly event: CoordinationEvent\n}\n\ntype LegacyCoordinationLogRecord = {\n readonly runId: string\n readonly ownerId?: CoordinationOwnerId\n readonly at: string\n readonly event: CoordinationEvent\n}\n\n/** Persist prior context plus exact continuation authorization, attempt, and result evidence.\n * Settlements have their own journal. */\nfunction persisted(event: CoordinationEvent): boolean {\n return event.type !== 'settled'\n}\n\n/** FS-backed `CoordinationLog`: append-only JSONL, fsynced per record. */\nexport class FileCoordinationLog implements CoordinationLog {\n private readonly writeContext = captureRunWriteContext()\n private appendTail: Promise<void> = Promise.resolve()\n\n constructor(private readonly path: string) {}\n\n async append(\n runId: string,\n record: BusRecord<CoordinationEvent>,\n ownerId?: CoordinationOwnerId,\n ): Promise<void> {\n if (!persisted(record.event)) return\n const append = this.appendTail.then(() =>\n this.writeContext(() => this.appendRecord(runId, record, ownerId)),\n )\n this.appendTail = append.catch(() => undefined)\n return append\n }\n\n private async appendRecord(\n runId: string,\n busRecord: BusRecord<CoordinationEvent>,\n ownerId?: CoordinationOwnerId,\n ): Promise<void> {\n const fs = await import('node:fs/promises')\n const { dirname } = await import('node:path')\n await fs.mkdir(dirname(this.path), { recursive: true })\n const record: CoordinationLogRecord = {\n runId,\n ...(ownerId !== undefined ? { ownerId } : {}),\n ...busRecord,\n }\n await appendCommittedJsonLine(this.path, record)\n }\n\n async load(runId: string, ownerId?: CoordinationOwnerId): Promise<PriorCoordination> {\n return foldCoordinationRecords(\n readCommittedJsonLines<CoordinationLogRecord | LegacyCoordinationLogRecord>(this.path, {\n allowMissing: true,\n }),\n runId,\n ownerId,\n )\n }\n}\n\n/** @internal Shared replay semantics for file and SQL coordination evidence. */\nexport async function foldCoordinationRecords(\n source:\n | Iterable<CoordinationLogRecord | LegacyCoordinationLogRecord>\n | AsyncIterable<CoordinationLogRecord | LegacyCoordinationLogRecord>,\n runId: string,\n ownerId?: CoordinationOwnerId,\n): Promise<PriorCoordination> {\n const byId = new Map<string, QuestionRecord>()\n const findings: AnalystFindingEvent[] = []\n const escalations: QuestionEscalationRecord[] = []\n const analystDefinitions: DefinedAnalystRecord[] = []\n const continuations: ContinuationInstruction[] = []\n const deliveryEvidence: CoordinationDeliveryEvidence[] = []\n const mail: PeerMailEvent[] = []\n const records: BusRecord<CoordinationEvent>[] = []\n let legacySeq = 0\n for await (const stored of source) {\n if (stored.runId !== runId) continue\n // Omitting ownerId preserves the historical all-run read for direct consumers. Runtime always\n // supplies one, so root and nested supervisors never receive one another's evidence.\n if (ownerId !== undefined && stored.ownerId !== ownerId) continue\n const record: BusRecord<CoordinationEvent> =\n 'seq' in stored\n ? {\n seq: stored.seq,\n at: stored.at,\n priority: stored.priority,\n event: stored.event,\n }\n : {\n seq: legacySeq++,\n at: Date.parse(stored.at),\n priority: 0,\n event: stored.event,\n }\n records.push(record)\n const ev = record.event\n if (ev.type === 'delivery-attempt' || ev.type === 'steer' || ev.type === 'answer') {\n deliveryEvidence.push(ev)\n }\n if (ev.type === 'question') {\n byId.set(ev.question.id, ev.question)\n } else if (ev.type === 'finding') {\n findings.push(ev.finding)\n } else if (ev.type === 'answer') {\n // Only accepted delivery resolves a blocking question. Authorization and an attempted\n // refusal remain evidence, but cannot turn \"worker never received the answer\" into answered\n // state on replay. `by` is not on the wire; prior-run is the honest attribution.\n const prior = byId.get(ev.questionId)\n if (prior && ev.down.delivered) {\n byId.set(ev.questionId, {\n ...prior,\n status: 'answered',\n decision: { kind: 'answer', answer: ev.down.instruction, by: 'prior-run' },\n })\n }\n } else if (ev.type === 'instruction') {\n continuations.push(ev.instruction)\n } else if (ev.type === 'mail') {\n mail.push(ev.mail)\n } else if (ev.type === 'escalation') {\n escalations.push(ev.escalation)\n } else if (ev.type === 'analyst-defined') {\n analystDefinitions.push(ev.analyst)\n }\n }\n return {\n ...(ownerId !== undefined ? { ownerId } : {}),\n questions: [...byId.values()],\n findings,\n escalations,\n analystDefinitions,\n continuations,\n deliveryEvidence,\n mail,\n records,\n }\n}\n","import { randomUUID } from 'node:crypto'\nimport { resolve } from 'node:path'\nimport {\n type AgentProfile,\n agentProfileSchema,\n canonicalCandidateDigest,\n type Sha256Digest,\n} from '@tangle-network/agent-interface'\nimport { ValidationError } from '../../errors'\nimport type { WorkerSpawnContext } from '../../mcp/tools/coordination-contracts'\nimport type { CoordinationEvent } from '../../mcp/tools/coordination-events'\nimport { deriveNodeExecutionIdentity } from './scope'\nimport { detachedSnapshot } from './snapshot'\nimport type { SupervisorNodeContext } from './supervisor-agent'\nimport type { AgentExecutionRef, NodeExecutionIdentity } from './types'\n\nexport function externalExecutionId(kind: string, identity: unknown): string {\n const digest = canonicalCandidateDigest({ kind, identity })\n return `${kind}-${digest.slice('sha256:'.length)}`\n}\n\nexport function freezeDetached<T>(value: T): T {\n return detachedSnapshot(value, 'supervise')\n}\n\nexport function freezeDetachedProfile(value: unknown): AgentProfile {\n return freezeDetached(agentProfileSchema.parse(value))\n}\n\nexport function canonicalExecution(\n profile: AgentProfile,\n task: unknown,\n rawExecution: AgentExecutionRef | undefined,\n context: string,\n): { readonly identity: NodeExecutionIdentity; readonly ref?: AgentExecutionRef } {\n const execution = rawExecution === undefined ? undefined : freezeDetached(rawExecution)\n if (execution !== undefined) {\n if (typeof execution !== 'object' || execution === null || Array.isArray(execution)) {\n throw new ValidationError(`${context}: execution must be an object`)\n }\n const unknown = Object.keys(execution).filter(\n (key) => key !== 'candidateDigest' && key !== 'correlation',\n )\n if (unknown.length > 0) {\n throw new ValidationError(`${context}: unknown execution fields: ${unknown.join(', ')}`)\n }\n }\n const identity = deriveNodeExecutionIdentity({ profile, execution }, task)\n if (!identity?.profileDigest || !identity.taskDigest) {\n throw new ValidationError(\n `${context}: profile and task must be finite, acyclic canonical JSON for durable identity`,\n )\n }\n const ref: AgentExecutionRef | undefined =\n identity.candidateDigest || identity.correlation\n ? Object.freeze({\n ...(identity.candidateDigest ? { candidateDigest: identity.candidateDigest } : {}),\n ...(identity.correlation ? { correlation: identity.correlation } : {}),\n })\n : undefined\n return { identity, ...(ref ? { ref } : {}) }\n}\n\nexport function rootCoordinationOwner(identity: NodeExecutionIdentity): string {\n return canonicalCandidateDigest({ kind: 'supervisor-root', identity })\n}\n\nexport function childCoordinationOwner(\n parentOwnerId: string,\n identity: NodeExecutionIdentity,\n context: WorkerSpawnContext,\n depth: number,\n): string {\n return canonicalCandidateDigest({\n kind: 'supervisor-child',\n parentOwnerId,\n identity,\n assignment: {\n id: context.assignmentId,\n label: context.label,\n key: context.key ?? null,\n depth,\n },\n })\n}\n\nexport function supervisionRunNamespace(runDir: string | undefined, runId: string): string {\n return canonicalCandidateDigest(\n runDir === undefined\n ? { kind: 'supervise-ephemeral-run', runId, nonce: randomUUID() }\n : { kind: 'supervise-durable-run', runId, runDir: resolve(runDir) },\n )\n}\n\nexport function workerAssignmentNamespace(\n runNamespace: string,\n parentOwnerId: string,\n assignmentId: string,\n): string {\n return canonicalCandidateDigest({\n kind: 'supervise-worker-assignment',\n runNamespace,\n parentOwnerId,\n assignmentId,\n })\n}\n\n/** Hash only durable coordination meaning. Bus sequence/timestamp are delivery metadata and a\n * resumed projection's marker describes the reader, not the original settlement. */\nexport function coordinationEventId(\n context: SupervisorNodeContext,\n event: CoordinationEvent,\n): Sha256Digest {\n const durableEvent =\n event.type === 'settled' && event.worker.resumed === true\n ? (() => {\n const { resumed: _resumed, ...worker } = event.worker\n return { type: 'settled' as const, worker }\n })()\n : event\n return canonicalCandidateDigest({\n kind: 'supervise-coordination-event',\n runNamespace: context.runNamespace,\n ownerId: context.ownerId,\n event: detachedSnapshot(durableEvent, 'supervise coordination event identity'),\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuGA,SAAS,UAAU,OAAmC;CACpD,OAAO,MAAM,SAAS;AACxB;;AAGA,IAAa,sBAAb,MAA4D;CAI7B;CAH7B,eAAgC,uBAAuB;CACvD,aAAoC,QAAQ,QAAQ;CAEpD,YAAY,MAA+B;EAAd,KAAA,OAAA;CAAe;CAE5C,MAAM,OACJ,OACA,QACA,SACe;EACf,IAAI,CAAC,UAAU,OAAO,KAAK,GAAG;EAC9B,MAAM,SAAS,KAAK,WAAW,WAC7B,KAAK,mBAAmB,KAAK,aAAa,OAAO,QAAQ,OAAO,CAAC,CACnE;EACA,KAAK,aAAa,OAAO,YAAY,KAAA,CAAS;EAC9C,OAAO;CACT;CAEA,MAAc,aACZ,OACA,WACA,SACe;EACf,MAAM,KAAK,MAAM,OAAO;EACxB,MAAM,EAAE,YAAY,MAAM,OAAO;EACjC,MAAM,GAAG,MAAM,QAAQ,KAAK,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;EACtD,MAAM,SAAgC;GACpC;GACA,GAAI,YAAY,KAAA,IAAY,EAAE,QAAQ,IAAI,CAAC;GAC3C,GAAG;EACL;EACA,MAAM,wBAAwB,KAAK,MAAM,MAAM;CACjD;CAEA,MAAM,KAAK,OAAe,SAA2D;EACnF,OAAO,wBACL,uBAA4E,KAAK,MAAM,EACrF,cAAc,KAChB,CAAC,GACD,OACA,OACF;CACF;AACF;;AAGA,eAAsB,wBACpB,QAGA,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AS,YAAY,IAAI,CAAC;CACtE,CAAC,IACD,KAAA;CACN,OAAO;EAAE;EAAU,GAAI,MAAM,EAAE,IAAI,IAAI,CAAC;CAAG;AAC7C;AAEA,SAAgB,sBAAsB,UAAyC;CAC7E,OAAO,yBAAyB;EAAE,MAAM;EAAmB;CAAS,CAAC;AACvE;AAEA,SAAgB,uBACd,eACA,UACA,SACA,OACQ;CACR,OAAO,yBAAyB;EAC9B,MAAM;EACN;EACA;EACA,YAAY;GACV,IAAI,QAAQ;GACZ,OAAO,QAAQ;GACf,KAAK,QAAQ,OAAO;GACpB;EACF;CACF,CAAC;AACH;AAEA,SAAgB,wBAAwB,QAA4B,OAAuB;CACzF,OAAO,yBACL,WAAW,KAAA,IACP;EAAE,MAAM;EAA2B;EAAO,OAAO,WAAW;CAAE,IAC9D;EAAE,MAAM;EAAyB;EAAO,QAAQ,QAAQ,MAAM;CAAE,CACtE;AACF;AAEA,SAAgB,0BACd,cACA,eACA,cACQ;CACR,OAAO,yBAAyB;EAC9B,MAAM;EACN;EACA;EACA;CACF,CAAC;AACH;;;AAIA,SAAgB,oBACd,SACA,OACc;CACd,MAAM,eACJ,MAAM,SAAS,aAAa,MAAM,OAAO,YAAY,cAC1C;EACL,MAAM,EAAE,SAAS,UAAU,GAAG,WAAW,MAAM;EAC/C,OAAO;GAAE,MAAM;GAAoB;EAAO;CAC5C,EAAA,CAAG,IACH;CACN,OAAO,yBAAyB;EAC9B,MAAM;EACN,cAAc,QAAQ;EACtB,SAAS,QAAQ;EACjB,OAAO,iBAAiB,cAAc,uCAAuC;CAC/E,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"supervise-identity-CAxifVzJ.js","names":[],"sources":["../src/runtime/supervise/coordination-log.ts","../src/runtime/supervise/supervise-identity.ts"],"sourcesContent":["/**\n * Durable side-log for coordination evidence the spawn journal does not own: questions, analyst\n * findings, answer decisions, authorized continuation receipts, delivery-attempt markers, and\n * delivery outcomes. A durable run\n * (`supervise({ runDir })`) appends them as they publish and loads them on resume, so a restarted\n * coordinator retains the exact evidence produced by prior processes.\n *\n * Answer down-events also fold status on load: a question answered before the crash reloads as\n * `answered`, not as a re-blocking `open`. Settled events are skipped (the spawn journal is their\n * ledger). A receipt followed by an attempt but no outcome proves the process died in the delivery\n * window; that outcome remains unknown and no prior instruction is auto-delivered.\n *\n * JSONL, one fsynced record per event, keyed by `runId` — several runs may share one log file\n * exactly as they share one spawn-journal file.\n *\n * @experimental\n */\n\nimport { appendCommittedJsonLine, readCommittedJsonLines } from '../../durable/jsonl-file'\nimport { captureRunWriteContext } from '../../durable/run-fence'\nimport type {\n AnalystFindingEvent,\n DefinedAnalystRecord,\n} from '../../mcp/tools/coordination-analysts'\nimport type { CoordinationEvent } from '../../mcp/tools/coordination-events'\nimport type { ContinuationInstruction } from '../../mcp/tools/coordination-messages'\nimport type {\n QuestionEscalationRecord,\n QuestionRecord,\n} from '../../mcp/tools/coordination-questions'\nimport type { BusRecord } from './event-bus'\nimport type { PeerMailEvent } from './peer-mail'\n\n/** Stable identity of the supervisor that owns one coordination stream. High-level supervision\n * derives it from the exact root/child execution identity plus its parent assignment. */\nexport type CoordinationOwnerId = string\n\n/** Durable delivery evidence retained in commit order. An attempt without a later event carrying\n * the same `receiptId` has an unknown outcome after a crash and is never replayed. */\nexport type CoordinationDeliveryEvidence = Extract<\n CoordinationEvent,\n { readonly type: 'delivery-attempt' | 'steer' | 'answer' }\n>\n\n/** Coordination evidence loaded from prior processes of one durable supervised run. */\nexport interface PriorCoordination {\n /** The owner filter used for this replay. Omitted only for the compatibility all-owner read. */\n readonly ownerId?: CoordinationOwnerId\n /** Every question the prior process raised, with answer-status folded in, raise order. */\n readonly questions: ReadonlyArray<QuestionRecord>\n /** Every analyst finding the prior process published, publish order. */\n readonly findings: ReadonlyArray<AnalystFindingEvent>\n /** Every `ask_parent` escalation the prior process made, raise order. An undelivered one names a\n * question the run raised that nothing above it received — retained so a resuming operator sees\n * it, never auto-redelivered. */\n readonly escalations: ReadonlyArray<QuestionEscalationRecord>\n /** Every lens the prior process DEFINED at run time, definition order. The exact authored bytes\n * and their digest, so an invented lens can be re-registered and any finding it produced can be\n * traced to the words that produced it. Re-registration is the owner's decision, never automatic:\n * the registry may have changed between processes. */\n readonly analystDefinitions: ReadonlyArray<DefinedAnalystRecord>\n /** Every authorized continuation, in commit order. These are evidence, never replayed to a new\n * worker automatically. */\n readonly continuations: ReadonlyArray<ContinuationInstruction>\n /** Delivery intent and result records in commit order, linked to receipts by `receiptId`. */\n readonly deliveryEvidence: ReadonlyArray<CoordinationDeliveryEvidence>\n /** Every peer-mail attempt the prior process made, delivered and refused alike, in commit order.\n * Evidence of what siblings told each other; never replayed into a new worker's inbox. */\n readonly mail: ReadonlyArray<PeerMailEvent>\n /** Exact source-bus stamps in durable append order. Bus `seq` restarts with each process; append\n * order remains the cross-process replay order. */\n readonly records: ReadonlyArray<BusRecord<CoordinationEvent>>\n}\n\n/** The durable coordination side-log seam. `append` records one bus event (kinds it does not\n * persist are ignored); `load` replays a run's prior records folded into `PriorCoordination`. */\nexport interface CoordinationLog {\n append(\n runId: string,\n record: BusRecord<CoordinationEvent>,\n ownerId?: CoordinationOwnerId,\n ): Promise<void>\n load(runId: string, ownerId?: CoordinationOwnerId): Promise<PriorCoordination>\n}\n\ntype CoordinationLogRecord = {\n readonly runId: string\n readonly ownerId?: CoordinationOwnerId\n readonly seq: number\n readonly at: number\n readonly priority: number\n readonly event: CoordinationEvent\n}\n\ntype LegacyCoordinationLogRecord = {\n readonly runId: string\n readonly ownerId?: CoordinationOwnerId\n readonly at: string\n readonly event: CoordinationEvent\n}\n\n/** Persist prior context plus exact continuation authorization, attempt, and result evidence.\n * Settlements have their own journal. */\nfunction persisted(event: CoordinationEvent): boolean {\n return event.type !== 'settled'\n}\n\n/** FS-backed `CoordinationLog`: append-only JSONL, fsynced per record. */\nexport class FileCoordinationLog implements CoordinationLog {\n private readonly writeContext = captureRunWriteContext()\n private appendTail: Promise<void> = Promise.resolve()\n\n constructor(private readonly path: string) {}\n\n async append(\n runId: string,\n record: BusRecord<CoordinationEvent>,\n ownerId?: CoordinationOwnerId,\n ): Promise<void> {\n if (!persisted(record.event)) return\n const append = this.appendTail.then(() =>\n this.writeContext(() => this.appendRecord(runId, record, ownerId)),\n )\n this.appendTail = append.catch(() => undefined)\n return append\n }\n\n private async appendRecord(\n runId: string,\n busRecord: BusRecord<CoordinationEvent>,\n ownerId?: CoordinationOwnerId,\n ): Promise<void> {\n const fs = await import('node:fs/promises')\n const { dirname } = await import('node:path')\n await fs.mkdir(dirname(this.path), { recursive: true })\n const record: CoordinationLogRecord = {\n runId,\n ...(ownerId !== undefined ? { ownerId } : {}),\n ...busRecord,\n }\n await appendCommittedJsonLine(this.path, record)\n }\n\n async load(runId: string, ownerId?: CoordinationOwnerId): Promise<PriorCoordination> {\n return foldCoordinationRecords(\n readCommittedJsonLines<CoordinationLogRecord | LegacyCoordinationLogRecord>(this.path, {\n allowMissing: true,\n }),\n runId,\n ownerId,\n )\n }\n}\n\n/** @internal Shared replay semantics for file and SQL coordination evidence. */\nexport async function foldCoordinationRecords(\n source:\n | Iterable<CoordinationLogRecord | LegacyCoordinationLogRecord>\n | AsyncIterable<CoordinationLogRecord | LegacyCoordinationLogRecord>,\n runId: string,\n ownerId?: CoordinationOwnerId,\n): Promise<PriorCoordination> {\n const byId = new Map<string, QuestionRecord>()\n const findings: AnalystFindingEvent[] = []\n const escalations: QuestionEscalationRecord[] = []\n const analystDefinitions: DefinedAnalystRecord[] = []\n const continuations: ContinuationInstruction[] = []\n const deliveryEvidence: CoordinationDeliveryEvidence[] = []\n const mail: PeerMailEvent[] = []\n const records: BusRecord<CoordinationEvent>[] = []\n let legacySeq = 0\n for await (const stored of source) {\n if (stored.runId !== runId) continue\n // Omitting ownerId preserves the historical all-run read for direct consumers. Runtime always\n // supplies one, so root and nested supervisors never receive one another's evidence.\n if (ownerId !== undefined && stored.ownerId !== ownerId) continue\n const record: BusRecord<CoordinationEvent> =\n 'seq' in stored\n ? {\n seq: stored.seq,\n at: stored.at,\n priority: stored.priority,\n event: stored.event,\n }\n : {\n seq: legacySeq++,\n at: Date.parse(stored.at),\n priority: 0,\n event: stored.event,\n }\n records.push(record)\n const ev = record.event\n if (ev.type === 'delivery-attempt' || ev.type === 'steer' || ev.type === 'answer') {\n deliveryEvidence.push(ev)\n }\n if (ev.type === 'question') {\n byId.set(ev.question.id, ev.question)\n } else if (ev.type === 'finding') {\n findings.push(ev.finding)\n } else if (ev.type === 'answer') {\n // Only accepted delivery resolves a blocking question. Authorization and an attempted\n // refusal remain evidence, but cannot turn \"worker never received the answer\" into answered\n // state on replay. `by` is not on the wire; prior-run is the honest attribution.\n const prior = byId.get(ev.questionId)\n if (prior && ev.down.delivered) {\n byId.set(ev.questionId, {\n ...prior,\n status: 'answered',\n decision: { kind: 'answer', answer: ev.down.instruction, by: 'prior-run' },\n })\n }\n } else if (ev.type === 'instruction') {\n continuations.push(ev.instruction)\n } else if (ev.type === 'mail') {\n mail.push(ev.mail)\n } else if (ev.type === 'escalation') {\n escalations.push(ev.escalation)\n } else if (ev.type === 'analyst-defined') {\n analystDefinitions.push(ev.analyst)\n }\n }\n return {\n ...(ownerId !== undefined ? { ownerId } : {}),\n questions: [...byId.values()],\n findings,\n escalations,\n analystDefinitions,\n continuations,\n deliveryEvidence,\n mail,\n records,\n }\n}\n","import { randomUUID } from 'node:crypto'\nimport { resolve } from 'node:path'\nimport {\n type AgentProfile,\n agentProfileSchema,\n canonicalCandidateDigest,\n type Sha256Digest,\n} from '@tangle-network/agent-interface'\nimport { ValidationError } from '../../errors'\nimport type { WorkerSpawnContext } from '../../mcp/tools/coordination-contracts'\nimport type { CoordinationEvent } from '../../mcp/tools/coordination-events'\nimport { deriveNodeExecutionIdentity } from './scope'\nimport { detachedSnapshot } from './snapshot'\nimport type { SupervisorNodeContext } from './supervisor-agent'\nimport type { AgentExecutionRef, NodeExecutionIdentity } from './types'\n\nexport function externalExecutionId(kind: string, identity: unknown): string {\n const digest = canonicalCandidateDigest({ kind, identity })\n return `${kind}-${digest.slice('sha256:'.length)}`\n}\n\nexport function freezeDetached<T>(value: T): T {\n return detachedSnapshot(value, 'supervise')\n}\n\nexport function freezeDetachedProfile(value: unknown): AgentProfile {\n return freezeDetached(agentProfileSchema.parse(value))\n}\n\nexport function canonicalExecution(\n profile: AgentProfile,\n task: unknown,\n rawExecution: AgentExecutionRef | undefined,\n context: string,\n): { readonly identity: NodeExecutionIdentity; readonly ref?: AgentExecutionRef } {\n const execution = rawExecution === undefined ? undefined : freezeDetached(rawExecution)\n if (execution !== undefined) {\n if (typeof execution !== 'object' || execution === null || Array.isArray(execution)) {\n throw new ValidationError(`${context}: execution must be an object`)\n }\n const unknown = Object.keys(execution).filter(\n (key) => key !== 'candidateDigest' && key !== 'correlation',\n )\n if (unknown.length > 0) {\n throw new ValidationError(`${context}: unknown execution fields: ${unknown.join(', ')}`)\n }\n }\n const identity = deriveNodeExecutionIdentity({ profile, execution }, task)\n if (!identity?.profileDigest || !identity.taskDigest) {\n throw new ValidationError(\n `${context}: profile and task must be finite, acyclic canonical JSON for durable identity`,\n )\n }\n const ref: AgentExecutionRef | undefined =\n identity.candidateDigest || identity.correlation\n ? Object.freeze({\n ...(identity.candidateDigest ? { candidateDigest: identity.candidateDigest } : {}),\n ...(identity.correlation ? { correlation: identity.correlation } : {}),\n })\n : undefined\n return { identity, ...(ref ? { ref } : {}) }\n}\n\nexport function rootCoordinationOwner(identity: NodeExecutionIdentity): string {\n return canonicalCandidateDigest({ kind: 'supervisor-root', identity })\n}\n\nexport function childCoordinationOwner(\n parentOwnerId: string,\n identity: NodeExecutionIdentity,\n context: WorkerSpawnContext,\n depth: number,\n): string {\n return canonicalCandidateDigest({\n kind: 'supervisor-child',\n parentOwnerId,\n identity,\n assignment: {\n id: context.assignmentId,\n label: context.label,\n key: context.key ?? null,\n depth,\n },\n })\n}\n\nexport function supervisionRunNamespace(runDir: string | undefined, runId: string): string {\n return canonicalCandidateDigest(\n runDir === undefined\n ? { kind: 'supervise-ephemeral-run', runId, nonce: randomUUID() }\n : { kind: 'supervise-durable-run', runId, runDir: resolve(runDir) },\n )\n}\n\nexport function workerAssignmentNamespace(\n runNamespace: string,\n parentOwnerId: string,\n assignmentId: string,\n): string {\n return canonicalCandidateDigest({\n kind: 'supervise-worker-assignment',\n runNamespace,\n parentOwnerId,\n assignmentId,\n })\n}\n\n/** Hash only durable coordination meaning. Bus sequence/timestamp are delivery metadata and a\n * resumed projection's marker describes the reader, not the original settlement. */\nexport function coordinationEventId(\n context: SupervisorNodeContext,\n event: CoordinationEvent,\n): Sha256Digest {\n const durableEvent =\n event.type === 'settled' && event.worker.resumed === true\n ? (() => {\n const { resumed: _resumed, ...worker } = event.worker\n return { type: 'settled' as const, worker }\n })()\n : event\n return canonicalCandidateDigest({\n kind: 'supervise-coordination-event',\n runNamespace: context.runNamespace,\n ownerId: context.ownerId,\n event: detachedSnapshot(durableEvent, 'supervise coordination event identity'),\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuGA,SAAS,UAAU,OAAmC;CACpD,OAAO,MAAM,SAAS;AACxB;;AAGA,IAAa,sBAAb,MAA4D;CAI7B;CAH7B,eAAgC,uBAAuB;CACvD,aAAoC,QAAQ,QAAQ;CAEpD,YAAY,MAA+B;EAAd,KAAA,OAAA;CAAe;CAE5C,MAAM,OACJ,OACA,QACA,SACe;EACf,IAAI,CAAC,UAAU,OAAO,KAAK,GAAG;EAC9B,MAAM,SAAS,KAAK,WAAW,WAC7B,KAAK,mBAAmB,KAAK,aAAa,OAAO,QAAQ,OAAO,CAAC,CACnE;EACA,KAAK,aAAa,OAAO,YAAY,KAAA,CAAS;EAC9C,OAAO;CACT;CAEA,MAAc,aACZ,OACA,WACA,SACe;EACf,MAAM,KAAK,MAAM,OAAO;EACxB,MAAM,EAAE,YAAY,MAAM,OAAO;EACjC,MAAM,GAAG,MAAM,QAAQ,KAAK,IAAI,GAAG,EAAE,WAAW,K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;EACjB,OAAO,iBAAiB,cAAc,uCAAuC;CAC/E,CAAC;AACH"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-DG8yufqX.js";
|
|
2
|
-
import { c as budgetOverspendText, f as createFileRunContext, i as createCoordinationToolsForManager, l as coordinationVerbNames, m as withRunContext, n as createSteerAcknowledger, p as createInMemoryRunContext, r as createCoordinationTools, t as createCancelAcknowledger, u as normalizeAnalyzeOnSettle } from "./driver-control-acknowledgers-
|
|
3
|
-
import { $t as worktreeCliProfileMaterialization, B as toolResultText, C as captureReusableExecutorConfig, Ct as bridgeAdmissionRefusal, Gt as fullProfileMaterialization, H as routerBrain, I as codeModeArguments, Jt as promptModelProfileMaterialization, K as providerOutputOptions, Kt as profileMaterializationAxes$1, L as codeModeModelOutput, Mt as bridgeRuntimeAttachmentsKey, Nt as bridgeRuntimeEnvKey, Pt as bridgeStopSignalKey, Q as createInbox, Qt as unsupportedProfileDimensions, R as createCodeModeTools, S as bindReusableExecutorExecutionId, T as snapshotExecutorConfig, Ut as controlProfileMaterialization, V as createRouterTranscript, Vt as assertProfileMaterialization, W as resolveAgentEnvironmentProvider, Wt as defineProfileMaterializationContract, Yt as renderUnsupported, Z as INBOX_RECEIPT_KEY, Zt as sandboxProfileMaterialization, _ as isDriverSpec, _t as preflightPublicCoordination, a as awaitRootWake, at as isPeerMailEnvelope, d as bestDelivered, dt as abandonablePending, f as runFinalizer, ft as classifyDriverFailure, g as driverExecutorFactory, gt as upstreamUnavailableSignal, h as driverChild, ht as undispatchedCredentialExit, i as assertRunParking, l as sleepScopeWait, lt as DriverAttemptsExhaustedError, m as createRootHandle, mt as transientFailureKind, n as createSupervisor, nt as PEER_MAIL_WIRE_KEY, o as bindScopeParkingDrain, p as runTree, pt as summarizeDriverAttempts, qt as promptControlProfileMaterialization, r as RunParkedError, s as isRunParked, u as withRunParking, ut as HarnessTurnFailedError, vt as CheckUnavailableError, w as createExecutor, wt as bridgeModelRouteRefusal, yt as gateFactoryOnDeliverable } from "./supervisor-
|
|
4
|
-
import { a as freezeDetached, c as supervisionRunNamespace, i as externalExecutionId, l as workerAssignmentNamespace, n as childCoordinationOwner, o as freezeDetachedProfile, r as coordinationEventId, s as rootCoordinationOwner, t as canonicalExecution } from "./supervise-identity-
|
|
2
|
+
import { c as budgetOverspendText, f as createFileRunContext, i as createCoordinationToolsForManager, l as coordinationVerbNames, m as withRunContext, n as createSteerAcknowledger, p as createInMemoryRunContext, r as createCoordinationTools, t as createCancelAcknowledger, u as normalizeAnalyzeOnSettle } from "./driver-control-acknowledgers-C6WDdngb.js";
|
|
3
|
+
import { $t as worktreeCliProfileMaterialization, B as toolResultText, C as captureReusableExecutorConfig, Ct as bridgeAdmissionRefusal, Gt as fullProfileMaterialization, H as routerBrain, I as codeModeArguments, Jt as promptModelProfileMaterialization, K as providerOutputOptions, Kt as profileMaterializationAxes$1, L as codeModeModelOutput, Mt as bridgeRuntimeAttachmentsKey, Nt as bridgeRuntimeEnvKey, Pt as bridgeStopSignalKey, Q as createInbox, Qt as unsupportedProfileDimensions, R as createCodeModeTools, S as bindReusableExecutorExecutionId, T as snapshotExecutorConfig, Ut as controlProfileMaterialization, V as createRouterTranscript, Vt as assertProfileMaterialization, W as resolveAgentEnvironmentProvider, Wt as defineProfileMaterializationContract, Yt as renderUnsupported, Z as INBOX_RECEIPT_KEY, Zt as sandboxProfileMaterialization, _ as isDriverSpec, _t as preflightPublicCoordination, a as awaitRootWake, at as isPeerMailEnvelope, d as bestDelivered, dt as abandonablePending, f as runFinalizer, ft as classifyDriverFailure, g as driverExecutorFactory, gt as upstreamUnavailableSignal, h as driverChild, ht as undispatchedCredentialExit, i as assertRunParking, l as sleepScopeWait, lt as DriverAttemptsExhaustedError, m as createRootHandle, mt as transientFailureKind, n as createSupervisor, nt as PEER_MAIL_WIRE_KEY, o as bindScopeParkingDrain, p as runTree, pt as summarizeDriverAttempts, qt as promptControlProfileMaterialization, r as RunParkedError, s as isRunParked, u as withRunParking, ut as HarnessTurnFailedError, vt as CheckUnavailableError, w as createExecutor, wt as bridgeModelRouteRefusal, yt as gateFactoryOnDeliverable } from "./supervisor-9_oKaGd_.js";
|
|
4
|
+
import { a as freezeDetached, c as supervisionRunNamespace, i as externalExecutionId, l as workerAssignmentNamespace, n as childCoordinationOwner, o as freezeDetachedProfile, r as coordinationEventId, s as rootCoordinationOwner, t as canonicalExecution } from "./supervise-identity-CAxifVzJ.js";
|
|
5
5
|
import { a as errMessage, c as errorStack, f as defaultRedactor, i as causeChain, l as errorText, n as detachedSnapshot, o as errorHttpStatus, u as providerTraceId } from "./snapshot-BKLziJ5K.js";
|
|
6
6
|
import { t as composeRuntimeHooks } from "./runtime-hooks-CsW2pfFk.js";
|
|
7
|
-
import { $n as generateSpanId, $r as runtimeOwnedScopeOwnerRuntime, $t as reconcileScopeRetainedOwnerEnvironment, Bt as recordScopeOwnerHarnessTranscript, Cr as isTerminalNodeStatus, Dr as authoredSeatStages, Dt as scopeRetainedOwnerResourceReader, Er as SeatPauseError, Et as releaseScopeRetainedOwnerForSeatPause, Ft as scopeRetainedOwnerResult, Gt as coordinationMcpAlias, Hr as recordRuntimeOwnedDriveHarnessProviderEvidence, Ht as restoreScopeOwnerAcceptedExecution, It as beginScopeOwnerAttempt, Jr as runtimeOwnedExecutorExecutionBinding, Jt as runtimeGraphMetadataKey, Kt as coordinationProfileToolPrefix, Mt as consumeScopeRetainedOwnerResult, Nr as attestRuntimeOwnedScopeOwner, Nt as prepareScopeRetainedOwnerTask, Or as seatExecutionProfile, Pr as authoredAgentIdentity, Pt as scopeRetainedOwnerPriorSpend, Qt as assertRetainedOwnerCoordinationRekey, Rt as holdScopeOwnerTranscript, Sr as isLiveNodeStatus, Tr as SeatChain, Tt as prepareScopeRetainedOwnerSeatSwitch, Ut as scopeOwnerExecutionObservation, V as parseWorkerToolTraceArtifact, Vn as WORKER_TRACE_PROPAGATION, Vr as providerAttemptEvidence, Vt as recordScopeOwnerMaterialization, Wt as scopeOwnerExecutorNodeContext, Xr as runtimeOwnedExecutorProviderEvidence, Yr as runtimeOwnedExecutorMaterialization, Yt as beginScopeRetainedOwnerDrive, Zn as createOtelExporter, Zr as runtimeOwnedPendingExecutorMaterialization, Zt as scopeRetainedOwnerTurnEnded, an as owners, cn as scopeRetainedOwnerJournalRoot, dr as persistHarnessTranscript, dt as meterRuntimeOwnedAccounting, en as scopeRetainedOwnerRestorePoint, fr as readHarnessTranscript, ft as meterRuntimeOwnedProviderAttempt, gt as recordScopeOwnerPause, ht as recordScopeOwnerDriverAttempt, i as ROOT_STREAM_FILE, ii as isRuntimeFlowBrain, in as bindScopeRetainedOwnerProvider, jt as abandonScopeRetainedOwnerInvocation, l as readRootStream, mt as recordScopeOwnerBarrenPause, nt as assertRecursiveReservationPolicy, o as createRootStreamSink, oi as runtimeFlowAgent, pr as settleHarnessTranscript, pt as pauseScopeSeatAdmission, qr as runtimeOwnedDriveHarnessProviderEvidence, qt as providerVisibleProfile, rn as bindScopeRetainedOwnerEnvironmentId, si as runtimeFlowBrain, sn as scopeRetainedOwnerContext, tn as noteScopeRetainedOwnerCoordination, vn as executorObservationSeamKey, wr as SEAT_RECHECK_MS, yr as createActivityLog, zt as noteScopeOwnerPlannedExecution } from "./supervisor-accounting-
|
|
7
|
+
import { $n as generateSpanId, $r as runtimeOwnedScopeOwnerRuntime, $t as reconcileScopeRetainedOwnerEnvironment, Bt as recordScopeOwnerHarnessTranscript, Cr as isTerminalNodeStatus, Dr as authoredSeatStages, Dt as scopeRetainedOwnerResourceReader, Er as SeatPauseError, Et as releaseScopeRetainedOwnerForSeatPause, Ft as scopeRetainedOwnerResult, Gt as coordinationMcpAlias, Hr as recordRuntimeOwnedDriveHarnessProviderEvidence, Ht as restoreScopeOwnerAcceptedExecution, It as beginScopeOwnerAttempt, Jr as runtimeOwnedExecutorExecutionBinding, Jt as runtimeGraphMetadataKey, Kt as coordinationProfileToolPrefix, Mt as consumeScopeRetainedOwnerResult, Nr as attestRuntimeOwnedScopeOwner, Nt as prepareScopeRetainedOwnerTask, Or as seatExecutionProfile, Pr as authoredAgentIdentity, Pt as scopeRetainedOwnerPriorSpend, Qt as assertRetainedOwnerCoordinationRekey, Rt as holdScopeOwnerTranscript, Sr as isLiveNodeStatus, Tr as SeatChain, Tt as prepareScopeRetainedOwnerSeatSwitch, Ut as scopeOwnerExecutionObservation, V as parseWorkerToolTraceArtifact, Vn as WORKER_TRACE_PROPAGATION, Vr as providerAttemptEvidence, Vt as recordScopeOwnerMaterialization, Wt as scopeOwnerExecutorNodeContext, Xr as runtimeOwnedExecutorProviderEvidence, Yr as runtimeOwnedExecutorMaterialization, Yt as beginScopeRetainedOwnerDrive, Zn as createOtelExporter, Zr as runtimeOwnedPendingExecutorMaterialization, Zt as scopeRetainedOwnerTurnEnded, an as owners, cn as scopeRetainedOwnerJournalRoot, dr as persistHarnessTranscript, dt as meterRuntimeOwnedAccounting, en as scopeRetainedOwnerRestorePoint, fr as readHarnessTranscript, ft as meterRuntimeOwnedProviderAttempt, gt as recordScopeOwnerPause, ht as recordScopeOwnerDriverAttempt, i as ROOT_STREAM_FILE, ii as isRuntimeFlowBrain, in as bindScopeRetainedOwnerProvider, jt as abandonScopeRetainedOwnerInvocation, l as readRootStream, mt as recordScopeOwnerBarrenPause, nt as assertRecursiveReservationPolicy, o as createRootStreamSink, oi as runtimeFlowAgent, pr as settleHarnessTranscript, pt as pauseScopeSeatAdmission, qr as runtimeOwnedDriveHarnessProviderEvidence, qt as providerVisibleProfile, rn as bindScopeRetainedOwnerEnvironmentId, si as runtimeFlowBrain, sn as scopeRetainedOwnerContext, tn as noteScopeRetainedOwnerCoordination, vn as executorObservationSeamKey, wr as SEAT_RECHECK_MS, yr as createActivityLog, zt as noteScopeOwnerPlannedExecution } from "./supervisor-accounting-DLjKVPwf.js";
|
|
8
8
|
import { _ as runAbortable, g as linkAbort, p as RunCancellationReason } from "./jsonl-file-B8xfYz9M.js";
|
|
9
9
|
import { a as createContinuationKeeper, i as checkVerdictOf, n as admitContinuationPolicy, r as bestComposite, t as CONTINUATIONS_DIR } from "./continuation-CDdjAkpk.js";
|
|
10
|
-
import {
|
|
11
|
-
import { a as readRunCancelRequest, d as writeRunCancellationAsync, l as watchRunCancellation, n as applyRunCancellationAsync, o as readRunCancellation, t as applyRunCancellation } from "./run-cancellation-
|
|
10
|
+
import { A as unavailableResumeAt, B as harnessProcessDied, F as contentAddress, H as turnFailureOf, L as executorFailure, O as reportedResetAt, T as jitteredMs, U as turnFailurePolicy, _ as registerRetainedExecutorPreparation, at as assertValidBudget, b as PLACEMENT_SIGNALS, g as refusedBeforeItRan, it as spendFromUsageTotals, jt as recordValue, k as unavailablePauseMs, l as RetainedExecutionPendingError, nt as newUsageTotals, tt as meterUsageEvent, v as retainedExecutorContext, w as cappedDoublingMs, x as RATE_LIMIT_SIGNALS, y as retainedExecutorSeamKey } from "./failure-cause-C96rzF-d.js";
|
|
11
|
+
import { a as readRunCancelRequest, d as writeRunCancellationAsync, l as watchRunCancellation, n as applyRunCancellationAsync, o as readRunCancellation, t as applyRunCancellation } from "./run-cancellation-ewCqEeaB.js";
|
|
12
12
|
import { o as safeJsonText } from "./coordination-map-routing-DovTCk1Y.js";
|
|
13
|
-
import { n as createStdioToolServer } from "./tool-server
|
|
13
|
+
import { n as createStdioToolServer } from "./tool-server-BhsyVDj2.js";
|
|
14
14
|
import { A as withBudgetResources, D as addResourceSpend, S as unmeteredSpend, T as zeroSpend, c as errorMessage, f as isAsyncIterable, i as chargedTokens, k as resourceTelemetry, m as promptCacheTokenClasses, n as addSpend, v as sleep, w as withTimeout } from "./util-qsH5cC9S.js";
|
|
15
15
|
import { d as teardownExecutor, i as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, l as isDeadlineAbortReason, o as armDeadlineTimer } from "./deadline-CySmJ_0S.js";
|
|
16
16
|
import { a as concreteProfileModel, b as harnessRunsAgent, c as profileModelExecutionSettings, l as profileProviderModel, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile, v as agentHarness } from "./model-policy-DFuhCC0-.js";
|
|
@@ -5264,14 +5264,7 @@ var DriverRetryLoop = class {
|
|
|
5264
5264
|
retryInMs: pauseMs,
|
|
5265
5265
|
resumeAt: new Date(pausedAt + pauseMs).toISOString()
|
|
5266
5266
|
});
|
|
5267
|
-
|
|
5268
|
-
const wait = AbortSignal.any([run.signal, steered.signal]);
|
|
5269
|
-
steering.steered(wait).then(() => steered.abort());
|
|
5270
|
-
try {
|
|
5271
|
-
await limits.sleep(pauseMs, wait);
|
|
5272
|
-
} finally {
|
|
5273
|
-
steered.abort();
|
|
5274
|
-
}
|
|
5267
|
+
await this.sleepUntilSteered(steering, pauseMs);
|
|
5275
5268
|
const ended = run.signal.aborted ? abortStop(run.signal) : limits.now() >= this.deadlineAt() ? "deadline" : void 0;
|
|
5276
5269
|
if (ended !== void 0) {
|
|
5277
5270
|
await this.emit({
|
|
@@ -5505,8 +5498,25 @@ var DriverRetryLoop = class {
|
|
|
5505
5498
|
barren
|
|
5506
5499
|
};
|
|
5507
5500
|
}
|
|
5501
|
+
/**
|
|
5502
|
+
* Sleep through a pause that a cancel or a root steer ends early; true when a steer ended it. A
|
|
5503
|
+
* steer ends every pause, a budget or barren pause included: it is how an operator changes a live
|
|
5504
|
+
* run. `steered` answers each steer once, so a pool still spent pauses again on its ladder.
|
|
5505
|
+
*/
|
|
5506
|
+
async sleepUntilSteered(steering, pauseMs) {
|
|
5507
|
+
const steered = new AbortController();
|
|
5508
|
+
const wait = AbortSignal.any([this.run.signal, steered.signal]);
|
|
5509
|
+
steering.steered(wait).then(() => steered.abort());
|
|
5510
|
+
try {
|
|
5511
|
+
await this.limits.sleep(pauseMs, wait);
|
|
5512
|
+
return steered.signal.aborted && !this.run.signal.aborted;
|
|
5513
|
+
} finally {
|
|
5514
|
+
steered.abort();
|
|
5515
|
+
}
|
|
5516
|
+
}
|
|
5508
5517
|
/** A barren streak at `maxBarren` paces the run and never ends it: journal the pause and sleep
|
|
5509
|
-
* through it, never past the earlier deadline; the caller reads the bounds again after.
|
|
5518
|
+
* through it, never past the earlier deadline; the caller reads the bounds again after. An
|
|
5519
|
+
* opted-in root's steer ends the pause, and the next turn is told the time it actually waited. */
|
|
5510
5520
|
async barrenPause(policy, attempt) {
|
|
5511
5521
|
if (this.barrenReentries < policy.maxBarren) return void 0;
|
|
5512
5522
|
const { run } = this;
|
|
@@ -5520,10 +5530,17 @@ var DriverRetryLoop = class {
|
|
|
5520
5530
|
lastProgressAt: new Date(this.lastProgressAt).toISOString()
|
|
5521
5531
|
};
|
|
5522
5532
|
await run.onBarrenPause?.(pause);
|
|
5523
|
-
|
|
5533
|
+
if (run.stopPause === void 0) {
|
|
5534
|
+
await this.limits.sleep(pauseMs, run.signal);
|
|
5535
|
+
return {
|
|
5536
|
+
streak: this.barrenReentries,
|
|
5537
|
+
pausedMs: pauseMs
|
|
5538
|
+
};
|
|
5539
|
+
}
|
|
5540
|
+
const pausedMs = await this.sleepUntilSteered(run.stopPause, pauseMs) ? Math.max(0, this.limits.now() - pausedAt) : pauseMs;
|
|
5524
5541
|
return {
|
|
5525
5542
|
streak: this.barrenReentries,
|
|
5526
|
-
pausedMs
|
|
5543
|
+
pausedMs
|
|
5527
5544
|
};
|
|
5528
5545
|
}
|
|
5529
5546
|
/** Read a completed drive: wait, continue, or end the loop. True re-enters the driver. */
|
|
@@ -8096,23 +8113,25 @@ var DriverExecutionAttempt = class {
|
|
|
8096
8113
|
}
|
|
8097
8114
|
async meterUnmeteredAttempts() {
|
|
8098
8115
|
const { scope, executor } = this;
|
|
8116
|
+
const refused = refusedBeforeItRan(this.failure);
|
|
8099
8117
|
for (;;) {
|
|
8100
8118
|
const evidence = runtimeOwnedExecutorProviderEvidence(executor);
|
|
8101
8119
|
if ((evidence?.attempts.length ?? 0) <= this.meteredProviderAttempts) break;
|
|
8102
|
-
const
|
|
8120
|
+
const attempt = evidence?.attempts[this.meteredProviderAttempts];
|
|
8121
|
+
const providerDispatchDidNotStart = attempt?.providerDispatch === "not_started" || refused && attempt?.observations.length === 0 && attempt.identityConflict !== true;
|
|
8103
8122
|
await meterRuntimeOwnedProviderAttempt(scope, withBudgetResources(providerDispatchDidNotStart ? zeroSpend() : unmeteredSpend(0), scope.budget, providerDispatchDidNotStart), this.nextProviderEvidence(), {
|
|
8104
8123
|
role: "driver",
|
|
8105
8124
|
runtime: executor.runtime,
|
|
8106
8125
|
telemetry: providerDispatchDidNotStart ? "known-zero-before-dispatch" : "unknown-after-failure"
|
|
8107
8126
|
});
|
|
8108
8127
|
}
|
|
8109
|
-
if (this.meteredProviderAttempts === 0) await meterRuntimeOwnedProviderAttempt(scope, withBudgetResources(unmeteredSpend(0), scope.budget), this.nextProviderEvidence(), {
|
|
8128
|
+
if (this.meteredProviderAttempts === 0) await meterRuntimeOwnedProviderAttempt(scope, withBudgetResources(refused ? zeroSpend() : unmeteredSpend(0), scope.budget, refused), this.nextProviderEvidence(), {
|
|
8110
8129
|
role: "driver",
|
|
8111
8130
|
runtime: executor.runtime,
|
|
8112
|
-
telemetry: "unknown-after-failure"
|
|
8131
|
+
telemetry: refused ? "known-zero-before-dispatch" : "unknown-after-failure"
|
|
8113
8132
|
});
|
|
8114
8133
|
const attempts = runtimeOwnedExecutorProviderEvidence(executor)?.attempts;
|
|
8115
|
-
const provenNotStarted = attempts !== void 0 && attempts.length > 0 && attempts.every((attempt) => attempt.providerDispatch === "not_started");
|
|
8134
|
+
const provenNotStarted = refused || attempts !== void 0 && attempts.length > 0 && attempts.every((attempt) => attempt.providerDispatch === "not_started");
|
|
8116
8135
|
if (scope.budget.resources !== void 0 && !provenNotStarted) await meterRuntimeOwnedAccounting(scope, withBudgetResources(zeroSpend(), scope.budget), {
|
|
8117
8136
|
role: "driver",
|
|
8118
8137
|
runtime: executor.runtime,
|
|
@@ -8242,8 +8261,9 @@ var ManagerDriveSession = class {
|
|
|
8242
8261
|
const seatJournalRoot = scopeRetainedOwnerJournalRoot(scope) ?? seatSelection.rootId;
|
|
8243
8262
|
this.seatChain ??= new SeatChain(authoredProfile, scope.view.root, seatJournalRoot, seatSelection.journal, seatSelection.select, now, (segment, phase) => seatSelection.onSegment(scope.view.root, segment, phase), async (selection, previous) => {
|
|
8244
8263
|
if (!previous || previous.seat === selection.seat) return;
|
|
8245
|
-
const sameEnvironment = previous.provider === selection.stage.provider && previous.harness === selection.stage.harness;
|
|
8264
|
+
const sameEnvironment = selection.nativeTurnGrant === true && previous.provider === selection.stage.provider && previous.harness === selection.stage.harness;
|
|
8246
8265
|
try {
|
|
8266
|
+
if (!sameEnvironment && (await reconcileScopeRetainedOwnerEnvironment(scope, "running")).state === "lost") return;
|
|
8247
8267
|
const checkpointAt = await prepareScopeRetainedOwnerSeatSwitch(scope, sameEnvironment ? "same-environment" : "replace-environment");
|
|
8248
8268
|
if (!sameEnvironment) this.switchedProviderCheckpointAt = checkpointAt;
|
|
8249
8269
|
} catch (error) {
|
|
@@ -8547,7 +8567,7 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
|
|
|
8547
8567
|
const priorCommittedArtifact = state.managerArtifact;
|
|
8548
8568
|
state.managerArtifact = void 0;
|
|
8549
8569
|
manager.switchedProviderCheckpointAt = void 0;
|
|
8550
|
-
await bindDriveRetainedOwner(manager, args);
|
|
8570
|
+
if (await bindDriveRetainedOwner(manager, args) !== void 0 && args.reentry?.reason.reason === "run-reentered") await reconcileScopeRetainedOwnerEnvironment(scope, "released");
|
|
8551
8571
|
await manager.selectSeat(args, seatSelection, executionId, now);
|
|
8552
8572
|
const retainedOwner = await bindDriveRetainedOwner(manager, args);
|
|
8553
8573
|
const driveTask = args.reentry === void 0 ? args.task : await reentryDriveTask(manager, args, args.reentry, retainedOwner !== void 0, priorCommittedArtifact);
|
|
@@ -8630,13 +8650,13 @@ async function bindDriveRetainedOwner(manager, { scope }) {
|
|
|
8630
8650
|
}
|
|
8631
8651
|
async function reentryDriveTask(manager, { scope, session }, reentry, retainedOwner, priorCommittedArtifact) {
|
|
8632
8652
|
const { activeSeat, switchedProviderCheckpointAt } = manager;
|
|
8633
|
-
const proven = reentry.reason.reason === "run-reentered" ?
|
|
8653
|
+
const proven = reentry.reason.reason === "run-reentered" ? await recoveredContinuity(manager.state.boundBackend, scope, retainedOwner) : switchedProviderCheckpointAt === void 0 ? await reentryContinuity(manager.state.boundBackend, scope, retainedOwner) : {
|
|
8634
8654
|
session: "new",
|
|
8635
8655
|
environment: "replaced",
|
|
8636
8656
|
workspace: "restored",
|
|
8637
8657
|
checkpointAt: switchedProviderCheckpointAt
|
|
8638
8658
|
};
|
|
8639
|
-
if (activeSeat?.previous && activeSeat.previous.seat !== activeSeat.seat && activeSeat.previous.provider === activeSeat.stage.provider && activeSeat.previous.harness === activeSeat.stage.harness && (proven.session !== "continued" || proven.environment !== "same")) throw new ValidationError("same-provider seat continuation lost its native environment");
|
|
8659
|
+
if (activeSeat?.nativeTurnGrant === true && activeSeat.previous && activeSeat.previous.seat !== activeSeat.seat && activeSeat.previous.provider === activeSeat.stage.provider && activeSeat.previous.harness === activeSeat.stage.harness && (proven.session !== "continued" || proven.environment !== "same")) throw new ValidationError("same-provider seat continuation lost its native environment");
|
|
8640
8660
|
const continuity = session === "fresh" && proven.session === "continued" ? {
|
|
8641
8661
|
...proven,
|
|
8642
8662
|
session: "new"
|
|
@@ -8682,20 +8702,28 @@ async function reentryContinuity(backend, scope, retainedOwner) {
|
|
|
8682
8702
|
environmentId: environment.environmentId,
|
|
8683
8703
|
workspace: "kept"
|
|
8684
8704
|
};
|
|
8685
|
-
if (environment.state === "lost")
|
|
8686
|
-
const restorePoint = await scopeRetainedOwnerRestorePoint(scope);
|
|
8687
|
-
return {
|
|
8688
|
-
session: "new",
|
|
8689
|
-
environment: "replaced",
|
|
8690
|
-
previousEnvironmentId: environment.environmentId,
|
|
8691
|
-
...restorePoint === void 0 ? { workspace: "lost" } : {
|
|
8692
|
-
workspace: "restored",
|
|
8693
|
-
checkpointAt: restorePoint.takenAt
|
|
8694
|
-
}
|
|
8695
|
-
};
|
|
8696
|
-
}
|
|
8705
|
+
if (environment.state === "lost") return replacedContinuity(scope, environment.environmentId);
|
|
8697
8706
|
return UNPROVEN_CONTINUITY;
|
|
8698
8707
|
}
|
|
8708
|
+
/** A restarted run proves only a loss: its own recovery decides whether anything else continues. */
|
|
8709
|
+
async function recoveredContinuity(backend, scope, retainedOwner) {
|
|
8710
|
+
if (backend.backend !== "provider" || !retainedOwner) return UNPROVEN_CONTINUITY;
|
|
8711
|
+
const environment = await reconcileScopeRetainedOwnerEnvironment(scope, "released");
|
|
8712
|
+
return environment.state === "lost" ? replacedContinuity(scope, environment.environmentId) : UNPROVEN_CONTINUITY;
|
|
8713
|
+
}
|
|
8714
|
+
/** The replacement starts from the lost environment's latest checkpoint when there is one. */
|
|
8715
|
+
async function replacedContinuity(scope, previousEnvironmentId) {
|
|
8716
|
+
const restorePoint = await scopeRetainedOwnerRestorePoint(scope);
|
|
8717
|
+
return {
|
|
8718
|
+
session: "new",
|
|
8719
|
+
environment: "replaced",
|
|
8720
|
+
previousEnvironmentId,
|
|
8721
|
+
...restorePoint === void 0 ? { workspace: "lost" } : {
|
|
8722
|
+
workspace: "restored",
|
|
8723
|
+
checkpointAt: restorePoint.takenAt
|
|
8724
|
+
}
|
|
8725
|
+
};
|
|
8726
|
+
}
|
|
8699
8727
|
// src/runtime/supervise/supervise-manager-harness.ts
|
|
8700
8728
|
/**
|
|
8701
8729
|
* Resolve the harness that drives each manager owner: the caller's resolver or harness, claimed
|
|
@@ -9545,4 +9573,4 @@ function superviseWithContext(profile, task, opts, brain) {
|
|
|
9545
9573
|
}
|
|
9546
9574
|
export { validateGraphTopology as A, allWorkersStalled as B, createFlowRun as C, validateFlowGraph as D, routeFlowOf as E, dumbContinuationPassPrompt as F, areaUnderCurve as G, noProgressFor as H, formatPromptHandle as I, renderAnytimeTable as J, bestSoFar as K, kernelPromptRegistry as L, createPromptRegistry as M, delegatesWorkerBriefPrompt as N, defaultEdgeTraversalCap as O, dumbContinuationFailPrompt as P, naiveContinuationPrompt as R, GraphRouteError as S, journaledGateDecider as T, plateau as U, anyOf as V, anytimeReport as W, createSupervisorSpanRecorder as Y, graphFlowSpawnProfile as _, bridgeProfileRefusal as a, serveCoordinationMcp as b, ASSISTANT_REASONING_SPAN as c, runToolSpans as d, UNPROVEN_CONTINUITY as f, createGraphOverlay as g, runBrainLoop as h, workerFromBackend as i, analyzesFindingsReportPrompt as j, graphRootProfile as k, ASSISTANT_TEXT_SPAN as l, driverAgent as m, superviseFleetCapabilities as n, supervisorAgent as o, composeReentryTask as p, plateauLength as q, superviseWithTestBrain as r, supervisorAgentWithTestBrain as s, supervise as t, rootStreamToolSpans as u, profileGuidanceComposer as v, flowRootProfile as w, coordinationControlToolNames as x, superviseRootProfile as y, promptHandle as z };
|
|
9547
9575
|
|
|
9548
|
-
//# sourceMappingURL=supervise-
|
|
9576
|
+
//# sourceMappingURL=supervise-x-0LPDZh.js.map
|