@zeph-to/cli 2.13.0 → 2.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
@@ -207,7 +207,11 @@ block here.
207
207
  behalf. tmux has no Windows build, so `zeph cc` needs WSL there.
208
208
 
209
209
  2. **Add `wsUrl` to `~/.zeph/config.json`** (the WebSocket endpoint of
210
- your Zeph backend — CDK output `WsApiUrl`):
210
+ your Zeph backend — CDK output `WsApiUrl`). Keep it on the same stage as
211
+ `baseUrl`: the REST stage is the path prefix (`/v1` prod, `/d1` dev) and the
212
+ socket stage is the hostname, so they can disagree without either looking
213
+ wrong. `zeph verify` says which stage each one is on, and the listener only
214
+ reads this at startup — `zeph listener --restart` after editing:
211
215
 
212
216
  ```json
213
217
  {
@@ -217,7 +221,12 @@ block here.
217
221
  }
218
222
  ```
219
223
 
220
- Alternatively set `ZEPH_WS_URL` in your shell env.
224
+ This is where it belongs. `--ws-url` overrides it for a single run.
225
+ `ZEPH_WS_URL` is deprecated: it used to outrank this file, which meant an
226
+ `export` in a shell profile silently chose the stage and left no trace of
227
+ having done so. It now loses to the file and is read only when the file has
228
+ no `wsUrl`, so nothing that worked stops working — but it will go, and
229
+ `zeph verify` says so while it is still set.
221
230
 
222
231
  3. **Run agents through the wrapper.** That's it.
223
232
 
@@ -328,6 +337,24 @@ With the service installed, launchd owns the process: `zeph cc` and
328
337
  `zeph listener --stop|--restart` ask launchd rather than signalling the
329
338
  PID, so there is never a second daemon racing the first.
330
339
 
340
+ ### Keeping the Mac awake
341
+
342
+ The listener holds an *outbound* socket, and macOS **"Wake for network
343
+ access" does not protect it** — that setting only wakes the machine for
344
+ inbound requests to services it advertises. When the Mac idle-sleeps, the
345
+ socket dies and the phone shows "Waiting for the live stream…" until
346
+ someone opens the lid. A Mac running Claude Code hides this (the agent
347
+ runs `caffeinate` during every turn), so one machine looks fine while
348
+ another, idling at a prompt, keeps dropping.
349
+
350
+ So on macOS the listener runs `caffeinate -s -w <its pid>` for as long as
351
+ it lives. `-s` is honoured **on AC power only** — on battery macOS ignores
352
+ it, so a laptop still sleeps and nothing drains. The display still turns
353
+ off; a closed lid still sleeps. Activity Monitor shows the daemon under
354
+ "Preventing Sleep". Opt out with `--no-keep-awake` or `"keepAwake": false`
355
+ in `~/.zeph/config.json`; the log's `keep-awake:` line says which way it
356
+ went.
357
+
331
358
  ### Diagnostics
332
359
 
333
360
  The auto-spawned listener writes to three files under `~/.zeph/`:
@@ -523,7 +550,7 @@ zeph notify --title "Hello" --json
523
550
  | `login` | Browser sign-in: auto-fetch API key + hook into `~/.zeph/config.json` over a localhost loopback (`--web-url`, `--timeout`). No copy-paste |
524
551
  | `install` (alias: `setup`) | One-command setup: detect agents, save config, install rules + hooks + MCP. No saved config → opens browser login automatically. `--only claude,cursor,…` skips the picker |
525
552
  | `uninstall` | Remove Zeph from all detected agents (`--dry-run`, `--purge`) |
526
- | `verify` | Check installation health across detected agents (`--ping` for a live API call) |
553
+ | `verify` | Check installation health across detected agents (`--ping` for a live API call). Also reports the resolved WebSocket URL **and where it came from** — `--ws-url`, config, the deprecated `ZEPH_WS_URL`, or the built-in default — warns when the socket and the API base are on different stages, and warns when the running listener is on a different URL than the one that resolves now (it reads the config once, at startup) |
527
554
  | `check-update` | Check whether a newer Zeph version is on npm |
528
555
  | `notify` | Send a push notification |
529
556
  | `list` | List recent push notifications |
@@ -559,11 +586,12 @@ which project + branch finished without writing per-IDE wrappers. Pass
559
586
 
560
587
  | Flag | Description |
561
588
  |------|-------------|
562
- | `--ws-url <url>` | WebSocket endpoint (or set `ZEPH_WS_URL` env, or `wsUrl` in `~/.zeph/config.json`) |
589
+ | `--ws-url <url>` | WebSocket endpoint for this run only; the lasting setting is `wsUrl` in `~/.zeph/config.json` |
563
590
  | `--key <api-key>` | API key (or set `ZEPH_API_KEY` env) |
564
591
  | `--base-url <url>` | REST API base URL (or set `ZEPH_BASE_URL` env, or `baseUrl` in `~/.zeph/config.json`) |
565
592
  | `--stop` | Stop the running daemon and clear its PID/version stamps |
566
593
  | `--restart` | Stop it and relaunch detached (logs to `~/.zeph/listener.log`) |
594
+ | `--no-keep-awake` | Don't hold the Mac awake on AC power (macOS). Lasting form: `"keepAwake": false` in `~/.zeph/config.json` |
567
595
 
568
596
  The listener reconnects with exponential backoff + jitter (1 s → 30 s
569
597
  cap). Heartbeat is ping every 25 s with a 10 s pong timeout. On an
@@ -663,7 +691,7 @@ The CLI checks `CLAUDE_PROJECT_DIR`, `CURSOR_PROJECT_DIR`,
663
691
  |----------|-------------|
664
692
  | `ZEPH_API_KEY` | API key (fallback when `--key` not provided) |
665
693
  | `ZEPH_BASE_URL` | API base URL (default: `https://api.zeph.to/v1`) |
666
- | `ZEPH_WS_URL` | WebSocket endpoint for `zeph listener` (no default required) |
694
+ | `ZEPH_WS_URL` | **Deprecated.** WebSocket endpoint for `zeph listener`. `wsUrl` in `~/.zeph/config.json` wins over it; read only when the file has none. It will stop being read |
667
695
  | `ZEPH_TMUX_SOCKET` | Explicit tmux socket path for the listener (skips auto-discovery — use when your tmux runs with `-L <name>` or a custom `-S <path>`) |
668
696
  | `ZEPH_SESSION_ID` | AI session ID (fallback when `--session` not provided) |
669
697
 
package/dist/cli.js CHANGED
@@ -104,6 +104,10 @@ ${usageAgentLines()}
104
104
  remove the login-time service
105
105
  --service-status
106
106
  show what the installed service points at
107
+ --no-keep-awake
108
+ don't hold the Mac awake on AC power
109
+ (macOS; default runs 'caffeinate -s' so an
110
+ idle Mac keeps the socket up)
107
111
 
108
112
  Notify options:
109
113
  --title <text> Push title
package/dist/config.d.ts CHANGED
@@ -6,6 +6,8 @@ export interface ZephConfig {
6
6
  baseUrl?: string;
7
7
  wsUrl?: string;
8
8
  deviceId?: string;
9
+ /** `false` stops the listener holding the Mac awake on AC (`caffeinate -s`). README § Listener Options. */
10
+ keepAwake?: boolean;
9
11
  }
10
12
  export declare const resolvedEnv: (key: string, env?: NodeJS.ProcessEnv) => string | undefined;
11
13
  /**
@@ -17,6 +19,14 @@ export declare const resolveHookId: (env?: NodeJS.ProcessEnv) => string | undefi
17
19
  export declare const PROJECT_DIR_ENV_VARS: readonly ["CLAUDE_PROJECT_DIR", "CURSOR_PROJECT_DIR", "WINDSURF_PROJECT_DIR"];
18
20
  /** First set project-dir env (unresolved `${VAR}` placeholders ignored), else cwd. */
19
21
  export declare const detectProjectDir: () => string;
22
+ /**
23
+ * An absent config is normal — plenty of commands run on `--key` alone, so it
24
+ * stays silent. A config that exists but does not parse is not normal, and used
25
+ * to be indistinguishable from absent: every value silently became undefined,
26
+ * so `zeph` behaved as if the file had never been written. That is precisely
27
+ * how "it isn't reading my config" looks from the outside, with nothing
28
+ * anywhere to say otherwise. Say it, on stderr, and carry on with defaults.
29
+ */
20
30
  export declare const loadConfig: () => ZephConfig;
21
31
  export declare const saveConfig: (config: ZephConfig) => void;
22
32
  export declare const VERSION: string;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,QAA2B,CAAC;AACnD,eAAO,MAAM,WAAW,QAAkC,CAAC;AAE3D,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,MAAK,MAAM,CAAC,UAAwB,KAAG,MAAM,GAAG,SAGxF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,MAAK,MAAM,CAAC,UAAwB,KAAG,MAAM,GAAG,SACrB,CAAC;AAM1D,eAAO,MAAM,oBAAoB,+EAAgF,CAAC;AAElH,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,QAAO,MAMnC,CAAC;AAEF,eAAO,MAAM,UAAU,QAAO,UAM7B,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,QAAQ,UAAU,KAAG,IAM/C,CAAC;AAEF,eAAO,MAAM,OAAO,QAOhB,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,QAA2B,CAAC;AACnD,eAAO,MAAM,WAAW,QAAkC,CAAC;AAE3D,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2GAA2G;IAC3G,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,MAAK,MAAM,CAAC,UAAwB,KAAG,MAAM,GAAG,SAGxF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,MAAK,MAAM,CAAC,UAAwB,KAAG,MAAM,GAAG,SACrB,CAAC;AAM1D,eAAO,MAAM,oBAAoB,+EAAgF,CAAC;AAElH,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,QAAO,MAMnC,CAAC;AAIF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,QAAO,UAqB7B,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,QAAQ,UAAU,KAAG,IAM/C,CAAC;AAEF,eAAO,MAAM,OAAO,QAOhB,CAAC"}
package/dist/config.js CHANGED
@@ -33,13 +33,38 @@ const detectProjectDir = () => {
33
33
  return process.cwd();
34
34
  };
35
35
  exports.detectProjectDir = detectProjectDir;
36
+ let warnedAboutBrokenConfig = false;
37
+ /**
38
+ * An absent config is normal — plenty of commands run on `--key` alone, so it
39
+ * stays silent. A config that exists but does not parse is not normal, and used
40
+ * to be indistinguishable from absent: every value silently became undefined,
41
+ * so `zeph` behaved as if the file had never been written. That is precisely
42
+ * how "it isn't reading my config" looks from the outside, with nothing
43
+ * anywhere to say otherwise. Say it, on stderr, and carry on with defaults.
44
+ */
36
45
  const loadConfig = () => {
46
+ let raw;
37
47
  try {
38
- return JSON.parse((0, fs_1.readFileSync)(exports.CONFIG_FILE, 'utf-8'));
48
+ raw = (0, fs_1.readFileSync)(exports.CONFIG_FILE, 'utf-8');
39
49
  }
40
50
  catch {
41
51
  return {};
42
52
  }
53
+ try {
54
+ return JSON.parse(raw);
55
+ }
56
+ catch (err) {
57
+ // Once per process: a single command can call loadConfig several times
58
+ // (handleVerify and resolveHookId both do), and repeating the same two
59
+ // lines four times reads like four separate problems.
60
+ if (!warnedAboutBrokenConfig) {
61
+ warnedAboutBrokenConfig = true;
62
+ const reason = err instanceof Error ? err.message : String(err);
63
+ console.error(`zeph: ${exports.CONFIG_FILE} is not valid JSON, so it is being ignored (${reason}).`);
64
+ console.error('zeph: fix the file, or re-run `zeph install` to write a fresh one.');
65
+ }
66
+ return {};
67
+ }
43
68
  };
44
69
  exports.loadConfig = loadConfig;
45
70
  const saveConfig = (config) => {
@@ -0,0 +1,32 @@
1
+ import { spawn } from 'node:child_process';
2
+ /**
3
+ * Keep the host awake while the listener runs — macOS only.
4
+ *
5
+ * The listener holds an OUTBOUND WebSocket. macOS "Wake for network access"
6
+ * only wakes the machine for inbound requests to Bonjour-advertised services,
7
+ * so it does nothing for us: when the Mac idle-sleeps, the socket dies and the
8
+ * phone sits on "Waiting for the live stream…" until the lid is opened. On a
9
+ * machine that runs Claude Code this is masked — the agent spawns
10
+ * `caffeinate -i -t 300` while a turn is running — which is why one Mac looks
11
+ * fine and another, idling at a prompt, keeps dropping.
12
+ *
13
+ * `caffeinate -s -w <pid>`: `-s` blocks system sleep and is honoured ONLY on
14
+ * AC power (macOS drops the assertion on battery, so this never drains a
15
+ * laptop); `-w` releases it the moment our pid exits, so a crashed daemon
16
+ * leaves no orphan holding the machine up. The display still sleeps; a closed
17
+ * lid still sleeps — those are the user's call, not ours.
18
+ */
19
+ export interface KeepAwakeOptions {
20
+ /** `false` = `--no-keep-awake` / `"keepAwake": false` in config. */
21
+ enabled: boolean;
22
+ log: (msg: string) => void;
23
+ platform?: NodeJS.Platform;
24
+ pid?: number;
25
+ spawnFn?: typeof spawn;
26
+ }
27
+ export interface KeepAwake {
28
+ /** Release the assertion now rather than at process exit. Idempotent. */
29
+ stop: () => void;
30
+ }
31
+ export declare const startKeepAwake: (opts: KeepAwakeOptions) => KeepAwake;
32
+ //# sourceMappingURL=keep-awake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keep-awake.d.ts","sourceRoot":"","sources":["../src/keep-awake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,WAAW,gBAAgB;IAC7B,oEAAoE;IACpE,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED,MAAM,WAAW,SAAS;IACtB,yEAAyE;IACzE,IAAI,EAAE,MAAM,IAAI,CAAC;CACpB;AAID,eAAO,MAAM,cAAc,GAAI,MAAM,gBAAgB,KAAG,SAoCvD,CAAC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startKeepAwake = void 0;
4
+ const node_child_process_1 = require("node:child_process");
5
+ const NOOP = { stop: () => undefined };
6
+ const startKeepAwake = (opts) => {
7
+ if (!opts.enabled) {
8
+ opts.log('keep-awake: off — the Mac may idle-sleep and drop the socket');
9
+ return NOOP;
10
+ }
11
+ if ((opts.platform ?? process.platform) !== 'darwin')
12
+ return NOOP;
13
+ const pid = opts.pid ?? process.pid;
14
+ const spawnFn = opts.spawnFn ?? node_child_process_1.spawn;
15
+ const child = spawnFn('caffeinate', ['-s', '-w', String(pid)], { stdio: 'ignore' });
16
+ let stopped = false;
17
+ // ENOENT and friends arrive here, asynchronously — spawn itself does not
18
+ // throw for a missing binary. Not fatal: the listener works without it,
19
+ // the machine just sleeps like it did before.
20
+ child.on('error', (err) => {
21
+ stopped = true;
22
+ opts.log(`! keep-awake: caffeinate unavailable (${err.message}) — the Mac may idle-sleep and drop the socket`);
23
+ });
24
+ child.on('exit', (code, signal) => {
25
+ if (stopped)
26
+ return;
27
+ stopped = true;
28
+ opts.log(`! keep-awake: caffeinate exited early (${code ?? signal}) — the Mac may idle-sleep and drop the socket`);
29
+ });
30
+ // Never keep the event loop alive on the child's account: the daemon's
31
+ // lifetime is the socket loop's, and `-w` ties caffeinate to it anyway.
32
+ child.unref();
33
+ opts.log(`keep-awake: caffeinate -s -w ${pid} — blocks idle sleep on AC power only (--no-keep-awake to disable)`);
34
+ return {
35
+ stop: () => {
36
+ if (stopped)
37
+ return;
38
+ stopped = true;
39
+ child.kill();
40
+ },
41
+ };
42
+ };
43
+ exports.startKeepAwake = startKeepAwake;
@@ -1,6 +1,13 @@
1
1
  export declare const LISTENER_PID_FILE: string;
2
2
  /** CLI version the running daemon booted from. Absent ⇒ pre-stamp build. */
3
3
  export declare const LISTENER_VERSION_FILE: string;
4
+ /**
5
+ * The socket the running daemon actually connected to. A stamp rather than a
6
+ * line in listener.log, because the log rotates at 5MB and a long-lived daemon
7
+ * — exactly the one whose config edit has been outlived — loses its own startup
8
+ * line to that rotation, which would silently switch the staleness check off.
9
+ */
10
+ export declare const LISTENER_WS_URL_FILE: string;
4
11
  export declare const LISTENER_LOG_FILE: string;
5
12
  export declare const sleep: (ms: number) => Promise<void>;
6
13
  /**
@@ -16,7 +23,9 @@ export declare const runningListenerPid: () => number | null;
16
23
  */
17
24
  export declare const runningListenerVersion: () => string | null;
18
25
  /** Claim the singleton slot for THIS process and stamp the version with it. */
19
- export declare const writeListenerRuntime: (version: string) => void;
26
+ export declare const writeListenerRuntime: (version: string, wsUrl?: string) => void;
27
+ /** The socket the running daemon connected to, or null when it is unknown. */
28
+ export declare const runningListenerWsUrl: () => string | null;
20
29
  /**
21
30
  * Drop the PID/version stamps, but only when they still name `pid` — a
22
31
  * successor that already claimed the slot must not be trampled by a
@@ -1 +1 @@
1
- {"version":3,"file":"listener-process.d.ts","sourceRoot":"","sources":["../src/listener-process.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,iBAAiB,QAAiC,CAAC;AAChE,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB,QAAqC,CAAC;AACxE,eAAO,MAAM,iBAAiB,QAAiC,CAAC;AAEhE,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,KAAG,OAAO,CAAC,IAAI,CAAsD,CAAC;AAEtG;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAO,MAAM,GAAG,IAS9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,QAAO,MAAM,GAAG,IAMlD,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,KAAG,IAItD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,MAAM,KAAG,IASlD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,QAAO,IAQ5C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAU,KAAK,MAAM,EAAE,kBAAiB,KAAG,OAAO,CAAC,OAAO,CAqBlF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,QAAO,MAAM,GAAG,IAM1C,CAAC;AAgBF,eAAO,MAAM,wBAAwB,QAAO,IAO3C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAO,OAgBxC,CAAC"}
1
+ {"version":3,"file":"listener-process.d.ts","sourceRoot":"","sources":["../src/listener-process.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,iBAAiB,QAAiC,CAAC;AAChE,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB,QAAqC,CAAC;AACxE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,QAAmC,CAAC;AACrE,eAAO,MAAM,iBAAiB,QAAiC,CAAC;AAEhE,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,KAAG,OAAO,CAAC,IAAI,CAAsD,CAAC;AAEtG;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAO,MAAM,GAAG,IAS9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,QAAO,MAAM,GAAG,IAMlD,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,EAAE,QAAQ,MAAM,KAAG,IAKtE,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,QAAO,MAAM,GAAG,IAOhD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,MAAM,KAAG,IAWlD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,QAAO,IAQ5C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAU,KAAK,MAAM,EAAE,kBAAiB,KAAG,OAAO,CAAC,OAAO,CAqBlF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,QAAO,MAAM,GAAG,IAM1C,CAAC;AAgBF,eAAO,MAAM,wBAAwB,QAAO,IAO3C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAO,OAgBxC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.spawnListenerDetached = exports.rotateListenerLogIfLarge = exports.resolveCliPath = exports.stopListener = exports.clearStaleListenerRuntime = exports.clearListenerRuntime = exports.writeListenerRuntime = exports.runningListenerVersion = exports.runningListenerPid = exports.sleep = exports.LISTENER_LOG_FILE = exports.LISTENER_VERSION_FILE = exports.LISTENER_PID_FILE = void 0;
3
+ exports.spawnListenerDetached = exports.rotateListenerLogIfLarge = exports.resolveCliPath = exports.stopListener = exports.clearStaleListenerRuntime = exports.clearListenerRuntime = exports.runningListenerWsUrl = exports.writeListenerRuntime = exports.runningListenerVersion = exports.runningListenerPid = exports.sleep = exports.LISTENER_LOG_FILE = exports.LISTENER_WS_URL_FILE = exports.LISTENER_VERSION_FILE = exports.LISTENER_PID_FILE = void 0;
4
4
  const node_child_process_1 = require("node:child_process");
5
5
  const node_fs_1 = require("node:fs");
6
6
  const node_os_1 = require("node:os");
@@ -26,6 +26,13 @@ const ZEPH_DIR = (0, node_path_1.join)((0, node_os_1.homedir)(), '.zeph');
26
26
  exports.LISTENER_PID_FILE = (0, node_path_1.join)(ZEPH_DIR, 'listener.pid');
27
27
  /** CLI version the running daemon booted from. Absent ⇒ pre-stamp build. */
28
28
  exports.LISTENER_VERSION_FILE = (0, node_path_1.join)(ZEPH_DIR, 'listener.version');
29
+ /**
30
+ * The socket the running daemon actually connected to. A stamp rather than a
31
+ * line in listener.log, because the log rotates at 5MB and a long-lived daemon
32
+ * — exactly the one whose config edit has been outlived — loses its own startup
33
+ * line to that rotation, which would silently switch the staleness check off.
34
+ */
35
+ exports.LISTENER_WS_URL_FILE = (0, node_path_1.join)(ZEPH_DIR, 'listener.wsurl');
29
36
  exports.LISTENER_LOG_FILE = (0, node_path_1.join)(ZEPH_DIR, 'listener.log');
30
37
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
31
38
  exports.sleep = sleep;
@@ -62,12 +69,26 @@ const runningListenerVersion = () => {
62
69
  };
63
70
  exports.runningListenerVersion = runningListenerVersion;
64
71
  /** Claim the singleton slot for THIS process and stamp the version with it. */
65
- const writeListenerRuntime = (version) => {
72
+ const writeListenerRuntime = (version, wsUrl) => {
66
73
  (0, node_fs_1.mkdirSync)(ZEPH_DIR, { recursive: true });
67
74
  (0, node_fs_1.writeFileSync)(exports.LISTENER_PID_FILE, String(process.pid));
68
75
  (0, node_fs_1.writeFileSync)(exports.LISTENER_VERSION_FILE, version);
76
+ if (wsUrl)
77
+ (0, node_fs_1.writeFileSync)(exports.LISTENER_WS_URL_FILE, wsUrl);
69
78
  };
70
79
  exports.writeListenerRuntime = writeListenerRuntime;
80
+ /** The socket the running daemon connected to, or null when it is unknown. */
81
+ const runningListenerWsUrl = () => {
82
+ if ((0, exports.runningListenerPid)() === null)
83
+ return null;
84
+ try {
85
+ return (0, node_fs_1.readFileSync)(exports.LISTENER_WS_URL_FILE, 'utf-8').trim() || null;
86
+ }
87
+ catch {
88
+ return null;
89
+ }
90
+ };
91
+ exports.runningListenerWsUrl = runningListenerWsUrl;
71
92
  /**
72
93
  * Drop the PID/version stamps, but only when they still name `pid` — a
73
94
  * successor that already claimed the slot must not be trampled by a
@@ -80,10 +101,12 @@ const clearListenerRuntime = (pid) => {
80
101
  if (Number((0, node_fs_1.readFileSync)(exports.LISTENER_PID_FILE, 'utf-8').trim()) !== pid)
81
102
  return;
82
103
  (0, node_fs_1.unlinkSync)(exports.LISTENER_PID_FILE);
83
- try {
84
- (0, node_fs_1.unlinkSync)(exports.LISTENER_VERSION_FILE);
104
+ for (const stamp of [exports.LISTENER_VERSION_FILE, exports.LISTENER_WS_URL_FILE]) {
105
+ try {
106
+ (0, node_fs_1.unlinkSync)(stamp);
107
+ }
108
+ catch { /* best-effort — a missing stamp is already the desired state */ }
85
109
  }
86
- catch { /* best-effort — a missing stamp is already the desired state */ }
87
110
  }
88
111
  catch { /* best-effort */ }
89
112
  };
@@ -783,17 +783,6 @@ export declare const gcAttachments: (now?: number, dir?: string, ttl?: number) =
783
783
  export declare const handlePush: (push: PushItem, deps?: HandlePushDeps) => Promise<boolean>;
784
784
  export declare const computeBackoff: (attempt: number) => number;
785
785
  export declare const computeListenerDeviceId: (host?: string) => string;
786
- /**
787
- * A user who only set ZEPH_API_KEY (no `zeph login`, no config file) gets the
788
- * prod socket by default — mirroring the DEFAULT_API_BASE fallback for REST.
789
- * The default only applies when the base URL is also the prod default: with a
790
- * custom base URL, silently pointing the listener at the prod socket while
791
- * REST talks to another stage would split the device across environments, so
792
- * that combination still errors loudly.
793
- */
794
- export declare const resolveWsUrl: (args: Record<string, string | boolean>, config: {
795
- wsUrl?: string;
796
- }, baseUrl: string) => string | null;
786
+ export { resolveWsUrl } from './ws-url.js';
797
787
  export declare const handleListener: (args: Record<string, string | boolean>) => Promise<number>;
798
- export {};
799
788
  //# sourceMappingURL=listener.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../src/listener.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AA4BH,OAAO,EAA0C,KAAK,SAAS,EAAE,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAUxH,OAAO,EAAiD,KAAK,UAAU,EAA4C,MAAM,kBAAkB,CAAC;AAG5I,OAAO,EAA4E,KAAK,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACvI,OAAO,EAA6C,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAmCtG,eAAO,MAAM,2BAA2B,QAAS,CAAC;AAElD,UAAU,YAAY;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;;;;;;;;;;;;OAYG;IACH,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,SAAS,CAAC,EAAE,MA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AM,MAAM,EACZ,MAAK,MAAM,MAAiB,KAC7B,OAUF,CAAC;AA0DF,eAAO,MAAM,oBAAoB,GAAI,KAAK;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,KAAG,IAE/E,CAAC;AA2FF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACtB,MAAK,MAAmB,EACxB,MAAK,MAAwB,EAC7B,MAAK,MAA0B,KAChC,MAaF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GACnB,MAAM,QAAQ,EACd,OAAM,cAAmB,KAC1B,OAAO,CAAC,OAAO,CAgDjB,CAAC;AAcF,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,KAAG,MAIhD,CAAC;AA4DF,eAAO,MAAM,uBAAuB,GAAI,OAAO,MAAM,KAAG,MA2BvD,CAAC;AAgSF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA+H3C,eAAO,MAAM,cAAc,GAAU,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAG,OAAO,CAAC,MAAM,CAoK3F,CAAC"}
package/dist/listener.js CHANGED
@@ -34,6 +34,7 @@ const os_1 = require("os");
34
34
  const path_1 = require("path");
35
35
  const ws_1 = __importDefault(require("ws"));
36
36
  const config_js_1 = require("./config.js");
37
+ const ws_url_js_1 = require("./ws-url.js");
37
38
  const listener_process_js_1 = require("./listener-process.js");
38
39
  const gate_js_1 = require("./gate.js");
39
40
  const session_registry_js_1 = require("./session-registry.js");
@@ -44,6 +45,7 @@ const inventory_offload_js_1 = require("./inventory-offload.js");
44
45
  const agent_rules_fetch_js_1 = require("./agent-rules-fetch.js");
45
46
  const crypto_js_1 = require("./crypto.js");
46
47
  const input_sequencer_js_1 = require("./input-sequencer.js");
48
+ const keep_awake_js_1 = require("./keep-awake.js");
47
49
  const PING_INTERVAL_MS = 25_000;
48
50
  const PONG_TIMEOUT_MS = 10_000;
49
51
  const RECONNECT_BASE_MS = 1_000;
@@ -3224,21 +3226,11 @@ const streamSession = (wsUrl, apiKey) => {
3224
3226
  terminate: () => { ws?.terminate(); },
3225
3227
  };
3226
3228
  };
3227
- const DEFAULT_WS_URL = 'wss://ws.zeph.to';
3228
- /**
3229
- * A user who only set ZEPH_API_KEY (no `zeph login`, no config file) gets the
3230
- * prod socket by default — mirroring the DEFAULT_API_BASE fallback for REST.
3231
- * The default only applies when the base URL is also the prod default: with a
3232
- * custom base URL, silently pointing the listener at the prod socket while
3233
- * REST talks to another stage would split the device across environments, so
3234
- * that combination still errors loudly.
3235
- */
3236
- const resolveWsUrl = (args, config, baseUrl) => {
3237
- const fromArg = typeof args['ws-url'] === 'string' ? args['ws-url'] : null;
3238
- return fromArg || (0, config_js_1.resolvedEnv)('ZEPH_WS_URL') || config.wsUrl
3239
- || (baseUrl === DEFAULT_API_BASE ? DEFAULT_WS_URL : null);
3240
- };
3241
- exports.resolveWsUrl = resolveWsUrl;
3229
+ // Resolution (and its precedence) lives in ws-url.ts so `zeph verify` can ask
3230
+ // the same question without loading this module. Re-exported because
3231
+ // listener.test.ts has always asked it here.
3232
+ var ws_url_js_2 = require("./ws-url.js");
3233
+ Object.defineProperty(exports, "resolveWsUrl", { enumerable: true, get: function () { return ws_url_js_2.resolveWsUrl; } });
3242
3234
  // ── Singleton guard (PID file) ──────────────────────────────────────
3243
3235
  /**
3244
3236
  * Whether another `zeph listener` is already running on this machine.
@@ -3253,12 +3245,14 @@ const otherListenerAlive = () => {
3253
3245
  const pid = (0, listener_process_js_1.runningListenerPid)();
3254
3246
  return pid === null || pid === process.pid ? null : pid;
3255
3247
  };
3256
- const writeListenerPid = () => {
3248
+ const writeListenerPid = (wsUrl) => {
3257
3249
  try {
3258
3250
  // Stamp the version alongside the pid: `npm i -g` swaps the package
3259
3251
  // on disk without touching this already-running process, and the
3260
- // stamp is how `zeph cc` notices the drift and restarts us.
3261
- (0, listener_process_js_1.writeListenerRuntime)(config_js_1.VERSION);
3252
+ // stamp is how `zeph cc` notices the drift and restarts us. The socket
3253
+ // goes with it so `zeph verify` can say what this daemon is actually
3254
+ // connected to without reading a log that rotates out from under it.
3255
+ (0, listener_process_js_1.writeListenerRuntime)(config_js_1.VERSION, wsUrl);
3262
3256
  }
3263
3257
  catch (err) {
3264
3258
  log(`! could not write ${listener_process_js_1.LISTENER_PID_FILE}: ${err.message}`);
@@ -3391,15 +3385,17 @@ const handleListener = async (args) => {
3391
3385
  // resolution order as the rest of the CLI; falls back to the prod API.
3392
3386
  const baseUrl = args['base-url'] || (0, config_js_1.resolvedEnv)('ZEPH_BASE_URL') || config.baseUrl || DEFAULT_API_BASE;
3393
3387
  (0, exports.setAttachmentContext)({ apiKey, baseUrl });
3394
- const wsUrl = (0, exports.resolveWsUrl)(args, config, baseUrl);
3388
+ const staleWsEnv = (0, ws_url_js_1.legacyWsEnvNotice)(config);
3389
+ if (staleWsEnv)
3390
+ console.error(staleWsEnv);
3391
+ const wsUrl = (0, ws_url_js_1.resolveWsUrlDetailed)(args, config, baseUrl)?.url ?? null;
3395
3392
  if (!wsUrl) {
3396
3393
  console.error('zeph listener: WebSocket URL not set. Either:\n' +
3397
3394
  ' • add "wsUrl": "wss://..." to ~/.zeph/config.json\n' +
3398
- ' • export ZEPH_WS_URL=wss://...\n' +
3399
3395
  ' • pass --ws-url wss://...');
3400
3396
  return 1;
3401
3397
  }
3402
- writeListenerPid();
3398
+ writeListenerPid(wsUrl);
3403
3399
  process.on('exit', removeListenerPid);
3404
3400
  // Rotate before writing anything, so this run's first line lands in the
3405
3401
  // file the user tails rather than being copied straight into `.old`. The
@@ -3412,6 +3408,12 @@ const handleListener = async (args) => {
3412
3408
  log(`zeph listener starting — v${config_js_1.VERSION} — ${wsUrl}`);
3413
3409
  log(`device=${(0, exports.computeListenerDeviceId)()} host=${(0, os_1.hostname)()} pid=${process.pid}`);
3414
3410
  log("Waiting for 'agent.command' pushes from the phone picker. Ctrl-C to stop.");
3411
+ // Idle sleep kills the socket; "Wake for network access" does not bring it
3412
+ // back (see keep-awake.ts). Flag beats config; the default is on.
3413
+ const keepAwake = (0, keep_awake_js_1.startKeepAwake)({
3414
+ enabled: args['no-keep-awake'] !== true && config.keepAwake !== false,
3415
+ log,
3416
+ });
3415
3417
  // Heartbeat memory log — once an hour. Lets the user (and us) spot
3416
3418
  // gradual growth in a long-running daemon before it gets bad enough
3417
3419
  // to make the host shell unresponsive. The MB counter is human-
@@ -3465,6 +3467,7 @@ const handleListener = async (args) => {
3465
3467
  // Force-close any open WS so the streamSession promise resolves
3466
3468
  // immediately instead of waiting for the server to drop us.
3467
3469
  activeHandle?.terminate();
3470
+ keepAwake.stop();
3468
3471
  notifyStop();
3469
3472
  };
3470
3473
  process.on('SIGINT', () => stop('SIGINT'));
@@ -1 +1 @@
1
- {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AA4DA;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,EAAE,KAAK,MAAM,KAAG,MAAM,EAAE,GAAG,IAa5E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,OAQ5C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GACrB;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GACpD;IAAE,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAElE,wFAAwF;AACxF,eAAO,MAAM,uBAAuB,GAChC,MAAM,MAAM,EAAE,GAAG,IAAI,EACrB,UAAU,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,KACnC,eAAe,GAAG,IAMpB,CAAC;AAYF,eAAO,MAAM,YAAY,GAAU,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAG,OAAO,CAAC,MAAM,CA+GzF,CAAC"}
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAmEA;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,EAAE,KAAK,MAAM,KAAG,MAAM,EAAE,GAAG,IAa5E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,OAQ5C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GACrB;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GACpD;IAAE,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAElE,wFAAwF;AACxF,eAAO,MAAM,uBAAuB,GAChC,MAAM,MAAM,EAAE,GAAG,IAAI,EACrB,UAAU,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,KACnC,eAAe,GAAG,IAMpB,CAAC;AAuCF,eAAO,MAAM,YAAY,GAAU,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAG,OAAO,CAAC,MAAM,CA8IzF,CAAC"}
package/dist/verify.js CHANGED
@@ -9,6 +9,8 @@ const config_js_1 = require("./config.js");
9
9
  const listener_service_js_1 = require("./listener-service.js");
10
10
  const zeph_hook_js_1 = require("./zeph-hook.js");
11
11
  const mcp_command_js_1 = require("./mcp-command.js");
12
+ const listener_process_js_1 = require("./listener-process.js");
13
+ const ws_url_js_1 = require("./ws-url.js");
12
14
  const HOME = (0, os_1.homedir)();
13
15
  const pass = (msg) => console.log(` ✓ ${msg}`);
14
16
  const warn = (msg) => console.log(` ! ${msg}`);
@@ -118,6 +120,34 @@ const activeMcpRegistrations = (isOnPath) => MCP_REGISTRIES.flatMap((registry) =
118
120
  const result = (0, exports.classifyMcpRegistration)((0, exports.registeredMcpArgv)(registry.path, registry.key), isOnPath);
119
121
  return result ? [{ agent: registry.agent, result }] : [];
120
122
  });
123
+ /** Where a resolved WebSocket URL came from, in the user's terms. */
124
+ const WS_SOURCE_LABEL = {
125
+ flag: '--ws-url',
126
+ config: '~/.zeph/config.json',
127
+ 'env-deprecated': 'ZEPH_WS_URL (deprecated)',
128
+ default: 'built-in default',
129
+ };
130
+ /**
131
+ * The URL the live daemon connected to, or null when none is running.
132
+ *
133
+ * The stamp first; the log only as a fallback, for a daemon started by a build
134
+ * that predates the stamp. Reading the log alone was not enough — it rotates at
135
+ * 5MB, and the daemon whose startup line has been rotated away is precisely the
136
+ * long-lived one whose config edit this check exists to catch.
137
+ */
138
+ const liveListenerWsUrl = () => {
139
+ if ((0, listener_process_js_1.runningListenerPid)() === null)
140
+ return null;
141
+ const stamped = (0, listener_process_js_1.runningListenerWsUrl)();
142
+ if (stamped)
143
+ return stamped;
144
+ try {
145
+ return (0, ws_url_js_1.parseListenerStartUrl)((0, fs_1.readFileSync)(listener_process_js_1.LISTENER_LOG_FILE, 'utf-8'));
146
+ }
147
+ catch {
148
+ return null;
149
+ }
150
+ };
121
151
  const handleVerify = async (args) => {
122
152
  const doPing = args.ping === true;
123
153
  const checks = [];
@@ -172,6 +202,35 @@ const handleVerify = async (args) => {
172
202
  for (const row of serviceRows)
173
203
  record(row.label, row.state);
174
204
  }
205
+ // ── WebSocket ────────────────────────────────────────────────
206
+ // The phone's Agents list is fed over this socket, so a machine on the
207
+ // wrong stage is simply absent from the app with nothing to explain it.
208
+ console.log('\n WebSocket:');
209
+ const wsBaseUrl = args['base-url'] || (0, config_js_1.resolvedEnv)('ZEPH_BASE_URL') || config.baseUrl || ws_url_js_1.DEFAULT_API_BASE;
210
+ const staleWsEnv = (0, ws_url_js_1.legacyWsEnvNotice)(config);
211
+ if (staleWsEnv)
212
+ record(staleWsEnv.replace(/^zeph: /, ''), 'warn');
213
+ const ws = (0, ws_url_js_1.resolveWsUrlDetailed)(args, config, wsBaseUrl);
214
+ if (!ws) {
215
+ record('no WebSocket URL, and none can be guessed for a custom API base — set "wsUrl" in ~/.zeph/config.json', 'fail');
216
+ }
217
+ else {
218
+ record(`${ws.url} (from ${WS_SOURCE_LABEL[ws.source]})`, 'pass');
219
+ // Socket on one stage and REST on another splits the device: pushes go
220
+ // one way, the agent list the other, and neither half looks broken.
221
+ const wsStage = (0, ws_url_js_1.endpointStage)(ws.url);
222
+ const apiStage = (0, ws_url_js_1.endpointStage)(wsBaseUrl);
223
+ record(wsStage === apiStage
224
+ ? `API base is the same stage (${apiStage})`
225
+ : `stage mismatch — socket is ${wsStage}, API base is ${apiStage} (${wsBaseUrl}). Pushes and the agent list would land in different environments`, wsStage === apiStage ? 'pass' : 'warn');
226
+ // The daemon reads this once, at startup. Editing the config does
227
+ // nothing to a listener that has been up since before the edit — which
228
+ // looks exactly like the config not being read at all.
229
+ const live = liveListenerWsUrl();
230
+ if (live && live !== ws.url) {
231
+ record(`the running listener is on ${live}, not the resolved URL — restart it: zeph listener --restart`, 'warn');
232
+ }
233
+ }
175
234
  // ── MCP registrations ────────────────────────────────────────
176
235
  const registrations = activeMcpRegistrations(resolves);
177
236
  if (registrations.length > 0) {
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Where the listener's WebSocket URL comes from.
3
+ *
4
+ * The listener reads this once, at startup, and four things can supply it —
5
+ * which is exactly why a machine can sit on the wrong stage for hours with
6
+ * nothing to show for it but a line buried in listener.log. `zeph verify`
7
+ * reports the answer AND its source, so "config isn't being read" stops being
8
+ * a guess.
9
+ *
10
+ * Its own module rather than listener.ts so `zeph verify` can ask without
11
+ * loading the 187KB daemon.
12
+ */
13
+ export declare const DEFAULT_API_BASE = "https://api.zeph.to/v1";
14
+ export declare const DEFAULT_WS_URL = "wss://ws.zeph.to";
15
+ /**
16
+ * Which input won. Reported to the user verbatim.
17
+ *
18
+ * `ZEPH_WS_URL` used to sit ABOVE the config file, so an `export` in a shell
19
+ * profile silently outranked `~/.zeph/config.json` — invisible in the file,
20
+ * invisible in the app, indistinguishable from "the config is not being read".
21
+ * It now sits BELOW it, and warns whenever it is what answered.
22
+ *
23
+ * Not removed outright, because for one real configuration it was the only
24
+ * answer: a self-hosted deployment (custom API base) with the URL only in the
25
+ * environment. Dropping the lane made that listener refuse to start, and on the
26
+ * `zeph cc` autostart path its stderr goes to the log file, so the machine
27
+ * would just vanish from the app — the very failure this change exists to end.
28
+ */
29
+ export type WsUrlSource = 'flag' | 'config' | 'env-deprecated' | 'default';
30
+ export interface ResolvedWsUrl {
31
+ readonly url: string;
32
+ readonly source: WsUrlSource;
33
+ }
34
+ /**
35
+ * A user who only set ZEPH_API_KEY (no `zeph login`, no config file) gets the
36
+ * prod socket by default — mirroring the DEFAULT_API_BASE fallback for REST.
37
+ * The default only applies when the base URL is also the prod default: with a
38
+ * custom base URL, silently pointing the listener at the prod socket while
39
+ * REST talks to another stage would split the device across environments, so
40
+ * that combination still errors loudly.
41
+ */
42
+ export declare const resolveWsUrlDetailed: (args: Record<string, string | boolean>, config: {
43
+ wsUrl?: string;
44
+ }, baseUrl: string) => ResolvedWsUrl | null;
45
+ /** The URL alone — the listener's own question. One precedence list, not two. */
46
+ export declare const resolveWsUrl: (args: Record<string, string | boolean>, config: {
47
+ wsUrl?: string;
48
+ }, baseUrl: string) => string | null;
49
+ export declare const endpointStage: (url: string) => string;
50
+ /**
51
+ * The URL the RUNNING listener actually connected to, read out of its own
52
+ * startup line. The daemon resolves this once and can outlive a config edit by
53
+ * hours, so "what the config says" and "what is connected" are different
54
+ * questions — and only the second one explains a machine missing from the app.
55
+ *
56
+ * Matches the line listener.ts writes: `[HH:MM:SS] zeph listener starting — vX — <url>`.
57
+ * Last one wins; the log accumulates every restart.
58
+ */
59
+ export declare const parseListenerStartUrl: (logText: string) => string | null;
60
+ /**
61
+ * A one-line notice for a machine that still exports `ZEPH_WS_URL`, or null.
62
+ *
63
+ * The variable is no longer read, and dropping it in silence would be the same
64
+ * failure it caused: a value that appears to be in effect while something else
65
+ * decides. Read only to say it is being ignored, never to use.
66
+ */
67
+ export declare const legacyWsEnv: (env?: NodeJS.ProcessEnv) => string | null;
68
+ /**
69
+ * What to tell a machine that still exports `ZEPH_WS_URL`, or null.
70
+ *
71
+ * Two different messages, because the two situations are not the same problem:
72
+ * the config file now wins, so an export alongside it is dead weight, while an
73
+ * export on its own is still holding the machine up and must not be deleted
74
+ * before the value is moved.
75
+ */
76
+ export declare const legacyWsEnvNotice: (config?: {
77
+ wsUrl?: string;
78
+ }, env?: NodeJS.ProcessEnv) => string | null;
79
+ //# sourceMappingURL=ws-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws-url.d.ts","sourceRoot":"","sources":["../src/ws-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,2BAA2B,CAAC;AACzD,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAE3E,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAC7B,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EACtC,QAAQ;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EAC1B,SAAS,MAAM,KAChB,aAAa,GAAG,IAalB,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,YAAY,GACrB,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EACtC,QAAQ;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EAC1B,SAAS,MAAM,KAChB,MAAM,GAAG,IAAgE,CAAC;AAgB7E,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,KAAG,MAmB3C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,MAAM,KAAG,MAAM,GAAG,IAIhE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,MAAK,MAAM,CAAC,UAAwB,KAAG,MAAM,GAAG,IAK3E,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,GAC1B,SAAQ;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,EAC/B,MAAK,MAAM,CAAC,UAAwB,KACrC,MAAM,GAAG,IAKX,CAAC"}
package/dist/ws-url.js ADDED
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.legacyWsEnvNotice = exports.legacyWsEnv = exports.parseListenerStartUrl = exports.endpointStage = exports.resolveWsUrl = exports.resolveWsUrlDetailed = exports.DEFAULT_WS_URL = exports.DEFAULT_API_BASE = void 0;
4
+ /**
5
+ * Where the listener's WebSocket URL comes from.
6
+ *
7
+ * The listener reads this once, at startup, and four things can supply it —
8
+ * which is exactly why a machine can sit on the wrong stage for hours with
9
+ * nothing to show for it but a line buried in listener.log. `zeph verify`
10
+ * reports the answer AND its source, so "config isn't being read" stops being
11
+ * a guess.
12
+ *
13
+ * Its own module rather than listener.ts so `zeph verify` can ask without
14
+ * loading the 187KB daemon.
15
+ */
16
+ exports.DEFAULT_API_BASE = 'https://api.zeph.to/v1';
17
+ exports.DEFAULT_WS_URL = 'wss://ws.zeph.to';
18
+ /**
19
+ * A user who only set ZEPH_API_KEY (no `zeph login`, no config file) gets the
20
+ * prod socket by default — mirroring the DEFAULT_API_BASE fallback for REST.
21
+ * The default only applies when the base URL is also the prod default: with a
22
+ * custom base URL, silently pointing the listener at the prod socket while
23
+ * REST talks to another stage would split the device across environments, so
24
+ * that combination still errors loudly.
25
+ */
26
+ const resolveWsUrlDetailed = (args, config, baseUrl) => {
27
+ const fromArg = typeof args['ws-url'] === 'string' ? args['ws-url'] : null;
28
+ if (fromArg)
29
+ return { url: fromArg, source: 'flag' };
30
+ if (config.wsUrl)
31
+ return { url: config.wsUrl, source: 'config' };
32
+ // Below the config file, and above the built-in default: a machine that
33
+ // only ever had the environment variable keeps the stage it was on instead
34
+ // of being silently relocated to prod (or refusing to start).
35
+ const legacyEnv = (0, exports.legacyWsEnv)();
36
+ if (legacyEnv)
37
+ return { url: legacyEnv, source: 'env-deprecated' };
38
+ return baseUrl === exports.DEFAULT_API_BASE ? { url: exports.DEFAULT_WS_URL, source: 'default' } : null;
39
+ };
40
+ exports.resolveWsUrlDetailed = resolveWsUrlDetailed;
41
+ /** The URL alone — the listener's own question. One precedence list, not two. */
42
+ const resolveWsUrl = (args, config, baseUrl) => (0, exports.resolveWsUrlDetailed)(args, config, baseUrl)?.url ?? null;
43
+ exports.resolveWsUrl = resolveWsUrl;
44
+ /**
45
+ * Stage label for a zeph endpoint. The two endpoints carry it differently, and
46
+ * both forms have to be read or a correctly paired dev setup reports as broken:
47
+ *
48
+ * - The REST base encodes it in the PATH PREFIX — `/v1` is prod, `/d1` is dev,
49
+ * on the same `api.zeph.to` host (see agent-rules-fetch.ts).
50
+ * - The socket encodes it in the HOSTNAME — `ws.zeph.to` vs `ws-dev.zeph.to`,
51
+ * with no path at all.
52
+ *
53
+ * Only used to notice that the two point at different stages — a split-brain
54
+ * device, pushes going one way and the agent list the other. Never blocks.
55
+ */
56
+ const API_STAGE_PREFIX = { v1: 'prod', d1: 'dev' };
57
+ const endpointStage = (url) => {
58
+ let host = url;
59
+ let path = '';
60
+ try {
61
+ const parsed = new URL(url);
62
+ host = parsed.hostname;
63
+ path = parsed.pathname;
64
+ }
65
+ catch { /* not a URL — fall through and read it as a hostname */ }
66
+ // Host marker first: it is explicit, and it outranks the path. An
67
+ // `api-staging.zeph.to/v1` is staging — the `/v1` there says "the v1 API of
68
+ // the staging deployment", not "prod".
69
+ const marked = host.match(/(?:^|[.-])(dev|stage|staging|local|test)(?:[.-]|$)/);
70
+ if (marked)
71
+ return marked[1];
72
+ // Unmarked host: the path prefix is the only thing left that carries a
73
+ // stage, and on api.zeph.to it is the whole distinction.
74
+ const prefix = path.split('/').filter(Boolean)[0];
75
+ return (prefix && API_STAGE_PREFIX[prefix]) || 'prod';
76
+ };
77
+ exports.endpointStage = endpointStage;
78
+ /**
79
+ * The URL the RUNNING listener actually connected to, read out of its own
80
+ * startup line. The daemon resolves this once and can outlive a config edit by
81
+ * hours, so "what the config says" and "what is connected" are different
82
+ * questions — and only the second one explains a machine missing from the app.
83
+ *
84
+ * Matches the line listener.ts writes: `[HH:MM:SS] zeph listener starting — vX — <url>`.
85
+ * Last one wins; the log accumulates every restart.
86
+ */
87
+ const parseListenerStartUrl = (logText) => {
88
+ const starts = [...logText.matchAll(/zeph listener starting\b.*?(\S+)\s*$/gm)];
89
+ const last = starts.at(-1);
90
+ return last ? last[1] : null;
91
+ };
92
+ exports.parseListenerStartUrl = parseListenerStartUrl;
93
+ /**
94
+ * A one-line notice for a machine that still exports `ZEPH_WS_URL`, or null.
95
+ *
96
+ * The variable is no longer read, and dropping it in silence would be the same
97
+ * failure it caused: a value that appears to be in effect while something else
98
+ * decides. Read only to say it is being ignored, never to use.
99
+ */
100
+ const legacyWsEnv = (env = process.env) => {
101
+ const value = env.ZEPH_WS_URL;
102
+ // Same guard resolvedEnv applies: an unexpanded "${ZEPH_WS_URL}" from an
103
+ // agent's env block is a placeholder, not a value.
104
+ return value && !value.startsWith('${') ? value : null;
105
+ };
106
+ exports.legacyWsEnv = legacyWsEnv;
107
+ /**
108
+ * What to tell a machine that still exports `ZEPH_WS_URL`, or null.
109
+ *
110
+ * Two different messages, because the two situations are not the same problem:
111
+ * the config file now wins, so an export alongside it is dead weight, while an
112
+ * export on its own is still holding the machine up and must not be deleted
113
+ * before the value is moved.
114
+ */
115
+ const legacyWsEnvNotice = (config = {}, env = process.env) => {
116
+ if (!(0, exports.legacyWsEnv)(env))
117
+ return null;
118
+ return config.wsUrl
119
+ ? 'zeph: ZEPH_WS_URL is set but ~/.zeph/config.json wins now — the export does nothing and can go.'
120
+ : 'zeph: ZEPH_WS_URL is deprecated and will stop being read — move the value to "wsUrl" in ~/.zeph/config.json.';
121
+ };
122
+ exports.legacyWsEnvNotice = legacyWsEnvNotice;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeph-to/cli",
3
- "version": "2.13.0",
3
+ "version": "2.15.0",
4
4
  "description": "Zeph CLI + push notification SDK for AI agents",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",