@tangle-network/agent-runtime 10.0.19 → 10.0.20
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 +4 -0
- package/dist/{activation-DLnZJab0.js → activation-5TrUzeFd.js} +2 -2
- package/dist/{activation-DLnZJab0.js.map → activation-5TrUzeFd.js.map} +1 -1
- package/dist/{activation-BudDVuT6.d.ts → activation-B0arteLE.d.ts} +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +4 -4
- package/dist/{delegate-9b8qGlXp.js → delegate-DnW85VY0.js} +2 -2
- package/dist/{delegate-9b8qGlXp.js.map → delegate-DnW85VY0.js.map} +1 -1
- package/dist/{driver-control-acknowledgers-b5MsXxR5.js → driver-control-acknowledgers-vgmZqgZ-.js} +8 -8
- package/dist/{driver-control-acknowledgers-b5MsXxR5.js.map → driver-control-acknowledgers-vgmZqgZ-.js.map} +1 -1
- package/dist/durable-writer-thread.js +4 -4
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +13 -14
- package/dist/durable.js.map +1 -1
- package/dist/{graph--n31XKWJ.js → graph-DHNPE7kw.js} +8 -8
- package/dist/{graph--n31XKWJ.js.map → graph-DHNPE7kw.js.map} +1 -1
- package/dist/{graph-registry-aMRd94PD.js → graph-registry-DI8o9iCB.js} +1 -1
- package/dist/{graph-registry-SgsCxCTZ.js → graph-registry-qyaNDATw.js} +2 -3
- package/dist/{graph-registry-SgsCxCTZ.js.map → graph-registry-qyaNDATw.js.map} +1 -1
- package/dist/{improve-sIZhpXqE.js → improve-BLFqeD3X.js} +6 -6
- package/dist/{improve-sIZhpXqE.js.map → improve-BLFqeD3X.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/{continuation-CDdjAkpk.js → jsonl-file-B2ESMrTh.js} +396 -4
- package/dist/jsonl-file-B2ESMrTh.js.map +1 -0
- package/dist/kernel.d.ts +1 -1
- package/dist/kernel.js +17 -18
- package/dist/{loop-runner-Bn7lFuQZ.d.ts → loop-runner-BFC781pC.d.ts} +2 -2
- package/dist/{loop-runner-Dt7I2oMa.js → loop-runner-CITvo-q1.js} +2 -2
- package/dist/{loop-runner-Dt7I2oMa.js.map → loop-runner-CITvo-q1.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-DfDAdtqb.js → provision-supervisor-CyUbiMz8.js} +6 -6
- package/dist/{provision-supervisor-DfDAdtqb.js.map → provision-supervisor-CyUbiMz8.js.map} +1 -1
- package/dist/{result-blob-store-Dke805sV.js → result-blob-store-CJjp44Mz.js} +3 -3
- package/dist/{result-blob-store-Dke805sV.js.map → result-blob-store-CJjp44Mz.js.map} +1 -1
- package/dist/{run-cancellation-B0SgcidY.js → run-cancellation-BNBmsY3a.js} +2 -2
- package/dist/{run-cancellation-B0SgcidY.js.map → run-cancellation-BNBmsY3a.js.map} +1 -1
- package/dist/{run-lock-BOg7BaXF.js → run-lock-Dcr79Wql.js} +2 -2
- package/dist/{run-lock-BOg7BaXF.js.map → run-lock-Dcr79Wql.js.map} +1 -1
- package/dist/{run-reopen-B7TN2aQQ.js → run-reopen-Cr2SHmYa.js} +6 -6
- package/dist/{run-reopen-B7TN2aQQ.js.map → run-reopen-Cr2SHmYa.js.map} +1 -1
- package/dist/{run-state-BNBUy2uK.js → run-state-AYXAe_lX.js} +7 -7
- package/dist/{run-state-BNBUy2uK.js.map → run-state-AYXAe_lX.js.map} +1 -1
- package/dist/{runtime-DXeWY00j.js → runtime-D-FpUoQg.js} +19 -20
- package/dist/{runtime-DXeWY00j.js.map → runtime-D-FpUoQg.js.map} +1 -1
- package/dist/{search-executor-BoQHI2Tz.js → search-executor-BHfb4p6C.js} +4 -4
- package/dist/{search-executor-BoQHI2Tz.js.map → search-executor-BHfb4p6C.js.map} +1 -1
- package/dist/{server-Xkgobp5y.js → server-CAXzZHVz.js} +4 -4
- package/dist/{server-Xkgobp5y.js.map → server-CAXzZHVz.js.map} +1 -1
- package/dist/{settle-record-B5OpVDnC.js → settle-record-BlIw2MU1.js} +3 -3
- package/dist/{settle-record-B5OpVDnC.js.map → settle-record-BlIw2MU1.js.map} +1 -1
- package/dist/{structural-rollout-BSF5tzUm.js → structural-rollout-BVuf5hFl.js} +4 -4
- package/dist/{structural-rollout-BSF5tzUm.js.map → structural-rollout-BVuf5hFl.js.map} +1 -1
- package/dist/{supervise-Drc1Pj1d.js → supervise-Ci8wiyla.js} +13 -13
- package/dist/supervise-Ci8wiyla.js.map +1 -0
- package/dist/{supervise-identity-Cz-Hzg9s.js → supervise-identity-CtxWEk1I.js} +3 -3
- package/dist/{supervise-identity-Cz-Hzg9s.js.map → supervise-identity-CtxWEk1I.js.map} +1 -1
- package/dist/{supervision-discovery-DdRd1lsz.js → supervision-discovery-DKxqbnHf.js} +4 -4
- package/dist/{supervision-discovery-DdRd1lsz.js.map → supervision-discovery-DKxqbnHf.js.map} +1 -1
- package/dist/{supervisor-CwUD7dsm.js → supervisor-KcnH2hC4.js} +10 -592
- package/dist/supervisor-KcnH2hC4.js.map +1 -0
- package/dist/{supervisor-accounting-CPDPG8mH.js → supervisor-accounting-DlDUl58C.js} +600 -8
- package/dist/supervisor-accounting-DlDUl58C.js.map +1 -0
- package/dist/{supervisor-root-contract-Uw2q3nvG.js → supervisor-root-contract-BCbu1A4n.js} +3 -3
- package/dist/{supervisor-root-contract-Uw2q3nvG.js.map → supervisor-root-contract-BCbu1A4n.js.map} +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +11 -11
- package/dist/{failure-cause-C96rzF-d.js → tool-server-n4XYpCok.js} +181 -2
- package/dist/tool-server-n4XYpCok.js.map +1 -0
- package/dist/{top-web-5ThvdyD0.js → top-web-B-sHmI3g.js} +8 -8
- package/dist/{top-web-5ThvdyD0.js.map → top-web-B-sHmI3g.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-BLhsL4qy.d.ts → types-YXZL7Wxi.d.ts} +5 -3
- package/package.json +1 -1
- package/dist/continuation-CDdjAkpk.js.map +0 -1
- package/dist/failure-cause-C96rzF-d.js.map +0 -1
- package/dist/jsonl-file-B8xfYz9M.js +0 -397
- package/dist/jsonl-file-B8xfYz9M.js.map +0 -1
- package/dist/supervise-Drc1Pj1d.js.map +0 -1
- package/dist/supervisor-CwUD7dsm.js.map +0 -1
- package/dist/supervisor-accounting-CPDPG8mH.js.map +0 -1
- package/dist/tool-server-BhsyVDj2.js +0 -174
- package/dist/tool-server-BhsyVDj2.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as contentAddress } from "./tool-server-n4XYpCok.js";
|
|
2
2
|
import { f as RuntimeRunStateError } from "./errors-DG8yufqX.js";
|
|
3
|
-
import {
|
|
3
|
+
import { $r as knownExecutionBindingReceipt, ei as knownMaterializationReceipt, et as reenteredWorkers, gi as unknownMaterializationReceipt, hi as unknownExecutionBindingReceipt } from "./supervisor-accounting-DlDUl58C.js";
|
|
4
4
|
import { sha256DigestSchema } from "@tangle-network/agent-interface";
|
|
5
5
|
// src/runtime/supervise/supervisor-root-contract.ts
|
|
6
6
|
/** A resumed process may continue only the exact root contract first recorded for this run id. Its
|
|
@@ -162,4 +162,4 @@ function rootStartedAtMs(root) {
|
|
|
162
162
|
}
|
|
163
163
|
export { recordRootReentered as a, rootMaterializationReceipt as c, changesRootProfile as i, rootStartedAtMs as l, assertResumeLimits as n, recordRootSegment as o, assertRootIdentity as r, rootExecutionBindingReceipt as s, assertResumeContract as t };
|
|
164
164
|
|
|
165
|
-
//# sourceMappingURL=supervisor-root-contract-
|
|
165
|
+
//# sourceMappingURL=supervisor-root-contract-BCbu1A4n.js.map
|
package/dist/{supervisor-root-contract-Uw2q3nvG.js.map → supervisor-root-contract-BCbu1A4n.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervisor-root-contract-Uw2q3nvG.js","names":[],"sources":["../src/runtime/supervise/supervisor-root-contract.ts"],"sourcesContent":["import { sha256DigestSchema } from '@tangle-network/agent-interface'\nimport { contentAddress } from '../../durable/content-address'\nimport { RuntimeRunStateError } from '../../errors'\nimport {\n knownExecutionBindingReceipt,\n knownMaterializationReceipt,\n unknownExecutionBindingReceipt,\n unknownMaterializationReceipt,\n} from './materialization'\nimport type { ScopeResumeState } from './recover-executors'\nimport { reenteredWorkers } from './scope'\nimport type {\n ExecutionBindingReceipt,\n ProfileMaterializationReceipt,\n RootSegmentEntry,\n SpawnEvent,\n SupervisorOpts,\n} from './types'\n\nexport type SpawnedEvent = Extract<SpawnEvent, { kind: 'spawned' }>\n\n/** A resumed process may continue only the exact root contract first recorded for this run id. Its\n * budget is the root's, or the one the run's last budget-carrying `reopened` row recorded. */\nexport function assertResumeContract(events: SpawnEvent[], opts: SupervisorOpts): SpawnedEvent {\n const recorded = assertResumeLimits(events, opts)\n if (!sameOptionalIdentity(recorded.identity, opts.rootIdentity)) {\n throw new RuntimeRunStateError(\n `supervisor: resume identity mismatch for run '${opts.runId}'; ${describeIdentityMismatch(recorded.identity, opts.rootIdentity)}`,\n )\n }\n const receipts = events.filter(\n (event): event is Extract<SpawnEvent, { kind: 'materialized' }> =>\n event.kind === 'materialized' && event.id === opts.runId,\n )\n const expectedReceipt = rootMaterializationReceipt(opts)\n if (expectedReceipt === undefined) {\n if (receipts.length > 1) {\n throw new RuntimeRunStateError(\n `supervisor: resumed run '${opts.runId}' contains duplicate root materialization evidence`,\n )\n }\n } else if (\n receipts.length !== 1 ||\n contentAddress(receipts[0]?.receipt) !== contentAddress(expectedReceipt)\n ) {\n throw new RuntimeRunStateError(\n `supervisor: resume materialization mismatch for run '${opts.runId}'; backend, model, execution identity, and plan must match`,\n )\n }\n return recorded\n}\n\n/**\n * The limits half of the resume contract: one root identity event, the recorded budget and the\n * reservation policy. A reopen checks them before it archives anything (`durable/run-reopen.ts`);\n * `reopenBudget` is the budget that reopen is about to record, which then replaces the recorded one.\n */\nexport function assertResumeLimits(\n events: readonly SpawnEvent[],\n opts: Pick<SupervisorOpts, 'runId' | 'budget' | 'reservationPolicy'>,\n reopenBudget?: SupervisorOpts['budget'],\n): SpawnedEvent {\n const roots = events.filter(\n (event): event is SpawnedEvent => event.kind === 'spawned' && event.parent === undefined,\n )\n if (roots.length !== 1 || roots[0]?.id !== opts.runId) {\n throw new RuntimeRunStateError(\n `supervisor: resumed run '${opts.runId}' must contain exactly one root identity event; found ${roots.length}`,\n )\n }\n const recorded = roots[0]!\n // A reopen may carry a new budget; the last one that did is the budget this run is held to.\n const reopenedBudget =\n reopenBudget ??\n events\n .filter(\n (event): event is Extract<SpawnEvent, { kind: 'reopened' }> =>\n event.kind === 'reopened' && event.id === opts.runId && event.budget !== undefined,\n )\n .at(-1)?.budget\n if (contentAddress(reopenedBudget ?? recorded.budget) !== contentAddress(opts.budget)) {\n throw new RuntimeRunStateError(\n `supervisor: resume budget mismatch for run '${opts.runId}'; use a new runId to change limits`,\n )\n }\n const expectedAdmission = opts.reservationPolicy ? { policy: opts.reservationPolicy } : undefined\n if (\n contentAddress(recorded.recursiveAdmission ?? null) !==\n contentAddress(expectedAdmission ?? null)\n ) {\n throw new RuntimeRunStateError(\n `supervisor: resume reservation policy mismatch for run '${opts.runId}'; use a new runId`,\n )\n }\n return recorded\n}\n\n/** Mint root evidence at the trusted composition boundary. A generic in-process Agent root has no\n * executor declaration and remains explicitly unknown rather than inheriting fabricated details. */\nexport function rootMaterializationReceipt(\n opts: SupervisorOpts,\n): ProfileMaterializationReceipt | undefined {\n const declaration = opts.rootMaterialization\n if (declaration === undefined) {\n return unknownMaterializationReceipt({\n ...(opts.rootIdentity?.profileDigest === undefined\n ? {}\n : { authoredProfileDigest: opts.rootIdentity.profileDigest }),\n runtime: 'inline',\n reason: 'root-agent-did-not-report',\n })\n }\n if (declaration.declaration === 'deferred') return undefined\n if (opts.rootIdentity?.profileDigest === undefined) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' cannot record known root materialization without an exact profileDigest`,\n )\n }\n try {\n return knownMaterializationReceipt({\n authoredProfileDigest: opts.rootIdentity.profileDigest,\n runtime: declaration.runtime,\n declaration: declaration.declaration,\n })\n } catch (error) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' has invalid root materialization evidence`,\n { cause: error },\n )\n }\n}\n\nexport function rootExecutionBindingReceipt(\n opts: SupervisorOpts,\n materialization: ProfileMaterializationReceipt,\n attemptId: string,\n): ExecutionBindingReceipt | undefined {\n const root = opts.rootMaterialization\n if (root?.declaration === 'deferred') return undefined\n if (root === undefined) {\n return unknownExecutionBindingReceipt(materialization, attemptId, 'root-agent-did-not-report')\n }\n try {\n return knownExecutionBindingReceipt(materialization, {\n attemptId,\n ...root.binding,\n })\n } catch (error) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' has invalid root execution binding`,\n { cause: error },\n )\n }\n}\n\n/** Whether a segment changes what the recorded profile runs, apart from the caller's stack. */\nexport function changesRootProfile(entry: RootSegmentEntry): boolean {\n const { stack: _stack, ...current } = entry.current\n return contentAddress(current) !== contentAddress(entry.registered)\n}\n\n/**\n * Append one `root-segment` record when the root enters a segment that differs from the one it\n * last ran. The last record's `to` is what it last ran; a resumed run with no record last ran its\n * recorded profile, and a fresh run ran nothing. Every later entry on the same segment appends\n * nothing, so a resume after a dead supervisor or a lost stream is a boundary, not a segment.\n */\nexport async function recordRootSegment(\n opts: SupervisorOpts,\n events: readonly SpawnEvent[],\n at: string,\n fresh: boolean,\n): Promise<void> {\n const entry = opts.rootSegment\n if (entry === undefined) return\n const records = events.filter(\n (event): event is Extract<SpawnEvent, { kind: 'root-segment' }> =>\n event.kind === 'root-segment' && event.id === opts.runId,\n )\n const last = records.at(-1)?.to ?? (fresh ? undefined : entry.registered)\n if (last !== undefined && contentAddress(last) === contentAddress(entry.current)) return\n await opts.journal.appendEvent(opts.runId, {\n kind: 'root-segment',\n id: opts.runId,\n ...(last === undefined ? {} : { from: last }),\n to: entry.current,\n reason: entry.reason,\n seq: records.length,\n at,\n })\n}\n\n/**\n * Append one `root-reentered` record: this process is supervising a run an earlier process drove.\n * After a host reboot the re-entered root ran two\n * barren continuations and the run settled `no-result-selected`, with three workers still open in\n * the journal and no record that a restart had happened.\n */\nexport async function recordRootReentered(\n opts: SupervisorOpts,\n resumeFrom: ScopeResumeState,\n at: string,\n): Promise<void> {\n await opts.journal.appendEvent(opts.runId, {\n kind: 'root-reentered',\n id: opts.runId,\n ...reenteredWorkers(resumeFrom, opts.runId),\n seq: resumeFrom.events.filter((event) => event.kind === 'root-reentered').length,\n at,\n })\n}\n\nfunction sameOptionalIdentity(\n recorded: SpawnedEvent['identity'],\n requested: SpawnedEvent['identity'],\n): boolean {\n if (recorded === undefined || requested === undefined) return recorded === requested\n return contentAddress(recorded) === contentAddress(requested)\n}\n\n/**\n * Name the identity fields that actually differ, with both values.\n *\n * The identity is compared as one content address, so a mismatch is a single boolean and the\n * message could only list every field that MIGHT have caused it. A caller then has to diff four\n * digests by hand to learn which one moved, and the common cause — a task file regenerated with\n * one character different — is indistinguishable from a genuinely different profile.\n *\n * Digests are truncated because the prefix identifies them and the full 64 characters push the\n * real content off the end of a terminal line.\n */\nfunction describeIdentityMismatch(\n recorded: SpawnedEvent['identity'],\n requested: SpawnedEvent['identity'],\n): string {\n if (recorded === undefined)\n return 'the recorded root carried no identity but this resume supplies one'\n if (requested === undefined)\n return 'the recorded root carried an identity but this resume supplies none'\n const short = (value: unknown): string => {\n if (value === undefined) return '(absent)'\n const text = typeof value === 'string' ? value : JSON.stringify(value)\n return text.length > 20 ? `${text.slice(0, 20)}…` : text\n }\n const differing = (['profileDigest', 'taskDigest', 'candidateDigest', 'correlation'] as const)\n .filter((field) => contentAddress(recorded[field]) !== contentAddress(requested[field]))\n .map(\n (field) =>\n `${field} recorded ${short(recorded[field])} but resumed with ${short(requested[field])}`,\n )\n // A differing content address with no differing field means the shape itself changed (an extra\n // key, a different key order the address is sensitive to). Say that rather than nothing.\n if (differing.length === 0)\n return 'the identity objects differ in shape while every known field matches'\n return `${differing.join('; ')} — a different task or root profile is a new run; a resume may change the root's model, reasoning effort and harness as a new segment of this run (segment)`\n}\n\n/** Validate caller-supplied root identity before any journal access. Fresh runs may omit identity,\n * but once supplied it is trusted durable evidence and therefore must be complete and canonical;\n * resumed runs always require it so the prior root can be matched exactly. */\nexport function assertRootIdentity(opts: SupervisorOpts): void {\n const identity = opts.rootIdentity\n if (identity === undefined) {\n if (opts.resume !== true) return\n throw new RuntimeRunStateError(\n `supervisor: resumed run '${opts.runId}' requires an exact rootIdentity with profileDigest and taskDigest`,\n )\n }\n const unknownFields = Object.keys(identity).filter(\n (key) =>\n key !== 'profileDigest' &&\n key !== 'taskDigest' &&\n key !== 'candidateDigest' &&\n key !== 'correlation',\n )\n const correlation = identity.correlation\n const validCorrelation =\n correlation === undefined ||\n (typeof correlation === 'object' &&\n correlation !== null &&\n !Array.isArray(correlation) &&\n Object.entries(correlation).every(\n ([key, value]) => key.length > 0 && typeof value === 'string' && value.length > 0,\n ))\n if (\n unknownFields.length > 0 ||\n !sha256DigestSchema.safeParse(identity.profileDigest).success ||\n !sha256DigestSchema.safeParse(identity.taskDigest).success ||\n (identity.candidateDigest !== undefined &&\n !sha256DigestSchema.safeParse(identity.candidateDigest).success) ||\n !validCorrelation\n ) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' requires an exact rootIdentity with valid profileDigest, taskDigest, candidateDigest, and correlation`,\n )\n }\n}\n\n/** The instant the run's root was journaled — the anchor for both the absolute deadline and the\n * terminal wall-clock `ms`, so a resumed run measures from its ORIGINAL start, not this\n * process's. */\nexport function rootStartedAtMs(root: SpawnedEvent): number {\n const startedAt = Date.parse(root.at)\n if (!Number.isFinite(startedAt)) {\n throw new RuntimeRunStateError(\n `supervisor: root event for '${root.id}' has an invalid timestamp '${root.at}'`,\n )\n }\n return startedAt\n}\n"],"mappings":";;;;;;;AAuBA,SAAgB,qBAAqB,QAAsB,MAAoC;CAC7F,MAAM,WAAW,mBAAmB,QAAQ,IAAI;CAChD,IAAI,CAAC,qBAAqB,SAAS,UAAU,KAAK,YAAY,GAC5D,MAAM,IAAI,qBACR,iDAAiD,KAAK,MAAM,KAAK,yBAAyB,SAAS,UAAU,KAAK,YAAY,GAChI;CAEF,MAAM,WAAW,OAAO,QACrB,UACC,MAAM,SAAS,kBAAkB,MAAM,OAAO,KAAK,KACvD;CACA,MAAM,kBAAkB,2BAA2B,IAAI;CACvD,IAAI,oBAAoB,KAAA,GAClB;MAAA,SAAS,SAAS,GACpB,MAAM,IAAI,qBACR,4BAA4B,KAAK,MAAM,mDACzC;CAAA,OAEG,IACL,SAAS,WAAW,KACpB,eAAe,SAAS,EAAE,EAAE,OAAO,MAAM,eAAe,eAAe,GAEvE,MAAM,IAAI,qBACR,wDAAwD,KAAK,MAAM,2DACrE;CAEF,OAAO;AACT;;;;;;AAOA,SAAgB,mBACd,QACA,MACA,cACc;CACd,MAAM,QAAQ,OAAO,QAClB,UAAiC,MAAM,SAAS,aAAa,MAAM,WAAW,KAAA,CACjF;CACA,IAAI,MAAM,WAAW,KAAK,MAAM,EAAE,EAAE,OAAO,KAAK,OAC9C,MAAM,IAAI,qBACR,4BAA4B,KAAK,MAAM,wDAAwD,MAAM,QACvG;CAEF,MAAM,WAAW,MAAM;CAEvB,MAAM,iBACJ,gBACA,OACG,QACE,UACC,MAAM,SAAS,cAAc,MAAM,OAAO,KAAK,SAAS,MAAM,WAAW,KAAA,CAC7E,CAAC,CACA,GAAG,EAAE,CAAC,EAAE;CACb,IAAI,eAAe,kBAAkB,SAAS,MAAM,MA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AgB,MAA4B;CAC1D,MAAM,YAAY,KAAK,MAAM,KAAK,EAAE;CACpC,IAAI,CAAC,OAAO,SAAS,SAAS,GAC5B,MAAM,IAAI,qBACR,+BAA+B,KAAK,GAAG,8BAA8B,KAAK,GAAG,EAC/E;CAEF,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"supervisor-root-contract-BCbu1A4n.js","names":[],"sources":["../src/runtime/supervise/supervisor-root-contract.ts"],"sourcesContent":["import { sha256DigestSchema } from '@tangle-network/agent-interface'\nimport { contentAddress } from '../../durable/content-address'\nimport { RuntimeRunStateError } from '../../errors'\nimport {\n knownExecutionBindingReceipt,\n knownMaterializationReceipt,\n unknownExecutionBindingReceipt,\n unknownMaterializationReceipt,\n} from './materialization'\nimport type { ScopeResumeState } from './recover-executors'\nimport { reenteredWorkers } from './scope'\nimport type {\n ExecutionBindingReceipt,\n ProfileMaterializationReceipt,\n RootSegmentEntry,\n SpawnEvent,\n SupervisorOpts,\n} from './types'\n\nexport type SpawnedEvent = Extract<SpawnEvent, { kind: 'spawned' }>\n\n/** A resumed process may continue only the exact root contract first recorded for this run id. Its\n * budget is the root's, or the one the run's last budget-carrying `reopened` row recorded. */\nexport function assertResumeContract(events: SpawnEvent[], opts: SupervisorOpts): SpawnedEvent {\n const recorded = assertResumeLimits(events, opts)\n if (!sameOptionalIdentity(recorded.identity, opts.rootIdentity)) {\n throw new RuntimeRunStateError(\n `supervisor: resume identity mismatch for run '${opts.runId}'; ${describeIdentityMismatch(recorded.identity, opts.rootIdentity)}`,\n )\n }\n const receipts = events.filter(\n (event): event is Extract<SpawnEvent, { kind: 'materialized' }> =>\n event.kind === 'materialized' && event.id === opts.runId,\n )\n const expectedReceipt = rootMaterializationReceipt(opts)\n if (expectedReceipt === undefined) {\n if (receipts.length > 1) {\n throw new RuntimeRunStateError(\n `supervisor: resumed run '${opts.runId}' contains duplicate root materialization evidence`,\n )\n }\n } else if (\n receipts.length !== 1 ||\n contentAddress(receipts[0]?.receipt) !== contentAddress(expectedReceipt)\n ) {\n throw new RuntimeRunStateError(\n `supervisor: resume materialization mismatch for run '${opts.runId}'; backend, model, execution identity, and plan must match`,\n )\n }\n return recorded\n}\n\n/**\n * The limits half of the resume contract: one root identity event, the recorded budget and the\n * reservation policy. A reopen checks them before it archives anything (`durable/run-reopen.ts`);\n * `reopenBudget` is the budget that reopen is about to record, which then replaces the recorded one.\n */\nexport function assertResumeLimits(\n events: readonly SpawnEvent[],\n opts: Pick<SupervisorOpts, 'runId' | 'budget' | 'reservationPolicy'>,\n reopenBudget?: SupervisorOpts['budget'],\n): SpawnedEvent {\n const roots = events.filter(\n (event): event is SpawnedEvent => event.kind === 'spawned' && event.parent === undefined,\n )\n if (roots.length !== 1 || roots[0]?.id !== opts.runId) {\n throw new RuntimeRunStateError(\n `supervisor: resumed run '${opts.runId}' must contain exactly one root identity event; found ${roots.length}`,\n )\n }\n const recorded = roots[0]!\n // A reopen may carry a new budget; the last one that did is the budget this run is held to.\n const reopenedBudget =\n reopenBudget ??\n events\n .filter(\n (event): event is Extract<SpawnEvent, { kind: 'reopened' }> =>\n event.kind === 'reopened' && event.id === opts.runId && event.budget !== undefined,\n )\n .at(-1)?.budget\n if (contentAddress(reopenedBudget ?? recorded.budget) !== contentAddress(opts.budget)) {\n throw new RuntimeRunStateError(\n `supervisor: resume budget mismatch for run '${opts.runId}'; use a new runId to change limits`,\n )\n }\n const expectedAdmission = opts.reservationPolicy ? { policy: opts.reservationPolicy } : undefined\n if (\n contentAddress(recorded.recursiveAdmission ?? null) !==\n contentAddress(expectedAdmission ?? null)\n ) {\n throw new RuntimeRunStateError(\n `supervisor: resume reservation policy mismatch for run '${opts.runId}'; use a new runId`,\n )\n }\n return recorded\n}\n\n/** Mint root evidence at the trusted composition boundary. A generic in-process Agent root has no\n * executor declaration and remains explicitly unknown rather than inheriting fabricated details. */\nexport function rootMaterializationReceipt(\n opts: SupervisorOpts,\n): ProfileMaterializationReceipt | undefined {\n const declaration = opts.rootMaterialization\n if (declaration === undefined) {\n return unknownMaterializationReceipt({\n ...(opts.rootIdentity?.profileDigest === undefined\n ? {}\n : { authoredProfileDigest: opts.rootIdentity.profileDigest }),\n runtime: 'inline',\n reason: 'root-agent-did-not-report',\n })\n }\n if (declaration.declaration === 'deferred') return undefined\n if (opts.rootIdentity?.profileDigest === undefined) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' cannot record known root materialization without an exact profileDigest`,\n )\n }\n try {\n return knownMaterializationReceipt({\n authoredProfileDigest: opts.rootIdentity.profileDigest,\n runtime: declaration.runtime,\n declaration: declaration.declaration,\n })\n } catch (error) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' has invalid root materialization evidence`,\n { cause: error },\n )\n }\n}\n\nexport function rootExecutionBindingReceipt(\n opts: SupervisorOpts,\n materialization: ProfileMaterializationReceipt,\n attemptId: string,\n): ExecutionBindingReceipt | undefined {\n const root = opts.rootMaterialization\n if (root?.declaration === 'deferred') return undefined\n if (root === undefined) {\n return unknownExecutionBindingReceipt(materialization, attemptId, 'root-agent-did-not-report')\n }\n try {\n return knownExecutionBindingReceipt(materialization, {\n attemptId,\n ...root.binding,\n })\n } catch (error) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' has invalid root execution binding`,\n { cause: error },\n )\n }\n}\n\n/** Whether a segment changes what the recorded profile runs, apart from the caller's stack. */\nexport function changesRootProfile(entry: RootSegmentEntry): boolean {\n const { stack: _stack, ...current } = entry.current\n return contentAddress(current) !== contentAddress(entry.registered)\n}\n\n/**\n * Append one `root-segment` record when the root enters a segment that differs from the one it\n * last ran. The last record's `to` is what it last ran; a resumed run with no record last ran its\n * recorded profile, and a fresh run ran nothing. Every later entry on the same segment appends\n * nothing, so a resume after a dead supervisor or a lost stream is a boundary, not a segment.\n */\nexport async function recordRootSegment(\n opts: SupervisorOpts,\n events: readonly SpawnEvent[],\n at: string,\n fresh: boolean,\n): Promise<void> {\n const entry = opts.rootSegment\n if (entry === undefined) return\n const records = events.filter(\n (event): event is Extract<SpawnEvent, { kind: 'root-segment' }> =>\n event.kind === 'root-segment' && event.id === opts.runId,\n )\n const last = records.at(-1)?.to ?? (fresh ? undefined : entry.registered)\n if (last !== undefined && contentAddress(last) === contentAddress(entry.current)) return\n await opts.journal.appendEvent(opts.runId, {\n kind: 'root-segment',\n id: opts.runId,\n ...(last === undefined ? {} : { from: last }),\n to: entry.current,\n reason: entry.reason,\n seq: records.length,\n at,\n })\n}\n\n/**\n * Append one `root-reentered` record: this process is supervising a run an earlier process drove.\n * After a host reboot the re-entered root ran two\n * barren continuations and the run settled `no-result-selected`, with three workers still open in\n * the journal and no record that a restart had happened.\n */\nexport async function recordRootReentered(\n opts: SupervisorOpts,\n resumeFrom: ScopeResumeState,\n at: string,\n): Promise<void> {\n await opts.journal.appendEvent(opts.runId, {\n kind: 'root-reentered',\n id: opts.runId,\n ...reenteredWorkers(resumeFrom, opts.runId),\n seq: resumeFrom.events.filter((event) => event.kind === 'root-reentered').length,\n at,\n })\n}\n\nfunction sameOptionalIdentity(\n recorded: SpawnedEvent['identity'],\n requested: SpawnedEvent['identity'],\n): boolean {\n if (recorded === undefined || requested === undefined) return recorded === requested\n return contentAddress(recorded) === contentAddress(requested)\n}\n\n/**\n * Name the identity fields that actually differ, with both values.\n *\n * The identity is compared as one content address, so a mismatch is a single boolean and the\n * message could only list every field that MIGHT have caused it. A caller then has to diff four\n * digests by hand to learn which one moved, and the common cause — a task file regenerated with\n * one character different — is indistinguishable from a genuinely different profile.\n *\n * Digests are truncated because the prefix identifies them and the full 64 characters push the\n * real content off the end of a terminal line.\n */\nfunction describeIdentityMismatch(\n recorded: SpawnedEvent['identity'],\n requested: SpawnedEvent['identity'],\n): string {\n if (recorded === undefined)\n return 'the recorded root carried no identity but this resume supplies one'\n if (requested === undefined)\n return 'the recorded root carried an identity but this resume supplies none'\n const short = (value: unknown): string => {\n if (value === undefined) return '(absent)'\n const text = typeof value === 'string' ? value : JSON.stringify(value)\n return text.length > 20 ? `${text.slice(0, 20)}…` : text\n }\n const differing = (['profileDigest', 'taskDigest', 'candidateDigest', 'correlation'] as const)\n .filter((field) => contentAddress(recorded[field]) !== contentAddress(requested[field]))\n .map(\n (field) =>\n `${field} recorded ${short(recorded[field])} but resumed with ${short(requested[field])}`,\n )\n // A differing content address with no differing field means the shape itself changed (an extra\n // key, a different key order the address is sensitive to). Say that rather than nothing.\n if (differing.length === 0)\n return 'the identity objects differ in shape while every known field matches'\n return `${differing.join('; ')} — a different task or root profile is a new run; a resume may change the root's model, reasoning effort and harness as a new segment of this run (segment)`\n}\n\n/** Validate caller-supplied root identity before any journal access. Fresh runs may omit identity,\n * but once supplied it is trusted durable evidence and therefore must be complete and canonical;\n * resumed runs always require it so the prior root can be matched exactly. */\nexport function assertRootIdentity(opts: SupervisorOpts): void {\n const identity = opts.rootIdentity\n if (identity === undefined) {\n if (opts.resume !== true) return\n throw new RuntimeRunStateError(\n `supervisor: resumed run '${opts.runId}' requires an exact rootIdentity with profileDigest and taskDigest`,\n )\n }\n const unknownFields = Object.keys(identity).filter(\n (key) =>\n key !== 'profileDigest' &&\n key !== 'taskDigest' &&\n key !== 'candidateDigest' &&\n key !== 'correlation',\n )\n const correlation = identity.correlation\n const validCorrelation =\n correlation === undefined ||\n (typeof correlation === 'object' &&\n correlation !== null &&\n !Array.isArray(correlation) &&\n Object.entries(correlation).every(\n ([key, value]) => key.length > 0 && typeof value === 'string' && value.length > 0,\n ))\n if (\n unknownFields.length > 0 ||\n !sha256DigestSchema.safeParse(identity.profileDigest).success ||\n !sha256DigestSchema.safeParse(identity.taskDigest).success ||\n (identity.candidateDigest !== undefined &&\n !sha256DigestSchema.safeParse(identity.candidateDigest).success) ||\n !validCorrelation\n ) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' requires an exact rootIdentity with valid profileDigest, taskDigest, candidateDigest, and correlation`,\n )\n }\n}\n\n/** The instant the run's root was journaled — the anchor for both the absolute deadline and the\n * terminal wall-clock `ms`, so a resumed run measures from its ORIGINAL start, not this\n * process's. */\nexport function rootStartedAtMs(root: SpawnedEvent): number {\n const startedAt = Date.parse(root.at)\n if (!Number.isFinite(startedAt)) {\n throw new RuntimeRunStateError(\n `supervisor: root event for '${root.id}' has an invalid timestamp '${root.at}'`,\n )\n }\n return startedAt\n}\n"],"mappings":";;;;;;;AAuBA,SAAgB,qBAAqB,QAAsB,MAAoC;CAC7F,MAAM,WAAW,mBAAmB,QAAQ,IAAI;CAChD,IAAI,CAAC,qBAAqB,SAAS,UAAU,KAAK,YAAY,GAC5D,MAAM,IAAI,qBACR,iDAAiD,KAAK,MAAM,KAAK,yBAAyB,SAAS,UAAU,KAAK,YAAY,GAChI;CAEF,MAAM,WAAW,OAAO,QACrB,UACC,MAAM,SAAS,kBAAkB,MAAM,OAAO,KAAK,KACvD;CACA,MAAM,kBAAkB,2BAA2B,IAAI;CACvD,IAAI,oBAAoB,KAAA,GAClB;MAAA,SAAS,SAAS,GACpB,MAAM,IAAI,qBACR,4BAA4B,KAAK,MAAM,mDACzC;CAAA,OAEG,IACL,SAAS,WAAW,KACpB,eAAe,SAAS,EAAE,EAAE,OAAO,MAAM,eAAe,eAAe,GAEvE,MAAM,IAAI,qBACR,wDAAwD,KAAK,MAAM,2DACrE;CAEF,OAAO;AACT;;;;;;AAOA,SAAgB,mBACd,QACA,MACA,cACc;CACd,MAAM,QAAQ,OAAO,QAClB,UAAiC,MAAM,SAAS,aAAa,MAAM,WAAW,KAAA,CACjF;CACA,IAAI,MAAM,WAAW,KAAK,MAAM,EAAE,EAAE,OAAO,KAAK,OAC9C,MAAM,IAAI,qBACR,4BAA4B,KAAK,MAAM,wDAAwD,MAAM,QACvG;CAEF,MAAM,WAAW,MAAM;CAEvB,MAAM,iBACJ,gBACA,OACG,QACE,UACC,MAAM,SAAS,cAAc,MAAM,OAAO,KAAK,SAAS,MAAM,WAAW,KAAA,CAC7E,CAAC,CACA,GAAG,EAAE,CAAC,EAAE;CACb,IAAI,eAAe,kBAAk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AAKA,SAAgB,gBAAgB,MAA4B;CAC1D,MAAM,YAAY,KAAK,MAAM,KAAK,EAAE;CACpC,IAAI,CAAC,OAAO,SAAS,SAAS,GAC5B,MAAM,IAAI,qBACR,+BAA+B,KAAK,GAAG,8BAA8B,KAAK,GAAG,EAC/E;CAEF,OAAO;AACT"}
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $g as RouterResponseReceipt, $h as Inbox, Aa as Agent, Db as EscalateQuestion, E as Budget, Eb as ChildQuestionInbox, Hb as ContinuityMode, Lx as AnalystRegistry, Rf as RunGraphTestOptions, Sh as SpawnResourceReader, Um as SupervisorFinalizer, Vf as runGraphWithTestBrain, Yb as MapOnSettleRoute, _b as DecideGate, aa as ResultBlobStore, at as MakeWorkerAgent, c_ as ToolLoopToolCall, ct as SpawnPreflight, eh as CoordinationDeliveryEvidence, ft as SuperviseProfileEntry, gb as WorkerWatchOptions, i_ as ToolLoopChat, it as GraphSubtasks, jm as StopRule, kv as DeliverableSpec, lt as SpawnPreflightContext, o_ as ToolLoopCompactionOptions, ot as PeerAuditAccess, pC as HarnessTranscriptCapture, pf as superviseWithTestBrain, r_ as ToolLoopCallContext, rh as PriorCoordination, rt as GraphSubtaskPreparation, s_ as ToolLoopMessageRecord, tt as CoordinationTools, ub as CoordinationEvent, um as supervisorAgentWithTestBrain, ut as SpawnRefusal, vf as SuperviseTestOptions, vx as McpToolDescriptor, wm as ManagerWakePolicy, xb as RouteFlow, xx as BusRecord, yS as RunCancelRequest, ym as SupervisorAgentTestDeps, zb as AuthorizeDownMessage, zx as AnalyzeOnSettleRoute } from "./types-
|
|
1
|
+
import { $g as RouterResponseReceipt, $h as Inbox, Aa as Agent, Db as EscalateQuestion, E as Budget, Eb as ChildQuestionInbox, Hb as ContinuityMode, Lx as AnalystRegistry, Rf as RunGraphTestOptions, Sh as SpawnResourceReader, Um as SupervisorFinalizer, Vf as runGraphWithTestBrain, Yb as MapOnSettleRoute, _b as DecideGate, aa as ResultBlobStore, at as MakeWorkerAgent, c_ as ToolLoopToolCall, ct as SpawnPreflight, eh as CoordinationDeliveryEvidence, ft as SuperviseProfileEntry, gb as WorkerWatchOptions, i_ as ToolLoopChat, it as GraphSubtasks, jm as StopRule, kv as DeliverableSpec, lt as SpawnPreflightContext, o_ as ToolLoopCompactionOptions, ot as PeerAuditAccess, pC as HarnessTranscriptCapture, pf as superviseWithTestBrain, r_ as ToolLoopCallContext, rh as PriorCoordination, rt as GraphSubtaskPreparation, s_ as ToolLoopMessageRecord, tt as CoordinationTools, ub as CoordinationEvent, um as supervisorAgentWithTestBrain, ut as SpawnRefusal, vf as SuperviseTestOptions, vx as McpToolDescriptor, wm as ManagerWakePolicy, xb as RouteFlow, xx as BusRecord, yS as RunCancelRequest, ym as SupervisorAgentTestDeps, zb as AuthorizeDownMessage, zx as AnalyzeOnSettleRoute } from "./types-YXZL7Wxi.js";
|
|
2
2
|
import { AgentImprovementProposal, AgentProfile, AgentProfileImprovementMeasuredComparison, SandboxSizePreset } from "@tangle-network/agent-interface";
|
|
3
3
|
/** What the brain returned for one turn, as the recorder keeps it. */
|
|
4
4
|
interface RouterTranscriptReply {
|
package/dist/testing.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { m as canonicalCandidateDigest$1, v as immutableCandidateValue } from "./output-artifacts-AqkZ8lO2.js";
|
|
2
2
|
import { a as applyExactAgentProfileDiff, v as parseExactAgentProfile } from "./profile-Cxl_Ajl2.js";
|
|
3
|
-
import { c as verifyAgentImprovementProposal } from "./activation-
|
|
4
|
-
import { m as driverAgent, r as superviseWithTestBrain, s as supervisorAgentWithTestBrain } from "./supervise-
|
|
5
|
-
import { r as runGraphWithTestBrain } from "./graph
|
|
3
|
+
import { c as verifyAgentImprovementProposal } from "./activation-5TrUzeFd.js";
|
|
4
|
+
import { m as driverAgent, r as superviseWithTestBrain, s as supervisorAgentWithTestBrain } from "./supervise-Ci8wiyla.js";
|
|
5
|
+
import { r as runGraphWithTestBrain } from "./graph-DHNPE7kw.js";
|
|
6
6
|
import { SANDBOX_SIZE_PRESET_NAMES, canonicalAgentProfileDigest } from "@tangle-network/agent-interface";
|
|
7
7
|
// src/testing/fixtures/agent-improvement-proposal.json
|
|
8
8
|
var agent_improvement_proposal_default = {
|
|
9
9
|
changedSurfaces: ["prompt"],
|
|
10
|
-
digest: "sha256:
|
|
10
|
+
digest: "sha256:353dcb5d4e3a5ba9d0f4192e3f8b268e56bbe410e37bbbb728b45988e2fd1da6",
|
|
11
11
|
evaluation: {
|
|
12
12
|
"decision": {
|
|
13
13
|
"contributingChecks": [
|
|
@@ -4578,7 +4578,7 @@ var agent_improvement_proposal_default = {
|
|
|
4578
4578
|
],
|
|
4579
4579
|
"metadata": {
|
|
4580
4580
|
"fixture": "agent-improvement-proposal",
|
|
4581
|
-
"runtimeVersion": "10.0.
|
|
4581
|
+
"runtimeVersion": "10.0.20"
|
|
4582
4582
|
},
|
|
4583
4583
|
"objectives": [
|
|
4584
4584
|
{
|
|
@@ -4689,8 +4689,8 @@ var agent_improvement_proposal_default = {
|
|
|
4689
4689
|
"baselineContentHash": "sha256:5c21ee53e513fc604cb09754e21c392b24a424da0ef37dbf8f1ee4a8a0b08f09",
|
|
4690
4690
|
"candidateContentHash": "sha256:60fcbb1c728194bd51d7d19cb732d1c3f1881dce7e0a6266b41c8b98cfd65693",
|
|
4691
4691
|
"kind": "agent-eval-loop",
|
|
4692
|
-
"recordDigest": "sha256:
|
|
4693
|
-
"runId": "agent-runtime-10.0.
|
|
4692
|
+
"recordDigest": "sha256:a6423c98ab33d93bcce0db511de13ca3547b4820ee75d5f50eddd38dc623be6d",
|
|
4693
|
+
"runId": "agent-runtime-10.0.20-proposal-fixture",
|
|
4694
4694
|
"schema": "agent-candidate-experiment"
|
|
4695
4695
|
}
|
|
4696
4696
|
},
|
|
@@ -4713,12 +4713,12 @@ var agent_improvement_proposal_default = {
|
|
|
4713
4713
|
}],
|
|
4714
4714
|
kind: "agent-improvement-proposal",
|
|
4715
4715
|
proposedAt: "2026-07-10T01:00:00.000Z",
|
|
4716
|
-
runId: "agent-runtime-10.0.
|
|
4716
|
+
runId: "agent-runtime-10.0.20-proposal-fixture"
|
|
4717
4717
|
};
|
|
4718
4718
|
// src/testing/fixtures/agent-profile-improvement-proposal.json
|
|
4719
4719
|
var agent_profile_improvement_proposal_default = {
|
|
4720
4720
|
changedSurfaces: ["prompt", "skills"],
|
|
4721
|
-
digest: "sha256:
|
|
4721
|
+
digest: "sha256:ac6f0a96e97a6d3c6402918869cde95dce8417a9fed6a41de9e31c7a5fcb1b46",
|
|
4722
4722
|
evaluation: {
|
|
4723
4723
|
"decision": {
|
|
4724
4724
|
"contributingChecks": [
|
|
@@ -6352,7 +6352,7 @@ var agent_profile_improvement_proposal_default = {
|
|
|
6352
6352
|
],
|
|
6353
6353
|
"metadata": {
|
|
6354
6354
|
"fixture": "agent-profile-improvement-proposal",
|
|
6355
|
-
"runtimeVersion": "10.0.
|
|
6355
|
+
"runtimeVersion": "10.0.20"
|
|
6356
6356
|
},
|
|
6357
6357
|
"objectives": [
|
|
6358
6358
|
{
|
|
@@ -6463,7 +6463,7 @@ var agent_profile_improvement_proposal_default = {
|
|
|
6463
6463
|
"baselineContentHash": "sha256:21c495a37c418c10bde64fbaa188beddeed31f1f051ea60a6a6582a9ee0db704",
|
|
6464
6464
|
"candidateContentHash": "sha256:103f77bc8481601eef1ad5fe6ba84a40dffabc3a44f421f8c8559121edab84e9",
|
|
6465
6465
|
"kind": "agent-eval-loop",
|
|
6466
|
-
"recordDigest": "sha256:
|
|
6466
|
+
"recordDigest": "sha256:e12034ee9e7339b05db891fd13e5486377386932a2edfde39779f9cfd5c0d6e2",
|
|
6467
6467
|
"runId": "profile-improvement-1",
|
|
6468
6468
|
"schema": "agent-profile-improvement-experiment"
|
|
6469
6469
|
}
|
|
@@ -9,6 +9,7 @@ import { AgentTurnFailureSchema } from "@tangle-network/agent-interface/environm
|
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
import { setImmediate } from "node:timers/promises";
|
|
11
11
|
import { LedgerCanonicalizationError, canonicalString, jsonDocument, merkleLeafHash, merkleRoot, merkleSalt } from "@tangle-network/agent-eval/ledger-core";
|
|
12
|
+
import { createInterface } from "node:readline";
|
|
12
13
|
// src/record-value.ts
|
|
13
14
|
function recordValue(value) {
|
|
14
15
|
return isRecord(value) ? value : void 0;
|
|
@@ -2840,6 +2841,16 @@ const TEXT_REFUSALS = /Refusing to replace existing profile file: |Duplicate pro
|
|
|
2840
2841
|
/** True for an error that is itself a deterministic provisioning refusal (see above). */
|
|
2841
2842
|
const isProvisioningRefusal = (value) => refusedAs(PROVISIONING_REFUSALS, value) || value instanceof Error && TEXT_REFUSALS.test(errorProperty(value, "message") ?? "");
|
|
2842
2843
|
/**
|
|
2844
|
+
* Sandbox's refusal of a keyed create whose recorded box no longer exists (409): "The keyed
|
|
2845
|
+
* create's recorded project is unavailable; use a new key". The key can never create again, and a
|
|
2846
|
+
* create under another key is not refused. A box deleted after its create spends its key: the
|
|
2847
|
+
* Tangle provider deletes a box that fails its post-create checks, and Sandbox rolls back a box
|
|
2848
|
+
* whose GPU attach failed.
|
|
2849
|
+
*/
|
|
2850
|
+
const SPENT_CREATE_KEY_REFUSALS = /* @__PURE__ */ new Map([["CREATION_RESULT_UNAVAILABLE", 409]]);
|
|
2851
|
+
/** True for an error that is itself Sandbox's refusal of a spent create key (see above). */
|
|
2852
|
+
const isSpentCreateKeyRefusal = (value) => refusedAs(SPENT_CREATE_KEY_REFUSALS, value);
|
|
2853
|
+
/**
|
|
2843
2854
|
* Platform refusals the orchestrator answers BEFORE it forwards a dispatch, by machine code and
|
|
2844
2855
|
* the HTTP status it is sent with. Run 002f69d5: `HUB_CREDENTIAL_REFRESH_FAILED` at 503 left no
|
|
2845
2856
|
* effect, yet read as a lost transport. Any other 5xx stays a transport failure, in doubt.
|
|
@@ -3273,6 +3284,174 @@ function settlementFailureCause(down) {
|
|
|
3273
3284
|
...providerEvidence
|
|
3274
3285
|
};
|
|
3275
3286
|
}
|
|
3276
|
-
|
|
3287
|
+
// src/mcp/tool-server.ts
|
|
3288
|
+
/**
|
|
3289
|
+
* `createStdioToolServer` — the generic newline-delimited JSON-RPC 2.0 MCP
|
|
3290
|
+
* server core: `initialize` / `notifications/initialized` / `tools/list` /
|
|
3291
|
+
* `ping` / `tools/call` over a stdio-shaped transport. It answers the
|
|
3292
|
+
* client's protocol version when listed in `SUPPORTED_PROTOCOL_VERSIONS`,
|
|
3293
|
+
* else 2024-11-05, and publishes tool annotations when a tool declares them.
|
|
3294
|
+
*
|
|
3295
|
+
* @experimental
|
|
3296
|
+
*/
|
|
3297
|
+
const PROTOCOL_VERSION = "2024-11-05";
|
|
3298
|
+
/**
|
|
3299
|
+
* Protocol versions this server speaks, newest first. `initialize` answers with
|
|
3300
|
+
* the client's requested version when it is listed here, and otherwise with
|
|
3301
|
+
* `PROTOCOL_VERSION` (2024-11-05), which every client that speaks 2024-11-05 accepts.
|
|
3302
|
+
*/
|
|
3303
|
+
const SUPPORTED_PROTOCOL_VERSIONS = [
|
|
3304
|
+
"2025-11-25",
|
|
3305
|
+
"2025-06-18",
|
|
3306
|
+
"2025-03-26",
|
|
3307
|
+
PROTOCOL_VERSION
|
|
3308
|
+
];
|
|
3309
|
+
const toolFailureSchema = runtimeFailureCauseSchema.unwrap().pick({
|
|
3310
|
+
code: true,
|
|
3311
|
+
owner: true,
|
|
3312
|
+
providerCode: true,
|
|
3313
|
+
providerStatus: true,
|
|
3314
|
+
retryAfterMs: true
|
|
3315
|
+
});
|
|
3316
|
+
/** Build the generic stdio JSON-RPC tool server. */
|
|
3317
|
+
function createStdioToolServer(options) {
|
|
3318
|
+
const tools = /* @__PURE__ */ new Map();
|
|
3319
|
+
for (const tool of options.tools) {
|
|
3320
|
+
if (tools.has(tool.name)) throw new ValidationError(`createStdioToolServer: duplicate tool name "${tool.name}"`);
|
|
3321
|
+
tools.set(tool.name, tool);
|
|
3322
|
+
}
|
|
3323
|
+
let stopped = false;
|
|
3324
|
+
let activeReadline;
|
|
3325
|
+
async function handle(message) {
|
|
3326
|
+
if (stopped) return rpcError(message.id ?? null, -32099, "server stopped");
|
|
3327
|
+
if (message.method === "initialize") {
|
|
3328
|
+
const requested = message.params?.protocolVersion;
|
|
3329
|
+
return rpcResult(message.id ?? null, {
|
|
3330
|
+
protocolVersion: typeof requested === "string" && SUPPORTED_PROTOCOL_VERSIONS.includes(requested) ? requested : PROTOCOL_VERSION,
|
|
3331
|
+
capabilities: { tools: {} },
|
|
3332
|
+
serverInfo: {
|
|
3333
|
+
name: options.serverName,
|
|
3334
|
+
version: options.serverVersion
|
|
3335
|
+
}
|
|
3336
|
+
});
|
|
3337
|
+
}
|
|
3338
|
+
if (message.method === "notifications/initialized") return null;
|
|
3339
|
+
if (message.method === "ping") return rpcResult(message.id ?? null, {});
|
|
3340
|
+
if (message.method === "tools/list") return rpcResult(message.id ?? null, { tools: [...tools.values()].map((tool) => ({
|
|
3341
|
+
name: tool.name,
|
|
3342
|
+
description: tool.description,
|
|
3343
|
+
inputSchema: tool.inputSchema,
|
|
3344
|
+
...tool.annotations ? { annotations: tool.annotations } : {}
|
|
3345
|
+
})) });
|
|
3346
|
+
if (message.method === "tools/call") {
|
|
3347
|
+
const params = message.params ?? {};
|
|
3348
|
+
const name = typeof params.name === "string" ? params.name : "";
|
|
3349
|
+
const tool = tools.get(name);
|
|
3350
|
+
if (!tool) return rpcError(message.id ?? null, -32601, `unknown tool: ${name}`);
|
|
3351
|
+
try {
|
|
3352
|
+
const output = await tool.handler(params.arguments ?? {});
|
|
3353
|
+
return rpcResult(message.id ?? null, toolCallResult(output));
|
|
3354
|
+
} catch (err) {
|
|
3355
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
3356
|
+
const code = err instanceof TypeError || err instanceof RangeError ? -32602 : -32e3;
|
|
3357
|
+
const failure = toolFailureSchema.safeParse(runtimeFailureCause(err));
|
|
3358
|
+
return rpcError(message.id ?? null, code, reason, failure.success ? { failure: failure.data } : void 0);
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
if (message.id === void 0 || message.id === null) return null;
|
|
3362
|
+
return rpcError(message.id, -32601, `unknown method: ${message.method}`);
|
|
3363
|
+
}
|
|
3364
|
+
async function serve(transport) {
|
|
3365
|
+
const input = transport?.input ?? process.stdin;
|
|
3366
|
+
const output = transport?.output ?? process.stdout;
|
|
3367
|
+
const rl = createInterface({
|
|
3368
|
+
input,
|
|
3369
|
+
crlfDelay: Number.POSITIVE_INFINITY
|
|
3370
|
+
});
|
|
3371
|
+
activeReadline = rl;
|
|
3372
|
+
return new Promise((resolve, reject) => {
|
|
3373
|
+
rl.on("line", (line) => {
|
|
3374
|
+
const trimmed = line.trim();
|
|
3375
|
+
if (!trimmed) return;
|
|
3376
|
+
let parsed;
|
|
3377
|
+
try {
|
|
3378
|
+
parsed = JSON.parse(trimmed);
|
|
3379
|
+
} catch (err) {
|
|
3380
|
+
writeResponse(output, rpcError(null, -32700, `parse error: ${err.message}`));
|
|
3381
|
+
return;
|
|
3382
|
+
}
|
|
3383
|
+
if (parsed?.jsonrpc !== "2.0" || typeof parsed.method !== "string") {
|
|
3384
|
+
writeResponse(output, rpcError(parsed?.id ?? null, -32600, "invalid request"));
|
|
3385
|
+
return;
|
|
3386
|
+
}
|
|
3387
|
+
handle(parsed).then((response) => {
|
|
3388
|
+
if (response) writeResponse(output, response);
|
|
3389
|
+
});
|
|
3390
|
+
});
|
|
3391
|
+
rl.on("close", () => resolve());
|
|
3392
|
+
rl.on("error", (err) => reject(err));
|
|
3393
|
+
if (stopped) {
|
|
3394
|
+
rl.close();
|
|
3395
|
+
resolve();
|
|
3396
|
+
}
|
|
3397
|
+
});
|
|
3398
|
+
}
|
|
3399
|
+
function stop() {
|
|
3400
|
+
stopped = true;
|
|
3401
|
+
activeReadline?.close();
|
|
3402
|
+
activeReadline = void 0;
|
|
3403
|
+
}
|
|
3404
|
+
return {
|
|
3405
|
+
tools,
|
|
3406
|
+
handle,
|
|
3407
|
+
serve,
|
|
3408
|
+
stop
|
|
3409
|
+
};
|
|
3410
|
+
}
|
|
3411
|
+
function toolCallResult(output) {
|
|
3412
|
+
let json;
|
|
3413
|
+
try {
|
|
3414
|
+
json = JSON.stringify(output);
|
|
3415
|
+
} catch (err) {
|
|
3416
|
+
const reason = err instanceof Error ? `: ${err.message}` : "";
|
|
3417
|
+
throw new TypeError(`MCP tool result must be JSON-serializable${reason}`, { cause: err });
|
|
3418
|
+
}
|
|
3419
|
+
if (json === void 0) throw new TypeError("MCP tool result must be JSON-serializable");
|
|
3420
|
+
const serialized = JSON.parse(json);
|
|
3421
|
+
const result = {
|
|
3422
|
+
content: [{
|
|
3423
|
+
type: "text",
|
|
3424
|
+
text: typeof serialized === "string" ? serialized : json
|
|
3425
|
+
}],
|
|
3426
|
+
isError: false
|
|
3427
|
+
};
|
|
3428
|
+
if (serialized !== null && typeof serialized === "object" && !Array.isArray(serialized)) result.structuredContent = serialized;
|
|
3429
|
+
return result;
|
|
3430
|
+
}
|
|
3431
|
+
function rpcResult(id, result) {
|
|
3432
|
+
return {
|
|
3433
|
+
jsonrpc: "2.0",
|
|
3434
|
+
id,
|
|
3435
|
+
result
|
|
3436
|
+
};
|
|
3437
|
+
}
|
|
3438
|
+
function rpcError(id, code, message, data) {
|
|
3439
|
+
return {
|
|
3440
|
+
jsonrpc: "2.0",
|
|
3441
|
+
id,
|
|
3442
|
+
error: data === void 0 ? {
|
|
3443
|
+
code,
|
|
3444
|
+
message
|
|
3445
|
+
} : {
|
|
3446
|
+
code,
|
|
3447
|
+
message,
|
|
3448
|
+
data
|
|
3449
|
+
}
|
|
3450
|
+
};
|
|
3451
|
+
}
|
|
3452
|
+
function writeResponse(output, response) {
|
|
3453
|
+
output.write(`${JSON.stringify(response)}\n`);
|
|
3454
|
+
}
|
|
3455
|
+
export { budgetLeases as $, printedStatus as A, sandboxTerminalUsageField as At, executorFailure as B, PLACEMENT_SIGNALS as C, createSandboxUsageLedger as Ct, cappedDoublingMs as D, sameModelId as Dt, UNAVAILABLE_STATUSES as E, notifySandboxEventObserver as Et, TRACE_ROOT_SCHEMA as F, turnFailureOf as G, executorFailureReason as H, TRACE_SUMMARY_SCHEMA as I, hashJson as J, turnFailurePolicy as K, traceRootWriter as L, unavailablePauseMs as M, decodeHarnessUsage as Mt, unavailableResumeAt as N, parseCodexUsageRecord as Nt, jitteredMs as O, sandboxEventProviderModels as Ot, unavailableSignalOfFailure as P, recordValue as Pt, budgetLeaseUpdates as Q, contentAddress as R, retainedExecutorSeamKey as S, createSandboxTurnEventCollector as St, UNAVAILABLE_CODES as T, isSandboxTerminalEvent as Tt, harnessProcessDied as U, executorFailureInfra as V, runtimeFailureRemediationSchema as W, isCredentialRefusal as X, credentialCommandExit as Y, BudgetReconcileFault as Z, leafContinuationExecutionId as _, canonicalStreamEventFromSandboxEvent as _t, runtimeFailureCauseSchema as a, newUsageTotals as at, registerRetainedExecutorPreparation as b, assertSandboxServedModel as bt, BUDGET_CONTINUATION_TASK as c, assertValidBudget as ct, RetainedExecutionPendingError as d, mapSandboxEvent as dt, budgetRecoverySeeds as et, TRANSPORT_ERROR_CODES as f, mapSandboxToolEvent as ft, isSpentCreateKeyRefusal as g, terminalTextFromSandboxEvent as gt, isSchemaRejection as h, sandboxProgressEvents as ht, runtimeFailureCause as i, meterUsageEvent as it, reportedResetAt as j, sumSandboxUsage as jt, placementRefusal as k, sandboxEventServedBackend as kt, DISPATCH_EXECUTION_CHANGED_CODE as l, assertValidSpend as lt, isProvisioningRefusal as m, sandboxOutputMarker as mt, createStdioToolServer as n, createBudgetPool as nt, runtimeProviderCode as o, spendFromUsageEvents as ot, executorEvidenceWriter as p, sandboxLeafOutputFromEvents as pt, turnRemediationOf as q, reportedFailureCause as r, refreshBudgetLease as rt, settlementFailureCause as s, spendFromUsageTotals as st, PROTOCOL_VERSION as t, completedLeafBacking as tt, DISPATCH_NOT_ADMITTED_CODE as u, createSandboxToolPartState as ut, prepareRetainedExecutor as v, extractTransportEventIdentity as vt, RATE_LIMIT_SIGNALS as w, extractLlmCallEvent as wt, retainedExecutorContext as x, canonicalSandboxUsageMode as xt, refusedBeforeItRan as y, parseCanonicalTransportEvent as yt, contentRef as z };
|
|
3277
3456
|
|
|
3278
|
-
//# sourceMappingURL=
|
|
3457
|
+
//# sourceMappingURL=tool-server-n4XYpCok.js.map
|