Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

fix(worker): give a main-only Claude spawn the same permission posture as a GUI hire

Ed Chane84dc4ae5a94
diff --git a/package.json b/package.json
index 863bba80..58ddf586 100644
--- a/package.json
+++ b/package.json
@@ -19,7 +19,7 @@
"typecheck:node": "tsc --noEmit -p tsconfig.node.json",
"typecheck:web": "tsc --noEmit -p tsconfig.web.json",
"typecheck": "npm run typecheck:node && npm run typecheck:web",
- "test:focused": "node --test test/codex-remote.test.cjs test/control.test.cjs test/provider-automation.test.cjs test/provider-config.test.cjs test/queue-delivery.test.cjs test/terminal-automation.test.cjs test/terminal-recovery.test.cjs test/roster.test.cjs test/proc-kill.test.cjs test/expand-tilde.test.cjs test/hive-cwd.test.cjs test/hive-hook-node.test.cjs test/hive-roster-injection.test.cjs test/hive-runtime-path.test.cjs test/cli-install-ladder.test.cjs test/node-install.test.cjs test/office-gl-recovery.test.cjs test/update-state.test.cjs test/transcript-project-dir.test.cjs test/commit-graph.test.cjs test/task-ledger.test.cjs test/memory-rearm.test.cjs",
+ "test:focused": "node --test test/codex-remote.test.cjs test/control.test.cjs test/provider-automation.test.cjs test/provider-config.test.cjs test/queue-delivery.test.cjs test/terminal-automation.test.cjs test/terminal-recovery.test.cjs test/roster.test.cjs test/proc-kill.test.cjs test/expand-tilde.test.cjs test/hive-cwd.test.cjs test/hive-hook-node.test.cjs test/hive-roster-injection.test.cjs test/hive-runtime-path.test.cjs test/cli-install-ladder.test.cjs test/node-install.test.cjs test/office-gl-recovery.test.cjs test/update-state.test.cjs test/transcript-project-dir.test.cjs test/commit-graph.test.cjs test/task-ledger.test.cjs test/memory-rearm.test.cjs test/worker-permission-parity.test.cjs",
"check:links": "node tools/check-release-links.cjs",
"dist": "npm run build && electron-builder",
"dist:mac": "npm run build && electron-builder --mac",
diff --git a/src/main/index.ts b/src/main/index.ts
index 9dab0c22..6a9a16eb 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -62,6 +62,7 @@ import { fetchHireManifest, readHireManifestFile } from './hire';
import { parseHireDeepLink, type HireManifest } from '../shared/hire';
import { ClosingTimeController } from './closingTime';
import {
+ argsWithAutoModeFlag,
inferAgentProvider,
isClaudeProvider,
nonInteractiveEnvForProvider,
@@ -2538,7 +2539,20 @@ async function spawnAgentCore(opts: AgentSpawnOptions, owner: Electron.WebConten
// in the command string the renderer already built.
if (opts.hive && claudeProvider) {
const cfg = readConfig();
- const args = opts.args ?? [];
+ // Permission posture (D9): only a GUI hire (Add Agent) builds its command
+ // through buildSpawnCommand, which bakes autoMode's bypass flag into the
+ // command STRING before this function ever sees it. A main-only spawn (the
+ // ephemeral-worker watcher, a voice hire) skips that step entirely, so it
+ // previously reached here with neither the flag nor any equivalent — every
+ // other Claude spawn path got the user's autoMode posture and this one
+ // didn't. argsWithAutoModeFlag is idempotent (a GUI spawn's args already has
+ // the flag, so this is a no-op for it) and is the SAME check spawnAgentCore
+ // already applies for opencode/crush et al a few lines below via
+ // HIVE_AUTO_APPROVE — one global toggle, one posture, every spawn path.
+ // Confirmed live: a worker spawned without this flag deadlocked — a
+ // cross-session message to it came back "held for the recipient user's
+ // approval" with no surface for anyone to ever grant that approval.
+ const args = argsWithAutoModeFlag(opts.args ?? [], cfg.autoMode, provider);
// Model precedence: an explicit per-agent --model (from the renderer) wins;
// else the user's global defaultModel; else the role-based default tier. The
// GOD is special-cased: it has its own engine config (godProvider/godModel), so
diff --git a/src/shared/agentProvider.ts b/src/shared/agentProvider.ts
index aa41c58f..3dea19bd 100644
--- a/src/shared/agentProvider.ts
+++ b/src/shared/agentProvider.ts
@@ -567,6 +567,23 @@ export function autoModeFlagForProvider(provider: AgentProvider): string {
return providerPreset(provider).autoModeFlag ?? '';
}
+/** Idempotently append a provider's auto-mode flag to an args array, honoring the
+ * user's global autoMode toggle. The renderer's Add Agent flow bakes this same
+ * flag into the command STRING before a GUI hire ever reaches the shared spawn
+ * core (buildSpawnCommand → tokenizeCommand), so `args` for a GUI spawn already
+ * contains it by the time it gets here — this is a no-op for that path. A
+ * main-only spawn (an ephemeral worker, a voice hire) never passes through that
+ * renderer step, so without this it got neither the flag nor any equivalent,
+ * leaving it in an ask-first posture no one could ever answer. */
+export function argsWithAutoModeFlag(args: string[], autoMode: boolean, provider: AgentProvider): string[] {
+ if (!autoMode) return args;
+ const flag = autoModeFlagForProvider(provider);
+ if (!flag) return args;
+ const tokens = flag.trim().split(/\s+/);
+ if (args.includes(tokens[0])) return args;
+ return [...args, ...tokens];
+}
+
/** Returns any env vars the provider needs for non-interactive / first-run suppression. */
export function nonInteractiveEnvForProvider(provider: AgentProvider): Record<string, string> {
return providerPreset(provider).nonInteractiveEnv ?? {};
diff --git a/test/worker-permission-parity.test.cjs b/test/worker-permission-parity.test.cjs
new file mode 100644
index 00000000..3b599327
--- /dev/null
+++ b/test/worker-permission-parity.test.cjs
@@ -0,0 +1,68 @@
+'use strict';
+
+/**
+ * D9 — an ephemeral worker (startEphemeralWorkerWatcher) and a voice-hire spawn
+ * both call the shared spawnAgentCore directly, bypassing the renderer's Add
+ * Agent flow. Only that renderer flow (buildSpawnCommand) ever baked autoMode's
+ * bypass-permissions flag into a spawn — so both main-only paths reached Claude
+ * with no flag and no args-array equivalent, regardless of the user's global
+ * autoMode setting.
+ *
+ * Confirmed live: a worker spawned this way deadlocked — a cross-session message
+ * to it came back "held for the recipient user's approval" with no surface for
+ * anyone to ever grant that approval, since the worker also had no GUI card (D7).
+ *
+ * argsWithAutoModeFlag (src/shared/agentProvider.ts) is the fix: spawnAgentCore
+ * now applies it to EVERY Claude spawn's args, so a main-only spawn gets the same
+ * posture a GUI hire already had baked into its command string. It must be a
+ * no-op for the GUI path (whose args already carry the flag from
+ * buildSpawnCommand + tokenizeCommand) or agents would launch with the flag
+ * duplicated on the command line.
+ */
+
+const test = require('node:test');
+const assert = require('node:assert/strict');
+const loadTs = require('./load-ts.cjs');
+
+const { argsWithAutoModeFlag } = loadTs('src/shared/agentProvider.ts');
+
+test('a main-only spawn (ephemeral worker, voice hire) gets the bypass flag when autoMode is on', () => {
+ assert.deepEqual(
+ argsWithAutoModeFlag([], true, 'claude'),
+ ['--permission-mode', 'bypassPermissions']
+ );
+});
+
+test('autoMode off leaves a main-only spawn in the same ask-first posture as a GUI hire', () => {
+ assert.deepEqual(argsWithAutoModeFlag([], false, 'claude'), []);
+});
+
+test('a GUI hire\'s args (already tokenized from buildSpawnCommand) are left untouched, not duplicated', () => {
+ const guiArgs = ['--model', 'claude-sonnet-5', '--permission-mode', 'bypassPermissions'];
+ assert.deepEqual(argsWithAutoModeFlag(guiArgs, true, 'claude'), guiArgs);
+});
+
+test('other args on a main-only spawn are preserved alongside the appended flag', () => {
+ assert.deepEqual(
+ argsWithAutoModeFlag(['--model', 'claude-sonnet-5'], true, 'claude'),
+ ['--model', 'claude-sonnet-5', '--permission-mode', 'bypassPermissions']
+ );
+});
+
+test('the input array is never mutated in place', () => {
+ const input = ['--model', 'claude-sonnet-5'];
+ const result = argsWithAutoModeFlag(input, true, 'claude');
+ assert.deepEqual(input, ['--model', 'claude-sonnet-5']);
+ assert.notEqual(result, input);
+});
+
+test('a provider with no auto-mode flag (custom) is left alone', () => {
+ assert.deepEqual(argsWithAutoModeFlag(['--foo'], true, 'custom'), ['--foo']);
+});
+
+test('a single-token auto flag (codex) is applied the same way as Claude\'s two-token flag', () => {
+ assert.deepEqual(
+ argsWithAutoModeFlag(['--model', 'gpt-5.6-sol'], true, 'codex'),
+ ['--model', 'gpt-5.6-sol', '--dangerously-bypass-approvals-and-sandbox']
+ );
+});