@tangle-network/sandbox 0.54.2-develop.20260927014918.a761d6e → 0.55.1
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/dist/agent/index.d.ts +28 -4
- package/dist/agent/index.js +125 -8
- package/dist/{agent-run-outcome-DRsFrVVD.d.ts → agent-run-outcome-CWo6e5lW.d.ts} +1 -1
- package/dist/{client-DfKvEnty.d.ts → client-B-LZQQ51.d.ts} +143 -39
- package/dist/{client-BNabJNXr.js → client-Bd8nskJA.js} +921 -81
- package/dist/core.d.ts +3 -3
- package/dist/core.js +2 -2
- package/dist/{index-DfO6rIkV.d.ts → index-ATSSTK2A.d.ts} +2 -2
- package/dist/index.d.ts +6 -6
- package/dist/index.js +5 -5
- package/dist/{runtime-api-BARzSO0x.js → runtime-api-DoZsOiOR.js} +2 -1
- package/dist/runtime.d.ts +3 -2
- package/dist/runtime.js +1 -1
- package/dist/{sandbox-_NN_Uvke.d.ts → sandbox-C7KqjY6Y.d.ts} +1 -1
- package/dist/{sandbox-CaLpJBSf.js → sandbox-DzSE1u7d.js} +9 -1
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-otjgFbDA.js → tangle-CmpR_07-.js} +1 -1
- package/dist/{types-BoW_VFjX.d.ts → types-UOIM3RS6.d.ts} +198 -23
- package/package.json +5 -4
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as SandboxSession, h as SandboxTaskSession, r as SandboxInstance } from "../sandbox-
|
|
2
|
-
import { D as CodeExecutionResult, E as CodeExecutionOptions,
|
|
3
|
-
import { i as Sandbox } from "../client-
|
|
1
|
+
import { g as SandboxSession, h as SandboxTaskSession, r as SandboxInstance } from "../sandbox-C7KqjY6Y.js";
|
|
2
|
+
import { D as CodeExecutionResult, E as CodeExecutionOptions, Gr as SandboxFleetParent, Ki as SessionListOptions, O as CodeLanguage, Wi as SessionInfo, d as BackendConfig, k as CodeResultPart, za as BackendType } from "../types-UOIM3RS6.js";
|
|
3
|
+
import { i as Sandbox } from "../client-B-LZQQ51.js";
|
|
4
4
|
import * as _$_modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
5
|
import { JSONSchema } from "zod/v4/core";
|
|
6
6
|
|
|
@@ -318,6 +318,8 @@ declare function anthropicTools(box: SandboxInstance, options?: AnthropicToolPac
|
|
|
318
318
|
//#region src/agent/tools/fleet/_specs.d.ts
|
|
319
319
|
interface FleetToolHandlerContext {
|
|
320
320
|
client: Sandbox;
|
|
321
|
+
/** Recorded as the parent of every fleet these tools spawn. */
|
|
322
|
+
parent?: SandboxFleetParent;
|
|
321
323
|
}
|
|
322
324
|
interface FleetToolSpec<TArgs = Record<string, unknown>, TResult = unknown> {
|
|
323
325
|
name: string;
|
|
@@ -326,9 +328,25 @@ interface FleetToolSpec<TArgs = Record<string, unknown>, TResult = unknown> {
|
|
|
326
328
|
makeHandler: (ctx: FleetToolHandlerContext) => (args: TArgs) => Promise<TResult>;
|
|
327
329
|
}
|
|
328
330
|
declare const FLEET_TOOL_SPECS: {
|
|
331
|
+
readonly sandbox_fleet_run: FleetToolSpec<{
|
|
332
|
+
prompt?: string;
|
|
333
|
+
agents?: number;
|
|
334
|
+
agent_specs?: Array<{
|
|
335
|
+
agent_id?: string;
|
|
336
|
+
harness?: BackendType;
|
|
337
|
+
model?: string;
|
|
338
|
+
profile_id?: string;
|
|
339
|
+
task?: string;
|
|
340
|
+
}>;
|
|
341
|
+
agents_per_sandbox?: number;
|
|
342
|
+
model?: string;
|
|
343
|
+
max_spend_usd: number;
|
|
344
|
+
timeout_ms?: number;
|
|
345
|
+
}, unknown>;
|
|
329
346
|
readonly sandbox_fleet_spawn: FleetToolSpec<{
|
|
330
347
|
template_id: string;
|
|
331
348
|
workers: number;
|
|
349
|
+
max_spend_usd?: number;
|
|
332
350
|
metadata?: Record<string, string>;
|
|
333
351
|
}, unknown>;
|
|
334
352
|
readonly sandbox_fleet_dispatch: FleetToolSpec<{
|
|
@@ -350,8 +368,14 @@ declare const ALL_FLEET_TOOL_SPECS: FleetToolSpec[];
|
|
|
350
368
|
//#endregion
|
|
351
369
|
//#region src/agent/tools/fleet/index.d.ts
|
|
352
370
|
interface FleetToolPackOptions {
|
|
353
|
-
/** Which fleet tools to expose. Defaults to all
|
|
371
|
+
/** Which fleet tools to expose. Defaults to all of them. */
|
|
354
372
|
allow?: FleetToolName[];
|
|
373
|
+
/**
|
|
374
|
+
* The fleet and agent this tool pack acts for. Fleets it spawns record it
|
|
375
|
+
* as their parent, so their cap is carved from the parent's and deleting or
|
|
376
|
+
* cancelling the parent reaches them.
|
|
377
|
+
*/
|
|
378
|
+
parent?: SandboxFleetParent;
|
|
355
379
|
}
|
|
356
380
|
interface AnthropicFleetTool {
|
|
357
381
|
name: string;
|
package/dist/agent/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { x as assertCurrentBackendType } from "../runtime-api-DoZsOiOR.js";
|
|
2
2
|
import { c as NotFoundError, g as ValidationError, m as StateError } from "../errors-CmYPVl-k.js";
|
|
3
|
-
import { n as Sandbox } from "../client-
|
|
4
|
-
import { t as SandboxInstance } from "../sandbox-
|
|
3
|
+
import { n as Sandbox } from "../client-Bd8nskJA.js";
|
|
4
|
+
import { t as SandboxInstance } from "../sandbox-DzSE1u7d.js";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
//#region src/agent/instances.ts
|
|
@@ -564,6 +564,105 @@ function imageMediaType(format) {
|
|
|
564
564
|
}
|
|
565
565
|
}
|
|
566
566
|
const FLEET_TOOL_SPECS = {
|
|
567
|
+
sandbox_fleet_run: {
|
|
568
|
+
name: "sandbox_fleet_run",
|
|
569
|
+
description: "Spawn a fleet of agents, run one turn on every agent in parallel, return each agent's response, then delete the fleet. Pass `agents` for N identical agents running `prompt`, or `agent_specs` to give each agent its own harness, model, saved profile and task. Agents are packed onto sandboxes by memory unless agents_per_sandbox is set. The Platform refuses every charge past max_spend_usd. COST SCALES with agents.",
|
|
570
|
+
inputSchema: {
|
|
571
|
+
type: "object",
|
|
572
|
+
properties: {
|
|
573
|
+
prompt: {
|
|
574
|
+
type: "string",
|
|
575
|
+
description: "Prompt for every agent without its own task."
|
|
576
|
+
},
|
|
577
|
+
agents: {
|
|
578
|
+
type: "number",
|
|
579
|
+
description: "Number of identical agents."
|
|
580
|
+
},
|
|
581
|
+
agent_specs: {
|
|
582
|
+
type: "array",
|
|
583
|
+
description: "One entry per agent.",
|
|
584
|
+
items: {
|
|
585
|
+
type: "object",
|
|
586
|
+
properties: {
|
|
587
|
+
agent_id: { type: "string" },
|
|
588
|
+
harness: {
|
|
589
|
+
type: "string",
|
|
590
|
+
description: "Harness, e.g. opencode or codex."
|
|
591
|
+
},
|
|
592
|
+
model: {
|
|
593
|
+
type: "string",
|
|
594
|
+
description: "Model id."
|
|
595
|
+
},
|
|
596
|
+
profile_id: {
|
|
597
|
+
type: "string",
|
|
598
|
+
description: "Saved profile id from the agent-profile catalog."
|
|
599
|
+
},
|
|
600
|
+
task: {
|
|
601
|
+
type: "string",
|
|
602
|
+
description: "This agent's task."
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
additionalProperties: false
|
|
606
|
+
}
|
|
607
|
+
},
|
|
608
|
+
agents_per_sandbox: {
|
|
609
|
+
type: "number",
|
|
610
|
+
description: "Agents per sandbox. Omit to pack by sandbox memory."
|
|
611
|
+
},
|
|
612
|
+
model: {
|
|
613
|
+
type: "string",
|
|
614
|
+
description: "Model for agents that name none, e.g. gpt-4.1-mini."
|
|
615
|
+
},
|
|
616
|
+
max_spend_usd: {
|
|
617
|
+
type: "number",
|
|
618
|
+
description: "Budget for the fleet in USD, enforced by the Platform."
|
|
619
|
+
},
|
|
620
|
+
timeout_ms: {
|
|
621
|
+
type: "number",
|
|
622
|
+
description: "Per-agent turn timeout."
|
|
623
|
+
}
|
|
624
|
+
},
|
|
625
|
+
required: ["max_spend_usd"],
|
|
626
|
+
additionalProperties: false
|
|
627
|
+
},
|
|
628
|
+
makeHandler: ({ client, parent }) => async (args) => {
|
|
629
|
+
const agents = args.agent_specs ? args.agent_specs.map((spec) => ({
|
|
630
|
+
...spec.agent_id ? { agentId: spec.agent_id } : {},
|
|
631
|
+
...spec.harness ? { harness: spec.harness } : {},
|
|
632
|
+
...spec.model ? { model: spec.model } : {},
|
|
633
|
+
...spec.profile_id ? { profile: { profileId: spec.profile_id } } : {},
|
|
634
|
+
...spec.task ? { task: spec.task } : {}
|
|
635
|
+
})) : args.agents ?? 0;
|
|
636
|
+
const fleet = await client.fleets.create({
|
|
637
|
+
agents,
|
|
638
|
+
placement: args.agents_per_sandbox ? { agentsPerSandbox: args.agents_per_sandbox } : "auto",
|
|
639
|
+
defaults: args.model ? { backend: {
|
|
640
|
+
type: "opencode",
|
|
641
|
+
model: { model: args.model }
|
|
642
|
+
} } : {},
|
|
643
|
+
budgetUsd: args.max_spend_usd,
|
|
644
|
+
...parent ? { parent } : {}
|
|
645
|
+
});
|
|
646
|
+
try {
|
|
647
|
+
const results = await fleet.runAll(args.prompt, { timeoutMs: args.timeout_ms });
|
|
648
|
+
return {
|
|
649
|
+
fleetId: fleet.fleetId,
|
|
650
|
+
sandboxes: fleet.machines.size,
|
|
651
|
+
results: results.map((result) => ({
|
|
652
|
+
agentId: result.agentId,
|
|
653
|
+
harness: result.harness,
|
|
654
|
+
model: result.model,
|
|
655
|
+
status: result.status,
|
|
656
|
+
response: result.result?.response,
|
|
657
|
+
error: result.error,
|
|
658
|
+
costUsd: result.costUsd
|
|
659
|
+
}))
|
|
660
|
+
};
|
|
661
|
+
} finally {
|
|
662
|
+
await fleet.delete({ continueOnError: true });
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
},
|
|
567
666
|
sandbox_fleet_spawn: {
|
|
568
667
|
name: "sandbox_fleet_spawn",
|
|
569
668
|
description: "Spawn a fleet of N sandboxes from a template, with a coordinator plus N workers sharing a workspace. Returns the fleet id and the machine ids. Each worker has its own persistent code-execution kernel; the same workspace is mounted across them. COSTS SCALE LINEARLY with `workers`. Use sandbox_fleet_destroy when done.",
|
|
@@ -578,6 +677,10 @@ const FLEET_TOOL_SPECS = {
|
|
|
578
677
|
type: "number",
|
|
579
678
|
description: "Number of worker sandboxes. Each is billed independently."
|
|
580
679
|
},
|
|
680
|
+
max_spend_usd: {
|
|
681
|
+
type: "number",
|
|
682
|
+
description: "Budget for the fleet in USD, enforced by the Platform. Required when this tool acts for a budgeted parent fleet; the budget is reserved from the parent's."
|
|
683
|
+
},
|
|
581
684
|
metadata: {
|
|
582
685
|
type: "object",
|
|
583
686
|
properties: {},
|
|
@@ -588,10 +691,12 @@ const FLEET_TOOL_SPECS = {
|
|
|
588
691
|
required: ["template_id", "workers"],
|
|
589
692
|
additionalProperties: false
|
|
590
693
|
},
|
|
591
|
-
makeHandler: ({ client }) => async (args) => {
|
|
694
|
+
makeHandler: ({ client, parent }) => async (args) => {
|
|
592
695
|
const fleet = await client.fleets.createWithCoordinator({
|
|
696
|
+
...parent ? { parent } : {},
|
|
593
697
|
defaults: { publicTemplateId: args.template_id },
|
|
594
698
|
workers: Array.from({ length: args.workers }, (_, i) => ({ machineId: `worker-${i}` })),
|
|
699
|
+
...args.max_spend_usd !== void 0 ? { budgetUsd: args.max_spend_usd } : {},
|
|
595
700
|
metadata: args.metadata
|
|
596
701
|
});
|
|
597
702
|
return {
|
|
@@ -702,7 +807,10 @@ function selectFleetSpecs(allow) {
|
|
|
702
807
|
*/
|
|
703
808
|
function anthropicFleetTools(client, options = {}) {
|
|
704
809
|
const specs = selectFleetSpecs(options.allow);
|
|
705
|
-
const handlers = buildFleetHandlers(specs, {
|
|
810
|
+
const handlers = buildFleetHandlers(specs, {
|
|
811
|
+
client,
|
|
812
|
+
parent: options.parent
|
|
813
|
+
});
|
|
706
814
|
return {
|
|
707
815
|
tools: specs.map((s) => ({
|
|
708
816
|
name: s.name,
|
|
@@ -737,7 +845,10 @@ function anthropicFleetTools(client, options = {}) {
|
|
|
737
845
|
}
|
|
738
846
|
function openaiFleetTools(client, options = {}) {
|
|
739
847
|
const specs = selectFleetSpecs(options.allow);
|
|
740
|
-
const handlers = buildFleetHandlers(specs, {
|
|
848
|
+
const handlers = buildFleetHandlers(specs, {
|
|
849
|
+
client,
|
|
850
|
+
parent: options.parent
|
|
851
|
+
});
|
|
741
852
|
return {
|
|
742
853
|
tools: specs.map((s) => ({
|
|
743
854
|
type: "function",
|
|
@@ -784,7 +895,10 @@ async function vercelAiFleetTools(client, options = {}) {
|
|
|
784
895
|
throw new Error("vercelAiFleetTools(): the `ai` package is not installed. Install via `pnpm add ai`.");
|
|
785
896
|
}
|
|
786
897
|
const specs = selectFleetSpecs(options.allow);
|
|
787
|
-
const handlers = buildFleetHandlers(specs, {
|
|
898
|
+
const handlers = buildFleetHandlers(specs, {
|
|
899
|
+
client,
|
|
900
|
+
parent: options.parent
|
|
901
|
+
});
|
|
788
902
|
const result = {};
|
|
789
903
|
for (const spec of specs) result[spec.name] = ai.tool({
|
|
790
904
|
description: spec.description,
|
|
@@ -805,7 +919,10 @@ async function mastraFleetTools(client, options = {}) {
|
|
|
805
919
|
throw new Error("mastraFleetTools(): the `@mastra/core` package is not installed. Install via `pnpm add @mastra/core`.");
|
|
806
920
|
}
|
|
807
921
|
const specs = selectFleetSpecs(options.allow);
|
|
808
|
-
const handlers = buildFleetHandlers(specs, {
|
|
922
|
+
const handlers = buildFleetHandlers(specs, {
|
|
923
|
+
client,
|
|
924
|
+
parent: options.parent
|
|
925
|
+
});
|
|
809
926
|
const result = {};
|
|
810
927
|
for (const spec of specs) result[spec.name] = mastra.createTool({
|
|
811
928
|
id: spec.name,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Er as SandboxEvent, a as AgentQuestionRequest, i as AgentApprovalRequirement, o as AgentRunStatus, s as AgentToolInvocation, st as DurablePlanSnapshot } from "./types-UOIM3RS6.js";
|
|
2
2
|
import { InteractionRequest } from "@tangle-network/agent-interface";
|
|
3
3
|
|
|
4
4
|
//#region src/agent-run-outcome.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { R as LinesClient, l as TraceExportResult, n as HttpClient, r as SandboxInstance, u as TraceExportSink } from "./sandbox-
|
|
1
|
+
import { R as LinesClient, l as TraceExportResult, n as HttpClient, r as SandboxInstance, u as TraceExportSink } from "./sandbox-C7KqjY6Y.js";
|
|
2
2
|
import { l as ScopedToken, s as MintInteractiveSessionTokenOptions } from "./terminal-stream-CcaBTVg3.js";
|
|
3
|
-
import { $n as
|
|
3
|
+
import { $n as PublicTemplateVersionInfo, Ar as SandboxFleetArtifactSpec, B as CreateSandboxOptions, Br as SandboxFleetMachineRecord, Bt as FleetDriveTurnOutcome, Dr as SandboxFleetAgent, F as CreateIntelligenceReportOptions, G as DeleteMatchingSandboxesFilter, Gn as PromptInputPart, Gr as SandboxFleetParent, Gt as FleetPromptDispatchOptions, Hr as SandboxFleetManifest, Ht as FleetExecDispatchOptions, I as CreateRequestOptions, Ir as SandboxFleetInfo, It as FleetDispatchCancelResult, Jt as FleetRunOptions, K as DeleteMatchingSandboxesOptions, Kn as PromptOptions, Kt as FleetPromptDispatchResult, L as CreateSandboxFleetOptions, Lt as FleetDispatchResultBuffer, M as ConversationTurnOptions, Mt as FleetAgentId, N as ConversationTurnResult, Na as BatchEvent, Nr as SandboxFleetDispatchResponse, Pi as SecretsManager, Pr as SandboxFleetDriverCapability, Pt as FleetAgentResult, Qn as PublicTemplateInfo, R as CreateSandboxFleetTokenOptions, Rt as FleetDispatchResultBufferOptions, Ta as UsageInfo, Tn as ListSandboxOptions, Tr as SandboxEnvironment, Ut as FleetExecDispatchResult, Vr as SandboxFleetMachineSpec, Vt as FleetDriveTurnRequest, Wr as SandboxFleetOperationsSummary, Wt as FleetMachineId, Xr as SandboxFleetToken, Yr as SandboxFleetSpend, Zr as SandboxFleetTraceBundle, _n as IntelligenceReportBudget, _t as ExecOptions, ai as SandboxFleetWorkspaceSnapshotResult, ar as ReconcileSandboxFleetsResult, b as BatchRunRequest, bn as IntelligenceReportWindow, ca as SubscriptionInfo, d as BackendConfig, ei as SandboxFleetTraceOptions, er as PublishPublicTemplateOptions, gn as IntelligenceReport, ia as SshKeysManager, ii as SandboxFleetWorkspaceRestoreResult, ir as ReconcileSandboxFleetsOptions, jr as SandboxFleetCostEstimate, kr as SandboxFleetArtifact, l as AttachSandboxFleetMachineOptions, nr as ReapExpiredSandboxFleetsOptions, oi as SandboxIdentity, q as DeleteMatchingSandboxesResult, qn as PromptResult, qr as SandboxFleetPolicy, qt as FleetRunEvent, ri as SandboxFleetWorkspaceReconcileResult, rr as ReapExpiredSandboxFleetsResult, si as SandboxInfo, ti as SandboxFleetUsage, tr as PublishPublicTemplateVersionOptions, v as BatchResult, vi as SandboxShapesInfo, vn as IntelligenceReportCompareTo, vr as SandboxConfig, vt as ExecResult, wn as ListSandboxFleetOptions, y as BatchRunOptions, ya as TokenRefreshHandler, z as CreateSandboxFleetWithCoordinatorOptions, zt as FleetDispatchStreamOptions } from "./types-UOIM3RS6.js";
|
|
4
4
|
import { f as SandboxError } from "./errors-Cz23YNu2.js";
|
|
5
5
|
import { AgentInteractiveSessionRef } from "@tangle-network/agent-interface";
|
|
6
6
|
import { z } from "zod";
|
|
@@ -168,6 +168,10 @@ interface FleetClientHost {
|
|
|
168
168
|
list(options?: ListSandboxOptions): Promise<SandboxInstance[]>;
|
|
169
169
|
get(id: string): Promise<SandboxInstance | null>;
|
|
170
170
|
fetch(path: string, options?: RequestInit): Promise<Response>;
|
|
171
|
+
/** Fetch from the Platform API (agent-profile catalog, keys) with the same key. */
|
|
172
|
+
platformFetch(path: string, options?: RequestInit): Promise<Response>;
|
|
173
|
+
/** A host with the same settings that authenticates with `apiKey`. */
|
|
174
|
+
withApiKey(apiKey: string): FleetClientHost;
|
|
171
175
|
readonly fleets: SandboxFleetClient;
|
|
172
176
|
readonly intelligence: {
|
|
173
177
|
createReport(options: CreateIntelligenceReportOptions): Promise<IntelligenceReport>;
|
|
@@ -177,7 +181,22 @@ declare class SandboxFleet {
|
|
|
177
181
|
private readonly client;
|
|
178
182
|
readonly fleetId: string;
|
|
179
183
|
readonly machines: ReadonlyMap<FleetMachineId, SandboxInfo>;
|
|
180
|
-
|
|
184
|
+
private readonly record;
|
|
185
|
+
private readonly boxes;
|
|
186
|
+
private readonly activeRuns;
|
|
187
|
+
private readonly warmAgents;
|
|
188
|
+
private readonly coldStarts;
|
|
189
|
+
constructor(client: FleetClientHost, fleetId: string, machines: ReadonlyMap<FleetMachineId, SandboxInfo>, record?: Omit<SandboxFleetInfo, "fleetId" | "machines">);
|
|
190
|
+
get policy(): SandboxFleetPolicy | undefined;
|
|
191
|
+
get parent(): SandboxFleetParent | undefined;
|
|
192
|
+
/** Id of the Platform key the fleet's sandboxes charge; set when the fleet has a cap. */
|
|
193
|
+
get keyId(): string | undefined;
|
|
194
|
+
/** Every agent of the fleet, in machine order. */
|
|
195
|
+
get agents(): SandboxFleetAgent[];
|
|
196
|
+
agent(agentId: FleetAgentId): SandboxFleetAgent;
|
|
197
|
+
private agentSpecs;
|
|
198
|
+
/** The model of agents that set none: the fleet's `defaults.backend.model`. */
|
|
199
|
+
get model(): string | undefined;
|
|
181
200
|
get ids(): FleetMachineId[];
|
|
182
201
|
get(machineId: FleetMachineId): SandboxInfo;
|
|
183
202
|
sandbox(machineId: FleetMachineId): Promise<SandboxInstance>;
|
|
@@ -185,17 +204,57 @@ declare class SandboxFleet {
|
|
|
185
204
|
exec(machineId: FleetMachineId, command: string, options?: ExecOptions): Promise<ExecResult>;
|
|
186
205
|
dispatchExec(command: string, options?: FleetExecDispatchOptions): Promise<FleetExecDispatchResult[]>;
|
|
187
206
|
dispatchExecDetailed(command: string, options?: FleetExecDispatchOptions): Promise<SandboxFleetDispatchResponse<FleetExecDispatchResult>>;
|
|
207
|
+
/**
|
|
208
|
+
* Run one prompt on one machine's default agent through the API's fleet
|
|
209
|
+
* dispatch. For agent fleets, `run()` and `runAll()` run each agent in its
|
|
210
|
+
* own session through the sandbox runtime path.
|
|
211
|
+
*/
|
|
188
212
|
prompt(machineId: FleetMachineId, message: string | PromptInputPart[], options?: PromptOptions): Promise<PromptResult>;
|
|
189
213
|
dispatchPrompt(message: string | PromptInputPart[], options?: FleetPromptDispatchOptions): Promise<FleetPromptDispatchResult[]>;
|
|
190
214
|
dispatchPromptDetailed(message: string | PromptInputPart[], options?: FleetPromptDispatchOptions): Promise<SandboxFleetDispatchResponse<FleetPromptDispatchResult>>;
|
|
191
215
|
/**
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
216
|
+
* Run one turn on each selected agent, all at once, and yield each agent's
|
|
217
|
+
* start and result as they happen. Every turn goes through the same
|
|
218
|
+
* per-sandbox runtime path as `box.prompt()`: the managed model
|
|
219
|
+
* credential, access audit, metering and trace id all apply per agent.
|
|
220
|
+
*
|
|
221
|
+
* A fleet created with `budgetUsd` drives every turn with its budgeted
|
|
222
|
+
* key, so the Platform refuses each charge past the budget; such a turn
|
|
223
|
+
* ends `budget_exhausted`. Turns already running are not aborted: each is
|
|
224
|
+
* refused at its own next charge.
|
|
225
|
+
*/
|
|
226
|
+
run(message?: string | PromptInputPart[] | ((agent: SandboxFleetAgent) => string | PromptInputPart[]), options?: FleetRunOptions): AsyncGenerator<FleetRunEvent>;
|
|
227
|
+
/** Run one turn on each selected agent and return every agent's result. */
|
|
228
|
+
runAll(message?: string | PromptInputPart[] | ((agent: SandboxFleetAgent) => string | PromptInputPart[]), options?: FleetRunOptions): Promise<FleetAgentResult[]>;
|
|
229
|
+
/**
|
|
230
|
+
* Stop the fleet's work: abort the runs this handle started, interrupt every
|
|
231
|
+
* agent's session on its sandbox (so turns started by another process stop
|
|
232
|
+
* too), and cancel every child fleet. One unreachable sandbox or child does
|
|
233
|
+
* not stop the rest; each failure is reported. Sandboxes keep running;
|
|
234
|
+
* `delete()` removes them.
|
|
235
|
+
*/
|
|
236
|
+
cancel(): Promise<{
|
|
237
|
+
interrupted: number;
|
|
238
|
+
children: number;
|
|
239
|
+
failures: string[];
|
|
240
|
+
}>;
|
|
241
|
+
/** Fleets whose `parent.fleetId` is this fleet. */
|
|
242
|
+
children(): Promise<SandboxFleet[]>;
|
|
243
|
+
/**
|
|
244
|
+
* The fleet's spend as the Platform metered it on the fleet's budgeted key:
|
|
245
|
+
* every router call and compute charge of its sandboxes, from any process.
|
|
246
|
+
* Only a capped fleet has a key; an uncapped fleet has nothing to meter.
|
|
247
|
+
*/
|
|
248
|
+
spend(): Promise<SandboxFleetSpend>;
|
|
249
|
+
/**
|
|
250
|
+
* Drive one settle → poll → dispatch pass across agents — the fleet
|
|
251
|
+
* counterpart of `box.driveTurn()` for tick-based callers (Workflows steps,
|
|
252
|
+
* queue consumers, crons) that re-invoke on their own schedule. One
|
|
195
253
|
* invocation never loops, never sleeps, and never holds a connection: each
|
|
196
|
-
*
|
|
197
|
-
* that
|
|
198
|
-
*
|
|
254
|
+
* agent gets exactly one pass in its own session, and a per-agent failure is
|
|
255
|
+
* captured in that agent's outcome instead of failing the batch. At most
|
|
256
|
+
* `concurrency` passes run at once, and an agent's first turn waits on the
|
|
257
|
+
* same per-sandbox cold-start limit as `run()`.
|
|
199
258
|
*/
|
|
200
259
|
driveTurns(turns: readonly FleetDriveTurnRequest[], options?: {
|
|
201
260
|
concurrency?: number;
|
|
@@ -205,13 +264,21 @@ declare class SandboxFleet {
|
|
|
205
264
|
detachMachine(machineId: FleetMachineId): Promise<{
|
|
206
265
|
success: boolean;
|
|
207
266
|
}>;
|
|
208
|
-
dispatchResults<T = FleetExecDispatchResult
|
|
267
|
+
dispatchResults<T = FleetExecDispatchResult>(dispatchId: string, options?: FleetDispatchResultBufferOptions): Promise<FleetDispatchResultBuffer<T>>;
|
|
209
268
|
cancelDispatch(dispatchId: string, reason?: string): Promise<FleetDispatchCancelResult>;
|
|
210
269
|
createWorkspaceSnapshot(): Promise<SandboxFleetWorkspaceSnapshotResult>;
|
|
211
270
|
restoreWorkspaceSnapshot(snapshotId: string): Promise<SandboxFleetWorkspaceRestoreResult>;
|
|
212
271
|
reconcileWorkspace(): Promise<SandboxFleetWorkspaceReconcileResult>;
|
|
213
272
|
dispatchExecStream(command: string, options?: FleetExecDispatchOptions & FleetDispatchStreamOptions): AsyncGenerator<ParsedSSEEvent, any, any>;
|
|
214
273
|
dispatchPromptStream(message: string | PromptInputPart[], options?: FleetPromptDispatchOptions & FleetDispatchStreamOptions): AsyncGenerator<ParsedSSEEvent, any, any>;
|
|
274
|
+
/**
|
|
275
|
+
* Delete the fleet with its child fleets. The API deprovisions children
|
|
276
|
+
* first, then this fleet's sandboxes, and keeps a fleet's record while any
|
|
277
|
+
* machine of it or its descendants remains, so nothing is left billing
|
|
278
|
+
* without an owner. A failed delete is retried; after the tree is gone the
|
|
279
|
+
* fleet's budgeted key is revoked. Revoking returns only unspent budget: a
|
|
280
|
+
* child's spend stays counted against its parent.
|
|
281
|
+
*/
|
|
215
282
|
delete(options?: {
|
|
216
283
|
continueOnError?: boolean;
|
|
217
284
|
}): Promise<void>;
|
|
@@ -237,18 +304,65 @@ declare class SandboxFleet {
|
|
|
237
304
|
exportTrace(sink: TraceExportSink): Promise<TraceExportResult>;
|
|
238
305
|
cost(): Promise<SandboxFleetCostEstimate>;
|
|
239
306
|
createToken(options?: CreateSandboxFleetTokenOptions): Promise<SandboxFleetToken>;
|
|
240
|
-
|
|
307
|
+
/**
|
|
308
|
+
* The API's prompt dispatch bills the calling key, so a budgeted fleet
|
|
309
|
+
* refuses it: its turns run through `run()`, `runAll()` or `prompt()`.
|
|
310
|
+
*/
|
|
311
|
+
private assertUnbudgetedDispatch;
|
|
312
|
+
/** @internal */
|
|
313
|
+
coldStartGate(machineId: FleetMachineId): Semaphore;
|
|
314
|
+
private sandboxFor;
|
|
241
315
|
}
|
|
242
316
|
declare class SandboxFleetClient {
|
|
243
317
|
private readonly client;
|
|
318
|
+
/**
|
|
319
|
+
* Budgeted keys of the capped fleets this client created, by fleet id. A
|
|
320
|
+
* key's secret exists only here; a child fleet under a capped parent is
|
|
321
|
+
* minted with the parent's key, so it must be created by this client.
|
|
322
|
+
*/
|
|
323
|
+
private readonly fleetKeys;
|
|
244
324
|
constructor(client: FleetClientHost);
|
|
325
|
+
/** Mint the key a capped fleet's sandboxes charge, under `issuerKey`. */
|
|
326
|
+
private mintFleetKey;
|
|
327
|
+
/**
|
|
328
|
+
* @internal The host that authenticates as a capped fleet's budgeted key.
|
|
329
|
+
* Only the client that created the fleet holds the key; any other caller
|
|
330
|
+
* would spend outside the cap, so it is refused.
|
|
331
|
+
*/
|
|
332
|
+
hostFor(fleetId: string): FleetClientHost;
|
|
333
|
+
/** The budgeted key id a fleet's sandboxes carry, read from one of them. */
|
|
334
|
+
private budgetKeyIdOf;
|
|
335
|
+
/** @internal Revoke a fleet's budgeted key; an absent key is already revoked. */
|
|
336
|
+
revokeKey(keyId: string): Promise<void>;
|
|
337
|
+
/** @internal Read a fleet key's metered spend from the Platform. */
|
|
338
|
+
keySpend(keyId: string): Promise<SandboxFleetSpend>;
|
|
339
|
+
/**
|
|
340
|
+
* @internal Delete a fleet and its children through the API, retrying a
|
|
341
|
+
* transient failure. A fleet with no server record is deleted machine by
|
|
342
|
+
* machine from the caller's handle.
|
|
343
|
+
*/
|
|
344
|
+
deleteTree(fleetId: string, machines: readonly SandboxInfo[]): Promise<void>;
|
|
345
|
+
private descendantKeyIds;
|
|
346
|
+
private deleteTreeOnce;
|
|
347
|
+
private deleteMachines;
|
|
245
348
|
capabilities(): Promise<{
|
|
246
349
|
drivers: SandboxFleetDriverCapability[];
|
|
247
350
|
}>;
|
|
248
351
|
operations(): Promise<SandboxFleetOperationsSummary>;
|
|
249
352
|
reconcile(options?: ReconcileSandboxFleetsOptions): Promise<ReconcileSandboxFleetsResult>;
|
|
250
|
-
estimateCost(options: Pick<CreateSandboxFleetOptions, "defaults" | "
|
|
251
|
-
|
|
353
|
+
estimateCost(options: Pick<CreateSandboxFleetOptions, "defaults" | "policy" | "maxConcurrentCreates"> & {
|
|
354
|
+
machines: SandboxFleetMachineSpec[];
|
|
355
|
+
}): Promise<SandboxFleetCostEstimate>;
|
|
356
|
+
create(input: CreateSandboxFleetOptions): Promise<SandboxFleet>;
|
|
357
|
+
/**
|
|
358
|
+
* Turn `agents`/`placement` into machine specs, or pass explicit machines
|
|
359
|
+
* through. Each agent's harness, model and profile resolve from its spec,
|
|
360
|
+
* then its profile, then `defaults.backend`; saved profiles are fetched from
|
|
361
|
+
* the Platform catalog here, before any sandbox exists.
|
|
362
|
+
*/
|
|
363
|
+
private resolveFleetMachines;
|
|
364
|
+
/** Read a saved profile's definition from the Platform catalog. */
|
|
365
|
+
private savedProfile;
|
|
252
366
|
createWithCoordinator(options: CreateSandboxFleetWithCoordinatorOptions): Promise<SandboxFleet>;
|
|
253
367
|
private createMachine;
|
|
254
368
|
list(options: ListSandboxFleetOptions): Promise<SandboxFleet>;
|
|
@@ -256,6 +370,8 @@ declare class SandboxFleetClient {
|
|
|
256
370
|
continueOnError?: boolean;
|
|
257
371
|
}): Promise<void>;
|
|
258
372
|
fromInfo(info: SandboxFleetInfo): SandboxFleet;
|
|
373
|
+
/** Fleets spawned by `fleetId`, from the API's `parent` lineage. */
|
|
374
|
+
children(fleetId: string): Promise<SandboxFleet[]>;
|
|
259
375
|
private persistFleet;
|
|
260
376
|
private getServerFleet;
|
|
261
377
|
deleteRecord(fleetId: string): Promise<void>;
|
|
@@ -280,7 +396,7 @@ declare class SandboxFleetClient {
|
|
|
280
396
|
detachMachine(fleetId: string, machineId: FleetMachineId): Promise<{
|
|
281
397
|
success: boolean;
|
|
282
398
|
}>;
|
|
283
|
-
dispatchResults<T = FleetExecDispatchResult
|
|
399
|
+
dispatchResults<T = FleetExecDispatchResult>(fleetId: string, dispatchId: string, options?: FleetDispatchResultBufferOptions): Promise<FleetDispatchResultBuffer<T>>;
|
|
284
400
|
cancelDispatch(fleetId: string, dispatchId: string, reason?: string): Promise<FleetDispatchCancelResult>;
|
|
285
401
|
createWorkspaceSnapshot(fleetId: string): Promise<SandboxFleetWorkspaceSnapshotResult>;
|
|
286
402
|
restoreWorkspaceSnapshot(fleetId: string, snapshotId: string): Promise<SandboxFleetWorkspaceRestoreResult>;
|
|
@@ -291,6 +407,14 @@ declare class SandboxFleetClient {
|
|
|
291
407
|
private hydrateServerFleet;
|
|
292
408
|
private listBySandboxMetadata;
|
|
293
409
|
}
|
|
410
|
+
/** Counting semaphore whose waiters leave the queue when their signal aborts. */
|
|
411
|
+
declare class Semaphore {
|
|
412
|
+
private available;
|
|
413
|
+
private readonly waiters;
|
|
414
|
+
constructor(available: number);
|
|
415
|
+
acquire(signal: AbortSignal): Promise<void>;
|
|
416
|
+
release(): void;
|
|
417
|
+
}
|
|
294
418
|
//#endregion
|
|
295
419
|
//#region src/instances.d.ts
|
|
296
420
|
/** The profile version that new sessions of an instance bind to. */
|
|
@@ -438,33 +562,9 @@ interface SessionBroadcastResult {
|
|
|
438
562
|
}
|
|
439
563
|
//#endregion
|
|
440
564
|
//#region src/client.d.ts
|
|
441
|
-
/**
|
|
442
|
-
* Client for the Tangle Sandbox platform.
|
|
443
|
-
*
|
|
444
|
-
* @example
|
|
445
|
-
* ```typescript
|
|
446
|
-
* import { Sandbox } from "@tangle-network/sandbox";
|
|
447
|
-
*
|
|
448
|
-
* const client = new Sandbox({
|
|
449
|
-
* apiKey: "sk-tan-...",
|
|
450
|
-
* baseUrl: "https://your-sandbox-api.example.com",
|
|
451
|
-
* });
|
|
452
|
-
*
|
|
453
|
-
* // Create a sandbox
|
|
454
|
-
* const box = await client.create({
|
|
455
|
-
* name: "my-project",
|
|
456
|
-
* sshEnabled: true,
|
|
457
|
-
* });
|
|
458
|
-
*
|
|
459
|
-
* // Execute commands
|
|
460
|
-
* const result = await box.exec("npm install");
|
|
461
|
-
*
|
|
462
|
-
* // Clean up
|
|
463
|
-
* await box.delete();
|
|
464
|
-
* ```
|
|
465
|
-
*/
|
|
466
565
|
declare class Sandbox implements HttpClient, ScopedTokenHttpClient {
|
|
467
566
|
private readonly baseUrl;
|
|
567
|
+
private readonly platformUrl;
|
|
468
568
|
private readonly apiKey;
|
|
469
569
|
private readonly timeoutMs;
|
|
470
570
|
private readonly trustLocalCliAuth;
|
|
@@ -497,6 +597,10 @@ declare class Sandbox implements HttpClient, ScopedTokenHttpClient {
|
|
|
497
597
|
get lines(): LinesClient;
|
|
498
598
|
get intelligence(): IntelligenceClient;
|
|
499
599
|
getApiKey(): string;
|
|
600
|
+
/** A client with this one's settings that authenticates with `apiKey`. */
|
|
601
|
+
withApiKey(apiKey: string): Sandbox;
|
|
602
|
+
/** Fetch a Platform API path (e.g. the agent-profile catalog) with this key. */
|
|
603
|
+
platformFetch(path: string, options?: RequestInit): Promise<Response>;
|
|
500
604
|
/**
|
|
501
605
|
* Access the secrets manager for storing and retrieving encrypted secrets.
|
|
502
606
|
*
|