Skip to content

feat(agents): add agent permission-policy control (OpenCode pilot) - #4030

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

feat(agents): add agent permission-policy control (OpenCode pilot)#4030
whyihaveyou wants to merge 1 commit into
iOfficeAI:mainfrom
whyihaveyou:feat/opencode-permission-adapter

Conversation

@whyihaveyou

Copy link
Copy Markdown
Contributor

Description

Add an agent-side permission-policy control to the Agent settings page (OpenCode pilot for #4018). The backend (AionCore PR #845) exposes /api/agents/permission-policy* read/write routes; this PR adds the UI that reads the read-model and write-throughs the chosen level to the agent's own config file.

The control only renders when the backend reports the agent is supported and installed (OpenCode today, future agents plug in later). It offers three normalized levels (ask / auto_edit / full_auto) plus an unmanaged option, and re-polls the read-model after a write-through so the echoed value stays in sync with the agent's config.

Related Issues

Type of Change

  • feat — New feature (non-breaking change which adds functionality)

Atomic PR Checklist (Rule 1)

  • This PR contains exactly one feature or bug fix that cannot be further decomposed
  • The PR title follows Conventional Commit format: <type>(<scope>): <subject> (English)

Local Checks (Rule 3)

  • bun run format — formatting passes
  • bun run lint — no lint errors (0 errors; only pre-existing warnings)
  • bunx tsc --noEmit — no type errors
  • bunx vitest run — new tests pass (18 LocalAgents + 10 permission tests); full suite green except pre-existing failures that require resources/windows/*.nsh absent from a sparse checkout
  • i18n validated (bun run i18n:types + node scripts/check-i18n.js)
  • New/changed user-facing text uses i18n keys (13 locales)

Runtime Verification

  • I have performed a self-review of my own code

Additional Context

Dependency: this UI consumes the /api/agents/permission-policy* routes added in AionCore PR #845. Merge order: AionCore first, then this PR.

中文说明

AionUi 统一管理外部 Agent 配置(issue #4018)的试点收尾:AionCore PR #845 新增了
/api/agents/permission-policy 系列接口(list / get / put / clear),本 PR 实现对应的前端权限控件。

  • 在 Agent 设置页的官方 Agent 卡片下方新增「权限策略」下拉框,仅当后端返回该 agent
    supported && installed 时才显示(当前只有 OpenCode)。
  • 三个归一化级别:ask(询问)/ auto_edit(自动编辑)/ full_auto(全自动),另加
    「未设置」选项用于清除策略、回退到 agent 默认行为。
  • 写入后重新拉取 read-model,回显的值始终与 agent 自身配置文件保持一致。
  • 新增 ipcBridge.permissionPolicy(list / setLevel / clear)、模型文件、控件组件,
    以及 i18n(13 locale)与 Vitest 测试(模型 + 控件 DOM + LocalAgents 装配)。

…onUi iOfficeAI#4018)

Add a permission-level selector to the Agent settings page for external
agents (OpenCode pilot). It reads the backend's /api/agents/permission-policy
read-model and write-throughs the selected level (ask / auto_edit / full_auto)
to the agent's own config, then re-polls so the echoed level stays in sync.

- agentPermissionPolicy model: normalized levels, read-model types, and an
  actionable check (supported + installed).
- AgentPermissionControl: renders only when the backend reports the agent is
  supported and installed; clear option resets to agent default.
- LocalAgents wiring: fetch policy read-models, pass per-agent to the control,
  re-poll on change.
- ipcBridge.permissionPolicy: list / setLevel / clear routes.
- i18n: 13 locales + generated key types.
- Vitest: unit + DOM tests for model, control, and LocalAgents wiring.
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.84211% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/desktop/src/common/adapter/ipcBridge.ts 25.00% 3 Missing ⚠️
...derer/pages/settings/AgentSettings/LocalAgents.tsx 84.61% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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.

[Feature]: Unified config management for external agents (permissions / models / endpoints), OpenCode permission pilot first

1 participant