@tangle-network/sandbox 0.27.2 → 0.28.0-develop.20260819001319.32159f4
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 +89 -1
- package/dist/agent/index.d.ts +94 -4
- package/dist/agent/index.js +139 -1
- package/dist/{client-DZxBi30R.d.ts → client-CtbXjqd2.d.ts} +2 -2
- package/dist/core.d.ts +3 -3
- package/dist/{index-DIuMQrlL.d.ts → index-DweQWp1c.d.ts} +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/runtime.d.ts +1 -1
- package/dist/{sandbox-BoBp6F83.d.ts → sandbox-BpmHeBK1.d.ts} +1 -1
- package/dist/tangle/index.d.ts +1 -1
- package/dist/{types-DL7FzacJ.d.ts → types-jfr4fgD3.d.ts} +208 -208
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ export SANDBOX_BASE_URL=https://sandbox.tangle.tools
|
|
|
28
28
|
| Collaborative document clients and file bridging | `@tangle-network/sandbox/collaboration` |
|
|
29
29
|
| Browser WebSocket session streaming and replay | `@tangle-network/sandbox/session-gateway` |
|
|
30
30
|
| OpenAI-compatible request and event translation | `@tangle-network/sandbox/openai` |
|
|
31
|
-
|
|
|
31
|
+
| Multiple managed Agents, framework tool packs, and the local MCP bridge | `@tangle-network/sandbox/agent` |
|
|
32
32
|
| Browser-safe trace reads from Tangle Intelligence | `@tangle-network/sandbox/intelligence` |
|
|
33
33
|
|
|
34
34
|
Install an optional peer dependency only when the selected integration requires it.
|
|
@@ -109,6 +109,93 @@ for (const environment of environments) {
|
|
|
109
109
|
Use `bare: true` for a minimal container with command execution and lifecycle controls.
|
|
110
110
|
Use `agent: false` for managed files, processes, and telemetry without configuring an agent backend.
|
|
111
111
|
|
|
112
|
+
## Run several Agents in one Sandbox
|
|
113
|
+
|
|
114
|
+
Import the Agent entrypoint when one Sandbox should host several AgentProfiles.
|
|
115
|
+
It re-exports the main client and installs the typed `box.agents` namespace.
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import type { AgentProfile } from "@tangle-network/agent-interface";
|
|
119
|
+
import { Sandbox } from "@tangle-network/sandbox/agent";
|
|
120
|
+
|
|
121
|
+
const client = new Sandbox({
|
|
122
|
+
apiKey: process.env.TANGLE_API_KEY!,
|
|
123
|
+
baseUrl: process.env.SANDBOX_BASE_URL!,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const plannerProfile = {
|
|
127
|
+
name: "planner",
|
|
128
|
+
harness: "opencode",
|
|
129
|
+
prompt: { appendSystemPrompt: "Plan before editing files." },
|
|
130
|
+
} satisfies AgentProfile;
|
|
131
|
+
|
|
132
|
+
const implementerProfile = {
|
|
133
|
+
name: "implementer",
|
|
134
|
+
harness: "claude-code",
|
|
135
|
+
prompt: { appendSystemPrompt: "Implement the request and run tests." },
|
|
136
|
+
} satisfies AgentProfile;
|
|
137
|
+
|
|
138
|
+
const box = await client.create({
|
|
139
|
+
environment: "universal",
|
|
140
|
+
agent: false,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
const [planner, implementer] = await box.agents.startMany([
|
|
145
|
+
{
|
|
146
|
+
id: "planner-v1",
|
|
147
|
+
backend: { type: "opencode", profile: plannerProfile },
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
id: "implementer-v1",
|
|
151
|
+
backend: { type: "claude-code", profile: implementerProfile },
|
|
152
|
+
},
|
|
153
|
+
]);
|
|
154
|
+
|
|
155
|
+
const [plan, implementation] = await Promise.all([
|
|
156
|
+
planner.prompt("Inspect the repository and produce a precise plan."),
|
|
157
|
+
implementer.prompt("Inspect the repository and implement the request."),
|
|
158
|
+
]);
|
|
159
|
+
|
|
160
|
+
console.log(plan.response);
|
|
161
|
+
console.log(implementation.response);
|
|
162
|
+
} finally {
|
|
163
|
+
await box.delete();
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Each returned Agent is the existing durable `SandboxSession` handle. Different
|
|
168
|
+
session ids may run in parallel; turns inside one session remain serialized.
|
|
169
|
+
Use a stable id and `box.agents.get(id)` to reattach from another process.
|
|
170
|
+
|
|
171
|
+
Shared workspace is the default. Use the existing task-session Git-worktree
|
|
172
|
+
path when file changes or profile control files must remain isolated:
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
const reviewer = await box.agents.start({
|
|
176
|
+
id: "reviewer",
|
|
177
|
+
backend: { type: "codex", profile: reviewerProfile },
|
|
178
|
+
workspace: { mode: "isolated", parentSessionId: "implementer-v1" },
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const changes = await reviewer.changes();
|
|
182
|
+
await reviewer.commit({ message: "Apply reviewer changes" });
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
An isolated Agent requires a Git repository and returns `SandboxTaskSession`.
|
|
186
|
+
Agents in one Sandbox share a broad trust and resource boundary. Use separate
|
|
187
|
+
Sandboxes for mutually untrusted Agents, separate tenants, or hard resource
|
|
188
|
+
isolation.
|
|
189
|
+
|
|
190
|
+
Applications that already import from the root can install the namespace with:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
import { Sandbox } from "@tangle-network/sandbox";
|
|
194
|
+
import "@tangle-network/sandbox/agent";
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
See `examples/multi-agent-sandbox.ts` for a complete runnable example.
|
|
198
|
+
|
|
112
199
|
## Lifecycle
|
|
113
200
|
|
|
114
201
|
The active states are `pending`, `provisioning`, `running`, `stopped`, `failed`, and `expired`.
|
|
@@ -409,6 +496,7 @@ The root entrypoint exports the primary client, instance, session, fleet, image,
|
|
|
409
496
|
|---|---|
|
|
410
497
|
| Account client | `Sandbox` |
|
|
411
498
|
| One environment | `SandboxInstance` |
|
|
499
|
+
| One or more managed Agents in a Sandbox | `box.agents` from the `/agent` entrypoint |
|
|
412
500
|
| Continued conversation | `SandboxSession` |
|
|
413
501
|
| Coordinated environments | `SandboxFleetClient`, `SandboxFleet` |
|
|
414
502
|
| Reusable images | `Image`, `ImageBuilder` |
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,8 +1,98 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { i as Sandbox } from "../client-
|
|
1
|
+
import { g as SandboxSession, h as SandboxTaskSession, r as SandboxInstance } from "../sandbox-BpmHeBK1.js";
|
|
2
|
+
import { C as CodeResultPart, S as CodeLanguage, b as CodeExecutionOptions, fi as SessionInfo, mi as SessionListOptions, s as BackendConfig, x as CodeExecutionResult } from "../types-jfr4fgD3.js";
|
|
3
|
+
import { i as Sandbox } from "../client-CtbXjqd2.js";
|
|
4
4
|
import * as _$_modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
5
|
|
|
6
|
+
//#region src/agent/instances.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Workspace semantics for one managed Agent inside a Sandbox.
|
|
9
|
+
*
|
|
10
|
+
* `shared` uses the Sandbox's ordinary project workspace. `isolated` uses the
|
|
11
|
+
* existing task-session Git worktree and exposes `changes()` and `commit()`.
|
|
12
|
+
* Neither mode is a security boundary between mutually untrusted processes.
|
|
13
|
+
*/
|
|
14
|
+
type SandboxAgentWorkspace = {
|
|
15
|
+
mode: "shared";
|
|
16
|
+
} | {
|
|
17
|
+
mode: "isolated";
|
|
18
|
+
parentSessionId?: string;
|
|
19
|
+
};
|
|
20
|
+
/** Start one managed Agent session inside an existing Sandbox. */
|
|
21
|
+
interface SandboxAgentSpec {
|
|
22
|
+
/** Stable session id. Omit to generate one. */
|
|
23
|
+
id?: string;
|
|
24
|
+
/** Human-readable session title. */
|
|
25
|
+
name?: string;
|
|
26
|
+
/** Exact harness, profile, model, and credential configuration. */
|
|
27
|
+
backend: BackendConfig;
|
|
28
|
+
/** Defaults to `{ mode: "shared" }`. */
|
|
29
|
+
workspace?: SandboxAgentWorkspace;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* An Agent is the SDK's existing durable session handle.
|
|
33
|
+
*
|
|
34
|
+
* Isolated Agents are `SandboxTaskSession` instances, which extend
|
|
35
|
+
* `SandboxSession` with `changes()` and `commit()`.
|
|
36
|
+
*/
|
|
37
|
+
type SandboxAgent = SandboxSession | SandboxTaskSession;
|
|
38
|
+
/** Exact handle returned for a statically known Agent specification. */
|
|
39
|
+
type SandboxAgentForSpec<Spec extends SandboxAgentSpec> = Spec extends {
|
|
40
|
+
workspace: {
|
|
41
|
+
mode: "isolated";
|
|
42
|
+
};
|
|
43
|
+
} ? SandboxTaskSession : SandboxSession;
|
|
44
|
+
interface SandboxAgentStopAcknowledgement {
|
|
45
|
+
agentId: string;
|
|
46
|
+
outcome: "stopped" | "not-found";
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A thin namespace over the Sandbox's durable session APIs.
|
|
50
|
+
*
|
|
51
|
+
* The manager stores no Agent lifecycle state. The sidecar session store and
|
|
52
|
+
* backend manager remain authoritative, so a new SDK process can reattach with
|
|
53
|
+
* `get()` or the existing `box.session(id)` API.
|
|
54
|
+
*/
|
|
55
|
+
declare class SandboxAgentManager {
|
|
56
|
+
private readonly sandbox;
|
|
57
|
+
/** @internal Constructed by the `box.agents` getter. */
|
|
58
|
+
constructor(sandbox: SandboxInstance);
|
|
59
|
+
start<const Spec extends SandboxAgentSpec>(spec: Spec): Promise<SandboxAgentForSpec<Spec>>;
|
|
60
|
+
/**
|
|
61
|
+
* Start independent Agent sessions concurrently.
|
|
62
|
+
*
|
|
63
|
+
* This is intentionally not an atomic transaction: if one start fails,
|
|
64
|
+
* another may already have succeeded. Use stable ids and `list()`/`get()` to
|
|
65
|
+
* inspect the durable result before retrying or cleaning up.
|
|
66
|
+
*/
|
|
67
|
+
startMany<const Specs extends readonly SandboxAgentSpec[]>(specs: Specs): Promise<{ -readonly [Index in keyof Specs]: SandboxAgentForSpec<Specs[Index]> }>;
|
|
68
|
+
/** Reattach to a durable Agent session from any SDK process. */
|
|
69
|
+
get(id: string): Promise<SandboxSession | null>;
|
|
70
|
+
/**
|
|
71
|
+
* Reattach to an isolated Agent when the caller knows it was created through
|
|
72
|
+
* the task-session path. The returned handle validates itself on first use.
|
|
73
|
+
*/
|
|
74
|
+
task(id: string): SandboxTaskSession;
|
|
75
|
+
/** List the Sandbox's durable Agent sessions. */
|
|
76
|
+
list(options?: SessionListOptions): Promise<Array<{
|
|
77
|
+
session: SandboxSession;
|
|
78
|
+
info: SessionInfo;
|
|
79
|
+
}>>;
|
|
80
|
+
/** Stop one Agent without stopping its Sandbox or sibling sessions. */
|
|
81
|
+
stop(id: string, options?: {
|
|
82
|
+
force?: boolean;
|
|
83
|
+
}): Promise<SandboxAgentStopAcknowledgement>;
|
|
84
|
+
private startPrepared;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Importing `@tangle-network/sandbox/agent` installs the typed `box.agents`
|
|
88
|
+
* namespace. The getter is lazy and keeps no correctness-relevant state.
|
|
89
|
+
*/
|
|
90
|
+
declare module "../sandbox.js" {
|
|
91
|
+
interface SandboxInstance {
|
|
92
|
+
readonly agents: SandboxAgentManager;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
6
96
|
//#region src/agent/tools/_specs.d.ts
|
|
7
97
|
/** JSON-schema-ish object describing tool inputs. Plain object literal — no Zod required. */
|
|
8
98
|
type ToolJSONSchema = {
|
|
@@ -522,4 +612,4 @@ type AnyTool = unknown;
|
|
|
522
612
|
*/
|
|
523
613
|
declare function vercelAiTools(box: SandboxInstance, options?: VercelAiToolPackOptions): Promise<Record<string, AnyTool>>;
|
|
524
614
|
//#endregion
|
|
525
|
-
export { ALL_FLEET_TOOL_SPECS, ALL_LIFECYCLE_TOOL_SPECS, ALL_TOOL_SPECS, type AnthropicFleetTool, type AnthropicFleetToolPack, type AnthropicLifecycleTool, type AnthropicLifecycleToolPack, type AnthropicTool, type AnthropicToolPack, type AnthropicToolPackOptions, type AnthropicToolResultBlock, type AnthropicToolUseBlock, type CodeExecutionOptions, type CodeExecutionResult, type CodeLanguage, type CodeResultPart, FLEET_TOOL_SPECS, type FleetToolHandlerContext, type FleetToolName, type FleetToolPackOptions, type FleetToolSpec, LIFECYCLE_TOOL_SPECS, type LifecycleToolHandlerContext, type LifecycleToolName, type LifecycleToolPackOptions, type LifecycleToolSpec, type MastraToolPackOptions, type McpServerHandle, type McpServerOptions, type OpenAIFleetTool, type OpenAIFleetToolPack, type OpenAILifecycleTool, type OpenAILifecycleToolPack, type OpenAITool, type OpenAIToolCall, type OpenAIToolPack, type OpenAIToolPackOptions, type OpenAIToolResultMessage, TOOL_SPECS, type ToolHandlerContext, type ToolName, type ToolSpec, type VercelAiToolPackOptions, anthropicFleetTools, anthropicLifecycleTools, anthropicTools, createMcpServer, mastraFleetTools, mastraTools, openaiFleetTools, openaiLifecycleTools, openaiTools, runCode, vercelAiFleetTools, vercelAiTools };
|
|
615
|
+
export { ALL_FLEET_TOOL_SPECS, ALL_LIFECYCLE_TOOL_SPECS, ALL_TOOL_SPECS, type AnthropicFleetTool, type AnthropicFleetToolPack, type AnthropicLifecycleTool, type AnthropicLifecycleToolPack, type AnthropicTool, type AnthropicToolPack, type AnthropicToolPackOptions, type AnthropicToolResultBlock, type AnthropicToolUseBlock, type CodeExecutionOptions, type CodeExecutionResult, type CodeLanguage, type CodeResultPart, FLEET_TOOL_SPECS, type FleetToolHandlerContext, type FleetToolName, type FleetToolPackOptions, type FleetToolSpec, LIFECYCLE_TOOL_SPECS, type LifecycleToolHandlerContext, type LifecycleToolName, type LifecycleToolPackOptions, type LifecycleToolSpec, type MastraToolPackOptions, type McpServerHandle, type McpServerOptions, type OpenAIFleetTool, type OpenAIFleetToolPack, type OpenAILifecycleTool, type OpenAILifecycleToolPack, type OpenAITool, type OpenAIToolCall, type OpenAIToolPack, type OpenAIToolPackOptions, type OpenAIToolResultMessage, Sandbox, type SandboxAgent, type SandboxAgentForSpec, SandboxAgentManager, type SandboxAgentSpec, type SandboxAgentStopAcknowledgement, type SandboxAgentWorkspace, TOOL_SPECS, type ToolHandlerContext, type ToolName, type ToolSpec, type VercelAiToolPackOptions, anthropicFleetTools, anthropicLifecycleTools, anthropicTools, createMcpServer, mastraFleetTools, mastraTools, openaiFleetTools, openaiLifecycleTools, openaiTools, runCode, vercelAiFleetTools, vercelAiTools };
|
package/dist/agent/index.js
CHANGED
|
@@ -1,4 +1,142 @@
|
|
|
1
|
+
import { f as assertCurrentBackendType } from "../runtime-api-CK-4S7oA.js";
|
|
2
|
+
import { d as StateError, o as NotFoundError, p as ValidationError } from "../errors-C6kn-3zt.js";
|
|
3
|
+
import { n as Sandbox } from "../client-BBKAFyDE.js";
|
|
4
|
+
import { t as SandboxInstance } from "../sandbox-NvbxFwTv.js";
|
|
1
5
|
import { createRequire } from "node:module";
|
|
6
|
+
//#region src/agent/instances.ts
|
|
7
|
+
const managers = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
function generateAgentId() {
|
|
9
|
+
const crypto = globalThis.crypto;
|
|
10
|
+
if (crypto?.randomUUID) return `agent-${crypto.randomUUID()}`;
|
|
11
|
+
if (crypto?.getRandomValues) {
|
|
12
|
+
const bytes = crypto.getRandomValues(new Uint8Array(16));
|
|
13
|
+
return `agent-${Array.from(bytes, (value) => value.toString(16).padStart(2, "0")).join("")}`;
|
|
14
|
+
}
|
|
15
|
+
throw new Error("Agent id generation requires global crypto");
|
|
16
|
+
}
|
|
17
|
+
function validateAgentId(id) {
|
|
18
|
+
const value = id.trim();
|
|
19
|
+
if (value.length < 1 || value.length > 128 || !/^[A-Za-z0-9](?:[A-Za-z0-9._:-]*[A-Za-z0-9])?$/u.test(value)) throw new ValidationError("Agent id must be 1-128 visible alphanumeric, '.', '_', ':', or '-' characters");
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
function prepareAgentSpec(spec) {
|
|
23
|
+
if (spec.backend.type !== void 0) assertCurrentBackendType(spec.backend.type);
|
|
24
|
+
const callerSelectedId = spec.id !== void 0;
|
|
25
|
+
const id = validateAgentId(spec.id ?? generateAgentId());
|
|
26
|
+
const name = spec.name?.trim();
|
|
27
|
+
if (name !== void 0 && name.length === 0) throw new ValidationError("Agent name cannot be empty");
|
|
28
|
+
return {
|
|
29
|
+
id,
|
|
30
|
+
callerSelectedId,
|
|
31
|
+
...name !== void 0 ? { name } : {},
|
|
32
|
+
backend: spec.backend,
|
|
33
|
+
workspace: spec.workspace ?? { mode: "shared" }
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A thin namespace over the Sandbox's durable session APIs.
|
|
38
|
+
*
|
|
39
|
+
* The manager stores no Agent lifecycle state. The sidecar session store and
|
|
40
|
+
* backend manager remain authoritative, so a new SDK process can reattach with
|
|
41
|
+
* `get()` or the existing `box.session(id)` API.
|
|
42
|
+
*/
|
|
43
|
+
var SandboxAgentManager = class {
|
|
44
|
+
/** @internal Constructed by the `box.agents` getter. */
|
|
45
|
+
constructor(sandbox) {
|
|
46
|
+
this.sandbox = sandbox;
|
|
47
|
+
}
|
|
48
|
+
async start(spec) {
|
|
49
|
+
return this.startPrepared(prepareAgentSpec(spec));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Start independent Agent sessions concurrently.
|
|
53
|
+
*
|
|
54
|
+
* This is intentionally not an atomic transaction: if one start fails,
|
|
55
|
+
* another may already have succeeded. Use stable ids and `list()`/`get()` to
|
|
56
|
+
* inspect the durable result before retrying or cleaning up.
|
|
57
|
+
*/
|
|
58
|
+
async startMany(specs) {
|
|
59
|
+
const prepared = specs.map(prepareAgentSpec);
|
|
60
|
+
const ids = /* @__PURE__ */ new Set();
|
|
61
|
+
for (const spec of prepared) {
|
|
62
|
+
if (ids.has(spec.id)) throw new ValidationError(`Duplicate Agent id in one startMany call: ${spec.id}`);
|
|
63
|
+
ids.add(spec.id);
|
|
64
|
+
}
|
|
65
|
+
return Promise.all(prepared.map((spec) => this.startPrepared(spec)));
|
|
66
|
+
}
|
|
67
|
+
/** Reattach to a durable Agent session from any SDK process. */
|
|
68
|
+
async get(id) {
|
|
69
|
+
const session = this.sandbox.session(validateAgentId(id));
|
|
70
|
+
return await session.status() ? session : null;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Reattach to an isolated Agent when the caller knows it was created through
|
|
74
|
+
* the task-session path. The returned handle validates itself on first use.
|
|
75
|
+
*/
|
|
76
|
+
task(id) {
|
|
77
|
+
return this.sandbox.taskSession(validateAgentId(id));
|
|
78
|
+
}
|
|
79
|
+
/** List the Sandbox's durable Agent sessions. */
|
|
80
|
+
list(options) {
|
|
81
|
+
return this.sandbox.sessions(options);
|
|
82
|
+
}
|
|
83
|
+
/** Stop one Agent without stopping its Sandbox or sibling sessions. */
|
|
84
|
+
async stop(id, options = {}) {
|
|
85
|
+
const agentId = validateAgentId(id);
|
|
86
|
+
const session = this.sandbox.session(agentId);
|
|
87
|
+
const current = await session.status();
|
|
88
|
+
if (!current) return {
|
|
89
|
+
agentId,
|
|
90
|
+
outcome: "not-found"
|
|
91
|
+
};
|
|
92
|
+
if (options.force === true && current.activeExecutionId) await session.interrupt({ executionId: current.activeExecutionId }).catch(() => void 0);
|
|
93
|
+
try {
|
|
94
|
+
await session.delete();
|
|
95
|
+
return {
|
|
96
|
+
agentId,
|
|
97
|
+
outcome: "stopped"
|
|
98
|
+
};
|
|
99
|
+
} catch (error) {
|
|
100
|
+
if (error instanceof NotFoundError) return {
|
|
101
|
+
agentId,
|
|
102
|
+
outcome: "not-found"
|
|
103
|
+
};
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async startPrepared(spec) {
|
|
108
|
+
if (spec.callerSelectedId) {
|
|
109
|
+
if (await this.sandbox.session(spec.id).status()) throw new StateError(`Agent ${spec.id} already exists; use box.agents.get("${spec.id}") to reattach or choose a new id`, "existing-agent", "new-agent-id");
|
|
110
|
+
}
|
|
111
|
+
if (spec.workspace.mode === "isolated") return (await this.sandbox.createTaskSession({
|
|
112
|
+
sessionId: spec.id,
|
|
113
|
+
title: spec.name ?? spec.id,
|
|
114
|
+
backend: spec.backend,
|
|
115
|
+
...spec.workspace.parentSessionId !== void 0 ? { parentSessionId: spec.workspace.parentSessionId } : {},
|
|
116
|
+
isolateFileWrites: true
|
|
117
|
+
})).session;
|
|
118
|
+
return (await this.sandbox.createSession({
|
|
119
|
+
sessionId: spec.id,
|
|
120
|
+
...spec.name !== void 0 ? { title: spec.name } : {},
|
|
121
|
+
backend: spec.backend
|
|
122
|
+
})).session;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
function managerFor(sandbox) {
|
|
126
|
+
let manager = managers.get(sandbox);
|
|
127
|
+
if (!manager) {
|
|
128
|
+
manager = new SandboxAgentManager(sandbox);
|
|
129
|
+
managers.set(sandbox, manager);
|
|
130
|
+
}
|
|
131
|
+
return manager;
|
|
132
|
+
}
|
|
133
|
+
if (!Object.getOwnPropertyDescriptor(SandboxInstance.prototype, "agents")) Object.defineProperty(SandboxInstance.prototype, "agents", {
|
|
134
|
+
configurable: false,
|
|
135
|
+
enumerable: false,
|
|
136
|
+
get() {
|
|
137
|
+
return managerFor(this);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
2
140
|
/**
|
|
3
141
|
* Keyed registry. `as const` preserves per-tool TArgs/TResult through the
|
|
4
142
|
* type system — `TOOL_SPECS.sandbox_run_code.makeHandler` returns a handler
|
|
@@ -1023,4 +1161,4 @@ async function vercelAiTools(box, options = {}) {
|
|
|
1023
1161
|
return result;
|
|
1024
1162
|
}
|
|
1025
1163
|
//#endregion
|
|
1026
|
-
export { ALL_FLEET_TOOL_SPECS, ALL_LIFECYCLE_TOOL_SPECS, ALL_TOOL_SPECS, FLEET_TOOL_SPECS, LIFECYCLE_TOOL_SPECS, TOOL_SPECS, anthropicFleetTools, anthropicLifecycleTools, anthropicTools, createMcpServer, mastraFleetTools, mastraTools, openaiFleetTools, openaiLifecycleTools, openaiTools, runCode, vercelAiFleetTools, vercelAiTools };
|
|
1164
|
+
export { ALL_FLEET_TOOL_SPECS, ALL_LIFECYCLE_TOOL_SPECS, ALL_TOOL_SPECS, FLEET_TOOL_SPECS, LIFECYCLE_TOOL_SPECS, Sandbox, SandboxAgentManager, TOOL_SPECS, anthropicFleetTools, anthropicLifecycleTools, anthropicTools, createMcpServer, mastraFleetTools, mastraTools, openaiFleetTools, openaiLifecycleTools, openaiTools, runCode, vercelAiFleetTools, vercelAiTools };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { l as TraceExportResult, n as HttpClient, r as SandboxInstance, u as TraceExportSink } from "./sandbox-BpmHeBK1.js";
|
|
2
|
+
import { $t as IntelligenceReportWindow, A as CreateSandboxFleetTokenOptions, Ar as SandboxFleetWorkspaceRestoreResult, Bi as TokenRefreshHandler, Cr as SandboxFleetTraceBundle, Ct as FleetExecDispatchOptions, D as CreateIntelligenceReportOptions, Dr as SandboxFleetUsage, Dt as FleetPromptDispatchResult, En as PromptResult, Er as SandboxFleetTraceOptions, Et as FleetPromptDispatchOptions, Fn as ReapExpiredSandboxFleetsOptions, In as ReapExpiredSandboxFleetsResult, Ki as UsageInfo, Ln as ReconcileSandboxFleetsOptions, M as CreateSandboxOptions, Mn as PublicTemplateVersionInfo, Mr as SandboxIdentity, Nn as PublishPublicTemplateOptions, Nr as SandboxInfo, O as CreateRequestOptions, Pn as PublishPublicTemplateVersionOptions, Rn as ReconcileSandboxFleetsResult, Sr as SandboxFleetToken, St as FleetDriveTurnRequest, Ti as SshKeysManager, Tn as PromptOptions, Tt as FleetMachineId, Xt as IntelligenceReportBudget, Yt as IntelligenceReport, Zn as SandboxConfig, Zt as IntelligenceReportCompareTo, _t as FleetDispatchCancelResult, a as AttachSandboxFleetMachineOptions, ar as SandboxFleetArtifact, br as SandboxFleetOperationsSummary, bt as FleetDispatchStreamOptions, ea as BatchEvent, f as BatchResult, fr as SandboxFleetInfo, gr as SandboxFleetMachineRecord, ii as SecretsManager, in as ListSandboxOptions, j as CreateSandboxFleetWithCoordinatorOptions, jn as PublicTemplateInfo, jr as SandboxFleetWorkspaceSnapshotResult, k as CreateSandboxFleetOptions, ki as SubscriptionInfo, kr as SandboxFleetWorkspaceReconcileResult, lr as SandboxFleetDispatchResponse, m as BatchRunRequest, nt as ExecOptions, or as SandboxFleetArtifactSpec, p as BatchRunOptions, rn as ListSandboxFleetOptions, rr as SandboxEnvironment, rt as ExecResult, sr as SandboxFleetCostEstimate, ur as SandboxFleetDriverCapability, vr as SandboxFleetManifest, vt as FleetDispatchResultBuffer, wn as PromptInputPart, wt as FleetExecDispatchResult, xt as FleetDriveTurnOutcome, yt as FleetDispatchResultBufferOptions } from "./types-jfr4fgD3.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
//#region src/backend-registry.d.ts
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { C as isBackendRegistryInteractionKind, S as backendRegistryResponseSchema, T as parseBackendRegistryResponseBody, _ as BackendRegistryInteractionKind, b as backendRegistryEntrySchema, g as BackendRegistryEntry, h as BackendRegistryCapabilities, i as Sandbox, v as BackendRegistryResponse, w as parseBackendRegistryResponse, x as backendRegistryInteractionKindSchema, y as backendRegistryCapabilitiesSchema } from "./client-
|
|
1
|
+
import { a as WorkspaceImagePublishRequestOptions, i as WorkspaceImagePublishInput, o as WorkspaceImagePublishResult, r as SandboxInstance, s as WorkspaceImages } from "./sandbox-BpmHeBK1.js";
|
|
2
|
+
import { M as CreateSandboxOptions, Nr as SandboxInfo, Vr as SandboxStatus, Zn as SandboxConfig, cn as NetworkConfig, hn as PreviewLinkWaitOptions, mn as PreviewLinkManager, nt as ExecOptions, pn as PreviewLinkInfo, rt as ExecResult, wn as PromptInputPart } from "./types-jfr4fgD3.js";
|
|
3
|
+
import { C as isBackendRegistryInteractionKind, S as backendRegistryResponseSchema, T as parseBackendRegistryResponseBody, _ as BackendRegistryInteractionKind, b as backendRegistryEntrySchema, g as BackendRegistryEntry, h as BackendRegistryCapabilities, i as Sandbox, v as BackendRegistryResponse, w as parseBackendRegistryResponse, x as backendRegistryInteractionKindSchema, y as backendRegistryCapabilitiesSchema } from "./client-CtbXjqd2.js";
|
|
4
4
|
import { a as NetworkError, c as QuotaError, d as SandboxFailureDetail, f as ServerError, h as ValidationError, i as FileWriteConflictError, l as SandboxError, m as TimeoutError, n as CapabilityError, o as NotFoundError, p as StateError, s as PartialFailureError, t as AuthError, u as SandboxErrorJson } from "./errors-Bdy5jXzc.js";
|
|
5
5
|
export { AuthError, type BackendRegistryCapabilities, type BackendRegistryEntry, type BackendRegistryInteractionKind, type BackendRegistryResponse, CapabilityError, type CreateSandboxOptions, type ExecOptions, type ExecResult, FileWriteConflictError, type NetworkConfig, NetworkError, NotFoundError, PartialFailureError, type PreviewLinkInfo, type PreviewLinkManager, type PreviewLinkWaitOptions, type PromptInputPart, QuotaError, Sandbox, type SandboxConfig, SandboxError, type SandboxErrorJson, type SandboxFailureDetail, type SandboxInfo, SandboxInstance, type SandboxStatus, ServerError, StateError, TimeoutError, ValidationError, type WorkspaceImagePublishInput, type WorkspaceImagePublishRequestOptions, type WorkspaceImagePublishResult, WorkspaceImages, backendRegistryCapabilitiesSchema, backendRegistryEntrySchema, backendRegistryInteractionKindSchema, backendRegistryResponseSchema, isBackendRegistryInteractionKind, parseBackendRegistryResponse, parseBackendRegistryResponseBody };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as HttpClient, r as SandboxInstance } from "./sandbox-BpmHeBK1.js";
|
|
2
|
+
import { M as CreateSandboxOptions } from "./types-jfr4fgD3.js";
|
|
3
3
|
|
|
4
4
|
//#region src/tangle/abi.d.ts
|
|
5
5
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { C as isBackendRegistryInteractionKind, S as backendRegistryResponseSchema, T as parseBackendRegistryResponseBody, _ as BackendRegistryInteractionKind, a as Team, b as backendRegistryEntrySchema, c as SessionBroadcastEvent, d as SandboxFleetClient, f as ParseSSEStreamOptions, g as BackendRegistryEntry, h as BackendRegistryCapabilities, i as Sandbox, l as SessionBroadcastResult, m as parseSSEStream, n as IntelligenceClient, o as TeamInvitation, p as ParsedSSEEvent, r as InviteTeamMemberOptions, s as TeamMember, t as CreateTeamOptions, u as SandboxFleet, v as BackendRegistryResponse, w as parseBackendRegistryResponse, x as backendRegistryInteractionKindSchema, y as backendRegistryCapabilitiesSchema } from "./client-
|
|
1
|
+
import { A as BuildControlPlaneMcpConfigOptions, C as InterruptResult, D as SandboxInteractionConflict, E as SandboxInteractionCommandResult, F as SandboxMcpEndpoint, I as SandboxMcpServerEntry, L as buildControlPlaneMcpConfig, M as CONTROL_PLANE_MCP_SERVER_NAME, N as SANDBOX_MCP_SERVER_NAME, O as SandboxInteractionResolution, P as SandboxMcpConfig, R as buildSandboxMcpConfig, S as InteractiveSessionStatus, T as StartInteractiveOptions, _ as InteractiveAttachOptions, a as WorkspaceImagePublishRequestOptions, b as InteractiveSessionHost, c as TraceExportFormat, d as buildTraceExportPayload, f as exportTraceBundle, g as SandboxSession, h as SandboxTaskSession, i as WorkspaceImagePublishInput, j as BuildSandboxMcpConfigOptions, k as SandboxInteractionResult, l as TraceExportResult, m as toOtelJson, o as WorkspaceImagePublishResult, p as otelTraceIdForTangleTrace, r as SandboxInstance, s as WorkspaceImages, t as ForkAcknowledgement, u as TraceExportSink, v as InteractiveAuthFile, w as RespondToPermissionOptions, x as InteractiveSessionInfo, y as InteractiveSessionHandle } from "./sandbox-BpmHeBK1.js";
|
|
2
|
+
import { $ as EnsureDevServerOptions, $i as BatchBackendStats, $n as SandboxCreateOutcome, $r as ScopedToken, $t as IntelligenceReportWindow, Ai as TaskSessionChanges, An as ProvisionStep, Ar as SandboxFleetWorkspaceRestoreResult, At as ForkLookupOptions, B as DownloadOptions, Bi as TokenRefreshHandler, Br as SandboxRuntimeHealth, Bt as GpuLeaseCommandResult, Ci as SnapshotOptions, Cn as ProcessStatus, Cr as SandboxFleetTraceBundle, Ct as FleetExecDispatchOptions, D as CreateIntelligenceReportOptions, Di as StartupOperation, Dn as ProvisionEvent, Dr as SandboxFleetUsage, E as CreateGpuLeaseOptions, Ei as StartupDiagnostics, En as PromptResult, Er as SandboxFleetTraceOptions, Et as FleetPromptDispatchOptions, F as DeleteOptions, Fi as TeeAttestationOptions, Fn as ReapExpiredSandboxFleetsOptions, Fr as SandboxPortBinding, Ft as GitConfig, G as DriverType, Gi as UploadProgress, Gn as RolloutScorer, Gr as SandboxTerminalManager, Gt as GpuLeaseStatus, H as DriveTurnOptions, Hi as TurnDriveResult, Hn as Rollout, Hr as SandboxTerminalAttachOptions, Ht as GpuLeaseExecResult, I as DevServerInfo, Ii as TeeAttestationReport, In as ReapExpiredSandboxFleetsResult, Ir as SandboxPortPreviewLink, It as GitDiff, J as EffectiveBackend, Ji as WaitForRolloutOptions, Jn as RolloutTurnPart, Jr as SandboxTraceBundle, Jt as InstalledTool, K as DurablePlan, Ki as UsageInfo, Kn as RolloutStartResult, Kr as SandboxTerminalRequestOptions, Kt as HostAgentDriverConfig, L as DirectoryPermission, Li as TeeAttestationResponse, Ln as ReconcileSandboxFleetsOptions, Lr as SandboxResourceUsage, Lt as GitStatus, M as CreateSandboxOptions, Mi as TaskSessionFileChange, Mn as PublicTemplateVersionInfo, Mr as SandboxIdentity, Mt as GitAuth, N as CreateSessionOptions, Ni as TaskSessionInfo, Nn as PublishPublicTemplateOptions, Nr as SandboxInfo, Nt as GitBranch, O as CreateRequestOptions, Oi as StorageConfig, On as ProvisionResult, Or as SandboxFleetWorkspace, Ot as ForkCounts, P as CreateTaskSessionOptions, Pi as TaskSessionProfile, Pn as PublishPublicTemplateVersionOptions, Pr as SandboxIntelligenceEnvelope, Pt as GitCommit, Q as EgressPolicy, Qi as WriteManyOptions, Qn as SandboxConnection, Qr as SandboxUser, Qt as IntelligenceReportSubjectType, R as DispatchPromptOptions, Ri as TeePublicKey, Rn as ReconcileSandboxFleetsResult, Rr as SandboxResources, Rt as GpuLease, Si as SnapshotInfo, Sn as ProcessSpawnOptions, Sr as SandboxFleetToken, St as FleetDriveTurnRequest, T as CompletedTurnResult, Tn as PromptOptions, Tr as SandboxFleetTraceExport, Tt as FleetMachineId, U as DriverConfig, Ui as UpdateUserOptions, Un as RolloutChildResult, Ur as SandboxTerminalCreateOptions, Ut as GpuLeaseManager, V as DownloadProgress, Vi as TokenUsage, Vr as SandboxStatus, Vt as GpuLeaseExecOptions, W as DriverInfo, Wi as UploadOptions, Wn as RolloutOptions, Wr as SandboxTerminalInfo, Wt as GpuLeaseProviderName, X as EffectiveBackendSource, Xi as WriteFileOptions, Xn as SSHCredentials, Xr as SandboxTraceExport, Xt as IntelligenceReportBudget, Y as EffectiveBackendProfile, Yi as WorkspaceOperationLookup, Yn as SSHCommandDescriptor, Yr as SandboxTraceEvent, Yt as IntelligenceReport, Z as EgressManager, Zi as WriteManyFile, Zn as SandboxConfig, Zr as SandboxTraceOptions, Zt as IntelligenceReportCompareTo, _ as BranchOptions, _i as SessionResultOptions, _n as ProcessInfo, _r as SandboxFleetMachineSpec, _t as FleetDispatchCancelResult, a as AttachSandboxFleetMachineOptions, aa as BackendType, ai as SendSessionMessageOptions, an as McpServerConfig, ar as SandboxFleetArtifact, at as FileReadBatchOptions, bi as SnapshotDeleteOutcome, bn as ProcessManager, br as SandboxFleetOperationsSummary, bt as FleetDispatchStreamOptions, c as BackendInfo, ca as TerminalExitInfo, ci as SessionBackendCredentials, cn as NetworkConfig, cr as SandboxFleetDispatchFailureClass, ct as FileReadResult, d as BatchBackend, da as TerminalStreamAuthFormat, di as SessionForkOptions, dn as PermissionLevel, dr as SandboxFleetDriverTimings, dt as FileTreeFile, ea as BatchEvent, ei as ScopedTokenScope, er as SandboxCreateReceipt, et as EventStreamOptions, f as BatchResult, fa as TerminalStreamError, fi as SessionInfo, fn as PermissionsManager, fr as SandboxFleetInfo, ft as FileTreeOptions, g as BatchTaskResult, gi as SessionMessageInputPart, gn as Process, gr as SandboxFleetMachineRecord, gt as FileWriteResult, h as BatchTask, ha as TerminalStreamToken, hi as SessionMessage, hn as PreviewLinkWaitOptions, hr as SandboxFleetMachineMeteredUsage, ht as FileUsageResult, i as AttachGpuLeaseOptions, ia as PublicBatchRunRequest, ii as SecretsManager, in as ListSandboxOptions, ir as SandboxEvent, it as FileInfo, j as CreateSandboxFleetWithCoordinatorOptions, ji as TaskSessionCommitResult, jn as PublicTemplateInfo, jr as SandboxFleetWorkspaceSnapshotResult, jt as GPU_LEASE_PROVIDER_NAMES, k as CreateSandboxFleetOptions, ki as SubscriptionInfo, kn as ProvisionStatus, kr as SandboxFleetWorkspaceReconcileResult, kt as ForkIdempotency, l as BackendManager, la as TerminalReadyInfo, li as SessionEventStreamOptions, ln as NetworkManager, lr as SandboxFleetDispatchResponse, lt as FileRenameResult, m as BatchRunRequest, ma as TerminalStreamOptions, mi as SessionListOptions, mn as PreviewLinkManager, mr as SandboxFleetMachine, mt as FileUsageOptions, n as AccessPolicyRule, na as BatchSidecarGroup, ni as SearchOptions, nn as ListOptions, nr as SandboxDeleteOutcome, nt as ExecOptions, o as BackendCapabilities, oa as parseBackendType, oi as SendSessionMessageRequest, on as MintScopedTokenOptions, or as SandboxFleetArtifactSpec, ot as FileReadBatchResult, p as BatchRunOptions, pa as TerminalStreamHandlers, pi as SessionInterruptOptions, pn as PreviewLinkInfo, pr as SandboxFleetIntelligenceEnvelope, pt as FileTreeResult, q as DurablePlanDecisionResult, qi as WaitForOptions, qn as RolloutStatus, qr as SandboxTerminals, qt as HostAgentRuntimeBackend, r as AddUserOptions, ra as BatchTaskUsage, ri as SecretInfo, rn as ListSandboxFleetOptions, rr as SandboxEnvironment, rt as ExecResult, s as BackendConfig, sa as TERMINAL_WS_ECHO_SUBPROTOCOL, si as SentSessionMessage, sn as MkdirOptions, sr as SandboxFleetCostEstimate, st as FileReadError, t as AcceleratorKind, ta as BatchEventDataMap, ti as SearchMatch, tn as ListMessagesOptions, tr as SandboxDeleteAcknowledgement, tt as ExactProcessSpawnOptions, u as BackendStatus, ua as TerminalStream, ui as SessionFailureReason, un as NonHostAgentDriverConfig, ur as SandboxFleetDriverCapability, ut as FileSystem, v as ChunkedUploadOptions, vi as SessionStatus, vn as ProcessListOptions, vr as SandboxFleetManifest, vt as FleetDispatchResultBuffer, w as CommitTaskSessionOptions, wi as SnapshotResult, wn as PromptInputPart, wr as SandboxFleetTraceEvent, xi as SnapshotIdempotency, xn as ProcessSignal, xr as SandboxFleetPolicy, xt as FleetDriveTurnOutcome, y as ChunkedUploadResult, yi as SnapshotDeleteAcknowledgement, yn as ProcessLogEntry, yr as SandboxFleetManifestMachine, yt as FleetDispatchResultBufferOptions, z as DispatchedSession, zi as TeePublicKeyResponse, zn as RenameOptions, zr as SandboxRuntimeCapabilities, zt as GpuLeaseBilling } from "./types-jfr4fgD3.js";
|
|
3
|
+
import { C as isBackendRegistryInteractionKind, S as backendRegistryResponseSchema, T as parseBackendRegistryResponseBody, _ as BackendRegistryInteractionKind, a as Team, b as backendRegistryEntrySchema, c as SessionBroadcastEvent, d as SandboxFleetClient, f as ParseSSEStreamOptions, g as BackendRegistryEntry, h as BackendRegistryCapabilities, i as Sandbox, l as SessionBroadcastResult, m as parseSSEStream, n as IntelligenceClient, o as TeamInvitation, p as ParsedSSEEvent, r as InviteTeamMemberOptions, s as TeamMember, t as CreateTeamOptions, u as SandboxFleet, v as BackendRegistryResponse, w as parseBackendRegistryResponse, x as backendRegistryInteractionKindSchema, y as backendRegistryCapabilitiesSchema } from "./client-CtbXjqd2.js";
|
|
4
4
|
import { d as AnyTokenPayload, h as IssueCollaborationTokenOptions, m as CollaborationTokenPayload, p as CollaborationAccess } from "./index-DtRFVx5U.js";
|
|
5
5
|
import { _ as CollaborationTransportConfig, a as CollaborationClient, c as CollaborationClientConfig, d as CollaborationDocumentRef, f as CollaborationFileBridgeOptions, g as CollaborationTokenRefreshResponse, h as CollaborationTokenRefreshRequest, i as parseCollaborationDocumentId, l as CollaborationDocumentAdapter, m as CollaborationPermissions, n as buildCollaborationDocumentId, o as CollaborationBootstrapRequest, p as CollaborationFileEvent, r as normalizeCollaborationPath, s as CollaborationBootstrapResponse, t as CollaborationFileBridge, u as CollaborationDocumentChange, v as SaveCollaborationSnapshotRequest, y as SaveCollaborationSnapshotResponse } from "./index-Cp1KYanB.js";
|
|
6
6
|
import { a as NetworkError, c as QuotaError, d as SandboxFailureDetail, f as ServerError, h as ValidationError, i as FileWriteConflictError, l as SandboxError, m as TimeoutError, n as CapabilityError, o as NotFoundError, p as StateError, r as EgressProxyRecoveryError, s as PartialFailureError, t as AuthError, u as SandboxErrorJson } from "./errors-Bdy5jXzc.js";
|
|
7
|
-
import { s as TangleSandboxClientConfig, t as TangleSandboxClient } from "./index-
|
|
7
|
+
import { s as TangleSandboxClientConfig, t as TangleSandboxClient } from "./index-DweQWp1c.js";
|
|
8
8
|
import * as _$_tangle_network_agent_interface0 from "@tangle-network/agent-interface";
|
|
9
9
|
import { AgentProfile, AgentProfile as AgentProfile$1, AgentProfileCapabilities, AgentProfileConfidential, AgentProfileConfigValue, AgentProfileConnection, AgentProfileFileMount, AgentProfileFileMount as AgentProfileFileMount$1, AgentProfileMcpServer, AgentProfileModelHints, AgentProfilePermissionValue, AgentProfilePrompt, AgentProfileResourceRef, AgentProfileResources, AgentProfileSecurityPolicy, AgentProfileValidationIssue, AgentProfileValidationResult, AgentRunCancellationAcknowledgement, AgentRunCancellationRequest, AgentSubagentProfile, Capability, SANDBOX_SIZE_PRESET_NAMES, SandboxSizePreset } from "@tangle-network/agent-interface";
|
|
10
10
|
import { z } from "zod";
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ai as TaskSessionChanges, Br as SandboxRuntimeHealth, Fr as SandboxPortBinding, Gi as UploadProgress, Gr as SandboxTerminalManager, Kr as SandboxTerminalRequestOptions, N as CreateSessionOptions, Ni as TaskSessionInfo, P as CreateTaskSessionOptions, Ur as SandboxTerminalCreateOptions, Wr as SandboxTerminalInfo, Xi as WriteFileOptions, ai as SendSessionMessageOptions, at as FileReadBatchOptions, fi as SessionInfo, ft as FileTreeOptions, gt as FileWriteResult, hi as SessionMessage, ht as FileUsageResult, ji as TaskSessionCommitResult, lt as FileRenameResult, mt as FileUsageOptions, oi as SendSessionMessageRequest, ot as FileReadBatchResult, pt as FileTreeResult, si as SentSessionMessage, tn as ListMessagesOptions, v as ChunkedUploadOptions, w as CommitTaskSessionOptions, y as ChunkedUploadResult, zn as RenameOptions } from "./types-
|
|
1
|
+
import { Ai as TaskSessionChanges, Br as SandboxRuntimeHealth, Fr as SandboxPortBinding, Gi as UploadProgress, Gr as SandboxTerminalManager, Kr as SandboxTerminalRequestOptions, N as CreateSessionOptions, Ni as TaskSessionInfo, P as CreateTaskSessionOptions, Ur as SandboxTerminalCreateOptions, Wr as SandboxTerminalInfo, Xi as WriteFileOptions, ai as SendSessionMessageOptions, at as FileReadBatchOptions, fi as SessionInfo, ft as FileTreeOptions, gt as FileWriteResult, hi as SessionMessage, ht as FileUsageResult, ji as TaskSessionCommitResult, lt as FileRenameResult, mt as FileUsageOptions, oi as SendSessionMessageRequest, ot as FileReadBatchResult, pt as FileTreeResult, si as SentSessionMessage, tn as ListMessagesOptions, v as ChunkedUploadOptions, w as CommitTaskSessionOptions, y as ChunkedUploadResult, zn as RenameOptions } from "./types-jfr4fgD3.js";
|
|
2
2
|
import { a as NetworkError, c as QuotaError, d as SandboxFailureDetail, f as ServerError, h as ValidationError, i as FileWriteConflictError, l as SandboxError, m as TimeoutError, n as CapabilityError, o as NotFoundError, p as StateError, s as PartialFailureError, t as AuthError, u as SandboxErrorJson } from "./errors-Bdy5jXzc.js";
|
|
3
3
|
|
|
4
4
|
//#region src/lib/chunked-upload.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $r as ScopedToken, $t as IntelligenceReportWindow, Ai as TaskSessionChanges, At as ForkLookupOptions, Bn as RestoreSnapshotOptions, Br as SandboxRuntimeHealth, Ci as SnapshotOptions, Cr as SandboxFleetTraceBundle, Dn as ProvisionEvent, Ei as StartupDiagnostics, En as PromptResult, Fi as TeeAttestationOptions, Fr as SandboxPortBinding, H as DriveTurnOptions, Hi as TurnDriveResult, Hn as Rollout, Hr as SandboxTerminalAttachOptions, It as GitDiff, Ji as WaitForRolloutOptions, Jr as SandboxTraceBundle, Jt as InstalledTool, K as DurablePlan, Kn as RolloutStartResult, Li as TeeAttestationResponse, Lr as SandboxResourceUsage, Lt as GitStatus, N as CreateSessionOptions, Ni as TaskSessionInfo, Nr as SandboxInfo, Nt as GitBranch, On as ProvisionResult, Ot as ForkCounts, P as CreateTaskSessionOptions, Pt as GitCommit, Qi as WriteManyOptions, Qn as SandboxConnection, R as DispatchPromptOptions, Rt as GpuLease, S as CodeLanguage, Si as SnapshotInfo, T as CompletedTurnResult, Tn as PromptOptions, Ut as GpuLeaseManager, Vn as ResumeOptions, Vr as SandboxStatus, W as DriverInfo, Wn as RolloutOptions, Xi as WriteFileOptions, Xn as SSHCredentials, Xt as IntelligenceReportBudget, Yi as WorkspaceOperationLookup, Yn as SSHCommandDescriptor, Yt as IntelligenceReport, Z as EgressManager, Zi as WriteManyFile, Zr as SandboxTraceOptions, Zt as IntelligenceReportCompareTo, _ as BranchOptions, _i as SessionResultOptions, aa as
|
|
1
|
+
import { $r as ScopedToken, $t as IntelligenceReportWindow, Ai as TaskSessionChanges, At as ForkLookupOptions, Bn as RestoreSnapshotOptions, Br as SandboxRuntimeHealth, Ci as SnapshotOptions, Cr as SandboxFleetTraceBundle, Dn as ProvisionEvent, Ei as StartupDiagnostics, En as PromptResult, Fi as TeeAttestationOptions, Fr as SandboxPortBinding, H as DriveTurnOptions, Hi as TurnDriveResult, Hn as Rollout, Hr as SandboxTerminalAttachOptions, It as GitDiff, Ji as WaitForRolloutOptions, Jr as SandboxTraceBundle, Jt as InstalledTool, K as DurablePlan, Kn as RolloutStartResult, Li as TeeAttestationResponse, Lr as SandboxResourceUsage, Lt as GitStatus, N as CreateSessionOptions, Ni as TaskSessionInfo, Nr as SandboxInfo, Nt as GitBranch, On as ProvisionResult, Ot as ForkCounts, P as CreateTaskSessionOptions, Pt as GitCommit, Qi as WriteManyOptions, Qn as SandboxConnection, R as DispatchPromptOptions, Rt as GpuLease, S as CodeLanguage, Si as SnapshotInfo, T as CompletedTurnResult, Tn as PromptOptions, Ut as GpuLeaseManager, Vn as ResumeOptions, Vr as SandboxStatus, W as DriverInfo, Wn as RolloutOptions, Xi as WriteFileOptions, Xn as SSHCredentials, Xt as IntelligenceReportBudget, Yi as WorkspaceOperationLookup, Yn as SSHCommandDescriptor, Yt as IntelligenceReport, Z as EgressManager, Zi as WriteManyFile, Zr as SandboxTraceOptions, Zt as IntelligenceReportCompareTo, _ as BranchOptions, _i as SessionResultOptions, aa as BackendType, ai as SendSessionMessageOptions, b as CodeExecutionOptions, bn as ProcessManager, di as SessionForkOptions, en as JsonValue, er as SandboxCreateReceipt, et as EventStreamOptions, fi as SessionInfo, fn as PermissionsManager, gt as FileWriteResult, hi as SessionMessage, ir as SandboxEvent, ji as TaskSessionCommitResult, kt as ForkIdempotency, l as BackendManager, li as SessionEventStreamOptions, ln as NetworkManager, mi as SessionListOptions, mn as PreviewLinkManager, ni as SearchOptions, nt as ExecOptions, oi as SendSessionMessageRequest, on as MintScopedTokenOptions, pa as TerminalStreamHandlers, pi as SessionInterruptOptions, q as DurablePlanDecisionResult, qi as WaitForOptions, qr as SandboxTerminals, rt as ExecResult, s as BackendConfig, si as SentSessionMessage, ti as SearchMatch, tn as ListMessagesOptions, tr as SandboxDeleteAcknowledgement, ua as TerminalStream, ut as FileSystem, w as CommitTaskSessionOptions, wi as SnapshotResult, wn as PromptInputPart, x as CodeExecutionResult, yi as SnapshotDeleteAcknowledgement, z as DispatchedSession, zi as TeePublicKeyResponse, zr as SandboxRuntimeCapabilities } from "./types-jfr4fgD3.js";
|
|
2
2
|
import { AgentProfile, AgentRunCancellationAcknowledgement, AgentRunCancellationRequest, InteractionAcknowledgement, InteractionData, InteractionRequest, InteractionResponseCommand } from "@tangle-network/agent-interface";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
package/dist/tangle/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as TANGLE_JOBS_CONTRACT, c as AgentSandboxBlueprintAbi, d as SandboxCreateParamTypes, f as SandboxCreateResponseParamTypes, i as TANGLE_CHAIN_ID, l as ITangleJobsAbi, n as JOB_SANDBOX_CREATE, o as TANGLE_MAINNET_RPC, p as SandboxIdParamTypes, r as JOB_SANDBOX_DELETE, s as TangleSandboxClientConfig, t as TangleSandboxClient, u as JsonResponseParamTypes } from "../index-
|
|
1
|
+
import { a as TANGLE_JOBS_CONTRACT, c as AgentSandboxBlueprintAbi, d as SandboxCreateParamTypes, f as SandboxCreateResponseParamTypes, i as TANGLE_CHAIN_ID, l as ITangleJobsAbi, n as JOB_SANDBOX_CREATE, o as TANGLE_MAINNET_RPC, p as SandboxIdParamTypes, r as JOB_SANDBOX_DELETE, s as TangleSandboxClientConfig, t as TangleSandboxClient, u as JsonResponseParamTypes } from "../index-DweQWp1c.js";
|
|
2
2
|
export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TANGLE_MAINNET_RPC, TangleSandboxClient, TangleSandboxClientConfig };
|
|
@@ -1,6 +1,213 @@
|
|
|
1
1
|
import { AgentExactRunControlRef, AgentProfile, AgentProfileCapabilities, AgentProfileConfidential, AgentProfileValidationResult, HarnessType, ReasoningEffort } from "@tangle-network/agent-interface";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
|
+
//#region src/terminal-stream.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* TerminalStream — typed client for the sandbox terminal WebSocket protocol.
|
|
7
|
+
*
|
|
8
|
+
* Drives a live PTY session (an interactive harness TUI or a plain shell)
|
|
9
|
+
* from the caller's own program: binary frames stream raw PTY output bytes,
|
|
10
|
+
* TEXT JSON frames carry the control protocol. The wire contract is defined
|
|
11
|
+
* by the sidecar in `apps/sidecar/src/terminal/websocket-protocol.ts` (the
|
|
12
|
+
* source of truth for these message shapes — its zod schemas cannot be
|
|
13
|
+
* imported here without pulling sidecar dependencies into the SDK bundle,
|
|
14
|
+
* so the types are mirrored locally):
|
|
15
|
+
*
|
|
16
|
+
* client → server (TEXT JSON):
|
|
17
|
+
* init {connectionId?, cols, rows, command?, cwd?, env?} — MUST be first
|
|
18
|
+
* input {data}
|
|
19
|
+
* resize {cols, rows}
|
|
20
|
+
* server → client (TEXT JSON):
|
|
21
|
+
* ready {connectionId, sessionId, restored, detachTimeoutMs}
|
|
22
|
+
* exit {exitCode?, exitSignal?}
|
|
23
|
+
* error {code, message}
|
|
24
|
+
* rec / rec.done — recording tee frames for the platform's session
|
|
25
|
+
* capture consumer; not part of the client surface
|
|
26
|
+
* server → client (BINARY): raw PTY output bytes
|
|
27
|
+
*
|
|
28
|
+
* Detach/reconnect: the server keeps the PTY alive for `detachTimeoutMs`
|
|
29
|
+
* (5 minutes today) after the socket closes; re-dialing with the SAME
|
|
30
|
+
* connectionId reattaches and replays the buffered output history, so a
|
|
31
|
+
* fresh client repaints the current screen.
|
|
32
|
+
*
|
|
33
|
+
* Browser-safe: uses the global `WebSocket` (browsers, Workers, Node >= 22)
|
|
34
|
+
* and never imports `ws` — the same environment contract as
|
|
35
|
+
* `session-gateway/client.ts`.
|
|
36
|
+
*/
|
|
37
|
+
/** Ready acknowledgement — the PTY is attached and history replay follows. */
|
|
38
|
+
interface TerminalReadyInfo {
|
|
39
|
+
connectionId: string;
|
|
40
|
+
sessionId: string;
|
|
41
|
+
/** True when an existing PTY was reattached (its history is replayed). */
|
|
42
|
+
restored: boolean;
|
|
43
|
+
/** How long (ms) the server keeps the PTY alive after this socket closes. */
|
|
44
|
+
detachTimeoutMs: number;
|
|
45
|
+
}
|
|
46
|
+
/** Terminal process exit notification. */
|
|
47
|
+
interface TerminalExitInfo {
|
|
48
|
+
exitCode?: number;
|
|
49
|
+
exitSignal?: string;
|
|
50
|
+
}
|
|
51
|
+
/** A protocol `error` control frame or a transport failure. */
|
|
52
|
+
declare class TerminalStreamError extends Error {
|
|
53
|
+
/** Protocol error code (e.g. `INIT_FAILED`) or `TRANSPORT` for socket faults. */
|
|
54
|
+
readonly code: string;
|
|
55
|
+
constructor(message: string, code: string);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Event callbacks, passed at construction (the same idiom as
|
|
59
|
+
* `SessionGatewayClient`'s `handlers` config). Registering them up front is
|
|
60
|
+
* load-bearing: the server replays PTY history immediately after `ready`, so
|
|
61
|
+
* a handler attached after connect would miss the replayed screen.
|
|
62
|
+
*/
|
|
63
|
+
interface TerminalStreamHandlers {
|
|
64
|
+
/** Raw PTY output bytes (both live output and reattach history replay). */
|
|
65
|
+
onData?: (data: Uint8Array) => void;
|
|
66
|
+
onReady?: (info: TerminalReadyInfo) => void;
|
|
67
|
+
onExit?: (info: TerminalExitInfo) => void;
|
|
68
|
+
/** Protocol `error` frames and post-connect transport failures. */
|
|
69
|
+
onError?: (error: TerminalStreamError) => void;
|
|
70
|
+
/** Socket closed — by the server, the network, or a local `close()`. */
|
|
71
|
+
onClose?: (code: number, reason: string) => void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Which WebSocket-subprotocol auth envelope to offer. A WebSocket client
|
|
75
|
+
* cannot set an Authorization header, so the bearer rides the
|
|
76
|
+
* `Sec-WebSocket-Protocol` offer — and the two dialable endpoints expect
|
|
77
|
+
* DIFFERENT envelopes:
|
|
78
|
+
*
|
|
79
|
+
* - `"edge"` (default): the public API proxy
|
|
80
|
+
* (`wss://<api>/v1/sidecar-proxy/{sidecarId}/terminals/{id}/ws`) expects
|
|
81
|
+
* `bearer.<base64url(token)>` — see `parseTerminalWsSubprotocolToken` in
|
|
82
|
+
* `products/sandbox/api/src/lib/terminal-websocket.ts`. The fixed
|
|
83
|
+
* `tangle.terminal.v1` marker is offered alongside the credential (see
|
|
84
|
+
* {@link TERMINAL_WS_ECHO_SUBPROTOCOL}).
|
|
85
|
+
* - `"sidecar-direct"`: the sidecar's own `/terminals/{id}/ws` route expects
|
|
86
|
+
* `tangle.bearer.<token>` plus the same `tangle.terminal.v1` echo marker —
|
|
87
|
+
* see `apps/sidecar/src/routes/ws-subprotocol-auth.ts`. Only
|
|
88
|
+
* platform-internal callers (and the composed integration tests) dial the
|
|
89
|
+
* sidecar directly.
|
|
90
|
+
*/
|
|
91
|
+
type TerminalStreamAuthFormat = "edge" | "sidecar-direct";
|
|
92
|
+
/**
|
|
93
|
+
* Bearer credential for the dial: a token string, or a provider invoked on
|
|
94
|
+
* EVERY dial (including {@link TerminalStream.reconnect}). Scoped terminal
|
|
95
|
+
* tokens are short-lived (the platform clamps them to <= 15 minutes), so a
|
|
96
|
+
* reconnect after the detach window with the original string would be
|
|
97
|
+
* rejected — a provider lets the SDK re-mint a fresh token per dial.
|
|
98
|
+
*/
|
|
99
|
+
type TerminalStreamToken = string | (() => Promise<string> | string);
|
|
100
|
+
interface TerminalStreamOptions {
|
|
101
|
+
/**
|
|
102
|
+
* Absolute URL of the terminal WebSocket endpoint. `http(s)` URLs are
|
|
103
|
+
* converted to `ws(s)` automatically.
|
|
104
|
+
*/
|
|
105
|
+
url: string;
|
|
106
|
+
/**
|
|
107
|
+
* Bearer token carried in the auth subprotocol (see `authFormat`) — a
|
|
108
|
+
* string, or a provider re-invoked on every dial so short-lived scoped
|
|
109
|
+
* tokens stay fresh across reconnects.
|
|
110
|
+
*/
|
|
111
|
+
token: TerminalStreamToken;
|
|
112
|
+
/**
|
|
113
|
+
* PTY connection id — also sent in the `init` frame; the server rejects a
|
|
114
|
+
* mismatch with the URL's id. Reusing an id reattaches the existing PTY.
|
|
115
|
+
*/
|
|
116
|
+
connectionId: string;
|
|
117
|
+
cols?: number;
|
|
118
|
+
rows?: number;
|
|
119
|
+
/** Command to run when the id has no live PTY (defaults to the shell). */
|
|
120
|
+
command?: string;
|
|
121
|
+
cwd?: string;
|
|
122
|
+
env?: Record<string, string>;
|
|
123
|
+
/** Auth subprotocol envelope. Default `"edge"`. */
|
|
124
|
+
authFormat?: TerminalStreamAuthFormat;
|
|
125
|
+
handlers?: TerminalStreamHandlers;
|
|
126
|
+
/** Reject `connect()` if `ready` has not arrived within this window. */
|
|
127
|
+
connectTimeoutMs?: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Fixed non-credential marker offered on EVERY dial (both auth formats),
|
|
131
|
+
* giving a spec-compliant server something safe to select into the 101's
|
|
132
|
+
* `Sec-WebSocket-Protocol`. Two reasons it exists:
|
|
133
|
+
*
|
|
134
|
+
* 1. RFC 6455 §4.1 says a client that offered subprotocols MUST fail the
|
|
135
|
+
* connection when the server selects none. Node's WebSocket (undici,
|
|
136
|
+
* per the WHATWG spec) enforces this strictly; browsers are lenient and
|
|
137
|
+
* tolerate a 101 with no selected subprotocol — which is why the
|
|
138
|
+
* browser-only reference client got away with offering just the
|
|
139
|
+
* credential.
|
|
140
|
+
* 2. The server must never echo the token-bearing offer back (that would
|
|
141
|
+
* leak the live credential into a response header) — so it needs a
|
|
142
|
+
* non-credential protocol it CAN select.
|
|
143
|
+
*/
|
|
144
|
+
declare const TERMINAL_WS_ECHO_SUBPROTOCOL = "tangle.terminal.v1";
|
|
145
|
+
/**
|
|
146
|
+
* Client for one terminal WebSocket connection. Construct via
|
|
147
|
+
* {@link TerminalStream.connect}, which resolves once the server
|
|
148
|
+
* acknowledges the attach with `ready` (history replay then streams through
|
|
149
|
+
* `handlers.onData`).
|
|
150
|
+
*/
|
|
151
|
+
declare class TerminalStream {
|
|
152
|
+
private readonly ws;
|
|
153
|
+
private readonly options;
|
|
154
|
+
private readonly handlers;
|
|
155
|
+
private readyInfo;
|
|
156
|
+
private closed;
|
|
157
|
+
private closeWaiters;
|
|
158
|
+
private readonly textDecoder;
|
|
159
|
+
/**
|
|
160
|
+
* Dial the endpoint, send `init` as the first frame, and resolve once the
|
|
161
|
+
* server responds `ready`. Rejects on a protocol `error` frame, a socket
|
|
162
|
+
* close/failure before `ready`, or the connect timeout — always with the
|
|
163
|
+
* reason the server gave. A token PROVIDER is awaited here, before the
|
|
164
|
+
* socket opens, so every dial (first connect and each reconnect) carries a
|
|
165
|
+
* fresh credential.
|
|
166
|
+
*/
|
|
167
|
+
static connect(options: TerminalStreamOptions): Promise<TerminalStream>;
|
|
168
|
+
private constructor();
|
|
169
|
+
private establish;
|
|
170
|
+
private handleMessage;
|
|
171
|
+
/** PTY connection id this stream is attached to. */
|
|
172
|
+
get connectionId(): string;
|
|
173
|
+
/** The server's `ready` acknowledgement. Set once `connect()` resolves. */
|
|
174
|
+
get ready(): TerminalReadyInfo;
|
|
175
|
+
/** True while the socket is open. */
|
|
176
|
+
get isOpen(): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Send input keystrokes to the PTY. `Uint8Array` input is decoded as
|
|
179
|
+
* UTF-8 (the wire protocol carries input as JSON text). Input larger than
|
|
180
|
+
* the server's 1 MiB frame cap is split across multiple `input` frames in
|
|
181
|
+
* order on the same socket, so delivery order is preserved.
|
|
182
|
+
*/
|
|
183
|
+
write(data: string | Uint8Array): void;
|
|
184
|
+
/** Resize the PTY. */
|
|
185
|
+
resize(cols: number, rows: number): void;
|
|
186
|
+
/**
|
|
187
|
+
* Detach cleanly: close the socket and resolve once the close completes.
|
|
188
|
+
* The PTY survives server-side for `ready.detachTimeoutMs` (5 minutes
|
|
189
|
+
* today) — reattach within that window via {@link reconnect} (or a fresh
|
|
190
|
+
* `connect()` with the same connectionId) to replay history and continue.
|
|
191
|
+
*/
|
|
192
|
+
close(): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Re-dial the same endpoint with the same connectionId on a fresh socket
|
|
195
|
+
* — the server reattaches the PTY and replays its buffered history. When
|
|
196
|
+
* the stream was constructed with a token PROVIDER, it is re-invoked for
|
|
197
|
+
* the new dial (scoped terminal tokens expire within minutes, so the
|
|
198
|
+
* original credential may be dead by reconnect time); with a plain string
|
|
199
|
+
* token, pass a fresh `token` override yourself when it may have expired.
|
|
200
|
+
* `handlers` rebinds callbacks for the new stream.
|
|
201
|
+
*/
|
|
202
|
+
reconnect(overrides?: {
|
|
203
|
+
token?: TerminalStreamToken;
|
|
204
|
+
handlers?: TerminalStreamHandlers;
|
|
205
|
+
cols?: number;
|
|
206
|
+
rows?: number;
|
|
207
|
+
}): Promise<TerminalStream>;
|
|
208
|
+
private assertOpen;
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
4
211
|
//#region ../../../packages/runtime-contracts/dist/backend-types.d.ts
|
|
5
212
|
/**
|
|
6
213
|
* Canonical harnesses this repo ships no provider adapter for.
|
|
@@ -1130,213 +1337,6 @@ interface BatchResult$1 {
|
|
|
1130
1337
|
};
|
|
1131
1338
|
}
|
|
1132
1339
|
//#endregion
|
|
1133
|
-
//#region src/terminal-stream.d.ts
|
|
1134
|
-
/**
|
|
1135
|
-
* TerminalStream — typed client for the sandbox terminal WebSocket protocol.
|
|
1136
|
-
*
|
|
1137
|
-
* Drives a live PTY session (an interactive harness TUI or a plain shell)
|
|
1138
|
-
* from the caller's own program: binary frames stream raw PTY output bytes,
|
|
1139
|
-
* TEXT JSON frames carry the control protocol. The wire contract is defined
|
|
1140
|
-
* by the sidecar in `apps/sidecar/src/terminal/websocket-protocol.ts` (the
|
|
1141
|
-
* source of truth for these message shapes — its zod schemas cannot be
|
|
1142
|
-
* imported here without pulling sidecar dependencies into the SDK bundle,
|
|
1143
|
-
* so the types are mirrored locally):
|
|
1144
|
-
*
|
|
1145
|
-
* client → server (TEXT JSON):
|
|
1146
|
-
* init {connectionId?, cols, rows, command?, cwd?, env?} — MUST be first
|
|
1147
|
-
* input {data}
|
|
1148
|
-
* resize {cols, rows}
|
|
1149
|
-
* server → client (TEXT JSON):
|
|
1150
|
-
* ready {connectionId, sessionId, restored, detachTimeoutMs}
|
|
1151
|
-
* exit {exitCode?, exitSignal?}
|
|
1152
|
-
* error {code, message}
|
|
1153
|
-
* rec / rec.done — recording tee frames for the platform's session
|
|
1154
|
-
* capture consumer; not part of the client surface
|
|
1155
|
-
* server → client (BINARY): raw PTY output bytes
|
|
1156
|
-
*
|
|
1157
|
-
* Detach/reconnect: the server keeps the PTY alive for `detachTimeoutMs`
|
|
1158
|
-
* (5 minutes today) after the socket closes; re-dialing with the SAME
|
|
1159
|
-
* connectionId reattaches and replays the buffered output history, so a
|
|
1160
|
-
* fresh client repaints the current screen.
|
|
1161
|
-
*
|
|
1162
|
-
* Browser-safe: uses the global `WebSocket` (browsers, Workers, Node >= 22)
|
|
1163
|
-
* and never imports `ws` — the same environment contract as
|
|
1164
|
-
* `session-gateway/client.ts`.
|
|
1165
|
-
*/
|
|
1166
|
-
/** Ready acknowledgement — the PTY is attached and history replay follows. */
|
|
1167
|
-
interface TerminalReadyInfo {
|
|
1168
|
-
connectionId: string;
|
|
1169
|
-
sessionId: string;
|
|
1170
|
-
/** True when an existing PTY was reattached (its history is replayed). */
|
|
1171
|
-
restored: boolean;
|
|
1172
|
-
/** How long (ms) the server keeps the PTY alive after this socket closes. */
|
|
1173
|
-
detachTimeoutMs: number;
|
|
1174
|
-
}
|
|
1175
|
-
/** Terminal process exit notification. */
|
|
1176
|
-
interface TerminalExitInfo {
|
|
1177
|
-
exitCode?: number;
|
|
1178
|
-
exitSignal?: string;
|
|
1179
|
-
}
|
|
1180
|
-
/** A protocol `error` control frame or a transport failure. */
|
|
1181
|
-
declare class TerminalStreamError extends Error {
|
|
1182
|
-
/** Protocol error code (e.g. `INIT_FAILED`) or `TRANSPORT` for socket faults. */
|
|
1183
|
-
readonly code: string;
|
|
1184
|
-
constructor(message: string, code: string);
|
|
1185
|
-
}
|
|
1186
|
-
/**
|
|
1187
|
-
* Event callbacks, passed at construction (the same idiom as
|
|
1188
|
-
* `SessionGatewayClient`'s `handlers` config). Registering them up front is
|
|
1189
|
-
* load-bearing: the server replays PTY history immediately after `ready`, so
|
|
1190
|
-
* a handler attached after connect would miss the replayed screen.
|
|
1191
|
-
*/
|
|
1192
|
-
interface TerminalStreamHandlers {
|
|
1193
|
-
/** Raw PTY output bytes (both live output and reattach history replay). */
|
|
1194
|
-
onData?: (data: Uint8Array) => void;
|
|
1195
|
-
onReady?: (info: TerminalReadyInfo) => void;
|
|
1196
|
-
onExit?: (info: TerminalExitInfo) => void;
|
|
1197
|
-
/** Protocol `error` frames and post-connect transport failures. */
|
|
1198
|
-
onError?: (error: TerminalStreamError) => void;
|
|
1199
|
-
/** Socket closed — by the server, the network, or a local `close()`. */
|
|
1200
|
-
onClose?: (code: number, reason: string) => void;
|
|
1201
|
-
}
|
|
1202
|
-
/**
|
|
1203
|
-
* Which WebSocket-subprotocol auth envelope to offer. A WebSocket client
|
|
1204
|
-
* cannot set an Authorization header, so the bearer rides the
|
|
1205
|
-
* `Sec-WebSocket-Protocol` offer — and the two dialable endpoints expect
|
|
1206
|
-
* DIFFERENT envelopes:
|
|
1207
|
-
*
|
|
1208
|
-
* - `"edge"` (default): the public API proxy
|
|
1209
|
-
* (`wss://<api>/v1/sidecar-proxy/{sidecarId}/terminals/{id}/ws`) expects
|
|
1210
|
-
* `bearer.<base64url(token)>` — see `parseTerminalWsSubprotocolToken` in
|
|
1211
|
-
* `products/sandbox/api/src/lib/terminal-websocket.ts`. The fixed
|
|
1212
|
-
* `tangle.terminal.v1` marker is offered alongside the credential (see
|
|
1213
|
-
* {@link TERMINAL_WS_ECHO_SUBPROTOCOL}).
|
|
1214
|
-
* - `"sidecar-direct"`: the sidecar's own `/terminals/{id}/ws` route expects
|
|
1215
|
-
* `tangle.bearer.<token>` plus the same `tangle.terminal.v1` echo marker —
|
|
1216
|
-
* see `apps/sidecar/src/routes/ws-subprotocol-auth.ts`. Only
|
|
1217
|
-
* platform-internal callers (and the composed integration tests) dial the
|
|
1218
|
-
* sidecar directly.
|
|
1219
|
-
*/
|
|
1220
|
-
type TerminalStreamAuthFormat = "edge" | "sidecar-direct";
|
|
1221
|
-
/**
|
|
1222
|
-
* Bearer credential for the dial: a token string, or a provider invoked on
|
|
1223
|
-
* EVERY dial (including {@link TerminalStream.reconnect}). Scoped terminal
|
|
1224
|
-
* tokens are short-lived (the platform clamps them to <= 15 minutes), so a
|
|
1225
|
-
* reconnect after the detach window with the original string would be
|
|
1226
|
-
* rejected — a provider lets the SDK re-mint a fresh token per dial.
|
|
1227
|
-
*/
|
|
1228
|
-
type TerminalStreamToken = string | (() => Promise<string> | string);
|
|
1229
|
-
interface TerminalStreamOptions {
|
|
1230
|
-
/**
|
|
1231
|
-
* Absolute URL of the terminal WebSocket endpoint. `http(s)` URLs are
|
|
1232
|
-
* converted to `ws(s)` automatically.
|
|
1233
|
-
*/
|
|
1234
|
-
url: string;
|
|
1235
|
-
/**
|
|
1236
|
-
* Bearer token carried in the auth subprotocol (see `authFormat`) — a
|
|
1237
|
-
* string, or a provider re-invoked on every dial so short-lived scoped
|
|
1238
|
-
* tokens stay fresh across reconnects.
|
|
1239
|
-
*/
|
|
1240
|
-
token: TerminalStreamToken;
|
|
1241
|
-
/**
|
|
1242
|
-
* PTY connection id — also sent in the `init` frame; the server rejects a
|
|
1243
|
-
* mismatch with the URL's id. Reusing an id reattaches the existing PTY.
|
|
1244
|
-
*/
|
|
1245
|
-
connectionId: string;
|
|
1246
|
-
cols?: number;
|
|
1247
|
-
rows?: number;
|
|
1248
|
-
/** Command to run when the id has no live PTY (defaults to the shell). */
|
|
1249
|
-
command?: string;
|
|
1250
|
-
cwd?: string;
|
|
1251
|
-
env?: Record<string, string>;
|
|
1252
|
-
/** Auth subprotocol envelope. Default `"edge"`. */
|
|
1253
|
-
authFormat?: TerminalStreamAuthFormat;
|
|
1254
|
-
handlers?: TerminalStreamHandlers;
|
|
1255
|
-
/** Reject `connect()` if `ready` has not arrived within this window. */
|
|
1256
|
-
connectTimeoutMs?: number;
|
|
1257
|
-
}
|
|
1258
|
-
/**
|
|
1259
|
-
* Fixed non-credential marker offered on EVERY dial (both auth formats),
|
|
1260
|
-
* giving a spec-compliant server something safe to select into the 101's
|
|
1261
|
-
* `Sec-WebSocket-Protocol`. Two reasons it exists:
|
|
1262
|
-
*
|
|
1263
|
-
* 1. RFC 6455 §4.1 says a client that offered subprotocols MUST fail the
|
|
1264
|
-
* connection when the server selects none. Node's WebSocket (undici,
|
|
1265
|
-
* per the WHATWG spec) enforces this strictly; browsers are lenient and
|
|
1266
|
-
* tolerate a 101 with no selected subprotocol — which is why the
|
|
1267
|
-
* browser-only reference client got away with offering just the
|
|
1268
|
-
* credential.
|
|
1269
|
-
* 2. The server must never echo the token-bearing offer back (that would
|
|
1270
|
-
* leak the live credential into a response header) — so it needs a
|
|
1271
|
-
* non-credential protocol it CAN select.
|
|
1272
|
-
*/
|
|
1273
|
-
declare const TERMINAL_WS_ECHO_SUBPROTOCOL = "tangle.terminal.v1";
|
|
1274
|
-
/**
|
|
1275
|
-
* Client for one terminal WebSocket connection. Construct via
|
|
1276
|
-
* {@link TerminalStream.connect}, which resolves once the server
|
|
1277
|
-
* acknowledges the attach with `ready` (history replay then streams through
|
|
1278
|
-
* `handlers.onData`).
|
|
1279
|
-
*/
|
|
1280
|
-
declare class TerminalStream {
|
|
1281
|
-
private readonly ws;
|
|
1282
|
-
private readonly options;
|
|
1283
|
-
private readonly handlers;
|
|
1284
|
-
private readyInfo;
|
|
1285
|
-
private closed;
|
|
1286
|
-
private closeWaiters;
|
|
1287
|
-
private readonly textDecoder;
|
|
1288
|
-
/**
|
|
1289
|
-
* Dial the endpoint, send `init` as the first frame, and resolve once the
|
|
1290
|
-
* server responds `ready`. Rejects on a protocol `error` frame, a socket
|
|
1291
|
-
* close/failure before `ready`, or the connect timeout — always with the
|
|
1292
|
-
* reason the server gave. A token PROVIDER is awaited here, before the
|
|
1293
|
-
* socket opens, so every dial (first connect and each reconnect) carries a
|
|
1294
|
-
* fresh credential.
|
|
1295
|
-
*/
|
|
1296
|
-
static connect(options: TerminalStreamOptions): Promise<TerminalStream>;
|
|
1297
|
-
private constructor();
|
|
1298
|
-
private establish;
|
|
1299
|
-
private handleMessage;
|
|
1300
|
-
/** PTY connection id this stream is attached to. */
|
|
1301
|
-
get connectionId(): string;
|
|
1302
|
-
/** The server's `ready` acknowledgement. Set once `connect()` resolves. */
|
|
1303
|
-
get ready(): TerminalReadyInfo;
|
|
1304
|
-
/** True while the socket is open. */
|
|
1305
|
-
get isOpen(): boolean;
|
|
1306
|
-
/**
|
|
1307
|
-
* Send input keystrokes to the PTY. `Uint8Array` input is decoded as
|
|
1308
|
-
* UTF-8 (the wire protocol carries input as JSON text). Input larger than
|
|
1309
|
-
* the server's 1 MiB frame cap is split across multiple `input` frames in
|
|
1310
|
-
* order on the same socket, so delivery order is preserved.
|
|
1311
|
-
*/
|
|
1312
|
-
write(data: string | Uint8Array): void;
|
|
1313
|
-
/** Resize the PTY. */
|
|
1314
|
-
resize(cols: number, rows: number): void;
|
|
1315
|
-
/**
|
|
1316
|
-
* Detach cleanly: close the socket and resolve once the close completes.
|
|
1317
|
-
* The PTY survives server-side for `ready.detachTimeoutMs` (5 minutes
|
|
1318
|
-
* today) — reattach within that window via {@link reconnect} (or a fresh
|
|
1319
|
-
* `connect()` with the same connectionId) to replay history and continue.
|
|
1320
|
-
*/
|
|
1321
|
-
close(): Promise<void>;
|
|
1322
|
-
/**
|
|
1323
|
-
* Re-dial the same endpoint with the same connectionId on a fresh socket
|
|
1324
|
-
* — the server reattaches the PTY and replays its buffered history. When
|
|
1325
|
-
* the stream was constructed with a token PROVIDER, it is re-invoked for
|
|
1326
|
-
* the new dial (scoped terminal tokens expire within minutes, so the
|
|
1327
|
-
* original credential may be dead by reconnect time); with a plain string
|
|
1328
|
-
* token, pass a fresh `token` override yourself when it may have expired.
|
|
1329
|
-
* `handlers` rebinds callbacks for the new stream.
|
|
1330
|
-
*/
|
|
1331
|
-
reconnect(overrides?: {
|
|
1332
|
-
token?: TerminalStreamToken;
|
|
1333
|
-
handlers?: TerminalStreamHandlers;
|
|
1334
|
-
cols?: number;
|
|
1335
|
-
rows?: number;
|
|
1336
|
-
}): Promise<TerminalStream>;
|
|
1337
|
-
private assertOpen;
|
|
1338
|
-
}
|
|
1339
|
-
//#endregion
|
|
1340
1340
|
//#region src/types.d.ts
|
|
1341
1341
|
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
1342
1342
|
[key: string]: JsonValue;
|
|
@@ -6421,4 +6421,4 @@ interface CodeExecutionOptions {
|
|
|
6421
6421
|
idempotencyKey?: string;
|
|
6422
6422
|
}
|
|
6423
6423
|
//#endregion
|
|
6424
|
-
export { EnsureDevServerOptions as $,
|
|
6424
|
+
export { EnsureDevServerOptions as $, BatchBackendStats as $i, SandboxCreateOutcome as $n, ScopedToken as $r, IntelligenceReportWindow as $t, CreateSandboxFleetTokenOptions as A, TaskSessionChanges as Ai, ProvisionStep as An, SandboxFleetWorkspaceRestoreResult as Ar, ForkLookupOptions as At, DownloadOptions as B, TokenRefreshHandler as Bi, RestoreSnapshotOptions as Bn, SandboxRuntimeHealth as Br, GpuLeaseCommandResult as Bt, CodeResultPart as C, SnapshotOptions as Ci, ProcessStatus as Cn, SandboxFleetTraceBundle as Cr, FleetExecDispatchOptions as Ct, CreateIntelligenceReportOptions as D, StartupOperation as Di, ProvisionEvent as Dn, SandboxFleetUsage as Dr, FleetPromptDispatchResult as Dt, CreateGpuLeaseOptions as E, StartupDiagnostics as Ei, PromptResult as En, SandboxFleetTraceOptions as Er, FleetPromptDispatchOptions as Et, DeleteOptions as F, TeeAttestationOptions as Fi, ReapExpiredSandboxFleetsOptions as Fn, SandboxPortBinding as Fr, GitConfig as Ft, DriverType as G, UploadProgress as Gi, RolloutScorer as Gn, SandboxTerminalManager as Gr, GpuLeaseStatus as Gt, DriveTurnOptions as H, TurnDriveResult as Hi, Rollout as Hn, SandboxTerminalAttachOptions as Hr, GpuLeaseExecResult as Ht, DevServerInfo as I, TeeAttestationReport as Ii, ReapExpiredSandboxFleetsResult as In, SandboxPortPreviewLink as Ir, GitDiff as It, EffectiveBackend as J, WaitForRolloutOptions as Ji, RolloutTurnPart as Jn, SandboxTraceBundle as Jr, InstalledTool as Jt, DurablePlan as K, UsageInfo as Ki, RolloutStartResult as Kn, SandboxTerminalRequestOptions as Kr, HostAgentDriverConfig as Kt, DirectoryPermission as L, TeeAttestationResponse as Li, ReconcileSandboxFleetsOptions as Ln, SandboxResourceUsage as Lr, GitStatus as Lt, CreateSandboxOptions as M, TaskSessionFileChange as Mi, PublicTemplateVersionInfo as Mn, SandboxIdentity as Mr, GitAuth as Mt, CreateSessionOptions as N, TaskSessionInfo as Ni, PublishPublicTemplateOptions as Nn, SandboxInfo as Nr, GitBranch as Nt, CreateRequestOptions as O, StorageConfig as Oi, ProvisionResult as On, SandboxFleetWorkspace as Or, ForkCounts as Ot, CreateTaskSessionOptions as P, TaskSessionProfile as Pi, PublishPublicTemplateVersionOptions as Pn, SandboxIntelligenceEnvelope as Pr, GitCommit as Pt, EgressPolicy as Q, WriteManyOptions as Qi, SandboxConnection as Qn, SandboxUser as Qr, IntelligenceReportSubjectType as Qt, DispatchPromptOptions as R, TeePublicKey as Ri, ReconcileSandboxFleetsResult as Rn, SandboxResources as Rr, GpuLease as Rt, CodeLanguage as S, SnapshotInfo as Si, ProcessSpawnOptions as Sn, SandboxFleetToken as Sr, FleetDriveTurnRequest as St, CompletedTurnResult as T, SshKeysManager as Ti, PromptOptions as Tn, SandboxFleetTraceExport as Tr, FleetMachineId as Tt, DriverConfig as U, UpdateUserOptions as Ui, RolloutChildResult as Un, SandboxTerminalCreateOptions as Ur, GpuLeaseManager as Ut, DownloadProgress as V, TokenUsage as Vi, ResumeOptions as Vn, SandboxStatus as Vr, GpuLeaseExecOptions as Vt, DriverInfo as W, UploadOptions as Wi, RolloutOptions as Wn, SandboxTerminalInfo as Wr, GpuLeaseProviderName as Wt, EffectiveBackendSource as X, WriteFileOptions as Xi, SSHCredentials as Xn, SandboxTraceExport as Xr, IntelligenceReportBudget as Xt, EffectiveBackendProfile as Y, WorkspaceOperationLookup as Yi, SSHCommandDescriptor as Yn, SandboxTraceEvent as Yr, IntelligenceReport as Yt, EgressManager as Z, WriteManyFile as Zi, SandboxConfig as Zn, SandboxTraceOptions as Zr, IntelligenceReportCompareTo as Zt, BranchOptions as _, SessionResultOptions as _i, ProcessInfo as _n, SandboxFleetMachineSpec as _r, FleetDispatchCancelResult as _t, AttachSandboxFleetMachineOptions as a, BackendType as aa, SendSessionMessageOptions as ai, McpServerConfig as an, SandboxFleetArtifact as ar, FileReadBatchOptions as at, CodeExecutionOptions as b, SnapshotDeleteOutcome as bi, ProcessManager as bn, SandboxFleetOperationsSummary as br, FleetDispatchStreamOptions as bt, BackendInfo as c, TerminalExitInfo as ca, SessionBackendCredentials as ci, NetworkConfig as cn, SandboxFleetDispatchFailureClass as cr, FileReadResult as ct, BatchBackend as d, TerminalStreamAuthFormat as da, SessionForkOptions as di, PermissionLevel as dn, SandboxFleetDriverTimings as dr, FileTreeFile as dt, BatchEvent as ea, ScopedTokenScope as ei, JsonValue as en, SandboxCreateReceipt as er, EventStreamOptions as et, BatchResult as f, TerminalStreamError as fa, SessionInfo as fi, PermissionsManager as fn, SandboxFleetInfo as fr, FileTreeOptions as ft, BatchTaskResult as g, SessionMessageInputPart as gi, Process as gn, SandboxFleetMachineRecord as gr, FileWriteResult as gt, BatchTask as h, TerminalStreamToken as ha, SessionMessage as hi, PreviewLinkWaitOptions as hn, SandboxFleetMachineMeteredUsage as hr, FileUsageResult as ht, AttachGpuLeaseOptions as i, PublicBatchRunRequest as ia, SecretsManager as ii, ListSandboxOptions as in, SandboxEvent as ir, FileInfo as it, CreateSandboxFleetWithCoordinatorOptions as j, TaskSessionCommitResult as ji, PublicTemplateInfo as jn, SandboxFleetWorkspaceSnapshotResult as jr, GPU_LEASE_PROVIDER_NAMES as jt, CreateSandboxFleetOptions as k, SubscriptionInfo as ki, ProvisionStatus as kn, SandboxFleetWorkspaceReconcileResult as kr, ForkIdempotency as kt, BackendManager as l, TerminalReadyInfo as la, SessionEventStreamOptions as li, NetworkManager as ln, SandboxFleetDispatchResponse as lr, FileRenameResult as lt, BatchRunRequest as m, TerminalStreamOptions as ma, SessionListOptions as mi, PreviewLinkManager as mn, SandboxFleetMachine as mr, FileUsageOptions as mt, AccessPolicyRule as n, BatchSidecarGroup as na, SearchOptions as ni, ListOptions as nn, SandboxDeleteOutcome as nr, ExecOptions as nt, BackendCapabilities as o, parseBackendType as oa, SendSessionMessageRequest as oi, MintScopedTokenOptions as on, SandboxFleetArtifactSpec as or, FileReadBatchResult as ot, BatchRunOptions as p, TerminalStreamHandlers as pa, SessionInterruptOptions as pi, PreviewLinkInfo as pn, SandboxFleetIntelligenceEnvelope as pr, FileTreeResult as pt, DurablePlanDecisionResult as q, WaitForOptions as qi, RolloutStatus as qn, SandboxTerminals as qr, HostAgentRuntimeBackend as qt, AddUserOptions as r, BatchTaskUsage as ra, SecretInfo as ri, ListSandboxFleetOptions as rn, SandboxEnvironment as rr, ExecResult as rt, BackendConfig as s, TERMINAL_WS_ECHO_SUBPROTOCOL as sa, SentSessionMessage as si, MkdirOptions as sn, SandboxFleetCostEstimate as sr, FileReadError as st, AcceleratorKind as t, BatchEventDataMap as ta, SearchMatch as ti, ListMessagesOptions as tn, SandboxDeleteAcknowledgement as tr, ExactProcessSpawnOptions as tt, BackendStatus as u, TerminalStream as ua, SessionFailureReason as ui, NonHostAgentDriverConfig as un, SandboxFleetDriverCapability as ur, FileSystem as ut, ChunkedUploadOptions as v, SessionStatus as vi, ProcessListOptions as vn, SandboxFleetManifest as vr, FleetDispatchResultBuffer as vt, CommitTaskSessionOptions as w, SnapshotResult as wi, PromptInputPart as wn, SandboxFleetTraceEvent as wr, FleetExecDispatchResult as wt, CodeExecutionResult as x, SnapshotIdempotency as xi, ProcessSignal as xn, SandboxFleetPolicy as xr, FleetDriveTurnOutcome as xt, ChunkedUploadResult as y, SnapshotDeleteAcknowledgement as yi, ProcessLogEntry as yn, SandboxFleetManifestMachine as yr, FleetDispatchResultBufferOptions as yt, DispatchedSession as z, TeePublicKeyResponse as zi, RenameOptions as zn, SandboxRuntimeCapabilities as zr, GpuLeaseBilling as zt };
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/sandbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0-develop.20260819001319.32159f4",
|
|
4
4
|
"description": "Client SDK for the Tangle Sandbox platform - build AI agent applications with dev containers",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"./dist/agent/index.js"
|
|
8
|
+
],
|
|
6
9
|
"main": "./dist/index.js",
|
|
7
10
|
"types": "./dist/index.d.ts",
|
|
8
11
|
"exports": {
|