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.

Merge remote-tracking branch 'origin/main' into feat/web

Dev jacob28ce145d3a7a
diff --cc cli/src/authCommand.spec.ts
index 75d883212,151b30ad1..1ab64857e
--- a/cli/src/authCommand.spec.ts
+++ b/cli/src/authCommand.spec.ts
@@@ -333,53 -509,6 +509,53 @@@ describe('harness login --json', () =>
expect(lines).toEqual([{ type: 'result', status: 'error', code: 'BACKEND_ERROR', message: expect.any(String) }])
})
+ it('names the account the person chose and the surface that asked, and nothing it was not told', async () => {
+ // `--google` / `--apple` are what the app's two buttons and the terminal picker send; a client
+ // that predates them sends neither and still gets the sign-in page's own chooser. The surface
+ // is the auth-service client the sign-in is made as: the terminal's, or the desktop app's.
+ for (const [flags, expected] of [
+ [['--google'], { provider: 'google', clientId: 'harness-cli' }],
+ [['--apple', '--entry-point=desktop'], { provider: 'apple', clientId: 'harness-desktop' }],
+ [[], { provider: undefined, clientId: 'harness-cli' }],
+ ] as const) {
+ let body: Record<string, unknown> = {}
+ const { base } = await fakeBackend({
+ authorizeNative: (sent) => { body = sent; return { authorizeUrl: 'https://sso.example.test/authorize?tx=abc', tx: 'tx_abc' } },
+ })
+ const login = jsonChild(tempRoot(), base, ['login', '--force', ...flags, '--json'])
+ const page = await login.next()
+ expect(page).toMatchObject({ type: 'authorize_url' })
+ // This backend's page does not name the account (one from before `provider`): the page the
+ // browser is sent to names it all the same.
+ expect(new URL(String(page.url)).searchParams.get('provider')).toBe(expected.provider ?? null)
+ expect(body.provider).toBe(expected.provider)
+ expect(body.clientId).toBe(expected.clientId)
+ login.child.kill()
+ await login.exit
+ }
+ }, 30_000)
+
+ it('keeps the client the backend exchanged as — not the one it asked for — with the session', async () => {
+ // A refresh has to name the client the tokens were issued to. A backend from before the
+ // clients were split exchanges as its configured one and names none: the session keeps none.
+ for (const [answered, kept] of [['harness-cli', 'harness-cli'], [undefined, undefined], ['someone-else', undefined]] as const) {
+ const root = tempRoot()
+ let redirectUri = ''
+ const { base } = await fakeBackend({
+ authorizeNative: (body) => { redirectUri = body.redirectUri; return { authorizeUrl: 'https://sso.example.test/authorize?tx=abc', tx: 'tx_abc' } },
+ exchange: () => ({ token: 'tok_new', refreshToken: 'refresh_new', expiresIn: 3600, autonomousEnv: 'prod', ...(answered ? { clientId: answered } : {}) }),
+ resolveComputer: () => ({ machine: { machineId: 'm_new' } }),
+ })
+ const login = jsonChild(root, base, ['login', '--google', '--json'])
+ expect(await login.next()).toMatchObject({ type: 'authorize_url' })
+ await fetch(`${redirectUri}?code=code_123&state=state_456`)
- expect(await login.next()).toEqual({ type: 'result', status: 'success' })
++ expect(await login.next()).toMatchObject({ type: 'result', status: 'success' })
+ await login.exit
+ const session = JSON.parse(readFileSync(join(root, 'auth', 'session.json'), 'utf8')) as Record<string, unknown>
+ expect(session.clientId).toBe(kept)
+ }
+ }, 45_000)
+
it('drives the full loopback flow: emits authorize_url, then a success result once the callback lands', async () => {
const root = tempRoot()
let capturedRedirectUri = ''
diff --cc cli/src/cli.ts
index 7fd4b23f3,23a5b81b6..967eeea1d
--- a/cli/src/cli.ts
+++ b/cli/src/cli.ts
@@@ -66,7 -67,7 +67,7 @@@ import { ensureTmuxOnPath } from './lib
import { flashCommand } from './lib/flash.js'
import { readOrMintComputerId } from './lib/computerIdentity.js'
import { awaitLoginCallback, extractCallbackParams, LOGIN_TIMEOUT_MESSAGE } from './lib/loginCallback.js'
- import { AuthSessionError, AuthSessionManager, clearAuthSession, knownSsoClientId, readAuthSession, ssoClientIdFor, writeAuthSession, type AuthSession } from './lib/authSession.js'
-import { AUTH_DIR, AuthSessionError, AuthSessionManager, clearAuthSession, readAuthSession, writeAuthSession, type AuthSession } from './lib/authSession.js'
++import { AUTH_DIR, AuthSessionError, AuthSessionManager, clearAuthSession, knownSsoClientId, readAuthSession, ssoClientIdFor, writeAuthSession, type AuthSession } from './lib/authSession.js'
import { LocalPresence, PAIR_HARNESS_DSH, ZooTurnCounter, ZooTurnReporter } from './lib/zooTurns.js'
import { ZooLessonReporter } from './lib/zooLessons.js'
import { DAEMONS_OFF, DAEMONS_OFF_DETAIL, DaemonsSwitch, localKillSwitch, zooPassthrough, type ZooRead } from './lib/daemonsSwitch.js'
@@@ -814,15 -851,22 +852,23 @@@ async function loginCommand
// browser — and never as a side effect of signing in to Harness.
const succeed = async (alreadySignedIn: boolean, email?: string): Promise<SignInOutcome> => {
if (opts.chained) return { signedIn: true, alreadySignedIn }
- if (json) emit(alreadySignedIn ? { type: 'result', status: 'success', alreadySignedIn: true } : { type: 'result', status: 'success', ...(email ? { email } : {}) })
- else if (alreadySignedIn) console.log('\n ✓ Already signed in. Run `harness start` to connect this computer.\n')
- else console.log(`\n ✓ Signed in${email ? ` as ${email}` : ''}. Run \`harness start\` to connect this computer.\n`)
+ // The key code is what the person compares on their other devices, so it is said at the moment the
+ // machine joins them. Left out when it cannot be computed: the line is then exactly what it was.
+ const fp = thisDeviceFingerprint(true)
+ const device = fp ? ` · ${fp}` : ''
+ if (json) emit(alreadySignedIn ? { type: 'result', status: 'success', alreadySignedIn: true, ...(fp ? { fingerprint: fp } : {}) } : { type: 'result', status: 'success', ...(email ? { email } : {}), ...(fp ? { fingerprint: fp } : {}) })
+ else {
+ const hint = ' Run `harness start` to connect this computer.'
+ if (!fp) console.log(alreadySignedIn ? '\n ✓ Already signed in. Run `harness start` to connect this computer.\n' : `\n ✓ Signed in${email ? ` as ${email}` : ''}. Run \`harness start\` to connect this computer.\n`)
+ else if (alreadySignedIn) console.log(`\n ✓ Already signed in — this machine is "${thisDeviceLabel()}"${device}\n${hint}\n`)
+ else console.log(`\n ✓ Signed in${email ? ` as ${email}` : ''} — this machine joins your devices as "${thisDeviceLabel()}"${device}\n${hint}\n`)
+ }
return { signedIn: true, alreadySignedIn }
}
- // SSO in the browser, or a QR the phone scans. Asked only of a person at a terminal with no flag; a
- // client driving --json says `--qr` or gets the browser, as before.
- let method: 'sso' | 'qr' = opts.method === 'qr' ? 'qr' : 'sso'
+ // Google or Apple in the browser, or a QR the phone scans. Asked only of a person at a terminal
+ // with no flag. Nothing named — a client driving --json that predates the flags, a pipe — is the
+ // browser still, on the sign-in page's own chooser.
+ let method: SignInMethod | undefined = opts.method === 'ask' ? undefined : opts.method
// The app driving --json: its answers, and its going away. A sign-in it left behind (the app quit
// or restarted) would otherwise wait on — minutes, holding the daemon spawn lock — and the app's
// next sign-in would sit behind it with nothing on screen. So while it waits on a person it takes
diff --cc desktop/pubspec.yaml
index 6c7216e42,fa3799b98..822cd3b1f
--- a/desktop/pubspec.yaml
+++ b/desktop/pubspec.yaml
@@@ -147,9 -147,8 +147,10 @@@ flutter
- assets/models.png
- assets/model-icons/
- assets/octicons/
+ # The marks on the login screen's two buttons (`widgets/sign_in_provider_button.dart`).
+ - assets/sign-in/
- assets/harness_device_studio.jpg
+ - assets/devices/
- assets/harness_store_card.jpg
- assets/swarm-wallpapers/