@heywavie/cli 0.2.2 → 0.2.4

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.4",
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/claude.mjs CHANGED
@@ -55,6 +55,10 @@ export function claudeEnv(env = process.env, home = os.homedir(), bin = null, {
55
55
  */
56
56
  export const CLAUDE_MODEL = 'claude-opus-5-5';
57
57
 
58
+ /** What a person may pick for their teammate (heywavie's composer): Claude Code's model aliases and effort levels. */
59
+ export const CLAUDE_MODELS = ['fable', 'opus', 'sonnet'];
60
+ export const CLAUDE_EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'];
61
+
58
62
  /** Claude Code's refusal of a model the account can't use: its first message, marked or in its own words. */
59
63
  const REFUSED = /issue with the selected model/i;
60
64
  // Refused once here: later turns go straight to Claude Code's own default, until the service starts again.
@@ -67,8 +71,8 @@ export const mcpConfig = (tools) => ({ mcpServers: { wavie: { type: 'http', url:
67
71
  * The one command a turn runs: model only, Wavie's tools its only ones. The instructions and the tools' address are in
68
72
  * files only they can read (`systemFile`, `mcpFile`), never on the command line, where anyone on the computer sees it (ps).
69
73
  */
70
- export function claudeArgs({ systemFile, mcpFile, maxSteps, model = CLAUDE_MODEL }) {
71
- return ['-p', ...(model ? ['--model', model] : []), '--output-format', 'stream-json', '--verbose', '--include-partial-messages', '--input-format', 'stream-json',
74
+ export function claudeArgs({ systemFile, mcpFile, maxSteps, model = CLAUDE_MODEL, effort = null }) {
75
+ return ['-p', ...(model ? ['--model', model] : []), ...(effort ? ['--effort', effort] : []), '--output-format', 'stream-json', '--verbose', '--include-partial-messages', '--input-format', 'stream-json',
72
76
  '--system-prompt-file', systemFile, '--tools', '', '--strict-mcp-config', '--mcp-config', mcpFile,
73
77
  '--allowedTools', 'mcp__wavie', '--permission-prompts', 'none', '--no-session-persistence', '--disable-slash-commands',
74
78
  // No --safe-mode: it turns off MCP servers too, Wavie's with them. Their CLAUDE.md stays out without it.
@@ -110,7 +114,10 @@ export function turnOf(input, api) {
110
114
  if (!at || at[1] !== tools[1] || !FILE_TYPES.has(f.mediaType)) throw new Error('Not a turn of Wavie\'s.');
111
115
  return { url: `${api}${at[0]}`, name: String(f.name ?? 'file').slice(0, 200), mediaType: f.mediaType };
112
116
  });
113
- return { tools: `${api}${tools[0]}`, events: `${api}${events[0]}`, system: input.system, prompt: input.prompt, files, maxSteps: steps };
117
+ // The model and effort they picked, only from Claude Code's own lists; anything else runs as if unpicked.
118
+ const model = CLAUDE_MODELS.includes(input.model) ? input.model : null;
119
+ const effort = CLAUDE_EFFORTS.includes(input.effort) ? input.effort : null;
120
+ return { tools: `${api}${tools[0]}`, events: `${api}${events[0]}`, system: input.system, prompt: input.prompt, files, maxSteps: steps, model, effort };
114
121
  }
115
122
 
116
123
  /** Who Claude Code on this computer is signed in as: `{ found, loggedIn, email, kind }`. */
@@ -231,11 +238,11 @@ export async function runTurn({ bin, turn, fetch = globalThis.fetch, env = proce
231
238
  await writeFile(mcpFile, JSON.stringify(mcpConfig(turn.tools)), { mode: 0o600 });
232
239
  const ceiling = setTimeout(stop, maxMs);
233
240
  let errText = '';
234
- // Once on CLAUDE_MODEL. A plan that can't use it (Claude Code answers its first message with model_not_found) runs
235
- // again on Claude Code's own default: Claude Code's opening lines wait until the first message shows which, and the
236
- // refusal never reaches the server as an answer.
241
+ // Once on the model they picked, else CLAUDE_MODEL. A plan that can't use it (Claude Code answers its first message
242
+ // with model_not_found) runs again on Claude Code's own default: Claude Code's opening lines wait until the first
243
+ // message shows which, and the refusal never reaches the server as an answer.
237
244
  const once = async (model) => {
238
- child = spawn(bin, claudeArgs({ systemFile, mcpFile, maxSteps: turn.maxSteps, model }), { cwd: dir, env: claudeEnv(env, home, bin, { user: os.userInfo().username }),
245
+ child = spawn(bin, claudeArgs({ systemFile, mcpFile, maxSteps: turn.maxSteps, model, effort: turn.effort ?? null }), { cwd: dir, env: claudeEnv(env, home, bin, { user: os.userInfo().username }),
239
246
  stdio: ['pipe', 'pipe', 'pipe'] });
240
247
  children.add(child);
241
248
  let buffer = '';
@@ -274,8 +281,9 @@ export async function runTurn({ bin, turn, fetch = globalThis.fetch, env = proce
274
281
  if (held) pending.push(...held);
275
282
  return { exit, refused };
276
283
  };
277
- let { exit: code, refused } = await once(refusedHere ? null : CLAUDE_MODEL);
278
- if (refused) refusedHere = true;
284
+ // A model they picked is tried every turn; only the default one, once refused, is skipped from then on.
285
+ let { exit: code, refused } = await once(turn.model ?? (refusedHere ? null : CLAUDE_MODEL));
286
+ if (refused && !turn.model) refusedHere = true;
279
287
  if (refused && !stopping) ({ exit: code } = await once(null));
280
288
  clearInterval(timer);
281
289
  clearTimeout(ceiling);
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();