Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(acp): Kimi CLI sign-in opens its login terminal #34892

Openjuliusmarmingewants to merge 2 commits intomain fromrefs/pull/34892/headopened View on GitHub

juliusmarmingecommented

Kimi CLI 1.52.0 lists its login method with no top-level type and puts the login command only in _meta["terminal-auth"]. AcpRegistryAuth.authenticate treated any method with no type as agent-managed and sent ACP authenticate. Kimi crashes while serializing its error reply, so the request never gets an answer and sign-in hangs on 'Starting sign-in…'. The fix adds acpRegistryTerminalAuthLaunch in probe.ts, which returns the terminal launch for a method. Methods typed terminal are unchanged: the agent's spawn command plus the method's args and env. A method with no type whose _meta["terminal-auth"] decodes as {command: string, args?: string[], env?: Record<string,string>} runs that command as given, without the agent's own command in front, with the command length capped at 2,048 characters. In auth.ts, sign-in uses this launch to choose the terminal path and to spawn the terminal, so authenticate is never sent for these methods. normalizeAcpRegistryAuthMethods now reports these legacy methods as type 'terminal' and builds their displayed command from the same launch, so discovery lists them as terminal methods with the right command. There is no new regex or hand-written parser: the _meta value is checked against a fixed-shape schema, which takes time proportional to its size. This takes the same approach as open PR #24409, in a smaller form. The fix was not run end to end against a live Kimi CLI; the proof is the repro unit test.

Fixes pingdotgg/t3code#24302

Reproduction on main

Commit 3c68642354 (origin/main). Ran T3CODE_DEV_SEED=0 vp run dev in a fresh worktree on Linux, with no ~/.kimi on the machine, and paired the web client. Went to Settings → Providers → Add provider → Show more → ACP Registry → 'Kimi CLI (Legacy)' (v1.52.0 binary) → Add → Continue to sign-in → Sign in. About a minute later the dialog still read 'Account: Starting sign-in.' and offered only Cancel; no terminal and no browser opened. ~/.kimi/logs/kimi.log showed kimi_cli.acp.server:authenticate:385 Authentication not complete for method: login (no valid token found), then TypeError: Object of type AuthMethod is not JSON serializable while serializing error.data.authMethods, so the ACP authenticate request never got a reply. Also added a unit test to packages/provider-acp-registry/src/server/auth.test.ts that feeds Kimi's advertised method (id 'login', no top-level type, login command only in _meta["terminal-auth"]). It fails on main with expected [ 'login' ] to deeply equal [] because ACP authenticate is called instead of a terminal login. The newer registry entry 'Kimi Code' was not tested.

Evidence

Settings → Providers → Add provider → Show more → ACP Registry → Kimi CLI (Legacy), v1.52.0 → Add → Continue to sign-in → Sign in.

Both sides: Linux web client, Chromium, 1280×800, light theme, separate fresh unseeded databases, real Kimi binary.

BeforeAfter
3c68642354626426406a
Before: Starting sign-in remains stuckAfter: Kimi login terminal displays authorization instructions
Before recording: remains stuck for over a minute, no terminal.After recording: opens the real kimi login terminal and waits for authorization.

Images are frames extracted from the recordings. Environment details and the temporary authorization code are masked; commit captions were added during processing.

Browser driver

AI-assisted; verified with the tests and tools listed above.

Not shown:

  • Completed account authentication and subsequent credential verification were not exercised because no Kimi account was used.
  • The newer Kimi Code registry entry and other ACP authentication-method variants were not exercised.

Tests

Repro test on the base branch (vp test run src/server/auth.test.ts -t "legacy _meta" in packages/provider-acp-registry): 1 failed, as expected. With the fix, vp test run src/server/: 5 files, 65 tests passed. vp run check:changed: format, lint, knip, typecheck (10 packages) and tests for the 2 changed files (11 tests) all passed.

Not in this change

  • Kimi CLI's own crash when serializing error.data.authMethods (an upstream Kimi bug) is not handled; T3 still has no shorter timeout for an ACP authenticate request that is never answered.
  • The newer 'Kimi Code' registry entry was not tested.

AI-assisted; verified with the tests and tools listed above.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Approvability

      Verdict: Approved at 6264264

      Macroscope's review found this PR approvable — Legacy ACP sign-in methods such as Kimi CLI now open their advertised login terminal. The change stays within explicitly initiated sign-in and preserves existing terminal cleanup and credential verification.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.5 KiB21.5 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Baseline: 4e0b528 · PR result: 6264264 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The ACP registry auth flow now recognizes valid legacy terminal-auth metadata on methods with no declared type. It builds terminal launch details from that metadata and uses them to start terminal sign-in. A test covers the legacy login arguments and confirms that authenticate is not called.

      Changes: Legacy terminal authentication

      Layer / File(s)Summary
      Decode and normalize terminal launch metadata
      packages/provider-acp-registry/src/server/probe.ts
      The probe code validates legacy terminal-auth metadata, constructs launch details for typed and legacy methods, classifies valid unset-type methods as terminal, and uses launch details to generate the displayed command.
      Run terminal authentication
      packages/provider-acp-registry/src/server/auth.ts, packages/provider-acp-registry/src/server/auth.test.ts
      The auth flow passes normalized launch details to the terminal runner. The test checks that legacy login arguments are used, a terminal interaction starts, and authenticate is not called.

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Sequence Diagram(s)

      sequenceDiagram
        participant AuthFlow
        participant LaunchHelper
        participant TerminalRunner
        participant ManagedAgent
        AuthFlow->>LaunchHelper: Resolve method and spawn context
        LaunchHelper-->>AuthFlow: Return command, args, and env
        AuthFlow->>TerminalRunner: Start terminal with launch details
        TerminalRunner->>ManagedAgent: Spawn command with args and env

      Possibly related issues

      • pingdotgg/t3code#28833: The change handles the issue’s reported legacy metadata shape, but does not address its separate report of a five-minute wait for an unanswered authenticate request.

      Possibly related PRs

      • pingdotgg/t3code#24409: The PR changes the same auth flow and probe exports to route legacy Kimi terminal-auth metadata through terminal sign-in.

      Suggested labels: bugfix

      Suggested reviewers: maria-rcks, macroscopeapp

      Merge Risk: Minimal · up to 62642

      This change lets Kimi CLI sign-in open a terminal rather than hang on an ACP authenticate request. No actionable merge-blocking risk remains. It has not been tested against a live Kimi CLI.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title names the Kimi CLI sign-in fix, which matches the main change: legacy terminal-auth metadata now opens a login terminal instead of sending ACP authenticate. It uses a conventional commit pre…
      Linked Issues checkPassed[#24302] The issue requires that Kimi sign-in proceeds instead of hanging at 'Starting sign-in…'. The root cause is that a method with no top-level type was treated as agent-managed and sent ACP authe…
      Out of Scope Changes checkPassedAll changed code supports the legacy terminal-auth fix for Kimi. probe.ts adds the launch type, the decoder, and the launch function. It also updates normalizeAcpRegistryAuthMethods so the display com…
      Description checkPassedThe description follows the repository template closely. It has Problem, Change, Scope, and Verification sections, and each is substantively filled in. The Problem section explains the Kimi CLI 1.52.0…
      Full details: Title check

      Explanation

      The title names the Kimi CLI sign-in fix, which matches the main change: legacy terminal-auth metadata now opens a login terminal instead of sending ACP authenticate. It uses a conventional commit prefix and is specific enough for a teammate scanning history.

      Full details: Linked Issues check

      Explanation

      [#24302] The issue requires that Kimi sign-in proceeds instead of hanging at 'Starting sign-in…'. The root cause is that a method with no top-level type was treated as agent-managed and sent ACP authenticate. At the reviewed head, probe.ts adds legacyTerminalAuthLaunch. It decodes _meta['terminal-auth'] with a fixed-shape schema (command, optional args, optional env) and bounds the command length. auth.ts calls acpRegistryTerminalAuthLaunch before any authenticate call. When a launch exists, it closes the runtime scope and runs runTerminal with that launch, so authenticate is not sent for these methods. normalizeAcpRegistryAuthMethods also reports these methods as type 'terminal', so discovery lists them correctly. A unit test in auth.test.ts covers the legacy metadata case. The change does not include a live end-to-end run against Kimi CLI. That run is verification evidence, not a coding requirement, so it does not change this result.

      Full details: Out of Scope Changes check

      Explanation

      All changed code supports the legacy terminal-auth fix for Kimi. probe.ts adds the launch type, the decoder, and the launch function. It also updates normalizeAcpRegistryAuthMethods so the display command comes from the same launch. auth.ts switches runTerminal from a terminal auth method to a launch object, so typed terminal methods still use the agent command, args, and env. auth.test.ts adds the regression test. The PR description states that the Kimi serialization crash and the unanswered-authenticate timeout are not changed. The diff does not include changes to those areas, so no unrelated change was found.

      Full details: Description check

      Explanation

      The description follows the repository template closely. It has Problem, Change, Scope, and Verification sections, and each is substantively filled in. The Problem section explains the Kimi CLI 1.52.0 sign-in hang and the expected behavior. The Change section explains the terminal-launch path in probe.ts and auth.ts. The Scope section links issue #24302 and explains the fix for an observed bug. The Verification section gives a reproduction on main, a before/after comparison with screenshots and recordings, the focused test command, and the observed results. It also states what was not checked: a live Kimi account sign-in, the newer 'Kimi Code' entry, and other auth variants. The template asks for the model and harness used for agent work. The description says 'AI-assisted' but does not name the model or harness, so that item is missing. The description also includes a note about a regex-free parser and a comparison to PR #24409. These are extra context and do not hurt the check. Overall the description is mostly complete.

      Finishing Touches

      Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 4e0b52806be83e66f80839e1e372398307346425 and 626426406ab8a6dcd37bb39da2c805c135c8c2ca.

      Files selected for processing: 3

      • packages/provider-acp-registry/src/server/auth.test.ts
      • packages/provider-acp-registry/src/server/auth.ts
      • packages/provider-acp-registry/src/server/probe.ts

      Limit details: You’ve used all 10 included reviews currently available.

    5. tanstack-source added labelsbug

Sign in to join this conversation.