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,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>[];