@nopeek/agent-bridge 0.5.0 → 0.5.2

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.0";
2
+ export declare const VERSION = "0.5.2";
3
3
  export interface PairRequest {
4
4
  pairingSecret: string;
5
5
  appId: string;
package/dist/bridge.js CHANGED
@@ -14,7 +14,7 @@ import { resolveBrain } from "./brain.js";
14
14
  import { provisionSoul } from "./backends.js";
15
15
  import { reportCapabilities } from "./capabilities.js";
16
16
  import { isBrainBackend } from "./config.js";
17
- export const VERSION = "0.5.0";
17
+ export const VERSION = "0.5.2";
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,10 +160,17 @@ 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
176
  if (backend !== "echo") {
@@ -232,7 +239,9 @@ export class BridgeApp {
232
239
  async provisionBrain(info) {
233
240
  const cmd = this.cfg.brainProvisionCmd;
234
241
  const handle = info.handle.replace(/^@/, "");
235
- if (!cmd || this.cfg.brainMap[handle] || this.provisioning.has(handle))
242
+ // A server-mediated backend (picked on the phone) makes auto-provisioning
243
+ // moot — provisioning would only produce a default that must lose anyway.
244
+ if (!cmd || this.cfg.brainMap[handle] || this.cfg.serverBackends[handle] || this.provisioning.has(handle))
236
245
  return;
237
246
  this.provisioning.add(handle);
238
247
  console.log(`[provision:@${handle}] running brain provisioner`);
@@ -269,7 +278,7 @@ export class BridgeApp {
269
278
  }
270
279
  // Use the LAST non-empty stdout line: provisioners may log progress above it.
271
280
  const brainCmd = out.split("\n").map((l) => l.trim()).filter(Boolean).pop();
272
- this.setBrains({ map: { [handle]: { cmd: brainCmd } } });
281
+ this.setBrains({ map: { [handle]: { cmd: brainCmd, auto: true } } });
273
282
  console.log(`[provision:@${handle}] brain provisioned`);
274
283
  }
275
284
  /** Fetch the authoritative bot list and start anything we're missing. */
package/dist/cli.js CHANGED
File without changes
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.0",
3
+ "version": "0.5.2",
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",
@@ -22,15 +22,8 @@
22
22
  "engines": {
23
23
  "node": ">=22"
24
24
  },
25
- "scripts": {
26
- "build": "tsc -p tsconfig.json",
27
- "prepack": "tsc -p tsconfig.json",
28
- "start": "node dist/cli.js",
29
- "dev": "tsx src/cli.ts",
30
- "typecheck": "tsc -p tsconfig.json --noEmit"
31
- },
32
25
  "dependencies": {
33
- "@nopeek/chat": "workspace:*"
26
+ "@nopeek/chat": "0.2.1"
34
27
  },
35
28
  "devDependencies": {
36
29
  "@types/node": "^22.10.0",
@@ -47,5 +40,11 @@
47
40
  ],
48
41
  "publishConfig": {
49
42
  "access": "public"
43
+ },
44
+ "scripts": {
45
+ "build": "tsc -p tsconfig.json",
46
+ "start": "node dist/cli.js",
47
+ "dev": "tsx src/cli.ts",
48
+ "typecheck": "tsc -p tsconfig.json --noEmit"
50
49
  }
51
- }
50
+ }