Repository navigation
feat(agent-core-v2): make workspace trust configurable - #4517
Conversation
🦋 Changeset detectedLatest commit: 0107d08 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79afeeff3d
ℹ️ 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".
|
|
||
| async get(): Promise<boolean> { | ||
| await this.config.ready; | ||
| if (!this.trustGateEnabled()) return true; |
There was a problem hiding this comment.
Load persisted trust before re-enabling the gate
When Kimi Code starts with require_trust = false, this early return bypasses this.ready, so an existing trust record is never read. If the user then re-enables the requirement with the documented /reload flow, onConfigChange() publishes the cached false state and reloadAfterTrustChange() unloads project MCP servers; a later get() can discover the persisted true value, but normal initialization emits no follow-up change, leaving MCP unloaded until restart or re-trust. Load the persisted state before publishing the re-enabled gate state.
AGENTS.md reference: AGENTS.md:L111-L113
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 38e2305416
ℹ️ 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".
| const trusted = | ||
| (await readWorkspaceTrust(this.docs, cwd)) || | ||
| trustWorkspaceEnvTrusted((name) => this.bootstrap.getEnv(name)); | ||
| const trusted = await this.trust.forRoot(cwd).get(); |
There was a problem hiding this comment.
Refresh persisted trust before registry queries
When this process has queried a workspace once, WorkspaceTrustEntry.get() reuses its resolved initialization promise and never reads the trust record again. If another Kimi Code process subsequently trusts or untrusts the same directory, MCP management operations in this process continue returning the old project-level registry view until restart; the replaced implementation called readWorkspaceTrust on every query and observed such changes. Preserve that fresh-read behavior or invalidate the cached entry when querying the registry.
AGENTS.md reference: AGENTS.md:L127-L129
Useful? React with 👍 / 👎.
|
|
||
| `enabled` can be overridden by the `KIMI_CODE_WATCH` environment variable, which takes higher priority than `config.toml`. | ||
|
|
||
| ## `workspace` |
There was a problem hiding this comment.
Keep the existing workspace documentation anchor stable
Adding this second heading named workspace duplicates the existing project-local workspace heading later in both locale pages. VitePress assigns the first heading #workspace and disambiguates the later one, so existing public links or bookmarks to the project-local configuration now land on the unrelated global trust section. Give the new section a distinct heading/anchor and update the new links so the prior #workspace target remains stable.
AGENTS.md reference: docs/AGENTS.md:L18-L21
Useful? React with 👍 / 👎.
| #### `POST /api/v1/workspaces/{workspace_id}/untrust` | ||
|
|
||
| Revokes workspace trust, unloading its project-level MCP config. | ||
| Revokes the persisted workspace trust record. Unless a process or config override keeps the workspace trusted, its project-level MCP config unloads. |
There was a problem hiding this comment.
Update the untrust route's generated description
This documentation correctly makes MCP unloading conditional, but the route definition in packages/kap-server/src/routes/workspaces.ts still publishes the unconditional OpenAPI description Revoke workspace trust (project-level MCP config unloads). With require_trust = false, the endpoint now leaves project MCP loaded, so generated API consumers receive a contract that contradicts both the response and this reference page; update the route metadata to describe the override.
AGENTS.md reference: AGENTS.md:L123-L125
Useful? React with 👍 / 👎.
… as already landed MoonshotAI#4434's CSP already allows data: and blob: media fetches, MoonshotAI#4517's [workspace] require_trust section and its store short-circuit are in the tree with both locale docs, and MoonshotAI#4605's tunnel scenario already reports httpCapabilities and asserts the reconnected response. Ledger: closed 28 -> 32, remaining 67.
Ports the docs half of upstream MoonshotAI/kimi-code 8b6a003 (MoonshotAI#4673): the 2.5.0 section from the upstream release notes lands in both changelogs, en and zh, word for word. Every feature the section names is in this tree - busy /model and /effort (MoonshotAI#4621), merged project-level skills (MoonshotAI#4520), remote sessions in SSH, Docker and custom-command environments (MoonshotAI#4062), [workspace] require_trust (MoonshotAI#4517), web search off by default (MoonshotAI#4516), and the subagent model pool (MoonshotAI#4418) - so the notes describe what the fork actually does. Deliberately not touched: apps/kimi-code/CHANGELOG.md still tops out at 2.4.1 and package.json still says 2.4.1. That file is generated by `changeset version`, this tree has 377 pending changesets, and AGENTS.md forbids running version or publish from this repository, so the entry is written on the docs side only. Whoever next cuts a release here should reconcile this section with what changeset version generates rather than re-deriving it by hand.
Requirement or Bug
允许用户通过
config.toml全局关闭工作区信任确认。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
同时更新配置 manifest、中英文配置/MCP/Server API 文档和 patch changeset。
Behavior Changes and Affected Users
require_trust默认true,非法值也回退启用,行为不变require_trust = falsetrue并/reloadKIMI_CODE_TRUST_WORKSPACE1按进程强制信任,假值不撤销记录require_trust = falsetrust()/untrust()与信任记录true,重新开启后按记录恢复trueconfig.toml的交互用户/reload或重启require_trust = true覆盖情况:
workspaces、workspaceTrust、mcpRegistry、mcpManagement、workspaceMcpConfig、initialization共 6 文件、144/144 通过,包含首轮全量测试发现的两个初始化恢复场景。workspaceTrust保持 21 个用例,测试总数未增加。false加载项目 MCP、真实 reload 恢复true、非法值 fail closed 均通过。agent-core-v2typecheck、仓库 lint、完整 build 和中英文 docs build 通过。Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docs的 changelog 同步步骤无法执行,因为当前基线不存在docs/scripts/sync-changelog.mjs。