@tangle-network/agent-runtime 0.132.13 → 0.133.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -7
- package/dist/{activation-CWX1dpfx.js → activation-BKeGUWTV.js} +3 -3
- package/dist/{activation-CWX1dpfx.js.map → activation-BKeGUWTV.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/{analyst-loop-CBiT-ev1.js → analyst-loop-C189F6v8.js} +2 -2
- package/dist/{analyst-loop-CBiT-ev1.js.map → analyst-loop-C189F6v8.js.map} +1 -1
- package/dist/analyst-loop.js +1 -1
- package/dist/{authoring-D8uh1TYA.js → authoring-CoJWo0Ju.js} +2 -2
- package/dist/{authoring-D8uh1TYA.js.map → authoring-CoJWo0Ju.js.map} +1 -1
- package/dist/candidate-execution/index.js +4 -4
- package/dist/{candidate-execution-DUefVdnW.js → candidate-execution-gDXl7pGk.js} +4 -4
- package/dist/{candidate-execution-DUefVdnW.js.map → candidate-execution-gDXl7pGk.js.map} +1 -1
- package/dist/{conversation-BiII3X_6.js → conversation-kPowfA_A.js} +4 -4
- package/dist/{conversation-BiII3X_6.js.map → conversation-kPowfA_A.js.map} +1 -1
- package/dist/conversation.d.ts +1 -1
- package/dist/conversation.js +1 -1
- package/dist/{environment-provider-CkSDxRZd.d.ts → environment-provider-B-w9VYcF.d.ts} +4 -4
- package/dist/environment-provider.d.ts +1 -1
- package/dist/{errors-DEAvWQPy.js → errors-DRoXIc7E.js} +45 -2
- package/dist/errors-DRoXIc7E.js.map +1 -0
- package/dist/{graph-BJy5vrLu.js → graph-B2xqnhnF.js} +4 -4
- package/dist/{graph-BJy5vrLu.js.map → graph-B2xqnhnF.js.map} +1 -1
- package/dist/{improvement-cycle-zRBcigo7.js → improvement-cycle-Cq5xHru1.js} +9 -9
- package/dist/{improvement-cycle-zRBcigo7.js.map → improvement-cycle-Cq5xHru1.js.map} +1 -1
- package/dist/{index-CWnUn15M.d.ts → index-B7qKWyMV.d.ts} +250 -98
- package/dist/{index-DHwZyU_t.d.ts → index-BNz-BzLt.d.ts} +4 -4
- package/dist/{index-Cdf9NET5.d.ts → index-DqJa9jGF.d.ts} +2 -2
- package/dist/index.d.ts +8 -8
- package/dist/index.js +15 -15
- package/dist/intelligence.d.ts +4 -4
- package/dist/intelligence.js +5 -5
- package/dist/kernel.d.ts +6 -6
- package/dist/kernel.js +10 -10
- package/dist/{knowledge-BbG7PnL5.js → knowledge-D-ofzi3v.js} +7 -7
- package/dist/{knowledge-BbG7PnL5.js.map → knowledge-D-ofzi3v.js.map} +1 -1
- package/dist/knowledge.d.ts +1 -1
- package/dist/knowledge.js +1 -1
- package/dist/{loop-runner-bin-DpjmkfXR.js → loop-runner-bin-BwF5A_xf.js} +5 -5
- package/dist/{loop-runner-bin-DpjmkfXR.js.map → loop-runner-bin-BwF5A_xf.js.map} +1 -1
- package/dist/{loop-runner-bin-C-u6nlIN.d.ts → loop-runner-bin-CBW9ri20.d.ts} +3 -3
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/{materialization-JR_nN_oT.js → materialization-D2bdTfkK.js} +78 -17
- package/dist/materialization-D2bdTfkK.js.map +1 -0
- package/dist/mcp/bin.js +4 -4
- package/dist/mcp/index.d.ts +3 -3
- package/dist/mcp/index.js +8 -8
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/{memory-server-eD2baiRO.js → memory-server-CblxrUKT.js} +3 -3
- package/dist/{memory-server-eD2baiRO.js.map → memory-server-CblxrUKT.js.map} +1 -1
- package/dist/{model-policy-mWSoToiQ.js → model-policy-Bv1DU2fw.js} +2 -2
- package/dist/{model-policy-mWSoToiQ.js.map → model-policy-Bv1DU2fw.js.map} +1 -1
- package/dist/{openai-tools-Cmu2MzOW.js → openai-tools-rpPRFsVG.js} +2 -2
- package/dist/{openai-tools-Cmu2MzOW.js.map → openai-tools-rpPRFsVG.js.map} +1 -1
- package/dist/{prepare-BQ82nG06.js → prepare-DWH0J5z2.js} +2 -2
- package/dist/{prepare-BQ82nG06.js.map → prepare-DWH0J5z2.js.map} +1 -1
- package/dist/primeintellect/index.d.ts +1 -1
- package/dist/profiles.js +1 -1
- package/dist/{protected-model-port-BAOj4gQN.js → protected-model-port-djV8FMXc.js} +2 -2
- package/dist/{protected-model-port-BAOj4gQN.js.map → protected-model-port-djV8FMXc.js.map} +1 -1
- package/dist/{redact-DMqkOZNV.d.ts → redact-BSD-nvTf.d.ts} +3 -3
- package/dist/{researcher-CYmr4VJy.js → researcher-BiWSFLi6.js} +3 -3
- package/dist/{researcher-CYmr4VJy.js.map → researcher-BiWSFLi6.js.map} +1 -1
- package/dist/{runtime-DDg4OVlX.js → runtime-CmTSbexZ.js} +228 -88
- package/dist/runtime-CmTSbexZ.js.map +1 -0
- package/dist/{runtime-CIVruNqK.d.ts → runtime-D-26vxJt.d.ts} +3 -3
- package/dist/{snapshot-CXiiuHhL.js → snapshot-DY6VGliG.js} +2 -2
- package/dist/{snapshot-CXiiuHhL.js.map → snapshot-DY6VGliG.js.map} +1 -1
- package/dist/{spawn-journal-Cd5L-Ie9.js → spawn-journal-BX3-4WDm.js} +185 -7
- package/dist/spawn-journal-BX3-4WDm.js.map +1 -0
- package/dist/{stream-agent-turn-Bo5ZSAUR.js → stream-agent-turn-D8YHY0oO.js} +4 -4
- package/dist/{stream-agent-turn-Bo5ZSAUR.js.map → stream-agent-turn-D8YHY0oO.js.map} +1 -1
- package/dist/{stream-agent-turn-By46GZlo.d.ts → stream-agent-turn-NFWCv1X1.d.ts} +2 -2
- package/dist/{structural-rollout-CwK_V7eP.js → structural-rollout-Cy0l0bbT.js} +6 -6
- package/dist/{structural-rollout-CwK_V7eP.js.map → structural-rollout-Cy0l0bbT.js.map} +1 -1
- package/dist/{supervise-B8BYfxEw.js → supervise-DZxpJGK_.js} +102 -33
- package/dist/supervise-DZxpJGK_.js.map +1 -0
- package/dist/{supervisor-DnA7FWmf.js → supervisor-BpIcKHy7.js} +82 -21
- package/dist/supervisor-BpIcKHy7.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +12 -12
- package/dist/{tool-server-Gs3VvfSK.js → tool-server-VvSK1K3X.js} +2 -2
- package/dist/{tool-server-Gs3VvfSK.js.map → tool-server-VvSK1K3X.js.map} +1 -1
- package/dist/{types-BjUQODeG.d.ts → types-DJ7k6vHE.d.ts} +30 -6
- package/dist/{workspace-archive-CGcXL3zA.js → workspace-archive-DdrlLnIj.js} +2 -2
- package/dist/{workspace-archive-CGcXL3zA.js.map → workspace-archive-DdrlLnIj.js.map} +1 -1
- package/package.json +1 -1
- package/dist/errors-DEAvWQPy.js.map +0 -1
- package/dist/materialization-JR_nN_oT.js.map +0 -1
- package/dist/runtime-DDg4OVlX.js.map +0 -1
- package/dist/spawn-journal-Cd5L-Ie9.js.map +0 -1
- package/dist/supervise-B8BYfxEw.js.map +0 -1
- package/dist/supervisor-DnA7FWmf.js.map +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./stream-agent-turn-
|
|
3
|
-
import { i as InMemorySpawnJournal, r as InMemoryResultBlobStore,
|
|
1
|
+
import { c as RetainedRunAdmissionError, f as ValidationError, l as RetainedRunDispatchBindingError, n as AnalystError, s as PlannerError } from "./errors-DRoXIc7E.js";
|
|
2
|
+
import "./stream-agent-turn-D8YHY0oO.js";
|
|
3
|
+
import { S as contentAddress, i as InMemorySpawnJournal, r as InMemoryResultBlobStore, y as isTraceAnalysisStore } from "./spawn-journal-BX3-4WDm.js";
|
|
4
4
|
import { a as isAbortError, i as hasCompleteCacheBreakdown, l as sleep, m as zeroTokenUsage, n as cloneTokenUsage, s as randomSuffix, t as addTokenUsage, u as stringifySafe } from "./util-Dr--8wAL.js";
|
|
5
5
|
import { i as redactProtectedValue, r as redactProtectedReason } from "./protected-redaction--F3v1oo8.js";
|
|
6
6
|
import { a as notifySandboxEventObserver, c as parseCanonicalTransportEvent, s as extractTransportEventIdentity } from "./sandbox-events-vIwmuPdl.js";
|
|
7
|
-
import { c as profileProviderModel, i as concreteModelId, s as profileModelExecutionSettings, t as assertExecutableAgentProfile } from "./model-policy-
|
|
8
|
-
import {
|
|
9
|
-
import { $ as
|
|
7
|
+
import { c as profileProviderModel, i as concreteModelId, s as profileModelExecutionSettings, t as assertExecutableAgentProfile } from "./model-policy-Bv1DU2fw.js";
|
|
8
|
+
import { T as executableAgentSpecSnapshot, w as executableAgentProfileSnapshot } from "./materialization-D2bdTfkK.js";
|
|
9
|
+
import { $ as defaultSelectWinner, F as createExecutorRegistry, G as createPushTraceSource, L as createWorktreeCliExecutor, P as createExecutor, T as rollingDispatch, at as runBrainLoop, et as runAgentRounds, h as settledToIteration, it as routerBrain, l as withDriverExecutor, n as createSupervisor, nt as probeSandboxCapabilities, ot as canonicalObservedModel, tt as createSandboxLineage } from "./supervisor-BpIcKHy7.js";
|
|
10
10
|
import "./environment-provider-mDsjfGjY.js";
|
|
11
11
|
import { i as notifyRuntimeHookEvent } from "./runtime-hooks-C7iJOWm3.js";
|
|
12
|
-
import { C as observe, O as strategyAuthorMethod, T as profileChatClient, b as sample, v as refine, x as sampleThenRefine, y as runAgentic } from "./structural-rollout-
|
|
13
|
-
import { It as gateOnDeliverable, Lt as mapExecutorResult, n as supervise } from "./supervise-
|
|
14
|
-
import "./authoring-
|
|
15
|
-
import "./graph-
|
|
16
|
-
import { CODING_HARNESSES, InMemoryTraceStore, OUTPUT_VALUE, benjaminiHochberg, buildTrajectory, computeFindingId as computeFindingId$1, confidenceInterval, expandProfileAxes, makeFinding as makeFinding$1,
|
|
12
|
+
import { C as observe, O as strategyAuthorMethod, T as profileChatClient, b as sample, v as refine, x as sampleThenRefine, y as runAgentic } from "./structural-rollout-Cy0l0bbT.js";
|
|
13
|
+
import { It as gateOnDeliverable, Lt as mapExecutorResult, n as supervise } from "./supervise-DZxpJGK_.js";
|
|
14
|
+
import "./authoring-CoJWo0Ju.js";
|
|
15
|
+
import "./graph-B2xqnhnF.js";
|
|
16
|
+
import { CODING_HARNESSES, InMemoryTraceStore, OUTPUT_VALUE, benjaminiHochberg, buildTrajectory, computeFindingId as computeFindingId$1, confidenceInterval, expandProfileAxes, makeFinding as makeFinding$1, pairedBootstrap, paretoFrontier, wilcoxonSignedRank, wilson } from "@tangle-network/agent-eval";
|
|
17
17
|
import { heldoutSignificance, runProfileMatrix } from "@tangle-network/agent-eval/campaign";
|
|
18
18
|
import { AgentEnvironmentCapabilitiesSchema, AgentExactRunControlRefSchema, AgentNativeContextContinuationResultSchema, AgentRunCancellationAcknowledgementSchema, AgentRunCancellationRequestSchema, AgentTurnResultSchema, InteractionAcknowledgementSchema, InteractionResponseCommandSchema, NativeContextBoundaryProofSchema, NativeContextContinuationRequestSchema, RuntimeEventEnvelopeSchema, agentNativeContextContinuationResultMatchesRequest, agentProfileSchema, agentRunCancellationAcknowledgementMatchesRequest, agentRunCancellationRequestDigest, canonicalAgentProfileDigest, canonicalCandidateDigest, nativeContextContinuationTurnDigest, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
|
|
19
19
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
@@ -995,38 +995,6 @@ function deterministicCompletion(check) {
|
|
|
995
995
|
}
|
|
996
996
|
//#endregion
|
|
997
997
|
//#region src/runtime/loop-dispatch.ts
|
|
998
|
-
/**
|
|
999
|
-
* `loopDispatch` — turn `runAgentRounds` into an agent-eval campaign dispatch.
|
|
1000
|
-
*
|
|
1001
|
-
* Without this adapter a consumer wiring `runAgentRounds` into `runProfileMatrix` /
|
|
1002
|
-
* `runCampaign` has to, by hand, every time: (a) build an `ExecCtx` with a
|
|
1003
|
-
* sandbox client, (b) adapt the campaign `DispatchContext.trace` into a
|
|
1004
|
-
* `LoopTraceEmitter` (or lose all loop trace correlation), and (c) remember to
|
|
1005
|
-
* forward the loop's cost + tokens via `ctx.cost` (forgetting it yields a
|
|
1006
|
-
* `{0,0}` cell the backend-integrity guard reads as a stub). Three foot-guns,
|
|
1007
|
-
* the third silent. The fleet's products skipped (c) and fell back to a
|
|
1008
|
-
* `workerRecords[]` side-channel — the exact anti-pattern the substrate exists
|
|
1009
|
-
* to kill.
|
|
1010
|
-
*
|
|
1011
|
-
* `loopDispatch` collapses all three into one typed call:
|
|
1012
|
-
*
|
|
1013
|
-
* const dispatch = loopDispatch({
|
|
1014
|
-
* sandboxClient,
|
|
1015
|
-
* toLoopOptions: (scenario, profile) => ({ driver, agentRun, output, validator, task }),
|
|
1016
|
-
* })
|
|
1017
|
-
* await runProfileMatrix({ profiles, scenarios, dispatch, judges, commitSha })
|
|
1018
|
-
*
|
|
1019
|
-
* The complete Runtime cell starts inside `ctx.cost.runPaidCall` before any
|
|
1020
|
-
* sandbox work begins. Its provider-reported usage becomes the paid-call
|
|
1021
|
-
* receipt before Eval settles the call. A completed `LoopResult` cannot be
|
|
1022
|
-
* attached afterward because it cannot prove pre-execution admission.
|
|
1023
|
-
* Trace events are forwarded automatically and the Runtime context is built
|
|
1024
|
-
* automatically.
|
|
1025
|
-
*
|
|
1026
|
-
* Typed structurally against the campaign `DispatchContext` (imported type-only
|
|
1027
|
-
* from `@tangle-network/agent-eval/campaign`) — a downward dependency, never an
|
|
1028
|
-
* inversion.
|
|
1029
|
-
*/
|
|
1030
998
|
/** Bridge a campaign `DispatchContext.trace` to a `LoopTraceEmitter` so every
|
|
1031
999
|
* `loop.*` event lands as a span under the cell's scoped trace. */
|
|
1032
1000
|
function campaignTraceToLoopEmitter(trace) {
|
|
@@ -1095,43 +1063,84 @@ function costReceiptFromUsage(usage, model, cost) {
|
|
|
1095
1063
|
...cost.estimatedCostUsd !== void 0 ? { estimatedCostUsd: cost.estimatedCostUsd } : {}
|
|
1096
1064
|
};
|
|
1097
1065
|
}
|
|
1098
|
-
/**
|
|
1099
|
-
*
|
|
1100
|
-
*
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1103
|
-
*
|
|
1104
|
-
|
|
1105
|
-
*/
|
|
1106
|
-
|
|
1107
|
-
const
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1066
|
+
/** Eval has one pre-admitted paid call for this dispatch. A tree can settle that call only when
|
|
1067
|
+
* Runtime has provider-served identity for every inference attempt that actually started. Plan
|
|
1068
|
+
* materialization is deliberately ignored: it describes what Runtime requested, not what the
|
|
1069
|
+
* provider served. Every visible terminal child must carry provider attempt evidence; a missing
|
|
1070
|
+
* evidence record stays unknown, including zero-valued or incomplete spend.
|
|
1071
|
+
* @internal Testable identity projection used by superviseDispatch. */
|
|
1072
|
+
function supervisedTreeModelForDispatch(result, rootProfile) {
|
|
1073
|
+
const canonicalModels = /* @__PURE__ */ new Set();
|
|
1074
|
+
const observedModels = [];
|
|
1075
|
+
const wholeTreeEvidence = result.providerModel;
|
|
1076
|
+
if (wholeTreeEvidence === void 0 || wholeTreeEvidence.status !== "known" && wholeTreeEvidence.reason !== "provider-model-conflict" || wholeTreeEvidence.attempts.length === 0) return { kind: "unknown" };
|
|
1077
|
+
const wholeTreeIdentity = collectProviderModels(wholeTreeEvidence, () => true);
|
|
1078
|
+
if (wholeTreeIdentity.kind !== "known") return wholeTreeIdentity;
|
|
1079
|
+
for (const model of wholeTreeIdentity.observed) {
|
|
1080
|
+
observedModels.push(model.raw);
|
|
1081
|
+
canonicalModels.add(model.canonical);
|
|
1113
1082
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
if (node.ownedTreeRoot !== void 0) {
|
|
1117
|
-
unknown = true;
|
|
1118
|
-
continue;
|
|
1119
|
-
}
|
|
1120
|
-
const materialization = node.materialization;
|
|
1121
|
-
if (materialization?.status !== "known" || materialization.model.status !== "known") {
|
|
1122
|
-
unknown = true;
|
|
1123
|
-
continue;
|
|
1124
|
-
}
|
|
1125
|
-
models.add(materialization.model.id);
|
|
1126
|
-
}
|
|
1127
|
-
if (unknown || models.size === 0) return { kind: "unknown" };
|
|
1128
|
-
if (models.size !== 1) return {
|
|
1083
|
+
if (canonicalModels.size === 0) return { kind: "unknown" };
|
|
1084
|
+
if (canonicalModels.size !== 1) return {
|
|
1129
1085
|
kind: "mixed",
|
|
1130
|
-
models: [...
|
|
1086
|
+
models: [...canonicalModels].sort()
|
|
1131
1087
|
};
|
|
1132
1088
|
return {
|
|
1133
1089
|
kind: "known",
|
|
1134
|
-
model: [
|
|
1090
|
+
model: observedModels[0]
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
function collectProviderModels(evidence, validate) {
|
|
1094
|
+
if (evidence.status !== "known" && evidence.reason !== "provider-model-conflict" || !Array.isArray(evidence.attempts) || evidence.attempts.length === 0 || !Array.isArray(evidence.models)) return { kind: "unknown" };
|
|
1095
|
+
const observed = [];
|
|
1096
|
+
const canonical = /* @__PURE__ */ new Set();
|
|
1097
|
+
const observedRaw = /* @__PURE__ */ new Set();
|
|
1098
|
+
for (const attempt of evidence.attempts) {
|
|
1099
|
+
if (attempt === null || typeof attempt !== "object" || !Array.isArray(attempt.observations) || attempt.observations.length === 0 || attempt.identityConflict === true) return { kind: "unknown" };
|
|
1100
|
+
let attemptBase;
|
|
1101
|
+
let attemptSnapshot;
|
|
1102
|
+
let representative;
|
|
1103
|
+
for (const model of attempt.observations) {
|
|
1104
|
+
if (typeof model !== "string" || !validate(model)) return { kind: "unknown" };
|
|
1105
|
+
const identity = canonicalObservedModel(model);
|
|
1106
|
+
if (identity === void 0) return { kind: "unknown" };
|
|
1107
|
+
const at = identity.lastIndexOf("@");
|
|
1108
|
+
const base = at < 0 ? identity : identity.slice(0, at);
|
|
1109
|
+
const snapshot = at < 0 ? void 0 : identity.slice(at + 1);
|
|
1110
|
+
if (attemptBase !== void 0 && attemptBase !== base) return {
|
|
1111
|
+
kind: "mixed",
|
|
1112
|
+
models: [.../* @__PURE__ */ new Set([...attemptBase ? [attemptBase] : [], identity])]
|
|
1113
|
+
};
|
|
1114
|
+
if (attemptSnapshot !== void 0 && snapshot !== void 0 && attemptSnapshot !== snapshot) return {
|
|
1115
|
+
kind: "mixed",
|
|
1116
|
+
models: [`${attemptBase}@${attemptSnapshot}`, `${base}@${snapshot}`]
|
|
1117
|
+
};
|
|
1118
|
+
attemptBase = base;
|
|
1119
|
+
attemptSnapshot ??= snapshot;
|
|
1120
|
+
if (snapshot !== void 0) representative = model;
|
|
1121
|
+
observedRaw.add(model);
|
|
1122
|
+
}
|
|
1123
|
+
if (attemptBase === void 0 || attemptSnapshot === void 0 || representative === void 0) return { kind: "unknown" };
|
|
1124
|
+
const attemptIdentity = `${attemptBase}@${attemptSnapshot}`;
|
|
1125
|
+
observed.push({
|
|
1126
|
+
raw: representative,
|
|
1127
|
+
canonical: attemptIdentity
|
|
1128
|
+
});
|
|
1129
|
+
canonical.add(attemptIdentity);
|
|
1130
|
+
}
|
|
1131
|
+
if (observed.length === 0) return { kind: "unknown" };
|
|
1132
|
+
const declaredRaw = /* @__PURE__ */ new Set();
|
|
1133
|
+
for (const model of evidence.models) {
|
|
1134
|
+
if (typeof model !== "string") return { kind: "unknown" };
|
|
1135
|
+
declaredRaw.add(model);
|
|
1136
|
+
}
|
|
1137
|
+
if (declaredRaw.size !== observedRaw.size || [...declaredRaw].some((model) => !observedRaw.has(model))) return { kind: "unknown" };
|
|
1138
|
+
return canonical.size > 1 ? {
|
|
1139
|
+
kind: "mixed",
|
|
1140
|
+
models: [...canonical].sort()
|
|
1141
|
+
} : {
|
|
1142
|
+
kind: "known",
|
|
1143
|
+
observed
|
|
1135
1144
|
};
|
|
1136
1145
|
}
|
|
1137
1146
|
/** The Eval receipt surface has no pre-admitted per-model recursive-tree receipt bundle yet. */
|
|
@@ -1168,12 +1177,12 @@ function superviseDispatch(opts) {
|
|
|
1168
1177
|
...superviseOptions,
|
|
1169
1178
|
signal: executionSignal
|
|
1170
1179
|
});
|
|
1171
|
-
const identity =
|
|
1180
|
+
const identity = supervisedTreeModelForDispatch(result, profile);
|
|
1172
1181
|
if (identity.kind !== "known") throw new SupervisedTreeModelIdentityError(identity);
|
|
1173
1182
|
return result;
|
|
1174
1183
|
},
|
|
1175
1184
|
receipt: (result) => {
|
|
1176
|
-
const identity =
|
|
1185
|
+
const identity = supervisedTreeModelForDispatch(result, profile);
|
|
1177
1186
|
if (identity.kind !== "known") throw new SupervisedTreeModelIdentityError(identity);
|
|
1178
1187
|
return costReceiptFromUsage(result.spentTotal.tokens, identity.model, {
|
|
1179
1188
|
usageUnknown: result.spentTotal.tokensKnown === false,
|
|
@@ -3854,8 +3863,33 @@ function freshTurnInput(input, runtime) {
|
|
|
3854
3863
|
//#endregion
|
|
3855
3864
|
//#region src/runtime/retained-run-start.ts
|
|
3856
3865
|
/**
|
|
3866
|
+
* Mint deterministic dispatch coordinates from the two caller-supplied keys.
|
|
3867
|
+
* The same `(idempotencyKey, turnId)` pair yields the same coordinates in
|
|
3868
|
+
* every process, so a pre-dispatch admission record always names the exact
|
|
3869
|
+
* session and execution the dispatch will request. Format is readable, not
|
|
3870
|
+
* hashed, following `deriveExecutionId`: components are URL-encoded so
|
|
3871
|
+
* delimiters inside caller keys cannot collapse distinct pairs, and the
|
|
3872
|
+
* result stays inside the 256-byte identifier bound.
|
|
3873
|
+
*/
|
|
3874
|
+
function mintRetainedIdentity(idempotencyKey, turnId) {
|
|
3875
|
+
const base = `${encodeURIComponent(idempotencyKey)}:${encodeURIComponent(turnId)}`;
|
|
3876
|
+
const sessionId = `retained-session:${base}`;
|
|
3877
|
+
const executionId = `retained-execution:${base}`;
|
|
3878
|
+
if (executionId.length > 256) throw new RangeError("minted retained identity must not exceed 256 bytes");
|
|
3879
|
+
return {
|
|
3880
|
+
sessionId,
|
|
3881
|
+
executionId
|
|
3882
|
+
};
|
|
3883
|
+
}
|
|
3884
|
+
/**
|
|
3857
3885
|
* Dispatch one detached, replayable run and return only after exact durable
|
|
3858
|
-
* coordinates are confirmed by the provider.
|
|
3886
|
+
* coordinates are confirmed by the provider and persisted by the caller.
|
|
3887
|
+
*
|
|
3888
|
+
* The required `onAdmission` hook is awaited twice: with the recovery
|
|
3889
|
+
* coordinates after environment creation, and with the verified exact control
|
|
3890
|
+
* reference after dispatch. The returned promise resolves only after the
|
|
3891
|
+
* dispatched admission is durable, so no caller can observe a successful start
|
|
3892
|
+
* whose exact reference a crash would lose.
|
|
3859
3893
|
*
|
|
3860
3894
|
* @stable
|
|
3861
3895
|
*/
|
|
@@ -3866,9 +3900,19 @@ async function startRetainedRun(options) {
|
|
|
3866
3900
|
assertStableText(options.identity.sessionId, "retained session id");
|
|
3867
3901
|
assertStableText(options.identity.executionId, "retained execution id");
|
|
3868
3902
|
}
|
|
3903
|
+
if (typeof options.onAdmission !== "function") throw new Error("startRetainedRun requires an awaited onAdmission durability hook");
|
|
3904
|
+
const identity = options.identity ?? mintRetainedIdentity(options.environment.idempotencyKey, options.turn.turnId);
|
|
3869
3905
|
const capabilities = await assertRetainedCapabilities(options.provider);
|
|
3870
3906
|
if (!options.provider.get) throw new Error(`provider "${options.provider.name}" cannot reconstruct an environment by id`);
|
|
3871
|
-
const environment = await options.provider.create(
|
|
3907
|
+
const environment = await options.provider.create({
|
|
3908
|
+
...options.environment,
|
|
3909
|
+
metadata: {
|
|
3910
|
+
...options.environment.metadata,
|
|
3911
|
+
retainedIdempotencyKey: options.environment.idempotencyKey,
|
|
3912
|
+
sessionId: identity.sessionId,
|
|
3913
|
+
executionId: identity.executionId
|
|
3914
|
+
}
|
|
3915
|
+
});
|
|
3872
3916
|
if (!environment.dispatch || !environment.session) {
|
|
3873
3917
|
try {
|
|
3874
3918
|
await environment.destroy?.();
|
|
@@ -3877,19 +3921,115 @@ async function startRetainedRun(options) {
|
|
|
3877
3921
|
}
|
|
3878
3922
|
throw new Error(`provider "${options.provider.name}" does not expose detached session control`);
|
|
3879
3923
|
}
|
|
3924
|
+
await admitDurably(options.onAdmission, {
|
|
3925
|
+
phase: "environment",
|
|
3926
|
+
provider: options.provider.name,
|
|
3927
|
+
environmentId: environment.id,
|
|
3928
|
+
idempotencyKey: options.environment.idempotencyKey,
|
|
3929
|
+
turnId: options.turn.turnId,
|
|
3930
|
+
sessionId: identity.sessionId,
|
|
3931
|
+
executionId: identity.executionId
|
|
3932
|
+
});
|
|
3880
3933
|
const reference = await environment.dispatch(freshTurnInput(options.turn, {
|
|
3881
3934
|
turnId: options.turn.turnId,
|
|
3882
3935
|
detach: true,
|
|
3883
|
-
...
|
|
3884
|
-
}));
|
|
3885
|
-
if (reference.provider !== void 0 && reference.provider !== options.provider.name) throw new Error("provider dispatch returned a session reference for another provider");
|
|
3886
|
-
const exact = exactSession(environment, exactControlRef(reference.controlRef, {
|
|
3887
|
-
provider: options.provider.name,
|
|
3888
|
-
environmentId: environment.id,
|
|
3889
|
-
sessionId: reference.id
|
|
3936
|
+
...identity
|
|
3890
3937
|
}));
|
|
3938
|
+
let exact;
|
|
3939
|
+
try {
|
|
3940
|
+
if (reference.provider !== void 0 && reference.provider !== options.provider.name) throw new Error("provider dispatch returned a session reference for another provider");
|
|
3941
|
+
if (reference.id !== identity.sessionId) throw new Error("provider dispatched into another session than the requested identity");
|
|
3942
|
+
const controlRef = exactControlRef(reference.controlRef, {
|
|
3943
|
+
provider: options.provider.name,
|
|
3944
|
+
environmentId: environment.id,
|
|
3945
|
+
sessionId: identity.sessionId
|
|
3946
|
+
});
|
|
3947
|
+
if (controlRef.executionId !== identity.executionId) throw new Error("provider bound another execution than the requested identity");
|
|
3948
|
+
exact = exactSession(environment, controlRef);
|
|
3949
|
+
} catch (error) {
|
|
3950
|
+
throw new RetainedRunDispatchBindingError({
|
|
3951
|
+
provider: options.provider.name,
|
|
3952
|
+
environmentId: environment.id,
|
|
3953
|
+
sessionId: identity.sessionId,
|
|
3954
|
+
executionId: identity.executionId
|
|
3955
|
+
}, {
|
|
3956
|
+
...reference.id === void 0 ? {} : { id: reference.id },
|
|
3957
|
+
...reference.provider === void 0 ? {} : { provider: reference.provider },
|
|
3958
|
+
...reference.controlRef === void 0 ? {} : { controlRef: reference.controlRef }
|
|
3959
|
+
}, { cause: error });
|
|
3960
|
+
}
|
|
3961
|
+
await admitDurably(options.onAdmission, {
|
|
3962
|
+
phase: "dispatched",
|
|
3963
|
+
controlRef: freezeControlRef(exact.controlRef),
|
|
3964
|
+
idempotencyKey: options.environment.idempotencyKey,
|
|
3965
|
+
turnId: options.turn.turnId
|
|
3966
|
+
});
|
|
3891
3967
|
return createRetainedRunHandle(environment, exact.session, exact.controlRef, capabilities, options.now);
|
|
3892
3968
|
}
|
|
3969
|
+
/**
|
|
3970
|
+
* Await one admission record through the caller's durability hook. A rejection
|
|
3971
|
+
* keeps the environment alive — the provider state plus any partial admission
|
|
3972
|
+
* record is the recovery path — and surfaces as `RetainedRunAdmissionError` so
|
|
3973
|
+
* callers can distinguish a persistence failure from a provider failure.
|
|
3974
|
+
*/
|
|
3975
|
+
async function admitDurably(onAdmission, admission) {
|
|
3976
|
+
try {
|
|
3977
|
+
await onAdmission(Object.freeze(admission));
|
|
3978
|
+
} catch (error) {
|
|
3979
|
+
throw new RetainedRunAdmissionError(admission, { cause: error });
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
/**
|
|
3983
|
+
* Rebuild the exact run named by pre-dispatch admission coordinates, or
|
|
3984
|
+
* report why the provider cannot prove it.
|
|
3985
|
+
*
|
|
3986
|
+
* `not_found`: the provider no longer holds the environment, so nothing
|
|
3987
|
+
* remains to destroy. `recovered`: the provider self-identified the session
|
|
3988
|
+
* with a strict exact reference matching the recorded coordinates.
|
|
3989
|
+
* `unverifiable`: the environment exists but the provider cannot
|
|
3990
|
+
* self-identify the session — no session accessor, an accessor that throws,
|
|
3991
|
+
* a lazy accessor with no stored reference, or a loose reference. That
|
|
3992
|
+
* outcome is never destroy-safe: keep the environment, retry
|
|
3993
|
+
* `reconnectRetainedRun` with a dispatched admission record, or inspect the
|
|
3994
|
+
* environment with provider-native tools. A session that self-identifies
|
|
3995
|
+
* with different coordinates throws: something live is not the recorded run.
|
|
3996
|
+
*
|
|
3997
|
+
* @stable
|
|
3998
|
+
*/
|
|
3999
|
+
async function recoverRetainedRun(options) {
|
|
4000
|
+
assertStableText(options.environmentId, "retained environment id");
|
|
4001
|
+
assertStableText(options.sessionId, "retained session id");
|
|
4002
|
+
assertStableText(options.executionId, "retained execution id");
|
|
4003
|
+
const capabilities = await assertRetainedCapabilities(options.provider);
|
|
4004
|
+
if (!options.provider.get) throw new Error(`provider "${options.provider.name}" cannot reconstruct an environment by id`);
|
|
4005
|
+
const environment = await options.provider.get(options.environmentId);
|
|
4006
|
+
if (!environment) return { outcome: "not_found" };
|
|
4007
|
+
if (!environment.session) return {
|
|
4008
|
+
outcome: "unverifiable",
|
|
4009
|
+
environment
|
|
4010
|
+
};
|
|
4011
|
+
let session;
|
|
4012
|
+
try {
|
|
4013
|
+
session = environment.session(options.sessionId);
|
|
4014
|
+
} catch {
|
|
4015
|
+
return {
|
|
4016
|
+
outcome: "unverifiable",
|
|
4017
|
+
environment
|
|
4018
|
+
};
|
|
4019
|
+
}
|
|
4020
|
+
const parsed = AgentExactRunControlRefSchema.safeParse(session.controlRef);
|
|
4021
|
+
if (!parsed.success) return {
|
|
4022
|
+
outcome: "unverifiable",
|
|
4023
|
+
environment
|
|
4024
|
+
};
|
|
4025
|
+
const controlRef = parsed.data;
|
|
4026
|
+
if (controlRef.provider !== options.provider.name || controlRef.environmentId !== options.environmentId || controlRef.sessionId !== options.sessionId || controlRef.executionId !== options.executionId) throw new Error("provider session is bound to other retained run coordinates");
|
|
4027
|
+
const exact = exactSession(environment, controlRef);
|
|
4028
|
+
return {
|
|
4029
|
+
outcome: "recovered",
|
|
4030
|
+
handle: createRetainedRunHandle(environment, exact.session, exact.controlRef, capabilities, options.now)
|
|
4031
|
+
};
|
|
4032
|
+
}
|
|
3893
4033
|
/** Rebuild a retained-run client without retaining any object from the starter. @stable */
|
|
3894
4034
|
async function reconnectRetainedRun(options) {
|
|
3895
4035
|
const controlRef = AgentExactRunControlRefSchema.parse(options.controlRef);
|
|
@@ -6211,6 +6351,6 @@ function tail(s) {
|
|
|
6211
6351
|
return s.slice(-400);
|
|
6212
6352
|
}
|
|
6213
6353
|
//#endregion
|
|
6214
|
-
export {
|
|
6354
|
+
export { flatWidenGate as $, assertStrategyContract as A, defaultAuditorInstruction as At, startRetainedRun as B, secretEnvOfMcpServer as Bt, chatTransportExecutor as C, leaderboard as Ct, pickChampion as D, renderLeaderboardSvg as Dt, discriminatingMeans as E, renderLeaderboardMarkdown as Et, openSandboxRun as F, sanitizeMcpToolSchema as Ft, runPersonified as G, equalKOnCost as H, printBenchmarkReport as I, envKeyProvider as It, registerShape as J, builtinShapes as K, runBenchmark as L, mcpSecretEnvMetadataKey as Lt, strategyAuthorContract as M, connectStdioMcp as Mt, strategyAuthorSystemPrompt as N, materializeLocalMcp as Nt, runStrategyEvolution as O, renderPairwiseMarkdown as Ot, SandboxRunAbortError as P, createMcpEnvironment as Pt, fanout as Q, reconnectRetainedRun as R, resolveMcpServerLaunch as Rt, runCoderChecks as S, stopSentinel as St, createChatSessionStore as T, renderLeaderboardHtml as Tt, trajectoryReport as U, promotionGate as V, definePersona as W, InMemoryCorpus as X, FileCorpus as Y, renderCorpusToInstructions as Z, settledWorkerOut as _, loopDispatch as _t, localShell as a, widen as at, analyzeTrace as b, deterministicCompletion as bt, createVerifierEnvironment as c, createScopeAnalyst as ct, worktreeFanout as d, harvestCorpus as dt, loopUntil as et, EVIDENCE_MAX_CHARS as f, defineLeaderboard as ft, composeWorkerEvidence as g, loopCampaignDispatch as gt, closingWorkerNote as h, inlineSandboxClient as ht, jjWorkspace as i, verify as it, authorStrategy as j, McpSpawnFault as jt, selectChampion as k, auditIntent as kt, failuresAnalyst as l, registryScopeAnalyst as lt, VERIFY_TAIL_CHARS as m, localSandboxClient as mt, makeFinding$1 as n, pipeline as nt, runInWorkspace as o, assertTraceDerivedFindings as ot, NOTE_MAX_CHARS as p, resolveSandboxClient as pt, createShapeRegistry as q, gitWorkspace as r, selectValidWinner as rt, createWaterfallCollector as s, buildSteerContext as st, computeFindingId$1 as t, panel as tt, superviseSurface as u, inProcessSandboxClient as ut, copyUntrackedIntoClone as v, superviseDispatch as vt, chatWorkerSeam as w, pairwiseSignificance as wt, patchDelivered as x, sentinelCompletion as xt, withUntrackedArtifacts as y, completionAuthorizes as yt, recoverRetainedRun as z, resolveSecretEnv as zt };
|
|
6215
6355
|
|
|
6216
|
-
//# sourceMappingURL=runtime-
|
|
6356
|
+
//# sourceMappingURL=runtime-CmTSbexZ.js.map
|