Commit Graph
3546 Commits
Author SHA1 Message Date
chengyongruandchengyongru 93571149db fix(webui): prioritize skill names in autocomplete 2026-07-21 15:19:38 +08:00
chengyongruandchengyongru 052f671b3c fix(webui): keep Markdown table diffs inline 2026-07-21 15:16:12 +08:00
amplifierplusandchengyongru cdb2df4982 fix(files): reject oversized reads before loading 2026-07-21 15:02:27 +08:00
chengyongruandXubin Ren d5658dbc91 fix: preserve background operator in allowlist segments
Maintainer edit: keep a top-level trailing '&' in the segment being matched so background execution cannot be checked as if the ampersand were absent. Redirection forms like 2>&1 and &> remain untouched.
2026-07-21 13:50:24 +08:00
chengyongruandXubin Ren ab6ceef1a1 refactor: simplify ampersand segment check
Maintainer edit: keep the single-ampersand guard behavior, but fold the redirect exceptions into one condition instead of carrying temporary previous/next character variables.
2026-07-21 13:50:24 +08:00
chengyongruandXubin Ren 12c52c11d3 fix: treat single ampersand as shell segment
Maintainer edit: single '&' backgrounds the preceding command and starts another top-level shell segment, so allowPatterns must split it the same way as ';', '|', '&&', and '||'. Keep fd redirections such as 2>&1 and &> intact.
2026-07-21 13:50:24 +08:00
michaelxerandXubin Ren f4a7079e65 fix(security): use re.fullmatch per segment instead of re.search
Fixes chengyongru's review concern: re.search is more permissive
than the original re.fullmatch behavior for single-segment commands.
Using re.fullmatch per segment preserves backward compatibility while
still fixing the chained-command bypass.
2026-07-21 13:50:24 +08:00
michaelxerandXubin Ren bbca32fea9 fix(security): validate each shell segment against exec.allowPatterns
Guard against shell-chain bypass where an attacker appends '&& malicious'
after an allowlisted prefix. The allowlist check now splits the command
on top-level chaining operators (&&, ||, ;, |) and requires every segment
to match at least one allowPattern independently.

Fixes #4521
2026-07-21 13:50:24 +08:00
KDBandXubin Ren 8981995474 fix(exec): clean up sessions on shutdown 2026-07-21 13:48:51 +08:00
KDBandXubin Ren 7cf3c71e3a fix(session): cap messages at persistence boundary
Bind SessionManager saves to the existing raw archive path so SDK imports and other bypass saves cannot persist more than the file cap without archiving unconsolidated overflow.

Add an SDK regression test that exercises the real ingest path.

Refs #4787
2026-07-21 13:47:18 +08:00
axelray-devandXubin Ren fde55d06e2 fix(runner): narrow BaseException catch to Exception in tool execution
The tool execution path caught BaseException, which includes
KeyboardInterrupt, SystemExit, MemoryError, and GeneratorExit.
These should never be caught and converted into conversational
error messages. CancelledError is already handled separately.

Change except BaseException to except Exception so fatal signals
propagate instead of being swallowed.

Adds parametrized regression test for KeyboardInterrupt and
SystemExit propagation.

Fixes #4788
2026-07-21 13:46:05 +08:00
santhrealandXubin Ren b6156fdd79 fix(cron): also coerce null createdAtMs/updatedAtMs on load
Same present-null footgun as runHistory; route all required store
ints through _store_int.
2026-07-21 13:45:02 +08:00
santhrealandXubin Ren 0b1b02f187 fix(cron): coerce null runHistory ms fields from jobs.json
Explicit JSON null for runAtMs/durationMs bypassed the missing-key
default and raised TypeError on load. Treat null/blank like missing.
2026-07-21 13:45:02 +08:00
chengyongruandchengyongru dfc3919b52 fix: stop masking runtime failures 2026-07-21 11:44:52 +08:00
chengyongruandchengyongru afc65c086e refactor(session): simplify directory fsync handling 2026-07-21 10:11:53 +08:00
sunpengcheng05andchengyongru 4a79cbb6e7 fix(session): tolerate unsupported directory fsync 2026-07-21 10:11:53 +08:00
chengyongruandGitHub 9db0d9f3c9 refactor(agent): unify internal turn lifecycle (#4993) 2026-07-21 00:14:27 +08:00
chengyongruandchengyongru b67f4b1371 fix(qq): account for SDK reconnect pacing
Use per-session retry deadlines so botpy's post-connect delay counts toward backoff, and keep unexpected failures on the channel logger.
2026-07-20 23:24:03 +08:00
golaandchengyongru ab0d28103b fix(qq): add exponential backoff to WebSocket reconnect loop
The QQ channel's _run_bot() used a fixed 5-second reconnect interval with
no backoff. When the network is unavailable (e.g., DNS failure), this
produces excessive botpy SDK error tracebacks every 5 seconds, flooding
logs.

botpy's Client.bot_connect() catches ws_connect() exceptions internally
and calls BotWebSocket.on_error(), which logs a full traceback and
immediately re-queues the session. The outer _run_bot() except never
fires for the reported DNS failure path.

Override bot_connect() on the _Bot subclass to:
- Apply exponential backoff (5s -> 300s cap) before re-queuing the session
- Log network errors (ClientConnectorDNSError, ClientConnectorError,
  OSError) compactly without traceback
- Reset backoff on successful connection
- Still call traceback.print_exc() for non-network errors

The outer _run_bot() loop retains exponential backoff as a fallback for
exceptions that escape start() entirely. The botpy library logging
redirect is elevated to ERROR to suppress redundant connection tracebacks.

Consistent with patterns already used in matrix.py and napcat.py.

Add 7 regression tests covering:
- DNS error applies backoff and re-queues session
- No traceback printed for network errors
- ClientConnectorError also triggers backoff
- Backoff doubles and caps at 300s
- Successful connection resets backoff
- Non-network errors still re-queue without backoff
- _is_network_error() classification

Fixes #4767
2026-07-20 23:24:03 +08:00
chengyongruandchengyongru 9d830fb6b6 docs(ollama): explain tool prompt cache reuse 2026-07-20 17:47:04 +08:00
chengyongruandGitHub 8423cf3eeb fix(channels): complete dependency manifest migration (#4995)
* fix(channels): complete dependency manifest migration

* docs(docker): clarify custom uid dependency installs

* fix(channels): keep dependency preinstall internal

* refactor(channels): move dependency installer to scripts

* fix(docker): limit runtime write access
2026-07-20 15:24:57 +08:00
chengyongruandGitHub 76f3eead42 style(webui): simplify Markdown code blocks (#5002) 2026-07-20 14:41:23 +08:00
chengyongruandchengyongru 949cfad548 fix(webui): show copy action on every assistant message 2026-07-20 13:51:53 +08:00
chengyongruandchengyongru e3de01c9f6 fix(webui): resolve build runner executable 2026-07-19 23:59:34 +08:00
chengyongruandGitHub 462a0dfb0f refactor(channels): make built-in channels self-contained (#4908)
* refactor(channels): own setup and instance contracts

* refactor(channels): isolate management contracts

* refactor(channels): normalize activation contracts

* fix(channels): enforce management contracts

* refactor(channels): finish setup ownership migration

* fix(channels): harden management contracts

* fix(channels): enforce lazy loading and runtime ownership

* fix(feishu): make multi-instance startup idempotent

* fix(webui): render channel setup contracts cleanly

* fix(feishu): stop websocket clients cleanly

* fix(channels): enforce persistence and activation gates

* fix(channels): preserve global feature action scope

* fix(channels): apply defaults for single plugins

* fix(channels): enforce management contract boundaries

* refactor(feishu): remove identity helper indirection

* fix(channels): preserve management setup contracts

* refactor(channels): generalize instance settings UI

* refactor(channels): package channel plugins with web UI metadata

* refactor(channels): make built-ins self-contained packages

* test(channels): colocate tests with channel packages

* fix(dingtalk): use official brand icon

* feat(channels): colocate webui translations

* docs(channels): clarify plugin ownership

* test(exec): remove output wait race

* refactor(channels): unify plugin descriptors

* fix(channels): enforce descriptor-owned contracts

* refactor(channels): finish package-owned plugin setup

* refactor(channels): use repository-owned packages only

* fix(channels): self-describe dependencies and runtime state

* fix(channels): warn about legacy entry points
2026-07-19 23:30:49 +08:00
chengyongruandchengyongru 7aaac37bca fix(triggers): require channel enablement predicate 2026-07-19 22:33:29 +08:00
Pei Futongandchengyongru 91514ad0b1 fix(triggers): reject deliveries to disabled channels 2026-07-19 22:33:29 +08:00
chengyongruandGitHub a6b68178aa fix(whatsapp): allow group ids in allowFrom (#4834) 2026-07-19 19:16:37 +08:00
chengyongruandGitHub 2099cb009e fix(providers): fail over across provider failure domains 2026-07-19 17:37:55 +08:00
Pei Futongandchengyongru 39a952ecce fix(cli-apps): decode subprocess output as UTF-8 2026-07-19 16:05:26 +08:00
chengyongruandchengyongru b1232fdaf4 fix(gitstore): preserve staged symlinks 2026-07-19 16:01:11 +08:00
Pei Futongandchengyongru cea8617096 fix(gitstore): resolve staged paths relative to workspace 2026-07-19 16:01:11 +08:00
chengyongruandchengyongru ffb7ddfa1e refactor(triggers): clarify stored integer coercion 2026-07-19 15:46:00 +08:00
santhrealandchengyongru c2071594cf fix(triggers): rename coerce helper to _store_int
Match the cron store-load naming and cover null attempts on deliveries.
2026-07-19 15:46:00 +08:00
santhrealandchengyongru cf96c4d5e9 fix(triggers): coerce null ms fields when loading local triggers
Explicit JSON null for runAtMs/createdAtMs raised TypeError and could
quarantine triggers.json. Treat null/blank like a missing key (0).
2026-07-19 15:46:00 +08:00
chengyongruandchengyongru cf00f537bd fix(agent): guide recovery from oversized tool results
Use the existing in-flight context governor to replace tool output that cannot fit the next model request with a bounded, actionable instruction. The model can retry with narrower arguments, use another tool, or explain the context limit without a second recovery state machine.
2026-07-19 01:08:36 +08:00
cfa49c6e78 fix(render): issue short-lived WebUI tokens via tokenIssueSecret
Map NANOBOT_WEB_TOKEN to channels.websocket.tokenIssueSecret instead of
the static token, and remove the static token. The gateway now issues
short-lived WebSocket/API tokens rather than accepting a long-lived
credential directly at the handshake, matching the public-WebUI login
flow and documentation. Users still enter the same NANOBOT_WEB_TOKEN,
and websocketRequiresToken remains true.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-18 17:39:59 +08:00
c062e1af14 fix(webui): quiet non-WebSocket handshake noise on public port
The WebSocket channel also serves the WebUI over plain HTTP, so on a
public endpoint (e.g. a Render *.onrender.com service) the underlying
websockets library logs a full-traceback ERROR for every request that
isn't a valid GET handshake: HEAD probes ("unsupported HTTP method;
expected GET"), port scanners, uptime monitors, and TLS-to-plain-port
attempts. These are internet background noise, not server faults.

WebSocketHandshakeNoiseFilter already suppressed "opening handshake
failed" records caused by mid-handshake disconnects; widen it to also
suppress records whose exception chain contains websockets'
InvalidMessage, which covers both non-GET methods and malformed/empty
requests. Genuine server-side handshake errors still log.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-18 17:39:59 +08:00
Ho1yShifandXubin Ren c77379099b refactor(entrypoint): improve privilege dropping and config initialization
- Updated entrypoint.sh to initialize the on-disk config only if it does not already exist, preserving user edits across restarts.
- Enhanced privilege dropping logic to ensure the container does not run as root if the privilege drop fails.
- Clarified comments in Dockerfile and entrypoint.sh for better understanding of the privilege management process.
- Updated README.md to include a note about persistent disks requiring a paid service on Render.
- Adjusted render.yaml to clarify the Docker command behavior and added a note regarding auto-deploy settings.
2026-07-18 17:39:59 +08:00
Ho1yShifandXubin Ren ca873e4d17 fix(README): update Deploy to Render link to point to the correct GitHub repository 2026-07-18 17:39:59 +08:00
Ho1yShifandXubin Ren 63895fc101 fix: update Deploy to Render link in README
Changed the repository link for the one-click Deploy to Render button in the README.md file to point to the correct GitHub repository.
2026-07-18 17:39:59 +08:00
770d89b430 feat: add one-click Deploy to Render support
Adds a Render Blueprint (render.yaml) and supporting pieces so nanobot can
be deployed to Render in one click, with persistent memory across deploys.

- render.yaml: web service + 1GB persistent disk mounted at
  /home/nanobot/.nanobot. Prompts for ANTHROPIC_API_KEY and
  NANOBOT_WEB_TOKEN at deploy time (sync: false).
- render-config.json: committed gateway config that wires secrets via
  ${VAR} placeholders (resolved at runtime). Nothing secret is committed.
- entrypoint.sh: adds a branch gated on RENDER=true that copies the config
  onto the mounted disk, chowns the root-owned mount, and drops to the
  non-root nanobot user via setpriv. Local (non-Render) path is unchanged.
- Dockerfile: COPY render-config.json; USER nanobot -> USER root so the
  entrypoint can chown the freshly-mounted disk before dropping privileges;
  add PYTHONUNBUFFERED/PYTHONFAULTHANDLER for diagnosable crash output.
- README.md: Deploy to Render button + section.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-18 17:39:59 +08:00
santhrealandXubin Ren afed32b013 fix(cron): dual-case keys when loading jobs.json
jobs.json hand-edits and asdict-style snake_case for schedule intervals and
runHistory crashed or silently disabled cron. Deserialize via Cron* from_store_dict
and shared get_camel_snake (also used by local triggers).
2026-07-18 17:39:06 +08:00
bingqilinweimaotaiandXubin Ren 8c68c6fe1e feat: support Kimi K3 2026-07-18 17:38:32 +08:00
Yuxin LouandXubin Ren b76d54aae1 Harden default Docker Compose security 2026-07-18 17:37:41 +08:00
KDBandXubin Ren d35f99abfc fix(session): bound the in-memory session cache
Keep only 128 recently used sessions strongly cached while retaining weak references to evicted sessions still owned by active callers. This bounds idle memory growth without allowing duplicate live Session objects or skipping shutdown flushes.

Add LRU, lifecycle, SDK, and flush regression coverage.

Refs #4786
2026-07-18 17:37:07 +08:00
adabarbulescuandXubin Ren d4f5abe004 fix: preserve real cancellation in MCP paths 2026-07-18 17:36:35 +08:00
yu-xin-candXubin Ren 07ad0bafa8 test(exec): relax wait-for timing on Windows 2026-07-18 17:35:56 +08:00
yu-xin-candXubin Ren 995cc44e89 fix(exec): isolate exec session managers 2026-07-18 17:35:56 +08:00
santhrealandXubin Ren 7ac9a46978 fix(utils): avoid hang in split_message when max_len <= 0
When max_len is 0 or negative the cut pointer never advances, so the loop hangs. Return the content unsplit, matching truncate_text_to_tokens for non-positive budgets.
2026-07-18 17:24:12 +08:00