@tangle-network/agent-provider-tangle 1.6.0 → 1.7.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.
@@ -107,10 +107,14 @@ export function defaultTangleSandboxCapabilities(harness) {
107
107
  // Create carries both fields to the Sandbox API unchanged. The API still authorizes the
108
108
  // caller for a delegated billing owner, and it rejects the create when it does not, so this
109
109
  // states only that neither field is dropped on the way.
110
+ // A workspace checkpoint is a Sandbox snapshot. Create restores it into the new box, and the
111
+ // snapshot outlives the box it was taken from (measured 2026-09-24: files byte-identical in
112
+ // a box created 19 s after the source box was deleted).
110
113
  create: {
111
114
  egress: ["open", "strict", "blocked"],
112
115
  billingOwner: true,
113
116
  runtimeAttachments: { mcp: true },
117
+ workspaceCheckpoint: true,
114
118
  },
115
119
  // This is intent only. Narrowing requires both raw TEE evidence and the
116
120
  // caller's external provider-key verifier before the flag survives.
@@ -3,6 +3,16 @@ import type { CreateAgentEnvironmentInput, WorkspaceRequest } from "@tangle-netw
3
3
  import type { TangleProviderOptions } from "./tangle-types.js";
4
4
  export declare function captureModelCredentials(value: TangleProviderOptions["modelCredentials"]): TangleProviderOptions["modelCredentials"];
5
5
  export declare function sandboxOptionsFromCreateInput(input: CreateAgentEnvironmentInput, defaultBackend?: BackendType, parsedWorkspace?: WorkspaceRequest, modelCredentials?: TangleProviderOptions["modelCredentials"]): CreateSandboxOptions;
6
+ /**
7
+ * Project a portable workspace checkpoint onto the Sandbox restore fields.
8
+ *
9
+ * A Tangle checkpoint is a snapshot of its source box, and Sandbox names a snapshot by the pair
10
+ * (snapshot id, source box id). The source box may already be deleted.
11
+ */
12
+ export declare function sandboxRestoreFromCheckpoint(checkpoint: WorkspaceRequest["checkpoint"]): {
13
+ fromSnapshot: string;
14
+ fromSandboxId: string;
15
+ } | undefined;
6
16
  /** Reject value-bearing secret maps before any custom mapper can drop them. */
7
17
  export declare function assertNoInlineSecretValues(input: CreateAgentEnvironmentInput, parsedWorkspace?: WorkspaceRequest): void;
8
18
  /** A custom mapper must not smuggle a value map into the Sandbox request. */
@@ -61,6 +61,7 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
61
61
  throw new Error("Tangle workspace providerOptions are not supported");
62
62
  }
63
63
  const workspaceCwd = workspaceCwdPathForBase(workspace.cwd, "repository", "Tangle");
64
+ const restore = sandboxRestoreFromCheckpoint(workspace.checkpoint);
64
65
  if (input.resources?.providerOptions && Object.keys(input.resources.providerOptions).length > 0) {
65
66
  throw new Error("Tangle resource providerOptions are not supported");
66
67
  }
@@ -91,6 +92,7 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
91
92
  }
92
93
  : {}),
93
94
  ...(resources ? { resources } : {}),
95
+ ...(restore ?? {}),
94
96
  ...(input.env ? { env: input.env } : {}),
95
97
  ...(Array.isArray(input.secrets) ? { secrets: input.secrets } : {}),
96
98
  ...(input.egress === undefined ? {} : { egressPolicy: sandboxEgressPolicy(input.egress) }),
@@ -110,6 +112,20 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
110
112
  };
111
113
  return mapped;
112
114
  }
115
+ /**
116
+ * Project a portable workspace checkpoint onto the Sandbox restore fields.
117
+ *
118
+ * A Tangle checkpoint is a snapshot of its source box, and Sandbox names a snapshot by the pair
119
+ * (snapshot id, source box id). The source box may already be deleted.
120
+ */
121
+ export function sandboxRestoreFromCheckpoint(checkpoint) {
122
+ if (checkpoint === undefined)
123
+ return undefined;
124
+ return {
125
+ fromSnapshot: boundedIdentifier(checkpoint.checkpointId, "Tangle workspace checkpoint id"),
126
+ fromSandboxId: boundedIdentifier(checkpoint.source.environmentId, "Tangle workspace checkpoint source"),
127
+ };
128
+ }
113
129
  /**
114
130
  * Project the portable egress policy onto the Sandbox policy.
115
131
  *
@@ -4,7 +4,7 @@ import { createTangleExactProcessProvider, } from "./exact-process.js";
4
4
  import { capabilitiesForClient, defaultTangleSandboxCapabilities, narrowTangleCapabilitiesToBackend, } from "./tangle-capabilities.js";
5
5
  import { sandboxInstanceAsEnvironment } from "./tangle-environment.js";
6
6
  import { confidentialVerifierOption, createTangleWorkspaceBranching, } from "./tangle-workspace-branching.js";
7
- import { assertCreateInputShape, assertMappedCreateOptions, assertMappedSecretNames, assertNoInlineSecretValues, captureModelCredentials, sandboxOptionsFromCreateInput } from "./tangle-create-options.js";
7
+ import { assertCreateInputShape, assertMappedCreateOptions, assertMappedSecretNames, assertNoInlineSecretValues, captureModelCredentials, sandboxOptionsFromCreateInput, sandboxRestoreFromCheckpoint } from "./tangle-create-options.js";
8
8
  import { statusFromUnknown } from "./tangle-environment-values.js";
9
9
  import { awaitSandboxRunning, DEFAULT_TANGLE_READY_TIMEOUT_MS, } from "./tangle-readiness.js";
10
10
  import { requestedResourceProfile } from "./tangle-resources.js";
@@ -71,6 +71,22 @@ export function createTangleProvider(options) {
71
71
  throw new Error("Tangle mapped create options must preserve input idempotencyKey");
72
72
  }
73
73
  assertMappedSecretNames(createOptions);
74
+ const checkpoint = parsedWorkspace?.checkpoint;
75
+ if (checkpoint !== undefined) {
76
+ // A checkpoint names a snapshot this provider took. Another provider's id means nothing to
77
+ // Sandbox, and a mapper that drops the restore would return an empty workspace as if full.
78
+ if (checkpoint.provider !== providerName) {
79
+ throw new Error(`Tangle cannot restore a workspace checkpoint taken by provider "${checkpoint.provider}"`);
80
+ }
81
+ const restore = sandboxRestoreFromCheckpoint(checkpoint);
82
+ if (createOptions.fromSnapshot !== restore?.fromSnapshot ||
83
+ createOptions.fromSandboxId !== restore?.fromSandboxId) {
84
+ throw new Error("Tangle mapped create options must preserve the workspace checkpoint");
85
+ }
86
+ }
87
+ else if (createOptions.fromSnapshot !== undefined || createOptions.fromSandboxId !== undefined) {
88
+ throw new Error("Tangle mapped create options restore a snapshot the create input did not name");
89
+ }
74
90
  if (input.runtimeAttachments !== undefined &&
75
91
  (createOptions.backend?.runtimeAttachments === undefined ||
76
92
  canonicalCandidateDigest(input.runtimeAttachments) !== canonicalCandidateDigest(createOptions.backend.runtimeAttachments))) {
@@ -80,6 +96,9 @@ export function createTangleProvider(options) {
80
96
  // default cannot describe a sandbox that this projection routes elsewhere.
81
97
  const declaredCapabilities = await resolveDeclaredCapabilities(createOptions.backend?.type);
82
98
  narrowedProviderCapabilities(declaredCapabilities);
99
+ if (checkpoint !== undefined && declaredCapabilities.create?.workspaceCheckpoint !== true) {
100
+ throw new Error("Tangle workspace checkpoint restore is not supported by the declared capabilities");
101
+ }
83
102
  if (createOptions.backend?.runtimeAttachments !== undefined) {
84
103
  if (createOptions.backend.type === undefined || declaredCapabilities.create?.runtimeAttachments?.mcp !== true) {
85
104
  throw new Error("Tangle runtime attachments are not supported by the selected backend deployment");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-provider-tangle",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -99,7 +99,7 @@
99
99
  "LICENSE"
100
100
  ],
101
101
  "dependencies": {
102
- "@tangle-network/agent-interface": "^2.10.0"
102
+ "@tangle-network/agent-interface": "^2.13.0"
103
103
  },
104
104
  "peerDependencies": {
105
105
  "@tangle-network/sandbox": ">=0.39.0 <1.0.0"
@@ -110,8 +110,8 @@
110
110
  }
111
111
  },
112
112
  "devDependencies": {
113
- "@tangle-network/agent-eval": "0.173.1",
114
- "@tangle-network/agent-runtime": "0.192.2",
113
+ "@tangle-network/agent-eval": "0.182.0",
114
+ "@tangle-network/agent-runtime": "0.231.1",
115
115
  "@tangle-network/sandbox": "0.39.0",
116
116
  "@types/node": "26.4.1",
117
117
  "typescript": "7.0.2",