2026-05-17 13:19:59 +00:00
|
|
|
DROP TABLE IF EXISTS tenant_invitations;
|
2026-07-05 02:25:37 +00:00
|
|
|
DROP TABLE IF EXISTS tenant_api_keys;
|
2026-07-27 07:01:43 +00:00
|
|
|
DROP TABLE IF EXISTS wiki_page_revisions;
|
|
|
|
|
DROP TABLE IF EXISTS wiki_page_issues;
|
|
|
|
|
DROP TABLE IF EXISTS wiki_pages;
|
|
|
|
|
DROP TABLE IF EXISTS wiki_folders;
|
2026-05-18 03:58:46 +00:00
|
|
|
DROP TABLE IF EXISTS user_kb_pins;
|
2026-05-16 15:04:03 +00:00
|
|
|
DROP TABLE IF EXISTS user_resource_favorites;
|
2026-02-28 05:22:07 +00:00
|
|
|
DROP TABLE IF EXISTS tenant_disabled_shared_agents;
|
|
|
|
|
DROP TABLE IF EXISTS agent_shares;
|
|
|
|
|
DROP TABLE IF EXISTS organization_join_requests;
|
|
|
|
|
DROP TABLE IF EXISTS kb_shares;
|
feat(rbac): lift org membership from per-user to per-tenant (Plan 3, #1303)
Before this change, the `organization_members` table keyed on user_id —
joining an org as a Viewer in tenant T meant only that one user got
visibility on shared KBs/agents, while the rest of T (including its
Owner) saw nothing. The mismatch surfaced as confusing UX bugs:
"my colleague shared this with us, why can't I see it?"
This change replaces `organization_members` with
`organization_tenant_members`. Membership and Org-RBAC role now key on
(org_id, tenant_id); `representative_user_id` stays as a display-only
label of the user who first brought the tenant in.
Permission resolution gains a 3-D cap so tenant-RBAC stays honest under
cross-tenant sharing:
effective = min(share.Permission, tenant_org_role, tenant_role_cap)
where tenant_role_cap pins tenant Viewers to OrgRoleViewer regardless
of the org-level grant. A Viewer in their own tenant cannot edit a
shared KB even if the org granted Editor — preserves the
"Viewer = read-only everywhere" promise.
Migration 000045 backfills `organization_tenant_members` from the old
table by collapsing each (org, tenant) group to its max role, then
renames the old table to `organization_members_pre_plan3` for safe
rollback. Sqlite mirror (Lite mode) is fresh-bootstrap: the init
schema replaces the old table directly.
Routes: member-management URLs change from `:user_id` to `:tenant_id`.
Org create / join / leave now require Admin+ in the caller's tenant —
joining an Org affects everyone in T, so the decision can't sit with
a Viewer.
Frontend: OrganizationSettingsModal + store update to address members
by tenant_id.
2026-05-15 13:49:54 +00:00
|
|
|
DROP TABLE IF EXISTS organization_tenant_members;
|
2026-02-28 05:22:07 +00:00
|
|
|
DROP TABLE IF EXISTS organizations;
|
|
|
|
|
DROP TABLE IF EXISTS custom_agents;
|
feat(agent): human-in-the-loop approval for MCP tool calls (#1173)
Add an opt-in human approval gate so Agent runs pause before executing
MCP tools that operators flag as dangerous, surface an approval card in
the chat UI, and only resume after the user approves (optionally with
edited args) or rejects.
Backend
- New mcp_tool_approvals table + repo/service to mark per-tool approval
required (PG migration 000042 + sqlite init).
- approval.Gate coordinates RequestAndWait / Resolve with sync.Once
delivery, configurable timeout, and Redis Pub/Sub fan-out so multi-
replica deployments work without sticky sessions.
- MCPTool.Execute integrates the gate; uses a round-level ApprovalCtx
(without the per-tool 60s timeout) for the wait, and re-derives a
fresh 60s exec ctx after approval so CallTool keeps a full window.
- New SSE response types (tool_approval_required / _resolved) and
EventBus events plumb approval state to AgentStreamDisplay.
- REST: list/set per-tool approval flag, resolve pending approval.
- Configurable via agent.tool_approval_timeout_seconds (yaml) or
WEKNORA_AGENT_TOOL_APPROVAL_TIMEOUT env (accepts seconds or Go
duration).
Frontend
- MCP settings: per-tool "require approval" switch on the test panel.
- Chat: ToolApprovalCard renders the pause point with editable JSON
args, validation feedback, mm:ss countdown that turns warning/danger
near deadline, and a resolved state that retains context.
- i18n strings added for zh-CN / en-US / ko-KR / ru-RU.
Docs
- docs/zh/mcp-approval.md covering behavior, config, API, deployment
considerations (Redis cross-instance, restart limitations).
2026-05-10 13:23:49 +00:00
|
|
|
DROP TABLE IF EXISTS mcp_tool_approvals;
|
2026-02-28 05:22:07 +00:00
|
|
|
DROP TABLE IF EXISTS mcp_services;
|
|
|
|
|
DROP TABLE IF EXISTS knowledge_tags;
|
|
|
|
|
DROP TABLE IF EXISTS auth_tokens;
|
feat(rbac): per-tenant audit log for RBAC events (PR 6, #1303)
PR 1-5 of the multi-tenant RBAC series enforce the role matrix; what
they don't do is keep a durable record of who did what. Today the
RBAC middleware logs "[rbac] role insufficient ..." to stderr -
perishable, not searchable. Operators cannot answer "who removed
Alice from tenant T-foo on Tuesday" or "did we 403 a probing user
200 times last hour" after the fact.
This PR adds a generic per-tenant audit log that:
- Captures mutating RBAC actions (member add/remove/role-change/leave)
durably from the tenant_member service after the repo write succeeds.
- Captures enforcement rejections (RequireRole / RequireOwnershipOrRole
denies under EnableRBAC=true) via a gin-context-injected hook.
- Sliding-window dedup (1 minute) on (tenant, actor, action, path)
for denied events so a probing client cannot flood audit_logs.
- Default-on - no extra env flag. Schema is generic enough for future
KB / agent / datasource events to reuse via new action namespaces
without another migration.
Schema (migration 000044) mirrors wiki_log_entries' shape: a single
audit_logs table with action, target_type/id, request path/method,
outcome, and a JSONB details column. Three indexes: (tenant_id, id
DESC) for the per-tenant cursor feed, actor_user_id for "what did
Alice do", (tenant_id, action) for both the action filter and the
dedup lookup. Sqlite mirror added for Lite mode.
Wiring is nil-safe: the audit field on tenantMemberService and the
gin-context lookup in rbac.go both tolerate a nil service so existing
tests construct without a stub and dormant deployments degrade
gracefully if the provider is misconfigured.
The query API is GET /tenants/:id/audit-log, gated by Admin+ on top
of the existing PathTenantMatch (denial histories should not surface
to ordinary members). Cursor-paginated by descending id (sidesteps
the duplicate-timestamp tie-breaking that BIGSERIAL trivially solves).
Frontend: TenantMembers.vue gets a t-tabs wrapper with Members
(existing) and Audit log (new) tabs; the audit tab is gated to
Admin+ to mirror the server, lazy-loads on first open, paginates via
the next_cursor pattern, and renders coloured chips per
action/outcome so an operator can scan for anomalies. i18n keys
added in all four locales.
Tests: 14 new tests across service (6), middleware (4), and handler
(4). Service tests pin the dedup window behaviour (writes again
after expiry, dedup is per-actor-per-path, degrades on lookup
error). Middleware tests pin both reject sites' audit hook and the
"dormant mode does not fire" + "nil audit does not panic"
invariants. Handler tests pin the cursor envelope and that an empty
page returns next_cursor=0.
Out of scope: per-action ACL on the audit log, retention/TTL job,
KB/agent/datasource event wiring (schema supports it - just no
emitters yet), async writes, frontend filter UI.
2026-05-14 13:07:48 +00:00
|
|
|
DROP TABLE IF EXISTS audit_logs;
|
2026-05-13 11:47:48 +00:00
|
|
|
DROP TABLE IF EXISTS tenant_members;
|
2026-02-28 05:22:07 +00:00
|
|
|
DROP TABLE IF EXISTS users;
|
|
|
|
|
DROP TABLE IF EXISTS chunks;
|
|
|
|
|
DROP TABLE IF EXISTS messages;
|
2026-07-16 06:48:20 +00:00
|
|
|
DROP TABLE IF EXISTS temporary_documents;
|
2026-02-28 05:22:07 +00:00
|
|
|
DROP TABLE IF EXISTS sessions;
|
|
|
|
|
DROP TABLE IF EXISTS knowledges;
|
|
|
|
|
DROP TABLE IF EXISTS knowledge_bases;
|
2026-07-15 05:26:29 +00:00
|
|
|
DROP TABLE IF EXISTS storage_backends;
|
feat(resource): add stable resource registry with LLM-context alias compaction
Introduce resource://<handle> as the stable application identity for stored
objects, decoupling API responses, persisted rich text, and LLM prompts from
physical storage paths. Adds a resource catalog service (register/resolve/bind,
revocable expiring access grants), a request-local alias registry that compacts
resource references while in the LLM context and restores them (including across
streaming chunks), plus router, IM, chat-pipeline, and multimodal integration.
Includes schema migrations (resources, resource_bindings, resource_access_grants)
for sqlite, and hardens URL/output security handling.
2026-07-15 08:31:21 +00:00
|
|
|
DROP TABLE IF EXISTS resource_access_grants;
|
|
|
|
|
DROP TABLE IF EXISTS resource_bindings;
|
|
|
|
|
DROP TABLE IF EXISTS resources;
|
2026-02-28 05:22:07 +00:00
|
|
|
DROP TABLE IF EXISTS models;
|
|
|
|
|
DROP TABLE IF EXISTS tenants;
|