withruntime 0.3.1 → 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.
Files changed (105) hide show
  1. package/DAYTONA.md +129 -0
  2. package/E2B.md +146 -0
  3. package/README.md +84 -12
  4. package/VERCEL.md +127 -0
  5. package/dist/ai/index.d.ts +33 -0
  6. package/dist/ai/index.js +38 -0
  7. package/dist/claude-agent-sdk/index.d.ts +7 -0
  8. package/dist/claude-agent-sdk/index.js +65 -0
  9. package/dist/cli.d.ts +6 -0
  10. package/dist/cli.js +949 -105
  11. package/dist/client.d.ts +25 -2
  12. package/dist/client.js +14 -1
  13. package/dist/credentials.d.ts +10 -0
  14. package/dist/credentials.js +56 -1
  15. package/dist/daytona/client.d.ts +44 -0
  16. package/dist/daytona/client.js +40 -0
  17. package/dist/daytona/context.d.ts +26 -0
  18. package/dist/daytona/context.js +22 -0
  19. package/dist/daytona/daytona.d.ts +185 -0
  20. package/dist/daytona/daytona.js +416 -0
  21. package/dist/daytona/errors.d.ts +106 -0
  22. package/dist/daytona/errors.js +182 -0
  23. package/dist/daytona/filesystem.d.ts +84 -0
  24. package/dist/daytona/filesystem.js +206 -0
  25. package/dist/daytona/git.d.ts +33 -0
  26. package/dist/daytona/git.js +128 -0
  27. package/dist/daytona/image.d.ts +45 -0
  28. package/dist/daytona/image.js +140 -0
  29. package/dist/daytona/index.d.ts +50 -0
  30. package/dist/daytona/index.js +50 -0
  31. package/dist/daytona/process.d.ts +86 -0
  32. package/dist/daytona/process.js +339 -0
  33. package/dist/daytona/sandbox.d.ts +196 -0
  34. package/dist/daytona/sandbox.js +448 -0
  35. package/dist/e2b/client.d.ts +58 -0
  36. package/dist/e2b/client.js +66 -0
  37. package/dist/e2b/code-interpreter.d.ts +144 -0
  38. package/dist/e2b/code-interpreter.js +244 -0
  39. package/dist/e2b/commands.d.ts +100 -0
  40. package/dist/e2b/commands.js +268 -0
  41. package/dist/e2b/errors.d.ts +72 -0
  42. package/dist/e2b/errors.js +151 -0
  43. package/dist/e2b/filesystem.d.ts +82 -0
  44. package/dist/e2b/filesystem.js +143 -0
  45. package/dist/e2b/index.d.ts +28 -0
  46. package/dist/e2b/index.js +61 -0
  47. package/dist/e2b/sandbox.d.ts +203 -0
  48. package/dist/e2b/sandbox.js +490 -0
  49. package/dist/e2b/unsupported.d.ts +19 -0
  50. package/dist/e2b/unsupported.js +27 -0
  51. package/dist/errors.d.ts +10 -4
  52. package/dist/errors.js +26 -6
  53. package/dist/image-context.d.ts +39 -0
  54. package/dist/image-context.js +176 -0
  55. package/dist/index.d.ts +19 -2
  56. package/dist/index.js +17 -2
  57. package/dist/keys.d.ts +43 -0
  58. package/dist/keys.js +196 -0
  59. package/dist/login.js +27 -6
  60. package/dist/mcp.d.ts +2 -2
  61. package/dist/mcp.js +4 -3
  62. package/dist/openai-agents/index.d.ts +132 -0
  63. package/dist/openai-agents/index.js +791 -0
  64. package/dist/products/audit.d.ts +48 -0
  65. package/dist/products/audit.js +10 -0
  66. package/dist/products/images.d.ts +113 -7
  67. package/dist/products/images.js +186 -27
  68. package/dist/products/index.d.ts +11 -0
  69. package/dist/products/index.js +17 -1
  70. package/dist/products/observability.d.ts +186 -0
  71. package/dist/products/observability.js +117 -0
  72. package/dist/products/secrets.d.ts +40 -0
  73. package/dist/products/secrets.js +24 -0
  74. package/dist/products/switching.d.ts +89 -0
  75. package/dist/products/switching.js +25 -0
  76. package/dist/proxy.d.ts +30 -0
  77. package/dist/proxy.js +178 -0
  78. package/dist/sandbox.d.ts +30 -2
  79. package/dist/sandbox.js +101 -1
  80. package/dist/ssh.d.ts +21 -0
  81. package/dist/ssh.js +312 -0
  82. package/dist/tar.d.ts +1 -0
  83. package/dist/tar.js +4 -4
  84. package/dist/tools/index.d.ts +62 -0
  85. package/dist/tools/index.js +180 -0
  86. package/dist/transport.d.ts +12 -2
  87. package/dist/transport.js +76 -16
  88. package/dist/tunnel.d.ts +67 -0
  89. package/dist/tunnel.js +311 -0
  90. package/dist/types.d.ts +57 -1
  91. package/dist/vercel/client.d.ts +40 -0
  92. package/dist/vercel/client.js +39 -0
  93. package/dist/vercel/command.d.ts +70 -0
  94. package/dist/vercel/command.js +148 -0
  95. package/dist/vercel/errors.d.ts +53 -0
  96. package/dist/vercel/errors.js +113 -0
  97. package/dist/vercel/filesystem.d.ts +150 -0
  98. package/dist/vercel/filesystem.js +248 -0
  99. package/dist/vercel/index.d.ts +30 -0
  100. package/dist/vercel/index.js +38 -0
  101. package/dist/vercel/sandbox.d.ts +317 -0
  102. package/dist/vercel/sandbox.js +726 -0
  103. package/dist/vercel/snapshot.d.ts +93 -0
  104. package/dist/vercel/snapshot.js +123 -0
  105. package/package.json +69 -5
@@ -0,0 +1,38 @@
1
+ /** Runtime sandbox tools for the Vercel AI SDK, and for Mastra, whose agents
2
+ * take AI SDK tools as they are:
3
+ *
4
+ * import { generateText, stepCountIs } from "ai";
5
+ * import { Sandbox } from "withruntime";
6
+ * import { runtimeTools } from "withruntime/ai";
7
+ *
8
+ * await using sbx = await Sandbox.create();
9
+ * await generateText({ model, tools: runtimeTools(sbx), stopWhen: stepCountIs(10), prompt });
10
+ *
11
+ * Needs the `ai` package (version 5 or newer) beside this one. */
12
+ import { jsonSchema, tool } from "ai";
13
+ import { sandboxTools, } from "../tools/index.js";
14
+ export function runtimeTools(sandbox, options = {}) {
15
+ const [exec, read, write, list] = sandboxTools(sandbox, options);
16
+ return {
17
+ runtime_exec: tool({
18
+ description: exec.description,
19
+ inputSchema: jsonSchema(exec.inputSchema),
20
+ execute: (input) => exec.execute(input),
21
+ }),
22
+ runtime_read_file: tool({
23
+ description: read.description,
24
+ inputSchema: jsonSchema(read.inputSchema),
25
+ execute: (input) => read.execute(input),
26
+ }),
27
+ runtime_write_file: tool({
28
+ description: write.description,
29
+ inputSchema: jsonSchema(write.inputSchema),
30
+ execute: (input) => write.execute(input),
31
+ }),
32
+ runtime_list_files: tool({
33
+ description: list.description,
34
+ inputSchema: jsonSchema(list.inputSchema),
35
+ execute: (input) => list.execute(input),
36
+ }),
37
+ };
38
+ }
@@ -0,0 +1,7 @@
1
+ import type { Sandbox } from "../sandbox.js";
2
+ import { type SandboxToolOptions } from "../tools/index.js";
3
+ export type { SandboxToolOptions } from "../tools/index.js";
4
+ /** The tools' names as the Claude Agent SDK sees them, for `allowedTools`. */
5
+ export declare const RUNTIME_TOOL_NAMES: string[];
6
+ /** An MCP server named "runtime" whose four tools act on `sandbox`. */
7
+ export declare function runtimeMcpServer(sandbox: Sandbox, options?: SandboxToolOptions): import("@anthropic-ai/claude-agent-sdk").McpSdkServerConfigWithInstance;
@@ -0,0 +1,65 @@
1
+ /** Runtime sandbox tools for the Claude Agent SDK, as an in-process MCP server:
2
+ *
3
+ * import { query } from "@anthropic-ai/claude-agent-sdk";
4
+ * import { Sandbox } from "withruntime";
5
+ * import { runtimeMcpServer, RUNTIME_TOOL_NAMES } from "withruntime/claude-agent-sdk";
6
+ *
7
+ * await using sbx = await Sandbox.create();
8
+ * query({ prompt, options: {
9
+ * mcpServers: { runtime: runtimeMcpServer(sbx) },
10
+ * allowedTools: RUNTIME_TOOL_NAMES,
11
+ * disallowedTools: ["Bash", "Read", "Write", "Edit"], // keep work off this machine
12
+ * } });
13
+ *
14
+ * Needs `@anthropic-ai/claude-agent-sdk` and `zod` beside this one. For an agent
15
+ * that should create and manage sandboxes itself, connect Runtime's own MCP
16
+ * server instead: `npx -y withruntime mcp`. */
17
+ import { createSdkMcpServer, tool } from "@anthropic-ai/claude-agent-sdk";
18
+ import { z } from "zod";
19
+ import { sandboxTools } from "../tools/index.js";
20
+ /** The tools' names as the Claude Agent SDK sees them, for `allowedTools`. */
21
+ export const RUNTIME_TOOL_NAMES = [
22
+ "mcp__runtime__runtime_exec",
23
+ "mcp__runtime__runtime_read_file",
24
+ "mcp__runtime__runtime_write_file",
25
+ "mcp__runtime__runtime_list_files",
26
+ ];
27
+ const text = (value) => ({
28
+ content: [
29
+ { type: "text", text: typeof value === "string" ? value : JSON.stringify(value) },
30
+ ],
31
+ });
32
+ /** An MCP server named "runtime" whose four tools act on `sandbox`. */
33
+ export function runtimeMcpServer(sandbox, options = {}) {
34
+ const [exec, read, write, list] = sandboxTools(sandbox, options);
35
+ return createSdkMcpServer({
36
+ name: "runtime",
37
+ version: "1.0.0",
38
+ tools: [
39
+ tool(exec.name, exec.description, {
40
+ command: z.string().min(1).describe(exec.inputSchema.properties.command.description),
41
+ cwd: z.string().optional().describe(exec.inputSchema.properties.cwd.description),
42
+ timeoutSeconds: z
43
+ .number()
44
+ .int()
45
+ .min(1)
46
+ .optional()
47
+ .describe(exec.inputSchema.properties.timeoutSeconds.description),
48
+ }, async (input) => text(await exec.execute(input))),
49
+ tool(read.name, read.description, { path: z.string().describe(read.inputSchema.properties.path.description) }, async (input) => text(await read.execute(input))),
50
+ tool(write.name, write.description, {
51
+ path: z.string().describe(write.inputSchema.properties.path.description),
52
+ content: z.string().describe(write.inputSchema.properties.content.description),
53
+ }, async (input) => text(await write.execute(input))),
54
+ tool(list.name, list.description, {
55
+ path: z.string().optional().describe(list.inputSchema.properties.path.description),
56
+ depth: z
57
+ .number()
58
+ .int()
59
+ .min(1)
60
+ .optional()
61
+ .describe(list.inputSchema.properties.depth.description),
62
+ }, async (input) => text(await list.execute(input))),
63
+ ],
64
+ });
65
+ }
package/dist/cli.d.ts CHANGED
@@ -5,5 +5,11 @@ type Out = {
5
5
  error: (text: string) => void;
6
6
  };
7
7
  export declare function run(argv: string[], env?: NodeJS.ProcessEnv, out?: Out): Promise<number>;
8
+ export declare function secretsCommand(argv: string[], env: NodeJS.ProcessEnv, out: Out,
9
+ /** Tests give the value here; the CLI reads standard input. */
10
+ read?: () => Promise<string>): Promise<number>;
11
+ export declare function imageCommand(argv: string[], env: NodeJS.ProcessEnv, out: Out,
12
+ /** Tests give the registry secret here; the CLI reads standard input. */
13
+ read?: () => Promise<string>): Promise<number>;
8
14
  export declare function describeError(error: unknown, json: boolean): string;
9
15
  export {};