@tangle-network/agent-runtime 0.290.1 → 0.292.0
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/dist/{activation-BdvuHbTG.js → activation-Cqj8VNEY.js} +2 -2
- package/dist/{activation-BdvuHbTG.js.map → activation-Cqj8VNEY.js.map} +1 -1
- package/dist/{activation-qNAqp9BD.d.ts → activation-CssIKm0J.d.ts} +3 -3
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/{coordination-driver-CTw92HIk.js → coordination-driver-B_eE1omm.js} +3 -2
- package/dist/coordination-driver-B_eE1omm.js.map +1 -0
- package/dist/{delegate-DhAvvPIP.js → delegate-DiBCqmRo.js} +2 -2
- package/dist/{delegate-DhAvvPIP.js.map → delegate-DiBCqmRo.js.map} +1 -1
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +2 -2
- package/dist/{graph-2Iea0PDT.js → graph-DRcWEeEZ.js} +5 -5
- package/dist/{graph-2Iea0PDT.js.map → graph-DRcWEeEZ.js.map} +1 -1
- package/dist/{improvement-cycle-CdT1IClg.js → improvement-cycle-Dm5zGHc3.js} +4 -4
- package/dist/{improvement-cycle-CdT1IClg.js.map → improvement-cycle-Dm5zGHc3.js.map} +1 -1
- package/dist/{index-CNHHOhRS.d.ts → index-H2CGSpv6.d.ts} +12 -4
- package/dist/index.d.ts +6 -6
- package/dist/index.js +8 -8
- package/dist/intelligence.d.ts +3 -3
- package/dist/intelligence.js +4 -4
- package/dist/kernel.d.ts +4 -4
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-liVnm-Gi.d.ts → loop-runner-bin-CsKO_N_m.d.ts} +3 -3
- package/dist/{loop-runner-bin-BuEFaR7Z.js → loop-runner-bin-DRkG5Zdm.js} +3 -3
- package/dist/{loop-runner-bin-BuEFaR7Z.js.map → loop-runner-bin-DRkG5Zdm.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 +5 -5
- package/dist/mcp/index.js +5 -5
- package/dist/{model-policy-CA5d1YUP.js → model-policy-DydyWTQg.js} +186 -2
- package/dist/model-policy-DydyWTQg.js.map +1 -0
- package/dist/{openai-tools-De6m7S4Y.d.ts → openai-tools-BoNA2t3H.d.ts} +2 -2
- package/dist/profiles.d.ts +2 -2
- package/dist/profiles.js +1 -1
- package/dist/{provision-supervisor-Cm2-dL4F.js → provision-supervisor-mFkdGb6H.js} +4 -4
- package/dist/{provision-supervisor-Cm2-dL4F.js.map → provision-supervisor-mFkdGb6H.js.map} +1 -1
- package/dist/{runtime-DJ_ISfL-.js → runtime-CJLd9cvo.js} +9 -9
- package/dist/{runtime-DJ_ISfL-.js.map → runtime-CJLd9cvo.js.map} +1 -1
- package/dist/{search-method-Q7X92VD3.js → search-method-DgaXNlJj.js} +3 -3
- package/dist/{search-method-Q7X92VD3.js.map → search-method-DgaXNlJj.js.map} +1 -1
- package/dist/{server-CRTAzqiD.js → server-BXSFNE1v.js} +3 -3
- package/dist/{server-CRTAzqiD.js.map → server-BXSFNE1v.js.map} +1 -1
- package/dist/{stream-agent-turn-kseOD-Ma.d.ts → stream-agent-turn-DnJkgxgW.d.ts} +23 -5
- package/dist/{substrate-DFWtsdNI.d.ts → substrate-DaVkSZLU.d.ts} +2 -2
- package/dist/{supervise-CClk-m6Y.js → supervise-CrAbE9KL.js} +27 -7
- package/dist/supervise-CrAbE9KL.js.map +1 -0
- package/dist/{supervisor-CQFcQhlo.js → supervisor-B-LtKizU.js} +168 -179
- package/dist/supervisor-B-LtKizU.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +12 -12
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{types-BFcLI8Ge.d.ts → types-Ci1QbSne.d.ts} +2 -1
- package/package.json +5 -5
- package/dist/coordination-driver-CTw92HIk.js.map +0 -1
- package/dist/model-policy-CA5d1YUP.js.map +0 -1
- package/dist/supervise-CClk-m6Y.js.map +0 -1
- package/dist/supervisor-CQFcQhlo.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as RetainedInteractiveAdmissionError, d as RetainedRunDispatchBindingError, f as RuntimeRunStateError, i as ConfigError, l as RetainedInteractiveBindingError, m as ValidationError$1, r as BackendTransportError, t as AgentEvalError$1, u as RetainedRunAdmissionError } from "./errors-DodWX-cb.js";
|
|
2
|
-
import { a as concreteProfileModel, c as profileModelExecutionSettings, d as
|
|
2
|
+
import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, d as assertRouterAutoDeclaration, f as assertRouterAutoResponse, g as observedModelMatchesDeclared, h as observedModelHasSnapshot, l as profileProviderModel, m as mergeObservedModelIdentity, o as enforceTokenLimits, s as profileBridgeWireModel, t as assertExecutableAgentProfile, u as resolveRouterRetryPolicy } from "./model-policy-DydyWTQg.js";
|
|
3
3
|
import { S as verifyWorkspaceSnapshotArtifacts, i as verifyAgentCandidateWorkspaceArchive } from "./workspace-archive-MhowMCmp.js";
|
|
4
4
|
import { n as assertNoSymlinkDescendant, r as publishExclusiveDurableFile } from "./durable-file-DWQA4ooo.js";
|
|
5
5
|
import { i as notifyRuntimeHookEvent } from "./runtime-hooks-tXpAarhW.js";
|
|
@@ -5309,7 +5309,7 @@ function createOtelExporter(config) {
|
|
|
5309
5309
|
body: JSON.stringify(body),
|
|
5310
5310
|
signal: AbortSignal.timeout(timeoutMs)
|
|
5311
5311
|
});
|
|
5312
|
-
const text = await response.text()
|
|
5312
|
+
const text = await response.text();
|
|
5313
5313
|
if (!response.ok) {
|
|
5314
5314
|
const detail = text ? `: ${text.slice(0, 200)}` : "";
|
|
5315
5315
|
drop(batch.length, `HTTP ${response.status} from ${url}${detail}`);
|
|
@@ -5324,6 +5324,7 @@ function createOtelExporter(config) {
|
|
|
5324
5324
|
}
|
|
5325
5325
|
/** The single sender: it drains the queue batch by batch until the queue is empty. */
|
|
5326
5326
|
function drain() {
|
|
5327
|
+
if (sending === void 0 && queue.length === 0) return Promise.resolve();
|
|
5327
5328
|
sending ??= (async () => {
|
|
5328
5329
|
try {
|
|
5329
5330
|
while (queue.length > 0) {
|
|
@@ -8097,15 +8098,18 @@ function spendFromUsageEvents(events) {
|
|
|
8097
8098
|
for (const ev of events) meterUsageEvent(totals, ev);
|
|
8098
8099
|
return spendFromUsageTotals(totals);
|
|
8099
8100
|
}
|
|
8100
|
-
/** Fresh
|
|
8101
|
-
function newUsageTotals() {
|
|
8101
|
+
/** Fresh accounting totals, optionally restored from verified committed spend. */
|
|
8102
|
+
function newUsageTotals(priorSpent) {
|
|
8103
|
+
if (priorSpent !== void 0) assertValidSpend(priorSpent, "prior committed usage");
|
|
8102
8104
|
return {
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8105
|
+
...addResourceSpend(priorSpent?.resources),
|
|
8106
|
+
tokens: priorSpent === void 0 ? zeroTokenUsage() : cloneTokenUsage(priorSpent.tokens),
|
|
8107
|
+
tokensKnown: priorSpent?.tokensKnown !== false,
|
|
8108
|
+
...priorSpent?.tokensProvenance === void 0 ? {} : { tokensProvenance: priorSpent.tokensProvenance },
|
|
8109
|
+
usd: priorSpent?.usd ?? 0,
|
|
8110
|
+
usdEstimated: priorSpent?.usdEstimated ?? 0,
|
|
8111
|
+
usdKnown: priorSpent?.usdKnown !== false,
|
|
8112
|
+
iterations: priorSpent?.iterations ?? 0
|
|
8109
8113
|
};
|
|
8110
8114
|
}
|
|
8111
8115
|
/**
|
|
@@ -10555,9 +10559,11 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
10555
10559
|
const createProfile = options.profileForCreate?.(profile) ?? profile;
|
|
10556
10560
|
if (placement && canonicalAgentProfileDigest(createProfile) !== canonicalAgentProfileDigest(profile)) throw new ValidationError("provider placement: profileForCreate cannot change the selected profile");
|
|
10557
10561
|
const executionId = retention?.executionId ?? node?.nodeId ?? `provider-run-${randomUUID()}`;
|
|
10558
|
-
|
|
10559
|
-
|
|
10562
|
+
let workspaceExecutionId = executionId;
|
|
10563
|
+
const resetWorkspaceState = (next, invocationId = workspaceExecutionId) => {
|
|
10564
|
+
if (workspaceEnvironmentId === next.id && workspaceExecutionId === invocationId) return;
|
|
10560
10565
|
workspaceEnvironmentId = next.id;
|
|
10566
|
+
workspaceExecutionId = invocationId;
|
|
10561
10567
|
workspaceSnapshot = void 0;
|
|
10562
10568
|
workspaceProvenance = void 0;
|
|
10563
10569
|
workspaceCoverageComplete = false;
|
|
@@ -10607,7 +10613,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
10607
10613
|
workspaceOutcome = outcome;
|
|
10608
10614
|
workspaceCapturePromise = captureProviderWorkspaceSnapshot(workspaceRetention, {
|
|
10609
10615
|
environment: next,
|
|
10610
|
-
executionId,
|
|
10616
|
+
executionId: workspaceExecutionId,
|
|
10611
10617
|
...workspaceControlRef === void 0 ? {} : { controlRef: workspaceControlRef },
|
|
10612
10618
|
...node === void 0 ? {} : { node },
|
|
10613
10619
|
providerSessionId,
|
|
@@ -10740,17 +10746,23 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
10740
10746
|
beginWorkspaceExecution();
|
|
10741
10747
|
const linked = linkAbort(ctx.signal, signal, controller.signal);
|
|
10742
10748
|
try {
|
|
10743
|
-
const executionStartedAt = Date.now();
|
|
10749
|
+
const executionStartedAt = Date.now() - (retention?.priorSpent?.ms ?? 0);
|
|
10744
10750
|
let invocation = {
|
|
10745
10751
|
task,
|
|
10746
10752
|
retention,
|
|
10747
10753
|
executionId,
|
|
10748
10754
|
recovering
|
|
10749
10755
|
};
|
|
10750
|
-
let carried;
|
|
10756
|
+
let carried = retention?.priorSpent;
|
|
10751
10757
|
let refusalsInARow = 0;
|
|
10752
10758
|
for (let attempt = 1;; attempt += 1) {
|
|
10753
|
-
const continued =
|
|
10759
|
+
const continued = attempt > 1;
|
|
10760
|
+
if (continued && environment !== void 0) {
|
|
10761
|
+
resetWorkspaceState(environment, invocation.executionId);
|
|
10762
|
+
workspaceControlRef = void 0;
|
|
10763
|
+
providerSessionId = null;
|
|
10764
|
+
workspacePreservationRequired = options.workspaceRetention !== void 0;
|
|
10765
|
+
}
|
|
10754
10766
|
const ended = yield* streamProviderExecutor({
|
|
10755
10767
|
provider,
|
|
10756
10768
|
profile,
|
|
@@ -10765,7 +10777,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
10765
10777
|
recovering: invocation.recovering,
|
|
10766
10778
|
...carried === void 0 ? {} : { carried },
|
|
10767
10779
|
executionStartedAt,
|
|
10768
|
-
mayContinue: options.unavailablePause !== false &&
|
|
10780
|
+
mayContinue: options.unavailablePause !== false && invocation.retention?.continueInvocation !== void 0,
|
|
10769
10781
|
onRetained: (handle) => {
|
|
10770
10782
|
retained = handle;
|
|
10771
10783
|
workspaceControlRef = freezeControlRef(handle.controlRef);
|
|
@@ -10805,6 +10817,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
10805
10817
|
},
|
|
10806
10818
|
onPublishedSnapshot: (snapshot) => {
|
|
10807
10819
|
workspacePublishedSnapshot = snapshot;
|
|
10820
|
+
if (continued && snapshot !== void 0 && (!options.workspaceRetention?.requireCompleteProvenance || workspaceCoverageComplete)) workspacePreservationRequired = false;
|
|
10808
10821
|
},
|
|
10809
10822
|
captureWorkspace,
|
|
10810
10823
|
workspaceControlRef: () => workspaceControlRef,
|
|
@@ -10817,7 +10830,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
10817
10830
|
});
|
|
10818
10831
|
const refusal = ended.unavailable;
|
|
10819
10832
|
const continueInvocation = invocation.retention?.continueInvocation;
|
|
10820
|
-
if (refusal === void 0 || continueInvocation === void 0) return;
|
|
10833
|
+
if (refusal === void 0 || continueInvocation === void 0 || workspacePreservationRequired || workspaceCaptureFailure !== void 0) return;
|
|
10821
10834
|
refusalsInARow = ended.madeProgress ? 1 : refusalsInARow + 1;
|
|
10822
10835
|
const pauseMs = unavailablePauseMs(refusalsInARow, options.unavailablePause || {});
|
|
10823
10836
|
await invocation.retention?.onPause?.({
|
|
@@ -12187,143 +12200,6 @@ function contentRef(prefix, value) {
|
|
|
12187
12200
|
return `${prefix}:${(hash >>> 0).toString(16).padStart(8, "0")}`;
|
|
12188
12201
|
}
|
|
12189
12202
|
//#endregion
|
|
12190
|
-
//#region src/runtime/model-identity.ts
|
|
12191
|
-
const SNAPSHOT_TOKEN = /^[A-Za-z0-9._-]+$/u;
|
|
12192
|
-
const datedIsoSuffix = /^(.*)-(\d{4})-(\d{2})-(\d{2})$/u;
|
|
12193
|
-
const datedCompactSuffix = /^(.*)-(\d{4})(\d{2})(\d{2})$/u;
|
|
12194
|
-
const datedMonthSuffix = /^(.*)-(\d{4})-(\d{2})$/u;
|
|
12195
|
-
/** Match equivalent bare and provider-qualified spellings without discarding observed identity. */
|
|
12196
|
-
function observedModelMatchesDeclared(observed, declared) {
|
|
12197
|
-
const observedIdentity = modelIdentityParts(observed);
|
|
12198
|
-
const declaredIdentity = modelIdentityParts(declared);
|
|
12199
|
-
if (!observedIdentity || !declaredIdentity) return false;
|
|
12200
|
-
if (declaredIdentity.snapshot !== void 0 && (observedIdentity.snapshot !== declaredIdentity.snapshot || observedIdentity.snapshotKind !== declaredIdentity.snapshotKind)) return false;
|
|
12201
|
-
return equivalentModelBase(observedIdentity.base, declaredIdentity.base);
|
|
12202
|
-
}
|
|
12203
|
-
/** Merge two observations of one served model while retaining a snapshot-bearing raw identity. */
|
|
12204
|
-
function mergeObservedModelIdentity(current, next) {
|
|
12205
|
-
const currentIdentity = modelIdentityParts(current);
|
|
12206
|
-
const nextIdentity = modelIdentityParts(next);
|
|
12207
|
-
if (!currentIdentity || !nextIdentity) return void 0;
|
|
12208
|
-
if (!equivalentModelBase(currentIdentity.base, nextIdentity.base)) return void 0;
|
|
12209
|
-
if (currentIdentity.snapshot !== void 0 && nextIdentity.snapshot !== void 0 && (currentIdentity.snapshot !== nextIdentity.snapshot || currentIdentity.snapshotKind !== nextIdentity.snapshotKind)) return;
|
|
12210
|
-
return currentIdentity.snapshot === void 0 && nextIdentity.snapshot !== void 0 ? next : current;
|
|
12211
|
-
}
|
|
12212
|
-
/** Return the canonical model and its validated snapshot kind for runtime evidence reduction. */
|
|
12213
|
-
function canonicalObservedModelParts(model) {
|
|
12214
|
-
const identity = modelIdentityParts(model);
|
|
12215
|
-
if (!identity) return void 0;
|
|
12216
|
-
const base = identity.base.slice(identity.base.lastIndexOf("/") + 1);
|
|
12217
|
-
const canonical = identity.snapshot === void 0 ? base : identity.snapshotKind === "date" ? `${base}-${identity.snapshot}` : `${base}@${identity.snapshot}`;
|
|
12218
|
-
return {
|
|
12219
|
-
base,
|
|
12220
|
-
...identity.snapshot !== void 0 ? { snapshot: identity.snapshot } : {},
|
|
12221
|
-
...identity.snapshotKind !== void 0 ? { snapshotKind: identity.snapshotKind } : {},
|
|
12222
|
-
canonical
|
|
12223
|
-
};
|
|
12224
|
-
}
|
|
12225
|
-
/** Return whether an observed identity includes a provider snapshot. */
|
|
12226
|
-
function observedModelHasSnapshot(model) {
|
|
12227
|
-
return modelIdentityParts(model)?.snapshot !== void 0;
|
|
12228
|
-
}
|
|
12229
|
-
function modelIdentityParts(model) {
|
|
12230
|
-
if (model.length === 0) return null;
|
|
12231
|
-
const at = model.lastIndexOf("@");
|
|
12232
|
-
if (at < 0) {
|
|
12233
|
-
const dated = datedModelIdentity(model);
|
|
12234
|
-
if (dated !== void 0) return dated;
|
|
12235
|
-
return modelLeaf(model).length === 0 ? null : { base: model };
|
|
12236
|
-
}
|
|
12237
|
-
const base = model.slice(0, at);
|
|
12238
|
-
const snapshot = model.slice(at + 1);
|
|
12239
|
-
if (base.length === 0 || modelLeaf(base).length === 0 || !SNAPSHOT_TOKEN.test(snapshot)) return null;
|
|
12240
|
-
return {
|
|
12241
|
-
base,
|
|
12242
|
-
snapshot,
|
|
12243
|
-
snapshotKind: "opaque"
|
|
12244
|
-
};
|
|
12245
|
-
}
|
|
12246
|
-
function equivalentModelBase(observed, declared) {
|
|
12247
|
-
const observedPath = modelBaseParts(observed);
|
|
12248
|
-
const declaredPath = modelBaseParts(declared);
|
|
12249
|
-
if (!samePath(observedPath.path, declaredPath.path)) return false;
|
|
12250
|
-
if (observedPath.provider === void 0 || declaredPath.provider === void 0 || observedPath.provider === declaredPath.provider) return true;
|
|
12251
|
-
if (observedPath.provider === "tangle-router" || declaredPath.provider === "tangle-router") {
|
|
12252
|
-
const router = observedPath.provider === "tangle-router" ? observedPath : declaredPath;
|
|
12253
|
-
const upstream = observedPath.provider === "tangle-router" ? declaredPath : observedPath;
|
|
12254
|
-
if (upstream.provider === void 0) return false;
|
|
12255
|
-
return samePath(router.path, upstream.path) || router.path[0] === upstream.provider && samePath(router.path.slice(1), upstream.path);
|
|
12256
|
-
}
|
|
12257
|
-
return false;
|
|
12258
|
-
}
|
|
12259
|
-
function modelBaseParts(model) {
|
|
12260
|
-
const segments = model.split("/");
|
|
12261
|
-
const normalized = segments.length > 1 && isHarnessPrefix(segments[0]) ? segments.slice(1) : segments;
|
|
12262
|
-
if (normalized.length === 1) return {
|
|
12263
|
-
provider: void 0,
|
|
12264
|
-
path: normalized
|
|
12265
|
-
};
|
|
12266
|
-
return {
|
|
12267
|
-
provider: normalized[0],
|
|
12268
|
-
path: normalized.slice(1)
|
|
12269
|
-
};
|
|
12270
|
-
}
|
|
12271
|
-
function isHarnessPrefix(segment) {
|
|
12272
|
-
return segment !== void 0 && harnessTypeSchema.safeParse(segment).success;
|
|
12273
|
-
}
|
|
12274
|
-
function samePath(left, right) {
|
|
12275
|
-
return left.length === right.length && left.every((segment, index) => segment === right[index]);
|
|
12276
|
-
}
|
|
12277
|
-
function modelLeaf(model) {
|
|
12278
|
-
return model.slice(model.lastIndexOf("/") + 1);
|
|
12279
|
-
}
|
|
12280
|
-
/**
|
|
12281
|
-
* Parse the provider's documented dated snapshot forms.
|
|
12282
|
-
*
|
|
12283
|
-
* `undefined` means that the model has no dated shape and must be treated as a normal base.
|
|
12284
|
-
* `null` means that it has a dated shape but the date is invalid, so identity matching fails.
|
|
12285
|
-
*/
|
|
12286
|
-
function datedModelIdentity(model) {
|
|
12287
|
-
const iso = datedIsoSuffix.exec(model);
|
|
12288
|
-
if (iso) {
|
|
12289
|
-
const [, base, yearText, monthText, dayText] = iso;
|
|
12290
|
-
return buildDatedIdentity(base, `${yearText}-${monthText}-${dayText}`, isValidCalendarDate(yearText, monthText, dayText));
|
|
12291
|
-
}
|
|
12292
|
-
const compact = datedCompactSuffix.exec(model);
|
|
12293
|
-
if (compact) {
|
|
12294
|
-
const [, base, yearText, monthText, dayText] = compact;
|
|
12295
|
-
return buildDatedIdentity(base, `${yearText}-${monthText}-${dayText}`, isValidCalendarDate(yearText, monthText, dayText));
|
|
12296
|
-
}
|
|
12297
|
-
const month = datedMonthSuffix.exec(model);
|
|
12298
|
-
if (month) {
|
|
12299
|
-
const [, base, yearText, monthText] = month;
|
|
12300
|
-
return buildDatedIdentity(base, `${yearText}-${monthText}`, isValidCalendarMonth(yearText, monthText));
|
|
12301
|
-
}
|
|
12302
|
-
}
|
|
12303
|
-
function buildDatedIdentity(base, snapshot, valid) {
|
|
12304
|
-
if (base === void 0 || base.length === 0 || base.endsWith("/")) return void 0;
|
|
12305
|
-
return valid ? {
|
|
12306
|
-
base,
|
|
12307
|
-
snapshot,
|
|
12308
|
-
snapshotKind: "date"
|
|
12309
|
-
} : null;
|
|
12310
|
-
}
|
|
12311
|
-
function isValidCalendarDate(yearText, monthText, dayText) {
|
|
12312
|
-
if (yearText === void 0 || monthText === void 0 || dayText === void 0) return false;
|
|
12313
|
-
const year = Number(yearText);
|
|
12314
|
-
const month = Number(monthText);
|
|
12315
|
-
const day = Number(dayText);
|
|
12316
|
-
if (year < 2e3 || year > 2099 || month < 1 || month > 12 || day < 1 || day > 31) return false;
|
|
12317
|
-
const date = new Date(Date.UTC(year, month - 1, day));
|
|
12318
|
-
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
12319
|
-
}
|
|
12320
|
-
function isValidCalendarMonth(yearText, monthText) {
|
|
12321
|
-
if (yearText === void 0 || monthText === void 0) return false;
|
|
12322
|
-
const year = Number(yearText);
|
|
12323
|
-
const month = Number(monthText);
|
|
12324
|
-
return year >= 2e3 && year <= 2099 && month >= 1 && month <= 12;
|
|
12325
|
-
}
|
|
12326
|
-
//#endregion
|
|
12327
12203
|
//#region src/runtime/tool-loop.ts
|
|
12328
12204
|
/**
|
|
12329
12205
|
* THE canonical agentic tool-loop. One inference turn → run any requested tools → fold the
|
|
@@ -12588,7 +12464,7 @@ async function routerChatWithTools(cfg, messages, tools, opts) {
|
|
|
12588
12464
|
let transportAttempts = 1;
|
|
12589
12465
|
const headers = routerRequestHeaders(cfg, opts);
|
|
12590
12466
|
const complete = cfg.complete;
|
|
12591
|
-
const
|
|
12467
|
+
const raw = complete ? await (async () => {
|
|
12592
12468
|
const result = await retryRouterOperation(retry, opts?.signal, (signal) => complete(structuredClone(body), {
|
|
12593
12469
|
headers,
|
|
12594
12470
|
signal
|
|
@@ -12600,10 +12476,11 @@ async function routerChatWithTools(cfg, messages, tools, opts) {
|
|
|
12600
12476
|
method: "POST",
|
|
12601
12477
|
headers,
|
|
12602
12478
|
body: JSON.stringify(body)
|
|
12603
|
-
}, opts?.signal, retry);
|
|
12479
|
+
}, opts?.signal, retry, opts?.onResponse);
|
|
12604
12480
|
transportAttempts = result.attempts;
|
|
12605
12481
|
return routerResponseJson(result.response, result.attempts);
|
|
12606
12482
|
})();
|
|
12483
|
+
const data = raw;
|
|
12607
12484
|
const msg = data.choices?.[0]?.message;
|
|
12608
12485
|
if (!msg) throw new ValidationError$1("router completion: no choices[0].message");
|
|
12609
12486
|
const toolCalls = (msg?.tool_calls ?? []).map((tc, i) => ({
|
|
@@ -12613,6 +12490,7 @@ async function routerChatWithTools(cfg, messages, tools, opts) {
|
|
|
12613
12490
|
}));
|
|
12614
12491
|
const { usage, resources, costUsd, costProvenance, billedCostUsd, cache } = meterTurn(data.usage, cfg.model, transportAttempts);
|
|
12615
12492
|
return {
|
|
12493
|
+
response: raw,
|
|
12616
12494
|
content: msg?.content ?? null,
|
|
12617
12495
|
toolCalls,
|
|
12618
12496
|
transportAttempts,
|
|
@@ -12839,12 +12717,64 @@ function routerRequestHeaders(cfg, opts) {
|
|
|
12839
12717
|
function reportedModel(value) {
|
|
12840
12718
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
12841
12719
|
}
|
|
12842
|
-
async function fetchRouterResponse(url, init, callerSignal, retry) {
|
|
12720
|
+
async function fetchRouterResponse(url, init, callerSignal, retry, onResponse) {
|
|
12721
|
+
let attempt = 0;
|
|
12843
12722
|
const result = await retryRouterOperation(retry, callerSignal, async (signal) => {
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12723
|
+
attempt += 1;
|
|
12724
|
+
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
12725
|
+
let candidate;
|
|
12726
|
+
try {
|
|
12727
|
+
candidate = await fetch(url, {
|
|
12728
|
+
...init,
|
|
12729
|
+
signal
|
|
12730
|
+
});
|
|
12731
|
+
} catch (error) {
|
|
12732
|
+
await observeRouterResponse(onResponse, {
|
|
12733
|
+
endpoint: url,
|
|
12734
|
+
callId: new Headers(init.headers).get("idempotency-key") ?? "",
|
|
12735
|
+
attempt,
|
|
12736
|
+
startedAt,
|
|
12737
|
+
endedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12738
|
+
status: null,
|
|
12739
|
+
headers: {},
|
|
12740
|
+
body: null,
|
|
12741
|
+
error: {
|
|
12742
|
+
name: error instanceof Error ? error.name : "Error",
|
|
12743
|
+
message: error instanceof Error ? error.message : String(error)
|
|
12744
|
+
}
|
|
12745
|
+
}, signal);
|
|
12746
|
+
throw error;
|
|
12747
|
+
}
|
|
12748
|
+
if (onResponse) {
|
|
12749
|
+
const headers = Object.fromEntries([...candidate.headers].filter(([name]) => ![
|
|
12750
|
+
"authorization",
|
|
12751
|
+
"proxy-authorization",
|
|
12752
|
+
"set-cookie",
|
|
12753
|
+
"cookie"
|
|
12754
|
+
].includes(name.toLowerCase())));
|
|
12755
|
+
let body = null;
|
|
12756
|
+
let bodyError;
|
|
12757
|
+
try {
|
|
12758
|
+
body = await candidate.clone().text();
|
|
12759
|
+
} catch (error) {
|
|
12760
|
+
bodyError = error;
|
|
12761
|
+
}
|
|
12762
|
+
await observeRouterResponse(onResponse, {
|
|
12763
|
+
endpoint: url,
|
|
12764
|
+
callId: new Headers(init.headers).get("idempotency-key") ?? "",
|
|
12765
|
+
attempt,
|
|
12766
|
+
startedAt,
|
|
12767
|
+
endedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12768
|
+
status: candidate.status,
|
|
12769
|
+
headers,
|
|
12770
|
+
body,
|
|
12771
|
+
...bodyError === void 0 ? {} : { error: {
|
|
12772
|
+
name: bodyError instanceof Error ? bodyError.name : "Error",
|
|
12773
|
+
message: bodyError instanceof Error ? bodyError.message : String(bodyError)
|
|
12774
|
+
} }
|
|
12775
|
+
}, signal);
|
|
12776
|
+
if (bodyError !== void 0) throw bodyError;
|
|
12777
|
+
}
|
|
12848
12778
|
if (candidate.ok) return candidate;
|
|
12849
12779
|
const text = await candidate.text().catch(() => "<failed to read response body>");
|
|
12850
12780
|
throw new SDKError(`router ${candidate.status}: ${text.slice(0, 200)}`, {
|
|
@@ -12859,6 +12789,28 @@ async function fetchRouterResponse(url, init, callerSignal, retry) {
|
|
|
12859
12789
|
attempts: result.attempts
|
|
12860
12790
|
};
|
|
12861
12791
|
}
|
|
12792
|
+
/** Evidence failure cannot authorize a second inference, even after the request deadline. */
|
|
12793
|
+
async function observeRouterResponse(observer, receipt, signal) {
|
|
12794
|
+
if (!observer) return;
|
|
12795
|
+
let onAbort;
|
|
12796
|
+
try {
|
|
12797
|
+
const aborted = new Promise((_resolve, reject) => {
|
|
12798
|
+
onAbort = () => reject(signal.reason ?? /* @__PURE__ */ new Error("Response observation aborted"));
|
|
12799
|
+
if (signal.aborted) onAbort();
|
|
12800
|
+
else signal.addEventListener("abort", onAbort, { once: true });
|
|
12801
|
+
});
|
|
12802
|
+
await Promise.race([Promise.resolve().then(() => observer(receipt)), aborted]);
|
|
12803
|
+
} catch (error) {
|
|
12804
|
+
throw new SDKError("Router response observation failed", {
|
|
12805
|
+
code: "UNKNOWN",
|
|
12806
|
+
retryable: false,
|
|
12807
|
+
cause: error instanceof Error ? error : new Error(String(error)),
|
|
12808
|
+
context: { phase: "response_observation" }
|
|
12809
|
+
});
|
|
12810
|
+
} finally {
|
|
12811
|
+
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
12812
|
+
}
|
|
12813
|
+
}
|
|
12862
12814
|
async function retryRouterOperation(retry, callerSignal, operation) {
|
|
12863
12815
|
let attempts = 0;
|
|
12864
12816
|
try {
|
|
@@ -12869,6 +12821,7 @@ async function retryRouterOperation(retry, callerSignal, operation) {
|
|
|
12869
12821
|
try {
|
|
12870
12822
|
return await operation(attemptSignal.signal);
|
|
12871
12823
|
} catch (error) {
|
|
12824
|
+
if (error instanceof SDKError && error.context?.phase === "response_observation") throw error;
|
|
12872
12825
|
if (callerSignal?.aborted) throw callerSignal.reason ?? error;
|
|
12873
12826
|
if (attemptSignal.signal.aborted) throw new SDKError(`router request timeout after ${retry.requestTimeoutMs}ms`, {
|
|
12874
12827
|
code: "TIMEOUT",
|
|
@@ -18113,6 +18066,7 @@ const ROUTER_TRANSCRIPT_HARNESS = "router";
|
|
|
18113
18066
|
const TURN_CONTENT_BYTES = 256 * 1024;
|
|
18114
18067
|
function createRouterTranscript() {
|
|
18115
18068
|
const kept = [];
|
|
18069
|
+
const records = [];
|
|
18116
18070
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
18117
18071
|
let turnStart = 0;
|
|
18118
18072
|
let replyEchoPending = false;
|
|
@@ -18127,10 +18081,17 @@ function createRouterTranscript() {
|
|
|
18127
18081
|
if (message.role === "assistant") continue;
|
|
18128
18082
|
}
|
|
18129
18083
|
kept.push(message);
|
|
18084
|
+
records.push(message);
|
|
18130
18085
|
}
|
|
18131
18086
|
};
|
|
18132
18087
|
return {
|
|
18133
18088
|
observe,
|
|
18089
|
+
response(receipt) {
|
|
18090
|
+
records.push({
|
|
18091
|
+
type: "provider.response",
|
|
18092
|
+
...receipt
|
|
18093
|
+
});
|
|
18094
|
+
},
|
|
18134
18095
|
reply(reply) {
|
|
18135
18096
|
const message = {
|
|
18136
18097
|
role: "assistant",
|
|
@@ -18145,6 +18106,7 @@ function createRouterTranscript() {
|
|
|
18145
18106
|
})) } : {}
|
|
18146
18107
|
};
|
|
18147
18108
|
kept.push(message);
|
|
18109
|
+
records.push(message);
|
|
18148
18110
|
replyEchoPending = true;
|
|
18149
18111
|
const added = kept.slice(turnStart).map(forTurnEvent);
|
|
18150
18112
|
turnStart = kept.length;
|
|
@@ -18153,7 +18115,7 @@ function createRouterTranscript() {
|
|
|
18153
18115
|
capture() {
|
|
18154
18116
|
if (live !== void 0) observe(live);
|
|
18155
18117
|
if (kept.length === 0) return harnessTranscriptUnavailable("execution-never-started");
|
|
18156
|
-
return harnessTranscriptFromLines(ROUTER_TRANSCRIPT_HARNESS, "conversation",
|
|
18118
|
+
return harnessTranscriptFromLines(ROUTER_TRANSCRIPT_HARNESS, "conversation", records.map((record) => JSON.stringify(record)));
|
|
18157
18119
|
}
|
|
18158
18120
|
};
|
|
18159
18121
|
}
|
|
@@ -18991,6 +18953,7 @@ const routerToolsInlineExecutor = (spec, ctx) => {
|
|
|
18991
18953
|
routerKey: seam.routerKey,
|
|
18992
18954
|
tools: seam.tools
|
|
18993
18955
|
}, { multiTurn: true });
|
|
18956
|
+
if (model === "tangle/auto") assertRouterAutoDeclaration(profileExecution.extraBody?.auto, profileExecution.stream);
|
|
18994
18957
|
const enabledToolNames = new Set(seam.tools.map((tool) => tool.function.name));
|
|
18995
18958
|
const maxTurns = profileExecution.maxTurns ?? 0;
|
|
18996
18959
|
const requestIdentity = routerRequestIdentity(ctx);
|
|
@@ -19019,6 +18982,7 @@ const routerToolsInlineExecutor = (spec, ctx) => {
|
|
|
19019
18982
|
let resources;
|
|
19020
18983
|
let transportAttempts = 0;
|
|
19021
18984
|
let observedModel;
|
|
18985
|
+
const providerResponses = [];
|
|
19022
18986
|
let reasoningTokens = 0;
|
|
19023
18987
|
let reasoningKnown = true;
|
|
19024
18988
|
const promptCache = {};
|
|
@@ -19055,6 +19019,11 @@ const routerToolsInlineExecutor = (spec, ctx) => {
|
|
|
19055
19019
|
}, messages, seam.tools, {
|
|
19056
19020
|
...profileExecution.temperature !== void 0 ? { temperature: profileExecution.temperature } : {},
|
|
19057
19021
|
signal: turnController.signal,
|
|
19022
|
+
onResponse: async (receipt) => {
|
|
19023
|
+
providerResponses.push(receipt);
|
|
19024
|
+
transcript.response(receipt);
|
|
19025
|
+
await seam.onProviderResponse?.(structuredClone(receipt));
|
|
19026
|
+
},
|
|
19058
19027
|
...profileExecution.toolChoice ? { toolChoice: profileExecution.toolChoice } : {},
|
|
19059
19028
|
...profileExecution.tokenLimits.applied,
|
|
19060
19029
|
...profileExecution.seed !== void 0 ? { seed: profileExecution.seed } : {},
|
|
@@ -19092,7 +19061,12 @@ const routerToolsInlineExecutor = (spec, ctx) => {
|
|
|
19092
19061
|
}]))).resources;
|
|
19093
19062
|
transportAttempts += res.transportAttempts;
|
|
19094
19063
|
if (res.model !== void 0) recordRuntimeOwnedProviderModel(executor, res.model);
|
|
19095
|
-
|
|
19064
|
+
if (model === "tangle/auto") {
|
|
19065
|
+
assertRouterAutoResponse(profileExecution.extraBody?.auto, res.response, res.model);
|
|
19066
|
+
tokensKnown = false;
|
|
19067
|
+
reasoningKnown = false;
|
|
19068
|
+
usdKnown = false;
|
|
19069
|
+
} else assertObservedRouterModel(res.model, model, "routerToolsInlineExecutor");
|
|
19096
19070
|
if (res.model !== void 0) observedModel = res.model;
|
|
19097
19071
|
mergePromptCache(promptCache, res.cache);
|
|
19098
19072
|
if (res.usage) {
|
|
@@ -19214,6 +19188,7 @@ const routerToolsInlineExecutor = (spec, ctx) => {
|
|
|
19214
19188
|
turns,
|
|
19215
19189
|
toolCalls: executedToolCalls,
|
|
19216
19190
|
transportAttempts,
|
|
19191
|
+
providerResponses,
|
|
19217
19192
|
...estimatedUsd !== void 0 ? { estimatedCostUsd: estimatedUsd } : {},
|
|
19218
19193
|
...Object.keys(promptCache).length > 0 ? { promptCache } : {},
|
|
19219
19194
|
...reasoningKnown && turns > 0 ? { reasoningTokens } : {}
|
|
@@ -20042,12 +20017,13 @@ const cliInPlaceExecutor = (spec, ctx) => {
|
|
|
20042
20017
|
function snapshotExecutorConfig(config) {
|
|
20043
20018
|
switch (config.backend) {
|
|
20044
20019
|
case "router-tools": {
|
|
20045
|
-
const { complete, executeToolCall, onMessages, onToolStep, ...decisionData } = config;
|
|
20020
|
+
const { complete, executeToolCall, onMessages, onToolStep, onProviderResponse, ...decisionData } = config;
|
|
20046
20021
|
const snapshot = detachedSnapshot(decisionData, "createExecutor router-tools config");
|
|
20047
20022
|
return Object.freeze({
|
|
20048
20023
|
...snapshot,
|
|
20049
20024
|
...complete === void 0 ? {} : { complete },
|
|
20050
20025
|
executeToolCall,
|
|
20026
|
+
...onProviderResponse === void 0 ? {} : { onProviderResponse },
|
|
20051
20027
|
...onMessages === void 0 ? {} : { onMessages },
|
|
20052
20028
|
...onToolStep === void 0 ? {} : { onToolStep }
|
|
20053
20029
|
});
|
|
@@ -21741,15 +21717,20 @@ async function prepareInterruptedExecutors(opts, events, signal, now, parentId =
|
|
|
21741
21717
|
* derived from the input sequence exactly as the live scope derived it.
|
|
21742
21718
|
*/
|
|
21743
21719
|
async function leafContinuation(node, owned, latestInput, opts) {
|
|
21744
|
-
const
|
|
21720
|
+
const before = owned.slice(0, owned.indexOf(latestInput));
|
|
21721
|
+
const priorSession = [...before].reverse().flatMap((event) => event.kind === "execution-admitted" && event.admission.phase === "environment" ? [event.admission] : [])[0];
|
|
21745
21722
|
if (priorSession === void 0) throw new RuntimeRunStateError(`cannot recover '${node.id}': its continuation names no environment it continued in`);
|
|
21723
|
+
const priorResult = [...before].reverse().find((event) => event.kind === "execution-result");
|
|
21724
|
+
if (priorResult === void 0) throw new RuntimeRunStateError(`cannot recover '${node.id}': its continuation has no committed predecessor result`);
|
|
21725
|
+
await assertRecordedResult(node, priorResult, owned, opts);
|
|
21746
21726
|
const task = await opts.blobs.get(latestInput.taskRef);
|
|
21747
21727
|
if (task === void 0 || contentAddress(task) !== latestInput.taskRef) throw new RuntimeRunStateError(`continuation task for '${node.id}' is missing or corrupt`);
|
|
21748
21728
|
return {
|
|
21749
21729
|
task,
|
|
21750
21730
|
inputSeq: latestInput.seq,
|
|
21751
21731
|
executionId: leafContinuationExecutionId(node.id, latestInput.seq),
|
|
21752
|
-
priorSession
|
|
21732
|
+
priorSession,
|
|
21733
|
+
priorSpent: priorResult.spent
|
|
21753
21734
|
};
|
|
21754
21735
|
}
|
|
21755
21736
|
async function assertRecordedResult(node, result, events, opts) {
|
|
@@ -23944,7 +23925,8 @@ function createScope(args) {
|
|
|
23944
23925
|
const retainedContext = (continuing) => ({
|
|
23945
23926
|
...continuing === void 0 ? {} : {
|
|
23946
23927
|
executionId: continuing.executionId,
|
|
23947
|
-
priorSession: continuing.priorSession
|
|
23928
|
+
priorSession: continuing.priorSession,
|
|
23929
|
+
...continuing.priorSpent === void 0 ? {} : { priorSpent: continuing.priorSpent }
|
|
23948
23930
|
},
|
|
23949
23931
|
admissions,
|
|
23950
23932
|
...markRecoveryReady && continuing === void 0 ? { onReady: markRecoveryReady } : {},
|
|
@@ -23980,10 +23962,12 @@ function createScope(args) {
|
|
|
23980
23962
|
});
|
|
23981
23963
|
inputSeq = nextSeq;
|
|
23982
23964
|
admissions = [];
|
|
23965
|
+
const priorSpent = live.acceptedResult.spent;
|
|
23983
23966
|
live.acceptedResult = void 0;
|
|
23984
23967
|
return retainedContext({
|
|
23985
23968
|
executionId: leafContinuationExecutionId(id, nextSeq),
|
|
23986
|
-
priorSession: environment
|
|
23969
|
+
priorSession: environment,
|
|
23970
|
+
priorSpent
|
|
23987
23971
|
});
|
|
23988
23972
|
}
|
|
23989
23973
|
});
|
|
@@ -24001,7 +23985,8 @@ function createScope(args) {
|
|
|
24001
23985
|
...args.seams,
|
|
24002
23986
|
[retainedExecutorSeamKey]: retainedContext(recovery?.continuation === void 0 ? void 0 : {
|
|
24003
23987
|
executionId: recovery.continuation.executionId,
|
|
24004
|
-
priorSession: recovery.continuation.priorSession
|
|
23988
|
+
priorSession: recovery.continuation.priorSession,
|
|
23989
|
+
priorSpent: recovery.continuation.priorSpent
|
|
24005
23990
|
}),
|
|
24006
23991
|
[nestedScopeSeamKey]: makeNestedScopeSeam(args, workerSlots, permit, id, opts.budget, childDeadlineAtMs, deferredOwner),
|
|
24007
23992
|
...workerTrace ? { [workerTraceSeamKey]: workerTrace } : {},
|
|
@@ -24251,7 +24236,7 @@ function createScope(args) {
|
|
|
24251
24236
|
const childRun = runChild(live, executor, controller, recovery?.continuation?.task ?? task, opts, args.pool, reservation.ticket, args.blobs, now, args.journal, args.root, () => progressSeq++, materializationCommitted, {
|
|
24252
24237
|
complete: async () => pendingEvidence?.complete(),
|
|
24253
24238
|
fail: async () => pendingEvidence?.fail()
|
|
24254
|
-
}, childDeadlineAtMs, recovery !== void 0, closeRetainedWrites, budgetGranted, permit.ready);
|
|
24239
|
+
}, childDeadlineAtMs, recovery !== void 0, closeRetainedWrites, budgetGranted, permit.ready, recovery?.continuation?.priorSpent);
|
|
24255
24240
|
args.pool.attribute(reservation.ticket, { stage: "executing" });
|
|
24256
24241
|
const interactiveBindingCommitted = spawnCommitted.then(async () => {
|
|
24257
24242
|
if (args.interactiveBindingDir === void 0) return;
|
|
@@ -25353,7 +25338,8 @@ async function finalizeWait(child, settlement, seq, args, now, handle) {
|
|
|
25353
25338
|
* applied per child). The reservation is reconciled on EVERY path (success, abort, throw)
|
|
25354
25339
|
* so the conserved pool can never leak a reservation.
|
|
25355
25340
|
*/
|
|
25356
|
-
async function runChild(live, executor, childAbort, task, opts, pool, ticket, blobs, now, journal, journalRoot, nextProgressSeq, executionReady, executionEvidence, deadlineAtMs, recovering = false, closeRetainedWrites = async () => {}, budgetReady = void 0, slotReady = Promise.resolve()) {
|
|
25341
|
+
async function runChild(live, executor, childAbort, task, opts, pool, ticket, blobs, now, journal, journalRoot, nextProgressSeq, executionReady, executionEvidence, deadlineAtMs, recovering = false, closeRetainedWrites = async () => {}, budgetReady = void 0, slotReady = Promise.resolve(), priorSpent) {
|
|
25342
|
+
if (priorSpent !== void 0) live.spent = detachedSnapshot(priorSpent, "prior committed usage");
|
|
25357
25343
|
let reconciled = false;
|
|
25358
25344
|
let reconciliationError;
|
|
25359
25345
|
let teardownFailure;
|
|
@@ -25455,7 +25441,7 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
|
|
|
25455
25441
|
seq: nextProgressSeq(),
|
|
25456
25442
|
at: new Date(now()).toISOString()
|
|
25457
25443
|
});
|
|
25458
|
-
}, childAbort.signal);
|
|
25444
|
+
}, childAbort.signal, priorSpent);
|
|
25459
25445
|
live.spent = spend;
|
|
25460
25446
|
const reported = executor.resultArtifact();
|
|
25461
25447
|
artifact = await retainOutput(reported, preserveUnknownTelemetry(spend, reported.spent));
|
|
@@ -25823,8 +25809,8 @@ function freezeCorrelation(value) {
|
|
|
25823
25809
|
* turns deep from one that had produced nothing. It also means a worker that THROWS mid-stream
|
|
25824
25810
|
* now reconciles its real partial spend instead of refunding work the provider already billed.
|
|
25825
25811
|
*/
|
|
25826
|
-
async function foldStream(stream, onProgress, signal) {
|
|
25827
|
-
const totals = newUsageTotals();
|
|
25812
|
+
async function foldStream(stream, onProgress, signal, priorSpent) {
|
|
25813
|
+
const totals = newUsageTotals(priorSpent);
|
|
25828
25814
|
const iterator = stream[Symbol.asyncIterator]();
|
|
25829
25815
|
try {
|
|
25830
25816
|
for (;;) {
|
|
@@ -25838,6 +25824,7 @@ async function foldStream(stream, onProgress, signal) {
|
|
|
25838
25824
|
tokens: cloneTokenUsage(totals.tokens),
|
|
25839
25825
|
...totals.tokensKnown ? {} : { tokensKnown: false },
|
|
25840
25826
|
usd: totals.usd,
|
|
25827
|
+
...totals.usdEstimated > 0 ? { usdEstimated: totals.usdEstimated } : {},
|
|
25841
25828
|
...totals.usdKnown ? {} : { usdKnown: false },
|
|
25842
25829
|
...totals.tokensProvenance === void 0 || totals.tokensProvenance === "stream-receipt" ? {} : { tokensProvenance: totals.tokensProvenance },
|
|
25843
25830
|
ms: 0
|
|
@@ -25998,7 +25985,7 @@ function isInfraError(err) {
|
|
|
25998
25985
|
* journal so the executor can run its `act` inside a nested scope. `act` fails loud if
|
|
25999
25986
|
* called directly — a driver child runs THROUGH its nested-scope executor, never as a root.
|
|
26000
25987
|
*/
|
|
26001
|
-
function driverChild(profile, driver, journal, execution, acceptedSubmission, recoverExecutor) {
|
|
25988
|
+
function driverChild(profile, driver, journal, execution, acceptedSubmission, recoverExecutor, unassessedOutput) {
|
|
26002
25989
|
const name = profile.name ?? driver.name;
|
|
26003
25990
|
const traceSource = driver.traceSource;
|
|
26004
25991
|
const progress = driver.progress;
|
|
@@ -26011,6 +25998,7 @@ function driverChild(profile, driver, journal, execution, acceptedSubmission, re
|
|
|
26011
25998
|
driver,
|
|
26012
25999
|
journal,
|
|
26013
26000
|
...acceptedSubmission ? { acceptedSubmission } : {},
|
|
26001
|
+
...unassessedOutput ? { unassessedOutput } : {},
|
|
26014
26002
|
...recoverExecutor ? { recoverExecutor } : {},
|
|
26015
26003
|
...traceSource ? { traceSource } : {},
|
|
26016
26004
|
...progress ? { progress } : {},
|
|
@@ -26134,7 +26122,8 @@ const driverExecutorFactory = (rawSpec, ctx) => {
|
|
|
26134
26122
|
reported: childWork,
|
|
26135
26123
|
reservation: addSpend(childWork, totalMetered)
|
|
26136
26124
|
};
|
|
26137
|
-
const
|
|
26125
|
+
const acceptedSubmission = spec.acceptedSubmission?.() === true;
|
|
26126
|
+
const verdict = !acceptedSubmission && spec.unassessedOutput?.() === true ? void 0 : deriveDeliveryVerdict(events.filter((event) => event.kind === "settled"), out, acceptedSubmission);
|
|
26138
26127
|
artifact = {
|
|
26139
26128
|
outRef: `${driverRuntime}:${nestedRoot}`,
|
|
26140
26129
|
out: out === void 0 ? null : out,
|
|
@@ -28422,6 +28411,6 @@ function isNonEmptySpend(s) {
|
|
|
28422
28411
|
return s.iterations > 0 || s.tokens.input > 0 || s.tokens.output > 0 || s.usd > 0 || s.ms > 0 || s.tokensKnown === false || s.usdKnown === false || Object.values(s.resources ?? {}).some((resource) => resource.amount > 0 || !resource.known);
|
|
28423
28412
|
}
|
|
28424
28413
|
//#endregion
|
|
28425
|
-
export { waitUntil as $,
|
|
28414
|
+
export { waitUntil as $, projectSandboxOutcome as $i, captureWorkerTraceEvidence as $n, runWorktreeHarness as $r, claimsAuthority as $t, driverExecutorFactory as A, withBudgetResources as Aa, writeAllBytes as Ai, providerAsExecutor as An, mergeTraceEnv as Ar, cliInPlaceExecutor as At, recordScopeOwnerDriverAttempt as B, providerMessageText as Ba, recordRuntimeOwnedDriveHarnessProviderEvidence as Bi, FileResultBlobStore as Bn, createOtelExporter as Br, WORKER_TRACE_PROPAGATION as Bt, createContinuationKeeper as C, throwAbort as Ca, sandboxActProfileMaterialization as Ci, captureBeforeDestroy as Cn, runAbortable as Cr, recoverRetainedInteractiveRun as Ct, passedItems as D, zeroSpend as Da, isNoEntError as Di, runBrainLoop as Dn, readHarnessTranscript as Dr, rollingDispatch as Dt, failedItems as E, withTimeout as Ea, worktreeCliProfileMaterialization as Ei, routerBrain as En, persistHarnessTranscript as Er, queueOf as Et, beginScopeOwnerAttempt as F, armDeadlineTimer as Fa, inheritRuntimeOwnedExecutorAttestation as Fi, createPushTraceSource as Fn, resolveRedactor as Fr, createWorktreeCliExecutor as Ft, settledToIteration as G, runtimeOwnedPendingExecutorMaterialization as Gi, assertContentAddress as Gn, padTraceId as Gr, taskToPrompt as Gt, recordScopeOwnerPause as H, runtimeOwnedExecutorExecutionBinding as Hi, InMemoryResultBlobStore as Hn, generateSpanId as Hr, workerTraceEnv as Ht, createScope as I, teardownExecutor as Ia, knownExecutionBindingReceipt as Ii, decodeToolPart as In, buildLoopOtelSpans as Ir, DEFAULT_SANDBOX_STEERING_MAX_TURNS as It, createWaitProbes as J, unknownMaterializationReceipt as Ji, loadSpawnForest as Jn, createRuntimeStreamEventCollector as Jr, readWorkerProgress as Jt, createWorkerSlots as K, runtimeOwnedScopeOwnerRuntime as Ki, encodeResultBlob as Kn, toOtelAttributes as Kr, DEFAULT_STALL_AFTER_MS as Kt, deriveNodeExecutionIdentity as L, teardownSurfaces as La, knownMaterializationReceipt as Li, sandboxSessionTraceSource as Ln, buildLoopSpanNodes as Lr, createSteerableSandboxSession as Lt, withDriverExecutor as M, abortError$2 as Ma, attestRuntimeOwnedScopeOwner as Mi, resolveAgentEnvironmentProvider as Mn, traceContextToEnv as Mr, createExecutor as Mt, SUBTREE_RESULT_LIMIT as N, awaitAbortable$1 as Na, authoredProfileDigest as Ni, unavailablePauseMs as Nn, defaultRedactor as Nr, createExecutorRegistry as Nt, verdictFromJudgeScore as O, addResourceSpend as Oa, prepareJsonlAppend as Oi, LEAF_CONTINUATION_TASK as On, contentAddress as Or, bindReusableExecutorExecutionId as Ot, assertRecursiveReservationPolicy as P, DEFAULT_SUCCESSFUL_SHUTDOWN_MS as Pa, finalizeRuntimeOwnedPendingExecutor as Pi, unavailableSignalOfFailure as Pn, defaultRedactorIdentityMaterial as Pr, snapshotExecutorConfig as Pt, validateWaitSpec as Q, detachedSnapshot as Qi, WORKER_TOOL_TRACE_SCHEMA_VERSION as Qn, runSettledCommand as Qr, PEER_MAIL_WIRE_KEY as Qt, meterRuntimeOwnedAccounting as R, promptFromAgentTurnInput as Ra, newExecutionAttemptId as Ri, registerRetainedExecutorPreparation as Rn, buildRuntimeEventOtelSpans as Rr, createRouterTranscript as Rt, composeContinuationNote as S, stringifySafe as Sa, renderUnsupported as Si, SandboxEvidenceRetentionError as Sn, linkAbort as Sr, reconnectRetainedInteractiveRun as St, expandQuestions as T, unmeteredSpend as Ta, validateProfileMaterialization as Ti, readPromptOptions as Tn, harnessTranscriptArtifact as Tr, freeSlots as Tt, restoreScopeOwnerAcceptedExecution as U, runtimeOwnedExecutorMaterialization as Ui, InMemorySpawnJournal as Un, loopEventToOtelSpan as Ur, workerTraceHeaders as Ut, recordScopeOwnerMaterialization as V, runtimeOwnedDriveHarnessProviderEvidence as Vi, FileSpawnJournal as Vn, flatOtelSpan as Vr, readWorkerTraceContext as Vt, scopeOwnerExecutorNodeContext as W, runtimeOwnedExecutorProviderEvidence as Wi, SpawnEventIndex as Wn, padSpanId as Wr, workerTraceSeamKey as Wt, pollFor as X, executableAgentSpecSnapshot as Xi, pendingWaits as Xn, sanitizeKnowledgeReadinessReport as Xr, AUTHORITY_MARKERS as Xt, isWaitOutcome as Y, executableAgentProfileSnapshot as Yi, materializeTreeView as Yn, sanitizeAgentRuntimeEvent as Yr, createInbox as Yt, timerAt as Z, detachedFrozen as Zi, replaySpawnTree as Zn, sanitizeRuntimeStreamEvent as Zr, DEFAULT_PEER_MAIL_LIMITS as Zt, CheckUnavailableError as _, hasCompleteCacheBreakdown as _a, promptControlProfileMaterialization as _i, isTerminalDecision as _n, retainedCreateMaterial as _r, workerInteractiveAdmissionFile as _t, collectDelivered as a, extractLlmCallEvent as aa, harnessInvocation as ai, isTerminalNodeStatus as an, ReservationWaitRefused as ar, reconcileScopeRetainedOwnerEnvironment as at, bestComposite as b, randomSuffix as ba, promptResourceProfileMaterialization as bi, probeSandboxCapabilities as bn, RunCancellationReason as br, workerInteractiveBindingFile as bt, runTree as c, mapSandboxToolEvent as ca, parseCodexTokenUsage as ci, addHarnessUsage as cn, meterUsageEvent as cr, scopeRetainedOwnerResourceReader as ct, classifyDriverFailure as d, sandboxProgressEvents as da, AGENT_PROFILE_MATERIALIZATION_AXES as di, readCodexRolloutSession as dn, spendFromUsageTotals as dr, SPAWN_RESOURCE_PATH_MAX_BYTES as dt, readSandboxOutcome as ea, captureWorktreeDiff as ei, createPeerMailbox as en, isTraceAnalysisStore as er, bindScopeRetainedOwnerEnvironmentId as et, runDriverWithRetry as f, sumSandboxUsage as fa, assertProfileMaterialization as fi, bridgeRuntimeAttachmentsKey as fn, errMessage as fr, environmentReader as ft, CONTINUATION_FACTS as g, deleteBoxSafe as ga, profileMaterializationAxes$1 as gi, defaultSelectWinner as gn, startRetainedRunInEnvironment as gr, readWorkerInteractiveAdmissions as gt, CONTINUATIONS_DIR as h, cloneSpend as ha, fullProfileMaterialization as hi, createSandboxForSpec as hn, startRetainedRun as hr, interactiveAdmissionSeamKey as ht, bestDelivered as i, createSandboxUsageLedger as ia, LOCAL_HARNESSES as ii, isLiveNodeStatus as in, BudgetReconcileFault as ir, prepareScopeRetainedOwnerTask as it, isDriverSpec as j, decodeHarnessUsage as ja, attestRuntimeOwnedPendingExecutor as ji, providerAsSandboxClient as jn, readTraceContextFromEnv as jr, cliWorktreeExecutor as jt, driverChild as k, resourceTelemetry as ka, readCommittedJsonLines as ki, createAgentEnvironmentProviderRegistry as kn, createPropagatingTraceEmitter as kr, captureReusableExecutorConfig as kt, DriverAttemptsExhaustedError as l, notifySandboxEventObserver as la, CodexExecutionDiagnosticError as li, createCodexRolloutStoreReader as ln, newUsageTotals as lr, scopeRetainedOwnerRestorePoint as lt, upstreamUnavailableSignal as m, chargedTokens as ma, defineProfileMaterializationContract as mi, TERMINAL_DECISIONS as mn, recoverRetainedRun as mr, resolveSpawnResourcePaths as mt, createRootHandle as n, canonicalStreamEventFromSandboxEvent as na, removeWorktree as ni, peerMailTools as nn, workerTraceAnalysisStore as nr, consumeScopeRetainedOwnerResult as nt, pickBestDelivered as o, isSandboxTerminalEvent as oa, harnessSupportsReasoningEffort as oi, bridgeAdmissionRefusal as on, assertValidBudget as or, scopeRetainedOwnerContext as ot, summarizeDriverAttempts as p, addSpend as pa, controlProfileMaterialization as pi, bridgeStopSignalKey as pn, reconnectRetainedRun as pr, hostDirectoryReader as pt, openSlotGroup as q, unknownExecutionBindingReceipt as qi, insideCursorNamespace as qn, createRuntimeEventCollector as qr, createActivityLog as qt, createSupervisor as r, createSandboxToolPartState as ra, DEFAULT_LOCAL_HARNESS as ri, peerMailVerbNames as rn, executorFailure as rr, noteScopeRetainedOwnerCoordination as rt, runFinalizer as s, mapSandboxEvent as sa, localHarnessExecutable as si, bridgeModelRouteRefusal as sn, createBudgetPool as sr, scopeRetainedOwnerPriorSpend as st, DEFAULT_MAX_DEPTH as t, assertSandboxServedModel as ta, createWorktree as ti, isPeerMailEnvelope as tn, parseWorkerToolTraceArtifact as tr, bindScopeRetainedOwnerProvider as tt, HarnessTurnFailedError as u, sandboxEventServedBackend as ua, terminateProcessTreeAndConfirm as ui, harnessUsageIsEmpty as un, spendFromUsageEvents as ur, scopeRetainedOwnerResult as ut, admitContinuationPolicy as v, isAbortError$2 as va, promptModelProfileMaterialization as vi, runAgentRounds as vn, destroyInteractiveEnvironment as vr, attachWorker as vt, distillFindings as w, throwIfAborted as wa, unsupportedProfileDimensions as wi, assertBoxlessPromptOptions as wn, captureHarnessTranscript as wr, startRetainedInteractiveRun as wt, checkVerdictOf as x, sleep as xa, renderProfileMaterializationIssues as xi, acquireSandbox as xn, abortError as xr, workerInteractiveBindingsDir as xt, admitFinding as y, promptCacheTokenClasses as ya, promptOnlyProfileMaterialization as yi, createSandboxLineage as yn, environmentGone as yr, readWorkerInteractiveBinding as yt, meterRuntimeOwnedProviderAttempt as z, promptOptionsFromAgentTurnInput as za, providerAttemptEvidence as zi, retainedExecutorSeamKey as zn, createOpenInferenceFileExporter as zr, createInPlaceCliExecutor as zt };
|
|
28426
28415
|
|
|
28427
|
-
//# sourceMappingURL=supervisor-
|
|
28416
|
+
//# sourceMappingURL=supervisor-B-LtKizU.js.map
|