Skip to content

feat(agents): add OpenCode permission-policy write-through (AionUi #4018) - #845

Open
whyihaveyou wants to merge 1 commit into
iOfficeAI:mainfrom
whyihaveyou:feat/opencode-permission-adapter
Open

feat(agents): add OpenCode permission-policy write-through (AionUi #4018)#845
whyihaveyou wants to merge 1 commit into
iOfficeAI:mainfrom
whyihaveyou:feat/opencode-permission-adapter

Conversation

@whyihaveyou

Copy link
Copy Markdown

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: normalized PermissionLevel (ask / auto_edit / full_auto),
    PermissionPolicyView read-model, 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, 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.
  • Expose opencode.rs JSONC helpers as pub(crate) for reuse.
  • Unit tests for level mapping, schema mapping, serde roundtrip.

Runtime approval cards are unchanged — this only adds the agent-side policy control.

Validation

  • cargo fmt --all -- --check clean
  • cargo clippy -p aionui-mcp -p aionui-app -- -D warnings clean
  • cargo test -p aionui-mcp all green (permission + opencode adapter + routing unit tests)
  • cargo test -p aionui-app --no-run compiles

中文说明

AionUi 统一管理外部 Agent 配置的试点(issue #4018):后端新增 aionui-mcp/permission 模块,
把「权限级别」归一化为 ask(询问)/ auto_edit(自动编辑)/ full_auto(全自动)三档,
并抽象出 PermissionPolicyAdapter trait,当前只接入了 OpenCode 这一试点 adapter。

OpenCode adapter 读写 ~/.config/opencode/opencode.jsonpermission 字段,采用临时文件 +
rename 的原子落盘方式;HTTP 层新增 /api/agents/permission-policy 系列接口(list / get / put / clear),
全部挂在鉴权中间件之后。前端(AionUi 侧权限控件)由配套 PR 实现,依赖本 PR 的接口。

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.
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.

1 participant