Summary
Centralize the main agent id (main) so runtime code does not duplicate the literal across agent-core, node-sdk, and apps/kimi-code.
Motivation
The main agent id is currently treated as a shared protocol/identity value, but it is defined or hard-coded in multiple places. For example:
packages/node-sdk/src/rpc.ts defines a local MAIN_AGENT_ID
packages/node-sdk/src/session.ts defines a local MAIN_AGENT_ID
packages/agent-core/src/session/rpc.ts checks agentId === 'main'
apps/kimi-code has its own TUI-level MAIN_AGENT_ID
This makes future changes error-prone because the value is part of the SDK/core communication contract.
Proposed Change
Define MAIN_AGENT_ID once in agent-core and reuse it across the runtime code:
- Export
MAIN_AGENT_ID from packages/agent-core/src/agent/index.ts
- Use it in
agent-core session/rpc code instead of hard-coded 'main'
- Import it in
node-sdk from @moonshot-ai/agent-core
- Re-export it from
@moonshot-ai/kimi-code-sdk
- Let
apps/kimi-code consume it through the SDK boundary instead of importing agent-core directly
Scope
This is an internal refactor. It should not change runtime behavior.
Validation
Expected validation:
pnpm --filter @moonshot-ai/agent-core typecheck
pnpm --filter @moonshot-ai/kimi-code-sdk typecheck
pnpm --filter @moonshot-ai/kimi-code typecheck
If this direction sounds reasonable, I’d be happy to submit a PR to fix this.
Summary
Centralize the main agent id (
main) so runtime code does not duplicate the literal acrossagent-core,node-sdk, andapps/kimi-code.Motivation
The main agent id is currently treated as a shared protocol/identity value, but it is defined or hard-coded in multiple places. For example:
packages/node-sdk/src/rpc.tsdefines a localMAIN_AGENT_IDpackages/node-sdk/src/session.tsdefines a localMAIN_AGENT_IDpackages/agent-core/src/session/rpc.tschecksagentId === 'main'apps/kimi-codehas its own TUI-levelMAIN_AGENT_IDThis makes future changes error-prone because the value is part of the SDK/core communication contract.
Proposed Change
Define
MAIN_AGENT_IDonce inagent-coreand reuse it across the runtime code:MAIN_AGENT_IDfrompackages/agent-core/src/agent/index.tsagent-coresession/rpc code instead of hard-coded'main'node-sdkfrom@moonshot-ai/agent-core@moonshot-ai/kimi-code-sdkapps/kimi-codeconsume it through the SDK boundary instead of importingagent-coredirectlyScope
This is an internal refactor. It should not change runtime behavior.
Validation
Expected validation:
pnpm --filter @moonshot-ai/agent-core typecheckpnpm --filter @moonshot-ai/kimi-code-sdk typecheckpnpm --filter @moonshot-ai/kimi-code typecheckIf this direction sounds reasonable, I’d be happy to submit a PR to fix this.