@maestro-js/agent-container 1.0.0-alpha.19 → 1.0.0-alpha.2
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 +0 -4
- package/dist/index.js +6 -27
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -47,10 +47,6 @@ 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;
|
|
54
50
|
}
|
|
55
51
|
/** Result of running a command inside the container via {@link Container.exec}. */
|
|
56
52
|
interface ExecResult {
|
package/dist/index.js
CHANGED
|
@@ -61,9 +61,6 @@ 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
|
|
67
64
|
`;
|
|
68
65
|
|
|
69
66
|
// src/helpers.ts
|
|
@@ -114,19 +111,15 @@ async function create(config) {
|
|
|
114
111
|
env = {},
|
|
115
112
|
memory = "8gb",
|
|
116
113
|
cpus = 2,
|
|
117
|
-
volume
|
|
118
|
-
network,
|
|
119
|
-
setup = "pnpm install"
|
|
114
|
+
volume
|
|
120
115
|
} = config;
|
|
121
116
|
const dockerfileContent = dockerfile ?? DEFAULT_DOCKERFILE;
|
|
122
117
|
const userImageTag = await ensureImage(dockerfileContent);
|
|
123
118
|
const existing = await list();
|
|
124
119
|
const name = resolveContainerName(customName, existing, CONTAINER_PREFIX);
|
|
125
120
|
const envFlags = Object.entries(env).flatMap(([k, v]) => ["-e", `${k}=${v}`]);
|
|
126
|
-
const tzFlags = ["-e", "TZ=America/Chicago"];
|
|
127
121
|
const memoryFlags = memory ? ["--memory", memory] : [];
|
|
128
122
|
const cpuFlags = cpus !== void 0 ? ["--cpus", String(cpus)] : [];
|
|
129
|
-
const networkFlags = network ? ["--network", network] : [];
|
|
130
123
|
const runResult = await runDocker([
|
|
131
124
|
"run",
|
|
132
125
|
"-d",
|
|
@@ -135,10 +128,8 @@ async function create(config) {
|
|
|
135
128
|
"-v",
|
|
136
129
|
`${getVolumeName(volume, repoPath)}:/home/node`,
|
|
137
130
|
...envFlags,
|
|
138
|
-
...tzFlags,
|
|
139
131
|
...memoryFlags,
|
|
140
132
|
...cpuFlags,
|
|
141
|
-
...networkFlags,
|
|
142
133
|
userImageTag,
|
|
143
134
|
"tail",
|
|
144
135
|
"-f",
|
|
@@ -154,10 +145,9 @@ async function create(config) {
|
|
|
154
145
|
throw new Error(cpResult.stderr || `docker cp failed with exit code ${cpResult.exitCode}`);
|
|
155
146
|
}
|
|
156
147
|
await runDocker(["exec", "-u", "root", name, "chown", "-R", "node:node", workDir]);
|
|
157
|
-
const
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
throw new Error(detail || `setup command failed with exit code ${setupResult.exitCode}`);
|
|
148
|
+
const installResult = await exec(name, workDir, "pnpm install");
|
|
149
|
+
if (installResult.exitCode !== 0) {
|
|
150
|
+
throw new Error(installResult.stderr || `pnpm install failed with exit code ${installResult.exitCode}`);
|
|
161
151
|
}
|
|
162
152
|
const headResult = await runGit(["-C", repoPath, "rev-parse", "HEAD"]);
|
|
163
153
|
const hostBase = headResult.stdout.trim();
|
|
@@ -247,16 +237,7 @@ async function buildBaseImage() {
|
|
|
247
237
|
const tmpDir = await mkdtemp(join(tmpdir(), "maestro-agent-base-"));
|
|
248
238
|
try {
|
|
249
239
|
await writeFile(join(tmpDir, "Dockerfile"), BASE_DOCKERFILE);
|
|
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
|
-
]);
|
|
240
|
+
const result = await runDocker(["build", "-t", BASE_IMAGE_TAG, "--build-arg", `PNPM_VERSION=${pnpmVersion}`, tmpDir]);
|
|
260
241
|
if (result.exitCode !== 0) {
|
|
261
242
|
throw new Error(result.stderr || `docker build failed with exit code ${result.exitCode}`);
|
|
262
243
|
}
|
|
@@ -289,9 +270,7 @@ async function buildUserImage(dockerfileContent, userImageTag) {
|
|
|
289
270
|
function copyExcludingNodeModules(repoPath, containerName, workDir) {
|
|
290
271
|
return new Promise((resolve) => {
|
|
291
272
|
const gitLsFiles = spawn("git", ["-C", repoPath, "ls-files", "--cached", "--others", "--exclude-standard"]);
|
|
292
|
-
const tar = spawn("tar", ["-cf", "-", "-C", repoPath, "--files-from", "-"]
|
|
293
|
-
env: { ...process.env, COPYFILE_DISABLE: "1" }
|
|
294
|
-
});
|
|
273
|
+
const tar = spawn("tar", ["-cf", "-", "-C", repoPath, "--files-from", "-"]);
|
|
295
274
|
const dockerCp = spawn("docker", ["cp", "-", `${containerName}:${workDir}`]);
|
|
296
275
|
const stderrChunks = [];
|
|
297
276
|
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.2",
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "restricted"
|
|
17
17
|
},
|