@tangle-network/agent-runtime 0.94.12 → 0.94.13
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/candidate-execution/index.d.ts +2 -2
- package/dist/candidate-execution/index.js +2 -2
- package/dist/{chunk-37V4KQDC.js → chunk-CNH7DF7Z.js} +173 -84
- package/dist/chunk-CNH7DF7Z.js.map +1 -0
- package/dist/{chunk-FTXM7Q7P.js → chunk-TVJQAYQM.js} +13 -21
- package/dist/chunk-TVJQAYQM.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/intelligence.d.ts +1 -1
- package/dist/intelligence.js +1 -1
- package/dist/{prepare-DIeVgQG3.d.ts → prepare-CtdtsFNG.d.ts} +18 -14
- package/package.json +3 -3
- package/dist/chunk-37V4KQDC.js.map +0 -1
- package/dist/chunk-FTXM7Q7P.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CodeSurface } from '@tangle-network/agent-eval/campaign';
|
|
2
2
|
import { AgentCandidateCodeDisabled, AgentCandidateCodeNoOp, AgentCandidateGitHubRepository, AgentProfile, AgentProfileDiff, AgentCandidateProfile, AgentCandidateExecution, AgentCandidateKnowledge, AgentCandidateMemoryPolicy, AgentCandidateLineage, Sha256Digest, AgentCandidateArtifactRef, AgentCandidateWorkspaceSnapshotEvidence } from '@tangle-network/agent-interface';
|
|
3
|
-
import {
|
|
4
|
-
export { d as AgentCandidateArtifactPort, e as AgentCandidateBenchmarkGraderIdentity, f as AgentCandidateBenchmarkGraderPort, A as AgentCandidateBundleInput, g as AgentCandidateContainerPort, m as AgentCandidateExecutionCleanupHandles, n as AgentCandidateExecutionFailureClass, q as AgentCandidateExecutionPhase, u as AgentCandidateExecutionTerminalRecord, w as AgentCandidateExecutionUsage, x as AgentCandidateExecutorFinalCapture, y as AgentCandidateExecutorMemoryCapture, B as AgentCandidateExecutorProfileFile, C as AgentCandidateExecutorRequest, D as AgentCandidateExecutorStopRequest, F as AgentCandidateExecutorTaskOutcomeCapture, H as AgentCandidateExecutorWorkspaceInput, I as AgentCandidateMemoryPort, J as AgentCandidateMemoryResetResult, K as AgentCandidateModelLimits, Q as AgentCandidateProtectedModelCall, T as AgentCandidateProtectedRunCapture, U as AgentCandidateRepositoryPort, V as AgentCandidateRetryRejection, c as AgentCandidateRunFinalization, a as AgentCandidateTaskExecution, Y as CANDIDATE_TRACE_ENV, Z as CANDIDATE_TRACE_TAGS, _ as CanonicalCandidateDocument, E as ExecutePreparedAgentCandidateOptions, $ as InMemoryAgentCandidateExecutionClaimStore, P as PrepareAgentCandidateExecutionOptions, a1 as PreparedAgentCandidateInstruction, a2 as
|
|
3
|
+
import { aa as sealAgentCandidateBundle, a0 as PreparedAgentCandidateExecution, j as AgentCandidateExecutionClaim, l as AgentCandidateExecutionClaimStore, k as AgentCandidateExecutionClaimResult, i as AgentCandidateExecutionAttemptRef, h as AgentCandidateExecutionAttemptRecord, p as AgentCandidateExecutionLease, r as AgentCandidateExecutionPhaseResult, v as AgentCandidateExecutionTerminalResult, t as AgentCandidateExecutionStageResult, o as AgentCandidateExecutionFinishResult, s as AgentCandidateExecutionRecoveryEvidence, M as AgentCandidateOutputArtifactPort, N as AgentCandidateOutputPurpose, L as AgentCandidateModelPort, R as AgentCandidateProtectedModelReservation, O as AgentCandidateProtectedModelActivation, S as AgentCandidateProtectedModelSettlement, z as AgentCandidateExecutorPort, b as AgentCandidateExecutionPorts, W as AgentCandidateVerificationPorts, a6 as VerifiedAgentCandidate, G as AgentCandidateExecutorWorkspaceFile, X as AgentCandidateWorkspacePort } from '../prepare-CtdtsFNG.js';
|
|
4
|
+
export { d as AgentCandidateArtifactPort, e as AgentCandidateBenchmarkGraderIdentity, f as AgentCandidateBenchmarkGraderPort, A as AgentCandidateBundleInput, g as AgentCandidateContainerPort, m as AgentCandidateExecutionCleanupHandles, n as AgentCandidateExecutionFailureClass, q as AgentCandidateExecutionPhase, u as AgentCandidateExecutionTerminalRecord, w as AgentCandidateExecutionUsage, x as AgentCandidateExecutorFinalCapture, y as AgentCandidateExecutorMemoryCapture, B as AgentCandidateExecutorProfileFile, C as AgentCandidateExecutorRequest, D as AgentCandidateExecutorStopRequest, F as AgentCandidateExecutorTaskOutcomeCapture, H as AgentCandidateExecutorWorkspaceInput, I as AgentCandidateMemoryPort, J as AgentCandidateMemoryResetResult, K as AgentCandidateModelLimits, Q as AgentCandidateProtectedModelCall, T as AgentCandidateProtectedRunCapture, U as AgentCandidateRepositoryPort, V as AgentCandidateRetryRejection, c as AgentCandidateRunFinalization, a as AgentCandidateTaskExecution, Y as CANDIDATE_TRACE_ENV, Z as CANDIDATE_TRACE_TAGS, _ as CanonicalCandidateDocument, E as ExecutePreparedAgentCandidateOptions, $ as InMemoryAgentCandidateExecutionClaimStore, P as PrepareAgentCandidateExecutionOptions, a1 as PreparedAgentCandidateInstruction, a2 as PreparedAgentCandidateKnowledge, a3 as PreparedAgentCandidateLaunch, a4 as PreparedAgentCandidateTrace, a5 as ResolvedAgentCandidateContainer, a7 as VerifiedAgentCandidateTaskOutcome, a8 as executePreparedAgentCandidate, a9 as prepareAgentCandidateExecution } from '../prepare-CtdtsFNG.js';
|
|
5
5
|
import { TraceStore } from '@tangle-network/agent-eval';
|
|
6
6
|
|
|
7
7
|
/** A complete profile that can be frozen without losing behavior. */
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
createProtectedAgentCandidateModelPort,
|
|
8
8
|
disposePreparedAgentCandidateExecution,
|
|
9
9
|
recoverExpiredAgentCandidateExecution
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-TVJQAYQM.js";
|
|
11
11
|
import {
|
|
12
12
|
CANDIDATE_TRACE_ENV,
|
|
13
13
|
CANDIDATE_TRACE_TAGS,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
prepareAgentCandidateExecution,
|
|
22
22
|
sealAgentCandidateBundle,
|
|
23
23
|
verifyAgentCandidateBundle
|
|
24
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-CNH7DF7Z.js";
|
|
25
25
|
import "../chunk-WIPGQ4GT.js";
|
|
26
26
|
import "../chunk-3MDZX7YU.js";
|
|
27
27
|
import "../chunk-DGUM43GV.js";
|
|
@@ -1464,6 +1464,18 @@ async function readMaterializedWorkspaceFiles(root, expected, options = {}) {
|
|
|
1464
1464
|
(file) => Object.freeze({ path: file.path, mode: file.mode, bytes: Uint8Array.from(file.bytes) })
|
|
1465
1465
|
);
|
|
1466
1466
|
}
|
|
1467
|
+
function candidateWorkspaceManifest(files) {
|
|
1468
|
+
return {
|
|
1469
|
+
schemaVersion: 2,
|
|
1470
|
+
kind: "agent-candidate-workspace-manifest",
|
|
1471
|
+
files: files.map((file) => ({
|
|
1472
|
+
path: file.path,
|
|
1473
|
+
mode: file.mode,
|
|
1474
|
+
sha256: sha256Bytes(file.bytes),
|
|
1475
|
+
byteLength: file.bytes.byteLength
|
|
1476
|
+
})).sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0)
|
|
1477
|
+
};
|
|
1478
|
+
}
|
|
1467
1479
|
function assertWorkspaceManifest(observed, expected) {
|
|
1468
1480
|
if (!Buffer.from(canonicalCandidateBytes(observed)).equals(canonicalCandidateBytes(expected))) {
|
|
1469
1481
|
throw new Error(
|
|
@@ -1493,7 +1505,6 @@ async function scanWorkspace(root, ignoredProtectedRootEntries, limits) {
|
|
|
1493
1505
|
if (await realpath(absoluteRoot) !== absoluteRoot) {
|
|
1494
1506
|
throw new Error("workspace root has a symlinked path component");
|
|
1495
1507
|
}
|
|
1496
|
-
const files = [];
|
|
1497
1508
|
const capturedFiles = [];
|
|
1498
1509
|
let totalBytes = 0;
|
|
1499
1510
|
async function visit(directory) {
|
|
@@ -1519,7 +1530,7 @@ async function scanWorkspace(root, ignoredProtectedRootEntries, limits) {
|
|
|
1519
1530
|
if (!stats.isFile()) {
|
|
1520
1531
|
throw new Error(`workspace contains a non-regular entry: ${relPath}`);
|
|
1521
1532
|
}
|
|
1522
|
-
if (limits &&
|
|
1533
|
+
if (limits && capturedFiles.length >= limits.maxFiles) {
|
|
1523
1534
|
throw new Error("workspace exceeds maxFiles");
|
|
1524
1535
|
}
|
|
1525
1536
|
const descriptor = await open(
|
|
@@ -1535,9 +1546,6 @@ async function scanWorkspace(root, ignoredProtectedRootEntries, limits) {
|
|
|
1535
1546
|
throw new Error(`workspace contains a hard-linked file: ${relPath}`);
|
|
1536
1547
|
}
|
|
1537
1548
|
const mode = openedStats.mode & 511;
|
|
1538
|
-
if (mode !== 420 && mode !== 493) {
|
|
1539
|
-
throw new Error(`workspace file has unsupported mode ${mode.toString(8)}: ${relPath}`);
|
|
1540
|
-
}
|
|
1541
1549
|
if (limits && openedStats.size > limits.maxFileBytes) {
|
|
1542
1550
|
throw new Error(`workspace file exceeds maxFileBytes: ${relPath}`);
|
|
1543
1551
|
}
|
|
@@ -1551,28 +1559,15 @@ async function scanWorkspace(root, ignoredProtectedRootEntries, limits) {
|
|
|
1551
1559
|
relPath
|
|
1552
1560
|
);
|
|
1553
1561
|
totalBytes += bytes.byteLength;
|
|
1554
|
-
|
|
1555
|
-
files.push({
|
|
1556
|
-
path: relPath,
|
|
1557
|
-
mode: supportedMode,
|
|
1558
|
-
sha256: sha256Bytes(bytes),
|
|
1559
|
-
byteLength: bytes.byteLength
|
|
1560
|
-
});
|
|
1561
|
-
capturedFiles.push({ path: relPath, mode: supportedMode, bytes: Uint8Array.from(bytes) });
|
|
1562
|
+
capturedFiles.push({ path: relPath, mode, bytes: Uint8Array.from(bytes) });
|
|
1562
1563
|
} finally {
|
|
1563
1564
|
await descriptor.close();
|
|
1564
1565
|
}
|
|
1565
1566
|
}
|
|
1566
1567
|
}
|
|
1567
1568
|
await visit(absoluteRoot);
|
|
1568
|
-
files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
1569
|
-
capturedFiles.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
1570
1569
|
return {
|
|
1571
|
-
manifest:
|
|
1572
|
-
schemaVersion: 1,
|
|
1573
|
-
kind: "agent-candidate-workspace-manifest",
|
|
1574
|
-
files
|
|
1575
|
-
},
|
|
1570
|
+
manifest: candidateWorkspaceManifest(capturedFiles),
|
|
1576
1571
|
files: capturedFiles
|
|
1577
1572
|
};
|
|
1578
1573
|
}
|
|
@@ -1797,19 +1792,9 @@ async function assertSafeTree(repositoryRoot, tree, environment = {}) {
|
|
|
1797
1792
|
}
|
|
1798
1793
|
}
|
|
1799
1794
|
async function workspaceManifestFromGitTree(repositoryRoot, tree, environment) {
|
|
1800
|
-
|
|
1801
|
-
(
|
|
1802
|
-
path,
|
|
1803
|
-
mode,
|
|
1804
|
-
sha256: sha256Bytes(bytes),
|
|
1805
|
-
byteLength: bytes.byteLength
|
|
1806
|
-
})
|
|
1795
|
+
return candidateWorkspaceManifest(
|
|
1796
|
+
await readCandidateGitTreeFiles(repositoryRoot, tree, environment)
|
|
1807
1797
|
);
|
|
1808
|
-
return {
|
|
1809
|
-
schemaVersion: 1,
|
|
1810
|
-
kind: "agent-candidate-workspace-manifest",
|
|
1811
|
-
files
|
|
1812
|
-
};
|
|
1813
1798
|
}
|
|
1814
1799
|
async function readCandidateGitTreeFiles(repositoryRoot, tree, environment = {}, limits) {
|
|
1815
1800
|
const listing = (await runCandidateGit(
|
|
@@ -1951,6 +1936,14 @@ function isNoEntry(error) {
|
|
|
1951
1936
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
1952
1937
|
}
|
|
1953
1938
|
|
|
1939
|
+
// src/candidate-execution/workspace-task.ts
|
|
1940
|
+
function workspaceTaskRepository(task) {
|
|
1941
|
+
if (task.outcome.kind !== "workspace" || !task.repository) {
|
|
1942
|
+
throw new Error("candidate runtime requires a workspace outcome with repository provenance");
|
|
1943
|
+
}
|
|
1944
|
+
return task.repository;
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1954
1947
|
// src/candidate-execution/prepared-state.ts
|
|
1955
1948
|
var stateByExecution = /* @__PURE__ */ new WeakMap();
|
|
1956
1949
|
var lifecycleByExecution = /* @__PURE__ */ new WeakMap();
|
|
@@ -2058,7 +2051,7 @@ async function assertPreparedCandidateWorkspaces(state) {
|
|
|
2058
2051
|
await verifyMaterializedWorkspace(state.roots.staging.taskRoot, plan.task.workspace.material, {
|
|
2059
2052
|
ignoredProtectedRootEntries: [".git", ".sidecar"]
|
|
2060
2053
|
});
|
|
2061
|
-
await verifyTaskCheckout(state.roots.staging.taskRoot, plan.task
|
|
2054
|
+
await verifyTaskCheckout(state.roots.staging.taskRoot, workspaceTaskRepository(plan.task));
|
|
2062
2055
|
await verifyMaterializedProfileWorkspace(
|
|
2063
2056
|
state.roots.staging.profileRoot,
|
|
2064
2057
|
state.profilePlan.value.material
|
|
@@ -2125,9 +2118,10 @@ function detachPreparedCandidateState(input) {
|
|
|
2125
2118
|
...input.memoryReservation ? { memoryReservation: immutableCandidateValue(input.memoryReservation) } : {},
|
|
2126
2119
|
...input.knowledge ? {
|
|
2127
2120
|
knowledge: Object.freeze({
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2121
|
+
candidate: immutableCandidateValue(input.knowledge.candidate),
|
|
2122
|
+
snapshot: immutableCandidateValue(input.knowledge.snapshot),
|
|
2123
|
+
files: immutableExecutorFiles(input.knowledge.files),
|
|
2124
|
+
...input.knowledge.retrievalConfig ? { retrievalConfig: Uint8Array.from(input.knowledge.retrievalConfig) } : {}
|
|
2131
2125
|
})
|
|
2132
2126
|
} : {},
|
|
2133
2127
|
trace: immutableCandidateValue(input.trace),
|
|
@@ -2157,6 +2151,7 @@ function assertPrivateCandidateIntegrity(state) {
|
|
|
2157
2151
|
throw new Error("prepared model access no longer matches the signed execution plan");
|
|
2158
2152
|
}
|
|
2159
2153
|
assertExecutorInputs(state);
|
|
2154
|
+
assertPreparedKnowledge(state);
|
|
2160
2155
|
if (state.memory.mode === "isolated" && !state.memoryReservation || state.memory.mode === "disabled" && state.memoryReservation) {
|
|
2161
2156
|
throw new Error("prepared memory reservation does not match the signed execution plan");
|
|
2162
2157
|
}
|
|
@@ -2210,13 +2205,16 @@ function bytesView(value, key) {
|
|
|
2210
2205
|
});
|
|
2211
2206
|
}
|
|
2212
2207
|
function knowledgeView(knowledge) {
|
|
2213
|
-
const
|
|
2208
|
+
const retrievalConfig = knowledge.retrievalConfig ? Uint8Array.from(knowledge.retrievalConfig) : void 0;
|
|
2214
2209
|
return Object.freeze({
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2210
|
+
candidate: knowledge.candidate,
|
|
2211
|
+
snapshot: knowledge.snapshot,
|
|
2212
|
+
files: Object.freeze(knowledge.files.map((file) => profileFileView(file))),
|
|
2213
|
+
...retrievalConfig ? {
|
|
2214
|
+
get retrievalConfig() {
|
|
2215
|
+
return Uint8Array.from(retrievalConfig);
|
|
2216
|
+
}
|
|
2217
|
+
} : {}
|
|
2220
2218
|
});
|
|
2221
2219
|
}
|
|
2222
2220
|
function workspaceInputView(snapshot, sourceFiles) {
|
|
@@ -2261,6 +2259,28 @@ function assertExecutorInputs(state) {
|
|
|
2261
2259
|
}
|
|
2262
2260
|
}
|
|
2263
2261
|
}
|
|
2262
|
+
function assertPreparedKnowledge(state) {
|
|
2263
|
+
const expected = state.bundle.knowledge;
|
|
2264
|
+
const actual = state.knowledge;
|
|
2265
|
+
if (!expected || !actual) {
|
|
2266
|
+
if (expected || actual)
|
|
2267
|
+
throw new Error("prepared knowledge does not match the candidate bundle");
|
|
2268
|
+
return;
|
|
2269
|
+
}
|
|
2270
|
+
if (canonicalCandidateDigest(actual.candidate) !== canonicalCandidateDigest(expected.candidate) || canonicalCandidateDigest(actual.snapshot) !== canonicalCandidateDigest(expected.snapshot) || state.executionPlan.value.material.knowledgeManifestDigest !== expected.snapshot.digest) {
|
|
2271
|
+
throw new Error("prepared knowledge identity does not match the candidate bundle");
|
|
2272
|
+
}
|
|
2273
|
+
assertWorkspaceExecutorFiles(actual.files, expected.snapshot.material);
|
|
2274
|
+
if (!expected.retrievalConfig || !actual.retrievalConfig) {
|
|
2275
|
+
if (expected.retrievalConfig || actual.retrievalConfig) {
|
|
2276
|
+
throw new Error("prepared knowledge retrieval config does not match the candidate bundle");
|
|
2277
|
+
}
|
|
2278
|
+
return;
|
|
2279
|
+
}
|
|
2280
|
+
if (actual.retrievalConfig.byteLength !== expected.retrievalConfig.byteLength || sha256Bytes(actual.retrievalConfig) !== expected.retrievalConfig.sha256) {
|
|
2281
|
+
throw new Error("prepared knowledge retrieval config does not match the candidate bundle");
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2264
2284
|
function assertWorkspaceExecutorFiles(actualFiles, expected) {
|
|
2265
2285
|
if (actualFiles.length !== expected.files.length) {
|
|
2266
2286
|
throw new Error("prepared workspace executor files do not match the signed manifest");
|
|
@@ -2452,6 +2472,18 @@ function sealAgentCandidateExecutorFinalCapture(value) {
|
|
|
2452
2472
|
...memoryAfter ? { memoryAfter: Object.freeze(memoryAfter) } : {}
|
|
2453
2473
|
});
|
|
2454
2474
|
}
|
|
2475
|
+
function encodeAgentCandidateExecutorCapture(input) {
|
|
2476
|
+
return canonicalCandidateBytes({
|
|
2477
|
+
schemaVersion: 1,
|
|
2478
|
+
kind: "agent-candidate-executor-capture",
|
|
2479
|
+
executionId: input.executionId,
|
|
2480
|
+
executionPlanDigest: input.executionPlanDigest,
|
|
2481
|
+
termination: input.termination,
|
|
2482
|
+
stopped: true,
|
|
2483
|
+
taskOutcome: input.taskOutcome,
|
|
2484
|
+
...input.memoryAfter ? { memoryAfter: input.memoryAfter } : {}
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2455
2487
|
function sealMemoryCapture(value) {
|
|
2456
2488
|
const capture = requireRecord(value, "candidate memory capture");
|
|
2457
2489
|
assertExactObjectKeys(capture, ["afterState", "archive"], "candidate memory capture");
|
|
@@ -2498,7 +2530,7 @@ import { mkdtemp as mkdtemp2, rm as rm2 } from "fs/promises";
|
|
|
2498
2530
|
import { tmpdir as tmpdir2 } from "os";
|
|
2499
2531
|
import { join as join2 } from "path";
|
|
2500
2532
|
import { isLlmSpan as isLlmSpan2, REDACTION_VERSION as REDACTION_VERSION2 } from "@tangle-network/agent-eval";
|
|
2501
|
-
import {
|
|
2533
|
+
import { agentCandidateRunReceiptSchema } from "@tangle-network/agent-interface";
|
|
2502
2534
|
|
|
2503
2535
|
// src/candidate-execution/model-settlement.ts
|
|
2504
2536
|
import { isLlmSpan } from "@tangle-network/agent-eval";
|
|
@@ -2883,7 +2915,7 @@ function provisionalCandidateWorkspaceSnapshot(materialInput, archive) {
|
|
|
2883
2915
|
);
|
|
2884
2916
|
const manifestBytes = canonicalCandidateBytes(material);
|
|
2885
2917
|
const snapshot = Object.freeze({
|
|
2886
|
-
schemaVersion:
|
|
2918
|
+
schemaVersion: 2,
|
|
2887
2919
|
kind: "agent-candidate-workspace-snapshot",
|
|
2888
2920
|
digest: sha256Bytes(manifestBytes),
|
|
2889
2921
|
material,
|
|
@@ -2912,7 +2944,7 @@ async function persistCandidateWorkspaceSnapshot(port, input) {
|
|
|
2912
2944
|
]);
|
|
2913
2945
|
return immutableCandidateValue(
|
|
2914
2946
|
agentCandidateWorkspaceSnapshotEvidenceSchema.parse({
|
|
2915
|
-
schemaVersion:
|
|
2947
|
+
schemaVersion: 2,
|
|
2916
2948
|
kind: "agent-candidate-workspace-snapshot",
|
|
2917
2949
|
digest: sha256Bytes(manifestBytes),
|
|
2918
2950
|
material,
|
|
@@ -2961,7 +2993,6 @@ async function finalizeAgentCandidateRun(state, capture, traceStore, settlement,
|
|
|
2961
2993
|
);
|
|
2962
2994
|
const modelSpans = orderedSpans.filter(isLlmSpan2);
|
|
2963
2995
|
assertTraceMatchesModelSettlement(modelSpans, settlement);
|
|
2964
|
-
const usage = settlement.usage;
|
|
2965
2996
|
enforceLimits(state, run.startedAt, run.endedAt, orderedSpans, settlement);
|
|
2966
2997
|
const finalCapture = sealAgentCandidateExecutorFinalCapture(evidence.finalCapture);
|
|
2967
2998
|
const memory = await memoryReceipt(
|
|
@@ -2971,6 +3002,20 @@ async function finalizeAgentCandidateRun(state, capture, traceStore, settlement,
|
|
|
2971
3002
|
protectedValues,
|
|
2972
3003
|
signal
|
|
2973
3004
|
);
|
|
3005
|
+
const executorCaptureBytes = encodeAgentCandidateExecutorCapture({
|
|
3006
|
+
executionId: protectedCapture.executionId,
|
|
3007
|
+
executionPlanDigest: state.executionPlan.value.digest,
|
|
3008
|
+
termination: protectedCapture.termination,
|
|
3009
|
+
taskOutcome: evidence.taskOutcome.evidence,
|
|
3010
|
+
...memory.mode === "isolated" ? { memoryAfter: memory.afterState } : {}
|
|
3011
|
+
});
|
|
3012
|
+
assertNoProtectedBytes(executorCaptureBytes, protectedValues);
|
|
3013
|
+
const executorCapture = await persistCandidateOutputArtifact(evidence.outputArtifacts, {
|
|
3014
|
+
executionId: state.executionId,
|
|
3015
|
+
purpose: "executor-capture",
|
|
3016
|
+
bytes: executorCaptureBytes,
|
|
3017
|
+
signal
|
|
3018
|
+
});
|
|
2974
3019
|
const redacted = redactProtectedValue(
|
|
2975
3020
|
{
|
|
2976
3021
|
schemaVersion: 1,
|
|
@@ -3010,23 +3055,21 @@ async function finalizeAgentCandidateRun(state, capture, traceStore, settlement,
|
|
|
3010
3055
|
modelCallCount: modelSpans.length
|
|
3011
3056
|
};
|
|
3012
3057
|
const document = canonicalCandidateDocument({
|
|
3013
|
-
schemaVersion:
|
|
3058
|
+
schemaVersion: 3,
|
|
3014
3059
|
kind: "agent-candidate-run",
|
|
3015
3060
|
digestAlgorithm: "rfc8785-sha256",
|
|
3016
3061
|
bundleDigest: state.bundle.digest,
|
|
3017
3062
|
materializationReceiptDigest: state.materializationReceipt.digest,
|
|
3018
3063
|
executionPlanDigest: state.executionPlan.value.digest,
|
|
3019
3064
|
memory,
|
|
3020
|
-
usage,
|
|
3021
|
-
modelUsage: { resolved: state.resolvedModel, usage },
|
|
3022
3065
|
trace,
|
|
3023
3066
|
termination,
|
|
3024
|
-
|
|
3067
|
+
executorCapture,
|
|
3025
3068
|
modelSettlement: evidence.modelSettlement,
|
|
3026
3069
|
taskOutcome: evidence.taskOutcome.evidence,
|
|
3027
3070
|
benchmarkResult: evidence.benchmarkResult
|
|
3028
3071
|
});
|
|
3029
|
-
|
|
3072
|
+
agentCandidateRunReceiptSchema.parse(document.value);
|
|
3030
3073
|
const runReceipt = await persistCandidateOutputArtifact(evidence.outputArtifacts, {
|
|
3031
3074
|
executionId: state.executionId,
|
|
3032
3075
|
purpose: "run-receipt",
|
|
@@ -3037,6 +3080,7 @@ async function finalizeAgentCandidateRun(state, capture, traceStore, settlement,
|
|
|
3037
3080
|
succeeded: true,
|
|
3038
3081
|
receipt: document,
|
|
3039
3082
|
artifacts: {
|
|
3083
|
+
executorCapture,
|
|
3040
3084
|
modelSettlement: evidence.modelSettlement.artifact,
|
|
3041
3085
|
taskOutcome: evidence.taskOutcome.evidence.artifact,
|
|
3042
3086
|
benchmarkResult: evidence.benchmarkResult.artifact,
|
|
@@ -3288,7 +3332,7 @@ async function persistCandidateModelSettlementEvidence(identity, settlement, out
|
|
|
3288
3332
|
});
|
|
3289
3333
|
return immutableCandidateValue(
|
|
3290
3334
|
agentCandidateModelSettlementEvidenceSchema.parse({
|
|
3291
|
-
schemaVersion:
|
|
3335
|
+
schemaVersion: 2,
|
|
3292
3336
|
kind: "agent-candidate-model-settlement",
|
|
3293
3337
|
digest,
|
|
3294
3338
|
material,
|
|
@@ -3305,7 +3349,7 @@ async function persistVerifiedCandidateTaskOutcome(state, capture, outputArtifac
|
|
|
3305
3349
|
assertNoProtectedBytes(archive, protectedValues);
|
|
3306
3350
|
const provisional = provisionalCandidateWorkspaceSnapshot(capture.afterState, archive);
|
|
3307
3351
|
const afterState = provisional.material;
|
|
3308
|
-
const repository = state.executionPlan.value.material.task
|
|
3352
|
+
const repository = workspaceTaskRepository(state.executionPlan.value.material.task);
|
|
3309
3353
|
const verified = await verifyTaskOutcomePatch({
|
|
3310
3354
|
repositoryRoot: state.roots.staging.taskRoot,
|
|
3311
3355
|
baseCommit: repository.baseCommit,
|
|
@@ -3332,25 +3376,28 @@ async function persistVerifiedCandidateTaskOutcome(state, capture, outputArtifac
|
|
|
3332
3376
|
signal
|
|
3333
3377
|
});
|
|
3334
3378
|
const material = {
|
|
3335
|
-
schemaVersion:
|
|
3379
|
+
schemaVersion: 2,
|
|
3336
3380
|
kind: "agent-candidate-task-outcome-material",
|
|
3337
3381
|
executionPlanDigest: state.executionPlan.value.digest,
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3382
|
+
outcome: {
|
|
3383
|
+
kind: "workspace",
|
|
3384
|
+
baseRepository: {
|
|
3385
|
+
identity: repository.identity,
|
|
3386
|
+
rootIdentity: repository.rootIdentity,
|
|
3387
|
+
commit: repository.baseCommit,
|
|
3388
|
+
tree: repository.baseTree
|
|
3389
|
+
},
|
|
3390
|
+
resultRepository: {
|
|
3391
|
+
identity: repository.identity,
|
|
3392
|
+
rootIdentity: repository.rootIdentity,
|
|
3393
|
+
commit: verified.resultCommit,
|
|
3394
|
+
tree: verified.resultTree
|
|
3395
|
+
},
|
|
3396
|
+
afterState: snapshot,
|
|
3397
|
+
gitDiff: {
|
|
3398
|
+
format: "git-diff-binary",
|
|
3399
|
+
artifact: gitDiff
|
|
3400
|
+
}
|
|
3354
3401
|
}
|
|
3355
3402
|
};
|
|
3356
3403
|
const bytes = canonicalCandidateBytes(material);
|
|
@@ -3363,7 +3410,7 @@ async function persistVerifiedCandidateTaskOutcome(state, capture, outputArtifac
|
|
|
3363
3410
|
});
|
|
3364
3411
|
const evidence = immutableCandidateValue(
|
|
3365
3412
|
agentCandidateTaskOutcomeEvidenceSchema.parse({
|
|
3366
|
-
schemaVersion:
|
|
3413
|
+
schemaVersion: 2,
|
|
3367
3414
|
kind: "agent-candidate-task-outcome",
|
|
3368
3415
|
digest,
|
|
3369
3416
|
material,
|
|
@@ -4345,7 +4392,16 @@ async function verifyAgentCandidateBundle(input, ports) {
|
|
|
4345
4392
|
artifactBytes.set(artifactCacheKey(parsed.execution.workspace.manifest), workspace.manifest);
|
|
4346
4393
|
artifactBytes.set(artifactCacheKey(parsed.execution.workspace.archive), workspace.archive);
|
|
4347
4394
|
}
|
|
4348
|
-
if (parsed.knowledge)
|
|
4395
|
+
if (parsed.knowledge) {
|
|
4396
|
+
const knowledge = await verifyWorkspaceSnapshotArtifacts(
|
|
4397
|
+
parsed.knowledge.snapshot,
|
|
4398
|
+
ports.artifacts
|
|
4399
|
+
);
|
|
4400
|
+
artifactBytes.set(artifactCacheKey(parsed.knowledge.snapshot.manifest), knowledge.manifest);
|
|
4401
|
+
artifactBytes.set(artifactCacheKey(parsed.knowledge.snapshot.archive), knowledge.archive);
|
|
4402
|
+
if (parsed.knowledge.retrievalConfig) await readArtifact(parsed.knowledge.retrievalConfig);
|
|
4403
|
+
await readArtifact(parsed.knowledge.evaluation);
|
|
4404
|
+
}
|
|
4349
4405
|
if (parsed.memory.mode === "isolated" && parsed.memory.seed)
|
|
4350
4406
|
await readArtifact(parsed.memory.seed);
|
|
4351
4407
|
deepFreezeCandidate(parsed);
|
|
@@ -4416,6 +4472,41 @@ import {
|
|
|
4416
4472
|
applyAgentCandidateWorkspacePlan,
|
|
4417
4473
|
materializeCandidateProfile
|
|
4418
4474
|
} from "@tangle-network/agent-profile-materialize";
|
|
4475
|
+
|
|
4476
|
+
// src/candidate-execution/knowledge.ts
|
|
4477
|
+
import { mkdtemp as mkdtemp4, rm as rm4 } from "fs/promises";
|
|
4478
|
+
import { tmpdir as tmpdir4 } from "os";
|
|
4479
|
+
import { join as join4 } from "path";
|
|
4480
|
+
async function prepareAgentCandidateKnowledge(candidate, ports) {
|
|
4481
|
+
const knowledge = candidate.bundle.knowledge;
|
|
4482
|
+
if (!knowledge) return void 0;
|
|
4483
|
+
const archive = await verifiedArtifactBytes(candidate, knowledge.snapshot.archive);
|
|
4484
|
+
const retrievalConfig = knowledge.retrievalConfig ? await verifiedArtifactBytes(candidate, knowledge.retrievalConfig) : void 0;
|
|
4485
|
+
const root = await mkdtemp4(join4(tmpdir4(), "agent-candidate-knowledge-"));
|
|
4486
|
+
try {
|
|
4487
|
+
await ports.workspaces.materialize({
|
|
4488
|
+
role: "knowledge",
|
|
4489
|
+
snapshot: knowledge.snapshot,
|
|
4490
|
+
archive,
|
|
4491
|
+
destination: root
|
|
4492
|
+
});
|
|
4493
|
+
const files = await readMaterializedWorkspaceFiles(root, knowledge.snapshot.material);
|
|
4494
|
+
return Object.freeze({
|
|
4495
|
+
candidate: knowledge.candidate,
|
|
4496
|
+
snapshot: knowledge.snapshot,
|
|
4497
|
+
files: Object.freeze(
|
|
4498
|
+
files.map(
|
|
4499
|
+
(file) => Object.freeze({ path: file.path, mode: file.mode, bytes: Uint8Array.from(file.bytes) })
|
|
4500
|
+
)
|
|
4501
|
+
),
|
|
4502
|
+
...retrievalConfig ? { retrievalConfig: Uint8Array.from(retrievalConfig) } : {}
|
|
4503
|
+
});
|
|
4504
|
+
} finally {
|
|
4505
|
+
await rm4(root, { recursive: true, force: true });
|
|
4506
|
+
}
|
|
4507
|
+
}
|
|
4508
|
+
|
|
4509
|
+
// src/candidate-execution/prepare.ts
|
|
4419
4510
|
var MATERIALIZER_HARNESSES = /* @__PURE__ */ new Set([
|
|
4420
4511
|
"claude-code",
|
|
4421
4512
|
"claude",
|
|
@@ -4549,11 +4640,7 @@ async function prepareAgentCandidateExecution(candidate, task, ports, options =
|
|
|
4549
4640
|
cleanupTimeoutMs
|
|
4550
4641
|
);
|
|
4551
4642
|
const memory = preparedMemory.value;
|
|
4552
|
-
const knowledge =
|
|
4553
|
-
snapshotId: bundle.knowledge.snapshotId,
|
|
4554
|
-
manifestDigest: bundle.knowledge.manifest.sha256,
|
|
4555
|
-
manifest: await verifiedArtifactBytes(candidate, bundle.knowledge.manifest)
|
|
4556
|
-
} : void 0;
|
|
4643
|
+
const knowledge = await prepareAgentCandidateKnowledge(candidate, ports);
|
|
4557
4644
|
const baseLaunch = buildLaunch(candidate, task, profileApplication.flags);
|
|
4558
4645
|
const publicEnv = mergePublicEnvironment(
|
|
4559
4646
|
bundle.execution.env ?? {},
|
|
@@ -4567,7 +4654,7 @@ async function prepareAgentCandidateExecution(candidate, task, ports, options =
|
|
|
4567
4654
|
);
|
|
4568
4655
|
const routes = modelRoutes(bundle.profile, task.model.requested);
|
|
4569
4656
|
const executionMaterial = {
|
|
4570
|
-
schemaVersion:
|
|
4657
|
+
schemaVersion: 2,
|
|
4571
4658
|
kind: "agent-candidate-execution-plan-material",
|
|
4572
4659
|
bundleDigest: bundle.digest,
|
|
4573
4660
|
executionId: task.executionId,
|
|
@@ -4584,6 +4671,7 @@ async function prepareAgentCandidateExecution(candidate, task, ports, options =
|
|
|
4584
4671
|
delivery: bundle.execution.instructionDelivery
|
|
4585
4672
|
},
|
|
4586
4673
|
repository: task.repository,
|
|
4674
|
+
outcome: { kind: "workspace" },
|
|
4587
4675
|
workspace: task.workspace
|
|
4588
4676
|
},
|
|
4589
4677
|
workspaces: {
|
|
@@ -4613,7 +4701,7 @@ async function prepareAgentCandidateExecution(candidate, task, ports, options =
|
|
|
4613
4701
|
env: publicEnv,
|
|
4614
4702
|
cwd: bundle.execution.cwd
|
|
4615
4703
|
},
|
|
4616
|
-
...bundle.knowledge ? { knowledgeManifestDigest: bundle.knowledge.
|
|
4704
|
+
...bundle.knowledge ? { knowledgeManifestDigest: bundle.knowledge.snapshot.digest } : {},
|
|
4617
4705
|
memory,
|
|
4618
4706
|
limits: task.limits,
|
|
4619
4707
|
network: { mode: "disabled" }
|
|
@@ -4625,7 +4713,7 @@ async function prepareAgentCandidateExecution(candidate, task, ports, options =
|
|
|
4625
4713
|
throw new Error("execution plan canonical serializers disagree");
|
|
4626
4714
|
}
|
|
4627
4715
|
const executionPlan = agentCandidateExecutionPlanEvidenceSchema2.parse({
|
|
4628
|
-
schemaVersion:
|
|
4716
|
+
schemaVersion: 2,
|
|
4629
4717
|
kind: "agent-candidate-execution-plan",
|
|
4630
4718
|
digest: executionDigest,
|
|
4631
4719
|
material: executionMaterial,
|
|
@@ -4634,7 +4722,7 @@ async function prepareAgentCandidateExecution(candidate, task, ports, options =
|
|
|
4634
4722
|
const entrypoint = candidateEntrypointReceipt(candidate);
|
|
4635
4723
|
const materializationReceipt = canonicalCandidateDocument(
|
|
4636
4724
|
{
|
|
4637
|
-
schemaVersion:
|
|
4725
|
+
schemaVersion: 2,
|
|
4638
4726
|
kind: "agent-candidate-materialization",
|
|
4639
4727
|
digestAlgorithm: "rfc8785-sha256",
|
|
4640
4728
|
bundleDigest: bundle.digest,
|
|
@@ -4647,7 +4735,7 @@ async function prepareAgentCandidateExecution(candidate, task, ports, options =
|
|
|
4647
4735
|
harnessVersion: bundle.execution.harnessVersion,
|
|
4648
4736
|
container,
|
|
4649
4737
|
resolvedModel,
|
|
4650
|
-
...bundle.knowledge ? { knowledgeManifestDigest: bundle.knowledge.
|
|
4738
|
+
...bundle.knowledge ? { knowledgeManifestDigest: bundle.knowledge.snapshot.digest } : {},
|
|
4651
4739
|
...entrypoint ? { entrypoint } : {}
|
|
4652
4740
|
}
|
|
4653
4741
|
);
|
|
@@ -5119,7 +5207,7 @@ function exactProfileExecutorFiles(sourceFiles, expectedFiles) {
|
|
|
5119
5207
|
const source = byPath.get(expected.relPath);
|
|
5120
5208
|
const mode = source?.mode ?? 420;
|
|
5121
5209
|
const bytes = Buffer.from(source?.content ?? "", "utf8");
|
|
5122
|
-
if (!source || mode
|
|
5210
|
+
if (!source || !Number.isInteger(mode) || mode < 0 || mode > 511 || mode !== expected.mode || sha256Bytes(bytes) !== expected.contentSha256) {
|
|
5123
5211
|
throw new Error("profile source files do not match the signed profile plan");
|
|
5124
5212
|
}
|
|
5125
5213
|
return { path: expected.relPath, mode, bytes: Uint8Array.from(bytes) };
|
|
@@ -5179,6 +5267,7 @@ export {
|
|
|
5179
5267
|
verifyBytes,
|
|
5180
5268
|
verifyMaterializedWorkspace,
|
|
5181
5269
|
captureMaterializedWorkspace,
|
|
5270
|
+
candidateWorkspaceManifest,
|
|
5182
5271
|
assertNoGitIndirection,
|
|
5183
5272
|
readCandidateGitTreeFiles,
|
|
5184
5273
|
runCandidateGit,
|
|
@@ -5200,4 +5289,4 @@ export {
|
|
|
5200
5289
|
verifyAgentCandidateBundle,
|
|
5201
5290
|
prepareAgentCandidateExecution
|
|
5202
5291
|
};
|
|
5203
|
-
//# sourceMappingURL=chunk-
|
|
5292
|
+
//# sourceMappingURL=chunk-CNH7DF7Z.js.map
|