@tangle-network/agent-runtime 0.101.1 → 0.102.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.
@@ -1,8 +1,11 @@
1
+ import {
2
+ exactProcessProviderAsCandidateExecutor
3
+ } from "./chunk-SPCD4IQQ.js";
1
4
  import {
2
5
  createAgentImprovementActivationResult,
3
6
  executeAgentImprovementActivation,
4
7
  verifyAgentImprovementActivationResult
5
- } from "./chunk-DI677IPX.js";
8
+ } from "./chunk-LKKIM5QD.js";
6
9
  import {
7
10
  AGENT_IMPROVEMENT_PROFILE_SURFACES,
8
11
  AgentCandidateExperimentCellExecutionError,
@@ -22,19 +25,15 @@ import {
22
25
  verifyAgentImprovementProposal,
23
26
  verifyAgentImprovementReview,
24
27
  verifyCandidateExecutionEvidence
25
- } from "./chunk-RJPQLUDA.js";
28
+ } from "./chunk-4AMAFNUD.js";
26
29
  import {
27
30
  AGENT_CANDIDATE_EXECUTION_SUPPORT,
28
- CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV,
29
- CANDIDATE_KNOWLEDGE_ROOT_ENV,
30
31
  applyExactAgentProfileDiff,
31
- candidateKnowledgeExecutionPaths,
32
- canonicalCandidateBytes,
33
32
  immutableCandidateValue,
34
33
  omitUndefinedObjectFields,
35
34
  parseAgentCandidateProfileActivation,
36
35
  parseExactAgentProfile
37
- } from "./chunk-HGSHPVJ6.js";
36
+ } from "./chunk-TGDHHHH4.js";
38
37
  import {
39
38
  buildLoopOtelSpans,
40
39
  buildRuntimeEventOtelSpans,
@@ -43,6 +42,9 @@ import {
43
42
  } from "./chunk-2VZYRB55.js";
44
43
  import "./chunk-IKGCKPDX.js";
45
44
  import "./chunk-IMSNJSXH.js";
45
+ import {
46
+ resolveAgentEnvironmentProvider
47
+ } from "./chunk-M6MD6JBS.js";
46
48
  import "./chunk-3MDZX7YU.js";
47
49
  import "./chunk-FD2MBMOH.js";
48
50
  import "./chunk-M22PL4GH.js";
@@ -431,6 +433,54 @@ function isJsonSchema(v) {
431
433
  return typeof v === "object" && v !== null && !Array.isArray(v);
432
434
  }
433
435
 
436
+ // src/intelligence/exact-process-candidate.ts
437
+ var exactProcessCandidateExperimentExecutionSupport = Object.freeze({
438
+ outcomes: Object.freeze(["output"]),
439
+ outputMediaTypes: Object.freeze(["text/*", "application/json", "*+json"]),
440
+ code: Object.freeze(["disabled"]),
441
+ memory: Object.freeze(["disabled"]),
442
+ knowledge: true,
443
+ profile: AGENT_CANDIDATE_EXECUTION_SUPPORT.profile,
444
+ isolation: Object.freeze({
445
+ freshEnvironment: true,
446
+ exactProcess: true,
447
+ egress: Object.freeze(["blocked", "strict"])
448
+ })
449
+ });
450
+ function createExactProcessCandidateExperimentExecutor(options) {
451
+ const provider = resolveAgentEnvironmentProvider(options.provider, options.providerRegistry);
452
+ const executor = exactProcessProviderAsCandidateExecutor({
453
+ provider,
454
+ resources: options.resources,
455
+ ...options.providerOptions ? { providerOptions: options.providerOptions } : {},
456
+ ...options.provisionTimeoutMs === void 0 ? {} : { provisionTimeoutMs: options.provisionTimeoutMs },
457
+ ...options.recoveryRetentionMs === void 0 ? {} : { recoveryRetentionMs: options.recoveryRetentionMs }
458
+ });
459
+ return Object.freeze({
460
+ executor,
461
+ async execute(input) {
462
+ return await executeAgentCandidateExperimentCell({
463
+ ...input,
464
+ attempt: input.attempt ?? 1,
465
+ executionId: input.executionId,
466
+ executionRoots: input.executionRoots,
467
+ stagingRoots: input.stagingRoots,
468
+ ports: options.ports,
469
+ ...input.preparation ? { preparation: input.preparation } : {},
470
+ execution: {
471
+ executor,
472
+ grader: options.grader,
473
+ outputArtifacts: options.outputArtifacts,
474
+ traceStore: options.traceStore,
475
+ claimStore: options.claimStore,
476
+ ...options.cleanupTimeoutMs === void 0 ? {} : { cleanupTimeoutMs: options.cleanupTimeoutMs },
477
+ ...options.resultTimeoutMs === void 0 ? {} : { resultTimeoutMs: options.resultTimeoutMs }
478
+ }
479
+ });
480
+ }
481
+ });
482
+ }
483
+
434
484
  // src/intelligence/profile-activation.ts
435
485
  function prepareAgentImprovementProfileActivation(input) {
436
486
  const targetKeys = input.targets.map((target) => `${target.identity}\0${target.surface}`);
@@ -883,467 +933,6 @@ async function composeCertifiedProfileFromWire(base, profile, ctx = {}) {
883
933
  return composeCertifiedProfile(base, manifestFromProfile(profile), ctx);
884
934
  }
885
935
 
886
- // src/intelligence/sandbox-approved-candidate.ts
887
- import { posix } from "path";
888
- var sandboxCandidateExperimentExecutionSupport = Object.freeze({
889
- outcomes: Object.freeze(["output"]),
890
- outputMediaTypes: Object.freeze(["text/*", "application/json", "*+json"]),
891
- code: Object.freeze(["disabled"]),
892
- memory: Object.freeze(["disabled"]),
893
- knowledge: true,
894
- profile: AGENT_CANDIDATE_EXECUTION_SUPPORT.profile,
895
- isolation: Object.freeze({
896
- freshSandbox: true,
897
- exactProcess: true,
898
- egress: Object.freeze(["blocked", "strict"])
899
- })
900
- });
901
- function createSandboxCandidateExperimentExecutor(options) {
902
- const executor = new SandboxAgentCandidateExecutor(
903
- options.client,
904
- options.sandbox,
905
- options.resultTimeoutMs
906
- );
907
- return Object.freeze({
908
- executor,
909
- async execute(input) {
910
- return await executeAgentCandidateExperimentCell({
911
- ...input,
912
- attempt: input.attempt ?? 1,
913
- executionId: input.executionId,
914
- executionRoots: input.executionRoots,
915
- stagingRoots: input.stagingRoots,
916
- ports: options.ports,
917
- ...input.preparation ? { preparation: input.preparation } : {},
918
- execution: {
919
- executor,
920
- grader: options.grader,
921
- outputArtifacts: options.outputArtifacts,
922
- traceStore: options.traceStore,
923
- claimStore: options.claimStore,
924
- ...options.cleanupTimeoutMs === void 0 ? {} : { cleanupTimeoutMs: options.cleanupTimeoutMs },
925
- ...options.resultTimeoutMs === void 0 ? {} : { resultTimeoutMs: options.resultTimeoutMs }
926
- }
927
- });
928
- }
929
- });
930
- }
931
- var SandboxAgentCandidateExecutor = class {
932
- constructor(client, options = {}, captureTimeoutMs = 12e4) {
933
- this.client = client;
934
- this.options = options;
935
- this.captureTimeoutMs = captureTimeoutMs;
936
- }
937
- client;
938
- options;
939
- captureTimeoutMs;
940
- states = /* @__PURE__ */ new Map();
941
- async execute(request, context) {
942
- assertSupportedRequest(request);
943
- const outcome = request.benchmark.task.outcome;
944
- if (outcome.kind !== "output") throw new Error("sandbox executor requires an output task");
945
- const key = executionKey(request.executionId, request.executionPlan.value.digest);
946
- const sandbox = await this.client.create(sandboxCreateOptions(request, this.options), {
947
- signal: context.signal,
948
- timeoutMs: this.options.createTimeoutMs ?? 12e4
949
- });
950
- const state = { sandbox };
951
- this.states.set(key, state);
952
- if ((await sandbox.process.list()).length !== 0) {
953
- throw new Error("fresh candidate sandbox already contains a process");
954
- }
955
- await materializeRequest(sandbox, request);
956
- const launch = exactLaunch(request);
957
- const startedAt = Date.now();
958
- state.trace = {
959
- runId: request.trace.runId,
960
- scenarioId: request.benchmark.task.scenario.id,
961
- startedAt,
962
- deadlineAtMs: context.deadlineAtMs,
963
- timeoutMs: request.hardLimits.timeoutMs,
964
- tags: { ...request.trace.tags, sandboxId: sandbox.id },
965
- written: false
966
- };
967
- const process2 = await sandbox.process.spawnExact(launch.executable, launch.args, {
968
- cwd: request.launch.cwd,
969
- env: { ...request.launch.env },
970
- ...launch.stdin === void 0 ? {} : { stdin: launch.stdin },
971
- timeoutMs: request.hardLimits.timeoutMs
972
- });
973
- const outputPromise = collectOutput(process2, outcome.maxBytes);
974
- let cancellation;
975
- let cancellationTermination;
976
- let processExited = false;
977
- const cancel = () => {
978
- if (processExited) return;
979
- cancellationTermination = Date.now() >= context.deadlineAtMs ? { kind: "timeout", timeoutMs: request.hardLimits.timeoutMs } : { kind: "cancelled" };
980
- cancellation ??= killProcess(process2);
981
- };
982
- context.signal.addEventListener("abort", cancel, { once: true });
983
- if (context.signal.aborted) cancel();
984
- try {
985
- const waitedExitCode = await process2.wait();
986
- processExited = true;
987
- context.signal.removeEventListener("abort", cancel);
988
- if (cancellation) await cancellation;
989
- const status = await process2.status();
990
- if (status.running || status.exitCode !== waitedExitCode) {
991
- throw new Error("sandbox process returned an inconsistent terminal status");
992
- }
993
- state.output = await awaitOutput(outputPromise, context.signal, context.deadlineAtMs);
994
- state.termination = cancellationTermination ?? processTermination(status);
995
- await appendSandboxTrace(state, context.traceStore, status);
996
- return { executionId: request.executionId, termination: state.termination };
997
- } finally {
998
- context.signal.removeEventListener("abort", cancel);
999
- void outputPromise.catch(() => void 0);
1000
- }
1001
- }
1002
- async stop(request, context) {
1003
- context.signal.throwIfAborted();
1004
- const sandbox = await this.resolve(request, true);
1005
- if (!sandbox) return { stopped: true };
1006
- const statuses = await sandbox.process.list();
1007
- if (statuses.length > 1) throw new Error("candidate sandbox contains more than one process");
1008
- const status = statuses[0];
1009
- if (status?.running) {
1010
- const process2 = await sandbox.process.get(status.pid);
1011
- if (!process2) throw new Error("candidate sandbox lost its running process handle");
1012
- await killProcess(process2);
1013
- }
1014
- context.signal.throwIfAborted();
1015
- const remaining = await sandbox.process.list();
1016
- if (remaining.some((entry) => entry.running)) {
1017
- throw new Error("candidate sandbox process termination is not proven");
1018
- }
1019
- const state = this.states.get(executionKey(request.executionId, request.executionPlanDigest));
1020
- if (state) {
1021
- if (context.reason === "timeout") {
1022
- state.termination = { kind: "timeout", timeoutMs: state.trace?.timeoutMs ?? 0 };
1023
- }
1024
- await appendSandboxTrace(state, context.traceStore, remaining[0]);
1025
- }
1026
- return { stopped: true };
1027
- }
1028
- async capture(request, context) {
1029
- context.signal.throwIfAborted();
1030
- const sandbox = await this.resolve(request, false);
1031
- const statuses = await sandbox.process.list();
1032
- if (statuses.length > 1 || statuses.some((entry) => entry.running)) {
1033
- throw new Error("candidate sandbox must contain one stopped process before capture");
1034
- }
1035
- const state = this.states.get(executionKey(request.executionId, request.executionPlanDigest));
1036
- let output = state?.output;
1037
- let termination = state?.termination;
1038
- const status = statuses[0];
1039
- if (status && !output) {
1040
- const process2 = await sandbox.process.get(status.pid);
1041
- if (!process2) throw new Error("candidate sandbox lost its captured process handle");
1042
- const expected = sandboxOutputSpec(sandbox);
1043
- output = await awaitOutput(
1044
- collectOutput(process2, expected.maxBytes),
1045
- context.signal,
1046
- Date.now() + this.captureTimeoutMs
1047
- );
1048
- }
1049
- if (status && !termination) {
1050
- termination = processTermination(status);
1051
- }
1052
- context.signal.throwIfAborted();
1053
- const evidence = canonicalCandidateBytes({
1054
- kind: "sandbox-agent-candidate-capture",
1055
- sandboxId: sandbox.id,
1056
- executionId: request.executionId,
1057
- executionPlanDigest: request.executionPlanDigest,
1058
- ...status ? {
1059
- process: {
1060
- pid: status.pid,
1061
- exitCode: status.exitCode,
1062
- ...status.exitSignal ? { exitSignal: status.exitSignal } : {}
1063
- }
1064
- } : {},
1065
- ...termination ? { termination } : {}
1066
- });
1067
- return {
1068
- ...output ? { taskOutcome: { kind: "output", bytes: output } } : {},
1069
- evidence
1070
- };
1071
- }
1072
- async dispose(request, context) {
1073
- context.signal.throwIfAborted();
1074
- const sandbox = await this.resolve(request, true);
1075
- if (!sandbox) return { disposed: true };
1076
- try {
1077
- await sandbox.delete();
1078
- } catch (error) {
1079
- if (await this.client.get(sandbox.id)) throw error;
1080
- }
1081
- context.signal.throwIfAborted();
1082
- this.states.delete(executionKey(request.executionId, request.executionPlanDigest));
1083
- return { disposed: true };
1084
- }
1085
- async resolve(request, missingIsDeleted) {
1086
- const key = executionKey(request.executionId, request.executionPlanDigest);
1087
- const active = this.states.get(key)?.sandbox;
1088
- if (active) return active;
1089
- const matches = [];
1090
- const scope = this.options.teamId ? `team:${this.options.teamId}` : "personal";
1091
- for (let offset = 0; ; offset += 100) {
1092
- const page = await this.client.list({ scope, limit: 100, offset });
1093
- for (const candidate of page) {
1094
- if (matchesExecution(candidate, request)) matches.push(candidate);
1095
- }
1096
- if (page.length < 100) break;
1097
- }
1098
- if (matches.length === 1) return matches[0];
1099
- if (matches.length > 1) throw new Error("multiple sandboxes match one candidate execution");
1100
- if (missingIsDeleted) return void 0;
1101
- throw new Error("candidate sandbox evidence is unavailable");
1102
- }
1103
- };
1104
- async function appendSandboxTrace(state, traceStore, status) {
1105
- const trace = state.trace;
1106
- if (!trace || trace.written) return;
1107
- const endedAt = Math.max(trace.startedAt, Math.min(Date.now(), trace.deadlineAtMs));
1108
- await traceStore.appendRun({
1109
- runId: trace.runId,
1110
- scenarioId: trace.scenarioId,
1111
- startedAt: trace.startedAt,
1112
- endedAt,
1113
- status: state.termination?.kind !== "timeout" && status?.running === false && status.exitCode === 0 ? "completed" : "failed",
1114
- tags: trace.tags
1115
- });
1116
- trace.written = true;
1117
- }
1118
- function assertSupportedRequest(request) {
1119
- if (request.benchmark.task.outcome.kind !== "output") {
1120
- throw new Error("sandbox candidate executor does not support workspace outcomes; use Pier");
1121
- }
1122
- if (request.executionPlan.value.material.codeKind !== "disabled" || request.inputs.candidate) {
1123
- throw new Error("sandbox candidate executor does not support code workspaces; use Pier");
1124
- }
1125
- if (request.memory.mode !== "disabled") {
1126
- throw new Error("sandbox candidate executor does not support isolated memory");
1127
- }
1128
- const mediaType = request.benchmark.task.outcome.mediaType.toLowerCase();
1129
- if (!(mediaType.startsWith("text/") || mediaType === "application/json" || mediaType.endsWith("+json"))) {
1130
- throw new Error("sandbox candidate executor supports only UTF-8 text and JSON outputs");
1131
- }
1132
- }
1133
- function sandboxCreateOptions(request, options = {}) {
1134
- const material = request.executionPlan.value.material;
1135
- const retentionSeconds = options.evidenceRetentionSeconds ?? 900;
1136
- if (!Number.isSafeInteger(retentionSeconds) || retentionSeconds < 60) {
1137
- throw new Error("sandbox evidence retention must be at least 60 seconds");
1138
- }
1139
- const maxLifetimeSeconds = Math.ceil(request.hardLimits.timeoutMs / 1e3) + retentionSeconds;
1140
- const network = material.model.access.network;
1141
- const egressPolicy = network.mode === "disabled" ? { mode: "blocked" } : {
1142
- mode: "strict",
1143
- allowDomains: [...network.domains],
1144
- includeImplicitDomains: false
1145
- };
1146
- const value = {
1147
- image: exactImage(material.container.image, material.container.manifestDigest),
1148
- bare: true,
1149
- publicEdge: false,
1150
- ephemeral: true,
1151
- sshEnabled: false,
1152
- webTerminalEnabled: false,
1153
- secrets: [],
1154
- capabilities: [],
1155
- egressPolicy,
1156
- maxLifetimeSeconds,
1157
- idempotencyKey: `candidate-${request.executionPlan.value.digest.slice("sha256:".length)}`,
1158
- metadata: {
1159
- kind: "agent-candidate-execution",
1160
- executionId: request.executionId,
1161
- executionPlanDigest: request.executionPlan.value.digest,
1162
- outputMediaType: request.benchmark.task.outcome.kind === "output" ? request.benchmark.task.outcome.mediaType : "",
1163
- outputMaxBytes: request.benchmark.task.outcome.kind === "output" ? request.benchmark.task.outcome.maxBytes : 0
1164
- },
1165
- ...options.teamId ? { teamId: options.teamId } : {},
1166
- ...options.resources ? { resources: options.resources } : {}
1167
- };
1168
- return value;
1169
- }
1170
- async function materializeRequest(sandbox, request) {
1171
- const knowledgePaths = assertKnowledgeExecutionBinding(request);
1172
- for (const file of request.inputs.task.files) {
1173
- await writeExactFile(sandbox, beneath(request.roots.taskRoot, file.path), file.bytes, file.mode);
1174
- }
1175
- const profileRoot = request.executionPlan.value.material.profile.targetWorkspace === "task" ? request.roots.taskRoot : request.roots.candidateRoot;
1176
- if (!profileRoot) throw new Error("candidate profile targets a missing workspace");
1177
- for (const file of request.profileActivation.files) {
1178
- await writeExactFile(
1179
- sandbox,
1180
- beneath(profileRoot, file.path),
1181
- Buffer.from(file.content, "utf8"),
1182
- file.mode
1183
- );
1184
- }
1185
- if (request.knowledge && knowledgePaths) {
1186
- for (const file of request.knowledge.files) {
1187
- await writeExactFile(sandbox, beneath(knowledgePaths.root, file.path), file.bytes, file.mode);
1188
- }
1189
- if (request.knowledge.retrievalConfig && knowledgePaths.retrievalConfig) {
1190
- await writeExactFile(
1191
- sandbox,
1192
- knowledgePaths.retrievalConfig,
1193
- request.knowledge.retrievalConfig,
1194
- 420
1195
- );
1196
- }
1197
- }
1198
- if (request.instruction.delivery.kind === "utf8-file") {
1199
- await writeExactFile(
1200
- sandbox,
1201
- request.instruction.delivery.path,
1202
- request.instruction.bytes,
1203
- 420
1204
- );
1205
- }
1206
- }
1207
- function assertKnowledgeExecutionBinding(request) {
1208
- const knowledge = request.knowledge;
1209
- if (!knowledge) {
1210
- if (request.launch.env[CANDIDATE_KNOWLEDGE_ROOT_ENV] !== void 0 || request.launch.env[CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV] !== void 0) {
1211
- throw new Error("candidate launch declares knowledge paths without verified knowledge");
1212
- }
1213
- return void 0;
1214
- }
1215
- const paths = candidateKnowledgeExecutionPaths(
1216
- request.roots.taskRoot,
1217
- knowledge.retrievalConfig !== void 0
1218
- );
1219
- if (request.launch.env[CANDIDATE_KNOWLEDGE_ROOT_ENV] !== paths.root || request.launch.env[CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV] !== paths.retrievalConfig) {
1220
- throw new Error("candidate knowledge paths do not match the signed launch environment");
1221
- }
1222
- const reserved = [paths.root, paths.retrievalConfig].filter(
1223
- (value) => value !== void 0
1224
- );
1225
- const profileRoot = request.executionPlan.value.material.profile.targetWorkspace === "task" ? request.roots.taskRoot : request.roots.candidateRoot;
1226
- const otherFiles = [
1227
- ...request.inputs.task.files.map((file) => beneath(request.roots.taskRoot, file.path)),
1228
- ...profileRoot ? request.profileActivation.files.map((file) => beneath(profileRoot, file.path)) : [],
1229
- ...request.instruction.delivery.kind === "utf8-file" ? [request.instruction.delivery.path] : []
1230
- ];
1231
- if (otherFiles.some(
1232
- (path) => reserved.some(
1233
- (reservedPath) => path === reservedPath || path.startsWith(`${reservedPath}/`) || reservedPath.startsWith(`${path}/`)
1234
- )
1235
- )) {
1236
- throw new Error("candidate knowledge paths overlap other execution inputs");
1237
- }
1238
- return paths;
1239
- }
1240
- function exactLaunch(request) {
1241
- const instruction = new TextDecoder("utf-8", { fatal: true }).decode(request.instruction.bytes);
1242
- switch (request.instruction.delivery.kind) {
1243
- case "argv-append":
1244
- return { executable: request.launch.executable, args: [...request.launch.args, instruction] };
1245
- case "stdin-utf8":
1246
- return {
1247
- executable: request.launch.executable,
1248
- args: request.launch.args,
1249
- stdin: instruction
1250
- };
1251
- case "utf8-file":
1252
- return { executable: request.launch.executable, args: request.launch.args };
1253
- }
1254
- }
1255
- async function writeExactFile(sandbox, path, bytes, mode) {
1256
- await sandbox.fs.write(path, Buffer.from(bytes).toString("base64"), {
1257
- encoding: "base64",
1258
- mode
1259
- });
1260
- }
1261
- async function collectOutput(process2, maxBytes) {
1262
- const chunks = [];
1263
- let byteLength = 0;
1264
- for await (const chunk of process2.stdout()) {
1265
- const bytes = Buffer.from(chunk, "utf8");
1266
- byteLength += bytes.byteLength;
1267
- if (byteLength > maxBytes) {
1268
- await killProcess(process2);
1269
- throw new Error(`sandbox candidate output exceeds its ${maxBytes}-byte maximum`);
1270
- }
1271
- chunks.push(bytes);
1272
- }
1273
- return Uint8Array.from(Buffer.concat(chunks, byteLength));
1274
- }
1275
- async function awaitOutput(output, signal, deadlineAtMs) {
1276
- signal.throwIfAborted();
1277
- const remainingMs = deadlineAtMs - Date.now();
1278
- if (remainingMs <= 0) throw new Error("sandbox candidate output deadline expired");
1279
- let timer;
1280
- let onAbort;
1281
- try {
1282
- return await Promise.race([
1283
- output,
1284
- new Promise((_resolve, reject) => {
1285
- onAbort = () => reject(signal.reason ?? new Error("sandbox candidate output cancelled"));
1286
- signal.addEventListener("abort", onAbort, { once: true });
1287
- timer = setTimeout(
1288
- () => reject(new Error("sandbox candidate output deadline expired")),
1289
- remainingMs
1290
- );
1291
- })
1292
- ]);
1293
- } finally {
1294
- if (onAbort) signal.removeEventListener("abort", onAbort);
1295
- if (timer) clearTimeout(timer);
1296
- }
1297
- }
1298
- async function killProcess(process2) {
1299
- const before = await process2.status();
1300
- if (!before.running) return;
1301
- try {
1302
- await process2.kill("SIGKILL", { tree: true });
1303
- } catch (error) {
1304
- if ((await process2.status()).running) throw error;
1305
- }
1306
- }
1307
- function processTermination(status) {
1308
- if (status.running) throw new Error("candidate process is still running");
1309
- if (status.exitSignal) {
1310
- if (!/^SIG[A-Z0-9]+$/.test(status.exitSignal)) {
1311
- throw new Error("sandbox returned an invalid process signal");
1312
- }
1313
- return { kind: "signal", signal: status.exitSignal };
1314
- }
1315
- return { kind: "exit", exitCode: status.exitCode };
1316
- }
1317
- function matchesExecution(sandbox, request) {
1318
- return sandbox.metadata?.kind === "agent-candidate-execution" && sandbox.metadata.executionId === request.executionId && sandbox.metadata.executionPlanDigest === request.executionPlanDigest;
1319
- }
1320
- function sandboxOutputSpec(sandbox) {
1321
- const maxBytes = sandbox.metadata?.outputMaxBytes;
1322
- if (!Number.isSafeInteger(maxBytes) || Number(maxBytes) < 1) {
1323
- throw new Error("candidate sandbox output bound is unavailable");
1324
- }
1325
- return { maxBytes: Number(maxBytes) };
1326
- }
1327
- function executionKey(executionId, executionPlanDigest) {
1328
- return `${executionId}\0${executionPlanDigest}`;
1329
- }
1330
- function exactImage(image, manifestDigest) {
1331
- const marker = image.lastIndexOf("@");
1332
- if (marker < 0) return `${image}@${manifestDigest}`;
1333
- if (image.slice(marker + 1) !== manifestDigest) {
1334
- throw new Error("candidate container image conflicts with its resolved manifest");
1335
- }
1336
- return image;
1337
- }
1338
- function beneath(root, relativePath) {
1339
- if (posix.isAbsolute(relativePath)) throw new Error("candidate input path must be relative");
1340
- const path = posix.normalize(relativePath);
1341
- if (path === ".." || path.startsWith("../")) {
1342
- throw new Error("candidate input path escapes its execution root");
1343
- }
1344
- return posix.join(root, path);
1345
- }
1346
-
1347
936
  // src/intelligence/with-intelligence.ts
1348
937
  import { applyAgentProfileDiff } from "@tangle-network/agent-interface";
1349
938
  function summarizeRuntimeEvents(events) {
@@ -1788,10 +1377,11 @@ export {
1788
1377
  createAgentImprovementMeasuredComparison,
1789
1378
  createAgentImprovementProposal,
1790
1379
  createCertifiedPromptSource,
1380
+ createExactProcessCandidateExperimentExecutor,
1791
1381
  createIntelligenceClient,
1792
- createSandboxCandidateExperimentExecutor,
1793
1382
  defaultEffortTier,
1794
1383
  defaultRedactor,
1384
+ exactProcessCandidateExperimentExecutionSupport,
1795
1385
  executeAgentCandidateExperimentCell,
1796
1386
  executeAgentImprovementActivation,
1797
1387
  isAgentImprovementProfileSurface,
@@ -1807,7 +1397,6 @@ export {
1807
1397
  resolveRedactor,
1808
1398
  reviewAgentImprovementProposal,
1809
1399
  runAgentCandidateExperiment,
1810
- sandboxCandidateExperimentExecutionSupport,
1811
1400
  verifyAgentImprovementActivation,
1812
1401
  verifyAgentImprovementActivationResult,
1813
1402
  verifyAgentImprovementProposal,