An open-source, faster Devin alternative
TypeScript
merge main
Brian Reardon17de2688ca4b
diff --cc sdks/python/opencomputer/__init__.pyindex 3b9ddb6d,24f2efe1..e642b792--- a/sdks/python/opencomputer/__init__.py+++ b/sdks/python/opencomputer/__init__.py@@@ -4,9 -4,11 +4,11 @@@ from opencomputer.sandbox import Sandbofrom opencomputer.agent import Agent, AgentEvent, AgentSession, AgentSessionInfofrom opencomputer.filesystem import Filesystemfrom opencomputer.exec import Exec, ProcessResult, ExecSessionInfo+ from opencomputer.image import Imagefrom opencomputer.pty import Pty, PtySessionfrom opencomputer.template import Template-from opencomputer.project import Project+from opencomputer.project import SecretStore+ from opencomputer.snapshot import Snapshots__all__ = ["Sandbox",@@@ -21,7 -24,8 +24,8 @@@"Pty","PtySession","Template",- "Project",+ "SecretStore",+ "Snapshots",]__version__ = "0.5.0"diff --cc sdks/python/opencomputer/sandbox.pyindex 5c09b36d,a6000026..1317b3b3--- a/sdks/python/opencomputer/sandbox.py+++ b/sdks/python/opencomputer/sandbox.py@@@ -37,7 -39,10 +39,10 @@@ class Sandboxapi_url: str | None = None,envs: dict[str, str] | None = None,metadata: dict[str, str] | None = None,- project: str | None = None,+ secret_store: str | None = None,+ image: Image | None = None,+ snapshot: str | None = None,+ on_build_log: Callable[[str], None] | None = None,) -> Sandbox:"""Create a new sandbox instance.@@@ -46,10 -51,13 +51,13 @@@timeout: Sandbox timeout in seconds (default 300).api_key: API key (or OPENCOMPUTER_API_KEY env var).api_url: API URL (or OPENCOMPUTER_API_URL env var).- envs: Environment variables to inject. Overrides project secrets.+ envs: Environment variables to inject. Overrides store secrets.metadata: Custom metadata key-value pairs.- project: Project name — inherits template, cpu, memory, timeout,- and secrets from the project.+ secret_store: Secret store name — resolves encrypted secrets+ and egress allowlist.+ image: Declarative Image definition. The server builds and caches it as a checkpoint.+ snapshot: Name of a pre-built snapshot to create the sandbox from.+ on_build_log: Callback for build log streaming when using image/snapshot."""url = api_url or os.environ.get("OPENCOMPUTER_API_URL", "https://app.opencomputer.dev")url = url.rstrip("/")@@@ -72,12 -86,19 +86,19 @@@body["envs"] = envsif metadata:body["metadata"] = metadata- if project:- body["project"] = project+ if secret_store:+ body["secretStore"] = secret_store-- resp = await client.post("/sandboxes", json=body)- resp.raise_for_status()- data = resp.json()+ if image is not None:+ body["image"] = image.to_dict()+ if snapshot is not None:+ body["snapshot"] = snapshot++ if use_sse:+ data = await cls._create_with_sse(client, body, on_build_log)+ else:+ resp = await client.post("/sandboxes", json=body)+ resp.raise_for_status()+ data = resp.json()connect_url = data.get("connectURL", "")token = data.get("token", "")diff --cc sdks/typescript/src/index.tsindex a495380b,c4167287..4ada0e11--- a/sdks/typescript/src/index.ts+++ b/sdks/typescript/src/index.ts@@@ -4,4 -4,9 +4,9 @@@ export { Filesystem, type EntryInfo } fexport { Exec, type ProcessResult, type RunOpts, type ExecSession, type ExecSessionInfo, type ExecStartOpts, type ExecAttachOpts } from "./exec.js";export { Pty, type PtySession, type PtyOpts } from "./pty.js";export { Templates, type TemplateInfo } from "./template.js";-export { Project, type ProjectInfo, type ProjectOpts, type CreateProjectOpts, type UpdateProjectOpts } from "./project.js";+export { SecretStore, type SecretStoreInfo, type SecretEntryInfo, type SecretStoreOpts, type CreateSecretStoreOpts, type UpdateSecretStoreOpts } from "./project.js";+ // Node.js-only modules (use crypto, fs, path) — import directly if needed:+ // import { Image } from "@opencomputer/sdk/dist/image.js";+ // import { Snapshots } from "@opencomputer/sdk/dist/snapshot.js";+ export type { ImageManifest, ImageStep } from "./image.js";+ export type { SnapshotInfo, CreateSnapshotOpts } from "./snapshot.js";diff --cc sdks/typescript/src/sandbox.tsindex 6c1914a2,b801681d..027ca564--- a/sdks/typescript/src/sandbox.ts+++ b/sdks/typescript/src/sandbox.ts@@@ -17,8 -20,14 +20,14 @@@ export interface SandboxOptsmetadata?: Record<string, string>;cpuCount?: number;memoryMB?: number;- /** Project name — inherits template, cpu, memory, timeout, and secrets from the project. */- project?: string;+ /** Secret store name — resolves encrypted secrets and egress allowlist. */+ secretStore?: string;+ /** Declarative image definition. The server builds and caches it as a checkpoint. */+ image?: Image;+ /** Name of a pre-built snapshot to create the sandbox from. */+ snapshot?: string;+ /** Callback for build log streaming when using `image`. Called with each build step message. */+ onBuildLog?: (log: string) => void;}interface SandboxData {@@@ -120,7 -129,19 +129,19 @@@ export class Sandboxif (opts.metadata) body.metadata = opts.metadata;if (opts.cpuCount != null) body.cpuCount = opts.cpuCount;if (opts.memoryMB != null) body.memoryMB = opts.memoryMB;- if (opts.project) body.project = opts.project;+ if (opts.secretStore) body.secretStore = opts.secretStore;+ if (opts.image) body.image = opts.image.toJSON();+ if (opts.snapshot) body.snapshot = opts.snapshot;++ const useSSE = opts.onBuildLog && (opts.image || opts.snapshot);++ const headers: Record<string, string> = {+ "Content-Type": "application/json",+ ...(apiKey ? { "X-API-Key": apiKey } : {}),+ };+ if (useSSE) {+ headers["Accept"] = "text/event-stream";+ }const resp = await fetch(`${apiUrl}/sandboxes`, {method: "POST",