Repository navigation
feat(acp): add experimental agent-core-v2 ACP server (kimi acp-v2) #2571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9f9f31e
feat(acp): add agent-core-v2 ACP server
sailist 7cb6363
test: use neutral example domains in test fixtures and docs
sailist 821651a
fix(acp): align acp-server with agent-core-v2 interfaces and address …
sailist 744d457
fix(acp): use enqueue for prompt submission, stop advertising unimple…
sailist 25e8112
fix(acp): filter turn events by turnId, surface auth failures as auth…
sailist 613f412
fix(acp): gate acp-v2 behind experimental flag, filter sessions by cwd
sailist 9cadc2a
refactor(acp-server): rewire ACP server onto the klient facade
sailist 8a2bed7
feat(agent-core-v2): add session delete and ephemeral per-session MCP…
sailist e5cb090
feat(klient): expose session delete, per-session MCP, skills, and str…
sailist dd552a7
feat(acp-server): align ACP v2 server with acp-adapter capabilities
sailist 40d0bc9
fix(cli): drop stale registerServerCommand call and sherif ACP SDK split
sailist c024ae2
test: update fixtures for acp-v2 flag and domain rename, refresh nix …
sailist a97d7d3
fix(acp): widen the ACP v2 auth gate beyond OAuth-only providers
sailist 1bbb4a9
fix(acp): reject concurrent prompts instead of displacing the in-flig…
sailist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /** | ||
| * `kimi acp-v2` sub-command. | ||
| * | ||
| * Starts the Agent Client Protocol (ACP) server backed directly by the | ||
| * DI × Scope agent engine (`agent-core-v2`) over stdio, so ACP-compatible | ||
| * clients can drive a kimi-code session on the new engine. This is the v2 | ||
| * counterpart to `kimi acp` (which runs the legacy `@moonshot-ai/acp-adapter` | ||
| * over the SDK harness). | ||
| * | ||
| * Wire-up mirrors `kimi acp` for the parts that are host-independent: | ||
| * - `--login` pivots into the shared device-code login flow (the entry point | ||
| * ACP clients hit via the first-class `AuthMethodTerminal` path, re-invoking | ||
| * the agent binary with the advertised `args:['--login']`). | ||
| * - `KIMI_CODE_HOME` (if set) is forwarded into `authMethods[0].env` so the | ||
| * login subprocess writes its token under the same data root the server | ||
| * reads from, and `process.argv[1]` is advertised as the legacy | ||
| * `_meta['terminal-auth'].command` fallback. | ||
| * | ||
| * `@moonshot-ai/acp-server` (and its `agent-core-v2` engine) is loaded via a | ||
| * lazy dynamic import so the default CLI / `kimi acp` module graph stays free | ||
| * of the experimental v2 engine — mirroring the `kimi server run` v2 routing | ||
| * in `#/cli/sub/server/run.ts`. | ||
| */ | ||
|
|
||
| import type { Command } from 'commander'; | ||
|
|
||
| import { getVersion } from '#/cli/version'; | ||
| import { KIMI_CODE_HOME_ENV } from '#/constant/app'; | ||
| import { getDataDir } from '#/utils/paths'; | ||
|
|
||
| import { runLoginFlow } from './login-flow'; | ||
|
|
||
| export function registerAcpV2Command(parent: Command): void { | ||
| parent | ||
| .command('acp-v2') | ||
| .description( | ||
| 'Run kimi-code as an Agent Client Protocol (ACP) server over stdio (experimental agent-core-v2 engine).', | ||
| ) | ||
| .option( | ||
| '--login', | ||
| 'Run the device-code login flow then exit (entry point for ACP terminal-auth).', | ||
| false, | ||
| ) | ||
| .action(async (opts: { login?: boolean }) => { | ||
| if (opts.login === true) { | ||
| await runLoginFlow(); | ||
| return; | ||
| } | ||
| // Forward `KIMI_CODE_HOME` (if set) into `authMethods[0].env` so the | ||
| // login subprocess clients spawn for terminal-auth writes its token | ||
| // under the same data root the ACP server reads from. | ||
| const sandboxHome = process.env[KIMI_CODE_HOME_ENV]; | ||
| const terminalAuthEnv = | ||
| sandboxHome !== undefined && sandboxHome.length > 0 | ||
| ? { [KIMI_CODE_HOME_ENV]: sandboxHome } | ||
| : undefined; | ||
| // Legacy `_meta.terminal-auth` fallback for clients that don't yet | ||
| // honor the first-class `type:'terminal'`. `command` is the absolute | ||
| // path to this very binary so the client can spawn it for login. | ||
| const legacyCommand = process.argv[1]; | ||
| try { | ||
| const { runAcpServer } = await import('@moonshot-ai/acp-server'); | ||
| await runAcpServer({ | ||
| homeDir: getDataDir(), | ||
| agentInfo: { name: 'Kimi Code CLI', version: getVersion() }, | ||
| ...(terminalAuthEnv ? { terminalAuthEnv } : {}), | ||
| ...(legacyCommand !== undefined && legacyCommand.length > 0 | ||
| ? { terminalAuthLegacyCommand: legacyCommand } | ||
| : {}), | ||
| }); | ||
| process.exit(0); | ||
| } catch (error) { | ||
| process.stderr.write(`acp-v2 server: fatal error: ${String(error)}\n`); | ||
| process.exit(1); | ||
| } | ||
| }); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In every CLI startup,
createProgramreaches this call, butregisterServerCommandis not imported or declared anywhere underapps/kimi-code/src/cli(checked withrg). That throws aReferenceErrorbefore command registration completes, so evenkimi --help/normal startup fail as soon as this function runs; import a real command implementation or remove this call.Useful? React with 👍 / 👎.