@tangle-network/sandbox 0.60.78-develop.20261017090901.9326d18 → 0.60.78-develop.20261021201434.3bcd5ef
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 +61 -0
- package/dist/agent/index.d.ts +4 -4
- package/dist/agent/index.js +5 -5
- package/dist/agent/preview.d.ts +1 -1
- package/dist/agent/preview.js +2 -2
- package/dist/{agent-run-outcome-CTEpjCEZ.d.ts → agent-run-outcome-brwJbH5S.d.ts} +1 -1
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +5 -5
- package/dist/{backend-types-D6bYbvMB.js → backend-types-CLvdSX8V.js} +41 -1
- package/dist/{browser-interactive-control-controller-rpTbyvAS.d.ts → browser-interactive-control-controller-CvObO_Kf.d.ts} +1 -1
- package/dist/{browser-interactive-control-controller-BJf0P_J4.js → browser-interactive-control-controller-DHx53yre.js} +16 -1
- package/dist/{chunked-upload-DtIvkKNo.js → chunked-upload-DN2twsUu.js} +2 -59
- package/dist/{chunked-upload-file-DnsHEjg0.js → chunked-upload-file-Dpv1YsoA.js} +2 -1
- package/dist/{cli-auth-bundle-cSJjPeFF.js → cli-auth-bundle-CFeHsq-5.js} +23 -11
- package/dist/{client-R1tw-4Px.js → client-CgtR203z.js} +3349 -3341
- package/dist/client-Dr8qasCR.d.ts +6076 -0
- package/dist/collaboration/index.d.ts +1 -1
- package/dist/collaboration/index.js +1 -1
- package/dist/{collaboration-DaJU5O0E.js → collaboration-g_HzXa6f.js} +5 -5
- package/dist/core.d.ts +7 -7
- package/dist/core.js +7 -6
- package/dist/direct-http2-Dar5erTH.js +99 -0
- package/dist/{errors-DSJBKmGZ.js → errors-BfbOP_rx.js} +171 -22
- package/dist/{index-DO7GVpk_.d.ts → index-C8VSFtWl.d.ts} +1 -1
- package/dist/{index-DZ27pdB8.d.ts → index-CVjTnRWP.d.ts} +1 -1
- package/dist/{sandbox-CoIGxzm_.d.ts → index-D5dVNm76.d.ts} +2117 -1519
- package/dist/index.d.ts +12 -4704
- package/dist/index.js +40 -15
- package/dist/intelligence/index.js +1 -1
- package/dist/interactive-control.d.ts +1 -1
- package/dist/interactive-control.js +1 -1
- package/dist/{interactive-controller-CJ24g8Va.js → interactive-controller-OAsASPd_.js} +662 -620
- package/dist/interactive-controller-nMhGqXxq.d.ts +41 -0
- package/dist/keep-alive-fetch-BBzJDWyt.js +247 -0
- package/dist/{lines-DodQslsf.d.ts → lines-C5CPSg8n.d.ts} +21 -17
- package/dist/lines-C5ER4aN_.js +298 -0
- package/dist/lines.d.ts +1 -1
- package/dist/lines.js +1 -295
- package/dist/{local-cli-auth-CBV7Vjk5.js → local-cli-auth-D-CQ0-ub.js} +1 -1
- package/dist/{mcp-local-DjryqUiY.js → mcp-local-BjLG7VHY.js} +1 -1
- package/dist/{preview-wpGGk0bu.d.ts → preview-COO7TSBk.d.ts} +3 -3
- package/dist/public-templates-BDrchm0J.d.ts +80 -0
- package/dist/public-templates.d.ts +2 -0
- package/dist/public-templates.js +173 -0
- package/dist/{raw-evidence-archive-Br5a3xZ_.js → raw-evidence-archive-CDYDqHNv.js} +161 -69
- package/dist/runtime.d.ts +49 -41
- package/dist/runtime.js +8 -8
- package/dist/{sandbox-C7Tk62qn.js → sandbox-BrZxAq11.js} +9048 -8939
- package/dist/{secp256k1-Dx2XABHz.js → secp256k1-CmLpsmWl.js} +1 -1
- package/dist/session-gateway/index.d.ts +23 -67
- package/dist/session-gateway/index.js +578 -451
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-Ba4Kz5zT.js → tangle-GiPBak5X.js} +176 -169
- package/dist/terminal-stream-types-ClZCArRg.d.ts +662 -0
- package/dist/{types-B_QF-iHm.d.ts → types-CtH0GRql.d.ts} +6161 -5812
- package/package.json +12 -7
- package/dist/client-Lhxo82x1.d.ts +0 -1261
- package/dist/errors-mPL-qvgF.d.ts +0 -347
- package/dist/index-DRto9Ijb.d.ts +0 -579
- package/dist/managed-process-B7WfqKmi.d.ts +0 -15
- package/dist/terminal-stream-jdYomM1m.d.ts +0 -389
- /package/dist/{cli-auth-bundle-ODe06Ts7.d.ts → cli-auth-bundle-Dyw3hCGx.d.ts} +0 -0
- /package/dist/{line-application-Cq6dJLBD.js → line-application-DY9ZTdgF.js} +0 -0
- /package/dist/{preview-operations-DqSo-IBm.js → preview-operations-Ca02vPDJ.js} +0 -0
- /package/dist/{utils-B7_9Hl_z.js → utils-BGvM02yJ.js} +0 -0
|
@@ -30,6 +30,18 @@ const metadata = z.object({
|
|
|
30
30
|
ctimeMs: z.number().finite(),
|
|
31
31
|
sizeBytes: count
|
|
32
32
|
});
|
|
33
|
+
const nativeCopyFile = payload.extend({
|
|
34
|
+
store: safePath,
|
|
35
|
+
storePath: safePath,
|
|
36
|
+
format: text,
|
|
37
|
+
method: z.enum([
|
|
38
|
+
"byte-prefix",
|
|
39
|
+
"atomic-file",
|
|
40
|
+
"sqlite-backup"
|
|
41
|
+
]),
|
|
42
|
+
truncated: z.boolean(),
|
|
43
|
+
sourceBytes: count
|
|
44
|
+
});
|
|
33
45
|
const nativeSessionCopy = z.object({
|
|
34
46
|
harness: text,
|
|
35
47
|
format: text.nullable(),
|
|
@@ -50,40 +62,73 @@ const nativeSessionCopy = z.object({
|
|
|
50
62
|
"unknown"
|
|
51
63
|
])
|
|
52
64
|
}),
|
|
53
|
-
files: z.array(
|
|
54
|
-
|
|
65
|
+
files: z.array(nativeCopyFile),
|
|
66
|
+
superseded: z.array(z.object({
|
|
55
67
|
storePath: safePath,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
sourceBytes: count
|
|
64
|
-
})),
|
|
68
|
+
sha256: text,
|
|
69
|
+
sizeBytes: count,
|
|
70
|
+
supersededBy: z.object({
|
|
71
|
+
executionId: text,
|
|
72
|
+
attempt: count.min(1)
|
|
73
|
+
})
|
|
74
|
+
})).optional(),
|
|
65
75
|
complete: z.boolean(),
|
|
66
76
|
missingReasons: z.array(text)
|
|
67
77
|
});
|
|
78
|
+
const captureIdentity = {
|
|
79
|
+
proofStatus: z.enum(["verified", "unverified"]),
|
|
80
|
+
containerId: z.string().regex(/^[a-f0-9]{64}$/).optional(),
|
|
81
|
+
sidecarImageDigest: digest,
|
|
82
|
+
sidecarBundleRevision: z.string().regex(/^[a-f0-9]{40}$/),
|
|
83
|
+
sidecarBundleChecksum: digest.optional()
|
|
84
|
+
};
|
|
85
|
+
/** Every native store on the box: each runtime HOME's declared stores and every settled copy. */
|
|
86
|
+
const boxManifestSchema = z.object({
|
|
87
|
+
schema: z.literal("tangle.raw-evidence-archive.box.v1"),
|
|
88
|
+
scope: z.literal("box"),
|
|
89
|
+
status: z.enum(["captured", "partial"]),
|
|
90
|
+
...captureIdentity,
|
|
91
|
+
roots: z.array(z.object({
|
|
92
|
+
harness: text,
|
|
93
|
+
path: text,
|
|
94
|
+
kind: z.enum(["shared", "isolated"]),
|
|
95
|
+
homes: count
|
|
96
|
+
})),
|
|
97
|
+
homes: z.array(z.object({
|
|
98
|
+
harness: text,
|
|
99
|
+
runtimeHome: text,
|
|
100
|
+
copy: z.literal("snapshot"),
|
|
101
|
+
capturedAt: text,
|
|
102
|
+
live: z.boolean(),
|
|
103
|
+
files: z.array(nativeCopyFile),
|
|
104
|
+
excluded: z.array(z.object({
|
|
105
|
+
storePath: safePath,
|
|
106
|
+
reason: z.literal("credential")
|
|
107
|
+
})),
|
|
108
|
+
complete: z.boolean(),
|
|
109
|
+
missingReasons: z.array(text)
|
|
110
|
+
})),
|
|
111
|
+
nativeSessions: z.array(nativeSessionCopy.extend({ runtimeHome: text.nullable() })),
|
|
112
|
+
coverageComplete: z.boolean(),
|
|
113
|
+
missingReasons: z.array(text)
|
|
114
|
+
});
|
|
68
115
|
const manifestBase = z.object({
|
|
69
116
|
status: z.enum(["captured", "partial"]),
|
|
70
117
|
sessionId: text,
|
|
71
118
|
backendType: z.string().regex(/^[a-z][a-z0-9_-]{0,127}$/),
|
|
72
119
|
nativeSessionId: text.nullable(),
|
|
73
|
-
|
|
74
|
-
containerId: z.string().regex(/^[a-f0-9]{64}$/).optional(),
|
|
75
|
-
sidecarImageDigest: digest,
|
|
76
|
-
sidecarBundleRevision: z.string().regex(/^[a-f0-9]{40}$/),
|
|
77
|
-
sidecarBundleChecksum: digest.optional(),
|
|
120
|
+
...captureIdentity,
|
|
78
121
|
nativeRoots: z.array(z.object({
|
|
79
122
|
sourceId: text.optional(),
|
|
80
123
|
rootScope: scope,
|
|
81
124
|
path: text
|
|
82
125
|
})),
|
|
126
|
+
omitContent: z.array(text).optional(),
|
|
83
127
|
files: z.array(metadata.extend({
|
|
84
128
|
sha256: digest.optional(),
|
|
85
129
|
linkTarget: z.string().optional(),
|
|
86
|
-
content: payload.optional()
|
|
130
|
+
content: payload.optional(),
|
|
131
|
+
contentOmitted: z.literal(true).optional()
|
|
87
132
|
})),
|
|
88
133
|
excluded: z.array(metadata.extend({ reason: z.literal("credential") })),
|
|
89
134
|
skipped: z.array(z.object({
|
|
@@ -148,20 +193,42 @@ const manifestBase = z.object({
|
|
|
148
193
|
missingReasons: z.array(text)
|
|
149
194
|
});
|
|
150
195
|
/** v2 adds each attempt's native session, from the harness session contract. */
|
|
151
|
-
const
|
|
196
|
+
const manifestV2 = manifestBase.extend({
|
|
152
197
|
schema: z.literal("tangle.raw-evidence-archive.v2"),
|
|
153
|
-
nativeSessions: z.array(nativeSessionCopy)
|
|
154
|
-
|
|
198
|
+
nativeSessions: z.array(nativeSessionCopy),
|
|
199
|
+
homeWalk: z.literal("skipped").optional()
|
|
200
|
+
});
|
|
201
|
+
/** v2 for `parts=native`: the session copies alone, no event log, process stream or HOME walk. */
|
|
202
|
+
const manifestNative = manifestV2.omit({
|
|
203
|
+
processIo: true,
|
|
204
|
+
processTerminals: true
|
|
205
|
+
}).extend({
|
|
206
|
+
parts: z.literal("native"),
|
|
207
|
+
homeWalk: z.literal("skipped"),
|
|
208
|
+
processSources: z.tuple([]),
|
|
209
|
+
events: z.tuple([])
|
|
210
|
+
});
|
|
211
|
+
const manifestSchema = z.union([
|
|
212
|
+
manifestBase.extend({ schema: z.literal("tangle.raw-evidence-archive.v1") }),
|
|
213
|
+
manifestV2,
|
|
214
|
+
manifestNative
|
|
215
|
+
]);
|
|
155
216
|
const MAX_METADATA = 64 * 1024 * 1024;
|
|
217
|
+
/** Encoded `omitContent` query bound, well inside common request-line limits. */
|
|
218
|
+
const MAX_OMIT_CONTENT_QUERY_BYTES = 8 * 1024;
|
|
156
219
|
const MAX_RECORD = 16 * 1024 * 1024;
|
|
157
|
-
|
|
158
|
-
|
|
220
|
+
async function exportRawEvidenceDirectory(request, subject, targetDirectory, options, expected) {
|
|
221
|
+
const sessionId = typeof subject === "string" ? subject : void 0;
|
|
159
222
|
for (const [name, value] of Object.entries({
|
|
160
223
|
maxBytes: options.maxBytes,
|
|
161
224
|
maxFiles: options.maxFiles,
|
|
162
225
|
maxArchiveBytes: options.maxArchiveBytes ?? options.maxBytes
|
|
163
226
|
})) if (!Number.isSafeInteger(value) || value <= 0) throw new Error(`${name} must be a positive safe integer`);
|
|
164
227
|
if (options.maxFiles > 1e6) throw new Error("maxFiles exceeds 1000000");
|
|
228
|
+
if ("parts" in options && options.parts !== void 0 && (options.parts !== "native" || !options.copy)) throw new Error("parts must be native, together with copy");
|
|
229
|
+
const omitContent = "omitContent" in options ? options.omitContent : void 0;
|
|
230
|
+
if (omitContent !== void 0 && (omitContent.length > 64 || "parts" in options && options.parts !== void 0 || !omitContent.every((prefix) => prefix.length <= 512 && prefix.endsWith("/") && safePath.safeParse(prefix.slice(0, -1)).success))) throw new Error("omitContent must list at most 64 relative directory paths of at most 512 characters that end in /, without parts");
|
|
231
|
+
if (omitContent !== void 0 && new URLSearchParams(omitContent.map((prefix) => ["omitContent", prefix])).toString().length > MAX_OMIT_CONTENT_QUERY_BYTES) throw new Error(`omitContent encodes to more than ${MAX_OMIT_CONTENT_QUERY_BYTES} query bytes; name fewer or shorter directories`);
|
|
165
232
|
options.signal?.throwIfAborted();
|
|
166
233
|
const fs = await import("node:fs/promises");
|
|
167
234
|
const { dirname, join, resolve } = await import("node:path");
|
|
@@ -184,13 +251,18 @@ async function exportRawEvidenceDirectory(request, sessionId, targetDirectory, o
|
|
|
184
251
|
throw new Error(`Raw evidence archive request failed (HTTP ${response.status}); no legacy fallback`);
|
|
185
252
|
}
|
|
186
253
|
if (response.headers.get("content-type")?.includes("application/json")) {
|
|
187
|
-
const body = await readBoundedResponse(response, 64 * 1024, options.signal);
|
|
254
|
+
const body = JSON.parse(await readBoundedResponse(response, 64 * 1024, options.signal));
|
|
255
|
+
if (sessionId === void 0) return z.object({
|
|
256
|
+
status: z.literal("unavailable"),
|
|
257
|
+
scope: z.literal("box"),
|
|
258
|
+
reason: text
|
|
259
|
+
}).parse(body);
|
|
188
260
|
return z.object({
|
|
189
261
|
status: z.literal("unavailable"),
|
|
190
262
|
sessionId: z.literal(sessionId),
|
|
191
263
|
backendType: text,
|
|
192
264
|
reason: text
|
|
193
|
-
}).parse(
|
|
265
|
+
}).parse(body);
|
|
194
266
|
}
|
|
195
267
|
const expectedManifest = response.headers.get("x-evidence-manifest-sha256");
|
|
196
268
|
if (!expectedManifest || !/^sha256:[a-f0-9]{64}$/.test(expectedManifest)) {
|
|
@@ -320,57 +392,77 @@ async function exportRawEvidenceDirectory(request, sessionId, targetDirectory, o
|
|
|
320
392
|
for (const outcome of settled) if (outcome.status === "rejected") throw outcome.reason;
|
|
321
393
|
const manifestRef = members.get("manifest.json");
|
|
322
394
|
if (!manifestRef || manifestRef.sha256 !== expectedManifest) throw new Error("Evidence manifest digest mismatch");
|
|
323
|
-
const
|
|
324
|
-
if (manifest.sessionId !== sessionId || manifest.backendType === "unknown") throw new Error("Evidence identity mismatch");
|
|
325
|
-
if (manifest.proofStatus === "verified" && (!manifest.containerId || !manifest.sidecarBundleChecksum)) throw new Error("Evidence capture proof is incomplete");
|
|
326
|
-
if (expected && (manifest.proofStatus !== "verified" || manifest.containerId !== expected.containerId || manifest.sidecarImageDigest !== expected.imageId || manifest.sidecarBundleRevision !== expected.bundleRevision || manifest.sidecarBundleChecksum !== expected.bundleChecksum)) throw new Error("Evidence does not match current container capture proof");
|
|
327
|
-
const captured = manifest.status === "captured";
|
|
328
|
-
if (captured ? !manifest.coverageComplete || manifest.missingReasons.length || !Object.values(manifest.completeness).every(Boolean) || !manifest.attempts.length : manifest.coverageComplete || !manifest.missingReasons.length) throw new Error("Evidence coverage status is inconsistent");
|
|
329
|
-
if (manifest.inventory.skippedEntries !== manifest.skipped.length) throw new Error("Evidence inventory mismatch");
|
|
330
|
-
const ids = new Set(manifest.attempts.flatMap((attempt) => attempt.nativeSessionIds));
|
|
331
|
-
const aggregateId = ids.size === 1 && manifest.attempts.every((attempt) => attempt.nativeSessionIds.length === 1) ? [...ids][0] : null;
|
|
332
|
-
if (manifest.nativeSessionId !== aggregateId) throw new Error("Evidence native session ID mismatch");
|
|
395
|
+
const parsed = JSON.parse(await fs.readFile(join(directory, "manifest.json"), "utf8"));
|
|
333
396
|
const verify = (ref) => {
|
|
334
397
|
const member = members.get(ref.path);
|
|
335
398
|
if (!member || member.sha256 !== ref.sha256 || member.sizeBytes !== ref.sizeBytes) throw new Error("Evidence payload hash or size mismatch");
|
|
336
399
|
};
|
|
337
|
-
|
|
338
|
-
if (
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
400
|
+
const checkProof = (identity) => {
|
|
401
|
+
if (identity.proofStatus === "verified" && (!identity.containerId || !identity.sidecarBundleChecksum)) throw new Error("Evidence capture proof is incomplete");
|
|
402
|
+
if (expected && (identity.proofStatus !== "verified" || identity.containerId !== expected.containerId || identity.sidecarImageDigest !== expected.imageId || identity.sidecarBundleRevision !== expected.bundleRevision || identity.sidecarBundleChecksum !== expected.bundleChecksum)) throw new Error("Evidence does not match current container capture proof");
|
|
403
|
+
};
|
|
404
|
+
let manifest;
|
|
405
|
+
if (sessionId === void 0) {
|
|
406
|
+
const box = boxManifestSchema.parse(parsed);
|
|
407
|
+
checkProof(box);
|
|
408
|
+
if (box.status === "captured" ? !box.coverageComplete || box.missingReasons.length > 0 || box.homes.some((home) => home.live || !home.complete) : box.coverageComplete || box.missingReasons.length === 0) throw new Error("Evidence coverage status is inconsistent");
|
|
409
|
+
for (const home of box.homes) for (const file of home.files) verify(file);
|
|
410
|
+
for (const copy of box.nativeSessions) for (const file of copy.files) verify(file);
|
|
411
|
+
manifest = box;
|
|
412
|
+
} else {
|
|
413
|
+
const session = manifestSchema.parse(parsed);
|
|
414
|
+
if (session.sessionId !== sessionId || session.backendType === "unknown") throw new Error("Evidence identity mismatch");
|
|
415
|
+
checkProof(session);
|
|
416
|
+
const captured = session.status === "captured";
|
|
417
|
+
if (captured ? !session.coverageComplete || session.missingReasons.length || !Object.values(session.completeness).every(Boolean) || !session.attempts.length : session.coverageComplete || !session.missingReasons.length) throw new Error("Evidence coverage status is inconsistent");
|
|
418
|
+
if (session.inventory.skippedEntries !== session.skipped.length) throw new Error("Evidence inventory mismatch");
|
|
419
|
+
const ids = new Set(session.attempts.flatMap((attempt) => attempt.nativeSessionIds));
|
|
420
|
+
const aggregateId = ids.size === 1 && session.attempts.every((attempt) => attempt.nativeSessionIds.length === 1) ? [...ids][0] : null;
|
|
421
|
+
if (session.nativeSessionId !== aggregateId) throw new Error("Evidence native session ID mismatch");
|
|
422
|
+
if (session.omitContent !== void 0 && JSON.stringify(session.omitContent) !== JSON.stringify(omitContent)) throw new Error("Evidence content omission does not match the request");
|
|
423
|
+
for (const item of session.files) if (item.contentOmitted) {
|
|
424
|
+
if (item.kind !== "file" || item.content || item.sha256 || item.rootScope !== "session-home" || !omitContent?.some((prefix) => item.path.startsWith(prefix))) throw new Error("Evidence native content omission mismatch");
|
|
425
|
+
} else if (item.kind === "file") {
|
|
426
|
+
if (!item.content || item.sha256 !== item.content.sha256 || item.sizeBytes !== item.content.sizeBytes) throw new Error("Evidence native payload mismatch");
|
|
427
|
+
verify(item.content);
|
|
428
|
+
} else if (item.content || item.sha256 || item.kind === "symlink" && item.linkTarget === void 0) throw new Error("Evidence native metadata mismatch");
|
|
429
|
+
const nativeSessions = session.schema === "tangle.raw-evidence-archive.v2" ? session.nativeSessions : [];
|
|
430
|
+
for (const copy of nativeSessions) {
|
|
431
|
+
if (!session.attempts.some((attempt) => attempt.executionId === copy.executionId && attempt.ordinal === copy.attempt)) throw new Error("Evidence native session copy is unattributed");
|
|
432
|
+
for (const file of copy.files) verify(file);
|
|
433
|
+
}
|
|
434
|
+
for (const item of session.processSources) {
|
|
435
|
+
if (item.sha256 !== item.content.sha256 || item.sizeBytes !== item.content.sizeBytes) throw new Error("Evidence process source mismatch");
|
|
436
|
+
verify(item.content);
|
|
437
|
+
}
|
|
438
|
+
const processIo = "parts" in session ? void 0 : session.processIo;
|
|
439
|
+
const processRecords = "parts" in session ? [] : [session.processIo, session.processTerminals];
|
|
440
|
+
for (const ref of processRecords) {
|
|
441
|
+
verify(ref);
|
|
442
|
+
let count = 0;
|
|
443
|
+
for await (const row of readRecords(join(directory, ref.path), options.signal)) {
|
|
444
|
+
count++;
|
|
445
|
+
if (ref === processIo) {
|
|
446
|
+
const content = payload.parse(row.content);
|
|
447
|
+
verify(content);
|
|
448
|
+
if (content.sizeBytes !== row.sizeBytes || content.sha256 !== row.sha256 || row.contentBase64 !== void 0) throw new Error("Evidence process frame mismatch");
|
|
449
|
+
}
|
|
450
|
+
if (captured && !session.attempts.some((attempt) => attempt.executionId === row.executionId && attempt.ordinal === row.ordinal && attempt.providerSessionId === row.providerSessionId && attempt.processIds.includes(String(row.processId)))) throw new Error("Evidence process attribution mismatch");
|
|
359
451
|
}
|
|
360
|
-
if (
|
|
452
|
+
if (count !== ref.records) throw new Error("Evidence record count mismatch");
|
|
361
453
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
last
|
|
454
|
+
for (const event of session.events) {
|
|
455
|
+
verify(event.frames);
|
|
456
|
+
let count = 0;
|
|
457
|
+
let last = "";
|
|
458
|
+
for await (const row of readRecords(join(directory, event.frames.path), options.signal)) {
|
|
459
|
+
count++;
|
|
460
|
+
if (typeof row.eventId !== "string") throw new Error("Evidence event identity missing");
|
|
461
|
+
last = row.eventId;
|
|
462
|
+
}
|
|
463
|
+
if (count !== event.frames.records || event.metadata.sessionId !== sessionId || captured && (count !== event.metadata.eventCount || last !== event.metadata.lastEventId)) throw new Error("Evidence event sequence mismatch");
|
|
372
464
|
}
|
|
373
|
-
|
|
465
|
+
manifest = session;
|
|
374
466
|
}
|
|
375
467
|
options.signal?.throwIfAborted();
|
|
376
468
|
try {
|
|
@@ -397,7 +489,7 @@ async function exportRawEvidenceDirectory(request, sessionId, targetDirectory, o
|
|
|
397
489
|
} catch (error) {
|
|
398
490
|
await fs.writeFile(join(staging, "failure.json"), JSON.stringify({
|
|
399
491
|
status: "incomplete",
|
|
400
|
-
sessionId,
|
|
492
|
+
...sessionId === void 0 ? { scope: "box" } : { sessionId },
|
|
401
493
|
reason: error instanceof Error ? error.message : String(error)
|
|
402
494
|
}), { mode: 384 });
|
|
403
495
|
throw new Error(`Evidence export failed; partial bytes retained at ${staging}`, { cause: error });
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, r as browserInteractiveControlHolderId } from "./browser-interactive-control-controller-
|
|
4
|
-
import {
|
|
5
|
-
import { a as deriveAgentRunOutcome, i as deriveAgentResultOutcome, n as AgentRunOutcomeTracker, o as projectAgentTerminalRecord, r as createAgentRunOutcomeTracker, t as AgentRunOutcome } from "./agent-run-outcome-
|
|
1
|
+
import { A as NotFoundError, F as SandboxError, H as TimeoutError, I as SandboxErrorJson, L as SandboxFailureDetail, M as ProfileFileMountPathError, N as QuotaError, R as ServerError, S as CapabilityError, T as FileWriteConflictError, U as ValidationError, b as AuthError, j as PartialFailureError, k as NetworkError, u as ScopedToken, z as StateError } from "./terminal-stream-types-ClZCArRg.js";
|
|
2
|
+
import { Bn as SandboxPortBinding, Br as FileTreeResult, Ct as SessionMessageAdmission, Dt as TaskSessionCommitResult, Er as ChunkedUploadResult, Et as TaskSessionChanges, Gn as SandboxTerminalCreateOptions, Hr as FileUsageResult, Ir as FileRenameResult, Jn as SandboxTerminalRequestOptions, Jr as UploadProgress, Kn as SandboxTerminalInfo, Kr as RenameOptions, Mr as FileReadBatchOptions, Nr as FileReadBatchResult, Q as CommitTaskSessionOptions, St as SessionMessage, Tr as ChunkedUploadOptions, Un as SandboxRuntimeHealth, Ur as FileWriteResult, Vr as FileUsageOptions, Yr as WriteFileOptions, ct as ListMessagesOptions, dt as SendSessionMessageRequest, ft as SentSessionMessage, gt as SessionExecutionStatus, ht as SessionExecutionInfo, it as CreateTaskSessionOptions, kt as TaskSessionInfo, mt as SessionEventStreamOptions, pa as SandboxEvent, qn as SandboxTerminalManager, rr as TerminalStream, rt as CreateSessionOptions, ut as SendSessionMessageOptions, yt as SessionInfo, zr as FileTreeOptions } from "./types-CtH0GRql.js";
|
|
3
|
+
import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, r as browserInteractiveControlHolderId } from "./browser-interactive-control-controller-CvObO_Kf.js";
|
|
4
|
+
import { t as BrowserInteractiveSessionController } from "./interactive-controller-nMhGqXxq.js";
|
|
5
|
+
import { a as deriveAgentRunOutcome, i as deriveAgentResultOutcome, n as AgentRunOutcomeTracker, o as projectAgentTerminalRecord, r as createAgentRunOutcomeTracker, t as AgentRunOutcome } from "./agent-run-outcome-brwJbH5S.js";
|
|
6
6
|
|
|
7
7
|
//#region src/lib/chunked-upload.d.ts
|
|
8
8
|
/** The transport a caller wires this module to — {@link SandboxInstance.runtimeFetch}
|
|
@@ -29,15 +29,13 @@ interface ChunkedUploadTransport {
|
|
|
29
29
|
*/
|
|
30
30
|
declare function uploadChunked(transport: ChunkedUploadTransport, remotePath: string, data: Blob | ArrayBuffer | ArrayBufferView | string, options?: ChunkedUploadOptions): Promise<ChunkedUploadResult>;
|
|
31
31
|
//#endregion
|
|
32
|
-
//#region src/runtime-
|
|
32
|
+
//#region src/runtime-transport.d.ts
|
|
33
33
|
interface RuntimeTransport {
|
|
34
34
|
ensureRunning(): Promise<void>;
|
|
35
35
|
fetch(path: string, init?: RequestInit): Promise<Response>;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
declare class SandboxRuntimeApi {
|
|
40
|
-
private readonly transport;
|
|
37
|
+
declare class RuntimeApiTransport {
|
|
38
|
+
protected readonly transport: RuntimeTransport;
|
|
41
39
|
readonly terminals: SandboxTerminalManager;
|
|
42
40
|
constructor(transport: RuntimeTransport);
|
|
43
41
|
health(): Promise<SandboxRuntimeHealth>;
|
|
@@ -45,6 +43,44 @@ declare class SandboxRuntimeApi {
|
|
|
45
43
|
ttlMs?: number;
|
|
46
44
|
}): Promise<void>;
|
|
47
45
|
ports(): Promise<SandboxPortBinding[]>;
|
|
46
|
+
protected createTerminal(options?: SandboxTerminalCreateOptions, request?: SandboxTerminalRequestOptions): Promise<SandboxTerminalInfo>;
|
|
47
|
+
protected writeTerminal(terminalId: string, data: string, request?: SandboxTerminalRequestOptions): Promise<void>;
|
|
48
|
+
protected listTerminals(): Promise<SandboxTerminalInfo[]>;
|
|
49
|
+
protected getTerminal(terminalId: string): Promise<SandboxTerminalInfo | null>;
|
|
50
|
+
protected json<T>(path: string, init?: RequestInit): Promise<T>;
|
|
51
|
+
protected request(path: string, init?: RequestInit): Promise<Response>;
|
|
52
|
+
protected assertOk(response: Response): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/runtime-files.d.ts
|
|
56
|
+
declare class RuntimeFiles extends RuntimeApiTransport {
|
|
57
|
+
readFiles(paths: string[], options?: FileReadBatchOptions): Promise<FileReadBatchResult>;
|
|
58
|
+
writeFile(path: string, content: string, options?: WriteFileOptions): Promise<FileWriteResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Upload in-memory binary or text data to the sandbox over the chunked
|
|
61
|
+
* upload-session protocol — the browser/Worker-safe sanctioned path for
|
|
62
|
+
* payloads over ~1 MiB, sized to clear the gateway proxy's per-request cap
|
|
63
|
+
* (parts stay under {@link FILE_UPLOAD_PART_MAX_BYTES}). Binary-safe:
|
|
64
|
+
* accepts a `Blob`, `ArrayBuffer`, `ArrayBufferView`, or UTF-8 `string`.
|
|
65
|
+
* Delegates to the shared `uploadChunked` engine in `lib/chunked-upload.js`,
|
|
66
|
+
* wired to this client's `transport.fetch` so requests carry the same
|
|
67
|
+
* scoped-token `Authorization` header and base URL as every other method
|
|
68
|
+
* on this class (e.g. {@link SandboxRuntimeApi.writeFile}) — works
|
|
69
|
+
* identically over the gateway proxy or a direct sidecar connection.
|
|
70
|
+
*
|
|
71
|
+
* @throws {SandboxError} `PAYLOAD_TOO_LARGE` immediately, before any
|
|
72
|
+
* request, if the payload exceeds the chunked-upload session cap.
|
|
73
|
+
*/
|
|
74
|
+
uploadData(remotePath: string, data: Blob | ArrayBuffer | ArrayBufferView | string, options?: ChunkedUploadOptions): Promise<ChunkedUploadResult>;
|
|
75
|
+
deleteFile(path: string, options?: Pick<WriteFileOptions, "sessionId">): Promise<void>;
|
|
76
|
+
renameFile(sourcePath: string, destinationPath: string, options?: RenameOptions): Promise<FileRenameResult>;
|
|
77
|
+
fileTree(path: string, options?: FileTreeOptions): Promise<FileTreeResult>;
|
|
78
|
+
fileUsage(path: string, options?: FileUsageOptions): Promise<FileUsageResult>;
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/runtime-api.d.ts
|
|
82
|
+
/** Internal typed client for routes served by a sandbox runtime. */
|
|
83
|
+
declare class SandboxRuntimeApi extends RuntimeFiles {
|
|
48
84
|
/**
|
|
49
85
|
* Subscribe to a session's agent event stream (`/agents/events`).
|
|
50
86
|
*
|
|
@@ -69,28 +105,6 @@ declare class SandboxRuntimeApi {
|
|
|
69
105
|
runs(sessionId: string, options?: {
|
|
70
106
|
signal?: AbortSignal;
|
|
71
107
|
}): Promise<SessionExecutionInfo[]>;
|
|
72
|
-
readFiles(paths: string[], options?: FileReadBatchOptions): Promise<FileReadBatchResult>;
|
|
73
|
-
writeFile(path: string, content: string, options?: WriteFileOptions): Promise<FileWriteResult>;
|
|
74
|
-
/**
|
|
75
|
-
* Upload in-memory binary or text data to the sandbox over the chunked
|
|
76
|
-
* upload-session protocol — the browser/Worker-safe sanctioned path for
|
|
77
|
-
* payloads over ~1 MiB, sized to clear the gateway proxy's per-request cap
|
|
78
|
-
* (parts stay under {@link FILE_UPLOAD_PART_MAX_BYTES}). Binary-safe:
|
|
79
|
-
* accepts a `Blob`, `ArrayBuffer`, `ArrayBufferView`, or UTF-8 `string`.
|
|
80
|
-
* Delegates to the shared `uploadChunked` engine in `lib/chunked-upload.js`,
|
|
81
|
-
* wired to this client's `transport.fetch` so requests carry the same
|
|
82
|
-
* scoped-token `Authorization` header and base URL as every other method
|
|
83
|
-
* on this class (e.g. {@link SandboxRuntimeApi.writeFile}) — works
|
|
84
|
-
* identically over the gateway proxy or a direct sidecar connection.
|
|
85
|
-
*
|
|
86
|
-
* @throws {SandboxError} `PAYLOAD_TOO_LARGE` immediately, before any
|
|
87
|
-
* request, if the payload exceeds the chunked-upload session cap.
|
|
88
|
-
*/
|
|
89
|
-
uploadData(remotePath: string, data: Blob | ArrayBuffer | ArrayBufferView | string, options?: ChunkedUploadOptions): Promise<ChunkedUploadResult>;
|
|
90
|
-
deleteFile(path: string, options?: Pick<WriteFileOptions, "sessionId">): Promise<void>;
|
|
91
|
-
renameFile(sourcePath: string, destinationPath: string, options?: RenameOptions): Promise<FileRenameResult>;
|
|
92
|
-
fileTree(path: string, options?: FileTreeOptions): Promise<FileTreeResult>;
|
|
93
|
-
fileUsage(path: string, options?: FileUsageOptions): Promise<FileUsageResult>;
|
|
94
108
|
createSession(options: CreateSessionOptions): Promise<SessionInfo>;
|
|
95
109
|
messages(id: string, options?: Omit<ListMessagesOptions, "sessionId">): Promise<SessionMessage[]>;
|
|
96
110
|
createTaskSession(options: CreateTaskSessionOptions): Promise<TaskSessionInfo>;
|
|
@@ -98,13 +112,7 @@ declare class SandboxRuntimeApi {
|
|
|
98
112
|
deleteSession(id: string): Promise<void>;
|
|
99
113
|
taskSessionChanges(id: string): Promise<TaskSessionChanges>;
|
|
100
114
|
commitTaskSession(id: string, options?: CommitTaskSessionOptions): Promise<TaskSessionCommitResult>;
|
|
101
|
-
|
|
102
|
-
private writeTerminal;
|
|
103
|
-
private listTerminals;
|
|
104
|
-
private getTerminal;
|
|
105
|
-
private json;
|
|
106
|
-
private request;
|
|
107
|
-
private assertOk;
|
|
115
|
+
constructor(transport: RuntimeTransport);
|
|
108
116
|
}
|
|
109
117
|
//#endregion
|
|
110
118
|
//#region src/runtime-client.d.ts
|
|
@@ -127,11 +135,11 @@ interface SandboxRuntimeClientConfig {
|
|
|
127
135
|
* remains server-side.
|
|
128
136
|
*/
|
|
129
137
|
declare class SandboxRuntimeClient extends SandboxRuntimeApi {
|
|
130
|
-
private
|
|
138
|
+
#private;
|
|
131
139
|
constructor(config: SandboxRuntimeClientConfig);
|
|
132
140
|
/** Replace an expiring scoped token without rebuilding consumers. */
|
|
133
141
|
updateToken(token: string): void;
|
|
134
142
|
}
|
|
135
143
|
declare function createSandboxRuntimeClient(config: SandboxRuntimeClientConfig): SandboxRuntimeClient;
|
|
136
144
|
//#endregion
|
|
137
|
-
export { type AgentRunOutcome, type AgentRunOutcomeTracker, AuthError, BrowserInteractiveSessionController, CapabilityError, type ChunkedUploadOptions, type ChunkedUploadResult, type ChunkedUploadTransport, type FileReadBatchOptions, type FileReadBatchResult, type FileRenameResult, type FileTreeOptions, type FileTreeResult, FileWriteConflictError, type FileWriteResult, type InteractiveSessionIdentity, InteractiveSessionNotRunningError, type ListMessagesOptions, NetworkError, NotFoundError, PartialFailureError, QuotaError, type RenameOptions, SandboxError, type SandboxErrorJson, type SandboxEvent, type SandboxFailureDetail, SandboxRuntimeClient, type SandboxRuntimeClientConfig, type SandboxRuntimeHealth, type SandboxTerminalCreateOptions, type SandboxTerminalInfo, type SandboxTerminalManager, type SandboxTerminalRequestOptions, type ScopedToken, ServerError, type SessionEventStreamOptions, type SessionExecutionInfo, type SessionExecutionStatus, type SessionMessage, type SessionMessageAdmission, StateError, type TerminalStream, TimeoutError, type UploadProgress, ValidationError, type WriteFileOptions, browserInteractiveControlHolderId, createAgentRunOutcomeTracker, createSandboxRuntimeClient, deriveAgentResultOutcome, deriveAgentRunOutcome, projectAgentTerminalRecord, uploadChunked };
|
|
145
|
+
export { type AgentRunOutcome, type AgentRunOutcomeTracker, AuthError, BrowserInteractiveSessionController, CapabilityError, type ChunkedUploadOptions, type ChunkedUploadResult, type ChunkedUploadTransport, type FileReadBatchOptions, type FileReadBatchResult, type FileRenameResult, type FileTreeOptions, type FileTreeResult, FileWriteConflictError, type FileWriteResult, type InteractiveSessionIdentity, InteractiveSessionNotRunningError, type ListMessagesOptions, NetworkError, NotFoundError, PartialFailureError, ProfileFileMountPathError, QuotaError, type RenameOptions, SandboxError, type SandboxErrorJson, type SandboxEvent, type SandboxFailureDetail, SandboxRuntimeClient, type SandboxRuntimeClientConfig, type SandboxRuntimeHealth, type SandboxTerminalCreateOptions, type SandboxTerminalInfo, type SandboxTerminalManager, type SandboxTerminalRequestOptions, type ScopedToken, ServerError, type SessionEventStreamOptions, type SessionExecutionInfo, type SessionExecutionStatus, type SessionMessage, type SessionMessageAdmission, StateError, type TerminalStream, TimeoutError, type UploadProgress, ValidationError, type WriteFileOptions, browserInteractiveControlHolderId, createAgentRunOutcomeTracker, createSandboxRuntimeClient, deriveAgentResultOutcome, deriveAgentRunOutcome, projectAgentTerminalRecord, uploadChunked };
|
package/dist/runtime.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { f as combineAbortSignals, n as browserInteractiveControlHolderId, s as InteractiveSessionNotRunningError } from "./browser-interactive-control-controller-
|
|
4
|
-
import { s as uploadChunked } from "./chunked-upload-
|
|
1
|
+
import { I as createAgentRunOutcomeTracker, L as deriveAgentResultOutcome, R as deriveAgentRunOutcome, c as SandboxRuntimeApi, t as BrowserInteractiveSessionController, z as projectAgentTerminalRecord } from "./interactive-controller-OAsASPd_.js";
|
|
2
|
+
import { S as StateError, T as ValidationError, _ as ProfileFileMountPathError, a as AuthError, b as SandboxError, g as PartialFailureError, h as NotFoundError, m as NetworkError, s as CapabilityError, u as FileWriteConflictError, v as QuotaError, w as TimeoutError, x as ServerError } from "./errors-BfbOP_rx.js";
|
|
3
|
+
import { f as combineAbortSignals, n as browserInteractiveControlHolderId, s as InteractiveSessionNotRunningError } from "./browser-interactive-control-controller-DHx53yre.js";
|
|
4
|
+
import { s as uploadChunked } from "./chunked-upload-DN2twsUu.js";
|
|
5
5
|
//#region src/runtime-client.ts
|
|
6
6
|
const DEFAULT_RUNTIME_TIMEOUT_MS = 3e4;
|
|
7
7
|
function requireToken(token) {
|
|
@@ -35,7 +35,7 @@ function requireTimeout(timeoutMs) {
|
|
|
35
35
|
* remains server-side.
|
|
36
36
|
*/
|
|
37
37
|
var SandboxRuntimeClient = class extends SandboxRuntimeApi {
|
|
38
|
-
auth;
|
|
38
|
+
#auth;
|
|
39
39
|
constructor(config) {
|
|
40
40
|
const baseUrl = requireBaseUrl(config.baseUrl);
|
|
41
41
|
const auth = { token: requireToken(config.token) };
|
|
@@ -71,15 +71,15 @@ var SandboxRuntimeClient = class extends SandboxRuntimeApi {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
|
-
this
|
|
74
|
+
this.#auth = auth;
|
|
75
75
|
}
|
|
76
76
|
/** Replace an expiring scoped token without rebuilding consumers. */
|
|
77
77
|
updateToken(token) {
|
|
78
|
-
this
|
|
78
|
+
this.#auth.token = requireToken(token);
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
function createSandboxRuntimeClient(config) {
|
|
82
82
|
return new SandboxRuntimeClient(config);
|
|
83
83
|
}
|
|
84
84
|
//#endregion
|
|
85
|
-
export { AuthError, BrowserInteractiveSessionController, CapabilityError, FileWriteConflictError, InteractiveSessionNotRunningError, NetworkError, NotFoundError, PartialFailureError, QuotaError, SandboxError, SandboxRuntimeClient, ServerError, StateError, TimeoutError, ValidationError, browserInteractiveControlHolderId, createAgentRunOutcomeTracker, createSandboxRuntimeClient, deriveAgentResultOutcome, deriveAgentRunOutcome, projectAgentTerminalRecord, uploadChunked };
|
|
85
|
+
export { AuthError, BrowserInteractiveSessionController, CapabilityError, FileWriteConflictError, InteractiveSessionNotRunningError, NetworkError, NotFoundError, PartialFailureError, ProfileFileMountPathError, QuotaError, SandboxError, SandboxRuntimeClient, ServerError, StateError, TimeoutError, ValidationError, browserInteractiveControlHolderId, createAgentRunOutcomeTracker, createSandboxRuntimeClient, deriveAgentResultOutcome, deriveAgentRunOutcome, projectAgentTerminalRecord, uploadChunked };
|