@serendb/serendesktop 0.1.1 → 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 +21 -7
- 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 {
|
|
@@ -348,8 +358,8 @@ function findAgentBinary(binBase) {
|
|
|
348
358
|
const binName = `${binBase}${ext}`;
|
|
349
359
|
const home2 = process.env.HOME ?? "~";
|
|
350
360
|
const candidates = [
|
|
351
|
-
// 1. runtime/bin/ (bundled with seren-local)
|
|
352
|
-
resolve(import.meta.dirname, "
|
|
361
|
+
// 1. runtime/bin/ (bundled with seren-local — dist/ is one level below bin/)
|
|
362
|
+
resolve(import.meta.dirname, "../bin", binName),
|
|
353
363
|
// 2. ~/.seren-local/bin/ (user install location)
|
|
354
364
|
resolve(home2, ".seren-local/bin", binName),
|
|
355
365
|
// 3. Seren Desktop embedded-runtime (development)
|
|
@@ -358,7 +368,7 @@ function findAgentBinary(binBase) {
|
|
|
358
368
|
if (binBase === "seren-acp-claude") {
|
|
359
369
|
const legacyName = `acp_agent${ext}`;
|
|
360
370
|
candidates.push(
|
|
361
|
-
resolve(import.meta.dirname, "
|
|
371
|
+
resolve(import.meta.dirname, "../bin", legacyName),
|
|
362
372
|
resolve(home2, ".seren-local/bin", legacyName),
|
|
363
373
|
resolve(home2, "Projects/Seren_Projects/seren-desktop/src-tauri/embedded-runtime/bin", legacyName)
|
|
364
374
|
);
|
|
@@ -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") {
|