Commit Graph

300 Commits (main)

Author SHA1 Message Date
lyingbug eecfe4b3c8
feat(automation): scheduled agent runs with in-app notifications (#4492)
* feat(automation): scheduled agent runs with in-app notifications

Automations let a user have an agent run a task on a schedule as them.
The scheduler is database driven: every instance claims due rows with a
version CAS, so Lite and multi-instance deployments share one path.
Runs execute in deferred mode, suspend on approvals and notify the
owner; an answered prompt resumes the run from its snapshot. Standing
grants are promoted from approvals past runs asked for, bound to the
agent configuration and the owner's role.

Adds the automation, run and notification APIs, the automation.*
assistant operations, and regenerates the Swagger document.

* feat(frontend): automations page and notification bell

Adds an Automations page to the sidebar: a list with schedule, agent,
next run and last status; an editor with schedule presets, a custom
cron field, timezone and a live preview of the next runs; and a detail
drawer with run history, links into each run's conversation and the
standing approvals the owner can grant from past approval requests.

The top-right bell now merges pending invitations with in-app
notifications and polls for new ones.

* fix(automation): let the assistant schedule tasks and match the settings UI

The assistant never searched for automation operations, one-time times failed unless they were RFC3339, and the create, detail, and notification surfaces did not match the rest of the app.
2026-10-20 00:11:36 +08:00
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
lyingbug 966d841d19
feat(assistant): add durable multi-agent collaboration and live task views (#4438)
* feat(assistant): add persistent multi-agent collaboration and live task views

* fix(ci): wrap runtime notice message append

* fix(agent): preserve collaboration results and prevent duplicate execution

* fix(agent): fence panic followups and preserve approval timelines

* test(frontend): stub connector labels in assistant refresh fixture

* fix(migrations): avoid collaboration migration collision with main

* fix(assistant): preserve child continuations and artifact access

* fix(frontend): align artifact and icon checks with updated UI

* fix: enforce child approvals and finalize interrupted collaboration runs

* feat: support inherited temporary agent workers

* docs: clarify inherited worker scope and lifecycle

* fix: harden assistant retrieval and final delivery

* fix(agent): keep closed child prompts continuable and renew active deadlines

Expired child approvals were looked up by the child session, so the parent group stayed open and the run became needs_attention. Active collaborations also expired one hour after creation.

* fix(lint): clear golangci-lint findings on the collaboration PR

The previous CI run failed on line length, gofumpt, unchecked closes, and an unused dial parameter.

* fix(ci): use the public npm registry for frontend dependencies

* fix(agent): address collaboration review findings

- keep ordinary fallbacks when a turn delegated no work
- throttle lease/deadline heartbeats and drop duplicated child answers
- force-close or compact aggregates that exceed the size limit
- clamp completion budget to the model output limit
- honor prompt_suspend for non-collaboration tools
- clean up collaborations and child sessions on session delete, prune old rows
- bound concurrent child executions globally
- retry prompt classification and tolerate transient heartbeat errors
- scope prompt history to listed messages, reject nil tenants
2026-10-19 12:14:15 +08:00
Xinliang Zheng 164dafca85
feat(graph): add standalone JSON graph search API (#4395) 2026-10-17 23:00:55 +08:00
lyingbug 8776a2d92d
feat(assistant): let the assistant find skills and MCP services on the web (#4429)
* feat(assistant): let the assistant find skills and MCP services on the web

Enable web_search/web_fetch for the WeKnora assistant so it can locate a
skill source or MCP endpoint from a description, with prompt guidance on
sources, injected page text, console-only credentials and a missing search
provider. mcp_service.create now always asks the user.

Agent trials no longer stall on prompts nobody can answer: tool approvals
are refused at once and OAuth falls back to the non-interactive notice.

* fix(ci): wrap the unattended approval test constructor

golangci-lint rejects the NewGate call at 127 characters.
2026-10-17 15:25:08 +08:00
lyingbug 0d7516ea0a
feat(assistant): expand management operations and polish interaction UI (#4427)
* fix(assistant): polish interaction cards and stabilize composer context

Localize operation labels across all six UI languages and expose answer copying in the assistant panel. Refine question and page-link cards with a single open/return action, and keep the current-page context row at a stable height.

* feat(assistant): add common data source, chunk and knowledge base operations

* feat(assistant): support parsing configuration and batch FAQ updates

* feat(assistant): add MCP tool directory query and sync operations

* feat(assistant): manage web search providers and data source sync settings

* feat(assistant): add model configuration copy operation

* feat(assistant): add workspace profile members and system information operations

* feat(assistant): add system administrator queries and runtime diagnostics

* fix(frontend): polish assistant and resource card UI

Refine assistant composer layout, context controls and reply actions, including narrow-window alignment. Unify knowledge base, agent and shared-space cards with consistent icons, hover feedback, favorites, menus and compact localized statistics.

* fix(assistant): preserve concurrent settings and exclude upstream error secrets
2026-10-17 14:35:58 +08:00
lyingbug 7115cb2a61
feat(assistant): trial runs, session grants, page links, and MCP/model/skill management (#4375)
* feat(assistant): let the assistant check MCP services and retrieval

Add a probe risk for operations that change nothing but do real work
(connecting to a service, running a retrieval). Probes use POST, run
without approval at every access level, and are capped per run.

Open three operations on top of it:
- mcp_service.test: connect with the saved settings and report why not
- mcp_service.list_tools: list what a service offers before binding it
- knowledge_base.search: raw hybrid recall with thresholds, to explain
  why a document is or is not found

x-agent can now name one method when a handler documents several, and
catalog parameters accept numbers.

* feat(assistant): let the assistant try an agent it set up

Add try_agent: the assistant asks an agent one question the way a user
would and gets back its answer, the tools it called and the documents it
cited, so it can check a setup before calling it done.

- The trial runs as the signed-in user in a new agent_trial session kind,
  which ordinary listings already exclude and the API cannot create, and
  the session is removed afterwards. Runs are non-interactive, so tools
  that would ask the user are refused. Long-term memory is untouched: it
  is written only by the HTTP handler.
- The assistant itself, the Wiki fixer and the skill installer cannot be
  tried, nor any agent granted the operation catalog.
- A trial spends model calls and runs the agent's own tools, so it is a
  write for the access level: confirm asks, auto_write runs, read_only
  does not offer it. The confirmation card names the agent and question;
  ConfirmedTool now lets a wrapped tool supply that text.
- At most 3 trials per turn, 4 minutes each; the tool timeout is raised
  above that. Answers, tool errors and references are capped.
- The runner is bound to the session service after the container builds
  it, since the session service depends on the agent service.

* feat(assistant): let the user allow similar changes for the conversation

The confirmation card for a recoverable change now offers "allow this for
the rest of the conversation". Once chosen, later calls of the same kind
in the same session run without asking, so a batch tidy-up no longer
needs a click per item.

- What a grant covers is derived on the server, never taken from the
  model: the same catalog operation on the same knowledge bases (a
  document's knowledge base comes from the target read) or the same
  agent; the same Wiki tool on the run's Wiki knowledge bases; trials of
  the same agent. Deletions and operations without such a scope, such as
  creating a knowledge base, always ask.
- No new storage: the gate looks for an earlier approved prompt in the
  session with the same grant and allow_in_session set, for the same
  tenant and user. Grants therefore survive suspend/resume and replicas,
  and end with the conversation. A failed lookup asks again.
- The response validator accepts allow_in_session only on approval and
  only when the prompt offered a grant, so a client cannot widen it.
- The card shows the scope in the user's language. The model is told
  such calls may run without a card and that deletions always ask.
- describeTarget now returns its target read so the grant reuses it
  instead of reading again.

* feat(assistant): tell the assistant about settings pages and chat answers

Pages now report which page is open and, for the agent editor, which
section. The model and MCP settings name the model or service open for
editing, and chat answers gain an "ask the assistant" button that
attaches that answer. The backend resolves these for the assistant only:
models and MCP services in the caller's tenant without endpoints or
credentials, and messages through the caller's session read access, with
the question, an answer excerpt and cited sources quoted as data.

* feat(assistant): link the user to pages and filled-in forms

The assistant gains open_page, which shows a button to a knowledge base
or document, a Wiki page, an agent's editor at a tab, a model or MCP
service to edit, or a new model or MCP service with its form filled in.
Targets are read through the operation catalog as the user, so a link
never points at something they cannot open. Drafts take no credentials
and only http(s) endpoints without user info; the card shows the
endpoint, and the user enters keys and saves the form themselves.

* feat(assistant): manage MCP services, model names and skills

* fix(assistant): prefill model drafts on initial navigation

* feat(assistant): document tags, model catalog reads, clearer cards, live page refresh

- Operations project lists of objects; knowledge.get/list report tags.
- model.get shows provider, endpoint and capabilities; new
  model.list_providers and model.get_provider read the model catalog,
  including vendors an admin added.
- open_page and ask_user guidance: offer page buttons whenever the next
  step is the user's, word choices for the user.
- Chat cards: redesigned open-page card pinned under the final answer,
  ask-user inputs in the dock style, approval card with aligned fields,
  translated labels and a question built from the operation summary.
- Open pages reload after assistant changes: deletes and moves wait for
  the background task, Wiki edits now report their changes, KB list
  counts, tags and chat model selectors refresh.
- The assistant panel stays open across reloads within the tab.

* fix(ci): format assistant operation code and wrap long lines

* feat(assistant): let the assistant see, fill and open the page beside it

- read_page / fill_page tools answered by the browser over a page_action prompt,
  with refs, redaction, in-place text edits, undo card and a page-access switch
- composer shows the open page, dialog and selection; a selection bubble and an
  editor toolbar entry ask the assistant about the selected text
- edits scroll into view with a highlight and an inline undo bar
- open_page reaches any settings section, toolbox tool and list page, and can
  navigate there itself to read it, keeping the button when edits are unsaved

* feat(assistant): let the assistant open the tab it needs

A visible tab can be selected and re-read, and system settings can open straight to user management, so the next step is no longer blocked on the wrong tab.

* feat(assistant): expose read-only conversation operations

Add session.list, message.list, message.search and
message.chat_history_stats to the operation catalog, restrict the
sessions and messages areas to non-mutating operations, and search
messages with the raw query instead of the log-sanitized one.

* style(chat): restyle open-page and page-edit cards

* fix(ci): comply with assistant card styles and Go line limits
2026-10-16 23:36:01 +08:00
lyingbug 2fbfb44715
feat(assistant): let the assistant manage knowledge bases (#4353)
* feat(assistant): let the assistant manage knowledge bases

Create, update, and delete knowledge bases, tags, and manual Markdown,
and show those confirmations as labeled rows with model names.

* fix(assistant): satisfy lint on knowledge base operations

Check new error returns, wrap lines past 120 characters, and document the exported tag request types.

* fix(assistant): enforce knowledge base settings permissions and preserve patch fields
2026-10-15 23:54:14 +08:00
lyingbug 4d4acec418
feat(assistant): manage agents and skills, separate history, refresh pages (#4344)
* feat(assistant): let the assistant manage agents

Expose custom agents to the operation catalog (list, get, create, copy,
update, delete) plus read-only model and MCP service lookups, so the
assistant can set up agents end to end.

- Add PATCH /api/v1/agents/:id. PUT replaces the whole config, so a
  one-field change from the assistant would wipe the rest; PATCH only
  overlays the fields it carries and reuses the PUT validation path.
- Add x-agent-detail so long fields such as the system prompt are only
  projected for single-object reads, not lists.
- Add label_param so a create without a target is labelled by its name.
- The approval card lists agent setting changes and resolves model,
  knowledge base and MCP IDs to names.
- Deny sharing, publishing channels, credentials and OAuth routes; model
  and MCP endpoints, headers and secrets are never projected.
- Update the assistant prompt, starters, API docs and Go SDK.

* feat(assistant): list skills and configure agent skill scope

- Expose usable skill names for an agent sandbox without exposing skill
  administration or connection settings to the model.
- Validate PATCH selections against the workspace sandbox usable set so
  invented names and missing sandbox selections cannot be saved.
- Show skill changes in approvals and align the assistant prompt, API
  documentation, and Go SDK with focused refusal and projection tests.

* feat(assistant): isolate conversation history

- Keep assistant conversations out of ordinary session lists, search, artifacts and delete-all cleanup.
- Add private, paginated assistant history with session switching, confirmed deletion and stale-session recovery.
- Backfill session kinds safely on Postgres and SQLite, preserve kinds on forks, and align API docs and SDK coverage.

* feat(assistant): refresh pages after successful data changes

- Carry decoded mutation targets through live tool-result events without
  exposing refresh metadata to the model or persisted chat history.
- Coalesce page and selector refreshes, update document drawers, and warn
  about changed agents while preserving open editor drafts.
- Cover mutation, approval, stream, lifecycle and cache behavior with Go
  and Node tests using the existing frontend runner and component fixtures.

* feat(assistant): add agent page context and resource scope limits

- Attach verified agent context and persist personal scope across turns and approvals.
- Enforce resource boundaries before operation and Wiki approvals, including edited arguments.
- Add scope controls, translations, API and SDK support, and regression coverage.

* refactor(assistant): remove the scope limit

The scope picker confused users and duplicated what RBAC and the access
level already enforce. Keep the agent page context: the agent editor
still publishes agent_id and the backend still verifies it.

* feat(assistant): render operation and product-doc results

Show find/run operations and WeKnora docs as structured cards instead of raw JSON.

* feat(assistant): default new agents to smart-reasoning

Quick-answer cannot call MCP, and agent.update could not change the mode. New agents now start in smart-reasoning, and a patch can switch agent_mode.

* fix: resolve assistant management CI failures
2026-10-15 21:43:20 +08:00
lyingbug 450b6ed1b7
feat(assistant): side panel, access levels and role-aware operations (#4342)
* feat(frontend): add dockable assistant side panel

* feat(assistant): access levels, role-aware operations and assistant settings

* fix(assistant): preserve approval and workspace access safeguards
2026-10-15 18:18:22 +08:00
lyingbug a730a411d4
feat(agent): let the assistant manage FAQ entries (#4327)
* feat(agent): let the assistant manage FAQ entries

New operations: faq.list_entries, faq.get_entry, faq.create_entry,
faq.update_entry, faq.add_similar_questions and faq.delete_entries
(up to 20, each question named on the approval).

The catalog learns what FAQ needs:
- integer path parameters (entry_id) and integer lists (entry_ids);
  approval items resolve integer IDs too;
- x-agent-required, which makes the model send a field the API treats
  as optional. The FAQ update replaces the whole entry, so a left-out
  answer list, tag or answer strategy would be cleared;
- a body on DELETE, which the FAQ batch delete uses.

The FAQ list documents its page of FAQEntry instead of an untyped page,
and the delete body is a named type. FAQ tags are referenced by seq id,
so knowledge_base.list_tags also returns tag_seq_id.

* fix(agent): resolve FAQ operation lint failures

* fix(agent): preserve complete FAQ content during updates
2026-10-15 16:14:21 +08:00
lyingbug aaa1accebd
feat(agent): let the assistant delete and move documents in batches (#4319)
* feat(agent): let the assistant delete and move documents in batches

A batch target can now resolve each item: x-agent "items" names the list
parameter and a read run once per item, and the approval lists every
title under the knowledge base name. The list must be capped at
MaxApprovalItems (20) by x-agent-maximum, which now also bounds string
lists, so nothing approved goes unnamed. One item the user cannot read
blocks the whole batch before any prompt.

New operations: knowledge.batch_delete, knowledge.move (to another
knowledge base, destination named on the card),
knowledge.get_move_progress and knowledge_base.list_move_targets.
The move and move-progress Swagger responses now show their data
envelope.

The approval card keeps line breaks in its description and renders
trailing "- " lines as a scrollable list.

* fix(agent): reconcile batch approvals with workspace operation updates

* fix(agent): keep every batch approval item visible
2026-10-15 15:57:58 +08:00
lyingbug a37a1bc51a
feat(agent): open more workspace operations to the WeKnora assistant (#4318)
* feat(agent): open more workspace operations to the WeKnora assistant

Reads: knowledge_base.list / list_shared / list_tags, knowledge.list_folders,
chunk.list, wiki.get_page / list_folders / list_revisions; knowledge.list
also takes tag_ids, folder_path and folder_recursive.

Recoverable writes: knowledge.update (title, summary), batch_reparse,
move_to_folder, rename_folder, create_manual, create_from_url,
knowledge_base.generate_profile, wiki.create_folder / move_page / revert.

x-agent gains catch_all for routes registered as *slug, which Swagger
cannot express. run_operation decodes knowledge_ids handles. The shared
knowledge base list, the tag page and the URL import body get concrete
Swagger types instead of free-form objects.

* fix(agent): show the assistant the change it is about to make

Manual documents can reach the API length limit, unpaginated lists cover
a tenant, and tag pages report their total. wiki.list_revisions can
return one stored revision before revert, and the confirmation card
names the URL, folder, version and documents.

* fix(agent): align catalog tests with the knowledge API allowlist

Catch-all assertions follow the knowledge routes, and the nested tag
page fixture stays inside an area the catalog accepts. The rune-limit
error also fits the line-length check.
2026-10-15 15:19:23 +08:00
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
lyingbug 234aa948db
docs(swagger): document the real request and response types (#4304)
* docs(swagger): add shared response envelope types

* docs(swagger): type knowledge base responses

* docs(swagger): add concrete response body types

* docs(swagger): type chunk list responses

* docs(swagger): type knowledge mutation responses

* docs(swagger): type wiki search and autofix responses

* docs(swagger): type FAQ responses

* docs(swagger): type tag responses

* docs(swagger): type message responses and SSE schemas

* docs(swagger): type agent responses

* docs(swagger): type remaining handler responses

* docs(swagger): regenerate OpenAPI spec

* docs(swagger): type knowledge, activity and wiki maintenance endpoints

Covers the endpoints left out of the earlier passes: knowledge base
detail, document list/detail/spans/reparse/cancel/delete, knowledge
base activity and the Wiki stats, issues, lint and rebuild-links
endpoints. The spans handler now writes the documented structs instead
of gin.H, so the schema cannot drift from the body; the JSON is
unchanged. List filters gain their real enums and bounds, including
the finalizing, cancelled and deleting parse states.

* docs(swagger): document JSON-valued fields as JSON, not byte arrays

types.JSON and json.RawMessage are byte slices, so swag rendered every
metadata, details and config field as an array of integers. A swag
overrides file documents them as objects; the four fields that hold
arrays (relation chunk ids, allowed origins, image refs) say so with a
swaggertype tag.

* chore(lint): exempt swag annotation lines from the line-length limit

swag reads each @Param, @Success and @Failure as a single line, so an
enum list or a composed response type cannot be wrapped to fit.

* chore(lint): exempt struct tags carrying swag attributes from the line limit

Struct tags cannot wrap either; a field documented with swaggertype or
extensions keeps its tags on the declaration line.
2026-10-15 01:41:42 +08:00
lyingbug a77d83fe0e
feat(search): add RRF controls in a tabbed settings popover (#4300) 2026-10-14 23:41:16 +08:00
lyingbug 383d26535a
feat(agent): persist human-in-the-loop prompts with a shared broker (#4250)
* feat(agent): persist human-in-the-loop prompts with a shared broker

Tool approvals and MCP OAuth prompts are now rows in agent_prompts,
awaited through hitl.Broker (lease, DB polling, Redis wake-up, per-kind
answer validation). Resolve is bound to session and kind. This is P1 of
the suspend/resume design; runs still block as before.

* feat(agent): suspend runs whose prompt outlives a short in-memory wait

Behind agent.prompt_suspend_enabled (off by default). A run raised from the
HTTP stream saves its state when a tool approval is raised; after the hot
wait the prompt moves to suspended and the assistant message is saved as
awaiting_input instead of blocking. A reaper takes over prompts whose
waiting replica stopped renewing its lease. Resume comes in a later change.

* feat(agent): resume suspended runs once their prompt is answered

The replica that records the answer resumes the run in process under the
prompt's lease. Superseded, expired and abandoned runs are closed with a
result for every tool call, and approved tools are never replayed.

* feat(agent): let users answer suspended tool approvals and follow the resumed run

* feat(agent): ask_user tool and generic prompt answer endpoint

- ask_user built-in tool: options, short forms or free text; validated
  answers, decline, suspend/resume like tool approval; non-interactive
  callers (IM, API keys) are told to ask in the reply instead
- POST /agent/prompts/{prompt_id} (and embed variant) answers ask_user
  and tool_approval prompts, returns resumed; SDK ResolveAgentPrompt
- agent_prompt_required/resolved events; AskUserCard sharing the
  countdown with ToolApprovalCard; answered questions rebuilt as cards
  from history
- awaiting-input messages keep their steps expanded so the pending card
  stays visible; prompt cards keyed by their own id
- i18n for all locales; design doc updated

* fix(agent): keep prompt answers that race a suspending or vanished owner

- Resolve suspends a pending prompt whose owner's lease lapsed, as the
  reaper would, so the answer resumes the run instead of waking nobody.
- Resuming waits for the suspending run to persist its message and clear
  its live-run marker; a marker left by a vanished owner is cleared.
- A resumed run that suspends again on a new prompt no longer has its
  message closed from the old state.
- tool_approval answers are decoded strictly and require "approved";
  fix the SDK doc that showed {"decision": "approve"}.
- API-key runs block instead of suspending, since they cannot answer.
- A run state that cannot be saved falls back to an in-memory wait, and
  NUL escapes are stripped from snapshots for jsonb.

* style(chat): align the ask_user card with the other interaction cards

Question and answer use the timeline's step text styles instead of
primary-colored and monospace text; options and form controls use the
compact step size, the number input spans the row, and the free-text
character counter is hidden.

* feat(chat): dock pending agent prompts above the composer

Tool approvals, ask_user questions and MCP OAuth prompts were answered
inline in the agent timeline, where a long answer or scrolling back
pushes them out of view. Open prompts of a streaming or suspended run
now gather in a dock above the composer (main chat and embed), one at a
time with a pager, lettered options and Enter to submit. The timeline
keeps a one-line record with a link back to the dock and the outcome
once answered. Views without a dock still answer inline.

* fix(agent): fence prompt ownership and preserve resumed turn context

* fix(agent): keep runs through consume errors and file prompts under the caller

Consume reported a store error as a lost claim, so an answer consumed
during a database hiccup detached its run: the message was never
persisted, the live-run marker stayed, and the reaper skipped the row
because the waiter had already dropped the snapshot. Consume now retries,
then decides from the row, and gives a run up only when the prompt is
known to have moved on.

Tool approvals and OAuth prompts of a shared agent were filed under the
agent's workspace, so the user's answer failed the tenant check and the
prompt timed out. Like ask_user, they now use the caller's workspace;
policy and token lookups stay in the agent's.

Enter on a picked option submits it instead of toggling it off, and
resume errors no longer report a nil cause.

* fix(agent): validate prompt choices and require durable approval claims

Reject malformed serialized option lists so the model can retry with valid arguments. Distinguish prompt consumption failures from lost ownership without authorizing side effects, and preserve native Enter selection for unselected choices.

* fix(agent): resolve prompt workflow lint errors
2026-10-14 20:37:28 +08:00
lyingbug 3e22822c1d
chore(release): finalize v0.8.3 website and documentation (#4285)
* chore(release): prepare v0.8.3 website and documentation

* docs(website): broaden release highlights and simplify browser layout

* docs(website): keep feature descriptions and screenshots in view

* docs(website): show four expanded release highlights

* docs(website): show browser states beside screenshots

* docs(website): unify section backgrounds and spacing

* fix(website): sync product screenshots and refine hero content

* fix(website): add gallery detail view and refine feature headings

* docs: illustrate mention resource selection in v0.8.3 release notes

* docs(release): finalize v0.8.3 release date and publication wording
2026-10-14 15:20:30 +08:00
Ochan Kwon e0712df3e0
feat(mcp): let callers without a browser obtain MCP OAuth tokens (#4229)
WeKnora runs behind other applications: they sign their users in and
call WeKnora with a tenant API key and X-External-User-ID, and WeKnora
keeps sessions and MCP OAuth tokens per external user. When an agent
uses an OAuth-protected MCP service, the only way to get that user's
token is the browser authorization code flow, and in this deployment
the user never sees WeKnora, so there is no browser to complete it.
Independently, an OAuth MCP service can only get its client through
dynamic client registration (RFC 7591), so authorization servers
without a registration endpoint cannot be used at all ("server does not
support dynamic client registration"), and servers that allow a grant
only to clients an administrator registered refuse a dynamic one.

JWT bearer grant. The application in front already knows who the user
is. POST /api/v1/mcp-services/:id/oauth/assertion lets it present a
signed assertion of that identity, such as the Identity Assertion JWT
Authorization Grant (ID-JAG) used by MCP's Enterprise-Managed
Authorization extension. WeKnora sends it to the service's
authorization server with the JWT bearer grant (RFC 7523) and stores
the token exactly like the callback does, so status, revoke, runtime
connections and, when the response carries a refresh token, refresh
use it unchanged. The assertion is forwarded unread; validating it is
up to the authorization server. The request reuses the principal from
authorize-url, the SSRF-safe HTTP client and the callback's connection
recycling, and the client the service already has. It does not run
dynamic client registration, which describes a redirect-based client;
without a client it answers 400. The token request outlives the caller,
so a token issued for an assertion that can only be used once is not
lost. A 4xx response other than 408 and 429, or a 2xx response carrying
an OAuth error, answers 400 with the OAuth error code and is logged; a
5xx, 408 or 429 response or a network failure answers 500. Request
logging masks the assertion field.

Pre-registered client. auth_config.client_id names a client registered
with the authorization server in advance, and client_secret is its
secret for a confidential client. When client_id is set it takes the
place of dynamic registration everywhere a client is read: the
authorization URL, the code exchange, the assertion grant and runtime
connections with their token refreshes. The values live on the service
rather than in mcp_oauth_clients, because a refresh rejected with
invalid_client deletes that row so the next authorization registers
again; an administrator's client would silently disappear. client_id is
non-secret: it is set through the main PUT, where an empty value clears
it, and returned in auth_config. client_secret follows api_key and
token: encrypted at rest, never returned, accepted in the create body,
and changed afterwards through the credentials subresource. Changing
client_id rebuilds the service's connections, and a connection built
with a pre-registered client is not treated as holding a replaced
registration when an authorization recycles connections. The MCP
service dialog adds optional Client ID and Client Secret fields to the
OAuth section, in all six locales.

Nothing changes for existing services: with client_id empty every
existing path reads the stored registration and registers dynamically
as before, and the authorization code flow, its state, the callback and
the dynamic registration request are untouched. The authorization
server HTTP client is moved into a function that both paths call.
2026-10-13 16:37:24 +08:00
Ochan Kwon 809bda7b2f
fix(agent): make agent tool selection match the tools the runtime registers (#4211)
The tools a smart-reasoning agent may use were defined in three places
that never checked each other: the agent editor's checkboxes, the stored
allowed_tools, and what registerTools registers. The editor drew from a
hard-coded list that had drifted (search_conversations, a default tool,
had no checkbox), hid stored entries outside that list, and could not
untick a tool whose knowledge base capability was missing. The save API
stored any name. And an empty list could not mean "no tools": three
places treated it as "use the default tools", so clearing every checkbox
gave an agent without a knowledge base search_conversations, while the
editor's preview said it had none.

One source for the tool list: GET /api/v1/agents/tools serves the tools
of AvailableToolDefinitions with their group, danger flag and knowledge
base requirement, the default tools, and the tools other agent settings
register whatever the list says. The editor renders from it, falling
back to the catalog's label for a tool it has no translation for.

Stored values stay visible: a missing capability only blocks ticking a
tool, and stored names the catalog does not offer are shown ticked in
their own section and can be removed.

An empty list now means no built-in tools; only a list that was never
set selects the defaults. tools.EffectiveAllowedTools makes that
decision for tool registration, the session config and the rerank
requirement. Migration 000116 (SQLite 000035) writes the default tools
into the empty list of every existing smart-reasoning agent, so they
keep the tools they ran with. The knowledge base filter follows the
stored list, so such an agent with an "all" scope now gets the same
scope as one that ticked the defaults: bases search_knowledge cannot use
leave it. The editor writes the defaults into an unset list it loads,
so saving does not silently turn the defaults into no tools.

Saving validates the list: retired names are rewritten, switch-managed
and retired skill tools are dropped, names the request adds that no
tool answers to are rejected with a 400 that lists them, and unknown
names already stored are kept so an existing agent can still be saved.
The response reports what was kept or dropped.
2026-10-13 11:29:24 +08:00
JLi 643f64180e
feat(system): add platform user management and streamline settings (#4153)
* feat(system): platform user management — list, enable/disable, reset password, role toggle

Adds a SystemAdmin-only user management panel under platform settings
(System global -> Access). The backend already had repository primitives
and promote/revoke endpoints; this wires the missing service/handler/route
for listing and account-status changes and adds the UI.

Backend
- New GET /system/admin/users: paginated, cross-tenant user list
  (offset/limit, limit capped at 200), serialised via ToUserInfo so password
  hashes are never exposed; has_more derived with a limit+1 fetch (no COUNT).
- New POST /system/admin/users/status: enable/disable an account.
  Disabling revokes all of the user's tokens immediately. Service guards
  reject self-disable and disabling the last active system administrator.
- ValidateToken now re-checks is_active on every request, so a disabled
  account cannot keep using a previously issued access token.

Frontend
- UserListDialog: table with status/role tags, pagination, in-page
  username/email filter, enable/disable and reset-password actions, and
  one-click system-admin promote/revoke (reuses existing endpoints) with
  confirmation prompts. Reset-password dialog is a sibling (not nested)
  dialog so close/cancel/overlay all work.
- All new strings are i18n keys under system.globalSettings.userList in
  all six locales (en-US, zh-CN, zh-TW, ja-JP, ko-KR, ru-RU).

Tests: handler unit tests for list pagination/redaction/limit-cap and for
status-change success/guard/404 paths; existing handler/service/router
suites pass.

Co-authored-by: MOSS Agent <noreply@example.com>

* fix(system): make account status changes atomic and validate requests

* refactor(system): streamline settings and add dedicated user management tab

* fix(system): resolve user management CI lint findings

* fix(system): preserve account status during ordinary user updates

---------

Co-authored-by: desksk <26273255+desksk@users.noreply.github.com>
Co-authored-by: MOSS Agent <noreply@example.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-10-11 17:07:00 +08:00
hahahahahayesyeseys 419f17fc65
fix(wiki): resolve titles for unloaded backlinks (#3931)
* fix(wiki): resolve titles for unloaded backlinks

* fix(wiki): return backlink titles with page details

* docs(wiki): verify backlink titles in page detail schema
2026-10-09 10:50:52 +08:00
hailongzhao bccb4b151b fix(embed): 内嵌网页只传图片不输入文字时不再返回 400
内嵌网页的输入框允许只带图片或附件就点击发送,但 CreateKnowledgeQARequest.Query
带有 binding:"required",parseQARequest 也拒绝空 query,于是只传图片直接返回
400 "Query content cannot be empty"。

入口处理:去掉 binding:"required";文字为空但带有内联图片数据或内联附件时,
用 types.UploadOnlyQuestion 生成一句替用户提问的问题(中文界面为「请根据我
上传的内容回答。」,其他语言为英文),交给模型、检索、标题、会话历史索引、
追问建议和记忆使用。只有 URL 的图片不算上传,因为客户端传入的图片 URL 会被
清掉;预上传的 attachment_ids 也不算,这类文件在流开始后才解析,可能失败或
超时,届时模型没有任何内容可答。其余空 query 仍返回 400。

存储与显示:qaRequestContext 新增 userInput,保存用户消息时只存用户实际
输入,只传图片时为空,刷新后与发送当下显示一致;query 仍是给模型的问题。
steer 追问复制上一轮的请求上下文,显式设置 userInput,避免在只传图片的一轮
之后把追问存成空消息。

会话历史:文字为空但带图片或附件的用户消息,在两处历史重建里补上同一句
问题。知识问答流水线(loadAndProcessHistory)原先会整轮丢弃;Agent 历史
(LoadAgentHistory)原先会发出空的用户消息,被 SanitizeMessages 剔除后
前后两条回答被合并。

去掉 binding 标签会让 gofmt 重新对齐整个 CreateKnowledgeQARequest 的行尾
注释,这些既有的超长行因此会被 PR 的增量 lint 视为新增。按仓库惯例把字段
注释移到字段上一行(注释文字不变,swagger 描述不受影响),并把 Go 字段
KnowledgeIds 改名为 KnowledgeIDs(JSON 名仍是 knowledge_ids,接口不变)。

同步更新 swagger 文档,query 不再是必填字段。
2026-09-30 15:26:51 +08:00
lyingbug e896270c41
docs(readme): surface agent tools in the overview and condense feature tables (#3688)
* docs(readme): name skills, sandbox, browser and MCP in the overview

The overview only mentioned the built-in MCP Server; the agent's own
tools (skill sandboxes, the local browser, external MCP services) first
appeared far down in What's New and the feature tables.

Add an "Agent tools and execution" bullet to all four READMEs, and
update the Agent capability card (README artwork and the homepage it is
copied from) to mention the local browser, with concrete tags instead
of "tool calling / skills".

* docs(readme): condense the English feature and client tables

The four feature tables had 42 rows, many written as release notes
(removed backends, deprecated packages) or UI details, and repeated
what the overview, product tour and What's New already cover.

Replace them with a seven-row feature table linked to the docs and a
supported-backends table that keeps every compatibility list. Drop the
MCP Server subsection and the three client detail blocks, which repeat
the clients table, and shorten the v0.7.x entries in earlier releases.

* docs(readme): drop the v0.8.2 screenshot row

The three screenshots rendered at a third of the column width, too
small to read, and the local browser shot already appears in the
product tour.

* docs(readme): move the agent toolbox out of "beyond the three modes"

Skills, sandboxes, the local browser and MCP tools are part of the
agent mode, not something beside it. Describe them in a short paragraph
right under the capability cards and keep the list for platform
capabilities.

* docs(readme): condense the CN, JA and KO feature and client tables

Bring the translated READMEs to the same structure as the English one:
a seven-row feature table linked to the docs, a supported-backends table
with every compatibility list, no MCP Server subsection or client detail
blocks, and one-line v0.7.x entries.
2026-09-25 09:53:19 +08:00
lyingbug 44a1df6046
docs(readme): website-matched design for all four READMEs (#3679)
* docs(readme): match the product website's look and drop slogan copy

Add hero and capability-card artwork (English and Chinese, light and dark)
drawn in the website's palette, type and line icons, plus small gold table
icons; docs/images/readme/src/generate.py rebuilds them. The copy in the
artwork is the homepage's own.

Replace per-bullet emoji and slogan-style lead-ins with plain labels, drop
emoji from headings and captions, add the homepage's three ways to get
started and the v0.8.2 product shots, restyle the badges in the brand
colors, and give the client table real logos or consistent line icons.

* docs(readme): bring JA/KO in line and add feature spotlights

Rebuild README_JA.md and README_KO.md on the same structure as the English
and Chinese READMEs, keeping their existing translations. Add what they
were missing: CLI and Mini Program entries, the contribution validation
steps, knowledge graph, access control and security rows, Zhipu
embeddings and Tencent Cloud COS. README_KO keeps its usage scenarios.

Generate Japanese and Korean hero and capability artwork with
language-specific CJK fonts, so Japanese kanji do not fall back to
Chinese glyph forms and Hangul wraps at spaces.

Replace the flat screenshot grid with four spotlights (local browser,
skills and sandbox, automatic wiki, observability), each pairing two
real screenshots in window frames; the remaining shots move to a
two-column "more screenshots" grid. docs/images/readme/src/spotlights.py
rebuilds the spotlight images.

* docs(readme): keep the browser task preview visible in its spotlight

The browser-connection window sat in the bottom-right corner, right over
the in-chat task preview that the main screenshot is meant to show. Let
each spotlight pick the corner for its side window and put the browser
one bottom-left, over the session list instead.

* docs(readme): make spotlight images clickable and sharp when opened

GitHub links a bare <img> to the full image but leaves <picture> inert,
so the spotlights could not be opened. Wrap each one in a link to its
image, and write the spotlights at 3200x1800 so the screenshots are
readable at full size and crisp on high-density displays.

* docs(readme): add Q&A and toolbox spotlights, drop the leftover screenshots

Add two spotlights: quick Q&A beside smart reasoning, and the toolbox's
MCP service tools beside its skill catalog. They cover the Q&A and skill
catalog shots from the screenshot grid, so the grid and its remaining
chunk editing, folder tree and wiki revision shots go.

* docs(readme): redraw the architecture diagram and widen the hero highlights

Replace docs/images/architecture.png with a generated diagram in the
same visual language as the rest of the README (per language, light and
dark), drawn from website-docs/02-architecture: clients and channels
feed the Go app, where RAG Q&A, agent reasoning and auto wiki share one
knowledge pipeline over workspaces, the model catalog, the task queue
and tracing; the app calls docreader, sandboxes, model providers, web
search, external MCP services and data sources, and stores data in
PostgreSQL (ParadeDB), Redis and the optional vector, object, Neo4j and
Langfuse stores. The old PNG was only referenced by the READMEs.

The hero listed only the three core modes; show eight highlights
instead (adding the local browser, skills and sandbox, MCP Server,
long-term memory, and data sources and IM) so the first screen reflects
the product's range. The capability cards below still explain the three
core modes.
2026-09-24 20:16:55 +08:00
lyingbug 63ef76dd80
docs: 迁移有效文档至 website-docs 并清理旧文档 (#3580)
* docs: consolidate maintained documentation in website-docs

* docs: remove migrated legacy documentation and update remaining references
2026-09-22 23:25:40 +08:00
wizardchen 640e356e31 fix(browser): rebase BrowserSkill patches and use native session lifecycle 2026-09-20 00:09:50 +08:00
lyingbug 2a6a9c2517
fix(ui): 优化知识库文档交互与对话布局 (#3420)
* fix(knowledge): streamline document browsing and tag editing

* fix(chat): align panel headers and refine composer spacing
2026-09-19 11:58:49 +08:00
lyingbug 03d9d66a1f
feat(agent): size agent history by the window and calibrate token estimates (#3413)
* feat(agent): size agent history by the window and calibrate token estimates

Agent history was capped at history_turns (default 5) because compaction
could not survive a turn. With checkpoints persisted, load history by
tokens instead, and let compaction bound the session.

Budget. The loader drops the oldest turns that do not fit, and what it
drops is lost: neither replayed nor summarized. A budget equal to the
compaction threshold (the earlier attempt, since reverted) let the loader
trim first, so whenever one turn was larger than the system prompt plus
the new question the request never crossed the threshold; nothing was
summarized and the session became a sliding window with no checkpoint.
agent.HistoryTokenBudget is now the whole window: overflow reaches the
first round's compaction, which summarizes it into a new checkpoint.
A turn-by-turn regression test drives the real loader, budget and
compactor and fails as soon as a stored turn after the checkpoint is
missing from the loaded history; restoring the old budget fails it.

Summarizer input. History can now reach the window, so the part being
summarized can outgrow one request. An overflowing request degrades to a
raw archive that is never persisted, so every later turn would fail the
same way. Prepare keeps the newest messages that fit, the prompt states
how many were left out, and file paths still come from all of them.

Calibration. cl100k counts Chinese at about a token a character where
Qwen and DeepSeek spend about 0.6. The estimator now carries a scale
(clamped to 0.5-1.5, text only), learned from consecutive requests in a
turn: they share tools, system prompt and earlier messages, so the
provider's growth between them prices exactly the appended messages,
without mixing in how a provider renders tool schemas. The turn's scale
is stored on its usage (context_token_scale); the next turn's loader
prices history with it and hands it to the engine. Loading, the first
compaction check and compaction itself share one estimator, so they
agree; calibrating only the trigger would let the loader drop turns
again, which the regression test covers.

Also: history is priced as the engine sends it (redacted KB/Wiki results
cost one line); a checkpoint older than the rows read is matched by the
assistant rows' (created_at, id) order; a read ending on a turn's
question keeps that turn; a compaction discarded for freeing under 5%
still persists its checkpoint; a checkpoint write matching no row is an
error; a partial index backs the newest-checkpoint lookup. Agent mode no
longer reads history_turns: the field leaves AgentConfig, the editor
hides it in smart-reasoning mode, and quick-answer keeps its turn cap.

* fix(agent): address review of window-sized history loading

Summarization. The summarizer call had a fixed 60s total timeout. With
history loaded up to the window, a request could carry ~175k tokens and be
cut off while prefilling or writing normally; the degraded result left no
checkpoint, so the next turn reloaded the same history and failed the same
way. Summarization now streams and is cancelled only after no output for the
engine's stall timeout (120s by default, LLMCallTimeout overrides), with the
overall ceiling left to the transport, as for the engine's own rounds and as
in Codex and Pi. A stopped turn is not retried. When the summarizer still
fails, the raw archive is persisted as a checkpoint marked degraded so the
loop is broken, and the next compaction refines it as the previous summary.
The archive is held to the summary budget, newest messages first, so a
degraded compaction always frees room.

Loading. The loader priced turns as sent but returned and held them as
stored, so wiki pages stored in full and sent as one line could pile up in
memory. It now returns the as-sent history and releases each turn's stored
rows once replayed, keeping about a page of rows at a time.

Index. The partial checkpoint index is replaced by a composite
(session_id, created_at DESC, id DESC) index serving the backwards page,
the newest-checkpoint lookup and the recent-messages reads. It is built with
CREATE INDEX CONCURRENTLY so writes to messages are not blocked; the
migration holds that single statement, since a multi-statement query runs as
an implicit transaction. A PostgreSQL integration test, skipped without
WEKNORA_MIGRATION_TEST_POSTGRES_DSN, applies the chain, runs 000106 down and
up through golang-migrate, and checks both queries use the index without a
sort; the SQLite migration test checks the same plans.

Calibration. It no longer waits for a total token count, and a usage with
only a scale is persisted. A turn that measures nothing carries forward the
scale it started from, so the newest turn always has the latest one.
2026-09-18 22:51:31 +08:00
lyingbug 2be7bd4063
fix(agent): search bound knowledge bases before answering, and pass suggested-question origins (#3400)
* fix(agent): search bound knowledge bases before answering, and pass suggested-question origins

A user picked the suggested question "为什么在比较图形时需要谨慎处理?"
and the agent answered in round 1 with no tool call, claiming it had
searched the knowledge base and found nothing, then explained misleading
statistical charts. The question had been generated from "Corners Don't
Look Like That: Regarding Screenspace Ambient Occlusion" in a bound base,
where "comparing graphs" means SSAO falloff curves.

Two things let that happen: the grounding prompt said "Stable general
explanations need no lookup", and nothing told the agent where the
question came from - the base in question had no profile, only two
recent titles in the directory, and the click sent the text alone.

Prompt
- With knowledge tools available, search bound bases before answering a
  question about a topic, even one that reads like general knowledge;
  directory profiles and recent titles cannot prove a base lacks it.
- The general-explanation exemption applies only without bound bases.
- Say you searched or found nothing only when a search tool ran.

Question origin
- Suggested questions from FAQ/document chunks also return knowledge_id.
- Picking one on the home or chat page sends question_origin
  {knowledge_base_id, knowledge_id} with that question only.
- The service keeps the origin only when its base is inside the turn's
  resolved scope and the document belongs to that base; it never
  changes the scope (unlike knowledge_base_ids, which narrows it).
- The engine renders it in runtime_context as <question_origin> with the
  base and document handles and a note to search it before answering.

* fix(agent): keep question origins across file/tag scopes and bind them to the send

Review follow-up for the suggested-question origin.

- Scope check: the origin was kept only when its base was in the resolved
  KB list, which is empty for file-only and tag-only scopes even though
  their bases are searched. It is now checked against SearchTargets after
  they are built; the document is kept only when a target for that base
  covers it (unfiltered base, or a document scope listing it).
  resolveQuestionOriginInfo re-checks SearchTargets, looks up the name of
  a base that is not in kbInfos, and the renderer omits an unknown name.
- Frontend: the origin travelled through module-level "pending" state, so
  a send that returned early (agent not ready, upload in progress,
  steering) left it behind and a second pick overwrote it. It now rides
  with the one send: triggerSend(text, options) -> createSession ->
  send-msg -> sendMsg / changeFirstQuery.
- RetrieveKBOnlyWhenMentioned: suggestions are still generated from the
  agent's bases, but picking one retrieved nothing. The origin now
  selects its base, as an @mention would, when the agent may read it.
- API sync: question_origin in docs/api/chat.md and swagger;
  QuestionOrigin on the Go SDK's KnowledgeQARequest/AgentQARequest and
  knowledge_id on SuggestedQuestion.
2026-09-18 17:00:47 +08:00
lyingbug 76a19f14c4
feat(mcp): add built-in MCP server with per-workspace endpoints (#3371)
* feat(mcp): add built-in MCP server with per-workspace endpoints

WeKnora previously exposed itself to MCP clients only through the Python
package under mcp-server/, which binds one process to one API key and
therefore to one workspace, and mirrors the REST API tool-for-tool.

This adds a native MCP server surface to the Go backend:

- New mcp_endpoints table (PostgreSQL 000100, SQLite 000020). A workspace
  can publish any number of endpoints, each with its own bearer token
  (SHA-256 stored, rotatable, shown once), knowledge-base allowlist, tool
  allowlist, default agent and per-minute rate limit.
- Management API under /api/v1/mcp-endpoints (Viewer reads, Admin writes,
  API keys need manage_channels) plus a tool catalog endpoint.
- internal/mcpserver hosts one mcp-go Streamable HTTP server in stateless
  mode at /mcp/:endpoint_id. tools/list is filtered per endpoint and
  tools/call re-checks the allowlist, applies rate limiting and touches
  last_used_at. MCPEndpointAuth resolves the token and injects the
  workspace, an mcp_endpoint principal and an API-key style scope derived
  from the endpoint, so existing knowledge-base and capability checks
  apply unchanged.
- Redesigned tool set (12 tools in four groups): retrieval and reading
  reuse the agent's native tools; ask runs the default or a named agent
  synchronously and returns a cited answer with a session_id for
  follow-ups; wiki tools cover search, read and index; write tools are
  off by default. Knowledge bases accept ids or names.
- Frontend: new "MCP Server" integrations tab (tab id mcpserver, to
  avoid clashing with the existing MCP-client settings section) with
  endpoint cards, a create/edit drawer, a one-time token dialog and
  ready-to-paste snippets for Cursor/VS Code/Claude Desktop, Claude Code
  and mcp-remote. Locales updated in all five languages.
- Deployment capability integrations.mcpserver wired on both sides.
- Docs: website-docs MCP page now leads with the built-in server; the
  Python mcp-server README carries a deprecation notice.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(mcp): wire the MCP server into DI/router and tighten authorization

The previous commit lost eight staged files to the repo pre-commit hook,
which resolves ROOT to the main checkout and re-adds the main-checkout
copies of tracked files into the worktree index. This commit restores them
(container providers, RouterParams and route registration, context key,
principal, clone table entry, deployment capability key, SQLite parity
test) and addresses the review findings:

- Knowledge-base scope is authorized, not trusted: endpoint allowlists and
  every tool call resolve each knowledge base through access.ResolveKB for
  the calling principal (ownership or organization share). Foreign IDs are
  rejected on create/update and dropped at call time.
- Write tools mint explicit editor grants via access.KBAccess.WithGrant
  before calling the knowledge service, so add/update/delete go through the
  same RequireKBWrite path as the REST API. add_document also checks the
  grant itself.
- ask no longer accepts agent_id. It runs only the endpoint's configured
  agent; tenant-owned agents and user-facing builtins qualify, internal
  builtins (wiki fixer, skill installer) are refused both on save and at
  call time. Web search is forced off for MCP calls.
- Tool annotations match behaviour: ask is not read-only, add_document is
  a mutation.
- CORS allows MCP-Protocol-Version / Mcp-Session-Id / Last-Event-ID and
  exposes Mcp-Session-Id for browser-based MCP clients.
- Rate limiter runs its local cleanup goroutine; SQLite migration gains the
  deleted_at index for parity with PostgreSQL; non-ASCII endpoint names get
  unique mcpServers keys derived from the endpoint id.
- Swagger annotations on the management handler.
- Tests: KB isolation (service and server), write grants, endpoint-agent
  restriction, tool annotations, and a router test that mounts the public
  /mcp/:endpoint_id surface and checks the deployment capability.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore(mcp): renumber migrations after rebase onto main

main took 000100 / 000020 for chunks_index_diet, so the mcp_endpoints
migrations move to 000101 (PostgreSQL) and 000021 (SQLite); the SQLite
parity test and docs follow.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(mcp): run document tools under the knowledge base owner tenant

Shared knowledge bases resolved through access.ResolveKB were only half
usable: documents of an organization-shared knowledge base are stored under
the owner tenant, so the document-level tools that queried by the calling
tenant found nothing, and add_document would have created rows under the
caller's tenant inside someone else's knowledge base.

- knowledgeInScope loads documents tenant-agnostically and then requires
  the document to belong to an allowed knowledge base and to that base's
  tenant.
- scopedKBContext replaces grantContext: it resolves the grant, switches
  the execution tenant to the knowledge base owner (KBAccess.Context) and
  swaps TenantInfo to the owner so storage/model settings resolve there.
  list_documents, read_document and every write tool run under it.
- Locale text and docs no longer claim clients can pass agent_id.
- Go SDK gains MCP endpoint methods (client/mcp_endpoint.go) with docs, and
  the Swagger artifacts are regenerated.
- Tests: shared knowledge base read/write under the owner tenant, spoofed
  document tenant rejected, viewer share cannot write.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore(mcp): renumber migrations after rebase onto main

main now carries 000101 / 000021 (knowledge_profiles), so the
mcp_endpoints migrations move to 000102 (PostgreSQL) and 000022 (SQLite);
the SQLite parity test expects version 22 and the docs follow.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(mcp): guard last_used touch without a repository and wrap SDK line

The transport tests build the server without a repository; the background
last_used_at write then dereferenced a nil interface and, on the slower CI
runner, took the test binary down. touchLastUsed now returns early when no
repository is wired, and the tests inject a recording repository and assert
the touch instead. Also wraps a 123-column SDK signature for the client
module's lll check.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-17 22:40:05 +08:00
wizardchen fa56b5b932 fix(docker): upgrade ParadeDB for CPUs without AVX2 2026-09-17 17:17:04 +08:00
wizardchen 559ad532ae refactor(frontend): consolidate knowledge tag filters and remove stale styles 2026-09-17 16:46:27 +08:00
wizardchen 820a14dafa refactor(datasource): share connector filename sanitization 2026-09-17 16:18:52 +08:00
wizardchen 10973ed321 test: isolate fork reset Git environment 2026-09-17 15:51:51 +08:00
wizardchen 38be45c9d1 refactor: remove unused private Go helpers 2026-09-17 15:51:51 +08:00
wizardchen d645334d08 refactor(frontend): share citation popover lifecycle 2026-09-17 15:28:31 +08:00
serply e80f5dfbc7 feat(web-search): add Serply provider
Serply returns Google results through a keyed JSON API, which fills the
gap between Google Custom Search (needs an engine ID and a restricted
scope) and the scrapers. The adapter follows brave.go: hardcoded
endpoint, redirects refused so the key never leaves the official host,
4MB response cap, and per-call country and freshness filters. country
maps to Google's gl parameter and pd/pw/pm/py map to tbs qdr:d/w/m/y.
Serply has no date-range filter, so that form returns an error instead
of being silently dropped. num is clamped to 10 because the API serves
one results page per call.

Wiring matches the Bocha provider: type constant and metadata, registry
factory, service validation, frontend union, swagger enum entries (edited
by hand; a full swag regen drags in unrelated drift), and the web search
docs table.
2026-09-17 12:25:09 +08:00
wizardchen 84c9871d16 fix(browser): align BrowserSkill 0.3.0 and repair task lifecycle 2026-09-17 11:54:12 +08:00
wizardchen f2606629b3 refactor(frontend): share skill install progress subscriptions 2026-09-16 23:12:14 +08:00
wizardchen 5bcc43d728 refactor(frontend): share skill installer model configuration 2026-09-16 20:58:03 +08:00
wizardchen bfa7f0ed69 refactor(frontend): remove unused components and share tag selection logic 2026-09-16 20:49:16 +08:00
lyingbug d7ccd5ba51
fix: align client sessions and integration request handling (#3305)
* fix: align client sessions and integration request handling

* fix: preserve trusted Doris redirects and prepare browser tests

* fix: align proxy address checks and integration test coverage
2026-09-16 16:20:57 +08:00
ttommybot a7d3545297
feat(knowledge): add batch file downloads (#3300)
* feat(knowledge): add batch file downloads

* fix(knowledge): harden batch file downloads

Skip entries without original files, keep folder paths in the ZIP, map
client cancel to 400, and cap concurrent archives so a full-select
download is usable without 500s or disk pile-up.

* fix(knowledge): format batch-download tests for pre-push lint

---------

Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-16 15:40:10 +08:00
lyingbug 06e8022476
feat(website): add product homepage and unified docs deployment (#3297)
* feat(website): add product homepage and unified docs deployment

* fix(website): build the unified site in a multi-stage Docker image

* fix(website): reveal and highlight the active documentation sidebar item
2026-09-16 11:58:37 +08:00
nullptr-error 6ccc5cedf1
feat(sandbox): add a graphical desktop to session sandboxes (#3245) 2026-09-14 20:37:37 +08:00
DEMO 5d3114fc9e
feat(datasource): add DingTalk Docs integration with safe sync and localization (#2313)
* feat(datasource): add DingTalk Docs integration

* fix(datasource): harden DingTalk sync and complete translations

* fix(datasource): close DingTalk review gaps in sync and rendering

Prefer millisecond node timestamps, keep full-sync deletion reconciliation, and stop dropping official block payloads so incremental updates and Markdown import stay complete.

---------

Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-14 19:53:29 +08:00
hujiaxin fc2c12e8ec fix(models): protect auto-tag model references 2026-09-14 19:29:19 +08:00
Jonesxq 350b2ab364
fix(milvus): support multilingual BM25 retrieval (#3235)
* fix(milvus): support multilingual BM25 retrieval

* fix(milvus): preserve source metric and tighten collection matching

Read the source embedding index metric during BM25 migration, match
collections by {prefix}_{dimension}, and route Japanese/Korean text to
the ICU fallback.

* fix(milvus): satisfy lint on multilingual BM25 changes

---------

Co-authored-by: Jonesxq <239089032+Jonesxq@users.noreply.github.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-14 19:18:24 +08:00
wizardchen 801ae18f91 fix(embed): enforce host origin allowlists on framed pages 2026-09-14 18:03:57 +08:00