@tangle-network/agent-provider-tangle 1.8.1 → 1.9.1
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/exact-process.d.ts +1 -0
- package/dist/exact-process.js +13 -1
- package/dist/tangle-events.d.ts +2 -3
- package/dist/tangle-events.js +11 -14
- package/dist/tangle-evidence.d.ts +5 -2
- package/dist/tangle-evidence.js +31 -5
- package/dist/tangle-native-capture-proof.d.ts +5 -0
- package/dist/tangle-native-capture-proof.js +33 -0
- package/dist/tangle-provider.js +20 -1
- package/dist/tangle-types.d.ts +92 -86
- package/dist/tangle-workspace-branching.d.ts +1 -0
- package/dist/tangle-workspace-branching.js +6 -0
- package/package.json +6 -4
package/dist/exact-process.d.ts
CHANGED
package/dist/exact-process.js
CHANGED
|
@@ -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
|
-
|
|
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 = {}) {
|
package/dist/tangle-events.d.ts
CHANGED
|
@@ -6,9 +6,8 @@ export declare function isSandboxConnectionMarker(event: SandboxEvent): boolean;
|
|
|
6
6
|
* The session ids a Sandbox event carries, kept separate by field position.
|
|
7
7
|
*
|
|
8
8
|
* `runFrameSessionId` is `data.sessionId`/`data.sessionID`. The run/stream lane
|
|
9
|
-
* copies
|
|
10
|
-
*
|
|
11
|
-
* runtime session id.
|
|
9
|
+
* copies the public resume key from the adapter on `session.updated`.
|
|
10
|
+
* That key can differ from the Runtime session and is not native identity evidence.
|
|
12
11
|
*
|
|
13
12
|
* `envelopeSessionId` is the `properties` and `properties.info` position of an
|
|
14
13
|
* /agents/events frame, plus `properties.part` on a frame type that publishes a
|
package/dist/tangle-events.js
CHANGED
|
@@ -138,17 +138,15 @@ export function environmentEventFromSandboxEvent(event, expected = {}) {
|
|
|
138
138
|
if (Object.prototype.hasOwnProperty.call(data, "contextTransferReceipt")) {
|
|
139
139
|
throw new Error("Tangle Sandbox emitted an unsolicited context transfer receipt");
|
|
140
140
|
}
|
|
141
|
-
// A
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
// every position of every other frame type, names the runtime session and is
|
|
148
|
-
// compared to the expected id.
|
|
141
|
+
// A bound public stream can carry the adapter's resume key in session.updated.
|
|
142
|
+
// It is content, not evidence of provider-native identity or Runtime ownership.
|
|
143
|
+
// Envelope identities still bind the frame to the expected Runtime session.
|
|
144
|
+
if (record.type === "native.session.observed") {
|
|
145
|
+
throw new Error("Tangle public stream exposed a private native identity event");
|
|
146
|
+
}
|
|
149
147
|
const identity = sandboxEventIdentity(event);
|
|
150
|
-
const
|
|
151
|
-
const identityBearingSessionIds = carriedSessionIds(
|
|
148
|
+
const runFrameCarriesPublicResumeKey = expected.streamBound === true && record.type === "session.updated";
|
|
149
|
+
const identityBearingSessionIds = carriedSessionIds(runFrameCarriesPublicResumeKey
|
|
152
150
|
? { envelopeSessionId: identity.envelopeSessionId }
|
|
153
151
|
: identity);
|
|
154
152
|
if (expected.executionId !== undefined) {
|
|
@@ -180,8 +178,7 @@ export function environmentEventFromSandboxEvent(event, expected = {}) {
|
|
|
180
178
|
// Other event names do not prove whether their usage is incremental.
|
|
181
179
|
const usageMode = declaredModes[0] ??
|
|
182
180
|
(record.type === "result" || record.type === "done" ? "cumulative" : undefined);
|
|
183
|
-
//
|
|
184
|
-
// including the native id an execution-bound stream just accepted as content.
|
|
181
|
+
// Preserve the public resume key without promoting it to native attribution.
|
|
185
182
|
const normalized = normalizeSandboxEvent(record.type, data, identity);
|
|
186
183
|
return {
|
|
187
184
|
type: record.type,
|
|
@@ -210,8 +207,8 @@ function normalizeSandboxEvent(type, data, identity) {
|
|
|
210
207
|
// of the frame's own positions carries and introduces none of its own. Each
|
|
211
208
|
// position it can repeat is already bound: the check above compared every
|
|
212
209
|
// position that names the runtime session, and the run-frame position of a
|
|
213
|
-
// stream-bound `session.updated` holds the
|
|
214
|
-
// carries too. A frame that carries no session id can supply none either.
|
|
210
|
+
// stream-bound `session.updated` holds the public resume key the computed
|
|
211
|
+
// block carries too. A frame that carries no session id can supply none either.
|
|
215
212
|
if (parsed.data.type === "session.updated") {
|
|
216
213
|
if (!carriedSessionIds(identity).includes(parsed.data.sessionId)) {
|
|
217
214
|
throw new Error("Tangle Sandbox normalized event named a session the frame does not carry");
|
|
@@ -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
|
|
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;
|
package/dist/tangle-evidence.js
CHANGED
|
@@ -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
|
|
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
|
};
|
|
@@ -261,6 +268,13 @@ export async function captureTangleSandboxEvidence(box, options) {
|
|
|
261
268
|
}
|
|
262
269
|
nativeSessionId = native.nativeSessionId ?? null;
|
|
263
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
|
+
}
|
|
264
278
|
if (!/^sha256:[0-9a-f]{64}$/.test(native.sidecarImageDigest) ||
|
|
265
279
|
(options.expectedSidecarImageDigest !== undefined &&
|
|
266
280
|
native.sidecarImageDigest !== options.expectedSidecarImageDigest)) {
|
|
@@ -284,12 +298,12 @@ export async function captureTangleSandboxEvidence(box, options) {
|
|
|
284
298
|
}
|
|
285
299
|
const roots = new Set();
|
|
286
300
|
for (const root of native.nativeRoots) {
|
|
287
|
-
if (!["session-home", "workspace-session"].includes(root.
|
|
301
|
+
if (!["session-home", "workspace-session"].includes(root.rootScope) || roots.has(root.rootScope) ||
|
|
288
302
|
(root.path !== "." && canonicalEntryPath(root.path) !== root.path)) {
|
|
289
303
|
throw new Error("Tangle raw session native root is invalid");
|
|
290
304
|
}
|
|
291
|
-
roots.add(root.
|
|
292
|
-
nativeStore.roots.push(root);
|
|
305
|
+
roots.add(root.rootScope);
|
|
306
|
+
nativeStore.roots.push({ scope: root.rootScope, path: root.path });
|
|
293
307
|
}
|
|
294
308
|
if (!roots.size)
|
|
295
309
|
throw new Error("Tangle raw session has no native root");
|
|
@@ -365,7 +379,18 @@ export async function captureTangleSandboxEvidence(box, options) {
|
|
|
365
379
|
inventory.scannedSymlinks !== inventory.reportedSymlinks + inventory.excludedSymlinks) {
|
|
366
380
|
throw new Error("Tangle raw session inventory does not reconcile");
|
|
367
381
|
}
|
|
368
|
-
nativeStore.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
|
+
};
|
|
369
394
|
const ioSequences = new Map();
|
|
370
395
|
const frameMetadata = [];
|
|
371
396
|
for (const frame of native.processIo) {
|
|
@@ -471,6 +496,7 @@ export async function captureTangleSandboxEvidence(box, options) {
|
|
|
471
496
|
provider: "tangle-sandbox",
|
|
472
497
|
environmentId: box.id,
|
|
473
498
|
executionId: options.executionId,
|
|
499
|
+
...(captureProof ? { captureProof } : {}),
|
|
474
500
|
workspaceScope: "environment",
|
|
475
501
|
workspaceRoot,
|
|
476
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
|
+
}
|
package/dist/tangle-provider.js
CHANGED
|
@@ -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(
|
|
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 {
|
package/dist/tangle-types.d.ts
CHANGED
|
@@ -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,92 +638,8 @@ export interface SandboxSessionLike {
|
|
|
550
638
|
offset?: number;
|
|
551
639
|
since?: number;
|
|
552
640
|
}): Promise<unknown[]>;
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
sessionId: string;
|
|
556
|
-
backendType: string;
|
|
557
|
-
nativeSessionId?: string;
|
|
558
|
-
sidecarImageDigest: string;
|
|
559
|
-
sidecarBundleRevision: string;
|
|
560
|
-
nativeRoots: Array<{
|
|
561
|
-
scope: "session-home" | "workspace-session";
|
|
562
|
-
path: string;
|
|
563
|
-
}>;
|
|
564
|
-
inventory: {
|
|
565
|
-
scannedFiles: number;
|
|
566
|
-
reportedFiles: number;
|
|
567
|
-
excludedFiles: number;
|
|
568
|
-
scannedDirectories: number;
|
|
569
|
-
reportedDirectories: number;
|
|
570
|
-
excludedDirectories: number;
|
|
571
|
-
scannedSymlinks: number;
|
|
572
|
-
reportedSymlinks: number;
|
|
573
|
-
excludedSymlinks: number;
|
|
574
|
-
skippedEntries: 0;
|
|
575
|
-
};
|
|
576
|
-
files: Array<{
|
|
577
|
-
rootScope: "session-home" | "workspace-session";
|
|
578
|
-
path: string;
|
|
579
|
-
kind: "file" | "directory" | "symlink";
|
|
580
|
-
mode: number;
|
|
581
|
-
uid: number;
|
|
582
|
-
gid: number;
|
|
583
|
-
mtimeMs: number;
|
|
584
|
-
ctimeMs: number;
|
|
585
|
-
sizeBytes: number;
|
|
586
|
-
sha256?: string;
|
|
587
|
-
contentBase64?: string;
|
|
588
|
-
linkTarget?: string;
|
|
589
|
-
}>;
|
|
590
|
-
processIo: Array<{
|
|
591
|
-
processId: string;
|
|
592
|
-
sequence: number;
|
|
593
|
-
at: string;
|
|
594
|
-
stream: "stdin" | "stdout" | "stderr" | "protocol";
|
|
595
|
-
sizeBytes: number;
|
|
596
|
-
sha256: string;
|
|
597
|
-
contentBase64: string;
|
|
598
|
-
metadata?: unknown;
|
|
599
|
-
}>;
|
|
600
|
-
processTerminals: Array<{
|
|
601
|
-
processId: string;
|
|
602
|
-
sequence: number;
|
|
603
|
-
at: string;
|
|
604
|
-
result: {
|
|
605
|
-
code: number | null;
|
|
606
|
-
signal: string | null;
|
|
607
|
-
timedOut: boolean;
|
|
608
|
-
timeoutReason: string | null;
|
|
609
|
-
captureError: null;
|
|
610
|
-
spawnError?: string;
|
|
611
|
-
};
|
|
612
|
-
}>;
|
|
613
|
-
events: unknown[];
|
|
614
|
-
excluded: Array<{
|
|
615
|
-
rootScope: "session-home" | "workspace-session";
|
|
616
|
-
path: string;
|
|
617
|
-
kind: "file" | "directory" | "symlink";
|
|
618
|
-
mode: number;
|
|
619
|
-
uid: number;
|
|
620
|
-
gid: number;
|
|
621
|
-
mtimeMs: number;
|
|
622
|
-
ctimeMs: number;
|
|
623
|
-
sizeBytes: number;
|
|
624
|
-
reason: "credential";
|
|
625
|
-
}>;
|
|
626
|
-
completeness: {
|
|
627
|
-
nativeStore: true;
|
|
628
|
-
processIo: true;
|
|
629
|
-
events: true;
|
|
630
|
-
};
|
|
631
|
-
coverageComplete: true;
|
|
632
|
-
} | {
|
|
633
|
-
status: "unavailable";
|
|
634
|
-
sessionId: string;
|
|
635
|
-
backendType: string;
|
|
636
|
-
nativeSessionId?: string;
|
|
637
|
-
reason: string;
|
|
638
|
-
}>;
|
|
641
|
+
/** The SDK returns generic records. Validate their shape before retaining any bytes. */
|
|
642
|
+
rawEvidence?(): Promise<unknown>;
|
|
639
643
|
/** Exact native coding-agent TUI bound to this session id. */
|
|
640
644
|
interactive?(options?: {
|
|
641
645
|
ref?: AgentInteractiveSessionRef;
|
|
@@ -707,6 +711,8 @@ export interface TangleProviderOptions {
|
|
|
707
711
|
name?: string;
|
|
708
712
|
/** Overrides an inline profile's harness when create() names no backend. */
|
|
709
713
|
defaultBackend?: BackendType;
|
|
714
|
+
/** Require the selected Sandbox host to prove native session capture for every create. */
|
|
715
|
+
requireNativeSessionCapture?: boolean;
|
|
710
716
|
/**
|
|
711
717
|
* Stored model credential and endpoint used by the default create mapping.
|
|
712
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.
|
|
3
|
+
"version": "1.9.1",
|
|
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",
|
|
@@ -101,10 +103,10 @@
|
|
|
101
103
|
"LICENSE"
|
|
102
104
|
],
|
|
103
105
|
"dependencies": {
|
|
104
|
-
"@tangle-network/agent-interface": "^2.
|
|
106
|
+
"@tangle-network/agent-interface": "^2.15.0"
|
|
105
107
|
},
|
|
106
108
|
"peerDependencies": {
|
|
107
|
-
"@tangle-network/sandbox": ">=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.
|
|
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"
|