Skip to content

Instantly share code, notes, and snippets.

@RafalWilinski
Created July 13, 2025 09:03
Show Gist options
  • Save RafalWilinski/2e1d66b33704164909caf61871444ae8 to your computer and use it in GitHub Desktop.
Save RafalWilinski/2e1d66b33704164909caf61871444ae8 to your computer and use it in GitHub Desktop.
import alchemy from "alchemy";
import { Container, Worker } from "alchemy/cloudflare";
const app = await alchemy("codeact-agent", {
password: "i dont understand why it's needed",
});
import { DurableObjectNamespace } from "alchemy/cloudflare";
import type { Sandbox } from "./src/sandbox";
const sandboxContainer = await Container<Sandbox>("sandbox-container", {
className: "Sandbox",
// This doesn't work for some reason
// I had to copy the Dockerfile to the root of the project and change the container_src
// build: {
// context: import.meta.dir,
// dockerfile: "./node_modules/@cloudflare/sandbox/Dockerfile",
// },
dev: {
remote: true,
},
adopt: true,
instanceType: "basic",
observability: {
logs: {
enabled: true,
},
},
maxInstances: 10,
});
const codeActDurableObject = new DurableObjectNamespace(
"codeact-durable-object",
{
className: "CodeActAgent",
sqlite: true,
}
);
export const agent = await Worker("agent", {
entrypoint: "./src/agent.ts",
compatibilityFlags: ["nodejs_compat"],
adopt: true,
bindings: {
CODEACT_AGENT: codeActDurableObject,
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
SANDBOX: sandboxContainer,
},
observability: {
enabled: true,
},
});
console.log(`Agent deployed at: ${agent.url}`);
await app.finalize();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment