Claude Agent SDK integration
Keep the Claude Agent SDK loop in your own process and run Claude Code itself inside a Promigence sandbox. Anything the agent edits, installs or deletes stays in the sandbox.
The package is promigence-claude-agent-sdk on npm, for TypeScript.
Install
Install it and set your key.
npm install promigence-claude-agent-sdk @anthropic-ai/claude-agent-sdk promigence
export PROMIGENCE_API_KEY=prom_api_...
promigence secrets set ANTHROPIC_API_KEY --from-env ANTHROPIC_API_KEY
Language: bashExample
From the guide Run Claude Agent SDK agents in a Promigence sandbox, which goes on to the spend cap, cleaning up, and what the package does not support.
import { query } from "@anthropic-ai/claude-agent-sdk";
import { PromigenceClient, Sandbox } from "promigence";
import { spawnInPromigence } from "promigence-claude-agent-sdk";
const client = new PromigenceClient();
const sandbox = await Sandbox.create({ client, timeoutMs: 15 * 60_000, spendCap: 5 });
await sandbox.commands.run("command -v claude || npm install -g @anthropic-ai/claude-code");
try {
for await (const message of query({
prompt: "Fix the failing test in src/parser.ts",
options: {
pathToClaudeCodeExecutable: "/usr/local/bin/claude",
spawnClaudeCodeProcess: spawnInPromigence({
client,
sandboxId: sandbox.sandboxId,
cwd: "/workspace",
secrets: ["ANTHROPIC_API_KEY"],
onStderr: (text) => process.stderr.write(text),
}),
},
})) {
if (message.type === "result") console.error(`[${message.subtype}]`);
}
} finally {
await sandbox.kill();
}
Language: ts