@nopeek/agent-bridge 0.7.7 → 0.7.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/dist/backends.js +62 -6
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +1 -1
- package/package.json +1 -1
package/dist/backends.js
CHANGED
|
@@ -15,7 +15,7 @@ import { spawn, spawnSync } from "node:child_process";
|
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
16
16
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, symlinkSync, writeFileSync } from "node:fs";
|
|
17
17
|
import { homedir } from "node:os";
|
|
18
|
-
import { join } from "node:path";
|
|
18
|
+
import { basename, join } from "node:path";
|
|
19
19
|
import { stripAnsi } from "./brain.js";
|
|
20
20
|
const BRAIN_UNREACHABLE = "⚠️ I couldn't reach my brain just now — please try again in a moment.";
|
|
21
21
|
// ------------------------------------------------------------------ souls ----
|
|
@@ -319,17 +319,54 @@ const HERMES_NO_SESSION = /^No session found matching/i;
|
|
|
319
319
|
/** Session footer Hermes prints on exit; we filter it as chrome but capture
|
|
320
320
|
* the id so a fresh session can be renamed for future --continue. */
|
|
321
321
|
const HERMES_SESSION_ID = /^session(_| )?id:\s*(\S+)/i;
|
|
322
|
+
/**
|
|
323
|
+
* How this Hermes CLI selects a profile. Hermes ≥ v0.14 DROPPED the global
|
|
324
|
+
* `--profile <path>` flag (profiles are now named, selected via the
|
|
325
|
+
* HERMES_PROFILE env var); passing the old flag makes it exit 2 with an
|
|
326
|
+
* argparse usage error and NO stdout — which surfaced to users as a bot that
|
|
327
|
+
* "stopped responding" (the empty reply fell through to BRAIN_UNREACHABLE).
|
|
328
|
+
* Detected once per process from `hermes --help`, then cached.
|
|
329
|
+
* "env" → HERMES_PROFILE=<name> (v0.14+)
|
|
330
|
+
* "flag" → --profile <path> (legacy)
|
|
331
|
+
*/
|
|
332
|
+
let hermesProfileMode = null;
|
|
333
|
+
function detectHermesProfileMode(bin) {
|
|
334
|
+
if (hermesProfileMode)
|
|
335
|
+
return hermesProfileMode;
|
|
336
|
+
try {
|
|
337
|
+
const r = spawnSync(bin, ["--help"], {
|
|
338
|
+
encoding: "utf8",
|
|
339
|
+
timeout: 20_000,
|
|
340
|
+
env: { ...process.env, HOME: hermesHome() },
|
|
341
|
+
});
|
|
342
|
+
const help = `${r.stdout || ""}${r.stderr || ""}`;
|
|
343
|
+
// Only the legacy CLI advertises a global --profile option.
|
|
344
|
+
hermesProfileMode = /^\s*--profile\b|\[--profile\b/m.test(help) ? "flag" : "env";
|
|
345
|
+
}
|
|
346
|
+
catch {
|
|
347
|
+
hermesProfileMode = "env"; // current CLI is the safer default
|
|
348
|
+
}
|
|
349
|
+
console.log(`[hermes] profile selection mode: ${hermesProfileMode}`);
|
|
350
|
+
return hermesProfileMode;
|
|
351
|
+
}
|
|
322
352
|
export function hermesBrain(cfg) {
|
|
323
353
|
const runOnce = (profile, text, sessionName, tag, onChunk) => new Promise((resolvePromise) => {
|
|
324
354
|
const bin = resolveBin("hermes", "HERMES_BIN");
|
|
325
|
-
const
|
|
355
|
+
const mode = detectHermesProfileMode(bin);
|
|
356
|
+
// v0.14+ takes the profile NAME via env; legacy took the PATH via flag.
|
|
357
|
+
const profileName = basename(profile);
|
|
358
|
+
const args = mode === "flag" ? ["--profile", profile, "chat", "-Q"] : ["chat", "-Q"];
|
|
326
359
|
if (sessionName)
|
|
327
360
|
args.push("--continue", sessionName);
|
|
328
361
|
args.push("-q", text);
|
|
329
362
|
const child = spawn(bin, args, {
|
|
330
363
|
stdio: ["ignore", "pipe", "pipe"],
|
|
331
364
|
// Hermes keys everything off $HOME; point it at the Hermes install.
|
|
332
|
-
env: {
|
|
365
|
+
env: {
|
|
366
|
+
...process.env,
|
|
367
|
+
HOME: hermesHome(),
|
|
368
|
+
...(mode === "env" ? { HERMES_PROFILE: profileName } : {}),
|
|
369
|
+
},
|
|
333
370
|
});
|
|
334
371
|
let out = "";
|
|
335
372
|
let lineBuf = "";
|
|
@@ -462,9 +499,16 @@ export function hermesBrain(cfg) {
|
|
|
462
499
|
run = await runOnce(profile, text, null, tag, onChunk);
|
|
463
500
|
if (run.sessionId) {
|
|
464
501
|
const bin = resolveBin("hermes", "HERMES_BIN");
|
|
465
|
-
const
|
|
502
|
+
const mode = detectHermesProfileMode(bin);
|
|
503
|
+
const rn = spawn(bin, mode === "flag"
|
|
504
|
+
? ["--profile", profile, "sessions", "rename", run.sessionId, sessionName]
|
|
505
|
+
: ["sessions", "rename", run.sessionId, sessionName], {
|
|
466
506
|
stdio: "ignore",
|
|
467
|
-
env: {
|
|
507
|
+
env: {
|
|
508
|
+
...process.env,
|
|
509
|
+
HOME: hermesHome(),
|
|
510
|
+
...(mode === "env" ? { HERMES_PROFILE: basename(profile) } : {}),
|
|
511
|
+
},
|
|
468
512
|
});
|
|
469
513
|
rn.on("error", () => {
|
|
470
514
|
/* best-effort — worst case the next message starts fresh again */
|
|
@@ -485,7 +529,19 @@ export function hermesBrain(cfg) {
|
|
|
485
529
|
const secs = Math.round(cfg.brainTimeoutMs / 1000);
|
|
486
530
|
return `⚠️ My brain went quiet for over ${secs}s with no output and I had to give up on that turn — a long tool-use step or a very slow provider response can trigger this. Try messaging me again.`;
|
|
487
531
|
}
|
|
488
|
-
|
|
532
|
+
// Surface the REAL reason. Blaming "no authenticated provider" for every
|
|
533
|
+
// empty reply hid a CLI-flag incompatibility (Hermes v0.14 dropped
|
|
534
|
+
// --profile) for a full day: the bot kept answering "run hermes model",
|
|
535
|
+
// which was not the fix and sent debugging down the wrong path.
|
|
536
|
+
const err = run.stderr.trim();
|
|
537
|
+
if (/usage: hermes|invalid choice|unrecognized arguments/i.test(err)) {
|
|
538
|
+
return "⚠️ My brain couldn't start — the Hermes CLI on the host rejected the command (its options changed). The bridge needs updating: run `npm i -g @nopeek/agent-bridge@latest` on that computer.";
|
|
539
|
+
}
|
|
540
|
+
if (err) {
|
|
541
|
+
const first = err.split("\n").find((l) => l.trim()) ?? "";
|
|
542
|
+
return `⚠️ My brain returned no answer. Host reported: ${first.slice(0, 180)}`;
|
|
543
|
+
}
|
|
544
|
+
return "⚠️ My brain isn't reachable right now — Hermes returned nothing. Check `hermes status` / `hermes model` on the host, then message me again.";
|
|
489
545
|
}
|
|
490
546
|
return run.reply;
|
|
491
547
|
};
|
package/dist/bridge.d.ts
CHANGED
package/dist/bridge.js
CHANGED
|
@@ -17,7 +17,7 @@ import { resolveBrain } from "./brain.js";
|
|
|
17
17
|
import { provisionSoul, provisionHermesProfile } from "./backends.js";
|
|
18
18
|
import { reportCapabilities } from "./capabilities.js";
|
|
19
19
|
import { isBrainBackend } from "./config.js";
|
|
20
|
-
export const VERSION = "0.7.
|
|
20
|
+
export const VERSION = "0.7.8";
|
|
21
21
|
/** How often to re-probe + report brain availability to the server. */
|
|
22
22
|
const CAPABILITIES_INTERVAL_MS = 5 * 60_000;
|
|
23
23
|
// ---- Reconnect watchdog -----------------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nopeek/agent-bridge",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.8",
|
|
4
4
|
"description": "Run your own agents as E2EE NoPeek bots. Pairs with one-time codes (multiple accounts per computer), runs every bot each account owns, and pipes messages to any command or webhook.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|