@clearlysh/beehaven 0.8.20 → 0.8.22

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.
@@ -210,7 +210,7 @@ export class AgentSessions {
210
210
  return;
211
211
  }
212
212
  const base = this.wsBase().replace(/\/$/, '');
213
- const url = `${base}/my/hive/ws?token=${encodeURIComponent(spec.token)}&clientType=agent&client=agent&wsType=workspace&deviceId=agent-${encodeURIComponent(agentId)}`;
213
+ const url = `${base}/my/workspace/ws?token=${encodeURIComponent(spec.token)}&clientType=agent&client=agent&deviceId=agent-${encodeURIComponent(agentId)}`;
214
214
  let ws;
215
215
  let opened = false;
216
216
  let settled = false;
@@ -53,9 +53,9 @@ export const PUBLIC_BUILD = true;
53
53
  * ⚠ REWRITTEN IN `dist/` AT BUILD TIME, like `PUBLIC_BUILD`. `unstamped` is what a source checkout
54
54
  * carries and what `tsx`/`vitest` see, and it is honest: nothing has stamped them.
55
55
  */
56
- export const BUILD_SHA = '046981bccb35-dirty';
56
+ export const BUILD_SHA = '49efa8cde4ed-dirty';
57
57
  /** ISO-8601 minute precision, UTC. Rewritten in `dist/` by `scripts/stamp-build-channel.mjs`. */
58
- export const BUILD_TIME = '2026-09-29T05:23Z';
58
+ export const BUILD_TIME = '2026-09-30T19:01Z';
59
59
  /**
60
60
  * The build identity as one short string, for `--version`.
61
61
  *
package/dist/cli.js CHANGED
@@ -1950,6 +1950,7 @@ async function run() {
1950
1950
  * flag with two meanings is worse than a refusal that names the alternative.
1951
1951
  */
1952
1952
  'ticket',
1953
+ 'inbox',
1953
1954
  /**
1954
1955
  * ⚠ `trash` — CBH2-34. It pages `document-list { archived: true }` and honours `--limit` up to
1955
1956
  * 500, announcing the clamp when the ask is higher. Left off this list the flag is REFUSED,
@@ -6647,9 +6648,7 @@ complete -F _beehaven_completions beehaven`);
6647
6648
  break;
6648
6649
  }
6649
6650
  case 'swarm': {
6650
- // Distributed hive mesh — see the swarm, set THIS machine's role, and
6651
- // dispatch work to worker beehives. One namespace for the whole mesh
6652
- // (`hive`/`hives` already name the local-apps concept).
6651
+ // Queen and Omni identity commands remain; node registry/dispatch was retired.
6653
6652
  const { cmdSwarm } = await import('./commands/swarm.js');
6654
6653
  await cmdSwarm(positionals, values);
6655
6654
  break;
@@ -1830,42 +1830,22 @@ const PAGES = {
1830
1830
  related: ['app', 'pipe', 'pwd'],
1831
1831
  },
1832
1832
  swarm: {
1833
- synopsis: 'beehaven swarm <list|queen|role|dispatch|bees|sample-honey|forge-omni> [args]',
1834
- description: `The distributed HIVE MESH + its two AI bees. A "beehive" is a
1835
- node running the daemon + hives (this Mac, a headless server via
1836
- \`start --headless\`, or a Cloudflare container). A QUEEN hive orchestrates;
1837
- WORKER hives execute the work the queen dispatches. This machine registers
1838
- itself when the daemon connects — the Mac defaults to QUEEN, a
1839
- headless/container node to WORKER.
1840
-
1841
- Mesh subcommands:
1842
- list Every beehive: role, kind, hives, online state
1843
- queen Which NODE is orchestrating right now
1844
- role <queen|worker> Make THIS machine the queen (or a worker)
1845
- whoami This machine's beehive identity
1846
- dispatch <cap> <action> [json] Route work to the best worker (--target pins one)
1847
- forget <deviceId> Drop a stale OFFLINE node
1848
-
1849
- The bees (AI):
1833
+ synopsis: 'beehaven swarm <bees|sample-honey|forge-omni> [args]',
1834
+ description: `The two AI bees. The unfinished node registry and dispatch
1835
+ protocol were retired; they do not route work.
1836
+
1850
1837
  bees 👑 Queen + 🐝 Omni status
1851
1838
  sample-honey 👑 Queen ingests the WHOLE workspace corpus
1852
1839
  (memories, brain, prompts, brand voice) and gets fat
1853
1840
  forge-omni [--force] 👑 Queen distills a LEAN copy of you → 🐝 Omni,
1854
1841
  your personal-assistant AI TWIN (--force re-samples)
1855
1842
 
1856
- The Queen bee runs on the queen hive — same crown, two layers (the NODE vs.
1857
- the AI). Omni is the owner's twin: log in as it with \`agent login omni-bee\`.
1858
- Distinct from \`hives\` (local apps) — a beehive is a whole NODE.`,
1843
+ Omni is the owner's twin: log in as it with \`agent login omni-bee\`.`,
1859
1844
  flags: [
1860
- {
1861
- name: '--target <deviceId>',
1862
- desc: 'dispatch: pin to a specific beehive instead of auto-selecting',
1863
- },
1864
1845
  { name: '--force', desc: 'forge-omni: re-sample the honey before distilling' },
1865
1846
  ],
1866
1847
  examples: [
1867
- { cmd: 'beehaven swarm list', note: 'see the whole swarm' },
1868
- { cmd: 'beehaven swarm role queen', note: 'make this machine the queen' },
1848
+ { cmd: 'beehaven swarm bees', note: 'see Queen and Omni' },
1869
1849
  { cmd: 'beehaven swarm sample-honey', note: 'Queen ingests everything' },
1870
1850
  { cmd: 'beehaven swarm forge-omni', note: 'forge your AI twin' },
1871
1851
  { cmd: 'beehaven agent login omni-bee', note: 'log in as your twin' },
@@ -82,7 +82,7 @@ async function call(action, input, values) {
82
82
  async function printList(box, values) {
83
83
  const res = await call('inbox-list', {
84
84
  box, ...(values.search ? { q: String(values.search) } : {}), ...(values.as ? { as: String(values.as) } : {}),
85
- ...(values.limit ? { limit: Number(values.limit) } : {}),
85
+ ...(values.limit !== undefined ? { limit: Number(values.limit) } : {}),
86
86
  }, values);
87
87
  const threads = res.threads ?? [];
88
88
  const counts = res.counts ?? {};
@@ -1,26 +1,7 @@
1
1
  /**
2
- * swarm / hive — the distributed "hive mesh" from the terminal.
3
- *
4
- * A **beehive** is a node running the daemon + hives (this Mac, a headless
5
- * server, or a Cloudflare container). A **queen hive** orchestrates; **worker
6
- * hives** execute. This machine registers itself automatically when the daemon
7
- * connects (see daemon.ts `registerBeehive`) — these verbs let you SEE the
8
- * swarm, designate roles, and route work.
9
- *
10
- * beehaven swarm list # every beehive: role, kind, hives, online
11
- * beehaven swarm queen # who's orchestrating
12
- * beehaven swarm role <queen|worker> # make THIS machine the queen (or a worker)
13
- * beehaven swarm whoami # this machine's beehive identity
14
- * beehaven swarm dispatch <cap> <action> [json] # route work to the best worker
15
- * beehaven swarm forget <deviceId> # drop a stale offline node
16
- *
17
- * All cloud state lives in the always-on Home DO (rpc/swarm-rpcs.ts); these
18
- * verbs reach it through the daemon over IPC via `rpcOnce`. (One namespace on
19
- * purpose — `hive`/`hives` already name the local-apps concept.)
2
+ * swarm — the Queen and Omni identity commands. The unfinished node registry and
3
+ * dispatch protocol were retired; these two bees remain independent of it.
20
4
  */
21
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
22
- import { homedir, hostname, platform } from 'node:os';
23
- import { join } from 'node:path';
24
5
  import { rpcOnce } from '../ipc-client.js';
25
6
  const dim = (s) => `\x1b[2m${s}\x1b[0m`;
26
7
  const green = (s) => `\x1b[32m${s}\x1b[0m`;
@@ -28,50 +9,28 @@ const cyan = (s) => `\x1b[36m${s}\x1b[0m`;
28
9
  const yellow = (s) => `\x1b[33m${s}\x1b[0m`;
29
10
  const red = (s) => `\x1b[31m${s}\x1b[0m`;
30
11
  const bold = (s) => `\x1b[1m${s}\x1b[0m`;
31
- const CONFIG_DIR = join(homedir(), '.beehaven');
32
- const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
33
- /** This machine's stable beehive id — MUST match relay.ts `deviceId`. */
34
- function thisDeviceId() {
35
- return `${hostname()}-${platform()}`;
36
- }
37
- function loadConfig() {
38
- try {
39
- return existsSync(CONFIG_FILE) ? JSON.parse(readFileSync(CONFIG_FILE, 'utf8')) : {};
40
- }
41
- catch {
42
- return {};
43
- }
44
- }
45
- function saveConfig(update) {
46
- mkdirSync(CONFIG_DIR, { recursive: true });
47
- writeFileSync(CONFIG_FILE, JSON.stringify({ ...loadConfig(), ...update }, null, 2));
48
- }
49
12
  /** Unwrap the daemon's { result } envelope (rpcOnce sometimes returns it raw). */
50
13
  function unwrap(r) {
51
14
  return r?.result ?? r ?? {};
52
15
  }
53
16
  // ══════════════════════════════ swarm ══════════════════════════════
54
17
  export async function cmdSwarm(positionals, values) {
55
- const sub = positionals[1] ?? 'list';
56
- const rest = positionals.slice(2);
18
+ const sub = positionals[1] ?? 'bees';
57
19
  switch (sub) {
58
20
  case 'list':
59
21
  case 'ls':
60
- return swarmList();
61
22
  case 'queen':
62
- return swarmQueen();
63
23
  case 'role':
64
- return swarmRole(rest);
65
24
  case 'whoami':
66
25
  case 'status':
67
26
  case 'me':
68
- return swarmWhoami();
69
27
  case 'dispatch':
70
28
  case 'run':
71
- return swarmDispatch(rest, values);
72
29
  case 'forget':
73
30
  case 'rm':
74
- return swarmForget(rest);
31
+ console.log(' The node swarm registry and dispatch protocol were retired.');
32
+ console.log(dim(' Use beehaven swarm bees | sample-honey | forge-omni for Queen and Omni.'));
33
+ return;
75
34
  // The bees — 👑 Queen (samples all the honey) + 🐝 Omni (the owner's twin).
76
35
  case 'bees':
77
36
  return swarmBees();
@@ -83,121 +42,8 @@ export async function cmdSwarm(positionals, values) {
83
42
  return swarmForgeOmni(values);
84
43
  default:
85
44
  console.log(` Unknown swarm subcommand '${sub}'.`);
86
- console.log(dim(' Try: beehaven swarm list | queen | role | whoami | dispatch | forget | bees | sample-honey | forge-omni'));
87
- }
88
- }
89
- async function swarmList() {
90
- let res;
91
- try {
92
- res = unwrap(await rpcOnce('swarm-list', {}, 8_000));
93
- }
94
- catch {
95
- console.log(red(' Cannot reach the swarm.') + dim(' Is the daemon running? beehaven status'));
96
- return;
97
- }
98
- const beehives = res?.beehives ?? [];
99
- if (!beehives.length) {
100
- console.log('');
101
- console.log(' 🐝 No beehives registered yet.');
102
- console.log(dim(' This machine registers automatically when the daemon connects.'));
103
- console.log(dim(' Bring more online: `beehaven start --headless` on a server, or a cloud container.'));
104
- console.log('');
105
- return;
106
- }
107
- const me = thisDeviceId();
108
- console.log('');
109
- console.log(` 🐝 ${bold('Swarm')} ${dim(`— ${res.online}/${res.count} online`)}`);
110
- console.log(dim(' ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
111
- for (const b of beehives) {
112
- const dot = b.online ? green('●') : dim('○');
113
- const crown = b.role === 'queen' ? '👑' : '🐝';
114
- const mine = b.deviceId === me ? cyan(' ← this machine') : '';
115
- const caps = (b.capabilities ?? []).slice(0, 8).join(', ') || dim('no hives');
116
- console.log(` ${dot} ${crown} ${cyan(String(b.hostname).padEnd(22))} ${dim(String(b.kind).padEnd(15))} ${(b.role === 'queen' ? yellow('queen') : 'worker').padEnd(7)}${mine}`);
117
- console.log(` ${dim(b.deviceId)}`);
118
- console.log(` ${dim('hives:')} ${caps}${b.load ? dim(` load:${b.load}`) : ''}`);
119
- }
120
- console.log('');
121
- console.log(dim(` queen: ${res.queen ? green(res.queen) : 'none — promote one with `beehaven swarm role queen`'}`));
122
- console.log('');
123
- }
124
- async function swarmQueen() {
125
- let res;
126
- try {
127
- res = unwrap(await rpcOnce('swarm-queen', {}, 8_000));
128
- }
129
- catch {
130
- console.log(red(' Cannot reach the swarm.'));
131
- return;
132
- }
133
- const q = res?.queen;
134
- console.log('');
135
- if (!q) {
136
- console.log(' 👑 No queen designated.');
137
- console.log(dim(' Make this machine the queen: beehaven swarm role queen'));
138
- }
139
- else {
140
- console.log(` 👑 ${bold('Queen')} — ${cyan(q.hostname)} ${q.online ? green('(online)') : dim('(offline)')}`);
141
- console.log(` ${dim(q.deviceId)} · ${dim(q.kind)}`);
142
- console.log(` ${dim('hives:')} ${(q.capabilities ?? []).join(', ') || dim('none')}`);
143
- }
144
- console.log('');
145
- }
146
- async function swarmDispatch(rest, values) {
147
- const capability = rest[0];
148
- const action = rest[1];
149
- if (!capability || !action) {
150
- console.log(' Usage: beehaven swarm dispatch <capability> <action> [json]');
151
- console.log(dim(' capability = the hive to run (e.g. motion-studio, voice)'));
152
- console.log(dim(' e.g. beehaven swarm dispatch voice synthesize \'{"text":"hi"}\''));
153
- return;
154
- }
155
- let input = {};
156
- if (rest[2]) {
157
- try {
158
- input = JSON.parse(rest[2]);
159
- }
160
- catch {
161
- console.log(red(' Invalid JSON payload.'));
162
- return;
163
- }
45
+ console.log(dim(' Try: beehaven swarm bees | sample-honey | forge-omni'));
164
46
  }
165
- const targetDeviceId = typeof values?.target === 'string' ? values.target : undefined;
166
- console.log(dim(` → dispatching ${capability}:${action}${targetDeviceId ? ` @${targetDeviceId}` : ' to the best worker'}…`));
167
- let res;
168
- try {
169
- res = unwrap(await rpcOnce('swarm-dispatch', { capability, action, input, targetDeviceId }, 300_000));
170
- }
171
- catch (e) {
172
- console.log(red(` Dispatch failed: ${e?.message ?? e}`));
173
- return;
174
- }
175
- if (res?.error || res?.ok === false) {
176
- console.log(red(` ✗ ${res.error ?? 'dispatch failed'}`) + (res.code ? dim(` [${res.code}]`) : ''));
177
- return;
178
- }
179
- console.log(green(` ✓ ${capability}:${action}`) + dim(` on ${res.targetDeviceId} · ${res.durationMs}ms`));
180
- console.log(JSON.stringify(res.result, null, 2));
181
- }
182
- async function swarmForget(rest) {
183
- const deviceId = rest[0];
184
- if (!deviceId) {
185
- console.log(' Usage: beehaven swarm forget <deviceId>');
186
- return;
187
- }
188
- let res;
189
- try {
190
- res = unwrap(await rpcOnce('swarm-forget', { deviceId }, 8_000));
191
- }
192
- catch (e) {
193
- console.log(red(` ${e?.message ?? e}`));
194
- return;
195
- }
196
- if (res?.error) {
197
- console.log(red(` ✗ ${res.error}`));
198
- return;
199
- }
200
- console.log(green(` ✓ forgot beehive ${deviceId}`));
201
47
  }
202
48
  // ══════════════════════════════ the bees ══════════════════════════════
203
49
  // 👑 Queen samples ALL the honey (the full corpus, gets fat); 🐝 Omni is the
@@ -283,59 +129,3 @@ async function swarmForgeOmni(values) {
283
129
  console.log(dim(` Log in as your twin: ${res.loginCommand || 'beehaven agent login omni-bee'}`));
284
130
  console.log('');
285
131
  }
286
- // ─────────────────────── this machine's role/identity ───────────────────────
287
- async function swarmRole(rest) {
288
- const role = (rest[0] ?? '').toLowerCase();
289
- if (role !== 'queen' && role !== 'worker') {
290
- const current = loadConfig().role ?? (process.env.BEEHAVEN_HEADLESS === '1' ? 'worker' : 'queen');
291
- console.log(' Usage: beehaven swarm role <queen|worker>');
292
- console.log(dim(` This machine is currently: ${current === 'queen' ? yellow('👑 queen') : 'worker'}`));
293
- return;
294
- }
295
- // 1) Persist locally so it survives restarts + the daemon re-registers with it.
296
- saveConfig({ role });
297
- // 2) Update the cloud row immediately so the swarm reflects it now (the daemon
298
- // catches up its own role on its next register, ~2 min, or `beehaven restart`).
299
- const deviceId = thisDeviceId();
300
- let synced = false;
301
- try {
302
- const r = unwrap(await rpcOnce('hive-set-role', { deviceId, role }, 8_000));
303
- synced = !!r?.ok;
304
- }
305
- catch {
306
- /* daemon offline — local config still saved; applies on next connect */
307
- }
308
- console.log('');
309
- console.log(` ${green('✓')} This machine is now the ${role === 'queen' ? yellow('👑 queen hive') : 'worker hive'}.`);
310
- console.log(dim(synced
311
- ? ' Synced to the swarm. It orchestrates from here.'
312
- : ' Saved locally — applies when the daemon next connects (beehaven restart to apply now).'));
313
- console.log('');
314
- }
315
- async function swarmWhoami() {
316
- const cfg = loadConfig();
317
- const deviceId = thisDeviceId();
318
- const role = cfg.role ?? (process.env.BEEHAVEN_HEADLESS === '1' ? 'worker' : 'queen');
319
- const kind = process.env.BEEHAVEN_KIND ?? (process.env.BEEHAVEN_HEADLESS === '1' ? 'headless' : 'local-mac');
320
- console.log('');
321
- console.log(` 🐝 ${bold('This beehive')}`);
322
- console.log(` deviceId: ${cyan(deviceId)}`);
323
- console.log(` role: ${role === 'queen' ? yellow('👑 queen') : 'worker'} ${dim('(beehaven swarm role <queen|worker>)')}`);
324
- console.log(` kind: ${kind}`);
325
- // Best-effort live view from the swarm registry.
326
- try {
327
- const res = unwrap(await rpcOnce('swarm-list', {}, 5_000));
328
- const me = (res?.beehives ?? []).find((b) => b.deviceId === deviceId);
329
- if (me) {
330
- console.log(` online: ${me.online ? green('yes') : dim('no')}`);
331
- console.log(` hives: ${(me.capabilities ?? []).join(', ') || dim('none')}`);
332
- }
333
- else {
334
- console.log(dim(' not yet registered in the swarm — the daemon registers on connect.'));
335
- }
336
- }
337
- catch {
338
- /* daemon offline */
339
- }
340
- console.log('');
341
- }
package/dist/daemon.js CHANGED
@@ -45,7 +45,6 @@ import { join, dirname, relative } from 'path';
45
45
  import { fileURLToPath } from 'url';
46
46
  import { compareVersions, usableUpdateDigest } from './version-utils.js';
47
47
  import { installKind } from './commands/self-update.js';
48
- import { collectSystemTelemetry, collectGitStatus } from './telemetry.js';
49
48
  const __dirname = dirname(fileURLToPath(import.meta.url));
50
49
  const CONFIG_DIR = join(homedir(), '.beehaven');
51
50
  const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
@@ -2502,9 +2501,27 @@ export async function startDaemon(opts) {
2502
2501
  });
2503
2502
  });
2504
2503
  // Local client raw sends → forward to DO via relay
2505
- ipc.on('send', (msg) => {
2506
- if (relay.isConnected()) {
2507
- relay.wsSend(msg);
2504
+ const ipcLiveQueries = new Map();
2505
+ ipc.on('send', (msg, clientId) => {
2506
+ if (!relay.isConnected() || !relay.wsSend(msg))
2507
+ return;
2508
+ const queryId = typeof msg?.queryId === 'string' ? msg.queryId : '';
2509
+ if (!queryId || !clientId)
2510
+ return;
2511
+ if (msg.type === 'sql:subscribe') {
2512
+ if (!ipcLiveQueries.has(clientId)) {
2513
+ ipcLiveQueries.set(clientId, new Set());
2514
+ ipc.onClientDisconnect(clientId, () => {
2515
+ for (const ownedId of ipcLiveQueries.get(clientId) ?? []) {
2516
+ relay.wsSend({ type: 'sql:unsubscribe', queryId: ownedId });
2517
+ }
2518
+ ipcLiveQueries.delete(clientId);
2519
+ });
2520
+ }
2521
+ ipcLiveQueries.get(clientId).add(queryId);
2522
+ }
2523
+ else if (msg.type === 'sql:unsubscribe') {
2524
+ ipcLiveQueries.get(clientId)?.delete(queryId);
2508
2525
  }
2509
2526
  });
2510
2527
  // Local client HTTP proxy: make a fetch with the daemon's Firebase ID
@@ -3060,57 +3077,6 @@ export async function startDaemon(opts) {
3060
3077
  if (daemonAppManager) {
3061
3078
  relay.sendLocalAppStatus(daemonAppManager.status());
3062
3079
  }
3063
- // Capabilities may have changed (install/uninstall) — re-advertise this
3064
- // node's beehive record so the swarm's dispatch matching stays accurate.
3065
- registerBeehive();
3066
- }
3067
- // ── Distributed hive mesh — advertise this daemon as a beehive ──
3068
- //
3069
- // The node declares its ROLE (queen orchestrates / worker executes), its
3070
- // KIND (this Mac / a headless server / a cloud container), and its
3071
- // CAPABILITIES (the hives it can run — the dispatch match keys). The user's
3072
- // Mac defaults to QUEEN (the natural orchestrator — where the human is); a
3073
- // headless/container daemon defaults to WORKER. `beehaven swarm role` (config
3074
- // `role`) or BEEHAVEN_ROLE overrides. See rpc/swarm-rpcs.ts for the queen
3075
- // + dispatch side.
3076
- function beehiveRole() {
3077
- const env = (process.env.BEEHAVEN_ROLE || '').toLowerCase();
3078
- if (env === 'queen' || env === 'worker')
3079
- return env;
3080
- const cfgRole = String(loadConfig()?.role || '').toLowerCase();
3081
- if (cfgRole === 'queen' || cfgRole === 'worker')
3082
- return cfgRole;
3083
- return process.env.BEEHAVEN_HEADLESS === '1' ? 'worker' : 'queen';
3084
- }
3085
- function beehiveKind() {
3086
- const env = (process.env.BEEHAVEN_KIND || '').toLowerCase();
3087
- if (env === 'local-mac' || env === 'headless' || env === 'cloud-container')
3088
- return env;
3089
- return process.env.BEEHAVEN_HEADLESS === '1' ? 'headless' : 'local-mac';
3090
- }
3091
- function beehiveCapabilities() {
3092
- try {
3093
- const s = daemonAppManager?.status();
3094
- const caps = new Set(Array.isArray(s?.buildingTypes) ? s.buildingTypes : []);
3095
- // Surface app names too so `swarm list` reads friendly (motion-studio,
3096
- // voice, recorder …) even before a building instance has spun up.
3097
- for (const a of s?.apps ?? [])
3098
- if (a?.name)
3099
- caps.add(String(a.name));
3100
- return [...caps];
3101
- }
3102
- catch {
3103
- return [];
3104
- }
3105
- }
3106
- function registerBeehive() {
3107
- if (!relay.isConnected())
3108
- return;
3109
- relay.sendSwarmRegister({
3110
- role: beehiveRole(),
3111
- kind: beehiveKind(),
3112
- capabilities: beehiveCapabilities(),
3113
- });
3114
3080
  }
3115
3081
  /** Sync a single uninstall to the Home DO. */
3116
3082
  function syncUninstallToCloud(name) {
@@ -4221,18 +4187,6 @@ export async function startDaemon(opts) {
4221
4187
  setTimeout(() => {
4222
4188
  syncAvatarFromCloud().catch(() => { });
4223
4189
  }, 250);
4224
- // Register as a beehive the moment the WS opens so the node appears in
4225
- // the swarm immediately; syncInstalledAppsToCloud + the periodic tick
4226
- // below re-register with the full capability list once hives finish
4227
- // loading. Deferred slightly so the capability scan sees loaded hives.
4228
- setTimeout(() => {
4229
- try {
4230
- registerBeehive();
4231
- }
4232
- catch {
4233
- /* best-effort */
4234
- }
4235
- }, 500);
4236
4190
  // #111 — if startup rehydrated a Claude credential from keychain,
4237
4191
  // tell the worker now that the WS is open. Worker handler at
4238
4192
  // `case 'canvas-credential-rehydrated':` refreshes daemon_confirmed_at
@@ -4429,42 +4383,9 @@ export async function startDaemon(opts) {
4429
4383
  // Auto-update: check hourly, install when idle
4430
4384
  checkAndAutoUpdate();
4431
4385
  setInterval(() => checkAndAutoUpdate(), UPDATE_CHECK_INTERVAL);
4432
- // Telemetry: opt-in via config.shareTelemetry (default off, togglable from cloud)
4433
- // Sends system stats + agent metrics + git status every 2 minutes
4434
- let lastActiveCwd = null;
4435
- watcher.on('event', (e) => {
4436
- if (e.cwd)
4437
- lastActiveCwd = e.cwd;
4438
- });
4439
- const sendTelemetry = () => {
4440
- if (!daemonConfig?.shareTelemetry || !relay.isConnected())
4441
- return;
4442
- try {
4443
- const system = collectSystemTelemetry();
4444
- const agentSnapshot = metrics.snapshot();
4445
- const git = lastActiveCwd ? collectGitStatus(lastActiveCwd) : null;
4446
- relay.sendTelemetry({ system, git, agent: agentSnapshot });
4447
- }
4448
- catch {
4449
- /* non-critical */
4450
- }
4451
- };
4452
- setTimeout(sendTelemetry, 10_000);
4453
- setInterval(sendTelemetry, 120_000);
4454
- // Reset metrics window every 5 minutes
4386
+ // Reset the LOCAL metrics window every 5 minutes (no network).
4455
4387
  setInterval(() => metrics.resetWindow(), 5 * 60_000);
4456
- // Re-advertise this beehive every 2 min: refreshes last_seen and, crucially,
4457
- // self-heals the swarm's live routing map after a Home-DO hibernation dropped
4458
- // it (the WS survives hibernation, so without this the node would read
4459
- // "offline" until its next reconnect). Cheap — one WS frame.
4460
- setInterval(() => {
4461
- try {
4462
- registerBeehive();
4463
- }
4464
- catch {
4465
- /* best-effort */
4466
- }
4467
- }, 120_000);
4388
+ // No timed telemetry or swarm-register frames: an idle daemon must cost nothing.
4468
4389
  // Start REPL
4469
4390
  if (opts?.repl !== false && !process.env.BEEHAVEN_NO_REPL)
4470
4391
  repl.start();
@@ -471,7 +471,7 @@ export class IpcServer extends EventEmitter {
471
471
  break;
472
472
  case 'send':
473
473
  // Forward raw message to relay → DO
474
- this.emit('send', msg.msg);
474
+ this.emit('send', msg.msg, client.id);
475
475
  break;
476
476
  case 'app-rpc':
477
477
  // Forward RPC to a local app building (not the cloud relay).
package/dist/relay.js CHANGED
@@ -522,21 +522,17 @@ export class Relay {
522
522
  this.scheduleReconnect();
523
523
  return;
524
524
  }
525
- // The daemon holds ONE socket — to the user's HIVE (`/my/hive/ws`, the per-user
526
- // multiplexer). The hive opens a server-side portal to the caller's CANONICAL workspace
527
- // (no `workspaceId` → the hive resolves it from `building_assignments`) and pipes it
528
- // transparently, so every workspace RPC (canvas-invoke, actions, table sync) round-trips
529
- // exactly as before — plus the daemon shares the same socket the web app uses. (Plain
530
- // synchronous URL — no pre-connect HTTP hop — so nothing can stall the dial.)
525
+ // Workspace traffic terminates on the workspace DO itself. A Hive portal can close after
526
+ // 60 s while leaving the daemon socket open; then cloud pushes and local-tool requests
527
+ // disappear until the daemon sends another frame. The direct socket hibernates safely.
531
528
  const params = new URLSearchParams({
532
529
  token,
533
530
  client: process.env.BEEHAVEN_CLIENT || 'daemon',
534
531
  clientType: process.env.BEEHAVEN_CLIENT_TYPE || 'daemon',
535
- wsType: 'workspace',
536
532
  });
537
533
  if (this.deviceId)
538
534
  params.set('deviceId', String(this.deviceId).slice(0, 64));
539
- const url = `${this.wsBase()}/my/hive/ws?${params.toString()}`;
535
+ const url = `${this.wsBase()}/my/workspace/ws?${params.toString()}`;
540
536
  const ws = new WebSocket(url);
541
537
  // Wait for open or first error/close before resolving
542
538
  await new Promise((resolve) => {
@@ -1228,34 +1224,6 @@ export class Relay {
1228
1224
  sendLocalAppStatus(status) {
1229
1225
  this.wsSend({ type: 'local-app-status', ...status });
1230
1226
  }
1231
- /**
1232
- * Advertise this daemon as a BEEHIVE in the distributed hive mesh.
1233
- *
1234
- * The Home DO's `case 'swarm-register'` upserts a durable node row (keyed by
1235
- * this stable deviceId) + maps deviceId → this live session, which is how the
1236
- * swarm knows the node is online and how the queen targets a dispatch at it.
1237
- * Re-sent on connect, whenever capabilities change, and on a periodic cadence
1238
- * (see daemon.ts `registerBeehive`) so it also serves as the beehive's
1239
- * keepalive and self-heals after a DO hibernation dropped the live map.
1240
- *
1241
- * role 'queen' (orchestrator) | 'worker' (executor)
1242
- * kind 'local-mac' | 'headless' | 'cloud-container'
1243
- * capabilities the hive/building names this node can run (dispatch match keys)
1244
- */
1245
- sendSwarmRegister(opts) {
1246
- if (!this.connected)
1247
- return;
1248
- this.wsSend({
1249
- type: 'swarm-register',
1250
- deviceId: this.deviceId,
1251
- role: opts.role,
1252
- kind: opts.kind,
1253
- capabilities: opts.capabilities,
1254
- hostname: hostname(),
1255
- os: platform(),
1256
- root: homedir(),
1257
- });
1258
- }
1259
1227
  /** Start periodic token self-refresh (every 50 min, for headless/long-running daemons) */
1260
1228
  tokenRefreshTimer = null;
1261
1229
  startTokenRefresh() {
@@ -140,6 +140,7 @@ export const VERB_SURFACE = {
140
140
  describe: { cls: 'BEYOND', why: 'alias', aliasOf: 'explain' },
141
141
  rpc: { cls: 'BEYOND', why: 'the raw gateway envelope, below `call`' },
142
142
  ticket: { cls: 'BEYOND', why: 'resolves a board before creating, and refuses a numeric priority the API inverts' },
143
+ inbox: { cls: 'PROVISIONAL', why: 'reads and manages workspace message threads; keep until door traffic is measured' },
143
144
  comment: { cls: 'BEYOND', why: 'addresses ANY surface by key/title and turns per-surface anchor flags into one call; prints who the @s reached' },
144
145
  comments: { cls: 'BEYOND', why: 'served by the comment module', aliasOf: 'comment' },
145
146
  mention: { cls: 'BEYOND', why: 'resolves an 8-char id prefix before acking, and reads your mention queue as whichever identity you are' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clearlysh/beehaven",
3
- "version": "0.8.20",
3
+ "version": "0.8.22",
4
4
  "description": "Beehaven CLI — command your Clearly workspace, agents, and canvas from the terminal",
5
5
  "private": false,
6
6
  "type": "module",