WeKnora/internal/router
lyingbug 687b178706
feat(agent): add the built-in WeKnora assistant with an operation catalog (#4302)
* feat(agent): add the built-in WeKnora assistant with an operation catalog

Adds builtin-weknora-assistant, which inspects and manages WeKnora with the
signed-in user's permissions:

- find_operations / run_operation over an allow-listed API operation catalog,
  dispatched in-process through the real router as the user
- builtin approval for write/destructive operations, refused when
  non-interactive
- agent attribution in knowledge base activity, including async tasks
- page_context request field, narrowed to the turn's search targets and
  rendered into runtime_context with model handles

* refactor(agent): compile the operation catalog from x-agent Swagger annotations

The catalog was a hand-written copy of what the swag annotations already
describe: routes, parameters, enums and response shapes. It now compiles
from the Swagger document embedded in the binary. Handlers opt in with

  // @x-agent      {"id":"knowledge.delete","risk":"destructive",...}
  // @x-agent-hint "Cannot be undone."
  // @Param        id path string true "知识ID" extensions(x-agent=knowledge_id)

and response types mark the fields the model may see with an
extensions:"x-agent" struct tag. Exposure stays opt-in at every level:
unmarked operations, parameters and fields are not reachable, so a new
field on Knowledge or a new query parameter never reaches the model by
accident. NewCatalog still enforces the safety rules (forbidden areas,
risk versus method, approval targets), and a test fails when the
annotations and docs/swagger.json disagree.

The twelve operations compile to the same routes, parameters and
results as before; document results now share one field set, and the
parse_status filter accepts deleting, which the API supports.

* fix(agent): enforce resume and wiki context scopes
2026-10-15 12:18:30 +08:00
..
deployment_capabilities.go feat(lite): install and run skills on the host (#3661) 2026-09-24 21:30:34 +08:00
deployment_capabilities_test.go feat(sandbox): run unpinned Lite sessions on the host OS sandbox (#3549) 2026-09-22 19:35:03 +08:00
embed_frame_policy_test.go fix(embed): enforce host origin allowlists on framed pages 2026-09-14 18:03:57 +08:00
files.go fix(security): close cross-workspace access paths in shared spaces (#3408) 2026-09-18 22:00:02 +08:00
model_catalog_test.go feat(models): add system admin model catalog console (#3662) 2026-09-24 16:31:45 +08:00
operations.go feat(agent): add the built-in WeKnora assistant with an operation catalog (#4302) 2026-10-15 12:18:30 +08:00
operations_test.go feat(agent): add the built-in WeKnora assistant with an operation catalog (#4302) 2026-10-15 12:18:30 +08:00
rbac.go refactor(resource-access): unify scoped authorization and transfer recovery (#3097) 2026-09-08 15:36:33 +08:00
rbac_selfcheck_test.go Refine scoped API key capabilities 2026-07-07 12:00:13 +08:00
router.go feat(agent): add the built-in WeKnora assistant with an operation catalog (#4302) 2026-10-15 12:18:30 +08:00
router_api_key_capabilities_test.go feat(mcp): let callers without a browser obtain MCP OAuth tokens (#4229) 2026-10-13 16:37:24 +08:00
router_api_key_management_test.go feat: support updating API key configuration 2026-08-12 11:43:03 +08:00
router_files_test.go fix(knowledge): claim cloned and released document images in the resource catalog (#3752) 2026-10-09 13:01:26 +08:00
router_knowledge_download_test.go feat(knowledge): add batch file downloads (#3300) 2026-09-16 15:40:10 +08:00
router_presigned_preview_test.go fix(security): close cross-workspace access paths in shared spaces (#3408) 2026-09-18 22:00:02 +08:00
router_presigned_test.go fix: align client sessions and integration request handling (#3305) 2026-09-16 16:20:57 +08:00
router_static_test.go feat(resource): add stable resource registry with LLM-context alias compaction 2026-07-15 17:02:43 +08:00
router_wiki_test.go Remove redundant Wiki operation log 2026-07-28 11:18:33 +08:00
routes_agent.go feat(agent): persist human-in-the-loop prompts with a shared broker (#4250) 2026-10-14 20:37:28 +08:00
routes_auth_tenant.go feat(system): add platform user management and streamline settings (#4153) 2026-10-11 17:07:00 +08:00
routes_chat.go feat(session): in-place rewind with workspace checkpoint reset (#3469) 2026-09-20 21:01:00 +08:00
routes_infra.go feat(agent): persist human-in-the-loop prompts with a shared broker (#4250) 2026-10-14 20:37:28 +08:00
routes_knowledge.go feat(gallery): filter images by source document (#4159) 2026-10-12 15:43:28 +08:00
routes_mcp_endpoint.go feat(mcp): add built-in MCP server with per-workspace endpoints (#3371) 2026-09-17 22:40:05 +08:00
routes_mcp_endpoint_test.go feat(mcp): support 2026-07-28 alongside legacy clients (#4095) 2026-10-10 15:15:06 +08:00
routes_memory.go feat(memory): add cross-session long-term memory 2026-08-13 18:00:02 +08:00
static.go fix(embed): enforce host origin allowlists on framed pages 2026-09-14 18:03:57 +08:00
sync_task.go revert: take the plugin system back out of main 2026-09-26 14:58:18 +08:00
sync_task_options_test.go fix(knowledge): stop parses from getting stuck in processing or finalizing (#3696) 2026-09-25 13:26:38 +08:00
sync_task_retry_test.go fix: retry document summaries before fallback 2026-08-05 19:29:32 +08:00
task.go revert: take the plugin system back out of main 2026-09-26 14:58:18 +08:00
task_dead_letter_attempt_test.go fix(knowledge): stop parses from getting stuck in processing or finalizing (#3696) 2026-09-25 13:26:38 +08:00
task_delete_scope_test.go refactor(resource-access): unify scoped authorization and transfer recovery (#3097) 2026-09-08 15:36:33 +08:00
task_inspector.go feat(knowledge): flag documents that stop making progress (#3557) 2026-09-22 21:34:08 +08:00
task_inspector_errors.go fix(task-inspector): handle lazy queue not found errors 2026-07-23 14:24:21 +08:00
task_inspector_errors_test.go fix(knowledge): recover stranded deleting rows and align the KB count (#3367) 2026-09-18 00:55:44 +08:00
task_inspector_kb_cancel_test.go fix(tasks): dequeue work for deleted knowledge bases 2026-07-23 12:17:14 +08:00
task_inspector_queued_ids_test.go feat(knowledge): flag documents that stop making progress (#3557) 2026-09-22 21:34:08 +08:00
task_inspector_runtime_test.go fix(task-inspector): handle lazy queue not found errors 2026-07-23 14:24:21 +08:00
task_processing_scope_test.go refactor(resource-access): unify scoped authorization and transfer recovery (#3097) 2026-09-08 15:36:33 +08:00