@heywavie/cli 0.2.3 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/claude.mjs +17 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heywavie/cli",
3
- "version": "0.2.3",
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
6
  "license": "AGPL-3.0-only",
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);