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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
CLI: Team-written work starts on the owner's own computer with project settings off (#4307) (#3485)
0xken15a89280b2c9c8
diff --git a/cli/src/core/agents/create.spec.ts b/cli/src/core/agents/create.spec.tsindex 476505ba3..b7d379f17 100644--- a/cli/src/core/agents/create.spec.ts+++ b/cli/src/core/agents/create.spec.ts@@ -242,7 +242,8 @@ describe('creating an agent', () => {mkdirSync(config); writeFileSync(settings, '{"theme":"dark"}\n')const launch = { current: () => true, environment: { HOME: home, CLAUDE_CONFIG_DIR: config }, prepareHooks: async () => true } as unknown as NativeLaunchtry {- for (const over of [{}, { permissionMode: 'full', bypassPermission: true }]) {+ // Team-written work too: it runs in its owner's own mode and skips nothing (review of #3485).+ for (const over of [{}, { permissionMode: 'full', bypassPermission: true }, { permissionMode: 'teamWritten', bypassPermission: false }]) {for (const swarmRole of ['coordinator', 'agent']) {expect(await setup({ native: async () => ({ ok: true, launch }) }).create(request({ swarmRole, ...over }))).toMatchObject({ ok: true })}diff --git a/cli/src/engines/__fixtures__/launch-argv.golden.json b/cli/src/engines/__fixtures__/launch-argv.golden.jsonindex 8a7d2bd0f..a45428553 100644--- a/cli/src/engines/__fixtures__/launch-argv.golden.json+++ b/cli/src/engines/__fixtures__/launch-argv.golden.json@@ -732,7 +732,7 @@"claude · new, mode plan · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","--permission-mode","plan"],"script":"7b9a7551f122ab5c","command":3},"claude · new, mode ask · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","--permission-mode","default"],"script":"7b9a7551f122ab5c","command":3},"claude · new, mode full · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","--dangerously-skip-permissions"],"script":"7b9a7551f122ab5c","command":2},- "claude · new, mode teamWritten · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","--dangerously-skip-permissions","--setting-sources","user","--strict-mcp-config"],"script":"7b9a7551f122ab5c","command":5},+ "claude · new, mode teamWritten · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","--setting-sources","user","--strict-mcp-config"],"script":"7b9a7551f122ab5c","command":4},"claude · first prompt · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","Fix the \"parser\" — it's broken; $HOME stays literal, as does `date` and a 'quote' ✓"],"script":"7b9a7551f122ab5c","command":2},"claude · resume · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","--resume","sess-0001"],"script":"7b9a7551f122ab5c","command":3},"claude · resume, approving · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","--permission-mode","auto","--resume","sess-0001"],"script":"7b9a7551f122ab5c","command":5},@@ -760,7 +760,7 @@"codex · new, mode readOnly · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","--sandbox","read-only","-c","tui.fullscreen_transcript=false"],"script":"533ec1354e8b74a3","command":5},"codex · new, mode ask · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","-c","tui.fullscreen_transcript=false"],"script":"533ec1354e8b74a3","command":3},"codex · new, mode full · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","--dangerously-bypass-approvals-and-sandbox","-c","tui.fullscreen_transcript=false"],"script":"533ec1354e8b74a3","command":4},- "codex · new, mode teamWritten · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","--dangerously-bypass-approvals-and-sandbox","-c","tui.fullscreen_transcript=false"],"script":"533ec1354e8b74a3","command":4},+ "codex · new, mode teamWritten · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","-c","tui.fullscreen_transcript=false"],"script":"533ec1354e8b74a3","command":3},"codex · first prompt · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","-c","tui.fullscreen_transcript=false","Fix the \"parser\" — it's broken; $HOME stays literal, as does `date` and a 'quote' ✓"],"script":"533ec1354e8b74a3","command":4},"codex · resume · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","resume","sess-0001","-c","tui.fullscreen_transcript=false"],"script":"533ec1354e8b74a3","command":5},"codex · resume, approving · zsh · tmux": {"argv":["/usr/bin/env","DISABLE_AUTO_UPDATE=true","/bin/zsh","-lic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","resume","sess-0001","--approve-for-me","-c","tui.fullscreen_transcript=false"],"script":"533ec1354e8b74a3","command":6},@@ -965,7 +965,7 @@"claude · new, mode plan · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","--permission-mode","plan"],"script":"6d299a48b039bf1e","command":3},"claude · new, mode ask · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","--permission-mode","default"],"script":"6d299a48b039bf1e","command":3},"claude · new, mode full · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","--dangerously-skip-permissions"],"script":"6d299a48b039bf1e","command":2},- "claude · new, mode teamWritten · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","--dangerously-skip-permissions","--setting-sources","user","--strict-mcp-config"],"script":"6d299a48b039bf1e","command":5},+ "claude · new, mode teamWritten · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","--setting-sources","user","--strict-mcp-config"],"script":"6d299a48b039bf1e","command":4},"claude · first prompt · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","Fix the \"parser\" — it's broken; $HOME stays literal, as does `date` and a 'quote' ✓"],"script":"6d299a48b039bf1e","command":2},"claude · resume · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","--resume","sess-0001"],"script":"6d299a48b039bf1e","command":3},"claude · resume, approving · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","claude","--permission-mode","auto","--resume","sess-0001"],"script":"6d299a48b039bf1e","command":5},@@ -1072,7 +1072,7 @@"codex · new, mode readOnly · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","--sandbox","read-only","-c","tui.fullscreen_transcript=false"],"script":"585ef6d2032354bb","command":5},"codex · new, mode ask · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","-c","tui.fullscreen_transcript=false"],"script":"585ef6d2032354bb","command":3},"codex · new, mode full · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","--dangerously-bypass-approvals-and-sandbox","-c","tui.fullscreen_transcript=false"],"script":"585ef6d2032354bb","command":4},- "codex · new, mode teamWritten · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","--dangerously-bypass-approvals-and-sandbox","-c","tui.fullscreen_transcript=false"],"script":"585ef6d2032354bb","command":4},+ "codex · new, mode teamWritten · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","-c","tui.fullscreen_transcript=false"],"script":"585ef6d2032354bb","command":3},"codex · first prompt · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","-c","tui.fullscreen_transcript=false","Fix the \"parser\" — it's broken; $HOME stays literal, as does `date` and a 'quote' ✓"],"script":"585ef6d2032354bb","command":4},"codex · resume · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","resume","sess-0001","-c","tui.fullscreen_transcript=false"],"script":"585ef6d2032354bb","command":5},"codex · resume, approving · bash · no tmux": {"argv":["/bin/bash","-ic",". '<data>/launch/<one-time>.sh'","harness-engine","codex","resume","sess-0001","--approve-for-me","-c","tui.fullscreen_transcript=false"],"script":"585ef6d2032354bb","command":6},diff --git a/cli/src/engines/claude/launch.ts b/cli/src/engines/claude/launch.tsindex e03bf5297..7c2efb427 100644--- a/cli/src/engines/claude/launch.ts+++ b/cli/src/engines/claude/launch.ts@@ -10,12 +10,14 @@ const permissionModes = {plan: ['--permission-mode', 'plan'],ask: ['--permission-mode', 'default'],full: ['--dangerously-skip-permissions'],- // Code a Harness Team agent wrote, in a Team account (backend superTabs/teamWritten.ts, audit H2): full mode, and nothing the- // branch carries. `user` and not `local`: a branch can commit `.claude/settings.local.json`. Harness's hooks are in the user+ // Code a Harness Team agent wrote (backend superTabs/teamWritten.ts, audit H2): nothing the branch carries. Since v3 it runs as+ // the project owner on their own computer, not in a Team account's own OS user, so it skips no permission check: the+ // owner's own mode from their user settings (review of #3485). `user` and not `local`: a branch can commit+ // `.claude/settings.local.json`. Harness's hooks are in the user// settings. Claude Code 2.1.316, tried: planted settings.json, settings.local.json and .mcp.json each ran in a trusted// folder without these flags, and none with them. With no trust record the session stops at the trust question, so the record// stays and the flags are the barrier; a Yes on the main repository answers for its worktrees anyway.- teamWritten: ['--dangerously-skip-permissions', '--setting-sources', 'user', '--strict-mcp-config'],+ teamWritten: ['--setting-sources', 'user', '--strict-mcp-config'],}export const launch: EngineLaunch = {permissionModes, bypassPermission: permissionModes.auto,diff --git a/cli/src/engines/codex/launch.ts b/cli/src/engines/codex/launch.tsindex 802aac4f3..b675a3234 100644--- a/cli/src/engines/codex/launch.ts+++ b/cli/src/engines/codex/launch.ts@@ -5,10 +5,11 @@ const permissionModes = {readOnly: ['--sandbox', 'read-only'],ask: [],full: ['--dangerously-bypass-approvals-and-sandbox'],- // Code a Harness Team agent wrote, in a Team account (backend superTabs/teamWritten.ts, audit H2). Codex has no flag for it: a- // worktree takes its main repository's trust, and `-c projects...` does not turn it off (0.165.0, tried). The start gives- // this mode an engine home of its own, which trusts no project (superTabs/start.ts).- teamWritten: ['--dangerously-bypass-approvals-and-sandbox'],+ // Code a Harness Team agent wrote (backend superTabs/teamWritten.ts, audit H2). Codex has no flag for it: a worktree takes its+ // main repository's trust, and `-c projects...` does not turn it off (0.165.0, tried). The start gives this mode an engine+ // home of its own, which trusts no project (superTabs/start.ts). Since v3 it runs as the project owner on their own computer,+ // so with Codex's own approvals and sandbox, never bypassed (review of #3485).+ teamWritten: [],}/**diff --git a/cli/src/lib/engineLaunch.spec.ts b/cli/src/lib/engineLaunch.spec.tsindex d6eb264d7..359009297 100644--- a/cli/src/lib/engineLaunch.spec.ts+++ b/cli/src/lib/engineLaunch.spec.ts@@ -824,9 +824,12 @@ printf '%s %s' "$harness_status" "$resumed"`], { encoding: 'utf8', stdio: ['igno.toEqual([engineBin('claude'), '--dangerously-skip-permissions'])expect(buildEngineCommandArgv('codex', { permissionMode: 'readOnly' })).toEqual([engineBin('codex'), '--sandbox', 'read-only', ...CODEX_SCREEN])- // Team-written work reads none of the branch's own settings, `settings.local.json` included (audit H2).+ // Team-written work reads none of the branch's own settings, `settings.local.json` included (audit H2), and since v3 runs+ // as its owner on their own computer, so it skips no permission check and no sandbox (review of #3485).expect(buildEngineCommandArgv('claude', { permissionMode: 'teamWritten', bypassPermission: true }))- .toEqual([engineBin('claude'), '--dangerously-skip-permissions', '--setting-sources', 'user', '--strict-mcp-config'])+ .toEqual([engineBin('claude'), '--setting-sources', 'user', '--strict-mcp-config'])+ expect(buildEngineCommandArgv('codex', { permissionMode: 'teamWritten', bypassPermission: true }))+ .toEqual([engineBin('codex'), ...CODEX_SCREEN])// An older Buddy's saved mode is no mode: the registry clears it on load (task #4215).expect(permissionModeFlags('claude', 'buddy')).toBeNull()expect(permissionModeFlags('codex', 'readOnlyAsk')).toBeNull()diff --git a/cli/src/lib/engineLaunch.ts b/cli/src/lib/engineLaunch.tsindex 3b9db0ea0..63540408d 100644--- a/cli/src/lib/engineLaunch.ts+++ b/cli/src/lib/engineLaunch.ts@@ -88,7 +88,7 @@ export function permissionModeFlags(engine: AgentEngine, mode: string): readonly/** Whether [mode] lets the agent act without stopping to ask — what `bypassPermission` records. */export function permissionModeApproves(mode: string): boolean {- return mode === 'auto' || mode === 'full' || mode === 'teamWritten'+ return mode === 'auto' || mode === 'full'}/**diff --git a/cli/src/lib/engineShellStartup.spec.ts b/cli/src/lib/engineShellStartup.spec.tsindex d2d19c90a..bbd39400f 100644--- a/cli/src/lib/engineShellStartup.spec.ts+++ b/cli/src/lib/engineShellStartup.spec.ts@@ -38,7 +38,8 @@ export HARNESS_RC_LOADED=yesconst binary = join(dir, "engine with 'quotes")const result = join(dir, 'result.json')writeFileSync(binary, `#!${process.execPath}-const fs = require('node:fs');+// Node 26 runs an extensionless script as an ES module, where require is undefined; this works as either.+const fs = process.getBuiltinModule('node:fs');if (process.argv.includes('--help')) { console.log('--no-daemon --auto'); process.exit(0); }fs.writeFileSync(${JSON.stringify(result)}, JSON.stringify({args: process.argv.slice(2), cwd: process.cwd(),diff --git a/cli/src/superTabs/start.spec.ts b/cli/src/superTabs/start.spec.tsindex 27ee25a97..a7e3f82e0 100644--- a/cli/src/superTabs/start.spec.ts+++ b/cli/src/superTabs/start.spec.ts@@ -7,7 +7,7 @@ import { buddyOwnerFile, buddyOwnerOf } from '../lib/buddyGuard.js'import { worktreeFolderName } from '../lib/agentNames.js'import { env } from '../config/env.js'import { homedir, tmpdir } from 'node:os'-import { BUDDY_CLAUDE_SIGNED_OUT, BUDDY_NOT_OWN_MACHINE, HEAVY_NOT_RECORDED, HEAVY_REFUSED, inspectCapacity, MODEL_REPORT_WAIT_MS, startAgent } from './start.js'+import { BUDDY_CLAUDE_SIGNED_OUT, BUDDY_NOT_OWN_MACHINE, HEAVY_NOT_RECORDED, HEAVY_REFUSED, inspectCapacity, MODEL_REPORT_WAIT_MS, startAgent, TEAM_WRITTEN_CLAUDE_ONLY } from './start.js'import { buildEngineCommandArgv } from '../lib/engineLaunch.js'import { readCapacityDisk } from './disk.js'import { SuperTabHostError } from './wire.js'@@ -155,8 +155,8 @@ describe('Swarm permission mode', () => {Object.assign(f.start.request, { engine: 'claude', projectSettings: 'off' })expect(await startAgent({ action: 'resume', tabId: 'tab', startId: 'start' }, f.scoped, where, f.open)).toMatchObject({ ok: true })const payload = f.request.mock.calls.find(c => c[0] === 'agent_create')![1]!- expect(payload).toMatchObject({ permissionMode: 'teamWritten', bypassPermission: true })- expect(buildEngineCommandArgv('claude', { permissionMode: 'teamWritten' })).toEqual(expect.arrayContaining(['--dangerously-skip-permissions', '--setting-sources', 'user', '--strict-mcp-config']))+ expect(payload).toMatchObject({ permissionMode: 'teamWritten', bypassPermission: false })+ expect(buildEngineCommandArgv('claude', { permissionMode: 'teamWritten' })).toEqual(expect.arrayContaining(['--setting-sources', 'user', '--strict-mcp-config']))} finally { teamDaemon.value = false }})@@ -168,7 +168,7 @@ describe('Swarm permission mode', () => {Object.assign(f.start.request, { engine: 'codex', projectSettings: 'off' })expect(await startAgent({ action: 'resume', tabId: 'tab', startId: 'start' }, f.scoped, where, f.open)).toMatchObject({ ok: true })const payload = f.request.mock.calls.find(c => c[0] === 'agent_create')![1]!- expect(payload).toMatchObject({ permissionMode: 'teamWritten', bypassPermission: true })+ expect(payload).toMatchObject({ permissionMode: 'teamWritten', bypassPermission: false })expect(String(payload.codexHome)).toContain(`${sep}${PM_HOMES}${sep}`)rmSync(dirname(String(payload.codexHome)), { recursive: true, force: true })} finally { teamDaemon.value = false }@@ -208,12 +208,44 @@ describe('Swarm permission mode', () => {} finally { teamDaemon.value = false }})- it.each(['claude', 'codex'] as const)('refuses Team-written %s work in the main account, before anything is created', async engine => {+ // Swarm v3 (task #4307): no Team machine is left, and the server sends Team-written work only to the project owner's own+ // computer with project settings off (backend superTabs/teamWritten.ts, ruling #4120). It launches there as on a Team daemon.+ it('starts Team-written Claude Code work on the owner\'s own computer with project settings off', async () => {const f = fixture()- Object.assign(f.start.request, { engine, projectSettings: 'off' })- expect(await startAgent({ action: 'resume', tabId: 'tab', startId: 'start' }, f.scoped, where, f.open)).toMatchObject({ error: 'START_FAILED' })+ Object.assign(f.start.request, { engine: 'claude', projectSettings: 'off' })+ expect(await startAgent({ action: 'resume', tabId: 'tab', startId: 'start' }, f.scoped, where, f.open)).toMatchObject({ ok: true })+ const payload = f.request.mock.calls.find(c => c[0] === 'agent_create')![1]!+ expect(payload).toMatchObject({ permissionMode: 'teamWritten', bypassPermission: false })+ expect(payload).not.toHaveProperty('codexHome')+ expect(f.start.error).toBeNull()+ })++ // Review of #3485: another account's agent wrote this code, and it runs as the owner on their own computer, not in a Team+ // account's own OS user, so it gets the owner's own permission checks and sandbox: no flag that skips them.+ it.each(['claude', 'codex'] as const)('launches Team-written %s work with no flag that skips permissions or the sandbox', async engine => {+ const argv = buildEngineCommandArgv(engine, { permissionMode: 'teamWritten', bypassPermission: false,+ ...(process.platform === 'win32' ? { native: { startupArgs: [] } as never } : {}) })+ expect(argv).not.toContain('--dangerously-skip-permissions')+ expect(argv).not.toContain('--dangerously-bypass-approvals-and-sandbox')+ expect(argv.join(' ')).not.toMatch(/--permission-mode|--approve-for-me|--sandbox|bypass/)+ })++ // Codex keeps the branch's settings out only in an engine home of its own, which here has no sign-in, and Harness never reads+ // or links one (loginReads.spec.ts, security review 2 of #3485).+ it('refuses Team-written Codex work on the owner\'s own computer before anything is made, naming Claude Code', async () => {+ const f = fixture()+ Object.assign(f.start.request, { engine: 'codex', projectSettings: 'off' })+ expect(await startAgent({ action: 'resume', tabId: 'tab', startId: 'start' }, f.scoped, where, f.open)).toMatchObject({ error: 'START_FAILED', detail: TEAM_WRITTEN_CLAUDE_ONLY })expect(f.request.mock.calls.some(c => c[0] === 'agent_create')).toBe(false)- expect(f.start.error).toContain('Team account')+ expect(f.start.error).toContain('Claude Code')+ expect(existsSync(join(homedir(), PM_HOMES, f.start.creationId))).toBe(false)+ })++ it('gives a normal Codex start no engine home of its own', async () => {+ const f = fixture()+ Object.assign(f.start.request, { engine: 'codex' })+ expect(await startAgent({ action: 'resume', tabId: 'tab', startId: 'start' }, f.scoped, where, f.open)).toMatchObject({ ok: true })+ expect(f.request.mock.calls.find(c => c[0] === 'agent_create')![1]!).not.toHaveProperty('codexHome')})it.each(['opencode', 'kilo'])('fails a pending legacy %s Swarm start before native creation', async engine => {diff --git a/cli/src/superTabs/start.ts b/cli/src/superTabs/start.tsindex c5534ccdd..736c2c8fb 100644--- a/cli/src/superTabs/start.ts+++ b/cli/src/superTabs/start.ts@@ -22,7 +22,8 @@ const text = (v: unknown) => typeof v === 'string' ? v : nullconst number = (v: unknown) => typeof v === 'number' && Number.isFinite(v) ? v : null// These native validations run before dispatch. Storage errors, conflicts and// unknown failures deliberately stay uncertain: they cannot prove no launch.-const TEAM_WRITTEN_MAIN_ACCOUNT = 'A Harness Team agent wrote this task\'s code, so it runs only in a Team account, never in this machine\'s main account. Choose an agent or machine in a Team account.'+/** Why Team-written work starts only on Claude Code off a Team daemon (task #4307). */+export const TEAM_WRITTEN_CLAUDE_ONLY = 'A Harness Team agent wrote this task\'s code, so on this computer it runs only on Claude Code, which keeps the branch\'s own settings out. Codex would need a sign-in of its own for that, which Harness never makes from yours. Choose Claude Code for this task.'const PRE_DISPATCH_REFUSALS = new Set(['INVALID_ENGINE', 'INVALID_CWD', 'INVALID_PROJECT_SOURCE', 'INVALID_REPOSITORY','INVALID_GRID', 'INVALID_CODEX_HOME', 'INVALID_DSH', 'INVALID_PROMPT',@@ -380,12 +381,16 @@ async function startOnce(input: Json, scoped: ScopedRequest, where: Where, open:if (!refusedByBackend(error)) throw errorreturn await releaseRefused(error)}- // Code a Team agent wrote never runs as this machine's owner (backend superTabs/teamWritten.ts, audit H2). The server sends it- // only to a Team account's machine, so this is the last check, for a row or a server that says otherwise.- const projectSettingsOff = request.projectSettings === 'off'- if (projectSettingsOff && !isTeamDaemon()) {- requireSuccess(await scoped({ action: 'command', operationId: `refused-${startId}`, command: { type: 'agent.startFailed', startId, error: TEAM_WRITTEN_MAIN_ACCOUNT } }))- return { error: 'START_FAILED', startId, detail: TEAM_WRITTEN_MAIN_ACCOUNT }+ // Code a Team agent wrote runs with none of its branch's own settings, hooks or trust (backend superTabs/teamWritten.ts,+ // audit H2). Since Swarm v3 there is no Team machine, and the server sends such work only to the project owner's own+ // computer (ruling #4120); a refusal here failed every start of it (#4188, 11-07). Claude Code launches there in the+ // `teamWritten` mode below. Codex keeps the branch's settings out only in an engine home of its own, which off a Team+ // daemon has no sign-in, and Harness never reads or links one (anh Dee, 11-07; loginReads.spec.ts): refused, before+ // anything is made.+ const projectSettingsOff = request.projectSettings === 'off', team = isTeamDaemon()+ if (projectSettingsOff && !team && request.engine !== 'claude') {+ requireSuccess(await scoped({ action: 'command', operationId: `refused-${startId}`, command: { type: 'agent.startFailed', startId, error: TEAM_WRITTEN_CLAUDE_ONLY } }))+ return { error: 'START_FAILED', startId, detail: TEAM_WRITTEN_CLAUDE_ONLY }}// Both direct and contributed-host starts reach this boundary. Existing// native receipts are read above and never have their permissions changed.@@ -447,8 +452,8 @@ async function startOnce(input: Json, scoped: ScopedRequest, where: Where, open:// Swarm v3 (task #4215): a PM, an agent and a Buddy start with their owner's own permission settings: no mode, so the// engine opens in the person's own default. Forced full mode turned off every check on people's own computers, where// Anthropic says to use it only in isolated environments. Team-written work keeps its barrier against the branch's own- // settings, in a Team home that is no person's.- const payload: Json = { engine: request.engine, name: request.name, creationId, startedBy: 'agent', bypassPermission: projectSettingsOff,+ // settings, and approves nothing on its own either: it runs as the owner, on their own computer (review of #3485).+ const payload: Json = { engine: request.engine, name: request.name, creationId, startedBy: 'agent', bypassPermission: false,...(projectSettingsOff ? { permissionMode: 'teamWritten' } : {}),...(mode ? { swarmRole: role, swarmSkillMode: mode } : {}),...(github ? { swarmGitHub: true } : {}),@@ -466,7 +471,7 @@ async function startOnce(input: Json, scoped: ScopedRequest, where: Where, open:// A Codex Product Manager in a Harness Team account runs in an engine home of its own, deleted whole when the Swarm// ends it, so nothing of its chats stays where the account's next agent reads (teamDaemon.ts, security re-check 2 of #2089).// Team-written Codex work too: a home that trusts no project keeps the branch's own settings out (engines/codex/launch.ts).- const pmHome = lead || projectSettingsOff ? pmEngineHome(String(request.engine), creationId, isTeamDaemon(), homedir()) : null+ const pmHome = lead || projectSettingsOff ? pmEngineHome(String(request.engine), creationId, team, homedir()) : nullif (pmHome) {// Codex refuses a CODEX_HOME that is not there; only the Team user reads it.mkdirSync(pmHome, { recursive: true, mode: 0o700 })diff --git a/docs/plans/2026-11-07-team-written-owner-start-plan.md b/docs/plans/2026-11-07-team-written-owner-start-plan.mdnew file mode 100644index 000000000..55e03e5ef--- /dev/null+++ b/docs/plans/2026-11-07-team-written-owner-start-plan.md@@ -0,0 +1,44 @@+# Team-written work starts on the owner's own computer Plan++**Goal:** A start for Team-written work (`projectSettings: 'off'`) on a machine that is not a Team daemon launches with the+branch's own project settings kept out, instead of failing with "runs only in a Team account" (task #4307).++**Architecture:** Since Swarm v3 there is no Team machine; the backend sends Team-written work only to the project owner's+own computer with project settings off (backend `superTabs/commands.ts` start, `teamWritten.ts`, the PM's ruling #4120).+`cli/src/superTabs/start.ts` launches Claude Code there in the `teamWritten` mode (`--setting-sources user+--strict-mcp-config`). The mode no longer skips permission checks or Codex's sandbox: the code runs as the owner, not in a Team+account's own OS user (review of #3485). Codex keeps the branch's settings out only in an engine home of its own, which off a+Team daemon has no sign-in, and Harness never reads or links one (`loginReads.spec.ts`, security review 2 of #3485). So+Team-written Codex work off a Team daemon is refused before anything is made, naming Claude Code.++**Tech Stack:** TypeScript, Node `fs`, vitest.++**Spec:** the task brief of #4307.++This plan is implemented by its Engineer, task by task, test first.++## Global Constraints++- CLI only; `cli/src/superTabs/start.ts` and its spec.+- Never read a Claude or ChatGPT login, nor name its file (`loginReads.spec.ts`).+- No other start path changes: a Team daemon's starts and every normal start are as before.++## Review Focus++- The branch's own project settings, hooks and trust never load for Team-written code, on Claude Code or Codex.+- Team-written code skips no permission check and no sandbox off a Team daemon.+- A refused start creates nothing and says why.++## Task 1: Team-written starts off a Team daemon++**Files:** `cli/src/superTabs/start.ts`, `cli/src/engines/claude/launch.ts`, `cli/src/engines/codex/launch.ts`,+`cli/src/lib/engineLaunch.ts`, `cli/src/core/agents/create.ts`, their specs and the launch golden record.++**Interfaces:** `TEAM_WRITTEN_CLAUDE_ONLY`, the refusal's text.++- [ ] Write failing specs: on a non-Team machine, Team-written Claude Code work launches in `teamWritten` mode, records no+ bypass and has no engine home of its own; the `teamWritten` argv has no flag that skips permissions or the sandbox;+ no full-mode warning is accepted for it; Team-written Codex work is refused before anything is made, naming Claude Code.+- [ ] Run them and watch them fail.+- [ ] Remove the refusal for Claude Code, drop the bypass flags from `teamWritten`, refuse Codex off a Team daemon.+- [ ] Run the changed specs, the specs of what imports them, `loginReads.spec.ts` and `npm run test:core`.