mercury-agent 0.4.11 → 0.4.13
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/package.json
CHANGED
|
@@ -385,6 +385,22 @@ const PACKAGE_ROOT = path.join(__dirname, "../..");
|
|
|
385
385
|
/** Exit code 137 = SIGKILL (128 + 9), typically from OOM killer */
|
|
386
386
|
const OOM_EXIT_CODE = 137;
|
|
387
387
|
|
|
388
|
+
let _isDockerDesktop: boolean | undefined;
|
|
389
|
+
function isDockerDesktop(): boolean {
|
|
390
|
+
if (_isDockerDesktop !== undefined) return _isDockerDesktop;
|
|
391
|
+
try {
|
|
392
|
+
const info = execFileSync("docker", ["info", "--format", "{{.Name}}"], {
|
|
393
|
+
encoding: "utf8",
|
|
394
|
+
timeout: 10_000,
|
|
395
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
396
|
+
}).trim();
|
|
397
|
+
_isDockerDesktop = info === "docker-desktop";
|
|
398
|
+
} catch {
|
|
399
|
+
_isDockerDesktop = false;
|
|
400
|
+
}
|
|
401
|
+
return _isDockerDesktop;
|
|
402
|
+
}
|
|
403
|
+
|
|
388
404
|
export class AgentContainerRunner {
|
|
389
405
|
// Inner containers now run detached (no long-lived `docker` child process to
|
|
390
406
|
// hold a handle to), so we track only the container name — termination is by
|
|
@@ -934,7 +950,7 @@ export class AgentContainerRunner {
|
|
|
934
950
|
"-e",
|
|
935
951
|
"CONTAINER_RUNTIME=runsc",
|
|
936
952
|
);
|
|
937
|
-
} else if (this.config.containerBwrapDockerCompat) {
|
|
953
|
+
} else if (this.config.containerBwrapDockerCompat || isDockerDesktop()) {
|
|
938
954
|
// runc + bwrap: bubblewrap needs extra namespace syscalls that Docker's default
|
|
939
955
|
// seccomp/caps/AppArmor block. seccomp=unconfined allows unshare; apparmor=unconfined
|
|
940
956
|
// allows mount(MS_SLAVE); SYS_ADMIN grants the mount capability. Bwrap remains active
|
package/src/cli/mercury.ts
CHANGED
|
@@ -185,13 +185,30 @@ async function runAction(): Promise<void> {
|
|
|
185
185
|
stdio: "pipe",
|
|
186
186
|
});
|
|
187
187
|
if (imageCheck.status !== 0) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
// If the configured (registry) image isn't available, try the local build tag
|
|
189
|
+
const localTag = "mercury-agent:latest";
|
|
190
|
+
if (imageName !== localTag) {
|
|
191
|
+
const localCheck = spawnSync("docker", ["image", "inspect", localTag], {
|
|
192
|
+
stdio: "pipe",
|
|
193
|
+
});
|
|
194
|
+
if (localCheck.status === 0) {
|
|
195
|
+
console.log(
|
|
196
|
+
`ℹ️ Registry image not found, using locally built ${localTag}\n`,
|
|
197
|
+
);
|
|
198
|
+
process.env.MERCURY_AGENT_IMAGE = localTag;
|
|
199
|
+
} else {
|
|
200
|
+
console.error(`Error: Container image '${imageName}' not found.`);
|
|
201
|
+
console.error(
|
|
202
|
+
`Pull it: docker pull ${imageName}\n` +
|
|
203
|
+
`Or build: mercury build`,
|
|
204
|
+
);
|
|
205
|
+
process.exit(1);
|
|
206
|
+
}
|
|
191
207
|
} else {
|
|
208
|
+
console.error(`Error: Container image '${imageName}' not found.`);
|
|
192
209
|
console.error("Run 'mercury build' to build it.");
|
|
210
|
+
process.exit(1);
|
|
193
211
|
}
|
|
194
|
-
process.exit(1);
|
|
195
212
|
}
|
|
196
213
|
|
|
197
214
|
console.log("🪽 Starting mercury...\n");
|