@tangle-network/agent-provider-tangle 1.8.0 → 1.9.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/README.md CHANGED
@@ -467,5 +467,6 @@ Both functions return private binary files and provenance for the workspace, nat
467
467
  The caller must store those bytes in private durable custody before deleting the box.
468
468
  Credential exclusions remain listed with path, type, owner IDs, timestamps, mode, size, and reason.
469
469
  Each process stream has exact frame order and a terminal receipt.
470
- The capture records the running sidecar image digest and can compare it with the pre-create proof.
470
+ The capture records the running sidecar image digest and the served Sidecar bundle revision.
471
+ The image digest can be compared with the pre-create proof only when that proof identifies the actual placement image.
471
472
  An incomplete inventory, missing stream, unrelated backend, or mismatched digest does not produce complete evidence.
@@ -6,4 +6,5 @@ export declare function createTangleExactProcessProvider(input: {
6
6
  providerName: string;
7
7
  /** How long create() waits for the new sandbox to reach `running`. */
8
8
  readyTimeoutMs: number;
9
+ requireNativeSessionCapture?: boolean;
9
10
  }): AgentExactProcessProvider;
@@ -1,6 +1,7 @@
1
1
  import { assertBoundedJson, attachCleanupHandle, awaitWithSignal, boundedIdentifier, boundedString, exactProcessRequestDigest, isBoundedJson, MAX_LIST_RESULTS, SANDBOX_LIST_PAGE_SIZE, } from "./tangle-contract-safety.js";
2
2
  import { sandboxInstanceAsExactProcessEnvironment } from "./tangle-exact-process-environment.js";
3
3
  import { awaitSandboxRunning } from "./tangle-readiness.js";
4
+ import { requireNativeCaptureCapability, requireNativeCaptureProof } from "./tangle-native-capture-proof.js";
4
5
  import { assertExactProcessSandbox, assertSupportedProviderOptions, assertUnreservedMetadata, EXACT_PROCESS_METADATA_KEY, isExactProcessRequestConflict, isExactProcessSandbox, metadataMatches, assertSignalOptions, } from "./tangle-exact-process-validation.js";
5
6
  const IMMUTABLE_TANGLE_IMAGE = /^(?:sha256:[a-f0-9]{64}|\S+@sha256:[a-f0-9]{64})$/i;
6
7
  export function createTangleExactProcessProvider(input) {
@@ -21,7 +22,12 @@ export function createTangleExactProcessProvider(input) {
21
22
  assertUnreservedMetadata(createInput.metadata);
22
23
  const identityDigest = exactProcessRequestDigest(createInput, providerName, options);
23
24
  createInput.signal?.throwIfAborted();
24
- const createPromise = client.create(exactSandboxOptions(createInput, options, providerName, identityDigest), {
25
+ if (input.requireNativeSessionCapture)
26
+ await requireNativeCaptureCapability(client);
27
+ const createPromise = client.create({
28
+ ...exactSandboxOptions(createInput, options, providerName, identityDigest),
29
+ ...(input.requireNativeSessionCapture ? { requireNativeSessionCapture: true } : {}),
30
+ }, {
25
31
  ...(createInput.signal ? { signal: createInput.signal } : {}),
26
32
  ...(createInput.provisionTimeoutMs === undefined
27
33
  ? {}
@@ -56,6 +62,8 @@ export function createTangleExactProcessProvider(input) {
56
62
  // decided before the wait. A foreign sandbox returned under a reused
57
63
  // idempotency key is a conflict now, not two minutes from now.
58
64
  assertExactProcessSandbox(box, providerName, options.teamId, identityDigest);
65
+ if (input.requireNativeSessionCapture)
66
+ requireNativeCaptureProof(box, true);
59
67
  // A launch starts a process on this sandbox, so create() returns only
60
68
  // after the sandbox can run one. The caller's provisioning budget owns
61
69
  // the deadline when it named one.
@@ -64,6 +72,8 @@ export function createTangleExactProcessProvider(input) {
64
72
  ...(createInput.signal ? { signal: createInput.signal } : {}),
65
73
  });
66
74
  createInput.signal?.throwIfAborted();
75
+ if (input.requireNativeSessionCapture)
76
+ requireNativeCaptureProof(box, true);
67
77
  return sandboxInstanceAsExactProcessEnvironment(box, providerName);
68
78
  }
69
79
  catch (error) {
@@ -99,6 +109,8 @@ export function createTangleExactProcessProvider(input) {
99
109
  (box.metadata !== undefined && !isBoundedJson(box.metadata)) ||
100
110
  !isExactProcessSandbox(box, providerName, options.teamId))
101
111
  return null;
112
+ if (input.requireNativeSessionCapture)
113
+ requireNativeCaptureProof(box);
102
114
  return sandboxInstanceAsExactProcessEnvironment(box, providerName);
103
115
  },
104
116
  async list(query, operation = {}) {
@@ -1,6 +1,6 @@
1
1
  import type { AgentProfile } from "@tangle-network/agent-interface";
2
2
  import type { AgentEnvironment } from "@tangle-network/agent-interface/environment-provider";
3
- import type { SandboxClientLike, SandboxInstanceLike } from "./tangle-types.js";
3
+ import type { NativeCaptureProofLike, SandboxClientLike, SandboxInstanceLike } from "./tangle-types.js";
4
4
  export interface TangleEvidenceCapabilities {
5
5
  readonly workspaceCaptureV1: true;
6
6
  readonly nativeSessionCaptureV1: true;
@@ -27,8 +27,10 @@ interface WorkspaceEntryMetadata {
27
27
  export interface TangleEnvironmentEvidenceOptions {
28
28
  executionId: string;
29
29
  harness: NonNullable<AgentProfile["harness"]>;
30
- /** Optional next-create proof to compare with the running sidecar image. */
30
+ /** Optional local image ID to compare with the running sidecar image. */
31
31
  expectedSidecarImageDigest?: string;
32
+ /** Require raw session bytes to match this box's current verified create proof. */
33
+ requireNativeSessionCapture?: boolean;
32
34
  /** Exact Sandbox session id when execution was reattached after provider restart. */
33
35
  sandboxSessionId?: string | null;
34
36
  maxBytes: number;
@@ -51,6 +53,7 @@ export interface TangleEnvironmentEvidence {
51
53
  provider: string;
52
54
  environmentId: string;
53
55
  executionId: string;
56
+ captureProof?: NativeCaptureProofLike;
54
57
  workspaceScope: "environment";
55
58
  workspaceRoot: string;
56
59
  capturedAt: string;
@@ -72,6 +75,7 @@ export interface TangleEnvironmentEvidence {
72
75
  eventCountsByExecutionId: Record<string, number>;
73
76
  backendType: string;
74
77
  sidecarImageDigest: string | null;
78
+ sidecarBundleRevision: string | null;
75
79
  transportEvents: "complete" | "unavailable";
76
80
  eventCount: number;
77
81
  messageCount: number;
@@ -1,5 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { parseBackendType } from "@tangle-network/sandbox";
3
+ import { requireNativeCaptureProof } from "./tangle-native-capture-proof.js";
3
4
  const handles = new WeakMap();
4
5
  const blockedNames = new Set([".ssh", ".config", ".claude", ".codex", ".opencode", ".env", ".env.local", ".npmrc", ".sidecar"]);
5
6
  const MAX_ENTRIES = 100_000;
@@ -60,6 +61,7 @@ export async function captureTangleEnvironmentEvidence(environment, options) {
60
61
  executionId: options.executionId,
61
62
  harness: options.harness,
62
63
  expectedSidecarImageDigest: options.expectedSidecarImageDigest,
64
+ requireNativeSessionCapture: options.requireNativeSessionCapture,
63
65
  sandboxSessionIds: [...sessionIds],
64
66
  sessionExecutionIds: Object.fromEntries([...sessionIds].filter((id) => state.sessions.has(id))
65
67
  .map((id) => [id, [...state.sessions.get(id)]])),
@@ -85,6 +87,7 @@ export async function captureTangleSandboxEvidence(box, options) {
85
87
  if (options.sessionExecutionIds && Object.keys(options.sessionExecutionIds).some((id) => !options.sandboxSessionIds.includes(id))) {
86
88
  throw new Error("Tangle evidence execution mapping names an unrelated Sandbox session");
87
89
  }
90
+ const captureProof = options.requireNativeSessionCapture ? requireNativeCaptureProof(box) : null;
88
91
  const workspaceRoot = options.workspaceRoot ?? ".";
89
92
  if (workspaceRoot !== ".")
90
93
  canonicalEntryPath(workspaceRoot);
@@ -237,7 +240,11 @@ export async function captureTangleSandboxEvidence(box, options) {
237
240
  throw new Error("Tangle evidence exceeds byte limit");
238
241
  capturedBytes = files.reduce((sum, file) => sum + file.bytes.byteLength, 0) + bytes.byteLength;
239
242
  files.push({ path: `__retention__/sessions/${id}.json`, bytes, mode: 0o600 });
240
- const native = await session.rawEvidence?.();
243
+ const rawNative = await session.rawEvidence?.();
244
+ if (rawNative !== undefined && (rawNative === null || typeof rawNative !== "object")) {
245
+ throw new Error("Tangle raw evidence is malformed");
246
+ }
247
+ const native = rawNative;
241
248
  const nativeStore = {
242
249
  scope: "session", roots: [], inventory: null, complete: false, entries: [], excludedPaths: [],
243
250
  };
@@ -250,6 +257,7 @@ export async function captureTangleSandboxEvidence(box, options) {
250
257
  };
251
258
  let nativeSessionId = null;
252
259
  let sidecarImageDigest = null;
260
+ let sidecarBundleRevision = null;
253
261
  let nativeReason = "raw-session-capture-capability-absent";
254
262
  if (native !== undefined) {
255
263
  if (native.sessionId !== id || native.backendType !== options.harness) {
@@ -260,12 +268,23 @@ export async function captureTangleSandboxEvidence(box, options) {
260
268
  }
261
269
  nativeSessionId = native.nativeSessionId ?? null;
262
270
  if (native.status === "captured") {
271
+ if (captureProof && (native.proofStatus !== "verified" ||
272
+ native.containerId !== captureProof.containerId ||
273
+ native.sidecarImageDigest !== captureProof.imageId ||
274
+ native.sidecarBundleRevision !== captureProof.bundleRevision ||
275
+ native.sidecarBundleChecksum !== captureProof.bundleChecksum)) {
276
+ throw new Error("Tangle raw session identity differs from verified create proof");
277
+ }
263
278
  if (!/^sha256:[0-9a-f]{64}$/.test(native.sidecarImageDigest) ||
264
279
  (options.expectedSidecarImageDigest !== undefined &&
265
280
  native.sidecarImageDigest !== options.expectedSidecarImageDigest)) {
266
281
  throw new Error("Tangle raw session image digest is missing or differs from deployment proof");
267
282
  }
283
+ if (!/^[0-9a-f]{40}$/.test(native.sidecarBundleRevision)) {
284
+ throw new Error("Tangle raw session sidecar bundle revision is missing or invalid");
285
+ }
268
286
  sidecarImageDigest = native.sidecarImageDigest;
287
+ sidecarBundleRevision = native.sidecarBundleRevision;
269
288
  if (native.completeness?.nativeStore !== true || native.completeness.processIo !== true ||
270
289
  native.completeness.events !== true || !Array.isArray(native.files) ||
271
290
  !Array.isArray(native.processIo) || !Array.isArray(native.events) ||
@@ -279,12 +298,12 @@ export async function captureTangleSandboxEvidence(box, options) {
279
298
  }
280
299
  const roots = new Set();
281
300
  for (const root of native.nativeRoots) {
282
- if (!["session-home", "workspace-session"].includes(root.scope) || roots.has(root.scope) ||
301
+ if (!["session-home", "workspace-session"].includes(root.rootScope) || roots.has(root.rootScope) ||
283
302
  (root.path !== "." && canonicalEntryPath(root.path) !== root.path)) {
284
303
  throw new Error("Tangle raw session native root is invalid");
285
304
  }
286
- roots.add(root.scope);
287
- nativeStore.roots.push(root);
305
+ roots.add(root.rootScope);
306
+ nativeStore.roots.push({ scope: root.rootScope, path: root.path });
288
307
  }
289
308
  if (!roots.size)
290
309
  throw new Error("Tangle raw session has no native root");
@@ -360,7 +379,18 @@ export async function captureTangleSandboxEvidence(box, options) {
360
379
  inventory.scannedSymlinks !== inventory.reportedSymlinks + inventory.excludedSymlinks) {
361
380
  throw new Error("Tangle raw session inventory does not reconcile");
362
381
  }
363
- nativeStore.inventory = inventory;
382
+ nativeStore.inventory = {
383
+ scannedFiles: inventory.scannedFiles,
384
+ reportedFiles: inventory.reportedFiles,
385
+ excludedFiles: inventory.excludedFiles,
386
+ scannedDirectories: inventory.scannedDirectories,
387
+ reportedDirectories: inventory.reportedDirectories,
388
+ excludedDirectories: inventory.excludedDirectories,
389
+ scannedSymlinks: inventory.scannedSymlinks,
390
+ reportedSymlinks: inventory.reportedSymlinks,
391
+ excludedSymlinks: inventory.excludedSymlinks,
392
+ skippedEntries: 0,
393
+ };
364
394
  const ioSequences = new Map();
365
395
  const frameMetadata = [];
366
396
  for (const frame of native.processIo) {
@@ -448,7 +478,7 @@ export async function captureTangleSandboxEvidence(box, options) {
448
478
  }
449
479
  sessions.push({
450
480
  id, executionId: options.executionId, executionIds: [...executionIds], eventCountsByExecutionId,
451
- backendType: options.harness, sidecarImageDigest,
481
+ backendType: options.harness, sidecarImageDigest, sidecarBundleRevision,
452
482
  transportEvents: executionIds.every((executionId) => eventCountsByExecutionId[executionId] > 0) ? "complete" : "unavailable",
453
483
  eventCount: events.length, messageCount: messages.length, messageScope: "session",
454
484
  nativeSessionId, nativeReason, nativeStore, processStreams, nativeEvents,
@@ -466,6 +496,7 @@ export async function captureTangleSandboxEvidence(box, options) {
466
496
  provider: "tangle-sandbox",
467
497
  environmentId: box.id,
468
498
  executionId: options.executionId,
499
+ ...(captureProof ? { captureProof } : {}),
469
500
  workspaceScope: "environment",
470
501
  workspaceRoot,
471
502
  capturedAt: new Date().toISOString(),
@@ -0,0 +1,5 @@
1
+ import type { NativeCaptureProofLike, SandboxClientLike, SandboxInstanceLike } from "./tangle-types.js";
2
+ /** Require a current host proof; a create must also prove its receipt names that same container. */
3
+ export declare function requireNativeCaptureProof(box: SandboxInstanceLike, create?: boolean): NativeCaptureProofLike;
4
+ /** Refuse an unsupported deployment before creating a billable sandbox. */
5
+ export declare function requireNativeCaptureCapability(client: SandboxClientLike): Promise<void>;
@@ -0,0 +1,33 @@
1
+ const imageId = /^sha256:[0-9a-f]{64}$/;
2
+ const containerId = /^[0-9a-f]{64}$/;
3
+ const revision = /^[0-9a-f]{40}$/;
4
+ function valid(proof) {
5
+ return !!proof && typeof proof.hostId === "string" && proof.hostId.length > 0 &&
6
+ containerId.test(proof.containerId) && imageId.test(proof.imageId) &&
7
+ revision.test(proof.bundleRevision) && imageId.test(proof.bundleChecksum);
8
+ }
9
+ function equal(a, b) {
10
+ return a.hostId === b.hostId && a.containerId === b.containerId &&
11
+ a.imageId === b.imageId && a.bundleRevision === b.bundleRevision &&
12
+ a.bundleChecksum === b.bundleChecksum;
13
+ }
14
+ /** Require a current host proof; a create must also prove its receipt names that same container. */
15
+ export function requireNativeCaptureProof(box, create = false) {
16
+ const proof = box.captureProof?.();
17
+ if (!valid(proof))
18
+ throw new Error("Tangle native session capture has no verified current container proof");
19
+ if (create) {
20
+ const receipt = box.createReceipt?.()?.captureProof;
21
+ if (!valid(receipt) || !equal(proof, receipt)) {
22
+ throw new Error("Tangle native session capture create receipt differs from current container proof");
23
+ }
24
+ }
25
+ return proof;
26
+ }
27
+ /** Refuse an unsupported deployment before creating a billable sandbox. */
28
+ export async function requireNativeCaptureCapability(client) {
29
+ if (!client.evidenceCapabilities ||
30
+ (await client.evidenceCapabilities()).nativeSessionCaptureV1 !== true) {
31
+ throw new Error("Tangle deployment has not proven native session capture for next-create placement");
32
+ }
33
+ }
@@ -6,11 +6,15 @@ import { sandboxInstanceAsEnvironment } from "./tangle-environment.js";
6
6
  import { confidentialVerifierOption, createTangleWorkspaceBranching, } from "./tangle-workspace-branching.js";
7
7
  import { assertCreateInputShape, assertMappedCreateOptions, assertMappedSecretNames, assertNoInlineSecretValues, captureModelCredentials, sandboxOptionsFromCreateInput, sandboxRestoreFromCheckpoint } from "./tangle-create-options.js";
8
8
  import { statusFromUnknown } from "./tangle-environment-values.js";
9
+ import { requireNativeCaptureCapability, requireNativeCaptureProof } from "./tangle-native-capture-proof.js";
9
10
  import { awaitSandboxRunning, DEFAULT_TANGLE_READY_TIMEOUT_MS, } from "./tangle-readiness.js";
10
11
  import { requestedResourceProfile } from "./tangle-resources.js";
11
12
  import { assertBoundedJson, attachCleanupHandle, awaitWithSignal, boundedIdentifier, boundedString, MAX_LIST_RESULTS, PROFILE_AT_ROOT, SANDBOX_LIST_PAGE_SIZE, } from "./tangle-contract-safety.js";
12
13
  export function createTangleProvider(options) {
13
14
  const modelCredentials = captureModelCredentials(options.modelCredentials);
15
+ if (options.requireNativeSessionCapture !== undefined && typeof options.requireNativeSessionCapture !== "boolean") {
16
+ throw new Error("Tangle requireNativeSessionCapture must be a boolean");
17
+ }
14
18
  const mapCreateInput = options.mapCreateInput;
15
19
  if (modelCredentials !== undefined && mapCreateInput !== undefined) {
16
20
  throw new Error("Tangle modelCredentials cannot be combined with mapCreateInput");
@@ -27,6 +31,7 @@ export function createTangleProvider(options) {
27
31
  options: options.exactProcess,
28
32
  providerName,
29
33
  readyTimeoutMs,
34
+ ...(options.requireNativeSessionCapture ? { requireNativeSessionCapture: true } : {}),
30
35
  })
31
36
  : undefined;
32
37
  const resolveDeclaredCapabilities = async (backendType) => {
@@ -65,7 +70,10 @@ export function createTangleProvider(options) {
65
70
  const mappedOptions = mapCreateInput?.(input) ??
66
71
  sandboxOptionsFromCreateInput(input, options.defaultBackend, parsedWorkspace, modelCredentials);
67
72
  assertMappedCreateOptions(mappedOptions);
68
- const createOptions = deepFreeze(structuredClone(mappedOptions));
73
+ const createOptions = deepFreeze(structuredClone({
74
+ ...mappedOptions,
75
+ ...(options.requireNativeSessionCapture ? { requireNativeSessionCapture: true } : {}),
76
+ }));
69
77
  if (input.idempotencyKey !== undefined &&
70
78
  createOptions.idempotencyKey !== input.idempotencyKey) {
71
79
  throw new Error("Tangle mapped create options must preserve input idempotencyKey");
@@ -105,6 +113,8 @@ export function createTangleProvider(options) {
105
113
  }
106
114
  }
107
115
  input.signal?.throwIfAborted();
116
+ if (options.requireNativeSessionCapture)
117
+ await requireNativeCaptureCapability(options.client);
108
118
  const createPromise = options.client.create(createOptions, input.signal ? { signal: input.signal } : undefined);
109
119
  let box;
110
120
  try {
@@ -131,6 +141,8 @@ export function createTangleProvider(options) {
131
141
  }
132
142
  try {
133
143
  input.signal?.throwIfAborted();
144
+ if (options.requireNativeSessionCapture)
145
+ requireNativeCaptureProof(box, true);
134
146
  // The environment this call returns must accept a turn, and composing it
135
147
  // reads a deployment document that a starting sandbox cannot answer.
136
148
  // Both facts wait here, once, so no caller repeats the wait.
@@ -139,6 +151,8 @@ export function createTangleProvider(options) {
139
151
  ...(input.signal ? { signal: input.signal } : {}),
140
152
  });
141
153
  input.signal?.throwIfAborted();
154
+ if (options.requireNativeSessionCapture)
155
+ requireNativeCaptureProof(box, true);
142
156
  const requestedResources = requestedResourceProfile(input.resources);
143
157
  const environment = await sandboxInstanceAsEnvironment(box, providerName, options.client, declaredCapabilities, input.signal ? { signal: input.signal } : undefined, {
144
158
  ...(requestedResources === undefined
@@ -176,10 +190,13 @@ export function createTangleProvider(options) {
176
190
  if (!box || box.id !== environmentId)
177
191
  return null;
178
192
  boundedIdentifier(box.id, "Tangle workspace branching environment id");
193
+ if (options.requireNativeSessionCapture)
194
+ requireNativeCaptureProof(box);
179
195
  return (createTangleWorkspaceBranching({
180
196
  box,
181
197
  client: options.client,
182
198
  provider: providerName,
199
+ ...(options.requireNativeSessionCapture ? { requireNativeSessionCapture: true } : {}),
183
200
  ...confidentialVerifierOption(options.confidentialAttestationVerifier),
184
201
  }) ?? null);
185
202
  },
@@ -220,6 +237,8 @@ export function createTangleProvider(options) {
220
237
  operation?.signal?.throwIfAborted();
221
238
  if (!box || boundedIdentifier(box.id, "Tangle environment id") !== id)
222
239
  return null;
240
+ if (options.requireNativeSessionCapture)
241
+ requireNativeCaptureProof(box);
223
242
  let backendType;
224
243
  if (box.status === "running" && box.backend) {
225
244
  try {
@@ -7,9 +7,17 @@ import type { AgentEnvironmentCapabilities, AgentEnvironmentProvider, CreateAgen
7
7
  * earlier call with the same idempotency key allocated it; `unknown` means the
8
8
  * platform cannot prove either outcome.
9
9
  */
10
+ export interface NativeCaptureProofLike {
11
+ hostId: string;
12
+ containerId: string;
13
+ imageId: string;
14
+ bundleRevision: string;
15
+ bundleChecksum: string;
16
+ }
10
17
  export interface SandboxCreateReceiptLike {
11
18
  outcome: "created" | "idempotent_replay" | "unknown";
12
19
  idempotencyKeyApplied: boolean;
20
+ captureProof?: NativeCaptureProofLike;
13
21
  }
14
22
  export interface TangleExactProcessOptions {
15
23
  teamId?: string;
@@ -500,6 +508,8 @@ export interface SandboxInstanceLike {
500
508
  * by id or when the platform reported no receipt.
501
509
  */
502
510
  createReceipt?(): SandboxCreateReceiptLike | null;
511
+ /** Fresh server proof for this container incarnation. */
512
+ captureProof?(): NativeCaptureProofLike | null | undefined;
503
513
  /**
504
514
  * Hold until this sandbox reaches a lifecycle status, refreshing this
505
515
  * instance in place. Preferred over the client-side wait because the created
@@ -543,6 +553,84 @@ export interface SandboxInstanceLike {
543
553
  attestationNonce?: string;
544
554
  }): Promise<SandboxTeeAttestationResponseLike>;
545
555
  }
556
+ export type TangleRawEvidenceLike = {
557
+ status: "captured";
558
+ sessionId: string;
559
+ backendType: string;
560
+ nativeSessionId?: string;
561
+ proofStatus?: "verified" | "unverified";
562
+ containerId?: string;
563
+ sidecarImageDigest: string;
564
+ sidecarBundleRevision: string;
565
+ sidecarBundleChecksum?: string;
566
+ nativeRoots: Array<{
567
+ rootScope: "session-home" | "workspace-session";
568
+ path: string;
569
+ }>;
570
+ inventory: Record<string, number>;
571
+ files: Array<{
572
+ rootScope: "session-home" | "workspace-session";
573
+ path: string;
574
+ kind: "file" | "directory" | "symlink";
575
+ mode: number;
576
+ uid: number;
577
+ gid: number;
578
+ mtimeMs: number;
579
+ ctimeMs: number;
580
+ sizeBytes: number;
581
+ sha256?: string;
582
+ contentBase64?: string;
583
+ linkTarget?: string;
584
+ }>;
585
+ processIo: Array<{
586
+ processId: string;
587
+ sequence: number;
588
+ at: string;
589
+ stream: "stdin" | "stdout" | "stderr" | "protocol";
590
+ sizeBytes: number;
591
+ sha256: string;
592
+ contentBase64: string;
593
+ metadata?: unknown;
594
+ }>;
595
+ processTerminals: Array<{
596
+ processId: string;
597
+ sequence: number;
598
+ at: string;
599
+ result: {
600
+ code: number | null;
601
+ signal: string | null;
602
+ timedOut: boolean;
603
+ timeoutReason: string | null;
604
+ captureError: null;
605
+ spawnError?: string;
606
+ };
607
+ }>;
608
+ events: unknown[];
609
+ excluded: Array<{
610
+ rootScope: "session-home" | "workspace-session";
611
+ path: string;
612
+ kind: "file" | "directory" | "symlink";
613
+ mode: number;
614
+ uid: number;
615
+ gid: number;
616
+ mtimeMs: number;
617
+ ctimeMs: number;
618
+ sizeBytes: number;
619
+ reason: "credential";
620
+ }>;
621
+ completeness: {
622
+ nativeStore: true;
623
+ processIo: true;
624
+ events: true;
625
+ };
626
+ coverageComplete: true;
627
+ } | {
628
+ status: "unavailable";
629
+ sessionId: string;
630
+ backendType: string;
631
+ nativeSessionId?: string;
632
+ reason: string;
633
+ };
546
634
  export interface SandboxSessionLike {
547
635
  readonly id: string;
548
636
  messages?(options?: {
@@ -550,91 +638,8 @@ export interface SandboxSessionLike {
550
638
  offset?: number;
551
639
  since?: number;
552
640
  }): Promise<unknown[]>;
553
- rawEvidence?(): Promise<{
554
- status: "captured";
555
- sessionId: string;
556
- backendType: string;
557
- nativeSessionId?: string;
558
- sidecarImageDigest: string;
559
- nativeRoots: Array<{
560
- scope: "session-home" | "workspace-session";
561
- path: string;
562
- }>;
563
- inventory: {
564
- scannedFiles: number;
565
- reportedFiles: number;
566
- excludedFiles: number;
567
- scannedDirectories: number;
568
- reportedDirectories: number;
569
- excludedDirectories: number;
570
- scannedSymlinks: number;
571
- reportedSymlinks: number;
572
- excludedSymlinks: number;
573
- skippedEntries: 0;
574
- };
575
- files: Array<{
576
- rootScope: "session-home" | "workspace-session";
577
- path: string;
578
- kind: "file" | "directory" | "symlink";
579
- mode: number;
580
- uid: number;
581
- gid: number;
582
- mtimeMs: number;
583
- ctimeMs: number;
584
- sizeBytes: number;
585
- sha256?: string;
586
- contentBase64?: string;
587
- linkTarget?: string;
588
- }>;
589
- processIo: Array<{
590
- processId: string;
591
- sequence: number;
592
- at: string;
593
- stream: "stdin" | "stdout" | "stderr" | "protocol";
594
- sizeBytes: number;
595
- sha256: string;
596
- contentBase64: string;
597
- metadata?: unknown;
598
- }>;
599
- processTerminals: Array<{
600
- processId: string;
601
- sequence: number;
602
- at: string;
603
- result: {
604
- code: number | null;
605
- signal: string | null;
606
- timedOut: boolean;
607
- timeoutReason: string | null;
608
- captureError: null;
609
- spawnError?: string;
610
- };
611
- }>;
612
- events: unknown[];
613
- excluded: Array<{
614
- rootScope: "session-home" | "workspace-session";
615
- path: string;
616
- kind: "file" | "directory" | "symlink";
617
- mode: number;
618
- uid: number;
619
- gid: number;
620
- mtimeMs: number;
621
- ctimeMs: number;
622
- sizeBytes: number;
623
- reason: "credential";
624
- }>;
625
- completeness: {
626
- nativeStore: true;
627
- processIo: true;
628
- events: true;
629
- };
630
- coverageComplete: true;
631
- } | {
632
- status: "unavailable";
633
- sessionId: string;
634
- backendType: string;
635
- nativeSessionId?: string;
636
- reason: string;
637
- }>;
641
+ /** The SDK returns generic records. Validate their shape before retaining any bytes. */
642
+ rawEvidence?(): Promise<unknown>;
638
643
  /** Exact native coding-agent TUI bound to this session id. */
639
644
  interactive?(options?: {
640
645
  ref?: AgentInteractiveSessionRef;
@@ -706,6 +711,8 @@ export interface TangleProviderOptions {
706
711
  name?: string;
707
712
  /** Overrides an inline profile's harness when create() names no backend. */
708
713
  defaultBackend?: BackendType;
714
+ /** Require the selected Sandbox host to prove native session capture for every create. */
715
+ requireNativeSessionCapture?: boolean;
709
716
  /**
710
717
  * Stored model credential and endpoint used by the default create mapping.
711
718
  * Each create must explicitly list apiKeyEnv in its secrets.
@@ -5,6 +5,7 @@ export interface TangleWorkspaceBranchingOptions {
5
5
  client: SandboxClientLike;
6
6
  provider: string;
7
7
  confidentialAttestationVerifier?: TangleConfidentialAttestationVerifier;
8
+ requireNativeSessionCapture?: boolean;
8
9
  }
9
10
  /**
10
11
  * Carry the verifier only when the caller supplied one. Every option type that
@@ -1,3 +1,4 @@
1
+ import { requireNativeCaptureCapability, requireNativeCaptureProof } from "./tangle-native-capture-proof.js";
1
2
  import { ConfidentialAttestationSchema, ConfidentialExecutionRequestSchema, ForkedEnvironmentRefSchema, WorkspaceCheckpointRequestSchema, WorkspaceCleanupAcknowledgementSchema, WorkspaceCleanupRequestSchema, WorkspaceForkRequestSchema, WorkspaceOperationLookupRequestSchema, WorkspaceCheckpointResultSchema, WorkspaceCheckpointLookupResultSchema, WorkspaceForkResultSchema, WorkspaceForkLookupResultSchema, canonicalCandidateDigest, confidentialExecutionVerified, sha256Bytes, } from "@tangle-network/agent-interface";
2
3
  import { awaitWithSignal, boundedIdentifier, boundedString, MAX_STRING_LENGTH, cloneJson, safeIdentifier, safeString, } from "./tangle-contract-safety.js";
3
4
  import { encodeTangleConfidentialAttestationQuote } from "./tangle-confidential-attestation.js";
@@ -313,6 +314,8 @@ export function createTangleWorkspaceBranching(options) {
313
314
  : "Sandbox checkpoint inventory is unavailable", true);
314
315
  }
315
316
  const metadata = forkMarkerMetadata(request);
317
+ if (options.requireNativeSessionCapture)
318
+ await requireNativeCaptureCapability(client);
316
319
  let returnedChild;
317
320
  let outcome;
318
321
  try {
@@ -323,10 +326,13 @@ export function createTangleWorkspaceBranching(options) {
323
326
  fromSandboxId: box.id,
324
327
  idempotencyKey: request.idempotencyKey,
325
328
  metadata,
329
+ ...(options.requireNativeSessionCapture ? { requireNativeSessionCapture: true } : {}),
326
330
  ...(request.name === undefined ? {} : { name: request.name }),
327
331
  }, operation?.signal === undefined
328
332
  ? undefined
329
333
  : { signal: operation.signal }), operation?.signal);
334
+ if (options.requireNativeSessionCapture)
335
+ requireNativeCaptureProof(returnedChild, true);
330
336
  const receipt = returnedChild.createReceipt?.();
331
337
  if (!receipt ||
332
338
  receipt.idempotencyKeyApplied !== true ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-provider-tangle",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -51,6 +51,8 @@
51
51
  "dist/tangle-environment.js",
52
52
  "dist/tangle-evidence.d.ts",
53
53
  "dist/tangle-evidence.js",
54
+ "dist/tangle-native-capture-proof.d.ts",
55
+ "dist/tangle-native-capture-proof.js",
54
56
  "dist/tangle-environment-dispatch.d.ts",
55
57
  "dist/tangle-environment-dispatch.js",
56
58
  "dist/tangle-environment-session.d.ts",
@@ -104,7 +106,7 @@
104
106
  "@tangle-network/agent-interface": "^2.14.0"
105
107
  },
106
108
  "peerDependencies": {
107
- "@tangle-network/sandbox": ">=0.39.0 <1.0.0"
109
+ "@tangle-network/sandbox": ">=0.58.0 <1.0.0"
108
110
  },
109
111
  "peerDependenciesMeta": {
110
112
  "@tangle-network/sandbox": {
@@ -114,7 +116,7 @@
114
116
  "devDependencies": {
115
117
  "@tangle-network/agent-provider-testkit": "0.10.0",
116
118
  "@tangle-network/agent-runtime": "0.282.2",
117
- "@tangle-network/sandbox": "0.55.3",
119
+ "@tangle-network/sandbox": "0.58.0",
118
120
  "@types/node": "26.6.3",
119
121
  "typescript": "7.0.2",
120
122
  "vitest": "5.0.2"