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
Harness Team account: VM validation and the fixes it found (#1697)
Dee434aaf072a15
diff --git a/cli/src/team/admin.spec.ts b/cli/src/team/admin.spec.tsindex f6b6aead3..89bbd46f8 100644--- a/cli/src/team/admin.spec.ts+++ b/cli/src/team/admin.spec.ts@@ -52,6 +52,14 @@ describe('adminRunner', () => {.toEqual({ ok: false, code: 'FAILED', message: 'The script stopped (exit 2).' })})+ it('finds the script\'s reason after earlier lines, which osascript ends with CR', async () => {+ // As macOS returned it in the VM rig (24 Oct 2026): the owner's CLI said why first, then the script died.+ const stderr = '0:296: execution error: ✗ Harness would not give a team sign-in code: Invalid or expired token\r'+ + 'harness: could not get a sign-in code from your Harness sign-in (7)\n'+ expect(await fixture({ code: 1, stderr }).run(() => ({ script: '' }), 'p'))+ .toEqual({ ok: false, code: 'FAILED', message: 'could not get a sign-in code from your Harness sign-in' })+ })+it('removes the stage when building the script throws', async () => {const f = fixture({ code: 0 })await expect(f.run(() => { throw new Error('bad input') }, 'p')).rejects.toThrow('bad input')diff --git a/cli/src/team/admin.ts b/cli/src/team/admin.tsindex a1da4b58f..1c9f38d0e 100644--- a/cli/src/team/admin.ts+++ b/cli/src/team/admin.ts@@ -48,7 +48,9 @@ export function adminRunner(deps: AdminDeps = {}): RunAdmin {return { ok: false, code: 'CANCELLED', message: 'The administrator prompt was cancelled.' }}if (result.code !== 0) {- const said = result.stderr.trim().split('\n').pop()?.replace(/^.*harness: /, '').replace(/\s*\(\d+\)$/, '') ?? ''+ // `do shell script` hands the script's stderr back with its lines ended by CR, not LF: split on both, or a reason+ // after an earlier line is never found, and the CR left in it makes a terminal print the line over itself.+ const said = result.stderr.trim().split(/[\r\n]+/).pop()?.replace(/^.*harness: /, '').replace(/\s*\(\d+\)$/, '') ?? ''return { ok: false, code: 'FAILED', message: said || `The script stopped (exit ${result.code}).` }}return { ok: true, stdout: result.stdout }diff --git a/cli/src/team/command.spec.ts b/cli/src/team/command.spec.tsindex 29b624585..c1f1aaae7 100644--- a/cli/src/team/command.spec.ts+++ b/cli/src/team/command.spec.ts@@ -157,6 +157,14 @@ describe('harness team setup', () => {const stopped = fake({ adminResult: { ok: false, code: 'FAILED', message: 'launchd would not start the team daemon' } })expect(await teamCommand(['setup', '--json'], stopped.deps)).toBe(1)expect(JSON.parse(stopped.out.at(-1)!)).toMatchObject({ ok: false, code: 'SETUP_FAILED' })+ // The script's reason has no full stop of its own; the sentence after it must not run on.+ const unsigned = fake({ adminResult: { ok: false, code: 'FAILED', message: 'could not get a sign-in code from your Harness sign-in; the team daemon runs without a new sign-in' } })+ expect(await teamCommand(['setup'], unsigned.deps)).toBe(1)+ expect(unsigned.err[0]).toBe('✗ The Harness Team account was not finished: could not get a sign-in code from your Harness sign-in; '+ + 'the team daemon runs without a new sign-in. Run `harness team setup` again; it repairs what is there.')+ const failedRemove = fake({ readConfig: () => config, adminResult: { ok: false, code: 'FAILED', message: 'The script stopped (exit 2).' } })+ expect(await teamCommand(['remove'], failedRemove.deps)).toBe(1)+ expect(failedRemove.err[0]).toBe('✗ The Harness Team account was not fully removed: The script stopped (exit 2). Run `harness team remove` again.')})it('refuses where it cannot help, before any prompt', async () => {diff --git a/cli/src/team/command.ts b/cli/src/team/command.tsindex df6c1e7e6..b76856b8b 100644--- a/cli/src/team/command.ts+++ b/cli/src/team/command.ts@@ -172,6 +172,9 @@ function byHandLines(ownerHome: string): string[] {const notMac = 'The Harness Team account is made on a Mac. On a computer used only for agents, run `harness team on`.'+/** A script's reason as a sentence, so the one after it does not run on: the scripts' own reasons end without a stop. */+const sentence = (text: string): string => /[.!?]$/.test(text) ? text : `${text}.`+async function setup(deps: TeamCommandDeps, json: boolean, signInAgain: boolean): Promise<number> {if (deps.platform !== 'darwin') return fail(deps, json, 'UNSUPPORTED', notMac)if (deps.uid() === 0) return fail(deps, json, 'RUN_AS_YOURSELF', 'Run this as yourself, not with sudo: macOS asks for an administrator password itself.')@@ -213,7 +216,7 @@ async function setup(deps: TeamCommandDeps, json: boolean, signInAgain: boolean)}), SETUP_PROMPT)if (!result.ok) {if (result.code === 'CANCELLED') return fail(deps, json, 'CANCELLED', 'Nothing was changed: the administrator prompt was cancelled.')- return fail(deps, json, 'SETUP_FAILED', `The Harness Team account was not finished: ${result.message} Run \`harness team setup\` again; it repairs what is there.`)+ return fail(deps, json, 'SETUP_FAILED', `The Harness Team account was not finished: ${sentence(result.message)} Run \`harness team setup\` again; it repairs what is there.`)}try { deps.setupDecision?.clear() } catch { /* only Desktop's offer reads it */ }const handedOver = /handed a sign-in to the team account/.test(result.stdout)@@ -319,7 +322,7 @@ async function remove(deps: TeamCommandDeps, json: boolean): Promise<number> {}), REMOVE_PROMPT)if (!result.ok) {if (result.code === 'CANCELLED') return fail(deps, json, 'CANCELLED', 'Nothing was removed: the administrator prompt was cancelled.')- return fail(deps, json, 'REMOVE_FAILED', `The Harness Team account was not fully removed: ${result.message} Run \`harness team remove\` again.`)+ return fail(deps, json, 'REMOVE_FAILED', `The Harness Team account was not fully removed: ${sentence(result.message)} Run \`harness team remove\` again.`)}try { deps.setupDecision?.decline() } catch { /* only Desktop's offer reads it */ }if (json) deps.out(JSON.stringify({ ok: true, removed: true }))diff --git a/cli/src/team/script.spec.ts b/cli/src/team/script.spec.tsindex e86e7a9f2..d9491a3b0 100644--- a/cli/src/team/script.spec.ts+++ b/cli/src/team/script.spec.ts@@ -112,6 +112,21 @@ describe('setup script', () => {expect(buildSetupScript(input())).toContain('if [ "$SIGN_IN" = always ] || [ ! -s "$TEAM_SESSION" ]; then')})+ it('starts the daemon it stopped again when no sign-in code can be had, then says why', () => {+ // In the VM rig (24 Oct 2026) a repair run whose mint was refused died at step 7, after step 4 had stopped the daemon:+ // the team machine stayed down until the Mac restarted.+ const script = buildSetupScript(input())+ expect(script).not.toMatch(/team __handoff\)[^\n]*\|\| die/)+ expect(script).not.toMatch(/die "the sign-in code was not in the form/)+ const bootstrap = at(script, 'launchctl bootstrap system "$PLIST"')+ expect(at(script, 'no_sign_in="could not get a sign-in code from your Harness sign-in"')).toBeLessThan(bootstrap)+ expect(at(script, 'no_sign_in="the sign-in code was not in the form Harness expects"')).toBeLessThan(bootstrap)+ expect(at(script, '[ -z "$no_sign_in" ] || die "$no_sign_in; the team daemon runs without a new sign-in" 7')).toBeGreaterThan(bootstrap)+ // Nothing is handed over without a code.+ expect(at(script, 'if [ -z "$no_sign_in" ]; then')).toBeLessThan(at(script, 'printf \'%s\\n\' "$code" | as_team'))+ parses(script)+ })+it('copies a managed tmux only when there is one', () => {expect(buildSetupScript(input())).toContain("TMUX_NAME=''")const script = buildSetupScript(input({ tmuxRuntimeDir: `${OWNER_HOME}/.harness/runtime/tmux-3.5a-darwin-arm64` }))@@ -178,6 +193,8 @@ describe('the team account\'s copy of the runtime', () => {const runtime = join(home, '.harness', 'runtime')expect(readFileSync(join(runtime, 'current-node'), 'utf8')).toBe(`${runtime}/node-v1/bin/node\n`)expect(existsSync(join(runtime, 'node-v1.next'))).toBe(false)+ // On the account's PATH, so Codex's `#!/usr/bin/env node` launcher starts in its terminals.+ expect(readlinkSync(join(home, '.local', 'bin', 'node'))).toBe(`${runtime}/node-v1/bin/node`)expect(readFileSync(join(home, '.harness', 'cli', 'cli.js'), 'utf8')).toBe('// cli')expect(existsSync(join(home, '.harness', 'cli', 'notify.mjs'))).toBe(false)expect(statSync(join(home, '.harness')).mode & 0o777).toBe(0o700)diff --git a/cli/src/team/script.ts b/cli/src/team/script.tsindex 70288baa1..3e25e27b6 100644--- a/cli/src/team/script.ts+++ b/cli/src/team/script.ts@@ -163,6 +163,10 @@ export const TEAM_COPY = ['put_dir() { rm -rf "$2.next"; cp -R "$1" "$2.next"; rm -rf "$2"; mv "$2.next" "$2"; }','put_dir "$stage/node" "$rt/$node_name"',`printf '%s\\n' "$rt/$node_name/bin/node" > "$rt/current-node.next" && mv -f "$rt/current-node.next" "$rt/current-node"`,+ // Its Node on its own PATH, as tmux is: Codex's launcher is `#!/usr/bin/env node`, and the account has no other Node, so+ // `codex login` in a terminal on its machine would not start. ~/.local/bin is last on a login shell's PATH: a Node the+ // system has wins.+ 'ln -sfn "$rt/$node_name/bin/node" "$bin/node"','if [ -n "$tmux_name" ]; then',' put_dir "$stage/tmux" "$rt/$tmux_name"',` printf '%s\\n' "$rt/$tmux_name/bin/tmux" > "$rt/current-tmux.next" && mv -f "$rt/current-tmux.next" "$rt/current-tmux"`,@@ -349,15 +353,23 @@ export function buildSetupScript(input: SetupScriptInput): string {'','# 7. Sign-in: a single-use code minted from the owner\'s own sign-in now, so its 90 seconds start here, and','# written where only the team account can read it. The team daemon redeems it as it starts and deletes it.',+ '# A code that cannot be had is reported after step 8: step 4 stopped the daemon, and it must start again,',+ '# with the sign-in it had or none, rather than stay stopped until the next successful setup or restart.',+ 'no_sign_in=','if [ "$SIGN_IN" = always ] || [ ! -s "$TEAM_SESSION" ]; then',- ` minted=$(as_owner /usr/bin/env ${mintEnv ? `${mintEnv} ` : ''}"$OWNER_NODE" "$OWNER_CLI" team __handoff) || die "could not get a sign-in code from your Harness sign-in" 7`,+ ` if minted=$(as_owner /usr/bin/env ${mintEnv ? `${mintEnv} ` : ''}"$OWNER_NODE" "$OWNER_CLI" team __handoff); then`,// Its last line: a warning the CLI printed first must not become part of the code.- ' code=$(printf \'%s\\n\' "$minted" | tail -n 1)',+ ' code=$(printf \'%s\\n\' "$minted" | tail -n 1)',// The shell's own check of what ./layout.ts HANDOFF_CODE allows: token characters, 16 to 256 of them.- ' case $code in \'\'|*[!A-Za-z0-9_-]*) die "the sign-in code was not in the form Harness expects" 7 ;; esac',- ' [ "${#code}" -ge 16 ] && [ "${#code}" -le 256 ] || die "the sign-in code was not in the form Harness expects" 7',- ` printf '%s\\n' "$code" | as_team /bin/sh -c ${sh(WRITE_PRIVATE)} sh "$HANDOFF"`,- ' say "handed a sign-in to the team account"',+ ' case $code in \'\'|*[!A-Za-z0-9_-]*) no_sign_in="the sign-in code was not in the form Harness expects" ;; esac',+ ' [ -n "$no_sign_in" ] || { [ "${#code}" -ge 16 ] && [ "${#code}" -le 256 ]; } || no_sign_in="the sign-in code was not in the form Harness expects"',+ ' else',+ ' no_sign_in="could not get a sign-in code from your Harness sign-in"',+ ' fi',+ ' if [ -z "$no_sign_in" ]; then',+ ` printf '%s\\n' "$code" | as_team /bin/sh -c ${sh(WRITE_PRIVATE)} sh "$HANDOFF"`,+ ' say "handed a sign-in to the team account"',+ ' fi','fi','','# 8. The LaunchDaemon, root\'s, which runs the team daemon as the team account from boot.',@@ -372,6 +384,7 @@ export function buildSetupScript(input: SetupScriptInput): string {' sleep 1','done','say "the team daemon runs as $TEAM ($LABEL)"',+ '[ -z "$no_sign_in" ] || die "$no_sign_in; the team daemon runs without a new sign-in" 7','',]return lines.join('\n')diff --git a/docs/plans/2026-10-24-swarm-team-account.md b/docs/plans/2026-10-24-swarm-team-account.mdindex 7b237eb1b..78e4da59a 100644--- a/docs/plans/2026-10-24-swarm-team-account.md+++ b/docs/plans/2026-10-24-swarm-team-account.md@@ -104,3 +104,55 @@ Files: `backend/src/superTabs/commands.ts` (`message.send`), a small detector mo## Out of scopeVMs; team accounts on Windows and Linux (dedicated machines use `harness team on`); blocking the team user from the owner's local network services with per-user firewall rules (next); pooling or reselling subscriptions.++## Validation, 24 Oct 2026 (VM)++`harness team setup`, `status`, `remove`, `on` and `off` from `main` at #1695, end to end in a fresh macOS VM from the fresh-Mac rig (macOS 26.6.2, `ghcr.io/cirruslabs/macos-tahoe-vanilla`). The VM's `admin` (an administrator, signed in at the console) is the owner. Nothing ran on a developer's own Mac.++**How.** The CLI was bundled from this branch and installed by the real installer (`cli/scripts/install.sh`) from a local manifest: managed Node 22.23.2, managed tmux 3.7c, `~/.harness/cli/cli.js` and the `harness` launcher, where `layout.ts` expects them. The owner's home started at `drwxr-x---` (750), the macOS default. It also got a world-readable `~/.gitconfig`, a 755 `~/code` and an `~/.ssh`. Harness sign-in needs a person to scan the QR code, so the owner's sign-in and the backend were stand-ins. The sign-in was a session file in the shape `harness login` writes. The backend was a small server on the VM's loopback that answers `/api/auth/handoff`, `/handoff/redeem` and `/revoke` as the deployed backend does today (`backend/src/routes/auth.ts` before #1691): minting ignores `kind`, and redeeming returns a phone-style `hna_`/`hnr_` session without `kind`. Owner commands ran with `WEB_URL`/`BACKEND_WS_URL` pointing at it and `ADAPTER_UPDATE_DISABLE=true`, which setup carries into the team daemon. Nothing reached production.++| Step | Result |+|---|---|+| 1. Build and install | ✓ as above |+| 2. Owner sign-in | Stand-in only; real sign-in not exercised |+| 3. Administrator prompt | ✓ `harness team setup` from Terminal in the console session. macOS showed `SETUP_PROMPT`, answered over VNC on the first try; 54 s from start to finish, engine installs included. 5 setups and 2 removals went through the real prompt |+| 4. Verify | ✓, except that Users & Groups does not list the account (open bug 5) |+| 5. Negative check | ✓ |+| 6. Idempotency | ✓ |+| 7. Removal | ✗ through `harness team remove` (open bug 6); ✓ the same script run as root over ssh |+| 8. `team on` / `team off` | ✓ safe refusals; nothing changed |++**Step 4.**+- `dscl . -read /Users/harnessteam`: RealName `Harness Team`, UniqueID 600, PrimaryGroupID 20, `/bin/zsh`, Password `*`, `No such key: IsHidden`. `dseditgroup -o checkmember -m harnessteam admin`: `no harnessteam is NOT a member of admin`.+- `ls -ld /Users/admin /Users/harnessteam`: both `drwx------+`. The sentinel `/Users/admin/.harness-team-privacy` is `-rw-r--r-- admin`, 199 bytes.+- `launchctl print system/ai.autonomous.harness.team`: `state = running`, `username = harnessteam`, `group = staff`. `lsof -iTCP:18493 -sTCP:LISTEN`: `harnessd- … harnessteam … 127.0.0.1:18493 (LISTEN)`.+- The team daemon's log: `[team] sign-in failed: This Harness backend does not make team sign-ins yet, so nothing was signed in.`, then `[team] privacy check passed` and `[team] engines: claude installed, codex installed`. The stand-in logged the mint (`{"kind":"team"}`), the redeem, and the revoke of the returned `hnr_` 6 ms later. The team account's `~/.harness/auth/` stayed empty. `harness team setup` therefore exits 1 today, with `✗ The team account did not sign in: …` before `✓ Private: the team account cannot read your files.`+- `/Library/Application Support/Harness/` (root, 755) holds `team.json` (root, 644) and `Team/` (harnessteam, 755) with `status.json`. `harness team status` and `--json` show: account exists, daemon running, sign-in failed (that sentence), `Private ✓`, home `mode 700 ✓`, and Claude Code and Codex `✓ installed · ✗ not signed in`.+- Engines: `~/.local/bin/claude` (Claude Code 2.1.310) and `~/.local/bin/codex` (codex-cli 0.164.0), installed by the team account itself.+- As `harnessteam`: `cat /Users/admin/.harness-team-privacy`, `ls /Users/admin`, `cat /Users/admin/.gitconfig` and `ls /Users/admin/code` each get `Permission denied`.+- After the VM was powered off hard (see the rig note below), launchd started the team daemon at boot and the check passed again.++**Step 5.** With `chmod 750 /Users/admin`, the team account could read the sentinel. `launchctl kickstart -k system/ai.autonomous.harness.team` logged `privacy check FAILED (sentinel): The team account could read the privacy sentinel in your home folder.`, and status showed `privacy ✗ sentinel: …` and `mode 750 ✗ should be 700`. After `chmod 700` and another kickstart it logged `privacy check passed` and status showed `Private ✓`.++**Step 6.** Ran setup a second time through the prompt and diffed snapshots: only the job's pid and run count changed. One account (uid 600), one plist (same SHA-256), one sentinel, one launchd job, no leftover staging folders or `.next` files, and the same team computer id on redeem.++**Step 7.** See open bug 6. The script `buildRemoveScript` makes from `team.json`, run with sudo over ssh, printed `harness: removed the Harness Team account, its home folder and its daemon`. The user, its home, the plist, the job, `team.json`, `Team/` and the sentinel are gone, and `/Users/admin` stays 700. `harness team status` then prints `No Harness Team account on this computer.`, and `harness team remove` prints `No Harness Team account on this Mac; nothing to remove.`++**Step 8.** With the account present, `team on --yes` refuses with `TEAM_ACCOUNT` (`This Mac has a Harness Team account, which runs its team work. …`), and `team off` prints `This computer does not run team work only; nothing to change.` Neither calls the backend. Without the account, `team on` asks for `--yes`, and `team on --yes` prints `✗ This Harness backend does not make team sign-ins yet, so nothing was signed in. Nothing was changed on this computer.` after the mint, the redeem and the revoke of the session it got. The session file's SHA-256 is unchanged throughout. Against the stand-in answering `kind: "team"`, `team on` stored a `kind: "team"` session (`hta_`/`htr_`) and revoked the previous refresh token, and `team off` revoked it and removed the session.++**Fixed in this change** (each with a spec that fails on `main`):+1. *A repair run whose code cannot be minted leaves the team daemon stopped.* `harness team setup` with minting refused (401) ends with status `daemon ○ installed, not loaded`, and `launchctl print` prints `Could not find service "ai.autonomous.harness.team" in domain for system`. Step 4 boots the daemon out, and step 7 exited before step 8 started it again. This happens on every run while the team account is signed out (every run today) and with `--sign-in-again`. Now step 7 records the reason, step 8 runs, and the script then exits 7 with `…; the team daemon runs without a new sign-in`. Checked in the VM: the daemon runs again and no sign-in file is written.+2. *The failure message was garbled.* Before: `✗ The Harness Team account was not finished: 0:296: execution error: ✗ Harness would not give a team sign-in code: Invalid or expired token⏎harness: could not get a sign-in code from your Harness sign-in Run …`, where ⏎ is a CR that makes a terminal overprint the line. `do shell script` ends stderr lines with CR, and `admin.ts` split on LF only. It now splits on both. `lib/guestHelperInstall.ts:172` parses the same way; that was not exercised or changed.+3. *The script's reason ran on into "Run `harness team setup` again".* Setup and remove now end the reason with a full stop.+4. *Codex could not start in the team account's terminals.* In a login shell with the team daemon's environment, `codex --version` and `codex login --device-auth` (the sign-in step `harness team status` prints) both gave `env: node: No such file or directory`, while status said `Codex ✓ installed`. Codex's launcher is `#!/usr/bin/env node`, and the team account has no Node on its PATH: engine launches add Harness's Node, plain terminals do not. Setup now links the team account's Node as `~/.local/bin/node`, as it links tmux. Checked in the VM: `codex-cli 0.164.0`, and `codex login --device-auth` starts its device-code steps.++**Open, for a decision:**+5. *Users & Groups does not list the account.* System Settings > Users & Groups showed only `admin` and Guest User. The record has `Password: *` and no `AuthenticationAuthority`. A test user made the same way was not listed either; the same user given a random password with `dscl . -passwd` (a `ShadowHash` authority) was listed as Standard. So "shown in Users & Groups" in setup's and status's text, and the reason given in `layout.ts`, do not hold today. Options include a random password nobody knows (the plan's original wording) or another way to make it visible.+6. *`harness team remove` cannot delete the account on macOS 26.6.2.* Two runs through the real prompt each printed `✗ The Harness Team account was not fully removed: <dscl_cmd> DS Error: -14120 (eDSPermissionError). Run \`harness team remove\` again.`, with no permission prompt. Deleting a test user with `sudo dscl . -delete` from Terminal raised `"Terminal" would like to administer your computer. Administration can include modifying passwords, networking, and system settings.`; over ssh it succeeded. `dscl . -create` is not gated this way. By the time the delete fails, the script has signed the team account out, booted out its daemon and deleted the plist. The account and its home stay, without a daemon (`daemon ○ not installed`, `sign-in ✗ signed-out`). Possible directions: check that deletion is allowed before changing anything; ask for the Administration permission in Privacy & Security; or delete from a context that permission allows.+7. Removal leaves an empty `/Library/Application Support/Harness` folder.++**Notes.** The administrator dialog is titled "osascript", and a repair run still says "Harness wants to create a separate account". From a folder it cannot read, `claude --version` as the team account fails with a misleading "low max file descriptors (Current limit: 256)". The daemon works from the team home, where it runs, so this is not a product bug. Rig: tart's `--vnc-experimental` server crashed the VM four times (`EXC_BAD_ACCESS` in `-[_VZVNCServer _vncServerClientConnectionCreated:]` when a VNC client connected). Each crash powered the VM off; it was restarted with `vmn-start`.++**Not exercised.** A real owner sign-in, and minting and redeeming against production. A real owner today takes the stand-in's path: the code is minted without `kind`, and the redeemed session has no `kind`, so it is revoked. Also not exercised: a team daemon signing in through setup; Desktop's automatic setup (join, contribute, startup); the 5-minute recheck while serving a Swarm (kickstart was used instead); finishing engine sign-in (a device code needs a person); and a Swarm start landing in the team account.++Tests: `npx vitest run src/team src/superTabs/machines.spec.ts src/superTabs/service.spec.ts`: 209 passed. `npm run typecheck` is clean.