@zookanalytics/agent-env 1.1.0 → 1.1.1
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/config/baseline/init-host.sh +18 -6
- package/dist/cli.js +55 -15
- package/package.json +1 -1
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# init-host.sh - Runs on the HOST before container creation (initializeCommand)
|
|
3
3
|
# Ensures mount sources exist to prevent devcontainer up failures.
|
|
4
|
-
# The .gitconfig
|
|
4
|
+
# The .gitconfig mount is provided by the image LABEL metadata; the SSH agent
|
|
5
|
+
# socket mount is injected per-platform by agent-env (resolveSshAgentMount).
|
|
5
6
|
|
|
6
7
|
set -euo pipefail
|
|
7
8
|
|
|
8
9
|
GITCONFIG="$HOME/.gitconfig"
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
# Host SSH agent socket. macOS Docker Desktop/OrbStack expose it at a fixed path;
|
|
12
|
+
# on Linux it is the host's real $SSH_AUTH_SOCK. Used only for a pre-flight warning.
|
|
13
|
+
if [ "$(uname -s)" = "Darwin" ]; then
|
|
14
|
+
SSH_SOCKET="/run/host-services/ssh-auth.sock"
|
|
15
|
+
else
|
|
16
|
+
SSH_SOCKET="${SSH_AUTH_SOCK:-}"
|
|
17
|
+
fi
|
|
10
18
|
|
|
11
19
|
# Ensure ~/.gitconfig exists (mounted read-only into container)
|
|
12
20
|
if [ ! -f "$GITCONFIG" ]; then
|
|
@@ -48,11 +56,15 @@ if [ -f "$PULSE_COOKIE_SRC" ]; then
|
|
|
48
56
|
echo "agent-env: Staged PulseAudio cookie for audio passthrough"
|
|
49
57
|
fi
|
|
50
58
|
|
|
51
|
-
# Verify SSH agent socket
|
|
52
|
-
if [ ! -S "$SSH_SOCKET" ]; then
|
|
53
|
-
echo "agent-env: Warning: SSH agent socket
|
|
59
|
+
# Verify a host SSH agent socket is available to forward into the container.
|
|
60
|
+
if [ -z "$SSH_SOCKET" ] || [ ! -S "$SSH_SOCKET" ]; then
|
|
61
|
+
echo "agent-env: Warning: no SSH agent socket found${SSH_SOCKET:+ at $SSH_SOCKET}"
|
|
54
62
|
echo "agent-env: SSH operations (git clone/push) may not work inside the container."
|
|
55
|
-
|
|
63
|
+
if [ "$(uname -s)" = "Darwin" ]; then
|
|
64
|
+
echo "agent-env: Ensure Docker Desktop or OrbStack is running."
|
|
65
|
+
else
|
|
66
|
+
echo "agent-env: Start an SSH agent and load your key (eval \"\$(ssh-agent -s)\" && ssh-add)."
|
|
67
|
+
fi
|
|
56
68
|
fi
|
|
57
69
|
|
|
58
70
|
echo "agent-env: Host initialization complete"
|
package/dist/cli.js
CHANGED
|
@@ -57,7 +57,7 @@ import React5 from "react";
|
|
|
57
57
|
// package.json
|
|
58
58
|
var package_default = {
|
|
59
59
|
name: "@zookanalytics/agent-env",
|
|
60
|
-
version: "1.1.
|
|
60
|
+
version: "1.1.1",
|
|
61
61
|
description: "CLI for creating isolated, AI-ready development environments",
|
|
62
62
|
type: "module",
|
|
63
63
|
bin: {
|
|
@@ -194,6 +194,37 @@ function createContainerLifecycle(executor = createExecutor()) {
|
|
|
194
194
|
const result = await executor("docker", ["info"], { timeout: DOCKER_INFO_TIMEOUT });
|
|
195
195
|
return result.ok;
|
|
196
196
|
}
|
|
197
|
+
async function isDevcontainerCliAvailable() {
|
|
198
|
+
const result = await executor("devcontainer", ["--version"], { timeout: DOCKER_INFO_TIMEOUT });
|
|
199
|
+
return result.ok;
|
|
200
|
+
}
|
|
201
|
+
async function checkDevcontainerPrerequisites() {
|
|
202
|
+
if (!await isDockerAvailable()) {
|
|
203
|
+
return {
|
|
204
|
+
ok: false,
|
|
205
|
+
status: "not-found",
|
|
206
|
+
containerId: null,
|
|
207
|
+
error: {
|
|
208
|
+
code: "ORBSTACK_REQUIRED",
|
|
209
|
+
message: "Docker is not available. OrbStack or Docker Desktop must be running.",
|
|
210
|
+
suggestion: "Start OrbStack or Docker Desktop, then try again."
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
if (!await isDevcontainerCliAvailable()) {
|
|
215
|
+
return {
|
|
216
|
+
ok: false,
|
|
217
|
+
status: "not-found",
|
|
218
|
+
containerId: null,
|
|
219
|
+
error: {
|
|
220
|
+
code: "DEVCONTAINER_CLI_MISSING",
|
|
221
|
+
message: "The `devcontainer` CLI was not found on your PATH.",
|
|
222
|
+
suggestion: 'Install it with `npm install -g @devcontainers/cli`, or \u2014 if you use VS Code \u2014 run the "Dev Containers: Install devcontainer CLI" command and ensure the resulting binary is on your PATH.'
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
197
228
|
async function containerStatus(containerName) {
|
|
198
229
|
const result = await executor("docker", ["inspect", containerName], {
|
|
199
230
|
timeout: DOCKER_INSPECT_TIMEOUT
|
|
@@ -296,18 +327,9 @@ function createContainerLifecycle(executor = createExecutor()) {
|
|
|
296
327
|
return name || null;
|
|
297
328
|
}
|
|
298
329
|
async function devcontainerUp(workspacePath, containerName, options) {
|
|
299
|
-
const
|
|
300
|
-
if (
|
|
301
|
-
return
|
|
302
|
-
ok: false,
|
|
303
|
-
status: "not-found",
|
|
304
|
-
containerId: null,
|
|
305
|
-
error: {
|
|
306
|
-
code: "ORBSTACK_REQUIRED",
|
|
307
|
-
message: "Docker is not available. OrbStack or Docker Desktop must be running.",
|
|
308
|
-
suggestion: "Start OrbStack or Docker Desktop, then try again."
|
|
309
|
-
}
|
|
310
|
-
};
|
|
330
|
+
const prereqError = await checkDevcontainerPrerequisites();
|
|
331
|
+
if (prereqError) {
|
|
332
|
+
return prereqError;
|
|
311
333
|
}
|
|
312
334
|
const buildNoCache = options?.buildNoCache === true;
|
|
313
335
|
const remoteEnvArgs = Object.entries(options?.remoteEnv ?? {}).flatMap(([key, value]) => [
|
|
@@ -412,6 +434,7 @@ function createContainerLifecycle(executor = createExecutor()) {
|
|
|
412
434
|
}
|
|
413
435
|
return {
|
|
414
436
|
isDockerAvailable,
|
|
437
|
+
isDevcontainerCliAvailable,
|
|
415
438
|
containerStatus,
|
|
416
439
|
getContainerNameById,
|
|
417
440
|
findContainerByWorkspaceLabel,
|
|
@@ -988,12 +1011,28 @@ async function writeGeneratedConfig(outputPath, config, deps = defaultMergeDeps)
|
|
|
988
1011
|
await deps.writeFile(tmpPath, content, "utf-8");
|
|
989
1012
|
await deps.rename(tmpPath, outputPath);
|
|
990
1013
|
}
|
|
1014
|
+
var SSH_AGENT_CONTAINER_SOCKET = "/run/host-services/ssh-auth.sock";
|
|
1015
|
+
function resolveSshAgentMount(platform2 = process.platform, sshAuthSock = process.env.SSH_AUTH_SOCK) {
|
|
1016
|
+
const target = SSH_AGENT_CONTAINER_SOCKET;
|
|
1017
|
+
const forwarding = (source) => ({
|
|
1018
|
+
mount: `source=${source},target=${target},type=bind`,
|
|
1019
|
+
env: { SSH_AUTH_SOCK: target }
|
|
1020
|
+
});
|
|
1021
|
+
if (platform2 === "darwin") {
|
|
1022
|
+
return forwarding(target);
|
|
1023
|
+
}
|
|
1024
|
+
if (sshAuthSock && sshAuthSock.length > 0) {
|
|
1025
|
+
return forwarding("${localEnv:SSH_AUTH_SOCK}");
|
|
1026
|
+
}
|
|
1027
|
+
return null;
|
|
1028
|
+
}
|
|
991
1029
|
function buildManagedConfig(defaults, params) {
|
|
992
1030
|
const statusBarWatcher = {
|
|
993
1031
|
match: `${STATUS_BAR_JSON_FILENAME}$`,
|
|
994
1032
|
event: "onFolderChange",
|
|
995
1033
|
vscodeTask: "betterStatusBar.refreshButtons"
|
|
996
1034
|
};
|
|
1035
|
+
const sshAgent = params.sshAgent === void 0 ? resolveSshAgentMount() : params.sshAgent;
|
|
997
1036
|
return {
|
|
998
1037
|
image: defaults.image,
|
|
999
1038
|
instanceName: params.instanceName,
|
|
@@ -1005,9 +1044,10 @@ function buildManagedConfig(defaults, params) {
|
|
|
1005
1044
|
...defaults.baseContainerEnv,
|
|
1006
1045
|
AGENT_ENV_INSTANCE: params.instanceName,
|
|
1007
1046
|
AGENT_ENV_REPO: params.repoSlug,
|
|
1008
|
-
AGENT_ENV_PURPOSE: params.purpose
|
|
1047
|
+
AGENT_ENV_PURPOSE: params.purpose,
|
|
1048
|
+
...sshAgent?.env ?? {}
|
|
1009
1049
|
},
|
|
1010
|
-
mounts: [],
|
|
1050
|
+
mounts: sshAgent ? [sshAgent.mount] : [],
|
|
1011
1051
|
customizations: {
|
|
1012
1052
|
vscode: {
|
|
1013
1053
|
settings: {
|