@bakers-build/addon-claude 0.8.1-next.1 → 0.8.1-next.10

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.
@@ -20,10 +20,3 @@ import { type AgentFootprint } from '@bakers-build/conductor/contract';
20
20
  * to its tool_result. Only timestamped entries take part; no threshold.
21
21
  */
22
22
  export declare function parseClaudeTranscript(jsonl: string): AgentFootprint;
23
- /**
24
- * Every tool call `dontAsk` denied in a Claude-Code transcript, as `Tool(argument)`,
25
- * but only when the run stopped on one: a denial is among the last batch of tool
26
- * results, no call is outstanding and the agent has replied with text, no new call.
27
- * A run that worked on, waits on a sub-agent or on the model gives `[]`.
28
- */
29
- export declare function parseClaudePermissionDenials(jsonl: string): string[];
@@ -150,71 +150,3 @@ export function parseClaudeTranscript(jsonl) {
150
150
  return wait;
151
151
  }
152
152
  }
153
- /** Claude Code's tool_result text when `--permission-mode dontAsk` refuses a call. */
154
- const DONT_ASK_DENIAL = /^Permission to use \S+ has been denied because Claude Code is running in don't ask mode\./;
155
- /** The input field that names what a tool call acts on. */
156
- const ACTION_KEYS = ['file_path', 'command', 'url', 'path', 'pattern', 'skill'];
157
- /**
158
- * Every tool call `dontAsk` denied in a Claude-Code transcript, as `Tool(argument)`,
159
- * but only when the run stopped on one: a denial is among the last batch of tool
160
- * results, no call is outstanding and the agent has replied with text, no new call.
161
- * A run that worked on, waits on a sub-agent or on the model gives `[]`.
162
- */
163
- export function parseClaudePermissionDenials(jsonl) {
164
- const calls = new Map();
165
- const pending = new Set();
166
- const denied = [];
167
- let batchDenied = false;
168
- let batchMessage;
169
- let replied = false;
170
- for (const raw of jsonl.split('\n')) {
171
- let entry;
172
- try {
173
- entry = JSON.parse(raw);
174
- }
175
- catch {
176
- continue;
177
- }
178
- const content = entry?.message?.content;
179
- if (!Array.isArray(content))
180
- continue;
181
- const blocks = content;
182
- // Claude Code writes each block of a response as its own entry, sometimes with a
183
- // call's result before the response's next call: a call from a new response
184
- // opens a new batch, a reply without one ends the turn.
185
- if (entry?.type === 'assistant') {
186
- if (blocks.some((b) => b?.type === 'tool_use')) {
187
- const message = entry.message?.id;
188
- const sameResponse = message !== undefined && message === batchMessage;
189
- if (pending.size === 0 && !sameResponse)
190
- batchDenied = false;
191
- batchMessage = message;
192
- replied = false;
193
- }
194
- else if (blocks.some((b) => b?.type === 'text')) {
195
- // A thinking-only entry precedes the rest of its response, so it is no reply.
196
- replied = true;
197
- }
198
- }
199
- for (const block of blocks) {
200
- if (block?.type === 'tool_use' && typeof block.id === 'string') {
201
- const input = (block.input ?? {});
202
- const key = ACTION_KEYS.find((k) => typeof input[k] === 'string');
203
- const name = String(block.name);
204
- calls.set(block.id, key ? `${name}(${input[key]})` : name);
205
- pending.add(block.id);
206
- }
207
- else if (block?.type === 'tool_result') {
208
- pending.delete(String(block.tool_use_id));
209
- replied = false;
210
- if (block.is_error === true &&
211
- typeof block.content === 'string' &&
212
- DONT_ASK_DENIAL.test(block.content)) {
213
- batchDenied = true;
214
- denied.push(calls.get(String(block.tool_use_id)) ?? 'unknown tool');
215
- }
216
- }
217
- }
218
- }
219
- return batchDenied && replied && pending.size === 0 ? denied : [];
220
- }
@@ -61,12 +61,8 @@ export declare class ClaudeAgent implements BbAgent {
61
61
  * launch at all, silently (`claude` exits 0 on that error).
62
62
  */
63
63
  sessionExists(worktreePath: string, sessionId: string): Promise<boolean>;
64
- /** The run's pinned transcript only: the newest existing attempt, as {@link getRunLog} prefers it. */
65
- runLogModified(worktreePath: string, run: AgentRunIdentity): Promise<number | undefined>;
66
64
  getRunLog(worktreePath: string, run?: AgentRunIdentity): Promise<string>;
67
65
  parseFootprint(log: string): AgentFootprint;
68
- /** Only the sandbox launches in `dontAsk`; other modes are never reported. */
69
- permissionDenials(log: string): string[];
70
66
  /** Linux needs bwrap, socat and a user namespace; macOS ships Seatbelt. */
71
67
  sandboxPreflight(host?: SandboxHost): Promise<SandboxPreflight>;
72
68
  }
package/dist/src/index.js CHANGED
@@ -5,9 +5,9 @@ import { homedir } from 'node:os';
5
5
  import { join } from 'node:path';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import { promisify } from 'node:util';
8
- import { CONDUCTOR_TOKEN_ENV, CONDUCTOR_TOOLS_SERVER, ensureHome, homeKey, homePath, installCommand, lastLine, resolveAgentCliOptions, resolveSecurityOptions, systemSandboxHost, validateOptionalBoolean, } from '@bakers-build/conductor/contract';
8
+ import { CONDUCTOR_TOKEN_ENV, CONDUCTOR_TOOL_TIMEOUT_MS, CONDUCTOR_TOOLS_SERVER, ensureHome, homeKey, homePath, installCommand, lastLine, resolveAgentCliOptions, resolveSecurityOptions, systemSandboxHost, validateOptionalBoolean, } from '@bakers-build/conductor/contract';
9
9
  import { gitSandboxPaths, shellQuote, withoutGitDirs, } from '@bakers-build/core';
10
- import { parseClaudePermissionDenials, parseClaudeTranscript, } from './footprint.js';
10
+ import { parseClaudeTranscript } from './footprint.js';
11
11
  export { parseClaudeTranscript } from './footprint.js';
12
12
  /** src/index.ts and dist/src/index.js both sit two levels below the package root. */
13
13
  const MEASURE_WRAPPER = fileURLToPath(new URL(import.meta.url.includes('/dist/')
@@ -32,7 +32,7 @@ const SANDBOX_DEFAULTS = {
32
32
  mcp_servers: {},
33
33
  };
34
34
  /** The launch flags a security mode owns (`docs/addons/claude.md`). */
35
- function securityFlags({ mode, sandbox, config }, workspacePath, configDir, pluginsOn = false) {
35
+ function securityFlags({ mode, sandbox, config }, workspacePath, pluginsOn = false) {
36
36
  if (mode === 'system')
37
37
  return [];
38
38
  if (mode === 'yolo')
@@ -59,23 +59,18 @@ function securityFlags({ mode, sandbox, config }, workspacePath, configDir, plug
59
59
  network: { allowedDomains: sandbox.network },
60
60
  },
61
61
  disableClaudeAiConnectors: true,
62
- // What is allowed here runs without a prompt; under dontAsk anything
63
- // else, such as a write outside the worktree or to the protected
64
- // `.claude/`, is denied at once, since nobody answers a prompt on a box.
65
- // Every Bash command is either sandboxed or a trusted command, and the
66
- // Read deny covers the Read tool, which the OS sandbox does not confine.
62
+ // What is allowed here runs without a prompt; anything else, such as a
63
+ // write to the protected `.claude/`, asks the human watching the run's
64
+ // terminal (dontAsk would deny it, and no allow rule lifts that). Every
65
+ // Bash command is either sandboxed or a trusted command, and the Read
66
+ // deny covers the Read tool, which the OS sandbox does not confine.
67
67
  permissions: {
68
68
  // The conductor's server binds every call to this run's worktree and project.
69
- // The run's own plugins and skills live in its config dir, outside the worktree;
70
- // Claude applies Read rules to Glob and Grep as well.
71
69
  allow: [
72
70
  'Bash',
73
71
  'Edit(./**)',
74
72
  'AskUserQuestion',
75
73
  `mcp__${CONDUCTOR_TOOLS_SERVER}`,
76
- 'Skill',
77
- `Read(/${join(configDir, 'plugins')}/**)`,
78
- `Read(/${join(configDir, 'skills')}/**)`,
79
74
  ],
80
75
  // Claude reads a single leading `/` as relative to the settings file;
81
76
  // the plain rule covers a file entry, `/**` a directory's contents.
@@ -87,7 +82,7 @@ function securityFlags({ mode, sandbox, config }, workspacePath, configDir, plug
87
82
  };
88
83
  return [
89
84
  '--permission-mode',
90
- 'dontAsk',
85
+ 'default',
91
86
  // The agent home's user settings enable its plugins; the person's own stay out.
92
87
  '--setting-sources',
93
88
  pluginsOn ? 'user,project,local' : 'project,local',
@@ -245,7 +240,7 @@ export class ClaudeAgent {
245
240
  }
246
241
  // The flags are constants; only their generated values need quoting.
247
242
  parts.push(...[
248
- ...securityFlags(this.security, workspacePath, this.configDir, this.pluginsOn),
243
+ ...securityFlags(this.security, workspacePath, this.pluginsOn),
249
244
  ...this.mcpFlags(tools),
250
245
  ].map((t) => (t.startsWith('--') ? t : shellQuote(t))));
251
246
  // Pin the transcript's own session id to the run's UUID (BB-473), so
@@ -278,6 +273,7 @@ export class ClaudeAgent {
278
273
  type: 'http',
279
274
  url: tools.url,
280
275
  headers: { Authorization: `Bearer \${${CONDUCTOR_TOKEN_ENV}}` },
276
+ timeout: CONDUCTOR_TOOL_TIMEOUT_MS,
281
277
  },
282
278
  }
283
279
  : {};
@@ -312,22 +308,6 @@ export class ClaudeAgent {
312
308
  return false;
313
309
  }
314
310
  }
315
- /** The run's pinned transcript only: the newest existing attempt, as {@link getRunLog} prefers it. */
316
- async runLogModified(worktreePath, run) {
317
- const dir = join(this.configDir, 'projects', encodeClaudeProjectDir(worktreePath));
318
- const names = run.attemptFamily?.length
319
- ? [...run.attemptFamily].reverse()
320
- : [run.sessionId];
321
- for (const name of names) {
322
- try {
323
- return (await stat(join(dir, `${name}.jsonl`))).mtimeMs;
324
- }
325
- catch {
326
- // try the next, lower-numbered attempt.
327
- }
328
- }
329
- return undefined;
330
- }
331
311
  async getRunLog(worktreePath, run) {
332
312
  const dir = join(this.configDir, 'projects', encodeClaudeProjectDir(worktreePath));
333
313
  const startedAtMs = run?.startedAt !== undefined ? new Date(run.startedAt).getTime() : null;
@@ -422,12 +402,6 @@ export class ClaudeAgent {
422
402
  parseFootprint(log) {
423
403
  return parseClaudeTranscript(log);
424
404
  }
425
- /** Only the sandbox launches in `dontAsk`; other modes are never reported. */
426
- permissionDenials(log) {
427
- if (this.securityMode !== 'sandbox')
428
- return [];
429
- return parseClaudePermissionDenials(log);
430
- }
431
405
  /** Linux needs bwrap, socat and a user namespace; macOS ships Seatbelt. */
432
406
  async sandboxPreflight(host = systemSandboxHost()) {
433
407
  if (this.securityMode !== 'sandbox' || host.platform !== 'linux') {
@@ -6,7 +6,14 @@
6
6
  "properties": {
7
7
  "measure": {
8
8
  "type": "boolean",
9
- "description": "Run the launch through the measuring proxy. Default: false."
9
+ "description": "Start the launch through the addon's measuring proxy.",
10
+ "default": false
11
+ },
12
+ "model": {
13
+ "description": "Passed as `--model`; replaces `opus`, `sonnet` and `fable` with one custom candidate."
14
+ },
15
+ "effort": {
16
+ "description": "Passed as `--effort`."
10
17
  }
11
18
  },
12
19
  "unevaluatedProperties": false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/addon-claude",
3
- "version": "0.8.1-next.1",
3
+ "version": "0.8.1-next.10",
4
4
  "description": "bakers.build agent plugin for the Claude CLI.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,11 +26,11 @@
26
26
  "directory": "bakers-cli/addons/claude"
27
27
  },
28
28
  "peerDependencies": {
29
- "@bakers-build/conductor": "^0.8.1-next.1",
30
- "@bakers-build/core": "^0.8.1-next.1"
29
+ "@bakers-build/conductor": "^0.8.1-next.10",
30
+ "@bakers-build/core": "^0.8.1-next.10"
31
31
  },
32
32
  "bakersBuild": {
33
- "commit": "c4a887bee37bb2fed14bb9ba15ad0aacf0e26f7e",
33
+ "commit": "ceb44a12624feaa85cb2b0c9f84345399b38bf50",
34
34
  "channel": "next"
35
35
  }
36
36
  }