@tangle-network/agent-provider-tangle 3.6.0 → 3.6.2
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
|
@@ -447,8 +447,12 @@ metadata so a fresh process can recover the exact interface digest.
|
|
|
447
447
|
Snapshot-created children are validated through the marker and complete
|
|
448
448
|
account inventory, while legacy fork markers also require the Sandbox fork
|
|
449
449
|
ledger to report a settled success.
|
|
450
|
-
Checkpoint deletion
|
|
451
|
-
|
|
450
|
+
Checkpoint deletion reads only the source's own snapshots. A child created
|
|
451
|
+
from a checkpoint holds a full restore of it in its own volume, so deleting the
|
|
452
|
+
checkpoint neither waits for nor changes its children. One Sandbox path still
|
|
453
|
+
names the checkpoint after create: last-resort sidecar recreation replays the
|
|
454
|
+
child's original create request, and once the checkpoint is deleted that replay
|
|
455
|
+
fails with `SNAPSHOT_NOT_FOUND` (agent-dev-container#9388).
|
|
452
456
|
The adapter never treats an SDK response without an explicit idempotency or
|
|
453
457
|
deletion outcome as success.
|
|
454
458
|
|
package/dist/tangle-evidence.js
CHANGED
|
@@ -9,6 +9,54 @@ const handles = new WeakMap();
|
|
|
9
9
|
const blockedNames = new Set([".ssh", ".config", ".claude", ".codex", ".opencode", ".env", ".env.local", ".npmrc", ".sidecar"]);
|
|
10
10
|
const MAX_ENTRIES = 100_000;
|
|
11
11
|
const MAX_EVENTS = 100_000;
|
|
12
|
+
// How long a replay may go without its start marker once the stream is open. The Sidecar sends
|
|
13
|
+
// no replay markers when an execution has buffered nothing yet, so this bounds that case.
|
|
14
|
+
const REPLAY_START_GRACE_MS = 15_000;
|
|
15
|
+
/**
|
|
16
|
+
* The execution's events as the Sidecar had buffered them when this capture started.
|
|
17
|
+
*
|
|
18
|
+
* The Sidecar answers a cursor replay with its buffer between `history.replay.start` and
|
|
19
|
+
* `history.replay.end`, then follows the live turn, and the SDK returns only on the turn's `done`
|
|
20
|
+
* or `error`. Read to the end, a capture of a running turn waited for the turn to finish: in the
|
|
21
|
+
* 2026-10-04 trace proof every 2-minute copy blocked until its turn ended or the Lab's 180 s bound
|
|
22
|
+
* aborted it, and 6.2 minutes of live turns stored no copy at all. A settled execution's buffer
|
|
23
|
+
* already ends with its `done` or `error`, so it replays as before.
|
|
24
|
+
*/
|
|
25
|
+
async function* bufferedExecutionEvents(session, executionId, signal) {
|
|
26
|
+
const replay = new AbortController();
|
|
27
|
+
const forward = () => replay.abort(signal?.reason);
|
|
28
|
+
if (signal?.aborted)
|
|
29
|
+
forward();
|
|
30
|
+
else
|
|
31
|
+
signal?.addEventListener("abort", forward, { once: true });
|
|
32
|
+
let grace;
|
|
33
|
+
let empty = false;
|
|
34
|
+
try {
|
|
35
|
+
for await (const event of session.events({ since: "0", executionId, signal: replay.signal })) {
|
|
36
|
+
if (event.type === "connection.established" && grace === undefined) {
|
|
37
|
+
grace = setTimeout(() => {
|
|
38
|
+
empty = true;
|
|
39
|
+
replay.abort(new DOMException("Tangle replay buffer is empty", "AbortError"));
|
|
40
|
+
}, REPLAY_START_GRACE_MS);
|
|
41
|
+
grace.unref?.();
|
|
42
|
+
}
|
|
43
|
+
if (event.type === "history.replay.start")
|
|
44
|
+
clearTimeout(grace);
|
|
45
|
+
yield event;
|
|
46
|
+
if (event.type === "history.replay.end")
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (!empty || signal?.aborted)
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
clearTimeout(grace);
|
|
56
|
+
signal?.removeEventListener("abort", forward);
|
|
57
|
+
}
|
|
58
|
+
signal?.throwIfAborted();
|
|
59
|
+
}
|
|
12
60
|
// Match the Sidecar request limit without accumulating 100 large JSON payloads.
|
|
13
61
|
const WORKSPACE_BATCH_FILES = 100;
|
|
14
62
|
const WORKSPACE_BATCH_BYTES = 8 * 1024 * 1024;
|
|
@@ -295,7 +343,7 @@ async function captureSandboxEvidence(box, options, writer) {
|
|
|
295
343
|
const events = new EvidenceJsonArray(undefined, async function* () {
|
|
296
344
|
for (const executionId of executionIds) {
|
|
297
345
|
eventCountsByExecutionId[executionId] = 0;
|
|
298
|
-
for await (const event of session
|
|
346
|
+
for await (const event of bufferedExecutionEvents(session, executionId, options.signal)) {
|
|
299
347
|
options.signal?.throwIfAborted();
|
|
300
348
|
if (counts.events >= MAX_EVENTS)
|
|
301
349
|
throw new Error("Tangle event replay limit exceeded");
|
|
@@ -3,7 +3,7 @@ import { ConfidentialAttestationSchema, ConfidentialExecutionRequestSchema, Fork
|
|
|
3
3
|
import { awaitWithSignal, boundedIdentifier, boundedString, MAX_STRING_LENGTH, cloneJson, safeIdentifier, safeString, } from "./tangle-contract-safety.js";
|
|
4
4
|
import { encodeTangleConfidentialAttestationQuote } from "./tangle-confidential-attestation.js";
|
|
5
5
|
import { checkpointMarkerTags, forkMarkerMetadata, markerBelongsToSource, checkpointMarkerBelongsToSource, checkpointMarkerFromTags, forkMarkerFromMetadata, } from "./tangle-workspace-markers.js";
|
|
6
|
-
import { checkpointRecordFromSnapshot, validSnapshotResult, reconcileCheckpoint, findManagedCheckpoint, findForkByKey, findForkChildById, completeForkChild,
|
|
6
|
+
import { checkpointRecordFromSnapshot, validSnapshotResult, reconcileCheckpoint, findManagedCheckpoint, findForkByKey, findForkChildById, completeForkChild, lookupOutcomeFromSandbox, isoDate, } from "./tangle-workspace-recovery.js";
|
|
7
7
|
const TANGLE_ATTESTATION_NONCE_PATTERN = /^(?:0x)?[0-9a-fA-F]{64}(?:[0-9a-fA-F]{64})?$/;
|
|
8
8
|
function confidentialForkRefusal(request) {
|
|
9
9
|
const confidential = request.confidential;
|
|
@@ -220,30 +220,20 @@ export function createTangleWorkspaceBranching(options) {
|
|
|
220
220
|
if (previous.requestDigest !== request.requestDigest) {
|
|
221
221
|
return cleanupConflict(request, previous.requestDigest);
|
|
222
222
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
return cleanupUnknown(request, "Sandbox child inventory is unavailable; deletion was not attempted", true);
|
|
238
|
-
}
|
|
239
|
-
if (blocking.length > 0) {
|
|
240
|
-
const acknowledgement = cleanupInUse(request, blocking);
|
|
241
|
-
cleanup.set(request.operationId, {
|
|
242
|
-
requestDigest: request.requestDigest,
|
|
243
|
-
acknowledgement,
|
|
244
|
-
});
|
|
245
|
-
return acknowledgement;
|
|
246
|
-
}
|
|
223
|
+
return previous.acknowledgement.status === "deleted"
|
|
224
|
+
? cleanupAlreadyAbsent(request)
|
|
225
|
+
: previous.acknowledgement;
|
|
226
|
+
}
|
|
227
|
+
// A child created from a checkpoint holds a full restore of it in its own
|
|
228
|
+
// volume, and Sandbox deletes a snapshot without regard to children, so
|
|
229
|
+
// deletion reads only this source's snapshots. One Sandbox path still names
|
|
230
|
+
// the checkpoint after create: last-resort sidecar recreation replays the
|
|
231
|
+
// child's original create request, and after deletion that replay fails
|
|
232
|
+
// with SNAPSHOT_NOT_FOUND instead of restoring the checkpoint
|
|
233
|
+
// (agent-dev-container#9388). The
|
|
234
|
+
// account-wide child scan this replaces paged a listing that Sandbox
|
|
235
|
+
// rebuilds and re-sorts on every page; on a busy account a page failed or
|
|
236
|
+
// repeated, deletion was never attempted, and the source was kept running.
|
|
247
237
|
const known = await findManagedCheckpoint(box, provider, request.targetId, undefined, operation?.signal);
|
|
248
238
|
if (known === "unknown") {
|
|
249
239
|
return cleanupUnknown(request, "Sandbox checkpoint inventory is unavailable; deletion was not attempted", true);
|
|
@@ -870,14 +860,6 @@ function cleanupConflict(request, existingRequestDigest) {
|
|
|
870
860
|
message: "Cleanup operation id is bound to another target",
|
|
871
861
|
});
|
|
872
862
|
}
|
|
873
|
-
function cleanupInUse(request, blockingTargetIds) {
|
|
874
|
-
return WorkspaceCleanupAcknowledgementSchema.parse({
|
|
875
|
-
...request,
|
|
876
|
-
status: "in_use",
|
|
877
|
-
blockingTargetIds,
|
|
878
|
-
message: "Checkpoint is still referenced by forked environments",
|
|
879
|
-
});
|
|
880
|
-
}
|
|
881
863
|
function cleanupUnknown(request, message, retryable) {
|
|
882
864
|
return WorkspaceCleanupAcknowledgementSchema.parse({
|
|
883
865
|
...request,
|
|
@@ -49,7 +49,6 @@ export declare function findForkChildById(client: SandboxClientLike, box: Sandbo
|
|
|
49
49
|
* marker is absent. Never invent either field from the request.
|
|
50
50
|
*/
|
|
51
51
|
export declare function completeForkChild(client: SandboxClientLike, child: SandboxInstanceLike, signal?: AbortSignal): Promise<SandboxInstanceLike | undefined>;
|
|
52
|
-
export declare function findBlockingForks(box: SandboxInstanceLike, client: SandboxClientLike, provider: string, checkpointId: string, signal?: AbortSignal): Promise<string[] | undefined>;
|
|
53
52
|
/**
|
|
54
53
|
* Read a fork ledger answer for a key that left no marked resource behind.
|
|
55
54
|
*
|
|
@@ -383,28 +383,6 @@ export async function completeForkChild(client, child, signal) {
|
|
|
383
383
|
return undefined;
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
-
export async function findBlockingForks(box, client, provider, checkpointId, signal) {
|
|
387
|
-
const candidates = await listMarkedForkChildren(client, box, provider, undefined, signal);
|
|
388
|
-
if (candidates === undefined)
|
|
389
|
-
return undefined;
|
|
390
|
-
const blocking = new Set();
|
|
391
|
-
for (const { child, marker } of candidates) {
|
|
392
|
-
if (marker.request.checkpoint.checkpointId !== checkpointId)
|
|
393
|
-
continue;
|
|
394
|
-
try {
|
|
395
|
-
// A candidate that cannot be confirmed leaves the dependency set
|
|
396
|
-
// unknown, so cleanup must not proceed on a partial answer.
|
|
397
|
-
if (!(await forkOperationSucceeded(box, marker, signal)))
|
|
398
|
-
return undefined;
|
|
399
|
-
blocking.add(child.id);
|
|
400
|
-
}
|
|
401
|
-
catch {
|
|
402
|
-
signal?.throwIfAborted();
|
|
403
|
-
return undefined;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
return [...blocking].sort();
|
|
407
|
-
}
|
|
408
386
|
/**
|
|
409
387
|
* Read the complete account inventory through Sandbox offset pages.
|
|
410
388
|
*
|
|
@@ -460,9 +438,8 @@ async function listAllSandboxChildren(client, signal) {
|
|
|
460
438
|
/**
|
|
461
439
|
* Read every account child that carries a fork marker this source produced.
|
|
462
440
|
*
|
|
463
|
-
* The scan is the
|
|
464
|
-
*
|
|
465
|
-
* closed on the same condition.
|
|
441
|
+
* The scan is the front half of fork recovery. It returns undefined when the
|
|
442
|
+
* inventory itself cannot be trusted, so recovery fails closed.
|
|
466
443
|
*/
|
|
467
444
|
async function listMarkedForkChildren(client, box, provider, key, signal) {
|
|
468
445
|
const children = await listAllSandboxChildren(client, signal);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-provider-tangle",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.2",
|
|
4
4
|
"description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
}
|
|
140
140
|
},
|
|
141
141
|
"devDependencies": {
|
|
142
|
-
"@tangle-network/agent-provider-testkit": "0.10.
|
|
142
|
+
"@tangle-network/agent-provider-testkit": "0.10.1",
|
|
143
143
|
"@tangle-network/agent-runtime": "0.292.3",
|
|
144
144
|
"@tangle-network/sandbox": "0.58.7",
|
|
145
145
|
"@types/node": "26.6.3",
|