@bakers-build/addon-claude 0.8.1-next.3 → 0.8.1-next.5

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
- }
@@ -47,15 +47,6 @@ export declare class ClaudeAgent implements BbAgent {
47
47
  launchCommand(prompt: string, run?: AgentRunIdentity, workspacePath?: string, tools?: {
48
48
  url: string;
49
49
  }, _env?: Readonly<Record<string, string>>, pluginArgs?: readonly string[]): string;
50
- /**
51
- * `claude --resume <id>` with the launch's own flags, so a run whose pane
52
- * died continues its conversation. Not for a measured run: its wrapper
53
- * profiles one fresh session.
54
- */
55
- resumeCommand(sessionId: string, workspacePath?: string, tools?: {
56
- url: string;
57
- }, _env?: Readonly<Record<string, string>>, pluginArgs?: readonly string[]): string | undefined;
58
- private command;
59
50
  /**
60
51
  * The sandbox's strict MCP config, plus the conductor's tool server when
61
52
  * the run has one. A measured run stays without MCP servers. The token is
@@ -70,12 +61,8 @@ export declare class ClaudeAgent implements BbAgent {
70
61
  * launch at all, silently (`claude` exits 0 on that error).
71
62
  */
72
63
  sessionExists(worktreePath: string, sessionId: string): Promise<boolean>;
73
- /** The run's pinned transcript only: the newest existing attempt, as {@link getRunLog} prefers it. */
74
- runLogModified(worktreePath: string, run: AgentRunIdentity): Promise<number | undefined>;
75
64
  getRunLog(worktreePath: string, run?: AgentRunIdentity): Promise<string>;
76
65
  parseFootprint(log: string): AgentFootprint;
77
- /** Only the sandbox launches in `dontAsk`; other modes are never reported. */
78
- permissionDenials(log: string): string[];
79
66
  /** Linux needs bwrap, socat and a user namespace; macOS ships Seatbelt. */
80
67
  sandboxPreflight(host?: SandboxHost): Promise<SandboxPreflight>;
81
68
  }
package/dist/src/index.js CHANGED
@@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url';
7
7
  import { promisify } from 'node:util';
8
8
  import { CONDUCTOR_TOKEN_ENV, 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',
@@ -224,21 +219,6 @@ export class ClaudeAgent {
224
219
  if (prompt === '') {
225
220
  return 'claude';
226
221
  }
227
- return this.command(this.measure
228
- ? ['node', shellQuote(MEASURE_WRAPPER), 'claude', shellQuote(prompt)]
229
- : ['claude', shellQuote(prompt)], run, workspacePath, tools, pluginArgs);
230
- }
231
- /**
232
- * `claude --resume <id>` with the launch's own flags, so a run whose pane
233
- * died continues its conversation. Not for a measured run: its wrapper
234
- * profiles one fresh session.
235
- */
236
- resumeCommand(sessionId, workspacePath, tools, _env, pluginArgs = []) {
237
- if (this.measure)
238
- return undefined;
239
- return this.command(['claude', '--resume', shellQuote(sessionId)], undefined, workspacePath, tools, pluginArgs);
240
- }
241
- command(head, run, workspacePath, tools, pluginArgs) {
242
222
  // Wait for project-declared plugins (extraKnownMarketplaces) to install
243
223
  // before the first turn; a fresh worktree otherwise starts without them.
244
224
  // A new worktree path would stop the run at Claude Code's trust dialog.
@@ -248,7 +228,9 @@ export class ClaudeAgent {
248
228
  ...(workspacePath
249
229
  ? ['node', shellQuote(TRUST_WRAPPER), shellQuote(workspacePath)]
250
230
  : []),
251
- ...head,
231
+ ...(this.measure
232
+ ? ['node', shellQuote(MEASURE_WRAPPER), 'claude', shellQuote(prompt)]
233
+ : ['claude', shellQuote(prompt)]),
252
234
  ];
253
235
  if (this.model !== undefined && !this.overrides.model) {
254
236
  parts.push('--model', shellQuote(this.model));
@@ -258,7 +240,7 @@ export class ClaudeAgent {
258
240
  }
259
241
  // The flags are constants; only their generated values need quoting.
260
242
  parts.push(...[
261
- ...securityFlags(this.security, workspacePath, this.configDir, this.pluginsOn),
243
+ ...securityFlags(this.security, workspacePath, this.pluginsOn),
262
244
  ...this.mcpFlags(tools),
263
245
  ].map((t) => (t.startsWith('--') ? t : shellQuote(t))));
264
246
  // Pin the transcript's own session id to the run's UUID (BB-473), so
@@ -325,22 +307,6 @@ export class ClaudeAgent {
325
307
  return false;
326
308
  }
327
309
  }
328
- /** The run's pinned transcript only: the newest existing attempt, as {@link getRunLog} prefers it. */
329
- async runLogModified(worktreePath, run) {
330
- const dir = join(this.configDir, 'projects', encodeClaudeProjectDir(worktreePath));
331
- const names = run.attemptFamily?.length
332
- ? [...run.attemptFamily].reverse()
333
- : [run.sessionId];
334
- for (const name of names) {
335
- try {
336
- return (await stat(join(dir, `${name}.jsonl`))).mtimeMs;
337
- }
338
- catch {
339
- // try the next, lower-numbered attempt.
340
- }
341
- }
342
- return undefined;
343
- }
344
310
  async getRunLog(worktreePath, run) {
345
311
  const dir = join(this.configDir, 'projects', encodeClaudeProjectDir(worktreePath));
346
312
  const startedAtMs = run?.startedAt !== undefined ? new Date(run.startedAt).getTime() : null;
@@ -435,12 +401,6 @@ export class ClaudeAgent {
435
401
  parseFootprint(log) {
436
402
  return parseClaudeTranscript(log);
437
403
  }
438
- /** Only the sandbox launches in `dontAsk`; other modes are never reported. */
439
- permissionDenials(log) {
440
- if (this.securityMode !== 'sandbox')
441
- return [];
442
- return parseClaudePermissionDenials(log);
443
- }
444
404
  /** Linux needs bwrap, socat and a user namespace; macOS ships Seatbelt. */
445
405
  async sandboxPreflight(host = systemSandboxHost()) {
446
406
  if (this.securityMode !== 'sandbox' || host.platform !== 'linux') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/addon-claude",
3
- "version": "0.8.1-next.3",
3
+ "version": "0.8.1-next.5",
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.3",
30
- "@bakers-build/core": "^0.8.1-next.3"
29
+ "@bakers-build/conductor": "^0.8.1-next.5",
30
+ "@bakers-build/core": "^0.8.1-next.5"
31
31
  },
32
32
  "bakersBuild": {
33
- "commit": "808f07a3ab9eb6ca6005894ba725623817e79c30",
33
+ "commit": "0a852637a4317a2ba18e831a2dcee4be2e67d060",
34
34
  "channel": "next"
35
35
  }
36
36
  }