@tangle-network/agent-runtime 0.293.4 → 0.295.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-1BxDcwZs.d.ts → activation-DYCFEI_o.d.ts} +2 -2
- package/dist/{activation-BKz1t1Qb.js → activation-DbcZXadv.js} +3 -3
- package/dist/{activation-BKz1t1Qb.js.map → activation-DbcZXadv.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/{bundle-BfW-32vB.js → bundle-CDR0caM4.js} +2 -2
- package/dist/{bundle-BfW-32vB.js.map → bundle-CDR0caM4.js.map} +1 -1
- package/dist/candidate-execution/index.d.ts +27 -3
- package/dist/candidate-execution/index.js +6 -6
- package/dist/{coordination-driver-BpEJv7GR.js → coordination-driver-Do3g6Qif.js} +2 -2
- package/dist/{coordination-driver-BpEJv7GR.js.map → coordination-driver-Do3g6Qif.js.map} +1 -1
- package/dist/{delegate-DEP51NR7.js → delegate-CCaU8M4O.js} +2 -2
- package/dist/{delegate-DEP51NR7.js.map → delegate-CCaU8M4O.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +3 -3
- package/dist/{graph-oFWfYVpn.js → graph-dNmpMnzl.js} +4 -4
- package/dist/{graph-oFWfYVpn.js.map → graph-dNmpMnzl.js.map} +1 -1
- package/dist/{improvement-cycle-CBAuTq3p.js → improvement-cycle-D4hoGlAe.js} +6 -6
- package/dist/{improvement-cycle-CBAuTq3p.js.map → improvement-cycle-D4hoGlAe.js.map} +1 -1
- package/dist/{index-DZqkIP6a.d.ts → index-nREMiWJP.d.ts} +108 -6
- package/dist/index.d.ts +5 -5
- package/dist/index.js +9 -9
- package/dist/intelligence.d.ts +4 -4
- package/dist/intelligence.js +8 -8
- package/dist/kernel.d.ts +3 -3
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-D5lBiaf5.js → loop-runner-bin-DIf0bbQM.js} +3 -3
- package/dist/{loop-runner-bin-D5lBiaf5.js.map → loop-runner-bin-DIf0bbQM.js.map} +1 -1
- package/dist/{loop-runner-bin-BUldbpz8.d.ts → loop-runner-bin-cf1xZPC2.d.ts} +2 -2
- 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 +2 -2
- package/dist/mcp/index.js +4 -4
- package/dist/{prepare-CxnyZ1fG.js → prepare-Dzkj4AGj.js} +3 -3
- package/dist/prepare-Dzkj4AGj.js.map +1 -0
- package/dist/{profile-C4NDjZyB.js → profile-BubsrYhR.js} +2 -2
- package/dist/{profile-C4NDjZyB.js.map → profile-BubsrYhR.js.map} +1 -1
- package/dist/{protected-model-port-DDnU39ul.d.ts → protected-model-port-CAa0t1MT.d.ts} +2 -2
- package/dist/{protected-model-port-BSsgmdhI.js → protected-model-port-_Daje74V.js} +4 -4
- package/dist/{protected-model-port-BSsgmdhI.js.map → protected-model-port-_Daje74V.js.map} +1 -1
- package/dist/{provision-supervisor-CIwZLCGR.js → provision-supervisor-B_3hmSz6.js} +3 -3
- package/dist/{provision-supervisor-CIwZLCGR.js.map → provision-supervisor-B_3hmSz6.js.map} +1 -1
- package/dist/{runtime-10G-vbmJ.js → runtime-CXKCdGTg.js} +575 -34
- package/dist/runtime-CXKCdGTg.js.map +1 -0
- package/dist/{search-method-3EtnGKdL.js → search-method-B0VM-hHV.js} +3 -3
- package/dist/{search-method-3EtnGKdL.js.map → search-method-B0VM-hHV.js.map} +1 -1
- package/dist/{server-DgEDz4Rn.js → server--GKA8T0f.js} +3 -3
- package/dist/{server-DgEDz4Rn.js.map → server--GKA8T0f.js.map} +1 -1
- package/dist/{stream-agent-turn-DsHYpI9p.d.ts → stream-agent-turn-CwqktoXW.d.ts} +2 -2
- package/dist/{supervise-Cu0yOTkc.js → supervise-BwfqpTVR.js} +3 -3
- package/dist/{supervise-Cu0yOTkc.js.map → supervise-BwfqpTVR.js.map} +1 -1
- package/dist/{supervisor-B-UbeBqD.js → supervisor-Da7iAPSw.js} +15 -6
- package/dist/supervisor-Da7iAPSw.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +14 -14
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{workspace-archive-DpyZV2Cj.d.ts → workspace-archive-pz8YJ1fr.d.ts} +12 -1
- package/dist/{workspace-archive-MhowMCmp.js → workspace-streams-D4TMTrJV.js} +301 -15
- package/dist/workspace-streams-D4TMTrJV.js.map +1 -0
- package/package.json +1 -1
- package/dist/prepare-CxnyZ1fG.js.map +0 -1
- package/dist/runtime-10G-vbmJ.js.map +0 -1
- package/dist/supervisor-B-UbeBqD.js.map +0 -1
- package/dist/workspace-archive-MhowMCmp.js.map +0 -1
package/dist/testing.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Gn as ToolLoopChat, Wn as ToolLoopCallContext } from "./stream-agent-turn-
|
|
1
|
+
import { Ic as SuperviseTestOptions, Rc as superviseWithTestBrain, Tl as supervisorAgentWithTestBrain, Tn as driverAgent, Zt as RunGraphTestOptions, gl as SupervisorAgentTestDeps, tn as runGraphWithTestBrain, wn as DriverAgentOptions } from "./index-nREMiWJP.js";
|
|
2
|
+
import { Gn as ToolLoopChat, Wn as ToolLoopCallContext } from "./stream-agent-turn-CwqktoXW.js";
|
|
3
3
|
import { AgentImprovementProposal, AgentProfile, AgentProfileImprovementMeasuredComparison, SandboxSizePreset } from "@tangle-network/agent-interface";
|
|
4
4
|
//#region src/testing/index.d.ts
|
|
5
5
|
/** A proposal produced by Runtime's opaque profile-improvement path. */
|
package/dist/testing.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as verifyAgentImprovementProposal } from "./improvement-cycle-
|
|
3
|
-
import { i as applyExactAgentProfileDiff, p as parseExactAgentProfile } from "./profile-
|
|
4
|
-
import { r as driverAgent } from "./coordination-driver-
|
|
5
|
-
import { a as superviseWithTestBrain, h as supervisorAgentWithTestBrain } from "./supervise-
|
|
6
|
-
import { i as runGraphWithTestBrain } from "./graph-
|
|
1
|
+
import { D as canonicalCandidateDigest$1, j as immutableCandidateValue } from "./workspace-streams-D4TMTrJV.js";
|
|
2
|
+
import { f as verifyAgentImprovementProposal } from "./improvement-cycle-D4hoGlAe.js";
|
|
3
|
+
import { i as applyExactAgentProfileDiff, p as parseExactAgentProfile } from "./profile-BubsrYhR.js";
|
|
4
|
+
import { r as driverAgent } from "./coordination-driver-Do3g6Qif.js";
|
|
5
|
+
import { a as superviseWithTestBrain, h as supervisorAgentWithTestBrain } from "./supervise-BwfqpTVR.js";
|
|
6
|
+
import { i as runGraphWithTestBrain } from "./graph-dNmpMnzl.js";
|
|
7
7
|
import { SANDBOX_SIZE_PRESET_NAMES, canonicalAgentProfileDigest } from "@tangle-network/agent-interface";
|
|
8
8
|
//#region src/testing/fixtures/agent-improvement-proposal.json
|
|
9
9
|
var agent_improvement_proposal_default = {
|
|
10
10
|
changedSurfaces: ["prompt"],
|
|
11
|
-
digest: "sha256:
|
|
11
|
+
digest: "sha256:92ae4f0346f8bcf97d235489d683bdb8580acc51292cd42825038bddb74cd15b",
|
|
12
12
|
evaluation: {
|
|
13
13
|
"decision": {
|
|
14
14
|
"contributingChecks": [
|
|
@@ -4579,7 +4579,7 @@ var agent_improvement_proposal_default = {
|
|
|
4579
4579
|
],
|
|
4580
4580
|
"metadata": {
|
|
4581
4581
|
"fixture": "agent-improvement-proposal",
|
|
4582
|
-
"runtimeVersion": "0.
|
|
4582
|
+
"runtimeVersion": "0.295.0"
|
|
4583
4583
|
},
|
|
4584
4584
|
"objectives": [
|
|
4585
4585
|
{
|
|
@@ -4690,8 +4690,8 @@ var agent_improvement_proposal_default = {
|
|
|
4690
4690
|
"baselineContentHash": "sha256:5c21ee53e513fc604cb09754e21c392b24a424da0ef37dbf8f1ee4a8a0b08f09",
|
|
4691
4691
|
"candidateContentHash": "sha256:60fcbb1c728194bd51d7d19cb732d1c3f1881dce7e0a6266b41c8b98cfd65693",
|
|
4692
4692
|
"kind": "agent-eval-loop",
|
|
4693
|
-
"recordDigest": "sha256:
|
|
4694
|
-
"runId": "agent-runtime-0.
|
|
4693
|
+
"recordDigest": "sha256:910d1c0d45c3a710f6fd5e74e37f136b7e7f80134c1d60a802b632a32fb83ace",
|
|
4694
|
+
"runId": "agent-runtime-0.295.0-proposal-fixture",
|
|
4695
4695
|
"schema": "agent-candidate-experiment"
|
|
4696
4696
|
}
|
|
4697
4697
|
},
|
|
@@ -4714,13 +4714,13 @@ var agent_improvement_proposal_default = {
|
|
|
4714
4714
|
}],
|
|
4715
4715
|
kind: "agent-improvement-proposal",
|
|
4716
4716
|
proposedAt: "2026-07-10T01:00:00.000Z",
|
|
4717
|
-
runId: "agent-runtime-0.
|
|
4717
|
+
runId: "agent-runtime-0.295.0-proposal-fixture"
|
|
4718
4718
|
};
|
|
4719
4719
|
//#endregion
|
|
4720
4720
|
//#region src/testing/fixtures/agent-profile-improvement-proposal.json
|
|
4721
4721
|
var agent_profile_improvement_proposal_default = {
|
|
4722
4722
|
changedSurfaces: ["prompt", "skills"],
|
|
4723
|
-
digest: "sha256:
|
|
4723
|
+
digest: "sha256:d515abd0654e1c9bddad5f78adc5ebffdd67665d1877bb758a90ec45fb87b273",
|
|
4724
4724
|
evaluation: {
|
|
4725
4725
|
"decision": {
|
|
4726
4726
|
"contributingChecks": [
|
|
@@ -6354,7 +6354,7 @@ var agent_profile_improvement_proposal_default = {
|
|
|
6354
6354
|
],
|
|
6355
6355
|
"metadata": {
|
|
6356
6356
|
"fixture": "agent-profile-improvement-proposal",
|
|
6357
|
-
"runtimeVersion": "0.
|
|
6357
|
+
"runtimeVersion": "0.295.0"
|
|
6358
6358
|
},
|
|
6359
6359
|
"objectives": [
|
|
6360
6360
|
{
|
|
@@ -6465,7 +6465,7 @@ var agent_profile_improvement_proposal_default = {
|
|
|
6465
6465
|
"baselineContentHash": "sha256:21c495a37c418c10bde64fbaa188beddeed31f1f051ea60a6a6582a9ee0db704",
|
|
6466
6466
|
"candidateContentHash": "sha256:103f77bc8481601eef1ad5fe6ba84a40dffabc3a44f421f8c8559121edab84e9",
|
|
6467
6467
|
"kind": "agent-eval-loop",
|
|
6468
|
-
"recordDigest": "sha256:
|
|
6468
|
+
"recordDigest": "sha256:3ea42b79172f7a43340e78b622151271db8d8ead2ae5ada9f720340d20c56a32",
|
|
6469
6469
|
"runId": "profile-improvement-1",
|
|
6470
6470
|
"schema": "agent-profile-improvement-experiment"
|
|
6471
6471
|
}
|
package/dist/tui/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ct as ProvisionSupervisorConnection, Dt as provisionSupervisor, Et as SupervisorCleanupReceipt, Tt as ProvisionedSupervisor, wt as ProvisionSupervisorRequest } from "../index-
|
|
1
|
+
import { Ct as ProvisionSupervisorConnection, Dt as provisionSupervisor, Et as SupervisorCleanupReceipt, Tt as ProvisionedSupervisor, wt as ProvisionSupervisorRequest } from "../index-nREMiWJP.js";
|
|
2
2
|
//#region src/tui/top-app.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* The interactive side of the supervisor-run TUI: a keypress/mouse loop over the frames
|
package/dist/tui/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as provisionSupervisor } from "../provision-supervisor-
|
|
1
|
+
import { t as provisionSupervisor } from "../provision-supervisor-B_3hmSz6.js";
|
|
2
2
|
import { a as renderTopFrameWithLayout, i as renderTopFrame, n as runTopApp, r as loadTopSnapshot, t as renderTopOnce } from "../top-app-DaiR4LXM.js";
|
|
3
3
|
export { loadTopSnapshot, provisionSupervisor, renderTopFrame, renderTopFrameWithLayout, renderTopOnce, runTopApp };
|
|
@@ -16,10 +16,21 @@ declare const verifiedTaskOutcomeBrand: unique symbol;
|
|
|
16
16
|
/** Reads one content-addressed object from the closed S3/IPFS locator set. */
|
|
17
17
|
interface AgentCandidateArtifactPort {
|
|
18
18
|
read(ref: AgentCandidateArtifactRef): Promise<Uint8Array>;
|
|
19
|
+
/** Stream an artifact without materializing its complete contents. */
|
|
20
|
+
readStream?(ref: AgentCandidateArtifactRef, options?: {
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
}): AsyncIterable<Uint8Array>;
|
|
19
23
|
}
|
|
20
24
|
type AgentCandidateOutputPurpose = 'execution-plan' | 'materialization-receipt' | 'candidate-workspace-manifest' | 'candidate-workspace-archive' | 'task-manifest' | 'task-archive' | 'task-patch' | 'task-output' | 'task-outcome' | 'memory-after-manifest' | 'memory-after-archive' | 'grader-evidence' | 'benchmark-result' | 'model-settlement' | 'trace' | 'executor-native-evidence' | 'executor-capture' | 'run-receipt' | 'knowledge-retrieval-config' | 'knowledge-evaluation' | 'failure-evidence';
|
|
21
25
|
/** Durable content-addressed evidence store controlled only by the evaluator. */
|
|
22
26
|
interface AgentCandidateOutputArtifactPort extends AgentCandidateArtifactPort {
|
|
27
|
+
/** Consume all chunks before publishing; preserve put's identity and cancellation guarantees. */
|
|
28
|
+
putStream?(input: {
|
|
29
|
+
executionId: string;
|
|
30
|
+
purpose: AgentCandidateOutputPurpose;
|
|
31
|
+
chunks: AsyncIterable<Uint8Array>;
|
|
32
|
+
signal?: AbortSignal;
|
|
33
|
+
}): Promise<AgentCandidateArtifactRef>;
|
|
23
34
|
/** Must be idempotent for identical bytes and return only a durable S3/IPFS locator. */
|
|
24
35
|
put(input: {
|
|
25
36
|
executionId: string;
|
|
@@ -540,4 +551,4 @@ declare function captureAgentCandidateWorkspaceFiles(input: readonly AgentCandid
|
|
|
540
551
|
declare function createAgentCandidateWorkspacePort(options?: CreateAgentCandidateWorkspacePortOptions): AgentCandidateWorkspacePort;
|
|
541
552
|
//#endregion
|
|
542
553
|
export { AgentCandidateProtectedModelSettlement as A, CanonicalCandidateDocument as B, AgentCandidateMemoryResetResult as C, AgentCandidateOutputPurpose as D, AgentCandidateOutputArtifactPort as E, AgentCandidateTaskExecution as F, PreparedAgentCandidateLaunch as G, PreparedAgentCandidateExecution as H, AgentCandidateVerificationPorts as I, VerifiedAgentCandidate as J, PreparedAgentCandidateTrace as K, AgentCandidateWorkspacePort as L, AgentCandidateProtectedRunCapture as M, AgentCandidateRepositoryPort as N, AgentCandidateProtectedModelActivation as O, AgentCandidateRunFinalization as P, CANDIDATE_TRACE_ENV as R, AgentCandidateMemoryPort as S, AgentCandidateModelPort as T, PreparedAgentCandidateInstruction as U, PersistedTaskOutcomeEvidence as V, PreparedAgentCandidateKnowledge as W, AgentCandidateExecutionRoots as X, VerifiedAgentCandidateTaskOutcome as Y, AgentCandidateExecutorRequest as _, captureAgentCandidateWorkspace as a, AgentCandidateExecutorWorkspaceFile as b, AgentCandidateArtifactPort as c, AgentCandidateContainerPort as d, AgentCandidateExecutionPorts as f, AgentCandidateExecutorProfileFile as g, AgentCandidateExecutorPort as h, CreateAgentCandidateWorkspacePortOptions as i, AgentCandidateProtectedModelSettlementCall as j, AgentCandidateProtectedModelReservation as k, AgentCandidateBenchmarkGraderIdentity as l, AgentCandidateExecutorMemoryCapture as m, CaptureAgentCandidateWorkspaceOptions as n, captureAgentCandidateWorkspaceFiles as o, AgentCandidateExecutorFinalCapture as p, ResolvedAgentCandidateContainer as q, CapturedAgentCandidateWorkspace as r, createAgentCandidateWorkspacePort as s, AgentCandidateWorkspaceArchiveLimits as t, AgentCandidateBenchmarkGraderPort as u, AgentCandidateExecutorStopRequest as v, AgentCandidateModelLimits as w, AgentCandidateExecutorWorkspaceInput as x, AgentCandidateExecutorTaskOutcomeCapture as y, CANDIDATE_TRACE_TAGS as z };
|
|
543
|
-
//# sourceMappingURL=workspace-archive-
|
|
554
|
+
//# sourceMappingURL=workspace-archive-pz8YJ1fr.d.ts.map
|
|
@@ -7,6 +7,8 @@ import { lstat, mkdir, mkdtemp, open, readFile, readdir, readlink, realpath, ren
|
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
8
|
import { isAnyArrayBuffer, isSharedArrayBuffer } from "node:util/types";
|
|
9
9
|
import { extract, pack } from "tar-stream";
|
|
10
|
+
import { Readable } from "node:stream";
|
|
11
|
+
import { pipeline } from "node:stream/promises";
|
|
10
12
|
//#region src/candidate-execution/digest.ts
|
|
11
13
|
/** Use native hashing for workspace archives. */
|
|
12
14
|
function sha256Bytes$1(bytes) {
|
|
@@ -193,9 +195,11 @@ async function walkWorkspace(root, options, keepBytes) {
|
|
|
193
195
|
const scanned = [];
|
|
194
196
|
let totalBytes = 0;
|
|
195
197
|
async function visit(directory) {
|
|
198
|
+
options.signal?.throwIfAborted();
|
|
196
199
|
const entries = await readdir(directory, { withFileTypes: true });
|
|
197
200
|
entries.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
198
201
|
for (const entry of entries) {
|
|
202
|
+
options.signal?.throwIfAborted();
|
|
199
203
|
if (directory === absoluteRoot && ignoredProtectedRootEntries.has(entry.name)) continue;
|
|
200
204
|
const absolute = resolve(directory, entry.name);
|
|
201
205
|
const relPath = relative(absoluteRoot, absolute).split(sep).join("/");
|
|
@@ -217,7 +221,7 @@ async function walkWorkspace(root, options, keepBytes) {
|
|
|
217
221
|
if (limits && openedStats.size > limits.maxFileBytes) throw new WorkspaceScanLimitError(`workspace file exceeds maxFileBytes: ${relPath}`);
|
|
218
222
|
const remainingBytes = limits ? limits.maxTotalFileBytes - totalBytes : void 0;
|
|
219
223
|
if (remainingBytes !== void 0 && openedStats.size > remainingBytes) throw new WorkspaceScanLimitError("workspace exceeds maxTotalFileBytes");
|
|
220
|
-
const read = await readWorkspaceFile(descriptor, limits ? Math.min(limits.maxFileBytes, remainingBytes ?? limits.maxFileBytes) : void 0, keepBytes, relPath);
|
|
224
|
+
const read = await readWorkspaceFile(descriptor, limits ? Math.min(limits.maxFileBytes, remainingBytes ?? limits.maxFileBytes) : void 0, keepBytes, relPath, options.signal);
|
|
221
225
|
totalBytes += read.byteLength;
|
|
222
226
|
scanned.push({
|
|
223
227
|
path: relPath,
|
|
@@ -268,12 +272,13 @@ function isWithin(root, path) {
|
|
|
268
272
|
* chunks in order equals hashing the whole buffer, so a manifest a buffered read produced is
|
|
269
273
|
* reproduced byte for byte.
|
|
270
274
|
*/
|
|
271
|
-
async function readWorkspaceFile(descriptor, maxBytes, keepBytes, path) {
|
|
275
|
+
async function readWorkspaceFile(descriptor, maxBytes, keepBytes, path, signal) {
|
|
272
276
|
const hash = createHash("sha256");
|
|
273
277
|
const buffer = Buffer.allocUnsafe(1024 * 1024);
|
|
274
278
|
const chunks = [];
|
|
275
279
|
let total = 0;
|
|
276
280
|
while (true) {
|
|
281
|
+
signal?.throwIfAborted();
|
|
277
282
|
const { bytesRead } = await descriptor.read(buffer, 0, buffer.byteLength, null);
|
|
278
283
|
if (bytesRead === 0) break;
|
|
279
284
|
total += bytesRead;
|
|
@@ -951,17 +956,7 @@ function repositoryFromTar(metadata, bundle) {
|
|
|
951
956
|
}
|
|
952
957
|
async function writeTarEntry(archive, name, mode, bytes) {
|
|
953
958
|
await new Promise((resolveEntry, rejectEntry) => {
|
|
954
|
-
archive.entry(
|
|
955
|
-
name,
|
|
956
|
-
mode,
|
|
957
|
-
uid: 0,
|
|
958
|
-
gid: 0,
|
|
959
|
-
size: bytes.byteLength,
|
|
960
|
-
mtime: fixedTarTime,
|
|
961
|
-
type: "file",
|
|
962
|
-
uname: "",
|
|
963
|
-
gname: ""
|
|
964
|
-
}, Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength), (error) => error ? rejectEntry(error) : resolveEntry());
|
|
959
|
+
archive.entry(workspaceTarHeader(name, mode, bytes.byteLength), Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength), (error) => error ? rejectEntry(error) : resolveEntry());
|
|
965
960
|
});
|
|
966
961
|
}
|
|
967
962
|
async function readTarEntry(entry, maxBytes, label) {
|
|
@@ -1205,7 +1200,298 @@ function requireTypedArrayGetter(name) {
|
|
|
1205
1200
|
const typedArrayBufferGetter = requireTypedArrayGetter("buffer");
|
|
1206
1201
|
const typedArrayByteOffsetGetter = requireTypedArrayGetter("byteOffset");
|
|
1207
1202
|
const typedArrayByteLengthGetter = requireTypedArrayGetter("byteLength");
|
|
1203
|
+
/** Shared canonical header for both archive encoders. */
|
|
1204
|
+
function workspaceTarHeader(name, mode, size) {
|
|
1205
|
+
return {
|
|
1206
|
+
name,
|
|
1207
|
+
mode,
|
|
1208
|
+
uid: 0,
|
|
1209
|
+
gid: 0,
|
|
1210
|
+
size,
|
|
1211
|
+
mtime: fixedTarTime,
|
|
1212
|
+
type: "file",
|
|
1213
|
+
uname: "",
|
|
1214
|
+
gname: ""
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
//#endregion
|
|
1218
|
+
//#region src/candidate-execution/artifact-streams.ts
|
|
1219
|
+
/** Verify the complete stream, including its final digest, before accepting its consumer's result. */
|
|
1220
|
+
async function* verifiedArtifactChunks(artifact, port, signal) {
|
|
1221
|
+
signal?.throwIfAborted();
|
|
1222
|
+
if (!("content" in artifact) && !port.readStream) throw new Error("streaming workspace artifacts require readStream");
|
|
1223
|
+
const chunks = "content" in artifact ? [Buffer.from(artifact.content, "base64")] : port.readStream(artifact, { signal });
|
|
1224
|
+
const hash = createHash("sha256");
|
|
1225
|
+
let byteLength = 0;
|
|
1226
|
+
for await (const chunk of chunks) {
|
|
1227
|
+
signal?.throwIfAborted();
|
|
1228
|
+
if (!(chunk instanceof Uint8Array)) throw new Error("candidate artifact emitted a non-byte chunk");
|
|
1229
|
+
byteLength += chunk.byteLength;
|
|
1230
|
+
if (byteLength > artifact.byteLength) throw new Error("candidate artifact exceeds its declared length");
|
|
1231
|
+
hash.update(chunk);
|
|
1232
|
+
yield chunk;
|
|
1233
|
+
}
|
|
1234
|
+
signal?.throwIfAborted();
|
|
1235
|
+
if (byteLength !== artifact.byteLength || `sha256:${hash.digest("hex")}` !== artifact.sha256) throw new Error("candidate artifact failed digest or length verification");
|
|
1236
|
+
}
|
|
1237
|
+
/** Stream evaluator evidence into its existing store and verify durable readback before returning. */
|
|
1238
|
+
async function persistCandidateOutputArtifactStream(port, input) {
|
|
1239
|
+
if (!port.putStream || !port.readStream) throw new Error("streaming workspace persistence requires putStream and readStream");
|
|
1240
|
+
input.signal?.throwIfAborted();
|
|
1241
|
+
const hash = createHash("sha256");
|
|
1242
|
+
let byteLength = 0;
|
|
1243
|
+
let consumed = false;
|
|
1244
|
+
async function* checked() {
|
|
1245
|
+
for await (const chunk of input.chunks) {
|
|
1246
|
+
input.signal?.throwIfAborted();
|
|
1247
|
+
if (!(chunk instanceof Uint8Array)) throw new Error("candidate artifact emitted a non-byte chunk");
|
|
1248
|
+
byteLength += chunk.byteLength;
|
|
1249
|
+
if (byteLength > input.maxBytes) throw new Error("candidate workspace archive exceeds maxArchiveBytes");
|
|
1250
|
+
hash.update(chunk);
|
|
1251
|
+
yield chunk;
|
|
1252
|
+
}
|
|
1253
|
+
consumed = true;
|
|
1254
|
+
input.signal?.throwIfAborted();
|
|
1255
|
+
}
|
|
1256
|
+
const chunks = checked();
|
|
1257
|
+
try {
|
|
1258
|
+
const ref = agentCandidateArtifactRefSchema.parse(await port.putStream({
|
|
1259
|
+
executionId: input.executionId,
|
|
1260
|
+
purpose: input.purpose,
|
|
1261
|
+
chunks,
|
|
1262
|
+
...input.signal ? { signal: input.signal } : {}
|
|
1263
|
+
}));
|
|
1264
|
+
input.signal?.throwIfAborted();
|
|
1265
|
+
if (!consumed || ref.sha256 !== `sha256:${hash.digest("hex")}` || ref.byteLength !== byteLength) throw new Error("candidate output locator does not identify the submitted bytes");
|
|
1266
|
+
for await (const _chunk of verifiedArtifactChunks(ref, port, input.signal));
|
|
1267
|
+
return immutableCandidateValue(ref);
|
|
1268
|
+
} finally {
|
|
1269
|
+
await chunks.return(void 0);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
//#endregion
|
|
1273
|
+
//#region src/candidate-execution/workspace-streams.ts
|
|
1274
|
+
/** Capture regular files to durable artifacts with memory bounded by the manifest and stream buffers. */
|
|
1275
|
+
async function captureAgentCandidateWorkspaceToArtifacts(rootInput, options) {
|
|
1276
|
+
const { outputArtifacts, executionId, signal } = options.artifactPersistence;
|
|
1277
|
+
if (!outputArtifacts.putStream || !outputArtifacts.readStream) throw new Error("streaming workspace persistence requires putStream and readStream");
|
|
1278
|
+
if (!executionId.trim()) throw new Error("candidate workspace artifact persistence requires an executionId");
|
|
1279
|
+
signal?.throwIfAborted();
|
|
1280
|
+
const limits = workspaceLimits(options.limits);
|
|
1281
|
+
const material = await scanMaterializedWorkspaceManifest(rootInput, {
|
|
1282
|
+
limits,
|
|
1283
|
+
signal
|
|
1284
|
+
});
|
|
1285
|
+
validateManifest(material, limits);
|
|
1286
|
+
const root = await realpath(resolve(rootInput));
|
|
1287
|
+
const manifest = canonicalCandidateBytes$1(material);
|
|
1288
|
+
const manifestArtifact = await persistCandidateOutputArtifactStream(outputArtifacts, {
|
|
1289
|
+
executionId,
|
|
1290
|
+
purpose: "candidate-workspace-manifest",
|
|
1291
|
+
chunks: oneChunk(manifest),
|
|
1292
|
+
maxBytes: manifest.byteLength,
|
|
1293
|
+
signal
|
|
1294
|
+
});
|
|
1295
|
+
const archiveArtifact = await persistCandidateOutputArtifactStream(outputArtifacts, {
|
|
1296
|
+
executionId,
|
|
1297
|
+
purpose: "candidate-workspace-archive",
|
|
1298
|
+
chunks: workspaceArchiveChunks(root, material, signal),
|
|
1299
|
+
maxBytes: limits.maxArchiveBytes,
|
|
1300
|
+
signal
|
|
1301
|
+
});
|
|
1302
|
+
return Object.freeze({ snapshot: deepFreezeCandidate({
|
|
1303
|
+
kind: "agent-candidate-workspace-snapshot",
|
|
1304
|
+
digest: canonicalCandidateDigest$1(material),
|
|
1305
|
+
material,
|
|
1306
|
+
manifest: manifestArtifact,
|
|
1307
|
+
archive: archiveArtifact
|
|
1308
|
+
}) });
|
|
1309
|
+
}
|
|
1310
|
+
/** Verify durable regular-file workspace evidence without retaining archive or file contents. */
|
|
1311
|
+
async function verifyAgentCandidateWorkspaceArtifacts(input) {
|
|
1312
|
+
await consumeWorkspaceArtifacts(input);
|
|
1313
|
+
}
|
|
1314
|
+
/** Restore regular-file artifacts into an empty destination, publishing only after complete verification. */
|
|
1315
|
+
async function materializeAgentCandidateWorkspaceFromArtifacts(input) {
|
|
1316
|
+
input.signal?.throwIfAborted();
|
|
1317
|
+
if (!input.artifacts.readStream) throw new Error("streaming workspace artifacts require readStream");
|
|
1318
|
+
const destination = resolve(input.destination);
|
|
1319
|
+
await prepareEmptyDestination(destination);
|
|
1320
|
+
const staging = await mkdtemp(`${destination}.materializing-`);
|
|
1321
|
+
try {
|
|
1322
|
+
await consumeWorkspaceArtifacts(input, staging);
|
|
1323
|
+
input.signal?.throwIfAborted();
|
|
1324
|
+
await rename(staging, destination);
|
|
1325
|
+
} catch (error) {
|
|
1326
|
+
await rm(staging, {
|
|
1327
|
+
recursive: true,
|
|
1328
|
+
force: true
|
|
1329
|
+
});
|
|
1330
|
+
throw error;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
async function consumeWorkspaceArtifacts(input, destination) {
|
|
1334
|
+
const { artifacts, signal } = input;
|
|
1335
|
+
const snapshot = deepFreezeCandidate(structuredClone(input.snapshot));
|
|
1336
|
+
signal?.throwIfAborted();
|
|
1337
|
+
if (!artifacts.readStream) throw new Error("streaming workspace artifacts require readStream");
|
|
1338
|
+
const limits = workspaceLimits(input.limits);
|
|
1339
|
+
validateManifest(snapshot.material, limits);
|
|
1340
|
+
if (snapshot.archive.byteLength > limits.maxArchiveBytes) throw new Error("candidate workspace archive exceeds maxArchiveBytes");
|
|
1341
|
+
const manifest = canonicalCandidateBytes$1(snapshot.material);
|
|
1342
|
+
verifyBytes(manifest, snapshot.manifest.sha256, snapshot.manifest.byteLength, "candidate workspace manifest");
|
|
1343
|
+
if (canonicalCandidateDigest$1(snapshot.material) !== snapshot.digest) throw new Error("workspace snapshot digest does not match its canonical manifest material");
|
|
1344
|
+
let offset = 0;
|
|
1345
|
+
for await (const chunk of verifiedArtifactChunks(snapshot.manifest, artifacts, signal)) {
|
|
1346
|
+
if (!Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength).equals(manifest.subarray(offset, offset + chunk.byteLength))) throw new Error("workspace manifest artifact is not the exact canonical manifest material");
|
|
1347
|
+
offset += chunk.byteLength;
|
|
1348
|
+
}
|
|
1349
|
+
const parser = extract();
|
|
1350
|
+
const canonical = pack();
|
|
1351
|
+
const canonicalResult = digestChunks(canonical, limits.maxArchiveBytes, signal);
|
|
1352
|
+
const reading = pipeline(Readable.from(verifiedArtifactChunks(snapshot.archive, artifacts, signal)), parser, { signal });
|
|
1353
|
+
reading.catch(() => void 0);
|
|
1354
|
+
canonicalResult.catch(() => void 0);
|
|
1355
|
+
try {
|
|
1356
|
+
let index = 0;
|
|
1357
|
+
for await (const entry of parser) {
|
|
1358
|
+
signal?.throwIfAborted();
|
|
1359
|
+
const expected = snapshot.material.files[index++];
|
|
1360
|
+
if (!expected || entry.header.type !== "file" || entry.header.name !== `workspace/${expected.path}` || entry.header.mode !== expected.mode || entry.header.size !== expected.byteLength) throw new Error("candidate workspace archive does not match its snapshot manifest");
|
|
1361
|
+
const file = destination ? await openDestination(destination, expected.path) : void 0;
|
|
1362
|
+
try {
|
|
1363
|
+
async function* checked() {
|
|
1364
|
+
const hash = createHash("sha256");
|
|
1365
|
+
let byteLength = 0;
|
|
1366
|
+
for await (const chunk of entry) {
|
|
1367
|
+
if (!(chunk instanceof Uint8Array)) throw new Error("workspace entry emitted a non-byte chunk");
|
|
1368
|
+
signal?.throwIfAborted();
|
|
1369
|
+
byteLength += chunk.byteLength;
|
|
1370
|
+
if (byteLength > expected.byteLength) throw new Error("workspace entry exceeds its manifest length");
|
|
1371
|
+
hash.update(chunk);
|
|
1372
|
+
if (file) await file.writeFile(chunk);
|
|
1373
|
+
yield chunk;
|
|
1374
|
+
}
|
|
1375
|
+
if (byteLength !== expected.byteLength || `sha256:${hash.digest("hex")}` !== expected.sha256) throw new Error("candidate workspace archive does not match its snapshot manifest");
|
|
1376
|
+
}
|
|
1377
|
+
await appendTarFile(canonical, expected, checked(), signal);
|
|
1378
|
+
if (file) await file.chmod(expected.mode);
|
|
1379
|
+
} finally {
|
|
1380
|
+
await file?.close();
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
if (index !== snapshot.material.files.length) throw new Error("candidate workspace archive does not match its snapshot manifest");
|
|
1384
|
+
await reading;
|
|
1385
|
+
canonical.finalize();
|
|
1386
|
+
const observed = await canonicalResult;
|
|
1387
|
+
if (observed.byteLength !== snapshot.archive.byteLength || observed.sha256 !== snapshot.archive.sha256) throw new Error("candidate workspace tar is not canonical");
|
|
1388
|
+
} catch (error) {
|
|
1389
|
+
parser.destroy(asError(error));
|
|
1390
|
+
canonical.destroy(asError(error));
|
|
1391
|
+
await Promise.allSettled([reading, canonicalResult]);
|
|
1392
|
+
throw error;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
async function openDestination(destination, relativePath) {
|
|
1396
|
+
const path = workspacePath(destination, relativePath);
|
|
1397
|
+
await mkdir(dirname(path), {
|
|
1398
|
+
recursive: true,
|
|
1399
|
+
mode: 448
|
|
1400
|
+
});
|
|
1401
|
+
return open(path, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 384);
|
|
1402
|
+
}
|
|
1403
|
+
async function* workspaceArchiveChunks(root, material, signal) {
|
|
1404
|
+
const archive = pack();
|
|
1405
|
+
const writing = (async () => {
|
|
1406
|
+
try {
|
|
1407
|
+
for (const file of material.files) {
|
|
1408
|
+
signal?.throwIfAborted();
|
|
1409
|
+
await appendTarFile(archive, file, workspaceFileChunks(root, file, signal), signal);
|
|
1410
|
+
}
|
|
1411
|
+
archive.finalize();
|
|
1412
|
+
} catch (error) {
|
|
1413
|
+
archive.destroy(asError(error));
|
|
1414
|
+
throw error;
|
|
1415
|
+
}
|
|
1416
|
+
})();
|
|
1417
|
+
writing.catch(() => void 0);
|
|
1418
|
+
try {
|
|
1419
|
+
for await (const chunk of archive) {
|
|
1420
|
+
if (!(chunk instanceof Uint8Array)) throw new Error("workspace archive emitted a non-byte chunk");
|
|
1421
|
+
signal?.throwIfAborted();
|
|
1422
|
+
yield chunk;
|
|
1423
|
+
}
|
|
1424
|
+
await writing;
|
|
1425
|
+
} finally {
|
|
1426
|
+
archive.destroy();
|
|
1427
|
+
await writing.catch(() => void 0);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
async function* workspaceFileChunks(root, expected, signal) {
|
|
1431
|
+
const path = workspacePath(root, expected.path);
|
|
1432
|
+
if (await realpath(path) !== path) throw new Error(`workspace file path changed during capture: ${expected.path}`);
|
|
1433
|
+
const file = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
1434
|
+
try {
|
|
1435
|
+
const stats = await file.stat();
|
|
1436
|
+
if (!stats.isFile() || stats.nlink !== 1 || stats.size !== expected.byteLength || (stats.mode & 511) !== expected.mode) throw new Error(`workspace file changed during capture: ${expected.path}`);
|
|
1437
|
+
const hash = createHash("sha256");
|
|
1438
|
+
let byteLength = 0;
|
|
1439
|
+
for await (const chunk of file.createReadStream({
|
|
1440
|
+
autoClose: false,
|
|
1441
|
+
highWaterMark: 64 * 1024
|
|
1442
|
+
})) {
|
|
1443
|
+
signal?.throwIfAborted();
|
|
1444
|
+
byteLength += chunk.byteLength;
|
|
1445
|
+
if (byteLength > expected.byteLength) throw new Error(`workspace file changed during capture: ${expected.path}`);
|
|
1446
|
+
hash.update(chunk);
|
|
1447
|
+
yield chunk;
|
|
1448
|
+
}
|
|
1449
|
+
if (byteLength !== expected.byteLength || `sha256:${hash.digest("hex")}` !== expected.sha256) throw new Error(`workspace file changed during capture: ${expected.path}`);
|
|
1450
|
+
} finally {
|
|
1451
|
+
await file.close();
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
async function appendTarFile(archive, file, chunks, signal) {
|
|
1455
|
+
const entry = archive.entry(workspaceTarHeader(`workspace/${file.path}`, file.mode, file.byteLength));
|
|
1456
|
+
await pipeline(Readable.from(chunks), entry, { signal });
|
|
1457
|
+
}
|
|
1458
|
+
async function digestChunks(chunks, maxBytes, signal) {
|
|
1459
|
+
const hash = createHash("sha256");
|
|
1460
|
+
let byteLength = 0;
|
|
1461
|
+
for await (const chunk of chunks) {
|
|
1462
|
+
if (!(chunk instanceof Uint8Array)) throw new Error("workspace archive emitted a non-byte chunk");
|
|
1463
|
+
signal?.throwIfAborted();
|
|
1464
|
+
byteLength += chunk.byteLength;
|
|
1465
|
+
if (byteLength > maxBytes) throw new Error("candidate workspace archive exceeds maxArchiveBytes");
|
|
1466
|
+
hash.update(chunk);
|
|
1467
|
+
}
|
|
1468
|
+
return {
|
|
1469
|
+
sha256: `sha256:${hash.digest("hex")}`,
|
|
1470
|
+
byteLength
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1473
|
+
function validateManifest(material, limits) {
|
|
1474
|
+
if (material.kind !== "agent-candidate-workspace-manifest" || material.files.length > limits.maxFiles) throw new Error("candidate workspace exceeds maxFiles");
|
|
1475
|
+
let total = 0;
|
|
1476
|
+
let previous;
|
|
1477
|
+
const paths = /* @__PURE__ */ new Set();
|
|
1478
|
+
for (const file of material.files) {
|
|
1479
|
+
safeArchivePath(file.path, limits.maxPathBytes);
|
|
1480
|
+
assertWorkspacePathOrder(file.path, previous, paths, "candidate workspace paths must be unique and sorted");
|
|
1481
|
+
previous = file.path;
|
|
1482
|
+
if (!Number.isSafeInteger(file.mode) || file.mode < 0 || file.mode > 511) throw new Error("candidate workspace file has unsupported mode");
|
|
1483
|
+
if (!Number.isSafeInteger(file.byteLength) || file.byteLength < 0 || file.byteLength > limits.maxFileBytes) throw new Error("candidate workspace file exceeds maxFileBytes");
|
|
1484
|
+
total += file.byteLength;
|
|
1485
|
+
if (total > limits.maxTotalFileBytes) throw new Error("candidate workspace exceeds maxTotalFileBytes");
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
async function* oneChunk(bytes) {
|
|
1489
|
+
yield bytes;
|
|
1490
|
+
}
|
|
1491
|
+
function asError(error) {
|
|
1492
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
1493
|
+
}
|
|
1208
1494
|
//#endregion
|
|
1209
|
-
export {
|
|
1495
|
+
export { embeddedCandidateArtifact as A, verifyMaterializedProfileWorkspace as C, canonicalCandidateDigest$1 as D, canonicalCandidateBytes$1 as E, omitTopLevelDigest as M, sha256Bytes$1 as N, canonicalCandidateDocument as O, verifyCanonicalCandidateDocument as P, verifyBytes as S, verifyWorkspaceSnapshotArtifacts as T, candidateWorkspaceManifest as _, captureAgentCandidateWorkspaceFiles as a, readVerifiedArtifact as b, persistCandidateOutputArtifact as c, verifyTaskCheckout as d, verifyTaskOutcomePatch as f, artifactCacheKey as g, WorkspaceScanLimitError as h, captureAgentCandidateWorkspace as i, immutableCandidateValue as j, deepFreezeCandidate as k, readCandidateGitHubResource as l, isWellFormedUnicode as m, materializeAgentCandidateWorkspaceFromArtifacts as n, createAgentCandidateWorkspacePort as o, assertExactObjectKeys as p, verifyAgentCandidateWorkspaceArtifacts as r, verifyAgentCandidateWorkspaceArchive as s, captureAgentCandidateWorkspaceToArtifacts as t, verifyCandidateCode as u, captureMaterializedWorkspace as v, verifyMaterializedWorkspace as w, scanMaterializedWorkspaceManifest as x, readMaterializedWorkspaceFiles as y };
|
|
1210
1496
|
|
|
1211
|
-
//# sourceMappingURL=workspace-
|
|
1497
|
+
//# sourceMappingURL=workspace-streams-D4TMTrJV.js.map
|