@heywavie/cli 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,6 +18,10 @@ Claude Code they use there. Published to npm as `@heywavie/cli` (its command is
18
18
 
19
19
  The token works once, for 30 minutes, and rides after `#`, so fetching the page never sends it.
20
20
 
21
+ The Mac app (`desktop/`, 1.0.7 on) skips the sentence: it ships this package and runs `link` itself, its service run
22
+ by the app as Node. A change here reaches those Macs with the app's next version: started after an update, the app
23
+ puts its own copy in (`refresh`), when the CLI's version changed.
24
+
21
25
  ## What the service does
22
26
 
23
27
  `heywavie run` waits on `GET /device/asks` by the computer's key, as its own device, for `claude` asks only, and runs
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@heywavie/cli",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Claude on your computer, for Wavie: your agents think with your own Claude plan",
5
5
  "homepage": "https://heywavie.com",
6
- "license": "UNLICENSED",
6
+ "license": "AGPL-3.0-only",
7
7
  "type": "module",
8
8
  "bin": {
9
9
  "heywavie": "bin/heywavie.mjs"
package/src/host.mjs CHANGED
@@ -11,9 +11,17 @@ const WAIT_S = 20;
11
11
 
12
12
  const PLATFORM = { darwin: 'darwin', linux: 'linux', win32: 'win32' }[process.platform] ?? 'linux';
13
13
  const sleep = (ms, signal) => new Promise((resolve) => {
14
+ if (signal?.aborted) return resolve();
14
15
  const t = setTimeout(resolve, ms);
15
16
  signal?.addEventListener('abort', () => { clearTimeout(t); resolve(); }, { once: true });
16
17
  });
18
+ // A body that ends when the service stops: once its request is aborted, fetch can leave res.json() waiting for good.
19
+ const bodyOf = (res, signal) => new Promise((resolve) => {
20
+ if (signal?.aborted) return resolve({});
21
+ const stop = () => resolve({});
22
+ signal?.addEventListener('abort', stop, { once: true });
23
+ res.json().then(resolve, () => resolve({})).finally(() => signal?.removeEventListener('abort', stop));
24
+ });
17
25
 
18
26
  /** Turns running here at once, at most `max`: `place()` resolves when there is room, `free()` hands it on. */
19
27
  export function places(max = TURNS_MAX) {
@@ -90,7 +98,8 @@ export async function host({ link, fetch = globalThis.fetch, signal = null, log
90
98
  continue;
91
99
  }
92
100
  backoff = 1000;
93
- const { asks = [] } = await res.json().catch(() => ({}));
101
+ const { asks = [] } = await bodyOf(res, signal);
102
+ if (signal?.aborted) break;
94
103
  for (const ask of asks) if (ask?.ability === 'claude') await start(ask);
95
104
  }
96
105
  stopAll();