Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

fix(swarm): run new agents with full permissions (#1532)

0xken159142773b0b34
diff --git a/backend/integration/superTabs.test.ts b/backend/integration/superTabs.test.ts
index 92d7fa945..2327ef5c6 100644
--- a/backend/integration/superTabs.test.ts
+++ b/backend/integration/superTabs.test.ts
@@ -363,7 +363,7 @@ describe('Super Tabs on a real Mongo replica set', () => {
projectDiskFreeBytes: 120e9, deviceType: 'Laptop', chip: 'Fixture CPU', os: 'macOS', gpuPercent: null }, quotas: [], tools: { git: true }, runningHarnessIds: [], stoppedHarnessIds: [] }
await expect(store.observeMachine(owner, tab, 'pool-host', observation)).rejects.toMatchObject({ code: 'CONTRIBUTION_REVOKED' })
await store.observeMachine(host, tab, 'pool-host', observation)
- const request = { conversationId: 'lead', machineId: 'pool-host', engine: 'codex', name: 'Builder', cwd: '/project', worktree: true,
+ const request = { permissionMode: 'full', conversationId: 'lead', machineId: 'pool-host', engine: 'codex', name: 'Builder', cwd: '/project', worktree: true,
requirements: { memoryBytes: 0, diskBytes: 0, maxCpuPercent: 100, tools: [], devices: [], quotaRequired: false } }
await expect(run(tab, { type: 'agent.start', request: { ...request, cwd: '/private' } })).rejects.toMatchObject({ code: 'OUTSIDE_CONTRIBUTION' })
await expect(run(tab, { type: 'agent.start', request: { ...request, permissionMode: 'bypassPermissions' } })).rejects.toMatchObject({ code: 'OUTSIDE_CONTRIBUTION' })
@@ -373,6 +373,7 @@ describe('Super Tabs on a real Mongo replica set', () => {
const startId = (starts.find(r => r.status === 'fulfilled') as PromiseFulfilledResult<Awaited<ReturnType<typeof run>>>).value.result.startId as string
const queued = await store.start(owner, tab, startId)
expect(queued.poolGeneration).toBe(generation)
+ expect(queued.request.permissionMode).toBe('full')
await expect(run(tab, { type: 'agent.startDispatch', startId })).rejects.toMatchObject({ code: 'HOST_REQUIRED' })
await expect(store.start(peer, tab, startId, undefined, 'pool-host')).rejects.toMatchObject({ code: 'FORBIDDEN' })
const hostRun = (command: Command) => store.execute(host, tab, { operationId: randomUUID(), command }, undefined, 'pool-host')
diff --git a/backend/src/superTabs/machines.test.ts b/backend/src/superTabs/machines.test.ts
index d6797fc1f..91facdca3 100644
--- a/backend/src/superTabs/machines.test.ts
+++ b/backend/src/superTabs/machines.test.ts
@@ -25,6 +25,19 @@ function refusal(state: SuperTabState, request: AgentStartRequest, start?: Agent
const refused = (error: SuperTabError) => error.message.split('Refused: ')[1] ?? ''
describe('a start on a contributed machine', () => {
+ it.each(['claude', 'codex'])('admits full permissions for %s, including dispatch rechecks', engine => {
+ const f = setup()
+ expect(refusal(f.state, f.request({ engine, permissionMode: 'full' }))).toBeNull()
+ expect(refusal(f.state, f.request({ engine, permissionMode: 'full' }), { poolGeneration: 'g1' } as AgentStart)).toBeNull()
+ })
+
+ it.each(['ask', 'auto', 'readOnly', 'bypass'])('refuses permission mode %s with an accurate explanation', permissionMode => {
+ const f = setup()
+ const error = refusal(f.state, f.request({ permissionMode }))!
+ expect(error).toMatchObject({ code: 'OUTSIDE_CONTRIBUTION' })
+ expect(error.message).toContain('permissionMode (only full is accepted; leave it out to use the machine’s default)')
+ })
+
it('is admitted inside the contribution: its project folder, one of its engines, no account settings', () => {
const f = setup()
expect(refusal(f.state, f.request())).toBeNull()
@@ -59,7 +72,7 @@ describe('a start on a contributed machine', () => {
expect(refusal(f.state, f.request())!.message).toContain('it contributes no engines')
})
- it.each(['codexHome', 'gridModel', 'gridName', 'permissionMode'] as const)('names %s as the refused account setting, and not its value', field => {
+ it.each(['codexHome', 'gridModel', 'gridName'] as const)('names %s as the refused account setting, and not its value', field => {
const f = setup()
const error = refusal(f.state, f.request({ [field]: '/Users/lead/.secret-profile' }))!
expect(error).toMatchObject({ code: 'OUTSIDE_CONTRIBUTION', status: 403 })
@@ -75,7 +88,7 @@ describe('a start on a contributed machine', () => {
const error = refusal(f.state, f.request({ cwd: '/elsewhere', engine: 'opencode', codexHome: '/h', permissionMode: 'bypass' }))!
expect(error.message).toContain('cwd (this project uses /data/swarm-projects/tab/lead on it)')
expect(error.message).toContain('engine (it contributes claude, codex)')
- expect(error.message).toContain('codexHome, permissionMode (it runs with its own default account settings, so leave them out)')
+ expect(error.message).toContain('codexHome (it runs with its own default account settings, so leave it out); permissionMode (only full is accepted')
})
it('says nothing of other projects or machines', () => {
diff --git a/backend/src/superTabs/machines.ts b/backend/src/superTabs/machines.ts
index 162376781..d0aac212b 100644
--- a/backend/src/superTabs/machines.ts
+++ b/backend/src/superTabs/machines.ts
@@ -76,10 +76,13 @@ export function admitMachineStart(state: SuperTabState, request: AgentStartReque
const refused: string[] = []
if (request.cwd !== cwd) refused.push(`cwd (this project uses ${cwd} on it)`)
if (!pool.engines.includes(request.engine)) refused.push(`engine (it contributes ${pool.engines.join(', ') || 'no engines'})`)
- const settings = (['codexHome', 'gridModel', 'gridName', 'permissionMode'] as const).filter(key => request[key])
+ const settings = (['codexHome', 'gridModel', 'gridName'] as const).filter(key => request[key])
if (settings.length) refused.push(`${settings.join(', ')} (it runs with its own default account settings, so leave ${settings.length > 1 ? 'them' : 'it'} out)`)
+ if (request.permissionMode !== undefined && request.permissionMode !== 'full') {
+ refused.push('permissionMode (only full is accepted; leave it out to use the machine’s default)')
+ }
if (refused.length) {
- fail('OUTSIDE_CONTRIBUTION', `${pool.name} accepts only its contributed project folder, engines and default account settings. Refused: ${refused.join('; ')}.`, 403)
+ fail('OUTSIDE_CONTRIBUTION', `${pool.name} accepts only its contributed project folder, engines and default account settings, with full permissions for Swarm agents. Refused: ${refused.join('; ')}.`, 403)
}
if (!pool.observation || now - pool.observation.receivedAt > 45_000) {
fail('MACHINE_OFFLINE', 'Wait for a fresh reading from the contributed machine.')
diff --git a/cli/src/superTabs/start.spec.ts b/cli/src/superTabs/start.spec.ts
index 4d1fd7b4e..749744a6b 100644
--- a/cli/src/superTabs/start.spec.ts
+++ b/cli/src/superTabs/start.spec.ts
@@ -1,5 +1,13 @@
import { describe, expect, it, vi } from 'vitest'
import { startAgent } from './start.js'
+import { mkdtempSync, rmSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+import { createLaunchRequests } from '../core/agents/launches.js'
+import { AgentCreationReceipts } from '../lib/agentCreationReceipt.js'
+import type { RegisteredSession } from '../lib/registry.js'
+import type { AgentFrame } from '../lib/agentFrame.js'
+import { buildEngineCommandArgv } from '../lib/engineLaunch.js'
const where = { port: 14001, machineId: 'lead-machine', dataDir: '/fixture' }
function fixture(options: { refuse?: string; loseCancel?: boolean; loseFailure?: boolean; launchModel?: string[]; refuseModel?: string; frame?: string; guest?: boolean } = {}) {
const start = { creationId: 'super-native-receipt', error: null as string | null, request: { machineId: 'target', conversationId: 'group', engine: 'claude', name: 'Builder', cwd: '/repo', worktree: true,
@@ -44,6 +52,148 @@ function fixture(options: { refuse?: string; loseCancel?: boolean; loseFailure?:
return { scoped, start, request, open, close, loseJoin: () => { lostJoin = true }, forget: () => { nativeState = 'missing' } }
}
const switchCall = (f: { request: { mock: { calls: unknown[][] } } }) => f.request.mock.calls.find(c => c[0] === 'agent_update')
+
+describe('Swarm permission mode', () => {
+ it.each(['claude', 'codex'] as const)('starts %s in full mode on direct and contributed hosts', async engine => {
+ for (const hostDispatch of [false, true]) {
+ const f = fixture()
+ Object.assign(f.start.request, { engine, permissionMode: 'ask' })
+ if (hostDispatch) Object.assign(f.start, { poolGeneration: 'pool' })
+ const result = await startAgent({ action: 'resume', tabId: 'tab', startId: 'start', hostDispatch }, f.scoped, where, f.open)
+ expect(result).toMatchObject({ ok: true })
+ const payload = f.request.mock.calls.find(c => c[0] === 'agent_create')![1]!
+ expect(payload.permissionMode).toBe('full')
+ const argv = buildEngineCommandArgv(engine, { permissionMode: String(payload.permissionMode) })
+ expect(argv).toContain(engine === 'claude' ? '--dangerously-skip-permissions' : '--dangerously-bypass-approvals-and-sandbox')
+ }
+ })
+
+ it.each(['opencode', 'hermes'])('keeps %s launchable through the real native permission validator', async engine => {
+ const f = fixture(), request = f.request.getMockImplementation()!
+ Object.assign(f.start.request, { engine, worktree: false })
+ const folder = mkdtempSync(join(tmpdir(), 'swarm-native-'))
+ const created: Array<Record<string, unknown>> = []
+ const native = createLaunchRequests({
+ receipts: new AgentCreationReceipts(folder),
+ createAgent: () => async input => {
+ created.push(input)
+ return { ok: true, session: { agentId: 'native', engine } as RegisteredSession }
+ },
+ forkAgent: () => null, resumeAgent: () => null, restartAgent: () => null,
+ byAgent: () => undefined, toProject: async () => ({ id: 'native', engine }) as AgentFrame,
+ modelTarget: async () => null,
+ })
+ f.request.mockImplementation(async (type, payload) => {
+ if (type === 'agent_create') {
+ let reply: Record<string, unknown> = {}
+ await native.create({ ...payload, creationId: undefined }, { local: true }, value => { reply = value })
+ if (reply.error) return reply
+ }
+ return request(type, payload)
+ })
+ try {
+ expect(await startAgent({ action: 'resume', tabId: 'tab', startId: 'start' }, f.scoped, where, f.open)).toMatchObject({ ok: true })
+ expect(created).toHaveLength(1)
+ expect(created[0]).toMatchObject({ permissionMode: null, bypassPermission: true })
+ } finally { native.stop(); rmSync(folder, { recursive: true, force: true }) }
+ })
+
+ it('recovers the same legacy start after its accepted reply is lost', async () => {
+ const f = fixture(), scoped = f.scoped.getMockImplementation()!
+ Object.assign(f.start, { poolGeneration: 'pool' })
+ let recorded: string | undefined, accepted = 0
+ f.scoped.mockImplementation(async payload => {
+ const command = payload.command as Record<string, any> | undefined
+ if (command?.type !== 'agent.start') return scoped(payload)
+ const hash = JSON.stringify(command)
+ if (recorded) return recorded === hash ? scoped(payload) : { error: 'OPERATION_REUSED', detail: 'Use a new operation ID for a different request.' }
+ if (command.request.permissionMode) return { error: 'OUTSIDE_CONTRIBUTION', detail: 'Refused: permissionMode (it runs with its own default account settings, so leave it out).' }
+ recorded = hash; accepted++
+ throw new Error('Accepted reply lost')
+ })
+ const input = { action: 'start', tabId: 'tab', operationId: 'same-op', request: f.start.request }
+ await expect(startAgent(input, f.scoped, where, f.open)).rejects.toThrow('Accepted reply lost')
+ expect(await startAgent(input, f.scoped, where, f.open)).toMatchObject({ ok: true, queued: true, startId: 'start' })
+ expect(accepted).toBe(1)
+ expect(f.open).not.toHaveBeenCalled()
+ })
+
+ it('asks the backend for full mode even when the caller asks for another mode', async () => {
+ const f = fixture()
+ await startAgent({ action: 'start', tabId: 'tab', operationId: 'op', request: { ...f.start.request, permissionMode: 'ask' } }, f.scoped, where, f.open)
+ const command = f.scoped.mock.calls[0]![0].command as Record<string, any>
+ expect(command.request.permissionMode).toBe('full')
+ })
+
+ it.each([false, true])('recovers an older CLI start without warning that the backend is old (settled=%s)', async settled => {
+ const f = fixture()
+ Object.assign(f.start, { poolGeneration: 'pool', ...(settled ? { harnessId: 'existing', poolSettled: true } : {}) })
+ f.scoped.mockResolvedValueOnce({ error: 'OPERATION_REUSED', detail: 'Use a new operation ID for a different request.' })
+ const result = await startAgent({ action: 'start', tabId: 'tab', operationId: 'same-op', request: f.start.request }, f.scoped, where, f.open)
+ expect(result).toMatchObject({ ok: true, ...(settled ? { harnessId: 'existing' } : { queued: true }) })
+ expect(result).not.toHaveProperty('permissionWarning')
+ const attempts = f.scoped.mock.calls.map(c => c[0]).filter(c => (c.command as any)?.type === 'agent.start')
+ expect(attempts).toHaveLength(2)
+ expect(attempts.map(a => a.operationId)).toEqual(['same-op', 'same-op'])
+ expect(f.open).not.toHaveBeenCalled()
+ })
+
+ it.each([false, true])('retries an older backend permission refusal once and warns (settled=%s)', async settled => {
+ const f = fixture(), scoped = f.scoped.getMockImplementation()!
+ Object.assign(f.start, { poolGeneration: 'pool', ...(settled ? { harnessId: 'existing', poolSettled: true } : {}) })
+ f.scoped.mockImplementation(async payload => {
+ const command = payload.command as Record<string, any> | undefined
+ if (command?.type === 'agent.start' && command.request.permissionMode) return {
+ error: 'OUTSIDE_CONTRIBUTION', detail: 'Studio Mac accepts only its contributed project folder, engines and default account settings. Refused: permissionMode (it runs with its own default account settings, so leave it out).',
+ }
+ return scoped(payload)
+ })
+ const result = await startAgent({ action: 'start', tabId: 'tab', operationId: 'same-op', request: f.start.request }, f.scoped, where, f.open)
+ expect(result).toMatchObject({ ok: true, ...(settled ? { harnessId: 'existing' } : { queued: true }), permissionWarning: expect.stringContaining("machine's default") })
+ const attempts = f.scoped.mock.calls.map(c => c[0]).filter(c => (c.command as any)?.type === 'agent.start')
+ expect(attempts).toHaveLength(2)
+ expect(attempts.map(a => a.operationId)).toEqual(['same-op', 'same-op'])
+ expect((attempts[0]!.command as any).request.permissionMode).toBe('full')
+ expect((attempts[1]!.command as any).request).not.toHaveProperty('permissionMode')
+ expect(f.open).not.toHaveBeenCalled()
+ })
+
+ it('does not retry an uncertain backend reply', async () => {
+ const f = fixture(); f.scoped.mockRejectedValue(new Error('Reply lost'))
+ await expect(startAgent({ action: 'start', tabId: 'tab', operationId: 'op', request: f.start.request }, f.scoped, where, f.open)).rejects.toThrow('Reply lost')
+ expect(f.scoped).toHaveBeenCalledOnce()
+ expect(f.open).not.toHaveBeenCalled()
+ })
+
+ it('ends after the single legacy retry fails', async () => {
+ const f = fixture()
+ f.scoped.mockResolvedValueOnce({ error: 'OUTSIDE_CONTRIBUTION', detail: 'Refused: permissionMode (it runs with its own default account settings, so leave it out).' })
+ .mockResolvedValueOnce({ error: 'MACHINE_OFFLINE', detail: 'Wait for the machine.' })
+ await expect(startAgent({ action: 'start', tabId: 'tab', operationId: 'op', request: f.start.request }, f.scoped, where, f.open)).rejects.toThrow('Wait for the machine.')
+ expect(f.scoped).toHaveBeenCalledTimes(2)
+ expect(f.open).not.toHaveBeenCalled()
+ })
+
+ it('reads an existing native receipt without updating its permission mode', async () => {
+ const f = fixture(), request = f.request.getMockImplementation()!
+ f.request.mockImplementation(async (type, payload) => type === 'agent_create_status'
+ ? { creationId: f.start.creationId, state: 'created', agent: { id: 'native', engine: 'claude', permissionMode: 'ask' } }
+ : request(type, payload))
+ expect(await startAgent({ action: 'resume', tabId: 'tab', startId: 'start' }, f.scoped, where, f.open)).toMatchObject({ ok: true })
+ expect(f.request.mock.calls.some(c => c[0] === 'agent_create' || c[0] === 'agent_update')).toBe(false)
+ })
+
+ it.each([
+ { error: 'OUTSIDE_CONTRIBUTION', detail: 'Refused: codexHome, permissionMode (leave them out).' },
+ { error: 'OUTSIDE_CONTRIBUTION', detail: 'Refused: cwd (wrong folder); permissionMode (leave it out).' },
+ { error: 'FORBIDDEN', detail: 'permissionMode is forbidden' },
+ ])('does not retry an unrelated refusal: $detail', async refusal => {
+ const f = fixture(); f.scoped.mockResolvedValue(refusal)
+ await expect(startAgent({ action: 'start', tabId: 'tab', operationId: 'op', request: f.start.request }, f.scoped, where, f.open)).rejects.toThrow(refusal.detail)
+ expect(f.scoped).toHaveBeenCalledOnce()
+ expect(f.open).not.toHaveBeenCalled()
+ })
+})
const expectSwitchTo = (f: Parameters<typeof switchCall>[0], selectedModel: string) => {
const call = switchCall(f)!
expect(call[1]).toEqual({ agentId: 'native', selectedModel })
diff --git a/cli/src/superTabs/start.ts b/cli/src/superTabs/start.ts
index f23bc0692..bc5c2ac92 100644
--- a/cli/src/superTabs/start.ts
+++ b/cli/src/superTabs/start.ts
@@ -4,6 +4,8 @@ import { randomUUID } from 'node:crypto'
import { openDaemon, type Daemon, type Where } from '../agentClient/daemon.js'
import { admission, quotaOf, type Requirements } from './capacity.js'
import { identifier, object } from './host.js'
+import { permissionModeFlags } from '../lib/engineLaunch.js'
+import type { AgentEngine } from '../engines/types.js'
type Json = Record<string, unknown>
export type ScopedRequest = (payload: Json) => Promise<Json>
@@ -58,12 +60,27 @@ const launchesWithModel = (capacity: Json, engine: unknown) => Array.isArray(cap
export async function startAgent(input: Json, scoped: ScopedRequest, where: Where, open: typeof openDaemon = openDaemon): Promise<Json> {
let startId = input.startId
let routed: unknown
+ let permissionWarning: string | undefined
if (input.action === 'start') {
// The routing decision belongs to the command, not to the machine-side request.
const { routeDecisionId, overrideReason, ...request } = object(input.request)
routed = routeDecisionId
- const result = requireSuccess(await scoped({ action: 'command', operationId: input.operationId,
- command: { type: 'agent.start', request, ...(routeDecisionId ? { routeDecisionId } : {}), ...(overrideReason ? { overrideReason } : {}) } }))
+ const submit = (request: Json) => scoped({ action: 'command', operationId: input.operationId,
+ command: { type: 'agent.start', request, ...(routeDecisionId ? { routeDecisionId } : {}), ...(overrideReason ? { overrideReason } : {}) } })
+ let reply = await submit({ ...request, permissionMode: 'full' })
+ // Older backends refused this field before recording a start. A recorded
+ // legacy retry may instead report a hash mismatch after its reply was lost:
+ // replay its exact payload with the same operation ID to recover that receipt.
+ // Other refusals and uncertain replies never authorize another intent.
+ if (reply.error === 'OPERATION_REUSED' || (reply.error === 'OUTSIDE_CONTRIBUTION' && typeof reply.detail === 'string' &&
+ reply.detail.endsWith('Refused: permissionMode (it runs with its own default account settings, so leave it out).'))) {
+ const { permissionMode: _mode, ...legacyRequest } = request
+ if (reply.error === 'OUTSIDE_CONTRIBUTION') {
+ permissionWarning = "This backend cannot request full permissions. Older machine hosts run the agent with the machine's default. Update Harness on the backend and machine."
+ }
+ reply = await submit(legacyRequest)
+ }
+ const result = requireSuccess(reply)
startId = object(result.result).startId
}
if (!identifier(startId)) throw new Error('The start has no durable receipt. Do not create an agent without it.')
@@ -72,10 +89,12 @@ export async function startAgent(input: Json, scoped: ScopedRequest, where: Wher
const request = object(start.request), creationId = start.creationId
if (!identifier(request.machineId) || !identifier(creationId)) throw new Error('This start receipt is invalid.')
if (start.error) return { error: 'START_FAILED', startId, detail: start.error }
- if (start.harnessId && (!start.poolGeneration || start.poolSettled)) return { ok: true, startId, machineId: request.machineId, harnessId: start.harnessId }
+ if (start.harnessId && (!start.poolGeneration || start.poolSettled)) return { ok: true, startId, machineId: request.machineId, harnessId: start.harnessId,
+ ...(permissionWarning ? { permissionWarning } : {}) }
// Contributed capacity is executed by its owner. A collaborator receives no
// machine credentials and cannot issue arbitrary commands to that computer.
if (start.poolGeneration && input.hostDispatch !== true) return { ok: true, queued: true, startId, machineId: request.machineId,
+ ...(permissionWarning ? { permissionWarning } : {}),
detail: 'Queued on the contributed machine. Resume this start ID to read its receipt.' }
const target = await open(where, request.machineId)
/** What the agent runs now, as its frame says; null when the frame cannot say. */
@@ -119,13 +138,17 @@ export async function startAgent(input: Json, scoped: ScopedRequest, where: Wher
// native dispatch, even if retrying the backend operation returns a receipt.
requireSuccess(await scoped({ action: 'command', operationId: `dispatch-${randomUUID()}`,
command: { type: 'agent.startDispatch', startId } }))
- const payload: Json = { engine: request.engine, name: request.name, creationId, startedBy: 'agent',
+ // Both direct and contributed-host starts reach this boundary. Existing
+ // native receipts are read above and never have their permissions changed.
+ // Engines without a full mode retain their existing approving launch flags.
+ const payload: Json = { engine: request.engine, name: request.name, creationId, startedBy: 'agent', bypassPermission: true,
+ ...(permissionModeFlags(request.engine as AgentEngine, 'full') ? { permissionMode: 'full' } : {}),
prompt: `You are joining a shared Super Tab. Run harness super-tab --tab ${input.tabId} status until this harness appears in the roster. Do not begin project work yet. Your lead will assign work in conversation ${request.conversationId}. Reply in that conversation using harness super-tab --tab ${input.tabId} post ${request.conversationId} 'your message' UNIQUE_OPERATION_ID. Run harness super-tab help for commands. If sandbox restrictions block this local command, request permission to run it outside the sandbox.`,
...(request.worktree ? { projectSource: 'worktree', gitSource: request.cwd, branchName: `super-tab/${startId}`,
// No branch named: the repository's default branch, fetched, not the host checkout's old HEAD.
...(request.branchRef ? { branchRef: request.branchRef } : { branchBase: 'default' }) } : { cwd: request.cwd }),
}
- for (const key of ['permissionMode', 'codexHome', 'gridModel', 'gridName']) if (request[key] !== undefined) payload[key] = request[key]
+ for (const key of ['codexHome', 'gridModel', 'gridName']) if (request[key] !== undefined) payload[key] = request[key]
// The routed model goes on the command line of this session alone. Typing /model into the pane afterwards saves
// it as the person's default in their own Claude settings (manual run 2, 2026-10-19).
launched = canLaunch && launchesWithModel(resources.capacity, request.engine)
@@ -237,6 +260,7 @@ export async function startAgent(input: Json, scoped: ScopedRequest, where: Wher
}
}
}
- return { ok: true, startId, machineId: request.machineId, harnessId: nativeId, ...object(joined.result), ...(modelWarning ? { modelWarning } : {}) }
+ return { ok: true, startId, machineId: request.machineId, harnessId: nativeId, ...object(joined.result),
+ ...(permissionWarning ? { permissionWarning } : {}), ...(modelWarning ? { modelWarning } : {}) }
} finally { target.close() }
}
diff --git a/desktop/lib/state/harness_launch_integration.dart b/desktop/lib/state/harness_launch_integration.dart
index 3a6e24cd0..a03dd00c5 100644
--- a/desktop/lib/state/harness_launch_integration.dart
+++ b/desktop/lib/state/harness_launch_integration.dart
@@ -18,12 +18,15 @@ class HarnessLaunchIntegration {
this.projectVisibilityLocked = false,
this.initialTask,
this.engines,
+ this.forcedPermissionMode,
});
final String creationId, actionLabel;
// Restores the person's original request from a destination launch journal.
final String? initialTask;
// The only agents this destination may start, or null for any.
final List<String>? engines;
+ // A destination can require a mode without changing ordinary launch preferences.
+ final String? forcedPermissionMode;
String? projectVisibility;
bool projectVisibilityLocked;
final Future<String> Function(String machineId, String task) prepare;
diff --git a/desktop/lib/state/new_harness.dart b/desktop/lib/state/new_harness.dart
index 33eda7576..a691d2019 100644
--- a/desktop/lib/state/new_harness.dart
+++ b/desktop/lib/state/new_harness.dart
@@ -1397,8 +1397,10 @@ class NewHarnessController extends ChangeNotifier {
String get _settingsEngine => _agentPreview ?? _engine;
LocalCodexProfile? get _settingsProfile =>
_settingsEngine == _engine ? _profile : null;
- List<PermissionMode> get _settingsModes =>
- permissionModesOf(_baseOf(_settingsEngine));
+ String? get _forcedPermissionMode => integration?.forcedPermissionMode;
+ List<PermissionMode> get _settingsModes => _forcedPermissionMode != null
+ ? const []
+ : permissionModesOf(_baseOf(_settingsEngine));
String get _settingsMode =>
_settingsModes.any((mode) => mode.id == _permissionFor(_settingsEngine))
? _permissionFor(_settingsEngine)
@@ -1406,7 +1408,9 @@ class NewHarnessController extends ChangeNotifier {
bool get takesTask => isCloud || takesFirstTask(_base);
bool get taskTooLong => task.trim().length > kFirstTaskMaxLength;
List<PermissionMode> get _modes =>
- _noAgentSetup || isCloud ? const [] : permissionModesOf(_base);
+ _noAgentSetup || isCloud || _forcedPermissionMode != null
+ ? const []
+ : permissionModesOf(_base);
bool get hasModes => _modes.isNotEmpty;
String get mode =>
_modes.any((mode) => mode.id == _mode) ? _mode : kDefaultPermissionMode;
@@ -1425,7 +1429,9 @@ class NewHarnessController extends ChangeNotifier {
/// Settings are offered separately so browsing never inserts list rows.
List<NewHarnessOption> agentSettingsFor(String engine) {
- final modes = permissionModesOf(_baseOf(engine));
+ final modes = _forcedPermissionMode != null
+ ? const <PermissionMode>[]
+ : permissionModesOf(_baseOf(engine));
final mode =
modes.where((mode) => mode.id == _permissionFor(engine)).firstOrNull ??
modes.where((mode) => mode.id == kDefaultPermissionMode).firstOrNull;
@@ -3999,9 +4005,17 @@ class NewHarnessController extends ChangeNotifier {
);
}
}
- final permissionMode = hasModes ? mode : null;
+ final forcedMode = _forcedPermissionMode;
+ // Only Claude Code and Codex name a full mode. Other engines use their
+ // existing approving launch flags through bypassPermission.
+ final permissionMode = forcedMode == null
+ ? (hasModes ? mode : null)
+ : permissionModesOf(base).any((mode) => mode.id == forcedMode)
+ ? forcedMode
+ : null;
final bypass =
- permissionMode != null && permissionModeApproves(permissionMode);
+ forcedMode != null ||
+ (permissionMode != null && permissionModeApproves(permissionMode));
final folder = _project.folder;
final firstMessage = task.trim();
String launchMessage = firstMessage;
@@ -4033,7 +4047,10 @@ class NewHarnessController extends ChangeNotifier {
final launchSetup = LaunchSetup(
engine: base,
harnessId: harness,
- permissionMode: permissionMode ?? kDefaultPermissionMode,
+ // A Swarm's required mode is not the person's next ordinary launch choice.
+ permissionMode: _forcedPermissionMode != null
+ ? _permissionFor(base)
+ : permissionMode ?? kDefaultPermissionMode,
model: model,
profile: base == 'codex' && model == null && !asGuest ? _profile : null,
profileMachineId: _machineId,
diff --git a/desktop/lib/super_tabs/launch.dart b/desktop/lib/super_tabs/launch.dart
index 16c690129..d4cb5bbb7 100644
--- a/desktop/lib/super_tabs/launch.dart
+++ b/desktop/lib/super_tabs/launch.dart
@@ -57,6 +57,7 @@ class SuperTabLaunch {
saved['phase'] == 'starting' || saved['phase'] == 'joining';
late final HarnessLaunchIntegration integration;
integration = HarnessLaunchIntegration(
+ forcedPermissionMode: 'full',
creationId: saved['creationId'] as String? ?? superTabOperationId(),
initialTask: saved['initialMessage'] as String?,
actionLabel: saved['newProject'] == true
diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dart
index e0d6ad8d5..e43d16b1e 100644
--- a/desktop/lib/super_tabs/machines.dart
+++ b/desktop/lib/super_tabs/machines.dart
@@ -520,8 +520,14 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
Text(
'Let the product manager run agents here using this machine’s signed-in accounts.',
style: DesktopChrome.text(),
- )
- else ...[
+ ),
+ if (own.isNotEmpty) ...[
+ const SizedBox(height: 4),
+ Text(
+ 'Agents the Swarm starts on this machine run without asking for permission.',
+ style: DesktopChrome.text(),
+ ),
+ ] else ...[
Text(
'To add another computer, install Harness on it and sign in with '
'this account, or approve a device with no screen from Machines.',
diff --git a/desktop/test/super_tab_launch_test.dart b/desktop/test/super_tab_launch_test.dart
index 5267459d5..c7fa59aed 100644
--- a/desktop/test/super_tab_launch_test.dart
+++ b/desktop/test/super_tab_launch_test.dart
@@ -5,6 +5,7 @@ import 'dart:typed_data';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/core/first_task.dart';
import 'package:harness/core/models.dart';
+import 'package:harness/core/launch_setup.dart';
import 'package:harness/state/app_state.dart';
import 'package:harness/state/new_harness.dart';
import 'package:harness/state/harness_attachments.dart';
@@ -35,6 +36,7 @@ class SuperTabFixtureConnection extends WsConn {
final MemoryStore store;
final server = ConversationServer();
final calls = <(String, Map<String, dynamic>)>[];
+ final extraEngines = <String>[];
final joins = <Map<String, dynamic>>[];
bool loseCreate = false, loseJoin = false;
bool failNative = false;
@@ -307,6 +309,8 @@ class SuperTabFixtureConnection extends WsConn {
'engines': [
{'engine': 'codex', 'installed': true, 'supportsCodexHome': true},
{'engine': 'claude', 'installed': true},
+ for (final engine in extraEngines)
+ {'engine': engine, 'installed': true},
],
},
'codex_profiles_list' => {'profiles': <dynamic>[]},
@@ -377,6 +381,86 @@ class SuperTabLaunchFixture {
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
+ test(
+ 'Swarm members with no full mode retain their supported launch behavior',
+ () async {
+ for (final engine in ['opencode', 'hermes']) {
+ final f = SuperTabLaunchFixture();
+ f.connection.extraEngines.add(engine);
+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Company');
+ final box = await f.box(engine: engine);
+ expect(
+ await box.create(),
+ NewHarnessOutcome.created,
+ reason: box.error,
+ );
+ final request = f.connection.calls
+ .firstWhere((c) => c.$1 == 'agent_create')
+ .$2;
+ expect(request['permissionMode'], isNull);
+ expect(request['bypassPermission'], isTrue);
+ expect(
+ box.agentSettingsFor(engine).map((o) => o.id),
+ isNot(contains(NewHarnessController.permissionsId)),
+ );
+ }
+ },
+ );
+
+ for (final engine in ['claude', 'codex']) {
+ for (final kind in ['new Swarm', 'new project', 'member']) {
+ test(
+ '$kind launches $engine in full mode without permission choices',
+ () async {
+ final f = SuperTabLaunchFixture();
+ await f.app.agentPreference.selectPermissionMode(engine, 'ask');
+ await f.app.agentPreference.remember(
+ engine,
+ setup: LaunchSetup(engine: engine, permissionMode: 'ask'),
+ );
+ if (kind != 'new Swarm') {
+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Company');
+ }
+ final box = await f.box(
+ engine: engine,
+ newProject: kind == 'new project',
+ );
+ expect(
+ box.agentSettingsFor(engine).map((o) => o.id),
+ isNot(contains(NewHarnessController.permissionsId)),
+ );
+ box.advancedOpen = true;
+ expect(box.fields, isNot(contains(NewHarnessField.mode)));
+ box.openLaunchSetting(NewHarnessField.mode);
+ expect(box.field, isNot(NewHarnessField.mode));
+ expect(
+ await box.create(),
+ NewHarnessOutcome.created,
+ reason: box.error,
+ );
+ final request = f.connection.calls
+ .firstWhere((c) => c.$1 == 'agent_create')
+ .$2;
+ expect(request['permissionMode'], 'full');
+ await Future<void>.delayed(Duration.zero);
+ final ordinary = NewHarnessController(
+ f.app,
+ machineId: 'm',
+ engine: engine,
+ folder: '/work/project',
+ );
+ addTearDown(ordinary.dispose);
+ await Future<void>.delayed(Duration.zero);
+ expect(
+ ordinary.agentSettingsFor(engine).map((o) => o.id),
+ contains(NewHarnessController.permissionsId),
+ );
+ expect(ordinary.mode, 'ask');
+ },
+ );
+ }
+ }
+
test(
'guest machine access cannot create a Swarm lead under the owner account',
() async {
diff --git a/desktop/test/super_tab_machines_test.dart b/desktop/test/super_tab_machines_test.dart
index c7ff7989f..1dda770d5 100644
--- a/desktop/test/super_tab_machines_test.dart
+++ b/desktop/test/super_tab_machines_test.dart
@@ -542,6 +542,12 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.byTooltip('Add machine'));
await tester.pumpAndSettle();
+ expect(
+ find.text(
+ 'Agents the Swarm starts on this machine run without asking for permission.',
+ ),
+ findsOneWidget,
+ );
expect(_picker, findsOneWidget);
expect(
find.text('This Mac (${f.app.stateOf('m')!.machine.displayName})'),
diff --git a/docs/plans/2026-10-22-swarm-full-permission-mode.md b/docs/plans/2026-10-22-swarm-full-permission-mode.md
new file mode 100644
index 000000000..6847fb4d5
--- /dev/null
+++ b/docs/plans/2026-10-22-swarm-full-permission-mode.md
@@ -0,0 +1,107 @@
+# Swarm agents always run in full permission mode
+
+## Approved brief
+
+Every new Lead and every agent a Swarm starts uses Harness's existing `full`
+permission mode, including agents on contributed machines. Adding a machine is
+the owner's consent, disclosed in that dialog. Only new launches change: running
+agents retain their mode, and ordinary launches retain the person's choice.
+There is no per-Swarm or per-machine switch. New Swarm and + Project Lead forms,
+and forms that add an agent to a Swarm, hide the permission choice.
+
+CLI starts must set full mode at the shared native creation boundary used by
+both direct starts and contributed-machine host dispatch. Backend admission must
+accept `permissionMode: full` while continuing to reject other permission values
+and `codexHome`, `gridModel`, and `gridName` on contributed machines. When an older
+backend specifically refuses the permission field, retry once without it and
+report that the machine's default applies. Other failures must not retry.
+
+Desktop passes the forced mode through `HarnessLaunchIntegration`. Add machine
+explains: “Agents the Swarm starts on this machine run without asking for
+permission.” Keep this separate from the clone-trust group's copy.
+
+## Ownership and constraints
+
+- CLI: `src/superTabs/start.ts`, shared with the host-side start path, and tests.
+- Backend: `src/superTabs/machines.ts` admission and tests.
+- Desktop: `lib/super_tabs/launch.dart`,
+ `lib/state/harness_launch_integration.dart`, `lib/state/new_harness.dart`,
+ one sentence in `lib/super_tabs/machines.dart`, and affected tests.
+- No new dependencies, settings, changes to running agents, or unrelated cleanup.
+- Tests use disposable fixtures and never the live daemon, port 18473, real tmux,
+ or the person's Harness/Claude/Codex data.
+- Start from current main, rebase before delivery, push and open a draft PR only.
+ Do not mark ready, merge, or release.
+
+## Phase 1: CLI and backend
+
+1. Add failing start tests for direct and host-dispatched Claude/Codex launches,
+ overriding a requested mode, resume without recreation, and old-backend retry.
+2. Set the mode at the shared native creation boundary. Send full in new backend
+ start intents; on a specific pre-dispatch permission refusal retry the same
+ operation once without that field, retaining its durable creation identity.
+3. Add failing backend admission tests for full and each refused setting; allow
+ full and keep accurate, non-sensitive refusal text.
+4. Verify CLI start/host suites and launch argv specs, plus backend unit tests.
+
+## Phase 2: Desktop
+
+1. Add failing tests for New Swarm, + Project, and member launches: full is sent,
+ saved preferences cannot override it, and permission controls are absent.
+ Keep ordinary-launch preference coverage.
+2. Add an optional forced permission mode to the launch integration. Apply it to
+ launch payloads and hide both advanced and agent-picker permission choices.
+3. Add the Add machine consent sentence and a widget assertion.
+4. Verify affected launch/controller/widget tests and analyze changed Dart files.
+
+## Phase 3: Validation and draft delivery
+
+- Node 24, CLI: typecheck, all Super Tab unit specs, `test:super-tabs` (100%
+ per-file routing coverage), Claude/Codex launch argv golden specs.
+- Backend: `tsc --noEmit`, `vitest run src/superTabs`, `test:super-tabs`
+ (disposable MongoDB integration fixtures).
+- Desktop: analyze changed Dart files and run affected launch, settings,
+ recovery, and machine dialog tests on macOS.
+- Inspect the full diff, rebase on current main, repeat only checks invalidated
+ by integration changes, then push a branch and open a draft PR with exact
+ results and any unverified acceptance rows. Report head SHA and PR link.
+
+## Review focus
+
+Compatibility retries must be limited to explicit permission-field rejection;
+timeouts and mixed account-setting refusals cannot create a second intent.
+Resuming an existing receipt must never update an agent's permission mode.
+Hidden controls must include the previewed agent's settings, not just advanced
+fields. Engines without native permission modes must retain their launch support.
+Recovery of an already submitted Desktop launch must only read its receipt.
+
+## Implementation decisions and review
+
+- Claude Code and Codex declare `full`. Other engines retain their existing
+ approving flags through `bypassPermission`, with no unsupported mode sent;
+ otherwise native validation would reject OpenCode/Hermes and other members.
+ Their permission controls are hidden in Swarm forms as well.
+- A repeated start after a legacy fallback may encounter an existing operation
+ with the legacy request hash. Retry that same operation with the exact legacy
+ payload to recover its receipt. Never allocate a second operation or start.
+- Independent review identified both cases above. Regression tests reproduced
+ them before the fixes, including the real native launch validator and an
+ accepted legacy request whose response is lost.
+- The initial raw backend unit invocation lacked its fixture encryption key.
+ Running the repository's `npm test -- src/superTabs --maxWorkers=2` supplies
+ that fixture key; all 110 tests pass. No production configuration was used.
+
+## Validation evidence
+
+On macOS with Node 24.3.0, Flutter 3.47.5 and Dart 3.13.4:
+
+- CLI typecheck passed; Super Tab specs plus launch argv golden specs passed
+ 339 tests in 21 files. Routing gate passed 111 tests with 100% statements,
+ branches, functions and lines in each gated file.
+- Backend typecheck passed; Super Tab units passed 111 tests in eight files after rebasing current main.
+ The disposable MongoDB integration suite passed 60 tests in two files. The
+ added persisted-full-mode contribution case also passed its targeted rerun.
+- Desktop analysis found no issues. All seven affected launch, dialog, settings,
+ entry and recovery test files passed together: 149 tests.
+- Review fixes were each reproduced before implementation and verified after.
+ No real agent session, personal engine data or live daemon was used for tests.