withruntime 0.4.0 → 0.5.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/DAYTONA.md +129 -0
- package/E2B.md +3 -3
- package/README.md +47 -9
- package/VERCEL.md +127 -0
- package/dist/ai/index.d.ts +33 -0
- package/dist/ai/index.js +38 -0
- package/dist/claude-agent-sdk/index.d.ts +7 -0
- package/dist/claude-agent-sdk/index.js +65 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +959 -102
- package/dist/client.d.ts +25 -2
- package/dist/client.js +14 -1
- package/dist/credentials.d.ts +10 -0
- package/dist/credentials.js +56 -1
- package/dist/daytona/client.d.ts +44 -0
- package/dist/daytona/client.js +40 -0
- package/dist/daytona/context.d.ts +31 -0
- package/dist/daytona/context.js +25 -0
- package/dist/daytona/daytona.d.ts +185 -0
- package/dist/daytona/daytona.js +416 -0
- package/dist/daytona/errors.d.ts +106 -0
- package/dist/daytona/errors.js +182 -0
- package/dist/daytona/filesystem.d.ts +84 -0
- package/dist/daytona/filesystem.js +206 -0
- package/dist/daytona/git.d.ts +33 -0
- package/dist/daytona/git.js +128 -0
- package/dist/daytona/image.d.ts +45 -0
- package/dist/daytona/image.js +140 -0
- package/dist/daytona/index.d.ts +50 -0
- package/dist/daytona/index.js +50 -0
- package/dist/daytona/process.d.ts +86 -0
- package/dist/daytona/process.js +341 -0
- package/dist/daytona/sandbox.d.ts +196 -0
- package/dist/daytona/sandbox.js +448 -0
- package/dist/e2b/commands.js +6 -2
- package/dist/e2b/sandbox.d.ts +22 -2
- package/dist/e2b/sandbox.js +39 -7
- package/dist/errors.d.ts +10 -4
- package/dist/errors.js +26 -6
- package/dist/image-context.d.ts +39 -0
- package/dist/image-context.js +176 -0
- package/dist/index.d.ts +19 -2
- package/dist/index.js +17 -2
- package/dist/keys.d.ts +43 -0
- package/dist/keys.js +196 -0
- package/dist/login.js +14 -2
- package/dist/openai-agents/index.d.ts +132 -0
- package/dist/openai-agents/index.js +791 -0
- package/dist/products/audit.d.ts +48 -0
- package/dist/products/audit.js +10 -0
- package/dist/products/images.d.ts +113 -7
- package/dist/products/images.js +186 -27
- package/dist/products/index.d.ts +11 -0
- package/dist/products/index.js +17 -1
- package/dist/products/observability.d.ts +186 -0
- package/dist/products/observability.js +117 -0
- package/dist/products/secrets.d.ts +40 -0
- package/dist/products/secrets.js +24 -0
- package/dist/products/switching.d.ts +96 -0
- package/dist/products/switching.js +25 -0
- package/dist/sandbox.d.ts +26 -1
- package/dist/sandbox.js +101 -1
- package/dist/ssh.d.ts +21 -0
- package/dist/ssh.js +324 -0
- package/dist/tar.d.ts +1 -0
- package/dist/tar.js +4 -4
- package/dist/tools/index.d.ts +62 -0
- package/dist/tools/index.js +180 -0
- package/dist/transport.d.ts +12 -2
- package/dist/transport.js +31 -4
- package/dist/tunnel.d.ts +70 -0
- package/dist/tunnel.js +316 -0
- package/dist/types.d.ts +57 -1
- package/dist/vercel/client.d.ts +40 -0
- package/dist/vercel/client.js +39 -0
- package/dist/vercel/command.d.ts +70 -0
- package/dist/vercel/command.js +148 -0
- package/dist/vercel/errors.d.ts +53 -0
- package/dist/vercel/errors.js +113 -0
- package/dist/vercel/filesystem.d.ts +150 -0
- package/dist/vercel/filesystem.js +248 -0
- package/dist/vercel/index.d.ts +30 -0
- package/dist/vercel/index.js +38 -0
- package/dist/vercel/sandbox.d.ts +317 -0
- package/dist/vercel/sandbox.js +726 -0
- package/dist/vercel/snapshot.d.ts +93 -0
- package/dist/vercel/snapshot.js +123 -0
- package/package.json +56 -4
package/dist/keys.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { generateKeyPair, privateDecrypt } from "node:crypto";
|
|
3
|
+
import { hostname } from "node:os";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { connectionOrigins } from "./credentials.js";
|
|
6
|
+
import { RuntimeError } from "./errors.js";
|
|
7
|
+
import { named } from "./login.js";
|
|
8
|
+
import { describeRoute, envFetch } from "./proxy.js";
|
|
9
|
+
const KEY = /^rtcloud_([a-f0-9-]{36})_[A-Za-z0-9_-]{43}$/;
|
|
10
|
+
/** How often to ask whether the owner has answered. The website answers
|
|
11
|
+
* "pending" to anything faster than every 4.5 seconds. */
|
|
12
|
+
const POLL_MS = 5000;
|
|
13
|
+
/** Whole microdollars from a daily limit typed in dollars ("25", "7.5",
|
|
14
|
+
* "$1,000.10"), read as digits rather than through a float, from $0.01 to
|
|
15
|
+
* $1,000,000: the keys page's own rule (apps/cloud-web/src/app/account/keys/limit.ts). */
|
|
16
|
+
export function dailyLimitMicros(typed) {
|
|
17
|
+
const text = typed.trim().replace(/^\$/, "").replace(/,/g, "");
|
|
18
|
+
const parts = text.match(/^(\d{1,7})(?:\.(\d{1,2}))?$/);
|
|
19
|
+
const cents = parts ? Number(parts[1]) * 100 + Number((parts[2] ?? "").padEnd(2, "0")) : 0;
|
|
20
|
+
if (cents < 1 || cents > 100_000_000)
|
|
21
|
+
throw new RuntimeError({
|
|
22
|
+
code: "usage",
|
|
23
|
+
status: 0,
|
|
24
|
+
message: "--daily-limit is an amount in US dollars from 0.01 to 1000000, such as 25.",
|
|
25
|
+
});
|
|
26
|
+
return cents * 10_000;
|
|
27
|
+
}
|
|
28
|
+
function failure(code, message, status = 0, hint) {
|
|
29
|
+
return new RuntimeError({ code, status, message, ...(hint ? { hint } : {}) });
|
|
30
|
+
}
|
|
31
|
+
async function browser(url) {
|
|
32
|
+
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "rundll32" : "xdg-open";
|
|
33
|
+
const args = process.platform === "win32" ? ["url.dll,FileProtocolHandler", url] : [url];
|
|
34
|
+
await promisify(execFile)(command, args, { timeout: 10_000 });
|
|
35
|
+
}
|
|
36
|
+
function interrupted(cancel) {
|
|
37
|
+
const handler = () => {
|
|
38
|
+
process.stderr.write("\nCanceling the key request.\n");
|
|
39
|
+
void cancel()
|
|
40
|
+
.catch(() => undefined)
|
|
41
|
+
.finally(() => process.exit(130));
|
|
42
|
+
};
|
|
43
|
+
process.once("SIGINT", handler);
|
|
44
|
+
return () => void process.off("SIGINT", handler);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Asks for a key, waits for an owner to approve it in the browser, and hands
|
|
48
|
+
* it back with `confirm`, which tells the website it arrived. Call `confirm`
|
|
49
|
+
* after the key is shown: it clears the sealed copy the website held for
|
|
50
|
+
* delivery and turns the owner's page to "Key created".
|
|
51
|
+
*/
|
|
52
|
+
export async function createKey(request, env, options = {}) {
|
|
53
|
+
const name = request.name.trim();
|
|
54
|
+
if (!name ||
|
|
55
|
+
request.name.length > 80 ||
|
|
56
|
+
[...request.name].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127))
|
|
57
|
+
throw failure("usage", "Give the key a name of up to 80 characters.");
|
|
58
|
+
if (request.access === "read" && request.dailyLimitMicros !== null)
|
|
59
|
+
throw failure("usage", "A read-only key cannot spend, so it takes no --daily-limit.");
|
|
60
|
+
const origins = connectionOrigins(env);
|
|
61
|
+
const fetcher = options.fetch ?? envFetch;
|
|
62
|
+
const notify = options.notify ?? ((message) => process.stderr.write(`${message}\n`));
|
|
63
|
+
const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
64
|
+
// A key asked for here is approved on the page this address serves: only
|
|
65
|
+
// Runtime's own website, or one on this computer for testing.
|
|
66
|
+
const local = (origin) => ["localhost", "127.0.0.1", "[::1]"].includes(new URL(origin).hostname);
|
|
67
|
+
if (!(origins.auth === "https://withruntime.com" || local(origins.auth)))
|
|
68
|
+
throw failure("usage", "Keys are approved at https://withruntime.com, or at a local test address. Check RUNTIME_AUTH_URL.");
|
|
69
|
+
async function post(path, body, key) {
|
|
70
|
+
const address = `${origins.auth}/api/connect/${path}`;
|
|
71
|
+
let response;
|
|
72
|
+
try {
|
|
73
|
+
response = await fetcher(address, {
|
|
74
|
+
method: "POST",
|
|
75
|
+
redirect: "error",
|
|
76
|
+
signal: AbortSignal.timeout(20_000),
|
|
77
|
+
headers: {
|
|
78
|
+
"content-type": "application/json",
|
|
79
|
+
...(key ? { authorization: `Bearer ${key}` } : {}),
|
|
80
|
+
},
|
|
81
|
+
body: JSON.stringify(body),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
catch (cause) {
|
|
85
|
+
const route = options.fetch ? { via: "" } : describeRoute(address, cause, env);
|
|
86
|
+
throw failure("network_error", `Runtime could not be reached at ${origins.auth}${route.via}.`, 0, route.hint);
|
|
87
|
+
}
|
|
88
|
+
const result = (await response.json().catch(() => ({})));
|
|
89
|
+
if (!response.ok)
|
|
90
|
+
throw failure(response.status === 429 ? "rate_limited" : "key_request_failed", typeof result.error === "string" ? result.error : "Runtime could not take this request.", response.status);
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
const pair = await promisify(generateKeyPair)("rsa", {
|
|
94
|
+
modulusLength: 2048,
|
|
95
|
+
publicKeyEncoding: { type: "spki", format: "pem" },
|
|
96
|
+
privateKeyEncoding: { type: "pkcs8", format: "pem" },
|
|
97
|
+
});
|
|
98
|
+
const started = await post("start", {
|
|
99
|
+
purpose: "key",
|
|
100
|
+
agentName: name,
|
|
101
|
+
access: request.access,
|
|
102
|
+
dailyLimitMicros: request.dailyLimitMicros,
|
|
103
|
+
machine: options.machine ?? hostname(),
|
|
104
|
+
publicKey: pair.publicKey,
|
|
105
|
+
});
|
|
106
|
+
if (typeof started.verificationUri !== "string" ||
|
|
107
|
+
typeof started.deviceCode !== "string" ||
|
|
108
|
+
!/^[A-Za-z0-9_-]{43}$/.test(started.deviceCode) ||
|
|
109
|
+
typeof started.userCode !== "string" ||
|
|
110
|
+
!/^[A-F0-9]{4}(-[A-F0-9]{4}){2}$/.test(started.userCode) ||
|
|
111
|
+
typeof started.expiresAt !== "number" ||
|
|
112
|
+
!Number.isFinite(started.expiresAt))
|
|
113
|
+
throw failure("key_request_failed", "Runtime returned an invalid key request.");
|
|
114
|
+
const link = new URL(started.verificationUri);
|
|
115
|
+
if (link.origin !== origins.auth ||
|
|
116
|
+
link.pathname !== "/connect" ||
|
|
117
|
+
link.username ||
|
|
118
|
+
link.password ||
|
|
119
|
+
link.hash ||
|
|
120
|
+
[...link.searchParams.keys()].some((key) => key !== "code") ||
|
|
121
|
+
link.searchParams.get("code") !== started.userCode)
|
|
122
|
+
throw failure("key_request_failed", "Runtime returned an unexpected approval address.");
|
|
123
|
+
const deviceCode = started.deviceCode;
|
|
124
|
+
const expiresAt = Math.min(started.expiresAt, Date.now() + 15 * 60_000);
|
|
125
|
+
notify(`Approve this key in your browser: ${link.href}\nCheck that the page shows code ${started.userCode}. An account owner chooses Create key.\nWaiting for the approval, up to 15 minutes. Stopping this cancels the request.`);
|
|
126
|
+
if (options.interactive ?? Boolean(process.stderr.isTTY))
|
|
127
|
+
await (options.openBrowser ?? browser)(link.href).catch(() => notify("Open the link in a browser where an account owner is signed in."));
|
|
128
|
+
const stop = (options.onInterrupt ?? interrupted)(async () => {
|
|
129
|
+
await post("token", { deviceCode, action: "cancel" });
|
|
130
|
+
});
|
|
131
|
+
try {
|
|
132
|
+
// One poll past the expiry, because an approval given in its last seconds
|
|
133
|
+
// is still delivered.
|
|
134
|
+
for (;;) {
|
|
135
|
+
await sleep(POLL_MS);
|
|
136
|
+
const last = Date.now() >= expiresAt;
|
|
137
|
+
let result;
|
|
138
|
+
try {
|
|
139
|
+
result = await post("token", { deviceCode });
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
// A dropped connection or a busy website is not an answer: ask again.
|
|
143
|
+
if (!last &&
|
|
144
|
+
error instanceof RuntimeError &&
|
|
145
|
+
(error.code === "network_error" || error.status >= 500))
|
|
146
|
+
continue;
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
149
|
+
if (result.status === "pending") {
|
|
150
|
+
if (last)
|
|
151
|
+
break;
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (result.status === "denied")
|
|
155
|
+
throw failure("key_request_declined", "The key request was declined. No key was created.");
|
|
156
|
+
if (result.status === "canceled")
|
|
157
|
+
throw failure("key_request_canceled", "The key request was canceled. No key was issued.");
|
|
158
|
+
if (result.status === "expired")
|
|
159
|
+
break;
|
|
160
|
+
if (result.status !== "connected" ||
|
|
161
|
+
typeof result.encryptedKey !== "string" ||
|
|
162
|
+
typeof result.agentId !== "string" ||
|
|
163
|
+
typeof result.orgId !== "string")
|
|
164
|
+
throw failure("key_request_failed", "Runtime returned an invalid key.");
|
|
165
|
+
let key;
|
|
166
|
+
try {
|
|
167
|
+
key = privateDecrypt({ key: pair.privateKey, oaepHash: "sha256" }, Buffer.from(result.encryptedKey, "base64")).toString("utf8");
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
throw failure("key_request_failed", "Could not open the key Runtime returned. Start again.");
|
|
171
|
+
}
|
|
172
|
+
const match = KEY.exec(key);
|
|
173
|
+
if (!match)
|
|
174
|
+
throw failure("key_request_failed", "Runtime returned an invalid key.");
|
|
175
|
+
// From here the key is this command's: an interruption must not revoke it.
|
|
176
|
+
stop();
|
|
177
|
+
return {
|
|
178
|
+
name,
|
|
179
|
+
access: request.access,
|
|
180
|
+
dailyLimitMicros: request.dailyLimitMicros,
|
|
181
|
+
key,
|
|
182
|
+
keyId: match[1],
|
|
183
|
+
agentId: result.agentId,
|
|
184
|
+
orgId: result.orgId,
|
|
185
|
+
expires: null,
|
|
186
|
+
confirm: async () => {
|
|
187
|
+
await post("confirm", {}, key).catch(() => notify("The key works, but Runtime did not hear that it arrived. The approval page may still say Approved."));
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
finally {
|
|
193
|
+
stop();
|
|
194
|
+
}
|
|
195
|
+
throw failure("key_request_expired", named("The key request expired before it was approved. Run `runtime keys create` again."));
|
|
196
|
+
}
|
package/dist/login.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
import { generateKeyPair, privateDecrypt } from "node:crypto";
|
|
3
|
+
import { hostname } from "node:os";
|
|
3
4
|
import { promisify } from "node:util";
|
|
4
5
|
import { Runtime } from "./index.js";
|
|
5
6
|
import { connectionOrigins, connectionStore } from "./credentials.js";
|
|
@@ -163,9 +164,14 @@ export async function authenticationCommand(args, env, options = {}) {
|
|
|
163
164
|
let noBrowser = false;
|
|
164
165
|
let withKey = false;
|
|
165
166
|
let wait;
|
|
167
|
+
// `runtime account add`: connect another account even though this machine
|
|
168
|
+
// is connected already; the one in use is kept among the saved accounts.
|
|
169
|
+
let another = false;
|
|
166
170
|
for (let i = 0; i < rest.length; i++) {
|
|
167
171
|
if (rest[i] === "--no-browser")
|
|
168
172
|
noBrowser = true;
|
|
173
|
+
else if (rest[i] === "--another-account")
|
|
174
|
+
another = true;
|
|
169
175
|
else if (rest[i] === "--with-key")
|
|
170
176
|
withKey = true;
|
|
171
177
|
else if (rest[i] === "--wait")
|
|
@@ -212,7 +218,7 @@ export async function authenticationCommand(args, env, options = {}) {
|
|
|
212
218
|
}).usage();
|
|
213
219
|
return { connected: true, source: "environment" };
|
|
214
220
|
}
|
|
215
|
-
const saved = await store.read();
|
|
221
|
+
const saved = another ? null : await store.read();
|
|
216
222
|
if (saved) {
|
|
217
223
|
try {
|
|
218
224
|
await request("confirm", undefined, saved.key);
|
|
@@ -277,7 +283,13 @@ export async function beginDeviceLogin(env, agentName, options = {}) {
|
|
|
277
283
|
publicKeyEncoding: { type: "spki", format: "pem" },
|
|
278
284
|
privateKeyEncoding: { type: "pkcs8", format: "pem" },
|
|
279
285
|
});
|
|
280
|
-
|
|
286
|
+
// The computer's own name goes to the approval page beside the code, so an
|
|
287
|
+
// owner can tell this request from a link somebody else started.
|
|
288
|
+
const started = await request("start", {
|
|
289
|
+
agentName,
|
|
290
|
+
publicKey: pair.publicKey,
|
|
291
|
+
machine: hostname(),
|
|
292
|
+
});
|
|
281
293
|
if (typeof started.verificationUri !== "string" ||
|
|
282
294
|
typeof started.deviceCode !== "string" ||
|
|
283
295
|
!/^[A-Za-z0-9_-]{43}$/.test(started.deviceCode) ||
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/** Runtime Cloud sandboxes for the OpenAI Agents SDK (JavaScript).
|
|
2
|
+
*
|
|
3
|
+
* `RuntimeCloudSandboxClient` is a sandbox client for `SandboxAgent`: the
|
|
4
|
+
* agent's shell (with PTY sessions and stdin), file edits, image views and
|
|
5
|
+
* manifest all live in one Runtime Cloud microVM, and the agent definition
|
|
6
|
+
* does not change:
|
|
7
|
+
*
|
|
8
|
+
* import { run } from "@openai/agents";
|
|
9
|
+
* import { SandboxAgent } from "@openai/agents/sandbox";
|
|
10
|
+
* import { RuntimeCloudSandboxClient } from "withruntime/openai-agents";
|
|
11
|
+
*
|
|
12
|
+
* const agent = new SandboxAgent({ name: "Coder", instructions: "Fix the failing test." });
|
|
13
|
+
* await run(agent, "Go.", {
|
|
14
|
+
* sandbox: { client: new RuntimeCloudSandboxClient({ create: { funding: "trial" } }) },
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* Needs `@openai/agents` 0.18 or newer beside this package. The key comes from
|
|
18
|
+
* RUNTIME_API_KEY or this machine's `runtime login`. Plain function tools for
|
|
19
|
+
* an ordinary `Agent` are `runtimeFunctionTools(sandbox)`. */
|
|
20
|
+
import { type Editor } from "@openai/agents-core";
|
|
21
|
+
import type { Manifest } from "@openai/agents-core/sandbox";
|
|
22
|
+
import { type ExecCommandArgs, type ExposedPortEndpoint, type ListDirectoryArgs, type MaterializeEntryArgs, type ReadFileArgs, type SandboxClient, type SandboxClientCreateArgs, type SandboxDirectoryEntry, type SandboxExecResult, type SandboxSession, type SandboxSessionState, type ViewImageArgs, type WorkspaceArchiveData, type WriteStdinArgs } from "@openai/agents-core/sandbox";
|
|
23
|
+
import { Runtime } from "../client.js";
|
|
24
|
+
import type { Sandbox } from "../sandbox.js";
|
|
25
|
+
import { type SandboxToolOptions } from "../tools/index.js";
|
|
26
|
+
import type { CreateSandbox } from "../types.js";
|
|
27
|
+
export declare const BACKEND_ID = "runtime_cloud";
|
|
28
|
+
export type RuntimeCloudSandboxClientOptions = {
|
|
29
|
+
/** How to create the sandbox: every field `runtime.sandboxes.create` takes
|
|
30
|
+
* (funding, image, snapshot, vcpu, memoryMiB, network...). */
|
|
31
|
+
create?: CreateSandbox;
|
|
32
|
+
/** Set for every command, under the manifest's own environment. */
|
|
33
|
+
env?: Record<string, string>;
|
|
34
|
+
/** Ports `resolveExposedPort` may share as Runtime previews. */
|
|
35
|
+
exposedPorts?: number[];
|
|
36
|
+
/** Private previews carry their token in the endpoint's query. Default private. */
|
|
37
|
+
previewVisibility?: "private" | "public";
|
|
38
|
+
/** Pause instead of stopping at the end, so `resume` wakes the same machine. */
|
|
39
|
+
pauseOnExit?: boolean;
|
|
40
|
+
/** Longest a command may run. Default one hour; at most 24 hours. */
|
|
41
|
+
execTimeoutMs?: number;
|
|
42
|
+
};
|
|
43
|
+
export interface RuntimeCloudSandboxSessionState extends SandboxSessionState {
|
|
44
|
+
sandboxId: string;
|
|
45
|
+
create: CreateSandbox;
|
|
46
|
+
environment: Record<string, string>;
|
|
47
|
+
configuredExposedPorts?: number[];
|
|
48
|
+
previewVisibility: "private" | "public";
|
|
49
|
+
pauseOnExit: boolean;
|
|
50
|
+
execTimeoutMs: number;
|
|
51
|
+
}
|
|
52
|
+
/** One Runtime Cloud sandbox as an Agents SDK sandbox session. */
|
|
53
|
+
export declare class RuntimeCloudSandboxSession implements SandboxSession<RuntimeCloudSandboxSessionState> {
|
|
54
|
+
#private;
|
|
55
|
+
readonly state: RuntimeCloudSandboxSessionState;
|
|
56
|
+
constructor(args: {
|
|
57
|
+
state: RuntimeCloudSandboxSessionState;
|
|
58
|
+
runtime: Runtime;
|
|
59
|
+
sandbox?: Sandbox;
|
|
60
|
+
});
|
|
61
|
+
/** The Runtime sandbox, created (or woken) on first use. */
|
|
62
|
+
sandbox(): Promise<Sandbox>;
|
|
63
|
+
/** An absolute path inside the workspace root or a granted path; anything else is refused. */
|
|
64
|
+
resolvePath(path: string): string;
|
|
65
|
+
supportsPty(): boolean;
|
|
66
|
+
exec(args: ExecCommandArgs): Promise<SandboxExecResult>;
|
|
67
|
+
/** Starts the command and returns its output so far: finished, with its exit
|
|
68
|
+
* code, or still running, with a session id for `writeStdin`. */
|
|
69
|
+
execCommand(args: ExecCommandArgs): Promise<string>;
|
|
70
|
+
writeStdin(args: WriteStdinArgs): Promise<string>;
|
|
71
|
+
readFile(args: ReadFileArgs): Promise<Uint8Array>;
|
|
72
|
+
viewImage(args: ViewImageArgs): Promise<{
|
|
73
|
+
type: "image";
|
|
74
|
+
providerData?: Record<string, any> | undefined;
|
|
75
|
+
image?: string | {
|
|
76
|
+
data: string | Uint8Array<ArrayBuffer>;
|
|
77
|
+
mediaType?: string | undefined;
|
|
78
|
+
} | {
|
|
79
|
+
url: string;
|
|
80
|
+
} | {
|
|
81
|
+
fileId: string;
|
|
82
|
+
} | undefined;
|
|
83
|
+
detail?: "auto" | "high" | "low" | (string & {}) | undefined;
|
|
84
|
+
}>;
|
|
85
|
+
listDir(args: ListDirectoryArgs): Promise<SandboxDirectoryEntry[]>;
|
|
86
|
+
pathExists(path: string, runAs?: string): Promise<boolean>;
|
|
87
|
+
directoryExists(path: string, runAs?: string): Promise<boolean>;
|
|
88
|
+
createEditor(runAs?: string): Editor;
|
|
89
|
+
prepareWorkspaceRoot(): Promise<void>;
|
|
90
|
+
applyManifest(manifest: Manifest, runAs?: string): Promise<void>;
|
|
91
|
+
materializeEntry(args: MaterializeEntryArgs): Promise<void>;
|
|
92
|
+
resolveExposedPort(port: number): Promise<ExposedPortEndpoint>;
|
|
93
|
+
persistWorkspace(): Promise<Uint8Array>;
|
|
94
|
+
hydrateWorkspace(data: WorkspaceArchiveData): Promise<void>;
|
|
95
|
+
running(): Promise<boolean>;
|
|
96
|
+
/** Ends every process the agent started. */
|
|
97
|
+
shutdown(): Promise<void>;
|
|
98
|
+
/** Stops the sandbox, or pauses it with `pauseOnExit`. */
|
|
99
|
+
delete(): Promise<void>;
|
|
100
|
+
close(): Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
/** Creates, resumes and deletes Runtime Cloud sandbox sessions. */
|
|
103
|
+
export declare class RuntimeCloudSandboxClient implements SandboxClient<RuntimeCloudSandboxClientOptions, RuntimeCloudSandboxSessionState> {
|
|
104
|
+
#private;
|
|
105
|
+
readonly backendId = "runtime_cloud";
|
|
106
|
+
readonly runtime: Runtime;
|
|
107
|
+
constructor(options?: RuntimeCloudSandboxClientOptions & {
|
|
108
|
+
runtime?: Runtime;
|
|
109
|
+
});
|
|
110
|
+
create(args?: SandboxClientCreateArgs<RuntimeCloudSandboxClientOptions> | Manifest, manifestOptions?: RuntimeCloudSandboxClientOptions): Promise<RuntimeCloudSandboxSession>;
|
|
111
|
+
/** Reattaches to the same sandbox while it runs (waking it when paused);
|
|
112
|
+
* otherwise starts a new one and applies the manifest again. */
|
|
113
|
+
resume(state: RuntimeCloudSandboxSessionState): Promise<RuntimeCloudSandboxSession>;
|
|
114
|
+
delete(state: RuntimeCloudSandboxSessionState): Promise<void>;
|
|
115
|
+
canPersistOwnedSessionState(state: RuntimeCloudSandboxSessionState): boolean;
|
|
116
|
+
/** The state without secrets: the environment is materialized again on the way back. */
|
|
117
|
+
serializeSessionState(state: RuntimeCloudSandboxSessionState): Promise<Record<string, unknown>>;
|
|
118
|
+
deserializeSessionState(record: Record<string, unknown>): Promise<RuntimeCloudSandboxSessionState>;
|
|
119
|
+
}
|
|
120
|
+
/** The four sandbox tools as function tools for an ordinary `Agent`
|
|
121
|
+
* (no SandboxAgent): runtime_exec, runtime_read_file, runtime_write_file and
|
|
122
|
+
* runtime_list_files, bound to `sandbox`. */
|
|
123
|
+
export declare function runtimeFunctionTools(sandbox: Sandbox, options?: SandboxToolOptions): import("@openai/agents-core").FunctionTool<unknown, {
|
|
124
|
+
type: "object";
|
|
125
|
+
properties: Record<string, {
|
|
126
|
+
type: "string" | "integer";
|
|
127
|
+
description: string;
|
|
128
|
+
minimum?: number;
|
|
129
|
+
}>;
|
|
130
|
+
required: string[];
|
|
131
|
+
additionalProperties: true;
|
|
132
|
+
}, string>[];
|