arisa 2.3.2 → 2.3.4
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 +1 -1
- package/src/shared/ai-cli.ts +21 -3
package/package.json
CHANGED
package/src/shared/ai-cli.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module shared/ai-cli
|
|
3
3
|
* @role Resolve agent CLI binaries and execute them via Bun runtime.
|
|
4
|
-
* When running as root, wraps calls with su
|
|
4
|
+
* When running as root, wraps calls with su arisa to satisfy
|
|
5
5
|
* Claude CLI's non-root requirement.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -12,7 +12,8 @@ export type AgentCliName = "claude" | "codex";
|
|
|
12
12
|
|
|
13
13
|
const ARISA_USER_BUN = "/home/arisa/.bun/bin";
|
|
14
14
|
const ARISA_INK_SHIM = "/home/arisa/.arisa-ink-shim.js";
|
|
15
|
-
const
|
|
15
|
+
const ARISA_HOME = "/home/arisa";
|
|
16
|
+
const ARISA_BUN_ENV = `export HOME=${ARISA_HOME} && export BUN_INSTALL=${ARISA_HOME}/.bun && export PATH=${ARISA_USER_BUN}:$PATH`;
|
|
16
17
|
|
|
17
18
|
export function isRunningAsRoot(): boolean {
|
|
18
19
|
return process.getuid?.() === 0;
|
|
@@ -78,13 +79,30 @@ export function isAgentCliInstalled(cli: AgentCliName): boolean {
|
|
|
78
79
|
|
|
79
80
|
const INK_SHIM = join(dirname(new URL(import.meta.url).pathname), "ink-shim.js");
|
|
80
81
|
|
|
82
|
+
// Env vars that must survive the su - login shell reset
|
|
83
|
+
const PASSTHROUGH_VARS = [
|
|
84
|
+
"CLAUDE_CODE_OAUTH_TOKEN",
|
|
85
|
+
"ANTHROPIC_API_KEY",
|
|
86
|
+
"OPENAI_API_KEY",
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
function buildEnvExports(): string {
|
|
90
|
+
const exports: string[] = [];
|
|
91
|
+
for (const key of PASSTHROUGH_VARS) {
|
|
92
|
+
const val = process.env[key];
|
|
93
|
+
if (val) exports.push(`export ${key}=${shellEscape(val)}`);
|
|
94
|
+
}
|
|
95
|
+
return exports.length > 0 ? exports.join(" && ") + " && " : "";
|
|
96
|
+
}
|
|
97
|
+
|
|
81
98
|
export function buildBunWrappedAgentCliCommand(cli: AgentCliName, args: string[]): string[] {
|
|
82
99
|
if (isRunningAsRoot()) {
|
|
83
100
|
// Run as arisa user — Claude CLI refuses to run as root
|
|
84
101
|
const cliPath = resolveAgentCliPath(cli) || join(ARISA_USER_BUN, cli);
|
|
85
102
|
const shimPath = existsSync(ARISA_INK_SHIM) ? ARISA_INK_SHIM : INK_SHIM;
|
|
86
103
|
const inner = ["bun", "--preload", shimPath, cliPath, ...args].map(shellEscape).join(" ");
|
|
87
|
-
|
|
104
|
+
// su without "-" preserves parent env (tokens, keys); explicit HOME/PATH for arisa
|
|
105
|
+
return ["su", "arisa", "-s", "/bin/bash", "-c", `${ARISA_BUN_ENV} && ${buildEnvExports()}${inner}`];
|
|
88
106
|
}
|
|
89
107
|
|
|
90
108
|
const cliPath = resolveAgentCliPath(cli);
|