arisa 2.3.29 → 2.3.30
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/fallback.ts +24 -0
package/package.json
CHANGED
package/src/daemon/fallback.ts
CHANGED
|
@@ -15,6 +15,25 @@ import { getAgentCliLabel, runWithCliFallback } from "./agent-cli";
|
|
|
15
15
|
|
|
16
16
|
const log = createLogger("daemon");
|
|
17
17
|
|
|
18
|
+
/** Detect CLI output that is an error message, not a real response */
|
|
19
|
+
function looksLikeCliError(output: string): boolean {
|
|
20
|
+
const lower = output.toLowerCase();
|
|
21
|
+
const errorPatterns = [
|
|
22
|
+
"authentication_error",
|
|
23
|
+
"invalid bearer token",
|
|
24
|
+
"invalid api key",
|
|
25
|
+
"api error: 401",
|
|
26
|
+
"api error: 403",
|
|
27
|
+
"failed to authenticate",
|
|
28
|
+
"permission_error",
|
|
29
|
+
"rate_limit_error",
|
|
30
|
+
"overloaded_error",
|
|
31
|
+
"api error: 429",
|
|
32
|
+
"api error: 529",
|
|
33
|
+
];
|
|
34
|
+
return errorPatterns.some(p => lower.includes(p));
|
|
35
|
+
}
|
|
36
|
+
|
|
18
37
|
export async function fallbackClaude(message: string, coreError?: string): Promise<string> {
|
|
19
38
|
const systemContext = coreError
|
|
20
39
|
? `[System: Core process is down. Error: ${coreError}. You are running in fallback mode from Daemon. The user's project is at ${config.projectDir}. Respond to the user normally. If they ask about the error, explain what you see.]\n\n`
|
|
@@ -37,6 +56,11 @@ export async function fallbackClaude(message: string, coreError?: string): Promi
|
|
|
37
56
|
const cli = getAgentCliLabel(result.cli);
|
|
38
57
|
if (result.partial) {
|
|
39
58
|
log.warn(`Fallback ${cli} returned output but exited with code ${result.exitCode}`);
|
|
59
|
+
// Don't forward CLI error messages (auth failures, API errors) to the user
|
|
60
|
+
if (looksLikeCliError(result.output)) {
|
|
61
|
+
log.error(`Fallback ${cli} output is a CLI error, not forwarding to user: ${result.output.slice(0, 300)}`);
|
|
62
|
+
return `[Fallback mode] ${cli} CLI failed (exit ${result.exitCode}). Please check server logs.`;
|
|
63
|
+
}
|
|
40
64
|
} else {
|
|
41
65
|
log.warn(`Using fallback ${cli} CLI`);
|
|
42
66
|
}
|