arisa 2.3.33 → 2.3.35
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/core/processor.ts +3 -2
- package/src/daemon/agent-cli.ts +2 -1
- package/src/daemon/index.ts +1 -30
- package/src/shared/ai-cli.ts +5 -1
- package/src/shared/ink-shim.js +11 -4
package/package.json
CHANGED
package/src/core/processor.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { getRecentHistory } from "./history";
|
|
|
16
16
|
import { shouldContinue } from "./context";
|
|
17
17
|
import { config } from "../shared/config";
|
|
18
18
|
import { createLogger } from "../shared/logger";
|
|
19
|
-
import { buildBunWrappedAgentCliCommand } from "../shared/ai-cli";
|
|
19
|
+
import { buildBunWrappedAgentCliCommand, CLI_SPAWN_ENV } from "../shared/ai-cli";
|
|
20
20
|
import { existsSync, mkdirSync, readFileSync, appendFileSync } from "fs";
|
|
21
21
|
import { join } from "path";
|
|
22
22
|
|
|
@@ -151,7 +151,7 @@ async function runClaude(message: string, chatId: string): Promise<string> {
|
|
|
151
151
|
stdin: "pipe",
|
|
152
152
|
stdout: "pipe",
|
|
153
153
|
stderr: "pipe",
|
|
154
|
-
env: { ...process.env },
|
|
154
|
+
env: { ...process.env, ...CLI_SPAWN_ENV },
|
|
155
155
|
});
|
|
156
156
|
proc.stdin.end();
|
|
157
157
|
|
|
@@ -221,6 +221,7 @@ export async function processWithCodex(message: string): Promise<string> {
|
|
|
221
221
|
cwd: config.projectDir,
|
|
222
222
|
stdout: "pipe",
|
|
223
223
|
stderr: "pipe",
|
|
224
|
+
env: { ...process.env, ...CLI_SPAWN_ENV },
|
|
224
225
|
});
|
|
225
226
|
|
|
226
227
|
const timeout = setTimeout(() => {
|
package/src/daemon/agent-cli.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { createLogger } from "../shared/logger";
|
|
|
14
14
|
import {
|
|
15
15
|
buildBunWrappedAgentCliCommand,
|
|
16
16
|
resolveAgentCliPath,
|
|
17
|
+
CLI_SPAWN_ENV,
|
|
17
18
|
type AgentCliName,
|
|
18
19
|
} from "../shared/ai-cli";
|
|
19
20
|
|
|
@@ -71,7 +72,7 @@ async function runSingleCli(
|
|
|
71
72
|
cwd: config.projectDir,
|
|
72
73
|
stdout: "pipe",
|
|
73
74
|
stderr: "pipe",
|
|
74
|
-
env: { ...process.env },
|
|
75
|
+
env: { ...process.env, ...CLI_SPAWN_ENV },
|
|
75
76
|
});
|
|
76
77
|
|
|
77
78
|
const timeout = setTimeout(() => proc.kill(), timeoutMs);
|
package/src/daemon/index.ts
CHANGED
|
@@ -33,9 +33,7 @@ const { serveWithRetry, claimProcess, releaseProcess, cleanupSocket } = await im
|
|
|
33
33
|
const { TelegramChannel } = await import("./channels/telegram");
|
|
34
34
|
const { sendToCore } = await import("./bridge");
|
|
35
35
|
// lifecycle/autofix removed — Core runs in-process, --watch handles restarts
|
|
36
|
-
const {
|
|
37
|
-
const { maybeStartClaudeSetupToken, maybeFeedClaudeCode, setClaudeLoginNotify, isClaudeLoginPending } = await import("./claude-login");
|
|
38
|
-
const { autoInstallMissingClis, setAutoInstallNotify, setAuthProbeCallback } = await import("./auto-install");
|
|
36
|
+
const { autoInstallMissingClis, setAutoInstallNotify } = await import("./auto-install");
|
|
39
37
|
const { chunkMessage, markdownToTelegramHtml } = await import("../core/format");
|
|
40
38
|
// Message records are saved via Core's /record endpoint to avoid dual-writer
|
|
41
39
|
// conflicts (Daemon and Core sharing the same arisa.json through separate
|
|
@@ -95,35 +93,10 @@ const sendToAllChats = async (text: string) => {
|
|
|
95
93
|
};
|
|
96
94
|
|
|
97
95
|
setAutoInstallNotify(sendToAllChats);
|
|
98
|
-
setAuthProbeCallback((cli, errorText) => {
|
|
99
|
-
if (cli === "claude") {
|
|
100
|
-
// Start Claude setup-token for all known chats
|
|
101
|
-
for (const chatId of knownChatIds) {
|
|
102
|
-
maybeStartClaudeSetupToken(errorText, chatId);
|
|
103
|
-
}
|
|
104
|
-
} else if (cli === "codex") {
|
|
105
|
-
// Start Codex device-auth for all known chats
|
|
106
|
-
for (const chatId of knownChatIds) {
|
|
107
|
-
maybeStartCodexDeviceAuth(errorText, chatId);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
setCodexLoginNotify(async (chatId, text) => {
|
|
112
|
-
await telegram.send(chatId, text);
|
|
113
|
-
});
|
|
114
|
-
setClaudeLoginNotify(async (chatId, text) => {
|
|
115
|
-
await telegram.send(chatId, text);
|
|
116
|
-
});
|
|
117
96
|
|
|
118
97
|
telegram.onMessage(async (msg) => {
|
|
119
98
|
knownChatIds.add(msg.chatId);
|
|
120
99
|
|
|
121
|
-
// If Claude login is pending and user sends what looks like an OAuth code, feed it
|
|
122
|
-
if (isClaudeLoginPending() && msg.text && maybeFeedClaudeCode(msg.chatId, msg.text)) {
|
|
123
|
-
await telegram.send(msg.chatId, "Code received, authenticating...");
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
100
|
// Keep typing indicator alive while Core processes (expires every ~5s)
|
|
128
101
|
const typingInterval = setInterval(() => telegram.sendTyping(msg.chatId), 4000);
|
|
129
102
|
|
|
@@ -138,8 +111,6 @@ telegram.onMessage(async (msg) => {
|
|
|
138
111
|
clearInterval(typingInterval);
|
|
139
112
|
|
|
140
113
|
const raw = response.text || "";
|
|
141
|
-
maybeStartCodexDeviceAuth(raw, msg.chatId);
|
|
142
|
-
maybeStartClaudeSetupToken(raw, msg.chatId);
|
|
143
114
|
const messageParts = raw.split(/\n---CHUNK---\n/g);
|
|
144
115
|
let sentText = false;
|
|
145
116
|
|
package/src/shared/ai-cli.ts
CHANGED
|
@@ -101,6 +101,9 @@ export interface AgentCliOptions {
|
|
|
101
101
|
skipPreload?: boolean;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/** Env vars to suppress Ink/TTY in non-interactive CLI spawns. Merge into Bun.spawn env. */
|
|
105
|
+
export const CLI_SPAWN_ENV: Record<string, string> = { CI: "true", TERM: "dumb" };
|
|
106
|
+
|
|
104
107
|
/**
|
|
105
108
|
* Detect native executables (Mach-O, ELF) by reading magic bytes.
|
|
106
109
|
* Claude Code CLI v2+ ships as a native binary, not a JS script.
|
|
@@ -139,11 +142,12 @@ export function buildBunWrappedAgentCliCommand(cli: AgentCliName, args: string[]
|
|
|
139
142
|
|
|
140
143
|
if (isRunningAsRoot()) {
|
|
141
144
|
// Run as arisa user — Claude CLI refuses to run as root.
|
|
145
|
+
const ciEnv = options?.skipPreload ? "" : "export CI=true && export TERM=dumb && ";
|
|
142
146
|
const inner = native
|
|
143
147
|
? [cliPath, ...args].map(shellEscape).join(" ")
|
|
144
148
|
: ["bun", "--bun", ...(!options?.skipPreload ? ["--preload", INK_SHIM] : []), cliPath, ...args].map(shellEscape).join(" ");
|
|
145
149
|
// su without "-" preserves parent env (tokens, keys); explicit HOME/PATH for arisa
|
|
146
|
-
return ["su", "arisa", "-s", "/bin/bash", "-c", `${ARISA_BUN_ENV} && ${buildEnvExports()}${inner}`];
|
|
150
|
+
return ["su", "arisa", "-s", "/bin/bash", "-c", `${ARISA_BUN_ENV} && ${ciEnv}${buildEnvExports()}${inner}`];
|
|
147
151
|
}
|
|
148
152
|
|
|
149
153
|
if (native) {
|
package/src/shared/ink-shim.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
// Shim for running CLI tools that use Ink without a TTY.
|
|
2
2
|
// Prevents "Raw mode is not supported" crash by providing a no-op setRawMode.
|
|
3
|
-
//
|
|
4
|
-
if (process.stdin
|
|
5
|
-
process.stdin.
|
|
6
|
-
|
|
3
|
+
// Uses Object.defineProperty for robustness (Bun may make stdin props non-writable).
|
|
4
|
+
if (process.stdin) {
|
|
5
|
+
if (!process.stdin.isTTY) {
|
|
6
|
+
try { Object.defineProperty(process.stdin, "isTTY", { value: true, writable: true, configurable: true }); }
|
|
7
|
+
catch { process.stdin.isTTY = true; }
|
|
8
|
+
}
|
|
9
|
+
if (typeof process.stdin.setRawMode !== "function") {
|
|
10
|
+
const noop = function () { return process.stdin; };
|
|
11
|
+
try { Object.defineProperty(process.stdin, "setRawMode", { value: noop, writable: true, configurable: true }); }
|
|
12
|
+
catch { process.stdin.setRawMode = noop; }
|
|
13
|
+
}
|
|
7
14
|
}
|