796 Commits
Author SHA1 Message Date
RockChinQ 7fa9c0e426 fix: 修复独立环境登录 404 与「添加第一个模型」500(4.11 回归) (#2755)
* fix(space): keep dedicated-environment Space login working

A dedicated environment runs the OSS runtime with system.edition=cloud. The
process-level 'LangBot Models' compatibility provider is part of the OSS
single-Workspace contract, but write_space_model_providers() skipped creating it
for every non-community edition. The Space OAuth callback then unconditionally
rewarded the provider row by api key, so provider_service raised
WorkspaceNotFoundError('Provider not found') and the whole callback returned 404
-- after the Account and its Workspace had already been created. Every retry
failed the same way, making dedicated-environment login impossible on 4.11.x.

Gate the compatibility provider on the deployment shape instead of the edition
(genuine multi-tenant Cloud runs in CLOUD_RUNTIME persistence and never reaches
this path), and treat a missing provider row as a model-routing warning rather
than an authentication failure so a data anomaly can never block login.

* fix(agent): bind the first model to the 4.11 runner config

create_llm_model() still wrote the auto-selected model into the pre-4.11
ai['local-agent'] container. On a 4.11 Workspace that key does not exist, so the
assignment raised KeyError and POST /provider/models/llm returned 500 the first
time a user added a model -- and the default pipeline kept primary='', so every
Agent run failed with 'No authorized model for local-agent'.

Delegate to RunnerDefaultConfigService, which resolves the selected runner and
writes the schema-defined model selector into ai.runner_config[<runner id>].

Also default the NOT NULL description column on pipeline and bot creation:
omitting an optional description returned a 500 from the constraint instead of
creating the resource.

* fix(agent): keep seeding the model for pipelines that never migrated

set_pipeline_llm_model_if_empty() returns False when a pipeline has no 4.11
runner selected -- that is exactly the un-migrated shape, which still carries
ai.local-agent. Seed that container, but only when it exists, so the legacy path
keeps its old behaviour without the KeyError.
2026-10-22 23:26:30 +08:00
RockChinQandmultica-agent da508f9603 fix(plugin): reject archive entry names the SDK would refuse to extract (#2757)
The host inspects a package to read manifest.yaml and requirements.txt before the
SDK extracts it. Inspection normalized entry names with only
replace('\\','/').strip('/'), so it accepted names its own extractor rejects
(absolute paths, '..' components, drive letters) and it silently kept the first
member when two normalized to the same path.

There was no traversal write, because the SDK's _extract_verified_zip validates
every member before writing and the host only reads members by ZipInfo. The bug
is the divergence: a package could pass inspection and then fail to install, and
the two rule sets could drift further as either side changes.

Inspection now applies the same rule set as the SDK, via
_normalize_archive_entry_name: reject empty/NUL names, absolute paths, any '..'
component and drive letters; reject a duplicate after normalization. '.' and
empty segments are still collapsed, so './manifest.yaml' and 'components//x.py'
keep working.

Tests: 13 cases covering each rejection, the duplicate, traversal taking
precedence over the duplicate check, and two positive cases (nested/unicode
layout, cosmetic separators).

Co-authored-by: multica-agent <[email protected]>
2026-10-22 22:04:36 +08:00
RockChinQandmultica-agent 0b341086fb LANG-145: enforce credential-session TTL on a timer, not on traffic (#2756)
* fix(platform): enforce credential-session TTL on a timer, not on traffic

The four adapter registration flows (Lark one-click app, DingTalk device flow,
WeCom bot, QQ Official bind) each park a short-lived secret in an in-memory
session dict until the caller persists it: app_secret, client_secret, or the bot
secret.

Each store had a TTL and a cleanup function, but the cleanup only ran at the top
of a route handler. An abandoned flow therefore kept its secret in memory until
some *other* request happened to arrive, which for a quiet instance can be far
past the validity window (15 min for Lark, 10 for DingTalk, 5 for WeCom/QQ).

Changes:
- Move the sweep to module level as _sweep_credential_sessions(stores) so it is
  directly testable, and have it scrub app_secret/client_secret/secret as it
  evicts, so an evicted session dict no longer retains a readable credential.
- Add a background sweeper task started from the router group's initialize(),
  running every 60s, so the TTL holds regardless of traffic.
- Keep the per-route cleanups: they make eviction immediate under load.

Tests: 9 new cases (expiry, fresh sessions survive, secret scrubbing, per-store
TTL, cancelling a pending handshake task, not cancelling a finished one,
malformed session without created_at, multiple evictions, empty stores).

Co-authored-by: multica-agent <[email protected]>

* fix(platform): tolerate a task manager without create_task when starting the sweeper

The sweeper is started from the adapter router group's initialize(). Some
embeddings of the app provide a task manager that only exposes create_user_task,
so an unconditional create_task broke those harnesses. Fall back to the per-route
cleanups when create_task is unavailable.

Co-authored-by: multica-agent <[email protected]>

---------

Co-authored-by: multica-agent <[email protected]>
2026-10-22 21:51:01 +08:00
RockChinQandmultica-agent c759da50b1 fix(adapters): stop SSRF and arbitrary local file reads in media handling (#2753)
The platform adapters fetch URLs and open paths that come from inbound
messages, so both are attacker-influenced.

New guard module pkg/utils/outbound_url.py:

- assert_safe_outbound_url: checks the scheme, rejects literal private /
  loopback / link-local / reserved / multicast addresses, and resolves the
  hostname so a public-looking name pointing at an internal address is refused
  too. Optional allowed_domains confines a fetch to a known prefix.
- assert_safe_local_media_path: resolves a caller-supplied path and requires it
  to stay inside the media roots (data dir + temp dir), so symlinks and .. cannot
  escape. Directories are refused.

Wired in:

- DingTalk send_message: session_webhook is taken from the inbound event and was
  POSTed verbatim, so a forged event could redirect reply content (including LLM
  output) to any host. Now restricted to dingtalk.com.
- DingTalk send_attachment: component.url was fetched with no destination check;
  now goes through the SSRF guard, which also covers cloud metadata.
- DingTalk upload_image_media: caller-supplied file_path was opened directly; now
  confined to the media roots.
- Slack attachment_bytes: component.path was opened directly and uploaded to the
  channel (arbitrary file exfiltration); now confined to the media roots.
- Slack download_media: redirects were followed with no destination check. Every
  hop is now validated, the hop count is bounded, and a redirect off the Slack
  domain drops the bearer token.

Tests: 25 new cases for the guard (internal address forms, scheme rejection,
suffix impostor, traversal, symlink escape, directory). The Slack credential test
now stubs DNS because the guard resolves before fetching, and asserts
allow_redirects is False for every case since redirects are handled manually.

Co-authored-by: multica-agent <[email protected]>
2026-10-22 20:46:27 +08:00
RockChinQandmultica-agent 01789e498a LANG-145: bind WebAuthn to server config and make passkeys OSS-only (#2744)
* LANG-145: bind WebAuthn to server config and make passkeys OSS-only

Two problems in the passkey implementation:

1. The RP ID and expected origin came from the request: a JSON 'origin' field,
   then the Origin/Referer headers, then the request URL. WebAuthn's
   anti-phishing guarantee depends on values the server chose; trusting the
   request lets a sibling host under the same registrable domain obtain a valid
   assertion for a victim's credential. Resolution now follows the same rule the
   OAuth and invitation links already use: api.webui_url, then
   api.webhook_prefix, then the configured port on loopback.

2. Passkeys are now an OSS-only feature. Cloud deployments authenticate through
   their own account service, so every passkey route (register options/verify,
   auth options/verify, list, rename, delete) refuses with
   edition_unsupported, and /account-info advertises neither passkey_login_enabled
   nor passkey_supported. Both cloud flavours are covered: system.edition ==
   'cloud' and deployment.mode == 'cloud'.

Tests:
- New unit suite for the edition matrix and for origin resolution (including
  that client-supplied origin/Origin/Referer are ignored).
- The three 'reverse proxy scenario' tests asserted the old, unsafe behaviour
  (server trusting the request). They now assert the server-config contract.
- test_smoke cloud capabilities expectation updated to passkey_* = false.

Co-authored-by: multica-agent <[email protected]>

* style(api): drop the typing import left unused by the WebAuthn origin change

Co-authored-by: multica-agent <[email protected]>

---------

Co-authored-by: multica-agent <[email protected]>
2026-10-22 20:39:21 +08:00
huanghuoguoguo cc19395f5c perf(core): reduce execution projection and dispatch overhead (#2746)
* perf(core): join execution projection and reuse authorized tool schemas

* perf(pipeline): avoid duplicate checks before stage output validation

* perf(plugin): reuse reconciled settings within event dispatch

* fix(workspace): keep execution projection reads free of unrelated flushes
2026-10-22 20:00:42 +08:00
RockChinQandmultica-agent 5c0236ac3e fix(cloud): keep the directory projection fresh during startup
Boot continues for minutes after the first directory snapshot is committed:
platform ports reconnect, knowledge bases and pipelines reload, and a cold
shared Runtime restore may still be running. The refresh loop only started at
the end of that stage, so any boot slower than the projection staleness window
failed closed while restoring knowledge bases, and Core then exited during
startup - every retry hit the same window.

Start the single refresh task as soon as the first snapshot is committed and
keep the later start as a guarded fallback so the loop is never created twice.

Observed on the production Cloud instance: a boot that took ~120s to reach
knowledge base restore raised 'Cloud directory projection is stale' and the
process exited, while the same image had booted earlier with a faster start.

Co-authored-by: multica-agent <[email protected]>
2026-10-21 17:20:36 +00:00
RockChinQandmultica-agent d45b0a3957 feat(cloud): add configurable Cloud-only WebUI notice banner
Cloud deployments need a way to tell readers what is happening to the
instance they are using (maintenance windows, service notices) without
shipping a release per notice.

Add a cloud.banner config block (switch, tone, dismissal, link targets and
per-language copy) and expose the resolved banner on the unauthenticated
/api/v1/system/info payload so the WebUI can render it before login. The
banner resolves to null on OSS deployments, so a self-hosted copy of
config.yaml never shows managed-service copy. Copy is plain text; only
absolute http(s) link targets are rendered.

The WebUI renders it once from the root layout, offsets the fixed app shell
and the wizard through --cloud-banner-height, and keeps a dismissal bound to
the notice it dismissed so new copy reappears.

Co-authored-by: multica-agent <[email protected]>
2026-10-21 16:26:43 +00:00
RockChinQandmultica-agent d13ae56ea5 fix: bot routing setup and busy-session response checks (#2728)
Apply group response rules before busy-session steering. Initialize usable private-message and group-mention routes for new bots, including Wizard-created pipelines, and preserve member-configured rules across saves and retries.

Fix empty pipeline configuration, refresh the processor sidebar after automatic creation, and show creation feedback. Align routing regressions and use Node 24 for the browser CI job.

Correct the task's erroneous agent attribution while preserving every code tree and the original human contribution.

Co-authored-by: multica-agent <[email protected]>
2026-10-20 21:22:53 +08:00
RockChinQandmultica-agent f8e32ef14f LANG-134: Finish original inbound monitoring row on pipeline error (#2729)
* fix(inbound-error-state): Finish original inbound monitoring row on pipeline error (LANG-134)

* fix(pipeline): finalize monitoring on early exits and cancellation

Co-authored-by: multica-agent <[email protected]>

---------

Co-authored-by: multica-agent <[email protected]>
2026-10-20 20:39:10 +08:00
RockChinQ 819f65bd8a Merge pull request #2731 from langbot-app/task/LANG-136-explicit-response-files
LANG-136: Deliver explicit attachments without implicit Box scan
2026-10-20 19:46:48 +08:00
RockChinQ 71feb33244 Merge pull request #2730 from langbot-app/task/LANG-135-safe-history-indexes
LANG-135: Guard 0039 indexes against missing historical columns
2026-10-20 18:11:30 +08:00
Chin Rock 0990cc429d fix(explicit-response-files): Deliver explicit attachments without implicit Box scan (LANG-136) 2026-10-20 07:54:05 +00:00
Chin Rock 4d91903596 fix(safe-history-indexes): Guard 0039 indexes against missing historical columns (LANG-135) 2026-10-20 07:54:02 +00:00
Chin Rock 40d40204cf fix(install-diagnostics): Sanitize plugin installation network diagnostics (LANG-132) 2026-10-20 07:53:56 +00:00
彼方 1baba1b9f9 Merge pull request #2725 from langbot-app/fix/session-summary-persistence
fix(monitoring): persist session summaries to avoid history scans
2026-10-20 11:53:06 +08:00
BiFangKNT 3b1ea56f4f fix(monitoring): avoid historical payload reads in execution filters
- Add covering indexes through migration 0040
- Preserve PostgreSQL FORCE RLS state when marking historical summaries
- Add query-plan and migration regression tests to CI
2026-10-20 10:45:44 +08:00
BiFangKNT 7129e20cf6 fix(monitoring): paginate conversation IDs before loading message payloads
Count and paginate lightweight records, then load payloads only for the
selected page to avoid materializing large historical messages.

Add regression coverage for oversized history, ingress deduplication,
stable pagination, and PostgreSQL tenant isolation.
2026-10-20 09:34:05 +08:00
BiFangKNT 810d053df9 fix(monitoring): persist session summaries to avoid history scans
- Maintain counts and display snapshots in source transactions with replay-safe deduplication.
- Read session lists exclusively from summaries and remove execution-only filters.
- Automatically initialize historical summaries in bounded, resumable batches during OSS startup.
- Add behavioral contracts covering accounting, retention, query cost and PostgreSQL concurrency.

Verified with the required session_summary suite and real container upgrade startup.
2026-10-20 06:12:00 +08:00
Chin Rockandmultica-agent b7992e4ea6 fix(ci): align HTTP attachment test with explicit file export
Co-authored-by: multica-agent <[email protected]>
2026-10-19 19:02:21 +00:00
41b55952ff fix(runner): avoid duplicate inline image payloads (#2631)
* fix(runner): avoid duplicate inline image payloads

* fix(runner): preserve attachments and complete HTTP agent delivery

Co-authored-by: multica-agent <[email protected]>

---------

Co-authored-by: Qingsong Li <[email protected]>
Co-authored-by: Chin Rock <[email protected]>
Co-authored-by: multica-agent <[email protected]>
2026-10-20 02:14:36 +08:00
RockChinQandmultica-agent d9e4e7d9df fix(pipeline): decouple Runner from extension permissions (LANG-54) (#2723)
* fix(pipeline): decouple runner from extension allowlist

Co-authored-by: multica-agent <[email protected]>

* fix(pipeline): complete runner diagnostics and real runtime coverage

Co-authored-by: multica-agent <[email protected]>

---------

Co-authored-by: multica-agent <[email protected]>
2026-10-19 23:07:11 +08:00
RockChinQ 5a6ddbff6f Merge pull request #2656 from fluo-rite/fix/telegram-mention-entities
fix(telegram): respect entity boundaries when parsing bot mentions
2026-10-19 17:51:31 +08:00
RockChinQandmultica-agent 52e8042f51 fix(telegram): match mention usernames case-insensitively
Co-authored-by: multica-agent <[email protected]>
2026-10-19 17:33:51 +08:00
Haoxuan Jiang 841b4df09d fix(lark): preserve incoming rich-text code blocks (#2626) 2026-10-19 16:26:16 +08:00
947d8addea fix(box): validate and export explicitly selected files (#2641)
* fix(box): retain outbox files when export fails

* test(box): retain ownership evidence in CI logs

* test(box): exercise LocalAgent export repair through real runtime and Docker

Co-authored-by: multica-agent <[email protected]>

* fix(box): complete bounded outbox recovery contract

* feat(box): export explicitly selected files

Co-authored-by: multica-agent <[email protected]>

* test(box): exercise explicit export on real Docker

Co-authored-by: multica-agent <[email protected]>

* test(box): verify explicit exports with live model and Docker

Co-authored-by: multica-agent <[email protected]>

* fix(box): align explicit export SDK and integration contracts

* docs(box): describe selected-file export contract

---------

Co-authored-by: HaiYangBG1 <[email protected]>
Co-authored-by: Chin Rock <[email protected]>
Co-authored-by: multica-agent <[email protected]>
2026-10-19 15:31:33 +08:00
bce94bd0d9 fix(tools): require python3 for Box native file scripts (#2658)
* fix(tools): require python3 for Box native file scripts

Unversioned `python` is still Python 2 on some host-rootfs nsjail
mounts. Falling back to it made read/write/edit scripts fail with
SyntaxError on f-strings (#2603).

Resolve only `python3`, and return a clear JSON error when it is
missing instead of invoking Python 2.

Fixes #2603

* style(tools): format Box interpreter error command

Co-authored-by: multica-agent <[email protected]>

---------

Co-authored-by: Li-john1021 <[email protected]>
Co-authored-by: Chin Rock <[email protected]>
Co-authored-by: multica-agent <[email protected]>
2026-10-19 14:46:47 +08:00
Jonathan Neufeld 5c3675f4cc feat(vector): tag the Valkey Search client lib-name for attribution (#2620)
Set client_info_tag='langbot' on the Valkey Search vector store's glide
client, so CLIENT SETINFO LIB-NAME reports GlidePy(langbot) and operators
can attribute Valkey usage to LangBot. client_name is unchanged.

client_info_tag was added in valkey-glide 2.5.2, so raise the floor from
>=2.4.1 to >=2.5.2 (pyproject, install hint, docs) and regenerate uv.lock.
2026-10-19 14:29:19 +08:00
Hyu 868f89a383 merge: integrate master into lark webhook signature fix 2026-10-19 01:53:46 +08:00
Hyu 757f8b7a35 fix(lark): authenticate plaintext webhooks and explain credentials 2026-10-19 01:48:29 +08:00
彼方 62b647761f Merge pull request #2718 from langbot-app/fix/nonblocking-console-logging
fix(logging): prevent blocked stdout from freezing LangBot
2026-10-19 01:12:59 +08:00
RockChinQ 4b87bb0a35 Merge pull request #2654 from ShaoLOWu/fix/bootutils-files-global-clobber
fix(core): stop generate_files from clobbering the required_paths global
2026-10-19 00:52:19 +08:00
BiFangKNT de26cebdac fix(logging): make shutdown queue retry explicit 2026-10-18 19:29:36 +08:00
BiFangKNT 4a989dd8aa fix(logging): prevent blocked stdout from freezing LangBot
- Isolate console writes with a bounded queue and daemon thread
- Preserve file logging and WebUI caching when stdout stalls
- Flush startup output before starting the writer to prevent exit hangs
- Add regression tests for backpressure, overflow, and shutdown
2026-10-18 19:13:22 +08:00
BiFangKNT 57077740bd chore(merge): sync master and preserve monitoring test coverage 2026-10-18 12:43:44 +08:00
BiFangKNT b73f66a234 feat(persistence): enforce image reference storage contract
- Reject structured inline images on ORM and Core writes
- Route plugin run results through the media-aware journal
- Redact legacy inline images before merging run metadata
- Cover storage contracts and regressions on SQLite and PostgreSQL
2026-10-18 12:26:09 +08:00
BiFangKNT 1e5aeb6032 refactor(provider): decouple Groq message sanitization from reasoning family
Use the chat provider to apply transport-specific metadata cleanup.
Keep finish_reason removal in the common message conversion path.

Verify streaming and non-streaming HTTP payloads through LiteLLM,
metadata preservation for other providers, and source message immutability.
2026-10-18 11:38:15 +08:00
BiFangKNT f42d3919cb refactor(persistence): consolidate monitoring index migrations
- Merge migrations 0039 through 0041 into a single 0039 migration
- Preserve existing indexes and support partial historical schemas
- Update migration tests for the consolidated revision
2026-10-18 09:58:30 +08:00
BiFangKNT d610d64c67 fix(storage): expire historical inline images with bounded TTL cleanup
- Apply media retention to inline images while preserving text and URLs
- Persist per-workspace cursors atomically with payload updates
- Bound candidate scans and verify event ownership before loading payloads
- Add cleanup indexes and regression tests, and fix Windows path assertions
2026-10-18 09:58:04 +08:00
BiFangKNT cbc849d4e2 fix(storage): unify CAS persistence for inline images
- Externalize inline images in messages and run events before persistence
- Keep snapshots, transcripts, and metadata free of inline payloads
- Serialize messages after externalization to reduce peak memory usage
- Preserve live messages, URL-only images, and SDK image retrieval behavior
- Add regression tests for deduplication, redaction, storage failures, and serialization order
2026-10-18 00:04:20 +08:00
huanghuoguoguo 399685962e fix(skills): preserve escapes in Python workspace shell wrapper (#2666)
* fix(skills): preserve escapes in Python workspace shell wrapper

* style(skills): retain original end-of-file formatting
2026-10-17 23:13:27 +08:00
BiFangKNT f12490bc73 perf(monitoring): load execution details on demand
- Load overview first and fetch secondary sections when expanded
- Add a covering index and select conversation IDs before loading page payloads
- Preserve full-detail API compatibility and add pagination and lazy-loading tests
2026-10-17 21:10:55 +08:00
huanghuoguoguo ab29e83ca0 test: retain consolidated contracts when merging master 2026-10-17 20:15:07 +08:00
huanghuoguoguo 98cc2ec2d6 Merge pull request #2680 from langbot-app/fix/auth-invalid-json-contract-20261017
fix(auth): reject malformed credential payloads before authentication
2026-10-17 20:11:01 +08:00
BiFangKNT b3574efd95 fix(pipeline): preserve form callbacks and verify all group response rules
Allow routed Dify form callbacks to resume without another mention or
prefix while keeping ordinary messages subject to group response rules.

Cover mention, prefix, regex, random probability, and combined rules.
2026-10-17 20:03:24 +08:00
BiFangKNT 807de8d24a fix(provider): sanitize replayed Groq message metadata
Remove response-only finish_reason metadata when converting stored messages
into subsequent model requests.

Strip provider_specific_fields from Groq messages and tool calls to avoid
strict request validation failures after a tool response. Preserve metadata
required by other providers, including Gemini thought signatures, without
mutating the original message entities.

Cover streaming and non-streaming request construction with regression tests.
2026-10-17 19:48:25 +08:00
BiFangKNT 2ca9c2c7fb fix(pipeline): enforce group response rules after routing
Stop treating an explicit Pipeline route as permission to bypass group
response rules. Routed group messages must still satisfy the configured
mention or prefix matchers.

Preserve the bypass for verified interaction submissions that resume an
existing run. Cover ordinary messages, mentions, prefixes, and interaction
callbacks with regression tests.
2026-10-17 19:48:15 +08:00
BiFangKNT 4d90358da0 perf(monitoring): exclude payloads from session summaries
Exclude message_content and variables from the message source used by
conversation session summaries. These fields were carried through window
sorting even though the resulting summaries did not use them.

Preserve complete payloads for message detail queries. Add regression
coverage for summary counts, session metadata, and full message retrieval.
2026-10-17 19:46:39 +08:00
BiFangKNT d663331889 fix(monitoring): bound inflight snapshot queries
Require a valid owner and unexpired lease for pending Pipeline messages
to appear as active tasks. Exclude historical ingress records without
rewriting their stored status.

Project only the fields needed by snapshots, skip linkage queries for empty
results, and resolve linked runs from selected message IDs instead of a
cross-table OR join that scans historical messages.

Cover lease filtering, terminal transitions, Workspace isolation, payload
exclusion, and indexed lookup plans with regression tests.
2026-10-17 19:45:19 +08:00
BiFangKNT 1318efc248 perf(persistence): index workspace execution leases
Add composite indexes on Workspace, status, and lease expiry for AgentRun
and MonitoringMessage so lease maintenance can locate active executions
without scanning completed history.

Keep ORM metadata and Alembic migration 0039 consistent, including fresh
installations where the indexes already exist. Cover migration round trips,
data preservation, and SQLite query plans with regression tests.
2026-10-17 19:41:55 +08:00