Commit Graph
3065 Commits
Author SHA1 Message Date
NanoBotandXubin Ren e9494c1dce feat(telegram): add Bot API 10.1 sendRichMessage support
- Try sendRichMessage for all non-blockquote messages (tables, task lists,
  math, collapsible, etc.) with graceful fallback to legacy HTML
- Fix payload format to use top-level 'markdown' field per Bot API 10.1 spec
- Add rich path in send_delta() stream end (delete preview + send rich)
- Latch off permanently if server returns capability error
- Removes _needs_rich_rendering() gate and 4 regex patterns
2026-06-21 15:22:05 +08:00
Xubin Ren 98916a31e3 perf(tokens): document tool schema cache assumption 2026-06-21 13:06:34 +08:00
yu-xin-candXubin Ren 7275a81ec7 perf(tokens): cache tool schema estimates 2026-06-21 13:06:34 +08:00
Xubin Ren a81c5e704a fix(memory): reject negative history cursors 2026-06-21 13:05:57 +08:00
Stellar鱼andXubin Ren be058c0922 fix(memory): keep history cursor monotonic 2026-06-21 13:05:57 +08:00
franciscomaestreandXubin Ren 99e158c062 feat(whatsapp): seed LID->phone mappings on startup
WhatsApp can deliver a sender LID instead of a phone number. The channel
already learns the LID->phone mapping at runtime, but only after a message
that carries both values, so the first message from a contact can't be
resolved to a phone number.

Seed the mapping on startup from two sources:

- reverse mapping files the bridge persists in the auth directory
  (lid-mapping-<lid>_reverse.json), resolved via get_runtime_subdir so it
  respects a custom runtime dir
- a new optional channels.whatsapp.lidMappings config dict for static
  mappings (takes precedence over the on-disk files)

Malformed/empty mapping files are ignored rather than failing startup.
Adds tests for both sources, precedence, malformed files and the
no-auth-dir case, plus docs for the new config field.
2026-06-21 13:05:06 +08:00
Xubin Ren e81968a32b test: isolate MCP timeout regression from DNS 2026-06-20 19:12:36 +08:00
Xubin Ren 0eae7ceb1a test: use safe URL for MCP timeout regression 2026-06-19 21:07:51 +08:00
Xubin Ren bc8f42c639 test(mcp): cover streamable HTTP timeout 2026-06-19 21:07:51 +08:00
Luc NguyenandXubin Ren d7abf39169 fix: set httpx timeout for streamableHttp transport to prevent event loop blocking
timeout=None causes the httpx client to wait indefinitely when connecting
to MCP servers via streamableHttp transport, blocking the entire event loop.
This prevents Telegram polling and other async operations from running.

Set timeout=httpx.Timeout(30.0, connect=10.0) to match the pattern used
in the SSE transport's httpx_client_factory.
2026-06-19 21:07:51 +08:00
yorkhellenandXubin Ren 33638417be fix(session): delete_session also removes legacy path files to prevent history revival
SessionManager._load() migrates sessions from the legacy directory
(~/.nanobot/sessions/) to the workspace path, but delete_session only
checked the workspace path. A user deleting a session could therefore
see its history come back the next time the session was loaded.

- delete_session now attempts to unlink both paths
- returns True if at least one file was removed
- added regression tests: legacy-only, both-paths, and no-revival
2026-06-19 21:07:47 +08:00
sbyininandXubin Ren 6da56f3574 Fix OpenAI reference image home expansion test on Windows 2026-06-19 17:16:09 +08:00
sbyininandXubin Ren 44f7bbae50 fix openai image reference home paths 2026-06-19 17:16:09 +08:00
sbyininandXubin Ren adb737b614 fix openai image reference edits 2026-06-19 17:16:09 +08:00
chengyongruandXubin Ren dd4d410ce2 refactor(feishu): simplify table extraction
Maintainer edit: remove speculative recursive cell handling and keep table extraction to the documented columns and row values.
2026-06-19 17:16:04 +08:00
chengyongruandXubin Ren 215379ac63 fix(feishu): extract table card rows
Maintainer edit: parse Feishu card table columns and rows so forwarded table cards do not fall back to [interactive], and add parser regression coverage.
2026-06-19 17:16:04 +08:00
Jiajun XieandXubin Ren bc59fe8719 fix(feishu): support reading WebSocket rendered card content
Feishu cards arriving via WebSocket have a different structure than
expected: elements are nested lists with tag:text/text fields instead
of flat lists with tag:markdown/content. Also extract user_dsl for
richer card data and support body.elements (schema 2.0).
2026-06-19 17:16:04 +08:00
Xubin Ren 58a14d18dd test: tighten image placeholder assertions 2026-06-19 14:59:52 +08:00
Xubin Ren de5e216583 test: fix image strip test formatting 2026-06-19 14:59:52 +08:00
michaelxerandXubin Ren 7917466f4e fix(tests): update image placeholder assertions for new non-descriptive text
The _strip_image_content methods now use a fixed non-descriptive
placeholder instead of path-derived text. Update the 3 existing
test_provider_retry assertions to match the new placeholder format.
2026-06-19 14:59:52 +08:00
michaelxerandXubin Ren 9ed3905a23 fix(providers): use non-descriptive placeholder when stripping images
The image-strip fallback (triggered when a model errors on image input)
replaced image_url blocks with [image: <path>] or [image omitted]. Both
read like a live, available image to the LLM, causing it to:

1. hallucinate about image contents it never received
2. attempt read_file on the leaked server path
3. expose internal file paths to the model

Replace with an explicit '[Image not delivered to model — do not describe
or reference it]' placeholder that tells the LLM the image was stripped.

Fixes #4345
2026-06-19 14:59:52 +08:00
Xubin Ren bbd7bbd7f5 fix(mcp): avoid relying on progress notification root shape 2026-06-19 14:59:48 +08:00
yu-xin-candXubin Ren f9511049c4 fix(mcp): ignore malformed progress notifications 2026-06-19 14:59:48 +08:00
nanobot-contributorandXubin Ren c2c47f7a03 fix(fallback): treat empty API choices as fallbackable error
When the primary model (e.g. DeepSeek during peak hours) returns an empty
choices response with HTTP 200, the error carries no status code or
structured error metadata. The existing _FALLBACK_ERROR_TOKENS had no
matching token, so _should_fallback() returned False and fallback models
were never tried.

Changes:
- Add 'empty' token to _FALLBACK_ERROR_TOKENS so 'Error: API returned
  empty choices.' text matches the fallback path
- Set error_kind='empty' in openai_compat_provider when returning
  the empty-choices error, making the classification explicit
- Add test coverage for both text-only and error_kind matching paths

Fixes: glebov reported primary never falls back when DeepSeek returns
       empty responses
2026-06-19 14:59:44 +08:00
Xubin Ren d36117de7a feat(webui): support Firecrawl keyless MCP preset 2026-06-19 01:19:20 +08:00
chengyongruandXubin Ren 2d86094fc7 ci: skip docs-only changes 2026-06-18 22:47:43 +08:00
chengyongruandXubin Ren 8ca3f42a3b docs: note feishu login URL fallback
maintainer edit: document that Feishu login prints a URL when optional terminal QR rendering is unavailable.
2026-06-18 22:38:06 +08:00
chengyongruandXubin Ren 71d0593b06 fix: render feishu login with rich
maintainer edit: replace plain progress prints with Rich output for the interactive Feishu QR login flow.
2026-06-18 22:38:06 +08:00
chengyongruandXubin Ren 04777bf6f1 fix: polish feishu login prompts
maintainer edit: make the Feishu QR login output read like a user flow instead of development logs.
2026-06-18 22:38:06 +08:00
chengyongruandXubin Ren 08a5f4cbbb fix: keep feishu login URL unmodified
maintainer edit: remove nonessential tracking parameters from the Feishu QR login URL after the author confirmed the flow works without them.
2026-06-18 22:38:06 +08:00
chengyongruandXubin Ren 5dfdd4f892 fix: handle feishu login network errors
maintainer edit: keep QR login network failures on the expected failure path instead of crashing the channels login command.
2026-06-18 22:38:06 +08:00
chengyongruandXubin Ren a56cd9710b fix: simplify feishu QR login 2026-06-18 22:38:06 +08:00
chengyongruandXubin Ren 99846da6f3 fix: trim feishu login path output
maintainer edit: remove leftover config-path printing from Feishu channel login while keeping the generic success message.
2026-06-18 22:38:06 +08:00
chengyongruandXubin Ren cd51654bf1 fix: keep channel login generic
maintainer edit: remove the Feishu-specific config-file guard from the shared CLI login command. Feishu now follows the Weixin pattern where channel.login owns its setup and persistence.
2026-06-18 22:38:06 +08:00
chengyongruandXubin Ren 3d386f7b7e fix: stabilize feishu login setup
maintainer edit: fix the lint failure, report the active config path, fail fast when the registration response lacks a login URL, and cover the new Feishu login writeback path.
2026-06-18 22:38:06 +08:00
593ab4a788 feat(feishu): add QR scan-to-create bot CLI login feishu command
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-18 22:38:06 +08:00
Xubin Ren a1a627839c docs: include keenable in search provider list 2026-06-18 00:08:52 +08:00
d7280da17c fix(web): require API key for Keenable, fall back to DuckDuckGo
Manual testing against the live API showed the Keenable REST endpoint
(/v1/search) returns 401 without a key — the keyless "free tier" applies
only to the CLI, not the HTTP API. Treat Keenable like every other
key-based provider: fall back to DuckDuckGo when no key is configured,
and drop the now-inaccurate free-tier wording from the docs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 00:08:52 +08:00
092b07c7aa feat(web): use shared user-agent and send X-Keenable-Title
Drop the bespoke nanobot/<version> User-Agent in favor of self.user_agent
for consistency with every other search provider, and add an
X-Keenable-Title: nanobot header so Keenable can attribute traffic.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 00:08:52 +08:00
83cb296cdc style(test): match existing single-line result-dict style
Keep the Keenable search test consistent with the surrounding mocks
(test_tavily/test_brave) rather than introducing a multi-line outlier.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 00:08:52 +08:00
fa3e902ee8 feat(web): register Keenable provider in WebUI, docs, and tests
Bring the Keenable search provider in line with the established
multi-file provider pattern so it surfaces everywhere the others do:

- settings_api.py: register in the web-search provider options so it
  appears in the WebUI settings dropdown (credential: api_key, optional).
- WebUI provider-brand: add keenable brand entry + brand test.
- docs/configuration.md: provider table row + config example.
- Harden _search_keenable: honor config.timeout and return explicit
  messages on HTTP status errors (429 / other), matching peer providers.
- Add env-key and HTTP-error tests; add the websocket settings whitelist
  assertion.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 00:08:52 +08:00
4f6e5e9cb8 feat(web): send honest nanobot UA for Keenable
Keenable is a first-party API, so identify as nanobot/<version> instead
of the shared spoofed-browser User-Agent used by scraping providers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 00:08:52 +08:00
6fcf65a8e3 chore(web): drop redundant comments from Keenable provider
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 00:08:52 +08:00
a630a78941 feat(web): add Keenable search provider
Add Keenable (https://keenable.ai) as a web_search backend, modeled on
the existing httpx-based providers. Unlike key-gated providers, Keenable
has a no-login free tier, so it resolves to itself even without an API
key instead of falling back to DuckDuckGo; the X-API-Key header is only
sent when a key is configured (config api_key or KEENABLE_API_KEY env).

Maps result snippet (falling back to description) into the shared
content field. Covered by tests for keyed/anonymous search and the
no-fallback concurrency behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 00:08:52 +08:00
d5f5eb43e5 feat(providers): first-class Mistral support
Mistral's API constrains reasoning_effort to "high"/"none", rejects the
kwarg entirely for Magistral (reasoning is implicit), returns assistant
content as a mixed array of {type:"thinking",...}/{type:"text",...}
blocks, and 400s on the reasoning_content key in history.

- Remap user-supplied reasoning_effort (low/medium/minimal) onto Mistral's
  two-tier vocabulary; strip the kwarg for Magistral models
- Lift thinking blocks into reasoning_content for both batch and streaming
  responses; pass only text through on_content_delta callbacks
- Drop reasoning_content from outbound history when the spec asks for it
- Expose per-preset reasoning_effort_values so the UI can render the
  provider-specific option set

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-18 00:08:47 +08:00
comadrejaandXubin Ren 51bd3337ef feat(bridge): send read receipts (blue ticks) for incoming messages
Mark each incoming WhatsApp message as read via sock.readMessages()
right after the startup-timestamp filter. Wrapped in try/catch so a
failed receipt never blocks message processing.
2026-06-18 00:08:42 +08:00
chengyongruandXubin Ren 3f41605ddc refactor: simplify exact-file allowlist check
maintainer edit: make the exact-file allowlist check express the invariant directly: the resolved target must still equal the requested logical path before the logical path can match the allowlist.
2026-06-18 00:03:26 +08:00
chengyongruandXubin Ren 515e418eb4 fix: block exact-file allowlist link escapes
maintainer edit: compare exact-file allowlist entries using logical paths and require the resolved target to stay at that canonical path, so symlinks or junctions cannot redirect canonical memory files to an external write target.
2026-06-18 00:03:26 +08:00
chengyongruandXubin Ren 42ce294665 fix: preserve internal tool write scopes
Maintainer edit: keep capability-specific allowed_dir boundaries active even when the outer workspace scope is full access, and cover Dream plus ordinary full-access filesystem behavior.
2026-06-18 00:03:26 +08:00
chengyongruandXubin Ren 51f2dae855 refactor: trim unused filesystem allowlist state
maintainer edit: simplify the exact-file allowlist follow-up by removing unused read-side state and keeping the exact path helper private to workspace_policy.
2026-06-18 00:03:26 +08:00