@tangle-network/agent-provider-tangle 3.6.6 → 3.6.8

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
@@ -245,7 +245,7 @@ So `create()` can return a sandbox that reports `running` while the platform sti
245
245
 
246
246
  Composing an environment also reads the sandbox's deployment capability document once, and a sandbox that is not yet running cannot answer that read, so an environment composed during provisioning would claim nothing for the rest of its life.
247
247
 
248
- `readyTimeoutMs` bounds the wait and defaults to `DEFAULT_TANGLE_READY_TIMEOUT_MS` (120 seconds, the Sandbox SDK's own default).
248
+ `readyTimeoutMs` is passed to the HTTP `Sandbox.create` request, including a cold image pull, and also bounds the subsequent wait for `running`. It defaults to `DEFAULT_TANGLE_READY_TIMEOUT_MS` (120 seconds). A client whose `create` method ignores request options keeps its own create timeout; the provider still uses `readyTimeoutMs` for its later wait.
249
249
 
250
250
  ```ts
251
251
  const provider = createTangleProvider({
@@ -1,6 +1,8 @@
1
1
  import { type BackendType, type CreateSandboxOptions } from "@tangle-network/sandbox";
2
2
  import type { CreateAgentEnvironmentInput, WorkspaceRequest } from "@tangle-network/agent-interface/environment-provider";
3
3
  import type { TangleModelCredentials } from "./tangle-types.js";
4
+ /** Immutable create evidence used to bind a later native resume to its restored snapshot. */
5
+ export declare const NATIVE_RESUME_CHECKPOINT_METADATA_KEY = "tangleNativeResumeCheckpointId";
4
6
  export declare function captureModelCredentials(value: TangleModelCredentials | undefined): TangleModelCredentials | undefined;
5
7
  export declare function sandboxOptionsFromCreateInput(input: CreateAgentEnvironmentInput, defaultBackend?: BackendType, parsedWorkspace?: WorkspaceRequest, modelCredentials?: TangleModelCredentials, subscriptionSelection?: boolean): CreateSandboxOptions;
6
8
  /**
@@ -5,6 +5,8 @@ import { assertBoundedJson, boundedIdentifier, boundedString, MAX_ARRAY_LENGTH,
5
5
  import { profileCredentialSource } from "./model-credential-source.js";
6
6
  import { sandboxResourcesFromResourceRequest } from "./tangle-resources.js";
7
7
  import { tangleRuntimeAttachments } from "./tangle-runtime-attachments.js";
8
+ /** Immutable create evidence used to bind a later native resume to its restored snapshot. */
9
+ export const NATIVE_RESUME_CHECKPOINT_METADATA_KEY = "tangleNativeResumeCheckpointId";
8
10
  export function captureModelCredentials(value) {
9
11
  if (value === undefined)
10
12
  return undefined;
@@ -78,9 +80,16 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
78
80
  if (recordsCredential && Object.hasOwn(input.metadata ?? {}, "modelCredentials")) {
79
81
  throw new Error("Tangle credential selection owns metadata.modelCredentials");
80
82
  }
81
- const metadata = recordsCredential
82
- ? { ...input.metadata, modelCredentials }
83
- : input.metadata;
83
+ if (Object.hasOwn(input.metadata ?? {}, NATIVE_RESUME_CHECKPOINT_METADATA_KEY)) {
84
+ throw new Error("Tangle owns the native resume checkpoint metadata");
85
+ }
86
+ const metadata = {
87
+ ...input.metadata,
88
+ ...(recordsCredential ? { modelCredentials } : {}),
89
+ ...(workspace.checkpoint === undefined ? {} : {
90
+ [NATIVE_RESUME_CHECKPOINT_METADATA_KEY]: boundedIdentifier(workspace.checkpoint.checkpointId, "Tangle native resume checkpoint id"),
91
+ }),
92
+ };
84
93
  if (input.providerOptions && Object.keys(input.providerOptions).length > 0) {
85
94
  throw new Error("Tangle create providerOptions are not supported");
86
95
  }
@@ -137,7 +146,7 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
137
146
  ...(Array.isArray(secrets) ? { secrets } : {}),
138
147
  ...(input.egress === undefined ? {} : { egressPolicy: sandboxEgressPolicy(input.egress) }),
139
148
  ...(input.billingOwner === undefined ? {} : { billingOwnerId: input.billingOwner }),
140
- ...(metadata ? { metadata } : {}),
149
+ ...(Object.keys(metadata).length > 0 ? { metadata } : {}),
141
150
  ...(input.name === undefined ? {} : { name: input.name }),
142
151
  ...(input.idempotencyKey === undefined ? {} : { idempotencyKey: input.idempotencyKey }),
143
152
  backend: {
@@ -1,6 +1,6 @@
1
1
  import { assertCliAuthReferenceSupported } from "@tangle-network/sandbox/auth";
2
2
  import { canonicalCandidateDigest } from "@tangle-network/agent-interface";
3
- import { captureModelCredentials } from "./tangle-create-options.js";
3
+ import { captureModelCredentials, NATIVE_RESUME_CHECKPOINT_METADATA_KEY } from "./tangle-create-options.js";
4
4
  import { AgentTurnInputSchema, deepFreeze } from "@tangle-network/agent-interface";
5
5
  import { AgentEnvironmentCapabilitiesSchema } from "@tangle-network/agent-interface/environment-provider";
6
6
  import { environmentEventFromSandboxEvent } from "./tangle-events.js";
@@ -101,6 +101,16 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
101
101
  const usageLog = createExecutionUsageLog();
102
102
  const assertCaptureInput = (input) => {
103
103
  const backend = promptOptionsFromTurnInput(input, { provider: providerName, environmentId }).backend;
104
+ if (input.nativeResume !== undefined) {
105
+ const checkpointId = box.metadata?.[NATIVE_RESUME_CHECKPOINT_METADATA_KEY];
106
+ const harness = backend?.type ?? backend?.profile?.harness;
107
+ if (checkpointId !== input.nativeResume.sourceCheckpointId ||
108
+ harness !== input.nativeResume.harness ||
109
+ (backend?.profile?.harness !== undefined && backend.profile.harness !== harness) ||
110
+ nativeReference === undefined || boundCredentialSource !== "subscription") {
111
+ throw new Error("Tangle native resume requires the exact restored checkpoint, harness, and selected subscription credential");
112
+ }
113
+ }
104
114
  const turnSource = backend?.profile === undefined ? undefined : profileCredentialSource(backend.profile);
105
115
  if (turnSource !== undefined && turnSource !== boundCredentialSource) {
106
116
  throw new Error("Tangle turn credential source differs from its environment; create a separate environment for that profile");
@@ -51,6 +51,7 @@ export function promptOptionsFromTurnInput(input, target) {
51
51
  return {
52
52
  ...(sessionId ? { sessionId } : {}),
53
53
  ...(input.model ? { model: input.model } : {}),
54
+ ...(input.nativeResume === undefined ? {} : { nativeResume: input.nativeResume }),
54
55
  ...(backend === undefined ? {} : { backend }),
55
56
  ...(input.timeoutMs !== undefined ? { timeoutMs: input.timeoutMs } : {}),
56
57
  ...(input.context ? { context: input.context } : {}),
@@ -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, sandboxRestoreFromCheckpoint } from "./tangle-create-options.js";
7
+ import { assertCreateInputShape, assertMappedCreateOptions, assertMappedSecretNames, assertNoInlineSecretValues, captureModelCredentials, NATIVE_RESUME_CHECKPOINT_METADATA_KEY, sandboxOptionsFromCreateInput, sandboxRestoreFromCheckpoint } from "./tangle-create-options.js";
8
8
  import { statusFromUnknown } from "./tangle-environment-values.js";
9
9
  import { requireNativeCaptureCapability, requireNativeCaptureProof } from "./tangle-native-capture-proof.js";
10
10
  import { awaitSandboxRunning, DEFAULT_TANGLE_READY_TIMEOUT_MS, } from "./tangle-readiness.js";
@@ -131,10 +131,16 @@ export function createTangleProvider(options) {
131
131
  createOptions.fromSandboxId !== restore?.fromSandboxId) {
132
132
  throw new Error("Tangle mapped create options must preserve the workspace checkpoint");
133
133
  }
134
+ if (createOptions.metadata?.[NATIVE_RESUME_CHECKPOINT_METADATA_KEY] !== checkpoint.checkpointId) {
135
+ throw new Error("Tangle mapped create options must preserve the native resume checkpoint binding");
136
+ }
134
137
  }
135
138
  else if (createOptions.fromSnapshot !== undefined || createOptions.fromSandboxId !== undefined) {
136
139
  throw new Error("Tangle mapped create options restore a snapshot the create input did not name");
137
140
  }
141
+ else if (createOptions.metadata?.[NATIVE_RESUME_CHECKPOINT_METADATA_KEY] !== undefined) {
142
+ throw new Error("Tangle mapped create options claim a native resume checkpoint without a restore");
143
+ }
138
144
  if (input.runtimeAttachments !== undefined &&
139
145
  (createOptions.backend?.runtimeAttachments === undefined ||
140
146
  canonicalCandidateDigest(input.runtimeAttachments) !== canonicalCandidateDigest(createOptions.backend.runtimeAttachments))) {
@@ -162,7 +168,7 @@ export function createTangleProvider(options) {
162
168
  throw new Error("Tangle native capture selected backend differs from the exact profile harness");
163
169
  }
164
170
  }
165
- const createPromise = options.client.create(createOptions, input.signal ? { signal: input.signal } : undefined);
171
+ const createPromise = options.client.create(createOptions, { timeoutMs: readyTimeoutMs, ...(input.signal ? { signal: input.signal } : {}) });
166
172
  let box;
167
173
  try {
168
174
  box = await awaitWithSignal(createPromise, input.signal);
@@ -815,9 +815,10 @@ export interface TangleProviderOptions {
815
815
  mapCreateInput?: (input: CreateAgentEnvironmentInput) => CreateSandboxOptions;
816
816
  exactProcess?: TangleExactProcessOptions;
817
817
  /**
818
- * How long `create()` waits for a new sandbox to reach `running` before it
819
- * fails. Defaults to `DEFAULT_TANGLE_READY_TIMEOUT_MS`, exported from this
820
- * package, which is the Sandbox SDK's own wait default of 120 seconds.
818
+ * Passed to the HTTP Sandbox creation request and the subsequent wait for
819
+ * `running`. A client that ignores create request options keeps its own
820
+ * create timeout. Defaults to `DEFAULT_TANGLE_READY_TIMEOUT_MS`, exported
821
+ * from this package (120 seconds).
821
822
  */
822
823
  readyTimeoutMs?: number;
823
824
  /** External provider-key and measurement verifier for confidential forks. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-provider-tangle",
3
- "version": "3.6.6",
3
+ "version": "3.6.8",
4
4
  "description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -128,7 +128,7 @@
128
128
  "dist/model-credential-capacity.d.ts"
129
129
  ],
130
130
  "dependencies": {
131
- "@tangle-network/agent-interface": "^3.0.0"
131
+ "@tangle-network/agent-interface": "^3.1.2"
132
132
  },
133
133
  "peerDependencies": {
134
134
  "@tangle-network/sandbox": ">=0.60.27 <1.0.0"