Skip to content

chore: remove unused kaos package and MCP kaos executor option - #4184

Merged
7Sageer merged 5 commits into
mainfrom
chore-remove-kaos
Oct 12, 2026
Merged

7Sageer merged 5 commits into
mainfrom
chore-remove-kaos

Conversation

@7Sageer

@7Sageer 7Sageer commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

内部包 @moonshot-ai/kaos 已无任何运行时使用者,将其整体删除,并清理 SDK 公共 API 与 MCP 配置中残留的 kaos 引用。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

 packages/
-├── kaos/                       # 整个包删除(private,从未发布;仓库内已无运行时 import)
 ├── node-sdk/
 │   ├── src/
-│   │   ├── types.ts            # CreateSessionOptions / ResumeSessionInput 移除 kaos、persistenceKaos 选项
-│   │   ├── rpc.ts              # SDKRpcClientBase 移除 createSessionWithKaos / resumeSessionWithKaos
-│   │   ├── kimi-harness.ts     # 移除 kaos 转发;新增 stripLegacyKaosOptions,转发 RPC 与序列化 resume key 前剥离遗留 kaos 字段(防 JS host 循环引用崩溃)
-│   │   ├── sdk-rpc-client-v2.ts# 删除解释 kaos 退化的注释
-│   │   └── config/schema.ts    # MCP stdio executor 枚举收窄为 ['local']
 │   └── package.json / tsdown.config.ts / api-extractor.json / tsconfig.dts.json / scripts/build-dts.mjs
-│                               # 移除 kaos 依赖与打包映射
 ├── agent-core-v2/
-│   ├── src/mcpCore/config-schema.ts   # executor 枚举收窄为 ['local']
-│   ├── src/mcpCore/client-stdio.ts    # 删除随之成为死代码的 executor 运行时检查
-│   └── test/mcpCore/client-stdio.test.ts # 删除钉住旧拒绝行为的测试
 └── klient/
-    ├── src/contract/mcp.ts            # executor 枚举收窄为 ['local']
-    └── scripts/run-docker-e2e.sh      # 移除 kaos node_modules 挂载

 flake.nix                       # workspacePaths / workspaceNames 移除 kaos;pnpmDeps 哈希随 lockfile 更新
 pnpm-workspace.yaml / pnpm-lock.yaml # 移除 kaos 依赖与随之失效的 ssh2 overrides
 apps/vscode                     # tsdown alias 与 watch 列表移除 kaos
 AGENTS.md / CONTRIBUTING(.zh-CN).md / .changeset/README.md / gen-changesets skill # 项目地图与包列表同步

关键设计点:MCP 的 executor 字段本身保留,只收窄枚举。zod 默认剥离未知 key,若整个字段删除,写了 executor = "kaos" 的旧配置会被静默忽略并直接在本地启动 server;收窄枚举后这类配置在加载时显式报 CONFIG_INVALID。

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
SDK CreateSessionOptions.kaos / persistenceKaos 选项 类型上可传,运行时一律被忽略(v2 引擎无 kaos 注入点) 类型移除,传入会编译报错 SDK 外部使用者(code-app desktop/web、其他 SDK host);已确认本仓库与本地 code-app 源码均无人传入 删除该实参即可,运行时行为不变
SDK SDKRpcClientBase.createSessionWithKaos / resumeSessionWithKaos 方法 存在,忽略 kaos 参数后退化为普通 create/resume 方法移除 同上 直接调用 createSession / resumeSession
SDK 发布产物 d.ts 内联的 Kaos 类型 公开 d.ts 中包含 Kaos 类型定义 不再包含(已验证产物中零引用) 同上 同上
MCP stdio 配置 executor = "kaos" 通过 schema 校验,MCP client 构造时抛 NOT_IMPLEMENTED(该值从未可用,同文件其他 server 不受影响) 配置加载时整个文件 schema 校验失败、报 CONFIG_INVALID,同文件其他 server 一并不可用直至移除该条目(经 review 评估后接受的取舍,避免该值被静默忽略) 在 mcp 配置中写了 executor = "kaos" 的用户(从未有可工作行为) 删除 executor 字段或改为 "local"
MCP stdio 配置 executor = "local" 或未设置 本地启动 server 不变 所有现有 MCP 用户 —
旧版 ~/.kimi/kimi.json 中的 kaos 字段(migration-legacy 读取的历史数据) 正常读取迁移 不变(历史数据 schema 保留) 从 legacy CLI 迁移的用户 —

受影响模块与验证:

  • packages/node-sdk:typecheck + 完整 build(tsdown + api-extractor d.ts rollup)通过,公开 d.ts 中已无 Kaos
  • packages/agent-core-v2:mcpCore 测试 144/144;import-boundaries lint 测试 21/21;typecheck 通过
  • packages/klient:契约测试 10/10、typecheck(含编译期 contract parity)通过
  • apps/kimi-code / apps/vscode:typecheck 通过
  • scripts/check-nix-workspace.mjs 通过;全仓 @moonshot-ai/kaos 引用零残留
  • 旧行为的测试 pinning:无需保留——两处被删行为(SDK kaos 选项、executor = "kaos")在改动前均无可用功能

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Copilot AI balanced review requested due to automatic review settings October 12, 2026 08:53
@7Hanrui

7Hanrui commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

@codex review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T10:18:59.269773Z c0c0898 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@changeset-bot

changeset-bot Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c0c0898

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@moonshot-ai/kimi-code-sdk Minor
@moonshot-ai/kimi-code Patch
kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@c0c0898
npx https://pkg.pr.new/@moonshot-ai/kimi-code@c0c0898

commit: c0c0898

@github-actions

Copy link
Copy Markdown
Contributor

❌ Nix build failed

Hash mismatch in pnpmDeps:

Hash
specified sha256-xrn34bQ76s+ouOZPHZ4TBkpTHxG7gZejmx8RqSii2uA=
got sha256-XLjspHl3+xErXYH5fMW8J8fDB5m1ZF8MkATKh11odo0=

Please update flake.nix with the got hash.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e3065a9386

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/node-sdk/src/kimi-harness.ts Outdated
Comment on lines +661 to +662
function resumeCoalesceKey(id: string, input: ResumeSessionInput): string {
const { kaos, persistenceKaos, ...rest } = input;
return JSON.stringify({
...rest,
id,
kaos: kaos !== undefined,
persistenceKaos: persistenceKaos !== undefined,
});
return JSON.stringify({ ...input, id });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Strip legacy kaos objects before serializing the resume key

When a previously compiled or JavaScript SDK host upgrades but still passes the formerly valid kaos or persistenceKaos option, this now serializes the complete object. Custom Kaos implementations may contain circular runtime handles, so resumeSession can throw a TypeError before reaching the RPC; the previous implementation deliberately represented these values as booleans and therefore accepted such objects. Continue excluding the legacy fields from the coalescing key even after removing them from the TypeScript interface.

AGENTS.md reference: AGENTS.md:L97-L99

Useful? React with 👍 / 👎.

Comment on lines 173 to 175
if (active !== undefined && !active.isClosed) {
if (kaos !== undefined || persistenceKaos !== undefined) {
await this.rpc.resumeSessionWithKaos({ ...resumeInput, id }, kaos ?? persistenceKaos as Kaos, persistenceKaos);
} else if (input.agentProfile !== undefined) {
if (input.agentProfile !== undefined) {
await this.rpc.resumeSession({ ...resumeInput, id });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve option application when resuming an active session

For an SDK host that resumes an already-active session with a legacy kaos argument plus additionalDirs, the old kaos branch called resumeSessionWithKaos, which delegated to resumeSession and merged those directories; this replacement now calls the RPC only when agentProfile is present, silently dropping additionalDirs. This also means the documented escape hatch of merely removing the kaos argument cannot preserve the old behavior, so the active-session branch should still forward options that require re-resumption.

AGENTS.md reference: AGENTS.md:L97-L99

Useful? React with 👍 / 👎.

Comment thread .changeset/remove-kaos.md Outdated
"@moonshot-ai/kimi-code-sdk": minor
---

Remove the `kaos` / `persistenceKaos` session options and the `createSessionWithKaos` / `resumeSessionWithKaos` client methods. They were already ignored at runtime; hosts should drop these arguments. The internal `@moonshot-ai/kaos` package has been removed from the repository.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Rewrite the changesets as single user-facing sentences

This changeset contains three sentences, including implementation detail about the internal package, and the accompanying MCP changeset likewise contains two sentences. Repository workflow requires each changeset to be exactly one short user-facing sentence stating only what changed, so both entries need to be condensed before release-note generation.

AGENTS.md reference: AGENTS.md:L84-L86

Useful? React with 👍 / 👎.

env: StringRecordSchema.optional(),
cwd: z.string().optional(),
executor: z.enum(['local', 'kaos']).optional(),
executor: z.enum(['local']).optional(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Prevent one legacy executor from disabling every MCP server

When any user, project, or workspace MCP file contains one legacy executor: "kaos" entry alongside otherwise valid servers, narrowing this schema makes parseMcpJsonServers reject the whole file; the three layers are loaded through one Promise.all, and WorkspaceMcpConfigService catches the initialization failure only by logging it, leaving its complete server set empty. Previously the file loaded and only the unsupported kaos entry failed during its independent connection attempt, so this silently removes every working MCP tool rather than merely reporting the legacy entry as invalid.

AGENTS.md reference: AGENTS.md:L117-L119

Useful? React with 👍 / 👎.

Comment thread .changeset/remove-kaos.md
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code-sdk": minor

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Mark the SDK API removal as a breaking release

Removing the exported session option properties and SDKRpcClientBase methods makes existing TypeScript hosts fail compilation and existing JavaScript calls find the methods undefined, but this changeset requests only a minor SDK bump. Preserve compatibility shims or obtain the required confirmation and use the repository-mandated major bump so consumers are not given a non-breaking release signal for a public API removal.

AGENTS.md reference: AGENTS.md:L62-L62

Useful? React with 👍 / 👎.

@7Hanrui

7Hanrui commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18a32439ab

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/node-sdk/src/kimi-harness.ts Outdated
Comment on lines +141 to +142
const { planMode, sessionStartedProperties, ...coreOptions } = options;
const summary = await this.rpc.createSession(coreOptions);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Strip legacy kaos fields before forwarding session RPCs

When a previously compiled JavaScript host still supplies a legacy kaos or persistenceKaos object and its public SDKRpcClientBase subclass serializes RPC inputs, coreOptions now retains that object and can fail on circular runtime handles before session creation; previously the harness removed both fields before invoking the ordinary RPC. The same leak occurs in doResumeSession. The new resumeCoalesceKey fix is fresh evidence that these objects may be circular, but it strips them only from the map key rather than from the RPC payload, so both lifecycle paths should discard the legacy fields before forwarding.

AGENTS.md reference: AGENTS.md:L97-L99

Useful? React with 👍 / 👎.

@7Hanrui

7Hanrui commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 0483866f29

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@7Hanrui

7Hanrui commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: c0c0898edf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants