@theopenbee/engine-claude 0.1.1 → 0.2.1

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
@@ -46,6 +46,10 @@ Then enable the plugin, and pick `claude` as the default engine or per worker.
46
46
 
47
47
  The plugin checks the setting when it is enabled: it runs `claude --version` and shows the version, or the reason it failed (for example `claude not found on PATH`).
48
48
 
49
+ ## Model
50
+
51
+ The worker's **Model** field is passed to Claude Code as `--model <model>`, before the extra args. Claude Code has no command that lists models, so the plugin suggests the aliases `fable`, `opus`, `sonnet` and `haiku`; any other model name Claude Code accepts works too. If the engine args already set a model with `--model`, they win and the Model field is ignored. Without a model, Claude Code uses its own default.
52
+
49
53
  ## Sessions
50
54
 
51
55
  Sessions stay in Claude Code's own config directory, `~/.claude/projects/` (or `~/.config/claude/projects/`). The plugin does not copy or move them, so conversations that were started before the plugin was installed resume as before, and they survive uninstalling the plugin.
@@ -55,7 +59,7 @@ Token usage is read from the same session files and summed per model. If `CLAUDE
55
59
  ## How it runs Claude Code
56
60
 
57
61
  ```
58
- claude --dangerously-skip-permissions --verbose --output-format stream-json [--mcp-config=<json>] [--session-id <id> | --resume <id>] [extra args] --print
62
+ claude --dangerously-skip-permissions --verbose --output-format stream-json [--mcp-config=<json>] [--session-id <id> | --resume <id>] [--model <model>] [extra args] --print
59
63
  ```
60
64
 
61
65
  - The prompt is written to Claude Code's standard input.
package/dist/claude.d.ts CHANGED
@@ -6,7 +6,7 @@ export interface ResultScan {
6
6
  lastAssistantText: string;
7
7
  }
8
8
  export declare function mcpConfig(mcp: McpParams): string;
9
- export declare function buildArgs(params: Pick<RunParams, "session_id" | "resume" | "extra_args" | "mcp">): string[];
9
+ export declare function buildArgs(params: Pick<RunParams, "session_id" | "resume" | "extra_args" | "model" | "mcp">): string[];
10
10
  export declare function scanResultLog(logPath: string): Promise<ResultScan>;
11
11
  export declare function extractResultFromLog(logPath: string): Promise<string>;
12
12
  export declare function claudeBaseDirs(env?: NodeJS.ProcessEnv, home?: string): string[];
package/dist/claude.js CHANGED
@@ -4,6 +4,7 @@ import { join } from "node:path";
4
4
  import { createInterface } from "node:readline";
5
5
  import { cliVersion, findCli, log, spawnCli } from "@theopenbee/engine-sdk";
6
6
  const SYNTHETIC_MODEL = "<synthetic>";
7
+ const MODEL_ALIASES = ["fable", "opus", "sonnet", "haiku"];
7
8
  const EMPTY_ERROR_TEXT = "bee execution failed (no details available)";
8
9
  function isObject(value) {
9
10
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -27,6 +28,15 @@ export function mcpConfig(mcp) {
27
28
  },
28
29
  });
29
30
  }
31
+ function modelArgs(model, extraArgs) {
32
+ if (typeof model !== "string" || model === "")
33
+ return [];
34
+ if (extraArgs.some((arg) => arg === "--model" || arg.startsWith("--model="))) {
35
+ log.warn(`engine args already set a model, ignoring model ${JSON.stringify(model)}`);
36
+ return [];
37
+ }
38
+ return ["--model", model];
39
+ }
30
40
  export function buildArgs(params) {
31
41
  const args = ["--dangerously-skip-permissions", "--verbose", "--output-format", "stream-json"];
32
42
  if (params.mcp?.url)
@@ -34,7 +44,8 @@ export function buildArgs(params) {
34
44
  if (params.session_id) {
35
45
  args.push(params.resume ? "--resume" : "--session-id", params.session_id);
36
46
  }
37
- args.push(...(params.extra_args ?? []), "--print");
47
+ const extraArgs = params.extra_args ?? [];
48
+ args.push(...modelArgs(params.model, extraArgs), ...extraArgs, "--print");
38
49
  return args;
39
50
  }
40
51
  function firstAssistantText(event) {
@@ -277,4 +288,7 @@ export const engine = {
277
288
  async usage(req) {
278
289
  return collectUsage(claudeBaseDirs(), req.params.session_ids ?? []);
279
290
  },
291
+ async models() {
292
+ return MODEL_ALIASES.map((id) => ({ id }));
293
+ },
280
294
  };
package/icon.svg ADDED
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <path fill="currentColor" fill-rule="nonzero" d="M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z"/>
3
+ </svg>
@@ -5,6 +5,7 @@
5
5
  "name": { "en": "Claude Code", "zh": "Claude Code" },
6
6
  "description": { "en": "Runs tasks with Claude Code", "zh": "用 Claude Code 执行任务" },
7
7
  "command": ["node", "dist/index.js"],
8
+ "icon": "icon.svg",
8
9
  "config": [
9
10
  {
10
11
  "key": "path",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theopenbee/engine-claude",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "Claude Code engine plugin for openbee",
5
5
  "keywords": [
6
6
  "openbee",
@@ -22,6 +22,7 @@
22
22
  "main": "./dist/index.js",
23
23
  "files": [
24
24
  "dist",
25
+ "icon.svg",
25
26
  "openbee.plugin.json"
26
27
  ],
27
28
  "engines": {
@@ -37,7 +38,7 @@
37
38
  "prepare": "npm run build"
38
39
  },
39
40
  "dependencies": {
40
- "@theopenbee/engine-sdk": "^0.1.0"
41
+ "@theopenbee/engine-sdk": "^0.2.0"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@types/node": "^22.10.0",