@serendb/serendesktop 0.1.2 → 0.1.3
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/dist/server.js +18 -4
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -209,6 +209,16 @@ import { readFile, writeFile } from "fs/promises";
|
|
|
209
209
|
import { randomUUID } from "crypto";
|
|
210
210
|
import { resolve } from "path";
|
|
211
211
|
import { platform } from "os";
|
|
212
|
+
function isAuthError(message) {
|
|
213
|
+
const lower = message.toLowerCase();
|
|
214
|
+
return lower.includes("invalid api key") || lower.includes("authentication required") || lower.includes("auth required") || lower.includes("please run /login") || lower.includes("authrequired");
|
|
215
|
+
}
|
|
216
|
+
function authErrorMessage(agentType) {
|
|
217
|
+
if (agentType === "claude-code") {
|
|
218
|
+
return "Claude Code is not logged in. Please open a terminal and run:\n\n claude login\n\nThen try starting the agent again.";
|
|
219
|
+
}
|
|
220
|
+
return "Agent authentication required. Please log in via the agent CLI first.";
|
|
221
|
+
}
|
|
212
222
|
var sessions = /* @__PURE__ */ new Map();
|
|
213
223
|
function createClient(sessionId) {
|
|
214
224
|
return {
|
|
@@ -463,11 +473,13 @@ async function acpSpawn(params) {
|
|
|
463
473
|
session.acpSessionId = sessionResult.sessionId ?? sessionId;
|
|
464
474
|
} catch (err) {
|
|
465
475
|
session.status = "error";
|
|
476
|
+
const rawMessage = err instanceof Error ? err.message : JSON.stringify(err);
|
|
477
|
+
const errorMsg = isAuthError(rawMessage) ? authErrorMessage(agentType) : `Failed to initialize agent: ${rawMessage}`;
|
|
466
478
|
emit("acp://error", {
|
|
467
479
|
sessionId,
|
|
468
|
-
error:
|
|
480
|
+
error: errorMsg
|
|
469
481
|
});
|
|
470
|
-
throw
|
|
482
|
+
throw new Error(errorMsg);
|
|
471
483
|
}
|
|
472
484
|
return {
|
|
473
485
|
id: sessionId,
|
|
@@ -504,11 +516,13 @@ async function acpPrompt(params) {
|
|
|
504
516
|
stopReason: result.stopReason ?? "end_turn"
|
|
505
517
|
});
|
|
506
518
|
} catch (err) {
|
|
519
|
+
const rawMessage = err instanceof Error ? err.message : JSON.stringify(err);
|
|
520
|
+
const errorMsg = isAuthError(rawMessage) ? authErrorMessage(session.agentType) : `Prompt failed: ${rawMessage}`;
|
|
507
521
|
emit("acp://error", {
|
|
508
522
|
sessionId,
|
|
509
|
-
error:
|
|
523
|
+
error: errorMsg
|
|
510
524
|
});
|
|
511
|
-
throw
|
|
525
|
+
throw new Error(errorMsg);
|
|
512
526
|
} finally {
|
|
513
527
|
session.cancelling = false;
|
|
514
528
|
if (session.status === "prompting") {
|