@tangle-network/agent-runtime 0.94.8 → 0.94.9

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.
@@ -7,7 +7,7 @@ import {
7
7
  createProtectedAgentCandidateModelPort,
8
8
  disposePreparedAgentCandidateExecution,
9
9
  recoverExpiredAgentCandidateExecution
10
- } from "../chunk-5BT2NMML.js";
10
+ } from "../chunk-FTXM7Q7P.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-HKMKUESZ.js";
24
+ } from "../chunk-37V4KQDC.js";
25
25
  import "../chunk-WIPGQ4GT.js";
26
26
  import "../chunk-3MDZX7YU.js";
27
27
  import "../chunk-DGUM43GV.js";
@@ -2498,10 +2498,7 @@ import { mkdtemp as mkdtemp2, rm as rm2 } from "fs/promises";
2498
2498
  import { tmpdir as tmpdir2 } from "os";
2499
2499
  import { join as join2 } from "path";
2500
2500
  import { isLlmSpan as isLlmSpan2, REDACTION_VERSION as REDACTION_VERSION2 } from "@tangle-network/agent-eval";
2501
- import {
2502
- agentCandidateRunReceiptV2Schema,
2503
- agentCandidateWorkspaceSnapshotEvidenceSchema
2504
- } from "@tangle-network/agent-interface";
2501
+ import { agentCandidateRunReceiptV2Schema } from "@tangle-network/agent-interface";
2505
2502
 
2506
2503
  // src/candidate-execution/model-settlement.ts
2507
2504
  import { isLlmSpan } from "@tangle-network/agent-eval";
@@ -2875,6 +2872,56 @@ function escapeRegularExpression(value) {
2875
2872
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2876
2873
  }
2877
2874
 
2875
+ // src/candidate-execution/workspace-snapshot.ts
2876
+ import {
2877
+ agentCandidateWorkspaceManifestMaterialSchema as agentCandidateWorkspaceManifestMaterialSchema2,
2878
+ agentCandidateWorkspaceSnapshotEvidenceSchema
2879
+ } from "@tangle-network/agent-interface";
2880
+ function provisionalCandidateWorkspaceSnapshot(materialInput, archive) {
2881
+ const material = immutableCandidateValue(
2882
+ agentCandidateWorkspaceManifestMaterialSchema2.parse(materialInput)
2883
+ );
2884
+ const manifestBytes = canonicalCandidateBytes(material);
2885
+ const snapshot = Object.freeze({
2886
+ schemaVersion: 1,
2887
+ kind: "agent-candidate-workspace-snapshot",
2888
+ digest: sha256Bytes(manifestBytes),
2889
+ material,
2890
+ manifest: Object.freeze(embeddedCandidateArtifact(manifestBytes)),
2891
+ archive: Object.freeze(embeddedCandidateArtifact(archive))
2892
+ });
2893
+ return Object.freeze({ material, manifestBytes, snapshot });
2894
+ }
2895
+ async function persistCandidateWorkspaceSnapshot(port, input) {
2896
+ input.signal?.throwIfAborted();
2897
+ const material = immutableCandidateValue(input.material);
2898
+ const manifestBytes = canonicalCandidateBytes(material);
2899
+ const [manifest, archive] = await Promise.all([
2900
+ persistCandidateOutputArtifact(port, {
2901
+ executionId: input.executionId,
2902
+ purpose: input.purpose === "task" ? "task-manifest" : "memory-after-manifest",
2903
+ bytes: manifestBytes,
2904
+ ...input.signal ? { signal: input.signal } : {}
2905
+ }),
2906
+ persistCandidateOutputArtifact(port, {
2907
+ executionId: input.executionId,
2908
+ purpose: input.purpose === "task" ? "task-archive" : "memory-after-archive",
2909
+ bytes: input.archive,
2910
+ ...input.signal ? { signal: input.signal } : {}
2911
+ })
2912
+ ]);
2913
+ return immutableCandidateValue(
2914
+ agentCandidateWorkspaceSnapshotEvidenceSchema.parse({
2915
+ schemaVersion: 1,
2916
+ kind: "agent-candidate-workspace-snapshot",
2917
+ digest: sha256Bytes(manifestBytes),
2918
+ material,
2919
+ manifest,
2920
+ archive
2921
+ })
2922
+ );
2923
+ }
2924
+
2878
2925
  // src/candidate-execution/finalize.ts
2879
2926
  async function finalizeAgentCandidateRun(state, capture, traceStore, settlement, evidence, protectedValues, writeRedactionReport, signal) {
2880
2927
  let termination;
@@ -3048,25 +3095,17 @@ async function memoryReceipt(state, capture, outputArtifacts, protectedValues, s
3048
3095
  return { mode: "disabled" };
3049
3096
  }
3050
3097
  if (!capture.memoryAfter) throw new Error("isolated memory is missing its protected after-state");
3051
- const afterState = capture.memoryAfter.afterState;
3052
3098
  const archive = Uint8Array.from(capture.memoryAfter.archive);
3053
3099
  if (archive.byteLength === 0) throw new Error("isolated memory archive cannot be empty");
3054
- const manifestBytes = canonicalCandidateBytes(afterState);
3055
- assertNoProtectedBytes(manifestBytes, protectedValues);
3100
+ const provisional = provisionalCandidateWorkspaceSnapshot(capture.memoryAfter.afterState, archive);
3101
+ const afterState = provisional.material;
3102
+ assertNoProtectedBytes(provisional.manifestBytes, protectedValues);
3056
3103
  assertNoProtectedBytes(archive, protectedValues);
3057
- const provisionalSnapshot = agentCandidateWorkspaceSnapshotEvidenceSchema.parse({
3058
- schemaVersion: 1,
3059
- kind: "agent-candidate-workspace-snapshot",
3060
- digest: sha256Bytes(manifestBytes),
3061
- material: afterState,
3062
- manifest: embeddedCandidateArtifact(manifestBytes),
3063
- archive: embeddedCandidateArtifact(archive)
3064
- });
3065
3104
  const root = await mkdtemp2(join2(tmpdir2(), "agent-candidate-memory-after-"));
3066
3105
  try {
3067
3106
  await state.ports.workspaces.materialize({
3068
3107
  role: "memory",
3069
- snapshot: provisionalSnapshot,
3108
+ snapshot: provisional.snapshot,
3070
3109
  archive: Uint8Array.from(archive),
3071
3110
  destination: root
3072
3111
  });
@@ -3076,27 +3115,12 @@ async function memoryReceipt(state, capture, outputArtifacts, protectedValues, s
3076
3115
  } finally {
3077
3116
  await rm2(root, { recursive: true, force: true });
3078
3117
  }
3079
- const [manifest, archiveRef] = await Promise.all([
3080
- persistCandidateOutputArtifact(outputArtifacts, {
3081
- executionId: state.executionId,
3082
- purpose: "memory-after-manifest",
3083
- bytes: manifestBytes,
3084
- signal
3085
- }),
3086
- persistCandidateOutputArtifact(outputArtifacts, {
3087
- executionId: state.executionId,
3088
- purpose: "memory-after-archive",
3089
- bytes: archive,
3090
- signal
3091
- })
3092
- ]);
3093
- const snapshot = agentCandidateWorkspaceSnapshotEvidenceSchema.parse({
3094
- schemaVersion: 1,
3095
- kind: "agent-candidate-workspace-snapshot",
3096
- digest: sha256Bytes(manifestBytes),
3118
+ const snapshot = await persistCandidateWorkspaceSnapshot(outputArtifacts, {
3119
+ executionId: state.executionId,
3097
3120
  material: afterState,
3098
- manifest,
3099
- archive: archiveRef
3121
+ archive,
3122
+ purpose: "memory-after",
3123
+ signal
3100
3124
  });
3101
3125
  return {
3102
3126
  mode: "isolated",
@@ -3132,8 +3156,7 @@ import { join as join3 } from "path";
3132
3156
  import {
3133
3157
  agentCandidateBenchmarkResultEvidenceSchema,
3134
3158
  agentCandidateModelSettlementEvidenceSchema,
3135
- agentCandidateTaskOutcomeEvidenceSchema,
3136
- agentCandidateWorkspaceSnapshotEvidenceSchema as agentCandidateWorkspaceSnapshotEvidenceSchema2
3159
+ agentCandidateTaskOutcomeEvidenceSchema
3137
3160
  } from "@tangle-network/agent-interface";
3138
3161
 
3139
3162
  // src/candidate-execution/benchmark-grader.ts
@@ -3280,7 +3303,8 @@ async function persistVerifiedCandidateTaskOutcome(state, capture, outputArtifac
3280
3303
  if (archive.byteLength === 0) throw new Error("candidate task archive cannot be empty");
3281
3304
  assertNoProtectedBytes(patch, protectedValues);
3282
3305
  assertNoProtectedBytes(archive, protectedValues);
3283
- const afterState = immutableCandidateValue(capture.afterState);
3306
+ const provisional = provisionalCandidateWorkspaceSnapshot(capture.afterState, archive);
3307
+ const afterState = provisional.material;
3284
3308
  const repository = state.executionPlan.value.material.task.repository;
3285
3309
  const verified = await verifyTaskOutcomePatch({
3286
3310
  repositoryRoot: state.roots.staging.taskRoot,
@@ -3291,45 +3315,21 @@ async function persistVerifiedCandidateTaskOutcome(state, capture, outputArtifac
3291
3315
  afterState
3292
3316
  });
3293
3317
  signal?.throwIfAborted();
3294
- const manifestBytes = canonicalCandidateBytes(afterState);
3295
- assertNoProtectedBytes(manifestBytes, protectedValues);
3296
- const provisionalSnapshot = agentCandidateWorkspaceSnapshotEvidenceSchema2.parse({
3297
- schemaVersion: 1,
3298
- kind: "agent-candidate-workspace-snapshot",
3299
- digest: sha256Bytes(manifestBytes),
3300
- material: afterState,
3301
- manifest: embeddedCandidateArtifact(manifestBytes),
3302
- archive: embeddedCandidateArtifact(archive)
3303
- });
3304
- await verifyTaskOutcomeArchive(state, provisionalSnapshot, archive, protectedValues);
3318
+ assertNoProtectedBytes(provisional.manifestBytes, protectedValues);
3319
+ await verifyTaskOutcomeArchive(state, provisional.snapshot, archive, protectedValues);
3305
3320
  signal?.throwIfAborted();
3306
- const [manifest, archiveRef, gitDiff] = await Promise.all([
3307
- persistCandidateOutputArtifact(outputArtifacts, {
3308
- executionId: state.executionId,
3309
- purpose: "task-manifest",
3310
- bytes: manifestBytes,
3311
- signal
3312
- }),
3313
- persistCandidateOutputArtifact(outputArtifacts, {
3314
- executionId: state.executionId,
3315
- purpose: "task-archive",
3316
- bytes: archive,
3317
- signal
3318
- }),
3319
- persistCandidateOutputArtifact(outputArtifacts, {
3320
- executionId: state.executionId,
3321
- purpose: "task-patch",
3322
- bytes: patch,
3323
- signal
3324
- })
3325
- ]);
3326
- const snapshot = agentCandidateWorkspaceSnapshotEvidenceSchema2.parse({
3327
- schemaVersion: 1,
3328
- kind: "agent-candidate-workspace-snapshot",
3329
- digest: sha256Bytes(manifestBytes),
3321
+ const snapshot = await persistCandidateWorkspaceSnapshot(outputArtifacts, {
3322
+ executionId: state.executionId,
3330
3323
  material: afterState,
3331
- manifest,
3332
- archive: archiveRef
3324
+ archive,
3325
+ purpose: "task",
3326
+ signal
3327
+ });
3328
+ const gitDiff = await persistCandidateOutputArtifact(outputArtifacts, {
3329
+ executionId: state.executionId,
3330
+ purpose: "task-patch",
3331
+ bytes: patch,
3332
+ signal
3333
3333
  });
3334
3334
  const material = {
3335
3335
  schemaVersion: 1,
@@ -4409,7 +4409,7 @@ import {
4409
4409
  agentCandidateExecutionPlanMaterialSchema,
4410
4410
  agentCandidateMaterializationReceiptSchema as agentCandidateMaterializationReceiptSchema2,
4411
4411
  agentCandidateModelAccessNetworkSchema,
4412
- agentCandidateWorkspaceSnapshotEvidenceSchema as agentCandidateWorkspaceSnapshotEvidenceSchema3,
4412
+ agentCandidateWorkspaceSnapshotEvidenceSchema as agentCandidateWorkspaceSnapshotEvidenceSchema2,
4413
4413
  sha256DigestSchema
4414
4414
  } from "@tangle-network/agent-interface";
4415
4415
  import {
@@ -4813,7 +4813,7 @@ function assertTaskInput(task, delivery) {
4813
4813
  throw new Error("task instruction must be non-empty well-formed Unicode");
4814
4814
  }
4815
4815
  sha256DigestSchema.parse(task.splitDigest);
4816
- agentCandidateWorkspaceSnapshotEvidenceSchema3.parse(task.workspace);
4816
+ agentCandidateWorkspaceSnapshotEvidenceSchema2.parse(task.workspace);
4817
4817
  agentCandidateExecutionLimitsSchema.parse(task.limits);
4818
4818
  if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(task.repository.baseCommit)) {
4819
4819
  throw new Error("task repository base commit is not a full Git object id");
@@ -5200,4 +5200,4 @@ export {
5200
5200
  verifyAgentCandidateBundle,
5201
5201
  prepareAgentCandidateExecution
5202
5202
  };
5203
- //# sourceMappingURL=chunk-HKMKUESZ.js.map
5203
+ //# sourceMappingURL=chunk-37V4KQDC.js.map