feat(agents): add OpenCode permission-policy write-through (AionUi #4018) - #845
Open
whyihaveyou wants to merge 1 commit into
Open
feat(agents): add OpenCode permission-policy write-through (AionUi #4018)#845whyihaveyou wants to merge 1 commit into
whyihaveyou wants to merge 1 commit into
Conversation
Pilot for iOfficeAI/AionUi#4018: manage an external agent's permission policy from AionUi by writing through to the agent's own config file. - aionui-mcp/permission: normalized PermissionLevel (ask/auto_edit/full_auto), PermissionPolicyView, and a PermissionPolicyAdapter trait mirroring McpAgentAdapter so more agents can follow the OpenCode pilot later. - adapters/opencode_permission: reads/writes the 'permission' field of ~/.config/opencode/opencode.json (ask/auto-edit/full-auto -> opencode schema), atomic temp-file+rename persist; reuses the opencode.json JSONC helpers. - permission_routes + app wiring: GET/PUT/POST /api/agents/permission-policy[/{agent}] (+ clear), registered behind auth. Runtime approval cards are unchanged. - expose opencode.rs JSONC helpers as pub(crate) for reuse. - unit tests for level mapping, schema mapping, serde roundtrip.
10 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Add agent-side permission-policy write-through management as the pilot for
iOfficeAI/AionUi#4018
(manage an external agent's config from AionUi).
aionui-mcp/permission: normalizedPermissionLevel(ask/auto_edit/full_auto),PermissionPolicyViewread-model, and aPermissionPolicyAdaptertrait mirroringMcpAgentAdapterso more agents can follow the OpenCode pilot later.adapters/opencode_permission: reads/writes thepermissionfield of~/.config/opencode/opencode.json(ask/auto-edit/full-auto-> opencode schema),atomic temp-file+rename persist, reusing the existing opencode.json JSONC helpers.
permission_routes+ app wiring:GET /api/agents/permission-policy(list),GET/PUT /api/agents/permission-policy/{agent}(read / write-through),POST /api/agents/permission-policy/{agent}/clear(reset), all behind auth middleware.opencode.rsJSONC helpers aspub(crate)for reuse.Runtime approval cards are unchanged — this only adds the agent-side policy control.
Validation
cargo fmt --all -- --checkcleancargo clippy -p aionui-mcp -p aionui-app -- -D warningscleancargo test -p aionui-mcpall green (permission + opencode adapter + routing unit tests)cargo test -p aionui-app --no-runcompiles中文说明
AionUi 统一管理外部 Agent 配置的试点(issue #4018):后端新增
aionui-mcp/permission模块,把「权限级别」归一化为
ask(询问)/auto_edit(自动编辑)/full_auto(全自动)三档,并抽象出
PermissionPolicyAdaptertrait,当前只接入了 OpenCode 这一试点 adapter。OpenCode adapter 读写
~/.config/opencode/opencode.json的permission字段,采用临时文件 +rename 的原子落盘方式;HTTP 层新增
/api/agents/permission-policy系列接口(list / get / put / clear),全部挂在鉴权中间件之后。前端(AionUi 侧权限控件)由配套 PR 实现,依赖本 PR 的接口。