@koalaauto/agentchannel 3.35.1 → 3.35.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/src/cli.js +13 -9
- package/dist/src/env.d.ts +5 -0
- package/dist/src/env.js +10 -2
- package/dist/src/sandboxcheck.d.ts +2 -0
- package/dist/src/sandboxcheck.js +5 -5
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -18,6 +18,7 @@ export { VERSION } from './version.js';
|
|
|
18
18
|
import { VERSION } from './version.js';
|
|
19
19
|
import { bootGuard, markHealthy, SelfUpdater, superviseSelf, UPDATE_EXIT_CODE } from './selfupdate.js';
|
|
20
20
|
import { installProxy } from './netproxy.js';
|
|
21
|
+
import { inheritedEnv } from './env.js';
|
|
21
22
|
/** At a terminal, a command that replaces an agent's key says what that cuts off and asks (default no). --yes skips it; scripts are not asked. */
|
|
22
23
|
async function confirmKeyRotation(io, v, agentName) {
|
|
23
24
|
if (!io.ask || v.yes || v.json)
|
|
@@ -1630,6 +1631,14 @@ async function runCommand(p, io) {
|
|
|
1630
1631
|
throw new UsageError(`run: ${e.message}`);
|
|
1631
1632
|
}
|
|
1632
1633
|
// keeps this runner on the hub's release: waits for the runs in flight, installs, exits UPDATE_EXIT_CODE so the service restarts
|
|
1634
|
+
const passEnv = (Array.isArray(v['pass-env']) ? v['pass-env'] : []).flatMap(splitList);
|
|
1635
|
+
const baseEnv = (() => {
|
|
1636
|
+
const shim = writeAchShim(home);
|
|
1637
|
+
// macOS: the real git and python3 of the developer tools before the /usr/bin shims (scope.ts developerDir)
|
|
1638
|
+
const dev = developerDir();
|
|
1639
|
+
const path = [shim, dev ? `${dev}/usr/bin` : undefined, env.PATH].filter(Boolean).join(delimiter);
|
|
1640
|
+
return shim || dev ? { ...env, PATH: path } : env;
|
|
1641
|
+
})();
|
|
1633
1642
|
const runner = new Runner({
|
|
1634
1643
|
client: c,
|
|
1635
1644
|
adapter,
|
|
@@ -1647,7 +1656,7 @@ async function runCommand(p, io) {
|
|
|
1647
1656
|
secrets: [cfg.key ?? ''].filter(Boolean),
|
|
1648
1657
|
publicUrl: env.ACH_PUBLIC_URL || undefined,
|
|
1649
1658
|
onClientTooOld: () => void updater?.nudge(),
|
|
1650
|
-
passEnv
|
|
1659
|
+
passEnv,
|
|
1651
1660
|
startInfo: await (async () => {
|
|
1652
1661
|
const { startedByService } = await import('./servicefix.js');
|
|
1653
1662
|
const service = !startedByService(me.name, process.platform, env) ? '' : process.platform === 'darwin' ? 'launchd' : 'systemd';
|
|
@@ -1660,20 +1669,15 @@ async function runCommand(p, io) {
|
|
|
1660
1669
|
...(service === 'systemd' ? { linger: lingers(env) } : {}),
|
|
1661
1670
|
};
|
|
1662
1671
|
})(),
|
|
1663
|
-
baseEnv
|
|
1664
|
-
const shim = writeAchShim(home);
|
|
1665
|
-
// macOS: the real git and python3 of the developer tools before the /usr/bin shims (scope.ts developerDir)
|
|
1666
|
-
const dev = developerDir();
|
|
1667
|
-
const path = [shim, dev ? `${dev}/usr/bin` : undefined, env.PATH].filter(Boolean).join(delimiter);
|
|
1668
|
-
return shim || dev ? { ...env, PATH: path } : env;
|
|
1669
|
-
})(),
|
|
1672
|
+
baseEnv,
|
|
1670
1673
|
log: io.err,
|
|
1671
1674
|
sandboxCheck: async () => {
|
|
1672
1675
|
// kiro runs in Kiro's cloud sandbox: what this machine needs is kiro-cli and its key
|
|
1673
1676
|
if (runtime === 'kiro')
|
|
1674
1677
|
return (await import('./kirocheck.js')).probeKiro({ env });
|
|
1675
1678
|
const { probeEnvironment } = await import('./envcheck.js');
|
|
1676
|
-
|
|
1679
|
+
// the sandboxed command gets the vars a run gets, so one a run cannot start without shows here (TASK-59)
|
|
1680
|
+
return probeEnvironment(runtime === 'codex' ? 'codex' : 'claude', { env, hub: cfg.hub, runEnv: inheritedEnv(baseEnv, passEnv) });
|
|
1677
1681
|
},
|
|
1678
1682
|
});
|
|
1679
1683
|
io.err(`ach run: agent ${me.name}, runtime ${runtime}, perm min(${me.perm_level}, ${perm}), dir ${dir}` +
|
package/dist/src/env.d.ts
CHANGED
|
@@ -35,4 +35,9 @@ export interface AgentEnvInput {
|
|
|
35
35
|
passEnv?: string[];
|
|
36
36
|
}
|
|
37
37
|
/** Env for a spawned agent: allowlisted parent vars + --pass-env names + task-scoped ACH vars. */
|
|
38
|
+
/**
|
|
39
|
+
* The parent vars a spawned agent inherits: the allowlist, the platform's system vars and the --pass-env names. The runner's
|
|
40
|
+
* startup check runs the runtime with these too, so a var a run cannot do without fails there, not in the first task (TASK-59).
|
|
41
|
+
*/
|
|
42
|
+
export declare function inheritedEnv(base: NodeJS.ProcessEnv | Record<string, string | undefined>, passEnv?: string[], platform?: NodeJS.Platform): Record<string, string>;
|
|
38
43
|
export declare function buildAgentEnv(base: NodeJS.ProcessEnv | Record<string, string | undefined>, a: AgentEnvInput, platform?: NodeJS.Platform): Record<string, string>;
|
package/dist/src/env.js
CHANGED
|
@@ -48,15 +48,23 @@ export function neverPass(name) {
|
|
|
48
48
|
return /^CLAUDE_CODE_.*(SESSION|ENTRYPOINT|EXECPATH|SSE|PORT|SOCK|IPC|MESSAG|HOST|OAUTH|TOKEN|AUTH|BRIDGE|REMOTE)/.test(name);
|
|
49
49
|
}
|
|
50
50
|
/** Env for a spawned agent: allowlisted parent vars + --pass-env names + task-scoped ACH vars. */
|
|
51
|
-
|
|
51
|
+
/**
|
|
52
|
+
* The parent vars a spawned agent inherits: the allowlist, the platform's system vars and the --pass-env names. The runner's
|
|
53
|
+
* startup check runs the runtime with these too, so a var a run cannot do without fails there, not in the first task (TASK-59).
|
|
54
|
+
*/
|
|
55
|
+
export function inheritedEnv(base, passEnv = [], platform = process.platform) {
|
|
52
56
|
const env = {};
|
|
53
57
|
const win = platform === 'win32';
|
|
54
|
-
for (const k of [...ENV_ALLOWLIST, ...(win ? WINDOWS_ENV_ALLOWLIST : []), ...
|
|
58
|
+
for (const k of [...ENV_ALLOWLIST, ...(win ? WINDOWS_ENV_ALLOWLIST : []), ...passEnv]) {
|
|
55
59
|
const v = lookup(base, k, win);
|
|
56
60
|
if (v === undefined || neverPass(k))
|
|
57
61
|
continue;
|
|
58
62
|
env[k] = v;
|
|
59
63
|
}
|
|
64
|
+
return env;
|
|
65
|
+
}
|
|
66
|
+
export function buildAgentEnv(base, a, platform = process.platform) {
|
|
67
|
+
const env = inheritedEnv(base, a.passEnv, platform);
|
|
60
68
|
env.ACH_HUB = a.hub;
|
|
61
69
|
env.ACH_RUN_TOKEN = a.runToken;
|
|
62
70
|
env.ACH_TASK_ID = a.taskId;
|
|
@@ -90,6 +90,8 @@ export interface ProbeOptions {
|
|
|
90
90
|
codex?: string[];
|
|
91
91
|
/** the hub URL: when set, a Codex probe also checks that a sandboxed command reaches it (work runs call `ach` from there) */
|
|
92
92
|
hub?: string;
|
|
93
|
+
/** the env a run's runtime gets (inheritedEnv); the sandboxed commands run with it. Default: env */
|
|
94
|
+
runEnv?: NodeJS.ProcessEnv;
|
|
93
95
|
}
|
|
94
96
|
/** Probe `tool`'s sandbox on this machine. Never throws. */
|
|
95
97
|
export declare function probeSandbox(tool: SandboxTool, o?: ProbeOptions): Promise<SandboxStatus>;
|
package/dist/src/sandboxcheck.js
CHANGED
|
@@ -113,13 +113,13 @@ export async function probeSandbox(tool, o = {}) {
|
|
|
113
113
|
const platform = o.platform ?? process.platform;
|
|
114
114
|
const host = o.host ?? detectHost(env, platform);
|
|
115
115
|
const run = o.run ?? defaultRun;
|
|
116
|
-
const st = await probe(tool, { env, platform, host, run, home: o.home ?? homedir(), codex: o.codex, hub: o.hub });
|
|
116
|
+
const st = await probe(tool, { env, platform, host, run, home: o.home ?? homedir(), codex: o.codex, hub: o.hub, runEnv: o.runEnv ?? env });
|
|
117
117
|
if (!st.ok)
|
|
118
118
|
st.fix = sandboxFix(st, host);
|
|
119
119
|
return st;
|
|
120
120
|
}
|
|
121
121
|
async function probe(tool, o) {
|
|
122
|
-
const { platform, host, run, env } = o;
|
|
122
|
+
const { platform, host, run, env, runEnv } = o;
|
|
123
123
|
if (platform === 'win32') {
|
|
124
124
|
if (tool === 'claude')
|
|
125
125
|
return { tool, ok: false, problem: 'windows-native' };
|
|
@@ -152,12 +152,12 @@ async function probe(tool, o) {
|
|
|
152
152
|
let codex;
|
|
153
153
|
if (tool === 'claude' && platform === 'linux') {
|
|
154
154
|
// what Claude Code's sandbox does: a new session, no network, the filesystem read-only except the work directory
|
|
155
|
-
r = await run(host.bwrap, ['--new-session', '--die-with-parent', '--unshare-net', '--ro-bind', '/', '/', '--dev', '/dev', '--proc', '/proc', '--bind', dir, dir, '--', ...sh], { env });
|
|
155
|
+
r = await run(host.bwrap, ['--new-session', '--die-with-parent', '--unshare-net', '--ro-bind', '/', '/', '--dev', '/dev', '--proc', '/proc', '--bind', dir, dir, '--', ...sh], { env: runEnv });
|
|
156
156
|
}
|
|
157
157
|
else if (tool === 'claude') {
|
|
158
158
|
const q = (p) => JSON.stringify(p);
|
|
159
159
|
const profile = `(version 1)(allow default)(deny file-write* (subpath ${q(o.home)}))(allow file-write* (subpath ${q(dir)}))`;
|
|
160
|
-
r = await run('/usr/bin/sandbox-exec', ['-p', profile, ...sh], { env });
|
|
160
|
+
r = await run('/usr/bin/sandbox-exec', ['-p', profile, ...sh], { env: runEnv });
|
|
161
161
|
}
|
|
162
162
|
else {
|
|
163
163
|
codex = o.codex ?? codexCommand(env);
|
|
@@ -167,7 +167,7 @@ async function probe(tool, o) {
|
|
|
167
167
|
if (canary)
|
|
168
168
|
writeFileSync(canary, 'probe\n', { mode: 0o600 });
|
|
169
169
|
codexHome = probeCodexHome();
|
|
170
|
-
const cenv = { ...
|
|
170
|
+
const cenv = { ...runEnv, CODEX_HOME: codexHome };
|
|
171
171
|
// the work directory is the cwd; the sandbox is the one a work run gets (codexSandboxOverrides)
|
|
172
172
|
r = await run(codex[0], [...codex.slice(1), 'sandbox', ...codexProbeConfig(dir, o.home, o.hub), '--', ...cmd], { env: cenv, cwd: dir });
|
|
173
173
|
if (r.code !== 0 && /unrecognized subcommand|unexpected argument|Usage: codex \[OPTIONS\]/i.test(r.stderr)) {
|
package/dist/src/version.d.ts
CHANGED
package/dist/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koalaauto/agentchannel",
|
|
3
|
-
"version": "3.35.
|
|
3
|
+
"version": "3.35.2",
|
|
4
4
|
"description": "Hand work between your team's agents (Claude Code, Codex) and follow it in one panel: the ach CLI, MCP server and runner for AgentChannel v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentchannel",
|