@tangle-network/sandbox 0.60.78-develop.20261024162701.a2f5654 → 0.60.78-develop.20261024212902.c9b0cab

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.
Files changed (33) hide show
  1. package/dist/agent/index.d.ts +4 -4
  2. package/dist/agent/index.js +2 -2
  3. package/dist/agent/preview.d.ts +1 -1
  4. package/dist/{agent-run-outcome-B2GRLNiR.d.ts → agent-run-outcome-D8Riqf7N.d.ts} +1 -1
  5. package/dist/auth/index.js +1 -1
  6. package/dist/{cli-auth-bundle-DEwA4y7R.js → cli-auth-bundle-BBuXynrM.js} +1 -1
  7. package/dist/{client-MuxTROy7.js → client-CmoTway8.js} +11 -10
  8. package/dist/{client-DLd0YCcK.d.ts → client-DV1SbwZK.d.ts} +121 -6
  9. package/dist/core.d.ts +6 -6
  10. package/dist/core.js +4 -4
  11. package/dist/gpu-lease/index.d.ts +2 -2
  12. package/dist/gpu-lease/index.js +3 -3
  13. package/dist/{index-OlfnNs7A.d.ts → index-DpsISCBX.d.ts} +3 -3
  14. package/dist/index.d.ts +8 -8
  15. package/dist/index.js +5 -5
  16. package/dist/{interactive-controller-CfD8S3S7.d.ts → interactive-controller-BtdROvsm.d.ts} +1 -1
  17. package/dist/{lines-DwApng9S.d.ts → lines-DViw4KHn.d.ts} +1 -1
  18. package/dist/lines.d.ts +1 -1
  19. package/dist/{local-cli-auth-BR-B4HLq.js → local-cli-auth-BO2sfVoW.js} +1 -1
  20. package/dist/{preview-MU5AbbbZ.d.ts → preview-DRZnmu5V.d.ts} +3 -3
  21. package/dist/{public-templates-CqQWFYZG.d.ts → public-templates-ursM1K2F.d.ts} +1 -1
  22. package/dist/public-templates.d.ts +1 -1
  23. package/dist/runtime.d.ts +3 -3
  24. package/dist/{sandbox-mZ5kF4kb.js → sandbox-DiigN_DB.js} +5 -4
  25. package/dist/select-seat-BSEdpAMq.js +331 -0
  26. package/dist/select-seat-command.d.ts +16 -0
  27. package/dist/select-seat-command.js +87 -0
  28. package/dist/tangle/index.d.ts +1 -1
  29. package/dist/tangle/index.js +1 -1
  30. package/dist/{tangle-B1T44RTd.js → tangle-Ci5No-40.js} +1 -1
  31. package/dist/{types-Dal-kCMH.d.ts → types-D_RvPPTq.d.ts} +2 -2
  32. package/package.json +10 -5
  33. package/dist/line-application-CHcIY0uD.js +0 -124
@@ -0,0 +1,331 @@
1
+ import { T as ValidationError, b as SandboxError, s as CapabilityError } from "./errors-CfQHPcLX.js";
2
+ import { d as awaitWithAbort } from "./browser-interactive-control-controller-k1KkqDGF.js";
3
+ import { r as cliAuthReferenceSchema } from "./cli-auth-bundle-BBuXynrM.js";
4
+ import { z } from "zod";
5
+ import { agentProfileSchema, canonicalAgentProfileDigest } from "@tangle-network/agent-interface";
6
+ //#region src/line-application.ts
7
+ /** Bounded callback request bytes after canonicalization, including JSON framing. */
8
+ const LINE_APPLICATION_REQUEST_MAX_BYTES = 96 * 1024;
9
+ /** Fits the Lines reply splitter and the callback transport's 64 KiB read bound. */
10
+ const LINE_APPLICATION_REPLY_MAX_CHARS = 12e3;
11
+ function record(value) {
12
+ if (value === null || typeof value !== "object" || Array.isArray(value)) throw new TypeError("Expected a line application object");
13
+ return value;
14
+ }
15
+ function text(value, max) {
16
+ if (typeof value !== "string" || !value.trim() || value.includes("\0") || value.length > max) throw new TypeError("Invalid line application text");
17
+ return value;
18
+ }
19
+ function id(value) {
20
+ const result = text(value, 256);
21
+ if (!/^[A-Za-z0-9][A-Za-z0-9_.:@-]*$/.test(result)) throw new TypeError("Invalid line application identity");
22
+ return result;
23
+ }
24
+ function subjectId(value) {
25
+ if (typeof value !== "string" || !/^[A-Za-z0-9][A-Za-z0-9:._-]{0,127}$/.test(value)) throw new TypeError("Invalid line application subject");
26
+ return value;
27
+ }
28
+ function revision(value) {
29
+ const result = text(value, 64);
30
+ if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(result) || !Number.isFinite(Date.parse(result)) || new Date(result).toISOString() !== result) throw new TypeError("Invalid line member revision");
31
+ return result;
32
+ }
33
+ function deadline(value) {
34
+ const result = text(value, 64);
35
+ if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(result) || !Number.isFinite(Date.parse(result)) || new Date(result).toISOString() !== result) throw new TypeError("Invalid line dispatch deadline");
36
+ return result;
37
+ }
38
+ function binding(value) {
39
+ const result = text(value, 1024);
40
+ if (!/^[\x21-\x7e]+$/.test(result)) throw new TypeError("Invalid line application binding");
41
+ return result;
42
+ }
43
+ /** Canonicalize only defined fields. Unknown provider payloads and credentials stay out. */
44
+ function parseLineApplicationRequest(value) {
45
+ const input = record(value);
46
+ if (input.version !== 1) throw new TypeError("Unknown line application version");
47
+ const sender = record(input.sender);
48
+ const transport = input.transport;
49
+ if (transport !== "imessage" && transport !== "sms" && transport !== "whatsapp" && transport !== "email") throw new TypeError("Unknown line transport");
50
+ const receivedAt = text(input.receivedAt, 64);
51
+ if (!Number.isFinite(Date.parse(receivedAt))) throw new TypeError("Invalid line message time");
52
+ const hasSubject = input.subjectId !== void 0;
53
+ const hasRevision = input.memberRevision !== void 0;
54
+ if (hasSubject !== hasRevision) throw new TypeError("Incomplete line member authority");
55
+ const hasFence = input.dispatchFence !== void 0;
56
+ const hasDeadline = input.dispatchDeadline !== void 0;
57
+ if (hasFence !== hasDeadline || hasSubject && !hasFence && input.acceptedExecutionId === void 0) throw new TypeError("Incomplete line dispatch authority");
58
+ const result = {
59
+ version: 1,
60
+ binding: binding(input.binding),
61
+ messageId: id(input.messageId),
62
+ lineId: id(input.lineId),
63
+ attachmentId: id(input.attachmentId),
64
+ memberId: id(input.memberId),
65
+ lineThreadId: id(input.lineThreadId),
66
+ ownerUserId: id(input.ownerUserId),
67
+ ...hasSubject ? { subjectId: subjectId(input.subjectId) } : {},
68
+ ...hasRevision ? { memberRevision: revision(input.memberRevision) } : {},
69
+ ...hasFence ? { dispatchFence: id(input.dispatchFence) } : {},
70
+ ...hasDeadline ? { dispatchDeadline: deadline(input.dispatchDeadline) } : {},
71
+ sender: {
72
+ address: text(sender.address, 320),
73
+ role: id(sender.role)
74
+ },
75
+ transport,
76
+ receivedAt,
77
+ ...input.acceptedExecutionId === void 0 ? {} : { acceptedExecutionId: id(input.acceptedExecutionId) },
78
+ text: text(input.text, 64 * 1024)
79
+ };
80
+ if (new TextEncoder().encode(JSON.stringify(result)).byteLength > 98304) throw new TypeError("Line application request exceeds the byte limit");
81
+ return result;
82
+ }
83
+ /** A raw agent response is not this receipt. Applications report only settled output. */
84
+ function parseLineApplicationResult(value, request) {
85
+ const result = record(value);
86
+ if (result.version !== 1 || result.binding !== request.binding || result.messageId !== request.messageId || result.attachmentId !== request.attachmentId) throw new TypeError("Line application result identity mismatch");
87
+ if (request.acceptedExecutionId !== void 0 && result.executionId !== request.acceptedExecutionId) throw new TypeError("Accepted application execution changed");
88
+ const identity = {
89
+ version: 1,
90
+ binding: request.binding,
91
+ messageId: request.messageId,
92
+ attachmentId: request.attachmentId
93
+ };
94
+ switch (result.state) {
95
+ case "pending":
96
+ if (typeof result.admitted !== "boolean") throw new TypeError("Admission is not established");
97
+ if (result.admitted) return {
98
+ ...identity,
99
+ state: "pending",
100
+ admitted: true,
101
+ executionId: id(result.executionId)
102
+ };
103
+ if (result.executionId !== void 0) throw new TypeError("Unadmitted result cannot name an execution");
104
+ return {
105
+ ...identity,
106
+ state: "pending",
107
+ admitted: false
108
+ };
109
+ case "completed": return {
110
+ ...identity,
111
+ state: "completed",
112
+ executionId: id(result.executionId),
113
+ text: text(result.text, LINE_APPLICATION_REPLY_MAX_CHARS)
114
+ };
115
+ case "failed": {
116
+ const code = text(result.code, 80);
117
+ if (!/^[a-z][a-z0-9_:.-]*$/.test(code)) throw new TypeError("Invalid failure code");
118
+ return {
119
+ ...identity,
120
+ state: "failed",
121
+ code,
122
+ ...result.executionId === void 0 ? {} : { executionId: id(result.executionId) }
123
+ };
124
+ }
125
+ default: throw new TypeError("Unknown line application state");
126
+ }
127
+ }
128
+ //#endregion
129
+ //#region ../../../packages/runtime-contracts/dist/seat-selection.js
130
+ /**
131
+ * Wire contract of `POST /v1/model-credentials/resolve` seat selection, shared by
132
+ * the Sandbox SDK's `createSelectSeat` and the Sandbox API gateway.
133
+ */
134
+ const seatIdentifierSchema = z.string().min(1).max(256).refine((value) => value.trim() === value);
135
+ const seatSelectorSchema = z.union([z.strictObject({ kind: z.literal("all-eligible") }), z.strictObject({
136
+ kind: z.literal("seat"),
137
+ id: seatIdentifierSchema
138
+ })]);
139
+ /** An HTTPS provider origin with no userinfo, query or fragment that could carry a raw value. */
140
+ const seatProviderOriginSchema = z.url().refine((value) => {
141
+ const url = new URL(value);
142
+ return url.protocol === "https:" && !url.username && !url.password && !url.search && !url.hash;
143
+ });
144
+ const seatSecretNameSchema = z.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}$/);
145
+ /** Classified account-owner refusal; only these fields ever leave the gateway. */
146
+ const seatSelectionRefusalSchema = z.strictObject({ error: z.strictObject({
147
+ code: z.enum([
148
+ "provider_quota_exhausted",
149
+ "upstream_unavailable",
150
+ "model_credential_refused"
151
+ ]),
152
+ reason: z.enum([
153
+ "exhausted",
154
+ "unknown",
155
+ "held",
156
+ "busy",
157
+ "unsupported_route",
158
+ "forbidden",
159
+ "revoked"
160
+ ]),
161
+ resetAt: z.iso.datetime().optional(),
162
+ recheckAt: z.iso.datetime().optional()
163
+ }) });
164
+ //#endregion
165
+ //#region src/select-seat.ts
166
+ const identifier = seatIdentifierSchema;
167
+ const timestamp = z.iso.datetime();
168
+ const selectorSchema = seatSelectorSchema;
169
+ const credentialsSchema = z.union([z.strictObject({
170
+ apiKeyEnv: seatSecretNameSchema,
171
+ baseUrl: seatProviderOriginSchema
172
+ }), z.strictObject({ cliAuth: cliAuthReferenceSchema })]);
173
+ const resolutionSchema = z.strictObject({
174
+ seatId: identifier,
175
+ credentials: credentialsSchema
176
+ });
177
+ const refusalSchema = seatSelectionRefusalSchema;
178
+ /** The authenticated Sandbox gateway to the hosted account owner. */
179
+ function gatewaySeatTransport(client) {
180
+ return async (request, signal) => {
181
+ const response = await client.fetch("/v1/model-credentials/resolve", {
182
+ method: "POST",
183
+ body: JSON.stringify(request),
184
+ ...signal ? { signal } : {}
185
+ });
186
+ const body = await response.json().catch((error) => {
187
+ if (error instanceof SyntaxError) throw new ValidationError("The account owner returned invalid JSON");
188
+ throw error;
189
+ });
190
+ return {
191
+ ok: response.ok,
192
+ status: response.status,
193
+ body
194
+ };
195
+ };
196
+ }
197
+ /** Classified owner refusal, with fixed diagnostics and no upstream credential material. */
198
+ var SeatSelectionError = class extends SandboxError {
199
+ constructor(code, reason, status) {
200
+ super("The account owner refused seat selection", code, status);
201
+ this.reason = reason;
202
+ this.name = "SeatSelectionError";
203
+ }
204
+ };
205
+ function stageProfile(input) {
206
+ const { seats: _seats, ...base } = input.profile;
207
+ const stage = input.stage;
208
+ const profile = {
209
+ ...base,
210
+ harness: stage.harness,
211
+ ...stage.tools === void 0 ? {} : { tools: stage.tools },
212
+ ...stage.permissions === void 0 ? {} : { permissions: stage.permissions },
213
+ model: {
214
+ ...base.model,
215
+ default: stage.model,
216
+ provider: stage.provider
217
+ }
218
+ };
219
+ if (!agentProfileSchema.safeParse(profile).success) throw new ValidationError("Seat selection requires a valid exact stage profile");
220
+ return JSON.parse(JSON.stringify(profile));
221
+ }
222
+ async function checkNativeContinuation(options, input) {
223
+ if (!input.requiresNativeTurnGrant) return;
224
+ if (!input.retainedEnvironmentId) throw new CapabilityError("Native seat continuation requires a retained environment");
225
+ options.signal?.throwIfAborted();
226
+ const box = await awaitWithAbort(options.client.get(input.retainedEnvironmentId), options.signal);
227
+ if (!box || box.id !== input.retainedEnvironmentId || box.status !== "running") throw new CapabilityError("Native seat continuation requires the running retained environment");
228
+ const capabilities = await awaitWithAbort(box.capabilities(), options.signal);
229
+ options.signal?.throwIfAborted();
230
+ if (capabilities?.cliAuthReferences !== true || (input.stage.harness === "claude-code" ? capabilities.claudeTokenContinuations !== true : input.stage.harness === "codex" ? capabilities.codexCredentialContinuations !== true : true)) throw new CapabilityError("The retained environment cannot grant this native seat");
231
+ }
232
+ /** Compose the existing authenticated account selector with a caller's provider backend. */
233
+ function createSelectSeat(options) {
234
+ const runId = identifier.parse(options.runId);
235
+ const transport = options.transport ?? gatewaySeatTransport(options.client);
236
+ const minimumValidUntil = timestamp.parse(typeof options.minimumValidUntil === "function" ? options.minimumValidUntil() : options.minimumValidUntil);
237
+ return async (submittedInput) => {
238
+ const started = performance.now();
239
+ const nodeId = submittedInput.nodeId;
240
+ const key = JSON.stringify([
241
+ runId,
242
+ nodeId,
243
+ submittedInput.stageIndex,
244
+ submittedInput.segmentIndex
245
+ ]);
246
+ let ok = false;
247
+ let refusal;
248
+ try {
249
+ options.signal?.throwIfAborted();
250
+ const input = structuredClone(submittedInput);
251
+ identifier.parse(input.nodeId);
252
+ selectorSchema.parse(input.stage.selector);
253
+ if (input.resumeSeatId !== void 0) identifier.parse(input.resumeSeatId);
254
+ if (!Number.isSafeInteger(input.stageIndex) || input.stageIndex < 0 || !Number.isSafeInteger(input.segmentIndex) || input.segmentIndex < 0 || !Array.isArray(input.excludedSeatIds) || input.excludedSeatIds.length > 256 || input.excludedSeatIds.some((id) => !identifier.safeParse(id).success)) throw new ValidationError("Seat selection requires a stable logical segment");
255
+ if (Date.parse(minimumValidUntil) <= Date.now()) throw new ValidationError("The run's account validity deadline has elapsed");
256
+ const profile = stageProfile(input);
257
+ await checkNativeContinuation(options, input);
258
+ const response = await transport({ selection: {
259
+ runId,
260
+ nodeId: input.nodeId,
261
+ stageIndex: input.stageIndex,
262
+ segmentIndex: input.segmentIndex,
263
+ profile,
264
+ selector: input.stage.selector,
265
+ excludedSeatIds: input.excludedSeatIds,
266
+ ...input.resumeSeatId === void 0 ? {} : { resumeSeatId: input.resumeSeatId },
267
+ ...input.retainedEnvironmentId === void 0 ? {} : { retainedEnvironmentId: input.retainedEnvironmentId },
268
+ requiresNativeTurnGrant: input.requiresNativeTurnGrant,
269
+ minimumValidUntil
270
+ } }, options.signal);
271
+ const payload = response.body;
272
+ options.signal?.throwIfAborted();
273
+ if (!response.ok) {
274
+ const parsed = refusalSchema.safeParse(payload);
275
+ if (!parsed.success) throw new SandboxError("Account selection was not confirmed", "SEAT_SELECTION_UNCONFIRMED", response.status);
276
+ const error = parsed.data.error;
277
+ const resumeAt = error.resetAt ?? error.recheckAt;
278
+ refusal = {
279
+ code: error.code,
280
+ reason: error.reason,
281
+ ...resumeAt ? { resumeAt } : {}
282
+ };
283
+ if ((response.status === 429 || response.status === 503) && error.code === "provider_quota_exhausted" && error.reason === "exhausted" && resumeAt) return { resumeAt };
284
+ throw new SeatSelectionError(error.code, error.reason, response.status);
285
+ }
286
+ const parsed = resolutionSchema.safeParse(payload);
287
+ if (!parsed.success) throw new ValidationError("The account owner returned an invalid seat reference");
288
+ const { seatId, credentials } = parsed.data;
289
+ if (input.stage.selector.kind === "seat" && input.stage.selector.id !== seatId || input.resumeSeatId !== void 0 && input.resumeSeatId !== seatId || input.excludedSeatIds.includes(seatId)) throw new ValidationError("The account owner returned a conflicting seat");
290
+ if (input.requiresNativeTurnGrant && (!("cliAuth" in credentials) || (input.stage.harness === "claude-code" ? credentials.cliAuth.format !== "token" : input.stage.harness === "codex" ? !["bundle", "files"].includes(credentials.cliAuth.format) : true))) throw new CapabilityError("The selected reference cannot grant this native continuation");
291
+ const profileDigest = canonicalAgentProfileDigest(profile);
292
+ const resolveModelCredentials = (request) => {
293
+ if (request?.profile !== void 0 && (typeof request.profile === "string" || canonicalAgentProfileDigest(request.profile) !== profileDigest)) throw new ValidationError("A selected seat cannot authenticate a different stage profile");
294
+ return structuredClone(credentials);
295
+ };
296
+ const backend = await awaitWithAbort(Promise.resolve(options.createBackend({
297
+ seatId,
298
+ credentials: resolveModelCredentials(),
299
+ profile,
300
+ input,
301
+ resolveModelCredentials
302
+ })), options.signal);
303
+ options.signal?.throwIfAborted();
304
+ if (backend.backend !== "provider" || backend.provider === void 0 || backend.provider === null) throw new ValidationError("Seat selection requires a provider backend");
305
+ ok = true;
306
+ return {
307
+ seat: seatId,
308
+ backend,
309
+ ...input.requiresNativeTurnGrant ? { nativeTurnGrant: true } : {}
310
+ };
311
+ } catch (error) {
312
+ refusal ??= {
313
+ code: error instanceof SandboxError ? error.code : "SEAT_SELECTION_FAILED",
314
+ ...error instanceof SeatSelectionError ? { reason: error.reason } : {}
315
+ };
316
+ throw error;
317
+ } finally {
318
+ try {
319
+ options.onResolution?.({
320
+ key,
321
+ nodeId,
322
+ ms: performance.now() - started,
323
+ ok,
324
+ ...refusal ? { refusal } : {}
325
+ });
326
+ } catch {}
327
+ }
328
+ };
329
+ }
330
+ //#endregion
331
+ export { LINE_APPLICATION_REQUEST_MAX_BYTES as a, LINE_APPLICATION_REPLY_MAX_CHARS as i, createSelectSeat as n, parseLineApplicationRequest as o, gatewaySeatTransport as r, parseLineApplicationResult as s, SeatSelectionError as t };
@@ -0,0 +1,16 @@
1
+ import { k as SeatOwnerTransport } from "./client-DV1SbwZK.js";
2
+
3
+ //#region src/select-seat-command.d.ts
4
+ /** Public reply bound; the owner prints one metadata object. */
5
+ declare const SEAT_COMMAND_MAX_RESPONSE_BYTES: number;
6
+ declare const SEAT_COMMAND_TIMEOUT_MS = 30000;
7
+ interface CommandSeatTransportOptions {
8
+ /** Absolute argv of the account owner; never run through a shell. */
9
+ command: readonly string[];
10
+ /** Complete environment for the owner process. */
11
+ env?: Record<string, string | undefined>;
12
+ timeoutMs?: number;
13
+ }
14
+ declare function commandSeatTransport(options: CommandSeatTransportOptions): SeatOwnerTransport;
15
+ //#endregion
16
+ export { CommandSeatTransportOptions, SEAT_COMMAND_MAX_RESPONSE_BYTES, SEAT_COMMAND_TIMEOUT_MS, commandSeatTransport };
@@ -0,0 +1,87 @@
1
+ import { T as ValidationError, b as SandboxError } from "./errors-CfQHPcLX.js";
2
+ import { spawn } from "node:child_process";
3
+ //#region src/select-seat-command.ts
4
+ /**
5
+ * Node-only transport for `createSelectSeat`: runs a configured account-owner
6
+ * command (for example `acct sandbox resolve`) on a trusted controller host.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { createSelectSeat } from "@tangle-network/sandbox";
11
+ * import { commandSeatTransport } from "@tangle-network/sandbox/select-seat/command";
12
+ *
13
+ * const selectSeat = createSelectSeat({ client, runId, minimumValidUntil, createBackend,
14
+ * transport: commandSeatTransport({ command: ["/usr/local/bin/acct", "sandbox", "resolve"] }) });
15
+ * ```
16
+ *
17
+ * @packageDocumentation
18
+ */
19
+ /** Public reply bound; the owner prints one metadata object. */
20
+ const SEAT_COMMAND_MAX_RESPONSE_BYTES = 64 * 1024;
21
+ const SEAT_COMMAND_TIMEOUT_MS = 3e4;
22
+ /** The owner command's exit contract: 0 selected, 75 capacity refusal, 78 permanent route refusal. */
23
+ const EXIT_STATUS = {
24
+ 0: 200,
25
+ 75: 503,
26
+ 78: 400
27
+ };
28
+ function commandSeatTransport(options) {
29
+ const [program, ...args] = options.command;
30
+ if (program === void 0 || options.command.some((part) => typeof part !== "string" || part.length === 0)) throw new ValidationError("Seat selection requires a configured account command");
31
+ const timeoutMs = options.timeoutMs ?? 3e4;
32
+ return (request, signal) => new Promise((resolve, reject) => {
33
+ signal?.throwIfAborted();
34
+ const child = spawn(program, args, {
35
+ env: options.env ?? process.env,
36
+ shell: false,
37
+ stdio: [
38
+ "pipe",
39
+ "pipe",
40
+ "pipe"
41
+ ]
42
+ });
43
+ let settled = false;
44
+ let size = 0;
45
+ const chunks = [];
46
+ const finish = (error, reply = null) => {
47
+ if (settled) return;
48
+ settled = true;
49
+ clearTimeout(timer);
50
+ signal?.removeEventListener("abort", abort);
51
+ if (error) {
52
+ child.kill("SIGKILL");
53
+ reject(error);
54
+ } else if (reply) resolve(reply);
55
+ };
56
+ const fail = (message) => finish(new SandboxError(message, "SEAT_SELECTION_UNCONFIRMED", 502));
57
+ const abort = () => finish(signal?.reason instanceof Error ? signal.reason : /* @__PURE__ */ new Error("aborted"));
58
+ signal?.addEventListener("abort", abort, { once: true });
59
+ const timer = setTimeout(() => fail("The account owner command timed out"), timeoutMs);
60
+ child.stderr.resume();
61
+ child.stdin.on("error", () => fail("The account owner command refused its request"));
62
+ child.stdout.on("data", (chunk) => {
63
+ size += chunk.length;
64
+ if (size > 65536) return fail("The account owner exceeded its public response bound");
65
+ chunks.push(chunk);
66
+ });
67
+ child.on("error", () => fail("The account owner command could not start"));
68
+ child.on("close", (code) => {
69
+ const status = code === null ? void 0 : EXIT_STATUS[code];
70
+ if (status === void 0) return fail("The account owner could not establish eligible capacity");
71
+ let body;
72
+ try {
73
+ body = JSON.parse(Buffer.concat(chunks).toString("utf8"));
74
+ } catch {
75
+ return finish(new ValidationError("The account owner returned invalid JSON"));
76
+ }
77
+ finish(null, {
78
+ ok: status === 200,
79
+ status,
80
+ body
81
+ });
82
+ });
83
+ child.stdin.end(JSON.stringify(request));
84
+ });
85
+ }
86
+ //#endregion
87
+ export { SEAT_COMMAND_MAX_RESPONSE_BYTES, SEAT_COMMAND_TIMEOUT_MS, commandSeatTransport };
@@ -1,2 +1,2 @@
1
- import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as JOB_SANDBOX_DELETE, T as SandboxCreateResponseParamTypes, _ as TANGLE_JOBS_CONTRACT, a as fetchQuote, b as AgentSandboxBlueprintAbi, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as TANGLE_CHAIN_ID, h as TangleSandboxClient, i as SignedQuote, l as validateQuote, m as SignMessage, n as QuoteDomain, o as inputsHashOf, p as OperatorSessionToken, r as QuoteError, s as jobQuoteDigest, t as JobQuoteDetails, u as OperatorChallenge, v as TangleSandboxClientConfig, w as SandboxCreateParamTypes, x as JOB_SANDBOX_CREATE, y as ITangleJobsAbi } from "../index-OlfnNs7A.js";
1
+ import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as JOB_SANDBOX_DELETE, T as SandboxCreateResponseParamTypes, _ as TANGLE_JOBS_CONTRACT, a as fetchQuote, b as AgentSandboxBlueprintAbi, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as TANGLE_CHAIN_ID, h as TangleSandboxClient, i as SignedQuote, l as validateQuote, m as SignMessage, n as QuoteDomain, o as inputsHashOf, p as OperatorSessionToken, r as QuoteError, s as jobQuoteDigest, t as JobQuoteDetails, u as OperatorChallenge, v as TangleSandboxClientConfig, w as SandboxCreateParamTypes, x as JOB_SANDBOX_CREATE, y as ITangleJobsAbi } from "../index-DpsISCBX.js";
2
2
  export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JobQuoteDetails, JsonResponseParamTypes, OperatorChallenge, OperatorSession, OperatorSessionError, OperatorSessionToken, QuoteDomain, QuoteError, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, SignMessage, SignedQuote, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TangleSandboxClient, TangleSandboxClientConfig, fetchQuote, inputsHashOf, jobQuoteDigest, parseQuoteResponse, validateQuote };
@@ -1,2 +1,2 @@
1
- import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as TANGLE_JOBS_CONTRACT, f as ITangleJobsAbi, g as JsonResponseParamTypes, h as JOB_SANDBOX_DELETE, i as jobQuoteDigest, l as OperatorSessionError, m as JOB_SANDBOX_CREATE, n as fetchQuote, o as validateQuote, p as AgentSandboxBlueprintAbi, r as inputsHashOf, s as TangleSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-B1T44RTd.js";
1
+ import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as TANGLE_JOBS_CONTRACT, f as ITangleJobsAbi, g as JsonResponseParamTypes, h as JOB_SANDBOX_DELETE, i as jobQuoteDigest, l as OperatorSessionError, m as JOB_SANDBOX_CREATE, n as fetchQuote, o as validateQuote, p as AgentSandboxBlueprintAbi, r as inputsHashOf, s as TangleSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-Ci5No-40.js";
2
2
  export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, OperatorSession, OperatorSessionError, QuoteError, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TangleSandboxClient, fetchQuote, inputsHashOf, jobQuoteDigest, parseQuoteResponse, validateQuote };
@@ -1,5 +1,5 @@
1
1
  import { i as readResponseJson } from "./errors-CfQHPcLX.js";
2
- import { n as createSandboxInstanceFromResponse } from "./sandbox-mZ5kF4kb.js";
2
+ import { n as createSandboxInstanceFromResponse } from "./sandbox-DiigN_DB.js";
3
3
  import { _ as rotlBH, a as anumber, b as rotlSL, d as createXOFer, g as u32, h as toBytes$1, l as createHasher, m as swap32IfBE, n as abytes, o as aoutput, r as aexists, s as clean, t as Hash, v as rotlBL, x as split, y as rotlSH } from "./utils-Bl-H3KsQ.js";
4
4
  //#region ../../../packages/runtime-contracts/dist/tangle-blueprint-abi.js
5
5
  /**
@@ -6204,7 +6204,7 @@ interface CreateSandboxFleetOptions {
6204
6204
  /**
6205
6205
  * Sandbox creates in flight at once. Defaults to 8: every create and delete
6206
6206
  * mints or revokes two Platform keys, and about 25 in flight has locked the
6207
- * Platform key store for every customer (2026-09-15).
6207
+ * Platform key store for every customer.
6208
6208
  */
6209
6209
  maxConcurrentCreates?: number;
6210
6210
  /**
@@ -6245,7 +6245,7 @@ interface FleetExecDispatchOptions extends Pick<ExecOptions, "cwd" | "env" | "ti
6245
6245
  /**
6246
6246
  * Branches in flight at once. Defaults to every selected machine. The API
6247
6247
  * runs on a Cloudflare Worker, which keeps at most six upstream connections
6248
- * open per request, so branches past six queue (measured 2026-09-25: twelve
6248
+ * open per request, so branches past six queue (twelve
6249
6249
  * 8 s commands took 17.8 s, six took 9.7 s).
6250
6250
  */
6251
6251
  maxConcurrent?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sandbox",
3
- "version": "0.60.78-develop.20261024162701.a2f5654",
3
+ "version": "0.60.78-develop.20261024212902.c9b0cab",
4
4
  "description": "Client SDK for the Tangle Sandbox platform - build AI agent applications with dev containers",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -44,6 +44,11 @@
44
44
  "types": "./dist/auth/index.d.ts",
45
45
  "default": "./dist/auth/index.js"
46
46
  },
47
+ "./select-seat/command": {
48
+ "import": "./dist/select-seat-command.js",
49
+ "types": "./dist/select-seat-command.d.ts",
50
+ "default": "./dist/select-seat-command.js"
51
+ },
47
52
  "./collaboration": {
48
53
  "import": "./dist/collaboration/index.js",
49
54
  "types": "./dist/collaboration/index.d.ts",
@@ -160,12 +165,12 @@
160
165
  "ws": "^8.20.0",
161
166
  "yjs": "13.6.30",
162
167
  "@products/sandbox-test-utils": "0.0.0",
168
+ "@repo/shared": "0.0.0",
169
+ "@tangle-network/agent-profile-materialize": "0.26.0",
163
170
  "@tangle-network/cli-agent-registry": "0.10.2",
164
- "@tangle-network/sdk": "4.0.16",
165
171
  "@tangle-network/runtime-contracts": "0.19.0",
166
- "@tangle-network/sse-core": "0.0.0",
167
- "@repo/shared": "0.0.0",
168
- "@tangle-network/agent-profile-materialize": "0.26.0"
172
+ "@tangle-network/sdk": "4.0.16",
173
+ "@tangle-network/sse-core": "0.0.0"
169
174
  },
170
175
  "scripts": {
171
176
  "build": "node scripts/build-dist.mjs",
@@ -1,124 +0,0 @@
1
- //#region src/line-application.ts
2
- /** Bounded callback request bytes after canonicalization, including JSON framing. */
3
- const LINE_APPLICATION_REQUEST_MAX_BYTES = 96 * 1024;
4
- /** Fits the Lines reply splitter and the callback transport's 64 KiB read bound. */
5
- const LINE_APPLICATION_REPLY_MAX_CHARS = 12e3;
6
- function record(value) {
7
- if (value === null || typeof value !== "object" || Array.isArray(value)) throw new TypeError("Expected a line application object");
8
- return value;
9
- }
10
- function text(value, max) {
11
- if (typeof value !== "string" || !value.trim() || value.includes("\0") || value.length > max) throw new TypeError("Invalid line application text");
12
- return value;
13
- }
14
- function id(value) {
15
- const result = text(value, 256);
16
- if (!/^[A-Za-z0-9][A-Za-z0-9_.:@-]*$/.test(result)) throw new TypeError("Invalid line application identity");
17
- return result;
18
- }
19
- function subjectId(value) {
20
- if (typeof value !== "string" || !/^[A-Za-z0-9][A-Za-z0-9:._-]{0,127}$/.test(value)) throw new TypeError("Invalid line application subject");
21
- return value;
22
- }
23
- function revision(value) {
24
- const result = text(value, 64);
25
- if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(result) || !Number.isFinite(Date.parse(result)) || new Date(result).toISOString() !== result) throw new TypeError("Invalid line member revision");
26
- return result;
27
- }
28
- function deadline(value) {
29
- const result = text(value, 64);
30
- if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(result) || !Number.isFinite(Date.parse(result)) || new Date(result).toISOString() !== result) throw new TypeError("Invalid line dispatch deadline");
31
- return result;
32
- }
33
- function binding(value) {
34
- const result = text(value, 1024);
35
- if (!/^[\x21-\x7e]+$/.test(result)) throw new TypeError("Invalid line application binding");
36
- return result;
37
- }
38
- /** Canonicalize only defined fields. Unknown provider payloads and credentials stay out. */
39
- function parseLineApplicationRequest(value) {
40
- const input = record(value);
41
- if (input.version !== 1) throw new TypeError("Unknown line application version");
42
- const sender = record(input.sender);
43
- const transport = input.transport;
44
- if (transport !== "imessage" && transport !== "sms" && transport !== "whatsapp" && transport !== "email") throw new TypeError("Unknown line transport");
45
- const receivedAt = text(input.receivedAt, 64);
46
- if (!Number.isFinite(Date.parse(receivedAt))) throw new TypeError("Invalid line message time");
47
- const hasSubject = input.subjectId !== void 0;
48
- const hasRevision = input.memberRevision !== void 0;
49
- if (hasSubject !== hasRevision) throw new TypeError("Incomplete line member authority");
50
- const hasFence = input.dispatchFence !== void 0;
51
- const hasDeadline = input.dispatchDeadline !== void 0;
52
- if (hasFence !== hasDeadline || hasSubject && !hasFence && input.acceptedExecutionId === void 0) throw new TypeError("Incomplete line dispatch authority");
53
- const result = {
54
- version: 1,
55
- binding: binding(input.binding),
56
- messageId: id(input.messageId),
57
- lineId: id(input.lineId),
58
- attachmentId: id(input.attachmentId),
59
- memberId: id(input.memberId),
60
- lineThreadId: id(input.lineThreadId),
61
- ownerUserId: id(input.ownerUserId),
62
- ...hasSubject ? { subjectId: subjectId(input.subjectId) } : {},
63
- ...hasRevision ? { memberRevision: revision(input.memberRevision) } : {},
64
- ...hasFence ? { dispatchFence: id(input.dispatchFence) } : {},
65
- ...hasDeadline ? { dispatchDeadline: deadline(input.dispatchDeadline) } : {},
66
- sender: {
67
- address: text(sender.address, 320),
68
- role: id(sender.role)
69
- },
70
- transport,
71
- receivedAt,
72
- ...input.acceptedExecutionId === void 0 ? {} : { acceptedExecutionId: id(input.acceptedExecutionId) },
73
- text: text(input.text, 64 * 1024)
74
- };
75
- if (new TextEncoder().encode(JSON.stringify(result)).byteLength > 98304) throw new TypeError("Line application request exceeds the byte limit");
76
- return result;
77
- }
78
- /** A raw agent response is not this receipt. Applications report only settled output. */
79
- function parseLineApplicationResult(value, request) {
80
- const result = record(value);
81
- if (result.version !== 1 || result.binding !== request.binding || result.messageId !== request.messageId || result.attachmentId !== request.attachmentId) throw new TypeError("Line application result identity mismatch");
82
- if (request.acceptedExecutionId !== void 0 && result.executionId !== request.acceptedExecutionId) throw new TypeError("Accepted application execution changed");
83
- const identity = {
84
- version: 1,
85
- binding: request.binding,
86
- messageId: request.messageId,
87
- attachmentId: request.attachmentId
88
- };
89
- switch (result.state) {
90
- case "pending":
91
- if (typeof result.admitted !== "boolean") throw new TypeError("Admission is not established");
92
- if (result.admitted) return {
93
- ...identity,
94
- state: "pending",
95
- admitted: true,
96
- executionId: id(result.executionId)
97
- };
98
- if (result.executionId !== void 0) throw new TypeError("Unadmitted result cannot name an execution");
99
- return {
100
- ...identity,
101
- state: "pending",
102
- admitted: false
103
- };
104
- case "completed": return {
105
- ...identity,
106
- state: "completed",
107
- executionId: id(result.executionId),
108
- text: text(result.text, LINE_APPLICATION_REPLY_MAX_CHARS)
109
- };
110
- case "failed": {
111
- const code = text(result.code, 80);
112
- if (!/^[a-z][a-z0-9_:.-]*$/.test(code)) throw new TypeError("Invalid failure code");
113
- return {
114
- ...identity,
115
- state: "failed",
116
- code,
117
- ...result.executionId === void 0 ? {} : { executionId: id(result.executionId) }
118
- };
119
- }
120
- default: throw new TypeError("Unknown line application state");
121
- }
122
- }
123
- //#endregion
124
- export { parseLineApplicationResult as i, LINE_APPLICATION_REQUEST_MAX_BYTES as n, parseLineApplicationRequest as r, LINE_APPLICATION_REPLY_MAX_CHARS as t };