@tangle-network/agent-provider-tangle 1.9.2 → 3.0.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 +32 -7
- package/dist/exact-process.js +6 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/tangle-environment-session.d.ts +1 -1
- package/dist/tangle-environment-session.js +16 -9
- package/dist/tangle-environment.d.ts +4 -1
- package/dist/tangle-environment.js +25 -6
- package/dist/tangle-evidence.d.ts +19 -16
- package/dist/tangle-evidence.js +331 -102
- package/dist/tangle-native-capture-proof.d.ts +5 -4
- package/dist/tangle-native-capture-proof.js +14 -12
- package/dist/tangle-provider.js +25 -5
- package/dist/tangle-types.d.ts +54 -15
- package/dist/tangle-workspace-branching.js +11 -5
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @tangle-network/agent-provider-tangle
|
|
2
2
|
|
|
3
3
|
Wraps `@tangle-network/sandbox` as an `AgentEnvironmentProvider`.
|
|
4
|
-
The peer range is `>=0.
|
|
4
|
+
The Sandbox peer range is `>=0.58.4 <1.0.0`.
|
|
5
5
|
The floor includes runtime MCP attachment transport and preservation across per-turn model credential overrides.
|
|
6
6
|
|
|
7
7
|
Runtime MCP bindings travel through `CreateAgentEnvironmentInput.runtimeAttachments` to Sandbox's `backend.runtimeAttachments`.
|
|
@@ -455,12 +455,19 @@ The adapter rejects ordinary sandboxes during create, recovery, and list operati
|
|
|
455
455
|
|
|
456
456
|
## Private session evidence
|
|
457
457
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
458
|
+
Set `requireNativeSessionCapture: true` when the provider must retain complete native evidence.
|
|
459
|
+
Sandbox selects a host with fresh capture proof and returns proof for the created container.
|
|
460
|
+
The provider matches that proof to the create receipt before returning the environment.
|
|
461
|
+
Agent creation and reconnect check the selected container's capture protocol and exact backend through `box.capabilities()`.
|
|
462
|
+
Unsupported agent capture refuses before a model turn.
|
|
463
|
+
A newly created container is cleaned up when its required proof is missing.
|
|
464
|
+
An unrelated host or pending fleet update does not determine this container's admission.
|
|
465
|
+
|
|
466
|
+
Exact-process creation retains its container proof and existing managed-process output and terminal contracts.
|
|
467
|
+
Checkpoint restoration requires its container proof and exact source/checkpoint identity.
|
|
468
|
+
A restored agent environment verifies its actual backend when reconnected.
|
|
469
|
+
The capture requirement also reaches checkpoint operations exposed by an environment.
|
|
470
|
+
Fleet capability summaries are diagnostic observations, not placement admission.
|
|
464
471
|
|
|
465
472
|
Call `captureTangleEnvironmentEvidence(environment, options)` before destroying a provider environment.
|
|
466
473
|
For a Runtime-owned box, call `captureTangleSandboxEvidence(box, options)` with exact session and execution IDs.
|
|
@@ -469,6 +476,24 @@ Both functions return private binary files and provenance for the workspace, nat
|
|
|
469
476
|
The caller must store those bytes in private durable custody before deleting the box.
|
|
470
477
|
Credential exclusions remain listed with path, type, owner IDs, timestamps, mode, size, and reason.
|
|
471
478
|
Each process stream has exact frame order and a terminal receipt.
|
|
479
|
+
The attempt inventory binds each Sidecar execution and retry to provider sessions, observed native sessions, and recorded processes.
|
|
480
|
+
Each session has one `raw-manifest.json` in its private archive.
|
|
481
|
+
Each execution binds to its original HOME through `evidenceSources`.
|
|
482
|
+
Native files and process streams use that source ID in their archive paths.
|
|
483
|
+
Rotations keep earlier HOMEs until durable capture permits session deletion.
|
|
484
|
+
Every readable process spool keeps its exact original bytes in `processSources`.
|
|
485
|
+
It preserves all response metadata, including unknown fields, attempts, event buffers, terminal results, exclusions, and skipped paths.
|
|
486
|
+
Known `contentBase64` fields become JSON pointers in `contentRefs`.
|
|
487
|
+
Each pointer names the archive file whose verified bytes reconstruct that field.
|
|
488
|
+
Binary bytes are stored once.
|
|
489
|
+
An unavailable response also keeps its original metadata.
|
|
490
|
+
Sidecar execution IDs join `sessions[].executionIds`; the outer execution ID names the Runtime node.
|
|
491
|
+
Partial capture retains the readable native files, process frames, and events in the same archive.
|
|
492
|
+
Its missing reasons prevent a complete receipt and keep the source available for recovery.
|
|
493
|
+
An unknown attempt outcome or native session identity remains explicit.
|
|
494
|
+
Reconnecting uses the execution ID from the validated durable control reference.
|
|
495
|
+
Earlier executions without retained caller attribution stay in the raw manifest with explicit gaps.
|
|
496
|
+
The caller's attempt projection includes only its known execution IDs.
|
|
472
497
|
The capture records the running sidecar image digest and the served Sidecar bundle revision.
|
|
473
498
|
The image digest can be compared with the pre-create proof only when that proof identifies the actual placement image.
|
|
474
499
|
An incomplete inventory, missing stream, unrelated backend, or mismatched digest does not produce complete evidence.
|
package/dist/exact-process.js
CHANGED
|
@@ -1,7 +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 {
|
|
4
|
+
import { requireNativeCaptureProof } from "./tangle-native-capture-proof.js";
|
|
5
5
|
import { assertExactProcessSandbox, assertSupportedProviderOptions, assertUnreservedMetadata, EXACT_PROCESS_METADATA_KEY, isExactProcessRequestConflict, isExactProcessSandbox, metadataMatches, assertSignalOptions, } from "./tangle-exact-process-validation.js";
|
|
6
6
|
const IMMUTABLE_TANGLE_IMAGE = /^(?:sha256:[a-f0-9]{64}|\S+@sha256:[a-f0-9]{64})$/i;
|
|
7
7
|
export function createTangleExactProcessProvider(input) {
|
|
@@ -22,8 +22,6 @@ export function createTangleExactProcessProvider(input) {
|
|
|
22
22
|
assertUnreservedMetadata(createInput.metadata);
|
|
23
23
|
const identityDigest = exactProcessRequestDigest(createInput, providerName, options);
|
|
24
24
|
createInput.signal?.throwIfAborted();
|
|
25
|
-
if (input.requireNativeSessionCapture)
|
|
26
|
-
await requireNativeCaptureCapability(client);
|
|
27
25
|
const createPromise = client.create({
|
|
28
26
|
...exactSandboxOptions(createInput, options, providerName, identityDigest),
|
|
29
27
|
...(input.requireNativeSessionCapture ? { requireNativeSessionCapture: true } : {}),
|
|
@@ -41,7 +39,7 @@ export function createTangleExactProcessProvider(input) {
|
|
|
41
39
|
if (createInput.signal?.aborted) {
|
|
42
40
|
void createPromise
|
|
43
41
|
.then(async (lateBox) => {
|
|
44
|
-
if (!lateBox.delete) {
|
|
42
|
+
if (lateBox.createReceipt?.()?.outcome !== "created" || !lateBox.delete) {
|
|
45
43
|
attachCleanupHandle(error, lateBox);
|
|
46
44
|
return;
|
|
47
45
|
}
|
|
@@ -80,6 +78,10 @@ export function createTangleExactProcessProvider(input) {
|
|
|
80
78
|
if (isExactProcessRequestConflict(box, providerName, options.teamId, createInput.idempotencyKey, identityDigest)) {
|
|
81
79
|
throw new Error("Tangle exact process idempotency key conflicts with an existing request", { cause: error });
|
|
82
80
|
}
|
|
81
|
+
if (box.createReceipt?.()?.outcome !== "created") {
|
|
82
|
+
attachCleanupHandle(error, box);
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
83
85
|
if (!box.delete) {
|
|
84
86
|
const baseError = error instanceof Error ? error : new Error(String(error));
|
|
85
87
|
throw Object.assign(baseError, {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export { JsonBoundError, MAX_INLINE_PAYLOAD_BYTES, MAX_PAYLOAD_STRING_BYTES, MAX
|
|
|
3
3
|
export type { JsonBoundRule, JsonBoundViolation } from "./tangle-contract-safety.js";
|
|
4
4
|
export * from "./tangle-types.js";
|
|
5
5
|
export { createTangleProvider } from "./tangle-provider.js";
|
|
6
|
-
export {
|
|
7
|
-
export type {
|
|
6
|
+
export { captureTangleEnvironmentEvidence, captureTangleSandboxEvidence } from "./tangle-evidence.js";
|
|
7
|
+
export type { TangleEnvironmentEvidence, TangleEnvironmentEvidenceOptions, TangleSandboxEvidenceOptions } from "./tangle-evidence.js";
|
|
8
8
|
export { DEFAULT_TANGLE_READY_TIMEOUT_MS } from "./tangle-readiness.js";
|
|
9
9
|
export { defaultTangleSandboxCapabilities } from "./tangle-capabilities.js";
|
|
10
10
|
export { createTangleWorkspaceBranching, supportsWorkspaceBranching, } from "./tangle-workspace-branching.js";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { JsonBoundError, MAX_INLINE_PAYLOAD_BYTES, MAX_PAYLOAD_STRING_BYTES, MAX_TOTAL_PAYLOAD_BYTES, } from "./tangle-contract-safety.js";
|
|
2
2
|
export * from "./tangle-types.js";
|
|
3
3
|
export { createTangleProvider } from "./tangle-provider.js";
|
|
4
|
-
export {
|
|
4
|
+
export { captureTangleEnvironmentEvidence, captureTangleSandboxEvidence } from "./tangle-evidence.js";
|
|
5
5
|
export { DEFAULT_TANGLE_READY_TIMEOUT_MS } from "./tangle-readiness.js";
|
|
6
6
|
export { defaultTangleSandboxCapabilities } from "./tangle-capabilities.js";
|
|
7
7
|
export { createTangleWorkspaceBranching, supportsWorkspaceBranching, } from "./tangle-workspace-branching.js";
|
|
@@ -23,5 +23,5 @@ type ExactExecutionEventStream = (options: {
|
|
|
23
23
|
* environment observation reads it, because Sandbox reports usage per
|
|
24
24
|
* execution result and never for the environment.
|
|
25
25
|
*/
|
|
26
|
-
export declare function sandboxSessionAsAgentSession(session: SandboxSessionLike, controlRef: AgentRunControlRef | undefined, provider: string, environmentId: string, dispatch: ((input: AgentTurnInput) => Promise<AgentSessionRef>) | undefined, exactExecutionEvents: ExactExecutionEventStream | undefined, retainedControl: boolean, interactionResponses: boolean, usageLog?: ExecutionUsageLog, nativeContinuation?: boolean): AgentSession;
|
|
26
|
+
export declare function sandboxSessionAsAgentSession(session: SandboxSessionLike, controlRef: AgentRunControlRef | undefined, provider: string, environmentId: string, dispatch: ((input: AgentTurnInput) => Promise<AgentSessionRef>) | undefined, exactExecutionEvents: ExactExecutionEventStream | undefined, retainedControl: boolean, interactionResponses: boolean, usageLog?: ExecutionUsageLog, nativeContinuation?: boolean, beforePrompt?: (input: AgentTurnInput) => void, onExecution?: (executionId: string) => void): AgentSession;
|
|
27
27
|
export {};
|
|
@@ -24,14 +24,16 @@ import { hasReplayPayload, interruptExecutionAfterAbort, sessionPromptRequestDig
|
|
|
24
24
|
* environment observation reads it, because Sandbox reports usage per
|
|
25
25
|
* execution result and never for the environment.
|
|
26
26
|
*/
|
|
27
|
-
export function sandboxSessionAsAgentSession(session, controlRef, provider, environmentId, dispatch, exactExecutionEvents, retainedControl, interactionResponses, usageLog, nativeContinuation = false) {
|
|
27
|
+
export function sandboxSessionAsAgentSession(session, controlRef, provider, environmentId, dispatch, exactExecutionEvents, retainedControl, interactionResponses, usageLog, nativeContinuation = false, beforePrompt, onExecution) {
|
|
28
28
|
const measured = (executionId, result) => {
|
|
29
29
|
usageLog?.record(executionId, result.usage);
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
|
-
let activeControlRef = controlRef
|
|
33
|
-
?
|
|
34
|
-
:
|
|
32
|
+
let activeControlRef = controlRef === undefined
|
|
33
|
+
? undefined
|
|
34
|
+
: resolveRetainedSessionControlRef(controlRef, session.id, provider, environmentId);
|
|
35
|
+
if (activeControlRef !== undefined)
|
|
36
|
+
onExecution?.(activeControlRef.executionId);
|
|
35
37
|
let promptInFlight = false;
|
|
36
38
|
const respondToInteraction = interactionResponses && typeof session.respondToInteraction === "function"
|
|
37
39
|
? tangleInteractionResponder({
|
|
@@ -315,6 +317,7 @@ export function sandboxSessionAsAgentSession(session, controlRef, provider, envi
|
|
|
315
317
|
}));
|
|
316
318
|
},
|
|
317
319
|
async prompt(input) {
|
|
320
|
+
beforePrompt?.(input);
|
|
318
321
|
AgentTurnInputSchema.parse(input);
|
|
319
322
|
input.signal?.throwIfAborted();
|
|
320
323
|
if (promptInFlight) {
|
|
@@ -356,6 +359,7 @@ export function sandboxSessionAsAgentSession(session, controlRef, provider, envi
|
|
|
356
359
|
// The admission receipt is the durability boundary. Store it before
|
|
357
360
|
// waiting for the result so an aborted caller can reconnect later.
|
|
358
361
|
activeControlRef = nextControlRef;
|
|
362
|
+
onExecution?.(nextControlRef.executionId);
|
|
359
363
|
const result = await awaitWithSignal(session.result({
|
|
360
364
|
executionId: nextControlRef.executionId,
|
|
361
365
|
...(input.signal ? { signal: input.signal } : {}),
|
|
@@ -429,12 +433,15 @@ export function sandboxSessionAsAgentSession(session, controlRef, provider, envi
|
|
|
429
433
|
executionId,
|
|
430
434
|
controlRef: targetControlRef,
|
|
431
435
|
};
|
|
436
|
+
const prompt = promptFromTurnInput(input);
|
|
437
|
+
const promptOptions = promptOptionsFromTurnInput(promptInput, {
|
|
438
|
+
provider,
|
|
439
|
+
environmentId,
|
|
440
|
+
sessionId: session.id,
|
|
441
|
+
});
|
|
442
|
+
onExecution?.(executionId);
|
|
432
443
|
try {
|
|
433
|
-
const result = await awaitWithSignal(session.prompt(
|
|
434
|
-
provider,
|
|
435
|
-
environmentId,
|
|
436
|
-
sessionId: session.id,
|
|
437
|
-
})), input.signal);
|
|
444
|
+
const result = await awaitWithSignal(session.prompt(prompt, promptOptions), input.signal);
|
|
438
445
|
input.signal?.throwIfAborted();
|
|
439
446
|
const resultRecord = validatedSandboxPromptResult(result);
|
|
440
447
|
if (resultRecord.executionId !== executionId) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentEnvironment, AgentEnvironmentCapabilities, ResourceProfile } from "@tangle-network/agent-interface/environment-provider";
|
|
2
|
-
import type { SandboxClientLike, SandboxInstanceLike } from "./tangle-types.js";
|
|
2
|
+
import type { SandboxClientLike, SandboxInstanceLike, SandboxRuntimeCapabilityDocument } from "./tangle-types.js";
|
|
3
3
|
import type { TangleConfidentialAttestationVerifier } from "./tangle-types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Compose one concrete sandbox into an environment.
|
|
@@ -29,4 +29,7 @@ export declare function sandboxInstanceAsEnvironment(box: SandboxInstanceLike, p
|
|
|
29
29
|
}, request?: {
|
|
30
30
|
resources?: ResourceProfile;
|
|
31
31
|
confidentialAttestationVerifier?: TangleConfidentialAttestationVerifier;
|
|
32
|
+
requireNativeSessionCapture?: boolean;
|
|
33
|
+
captureCapabilities?: SandboxRuntimeCapabilityDocument;
|
|
34
|
+
captureHarness?: string;
|
|
32
35
|
}): Promise<AgentEnvironment>;
|
|
@@ -2,11 +2,10 @@ import { AgentTurnInputSchema, deepFreeze } from "@tangle-network/agent-interfac
|
|
|
2
2
|
import { AgentEnvironmentCapabilitiesSchema } from "@tangle-network/agent-interface/environment-provider";
|
|
3
3
|
import { environmentEventFromSandboxEvent } from "./tangle-events.js";
|
|
4
4
|
import { executionIdFromTurnInput, promptFromTurnInput, promptOptionsFromTurnInput, } from "./tangle-prompt.js";
|
|
5
|
-
import { resolveRetainedSessionControlRef } from "./tangle-session-control.js";
|
|
6
5
|
import { creationFromSandboxCreateReceipt, placementInfoFromLoopPlacement, statusFromUnknown, } from "./tangle-environment-values.js";
|
|
7
6
|
import { execResultFromSandboxExecResult } from "./tangle-result-values.js";
|
|
8
7
|
import { capabilitiesForSandbox, frozenCapabilityDocument, sandboxCapabilitySupport, } from "./tangle-capabilities.js";
|
|
9
|
-
import { readDeploymentCapabilitySupport } from "./tangle-deployment-capabilities.js";
|
|
8
|
+
import { deploymentCapabilitySupport, readDeploymentCapabilitySupport } from "./tangle-deployment-capabilities.js";
|
|
10
9
|
import { awaitWithSignal, assertBoundedJson, boundedIdentifier, boundedString, } from "./tangle-contract-safety.js";
|
|
11
10
|
import { assertExecOptions, assertOptionKeys, } from "./tangle-environment-validation.js";
|
|
12
11
|
import { interruptExecutionAfterAbort, } from "./tangle-environment-control.js";
|
|
@@ -20,6 +19,7 @@ import { createTangleTerminalRegistry } from "./tangle-terminal.js";
|
|
|
20
19
|
import { createTangleInteractiveAgentRegistry } from "./tangle-interactive.js";
|
|
21
20
|
import { confidentialVerifierOption, createTangleWorkspaceBranching, } from "./tangle-workspace-branching.js";
|
|
22
21
|
import { bindTangleEvidenceEnvironment, noteTangleSession } from "./tangle-evidence.js";
|
|
22
|
+
import { assertNativeCaptureHarness } from "./tangle-native-capture-proof.js";
|
|
23
23
|
/**
|
|
24
24
|
* Compose one concrete sandbox into an environment.
|
|
25
25
|
*
|
|
@@ -53,7 +53,9 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
53
53
|
assertBoundedJson(box.metadata, "Tangle environment metadata");
|
|
54
54
|
}
|
|
55
55
|
const support = sandboxCapabilitySupport(box, client, request?.resources);
|
|
56
|
-
const deployment =
|
|
56
|
+
const deployment = request?.captureCapabilities === undefined
|
|
57
|
+
? await readDeploymentCapabilitySupport(box, operation)
|
|
58
|
+
: deploymentCapabilitySupport(request.captureCapabilities);
|
|
57
59
|
const capabilities = frozenCapabilityDocument(AgentEnvironmentCapabilitiesSchema.parse(capabilitiesForSandbox(declaredCapabilities, support, deployment, confidentialVerifierOption(request?.confidentialAttestationVerifier))));
|
|
58
60
|
const workspaceBranching = capabilities.branching.checkpoint &&
|
|
59
61
|
capabilities.branching.fork &&
|
|
@@ -64,6 +66,7 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
64
66
|
client,
|
|
65
67
|
provider: providerName,
|
|
66
68
|
...confidentialVerifierOption(request?.confidentialAttestationVerifier),
|
|
69
|
+
...(request?.requireNativeSessionCapture ? { requireNativeSessionCapture: true } : {}),
|
|
67
70
|
})
|
|
68
71
|
: undefined;
|
|
69
72
|
// The published document is the single source for what this environment
|
|
@@ -73,6 +76,18 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
73
76
|
// Usage is measured per execution, so the log collects what runs through
|
|
74
77
|
// this handle and the observation reports the newest record it holds.
|
|
75
78
|
const usageLog = createExecutionUsageLog();
|
|
79
|
+
const assertCaptureInput = (input) => {
|
|
80
|
+
if (!request?.requireNativeSessionCapture)
|
|
81
|
+
return;
|
|
82
|
+
if (!request.captureCapabilities)
|
|
83
|
+
throw new Error("Tangle native capture has no measured container capability document");
|
|
84
|
+
const backend = promptOptionsFromTurnInput(input, { provider: providerName, environmentId }).backend;
|
|
85
|
+
const profileHarness = typeof backend?.profile === "object" ? backend.profile.harness : undefined;
|
|
86
|
+
if (backend?.type !== undefined && profileHarness !== undefined && backend.type !== profileHarness) {
|
|
87
|
+
throw new Error("Tangle native capture turn backend differs from its exact profile harness");
|
|
88
|
+
}
|
|
89
|
+
assertNativeCaptureHarness(request.captureCapabilities, backend?.type ?? profileHarness ?? request.captureHarness);
|
|
90
|
+
};
|
|
76
91
|
// The single destroy this handle performs, once it has been asked for.
|
|
77
92
|
let destruction;
|
|
78
93
|
const terminals = capabilities.interactiveTerminal?.attach === true
|
|
@@ -82,9 +97,13 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
82
97
|
capabilities.interactiveAgent.control === true
|
|
83
98
|
? createTangleInteractiveAgentRegistry(box, providerName, environmentId)
|
|
84
99
|
: undefined;
|
|
85
|
-
const
|
|
100
|
+
const dispatchRun = capabilities.streaming.detach && box.dispatchPrompt
|
|
86
101
|
? dispatchEnvironmentRun(box, providerName, environmentId)
|
|
87
102
|
: undefined;
|
|
103
|
+
const dispatch = dispatchRun === undefined ? undefined : (input) => {
|
|
104
|
+
assertCaptureInput(input);
|
|
105
|
+
return dispatchRun(input);
|
|
106
|
+
};
|
|
88
107
|
const exactExecutionEvents = (options) => box.streamPrompt("", {
|
|
89
108
|
sessionId: options.sessionId,
|
|
90
109
|
executionId: options.executionId,
|
|
@@ -113,6 +132,7 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
113
132
|
async *stream(input) {
|
|
114
133
|
AgentTurnInputSchema.parse(input);
|
|
115
134
|
input.signal?.throwIfAborted();
|
|
135
|
+
assertCaptureInput(input);
|
|
116
136
|
const expectedExecutionId = executionIdFromTurnInput(input);
|
|
117
137
|
const expectedSessionId = input.sessionId ?? input.controlRef?.sessionId;
|
|
118
138
|
if (expectedSessionId)
|
|
@@ -175,7 +195,6 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
175
195
|
? {
|
|
176
196
|
session(id, options) {
|
|
177
197
|
boundedIdentifier(id, "Tangle session id");
|
|
178
|
-
noteTangleSession(environment, id);
|
|
179
198
|
assertOptionKeys(options, ["controlRef", "signal"], "Tangle session");
|
|
180
199
|
options?.signal?.throwIfAborted();
|
|
181
200
|
const session = box.session?.(id, options?.signal ? { signal: options.signal } : undefined);
|
|
@@ -186,7 +205,7 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
186
205
|
if (session.id !== id) {
|
|
187
206
|
throw new Error("sandbox session(id) returned an unrelated session");
|
|
188
207
|
}
|
|
189
|
-
const agentSession = sandboxSessionAsAgentSession(session,
|
|
208
|
+
const agentSession = sandboxSessionAsAgentSession(session, options?.controlRef, providerName, environmentId, dispatch, exactExecutionEvents, retainedControl, interactionResponses, usageLog, capabilities.nativeContinuation !== undefined, assertCaptureInput, (executionId) => noteTangleSession(environment, id, executionId));
|
|
190
209
|
// sessions.continue was granted from the probe session and the
|
|
191
210
|
// deployment document together; this backstop holds every
|
|
192
211
|
// concrete session to that grant, so a client whose sessions
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
import type { AgentProfile
|
|
1
|
+
import type { AgentProfile } from "@tangle-network/agent-interface";
|
|
2
2
|
import type { AgentEnvironment } from "@tangle-network/agent-interface/environment-provider";
|
|
3
|
-
import type { NativeCaptureProofLike,
|
|
4
|
-
export interface TangleEvidenceCapabilities {
|
|
5
|
-
readonly workspaceCaptureV1: true;
|
|
6
|
-
readonly nativeSessionCaptureV1: boolean;
|
|
7
|
-
readonly nativeSessionCaptureHarnesses: readonly HarnessType[];
|
|
8
|
-
readonly sidecarImageDigest: string;
|
|
9
|
-
}
|
|
10
|
-
/** Read a deployment guarantee once, before Runtime starts creating environments. */
|
|
11
|
-
export declare function readTangleEvidenceCapabilities(client: SandboxClientLike): Promise<TangleEvidenceCapabilities>;
|
|
12
|
-
/** Require the exact profile harness in the deployment's verified admission list. */
|
|
13
|
-
export declare function assertTangleEvidenceProfileCapability(document: TangleEvidenceCapabilities, profile: AgentProfile): void;
|
|
14
|
-
/** Refuse unsupported or unproven native trace retention before Sandbox create. */
|
|
15
|
-
export declare function assertTangleEvidenceCapability(client: SandboxClientLike, profile: AgentProfile): Promise<void>;
|
|
3
|
+
import type { NativeCaptureProofLike, SandboxInstanceLike, TangleEvidenceAttemptLike, TangleEvidenceSourceLike } from "./tangle-types.js";
|
|
16
4
|
interface WorkspaceEntryMetadata {
|
|
17
5
|
path: string;
|
|
18
6
|
type: "file" | "directory" | "symlink";
|
|
@@ -69,6 +57,7 @@ export interface TangleEnvironmentEvidence {
|
|
|
69
57
|
reportedDirectories: number;
|
|
70
58
|
complete: true;
|
|
71
59
|
};
|
|
60
|
+
attempts: TangleEvidenceAttemptLike[];
|
|
72
61
|
sessions: Array<{
|
|
73
62
|
id: string;
|
|
74
63
|
executionId: string;
|
|
@@ -83,11 +72,13 @@ export interface TangleEnvironmentEvidence {
|
|
|
83
72
|
messageScope: "session";
|
|
84
73
|
nativeSessionId: string | null;
|
|
85
74
|
nativeReason: string | null;
|
|
75
|
+
evidenceSources: TangleEvidenceSourceLike[];
|
|
86
76
|
nativeStore: {
|
|
87
77
|
scope: "session";
|
|
88
78
|
roots: Array<{
|
|
89
79
|
scope: "session-home" | "workspace-session";
|
|
90
80
|
path: string;
|
|
81
|
+
sourceId?: string;
|
|
91
82
|
}>;
|
|
92
83
|
inventory: {
|
|
93
84
|
scannedFiles: number;
|
|
@@ -99,10 +90,11 @@ export interface TangleEnvironmentEvidence {
|
|
|
99
90
|
scannedSymlinks: number;
|
|
100
91
|
reportedSymlinks: number;
|
|
101
92
|
excludedSymlinks: number;
|
|
102
|
-
skippedEntries:
|
|
93
|
+
skippedEntries: number;
|
|
103
94
|
} | null;
|
|
104
95
|
complete: boolean;
|
|
105
96
|
entries: Array<{
|
|
97
|
+
sourceId?: string;
|
|
106
98
|
rootScope: "session-home" | "workspace-session";
|
|
107
99
|
path: string;
|
|
108
100
|
kind: "file" | "directory" | "symlink";
|
|
@@ -116,6 +108,7 @@ export interface TangleEnvironmentEvidence {
|
|
|
116
108
|
linkTarget: string | null;
|
|
117
109
|
}>;
|
|
118
110
|
excludedPaths: Array<{
|
|
111
|
+
sourceId?: string;
|
|
119
112
|
rootScope: "session-home" | "workspace-session";
|
|
120
113
|
path: string;
|
|
121
114
|
kind: "file" | "directory" | "symlink";
|
|
@@ -137,8 +130,17 @@ export interface TangleEnvironmentEvidence {
|
|
|
137
130
|
stdoutBytes: number;
|
|
138
131
|
stderrBytes: number;
|
|
139
132
|
protocolBytes: number;
|
|
133
|
+
sources: Array<{
|
|
134
|
+
sourceId: string;
|
|
135
|
+
path: string;
|
|
136
|
+
sizeBytes: number;
|
|
137
|
+
sha256: string;
|
|
138
|
+
}>;
|
|
140
139
|
terminals: Array<{
|
|
141
140
|
processId: string;
|
|
141
|
+
executionId?: string;
|
|
142
|
+
ordinal?: number;
|
|
143
|
+
providerSessionId?: string;
|
|
142
144
|
sequence: number;
|
|
143
145
|
at: string;
|
|
144
146
|
result: {
|
|
@@ -146,12 +148,13 @@ export interface TangleEnvironmentEvidence {
|
|
|
146
148
|
signal: string | null;
|
|
147
149
|
timedOut: boolean;
|
|
148
150
|
timeoutReason: string | null;
|
|
149
|
-
captureError: null;
|
|
151
|
+
captureError: string | null;
|
|
150
152
|
spawnError?: string;
|
|
151
153
|
};
|
|
152
154
|
}>;
|
|
153
155
|
};
|
|
154
156
|
nativeEvents: {
|
|
157
|
+
scope: "execution";
|
|
155
158
|
complete: boolean;
|
|
156
159
|
count: number;
|
|
157
160
|
};
|