@tangle-network/agent-runtime 9.0.7 → 9.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/{activation-BA4WLqwN.js → activation-BuKAzxZB.js} +4 -4
- package/dist/{activation-BA4WLqwN.js.map → activation-BuKAzxZB.js.map} +1 -1
- package/dist/{activation-OSYxeVWi.d.ts → activation-CVVpVGyG.d.ts} +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +4 -4
- package/dist/{bundle-CcpL2lfr.js → bundle-9NLb1WO3.js} +2 -2
- package/dist/{bundle-CcpL2lfr.js.map → bundle-9NLb1WO3.js.map} +1 -1
- package/dist/candidate-execution/index.js +5 -4
- package/dist/candidate-execution/index.js.map +1 -1
- package/dist/{continuation-DDPfLw2w.js → continuation-CZaeHEzQ.js} +2 -2
- package/dist/{continuation-DDPfLw2w.js.map → continuation-CZaeHEzQ.js.map} +1 -1
- package/dist/{coordination-manager-CawAzVwE.js → coordination-manager-B-Ugh18D.js} +6 -6
- package/dist/{coordination-manager-CawAzVwE.js.map → coordination-manager-B-Ugh18D.js.map} +1 -1
- package/dist/deadline-CySmJ_0S.js +134 -0
- package/dist/deadline-CySmJ_0S.js.map +1 -0
- package/dist/{delegate-CXtDKuZm.js → delegate-Dizy-1ZC.js} +2 -2
- package/dist/{delegate-CXtDKuZm.js.map → delegate-Dizy-1ZC.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +13 -13
- package/dist/{failure-cause-W0o778qO.js → failure-cause-WifbY42M.js} +2 -2
- package/dist/{failure-cause-W0o778qO.js.map → failure-cause-WifbY42M.js.map} +1 -1
- package/dist/{graph-wQhBJwV_.js → graph-Bf3axJxp.js} +210 -300
- package/dist/graph-Bf3axJxp.js.map +1 -0
- package/dist/{graph-registry-Dbm8QhbA.js → graph-registry-B_1C7qye.js} +1 -1
- package/dist/{graph-registry-D0FE9VpR.js → graph-registry-BbZN5deo.js} +282 -6
- package/dist/graph-registry-BbZN5deo.js.map +1 -0
- package/dist/{improve-CKQwcCz1.js → improve-JThdxpGB.js} +8 -9
- package/dist/{improve-CKQwcCz1.js.map → improve-JThdxpGB.js.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +15 -102
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +7 -7
- package/dist/{jsonl-file-DsxVI0E_.js → jsonl-file-BhuxeejY.js} +114 -2
- package/dist/jsonl-file-BhuxeejY.js.map +1 -0
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +17 -16
- package/dist/{loop-runner-CCdQ1pmE.d.ts → loop-runner-40_tD2d4.d.ts} +2 -2
- package/dist/{loop-runner-3Acu4nGM.js → loop-runner-D8FP4oEN.js} +2 -2
- package/dist/{loop-runner-3Acu4nGM.js.map → loop-runner-D8FP4oEN.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +7 -7
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/output-artifacts-AqkZ8lO2.js +331 -0
- package/dist/output-artifacts-AqkZ8lO2.js.map +1 -0
- package/dist/{prepare-D7WwIddG.js → prepare-Cw4ZaN01.js} +5 -4
- package/dist/{prepare-D7WwIddG.js.map → prepare-Cw4ZaN01.js.map} +1 -1
- package/dist/{profile-BT0X-dm5.js → profile-Cxl_Ajl2.js} +2 -2
- package/dist/{profile-BT0X-dm5.js.map → profile-Cxl_Ajl2.js.map} +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{provision-supervisor-Cm6RLHuw.js → provision-supervisor-BDAXc65B.js} +8 -6
- package/dist/{provision-supervisor-Cm6RLHuw.js.map → provision-supervisor-BDAXc65B.js.map} +1 -1
- package/dist/{run-cancellation-B4-1Rt4u.js → run-cancellation-Cy9ie5cQ.js} +3 -3
- package/dist/{run-cancellation-B4-1Rt4u.js.map → run-cancellation-Cy9ie5cQ.js.map} +1 -1
- package/dist/{run-state-D1LkVTBQ.js → run-state-9FP-wBWK.js} +6 -6
- package/dist/{run-state-D1LkVTBQ.js.map → run-state-9FP-wBWK.js.map} +1 -1
- package/dist/{runtime-Bpad93aK.js → runtime-Czu2SSMy.js} +50 -25
- package/dist/{runtime-Bpad93aK.js.map → runtime-Czu2SSMy.js.map} +1 -1
- package/dist/{search-executor-D8TxXXSY.js → search-executor-Dl_WUQeH.js} +6 -6
- package/dist/{search-executor-D8TxXXSY.js.map → search-executor-Dl_WUQeH.js.map} +1 -1
- package/dist/{server-ctFbmRE5.js → server-Dbge7VDj.js} +5 -5
- package/dist/{server-ctFbmRE5.js.map → server-Dbge7VDj.js.map} +1 -1
- package/dist/{settle-record-BmXd-_3O.js → settle-record-tgpwk6QF.js} +3 -3
- package/dist/{settle-record-BmXd-_3O.js.map → settle-record-tgpwk6QF.js.map} +1 -1
- package/dist/{structural-rollout-DXymZ3go.js → structural-rollout-DUMYWwZ3.js} +7 -6
- package/dist/{structural-rollout-DXymZ3go.js.map → structural-rollout-DUMYWwZ3.js.map} +1 -1
- package/dist/{supervise-BTjv6h7v.js → supervise-BpcWjDMr.js} +12 -10
- package/dist/{supervise-BTjv6h7v.js.map → supervise-BpcWjDMr.js.map} +1 -1
- package/dist/{supervision-discovery-DzYBmrJC.js → supervision-discovery-Hekh50FG.js} +5 -5
- package/dist/{supervision-discovery-DzYBmrJC.js.map → supervision-discovery-Hekh50FG.js.map} +1 -1
- package/dist/{supervisor-Cnn37lon.js → supervisor-CdrDXnOJ.js} +9 -8
- package/dist/{supervisor-Cnn37lon.js.map → supervisor-CdrDXnOJ.js.map} +1 -1
- package/dist/{supervisor-accounting-BMrdsYxz.js → supervisor-accounting-us4w7tG6.js} +65 -154
- package/dist/supervisor-accounting-us4w7tG6.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +13 -13
- package/dist/{tool-server-Df-Uy99W.js → tool-server-CirrqFlr.js} +2 -2
- package/dist/{tool-server-Df-Uy99W.js.map → tool-server-CirrqFlr.js.map} +1 -1
- package/dist/{top-web-Qk6x-A9O.js → top-web-xSGEh02D.js} +7 -7
- package/dist/{top-web-Qk6x-A9O.js.map → top-web-xSGEh02D.js.map} +1 -1
- package/dist/tui/bin.js +3 -3
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/{types-KQkbyDmn.d.ts → types-DRijOelA.d.ts} +189 -164
- package/dist/{util-fcckrkKp.js → util-qsH5cC9S.js} +3 -132
- package/dist/util-qsH5cC9S.js.map +1 -0
- package/dist/{workspace-streams-DA9R3j-p.js → workspace-streams-BakRr-Pl.js} +9 -330
- package/dist/workspace-streams-BakRr-Pl.js.map +1 -0
- package/package.json +1 -1
- package/dist/graph-registry-D0FE9VpR.js.map +0 -1
- package/dist/graph-wQhBJwV_.js.map +0 -1
- package/dist/jsonl-file-DsxVI0E_.js.map +0 -1
- package/dist/supervisor-accounting-BMrdsYxz.js.map +0 -1
- package/dist/util-fcckrkKp.js.map +0 -1
- package/dist/workspace-streams-DA9R3j-p.js.map +0 -1
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { i as ConfigError, m as ValidationError } from "./errors-DG8yufqX.js";
|
|
2
2
|
import { t as composeRuntimeHooks } from "./runtime-hooks-CsW2pfFk.js";
|
|
3
3
|
import { v as harnessRunsAgent } from "./model-policy-CZwhXp8O.js";
|
|
4
|
-
import {
|
|
5
|
-
import { Qr as runtimeFlowBrain, Xr as runtimeCheckFactory
|
|
6
|
-
import { C as journaledGateDecider, D as graphRootProfile, F as kernelPromptRegistry, O as validateGraphTopology, S as flowRootProfile, T as validateFlowGraph, b as GraphRouteError, i as profileGuidanceComposer, r as superviseWithTestBrain, t as supervise, w as routeFlowOf, x as createFlowRun, y as createGraphOverlay } from "./supervise-
|
|
7
|
-
import { f as createFileRunContext, m as withRunContext, p as createInMemoryRunContext } from "./coordination-manager-
|
|
8
|
-
import {
|
|
9
|
-
import { a as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
4
|
+
import { A as portableContinuationPolicySchema, C as boxCheckOutputReader, D as stopCheckBoxForRecovery, E as retainIsolatedCheckOutputs, O as stopCheckProcess, T as prepareIsolatedCheckOutputs, k as validateIsolatedCheckOutputs, w as localCheckOutputReader } from "./graph-registry-BbZN5deo.js";
|
|
5
|
+
import { Qr as runtimeFlowBrain, Xr as runtimeCheckFactory } from "./supervisor-accounting-us4w7tG6.js";
|
|
6
|
+
import { C as journaledGateDecider, D as graphRootProfile, F as kernelPromptRegistry, O as validateGraphTopology, S as flowRootProfile, T as validateFlowGraph, b as GraphRouteError, i as profileGuidanceComposer, r as superviseWithTestBrain, t as supervise, w as routeFlowOf, x as createFlowRun, y as createGraphOverlay } from "./supervise-BpcWjDMr.js";
|
|
7
|
+
import { f as createFileRunContext, m as withRunContext, p as createInMemoryRunContext } from "./coordination-manager-B-Ugh18D.js";
|
|
8
|
+
import { n as detachedSnapshot } from "./snapshot-BKI_w3JD.js";
|
|
9
|
+
import { a as captureMaterializedWorkspace, c as scanMaterializedWorkspaceManifest, n as WorkspaceScanLimitError, p as canonicalCandidateBytes$1 } from "./output-artifacts-AqkZ8lO2.js";
|
|
10
|
+
import { N as contentAddress, v as retainedExecutorContext } from "./failure-cause-WifbY42M.js";
|
|
11
|
+
import { a as readCommittedJsonLines, c as appendCommittedJsonLine, m as runAbortable, s as withJsonlFileLock } from "./jsonl-file-BhuxeejY.js";
|
|
12
|
+
import { Nt as defaultRunCommand, Pt as runSettledCommand } from "./supervisor-CdrDXnOJ.js";
|
|
13
|
+
import { o as armDeadlineTimer } from "./deadline-CySmJ_0S.js";
|
|
14
|
+
import { agentCandidateArtifactRefSchema, agentCandidateWorkspaceManifestMaterialSchema, canonicalCandidateDigest, sha256DigestSchema } from "@tangle-network/agent-interface";
|
|
15
|
+
import { z } from "zod";
|
|
14
16
|
import { randomUUID } from "node:crypto";
|
|
15
17
|
import { constants, mkdirSync, realpathSync } from "node:fs";
|
|
16
18
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
@@ -18,267 +20,6 @@ import { execFile, spawn } from "node:child_process";
|
|
|
18
20
|
import { chmod, cp, lstat, mkdir, mkdtemp, open, opendir, readlink, realpath, rm, stat, symlink, writeFile } from "node:fs/promises";
|
|
19
21
|
import { promisify } from "node:util";
|
|
20
22
|
import { tmpdir } from "node:os";
|
|
21
|
-
// src/runtime/isolated-checker-outputs.ts
|
|
22
|
-
const MAX_FILES = 16;
|
|
23
|
-
const MAX_BYTES = 67108864;
|
|
24
|
-
const MAX_TIMEOUT_MS = 12e4;
|
|
25
|
-
/** Validate authored declarations before starting a check. The returned paths are detached and frozen. */
|
|
26
|
-
function validateIsolatedCheckOutputs(value) {
|
|
27
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new ValidationError("check outputs must be a declaration object");
|
|
28
|
-
const item = value;
|
|
29
|
-
if (Object.keys(item).some((key) => ![
|
|
30
|
-
"paths",
|
|
31
|
-
"maxFileBytes",
|
|
32
|
-
"maxTotalBytes",
|
|
33
|
-
"timeoutMs"
|
|
34
|
-
].includes(key))) throw new ValidationError("check outputs has an unknown field");
|
|
35
|
-
if (!Array.isArray(item.paths) || item.paths.length < 1 || item.paths.length > MAX_FILES) throw new ValidationError("check outputs must name between 1 and 16 files");
|
|
36
|
-
const paths = [];
|
|
37
|
-
for (const path of item.paths) {
|
|
38
|
-
if (typeof path !== "string" || path.length > 512 || !/^[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/u.test(path) || path.split("/").some((part) => part === "." || part === ".." || part === ".git" || part === ".sidecar") || paths.some((prior) => prior === path || prior.startsWith(`${path}/`) || path.startsWith(`${prior}/`))) throw new ValidationError("check outputs paths must be distinct portable relative files");
|
|
39
|
-
paths.push(path);
|
|
40
|
-
}
|
|
41
|
-
for (const key of ["maxFileBytes", "maxTotalBytes"]) if (typeof item[key] !== "number" || !Number.isSafeInteger(item[key]) || item[key] < 1 || item[key] > MAX_BYTES) throw new ValidationError("check output byte limits must be positive integers at most 64 MiB");
|
|
42
|
-
const maxFileBytes = item.maxFileBytes;
|
|
43
|
-
const maxTotalBytes = item.maxTotalBytes;
|
|
44
|
-
if (maxFileBytes > maxTotalBytes) throw new ValidationError("check outputs maxFileBytes must not exceed maxTotalBytes");
|
|
45
|
-
if (item.timeoutMs !== void 0 && (typeof item.timeoutMs !== "number" || !Number.isSafeInteger(item.timeoutMs) || item.timeoutMs < 1 || item.timeoutMs > MAX_TIMEOUT_MS)) throw new ValidationError("check outputs timeoutMs must be a positive integer at most 120000");
|
|
46
|
-
return Object.freeze({
|
|
47
|
-
paths: Object.freeze(paths),
|
|
48
|
-
maxFileBytes,
|
|
49
|
-
maxTotalBytes,
|
|
50
|
-
...item.timeoutMs === void 0 ? {} : { timeoutMs: item.timeoutMs }
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
/** Resolve and validate trusted ports before any isolated work starts. */
|
|
54
|
-
function prepareIsolatedCheckOutputs(options) {
|
|
55
|
-
if (options === void 0) return void 0;
|
|
56
|
-
const { executionId, artifacts, ...declaration } = options;
|
|
57
|
-
const validated = validateIsolatedCheckOutputs(declaration);
|
|
58
|
-
if (typeof executionId !== "string" || executionId.trim() === "" || executionId.length > 200 || /\p{Cc}/u.test(executionId)) throw new ValidationError("check outputs executionId must be a nonempty bounded identifier");
|
|
59
|
-
if (typeof artifacts?.put !== "function" || typeof artifacts?.read !== "function") throw new ValidationError("check outputs requires a readable output artifact port");
|
|
60
|
-
return Object.freeze({
|
|
61
|
-
...validated,
|
|
62
|
-
executionId,
|
|
63
|
-
artifacts
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
var OutputCaptureError = class extends Error {
|
|
67
|
-
reason;
|
|
68
|
-
constructor(reason) {
|
|
69
|
-
super(reason);
|
|
70
|
-
this.reason = reason;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
/** Capture runs after command settlement, even on command failure or cancellation. There are no retries. */
|
|
74
|
-
async function retainIsolatedCheckOutputs(options, inputDigest, read) {
|
|
75
|
-
const controller = new AbortController();
|
|
76
|
-
const clearTimer = armDeadlineTimer(options.timeoutMs ?? 3e4, () => controller.abort(), true);
|
|
77
|
-
const files = [];
|
|
78
|
-
const missing = [];
|
|
79
|
-
let totalBytes = 0;
|
|
80
|
-
try {
|
|
81
|
-
for (const path of options.paths) {
|
|
82
|
-
let phase = "capture-failed";
|
|
83
|
-
try {
|
|
84
|
-
const bytes = await runAbortable(() => read(path, Math.min(options.maxFileBytes, options.maxTotalBytes - totalBytes), controller.signal), controller.signal, "output capture deadline exceeded");
|
|
85
|
-
totalBytes += bytes.byteLength;
|
|
86
|
-
phase = "store-failed";
|
|
87
|
-
const artifact = await runAbortable(() => persistCandidateOutputArtifact(options.artifacts, {
|
|
88
|
-
executionId: options.executionId,
|
|
89
|
-
purpose: "grader-evidence",
|
|
90
|
-
bytes,
|
|
91
|
-
signal: controller.signal
|
|
92
|
-
}), controller.signal, "output persistence deadline exceeded");
|
|
93
|
-
files.push({
|
|
94
|
-
path,
|
|
95
|
-
artifact
|
|
96
|
-
});
|
|
97
|
-
} catch (error) {
|
|
98
|
-
missing.push({
|
|
99
|
-
path,
|
|
100
|
-
reason: controller.signal.aborted ? "timeout" : error instanceof OutputCaptureError ? error.reason : phase
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
} finally {
|
|
105
|
-
clearTimer();
|
|
106
|
-
}
|
|
107
|
-
return Object.freeze({
|
|
108
|
-
executionId: options.executionId,
|
|
109
|
-
inputDigest,
|
|
110
|
-
status: missing.length === 0 ? "retained" : "incomplete",
|
|
111
|
-
files: Object.freeze(files.map((file) => Object.freeze(file))),
|
|
112
|
-
missing: Object.freeze(missing.map((file) => Object.freeze(file)))
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
/** The local namespace has exited; the trusted host must keep its private copy stable. */
|
|
116
|
-
function localCheckOutputReader(root) {
|
|
117
|
-
return async (path, maxBytes, signal) => {
|
|
118
|
-
try {
|
|
119
|
-
const rootInfo = await lstat(root);
|
|
120
|
-
if (!rootInfo.isDirectory() || rootInfo.isSymbolicLink()) throw new OutputCaptureError("unsafe-path");
|
|
121
|
-
let current = root;
|
|
122
|
-
const parts = path.split("/");
|
|
123
|
-
let expected;
|
|
124
|
-
for (let index = 0; index < parts.length; index++) {
|
|
125
|
-
current = join(current, parts[index]);
|
|
126
|
-
const info = await lstat(current, { bigint: true });
|
|
127
|
-
if (info.isSymbolicLink() || (index < parts.length - 1 ? !info.isDirectory() : !info.isFile() || info.nlink !== 1n)) throw new OutputCaptureError("unsafe-path");
|
|
128
|
-
expected = info;
|
|
129
|
-
}
|
|
130
|
-
signal.throwIfAborted();
|
|
131
|
-
const file = await open(current, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
132
|
-
try {
|
|
133
|
-
const before = await file.stat({ bigint: true });
|
|
134
|
-
if (!before.isFile() || before.nlink !== 1n || before.dev !== expected?.dev || before.ino !== expected?.ino) throw new OutputCaptureError("unsafe-path");
|
|
135
|
-
if (before.size > BigInt(maxBytes)) throw new OutputCaptureError("size-limit");
|
|
136
|
-
const chunks = [];
|
|
137
|
-
let total = 0;
|
|
138
|
-
const buffer = Buffer.allocUnsafe(Math.min(65536, maxBytes + 1));
|
|
139
|
-
while (true) {
|
|
140
|
-
signal.throwIfAborted();
|
|
141
|
-
const { bytesRead } = await file.read(buffer, 0, Math.min(buffer.length, maxBytes - total + 1), null);
|
|
142
|
-
if (bytesRead === 0) break;
|
|
143
|
-
total += bytesRead;
|
|
144
|
-
if (total > maxBytes) throw new OutputCaptureError("size-limit");
|
|
145
|
-
chunks.push(Buffer.from(buffer.subarray(0, bytesRead)));
|
|
146
|
-
}
|
|
147
|
-
const after = await file.stat({ bigint: true });
|
|
148
|
-
if (before.size !== BigInt(total) || before.size !== after.size || before.mtimeNs !== after.mtimeNs || before.ctimeNs !== after.ctimeNs || after.nlink !== 1n) throw new OutputCaptureError("capture-failed");
|
|
149
|
-
return Buffer.concat(chunks, total);
|
|
150
|
-
} finally {
|
|
151
|
-
await file.close();
|
|
152
|
-
}
|
|
153
|
-
} catch (error) {
|
|
154
|
-
if (error?.code === "ENOENT") throw new OutputCaptureError("missing");
|
|
155
|
-
if (["ELOOP", "ENOTDIR"].includes(error?.code ?? "")) throw new OutputCaptureError("unsafe-path");
|
|
156
|
-
throw error;
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
/** Preserve a whole box only after its native lifecycle owner confirms stopped state. */
|
|
161
|
-
async function stopCheckBoxForRecovery(box) {
|
|
162
|
-
const controller = new AbortController();
|
|
163
|
-
const clearTimer = armDeadlineTimer(3e4, () => controller.abort(), true);
|
|
164
|
-
try {
|
|
165
|
-
await runAbortable(() => box.stop({
|
|
166
|
-
wait: true,
|
|
167
|
-
signal: controller.signal
|
|
168
|
-
}), controller.signal, "check recovery stop deadline exceeded");
|
|
169
|
-
return true;
|
|
170
|
-
} catch {
|
|
171
|
-
return false;
|
|
172
|
-
} finally {
|
|
173
|
-
clearTimer();
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
/** Whether kill and process exit were confirmed; recovery custody still needs a whole-box stop. */
|
|
177
|
-
async function stopCheckProcess(child) {
|
|
178
|
-
const controller = new AbortController();
|
|
179
|
-
const clearTimer = armDeadlineTimer(5e3, () => controller.abort(), true);
|
|
180
|
-
try {
|
|
181
|
-
await runAbortable(async () => {
|
|
182
|
-
await child.kill("SIGKILL", { tree: true });
|
|
183
|
-
await child.wait();
|
|
184
|
-
}, controller.signal, "check process stop deadline exceeded");
|
|
185
|
-
return true;
|
|
186
|
-
} catch {
|
|
187
|
-
return false;
|
|
188
|
-
} finally {
|
|
189
|
-
clearTimer();
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
const isolatedCheckOutputCaptureProgram = `import base64, errno, hashlib, json, os, stat, sys
|
|
193
|
-
fds=[]
|
|
194
|
-
def fail(reason):
|
|
195
|
-
print(json.dumps({'error':reason})); sys.exit(0)
|
|
196
|
-
try:
|
|
197
|
-
root,path,limit=sys.argv[1],sys.argv[2],int(sys.argv[3])
|
|
198
|
-
directory=os.open(root,os.O_RDONLY|os.O_DIRECTORY|os.O_NOFOLLOW); fds.append(directory)
|
|
199
|
-
parts=path.split('/')
|
|
200
|
-
for part in parts[:-1]:
|
|
201
|
-
directory=os.open(part,os.O_RDONLY|os.O_DIRECTORY|os.O_NOFOLLOW,dir_fd=directory); fds.append(directory)
|
|
202
|
-
before=os.stat(parts[-1],dir_fd=directory,follow_symlinks=False)
|
|
203
|
-
if not stat.S_ISREG(before.st_mode) or before.st_nlink!=1: fail('unsafe-path')
|
|
204
|
-
fd=os.open(parts[-1],os.O_RDONLY|os.O_NOFOLLOW|os.O_NONBLOCK,dir_fd=directory); fds.append(fd)
|
|
205
|
-
opened=os.fstat(fd)
|
|
206
|
-
if not stat.S_ISREG(opened.st_mode) or opened.st_nlink!=1 or (before.st_dev,before.st_ino)!=(opened.st_dev,opened.st_ino): fail('unsafe-path')
|
|
207
|
-
if opened.st_size>limit: fail('size-limit')
|
|
208
|
-
chunks=[]; total=0
|
|
209
|
-
while True:
|
|
210
|
-
chunk=os.read(fd,min(1048576,limit-total+1))
|
|
211
|
-
if not chunk: break
|
|
212
|
-
total+=len(chunk)
|
|
213
|
-
if total>limit: fail('size-limit')
|
|
214
|
-
chunks.append(chunk)
|
|
215
|
-
after=os.fstat(fd)
|
|
216
|
-
if (opened.st_size,opened.st_mtime_ns,opened.st_ctime_ns,opened.st_nlink)!=(after.st_size,after.st_mtime_ns,after.st_ctime_ns,after.st_nlink) or total!=opened.st_size: fail('capture-failed')
|
|
217
|
-
data=b''.join(chunks)
|
|
218
|
-
print(json.dumps({'content':base64.b64encode(data).decode('ascii'),'sha256':'sha256:'+hashlib.sha256(data).hexdigest()}))
|
|
219
|
-
except OSError as error:
|
|
220
|
-
fail('missing' if error.errno==errno.ENOENT else 'unsafe-path' if error.errno in (errno.ELOOP,errno.ENOTDIR) else 'capture-failed')
|
|
221
|
-
finally:
|
|
222
|
-
for fd in reversed(fds): os.close(fd)
|
|
223
|
-
`;
|
|
224
|
-
/** A box with declared outputs needs python3; missing capture tooling fails closed and keeps custody. */
|
|
225
|
-
function boxCheckOutputReader(box, root, timeoutMs) {
|
|
226
|
-
return async (path, maxBytes, signal) => {
|
|
227
|
-
const child = await box.process.spawnExact("/usr/bin/python3", [
|
|
228
|
-
"-I",
|
|
229
|
-
"-S",
|
|
230
|
-
"-c",
|
|
231
|
-
isolatedCheckOutputCaptureProgram,
|
|
232
|
-
root,
|
|
233
|
-
path,
|
|
234
|
-
String(maxBytes)
|
|
235
|
-
], {
|
|
236
|
-
env: {
|
|
237
|
-
PATH: "/usr/bin:/bin",
|
|
238
|
-
LANG: "C"
|
|
239
|
-
},
|
|
240
|
-
inheritEnv: false,
|
|
241
|
-
timeoutMs
|
|
242
|
-
});
|
|
243
|
-
let stopping;
|
|
244
|
-
const stop = () => {
|
|
245
|
-
stopping ??= stopCheckProcess(child);
|
|
246
|
-
};
|
|
247
|
-
signal.addEventListener("abort", stop, { once: true });
|
|
248
|
-
if (signal.aborted) stop();
|
|
249
|
-
const chunks = [];
|
|
250
|
-
const limit = Math.ceil(maxBytes / 3) * 4 + 2048;
|
|
251
|
-
let length = 0;
|
|
252
|
-
let overflow = false;
|
|
253
|
-
const collect = async (stream, keep) => {
|
|
254
|
-
for await (const text of stream) {
|
|
255
|
-
length += Buffer.byteLength(text);
|
|
256
|
-
if (length > limit) {
|
|
257
|
-
overflow = true;
|
|
258
|
-
stop();
|
|
259
|
-
} else if (keep) chunks.push(text);
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
try {
|
|
263
|
-
await Promise.all([collect(child.stdout(), true), collect(child.stderr(), false)]);
|
|
264
|
-
if (overflow || await child.wait() !== 0) throw new OutputCaptureError("capture-failed");
|
|
265
|
-
signal.throwIfAborted();
|
|
266
|
-
const value = JSON.parse(chunks.join(""));
|
|
267
|
-
if (value.error === "missing" || value.error === "unsafe-path" || value.error === "size-limit" || value.error === "capture-failed") throw new OutputCaptureError(value.error);
|
|
268
|
-
if (typeof value.content !== "string" || typeof value.sha256 !== "string") throw new OutputCaptureError("capture-failed");
|
|
269
|
-
const bytes = Buffer.from(value.content, "base64");
|
|
270
|
-
if (bytes.byteLength > maxBytes) throw new OutputCaptureError("size-limit");
|
|
271
|
-
if (sha256Bytes$1(bytes) !== value.sha256) throw new OutputCaptureError("capture-failed");
|
|
272
|
-
return bytes;
|
|
273
|
-
} catch (error) {
|
|
274
|
-
stop();
|
|
275
|
-
throw error;
|
|
276
|
-
} finally {
|
|
277
|
-
signal.removeEventListener("abort", stop);
|
|
278
|
-
await stopping;
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
23
|
// src/runtime/isolated-checker.ts
|
|
283
24
|
const toolchains = [
|
|
284
25
|
"/usr",
|
|
@@ -956,6 +697,93 @@ function graphExecutionOptions(options) {
|
|
|
956
697
|
}
|
|
957
698
|
};
|
|
958
699
|
}
|
|
700
|
+
// src/runtime/isolated-check-result.ts
|
|
701
|
+
const isolatedCheckOutputEvidenceSchema = z.object({
|
|
702
|
+
executionId: z.string().max(200).refine((value) => value.trim() !== "" && !/\p{Cc}/u.test(value)),
|
|
703
|
+
inputDigest: sha256DigestSchema,
|
|
704
|
+
status: z.enum(["retained", "incomplete"]),
|
|
705
|
+
files: z.array(z.object({
|
|
706
|
+
path: z.string(),
|
|
707
|
+
artifact: agentCandidateArtifactRefSchema
|
|
708
|
+
}).strict()).max(16),
|
|
709
|
+
missing: z.array(z.object({
|
|
710
|
+
path: z.string(),
|
|
711
|
+
reason: z.enum([
|
|
712
|
+
"missing",
|
|
713
|
+
"unsafe-path",
|
|
714
|
+
"size-limit",
|
|
715
|
+
"capture-failed",
|
|
716
|
+
"store-failed",
|
|
717
|
+
"timeout"
|
|
718
|
+
])
|
|
719
|
+
}).strict()).max(16),
|
|
720
|
+
source: z.discriminatedUnion("kind", [z.object({
|
|
721
|
+
kind: z.literal("local"),
|
|
722
|
+
path: z.string().min(1)
|
|
723
|
+
}).strict(), z.object({
|
|
724
|
+
kind: z.literal("sandbox"),
|
|
725
|
+
sandboxId: z.string().min(1),
|
|
726
|
+
state: z.literal("stopped")
|
|
727
|
+
}).strict()]).optional()
|
|
728
|
+
}).strict().superRefine((value, context) => {
|
|
729
|
+
try {
|
|
730
|
+
validateIsolatedCheckOutputs({
|
|
731
|
+
paths: [...value.files, ...value.missing].map((file) => file.path),
|
|
732
|
+
maxFileBytes: 67108864,
|
|
733
|
+
maxTotalBytes: 67108864
|
|
734
|
+
});
|
|
735
|
+
} catch {
|
|
736
|
+
context.addIssue({
|
|
737
|
+
code: "custom",
|
|
738
|
+
message: "Check output evidence has invalid paths"
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
if (value.status === "retained" !== (value.missing.length === 0) || value.status === "retained" && value.source !== void 0 || value.files.reduce((bytes, file) => bytes + file.artifact.byteLength, 0) > 67108864) context.addIssue({
|
|
742
|
+
code: "custom",
|
|
743
|
+
message: "Check output evidence is inconsistent"
|
|
744
|
+
});
|
|
745
|
+
});
|
|
746
|
+
/** Decode the existing execution contract without widening or reinterpreting its evidence. */
|
|
747
|
+
const isolatedCheckBoxEvidenceSchema = z.object({
|
|
748
|
+
sandboxId: z.string().min(1),
|
|
749
|
+
account: z.string().min(1),
|
|
750
|
+
memoryMB: z.number().finite().positive().optional(),
|
|
751
|
+
input: agentCandidateWorkspaceManifestMaterialSchema,
|
|
752
|
+
inputDigest: sha256DigestSchema
|
|
753
|
+
}).strict().superRefine((value, context) => {
|
|
754
|
+
if (canonicalCandidateDigest(value.input) !== value.inputDigest) context.addIssue({
|
|
755
|
+
code: "custom",
|
|
756
|
+
message: "Check input digest does not match its manifest"
|
|
757
|
+
});
|
|
758
|
+
});
|
|
759
|
+
/** Execution evidence, not a verdict about task correctness or permission to execute again. */
|
|
760
|
+
const isolatedCheckResultSchema = z.discriminatedUnion("succeeded", [z.object({
|
|
761
|
+
succeeded: z.literal(true),
|
|
762
|
+
value: z.object({
|
|
763
|
+
stdout: z.string(),
|
|
764
|
+
stderr: z.string()
|
|
765
|
+
}).strict(),
|
|
766
|
+
box: isolatedCheckBoxEvidenceSchema.optional(),
|
|
767
|
+
outputs: isolatedCheckOutputEvidenceSchema.optional()
|
|
768
|
+
}).strict(), z.object({
|
|
769
|
+
succeeded: z.literal(false),
|
|
770
|
+
reason: z.enum([
|
|
771
|
+
"refused",
|
|
772
|
+
"failed",
|
|
773
|
+
"timeout",
|
|
774
|
+
"cancelled",
|
|
775
|
+
"output-limit",
|
|
776
|
+
"input-limit",
|
|
777
|
+
"cleanup-failed"
|
|
778
|
+
]),
|
|
779
|
+
diagnostic: z.string(),
|
|
780
|
+
stdout: z.string().optional(),
|
|
781
|
+
stderr: z.string().optional(),
|
|
782
|
+
exitCode: z.number().int().nullable().optional(),
|
|
783
|
+
cleanupDiagnostic: z.string().optional(),
|
|
784
|
+
box: isolatedCheckBoxEvidenceSchema.optional(),
|
|
785
|
+
outputs: isolatedCheckOutputEvidenceSchema.optional()
|
|
786
|
+
}).strict()]);
|
|
959
787
|
// src/runtime/supervise/stored-graph-check.ts
|
|
960
788
|
/** Driver-owned journal identity. Worker output never supplies any part of this authority. */
|
|
961
789
|
function receiptKey(receipt) {
|
|
@@ -981,8 +809,9 @@ function isReceipt(value) {
|
|
|
981
809
|
"outputDigest",
|
|
982
810
|
"output"
|
|
983
811
|
].every((key) => typeof row[key] === "string") || !row.nodeName || !row.nodeId || !row.attemptId || !(row.exitCode === null || Number.isSafeInteger(row.exitCode)) || typeof row.outputTruncated !== "boolean" || typeof row.nativeValid !== "boolean" || typeof row.valid !== "boolean") return false;
|
|
812
|
+
if (row.outputs !== void 0 && !isolatedCheckOutputEvidenceSchema.safeParse(row.outputs).success) return false;
|
|
984
813
|
const receipt = value;
|
|
985
|
-
return receipt.key === receiptKey(receipt) && receipt.valid === (receipt.exitCode === 0 && receipt.nativeValid);
|
|
814
|
+
return receipt.key === receiptKey(receipt) && receipt.valid === (receipt.exitCode === 0 && receipt.nativeValid && receipt.outputs?.status !== "incomplete");
|
|
986
815
|
}
|
|
987
816
|
async function appendReceipt(file, workspace, receipt) {
|
|
988
817
|
await withJsonlFileLock(file, async (canonicalPath) => {
|
|
@@ -1153,12 +982,17 @@ function evidenceOf(task) {
|
|
|
1153
982
|
if (evidence && typeof evidence === "object" && !Array.isArray(evidence)) for (const [id, result] of Object.entries(evidence)) entries.set(id, result);
|
|
1154
983
|
return [...entries];
|
|
1155
984
|
}
|
|
1156
|
-
async function writeEvidence(directory, task) {
|
|
985
|
+
async function writeEvidence(directory, task, trigger) {
|
|
1157
986
|
await mkdir(directory, { recursive: true });
|
|
1158
987
|
for (const [id, result] of evidenceOf(task)) {
|
|
1159
988
|
if (!safeNodeFile.test(id)) throw new ValidationError(`runGraph: evidence node id ${id}`);
|
|
1160
989
|
await writeFile(join(directory, `${id}.json`), `${JSON.stringify(result)}\n`);
|
|
1161
990
|
}
|
|
991
|
+
await mkdir(join(directory, "_input"), { recursive: true });
|
|
992
|
+
await writeFile(join(directory, "_input", "task.json"), canonicalCandidateBytes$1({
|
|
993
|
+
task,
|
|
994
|
+
...trigger === void 0 ? {} : { trigger }
|
|
995
|
+
}));
|
|
1162
996
|
}
|
|
1163
997
|
async function readSecrets(names, environment, node) {
|
|
1164
998
|
const secrets = {};
|
|
@@ -1170,7 +1004,11 @@ async function readSecrets(names, environment, node) {
|
|
|
1170
1004
|
return secrets;
|
|
1171
1005
|
}
|
|
1172
1006
|
/** Run one check node's command locally, in the run's working directory. */
|
|
1173
|
-
async function runLocalCheck(check, cwd, evidence, signal, secrets) {
|
|
1007
|
+
async function runLocalCheck(check, cwd, evidence, signal, secrets, retention) {
|
|
1008
|
+
const prior = new Map(await Promise.all((retention?.paths ?? []).map(async (path) => [path, await lstat(join(cwd, path), { bigint: true }).catch((error) => {
|
|
1009
|
+
if (error.code !== "ENOENT") throw error;
|
|
1010
|
+
})])));
|
|
1011
|
+
const inputDigest = retention ? canonicalCandidateDigest(await scanMaterializedWorkspaceManifest(evidence)) : void 0;
|
|
1174
1012
|
const timeoutMs = check.timeoutMs ?? CHECK_TIMEOUT_MS;
|
|
1175
1013
|
const result = await runSettledCommand({
|
|
1176
1014
|
command: "/bin/sh",
|
|
@@ -1180,18 +1018,42 @@ async function runLocalCheck(check, cwd, evidence, signal, secrets) {
|
|
|
1180
1018
|
signal,
|
|
1181
1019
|
env: {
|
|
1182
1020
|
...secrets,
|
|
1183
|
-
GRAPH_EVIDENCE: evidence
|
|
1021
|
+
GRAPH_EVIDENCE: evidence,
|
|
1022
|
+
GRAPH_INPUT: join(evidence, "_input", "task.json")
|
|
1184
1023
|
}
|
|
1185
1024
|
});
|
|
1186
1025
|
const timedOut = result.timedOut ? `\n[check timed out after ${timeoutMs} ms]` : "";
|
|
1026
|
+
const readOutput = localCheckOutputReader(cwd);
|
|
1027
|
+
const captured = retention ? await retainIsolatedCheckOutputs(retention, inputDigest, async (path, maxBytes, signal) => {
|
|
1028
|
+
const before = prior.get(path);
|
|
1029
|
+
if (before) {
|
|
1030
|
+
const after = await lstat(join(cwd, path), { bigint: true });
|
|
1031
|
+
if ([
|
|
1032
|
+
"dev",
|
|
1033
|
+
"ino",
|
|
1034
|
+
"size",
|
|
1035
|
+
"mtimeNs",
|
|
1036
|
+
"ctimeNs"
|
|
1037
|
+
].every((key) => before[key] === after[key])) throw new Error("Declared local check output was not changed by this command");
|
|
1038
|
+
}
|
|
1039
|
+
return readOutput(path, maxBytes, signal);
|
|
1040
|
+
}) : void 0;
|
|
1041
|
+
const outputs = captured?.status === "incomplete" ? {
|
|
1042
|
+
...captured,
|
|
1043
|
+
source: {
|
|
1044
|
+
kind: "local",
|
|
1045
|
+
path: cwd
|
|
1046
|
+
}
|
|
1047
|
+
} : captured;
|
|
1187
1048
|
return {
|
|
1188
1049
|
exitCode: result.timedOut ? null : result.exitCode,
|
|
1189
1050
|
stdout: result.stdout,
|
|
1190
|
-
output: result.stdout + result.stderr + timedOut
|
|
1051
|
+
output: result.stdout + result.stderr + timedOut,
|
|
1052
|
+
...outputs && { outputs }
|
|
1191
1053
|
};
|
|
1192
1054
|
}
|
|
1193
1055
|
/** Run one check node's command in a fresh box on the check account, as a declared check does. */
|
|
1194
|
-
async function runBoxCheck(check, node, placement, evidence, signal, secrets) {
|
|
1056
|
+
async function runBoxCheck(check, node, placement, evidence, signal, secrets, outputs) {
|
|
1195
1057
|
const workspaceRoot = await mkdtemp(join(evidence, "..", "box-"));
|
|
1196
1058
|
try {
|
|
1197
1059
|
const tree = join(workspaceRoot, "tree");
|
|
@@ -1203,12 +1065,13 @@ async function runBoxCheck(check, node, placement, evidence, signal, secrets) {
|
|
|
1203
1065
|
command: [
|
|
1204
1066
|
"/bin/sh",
|
|
1205
1067
|
"-c",
|
|
1206
|
-
`GRAPH_EVIDENCE="$PWD/_evidence"; export GRAPH_EVIDENCE; ${check.command}`
|
|
1068
|
+
`GRAPH_EVIDENCE="$PWD/_evidence"; GRAPH_INPUT="$GRAPH_EVIDENCE/_input/task.json"; export GRAPH_EVIDENCE GRAPH_INPUT; ${check.command}`
|
|
1207
1069
|
],
|
|
1208
1070
|
timeoutMs: check.timeoutMs ?? CHECK_TIMEOUT_MS,
|
|
1209
1071
|
maxOutputBytes: 16 * CHECK_OUTPUT_LIMIT,
|
|
1210
1072
|
env: secrets,
|
|
1211
1073
|
signal,
|
|
1074
|
+
...outputs && { outputs },
|
|
1212
1075
|
box: {
|
|
1213
1076
|
client: placement.client,
|
|
1214
1077
|
builderAccounts: placement.builderAccounts ?? ["run-owner"],
|
|
@@ -1222,19 +1085,17 @@ async function runBoxCheck(check, node, placement, evidence, signal, secrets) {
|
|
|
1222
1085
|
if (result.succeeded) return {
|
|
1223
1086
|
exitCode: 0,
|
|
1224
1087
|
stdout: result.value.stdout,
|
|
1225
|
-
output: result.value.stdout + result.value.stderr
|
|
1088
|
+
output: result.value.stdout + result.value.stderr,
|
|
1089
|
+
...result.outputs && { outputs: result.outputs }
|
|
1226
1090
|
};
|
|
1227
1091
|
const stdout = result.stdout ?? "";
|
|
1228
1092
|
const output = stdout + (result.stderr ?? "");
|
|
1229
|
-
if (result.reason === "failed"
|
|
1230
|
-
exitCode: result.exitCode,
|
|
1231
|
-
stdout,
|
|
1232
|
-
output
|
|
1233
|
-
};
|
|
1234
|
-
if (result.reason === "timeout") return {
|
|
1235
|
-
exitCode: null,
|
|
1093
|
+
if (result.outputs || result.reason === "failed" || result.reason === "timeout") return {
|
|
1094
|
+
exitCode: result.exitCode ?? null,
|
|
1236
1095
|
stdout,
|
|
1237
|
-
output: `${output}\n[check
|
|
1096
|
+
output: `${output}\n[check ${result.reason}: ${result.diagnostic}]`,
|
|
1097
|
+
nativeValid: result.reason === "failed" || result.reason === "timeout",
|
|
1098
|
+
...result.outputs && { outputs: result.outputs }
|
|
1238
1099
|
};
|
|
1239
1100
|
throw new Error(redact(`runGraph: check node ${node} box ${result.reason}: ${result.diagnostic}`, secrets));
|
|
1240
1101
|
} finally {
|
|
@@ -1246,14 +1107,39 @@ async function runBoxCheck(check, node, placement, evidence, signal, secrets) {
|
|
|
1246
1107
|
}
|
|
1247
1108
|
/** Every resolved secret value becomes `[redacted:NAME]` before output leaves the check. */
|
|
1248
1109
|
function redact(text, secrets) {
|
|
1249
|
-
return
|
|
1110
|
+
return redactBytes(Buffer.from(text), secrets).toString("utf8");
|
|
1111
|
+
}
|
|
1112
|
+
function redactBytes(bytes, secrets, maxBytes = Number.MAX_SAFE_INTEGER) {
|
|
1113
|
+
let out = Buffer.from(bytes);
|
|
1114
|
+
for (const [name, value] of Object.entries(secrets).sort(([, a], [, b]) => b.length - a.length)) {
|
|
1115
|
+
const needle = Buffer.from(value);
|
|
1116
|
+
const replacement = Buffer.from(`[redacted:${name}]`);
|
|
1117
|
+
let length = out.length;
|
|
1118
|
+
for (let at = out.indexOf(needle); at !== -1; at = out.indexOf(needle, at + needle.length)) {
|
|
1119
|
+
length += replacement.length - needle.length;
|
|
1120
|
+
if (length > maxBytes) throw new Error("Redacted check output exceeds its byte limit");
|
|
1121
|
+
}
|
|
1122
|
+
if (length === out.length && !out.includes(needle)) continue;
|
|
1123
|
+
const redacted = Buffer.allocUnsafe(length);
|
|
1124
|
+
let start = 0;
|
|
1125
|
+
let offset = 0;
|
|
1126
|
+
for (let at = out.indexOf(needle); at !== -1; at = out.indexOf(needle, start)) {
|
|
1127
|
+
offset += out.copy(redacted, offset, start, at);
|
|
1128
|
+
offset += replacement.copy(redacted, offset);
|
|
1129
|
+
start = at + needle.length;
|
|
1130
|
+
}
|
|
1131
|
+
out.copy(redacted, offset, start);
|
|
1132
|
+
out = redacted;
|
|
1133
|
+
}
|
|
1134
|
+
return out;
|
|
1250
1135
|
}
|
|
1251
1136
|
function checkOutput(receipt) {
|
|
1252
1137
|
return {
|
|
1253
1138
|
pass: receipt.valid,
|
|
1254
1139
|
exitCode: receipt.exitCode,
|
|
1255
1140
|
output: receipt.output,
|
|
1256
|
-
...receipt.json === void 0 ? {} : { json: receipt.json }
|
|
1141
|
+
...receipt.json === void 0 ? {} : { json: receipt.json },
|
|
1142
|
+
...receipt.outputs === void 0 ? {} : { outputs: (({ source: _source, ...outputs }) => outputs)(receipt.outputs) }
|
|
1257
1143
|
};
|
|
1258
1144
|
}
|
|
1259
1145
|
/** The receipt a run context's journal holds for this binding, as executor evidence. */
|
|
@@ -1287,6 +1173,14 @@ function bindGraphCheckNodes(graph, options) {
|
|
|
1287
1173
|
const timeoutMs = check.timeoutMs ?? CHECK_TIMEOUT_MS;
|
|
1288
1174
|
if (!check.command.trim() || !Number.isSafeInteger(timeoutMs) || timeoutMs <= 0) throw new ValidationError(`runGraph: check node ${id} needs a command and positive timeoutMs`);
|
|
1289
1175
|
if (placement && !check.environment?.trim()) throw new ValidationError(`runGraph: check node ${id} needs environment for box placement`);
|
|
1176
|
+
if (check.outputs !== void 0) {
|
|
1177
|
+
if (!options.checkArtifacts) throw new ValidationError(`runGraph: check node ${id} outputs require checkArtifacts`);
|
|
1178
|
+
prepareIsolatedCheckOutputs({
|
|
1179
|
+
...check.outputs,
|
|
1180
|
+
executionId: "graph-check-preflight",
|
|
1181
|
+
artifacts: options.checkArtifacts
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1290
1184
|
}
|
|
1291
1185
|
const local = placement === void 0 ? localCheckDirectories(options) : void 0;
|
|
1292
1186
|
const workspace = local?.cwd ?? backendWorkspace(options);
|
|
@@ -1307,7 +1201,8 @@ function bindGraphCheckNodes(graph, options) {
|
|
|
1307
1201
|
runId,
|
|
1308
1202
|
node: id,
|
|
1309
1203
|
checkDigest,
|
|
1310
|
-
at: spawn?.assignmentId
|
|
1204
|
+
at: spawn?.assignmentId,
|
|
1205
|
+
...options.trigger === void 0 ? {} : { trigger: options.trigger }
|
|
1311
1206
|
});
|
|
1312
1207
|
const executorFactory = (_spec, context_) => {
|
|
1313
1208
|
let artifact;
|
|
@@ -1353,10 +1248,16 @@ function bindGraphCheckNodes(graph, options) {
|
|
|
1353
1248
|
secrets: check.secrets ?? [],
|
|
1354
1249
|
signal
|
|
1355
1250
|
}) : box.env ?? {}, id);
|
|
1251
|
+
const retention = check.outputs && {
|
|
1252
|
+
...check.outputs,
|
|
1253
|
+
executionId: binding,
|
|
1254
|
+
artifacts: options.checkArtifacts,
|
|
1255
|
+
redact: (bytes) => redactBytes(bytes, secrets, check.outputs.maxFileBytes)
|
|
1256
|
+
};
|
|
1356
1257
|
let ran;
|
|
1357
1258
|
try {
|
|
1358
|
-
await writeEvidence(evidence, task);
|
|
1359
|
-
ran = local ? await runLocalCheck(check, local.cwd, evidence, signal, secrets) : await runBoxCheck(check, id, placement, evidence, signal, secrets);
|
|
1259
|
+
await writeEvidence(evidence, task, options.trigger);
|
|
1260
|
+
ran = local ? await runLocalCheck(check, local.cwd, evidence, signal, secrets, retention) : await runBoxCheck(check, id, placement, evidence, signal, secrets, retention);
|
|
1360
1261
|
} finally {
|
|
1361
1262
|
if (staged) await rm(staged, {
|
|
1362
1263
|
recursive: true,
|
|
@@ -1373,9 +1274,10 @@ function bindGraphCheckNodes(graph, options) {
|
|
|
1373
1274
|
exitCode: ran.exitCode,
|
|
1374
1275
|
output,
|
|
1375
1276
|
outputTruncated: truncated,
|
|
1376
|
-
nativeValid:
|
|
1377
|
-
valid: ran.exitCode === 0,
|
|
1378
|
-
...json === void 0 ? {} : { json }
|
|
1277
|
+
nativeValid: ran.nativeValid !== false,
|
|
1278
|
+
valid: ran.exitCode === 0 && ran.nativeValid !== false && ran.outputs?.status !== "incomplete",
|
|
1279
|
+
...json === void 0 ? {} : { json },
|
|
1280
|
+
...ran.outputs === void 0 ? {} : { outputs: ran.outputs }
|
|
1379
1281
|
};
|
|
1380
1282
|
if (file) await appendReceipt(file, workspace, receipt);
|
|
1381
1283
|
else await retainedExecutorContext(context_)?.onEvidence?.({ graphCheckReceipt: {
|
|
@@ -1569,7 +1471,9 @@ const runGraphOptionKeys = [
|
|
|
1569
1471
|
...GRAPH_TRANSFORMED_SUPERVISE_OPTIONS,
|
|
1570
1472
|
...GRAPH_REFUSED_SUPERVISE_OPTIONS,
|
|
1571
1473
|
"brain",
|
|
1572
|
-
"checkPlacement"
|
|
1474
|
+
"checkPlacement",
|
|
1475
|
+
"checkArtifacts",
|
|
1476
|
+
"trigger"
|
|
1573
1477
|
];
|
|
1574
1478
|
const runGraphOptionKeySet = new Set(runGraphOptionKeys);
|
|
1575
1479
|
const graphOwnedOptionKeySet = new Set(GRAPH_OWNED_SUPERVISE_OPTIONS);
|
|
@@ -1693,6 +1597,7 @@ function superviseAgentGraph(graph, opts, brain) {
|
|
|
1693
1597
|
...signal === void 0 ? {} : { signal }
|
|
1694
1598
|
}, brain));
|
|
1695
1599
|
const validated = assertRunGraphAuthoring(graph, opts, brain);
|
|
1600
|
+
const trigger = opts.trigger === void 0 ? void 0 : detachedSnapshot(opts.trigger, "runGraph trigger");
|
|
1696
1601
|
const context = opts.runContext ?? (opts.runDir === void 0 ? createInMemoryRunContext() : createFileRunContext(resolve(opts.runDir)));
|
|
1697
1602
|
const journal = opts.journal ?? context.journal;
|
|
1698
1603
|
const blobs = opts.blobs ?? context.blobs;
|
|
@@ -1700,7 +1605,8 @@ function superviseAgentGraph(graph, opts, brain) {
|
|
|
1700
1605
|
const now = opts.now ?? Date.now;
|
|
1701
1606
|
const checkNodes = bindGraphCheckNodes(graph, {
|
|
1702
1607
|
...opts,
|
|
1703
|
-
runId
|
|
1608
|
+
runId,
|
|
1609
|
+
trigger
|
|
1704
1610
|
});
|
|
1705
1611
|
const guidance = profileGuidanceComposer(opts.profileGuidance);
|
|
1706
1612
|
const overlay = createGraphOverlay(validated, {
|
|
@@ -1722,7 +1628,11 @@ function superviseAgentGraph(graph, opts, brain) {
|
|
|
1722
1628
|
} }, opts.hooks);
|
|
1723
1629
|
const rootProfile = flow === void 0 ? graphRootProfile(validated, registry) : flowRootProfile;
|
|
1724
1630
|
const rootBrain = flow === void 0 ? brain : runtimeFlowBrain();
|
|
1725
|
-
const
|
|
1631
|
+
const description = flow === void 0 ? graph.deliverable.describe ?? `Deliver the graph's deliverable by driving your worker nodes (root: '${validated.root.id}').` : graph.deliverable.describe ?? "Runtime runs this flow graph from its entries.";
|
|
1632
|
+
const task = trigger === void 0 ? description : {
|
|
1633
|
+
task: description,
|
|
1634
|
+
trigger
|
|
1635
|
+
};
|
|
1726
1636
|
const start = async () => {
|
|
1727
1637
|
const superviseOptions = {
|
|
1728
1638
|
...forwardedSuperviseOptions(opts),
|
|
@@ -1783,6 +1693,6 @@ function superviseAgentGraph(graph, opts, brain) {
|
|
|
1783
1693
|
};
|
|
1784
1694
|
return start();
|
|
1785
1695
|
}
|
|
1786
|
-
export {
|
|
1696
|
+
export { isolatedCheckBoxEvidenceSchema as a, runIsolatedCheck as c, superviseAgentGraph as i, runGraph as n, isolatedCheckResultSchema as o, runGraphWithTestBrain as r, graphExecutionOptions as s, GraphEdgeCapError as t };
|
|
1787
1697
|
|
|
1788
|
-
//# sourceMappingURL=graph-
|
|
1698
|
+
//# sourceMappingURL=graph-Bf3axJxp.js.map
|