An open-source, faster Devin alternative
TypeScript
Export Image and Snapshots from SDK (#99)
Mohamed Habibfecac2cbb612
diff --git a/docs/reference/typescript-sdk/overview.mdx b/docs/reference/typescript-sdk/overview.mdxindex 6d9b4604..3c86f0e8 100644--- a/docs/reference/typescript-sdk/overview.mdx+++ b/docs/reference/typescript-sdk/overview.mdx@@ -19,10 +19,11 @@ pnpm add @opencomputer/sdk```typescriptimport { Sandbox } from "@opencomputer/sdk";-import { Image } from "@opencomputer/sdk/dist/image.js";-import { Snapshots } from "@opencomputer/sdk/dist/snapshot.js";+import { Image, Snapshots } from "@opencomputer/sdk/node";```+> Note: The SDK is ESM-only. Use Node 18+ with `"type": "module"` (or `.mjs/.mts`) and top-level `await`, or use `const { Sandbox } = await import("@opencomputer/sdk"); const { Image, Snapshots } = await import("@opencomputer/sdk/node");` in CommonJS.+## Modules<CardGroup cols={2}>diff --git a/docs/sandboxes/templates.mdx b/docs/sandboxes/templates.mdxindex d33e7eb6..65afc60c 100644--- a/docs/sandboxes/templates.mdx+++ b/docs/sandboxes/templates.mdx@@ -19,7 +19,8 @@ Declarative images are **cached by content hash** — identical manifests produc<CodeGroup>```typescript TypeScript-import { Sandbox, Image } from '@opencomputer/sdk';+import { Sandbox } from '@opencomputer/sdk';+import { Image } from '@opencomputer/sdk/node';// Define an image with packages, env vars, and filesconst image = Image.base()@@ -94,7 +95,7 @@ Create named snapshots that persist permanently and can be shared across sandbox<CodeGroup>```typescript TypeScript-import { Image, Snapshots } from '@opencomputer/sdk';+import { Image, Snapshots } from '@opencomputer/sdk/node';const snapshots = new Snapshots();diff --git a/docs/sdks/typescript/templates.mdx b/docs/sdks/typescript/templates.mdxindex 784b0990..4c53c173 100644--- a/docs/sdks/typescript/templates.mdx+++ b/docs/sdks/typescript/templates.mdx@@ -17,7 +17,8 @@ Build images on-the-fly when creating sandboxes. Ideal for iterating quickly witDeclarative images are **cached by content hash** — identical manifests produce the same image. Subsequent runs reuse the cached image instantly.```typescript-import { Sandbox, Image } from '@opencomputer/sdk';+import { Sandbox } from '@opencomputer/sdk';+import { Image } from '@opencomputer/sdk/node';// Define an image with packages, env vars, and filesconst image = Image.base()@@ -57,7 +58,7 @@ When you pass an `image` to `Sandbox.create()`, the server:Create named snapshots that persist permanently and can be shared across sandboxes. Snapshots are visible in the dashboard and don't need to be rebuilt.```typescript-import { Image, Snapshots } from '@opencomputer/sdk';+import { Image, Snapshots } from '@opencomputer/sdk/node';const snapshots = new Snapshots();diff --git a/sdks/typescript/package.json b/sdks/typescript/package.jsonindex adba4319..cbffb02a 100644--- a/sdks/typescript/package.json+++ b/sdks/typescript/package.json@@ -1,6 +1,6 @@{"name": "@opencomputer/sdk",- "version": "0.5.12",+ "version": "0.5.13","description": "TypeScript SDK for OpenComputer - cloud sandbox platform","type": "module","main": "dist/index.js",@@ -9,6 +9,10 @@".": {"types": "./dist/index.d.ts","import": "./dist/index.js"+ },+ "./node": {+ "types": "./dist/node.d.ts",+ "import": "./dist/node.js"}},"files": [diff --git a/sdks/typescript/src/index.ts b/sdks/typescript/src/index.tsindex 4ada0e11..22156171 100644--- a/sdks/typescript/src/index.ts+++ b/sdks/typescript/src/index.ts@@ -5,8 +5,6 @@ export { Exec, type ProcessResult, type RunOpts, type ExecSession, type ExecSessexport { Pty, type PtySession, type PtyOpts } from "./pty.js";export { Templates, type TemplateInfo } from "./template.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";+// Node.js-only modules (use crypto, fs, path) — import via "@opencomputer/sdk/node".export type { ImageManifest, ImageStep } from "./image.js";export type { SnapshotInfo, CreateSnapshotOpts } from "./snapshot.js";diff --git a/sdks/typescript/src/node.ts b/sdks/typescript/src/node.tsnew file mode 100644index 00000000..31b5e66b--- /dev/null+++ b/sdks/typescript/src/node.ts@@ -0,0 +1,3 @@+export * from "./index.js";+export { Image, type ImageManifest, type ImageStep } from "./image.js";+export { Snapshots, type SnapshotInfo, type CreateSnapshotOpts } from "./snapshot.js";