oficina / equipo Public

Connections: recover by signing in; drop "at this machine"

A token row's Sign in again and the renewal line (now "Sign in again")
start the sign-in by a link, its card offering Paste a token you
already have second, as on the Add page; the rejected row says "This
token was rejected." alone.

"I am at this machine" was unreachable from the app: the form no
longer reads same_machine, the API refuses it, and the runner's
loopback sign-in, the link prompt kind and card, the fake's loopback
and their copy are gone. The wire fields stay because every connect
frame an older instance sends carries same_machine and the runner
parses strictly; the runner ignores it and signs Claude in by a link.

New tests failed first and their mutations go red; recorded in the
controller report.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 22f6e21ddefa67782d3640847712248cf658bb93 parent d9cc4a8
16 files changed, +199 −245
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +23 −0
  • docs/superpowers/specs/2026-11-08-equipo-connections.md +5 −2
  • internal/equipo/chat/connections.go +6 −7
  • internal/equipo/chat_connections.go +5 −6
  • internal/equipo/connections_view.go +5 −4
  • internal/equipo/copy.go +1 −5
  • internal/equipo/templates/models.html +2 −8
  • internal/fakeclaude/fake.go +2 −40
  • internal/headless/browser_token_test.go +20 −16
  • internal/headless/connections_test.go +17 −24
  • internal/runner/connect/login.go +0 −94
  • internal/runner/thin/connector.go +11 −25
  • internal/runner/thin/signin_test.go +19 −0
  • internal/runner/thin/token.go +7 −7
  • internal/thintest/signin_contract_test.go +67 −0
  • internal/wire/connections.go +9 −7

CI passed — run details

diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index d7652eae..7db34810 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -5343,6 +5343,7 @@ records remain unchanged.
| `chat.connections.code_failed` | That did not go through. Paste the code again. | Claude sign-in by a link (Connections page, sign-in card) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `chat.connections.code_no_key` | Your runner needs an update before it can take a code. | Claude sign-in by a link (Connections page, sign-in card) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `chat.connections.waiting_code` | Your runner is finishing the sign-in… | Claude sign-in by a link (Connections page, sign-in card) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
+| `chat.connections.token_rejected_row` | This token was rejected. | Claude sign-in by a link (Connections page, a rejected token row; its Sign in again is the sign-in by a link) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `work.merge_now` | Merge | Thin v1 slice 4c review round 2 (task card and page) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `work.step` | %s, attempt %d: %s | Thin v1 slice 4 review and checks (task card, task and Tasks pages, sidebar) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `work.steps` | Steps | Thin v1 slice 4 review and checks (task card, task and Tasks pages, sidebar) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
@@ -6471,6 +6472,28 @@ thin package, `./internal/thintest -run 'Connection|SignIn|Token|Add'`,
`./internal/headless -run 'TestHeadlessConnections$|TestHeadlessToken|TestHeadlessClaudeSignIn'`
and the connection browser tests (`-tags browser`).
+### Follow-ups: recovery signs in, "at this machine" dropped
+
+- A token row's Sign in again and the renewal line (now "Sign in
+ again", replacing "Paste a new token") start the sign-in by a link;
+ its card offers Paste a token you already have second, as on the Add
+ page. The rejected row says "This token was rejected." (the paste
+ attempt's ended note keeps "Run claude setup-token again").
+- "I am at this machine" is dropped end to end: the form no longer
+ reads `same_machine`, the API refuses `same_machine: true` (422), the
+ runner's loopback sign-in (`ClaudeLoopbackLogin`, `LoopbackURL`), the
+ `link` prompt kind and card, the fake's loopback and their copy are
+ gone. The wire fields stay: `ConnectCommand.same_machine` has no
+ omitempty, so every connect frame an older instance sends carries it,
+ and the runner parses frames strictly; the runner ignores it.
+
+| Guard | Mutation | Test | Result |
+|---|---|---|---|
+| Row recovers by sign-in | token kind on Sign in again | `TestContractTokenRecoverySignsIn` | red (red first before the change) |
+| Renewal by sign-in | token kind on the renewal | `TestContractTokenRecoverySignsIn` | red |
+| `same_machine` refused | accept it | `TestContractSameMachineRefused` | red (red first) |
+| Runner ignores `same_machine` | route it elsewhere | `TestSignInIgnoresSameMachine` | red (red first) |
+
### To confirm on the first live use
What CLI 2.1.312 prints after a right code (the runner takes the first
diff --git a/docs/superpowers/specs/2026-11-08-equipo-connections.md b/docs/superpowers/specs/2026-11-08-equipo-connections.md
index a8f35fcc..ffe934e4 100644
--- a/docs/superpowers/specs/2026-11-08-equipo-connections.md
+++ b/docs/superpowers/specs/2026-11-08-equipo-connections.md
@@ -583,7 +583,10 @@ give to the browser? We're trying to avoid the round-trip over SSH
here." Ruling: the one-time sign-in code is relayed through Equipo,
sealed, the same category of risk accepted for the pasted token. This
replaces §2.3 case 2's terminal card (and its watcher) as the way to
-add Claude with the browser elsewhere. The runner runs the unmodified
+add Claude with the browser elsewhere, and case 1's loopback sign-in
+"at this machine" too: the app refuses `same_machine` and the runner
+ignores it. A token row's Sign in again and the renewal line start
+this sign-in, the paste offered second. The runner runs the unmodified
`claude setup-token` itself, on a pseudo-terminal in the connection's
new home with the login environment and `BROWSER` a program that opens
nothing, and reads the authorize URL it prints (through ANSI and OSC 8
@@ -701,7 +704,7 @@ sources in §1:
|---|---|---|---|---|
| Codex (ChatGPT plan) | Device code via `account/login/start` | No | Runner, by the app-server polling OpenAI | Runner home (`auth.json`) |
| Codex (API key) | Sealed key | No | n/a | Runner home |
-| Claude (subscription), browser on runner's machine | CLI's own loopback OAuth, app shows the link | No | Runner, by the CLI | Runner home (`.credentials.json`, or Keychain on a Mac) |
+| Claude (subscription), browser on runner's machine | Removed 2026-11-10: the same sign-in by a link as below | n/a | n/a | n/a |
| Claude (subscription), runner remote | The runner's own `claude setup-token`; the app shows its link (as built 2026-11-10, §2.4) | Yes, the code, sealed to the runner and typed into the CLI | Runner, by the CLI | Runner home (`.oauth-token`) |
| Claude (`setup-token`) | A pasted token, sealed to the runner (as built 2026-11-09, §2.4) | Yes, sealed | n/a | Runner home (`.oauth-token`) |
| Claude (API key) | Sealed key | No | n/a | Runner home |
diff --git a/internal/equipo/chat/connections.go b/internal/equipo/chat/connections.go
index ed937045..254a755e 100644
--- a/internal/equipo/chat/connections.go
+++ b/internal/equipo/chat/connections.go
@@ -425,17 +425,16 @@ func (s *Store) Connection(ctx context.Context, person, id string) (out wire.Con
}
// StartConnection starts a connection attempt on the person's runner (spec §2.1):
-// a Codex account by device code; a Claude account by the CLI's own
-// sign-in, finished at the runner's machine (loopback, no paste) or, when
-// the person's browser is elsewhere, by the runner's own `claude
-// setup-token` whose sign-in code the page seals to the runner
+// a Codex account by device code; a Claude account by the runner's own
+// `claude setup-token`, whose sign-in code the page seals to the runner
// (wire.PromptAuthorize, SendSecret); or a Claude account from a pasted
-// setup token (kind token), sealed the same way. Nothing the instance
+// setup token (kind token), sealed the same way. The sign-in finished at
+// the runner's machine (same_machine) is gone and refused. Nothing the instance
// can read passes through it either way. A second attempt for the same
// provider while one is connecting returns that one.
func (s *Store) StartConnection(ctx context.Context, person string, in wire.Connect) (out wire.Connection, err error) {
token := in.Kind == wire.KindToken
- if in.Provider != wire.ProviderClaude && in.Provider != wire.ProviderCodex || in.Kind != "" && in.Kind != wire.KindSubscription && !token || token && (in.Provider != wire.ProviderClaude || in.SameMachine) {
+ if in.Provider != wire.ProviderClaude && in.Provider != wire.ProviderCodex || in.Kind != "" && in.Kind != wire.KindSubscription && !token || token && in.Provider != wire.ProviderClaude || in.SameMachine {
return out, ErrInvalid
}
err = s.tx(ctx, func(t *txn) error {
@@ -466,7 +465,7 @@ func (s *Store) StartConnection(ctx context.Context, person string, in wire.Conn
if token {
// The token card: run the command anywhere, approve, paste.
r.Kind, r.Prompt = wire.KindToken, asJSON(wire.ConnectPrompt{Kind: wire.PromptToken, Code: "claude setup-token"})
- } else if in.Provider == wire.ProviderClaude && !in.SameMachine {
+ } else if in.Provider == wire.ProviderClaude {
// Claude with no terminal: the runner starts setup-token and
// reports its link; until then the card says it is starting.
r.Prompt = asJSON(wire.ConnectPrompt{Kind: wire.PromptAuthorize})
diff --git a/internal/equipo/chat_connections.go b/internal/equipo/chat_connections.go
index f5a26614..2e90e5eb 100644
--- a/internal/equipo/chat_connections.go
+++ b/internal/equipo/chat_connections.go
@@ -236,19 +236,18 @@ func (a *application) connectionsPageFor(w http.ResponseWriter, r *http.Request,
// a pasted token) and a row's Sign in again or Paste a new token.
func (a *application) connectionsStart(w http.ResponseWriter, r *http.Request) {
a.chatActionTo(w, r, "/conversation/settings/connections/add", func(ctx context.Context, address string) error {
- provider, same := r.PostFormValue("provider"), r.PostFormValue("same_machine") == "1"
- kind := wire.KindSubscription
- if r.PostFormValue("kind") == wire.KindToken && !same {
+ provider, kind := r.PostFormValue("provider"), wire.KindSubscription
+ if r.PostFormValue("kind") == wire.KindToken {
kind = wire.KindToken
}
// The card open gives way to the other way of connecting: the
- // sign-in by a link, a token, or the sign-in at this machine.
+ // sign-in by a link, or a token.
conns, err := a.store.Chat().Connections(ctx, address)
if err != nil {
return err
}
for _, c := range conns {
- if c.State == wire.ConnConnecting && c.Provider == provider && (same || c.Kind != kind) {
+ if c.State == wire.ConnConnecting && c.Provider == provider && c.Kind != kind {
// Switching is not giving up: the ended card goes unsaid.
if _, err := a.store.Chat().CancelConnection(ctx, address, c.ID); err != nil {
return err
@@ -258,7 +257,7 @@ func (a *application) connectionsStart(w http.ResponseWriter, r *http.Request) {
}
}
}
- _, err = a.store.Chat().StartConnection(ctx, address, wire.Connect{Provider: provider, Kind: kind, SameMachine: same})
+ _, err = a.store.Chat().StartConnection(ctx, address, wire.Connect{Provider: provider, Kind: kind})
if errors.Is(err, chat.ErrRunnerOffline) {
return nil
}
diff --git a/internal/equipo/connections_view.go b/internal/equipo/connections_view.go
index 9732c93b..96492349 100644
--- a/internal/equipo/connections_view.go
+++ b/internal/equipo/connections_view.go
@@ -201,12 +201,13 @@ func newerThan(conns []wire.Connection, c wire.Connection) bool {
return false
}
-// tokenFacts says when a pasted token expires (about when, for an
-// estimate), asks for a new one within TokenRenewal of then, and says a
-// rejected one was rejected.
+// tokenFacts says when a token expires (about when, for an estimate),
+// asks for a sign-in again within TokenRenewal of then, and says a
+// rejected one was rejected. Both recoveries are the sign-in by a link
+// first, its card offering the paste second, as on the Add page.
func tokenFacts(row *connRow, c wire.Connection, now time.Time) {
if row.State == wire.ConnSignInAgain {
- row.Words = copyText("chat.connections.token_rejected")
+ row.Words = copyText("chat.connections.token_rejected_row")
return
}
if c.ExpiresAt == nil || row.State == wire.ConnSignedOut {
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index b8914c32..c3af69d0 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -720,9 +720,6 @@ var pageCopy = map[string]string{
"chat.connections.device_off": "OpenAI says device sign-in is off? Turn it on in ChatGPT, Settings, Security.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.copy": "Copy", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.copied": "Copied", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
- "chat.connections.waiting_sign_in": "Waiting for you to sign in…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
- "chat.connections.open_claude": "Open Claude", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
- "chat.connections.claude_back": "Sign in, then come back. Equipo connects on its own.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.connected": "%s connected", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.check_again": "Check again", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.usage_today": "%s tokens today", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
@@ -785,7 +782,6 @@ var pageCopy = map[string]string{
"chat.connections.claude_sub": "Claude signs in on the machine that runs your runner.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.code_once": "Shown once. It expires in 15 minutes.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.codex_fine": "Nothing but the code OpenAI generated passes through Equipo.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
- "chat.connections.claude_fine": "The sign-in happens inside Claude Code itself. Equipo never sees the code or the token.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.connected_big": "%s is connected", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.connected_next": "Your coordinator can use it from the next message.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.empty_title": "Equipo works through the accounts you already have", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
@@ -811,8 +807,8 @@ var pageCopy = map[string]string{
"chat.connections.token_expires": "Token expires %s", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.token_expires_about": "Expires about %s", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.token_renew": "It expires soon.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
- "chat.connections.token_new": "Paste a new token", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.token_rejected": "This token was rejected. Run claude setup-token again.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "chat.connections.token_rejected_row": "This token was rejected.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.copy_link": "Copy link", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.sign_in_how": "Sign in at Anthropic", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.paste_token_instead": "Paste a token you already have", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
diff --git a/internal/equipo/templates/models.html b/internal/equipo/templates/models.html
index 8f136478..36cda1a5 100644
--- a/internal/equipo/templates/models.html
+++ b/internal/equipo/templates/models.html
@@ -35,12 +35,6 @@
{{template "conn-waiting" (copy "chat.connections.waiting_approve")}}
<p equipo-conn-small>{{copy "chat.connections.device_off"}}</p>
<div equipo-conn-card-foot><span equipo-conn-small>{{copy "chat.connections.codex_fine"}}</span>{{template "conn-cancel" .ID}}</div>
-{{else if eq .Prompt.Kind "link"}}<ol equipo-conn-steps data-sign-in-steps>
-<li><div equipo-conn-link-row><a rst-btn="primary" href="{{.Prompt.URL}}" rel="noopener" target="_blank" data-sign-in>{{icon "external-link"}}{{copy "chat.connections.open_claude"}}</a>{{template "conn-copy-link" .Prompt.URL}}</div></li>
-<li><div><p>{{copy "chat.connections.claude_back"}}</p></div></li>
-</ol>
-{{template "conn-waiting" (copy "chat.connections.waiting_sign_in")}}
-<div equipo-conn-card-foot><span equipo-conn-small>{{copy "chat.connections.claude_fine"}}</span>{{template "conn-cancel" .ID}}</div>
{{else if eq .Prompt.Kind "token"}}<ol equipo-conn-steps data-token-steps>
<li><div><p>{{copy "chat.connections.token_run"}}</p><div equipo-conn-code-row><code equipo-conn-code data-command>{{.Prompt.Code}}</code>{{template "conn-copy" .Prompt.Code}}</div></div></li>
<li><div><p>{{copy "chat.connections.token_approve"}}</p></div></li>
@@ -66,11 +60,11 @@
<div equipo-conn-body>
<p equipo-conn-head><span equipo-conn-name>{{.Name}}</span><span equipo-conn-account>{{.Label}}{{with .Plan}}, {{.}}{{end}}</span>{{if .Preferred}}<span equipo-conn-pref>{{icon "star"}}{{copy "chat.connections.preferred"}}</span>{{end}}</p>
<p equipo-conn-facts><span equipo-conn-state data-connection-state data-s="{{.State}}">{{.Words}}</span>{{with .Expires}}<span equipo-conn-expires data-token-expires>{{.}}</span>{{end}}{{range .Meters}}<span equipo-conn-meter data-level="{{.Level}}"><span equipo-conn-bar><i data-w="{{.Used}}"></i></span><span>{{.Name}} <b>{{.Used}}%</b>{{with .Resets}}, {{.}}{{end}}</span></span>{{end}}</p>
-{{if .Renew}}<div equipo-conn-renew data-token-renew>{{copy "chat.connections.token_renew"}} <form method="post" action="/conversation/connections" data-add-form equipo-inline-form><input type="hidden" name="provider" value="{{.Provider}}"><input type="hidden" name="kind" value="token"><button equipo-link type="submit" data-renew>{{copy "chat.connections.token_new"}}</button></form></div>{{end}}
+{{if .Renew}}<div equipo-conn-renew data-token-renew>{{copy "chat.connections.token_renew"}} <form method="post" action="/conversation/connections" data-add-form equipo-inline-form><input type="hidden" name="provider" value="{{.Provider}}"><button equipo-link type="submit" data-renew>{{copy "chat.connections.sign_in_again_action"}}</button></form></div>{{end}}
{{if .Roles}}<p equipo-conn-roles><span equipo-conn-roles-label>{{copy "chat.connections.serving"}}</span>{{range .Roles}}<span equipo-conn-chip{{if .Live}} data-live{{end}}>{{if .Live}}{{template "conn-star"}}{{end}}{{.Name}}</span>{{end}}</p>{{else}}{{with .RolesNote}}<p equipo-conn-roles><span equipo-conn-roles-note>{{.}}</span></p>{{end}}{{end}}
</div>
<div equipo-conn-side>
-<div equipo-conn-actions>{{if .Needs}}<form method="post" action="/conversation/connections" data-add-form equipo-inline-form><input type="hidden" name="provider" value="{{.Provider}}">{{if eq .Kind "token"}}<input type="hidden" name="kind" value="token">{{end}}<button rst-btn type="submit" data-recover="{{.Provider}}">{{.Needs}}</button></form>{{end}}{{if or .MakePreferred .SignOut .Forget .CheckAgain}}<span equipo-conn-quiet>{{template "conn-quiet" .}}</span><details equipo-conn-more><summary aria-label="{{copy "chat.connections.more"}}">{{icon "more-horizontal"}}</summary><div>{{template "conn-quiet" .}}</div></details>{{end}}</div>
+<div equipo-conn-actions>{{if .Needs}}<form method="post" action="/conversation/connections" data-add-form equipo-inline-form><input type="hidden" name="provider" value="{{.Provider}}"><button rst-btn type="submit" data-recover="{{.Provider}}">{{.Needs}}</button></form>{{end}}{{if or .MakePreferred .SignOut .Forget .CheckAgain}}<span equipo-conn-quiet>{{template "conn-quiet" .}}</span><details equipo-conn-more><summary aria-label="{{copy "chat.connections.more"}}">{{icon "more-horizontal"}}</summary><div>{{template "conn-quiet" .}}</div></details>{{end}}</div>
<p equipo-conn-usage>{{if eq .State "signed_out"}}{{printf (copy "chat.connections.tokens_before") .Usage}}{{else}}<b>{{.Usage}}</b>{{.UsageTail}}{{end}}</p>
</div>
</article>{{end}}
diff --git a/internal/fakeclaude/fake.go b/internal/fakeclaude/fake.go
index 78565041..96098506 100644
--- a/internal/fakeclaude/fake.go
+++ b/internal/fakeclaude/fake.go
@@ -88,9 +88,6 @@ import (
_ "image/jpeg" // DecodeConfig for attached JPEGs
_ "image/png" // DecodeConfig for attached PNGs
"io"
- "net"
- "net/http"
- "net/url"
"os"
"os/exec"
"path/filepath"
@@ -185,44 +182,9 @@ func authStatus(stdout io.Writer) int {
}
func authLogin() int {
+ // Signs in as FAKE_LOGIN_EMAIL (the terminal login, whose
+ // paste goes into the CLI); the loopback sign-in is gone.
email := os.Getenv("FAKE_LOGIN_EMAIL")
- if b := os.Getenv("BROWSER"); b != "" && email == "" {
- // The loopback sign-in: open the browser at the authorize page with
- // a redirect to this process, and finish on the callback. The
- // callback carries the email the "browser" signed in as.
- l, err := net.Listen("tcp", "127.0.0.1:0")
- if err != nil {
- return 1
- }
- port := l.Addr().(*net.TCPAddr).Port
- state := "fake-state"
- u := "https://claude.com/cai/oauth/authorize?code=true&client_id=fake&response_type=code&redirect_uri=" + url.QueryEscape(fmt.Sprintf("http://127.0.0.1:%d/callback", port)) + "&state=" + state
- fmt.Println("Opening browser to sign in…")
- _ = exec.Command(b, u).Run()
- fmt.Println("If the browser didn't open, visit: https://claude.com/cai/oauth/authorize?code=true&client_id=fake&redirect_uri=https%3A%2F%2Fplatform.claude.com%2Foauth%2Fcode%2Fcallback")
- got := make(chan string, 1)
- srv := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if r.URL.Path != "/callback" || r.URL.Query().Get("state") != state || r.URL.Query().Get("code") == "" {
- http.Error(w, "bad callback", 400)
- return
- }
- fmt.Fprintln(w, "Signed in. You can close this tab.")
- select {
- case got <- r.URL.Query().Get("email"):
- default:
- }
- })}
- go srv.Serve(l)
- select {
- case email = <-got:
- case <-time.After(2 * time.Minute):
- return 1
- }
- srv.Close()
- if email == "" {
- return 1
- }
- }
if email == "" {
return 1
}
diff --git a/internal/headless/browser_token_test.go b/internal/headless/browser_token_test.go
index d06ddce9..2f90f12a 100644
--- a/internal/headless/browser_token_test.go
+++ b/internal/headless/browser_token_test.go
@@ -197,29 +197,32 @@ func TestBrowserConnectionsToken(t *testing.T) {
p.check(`(()=>{window.__equipoStayed=true;return true})()`, "mark")
// Within six weeks of the estimated expiry: a quiet line asks
- // for a new one.
+ // to sign in again (the sign-in by a link first).
soon := time.Now().UTC().Add(40 * 24 * time.Hour)
runner.hello(t, wire.HeldConnection{LocalID: "claude-1", Person: thintest.Owner, Provider: "claude", Kind: wire.KindToken, Label: second, State: wire.ConnHealthy, ExpiresAt: &soon, ExpiresEstimated: true})
- p.run(waitLong(`!!document.querySelector('[data-token-renew]') && document.querySelector('[data-token-renew]').textContent.includes('It expires soon.') && document.querySelector('[data-token-renew] [data-renew]').textContent==='Paste a new token'`))
+ p.run(waitLong(`!!document.querySelector('[data-token-renew]') && document.querySelector('[data-token-renew]').textContent.includes('It expires soon.') && document.querySelector('[data-token-renew] [data-renew]').textContent==='Sign in again' && !document.querySelector('[data-token-renew] input[name="kind"]')`))
shot("token-renew")
// Rejected: sign in again, said for a token.
runner.hello(t, wire.HeldConnection{LocalID: "claude-1", Person: thintest.Owner, Provider: "claude", Kind: wire.KindToken, Label: second, State: wire.ConnSignInAgain, ExpiresAt: &soon, ExpiresEstimated: true})
- p.run(waitLong(`(()=>{const row=document.querySelector('[equipo-conn-row][data-provider="claude"][data-state="sign_in_again"]');return !!row && row.querySelector('[data-connection-state]').textContent==='This token was rejected. Run claude setup-token again.' && row.querySelector('[data-recover]').textContent==='Sign in again'})()`))
+ p.run(waitLong(`(()=>{const row=document.querySelector('[equipo-conn-row][data-provider="claude"][data-state="sign_in_again"]');return !!row && row.querySelector('[data-connection-state]').textContent==='This token was rejected.' && row.querySelector('[data-recover]').textContent==='Sign in again'})()`))
shot("token-rejected")
p.check(stayed, "the page reloaded or navigated")
- // Sign in again is a new token attempt, on the Add page.
+ // Sign in again is the sign-in by a link, on the Add page, its
+ // card offering the paste second.
p.check(`(()=>{document.querySelector('[equipo-conn-row][data-state="sign_in_again"] [data-recover]').click();return true})()`, "Sign in again")
- p.run(waitLong(`location.pathname==='/conversation/settings/connections/add' && !!document.querySelector('[data-token-form]')`))
- if cmd := runner.expect(t, wire.FrameConnect).(*wire.ConnectCommand); cmd.Kind != wire.KindToken {
- t.Fatalf("Sign in again started %+v", cmd)
+ again := runner.expect(t, wire.FrameConnect).(*wire.ConnectCommand)
+ if again.Kind != wire.KindSubscription || again.Provider != "claude" {
+ t.Fatalf("Sign in again started %+v", again)
}
+ runner.send(t, wire.FrameConnection, wire.ConnectionReport{Connection: again.Connection, Person: thintest.Owner, Provider: "claude", State: wire.ConnConnecting, Prompt: &wire.ConnectPrompt{Kind: wire.PromptAuthorize, URL: signInLinks[0], Attempt: 1}})
+ p.run(waitLong(`location.pathname==='/conversation/settings/connections/add' && !!document.querySelector('[data-code-steps] [data-open-anthropic]') && !!document.querySelector('[data-connecting] [data-paste-instead]') && !document.querySelector('[data-token-form]')`))
})
}
}
// Paul, 2026-11-09: "a 'Copy URL' in addition to open, in case I want to
-// open it in a different browser." The Codex card and the Claude link
+// open it in a different browser." The Codex card and the Claude sign-in
// card each have Copy link beside their Open button; it copies the link
// and says Copied.
func TestBrowserConnectionsCopyLink(t *testing.T) {
@@ -252,18 +255,19 @@ func TestBrowserConnectionsCopyLink(t *testing.T) {
}
runner.expect(t, wire.FrameCancelConnect)
- // Claude at this machine: the loopback link card.
- const authorize = "https://claude.ai/oauth/authorize?code=true&state=fake"
- claude, err := client.Connect(t.Context(), wire.Connect{Provider: "claude", SameMachine: true})
+ // Claude: the sign-in card, its link from the runner's own
+ // setup-token. Open Anthropic is wider than Open OpenAI: on a
+ // phone Copy link may sit under it.
+ claude, err := client.Connect(t.Context(), wire.Connect{Provider: "claude"})
if err != nil {
t.Fatal(err)
}
runner.expect(t, wire.FrameConnect)
- runner.send(t, wire.FrameConnection, wire.ConnectionReport{Connection: claude.ID, Person: thintest.Owner, Provider: "claude", State: wire.ConnConnecting, Prompt: &wire.ConnectPrompt{Kind: wire.PromptLink, URL: authorize}})
- p.run(waitLong(`!!document.querySelector('[data-sign-in-steps] [data-copy-link]')`))
- p.check(strings.ReplaceAll(besides, "%[1]s", "[data-sign-in]"), "Copy link is not beside Open Claude")
- p.check(`(()=>{document.querySelector('[data-sign-in-steps] [data-copy-link]').click();return true})()`, "Copy link")
- p.run(waitLong(`document.querySelector('[data-sign-in-steps] [data-copy-link]').textContent==='Copied' && window.__copied[1]==='` + authorize + `'`))
+ runner.send(t, wire.FrameConnection, wire.ConnectionReport{Connection: claude.ID, Person: thintest.Owner, Provider: "claude", State: wire.ConnConnecting, Prompt: &wire.ConnectPrompt{Kind: wire.PromptAuthorize, URL: signInLinks[0], Attempt: 1}})
+ p.run(waitLong(`!!document.querySelector('[data-code-steps] [data-copy-link]')`))
+ p.check(`(()=>{const open=document.querySelector('[data-open-anthropic]');const copy=open.parentElement.querySelector('[data-copy-link]');const a=open.getBoundingClientRect(),b=copy.getBoundingClientRect();return copy.textContent==='Copy link' && copy.dataset.copy===open.getAttribute('href') && (Math.abs(a.top-b.top)<4 && b.left>a.right || b.top>=a.bottom && Math.abs(a.left-b.left)<2)})()`, "Copy link is not beside Open Anthropic")
+ p.check(`(()=>{document.querySelector('[data-code-steps] [data-copy-link]').click();return true})()`, "Copy link")
+ p.run(waitLong(`document.querySelector('[data-code-steps] [data-copy-link]').textContent==='Copied' && window.__copied[1]===` + jsonString(signInLinks[0])))
connShotOn(t, p, tokenDay, "claude-copy-link", width)
p.check(stayed, "the page reloaded or navigated")
})
diff --git a/internal/headless/connections_test.go b/internal/headless/connections_test.go
index 1343eef1..97ae4986 100644
--- a/internal/headless/connections_test.go
+++ b/internal/headless/connections_test.go
@@ -4,7 +4,6 @@ import (
"crypto/rand"
"encoding/json"
"fmt"
- "net/http"
"net/url"
"os"
"path/filepath"
@@ -276,42 +275,36 @@ func connCodexDeviceCode(t *testing.T, env *Env, inst *thintest.Instance, r *loc
}
}
-// C4: a second Claude account at the runner's machine: the card links to
-// Anthropic's sign-in page, whose redirect is the CLI's own loopback
-// listener (simulated here by the browser's callback); nothing is pasted
-// anywhere. (Elsewhere, the sign-in by a link: TestHeadlessClaudeSignIn.)
+// C4: a second Claude account. "I am at this machine" is gone and
+// refused; Claude is the sign-in by a link, started on the real runner
+// (its own setup-token, the fake), whose card shows the link; cancelled,
+// the CLI goes and so does the home. (The code and the token:
+// TestHeadlessClaudeSignIn.)
func connClaudeSignIn(t *testing.T, env *Env, inst *thintest.Instance, r *localRunner) {
r.start(t)
s := open(t, env)
- c, err := env.Client.Connect(s.ctx, wire.Connect{Provider: "claude", SameMachine: true})
+ if _, err := env.Client.Connect(s.ctx, wire.Connect{Provider: "claude", SameMachine: true}); thintest.Status(err) != 422 {
+ t.Fatalf("at this machine: %v", err)
+ }
+ c, err := env.Client.Connect(s.ctx, wire.Connect{Provider: "claude"})
if err != nil {
t.Fatal(err)
}
var link wire.Connection
s.wait(t, "sign-in link", time.Minute, func(cv *thintest.Conversation) bool {
link = cv.Connections[c.ID]
- return link.Prompt != nil && link.Prompt.Kind == wire.PromptLink
+ return link.Prompt != nil && link.Prompt.Kind == wire.PromptAuthorize && link.Prompt.URL != ""
})
u, err := url.Parse(link.Prompt.URL)
- if err != nil || u.Host != "claude.com" || !strings.HasSuffix(u.Path, "/oauth/authorize") {
+ if err != nil || u.Host != "claude.com" || u.Query().Get("redirect_uri") != wire.EndpointClaudeCode {
t.Fatalf("link %q", link.Prompt.URL)
}
- // The person's browser on this machine signs in; claude.ai redirects
- // to the CLI's listener.
- cb, _ := url.Parse(u.Query().Get("redirect_uri"))
- q := cb.Query()
- q.Set("code", "fake-code")
- q.Set("state", u.Query().Get("state"))
- q.Set("email", second)
- cb.RawQuery = q.Encode()
- res, err := http.Get(cb.String())
- if err != nil || res.StatusCode != 200 {
- t.Fatalf("callback %v %v", res, err)
- }
- res.Body.Close()
- s.wait(t, "claude-2 healthy", time.Minute, func(cv *thintest.Conversation) bool {
- v := cv.Connections[c.ID]
- return v.State == wire.ConnHealthy && v.LocalID == "claude-2" && v.Label == second
+ if _, err = env.Client.CancelConnection(s.ctx, c.ID); err != nil {
+ t.Fatal(err)
+ }
+ until(t, "the attempt's home gone", func() bool {
+ _, err := os.Stat(filepath.Join(r.root, "accounts", "claude-2"))
+ return os.IsNotExist(err)
})
var _ runner.Config
}
diff --git a/internal/runner/connect/login.go b/internal/runner/connect/login.go
index 83a40cbc..d3abb86e 100644
--- a/internal/runner/connect/login.go
+++ b/internal/runner/connect/login.go
@@ -1,17 +1,13 @@
package connect
import (
- "bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/url"
- "os"
"os/exec"
- "path/filepath"
- "strings"
"syscall"
"time"
@@ -145,93 +141,3 @@ func CodexDeviceLogin(ctx context.Context, binary, home string, env []string, pr
}
}
}
-
-// claudeHosts are the sign-in pages Claude's CLI may send a browser to.
-var claudeHosts = []string{"claude.ai", "claude.com", "platform.claude.com", "console.anthropic.com"}
-
-// LoopbackURL checks a sign-in URL: Anthropic's own authorize page with a
-// redirect to the CLI's loopback listener, nothing else.
-func LoopbackURL(raw string) (string, bool) {
- u, err := url.Parse(strings.TrimSpace(raw))
- if err != nil || u.Scheme != "https" || !strings.HasSuffix(u.Path, "/oauth/authorize") {
- return "", false
- }
- host := false
- for _, h := range claudeHosts {
- host = host || u.Host == h
- }
- redirect, err := url.Parse(u.Query().Get("redirect_uri"))
- if !host || err != nil || redirect.Scheme != "http" || redirect.Hostname() != "localhost" && redirect.Hostname() != "127.0.0.1" {
- return "", false
- }
- return u.String(), true
-}
-
-// ClaudeLoopbackLogin runs the unmodified `claude auth login` in a new
-// home on a pseudo-terminal, with BROWSER set to a recorder in scratch,
-// so the runner learns the authorize URL the CLI would open (spec §2.3
-// case 1). prompt shows it; the person's browser, on this machine, signs
-// in and claude.ai redirects to the CLI's own loopback listener. Nothing
-// is ever written to the CLI: no code or token passes through Equipo.
-// It returns once the CLI exits; success is its exit status 0.
-func ClaudeLoopbackLogin(ctx context.Context, binary, home, scratch string, env []string, prompt func(signInURL string)) error {
- recorded := filepath.Join(scratch, "sign-in-url")
- browser := filepath.Join(scratch, "browser")
- script := "#!/bin/sh\nprintf '%s\\n' \"$1\" > '" + recorded + "'\n"
- if strings.ContainsRune(recorded, '\'') {
- return fmt.Errorf("scratch path")
- }
- if err := os.WriteFile(browser, []byte(script), 0700); err != nil {
- return err
- }
- master, tty, err := openPTY()
- if err != nil {
- return err
- }
- defer master.Close()
- cmd := exec.Command(binary, "auth", "login", "--claudeai")
- cmd.Dir = home
- cmd.Env = append(env, "BROWSER="+browser, "TERM=xterm-256color")
- cmd.Stdin, cmd.Stdout, cmd.Stderr = tty, tty, tty
- cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true, Setctty: true}
- if err = cmd.Start(); err != nil {
- tty.Close()
- return err
- }
- tty.Close()
- // The CLI's own output is read and dropped: only the recorded URL is used.
- go func() { _, _ = io.Copy(io.Discard, master) }()
- exited := make(chan error, 1)
- go func() { exited <- cmd.Wait() }()
- shown := false
- tick := time.NewTicker(100 * time.Millisecond)
- defer tick.Stop()
- for {
- select {
- case err := <-exited:
- if err != nil {
- return ErrRefused
- }
- return nil
- case <-ctx.Done():
- _ = unix.Kill(-cmd.Process.Pid, unix.SIGKILL)
- <-exited
- if errors.Is(ctx.Err(), context.DeadlineExceeded) {
- return ErrTimedOut
- }
- return ErrCancelled
- case <-tick.C:
- if shown {
- continue
- }
- raw, err := os.ReadFile(recorded)
- if err != nil {
- continue
- }
- if u, ok := LoopbackURL(string(bytes.TrimSpace(raw))); ok {
- shown = true
- prompt(u)
- }
- }
- }
-}
diff --git a/internal/runner/thin/connector.go b/internal/runner/thin/connector.go
index 8a7f0c96..9ea6973a 100644
--- a/internal/runner/thin/connector.go
+++ b/internal/runner/thin/connector.go
@@ -32,10 +32,9 @@ CREATE TABLE IF NOT EXISTS seen_seals (connection_id TEXT NOT NULL, attempt INTE
const ConnectLimit = 10 * time.Minute
// Connector adds connections from the app (spec §2): a Codex account by
-// device code, a Claude account by the CLI's own sign-in finished at
-// this machine (loopback, no paste), or, when the person's browser is
-// elsewhere, by the runner's own `claude setup-token` with the sign-in
-// code relayed sealed (signin.go), or from a pasted token (token.go).
+// device code, a Claude account by the runner's own `claude setup-token`
+// with the sign-in code relayed sealed (signin.go), or from a pasted
+// token (token.go).
// The provider's own CLI signs in, in a new dedicated home; the instance
// only ever sees the provider's display code or sign-in page, the
// account's email and boxes it cannot open.
@@ -443,7 +442,9 @@ func (c *Connector) run(ctx context.Context, cancel context.CancelFunc, cmd wire
c.runToken(ctx, cmd, base)
return
}
- if cmd.Provider == wire.ProviderClaude && !cmd.SameMachine {
+ // Claude signs in only by the runner's own setup-token now; a frame
+ // that still says same_machine (an older instance) is the same.
+ if cmd.Provider == wire.ProviderClaude {
c.runSignIn(ctx, cmd, base)
return
}
@@ -478,26 +479,11 @@ func (c *Connector) run(ctx context.Context, cancel context.CancelFunc, cmd wire
}
defer lock.Close()
env := provider.LoginEnvironment(cmd.Provider, home)
- var acct connect.Account
- if cmd.Provider == wire.ProviderCodex {
- acct, err = connect.CodexDeviceLogin(ctx, c.Runner.CodexPath, home, env, func(u, code string) {
- r := base
- r.State, r.Prompt = wire.ConnConnecting, &wire.ConnectPrompt{Kind: wire.PromptDeviceCode, URL: u, Code: code}
- c.report(r)
- })
- } else {
- scratch, serr := os.MkdirTemp(c.Runner.ScratchRoot, "policy-")
- if serr != nil {
- err = serr
- } else {
- err = connect.ClaudeLoopbackLogin(ctx, c.Runner.ClaudePath, home, scratch, env, func(u string) {
- r := base
- r.State, r.Prompt = wire.ConnConnecting, &wire.ConnectPrompt{Kind: wire.PromptLink, URL: u}
- c.report(r)
- })
- os.RemoveAll(scratch)
- }
- }
+ acct, err := connect.CodexDeviceLogin(ctx, c.Runner.CodexPath, home, env, func(u, code string) {
+ r := base
+ r.State, r.Prompt = wire.ConnConnecting, &wire.ConnectPrompt{Kind: wire.PromptDeviceCode, URL: u, Code: code}
+ c.report(r)
+ })
if err != nil {
c.log("connect sign-in", err)
c.removeHome(home)
diff --git a/internal/runner/thin/signin_test.go b/internal/runner/thin/signin_test.go
index 01da9ee1..ef4f6228 100644
--- a/internal/runner/thin/signin_test.go
+++ b/internal/runner/thin/signin_test.go
@@ -525,3 +525,22 @@ func TestSignInCLIDies(t *testing.T) {
t.Fatal(r.errs)
}
}
+
+// A connect frame that still says same_machine (from an instance before
+// the loopback sign-in went) is the sign-in by a link: the runner has no
+// other way to sign Claude in.
+func TestSignInIgnoresSameMachine(t *testing.T) {
+ t.Parallel()
+ r := newTokenRig(t)
+ c := r.connector()
+ if err := c.Accept(r.ctx, "f-connect", wire.ConnectCommand{Connection: "cn_m1", Person: connPerson, Provider: wire.ProviderClaude, Kind: wire.KindSubscription, SameMachine: true}); err != nil {
+ t.Fatal(err)
+ }
+ link := r.prompt("cn_m1", 1).URL
+ if !r.deliver(c, "f-code", r.sealedCode("cn_m1", codeFor(link, "m@example.com"), 1, nil)) {
+ t.Fatal(r.errs)
+ }
+ if end := r.ended("cn_m1"); end.State != wire.ConnHealthy {
+ t.Fatalf("end %+v", end)
+ }
+}
diff --git a/internal/runner/thin/token.go b/internal/runner/thin/token.go
index bf3e8207..af08f854 100644
--- a/internal/runner/thin/token.go
+++ b/internal/runner/thin/token.go
@@ -40,7 +40,7 @@ var errStopped = errors.New("stopped")
// tokenAttempt is a token or sign-in attempt's row.
type tokenAttempt struct {
id, person, home, state, kind, secret, provider string
- cancelled, same bool
+ cancelled bool
}
func (a tokenAttempt) waiting() bool {
@@ -48,20 +48,20 @@ func (a tokenAttempt) waiting() bool {
}
// signIn says the attempt is Claude's sign-in by the runner's own
-// `claude setup-token` (signin.go): Claude, not a token, not at this
-// machine. Once its token is committed it is a token attempt.
+// `claude setup-token` (signin.go): Claude, not a token. Once its token
+// is committed it is a token attempt.
func (a tokenAttempt) signIn() bool {
- return a.provider == wire.ProviderClaude && a.kind != wire.KindToken && !a.same
+ return a.provider == wire.ProviderClaude && a.kind != wire.KindToken
}
func (c *Connector) attempt(ctx context.Context, id string) (tokenAttempt, bool, error) {
a := tokenAttempt{id: id}
- var cancelled, same int
- err := c.State.db.QueryRowContext(ctx, "SELECT person, home, state, kind, secret, provider, same_machine, cancelled FROM connect_attempts WHERE id=?", id).Scan(&a.person, &a.home, &a.state, &a.kind, &a.secret, &a.provider, &same, &cancelled)
+ var cancelled int
+ err := c.State.db.QueryRowContext(ctx, "SELECT person, home, state, kind, secret, provider, cancelled FROM connect_attempts WHERE id=?", id).Scan(&a.person, &a.home, &a.state, &a.kind, &a.secret, &a.provider, &cancelled)
if errors.Is(err, sql.ErrNoRows) {
return a, false, nil
}
- a.cancelled, a.same = cancelled == 1, same == 1
+ a.cancelled = cancelled == 1
return a, err == nil, err
}
diff --git a/internal/thintest/signin_contract_test.go b/internal/thintest/signin_contract_test.go
index 666416f1..ebbbf20c 100644
--- a/internal/thintest/signin_contract_test.go
+++ b/internal/thintest/signin_contract_test.go
@@ -4,6 +4,8 @@ import (
"bytes"
"encoding/base64"
"html"
+ "net/http"
+ "net/url"
"os"
"strings"
"testing"
@@ -217,3 +219,68 @@ func TestContractSignInCode(t *testing.T) {
}
}
}
+
+// Recovering a Claude token connection is the sign-in by a link first,
+// as on the Add page: the rejected row's Sign in again and the renewal
+// line's Sign in again post no token kind, and start a sign-in attempt
+// whose card offers the paste second. A rejected row says only that the
+// token was rejected (its button says what to do).
+func TestContractTokenRecoverySignsIn(t *testing.T) {
+ r := newRig(t)
+ soon := time.Now().UTC().Add(10 * 24 * time.Hour)
+ runner, err := DialRunnerHello(r.ctx, r.inst.URL, r.runner, held(
+ wire.HeldConnection{LocalID: "claude-8", Person: Owner, Provider: "claude", Kind: wire.KindToken, Label: "old@example.com", State: wire.ConnSignInAgain},
+ wire.HeldConnection{LocalID: "claude-9", Person: Owner, Provider: "claude", Kind: wire.KindToken, Label: "soon@example.com", State: wire.ConnHealthy, ExpiresAt: &soon, ExpiresEstimated: true},
+ ))
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(runner.Close)
+ r.wait("the token connections", func(c *Conversation) bool { return len(c.Connections) == 2 })
+ page := r.inst.Get(t, "/conversation/settings/connections")
+ rows := strings.Split(page, "<article equipo-conn-row")[1:]
+ if len(rows) != 2 {
+ t.Fatalf("%d rows", len(rows))
+ }
+ for _, row := range rows {
+ if strings.Contains(row, `name="kind" value="token"`) {
+ t.Fatalf("a row recovers by pasting a token: %.600s", row)
+ }
+ if strings.Contains(row, "Paste a new token") || strings.Contains(row, "Run claude setup-token") {
+ t.Fatalf("a row asks for a pasted token: %.600s", row)
+ }
+ }
+ if !strings.Contains(rows[0], "data-recover") || !strings.Contains(rows[0], "This token was rejected.") || !strings.Contains(rows[1], "data-token-renew") || !strings.Contains(rows[1], "data-renew") {
+ t.Fatal("the rows lack their recovery")
+ }
+ // What the row's form posts: provider only.
+ owner := r.inst.Cookie()
+ status, _ := (&toolRig{rig: r}).post(owner, "/conversation/connections", url.Values{"provider": {"claude"}})
+ if status != http.StatusSeeOther {
+ t.Fatalf("post %d", status)
+ }
+ _, body, err := runner.Expect(r.ctx, wire.FrameConnect)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if cmd := body.(*wire.ConnectCommand); cmd.Kind != wire.KindSubscription || cmd.Provider != "claude" {
+ t.Fatalf("connect %+v", cmd)
+ }
+ if add := r.inst.Get(t, "/conversation/settings/connections/add"); !strings.Contains(add, `data-kind`) && !strings.Contains(add, "data-loading") {
+ t.Fatal("no sign-in card")
+ }
+}
+
+// "I am at this machine" is gone: the API refuses same_machine for
+// Claude (and Codex, which never used it).
+func TestContractSameMachineRefused(t *testing.T) {
+ r := newRig(t)
+ runner := r.dial(0)
+ r.wait("runner online", func(c *Conversation) bool { return c.Runner.Online })
+ for _, p := range []string{"claude", "codex"} {
+ if _, err := r.client.Connect(r.ctx, wire.Connect{Provider: p, SameMachine: true}); Status(err) != 422 {
+ t.Fatalf("%s at this machine: %v", p, err)
+ }
+ }
+ _ = runner
+}
diff --git a/internal/wire/connections.go b/internal/wire/connections.go
index 2fada7c0..a5114ded 100644
--- a/internal/wire/connections.go
+++ b/internal/wire/connections.go
@@ -27,12 +27,10 @@ const (
KindSubscription = "subscription"
)
-// Prompt kinds on a connecting card: a device code to enter at URL, a
-// sign-in link to open on the runner's machine, or Claude's sign-in link
-// whose code comes back sealed (PromptAuthorize).
+// Prompt kinds on a connecting card: a device code to enter at URL, or
+// Claude's sign-in link whose code comes back sealed (PromptAuthorize).
const (
PromptDeviceCode = "device_code"
- PromptLink = "link"
// PromptAuthorize is Claude's sign-in with no terminal (Paul,
// 2026-11-10): the runner runs the unmodified `claude setup-token`
// itself and shows the authorize URL the CLI prints; the person signs
@@ -40,7 +38,7 @@ const (
// code to the runner (EndpointClaudeCode, Attempt the prompt's), and
// the runner types it into the waiting CLI. The token the CLI prints
// is kept as a pasted one is. A Claude Connect with Kind subscription
- // and not SameMachine starts it; the record is kind subscription
+ // starts it; the record is kind subscription
// while it connects and kind token once healthy. With no URL and
// Attempt 0 the runner is starting the CLI; with no URL and an
// Attempt, that attempt's code was sent and the runner is finishing.
@@ -129,8 +127,9 @@ type ConnectionList struct {
}
// Connect is POST /api/v1/connections. RunnerID empty means the person's
-// primary runner. SameMachine says the person's browser is on the
-// runner's machine (Claude's loopback sign-in can finish there).
+// primary runner. SameMachine is refused when true: the sign-in finished
+// at the runner's machine is gone (2026-11-10); the field stays so the
+// documents keep their shape.
type Connect struct {
Provider string `json:"provider"`
Kind string `json:"kind"`
@@ -191,6 +190,9 @@ type DisconnectCommand struct {
}
// ConnectCommand asks the runner to connect a new account for Person.
+// SameMachine is always false from this instance and ignored by the
+// runner; it stays because every connect frame an older instance sends
+// carries it, and frames are parsed strictly.
type ConnectCommand struct {
Connection string `json:"connection"`
Person string `json:"person"`