@nopeek/agent-bridge 0.5.1 → 0.5.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/brain.js CHANGED
@@ -138,7 +138,11 @@ const echoBrain = async (text) => `You said: ${text}`;
138
138
  */
139
139
  export function resolveBrain(cfg, handle) {
140
140
  const h = handle.replace(/^@/, "");
141
- const override = cfg.brainMap[h];
141
+ let override = cfg.brainMap[h];
142
+ // An AUTO-provisioned brain is our own default, not a human choice — the
143
+ // server-mediated backend (picked on the phone) outranks it.
144
+ if (override?.auto && cfg.serverBackends[h])
145
+ override = undefined;
142
146
  if (override?.cmd)
143
147
  return { brain: cmdBrain(override.cmd, cfg.brainTimeoutMs), kind: "cmd (per-bot)" };
144
148
  if (override?.url)
package/dist/bridge.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { BridgeConfig, BrainSpec } from "./config.js";
2
- export declare const VERSION = "0.5.1";
2
+ export declare const VERSION = "0.5.3";
3
3
  export interface PairRequest {
4
4
  pairingSecret: string;
5
5
  appId: string;
package/dist/bridge.js CHANGED
@@ -11,10 +11,10 @@ import { saveSettings } from "./config.js";
11
11
  import { BotRunner } from "./bot.js";
12
12
  import { ControlSocket } from "./control.js";
13
13
  import { resolveBrain } from "./brain.js";
14
- import { provisionSoul } from "./backends.js";
14
+ import { provisionSoul, provisionHermesProfile } from "./backends.js";
15
15
  import { reportCapabilities } from "./capabilities.js";
16
16
  import { isBrainBackend } from "./config.js";
17
- export const VERSION = "0.5.1";
17
+ export const VERSION = "0.5.3";
18
18
  /** How often to re-probe + report brain availability to the server. */
19
19
  const CAPABILITIES_INTERVAL_MS = 5 * 60_000;
20
20
  export class PairError extends Error {
@@ -160,13 +160,31 @@ export class BridgeApp {
160
160
  saveSettings(this.cfg);
161
161
  console.log(`[bridge] server backend for @${handle} = ${backend}`);
162
162
  }
163
- const hasLocalOverride = Boolean(this.cfg.brainMap[handle]);
164
- if (hasLocalOverride) {
165
- // Local override wins and is untouched; the server backend stays recorded
166
- // but does not drive this bot until the local override is cleared.
163
+ const local = this.cfg.brainMap[handle];
164
+ if (local?.auto) {
165
+ // Our own auto-provisioned default the phone's explicit choice
166
+ // supersedes it. Drop it so the server backend drives the bot.
167
+ delete this.cfg.brainMap[handle];
168
+ saveSettings(this.cfg);
169
+ console.log(`[bridge] auto-provisioned brain for @${handle} dropped in favor of server backend`);
170
+ }
171
+ else if (local) {
172
+ // HUMAN local override wins and is untouched; the server backend stays
173
+ // recorded but does not drive this bot until the override is cleared.
167
174
  return;
168
175
  }
169
- if (backend !== "echo") {
176
+ // Provision per backend, EAGERLY picking Hermes on the phone should make
177
+ // the bot's profile appear in `hermes profile list` immediately, not on its
178
+ // first message (hermesBrain still provisions lazily as a fallback).
179
+ if (backend === "hermes") {
180
+ try {
181
+ provisionHermesProfile(handle);
182
+ }
183
+ catch (err) {
184
+ console.error(`[bridge] hermes profile provisioning for @${handle} failed: ${err.message}`);
185
+ }
186
+ }
187
+ else if (backend !== "echo") {
170
188
  try {
171
189
  provisionSoul(handle, this.cfg.homeDir);
172
190
  }
@@ -232,7 +250,9 @@ export class BridgeApp {
232
250
  async provisionBrain(info) {
233
251
  const cmd = this.cfg.brainProvisionCmd;
234
252
  const handle = info.handle.replace(/^@/, "");
235
- if (!cmd || this.cfg.brainMap[handle] || this.provisioning.has(handle))
253
+ // A server-mediated backend (picked on the phone) makes auto-provisioning
254
+ // moot — provisioning would only produce a default that must lose anyway.
255
+ if (!cmd || this.cfg.brainMap[handle] || this.cfg.serverBackends[handle] || this.provisioning.has(handle))
236
256
  return;
237
257
  this.provisioning.add(handle);
238
258
  console.log(`[provision:@${handle}] running brain provisioner`);
@@ -269,7 +289,7 @@ export class BridgeApp {
269
289
  }
270
290
  // Use the LAST non-empty stdout line: provisioners may log progress above it.
271
291
  const brainCmd = out.split("\n").map((l) => l.trim()).filter(Boolean).pop();
272
- this.setBrains({ map: { [handle]: { cmd: brainCmd } } });
292
+ this.setBrains({ map: { [handle]: { cmd: brainCmd, auto: true } } });
273
293
  console.log(`[provision:@${handle}] brain provisioned`);
274
294
  }
275
295
  /** Fetch the authoritative bot list and start anything we're missing. */
package/dist/config.d.ts CHANGED
@@ -9,6 +9,12 @@ export interface BrainSpec {
9
9
  url?: string;
10
10
  backend?: BrainBackend;
11
11
  echo?: boolean;
12
+ /**
13
+ * True when this entry was written by the BRAIN_PROVISION_CMD auto-provisioner
14
+ * rather than a human. Auto entries rank BELOW a server-mediated backend:
15
+ * the phone's explicit choice must beat a default we picked ourselves.
16
+ */
17
+ auto?: boolean;
12
18
  }
13
19
  export declare function isBrainBackend(v: unknown): v is BrainBackend;
14
20
  export interface BridgeConfig {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nopeek/agent-bridge",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Run your own agents as E2EE NoPeek bots. Pairs with a one-time code, runs every bot you own, and pipes messages to any command or webhook.",
5
5
  "type": "module",
6
6
  "license": "MIT",