@tangle-network/sandbox 0.60.77 → 0.60.78-d5-preview.20261025130255.7c1d588b35

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 (83) hide show
  1. package/README.md +69 -3
  2. package/dist/abort-signal-BKVZNJul.js +46 -0
  3. package/dist/agent/index.d.ts +96 -172
  4. package/dist/agent/index.js +62 -125
  5. package/dist/agent/preview.d.ts +1 -1
  6. package/dist/agent/preview.js +2 -2
  7. package/dist/{agent-run-outcome-CTEpjCEZ.d.ts → agent-run-outcome-DhwdbtHs.d.ts} +1 -1
  8. package/dist/auth/index.d.ts +2 -2
  9. package/dist/auth/index.js +5 -5
  10. package/dist/{backend-types-D6bYbvMB.js → backend-types-CLvdSX8V.js} +41 -1
  11. package/dist/{browser-interactive-control-controller-BJf0P_J4.js → browser-interactive-control-controller-CLHNi8rG.js} +2 -31
  12. package/dist/{browser-interactive-control-controller-rpTbyvAS.d.ts → browser-interactive-control-controller-DaQzoLQV.d.ts} +1 -1
  13. package/dist/{chunked-upload-DtIvkKNo.js → chunked-upload-DPr_EPNJ.js} +2 -59
  14. package/dist/{chunked-upload-file-DnsHEjg0.js → chunked-upload-file-Bz40KnI1.js} +2 -1
  15. package/dist/{cli-auth-bundle-cSJjPeFF.js → cli-auth-bundle-4mtmR8Mo.js} +59 -12
  16. package/dist/client-B7wLVacH.d.ts +6163 -0
  17. package/dist/{client-CRkHfByN.js → client-ZwNO3WtJ.js} +3474 -3490
  18. package/dist/collaboration/index.d.ts +1 -1
  19. package/dist/collaboration/index.js +1 -1
  20. package/dist/{collaboration-DaJU5O0E.js → collaboration-CjGKiOIz.js} +5 -5
  21. package/dist/core-FODsUD6k.js +338 -0
  22. package/dist/core.d.ts +7 -15
  23. package/dist/core.js +7 -13
  24. package/dist/direct-http2-B6FAL0kH.js +99 -0
  25. package/dist/{errors-DSJBKmGZ.js → errors-CfQHPcLX.js} +173 -29
  26. package/dist/gpu-lease/index.d.ts +6 -11
  27. package/dist/gpu-lease/index.js +3 -3
  28. package/dist/{index-DO7GVpk_.d.ts → index--PbevcC-.d.ts} +1 -1
  29. package/dist/{index-DZ27pdB8.d.ts → index-CdSSy8x8.d.ts} +1 -1
  30. package/dist/{sandbox-CoIGxzm_.d.ts → index-D7Yq_Zpv.d.ts} +2116 -1544
  31. package/dist/index.d.ts +12 -4704
  32. package/dist/index.js +305 -37
  33. package/dist/intelligence/index.d.ts +12 -12
  34. package/dist/intelligence/index.js +1 -1
  35. package/dist/interactive-control.d.ts +1 -1
  36. package/dist/interactive-control.js +1 -1
  37. package/dist/{interactive-controller-CJ24g8Va.js → interactive-controller-CHepCNjB.js} +562 -733
  38. package/dist/interactive-controller-Cca71LR1.d.ts +41 -0
  39. package/dist/keep-alive-fetch-D96NqGgY.js +247 -0
  40. package/dist/lib/prepared-evidence.d.ts +7 -0
  41. package/dist/lib/prepared-evidence.js +2 -0
  42. package/dist/lib/prepared-process.d.ts +10 -0
  43. package/dist/lib/prepared-process.js +2 -0
  44. package/dist/{lines-DodQslsf.d.ts → lines-721qBB-s.d.ts} +21 -17
  45. package/dist/lines-UeuhtPZd.js +298 -0
  46. package/dist/lines.d.ts +1 -1
  47. package/dist/lines.js +1 -295
  48. package/dist/{local-cli-auth-CBV7Vjk5.js → local-cli-auth-lU0J87jb.js} +1 -1
  49. package/dist/{mcp-local-DjryqUiY.js → mcp-local-CK_PRKRR.js} +1 -1
  50. package/dist/openai/index.d.ts +3 -3
  51. package/dist/prepared-evidence-zKAHIepL.js +65 -0
  52. package/dist/prepared-process-8d-3cpbe.js +100 -0
  53. package/dist/{preview-wpGGk0bu.d.ts → preview-BOyw_XIl.d.ts} +3 -3
  54. package/dist/public-templates-C6x8cVMI.d.ts +80 -0
  55. package/dist/public-templates.d.ts +2 -0
  56. package/dist/public-templates.js +173 -0
  57. package/dist/{raw-evidence-archive-Br5a3xZ_.js → raw-evidence-archive-BqkAj6uf.js} +201 -102
  58. package/dist/retry-after-header-U_L5Ml9Q.js +13 -0
  59. package/dist/runtime.d.ts +49 -41
  60. package/dist/runtime.js +9 -8
  61. package/dist/{sandbox-DzSEprto.js → sandbox-BMUVHyre.js} +9435 -8927
  62. package/dist/{secp256k1-Dx2XABHz.js → secp256k1-RQWkttWI.js} +1 -1
  63. package/dist/select-seat-command.d.ts +16 -0
  64. package/dist/select-seat-command.js +87 -0
  65. package/dist/session-gateway/index.d.ts +122 -549
  66. package/dist/session-gateway/index.js +656 -782
  67. package/dist/sidecar-proxy-error-BU7Te3UT.js +24 -0
  68. package/dist/sse-parser-B3wXDwTY.js +227 -0
  69. package/dist/tangle/index.d.ts +1 -1
  70. package/dist/tangle/index.js +1 -1
  71. package/dist/{tangle-DHFKq9sn.js → tangle-fzod8ZqG.js} +206 -199
  72. package/dist/terminal-stream-types-Bnuke-yn.d.ts +663 -0
  73. package/dist/{types-B_QF-iHm.d.ts → types-tVKe37Pg.d.ts} +6227 -5806
  74. package/package.json +17 -8
  75. package/dist/client-Lhxo82x1.d.ts +0 -1261
  76. package/dist/errors-mPL-qvgF.d.ts +0 -347
  77. package/dist/index-DRto9Ijb.d.ts +0 -579
  78. package/dist/line-application-Cq6dJLBD.js +0 -124
  79. package/dist/managed-process-B7WfqKmi.d.ts +0 -15
  80. package/dist/terminal-stream-jdYomM1m.d.ts +0 -389
  81. /package/dist/{cli-auth-bundle-ODe06Ts7.d.ts → cli-auth-bundle-CdB8vWzg.d.ts} +0 -0
  82. /package/dist/{preview-operations-DqSo-IBm.js → preview-operations-RC0D3Ojg.js} +0 -0
  83. /package/dist/{utils-B7_9Hl_z.js → utils-q2gTYBR8.js} +0 -0
package/README.md CHANGED
@@ -27,10 +27,11 @@ export SANDBOX_BASE_URL=https://sandbox.tangle.tools
27
27
  | Direct Tangle chain operations | `@tangle-network/sandbox/tangle` |
28
28
  | Server-side token issuance and validation | `@tangle-network/sandbox/auth` |
29
29
  | Collaborative document clients and file bridging | `@tangle-network/sandbox/collaboration` |
30
- | Browser WebSocket session streaming and replay | `@tangle-network/sandbox/session-gateway` |
30
+ | Browser session event streaming from the cell edge, with replay | `@tangle-network/sandbox/session-gateway` |
31
31
  | OpenAI-compatible request and event translation | `@tangle-network/sandbox/openai` |
32
32
  | Multiple managed Agents, framework tool packs, and the local MCP bridge | `@tangle-network/sandbox/agent` |
33
33
  | Browser-safe trace reads from Tangle Intelligence | `@tangle-network/sandbox/intelligence` |
34
+ | Browser-safe public template catalog and publication jobs (`PublicTemplatesClient`) | `@tangle-network/sandbox/public-templates` |
34
35
 
35
36
  Install an optional peer dependency only when the selected integration requires it.
36
37
  The Tangle quote digest, input-hash, and signature-validation helpers do not need `viem` at runtime.
@@ -68,7 +69,9 @@ const runtime = createSandboxRuntimeClient({
68
69
  ```
69
70
 
70
71
  Use `scope: "session"` plus an authorized `runtimeSessionId` for
71
- `SessionGatewayClient` reconnect and replay. Use `scope: "read-only"` for
72
+ `SessionGatewayClient`: give it `scoped.runtimeUrl` and `scoped.token`, and it
73
+ streams that runtime session's events from the cell edge and resumes a
74
+ running turn from the sidecar's event store after a drop. Use `scope: "read-only"` for
72
75
  runtime reads that need no workspace or terminal mutation. The server must
73
76
  authorize every sandbox and session identifier before minting.
74
77
 
@@ -110,6 +113,7 @@ try {
110
113
  Keep `delete()` in `finally` unless the sandbox must outlive the process.
111
114
  `delete()` answers once the sandbox is dead and billed; its container, volume and network are reclaimed behind the answer, and the acknowledgement reports `removal: "pending"`.
112
115
  The sandbox is already gone for every read at that point.
116
+ Deleted customer snapshot repositories, including their final snapshot, remain until their owner explicitly deletes them. Platform-managed repositories of internal-account boxes retire automatically after the deleted-retention window, subject to preservation holds and active exports/restores. The serving window comes from the storage owner; see [deleted repository retention](../../../docs/sandbox-lifecycle-reliability.md#deleted-snapshot-repository-retirement).
113
117
  Pass `await box.delete({ until: "removed" })` when you need the reclaim itself, for example before reusing the same host capacity in a test; it reports `removal: "complete"`, or `"pending"` if the wait runs out.
114
118
 
115
119
  To remove every sandbox that one job created, tag them with metadata at create time and delete them by prefix:
@@ -459,6 +463,8 @@ Use `adopt` to move a sandbox you created earlier under a key.
459
463
 
460
464
  `exec()` returns the exit code, standard output, standard error, and timing data.
461
465
 
466
+ After an admitted blocking command is aborted or times out, the shared process transport sends a tree kill and follows the authenticated PID result until it settles, within the independent cleanup budget owned by [the shared process transport](src/lib/prepared-process.mjs). A kill acknowledgement alone does not prove exit. Missing results, authentication failures, transport failures, and cleanup expiry leave termination unknown; the caller still receives its original abort or timeout error. The SDK fetch transport cancels the terminal response stream without materializing completed command output. Existing parsed-JSON probe adapters retain their response transport's eager parsing.
467
+
462
468
  ```typescript
463
469
  const test = await box.exec("pnpm test", {
464
470
  cwd: "/workspace/service",
@@ -618,7 +624,7 @@ Keep the returned `executionId` with the session ID whenever another caller can
618
624
  `session.result({ executionId })` replays only that run, and `session.interrupt({ executionId })` cancels only that run, so neither operation can move to a newer turn between lookup and action.
619
625
  `prompt()` also returns the execution ID that actually produced its result, including an idempotent replay that resolves to an earlier execution than the caller requested.
620
626
  Use session events with an event ID when the consumer must replay a dropped stream.
621
- Use the `/session-gateway` entrypoint for browser WebSocket reconnect and replay.
627
+ Use the `/session-gateway` entrypoint for a browser's session event stream: it reattaches after a drop and resumes the running turn after the last event it delivered.
622
628
  A dispatched run that dies before producing output reports its cause on `session.status()`: `failureReason.message` carries the runtime's own error, such as a backend binary that could not be spawned or an agent profile that could not be materialized.
623
629
 
624
630
  ## Fleets
@@ -960,6 +966,8 @@ pnpm --filter @tangle-network/sandbox build
960
966
  pnpm --filter @tangle-network/sandbox verify-dist
961
967
  ```
962
968
 
969
+ Public type definitions live in `src/types/` by capability; `src/types.ts` preserves the existing import path. For a type split, run `node products/sandbox/sdk/scripts/check-type-capabilities.mjs <base-ref>` from the repository root to compare every moved declaration and report module sizes. Compare two emitted declaration trees with `node products/sandbox/sdk/scripts/verify-declarations.mjs <after-dist> --compare <before-dist>`. The report separates raw artifact bytes from declaration and import identity; it preserves JSDoc and overload order.
970
+
963
971
  ## License
964
972
 
965
973
  MIT
@@ -992,6 +1000,64 @@ most 64 MiB of cumulative part text. Limits and incomplete snapshots never becom
992
1000
  complete coverage. The dedicated Sidecar archive route is required; an older deployment
993
1001
  returns an error without falling back to the aggregate `rawEvidence()` API.
994
1002
 
1003
+ To keep the HOME walk but leave the bytes of directories the harness downloads
1004
+ again on the box, name them in `omitContent`. Each file below one keeps its
1005
+ metadata, has `contentOmitted: true`, and has no `content` or `sha256`:
1006
+
1007
+ ```ts
1008
+ const evidence = await box.session(sessionId).exportRawEvidence(destination, {
1009
+ maxBytes: 4 * 1024 ** 3,
1010
+ maxFiles: 100_000,
1011
+ omitContent: [".codex/plugins/cache/", ".codex/cache/remote_plugin_catalog/"],
1012
+ });
1013
+ ```
1014
+
1015
+ The manifest lists the honoured prefixes in `omitContent`. A prefix that covers
1016
+ or enters the harness's native session store (for example `.codex/` or
1017
+ `.codex/sessions/`) answers 400, so the session itself always keeps its bytes.
1018
+ The SDK allows at most 64 prefixes of at most 512 characters each, and 8 KiB of
1019
+ encoded query. A Sidecar older than the option ignores it and sends every
1020
+ file's bytes, so keep `maxBytes` sized for the whole HOME until every Sidecar
1021
+ you reach serves this version.
1022
+
1023
+ To keep only the native session store, ask for the session copies alone:
1024
+
1025
+ ```ts
1026
+ const native = await box.session(sessionId).exportRawEvidence(destination, {
1027
+ maxBytes: 3 * 1024 ** 3,
1028
+ maxFiles: 100_000,
1029
+ copy: "latest",
1030
+ parts: "native",
1031
+ });
1032
+ // Each attempt's session files: native.manifest.nativeSessions[].files
1033
+ ```
1034
+
1035
+ `parts: "native"` requires `copy`. The archive then holds the manifest and the
1036
+ `nativeSessions` copies only: no event log, process stream or HOME walk, so `maxBytes`
1037
+ bounds the copies however large the session's logs have grown, and a copy larger
1038
+ than the bound still fails. The manifest names what was left out (`parts: "native"`,
1039
+ `status: "partial"`, `events_not_requested`, `process_io_not_requested`). A sidecar
1040
+ older than the option serves the full archive within the same bounds.
1041
+
1042
+ To keep every native session store on the box before deleting it, export the box:
1043
+
1044
+ ```ts
1045
+ const stores = await box.exportRawEvidence(destination, {
1046
+ maxBytes: 3 * 1024 ** 3,
1047
+ maxFiles: 100_000,
1048
+ });
1049
+ // Each runtime HOME's store files: stores.manifest.homes[].files
1050
+ // Each settled copy, with the HOME it came from: stores.manifest.nativeSessions[]
1051
+ ```
1052
+
1053
+ The box archive (`tangle.raw-evidence-archive.box.v1`) finds stores by walking the
1054
+ runtime HOMEs, not the session listing, so it also serves a box restored from a
1055
+ snapshot whose session listing is empty. It reads only files a harness contract
1056
+ declares as its session store (Claude Code projects, Codex rollouts, OpenCode's
1057
+ SQLite database, and the rest), never credentials or config. A HOME a running
1058
+ harness holds is copied without stopping it and marked `live`. It needs a token
1059
+ that is not bound to one session; a sidecar older than the route answers 404.
1060
+
995
1061
 
996
1062
  ### Prepared durable-plan follow-ups
997
1063
 
@@ -0,0 +1,46 @@
1
+ //#region src/lib/abort-signal.ts
2
+ function combineAbortSignals(signals) {
3
+ return AbortSignal.any(signals);
4
+ }
5
+ function awaitWithAbort(work, signal) {
6
+ if (!signal) return work;
7
+ signal.throwIfAborted();
8
+ return new Promise((resolve, reject) => {
9
+ let settled = false;
10
+ const onAbort = () => {
11
+ if (settled) return;
12
+ settled = true;
13
+ signal.removeEventListener("abort", onAbort);
14
+ reject(signal.reason ?? new DOMException("The request was aborted", "AbortError"));
15
+ };
16
+ signal.addEventListener("abort", onAbort, { once: true });
17
+ work.then((value) => {
18
+ if (settled) return;
19
+ settled = true;
20
+ signal.removeEventListener("abort", onAbort);
21
+ resolve(value);
22
+ }, (cause) => {
23
+ if (settled) return;
24
+ settled = true;
25
+ signal.removeEventListener("abort", onAbort);
26
+ reject(cause);
27
+ });
28
+ });
29
+ }
30
+ const delayUntilAborted = (ms, signal) => new Promise((resolve, reject) => {
31
+ if (signal?.aborted) {
32
+ reject(signal.reason ?? /* @__PURE__ */ new Error("aborted"));
33
+ return;
34
+ }
35
+ const timer = setTimeout(() => {
36
+ signal?.removeEventListener("abort", onAbort);
37
+ resolve();
38
+ }, ms);
39
+ function onAbort() {
40
+ clearTimeout(timer);
41
+ reject(signal?.reason ?? /* @__PURE__ */ new Error("aborted"));
42
+ }
43
+ signal?.addEventListener("abort", onAbort, { once: true });
44
+ });
45
+ //#endregion
46
+ export { combineAbortSignals as n, delayUntilAborted as r, awaitWithAbort as t };
@@ -1,7 +1,7 @@
1
- import { g as SandboxSession, m as SandboxTaskSession, n as SandboxInstance } from "../sandbox-CoIGxzm_.js";
2
- import { D as CodeExecutionResult, E as CodeExecutionOptions, O as CodeLanguage, ai as SandboxFleetParent, bo as BackendType, ca as SessionInfo, d as BackendConfig, k as CodeResultPart, ua as SessionListOptions } from "../types-B_QF-iHm.js";
3
- import { i as Sandbox } from "../client-Lhxo82x1.js";
4
- import { u as PreviewAuthorizer } from "../preview-wpGGk0bu.js";
1
+ import { I as SandboxTaskSession, O as SandboxInstance, R as SandboxSession } from "../index-D7Yq_Zpv.js";
2
+ import { Co as BackendType, Di as CodeResultPart, Ei as CodeExecutionResult, Ha as CodeLanguage, Ti as CodeExecutionOptions, bn as SandboxFleetParent, xa as BackendConfig, xt as SessionListOptions, yt as SessionInfo } from "../types-tVKe37Pg.js";
3
+ import { t as Sandbox } from "../client-B7wLVacH.js";
4
+ import { u as PreviewAuthorizer } from "../preview-BOyw_XIl.js";
5
5
  import * as _$_modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
6
6
  import { JSONSchema } from "zod/v4/core";
7
7
  import { ToolSet } from "ai";
@@ -401,43 +401,8 @@ declare const FLEET_TOOL_SPECS: {
401
401
  type FleetToolName = keyof typeof FLEET_TOOL_SPECS;
402
402
  declare const ALL_FLEET_TOOL_SPECS: FleetToolSpec[];
403
403
  //#endregion
404
- //#region src/agent/tools/fleet/index.d.ts
405
- interface FleetToolPackOptions {
406
- /** Which fleet tools to expose. Defaults to all of them. */
407
- allow?: FleetToolName[];
408
- /**
409
- * The fleet and agent this tool pack acts for. Fleets it spawns record it
410
- * as their parent, so their cap is carved from the parent's and deleting or
411
- * cancelling the parent reaches them.
412
- */
413
- parent?: SandboxFleetParent;
414
- }
415
- interface AnthropicFleetTool {
416
- name: string;
417
- description: string;
418
- input_schema: {
419
- type: "object";
420
- properties: Record<string, unknown>;
421
- required?: string[];
422
- additionalProperties?: boolean;
423
- };
424
- }
425
- interface AnthropicFleetToolPack {
426
- tools: AnthropicFleetTool[];
427
- handleToolUse(block: {
428
- type: "tool_use";
429
- id: string;
430
- name: string;
431
- input: Record<string, unknown>;
432
- }): Promise<{
433
- type: "tool_result";
434
- tool_use_id: string;
435
- content: string;
436
- is_error?: boolean;
437
- }>;
438
- }
439
- declare function anthropicFleetTools(client: Sandbox, options?: FleetToolPackOptions): AnthropicFleetToolPack;
440
- interface OpenAIFleetTool {
404
+ //#region src/agent/tools/openai.d.ts
405
+ interface OpenAITool {
441
406
  type: "function";
442
407
  function: {
443
408
  name: string;
@@ -450,21 +415,97 @@ interface OpenAIFleetTool {
450
415
  };
451
416
  };
452
417
  }
453
- interface OpenAIFleetToolPack {
454
- tools: OpenAIFleetTool[];
455
- handleToolCall(call: {
418
+ interface OpenAIToolCall {
419
+ id: string;
420
+ type?: "function";
421
+ function: {
422
+ name: string;
423
+ arguments: string;
424
+ };
425
+ }
426
+ interface OpenAIToolResultMessage {
427
+ role: "tool";
428
+ tool_call_id: string;
429
+ content: string;
430
+ }
431
+ interface OpenAIToolPackOptions {
432
+ allow?: ToolName[];
433
+ sessionId?: string;
434
+ previewAuthorize?: PreviewAuthorizer;
435
+ signal?: AbortSignal;
436
+ }
437
+ interface OpenAIToolPack {
438
+ tools: OpenAITool[];
439
+ /** Dispatch a single tool call into a Chat Completions tool message. */
440
+ handleToolCall(call: OpenAIToolCall): Promise<OpenAIToolResultMessage>;
441
+ /**
442
+ * Convenience: dispatch every tool_call on an assistant message in parallel.
443
+ */
444
+ handleAssistantMessage(message: {
445
+ tool_calls?: OpenAIToolCall[];
446
+ }): Promise<OpenAIToolResultMessage[]>;
447
+ }
448
+ /**
449
+ * Build an OpenAI tool pack bound to one sandbox.
450
+ *
451
+ * @example
452
+ * ```ts
453
+ * import OpenAI from "openai";
454
+ * import { openaiTools } from "@tangle-network/sandbox/agent";
455
+ *
456
+ * const openai = new OpenAI();
457
+ * const { tools, handleAssistantMessage } = openaiTools(box, { sessionId: "s1" });
458
+ *
459
+ * const messages: any[] = [{ role: "user", content: "Plot sin(x) for x in [0, 2π]." }];
460
+ * for (let i = 0; i < 6; i++) {
461
+ * const r = await openai.chat.completions.create({
462
+ * model: "gpt-5.4", tools, messages,
463
+ * });
464
+ * const m = r.choices[0].message;
465
+ * messages.push(m);
466
+ * if (!m.tool_calls?.length) break;
467
+ * messages.push(...(await handleAssistantMessage(m)));
468
+ * }
469
+ * ```
470
+ */
471
+ declare function openaiTools(box: SandboxInstance, options?: OpenAIToolPackOptions): OpenAIToolPack;
472
+ //#endregion
473
+ //#region src/agent/tools/_client-packs.d.ts
474
+ interface AnthropicClientToolPack {
475
+ tools: AnthropicTool[];
476
+ handleToolUse(block: {
477
+ type: "tool_use";
456
478
  id: string;
457
- type?: "function";
458
- function: {
459
- name: string;
460
- arguments: string;
461
- };
479
+ name: string;
480
+ input: Record<string, unknown>;
462
481
  }): Promise<{
463
- role: "tool";
464
- tool_call_id: string;
482
+ type: "tool_result";
483
+ tool_use_id: string;
465
484
  content: string;
485
+ is_error?: boolean;
466
486
  }>;
467
487
  }
488
+ interface OpenAIClientToolPack {
489
+ tools: OpenAITool[];
490
+ handleToolCall(call: OpenAIToolCall): Promise<OpenAIToolResultMessage>;
491
+ }
492
+ //#endregion
493
+ //#region src/agent/tools/fleet/index.d.ts
494
+ interface FleetToolPackOptions {
495
+ /** Which fleet tools to expose. Defaults to all of them. */
496
+ allow?: FleetToolName[];
497
+ /**
498
+ * The fleet and agent this tool pack acts for. Fleets it spawns record it
499
+ * as their parent, so their cap is carved from the parent's and deleting or
500
+ * cancelling the parent reaches them.
501
+ */
502
+ parent?: SandboxFleetParent;
503
+ }
504
+ type AnthropicFleetTool = AnthropicTool;
505
+ type AnthropicFleetToolPack = AnthropicClientToolPack;
506
+ type OpenAIFleetTool = OpenAITool;
507
+ type OpenAIFleetToolPack = OpenAIClientToolPack;
508
+ declare function anthropicFleetTools(client: Sandbox, options?: FleetToolPackOptions): AnthropicFleetToolPack;
468
509
  declare function openaiFleetTools(client: Sandbox, options?: FleetToolPackOptions): OpenAIFleetToolPack;
469
510
  declare function vercelAiFleetTools(client: Sandbox, options?: FleetToolPackOptions): Promise<Record<string, unknown>>;
470
511
  declare function mastraFleetTools(client: Sandbox, options?: FleetToolPackOptions): Promise<Record<string, unknown>>;
@@ -502,59 +543,11 @@ interface LifecycleToolPackOptions {
502
543
  /** Which lifecycle tools to expose. Defaults to all three. */
503
544
  allow?: LifecycleToolName[];
504
545
  }
505
- interface AnthropicLifecycleTool {
506
- name: string;
507
- description: string;
508
- input_schema: {
509
- type: "object";
510
- properties: Record<string, unknown>;
511
- required?: string[];
512
- additionalProperties?: boolean;
513
- };
514
- }
515
- interface AnthropicLifecycleToolPack {
516
- tools: AnthropicLifecycleTool[];
517
- handleToolUse(block: {
518
- type: "tool_use";
519
- id: string;
520
- name: string;
521
- input: Record<string, unknown>;
522
- }): Promise<{
523
- type: "tool_result";
524
- tool_use_id: string;
525
- content: string;
526
- is_error?: boolean;
527
- }>;
528
- }
546
+ type AnthropicLifecycleTool = AnthropicTool;
547
+ type AnthropicLifecycleToolPack = AnthropicClientToolPack;
548
+ type OpenAILifecycleTool = OpenAITool;
549
+ type OpenAILifecycleToolPack = OpenAIClientToolPack;
529
550
  declare function anthropicLifecycleTools(client: Sandbox, options?: LifecycleToolPackOptions): AnthropicLifecycleToolPack;
530
- interface OpenAILifecycleTool {
531
- type: "function";
532
- function: {
533
- name: string;
534
- description: string;
535
- parameters: {
536
- type: "object";
537
- properties: Record<string, unknown>;
538
- required?: string[];
539
- additionalProperties?: boolean;
540
- };
541
- };
542
- }
543
- interface OpenAILifecycleToolPack {
544
- tools: OpenAILifecycleTool[];
545
- handleToolCall(call: {
546
- id: string;
547
- type?: "function";
548
- function: {
549
- name: string;
550
- arguments: string;
551
- };
552
- }): Promise<{
553
- role: "tool";
554
- tool_call_id: string;
555
- content: string;
556
- }>;
557
- }
558
551
  declare function openaiLifecycleTools(client: Sandbox, options?: LifecycleToolPackOptions): OpenAILifecycleToolPack;
559
552
  //#endregion
560
553
  //#region src/agent/tools/mastra.d.ts
@@ -579,75 +572,6 @@ interface MastraToolPackOptions {
579
572
  */
580
573
  declare function mastraTools(box: SandboxInstance, options?: MastraToolPackOptions): Promise<Record<string, unknown>>;
581
574
  //#endregion
582
- //#region src/agent/tools/openai.d.ts
583
- interface OpenAITool {
584
- type: "function";
585
- function: {
586
- name: string;
587
- description: string;
588
- parameters: {
589
- type: "object";
590
- properties: Record<string, unknown>;
591
- required?: string[];
592
- additionalProperties?: boolean;
593
- };
594
- };
595
- }
596
- interface OpenAIToolCall {
597
- id: string;
598
- type?: "function";
599
- function: {
600
- name: string;
601
- arguments: string;
602
- };
603
- }
604
- interface OpenAIToolResultMessage {
605
- role: "tool";
606
- tool_call_id: string;
607
- content: string;
608
- }
609
- interface OpenAIToolPackOptions {
610
- allow?: ToolName[];
611
- sessionId?: string;
612
- previewAuthorize?: PreviewAuthorizer;
613
- signal?: AbortSignal;
614
- }
615
- interface OpenAIToolPack {
616
- tools: OpenAITool[];
617
- /** Dispatch a single tool call into a Chat Completions tool message. */
618
- handleToolCall(call: OpenAIToolCall): Promise<OpenAIToolResultMessage>;
619
- /**
620
- * Convenience: dispatch every tool_call on an assistant message in parallel.
621
- */
622
- handleAssistantMessage(message: {
623
- tool_calls?: OpenAIToolCall[];
624
- }): Promise<OpenAIToolResultMessage[]>;
625
- }
626
- /**
627
- * Build an OpenAI tool pack bound to one sandbox.
628
- *
629
- * @example
630
- * ```ts
631
- * import OpenAI from "openai";
632
- * import { openaiTools } from "@tangle-network/sandbox/agent";
633
- *
634
- * const openai = new OpenAI();
635
- * const { tools, handleAssistantMessage } = openaiTools(box, { sessionId: "s1" });
636
- *
637
- * const messages: any[] = [{ role: "user", content: "Plot sin(x) for x in [0, 2π]." }];
638
- * for (let i = 0; i < 6; i++) {
639
- * const r = await openai.chat.completions.create({
640
- * model: "gpt-5.4", tools, messages,
641
- * });
642
- * const m = r.choices[0].message;
643
- * messages.push(m);
644
- * if (!m.tool_calls?.length) break;
645
- * messages.push(...(await handleAssistantMessage(m)));
646
- * }
647
- * ```
648
- */
649
- declare function openaiTools(box: SandboxInstance, options?: OpenAIToolPackOptions): OpenAIToolPack;
650
- //#endregion
651
575
  //#region src/agent/tools/vercel-ai.d.ts
652
576
  interface VercelAiToolPackOptions {
653
577
  allow?: ToolName[];