WeKnora/internal
lyingbug ba253bcbac
feat(agent): unified agent permission model with grants and run modes (#4490)
* refactor(agent): route approval decisions through a single policy

Operations, assistant write tools, MCP tool approval, delegated-child
approval and the child tool guard each compared access levels on their
own. They now ask policy.Decide, which maps an action's risk and the
run's rules to allow or ask. Behaviour is unchanged: MCP tools still
follow only the workspace per-tool flag and delegation, and a write that
reaches a read-only run still asks.

Add design docs for the agent permission model and scheduled automation.

* refactor(agent): replace interactive flags with a run mode

Runs are attended, deferred or unattended. Unattended runs refuse every
approval, including MCP approvals that used to wait out the timeout;
deferred runs suspend at once.

* feat(agent): apply access levels to MCP tools and every agent

MCP tools get a risk: the workspace's explicit setting, else the service's
readOnlyHint, never lower than a risk the service declared before. The
run's access level now decides MCP calls as it does operations; read-only
runs neither see nor run tools that change data. Ordinary agents get a
configurable ceiling that defaults to auto_write, and delegated children
take the lower of their parent's level and their own ceiling instead of
asking for every MCP call.

* feat(agent): persist approval grants with session/automation scopes

Remembered "allow for this conversation" approvals move from prompt history
into an agent_grants table keyed by root session (or automation binding), so
delegated children share the root grant and unattended runs honour it.
MCP write tools now offer the grant, keyed by service, tool and input schema.
Users can list and revoke their grants from the chat header.

* feat(agent): acting-via identity, decision logs and grant lapse reasons

Principal gains ActingVia so work done on a user's behalf (automations) is
told apart in audit details and policy decision logs. Every non-read policy
decision is logged with its action, risk, level, mode and verdict.
Automation grants bind to a hash of the agent setup, owner role and access
ceiling; a grant that no longer applies asks again and the card says why.

* docs(agent): record permission model implementation status

* chore(handler): check c.Error in agent grant handlers

* chore(handler): check c.Error in MCP tool policy handler

* fix(agent): raise MCP observed risk atomically and scope worker access

- Compare observed_risk inside the upsert so a stale lower observation
  cannot overwrite a higher one recorded concurrently.
- Delegated workers use the same conditional level as attach: the
  assistant ceiling applies only under an assistant parent.
- Mock @/api/assistant in useModalShell tests; gofmt internal/mcp/client.go.

* docs(agent): allow destructive pre-grants only in automation scope

Decide against a level that skips every prompt: Always stays
unwaivable and destructive actions may only be pre-approved per resource
when an automation is set up. Note that automation runs must look up
both automation and session grants.

* feat(agent): standing grant scope and risk-bounded grants

Grants record the risk they were approved for and never cover a riskier
call. Destructive calls are now named for matching, so an automation's
standing grant can cover one, but the card still offers to remember only
writes. The gate looks up the run's own scope and then its standing
scope; approvals during a run are written only to the run's scope.
2026-10-19 20:52:15 +08:00
..
agent feat(agent): unified agent permission model with grants and run modes (#4490) 2026-10-19 20:52:15 +08:00
application feat(agent): unified agent permission model with grants and run modes (#4490) 2026-10-19 20:52:15 +08:00
assets feat(assets): add ASR test audio file and embed it in the application 2026-04-02 21:27:27 +08:00
browserskill fix(browser): refine connection and preview UI with extension version 2026-09-23 10:57:59 +08:00
common fix(markdown): sanitize invalid UTF-8 and NUL bytes 2026-08-31 12:24:35 +08:00
config feat(agent): persist human-in-the-loop prompts with a shared broker (#4250) 2026-10-14 20:37:28 +08:00
container feat(agent): unified agent permission model with grants and run modes (#4490) 2026-10-19 20:52:15 +08:00
database feat(agent): unified agent permission model with grants and run modes (#4490) 2026-10-19 20:52:15 +08:00
datasource fix(feishu): stop logging tenant access token fragments (#4399) 2026-10-17 23:25:02 +08:00
embedpolicy fix(embed): enforce host origin allowlists on framed pages 2026-09-14 18:03:57 +08:00
errors feat(knowledge): flag documents that stop making progress (#3557) 2026-09-22 21:34:08 +08:00
event feat(agent): unified agent permission model with grants and run modes (#4490) 2026-10-19 20:52:15 +08:00
filetransport refactor(resource-access): unify scoped authorization and transfer recovery (#3097) 2026-09-08 15:36:33 +08:00
handler feat(agent): unified agent permission model with grants and run modes (#4490) 2026-10-19 20:52:15 +08:00
im fix(im): cap IM callback bodies before any adapter reads them (#4369) 2026-10-16 17:16:15 +08:00
infrastructure feat(assistant): add durable multi-agent collaboration and live task views (#4438) 2026-10-19 12:14:15 +08:00
ipclass fix: align client sessions and integration request handling (#3305) 2026-09-16 16:20:57 +08:00
localsandbox feat(lite): install and run skills on the host (#3661) 2026-09-24 21:30:34 +08:00
logger fix(logger): keep LLM debug records inside their directory 2026-09-25 18:22:14 +08:00
mcp feat(agent): unified agent permission model with grants and run modes (#4490) 2026-10-19 20:52:15 +08:00
mcpserver test(mcp): cover read_document query and pagination contract (#4426) 2026-10-17 23:17:26 +08:00
middleware feat(assistant): expand management operations and polish interaction UI (#4427) 2026-10-17 14:35:58 +08:00
modelcontext fix(agent): let open_page finish the turn with the answer above it (#4472) 2026-10-19 14:47:43 +08:00
models feat(assistant): add durable multi-agent collaboration and live task views (#4438) 2026-10-19 12:14:15 +08:00
productdocs feat(agent): let the WeKnora assistant read the bundled documentation (#4303) 2026-10-15 13:06:58 +08:00
ratelimit feat(embed): add backend embed channels with auth and rate limiting (#1657) 2026-06-12 23:10:39 +08:00
reranking perf(reranking): accelerate MMR selection with sparse postings 2026-10-10 20:06:30 +08:00
router feat(agent): unified agent permission model with grants and run modes (#4490) 2026-10-19 20:52:15 +08:00
runtime fix(server): run ResourceCleaner on signal shutdown instead of racing Fatalf exit (#3804) 2026-09-28 23:37:36 +08:00
sandbox feat(sandbox): Docker 后端支持交互式终端 (#4023) 2026-10-10 21:38:03 +08:00
searchutil feat: judge image hits by their image in rerank and show them to vision models (#4013) 2026-10-09 13:01:48 +08:00
sourceloc fix(citations): 修复原文定位、高亮范围与 DocReader 启动失败 (#3794) 2026-09-27 20:32:26 +08:00
storageallowlist fix(storage): align default provider fallback with STORAGE_ALLOW_LIST 2026-07-15 11:05:00 +08:00
storageurl feat: judge image hits by their image in rerank and show them to vision models (#4013) 2026-10-09 13:01:48 +08:00
stream feat(agent): persist human-in-the-loop prompts with a shared broker (#4250) 2026-10-14 20:37:28 +08:00
textconv fix: remove GPL converter and bundle third-party license sources 2026-09-08 15:19:10 +08:00
tracing/langfuse fix(models): align configuration and multimodal embedding workflows (#4080) 2026-10-10 11:06:00 +08:00
types feat(agent): unified agent permission model with grants and run modes (#4490) 2026-10-19 20:52:15 +08:00
utils fix(agent): scope database queries to authorized shared knowledge bases (#4136) 2026-10-12 11:26:34 +08:00