oomi-ai 0.13.0 → 0.15.0

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/README.md CHANGED
@@ -109,10 +109,14 @@ oomi connect --runtime hermes --name hermes --app-url https://www.oomi.ai
109
109
  oomi connect --runtime command --name my-agent --command '["/absolute/path/to/adapter"]' --app-url https://www.oomi.ai
110
110
  ```
111
111
 
112
- Use the user's app URL when provided. Hermes supports `--profile <profile>` and `--resume <exact-session-id>`. Without `--resume`, Oomi starts a persistent conversation with the same configured agent. Do not use `latest` or claim that an existing chat session was transferred unless its exact ID was selected. With oomi-ai 0.8.2+, an already-open Hermes conversation uses its existing local gateway owner and exact profile/session. Oomi attaches as another client; it never closes desktop, clears history, deletes a session lock, or substitutes a new chat. When no live owner exists, an Oomi-owned conversation (no `--resume`) runs on a warm `hermes acp` process with oomi-ai 0.9.0+: replies stream as they are written and stop when the person interrupts. From 0.9.1 the bridge starts Hermes and reopens recent conversations ahead of time (at bridge start and when a call opens), so the first message doesn't wait for Hermes to start. Hermes permission requests are denied, as `chat --quiet` denies dangerous commands; ordinary file edits run as they do in quiet mode. A conversation moving from the CLI starts a new Hermes session that receives the recent Oomi history. `--resume` conversations, Hermes without ACP, and `--hermes-transport cli` use `chat --quiet --query-file -` and resume the exact returned `session_id` on subsequent turns.
112
+ If your person's message has a pairing code or an `oomi.ai/pair/...` link, add `--pair CODE` to that command; the code or the whole link both work. An older package does not know `--pair`: update with `npm install -g oomi-ai@latest` first. You then ask to join their oomi account instead of handing them a link: the command says hello, connects as usual, and waits up to five minutes for them to say yes in oomi. Tell them "I've asked to join. Say yes in oomi." `Connected.` means they said yes. `Still waiting` means the bridge is running and they can still say yes while the prompt lasts. `Not connected` means they declined, cancelled, or the code expired; ask them before trying again. If the command prints an Auth Link instead (an expired code, a code another agent used, or a server that doesn't take codes), send that link to your person. The code works for one agent, so never pass it on. Your person sees the name and runtime you registered and this computer's host name, so they can tell it's you; `--computer "Desk PC"` shows a different label.
113
+
114
+ Use the user's app URL when provided. Hermes supports `--profile <profile>` and `--resume <exact-session-id>`. Without `--resume`, Oomi starts a persistent conversation with the same configured agent. Do not use `latest` or claim that an existing chat session was transferred unless its exact ID was selected. With oomi-ai 0.8.2+, an already-open Hermes conversation uses its existing local gateway owner and exact profile/session. Oomi attaches as another client; it never closes desktop, clears history, deletes a session lock, or substitutes a new chat. When no live owner exists, an Oomi-owned conversation (no `--resume`) runs on a warm `hermes acp` process with oomi-ai 0.9.0+: replies stream as they are written and stop when the person interrupts. From 0.9.1 the bridge starts Hermes and reopens recent conversations ahead of time (at bridge start and when a call opens), so the first message doesn't wait for Hermes to start. Hermes permission requests are denied, as `chat --quiet` denies dangerous commands; ordinary file edits run as they do in quiet mode. A conversation moving from the CLI starts a new Hermes session that receives the recent Oomi history. `--resume` conversations, Hermes without ACP, and `--hermes-transport cli` use `chat --quiet --query-file -` and resume the exact returned `session_id` on subsequent turns. If the connection check gets no answer over ACP and you did not pass `--hermes-transport`, `connect` retries once over the quiet CLI and keeps that connection on it; an explicit `--hermes-transport acp` fails instead.
113
115
 
114
116
  Shared desktop conversations require Hermes's loopback WebSocket gateway, active-session discovery, and durable prompt/reply row IDs. Busy conversations ask you to retry after the current task. If a simultaneous desktop send queues your message without a reply receipt, or the connection drops after sending, check the same Hermes chat before resending. Oomi cannot safely repeat an uncertain action. Human approvals stay in the existing Hermes desktop UI. Shared photo submission is not yet supported; use Hermes desktop for that photo. Older or terminal-only owners without a shared gateway receive an actionable error, never a competing process. The shared owner keeps its existing environment, so use the explicit Oomi `--connection NAME` for account commands.
115
117
 
118
+ From 0.14.0, messages the person types to the persona on the computer, in a conversation Oomi shares (Hermes desktop, or oomi's Talk showing the phone's conversation), join that Oomi conversation with the persona's reply, and the person's open Oomi chats (web, phone) reload within about a second. The bridge watches Hermes's `state.db` and reads the conversation from the running Hermes backend's transcript (`/api/sessions/{id}/messages`, the one Hermes desktop shows), only between its own turns. It copies what the person and the persona said, never tool output, and starts counting from its first run with this release; earlier computer messages aren't copied. Its own phone and web turns are recognised by Hermes's row ids or by their words, never by the time alone, and a phone or web message first picks up what was just typed on the computer, so the order holds. It reads only conversations Hermes changed, back to its last look; far behind, it reads forward from the last look a chunk at a time, so nothing is skipped. While no Hermes backend runs, nothing on the computer but the bridge (and Hermes's CLI by hand) can write to its conversations, so its own turns are settled without a read; rows written while a backend ran are picked up when one runs again, retried every 30 seconds and as soon as one starts. A phone or web turn waits at most a quarter second for what was just typed on the computer. A conversation record keeps its newest 1,000 messages and 200 finished receipts; a receipt for an action that never finished is always kept.
119
+
116
120
  The command verifies a real local reply, reuses saved credentials or pairs once, starts the bridge, waits for Oomi's subscription, then creates a single-use Auth Link. Failed verification means setup is incomplete: repair the selected runtime, never substitute a different one.
117
121
 
118
122
  The installer is an alternative to npm plus connect, and requires an explicit runtime:
@@ -169,7 +173,7 @@ oomi bridge repair --name hermes
169
173
  oomi invite --name hermes --app-url https://www.oomi.ai
170
174
  ```
171
175
 
172
- Do not pair again to refresh an expired Auth Link. Re-running `connect` reuses saved pairing and verification; only the first connection or an explicit `oomi verify` sends a model probe. A different command, profile, or working directory requires a new connection name, so one agent cannot silently replace another. Named connections store private state and logs under `~/.oomi/connections/<name>`; default OpenClaw keeps `~/.openclaw`. Since 0.8.0, `connect` installs a separate automatic-start service for each connection: macOS launchd or Linux systemd user. It restarts an exited worker and starts at the next login/user session. Linux servers can start at boot and remain running after logout when the host administrator enables user lingering (`loginctl enable-linger <user>`); `oomi bridge service status --name hermes` reports whether this is enabled. WSL needs systemd and a running WSL instance; native Windows does not yet have an automatic service installer. A sleeping, powered-off, or disconnected computer remains unavailable.
176
+ Do not pair again to refresh an expired Auth Link. Re-running `connect` reuses saved pairing and verification; only the first connection or an explicit `oomi verify` sends a model probe. A different command, profile, or working directory requires a new connection name, so one agent cannot silently replace another. Named connections store private state and logs under `~/.oomi/connections/<name>`; default OpenClaw keeps `~/.openclaw`. Since 0.8.0, `connect` installs a separate automatic-start service for each connection: macOS launchd, Linux systemd user, or (from 0.15.0) on Windows oomi's own supervisor, started from your Run key at sign-in. It restarts an exited worker and starts at the next login/user session. Linux servers can start at boot and remain running after logout when the host administrator enables user lingering (`loginctl enable-linger <user>`); `oomi bridge service status --name hermes` reports whether this is enabled. WSL needs systemd and a running WSL instance. Native Windows needs no administrator rights: the bridge runs while you are signed in to Windows and stops when you sign out. `--no-sign-in` keeps that worker recovery without writing the Run key (`--sign-in` turns it back on), and a Run key that Windows refuses no longer keeps the bridge from starting; `oomi status` says which of the two protections hold. A bridge started from inside another app, such as the Claude desktop app, stops whenever that app updates or restarts until sign-in starts it again, so start it from your own terminal or sign out and back in once. A sleeping, powered-off, or disconnected computer remains unavailable.
173
177
 
174
178
  Run `oomi bridge list` to find saved connection names and their startup protection on this computer. To update an existing connection on **each computer**, follow Updating Oomi safely above. Repair preserves pairing and conversations. On a running 0.8.1+ supervised bridge it queues a safe restart and reports pending work; on a stopped bridge it installs/starts supervision and waits for the broker connection. It does not send a model probe or switch agents. Do not copy connection credentials between computers.
175
179
 
@@ -354,7 +358,7 @@ Bridge status meanings:
354
358
  - `reconnecting`: transport dropped and retry is scheduled
355
359
  - `degraded`: bridge caught a runtime fault but is still alive
356
360
  - `error`: startup or auth failure blocked useful operation
357
- - `stopped`: not running or intentionally stopped
361
+ - `stopped`: not running or intentionally stopped. When the recorded process has ended without writing anything (a crash, `SIGKILL`, or Windows ending it outright), `oomi status` and `oomi bridge list` report `stopped` with `unrecordedExit: true` and `lastPid`, whatever the file last said
358
362
 
359
363
  ## Troubleshooting
360
364
 
@@ -203,6 +203,8 @@ oomi connect --runtime hermes --name hermes --app-url https://www.oomi.ai
203
203
  oomi connect --runtime command --name my-agent --command '["/absolute/path/to/adapter"]' --app-url https://www.oomi.ai
204
204
  ```
205
205
 
206
+ If your person's message has a pairing code or an `oomi.ai/pair/...` link, add `--pair CODE` to that command; the code or the whole link both work. An older package does not know `--pair`: update with `npm install -g oomi-ai@latest` first. You then ask to join their oomi account instead of handing them a link: the command says hello, connects as usual, and waits up to five minutes for them to say yes in oomi. Tell them "I've asked to join. Say yes in oomi." `Connected.` means they said yes. `Still waiting` means the bridge is running and they can still say yes while the prompt lasts. `Not connected` means they declined, cancelled, or the code expired; ask them before trying again. If the command prints an Auth Link instead (an expired code, a code another agent used, or a server that doesn't take codes), send that link to your person. The code works for one agent, so never pass it on. Your person sees the name and runtime you registered and this computer's host name, so they can tell it's you; `--computer "Desk PC"` shows a different label.
207
+
206
208
  Use the user's app URL when provided. Hermes supports `--profile <profile>` and `--resume <exact-session-id>`. Without `--resume`, Oomi starts a persistent conversation with the same configured agent. Do not use `latest` or claim that an existing chat session was transferred unless its exact ID was selected. With oomi-ai 0.8.2+, an already-open Hermes conversation uses its existing local gateway owner and exact profile/session. Oomi attaches as another client; it never closes desktop, clears history, deletes a session lock, or substitutes a new chat. When no live owner exists, Hermes uses `chat --quiet --query-file -` and resumes the exact returned `session_id` on subsequent turns.
207
209
 
208
210
  Shared desktop conversations require Hermes's loopback WebSocket gateway, active-session discovery, and durable prompt/reply row IDs. Busy conversations ask you to retry after the current task. If a simultaneous desktop send queues your message without a reply receipt, or the connection drops after sending, check the same Hermes chat before resending. Oomi cannot safely repeat an uncertain action. Human approvals stay in the existing Hermes desktop UI. Shared photo submission is not yet supported; use Hermes desktop for that photo. Older or terminal-only owners without a shared gateway receive an actionable error, never a competing process. The shared owner keeps its existing environment, so use the explicit Oomi `--connection NAME` for account commands.
@@ -263,7 +265,7 @@ oomi bridge repair --name hermes
263
265
  oomi invite --name hermes --app-url https://www.oomi.ai
264
266
  ```
265
267
 
266
- Do not pair again to refresh an expired Auth Link. Re-running `connect` reuses saved pairing and verification; only the first connection or an explicit `oomi verify` sends a model probe. A different command, profile, or working directory requires a new connection name, so one agent cannot silently replace another. Named connections store private state and logs under `~/.oomi/connections/<name>`; default OpenClaw keeps `~/.openclaw`. Since 0.8.0, `connect` installs a separate automatic-start service for each connection: macOS launchd or Linux systemd user. It restarts an exited worker and starts at the next login/user session. Linux servers can start at boot and remain running after logout when the host administrator enables user lingering (`loginctl enable-linger <user>`); `oomi bridge service status --name hermes` reports whether this is enabled. WSL needs systemd and a running WSL instance; native Windows does not yet have an automatic service installer. A sleeping, powered-off, or disconnected computer remains unavailable.
268
+ Do not pair again to refresh an expired Auth Link. Re-running `connect` reuses saved pairing and verification; only the first connection or an explicit `oomi verify` sends a model probe. A different command, profile, or working directory requires a new connection name, so one agent cannot silently replace another. Named connections store private state and logs under `~/.oomi/connections/<name>`; default OpenClaw keeps `~/.openclaw`. Since 0.8.0, `connect` installs a separate automatic-start service for each connection: macOS launchd, Linux systemd user, or (from 0.15.0) on Windows oomi's own supervisor, started from your Run key at sign-in. It restarts an exited worker and starts at the next login/user session. Linux servers can start at boot and remain running after logout when the host administrator enables user lingering (`loginctl enable-linger <user>`); `oomi bridge service status --name hermes` reports whether this is enabled. WSL needs systemd and a running WSL instance. Native Windows needs no administrator rights: the bridge runs while you are signed in to Windows and stops when you sign out. `--no-sign-in` keeps that worker recovery without writing the Run key (`--sign-in` turns it back on), and a Run key that Windows refuses no longer keeps the bridge from starting; `oomi status` says which of the two protections hold. A bridge started from inside another app, such as the Claude desktop app, stops whenever that app updates or restarts until sign-in starts it again, so start it from your own terminal or sign out and back in once. A sleeping, powered-off, or disconnected computer remains unavailable.
267
269
 
268
270
  Run `oomi bridge list` to find saved connection names and their startup protection on this computer. To update an existing connection on **each computer**, follow Updating Oomi safely above. Repair preserves pairing and conversations. On a running 0.8.1+ supervised bridge it queues a safe restart and reports pending work; on a stopped bridge it installs/starts supervision and waits for the broker connection. It does not send a model probe or switch agents. Do not copy connection credentials between computers.
269
271
 
package/bin/oomi-ai.js CHANGED
@@ -16,16 +16,17 @@ import { createGatewayRuns } from '../lib/gatewayRuns.js';
16
16
  import { CHAT_MODELS_CAPABILITY } from '../lib/chatModels.js';
17
17
  import { OpenclawModelRequests } from '../lib/openclawModels.js';
18
18
  import { startUpdateWatcher } from '../lib/updateWatcher.js';
19
- import { processCommand, readProcessTable } from '../lib/processTable.js';
19
+ import { processCommand, readProcessTable, isBridgeWorkerCommand as matchesBridgeWorker, liveBridgeStatus } from '../lib/processTable.js';
20
20
  import { bridgeServiceConfig, createBridgeService, renderLaunchAgent } from '../lib/bridgeService.js';
21
21
  import { LOCAL_PROTOCOL_MIN, LOCAL_PROTOCOL_MAX, probeGateway } from '../lib/gatewayProbe.js';
22
- import { LocalAgentRuntime, practiceContext, localAgentConfig, runLocalAgent, writePrivateJson, startChannelWorker } from '../lib/localAgent.js';
22
+ import { LocalAgentRuntime, practiceContext, localAgentConfig, runLocalAgent, hermesCliFallbackApplies, writePrivateJson, startChannelWorker } from '../lib/localAgent.js';
23
23
  import { validateAgentName, identityRequest, startIdentityWorker, handleIdentityCommand } from '../lib/agentIdentity.js';
24
24
  import { handleSpacesCommand, compactHealth } from '../lib/spaces.js';
25
25
  import { handleObjectivesCommand } from '../lib/objectives.js';
26
26
  import { handleRoutinesCommand, startRoutineEventWorker } from '../lib/routines.js';
27
27
  import { handleChannelCommand, startAgentChannelWorker } from '../lib/agentChannels.js';
28
28
  import { classifyRuntimeFailure } from '../lib/runtimeFailure.js';
29
+ import { parsePairCode, formatPairCode, pairHello, pairAnswer, waitForPairApproval, describePairOutcome, PAIR_POLL_MS, PAIR_WAIT_MS } from '../lib/pairingRequest.js';
29
30
  import { createPersonaApiClient } from '../lib/personaApiClient.js';
30
31
  import { inferSpokenMetadataFromContent, normalizeSpokenMetadata } from '../lib/spokenMetadata.js';
31
32
  import {
@@ -214,14 +215,18 @@ function usage() {
214
215
  Commands:
215
216
  update
216
217
  Check for a newer package and return a safe, approval-preserving update plan.
217
- connect --runtime openclaw|hermes|grokbot|command [--name CONNECTION] [--agent-name "Your name"] [--app-url URL]
218
+ connect --runtime openclaw|hermes|grokbot|command [--name CONNECTION] [--agent-name "Your name"] [--app-url URL] [--pair CODE]
218
219
  Verify the selected local agent, pair once, start its bridge, and return an Auth Link.
220
+ --pair CODE (or the oomi.ai/pair/CODE link from your person's prompt) asks to join their account instead:
221
+ the command waits up to 5 minutes for their yes and prints Connected. If the code can't be used, you get the Auth Link.
219
222
  Hermes: --hermes-home DIR --profile PROFILE [--hermes-command JSON_ARGV] [--resume SESSION_ID]
220
223
  Hermes: --profile PROFILE and --resume SESSION select the intended agent/session.
221
- Hermes: --hermes-transport auto|acp|cli (default auto streams replies over ACP when Hermes supports it).
224
+ Hermes: --hermes-transport auto|acp|cli (default auto streams replies over ACP when Hermes supports it,
225
+ and keeps the connection on the quiet CLI when the connection check gets no answer over ACP).
222
226
  Other agents: --command '["/absolute/path/to/adapter"]' (JSON stdin / JSON stdout).
223
227
  --cwd PATH selects the agent working directory; --name isolates multiple agents.
224
- Installs automatic startup on macOS/Linux. --no-service opts into external supervision.
228
+ Installs automatic startup on macOS, Linux and Windows. --no-service opts into external supervision.
229
+ Windows: --no-sign-in keeps worker recovery but doesn't start the bridge at sign-in (--sign-in turns it back on).
225
230
  status [--name NAME]
226
231
  Show broker connection and verified local agent health separately.
227
232
  verify [--name NAME]
@@ -235,8 +240,8 @@ Commands:
235
240
  Generate a fresh Auth Link from saved pairing without changing agents.
236
241
  bridge [start|ensure|stop|restart|repair|list|ps] [--name NAME] [--detach]
237
242
  Manage only the named agent's bridge. Repair restores supervision without re-pairing.
238
- bridge service [install|start|stop|restart|status|uninstall] [--name NAME]
239
- Manage automatic restart and startup (macOS launchd / Linux systemd user).
243
+ bridge service [install|start|stop|restart|status|uninstall] [--name NAME] [--sign-in|--no-sign-in]
244
+ Manage automatic restart and startup (macOS launchd / Linux systemd user / Windows sign-in).
240
245
 
241
246
  init
242
247
  Install Oomi agent instructions into OpenClaw AGENTS.md.
@@ -891,6 +896,9 @@ function currentBridgeService(runtime = readBridgeState().runtime) {
891
896
  logPath: resolveBridgeLiveLogPath(), scriptPath: fileURLToPath(import.meta.url),
892
897
  });
893
898
  const system = createBridgeService(config);
899
+ // Windows has neither launchd nor systemd: oomi's own supervisor restarts the worker, and the
900
+ // person's Run key starts it again at sign-in.
901
+ if (process.platform === 'win32') return createHostProcessService(config);
894
902
  if (runtime === 'grokbot' && process.platform === 'linux') {
895
903
  const host = createHostProcessService(config);
896
904
  if (fs.existsSync(host.config.file) || (!fs.existsSync(config.file) && !system.availability().available)) return host;
@@ -1045,12 +1053,7 @@ function isPidAlive(pid) {
1045
1053
  }
1046
1054
 
1047
1055
  function isBridgeWorkerCommand(command, connectionName = bridgeConnectionName) {
1048
- const text = String(command || '').trim().toLowerCase();
1049
- if (!/(?:oomi(?:-ai\.(?:js|mjs))?|openclaw)\s+bridge\b/.test(text)) return false;
1050
- const connection = text.match(/--(?:connection|name)[=\s]+([a-z0-9_-]+)/)?.[1] || '';
1051
- if (connection !== connectionName) return false;
1052
- if (/\bbridge\s+(ps|stop|restart|ensure|service)\b/.test(text)) return false;
1053
- return /\bbridge(?:\s+start)?(?:\s+--|$)/.test(text);
1056
+ return matchesBridgeWorker(command, connectionName);
1054
1057
  }
1055
1058
 
1056
1059
  function isBridgeProcess(pid) {
@@ -1064,6 +1067,12 @@ function isBridgeProcess(pid) {
1064
1067
  return isBridgeWorkerCommand(command);
1065
1068
  }
1066
1069
 
1070
+ // What the status file says, corrected by what is running: a bridge that died without writing
1071
+ // "stopped" is not connected (lib/processTable.js liveBridgeStatus).
1072
+ function readLiveBridgeStatus() {
1073
+ return liveBridgeStatus(readBridgeStatus(), isBridgeProcess);
1074
+ }
1075
+
1067
1076
  function readBridgeLock() {
1068
1077
  return readJsonSafe(resolveBridgeLockPath()) || {};
1069
1078
  }
@@ -2277,6 +2286,23 @@ function classifyBridgeFailure({ err, reason = '', code = '', forceClass = '' }
2277
2286
  };
2278
2287
  }
2279
2288
 
2289
+ // ActionCable uses disconnect for both planned restarts and refused credentials.
2290
+ // An explicit reconnect flag wins; older servers without one retry non-auth notices.
2291
+ function classifyBrokerDisconnect(payload = {}) {
2292
+ const reason = String(payload.reason || 'broker requested disconnect');
2293
+ const authFailure = /unauthorized|forbidden|invalid.?token|token.?expired/i.test(reason);
2294
+ const retryable = payload.reconnect === true || (payload.reconnect !== false && !authFailure);
2295
+ return {
2296
+ errorCode: retryable ? 'BROKER_DISCONNECT_RETRY' : 'BROKER_DISCONNECT_STOP',
2297
+ message: reason,
2298
+ failureClass: retryable ? 'network' : authFailure ? 'auth_rejected' : 'broker_disconnect_terminal',
2299
+ retryable,
2300
+ hint: retryable ? 'Broker requested a reconnect; retrying with backoff.'
2301
+ : 'Broker refused reconnect. Check the connection with its owner before re-pairing.',
2302
+ baseDelayMs: BRIDGE_RECONNECT_BASE_MS,
2303
+ };
2304
+ }
2305
+
2280
2306
  function computeReconnectDelayMs(attempt, baseDelayMs) {
2281
2307
  const growth = Math.min(BRIDGE_RECONNECT_MAX_MS, Math.round(baseDelayMs * (2 ** Math.max(0, attempt - 1))));
2282
2308
  const jitter = Math.floor(growth * (Math.random() * 0.25));
@@ -2645,6 +2671,8 @@ async function startOpenclawBridge(flags) {
2645
2671
  lastErrorMessage: '',
2646
2672
  consecutiveFailures: 0,
2647
2673
  pid: process.pid,
2674
+ // How an earlier process stopped says nothing about this one.
2675
+ stopSignal: null,
2648
2676
  startedAt: bridgeNowIso(),
2649
2677
  packageVersion: currentPackageVersion(),
2650
2678
  maintenanceProtocol: 1,
@@ -2820,6 +2848,26 @@ async function startOpenclawBridge(flags) {
2820
2848
  );
2821
2849
  };
2822
2850
 
2851
+ // Messages typed to the persona on this computer joined a conversation: Oomi tells the phone
2852
+ // and the web to reload it. Held until DeviceChannel confirms this connection's subscription.
2853
+ let conversationChangesReady = false;
2854
+ const pendingConversationChanges = new Map();
2855
+ const flushConversationChanges = () => {
2856
+ if (!conversationChangesReady || currentBrokerSocket?.readyState !== WebSocket.OPEN) return;
2857
+ for (const [sessionKey, reason] of pendingConversationChanges) {
2858
+ sendBrokerPayload(currentBrokerSocket, { action: 'conversation_changed', type: 'conversation.changed', sessionKey, reason });
2859
+ }
2860
+ pendingConversationChanges.clear();
2861
+ };
2862
+ if (localRuntime) {
2863
+ localRuntime.onConversationChanged = ({ sessionKey, reason }) => {
2864
+ if (!actionCableMode) return;
2865
+ pendingConversationChanges.set(sessionKey, pendingConversationChanges.get(sessionKey) === 'reply' ? 'reply' : reason);
2866
+ flushConversationChanges();
2867
+ };
2868
+ }
2869
+ const stopComputerTurns = localRuntime ? localRuntime.watchComputerTurns() : () => {};
2870
+
2823
2871
  const sendGatewayAck = (brokerSocket, {
2824
2872
  sessionId,
2825
2873
  requestId = '',
@@ -3013,6 +3061,7 @@ async function startOpenclawBridge(flags) {
3013
3061
  return {
3014
3062
  type: 'broker.disconnect',
3015
3063
  reason: String(payload.reason || ''),
3064
+ reconnect: payload.reconnect,
3016
3065
  };
3017
3066
  }
3018
3067
  if (payload.type === 'reject_subscription') {
@@ -3555,6 +3604,7 @@ async function startOpenclawBridge(flags) {
3555
3604
 
3556
3605
  brokerSocket.on('open', () => {
3557
3606
  bridgeDebugLog('[bridge] Connected to managed broker.');
3607
+ conversationChangesReady = false;
3558
3608
  reconnectState.attempt = 0;
3559
3609
  reconnectState.lastFailure = null;
3560
3610
  if (actionCableMode) {
@@ -3594,6 +3644,8 @@ async function startOpenclawBridge(flags) {
3594
3644
 
3595
3645
  if (payload.type === 'device.subscribed') {
3596
3646
  deviceChannelSubscribed = true;
3647
+ conversationChangesReady = true;
3648
+ flushConversationChanges();
3597
3649
  updateBridgeStatus({
3598
3650
  status: 'connected',
3599
3651
  deviceId,
@@ -3612,10 +3664,34 @@ async function startOpenclawBridge(flags) {
3612
3664
  }
3613
3665
 
3614
3666
  if (payload.type === 'broker.disconnect') {
3615
- reconnectState.lastFailure = classifyBridgeFailure({
3616
- reason: String(payload.reason || 'unauthorized'),
3617
- forceClass: 'auth_rejected',
3618
- });
3667
+ // ActionCable sends this notice for a planned restart too (audit C3/R6). That one reconnects
3668
+ // with backoff in this same process; only a refusal (an auth failure, or reconnect:false) stops it.
3669
+ const disconnect = classifyBrokerDisconnect(payload);
3670
+ if (disconnect.retryable) {
3671
+ reconnectState.lastFailure = disconnect;
3672
+ console.error(`[bridge] ${disconnect.hint}`);
3673
+ updateBridgeStatus({
3674
+ status: 'reconnecting',
3675
+ deviceId,
3676
+ brokerWs,
3677
+ brokerHttp,
3678
+ gatewayUrl: gateway.gatewayUrl,
3679
+ lastDisconnectAt: bridgeNowIso(),
3680
+ lastErrorCode: disconnect.errorCode,
3681
+ lastErrorClass: disconnect.failureClass,
3682
+ lastErrorMessage: disconnect.message,
3683
+ hint: disconnect.hint,
3684
+ consecutiveFailures: reconnectState.attempt + 1,
3685
+ pid: process.pid,
3686
+ });
3687
+ try {
3688
+ brokerSocket.close(1012, 'broker_restart');
3689
+ } catch {
3690
+ // The close handler schedules the reconnect either way.
3691
+ }
3692
+ return;
3693
+ }
3694
+ reconnectState.lastFailure = disconnect;
3619
3695
  reconnectState.stopped = true;
3620
3696
  console.error(`[bridge] Broker rejected connection: ${String(payload.reason || 'unauthorized')}`);
3621
3697
  console.error(`[bridge] ${reconnectState.lastFailure.hint}`);
@@ -3880,6 +3956,7 @@ async function startOpenclawBridge(flags) {
3880
3956
  }));
3881
3957
 
3882
3958
  brokerSocket.on('close', runBridgeCallbackSafely((code, reason) => {
3959
+ conversationChangesReady = false;
3883
3960
  if (actionCableHeartbeat) {
3884
3961
  clearInterval(actionCableHeartbeat);
3885
3962
  actionCableHeartbeat = null;
@@ -3931,6 +4008,7 @@ async function startOpenclawBridge(flags) {
3931
4008
  reconnectState.stopped = true;
3932
4009
  clearInterval(maintenanceTimer);
3933
4010
  stopChannelWorker();
4011
+ stopComputerTurns();
3934
4012
  stopIdentityWorker();
3935
4013
  stopRoutineWorker();
3936
4014
  agentChannelWorker.stop();
@@ -4149,8 +4227,8 @@ async function createOpenclawInviteLink(flags) {
4149
4227
 
4150
4228
  function printOpenclawBridgeStatus(flags) {
4151
4229
  const bridgeState = readBridgeState();
4152
- const runtimeStatus = readBridgeStatus();
4153
- if (runtimeStatus.pid && !isBridgeProcess(runtimeStatus.pid)) { runtimeStatus.status = 'stopped'; runtimeStatus.runtimeReady = false; }
4230
+ const runtimeStatus = readLiveBridgeStatus();
4231
+ const named = bridgeConnectionName ? ` --name ${bridgeConnectionName}` : '';
4154
4232
  const jsonOutput = isTruthyFlag(flags.json);
4155
4233
  const redactToken = (value) => {
4156
4234
  const text = String(value || '').trim();
@@ -4183,8 +4261,16 @@ function printOpenclawBridgeStatus(flags) {
4183
4261
  if (payload.maintenance) console.log(`Maintenance: ${payload.maintenance.status} — ${payload.maintenance.message || ''}`);
4184
4262
  console.log('Oomi Bridge Status');
4185
4263
  const supervision = payload.supervision;
4186
- console.log(supervision.manager === 'host-process' ? `Worker recovery: ${supervision.enabled ? 'on' : 'off'} for this host session; reconnect after a cloud computer restart.` : `Automatic startup: ${supervision.installed && supervision.enabled ? supervision.manager + ' (' + supervision.startsAt + ')' : 'off'}`);
4187
- if (!supervision.installed || !supervision.enabled || !supervision.running) console.log(`Repair on this computer: oomi bridge repair${bridgeConnectionName ? ' --name ' + bridgeConnectionName : ''}`);
4264
+ if (supervision.manager === 'windows-logon') {
4265
+ // Two separate promises on Windows: the supervisor restarts the worker while the person stays
4266
+ // signed in, and the Run key starts the supervisor at the next sign-in. Say which ones hold.
4267
+ console.log(`Worker recovery: ${supervision.enabled && supervision.loaded ? 'on' : 'off'} while you are signed in to Windows.`);
4268
+ console.log(supervision.enabled && supervision.startsAfterHostRestart ? 'Automatic startup: at Windows sign-in.'
4269
+ : `Automatic startup: off at Windows sign-in.${supervision.enabled ? ` To turn it on: oomi bridge service start${named} --sign-in` : ''}`);
4270
+ } else {
4271
+ console.log(supervision.manager === 'host-process' ? `Worker recovery: ${supervision.enabled ? 'on' : 'off'} for this host session; reconnect after a cloud computer restart.` : `Automatic startup: ${supervision.installed && supervision.enabled ? supervision.manager + ' (' + supervision.startsAt + ')' : 'off'}`);
4272
+ }
4273
+ if (!supervision.installed || !supervision.enabled || !supervision.running) console.log(`Repair on this computer: oomi bridge repair${named}`);
4188
4274
  if (supervision.reason) console.log(supervision.reason);
4189
4275
  console.log('------------------');
4190
4276
  console.log(`Bridge state: ${payload.bridgeStatePath}`);
@@ -4197,6 +4283,15 @@ function printOpenclawBridgeStatus(flags) {
4197
4283
  }
4198
4284
  if (payload.runtime && typeof payload.runtime === 'object' && Object.keys(payload.runtime).length > 0) {
4199
4285
  console.log(`Bridge state: ${String(payload.runtime.status || 'unknown')}`);
4286
+ if (payload.runtime.unrecordedExit) {
4287
+ console.log(` Its process (pid ${payload.runtime.lastPid}) has ended without recording why; its last update was at ${payload.runtime.updatedAt || 'an unknown time'}. Nothing answers for this connection until it starts again.`);
4288
+ }
4289
+ // A paired computer that no account has claimed connects fine, but no one can call or message it.
4290
+ if (/not linked/i.test(String(payload.runtime.agentChannelError || ''))) {
4291
+ console.log(`Account: this computer isn't linked to an oomi account yet. Make a fresh Auth Link with oomi invite${named} and open it while signed in to oomi.`);
4292
+ } else if (payload.runtime.agentChannelError) {
4293
+ console.log(`Chat links: ${payload.runtime.agentChannelError}`);
4294
+ }
4200
4295
  console.log(`Agent runtime: ${bridgeState.runtime || 'openclaw'}${bridgeState.localAgent?.profile ? ` (profile ${bridgeState.localAgent.profile})` : ''}`);
4201
4296
  console.log(`Local reply verified: ${payload.runtime.runtimeReady ? 'yes' : 'no'}${payload.runtime.verifiedAt ? ` at ${payload.runtime.verifiedAt}` : ''}`);
4202
4297
  if (payload.runtime.lastConnectedAt) {
@@ -4313,7 +4408,8 @@ function listLocalBridgeConnections() {
4313
4408
  const state = readBridgeState();
4314
4409
  const running = findRunningBridgeProcess();
4315
4410
  return { name: name || null, runtime: state.runtime || 'openclaw', deviceId: state.deviceId || null,
4316
- running: Boolean(running), supervision: currentBridgeService().status(),
4411
+ running: Boolean(running), status: liveBridgeStatus(readBridgeStatus(), (pid) => pid === running?.pid || isBridgeProcess(pid)).status || null,
4412
+ supervision: currentBridgeService().status(),
4317
4413
  repairCommand: `oomi bridge repair${name ? ' --name ' + name : ''}` };
4318
4414
  });
4319
4415
  } finally { bridgeConnectionName = selected; }
@@ -4362,15 +4458,17 @@ async function handleBridgeServiceCommand(actionRaw = '', flags = {}) {
4362
4458
  if (['install', 'start', 'restart'].includes(action)) requireSavedBridge();
4363
4459
  if (['install', 'restart'].includes(action) && !isTruthyFlag(flags['no-start']) && deferLiveRestart()) return;
4364
4460
  if (action !== 'start') assertIndependentMaintenance();
4461
+ const signIn = signInChoice(flags);
4462
+ let started;
4365
4463
  if (action === 'install') {
4366
- service.install({ noStart: true });
4464
+ service.install({ noStart: true, signIn });
4367
4465
  await stopSupervisedBridge(service);
4368
- if (!isTruthyFlag(flags['no-start'])) service.start();
4466
+ if (!isTruthyFlag(flags['no-start'])) started = service.start({ signIn });
4369
4467
  } else if (action === 'start') {
4370
- service.start(); // Idempotent: do not interrupt a healthy worker.
4468
+ started = service.start({ signIn }); // Idempotent: do not interrupt a healthy worker.
4371
4469
  } else if (action === 'restart') {
4372
4470
  await stopSupervisedBridge(service);
4373
- service.start({ rewrite: true });
4471
+ started = service.start({ rewrite: true, signIn });
4374
4472
  incrementBridgeMetric('bridge_restart_count');
4375
4473
  } else if (action === 'stop') {
4376
4474
  await stopSupervisedBridge(service);
@@ -4379,7 +4477,30 @@ async function handleBridgeServiceCommand(actionRaw = '', flags = {}) {
4379
4477
  service.uninstall();
4380
4478
  }
4381
4479
  const result = service.status();
4382
- console.log(JSON.stringify({ action, ...result }, null, 2));
4480
+ console.log(JSON.stringify({ action, ...result, ...(started?.signInError ? { signInError: started.signInError } : {}) }, null, 2));
4481
+ }
4482
+
4483
+ // Windows: --sign-in or --no-sign-in records whether the connection's supervisor also starts at
4484
+ // Windows sign-in (the person's Run key). Without either flag the saved choice stands (default on).
4485
+ function signInChoice(flags = {}) {
4486
+ if (isTruthyFlag(flags['no-sign-in'])) return false;
4487
+ if (isTruthyFlag(flags['sign-in'])) return true;
4488
+ return undefined;
4489
+ }
4490
+
4491
+ // What will bring this connection's bridge back, as its service reports it rather than as hoped.
4492
+ function describeSupervision(service, started = null) {
4493
+ const status = service.status();
4494
+ if (status.manager === 'host-process') return 'Worker recovery: enabled for this host session. After a cloud computer restart, rerun oomi connect; boot recovery is unavailable on this host.';
4495
+ if (status.manager !== 'windows-logon') return `Automatic startup: ${service.config.platform === 'darwin' ? 'macOS login service' : 'Linux user service'}; restarts after worker exits.`;
4496
+ const named = bridgeConnectionName ? ` --name ${bridgeConnectionName}` : '';
4497
+ const why = started?.signInError ? ` (${started.signInError})` : status.signIn === false ? ' (--no-sign-in)' : '';
4498
+ return [
4499
+ 'Worker recovery: on while you are signed in to Windows; the bridge restarts after its worker exits.',
4500
+ status.startsAfterHostRestart ? 'Automatic startup: at Windows sign-in.' : `Automatic startup: off at Windows sign-in${why}. To turn it on: oomi bridge service start${named} --sign-in`,
4501
+ // processSupervisor.js: a supervisor started by a command lives in the job of the program that ran it.
4502
+ "Started from inside an app (the Claude desktop app is one), it stops when that app updates or restarts, until it is started again at sign-in or from a terminal of your own.",
4503
+ ].join('\n');
4383
4504
  }
4384
4505
 
4385
4506
  async function repairBridge(flags = {}) {
@@ -4388,7 +4509,9 @@ async function repairBridge(flags = {}) {
4388
4509
  await handleBridgeServiceCommand('install', flags);
4389
4510
  if (!isTruthyFlag(flags['no-start'])) {
4390
4511
  await waitForBridgeConnection({});
4391
- console.log(currentBridgeService().status().manager === 'host-process' ? 'Oomi bridge restored with worker recovery for this host session. Reconnect after a cloud computer restart. Pairing and conversations preserved.' : 'Oomi bridge restored with automatic startup. Pairing and conversations preserved.');
4512
+ const service = currentBridgeService();
4513
+ if (service.status().manager === 'windows-logon') console.log(`Oomi bridge restored. Pairing and conversations preserved.\n${describeSupervision(service)}`);
4514
+ else console.log(service.status().manager === 'host-process' ? 'Oomi bridge restored with worker recovery for this host session. Reconnect after a cloud computer restart. Pairing and conversations preserved.' : 'Oomi bridge restored with automatic startup. Pairing and conversations preserved.');
4392
4515
  }
4393
4516
  }
4394
4517
 
@@ -4414,8 +4537,9 @@ async function startBridgeLifecycle(flags = {}) {
4414
4537
  const service = currentBridgeService();
4415
4538
  if (service.status().installed) {
4416
4539
  if (isTruthyFlag(flags.detach)) throw new Error('This connection has a supervisor. Use bridge start, or uninstall its service before using --detach.');
4417
- service.start();
4540
+ const started = service.start({ signIn: signInChoice(flags) });
4418
4541
  console.log(`Bridge service started: ${service.config.target}`);
4542
+ if (started?.signInError) console.warn(`Windows sign-in startup was not set: ${started.signInError}`);
4419
4543
  return;
4420
4544
  }
4421
4545
  }
@@ -4562,6 +4686,7 @@ function refreshSelectedSkill(state, flags = {}) {
4562
4686
  async function connectLocalAgent(flags) {
4563
4687
  assertIndependentMaintenance();
4564
4688
  const agentName = flags['agent-name'] === undefined ? undefined : validateAgentName(flags['agent-name']);
4689
+ const pairCode = flags.pair === undefined ? '' : parsePairCode(flags.pair);
4565
4690
  const runtime = String(flags.runtime || '');
4566
4691
  if (!['openclaw', 'hermes', 'grokbot', 'command'].includes(runtime)) throw new Error('Specify --runtime for your own agent: openclaw, hermes, grokbot, or command. An unlisted brand may use an adapter; read oomi capabilities. Never select a different agent just because it is installed.');
4567
4692
  const service = currentBridgeService(runtime);
@@ -4598,10 +4723,29 @@ async function connectLocalAgent(flags) {
4598
4723
  const identity = ({ hermesTransport, ...rest } = {}) => JSON.stringify(rest);
4599
4724
  if (saved && identity(saved) !== identity(state.localAgent)) throw new Error('This name already identifies a different agent configuration. Use a new --name to change its command, profile, session, or working directory.');
4600
4725
  }
4726
+ // A pairing code from the person's prompt: say hello first, so their waiting screen moves.
4727
+ let pairing = null;
4728
+ if (pairCode) {
4729
+ if (!state.brokerHttp) {
4730
+ const config = await fetchManagedGatewayConfig({ appUrl });
4731
+ state.brokerHttp = rewriteLoopbackBrokerUrlForAppHost(config.brokerHttpUrl, appUrl);
4732
+ state.brokerWs = rewriteLoopbackBrokerUrlForAppHost(config.brokerDeviceWsUrl, appUrl);
4733
+ }
4734
+ pairing = await pairHello({ backendHttp: state.brokerHttp, code: pairCode });
4735
+ }
4601
4736
  if (!previous.verifiedAt || isTruthyFlag(flags.verify)) {
4602
4737
  console.log(`Verifying ${runtime}${state.localAgent?.profile ? ` profile ${state.localAgent.profile}` : ''} with a local test message...`);
4603
4738
  try {
4604
- const verified = await verifyLocalAgent(state);
4739
+ let verified;
4740
+ try { verified = await verifyLocalAgent(state); }
4741
+ catch (err) {
4742
+ // Some Hermes installs never answer over ACP. Unless the person chose the transport, the
4743
+ // quiet CLI gets one try, and the connection keeps it so later turns don't wait on ACP again.
4744
+ if (!hermesCliFallbackApplies(state.localAgent, err)) throw err;
4745
+ console.log("Hermes didn't answer over its streaming connection; using its command line for this connection.");
4746
+ state.localAgent = { ...state.localAgent, hermesTransport: 'cli' };
4747
+ verified = await verifyLocalAgent(state);
4748
+ }
4605
4749
  state.verifiedAt = verified.verifiedAt;
4606
4750
  } catch (err) {
4607
4751
  const explained = explainVerificationFailure(err);
@@ -4612,6 +4756,7 @@ async function connectLocalAgent(flags) {
4612
4756
  console.log(`Reusing the verified ${runtime} runtime. No model test message sent. Use oomi verify for an explicit paid-model probe.`);
4613
4757
  }
4614
4758
  writeBridgeState(state); // Keep successful verification even if pairing later needs a retry.
4759
+ if (pairing && !pairing.ok) console.log(`${pairing.message} Connecting anyway; you'll get an Auth Link to send to your person instead.`);
4615
4760
  if (!state.deviceToken) {
4616
4761
  const config = await fetchManagedGatewayConfig({ appUrl });
4617
4762
  state.brokerHttp = rewriteLoopbackBrokerUrlForAppHost(config.brokerHttpUrl, appUrl);
@@ -4632,23 +4777,43 @@ async function connectLocalAgent(flags) {
4632
4777
  console.warn('This Oomi server does not support agent settings yet. Connecting without shared settings.');
4633
4778
  }
4634
4779
  // Install/update only this connection's supervisor, retaining its saved identity and session.
4635
- if (!unmanaged) service.install({ noStart: true });
4780
+ if (!unmanaged) service.install({ noStart: true, signIn: signInChoice(flags) });
4636
4781
  const stopped = unmanaged ? await stopBridgeProcesses() : await stopSupervisedBridge(service);
4637
4782
  if (stopped.stillAlive?.length) throw new Error('The existing bridge did not stop. Resolve it before reconnecting.');
4638
4783
  writeBridgeState(state);
4639
4784
  updateBridgeStatus({ status: 'starting', runtime, runtimeReady: true, verifiedAt: state.verifiedAt, lastErrorMessage: '' });
4640
- const child = unmanaged ? startBridgeDetachedProcess({ 'app-url': appUrl }) : (service.start(), {});
4785
+ const started = unmanaged ? null : service.start({ signIn: signInChoice(flags) });
4786
+ const child = unmanaged ? startBridgeDetachedProcess({ 'app-url': appUrl }) : {};
4641
4787
  await waitForBridgeConnection(child);
4642
- console.log(unmanaged ? 'Automatic startup: off (--no-service); your host supervisor must manage recovery.'
4643
- : service.status().manager === 'host-process' ? 'Worker recovery: enabled for this host session. After a cloud computer restart, rerun oomi connect; boot recovery is unavailable on this host.'
4644
- : `Automatic startup: ${service.config.platform === 'darwin' ? 'macOS login service' : 'Linux user service'}; restarts after worker exits.`);
4788
+ console.log(unmanaged ? 'Automatic startup: off (--no-service); your host supervisor must manage recovery.' : describeSupervision(service, started));
4645
4789
  const invite = await requestConnectInviteLink({ backendHttp: state.brokerHttp, appUrl, sessionKey: state.sessionKey, deviceToken: state.deviceToken });
4646
4790
  refreshSelectedSkill(state, flags);
4791
+ const ready = { status: 'ready', runtime, agentId: state.localAgent?.agentId, verifiedAt: state.verifiedAt, inviteUrl: invite.inviteUrl };
4792
+ if (pairing?.ok) {
4793
+ // Ask to join: the Auth Link goes to oomi against the code, and the person says yes there.
4794
+ const asked = await pairAnswer({ backendHttp: state.brokerHttp, code: pairCode, inviteUrl: invite.inviteUrl, deviceToken: state.deviceToken, computer: String(flags.computer || os.hostname() || '') });
4795
+ if (asked.ok) {
4796
+ console.log(`Verified agent: ${runtime}${state.localAgent?.profile ? ` (${state.localAgent.profile})` : ''}`);
4797
+ // Grok Bot's setup runs in the background; its reply command passes this on without waiting.
4798
+ if (flags['setup-worker']) return { ...ready, pairing: { status: 'answered', code: formatPairCode(pairCode) } };
4799
+ console.log('Asked to join. Waiting for your person to say yes in oomi…');
4800
+ const outcome = await waitForPairApproval({
4801
+ backendHttp: state.brokerHttp, code: pairCode, deviceToken: state.deviceToken,
4802
+ intervalMs: Number(process.env.OOMI_PAIR_POLL_MS) || PAIR_POLL_MS,
4803
+ timeoutMs: Number(process.env.OOMI_PAIR_WAIT_MS) || PAIR_WAIT_MS,
4804
+ });
4805
+ const described = describePairOutcome(outcome);
4806
+ console.log(described.line);
4807
+ if (described.exitCode) process.exitCode = described.exitCode;
4808
+ return { ...ready, pairing: { status: outcome.status } };
4809
+ }
4810
+ console.log(`${asked.message} Send this Auth Link to your person instead.`);
4811
+ }
4647
4812
  console.log(`Verified agent: ${runtime}${state.localAgent?.profile ? ` (${state.localAgent.profile})` : ''}`);
4648
4813
  console.log('Oomi Connect Ready');
4649
4814
  console.log(`Auth Link: ${invite.inviteUrl}`);
4650
4815
  console.log('Open the Auth Link to approve ownership, then send a message in Oomi to verify delivery end to end.');
4651
- return { status: 'ready', runtime, agentId: state.localAgent?.agentId, verifiedAt: state.verifiedAt, inviteUrl: invite.inviteUrl };
4816
+ return ready;
4652
4817
  }
4653
4818
 
4654
4819
  async function main() {
@@ -4719,7 +4884,8 @@ async function main() {
4719
4884
  console.log(JSON.stringify(receipt));
4720
4885
  if (receipt.verification) {
4721
4886
  const setup = await waitConnectionSetup(directory, args.flags['agent-id']);
4722
- if (setup?.status === 'ready') console.log(`Verified agent: grokbot (${args.flags['agent-id']})\nOomi Connect Ready\nAuth Link: ${setup.inviteUrl}`);
4887
+ if (setup?.status === 'ready' && setup.pairing?.status === 'answered') console.log(`Verified agent: grokbot (${args.flags['agent-id']})\nAsked to join. Tell your person: "I've asked to join. Say yes in oomi."`);
4888
+ else if (setup?.status === 'ready') console.log(`Verified agent: grokbot (${args.flags['agent-id']})\nOomi Connect Ready\nAuth Link: ${setup.inviteUrl}`);
4723
4889
  else if (setup) console.log(JSON.stringify(setup));
4724
4890
  }
4725
4891
  return;
@@ -4732,6 +4898,7 @@ async function main() {
4732
4898
  const directory = connectionDirectory();
4733
4899
  const config = grokbotConfig({ ...args.flags, 'agent-id': args.flags['agent-id'] || saved?.agentId, 'grokbot-config': args.flags['grokbot-config'] || saved?.configFile, 'grokbot-gateway': args.flags['grokbot-gateway'] || saved?.gatewayFile }, directory);
4734
4900
  if (!args.flags['setup-worker']) {
4901
+ if (args.flags.pair !== undefined) parsePairCode(args.flags.pair); // Refuse a mistyped code now, not in the background.
4735
4902
  if (!isTruthyFlag(args.flags['no-service'])) currentBridgeService('grokbot').preflight();
4736
4903
  console.log(JSON.stringify(queueConnectionSetup({ directory, agentId: config.agentId, cli: process.argv[1], args: process.argv.slice(2) }), null, 2));
4737
4904
  return;
@@ -4929,6 +5096,7 @@ export {
4929
5096
  handleOpenclawProfileCommand,
4930
5097
  buildBridgeLaunchAgentPlist,
4931
5098
  classifyBridgeFailure,
5099
+ classifyBrokerDisconnect,
4932
5100
  classifyBridgeSessionScope,
4933
5101
  createBridgeProcessFaultHandler,
4934
5102
  computeReconnectDelayMs,
@@ -4,6 +4,7 @@ import path from 'node:path';
4
4
  import { randomUUID } from 'node:crypto';
5
5
  import { readJson, writePrivateJson } from './localAgent.js';
6
6
  import { classifyRuntimeFailure } from './runtimeFailure.js';
7
+ import { isBridgeWorker, liveBridgeStatus } from './processTable.js';
7
8
 
8
9
  // Owner-visible conversations between this agent and one other agent.
9
10
  // Host side uses the device token against the Oomi API. Guest side (after
@@ -83,12 +84,16 @@ export function explainConnectionError(error, directory) {
83
84
  }
84
85
 
85
86
  // A link only helps if this agent can answer; warn before handing one out.
86
- export function bridgeWarnings(directory) {
87
+ // A status file can say "connected" for a bridge that has since been ended outright, so the
88
+ // recorded pid must still be this connection's running bridge (lib/processTable.js).
89
+ export function bridgeWarnings(directory, { isRunning } = {}) {
87
90
  if (!directory) return [];
88
- const status = readJson(path.join(directory, 'oomi-bridge-status.json'), null);
91
+ const connection = path.resolve(path.dirname(directory)) === path.resolve(connectionsRoot()) ? path.basename(directory) : '';
92
+ const status = liveBridgeStatus(readJson(path.join(directory, 'oomi-bridge-status.json'), null), isRunning || ((pid) => isBridgeWorker(pid, connection)));
89
93
  if (!status) return ['No oomi bridge status was found for this connection. Run oomi bridge repair for it, or guest messages will wait unanswered.'];
90
94
  const warnings = [];
91
- if (['error', 'degraded', 'failed', 'stopped'].includes(status.status)) warnings.push(`Your oomi bridge reports "${status.status}"${status.lastErrorMessage ? `: ${String(status.lastErrorMessage).replace(/\.\s*$/, '')}` : ''}.`);
95
+ if (status.unrecordedExit) warnings.push(`Your oomi bridge isn't running: its process (pid ${status.lastPid}) ended without recording why. Run oomi bridge repair${connection ? ` --name ${connection}` : ''} on this computer.`);
96
+ else if (['error', 'degraded', 'failed', 'stopped'].includes(status.status)) warnings.push(`Your oomi bridge reports "${status.status}"${status.lastErrorMessage ? `: ${String(status.lastErrorMessage).replace(/\.\s*$/, '')}` : ''}.`);
92
97
  if (status.agentChannelError) warnings.push(status.agentChannelError);
93
98
  return warnings;
94
99
  }