@tangle-network/sandbox 0.13.0-develop.20260727091103.289ad8d → 0.13.0-develop.20260727092139.956d833

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
@@ -312,7 +312,47 @@ try {
312
312
  ```
313
313
 
314
314
  Fleet policies are checked before provisioning and do not replace account quotas.
315
- Use `client.runBatch()` for unrelated one-shot jobs that do not need stable fleet membership.
315
+
316
+ ## Batch jobs
317
+
318
+ Use `runBatch()` for parallel tasks that do not need stable fleet membership.
319
+ The default creates temporary sandboxes and removes them after the run.
320
+
321
+ ```typescript
322
+ const result = await client.runBatch({
323
+ tasks: [
324
+ { id: "api", message: "Review the API package and fix its tests." },
325
+ { id: "web", message: "Review the web package and fix its tests." },
326
+ ],
327
+ backends: [{ id: "worker", type: "opencode" }],
328
+ });
329
+
330
+ console.log(result.totalSuccess, result.totalFailure);
331
+ ```
332
+
333
+ Set `persistent: true` when later runs must use the same workspace.
334
+ `reuseKey` selects that caller-owned workspace.
335
+ `idempotencyKey` identifies one exact batch request for join or replay.
336
+
337
+ ```typescript
338
+ const request = {
339
+ tasks: [{ id: "upgrade", message: "Upgrade dependencies and run tests." }],
340
+ backends: [{ id: "worker", type: "opencode" }],
341
+ persistent: true as const,
342
+ reuseKey: "service-maintenance",
343
+ git: { url: "https://github.com/acme/service.git" },
344
+ };
345
+
346
+ const result = await client.runBatch(request, {
347
+ idempotencyKey: "service-maintenance-run-42",
348
+ });
349
+ ```
350
+
351
+ Reuse an idempotency key only with the same request body.
352
+ A matching active run is joined and a completed run is replayed.
353
+ A different body with the same key is rejected.
354
+ Disconnecting an unkeyed stream cancels server work, while a keyed run continues and can be joined again with the same key and body.
355
+ `streamBatch()` accepts the same request and call options.
316
356
 
317
357
  ## Temporary GPU leases
318
358
 
@@ -1,6 +1,6 @@
1
- import { C as CodeExecutionResult, S as CodeExecutionOptions, T as CodeResultPart, w as CodeLanguage } from "../types-DtbMtW0q.js";
2
- import { n as SandboxInstance } from "../sandbox-DHLCriUS.js";
3
- import { i as Sandbox } from "../client-BlTjxYXF.js";
1
+ import { C as CodeResultPart, S as CodeLanguage, b as CodeExecutionOptions, x as CodeExecutionResult } from "../types-Dr1wNaqo.js";
2
+ import { n as SandboxInstance } from "../sandbox-Ceeti101.js";
3
+ import { i as Sandbox } from "../client-CGQnn2gj.js";
4
4
  import * as _$_modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
5
5
 
6
6
  //#region src/agent/tools/_specs.d.ts
@@ -1,5 +1,5 @@
1
- import { $n as SandboxFleetDispatchResponse, $t as ListSandboxOptions, A as CreateRequestOptions, An as ReapExpiredSandboxFleetsResult, Ci as TokenRefreshHandler, Cr as SandboxInfo, Ct as FleetMachineId, Dn as PublishPublicTemplateOptions, En as PublicTemplateVersionInfo, Gi as BatchEvent, Gn as SandboxConfig, Gt as IntelligenceReportBudget, Jt as IntelligenceReportWindow, Kt as IntelligenceReportCompareTo, M as CreateSandboxFleetTokenOptions, Mn as ReconcileSandboxFleetsResult, N as CreateSandboxFleetWithCoordinatorOptions, On as PublishPublicTemplateVersionOptions, P as CreateSandboxOptions, Qt as ListSandboxFleetOptions, Sr as SandboxIdentity, St as FleetExecDispatchResult, Tn as PublicTemplateInfo, Tt as FleetPromptDispatchResult, Wt as IntelligenceReport, Xn as SandboxFleetArtifactSpec, Yn as SandboxFleetArtifact, Zn as SandboxFleetCostEstimate, _r as SandboxFleetUsage, _t as FleetDispatchResultBufferOptions, a as AttachSandboxFleetMachineOptions, bn as PromptResult, br as SandboxFleetWorkspaceRestoreResult, bt as FleetDriveTurnRequest, ci as SshKeysManager, cr as SandboxFleetManifest, er as SandboxFleetDriverCapability, et as ExecOptions, fi as SubscriptionInfo, fr as SandboxFleetToken, g as BatchRunRequest, gr as SandboxFleetTraceOptions, gt as FleetDispatchResultBuffer, h as BatchRunOptions, ht as FleetDispatchCancelResult, j as CreateSandboxFleetOptions, jn as ReconcileSandboxFleetsOptions, k as CreateIntelligenceReportOptions, ki as UsageInfo, kn as ReapExpiredSandboxFleetsOptions, m as BatchResult, nr as SandboxFleetInfo, or as SandboxFleetMachineRecord, pr as SandboxFleetTraceBundle, qn as SandboxEnvironment, qr as SecretsManager, tt as ExecResult, ur as SandboxFleetOperationsSummary, vn as PromptInputPart, vt as FleetDispatchStreamOptions, wt as FleetPromptDispatchOptions, xr as SandboxFleetWorkspaceSnapshotResult, xt as FleetExecDispatchOptions, yn as PromptOptions, yr as SandboxFleetWorkspaceReconcileResult, yt as FleetDriveTurnOutcome } from "./types-DtbMtW0q.js";
2
- import { c as TraceExportResult, l as TraceExportSink, n as SandboxInstance, t as HttpClient } from "./sandbox-DHLCriUS.js";
1
+ import { $ as ExecResult, A as CreateSandboxFleetTokenOptions, An as ReconcileSandboxFleetsResult, Cn as PublicTemplateInfo, Ct as FleetPromptDispatchResult, D as CreateIntelligenceReportOptions, Di as UsageInfo, Dn as ReapExpiredSandboxFleetsOptions, En as PublishPublicTemplateVersionOptions, Gn as SandboxEnvironment, Gr as SecretsManager, Ht as IntelligenceReport, Jn as SandboxFleetArtifactSpec, Kt as IntelligenceReportWindow, M as CreateSandboxOptions, O as CreateRequestOptions, On as ReapExpiredSandboxFleetsResult, Q as ExecOptions, Qn as SandboxFleetDriverCapability, St as FleetPromptDispatchOptions, Tn as PublishPublicTemplateOptions, Ui as BatchEvent, Un as SandboxConfig, Ut as IntelligenceReportBudget, Wt as IntelligenceReportCompareTo, Xt as ListSandboxFleetOptions, Yn as SandboxFleetCostEstimate, Zn as SandboxFleetDispatchResponse, Zt as ListSandboxOptions, _n as PromptOptions, _r as SandboxFleetWorkspaceReconcileResult, _t as FleetDriveTurnOutcome, a as AttachSandboxFleetMachineOptions, br as SandboxIdentity, bt as FleetExecDispatchResult, cr as SandboxFleetOperationsSummary, dr as SandboxFleetTraceBundle, er as SandboxFleetInfo, f as BatchResult, gn as PromptInputPart, gt as FleetDispatchStreamOptions, hr as SandboxFleetUsage, ht as FleetDispatchResultBufferOptions, ir as SandboxFleetMachineRecord, j as CreateSandboxFleetWithCoordinatorOptions, k as CreateSandboxFleetOptions, kn as ReconcileSandboxFleetsOptions, m as BatchRunRequest, mr as SandboxFleetTraceOptions, mt as FleetDispatchResultBuffer, oi as SshKeysManager, or as SandboxFleetManifest, p as BatchRunOptions, pt as FleetDispatchCancelResult, qn as SandboxFleetArtifact, ui as SubscriptionInfo, ur as SandboxFleetToken, vn as PromptResult, vr as SandboxFleetWorkspaceRestoreResult, vt as FleetDriveTurnRequest, wn as PublicTemplateVersionInfo, xi as TokenRefreshHandler, xr as SandboxInfo, xt as FleetMachineId, yr as SandboxFleetWorkspaceSnapshotResult, yt as FleetExecDispatchOptions } from "./types-Dr1wNaqo.js";
2
+ import { c as TraceExportResult, l as TraceExportSink, n as SandboxInstance, t as HttpClient } from "./sandbox-Ceeti101.js";
3
3
 
4
4
  //#region src/lib/sse-parser.d.ts
5
5
  /**
@@ -26,8 +26,8 @@ import { c as TraceExportResult, l as TraceExportSink, n as SandboxInstance, t a
26
26
  * - Throws `AbortError` when the caller-supplied signal fires, so
27
27
  * consumers can distinguish "ran to completion" from "cancelled"
28
28
  * without peeking at signal state.
29
- * - Silently drops frames with malformed JSON — the stream remains
30
- * usable and only the individual frame is lost.
29
+ * - Rejects malformed JSON by default. Callers handling recoverable output
30
+ * streams can explicitly warn and skip one invalid frame.
31
31
  *
32
32
  * What it does NOT do:
33
33
  * - CR-only (legacy Mac) line terminators. No known emitter uses
@@ -52,6 +52,11 @@ interface ParseSSEStreamOptions {
52
52
  * to its own catch block instead of looking like a clean finish.
53
53
  */
54
54
  signal?: AbortSignal;
55
+ /**
56
+ * How to handle malformed JSON and non-object payloads. Stateful protocols
57
+ * should keep the default `throw`; output streams may opt into recovery.
58
+ */
59
+ invalidEvent?: "throw" | "warn-and-skip";
55
60
  }
56
61
  /**
57
62
  * Parse a streaming SSE response body into an async iterable of
@@ -456,15 +461,10 @@ declare class Sandbox implements HttpClient {
456
461
  * @param options - Batch execution options
457
462
  * @returns Aggregated batch results
458
463
  *
459
- * @throws {@link TimeoutError} if the server hasn't begun responding
460
- * before the deadline (pre-stream timeout).
461
464
  * @throws {@link ValidationError} / {@link QuotaError} / other typed
462
465
  * SDK errors if the server rejects the request before streaming.
463
466
  * @throws `DOMException` with `name === "AbortError"` if
464
- * `options.signal` fires OR the safety-valve deadline fires
465
- * AFTER streaming has begun — parseSSEStream can't distinguish
466
- * the source mid-stream. Callers that need to tell cancel from
467
- * timeout should check `options.signal?.aborted` in their catch.
467
+ * `options.signal` fires.
468
468
  * @throws `Error` with the server message if the stream emits a
469
469
  * `batch.failed` event.
470
470
  *
@@ -475,6 +475,7 @@ declare class Sandbox implements HttpClient {
475
475
  * { id: "task-1", message: "Analyze this file" },
476
476
  * { id: "task-2", message: "Generate a summary" },
477
477
  * ],
478
+ * backends: [{ id: "primary", type: "opencode" }],
478
479
  * });
479
480
  * console.log(`Success rate: ${result.successRate}%`);
480
481
  * ```
@@ -487,25 +488,24 @@ declare class Sandbox implements HttpClient {
487
488
  * @param request - Complete batch request
488
489
  * @param options - Per-call controls
489
490
  *
490
- * @throws {@link TimeoutError} if the server hasn't begun responding
491
- * before the deadline (pre-stream timeout).
492
491
  * @throws {@link ValidationError} / {@link QuotaError} / other typed
493
492
  * SDK errors if the server rejects the request before streaming.
494
- * @throws `DOMException` with `name === "AbortError"` if
495
- * `options.signal` fires OR the safety-valve deadline fires
496
- * AFTER streaming has begun. Distinguish via
497
- * `options.signal?.aborted` in the consumer's catch.
493
+ * @throws `DOMException` with `name === "AbortError"` when
494
+ * `options.signal` fires.
498
495
  *
499
496
  * @example
500
497
  * ```typescript
501
- * for await (const event of client.streamBatch({ tasks })) {
498
+ * for await (const event of client.streamBatch({
499
+ * tasks,
500
+ * backends: [{ id: "primary", type: "opencode" }],
501
+ * })) {
502
502
  * if (event.type === "task.completed") {
503
503
  * console.log(`Task ${event.data.taskId} completed`);
504
504
  * }
505
505
  * }
506
506
  * ```
507
507
  */
508
- streamBatch(request: BatchRunRequest, options?: BatchRunOptions): AsyncGenerator<BatchEvent>;
508
+ streamBatch(request: BatchRunRequest, options?: BatchRunOptions): AsyncGenerator<BatchEvent, BatchResult>;
509
509
  /**
510
510
  * Make an authenticated HTTP request to the API.
511
511
  * This is exposed for use by SandboxInstance.