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: no team work without the GitHub App, and roster reads without side effects (#1704)
Dee29b92541bff9
diff --git a/backend/integration/superTabTeam.test.ts b/backend/integration/superTabTeam.test.tsindex 939900f9f..35e06fc1d 100644--- a/backend/integration/superTabTeam.test.ts+++ b/backend/integration/superTabTeam.test.ts@@ -437,6 +437,23 @@ describe('a teammate\'s work and the machines that take it', () => {// machine. Its team account joins where the Mac is added, through the Mac's own daemon, and takes the teammates' work// started on the Mac.describe('one machine: a Mac and its Harness Team account', () => {+ it('with no GitHub App on the server, the team account is never asked to join', async () => {+ await db.machine.update({ where: { machineId: 'team-mac' }, data: { hostMachineId: 'personal-mac' } })+ try {+ const idle = new SuperTabStore(db, Date.now, null, { teamAccountsIdle: true })+ const tab = (await idle.create(owner, randomUUID(), 'No app')).id+ const invitation = await idle.execute(owner, tab, { operationId: randomUUID(), command: { type: 'invite.create', email: person.email, role: 'collaborator', conversationId: 'lead' } })+ await idle.execute(person, tab, { operationId: randomUUID(), command: { type: 'invite.accept', inviteId: invitation.result.inviteId as string } })+ await idle.execute(person, tab, { operationId: randomUUID(), command: { type: 'machine.contribute', machineId: 'personal-mac', name: 'MacBook Pro', cwd: '/work',+ scope: 'swarm', engines: ['codex'], maxAgents: 3 } })+ expect((await idle.hostTabs(person, 'personal-mac')).some(r => r.tabId === tab && 'joinTeam' in r)).toBe(false)+ // The same Swarm on a server with the app asks the Mac's host to add it.+ expect((await store.hostTabs(person, 'personal-mac')).some(r => r.tabId === tab && 'joinTeam' in r)).toBe(true)+ } finally {+ await db.machine.update({ where: { machineId: 'team-mac' }, data: { hostMachineId: null } })+ }+ })+it('the Mac\'s host adds its team account, which then takes the owner\'s project started on the Mac', async () => {await db.machine.update({ where: { machineId: 'team-mac' }, data: { hostMachineId: 'personal-mac' } })try {diff --git a/backend/src/routes/superTabs.ts b/backend/src/routes/superTabs.tsindex 2b62f44c4..aa88c505b 100644--- a/backend/src/routes/superTabs.ts+++ b/backend/src/routes/superTabs.ts@@ -66,7 +66,9 @@ export async function superTabRoutes(app: FastifyInstance, options: { store?: Suconst github = options.github !== undefined ? options.github : await githubTokensFromEnv(env)// A task that ends revokes the token it was given; a revoke that fails is logged inside and never blocks the write.const store = options.store ?? new SuperTabStore(prisma, Date.now, attachmentsFromEnv(env),- { workEnded: (tabId, ended) => { void github?.release(tabId, ended).catch(error => logger.warn('[github] release failed', { tabId, error: String(error) })) } })+ { workEnded: (tabId, ended) => { void github?.release(tabId, ended).catch(error => logger.warn('[github] release failed', { tabId, error: String(error) })) },+ // A team account has no git login of its own: without the app it takes no teammates' work.+ teamAccountsIdle: !github })app.get('/api/super-tabs/grids', (req, reply) => respond(reply, () => store.hostGrids(req.user!)))// Each row says whether this server has the Harness GitHub App, so the host knows to ask for a start's token below.app.get<{ Params: z.infer<typeof hostParams> }>('/api/super-tabs/hosts/:machineId/pools', { preHandler: validateParams(hostParams) },diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.tsindex 7d98debe0..78bce7d74 100644--- a/backend/src/superTabs/commands.ts+++ b/backend/src/superTabs/commands.ts@@ -223,6 +223,9 @@ export interface CommandContext {/** The tab's contributed machines whose account row is signed in as a Harness Team account (`Machine.sessionKind`),* read by the store for the commands that start, assign or route work (machines.ts teamWorkCheck). */teamMachines?: string[]+ /** No Harness GitHub App on this server (routes/superTabs.ts): a Mac's Harness Team account has no git login to fetch or+ * push with, so starts on the Mac stay with the Mac, as before team accounts (machines.ts teamMachineFor). */+ teamAccountsIdle?: boolean}/** Messages in a row between the Lead and its worker after which the Lead's message is no longer delivered automatically. */@@ -518,7 +521,7 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Commaconst member = candidate.kind === 'member' ? state.agents.find(a => a.id === candidate.agentId) : undefinedif (candidate.kind === 'member' && !member) return null// A new agent on a Mac for a teammate's project runs in the Mac's Harness Team account (machines.ts teamStartRequest).- const machineId = member?.machineId ?? teamMachineFor(state, candidate.machineId, project)+ const machineId = member?.machineId ?? teamMachineFor(state, candidate.machineId, project, context.teamAccountsIdle)const contributor = member?.contributorId ?? state.machines?.find(m => m.machineId === machineId)?.contributorId ?? starterreturn teamWorkCheck(state, machineId, contributor, project, context.now, context.teamMachines)}@@ -1032,7 +1035,7 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Commafail('STARTS_PENDING', 'Reconcile pending agent starts before adding more.')}// A teammate's project started on a Mac runs in that Mac's Harness Team account, never as its owner (machines.ts).- const request = teamStartRequest(state, command.request, home)+ const request = teamStartRequest(state, command.request, home, context.teamAccountsIdle)const pool = admitMachineStart(state, request, context.now, undefined, context.teamMachines)// Off the Machines list, a teammate's project never runs: nothing there shows a privacy check (machines.ts).if (!pool) requireTeamWork(state, request.machineId, grant.contributorId, home, context.now, context.teamMachines)diff --git a/backend/src/superTabs/machines.ts b/backend/src/superTabs/machines.tsindex caf95fce1..a1a75bd62 100644--- a/backend/src/superTabs/machines.ts+++ b/backend/src/superTabs/machines.ts@@ -205,7 +205,9 @@ export function teamPoolOf(state: SuperTabState, pool: ContributedMachine): Cont/** Where a new agent for [project] runs when a start names [machineId]: the Mac's team account when the project is not* its contributor's own and the Mac has one in this Swarm, else the machine named. */-export function teamMachineFor(state: SuperTabState, machineId: string, project: SwarmProject): string {+export function teamMachineFor(state: SuperTabState, machineId: string, project: SwarmProject, idle = false): string {+ // With no GitHub App on this server a team account cannot fetch or push, so the work stays on the Mac, as before.+ if (idle) return machineIdconst pool = state.machines?.find(m => m.machineId === machineId)if (!pool || project.ownerId === pool.contributorId) return machineIdreturn teamPoolOf(state, pool)?.machineId ?? machineId@@ -223,8 +225,8 @@ export function projectFolder(pool: ContributedMachine, project: SwarmProject):* place of the Mac's own for that project. Every other start is returned as it is, so the Mac's owner's own projects* stay with the owner's daemon, and a Mac without a team account here refuses it as before (teamWorkCheck).*/-export function teamStartRequest(state: SuperTabState, request: AgentStartRequest, project: SwarmProject): AgentStartRequest {- const machineId = teamMachineFor(state, request.machineId, project)+export function teamStartRequest(state: SuperTabState, request: AgentStartRequest, project: SwarmProject, idle = false): AgentStartRequest {+ const machineId = teamMachineFor(state, request.machineId, project, idle)if (machineId === request.machineId) return requestconst pool = state.machines!.find(m => m.machineId === request.machineId)!, team = state.machines!.find(m => m.machineId === machineId)!return { ...request, machineId, cwd: request.cwd === projectFolder(pool, project) ? projectFolder(team, project) : request.cwd }diff --git a/backend/src/superTabs/store.ts b/backend/src/superTabs/store.tsindex 67d10c6a1..80fb8b073 100644--- a/backend/src/superTabs/store.ts+++ b/backend/src/superTabs/store.ts@@ -119,6 +119,9 @@ export interface SuperTabStoreHooks {/** Tasks that stopped being in an agent's hands with this write (github/holds.ts): done, cancelled, stopped, given to* another attempt, or their agent removed. Called after the write commits; it must not throw. */workEnded?: (tabId: string, ended: WorkHold[]) => void+ /** No Harness GitHub App on this server: a Mac's Harness Team account joins no Swarm and takes no teammates' work, since+ * it has no git login to fetch or push with (commands.ts `teamAccountsIdle`). */+ teamAccountsIdle?: boolean}/** Persistent coordination. Host adapters own execution and must confirm their local session grants. */@@ -599,7 +602,10 @@ export class SuperTabStore {if (command.type === 'mention.done') context.mention = await readMention(tx, tabId, command.mentionId)if (command.type === 'message.send' && command.attachmentIds?.length) context.attachments = await this.sendable(tx, tabId, actor, command)if (command.type === 'route.record') context.recentRoutes = await recentRoutes(tx, tabId, context.now)- if (TEAM_WORK_COMMANDS.has(command.type)) context.teamMachines = await this.teamMachines(tx, original)+ if (TEAM_WORK_COMMANDS.has(command.type)) {+ context.teamMachines = await this.teamMachines(tx, original)+ if (this.hooks.teamAccountsIdle) context.teamAccountsIdle = true+ }if (command.type === 'agent.screen' || command.type === 'agent.input') {// A machine that is gone or no longer shared refuses at once instead of leaving the request to time out.await this.agentGrant(tx, original, agent(original, command.agentId))@@ -1290,7 +1296,7 @@ export class SuperTabStore {const cleaning = await tx.superTab.findMany({ where: { autonomousEnv: user.autonomousEnv, cleanupMachineIds: { has: machineId },id: { notIn: rows.map(r => r.id) } } })// This Mac's Harness Team account, which joins wherever this Mac is added (machines.ts): asked of the owner's own daemon only.- const teams = isTeamSession(user) ? [] : await tx.machine.findMany({ where: { userId: user.sub, hostMachineId: machineId, sessionKind: 'team',+ const teams = isTeamSession(user) || this.hooks.teamAccountsIdle ? [] : await tx.machine.findMany({ where: { userId: user.sub, hostMachineId: machineId, sessionKind: 'team',autonomousEnv: user.autonomousEnv, ...machineAlive }, select: { machineId: true } })const result = []for (const row of rows) {diff --git a/backend/src/superTabs/teamRouting.test.ts b/backend/src/superTabs/teamRouting.test.tsindex 451ee6f1f..77941405b 100644--- a/backend/src/superTabs/teamRouting.test.ts+++ b/backend/src/superTabs/teamRouting.test.ts@@ -407,6 +407,14 @@ describe('one machine: a Mac and its Harness Team account', () => {expect(f.state.starts![0]!.request).toMatchObject({ machineId: 'mate-mac', cwd: `/swarm/${f.mine}` })})+ it('with no GitHub App on the server, sends nothing to the team account: the Mac takes the start as before', () => {+ // Until a team account is required everywhere: a team account with no git login of its own cannot fetch or push.+ delete process.env.SWARM_TEAM_ACCOUNT_REQUIRED+ const f = oneMachine(), group = f.group()+ f.run({ type: 'agent.start', request: f.request(group, 'mate-mac') }, owner, { ...f.pooled('mate-mac'), teamAccountsIdle: true })+ expect(f.state.starts![0]!.request).toMatchObject({ machineId: 'mate-mac', cwd: '/swarm/lead' })+ })+it('still takes a start that names the team account\'s machine directly', () => {const f = oneMachine(), group = f.group()f.run({ type: 'agent.start', request: { ...f.request(group, 'mate-team'), cwd: '/team-swarm/lead' } }, owner, f.pooled('mate-team'))diff --git a/cli/src/gateway/start.ts b/cli/src/gateway/start.tsindex 920c9ae10..8a9e6ed16 100644--- a/cli/src/gateway/start.ts+++ b/cli/src/gateway/start.ts@@ -32,7 +32,7 @@ import { b64d, b64e, fingerprint } from '../lib/e2ee/core.js'import { DeviceLogStore } from '../lib/e2ee/deviceLogStore.js'import { DeviceLogSyncer, type DeviceKeysSeen, type DeviceLogFetched, type DeviceLogTrustOutcome } from '../lib/e2ee/deviceLogSyncer.js'import { GroupSyncer, relayRequester, SELF_STAMP } from '../lib/e2ee/groupSyncer.js'-import { MachineKinds } from '../lib/e2ee/machineKinds.js'+import { MACHINE_KINDS_READ_TIMEOUT_MS, MachineKinds } from '../lib/e2ee/machineKinds.js'import { MachinePeerStore } from '../lib/e2ee/machinePeers.js'import { applySharedTrust, isSharedKey } from './sharedTrust.js'import { E2eeStore } from '../lib/e2ee/store.js'@@ -133,9 +133,11 @@ export function startGateway(host: GatewayHost): StartedGateway {let account = host.accountlet reachable: Set<string> | null = null// Which of the account's machines are team machines, whose rosters the trust group never takes (lib/e2ee/machineKinds.ts).+ // Its own read, apart from the machine list the apps get: it changes neither that list nor which machines are reachable,+ // and a backend that hangs holds a roster round up for seconds, not the proxy's whole bound.const machineKinds = new MachineKinds({read: async () => {- const answer = await accountHttp.machines()+ const answer = await accountHttp.backend('GET', '/api/machines', undefined, MACHINE_KINDS_READ_TIMEOUT_MS)return answer.status === 200 && account.machineId ? answer.body : null},})diff --git a/cli/src/lib/e2ee/machineKinds.ts b/cli/src/lib/e2ee/machineKinds.tsindex 856ef4a17..f4a313a95 100644--- a/cli/src/lib/e2ee/machineKinds.ts+++ b/cli/src/lib/e2ee/machineKinds.ts@@ -22,6 +22,8 @@ export type MachineKind = 'team' | 'computer'/** A list is read again before a round once it is this old. */export const MACHINE_KINDS_REFRESH_MS = 60_000+/** How long a read of the list may take before a roster round goes on without it. */+export const MACHINE_KINDS_READ_TIMEOUT_MS = 5_000/** Past this, a list says nothing: a machine converted to team work since must not still count as the person's own. */export const MACHINE_KINDS_MAX_AGE_MS = 15 * 60_000diff --git a/cli/src/superTabs/routeCommand.spec.ts b/cli/src/superTabs/routeCommand.spec.tsindex a76996a07..cdc7bf36d 100644--- a/cli/src/superTabs/routeCommand.spec.ts+++ b/cli/src/superTabs/routeCommand.spec.ts@@ -833,6 +833,12 @@ describe('routing contributed capacity', () => {expect(excluded.some(e => e.reason === NO_ACCOUNT)).toBe(false)})+ it('offers a team account whose Mac is not in the Swarm as itself, folded into nothing', async () => {+ // Probed for new agents under its own name (here outranked on quota by the Lead's own machine), not left out as folded.+ const { excluded } = await route('owner', [{ ...team(), hostMachineId: 'm-elsewhere' }])+ expect(excluded).toEqual(expect.arrayContaining([expect.objectContaining({ title: 'New agent · Claude opus high · MacBook Pro' })]))+ })+it('a machines rule naming the Mac allows its team account', async () => {const rules = [{ id: 'r1', projectId: 'lead', rule: { kind: 'machines', machineIds: ['m1'] }, text: 'Only the MacBook Pro.' }]expect((await route('owner', undefined, rules)).answer).toMatchObject({ ok: true, pick: { machineId: 'm1-team' } })diff --git a/cli/src/team/engines.ts b/cli/src/team/engines.tsindex d96a6df54..9499d821f 100644--- a/cli/src/team/engines.ts+++ b/cli/src/team/engines.ts@@ -120,7 +120,8 @@ export class TeamEngineReporter {export function teamEngineReporter(): TeamEngineReporter {return new TeamEngineReporter({- config: () => readTeamConfig(),+ // Only a Mac has a Harness Team account: elsewhere nothing is read.+ config: () => process.platform === 'darwin' ? readTeamConfig() : null,user: () => userInfo().username,check: (config) => checkTeamEngines(realEngineCheckDeps(config.home)),read: (path) => readTeamStatus(path),diff --git a/docs/plans/2026-10-24-swarm-team-account.md b/docs/plans/2026-10-24-swarm-team-account.mdindex 3d5f88515..96fd6335e 100644--- a/docs/plans/2026-10-24-swarm-team-account.md+++ b/docs/plans/2026-10-24-swarm-team-account.md@@ -84,6 +84,7 @@ How it works (`backend/src/superTabs/machines.ts`, `teamWorkCheck`):- **Routing.** The tab read gives each machine `teamWork`: `{ allowed: true }`, or `{ allowed: false, code, reason }`. The CLI's route leaves those machines out for a teammate's project and lists the reason in `excluded[]`. The backend does the same with any candidate an older CLI still sends, and refuses a pick there ("… Route again.").- **Migration.** Nothing is stopped. Agents already running on personal machines keep their current task, its reports, messages and their sessions. New starts, new assignments and new Reviewer groups for another person's project follow the rule. A personal machine contributed with scope "swarm" now serves only its owner's projects. So does a machine contributed before projects (no scope) by someone other than the Swarm's owner: the Swarm's first project is the owner's.- **Switch.** The backend shipped (1.3.28) before the CLI that makes team accounts. So the rule is held to every machine only with `SWARM_TEAM_ACCOUNT_REQUIRED=1` (`machines.ts` `teamAccountRequired`). Until then, a machine without a team account takes a teammate's work as it did before, and a machine with one already follows the rule. Turn it on with the CLI and Desktop release that makes team accounts.+- **GitHub App first.** A team account has no git login, so it can fetch and push only with the Harness GitHub App. Until the server has the app (`docs/swarm-github-app.md`), a team account joins no Swarm and takes no teammates' work, and starts on its Mac stay with the Mac (`teamAccountsIdle`). Configure the app before turning `SWARM_TEAM_ACCOUNT_REQUIRED` on, or teammates' work has nowhere to run.## Task 4: Harness GitHub App (backend, CLI)