withruntime 0.4.0 → 0.5.0
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 +2 -2
- 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 +939 -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 +26 -0
- package/dist/daytona/context.js +22 -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 +339 -0
- package/dist/daytona/sandbox.d.ts +196 -0
- package/dist/daytona/sandbox.js +448 -0
- 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 +89 -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 +312 -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 +67 -0
- package/dist/tunnel.js +311 -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
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { Runtime } from "../client.js";
|
|
2
|
+
import type { Snapshot as RuntimeSnapshot } from "../snapshots.js";
|
|
3
|
+
import { type Credentials, type WithRuntime } from "./client.js";
|
|
4
|
+
type Status = "created" | "failed" | "deleted";
|
|
5
|
+
/** A saved sandbox, as Vercel's Snapshot, over a Runtime snapshot: files,
|
|
6
|
+
* memory and running processes. `sourceSessionId` is the Runtime id of the
|
|
7
|
+
* sandbox it came from. */
|
|
8
|
+
export declare class Snapshot {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(snapshot: RuntimeSnapshot, client: Runtime);
|
|
11
|
+
get snapshotId(): string;
|
|
12
|
+
get sourceSessionId(): string;
|
|
13
|
+
get regions(): string[];
|
|
14
|
+
get status(): Status;
|
|
15
|
+
get sizeBytes(): number;
|
|
16
|
+
get createdAt(): Date;
|
|
17
|
+
get updatedAt(): Date;
|
|
18
|
+
get expiresAt(): Date;
|
|
19
|
+
static get(params: {
|
|
20
|
+
snapshotId: string;
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
} & Credentials & {
|
|
23
|
+
withruntime?: WithRuntime;
|
|
24
|
+
}): Promise<Snapshot>;
|
|
25
|
+
/** Snapshots, oldest first; `name` narrows to one sandbox's. */
|
|
26
|
+
static list(params?: {
|
|
27
|
+
name?: string;
|
|
28
|
+
limit?: number;
|
|
29
|
+
} & Credentials & {
|
|
30
|
+
withruntime?: WithRuntime;
|
|
31
|
+
} & Record<string, unknown>): Promise<{
|
|
32
|
+
snapshots: {
|
|
33
|
+
id: string;
|
|
34
|
+
sourceSessionId: string;
|
|
35
|
+
region: string;
|
|
36
|
+
regions: string[];
|
|
37
|
+
status: Status;
|
|
38
|
+
sizeBytes: number;
|
|
39
|
+
createdAt: number;
|
|
40
|
+
updatedAt: number;
|
|
41
|
+
expiresAt: number;
|
|
42
|
+
}[];
|
|
43
|
+
pagination: {
|
|
44
|
+
count: number;
|
|
45
|
+
next: string | null;
|
|
46
|
+
};
|
|
47
|
+
} & {
|
|
48
|
+
pages(): AsyncGenerator<{
|
|
49
|
+
snapshots: {
|
|
50
|
+
id: string;
|
|
51
|
+
sourceSessionId: string;
|
|
52
|
+
region: string;
|
|
53
|
+
regions: string[];
|
|
54
|
+
status: Status;
|
|
55
|
+
sizeBytes: number;
|
|
56
|
+
createdAt: number;
|
|
57
|
+
updatedAt: number;
|
|
58
|
+
expiresAt: number;
|
|
59
|
+
}[];
|
|
60
|
+
pagination: {
|
|
61
|
+
count: number;
|
|
62
|
+
next: string | null;
|
|
63
|
+
};
|
|
64
|
+
}, void, unknown>;
|
|
65
|
+
[Symbol.asyncIterator](): AsyncGenerator<{
|
|
66
|
+
id: string;
|
|
67
|
+
sourceSessionId: string;
|
|
68
|
+
region: string;
|
|
69
|
+
regions: string[];
|
|
70
|
+
status: Status;
|
|
71
|
+
sizeBytes: number;
|
|
72
|
+
createdAt: number;
|
|
73
|
+
updatedAt: number;
|
|
74
|
+
expiresAt: number;
|
|
75
|
+
}, void, unknown>;
|
|
76
|
+
toArray(): Promise<{
|
|
77
|
+
id: string;
|
|
78
|
+
sourceSessionId: string;
|
|
79
|
+
region: string;
|
|
80
|
+
regions: string[];
|
|
81
|
+
status: Status;
|
|
82
|
+
sizeBytes: number;
|
|
83
|
+
createdAt: number;
|
|
84
|
+
updatedAt: number;
|
|
85
|
+
expiresAt: number;
|
|
86
|
+
}[]>;
|
|
87
|
+
}>;
|
|
88
|
+
static tree(): Promise<never>;
|
|
89
|
+
delete(opts?: {
|
|
90
|
+
signal?: AbortSignal;
|
|
91
|
+
}): Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { clientFor, signalOf } from "./client.js";
|
|
2
|
+
import { APIError, guard, NotSupportedError } from "./errors.js";
|
|
3
|
+
function statusOf(state) {
|
|
4
|
+
if (state === "failed")
|
|
5
|
+
return "failed";
|
|
6
|
+
if (state === "deleting" || state === "deleted")
|
|
7
|
+
return "deleted";
|
|
8
|
+
return "created";
|
|
9
|
+
}
|
|
10
|
+
function metadataOf(snapshot) {
|
|
11
|
+
return {
|
|
12
|
+
id: snapshot.id,
|
|
13
|
+
sourceSessionId: snapshot.sourceSandboxId,
|
|
14
|
+
region: "iad1",
|
|
15
|
+
regions: ["iad1"],
|
|
16
|
+
status: statusOf(snapshot.state),
|
|
17
|
+
sizeBytes: snapshot.storedBytes ?? 0,
|
|
18
|
+
createdAt: Date.parse(snapshot.createdAt),
|
|
19
|
+
updatedAt: Date.parse(snapshot.readyAt ?? snapshot.createdAt),
|
|
20
|
+
expiresAt: Date.parse(snapshot.expiresAt),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** A saved sandbox, as Vercel's Snapshot, over a Runtime snapshot: files,
|
|
24
|
+
* memory and running processes. `sourceSessionId` is the Runtime id of the
|
|
25
|
+
* sandbox it came from. */
|
|
26
|
+
export class Snapshot {
|
|
27
|
+
#snapshot;
|
|
28
|
+
#client;
|
|
29
|
+
constructor(snapshot, client) {
|
|
30
|
+
this.#snapshot = snapshot;
|
|
31
|
+
this.#client = client;
|
|
32
|
+
}
|
|
33
|
+
get snapshotId() {
|
|
34
|
+
return this.#snapshot.id;
|
|
35
|
+
}
|
|
36
|
+
get sourceSessionId() {
|
|
37
|
+
return this.#snapshot.sourceSandboxId;
|
|
38
|
+
}
|
|
39
|
+
get regions() {
|
|
40
|
+
return ["iad1"];
|
|
41
|
+
}
|
|
42
|
+
get status() {
|
|
43
|
+
return statusOf(this.#snapshot.state);
|
|
44
|
+
}
|
|
45
|
+
get sizeBytes() {
|
|
46
|
+
return this.#snapshot.storedBytes ?? 0;
|
|
47
|
+
}
|
|
48
|
+
get createdAt() {
|
|
49
|
+
return new Date(this.#snapshot.createdAt);
|
|
50
|
+
}
|
|
51
|
+
get updatedAt() {
|
|
52
|
+
return new Date(this.#snapshot.readyAt ?? this.#snapshot.createdAt);
|
|
53
|
+
}
|
|
54
|
+
get expiresAt() {
|
|
55
|
+
return new Date(this.#snapshot.expiresAt);
|
|
56
|
+
}
|
|
57
|
+
static async get(params) {
|
|
58
|
+
const client = clientFor(params);
|
|
59
|
+
return new Snapshot(await guard(() => client.snapshots.get(params.snapshotId, signalOf(params))), client);
|
|
60
|
+
}
|
|
61
|
+
/** Snapshots, oldest first; `name` narrows to one sandbox's. */
|
|
62
|
+
static async list(params = {}) {
|
|
63
|
+
for (const field of ["since", "until", "cursor", "sortOrder"])
|
|
64
|
+
if (params[field] !== undefined)
|
|
65
|
+
throw new NotSupportedError(`Listing snapshots by ${field}`, "List them all and filter the result yourself.");
|
|
66
|
+
const client = clientFor(params);
|
|
67
|
+
let sandboxId;
|
|
68
|
+
if (params.name !== undefined) {
|
|
69
|
+
const found = (await guard(() => client.sandboxes.list({ name: params.name, includeStopped: true }))).data[0];
|
|
70
|
+
if (!found)
|
|
71
|
+
return paginate([], null);
|
|
72
|
+
sandboxId = found.id;
|
|
73
|
+
}
|
|
74
|
+
const page = await guard(() => client.snapshots.list({
|
|
75
|
+
...(sandboxId ? { sandboxId } : {}),
|
|
76
|
+
...(params.limit ? { limit: params.limit } : {}),
|
|
77
|
+
}));
|
|
78
|
+
return paginate(page.data, page.nextCursor, page);
|
|
79
|
+
}
|
|
80
|
+
static tree() {
|
|
81
|
+
return Promise.reject(new NotSupportedError("Snapshot ancestry (Snapshot.tree)", "Use Snapshot.list and sourceSessionId."));
|
|
82
|
+
}
|
|
83
|
+
async delete(opts = {}) {
|
|
84
|
+
try {
|
|
85
|
+
await guard(() => this.#client.snapshots.delete(this.#snapshot.id, signalOf(opts)));
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error instanceof APIError && error.response.status === 404)
|
|
89
|
+
return;
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function paginate(data, next, page) {
|
|
95
|
+
const toPage = (items, cursor) => ({
|
|
96
|
+
snapshots: items.map(metadataOf),
|
|
97
|
+
pagination: { count: items.length, next: cursor },
|
|
98
|
+
});
|
|
99
|
+
return Object.assign(toPage(data, next), {
|
|
100
|
+
async *pages() {
|
|
101
|
+
if (!page) {
|
|
102
|
+
yield toPage(data, next);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
for await (const one of page.pages())
|
|
106
|
+
yield toPage(one.data, one.nextCursor);
|
|
107
|
+
},
|
|
108
|
+
async *[Symbol.asyncIterator]() {
|
|
109
|
+
if (!page)
|
|
110
|
+
return;
|
|
111
|
+
for await (const one of page.pages())
|
|
112
|
+
yield* one.data.map(metadataOf);
|
|
113
|
+
},
|
|
114
|
+
async toArray() {
|
|
115
|
+
const all = [];
|
|
116
|
+
if (!page)
|
|
117
|
+
return all;
|
|
118
|
+
for await (const one of page.pages())
|
|
119
|
+
all.push(...one.data.map(metadataOf));
|
|
120
|
+
return all;
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "withruntime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"mcpName": "com.withruntime/runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -15,6 +15,30 @@
|
|
|
15
15
|
"./e2b/code-interpreter": {
|
|
16
16
|
"types": "./dist/e2b/code-interpreter.d.ts",
|
|
17
17
|
"import": "./dist/e2b/code-interpreter.js"
|
|
18
|
+
},
|
|
19
|
+
"./daytona": {
|
|
20
|
+
"types": "./dist/daytona/index.d.ts",
|
|
21
|
+
"import": "./dist/daytona/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./vercel": {
|
|
24
|
+
"types": "./dist/vercel/index.d.ts",
|
|
25
|
+
"import": "./dist/vercel/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./tools": {
|
|
28
|
+
"types": "./dist/tools/index.d.ts",
|
|
29
|
+
"import": "./dist/tools/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./ai": {
|
|
32
|
+
"types": "./dist/ai/index.d.ts",
|
|
33
|
+
"import": "./dist/ai/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./claude-agent-sdk": {
|
|
36
|
+
"types": "./dist/claude-agent-sdk/index.d.ts",
|
|
37
|
+
"import": "./dist/claude-agent-sdk/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./openai-agents": {
|
|
40
|
+
"types": "./dist/openai-agents/index.d.ts",
|
|
41
|
+
"import": "./dist/openai-agents/index.js"
|
|
18
42
|
}
|
|
19
43
|
},
|
|
20
44
|
"bin": {
|
|
@@ -24,7 +48,9 @@
|
|
|
24
48
|
"files": [
|
|
25
49
|
"dist",
|
|
26
50
|
"README.md",
|
|
27
|
-
"E2B.md"
|
|
51
|
+
"E2B.md",
|
|
52
|
+
"DAYTONA.md",
|
|
53
|
+
"VERCEL.md"
|
|
28
54
|
],
|
|
29
55
|
"engines": {
|
|
30
56
|
"node": ">=22"
|
|
@@ -34,8 +60,9 @@
|
|
|
34
60
|
"prepack": "bun run build",
|
|
35
61
|
"check-types": "tsc --noEmit",
|
|
36
62
|
"lint": "eslint",
|
|
37
|
-
"test": "bun test && bun scripts/test-python.ts",
|
|
38
|
-
"test:python": "bun scripts/test-python.ts"
|
|
63
|
+
"test": "bun test && bun scripts/test-python.ts && bun scripts/test-go.ts",
|
|
64
|
+
"test:python": "bun scripts/test-python.ts",
|
|
65
|
+
"test:go": "bun scripts/test-go.ts"
|
|
39
66
|
},
|
|
40
67
|
"devDependencies": {
|
|
41
68
|
"@runtime/eslint-config": "workspace:*",
|
|
@@ -45,6 +72,7 @@
|
|
|
45
72
|
"eslint": "^9",
|
|
46
73
|
"typescript": "^5",
|
|
47
74
|
"@openai/agents": "0.18.0",
|
|
75
|
+
"@openai/agents-core": "0.18.0",
|
|
48
76
|
"@anthropic-ai/claude-agent-sdk": "0.3.277",
|
|
49
77
|
"ai": "7.0.87",
|
|
50
78
|
"zod": "^4.1.8",
|
|
@@ -66,5 +94,29 @@
|
|
|
66
94
|
],
|
|
67
95
|
"dependencies": {
|
|
68
96
|
"undici": "^7.29.1"
|
|
97
|
+
},
|
|
98
|
+
"peerDependencies": {
|
|
99
|
+
"@anthropic-ai/claude-agent-sdk": ">=0.2.0",
|
|
100
|
+
"@openai/agents": ">=0.18.0",
|
|
101
|
+
"@openai/agents-core": ">=0.18.0",
|
|
102
|
+
"ai": ">=5.0.0",
|
|
103
|
+
"zod": ">=3.25.0"
|
|
104
|
+
},
|
|
105
|
+
"peerDependenciesMeta": {
|
|
106
|
+
"@anthropic-ai/claude-agent-sdk": {
|
|
107
|
+
"optional": true
|
|
108
|
+
},
|
|
109
|
+
"@openai/agents": {
|
|
110
|
+
"optional": true
|
|
111
|
+
},
|
|
112
|
+
"@openai/agents-core": {
|
|
113
|
+
"optional": true
|
|
114
|
+
},
|
|
115
|
+
"ai": {
|
|
116
|
+
"optional": true
|
|
117
|
+
},
|
|
118
|
+
"zod": {
|
|
119
|
+
"optional": true
|
|
120
|
+
}
|
|
69
121
|
}
|
|
70
122
|
}
|