@commonlyai/cli 0.1.158 → 0.1.159
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
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keep the provider key available to pi's per-call auth resolver, but out of
|
|
3
|
+
* shells started by its model bash tool and by manual ! / !! commands.
|
|
4
|
+
* This limits environment inheritance; pi itself is not an OS sandbox.
|
|
5
|
+
*/
|
|
6
|
+
import { createBashTool, createLocalBashOperations } from '@earendil-works/pi-coding-agent';
|
|
7
|
+
|
|
8
|
+
export default function commonlyShellEnvironment(pi) {
|
|
9
|
+
const providerKey = process.env.COMMONLY_PI_PROVIDER_KEY_ENV;
|
|
10
|
+
if (!providerKey) throw new Error('pi adapter: missing provider key environment name');
|
|
11
|
+
const excluded = new Set([
|
|
12
|
+
providerKey, 'COMMONLY_LITELLM_KEY', 'COMMONLY_PI_PROVIDER_KEY_ENV',
|
|
13
|
+
].map((key) => key.toUpperCase()));
|
|
14
|
+
const cleanEnv = (env) => {
|
|
15
|
+
const clean = { ...env };
|
|
16
|
+
// Windows environment lookup ignores case; spreading it loses that behavior.
|
|
17
|
+
for (const key of Object.keys(clean)) {
|
|
18
|
+
if (excluded.has(key.toUpperCase())) delete clean[key];
|
|
19
|
+
}
|
|
20
|
+
return clean;
|
|
21
|
+
};
|
|
22
|
+
const spawnHook = (context) => ({ ...context, env: cleanEnv(context.env) });
|
|
23
|
+
const bash = createBashTool(process.cwd(), { spawnHook });
|
|
24
|
+
pi.registerTool({
|
|
25
|
+
...bash,
|
|
26
|
+
execute(id, params, signal, onUpdate, ctx) {
|
|
27
|
+
return createBashTool(ctx.cwd, { spawnHook }).execute(id, params, signal, onUpdate, ctx);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const local = createLocalBashOperations();
|
|
31
|
+
pi.on('user_bash', () => ({
|
|
32
|
+
operations: {
|
|
33
|
+
exec(command, cwd, options) {
|
|
34
|
+
return local.exec(command, cwd, {
|
|
35
|
+
...options,
|
|
36
|
+
env: cleanEnv(options.env ?? process.env),
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
}));
|
|
41
|
+
}
|
package/src/lib/adapters/pi.js
CHANGED
|
@@ -72,6 +72,7 @@ const THINKING = { none: 'off', off: 'off', minimal: 'minimal', low: 'low', medi
|
|
|
72
72
|
export const thinkingFor = (effort) => (effort ? THINKING[String(effort).toLowerCase()] || null : null);
|
|
73
73
|
|
|
74
74
|
const BRIDGE_PATH = join(dirname(fileURLToPath(import.meta.url)), 'pi-commonly-mcp.mjs');
|
|
75
|
+
const SHELL_ENV_PATH = join(dirname(fileURLToPath(import.meta.url)), 'pi-shell-env.mjs');
|
|
75
76
|
|
|
76
77
|
// Same substitution contract as claude.js / codex.js: ${COMMONLY_*}
|
|
77
78
|
// placeholders in the declared MCP env are the wrapper's per-(agent, pod)
|
|
@@ -457,6 +458,9 @@ export default {
|
|
|
457
458
|
...baseEnv,
|
|
458
459
|
PI_CODING_AGENT_DIR: agentDir,
|
|
459
460
|
PI_SKIP_VERSION_CHECK: '1',
|
|
461
|
+
// A variable NAME, never its value. The always-loaded extension uses
|
|
462
|
+
// this to scrub custom provider keys as well as the default LiteLLM key.
|
|
463
|
+
COMMONLY_PI_PROVIDER_KEY_ENV: provider.apiKeyEnv,
|
|
460
464
|
};
|
|
461
465
|
// `baseEnv` is normally the process environment, which carries the
|
|
462
466
|
// bootstrap export. Nothing below this process needs the value: the bridge
|
|
@@ -472,6 +476,8 @@ export default {
|
|
|
472
476
|
prompt: fullPrompt, provider: provider.name, model, thinking, sessionId, isResume, sessionDir,
|
|
473
477
|
bridge: servers.length ? (ctx._bridgePath || BRIDGE_PATH) : null,
|
|
474
478
|
});
|
|
479
|
+
// Shell isolation must not depend on whether this turn declares MCP.
|
|
480
|
+
args.splice(args.length - 1, 0, '-e', SHELL_ENV_PATH);
|
|
475
481
|
|
|
476
482
|
const reply = await runPi({
|
|
477
483
|
args,
|