Commit Graph

623 Commits (80c7b2f2bd36db31dc81edfdcabc86d7b5cd9987)

Author SHA1 Message Date
wizardchen a826a1f12c fix(skills): verify runtime prerequisites and support installer steering 2026-09-09 23:04:59 +08:00
wizardchen 5cf093706e fix(chat): preserve steering continuity and composer focus 2026-09-09 20:15:23 +08:00
nullptr-error 3ab6d3940d
feat(sandbox): unify the interactive PTY prompt and reconnect running sandboxes (#3128)
* feat(sandbox): use a classic colored user@host prompt in the PTY

Cube, Docker, and E2B now share user@host:last-dir with WeKnora brand green, overriding E2B's default `\w $ ` prompt.

* fix(sandbox): redraw the PTY prompt after connect instead of waiting for Enter

Reattach does not replay bash's already-printed prompt, and FitAddon can clear the first paint. Fit before flushing output, then Ctrl-L if the screen is still empty.

* feat(sandbox): add Debian-style ll/la/l aliases in the interactive PTY

Interactive bash now gets colored ls/grep shortcuts; non-interactive skill scripts still see the real commands.

* fix(sandbox): restore conventional ls colors so directories stay blue

Map ANSI blue/cyan back to Tango colors so directories and executables are distinguishable; keep brand green only for user@host.

* fix(sandbox): correct runtime env-var hint to this config and create time

The copy claimed workspace-wide injection. Scope it to sandboxes created from this config, point per-run secrets to the Sandbox secrets page, and keep the hint off the add-button row so Chinese no longer wraps mid-word.

* feat(sandbox): attach a running session sandbox when the terminal opens

Opening the panel used to always show the start overlay. Lookup first so a running sandbox reconnects, while paused or missing sandboxes still wait for an explicit click and Connect cannot silently resume.

* fix(sandbox): do not inject PTY input or auto-connect a non-running sandbox

Empty-screen reconnect now SIGWINCHes so a reattached busy PTY is not fed
Ctrl-L. Lookup-only opens require a click unless List confirms running, and
closing the panel drops the terminal mount so a Files-tab reopen cannot attach.

---------

Co-authored-by: hailongzhao <hailongzhao@tencent.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-09 18:17:10 +08:00
nullptr-error fbaff900a0
feat(chat): append messages to a running agent turn (#3123)
* feat(stream): persist live-run markers and per-run steer queues

Mid-run sends need a cross-replica pointer to the generating
assistant and a control-plane list that never hits the SSE stream.

* feat(agent): inject queued user messages at ReAct round boundaries

The engine drains the steer sink after each round, persists accepted
rows, and delays Done until after a loop-end inject so the turn can continue.

* feat(session): expose /steer and hand leftover messages to a follow-up turn

Owner-scoped steer routes queue or inject into the live run, single-flight
AgentQA via the live-run marker, and history replay keeps multiple user rows
inside one turn.

* feat(frontend): queue mid-run messages while an agent turn streams

Stop and Send stay visible together, the overlay follows server delivery,
and history splits the transcript around injected user bubbles.

* fix(frontend): type pending and client_id on SteerQueueItem

vue-tsc failed because the overlay sets those fields while POST /steer is in flight.

* fix(session): harden steer persist, handoff, and new_run

Keep SetLiveRun ahead of SSE and roll back orphan turns, make inject
persist idempotent, append-then-delete on rebind, cap overrun rounds,
and stop aborting a live stream when /steer returns new_run.

* fix(session): satisfy pre-push lint on steer paths

Wrap long lines, check discarded Error/Emit results, and keep
context as the first argument so the fork push hook can pass.

---------

Co-authored-by: hailongzhao <hailongzhao@tencent.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-09 16:43:33 +08:00
wizardchen 73462de222 feat(mcp)!: streamline setup and use short routing handles
BREAKING CHANGE: Updates that explicitly include usage_instructions must supply nonblank text of at most 16000 characters. Omitting the field preserves existing instructions; legacy descriptions remain readable.
2026-09-09 16:11:52 +08:00
lyingbug 85b76d1a30
feat(mcp)!: persist tool catalogs and add guided configuration (#3118)
* feat(mcp)!: persist tool catalogs and add guided configuration

* fix(mcp): write caller-owned catalogs and require a real tool sync

OAuth viewers can now persist their own directory, and the setup wizard no longer treats an unsynced service as complete. Missing catalogs auto-fetch on the tools step; already-used MCP functions are restored across engine turns.

* fix(mcp): skip redundant list_servers and tighten catalog UI

When the advertised server directory already fits in discover_mcp_tools, models should list_tools or describe directly. Chat and settings now show server names, collapsed docs, and initialize debug metadata for empty optional fields.

* fix(mcp): surface catalog summaries and polish tool detail UI

List responses now include a saved catalog count without live MCP calls, so settings cards and @ mentions can show sync state. Tool details open in a popup instead of expanding the row.

* fix(mcp): drop incomplete Anthropic calls and gate shared catalog refresh

Unclosed streamed tool_use was emitted as {} and executed. list_tools refresh=true now re-lists upstream instead of returning the saved snapshot, and only Admin (or MCP-capable API keys) can overwrite tenant-wide static-auth catalogs.

* fix(mcp): wrap client refresh path to satisfy lll

The metadata refresh URL made doRequest exceed the 120-character limit in the client module CI lint.
2026-09-09 13:34:56 +08:00
nullptr-error 277d6ee851
feat(sandbox): add an interactive terminal and files tab beside chat (#3110)
* feat(sandbox): stream interactive PTYs from Cube and E2B

Give session sandboxes a provider-neutral terminal capability so a later
WebSocket layer can attach without knowing Cube vs E2B. Long-lived
streams use a timeout-free client; idle terminals keep the sandbox alive
by refreshing TTL, and a workspace can set how long to wait before
disconnect.

* feat(session): bridge browser terminals to the session sandbox

Mint a short-lived ticket over a normal authenticated POST so the browser
WebSocket never puts the access JWT in the query string. After upgrade,
recheck the bound token, membership, and session ownership so logout or
revocation tears the PTY down. Provisioning stays opt-in: a GET
handshake only creates a sandbox when the client sends provision=1.

* feat(chat): add a sandbox terminal panel beside the conversation

Open a side panel with an xterm attached to the session sandbox. Starting
the terminal is an explicit click so merely opening the panel does not
create or resume a microVM; reconnects stay lookup-only until the user
confirms create-and-start. Persist the remote shell PID in
sessionStorage so a refresh reattaches instead of spawning an orphan.

* feat(sandbox): let workspaces set terminal idle disconnect

Expose the idle-disconnect duration in the sandbox config editor so an
operator can close unused terminals and let the provider TTL pause the
sandbox, instead of leaving PTYs open for the built-in 15 minutes.

* feat(chat): show generated files in the sandbox side panel

Move the per-message artifact list into the first tab of the right-hand panel so generated files stay in view with the terminal. Keep the old drawer only for embedded chat.

* fix(sandbox-terminal): keep tickets out of logs and live PTYs across refresh

Gin was copying the handshake JWT into response_body logs, silent access-token
rotation dropped open terminals as AUTH_REVOKED, and first-use provisioning
missed shared agents. Local echo now skips password prompts.

---------

Co-authored-by: hailongzhao <hailongzhao@tencent.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-08 17:43:15 +08:00
lyingbug 3d81b977f1
refactor(resource-access): unify scoped authorization and transfer recovery (#3097)
* refactor(resource-access): unify scoped authorization and transfer recovery

* fix(resource-access): close reparse and transfer review gaps

* fix: enforce explicit file bindings and recover move cleanup

* fix: align mutation admission and cleanup scope checks
2026-09-08 15:36:33 +08:00
MidoriKurage c591f16d53 refactor(system): drop idempotent flag from create-user response body 2026-09-07 17:30:47 +08:00
LuckVd 4fb0b08719 fix(initialization): pass stored ExtraConfig to model connection test
fillSecretsFromStoredModel only copied APIKey/AppSecret from the stored
model into the test request, so the temporary test model built by
buildTestModel always had a nil ExtraConfig. Any provider-specific
setting (thinking_control, api_version, remote_model_name, ...) was
silently dropped from POST /initialization/remote/check, making the
'Test Connection' button validate a bare model instead of the stored
configuration — and masking fixes that depend on extra_config.

Request-provided values keep precedence: extraConfig is only filled
when the request does not carry one, matching the existing secret
semantics ('non-empty request values are always preferred').

Fixes #3057
2026-09-07 11:43:44 +08:00
lyingbug 3d3bb7f6d1
fix(system): keep one-time create-user passwords and copy full account details (#3039)
* fix(system): keep one-time create-user passwords from being discarded

Escape leaked to the Settings modal, and a double submit could replace a
201 reveal with an idempotent 200. Show the password in plaintext and
distinguish create vs retry via an idempotent body flag.

* i18n(system): update copy button and success message for account details

Changed the labels for the copy button and success message across multiple languages in the localization files to reflect the new terminology for copying account details instead of just passwords. This update enhances clarity for users when interacting with the Create User dialog.
2026-09-06 00:35:08 +08:00
ninesun 1e36e071ec
feat(mcp): add per-tool enable toggle (#2989)
* feat(mcp): add per-tool enable toggle

* style: format migration test

* fix(mcp): keep enable and approval updates from overwriting each other

Partial policy writes now touch only the supplied columns, and a missing
tenant fails closed so a disabled tool cannot slip through.

---------

Co-authored-by: myysophia <myysophia@users.noreply.github.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-05 17:19:20 +08:00
lyingbug d5cb842580
feat(agent): unify sandbox tools and drop host preloaded skills (#3033)
* feat(agent): unify sandbox tools and drop host preloaded skills

Read workspace and skill files through read_file, and run installed or staged skills through shell_exec(skill_name). Remove the unused skills/preloaded tree and keep generated-file previews stable across re-renders.

* fix(frontend): do not assume classList in markdown sanitize hooks

Node unit tests stub anchors without a DOM classList. Detect download cards from class/download attributes instead.
2026-09-05 16:45:59 +08:00
nullptr-error e39277a75e
feat(sandbox): add tenant-configurable network policy (#2995)
* feat(sandbox): add the tenant network policy with its secrets and validation

Administrators need control over sandbox network access, so a named sandbox
config gains a network policy block. It lives inside the existing config JSONB,
so there is no schema change and old rows read back as the zero value.

Both booleans are phrased so that the zero value IS the intended default --
outbound open, inbound closed. That makes "no network block" and "explicitly
saved defaults" provably the same thing, and avoids a tri-state pointer where
nil would have to mean "allowed" for egress and "closed" for ingress.

Injected header values are credentials, so they ride the encrypt-at-rest and
mask-on-read path EnvVars already uses instead of a parallel mechanism. One
CloneWithSecrets traversal serves encrypt, decrypt and mask so the three
directions cannot disagree about which fields are secret.

Validation runs at save time because the alternative is failing at
sandbox-create time, where the admin no longer has the form in front of them.
It rejects both what a provider would refuse and what a provider would accept
without doing what the admin meant -- a domain allowlist with no deny-all
fallback still leaves every unresolved destination reachable.

* feat(sandbox): apply the network policy on both providers, persist the inbound token

Resolve the stored policy into one fully specified provider-neutral policy so
that nothing downstream re-derives a default. Both booleans come out non-nil on
every path, including the nil-tenant one, because a partially specified policy
would let the adapters fall back to their providers' more permissive defaults.
The three inversions (deny-egress to allow-internet, public-inbound, rule-deny
to rule-allow) happen in exactly one place.

Every sandbox-creating path carries it, so sessions, skill installs and the
deep connectivity check all run under the same config's policy rather than
each wiring its own.

Inbound access defaults to CLOSED, deliberately stricter than either
provider's own default: a sandbox URL reachable by anyone who learns the ID is
not a reasonable default for a tenant's workspace. Closing it makes the
provider issue a per-sandbox traffic token, and only at create time -- so the
token is stored with the session binding and replayed through Connect on every
reconnect. Without that, a sandbox that was paused on TTL or rebound after a
restart would answer 403 on every exec and file read, and 403 classifies as an
authentication error rather than NotFound, so the binding would never be
replaced and the session would stay wedged.

Connect therefore takes a request struct instead of a bare ID, which gives the
token a single documented way in rather than implicit state inside an adapter.

Metadata-based recovery is the one reconnect path with no binding to read the
token from. Rather than adopt a sandbox that would be permanently 403, it is
deleted and replaced -- but only for providers that have the credential at
all, since Docker has no inbound token and its containers are still adoptable.

go-e2b keeps the token and never sends it, so for E2B the data-plane
RoundTripper attaches the header from a process-local registry. Cube's SDK
already does this itself.

* fix(sandbox): classify data-plane traffic by authority shape, not the configured domain

isDataPlane suffix-matched the configured sandbox domain, which was wrong in
both directions. Both required a configured proxy_url, so E2B Cloud's default
usage was unaffected; the affected deployments are exactly the self-hosted and
E2B-compatible ones the gateway exists for.

A configured gateway could be silently ignored. sandbox_domain is optional for
E2B -- MissingRequiredFields asks only for api_key and template_id -- and with
it empty the check returned false for everything. The general form is worse
than the empty case: go-e2b's envdBaseURL prefers the domain the control plane
reported over the client-wide one, so the authority actually dialled need not
appear in the config at all. The failure is quiet whenever public DNS happens
to resolve the sandbox domain, and the operator believes traffic is passing
through a gateway that never sees it.

Control-plane calls could be sent to the gateway. E2B's own defaults put the
API host under the sandbox domain (api.e2b.app beneath e2b.app), so the suffix
match classified every Create, Connect and List as data-plane traffic. That
is loud where the gateway does not serve the API, but where it proxies both
planes it succeeds while downgrading an X-API-Key request to plaintext for an
http:// gateway. Cube was immune to the first problem, since it requires both
fields, but not to this one.

Classify on the "<port>-<sandboxID>.<domain>" shape both SDKs generate, using
the SandboxIDFromDataPlaneHost helper that token injection on the very same
request already relies on -- so routing and injection now agree by
construction instead of applying two different rules. That helper exists
precisely because the configured domain is unreliable here; it was simply
never used for the routing half.

The control host stays as an explicit exclusion. The shape test already
rejects api.<domain>, so this only covers an API host that itself wears the
shape, such as 8080-api.example.com.

One existing assertion was replaced rather than kept: the E2B pool test proved
that the Cube fields were ignored by asserting a cube.app authority was not
data-plane traffic, which tested the domain matching rather than the field
selection. It now asserts the transport dials the E2B gateway address and not
the Cube one.

* feat(sandbox): add the network policy editor to the sandbox config drawer

The policy sits in the runtime step, directly under the settings it
constrains, rather than in a step of its own. The existing execution timeouts
were compressed into a two-column grid to make room, keeping each field's own
label and its own tip -- the reason they were one per row was that three
unlabelled numbers sharing a footnote gave no clue which one you were editing,
and two columns with per-field tips does not regress that.

Provider-specific sections are shown only for the backend that has them: the
Cube L7 rule cards, E2B's per-host header transforms, and for Docker just the
bridge/none selector, since Docker can only express the overall switch.

Injected header values are write-only. A stored one shows as configured and is
preserved when the input is left blank, which is how env-var secrets already
behave. Renaming a rule or a header is the case worth care: the merge indexes
credentials on the rule-and-header pair, so a rename means the old value can no
longer be recovered. One helper decides both the placeholder text and whether
the payload re-attaches the value, so the form cannot claim a credential is
kept while the save blanks it.

The add buttons use keys of their own instead of reusing the env-var table's
"add variable", which read wrongly under a list of network destinations and
which the i18n key check cannot catch, since the key exists in every bundle.

* docs(sandbox): document the network policy and its inbound default change

The existing network bullet described the pre-feature state -- both providers
open by default, tunable only through the neutral policy at create time --
which is no longer true of the defaults or of the admin-facing surface.

Three things needed writing down rather than restating.

The inbound default flips from publicly reachable to credential-required. A
deployment that relies on a browser or an external service reaching a sandbox
port directly, rather than going through WeKnora, has to opt back in on that
config.

The binding store now holds a bearer credential in plaintext. Leaving it
unencrypted was a deliberate trade -- per-reconnect crypto on the hot path
against Redis's own access control -- and the trade is only sound if the
requirement is actually stated, along with the code-side constraint it depends
on: a binding or a handle is never logged whole, only the sandbox ID and
whether a credential is present.

On binding loss, a closed-inbound Cube or E2B config no longer adopts its old
sandbox by metadata. The token went with the binding and the provider will not
reissue it, so adoption would produce a session that answers 403 on every
data-plane call with no way back. The sandbox is deleted and rebuilt, which
costs the /workspace scratch. Docker has no such credential and still adopts.

* fix(sandbox): fail closed when a closed-inbound create has no traffic token

A Cube/E2B sandbox created without the inbound token would be bound anyway,
then 403 on every data-plane call as an unreplaceable authentication error.
Refuse the create, destroy the sandbox, and stop Docker from persisting
inbound/egress radios it cannot honour. Canonicalize IPv4 /0 deny-all onto
0.0.0.0/0 and reject CR/LF in injected header names and values.

* fix(sandbox): satisfy pre-push lint on the network policy files

Unexport the data-plane host parser, drop file-level package docs that
revive rejected, and lowercase error-string prefixes that staticcheck
ST1005 treats as capitalized English.

* fix(sandbox): persist rotated inbound tokens and stop misreporting restricted egress

Connect can reissue the traffic token after pause/resume; write it back onto
the binding so a restart does not restore a stale credential that 403s and
cannot be replaced. Restore the volume-support i18n key, map Docker
network_mode=none onto deny-egress, inject the E2B inbound header without a
gateway pool, and fold header names when merging redacted secrets.

---------

Co-authored-by: hailongzhao <hailongzhao@tencent.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-03 10:49:46 +08:00
wizardchen b747cdb3f6 feat(agent): stream live +/- progress for sandbox write and edit
Large write/edit calls used to sit on a spinner until the full JSON
arrived. Emit path and running line counts from partial arguments so
the UI can update in place, without putting file bodies on the SSE wire.
2026-09-02 23:36:58 +08:00
wizardchen 4c0d42c4cb feat(agent): keep long sandbox turns from truncating, overflowing, or rewriting files
Refuse truncated tool calls, compact-and-retry once on overflow, and let
sandbox files be appended, paged, and batch-edited instead of rewritten.
Models can set context_window (default 200K) so compaction sizes itself
from the real window; agent max_iterations of -1 means unlimited.
2026-09-02 22:09:09 +08:00
leon4z 988cbb0330
fix(models): show usage details when deletion is blocked (#2975)
* fix(models): show usage details when deletion is blocked

* fix(models): open the matching agent section and cap usage lists

Agent "open configuration" now lands on the tab that owns the binding
(VLM/ASR vs follow-ups), and delete failures keep the server message when
structured details cannot be parsed. Listed KB/agent rows are capped at 50
while totals still drive the deletion guard and dialog headings.

---------

Co-authored-by: Leon <leon_hfut@foxmail.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-02 17:20:37 +08:00
wizardchen 3d40ee0aff fix(skills): install ClawHub skills.sh catalog pages via the install resolver
Those /skills-sh/owner/repo/slug listings are federated, not native
@owner/slug pages, and the GitHub folder is often deeper than the URL
slug. Resolve them through ClawHub so the commit-pinned handoff names
the real skill path.
2026-09-02 16:22:55 +08:00
wizardchen 12c3465b95 feat(skills): add StopSkill functionality to abort in-flight installs
- Introduced StopSkill method to allow users to abort ongoing skill installations, enabling retry or uninstall options.
- Updated API documentation to include the new stop endpoint for skills.
- Enhanced frontend components to support stopping skills, including UI updates and user feedback messages.
- Added tests to ensure the StopSkill functionality works as intended, including handling various skill states.
- Updated internationalization files to include new messages related to stopping skills.
2026-09-02 15:08:05 +08:00
wizardchen bbe95a6c1b refactor(skills): enhance skill upload size management and error handling
- Updated .env.example to clarify skill zip upload limits and their implications for Nginx configuration.
- Refactored frontend logic to differentiate between skill zip uploads and other uploads, ensuring accurate error messages for oversized requests.
- Improved utility functions for managing upload limits and added tests to validate behavior for oversized JSON bodies.
- Enhanced error handling in various handlers to provide clearer feedback on upload size constraints, particularly for sandbox and catalog installations.
2026-09-02 15:08:05 +08:00
wizardchen 17324c46e4 refactor(skills): improve skill bundle size handling and error management
- Updated .env.example and docker-compose.yml to clarify skill bundle size limits and their implications for GitHub source downloads.
- Enhanced frontend logic to differentiate between skill bundle uploads and knowledge uploads, ensuring proper error messages for oversized requests.
- Introduced new utility functions for managing upload limits and added tests to validate behavior for oversized JSON bodies.
- Refactored error handling in various handlers to provide clearer feedback on upload size constraints.
2026-09-02 15:08:05 +08:00
wizardchen 3a06a3b9e9 refactor(skills): improve skill bundle size management and nginx configuration
- Updated .env.example to clarify the skill bundle size limits and their impact on Nginx configuration.
- Refactored frontend/docker-entrypoint.sh to separate max file size settings for skills and general uploads.
- Enhanced nginx.conf to apply specific body size limits for skill uploads without affecting other endpoints.
- Added tests to ensure proper handling of skill bundle file indexing and size constraints.
- Improved error handling in tenant_source.go and tenant_sandbox_config.go to manage skill file limits effectively.
2026-09-02 15:08:05 +08:00
wizardchen 56bf53a1fd fix(skills): raise skill zip cap and keep uninstall progress stable
GitHub skill packages such as ppt-master exceed the 50MB knowledge-upload limit. Give skills their own 256MB download/upload cap, keep uninstalling visible if the list lags, and distinguish zip-entry vs skill-file errors.
2026-09-02 15:08:05 +08:00
MidoriKurage a40ef46635
fix(auth): record last-active-tenant preference on SwitchTenant (#2922)
* fix(auth): record last-active-tenant preference on SwitchTenant

* docs(auth): note SwitchTenant updating last-active-tenant preference

* fix(auth): persist last-active tenant before SwitchTenant tokens

RefreshToken re-resolves from this preference because refresh JWTs omit
tenant_id. Fail the switch if the write fails so a 200 never returns a
token pair whose later refresh would land in a different workspace.

* fix(cli): align HybridSearch interfaces with SDK variadic options

Client.HybridSearch gained ResourceURLOptions; CLI ChunksService and
MCP knowledgeService still used the old signature, so *Client no longer
satisfied those interfaces.

* style(cli): wrap HybridSearch signatures under the 120-column lint

---------

Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-01 15:43:40 +08:00
lyingbug 02269bd8f1
feat: require opt-in for the Docker sandbox backend (#2936)
* feat: require opt-in for the Docker sandbox backend

Docker engine access is host-root equivalent, so keep the backend off
until System Settings or WEKNORA_SANDBOX_DOCKER_ENABLED says otherwise.
Also move system-settings help into the title icon and add i18n for
tenant.auto_accept_invitation.

* fix(i18n): drop tenant wording from Docker host-risk copy

The workspace terminology check rejects 租户 / tenant in user-facing strings.
2026-09-01 15:42:28 +08:00
cainbit a55f4b7834
feat: support complex password (#2929)
* feat: support complex password

* fix: honor runtime complex-password policy on all password writes

Keep the service layer as the last check, share one resolver with invite
registration and admin user create, and drop the leftover startup debug print.

* fix: satisfy pre-push lint on password-policy error paths

The hook diffs against origin/main, so wrap the original error strings
and check c.Error on the new validation branches.

---------

Co-authored-by: wuwc.ew <wuwc.ew@cebwm.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-01 11:50:10 +08:00
wizardchen 7fbbaffb9f fix(observability): nest follow-up completions under the chat trace
POST /suggestions often wins the race to generate follow-ups and has no
Langfuse parent, so chat.completion auto-creates an orphan root. Stamp
the originating W3C traceparent on the assistant message and resume it
before the extra LLM call.
2026-08-31 19:42:32 +08:00
wizardchen 5e1752b69a fix(skills): keep catalog bundles consistent and surface partial installs
Stop treating a failed sandbox as a full success, avoid writing a SHA
when the catalog archive is missing, and pick the newest stored fork
on migrate so files and chips match the catalog users actually see.
2026-08-28 15:17:37 +08:00
wizardchen cd3f8b4a9a feat(skills): store skills in a tenant catalog and install per sandbox
A skill is a workspace definition, not a sandbox setting. Keep one catalog
row and run a full image install for each backend, so agents only enable
skills that are already ready on the sandbox they use.
2026-08-28 15:17:37 +08:00
wizardchen 83d661af55 ui(sandbox): redesign personal sandbox secrets settings
Lead with skill credentials, hide empty inputs until edit, and rename the page to 沙箱密钥 so it is not mistaken for system env vars.
2026-08-27 16:55:09 +08:00
hailongzhao 188200e3b1 feat(sandbox): inject per-user and workspace skill env vars at execution
Skills declare the environment variables they read at run time, so a
credential no longer has to be an admin-set value shared by everyone
using the same skill image.

The installer agent writes a declaration the server validates against the
bundle. Admins fill workspace-wide values from the skill drawer, members
fill their own under Settings, and a successful shell_exec captures the
declared names a run already used for the current speaker. Resolution is
keyed by Principal so IM callers do not collapse onto one synthetic
account, and values are injected only into the process of that one run.

Values are AES-GCM encrypted at rest and never returned by any endpoint.
2026-08-27 14:32:00 +08:00
sun 8486912b48
fix(i18n): 修复内置智能体名称与描述不随界面语言切换的问题 (#2828)
* fix(i18n): 修复内置智能体名称与描述不随界面语言切换的问题

问题现象:切换界面语言后,内置智能体的名称/描述仍显示旧语言,
需要强制刷新(Ctrl+F5)才能恢复正确语言。

35820ebb 已在 GetAgentByID / ListAgents 读取路径按请求语言重新本地化,
本提交补全剩余场景:

后端:
- 共享智能体读取(sharedAgentInfo / GetSharedAgentForTenant)与组织
  共享列表(ListOrgAgentShares)补 ApplyBuiltinAgentLocalization;
- IM 渠道列表(ListChannelsByTenant)改传请求 ctx,内置渠道的
  AgentName 按调用方语言从 YAML i18n 重新解析(DB 列可能为空或为
  落库时语言的残留值);
- 写入侧收敛:内置智能体配置落库时持久化 YAML default 语言的展示
  字段(GetBuiltinAgent 而非 GetBuiltinAgentWithContext,与 locale
  无关),更新/创建接口返回值再按调用方语言本地化,避免未覆盖的
  读取路径显示随机语言。

前端:
- utils/request.ts 导出 getCurrentLanguage;
- chatResources 的 agents 缓存与 orgStore 的 sharedAgents 缓存在
  新鲜度判断中加入"加载时语言 == 当前语言",切换语言后缓存立即
  失效,下次访问按新 Accept-Language 重新拉取并响应式更新。

* fix(i18n): 按请求发起时的语言给智能体缓存打戳,避免切换语言时命中旧数据

落地预取尚未返回就改界面语言时,原先会把 zh-CN 响应标成 en-US 新鲜缓存,最多冻 60s。in-flight 只复用同语言请求,写入前校验代际,并补共享/IM 本地化回归测试。

---------

Co-authored-by: asmh1989 <minhua.sun@velavigo.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-27 11:53:45 +08:00
lyingbug 270b64f6ec
feat(agent): preview skill artifacts and verify installs without running them (#2823)
* feat(agent): preview skill artifacts and verify installs without running them

Generated files open in the chat drawer with overlay/Esc returning to the
list, and install verification no longer executes guessed skill entry
points. A failed install can be retried from the saved archive.

* ui(chat): use a folder icon and corner count for skill artifacts

The eye and document glyphs read as preview or copy, and TDesign's
loading spinner sat beside the icon. A folder with a top-right count
matches the generated-files drawer without covering the toolbar action.

* feat(artifact): implement inline artifact references with previews

Add support for inline artifact references in Markdown, allowing generated files to be displayed as clickable cards. Implemented a new rendering mechanism for artifacts, enabling previews directly from the chat interface. Updated localization files for new inline preview hints and missing file messages. Introduced tests for artifact reference normalization and rendering logic.

* fix(client): document AgentResponseType constants for revive

Touching the const block made golangci-lint require comments on every
exported value. Match the rest of the SDK and describe artifacts_pending.

* fix(agent): wrap artifact-reference prompt lines for lll

Pre-push golangci-lint rejected the branch on three lines over 120
characters in the sandbox: reference guidance.

* fix(agent): scope HTML scripts and tighten install verification

Keep scripted HTML preview on skill artifacts only, recreate sandbox
workspace dirs after they are deleted, and treat nested skill files as
dependencies rather than first-party imports.

* refactor(artifact): enhance artifact reference handling and metadata

Updated artifact metadata to include a stable resource handle for better identification. Adjusted artifact reference resolution to support both handle and name forms, ensuring compatibility with existing references. Enhanced tests to validate the new handling logic and ensure proper rendering of artifacts in chat messages. Improved documentation for clarity on artifact reference formats and their usage in the system.
2026-08-27 10:30:32 +08:00
wizardchen 7fda02637c feat(sandbox): remove the Local host-process backend
Local was a host-subprocess fallback that skill install, snapshots, and
session sandboxes already excluded. Drop it so Cube, E2B, and Docker are
the only backends; leftover local configs can only be deleted.
2026-08-26 17:48:21 +08:00
wizardchen 58acd8b33c feat(api): honor resource_urls=public on hybrid-search
Single-KB retrieval was still returning resource:// handles even when
callers asked for public URLs, unlike knowledge-search.
2026-08-26 17:40:54 +08:00
wizardchen acac16d540 fix(sandbox): rebuild templates without dropping the live ID
Deleting the WeKnora template before its replacement was ready left
sessions targeting a missing ID, and freeze was per-config while rebuild
is cluster-scoped. Rebuild in place when possible, persist the new
template ID, refuse replace across siblings with skills, and name
snapshots by tenant and config on every backend.
2026-08-26 16:56:26 +08:00
wizardchen c170854b89 feat(sandbox): pin Cube DNS on templates and freeze skill snapshot configs
Guest DNS only applies through the WeKnora template spec, and sessions
already on a skill snapshot would miss connection or rebuild changes.
Stop auto-creating templates, require explicit create/rebuild, and
refresh the settings card list when installs finish.
2026-08-26 16:56:26 +08:00
wizardchen ebfd5ef0fb feat(sandbox): browse installed skill files from settings
Read the stored skill bundle without booting a sandbox, and open a
resizable secondary drawer with a file tree and markdown preview.
2026-08-25 20:27:26 +08:00
wizardchen 625f9db80a fix(sandbox): advertise only image skills and unstick installs
The host skills/preloaded tree is not what execute_skill_script finds
inside the sandbox, so stop merging it into the agent's advertised set.
Seed install files as a tar, publish transcript locators before the copy,
and wait in the UI instead of 404-polling.
2026-08-25 18:03:53 +08:00
wizardchen b6cfb34be6 docs(sandbox): clarify skill source requirements in installation process
Updated documentation across multiple files to specify that the `source` for skill installation must be explicitly defined as `@owner/slug` for ClawHub or a full URL for GitHub/SkillHub. Bare `owner/slug` is now rejected as ambiguous. This change enhances clarity for users regarding valid input formats and improves error handling in the installation process.
2026-08-25 15:47:48 +08:00
wizardchen 92fd75f54a refactor(sandbox): remove token requirement for skill installation from source
Updated the skill installation process to eliminate the need for a token when installing skills from ClawHub, SkillHub, or Git URLs. The source must now be readable anonymously, ensuring that no credentials are sent during the fetch process. Adjusted related documentation and UI components to reflect this change, enhancing the user experience by simplifying the installation workflow.
2026-08-25 15:47:48 +08:00
wizardchen 260057b5f4 feat(sandbox): install skills from ClawHub, SkillHub, and git URLs
Paste a registry or GitHub link in the skill sandbox instead of only
uploading a zip. skillhub.cn pages resolve through api.skillhub.cn.
2026-08-25 15:47:48 +08:00
nullptr-error 18d22b014b
feat(sandbox): expose tenant skill management over HTTP and in the console (#2789)
* feat(sandbox): enhance skill management in sandbox configurations

Updated the skill management system to allow listing, installing, and removing skills within sandbox configurations. The ListSkills function now accepts a sandboxConfigID to filter skills based on the selected configuration. Introduced a new SandboxSkillsDrawer component for managing skills through the UI, along with necessary updates to the API and localization files to support these features.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: keep skill maintenance sessions out of the console session list

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat: store and expose the installer transcript locators

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat: record the skill installer agent's conversation

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat: stream and persist the installer transcript during a skill install

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat: expose install transcript locators on the skill type

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat: add the floating skill install transcript window

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat: open the install transcript from the sandbox skills drawer

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat(sandbox): 重构技能安装体验,支持内联时间线、编辑第4步及保留镜像指针

- 替换右下角浮窗为内联安装时间线 (SkillInstallTimeline.vue)
  - 新增 GET /api/v1/sandbox-configs/:id/skills/:skillId/transcript 接口,支持回放与追尾
  - 移除 /sessions/continue-stream 依赖,避免 404 问题
  - 事件日志以 install_prompt 开头,不再将工具调用 preamble 拼入最终答案
  - 删除 SkillInstallTranscript.vue,技能条目下可展开/折叠时间线

- 编辑向导新增第 4 步「管理技能」
  - Cube/E2B 环境:连接 → 模板 → 运行配置 → 技能(第4步)
  - Docker/Local 环境:无第4步(无快照镜像)
  - 首次创建必须按 1→2→3 顺序,第3步保存成功后自动进入第4步
  - 已有配置支持步骤条数字跳转,可直接访问任意步骤
  - 卡片菜单「管理技能」打开同一抽屉并定位至第4步
  - SandboxSkillsDrawer.vue 重命名为 SandboxSkillsPanel.vue,去除独立抽屉壳

- 修复保存运行配置时冲掉 skill_image 的问题
  - 顶部展示信息(基础模板/快照ID/版本/构建时间)读取 config.skill_image
  - 编辑器保存 payload 不再包含 skill_image,合并时保留已有 SkillImage 和 VolumeMount
  - MergeSandboxConfigForUpdate 增加对 SkillImage 和 VolumeMount 的保护
  - 已冲掉的配置需重新安装技能才能恢复镜像指针

- 「查看安装过程」在安装开始时即显示
  - 技能列表中出现「正在安装」状态即展示按钮
  - 若记录尚未写入,展示等待提示并自动重试,避免误报「没有留下记录」

* 沙盒内技能目录从 UUID 改成 SKILL.md 的 name。

* fix(sandbox): heal stuck skill rows and block planted maintenance sessions

The reaper left a mid-upgrade install spinning forever when the old snapshot was still live, and restored removals to ready after the pointer had already moved. Client session create/update can no longer hide chats behind the skill_maintenance: prefix.

* style: gofumpt the skill reaper test stubs

* style: satisfy golangci on the tenant skill admin API

* feat(sandbox): rebuild skill images at turn boundaries, not mid-exec

Hold a session turn lease through AgentQA so an install cannot tear down
the live sandbox between tool calls; the next turn's first resolve picks
up the new image. Configs can instead keep existing sandboxes and boot
the new snapshot only for new sessions.

* fix(sandbox): judge stuck skill runs from the snapshot chain

InstalledSnapshotID only records the generation that installed a skill; later
installs of other skills advance the live pointer without rewriting older rows.
Comparing those IDs made the reaper fail healthy installs and delete live
skills whose removal had stalled.

---------

Co-authored-by: hailongzhao <hailongzhao@tencent.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-25 11:28:12 +08:00
wizardchen e683008188 fix(chat): align live timestamps with persisted created_at
Echo the stored user/assistant times on the first stream event so the
UI stops showing a client-clock fallback that would jump after reload.
2026-08-24 17:04:48 +08:00
PP1 c5b6c10971 fix(handler): validate knowledge search pagination 2026-08-24 14:16:35 +08:00
wizardchen 9c5c52f0a4 feat(sandbox): Docker 后端支持会话级长驻容器与远程守护进程
将 Docker 沙箱后端从一次性 exec 容器改为会话级长驻容器,使其会话与文件
系统语义与 E2B / Cube 后端对齐:

- 新增 docker_engine / docker_remote_client / docker_rpc_timeout,直连
  Docker Engine API,支持 TCP+TLS 远程守护进程,并为拉镜像等慢操作单独
  设置超时;daemon 地址留空时跟随本机 docker context。
- 新增空闲清理器 docker_idle_sweeper,按 exec 刷新的活跃标记回收长驻
  容器;标记文件对沙箱非 root 账号可写。
- 会话容器补 PID1 以回收僵尸进程;标准镜像补入 curl。
- 镜像即模板:docker_template_catalog 只上报可识别的沙箱镜像,标准模板
  的拉取在后台进行并报告 building。
- 设置页与租户配置支持守护进程地址、TLS 与 CPU/内存限额,四种语言文案
  同步;沙箱健康检查覆盖 Docker 后端。
- 补充 docs/sandbox-docker-backend.md 与 POC,说明能力边界与快照语义;
  git 钩子的变更包检测跳过嵌套 module,避免拿 POC 的包去跑主 module 测试。
2026-08-24 12:22:58 +08:00
ochan.kwon 894cbec48a feat(agent): report and attribute per-turn LLM token usage
Accumulate token usage across every LLM round of an agent turn and
expose the aggregate everywhere a turn is observable:

- AgentState.TurnUsage accumulates each round's reported usage,
  including the final-answer synthesis call; TokenUsage.Accumulate
  keeps the cache counters as prompt subsets and recomputes the
  combined cache status (unsupported survives only while every call
  was itself unsupported).
- The agent completion event carries the aggregate, and the complete
  stream event exposes it both as data.usage and as a typed
  StreamEvent.Usage that buildStreamResponse promotes into the
  previously-unused StreamResponse.Usage wire field.
- The assistant message persists it as a nullable usage column on
  both migration targets (postgres 000085 jsonb, sqlite 000012 text),
  for web and IM channels alike, so history reads still carry the
  turn's cost after the live stream is gone.
- "[LLM Usage]" log lines gain ", session_id=..., principal=type:id"
  when the context carries them; calls outside sessions stay
  byte-identical.

Usage from failed retry attempts is not accumulated: the per-call
usage log remains the ground truth, while the turn aggregate serves
as the operational signal.
2026-08-24 10:36:19 +08:00
MidoriKurage ba03be775f
feat(system-admin): add endpoint for creating users (#2722)
* feat(types): add AdminCreateUserRequest for system-admin user creation

Password un-tagged so an empty value reaches the service and triggers
OIDC-style random-password generation.

* feat(system-admin): scaffold POST /system/admin/users/create endpoint

- Handler skeleton under the SystemAdmin()-guarded group
- Binding and validation live (400); happy path 501 until the
  service logic lands
- Response type declares the once-only generated_password contract

* test(system-admin): contract tests for user creation

- Create/audit/generated-password cases assert the final contract
  and are intentionally red against the 501 stub
- Binding and trim validation cases already pass
- Adds the system.user_created audit action as the audit contract

* feat(frontend): add createSystemUser API wrapper

Mirrors promote/revoke/reset-password conventions, including the
once-only generated_password contract on the response type.

* fix(system-admin): never rewrite password; re-check trimmed username

- Handler no longer trims the password: whitespace is part of the
  credential, hashed byte-for-byte (mirrors auth.go Register)
- Trimmed username re-checked to 2-50 runes (binding ran on the
  raw JSON)

* feat(service): implement AdminCreateUser with random-password fallback

- Empty password: OIDC-style crypto/rand generation, returned once
- Explicit password: must satisfy the 8-32 letter-and-number policy
- Delegates to Register: duplicate checks, tenant provisioning and
  Owner membership bootstrap match public registration

* feat(system-admin): implement create-user handler

- Resolves tenant mode from the shared auth.default_tenant_mode
  policy (single source for registration and admin creation)
- Emits system.user_created audit without the plaintext password
- 201 + once-only generated password; 400 for policy/duplicate,
  500 for internal failures

* test(service): whitespace-only password must be rejected

- All-whitespace password: ErrPasswordPolicy, nothing persisted
  (matches AdminResetPassword); only truly empty triggers generation
- Red against the current TrimSpace-empty check
- Handler test drops the whitespace-only 201 expectation, keeps
  byte-for-byte pass-through for spacey valid passwords

* fix(service): treat only a truly empty password as generate-request

Generation now triggers only on the empty string; whitespace-only
input is rejected by the 8-32 policy like AdminResetPassword.

* fix(service): regenerate until the generated password passes policy

A 32-char base64url draw misses digits ~0.4% of the time and could
400 a creation nobody picked a password for; regenerate until the
policy passes (expected ~1.004 draws).

* refactor(system-admin): drop TenantProvisioning from create payload

The value lived both on the request and as the service argument;
keep it only as the argument, mirroring LoginWithOIDC.

* test(system-admin): pin password_generated audit value; cover dupes

- Audit assertions check the exact password_generated boolean
  (true generated, false caller-supplied)
- Duplicate mapping table-driven over email and username errors

* feat(system-admin): explicit provide-and-validate password semantics

- Password pointer-typed: absence (or null) triggers random
  generation; any provided value, empty string included, is
  policy-checked and rejected otherwise
- Service: generation on nil only, all provided values hashed
  byte-for-byte
- Tests: empty string -> 400, absent -> generate, nil pass-through
  at the handler boundary
- Frontend: document that any provided value is policy-checked

* test(system-admin): merge duplicate rejection tests

Whitespace-only and weak-password rejection tests were structurally
identical, differing only in inputs. Merged into one table-driven
test covering weak, empty, whitespace and whitespace-only values.

* feat(system-admin): idempotent create on duplicate identity

- Register returns typed sentinels ErrUser{Email,Username}Exists
- AdminCreateUser re-queries the existing row, lookup targeted at the
  sentinel-named identity (email or username)
- Handler: duplicate sentinels -> 200 + UserInfo with idempotent=true
  audit, policy errors stay 400; drops the substring-matched branch

* fix(system-admin): reject partial identity conflicts on user create

Idempotent 200 now requires both email and username to match the existing
row; partial collisions return 409. Align handler identity sanitization and
password docs with nil-or-null generation semantics.

---------

Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-20 19:51:10 +08:00
Anky 0eb79c25e4
feat: support editing document summaries (#2752)
* feat: support editing document summaries

* fix: address review feedback for manual summary editing

Reset summary edit state when the drawer closes or generation is in
flight, sync summary_status on manual description updates, and add
service tests plus API docs for partial PUT behavior.

* chore: gofmt client/initialization.go for pre-push hook

---------

Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-20 14:54:53 +08:00
wizardchen e123f8247e feat(docparser): 引入 anydoc 引擎,在 Go 进程内解析 office 文档
通过 cgo 链接 anydoc Rust 静态库,把 docx/pptx/xlsx 等转为带原位图片的 Markdown;扫描版 PDF 无文字层时回落到 DocReader OCR。默认构建不链接该库。

Co-authored-by: lyingbug <lyingbug@users.noreply.github.com>
2026-08-16 11:37:27 +08:00