t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: ACP Registry provider sign-in ignores `_meta[terminal-auth]` and hangs for 5 minutes when signing into Kimi

Open jamesdchen opened this issue 1 month ago • 2 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate. (Related: #15899 covered the upstream ACP Registry pointing kimi at kimi-cli 1.52.0; this report covers two faults in T3 Code's own packages/provider-acp-registry sign-in handling.)
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/server (packages/provider-acp-registry ACP sign-in & ProviderAuthTerminal routing)

Steps to reproduce

  1. Open Settings → Providers in T3 Code 0.1.6 and add Kimi CLI from the ACP Registry (agentId: "kimi", which installs kimi 1.52.0 from the official ACP Registry).
  2. Ensure no existing Kimi token is present under ~/.kimi/credentials.
  3. Click Sign in (Login with Kimi account) in the Kimi provider settings panel.

Expected behavior

  1. T3 Code should recognize the ACP v1 _meta["terminal-auth"] descriptor advertised by initialize ({ type: "terminal", command: ".../kimi.exe", args: ["login"], env: {} }) when top-level AuthMethod.type is omitted, and open ProviderAuthTerminal to run the interactive kimi login flow.
  2. Even if an ACP agent's authenticate JSON-RPC handler fails to respond without exiting its stdio process, AcpRegistryAuth.authenticate should time out promptly (similar to the 30s timeout on discoverMethods and 60s timeout on logout) and surface an actionable error instead of hanging the sign-in UI for 5 minutes.

Actual behavior

  1. During initialize, kimi 1.52.0 (ACP protocol v1 v0.10.8 / Python ACP SDK 0.8.0) advertises terminal login via _meta["terminal-auth"] without a top-level type: "terminal" field:
    {
      "authMethods": [
        {
          "id": "login",
          "name": "Login with Kimi account",
          "description": "Run `kimi login` command in the terminal, then follow the instructions to finish login.",
          "_meta": {
            "terminal-auth": {
              "type": "terminal",
              "label": "Kimi Code Login",
              "command": "<USER_HOME>\\.t3\\tools\\kimi\\1.52.0\\windows-x86_64\\kimi.exe",
              "args": ["login"],
              "env": {}
            }
          }
        }
      ]
    }
    
  2. Both normalizeAcpRegistryAuthMethods (const type = method.type ?? "agent") and AcpRegistryAuth.authenticate (if (method.type === "terminal")) ignore method._meta?.["terminal-auth"].
  3. Instead of launching ProviderAuthTerminal with kimi login, T3 Code treats the method as type: "agent" and sends a JSON-RPC authenticate request ({"method": "authenticate", "params": {"methodId": "login"}}).
  4. Because no token exists yet, kimi acp raises Authentication required and hits a JSON serialization bug on its error payload (TypeError: Object of type AuthMethod is not JSON serializable), dropping the JSON-RPC reply while keeping the stdio process alive.
  5. runtime.authenticate(methodId) in AcpRegistryAuth.authenticate has no timeout, so the T3 Code sign-in UI stays stuck for ~300.5 seconds (5 minutes) until the outer ProviderAuthService fiber interrupts it.

Impact

Major degradation or frequent failure — out-of-the-box sign-in for Kimi from the ACP Registry never opens the terminal login UI and hangs for 5 minutes.

Version or commit

0.1.6 (desktop/server stable)

Environment

Windows x64 (win32-x64), T3 Code Desktop 0.1.6, ACP Registry kimi 1.52.0 (also verified against Kimi Code CLI 2.4.1, which emits both top-level type: "terminal", args: ["--login"] and the legacy _meta["terminal-auth"] fallback).

Logs or stack traces

From server.trace.ndjson (paths redacted):

{"type":"effect-span","name":"authenticate","durationMs":293648.7139,"attributes":{"rpc.system.name":"effect_rpc","rpc.method":"authenticate"},"exit":{"_tag":"Interrupted","cause":"InterruptError: All fibers interrupted without error\n    at AcpRegistryAuth.authenticate ..."}}
{"type":"effect-span","name":"AcpRegistryAuth.authenticate","durationMs":300492.6794,"exit":{"_tag":"Interrupted","cause":"InterruptError: All fibers interrupted without error\n    at AcpRegistryAuth.authenticate ..."}}

From ~/.kimi/logs/kimi.log at the exact timestamp of t3-code-provider-auth:

INFO     | kimi_cli.acp.server:initialize:50 | - ACP server initialized with client protocol version: 2, negotiated version: ACPVersionSpec(protocol_version=1, spec_tag='v0.10.8', sdk_version='0.8.0'), ... client info: field_meta=None name='t3-code-provider-auth' title=None version='0.0.0'
WARNING  | kimi_cli.acp.server:authenticate:385 | - Authentication not complete for method: login (no valid token found)
ERROR    | threading:run:1024 | - acp.exceptions.RequestError: Authentication required
ERROR    | threading:run:1024 | - TypeError: Object of type AuthMethod is not JSON serializable

Workaround

Install the newer Kimi Code CLI (irm https://code.kimi.com/kimi-code/install.ps1 | iex, v2.4.1+, which advertises top-level type: "terminal" alongside _meta["terminal-auth"]), set Executable override (commandPath) on the Kimi ACP provider instance to <USER_HOME>\.kimi-code\bin\kimi.exe, or run kimi login manually in an external terminal.

jamesdchen avatar Nov 01 '26 18:11 jamesdchen

Additional findings on Linux (0.1.6) with kimi-code 2.4.1

Testing the kimi-code 2.4.1 commandPath override workaround on a headless Debian 13 (linux-x64) T3 Code 0.1.6 server exposed two extra bugs caused by ignoring _meta["terminal-auth"] and switching from the ACP Registry's legacy kimi 1.52.0 binary:

  1. Top-level args: ["--login"] in kimi-code 2.4.1 also fails without _meta["terminal-auth"]: In 2.4.1, initialize returns both top-level type: "terminal" and _meta["terminal-auth"]:

    {
      "authMethods": [
        {
          "id": "login",
          "type": "terminal",
          "name": "Login with Kimi account",
          "description": "Open the device-code login flow in a terminal.",
          "args": ["--login"],
          "env": {},
          "_meta": {
            "terminal-auth": {
              "type": "terminal",
              "label": "Login with Kimi account",
              "command": "<USER_HOME>/.kimi-code/bin/kimi",
              "args": ["login"],
              "env": {}
            }
          }
        }
      ]
    }
    

    However, kimi-code 2.4.1 has no --login flag (kimi --login exits 1 immediately with error: unknown option '--login'); the actual subcommand is kimi login, which is only specified inside _meta["terminal-auth"].args. So T3 Code's terminal auth flow must prefer _meta["terminal-auth"] (command + args + env) even when top-level type: "terminal" is present.

  2. Switching commandPath from ACP Registry kimi 1.52.0 (~/.kimi) to kimi-code 2.4.1 (~/.kimi-code) hides Kimi as unauthenticated:

    • The ACP Registry entry currently downloads legacy MoonshotAI/kimi-cli 1.52.0, which stores config and OAuth tokens in ~/.kimi/ (~/.kimi/config.toml and ~/.kimi/credentials/kimi-code.json).
    • Newer kimi-code 2.4.1 (~/.kimi-code/bin/kimi) reads from ~/.kimi-code/ instead. Without ~/.kimi-code/config.toml and ~/.kimi-code/credentials/kimi-code.json, kimi acp logs auth summarize: enter total=0 oauthProviders=[] and T3 Code marks acpRegistry_kimi_cli as unauthenticated, hiding Kimi from the model picker.
    • Running kimi migrate --run migrates config.toml and sessions into ~/.kimi-code/, but intentionally skips copying OAuth credentials (oauthLoginsRequiringRelogin: ["kimi-code"]). Because FileTokenStorage in 2.4.1 uses the exact same JSON wire schema (access_token, refresh_token, expires_at, scope, token_type, expires_in), copying ~/.kimi/credentials/kimi-code.json to ~/.kimi-code/credentials/kimi-code.json (0700 dir / 0600 file) and adding ~/.kimi-code/bin to the t3code.service PATH immediately restores status: "ready" without re-authenticating.

jamesdchen avatar Nov 01 '26 23:11 jamesdchen

This is the same problem as #24302, so I'm closing it in favour of that one. If it is different, say how and it will be reopened.

juliusmarminge avatar Nov 12 '26 06:11 juliusmarminge