@maestro-js/agent-container 1.0.0-alpha.2 → 1.0.0-alpha.20
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.
- package/dist/index.d.ts +4 -0
- package/dist/index.js +27 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -47,6 +47,10 @@ declare namespace AgentContainer {
|
|
|
47
47
|
cpus?: number;
|
|
48
48
|
/** Docker volume name for persisting `/home/node` (Claude CLI config, zsh history). Defaults to a per-repo name based on `repoPath`. */
|
|
49
49
|
volume?: string;
|
|
50
|
+
/** Docker network to attach the container to (e.g. `'my-network'`). Omit to use the default bridge network. */
|
|
51
|
+
network?: string;
|
|
52
|
+
/** Shell command(s) to run after files are copied into the container. @default 'pnpm install' */
|
|
53
|
+
setup?: string;
|
|
50
54
|
}
|
|
51
55
|
/** Result of running a command inside the container via {@link Container.exec}. */
|
|
52
56
|
interface ExecResult {
|
package/dist/index.js
CHANGED
|
@@ -61,6 +61,9 @@ USER node
|
|
|
61
61
|
|
|
62
62
|
# Install Claude
|
|
63
63
|
RUN npm install -g @anthropic-ai/claude-code@latest
|
|
64
|
+
|
|
65
|
+
# Install Playwright CLI
|
|
66
|
+
RUN npm install -g @playwright/cli@latest
|
|
64
67
|
`;
|
|
65
68
|
|
|
66
69
|
// src/helpers.ts
|
|
@@ -111,15 +114,19 @@ async function create(config) {
|
|
|
111
114
|
env = {},
|
|
112
115
|
memory = "8gb",
|
|
113
116
|
cpus = 2,
|
|
114
|
-
volume
|
|
117
|
+
volume,
|
|
118
|
+
network,
|
|
119
|
+
setup = "pnpm install"
|
|
115
120
|
} = config;
|
|
116
121
|
const dockerfileContent = dockerfile ?? DEFAULT_DOCKERFILE;
|
|
117
122
|
const userImageTag = await ensureImage(dockerfileContent);
|
|
118
123
|
const existing = await list();
|
|
119
124
|
const name = resolveContainerName(customName, existing, CONTAINER_PREFIX);
|
|
120
125
|
const envFlags = Object.entries(env).flatMap(([k, v]) => ["-e", `${k}=${v}`]);
|
|
126
|
+
const tzFlags = ["-e", "TZ=America/Chicago"];
|
|
121
127
|
const memoryFlags = memory ? ["--memory", memory] : [];
|
|
122
128
|
const cpuFlags = cpus !== void 0 ? ["--cpus", String(cpus)] : [];
|
|
129
|
+
const networkFlags = network ? ["--network", network] : [];
|
|
123
130
|
const runResult = await runDocker([
|
|
124
131
|
"run",
|
|
125
132
|
"-d",
|
|
@@ -128,8 +135,10 @@ async function create(config) {
|
|
|
128
135
|
"-v",
|
|
129
136
|
`${getVolumeName(volume, repoPath)}:/home/node`,
|
|
130
137
|
...envFlags,
|
|
138
|
+
...tzFlags,
|
|
131
139
|
...memoryFlags,
|
|
132
140
|
...cpuFlags,
|
|
141
|
+
...networkFlags,
|
|
133
142
|
userImageTag,
|
|
134
143
|
"tail",
|
|
135
144
|
"-f",
|
|
@@ -145,9 +154,10 @@ async function create(config) {
|
|
|
145
154
|
throw new Error(cpResult.stderr || `docker cp failed with exit code ${cpResult.exitCode}`);
|
|
146
155
|
}
|
|
147
156
|
await runDocker(["exec", "-u", "root", name, "chown", "-R", "node:node", workDir]);
|
|
148
|
-
const
|
|
149
|
-
if (
|
|
150
|
-
|
|
157
|
+
const setupResult = await exec(name, workDir, setup);
|
|
158
|
+
if (setupResult.exitCode !== 0) {
|
|
159
|
+
const detail = [setupResult.stderr, setupResult.stdout].filter(Boolean).join("\n");
|
|
160
|
+
throw new Error(detail || `setup command failed with exit code ${setupResult.exitCode}`);
|
|
151
161
|
}
|
|
152
162
|
const headResult = await runGit(["-C", repoPath, "rev-parse", "HEAD"]);
|
|
153
163
|
const hostBase = headResult.stdout.trim();
|
|
@@ -237,7 +247,16 @@ async function buildBaseImage() {
|
|
|
237
247
|
const tmpDir = await mkdtemp(join(tmpdir(), "maestro-agent-base-"));
|
|
238
248
|
try {
|
|
239
249
|
await writeFile(join(tmpDir, "Dockerfile"), BASE_DOCKERFILE);
|
|
240
|
-
const result = await runDocker([
|
|
250
|
+
const result = await runDocker([
|
|
251
|
+
"build",
|
|
252
|
+
"-t",
|
|
253
|
+
BASE_IMAGE_TAG,
|
|
254
|
+
"--build-arg",
|
|
255
|
+
`PNPM_VERSION=${pnpmVersion}`,
|
|
256
|
+
"--build-arg",
|
|
257
|
+
"TZ=America/Chicago",
|
|
258
|
+
tmpDir
|
|
259
|
+
]);
|
|
241
260
|
if (result.exitCode !== 0) {
|
|
242
261
|
throw new Error(result.stderr || `docker build failed with exit code ${result.exitCode}`);
|
|
243
262
|
}
|
|
@@ -270,7 +289,9 @@ async function buildUserImage(dockerfileContent, userImageTag) {
|
|
|
270
289
|
function copyExcludingNodeModules(repoPath, containerName, workDir) {
|
|
271
290
|
return new Promise((resolve) => {
|
|
272
291
|
const gitLsFiles = spawn("git", ["-C", repoPath, "ls-files", "--cached", "--others", "--exclude-standard"]);
|
|
273
|
-
const tar = spawn("tar", ["-cf", "-", "-C", repoPath, "--files-from", "-"]
|
|
292
|
+
const tar = spawn("tar", ["-cf", "-", "-C", repoPath, "--files-from", "-"], {
|
|
293
|
+
env: { ...process.env, COPYFILE_DISABLE: "1" }
|
|
294
|
+
});
|
|
274
295
|
const dockerCp = spawn("docker", ["cp", "-", `${containerName}:${workDir}`]);
|
|
275
296
|
const stderrChunks = [];
|
|
276
297
|
gitLsFiles.stdout.pipe(tar.stdin);
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@types/node": "^22.19.11"
|
|
12
12
|
},
|
|
13
13
|
"description": "Docker-based isolated agent execution environment with patch-based sync. Use when you need to create sandboxed containers for AI agents, run code in isolated Docker environments, pull container changes back to the host working tree as patches, or manage container lifecycles. Provides create, list, kill, shell, open (VS Code), and pull operations. Containers include Node.js 22, pnpm, Claude CLI, Playwright, git, and zsh.",
|
|
14
|
-
"version": "1.0.0-alpha.
|
|
14
|
+
"version": "1.0.0-alpha.20",
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "restricted"
|
|
17
17
|
},
|