arisa 2.0.6 → 2.0.8
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/daemon/codex-login.ts +1 -0
- package/src/shared/ai-cli.ts +43 -2
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ import { buildBunWrappedAgentCliCommand } from "../shared/ai-cli";
|
|
|
15
15
|
const log = createLogger("daemon");
|
|
16
16
|
|
|
17
17
|
const AUTH_HINT_PATTERNS = [
|
|
18
|
+
/codex login is required/i,
|
|
18
19
|
/codex.*login --device-auth/i,
|
|
19
20
|
/codex is not authenticated on this server/i,
|
|
20
21
|
/missing bearer authentication in header/i,
|
package/src/shared/ai-cli.ts
CHANGED
|
@@ -3,10 +3,51 @@
|
|
|
3
3
|
* @role Resolve agent CLI binaries and execute them via Bun runtime.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { existsSync } from "fs";
|
|
7
|
+
import { delimiter, dirname, join } from "path";
|
|
8
|
+
|
|
6
9
|
export type AgentCliName = "claude" | "codex";
|
|
7
10
|
|
|
11
|
+
function unique(paths: Array<string | null | undefined>): string[] {
|
|
12
|
+
const seen = new Set<string>();
|
|
13
|
+
const out: string[] = [];
|
|
14
|
+
for (const p of paths) {
|
|
15
|
+
if (!p) continue;
|
|
16
|
+
if (seen.has(p)) continue;
|
|
17
|
+
seen.add(p);
|
|
18
|
+
out.push(p);
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function cliOverrideEnvVar(cli: AgentCliName): string | undefined {
|
|
24
|
+
return cli === "codex" ? process.env.ARISA_CODEX_BIN : process.env.ARISA_CLAUDE_BIN;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function candidatePaths(cli: AgentCliName): string[] {
|
|
28
|
+
const bunInstall = process.env.BUN_INSTALL?.trim();
|
|
29
|
+
const bunDir = dirname(process.execPath);
|
|
30
|
+
const fromPath = Bun.which(cli);
|
|
31
|
+
const fromEnvPath = (process.env.PATH || "")
|
|
32
|
+
.split(delimiter)
|
|
33
|
+
.map((entry) => entry.trim())
|
|
34
|
+
.filter(Boolean)
|
|
35
|
+
.map((entry) => join(entry, cli));
|
|
36
|
+
|
|
37
|
+
return unique([
|
|
38
|
+
cliOverrideEnvVar(cli),
|
|
39
|
+
bunInstall ? join(bunInstall, "bin", cli) : null,
|
|
40
|
+
join(bunDir, cli),
|
|
41
|
+
fromPath,
|
|
42
|
+
...fromEnvPath,
|
|
43
|
+
]);
|
|
44
|
+
}
|
|
45
|
+
|
|
8
46
|
export function resolveAgentCliPath(cli: AgentCliName): string | null {
|
|
9
|
-
|
|
47
|
+
for (const candidate of candidatePaths(cli)) {
|
|
48
|
+
if (existsSync(candidate)) return candidate;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
10
51
|
}
|
|
11
52
|
|
|
12
53
|
export function isAgentCliInstalled(cli: AgentCliName): boolean {
|
|
@@ -16,7 +57,7 @@ export function isAgentCliInstalled(cli: AgentCliName): boolean {
|
|
|
16
57
|
export function buildBunWrappedAgentCliCommand(cli: AgentCliName, args: string[]): string[] {
|
|
17
58
|
const cliPath = resolveAgentCliPath(cli);
|
|
18
59
|
if (!cliPath) {
|
|
19
|
-
throw new Error(`${cli} CLI not found
|
|
60
|
+
throw new Error(`${cli} CLI not found`);
|
|
20
61
|
}
|
|
21
62
|
return ["bun", "--bun", cliPath, ...args];
|
|
22
63
|
}
|