644 Commits

Author SHA1 Message Date
Qiu
0ac31207ee fix(api): unwind API resources after startup failure (#3111) 2026-12-01 21:37:49 +08:00
Antonio-Faure
572d80c2e7 fix(mcp): bind OAuth Test to the stored server origin (#2763)
* fix(mcp): bind OAuth Test to the stored server origin

A saved OAuth grant is addressed by the path name, but Test accepts an
unsaved payload URL. Without an origin check a valid stored bearer is
attached to any origin the caller names, so a draft can exfiltrate the
grant. Load the owner-scoped stored server and require the draft URL to
match its normalized origin; otherwise return needs-authorization
without opening a transport or touching the grant.

Refs #2589.

* chore(api): regenerate the router index fingerprint

* chore(api): regenerate router_index.json against dev

---------

Co-authored-by: Antonio-Faure <209759495+Antonio-Faure@users.noreply.github.com>
Co-authored-by: OrdoAbChao7 <2369980241@qq.com>
2026-12-01 20:30:43 +08:00
Leoy
8b2448e293 fix(knowledge): fit uploaded names and folder segments into the 255-byte limit (#3140)
Byte-fit KB upload filenames and folder segments to NAME_MAX, and share fit_filename_bytes with attachment/reading stores.
2026-12-01 17:00:42 +08:00
Rahul selvaraj
5ea8fa1ebc fix(mcp): let operators declare Fake-IP ranges for self-service servers (#2857)
* fix(mcp): let operators declare Fake-IP ranges for self-service servers

A local proxy in Fake-IP mode (Loon, Clash, Surge) answers DNS for public
hostnames with synthetic private addresses, e.g. fd27:712::/32 from Loon,
and routes the connection by hostname. Strict validation then rejects
public MCP Store entries such as GitMCP as private-network targets.

Add DEEPTUTOR_MCP_FAKE_IP_RANGES (comma separated CIDRs, opt-in, read from
the process environment). In strict mode an address a hostname resolves to
inside a declared range is no longer rejected as private. IP-literal URLs,
loopback and the link-local/metadata ranges stay blocked regardless, and
any other private answer for the same host still fails validation.

Closes #2789

Assisted-by: Claude <noreply@anthropic.com>

* fix(mcp): warn on Fake-IP opt-in and document single-user SSRF trade-offs

Address review feedback from JinhangHE126 on #2857:
Document clearly that DEEPTUTOR_MCP_FAKE_IP_RANGES relaxes hostname-based SSRF protection for hostnames resolving into declared ranges (as the proxy resolves targets and connects).
Emit a startup security warning when DEEPTUTOR_MCP_FAKE_IP_RANGES is set, noting that the setting is intended strictly for single-user/desktop installations.

Assisted-by: Gemini (Google Vertex AI)
2026-12-01 10:32:50 +08:00
fjm
bdafbc1cc8 chore(api): regenerate the router index
test_repository_index_matches_router_sources fails on dev since fea1be2c9: the stored fingerprint no longer matches the router sources. Regenerated with scripts/build_router_index.py. Only the fingerprint changes; the route patterns are identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01J2vr2J41oqPYhmpP8CzSJA
2026-11-30 20:22:33 +08:00
lipeh1
681b23766f feat(rag): support local rerankers for LightRAG queries (#3009)
* feat(rag): support local rerankers for LightRAG queries

Allow administrators to select a cross-encoder alongside the native LightRAG role models. Run scoring in a reusable worker and partition cached answers by reranker so model changes take effect on existing indexes.

Refs #2701

* fix(api): refresh the router index for LightRAG settings

* fix(rag): run LightRAG reranking in the shared reranker worker

anyio's process pool re-runs the server's __main__ file by path. When the
backend runs as `python -m deeptutor_cli.main serve` (the desktop app),
that file's relative imports fail, so every rerank call failed with
'Error during worker process initialization' and LightRAG silently kept
the original chunk order. Reuse the python -m reranker worker that the
LlamaIndex pipeline already uses.

---------

Co-authored-by: lipeih <lipeihan@eazytec.com>
Co-authored-by: zszz3 <zszz3@users.noreply.github.com>
2026-11-30 18:46:49 +08:00
Qiu
ff0b7be3f8 fix(book): use the active clock for standalone chapter retries (#3098) 2026-11-30 06:33:07 -03:00
AleFlyX
e542e3ff0e fix(knowledge): drop visual assets on every document-delete path (#3022)
* fix(knowledge): drop visual assets on every document-delete path

Extracted figures are tracked in `visual_assets/` (manifest + image files) and
were only cleaned by the HTTP delete-file route, which called
`VisualAssetStore.remove_source` itself. `remove_raw_document` has three
callers - that route plus the GitHub and web source syncs - so the two sync
paths deleted the document and left its figures and manifest entries behind
forever. Images are capped at 5 MB each, so a sync that drops figure-heavy
documents leaks a lot of disk.

Reproduced before the fix: a KB with one raw PDF and a matching asset entry,
then `remove_raw_document(kb, doc)` (exactly what both syncs do) -> the doc was
gone while the asset file and its manifest entry both remained.

Cleanup now happens in `remove_raw_document`, the single layer all three
deletion paths share, keyed by the module's existing `_raw_hash_key` - the same
rule indexing uses to record `source_path`, so nested raw/ paths cannot be
missed. The route's now-redundant call is removed rather than left as a second
owner: it also removes a second, lexical relative-path computation, and the old
uncaught call could 500 a delete on a corrupt manifest, which contradicts the
"cleanup never fails a user's delete" contract.

Best-effort like the surrounding code: a corrupt or read-only manifest logs a
warning and never turns a delete into an error. `VisualAssetStore.__init__`
only assigns paths, and `remove_source` returns before writing when no entry
matches, so KBs that never had images are not given an empty `visual_assets/`
directory (pinned by a test).

Verified: 7 new tests; mutation check shows disabling the cleanup fails 4 of
them. Independent checks: nested `papers/2024/` asset removed while a sibling
document's asset is preserved; no `visual_assets/` created for an image-free
KB; re-running the original repro now reports no leak.
Tests: 264 passed (knowledge, visual assets, source sync, HTTP file deletion).

Note: assets for an older parser signature are deliberately kept so a rollback
to an older index version still resolves its figures; that is retention, not a
leak, and is unchanged here.

* fix(api): 更新路由索引指纹

重新生成 knowledge 路由变更后的索引。原生引擎和路由加载器的 18 个测试均已通过。

---------

Co-authored-by: zszz3 <zszz3@users.noreply.github.com>
2026-11-30 15:37:35 +08:00
cro3w
d77ad8f6c4 fix(reading): isolate document ingestion from the API process (#2988)
* fix(reading): isolate document ingestion from the API process

(cherry picked from commit f0fd1f785eb1070f689816b0977bf4c60125f95a)

* chore(api): refresh router index for the reading routes

---------

Co-authored-by: zszz3 <zszz3@users.noreply.github.com>
2026-11-30 15:15:59 +08:00
Zhuoran Wang
3ce3d47858 Fix quiz-attempt 500 when the Book entity has no chat_session_id (#2692)
* Fix quiz-attempt 500 when the Book entity has no chat_session_id

book.py's attempt sync read book.chat_session_id, an attribute that only
exists on CreateBookRequest/BookInputs (a legacy creation-time shorthand)
and is not persisted on the Book model — so every quiz attempt without a
page-bound chat session raised AttributeError after the progress was
saved, returning 500 and dropping the Focus-Check assessment sync.

Read only the persisted per-page mapping, and cover it with a regression
test whose fake mirrors the real entity (no chat_session_id attribute).

* style: apply ruff format

* chore(api): refresh router index for the book router

---------

Co-authored-by: zszz3 <91608029+zszz3@users.noreply.github.com>
2026-11-29 15:28:55 +08:00
Leoy
566465dc42 fix(mastery): ignore knowledge-base sources that no longer resolve (#2752)
* fix(mastery): ignore knowledge-base sources that no longer resolve

Refs #2748

* fix(mastery): filter the caller's mounted knowledge bases too

A study session left open across a deletion keeps sending the base it was
mounted with, and that list is merged verbatim with the topic's sources.
Run both through knowledge_base_ref_available so a stale name cannot reach
the tool bundles and raise AccessError.
2026-11-29 14:49:40 +08:00
Qiu
506cea9d4f feat(desktop): finish Windows chat file actions (#3051)
Continues #2978 and closes #2887. Includes the original Windows file actions, integrates the changes with dev, and adds an explicit default-app action.

Co-authored-by: Botong Wu <2048400180@qq.com>
2026-11-28 13:09:15 -03:00
Rudy Mizrahi Celekli
df2d6f0b0b fix(reading): preserve original extensions on long multilingual filenames (#2780)
* fix(reading): fit original filenames within the UTF-8 limit

* fix(reading): shorten the temp upload name the same way

The upload is first written to a temp file named after the upload. A
100-character Chinese name is 300 UTF-8 bytes, so on Linux the request
failed with "File name too long" before the stored-name limit added
here was ever reached.

* chore(api): refresh router index for the reading upload change

---------

Co-authored-by: zszz3 <91608029+zszz3@users.noreply.github.com>
2026-11-28 20:26:37 +08:00
qiuqianyi66
32acc5889a fix(settings): answer 404 for unknown connection-test run ids (#2841)
* fix(settings): answer 404 for unknown connection-test run ids

* chore(api): refresh router index for the settings route change

tests/api/test_router_loader.py::test_repository_index_matches_router_sources
checks the fingerprint of router sources; regenerated with
scripts/build_router_index.py.

---------

Co-authored-by: zszz3 <91608029+zszz3@users.noreply.github.com>
2026-11-28 20:05:55 +08:00
Bingxi Zhao (Frank)
8ab4ecfee9 feat(books): review and undo scoped chapter and section edits
Fixes #2571
2026-11-15 01:42:47 +08:00
Bingxi Zhao (Frank)
ce4434e75a fix(workspaces): reuse knowledge references in selective conversation moves
Fixes #2289
2026-11-15 01:42:46 +08:00
Bingxi Zhao (Frank)
53bc9eb99d fix(learning): paginate and search question bank sources
Fixes #2641
2026-11-15 01:20:53 +08:00
Bingxi Zhao (Frank)
8ecf2da95f fix(parsing): validate uploads against available parser formats
Fixes #2338
2026-11-15 01:20:52 +08:00
Bingxi Zhao (Frank)
b46d9b5763 fix(mcp): reconnect after consent and refresh authorization status
Local dev repairs for #2586.

OAuth owner isolation and refresh-token stability verified. Hook polls until connected, refreshes on focus and stops on unmount. Python rechecks: 56 passed; UI batch: 25 passed. Web typecheck, 1407 Node tests, eslint and i18n passed.
2026-11-15 00:50:30 +08:00
Bingxi Zhao (Frank)
3a533c6c5f fix(auth): allow chat learners to record and play voice
Local dev repairs for #2437.

Guarded voice endpoints and negative permissions tested in the 375-pass first batch.
2026-11-15 00:50:30 +08:00
Bingxi Zhao (Frank)
47ae8a27e4 Merge PR #2515: feat(i18n): add Hungarian as an interface and reply language
Combine Hungarian with Italian UI and Hindi reply-language registries; translate 49 newly integrated keys and add the Hungarian endonym to Italian. Regenerate router and frontend contracts. 33 Python locale tests, full Node suite and locale parity pass.
2026-11-14 23:36:26 +08:00
Bingxi Zhao (Frank)
95aa81d624 Merge PR #2544: feat(i18n): add Italian (it) localization
Make Italian quality tests compatible with CommonJS Node test compiler; accept Italiano as reply-language alias; translate 48 keys added by other integrated PRs; regenerate router index and format i18n. 26 Python locale tests and full Node suite pass.
2026-11-14 23:34:48 +08:00
Bingxi Zhao (Frank)
af403550ce Merge PR #2639: fix: explain missing LLM access in chat
Retain admission error text and localized model-access guidance; allow explicit retry to revalidate access instead of permanently blocking stored messages. No automatic retry on reload. Backend tests and both manual retry paths passed.
2026-11-14 23:19:09 +08:00
Bingxi Zhao (Frank)
2d493edb84 Merge PR #2521: feat(i18n): add Hindi as a reply language
Regenerate the lazy route index after the reply-language contract changes; targeted tests passed.
2026-11-14 23:16:33 +08:00
Bingxi Zhao (Frank)
33078edd49 Merge PR #2542: fix: register connected knowledge bases in the viewing workspace
Regenerate the lazy route index after workspace registration changes; targeted API tests passed.
2026-11-14 23:16:29 +08:00
Bingxi Zhao (Frank)
9934fb15ca Merge PR #2625: feat(book): post-generation chapter CRUD without recompiling
Validate chapter existence, spine presence, and protected overview deletion before claiming a revision; cover failed edits followed by valid retries (22 passed).
2026-11-14 23:11:57 +08:00
Bingxi Zhao (Frank)
3fc9d2ce18 Merge PR #2534: feat(web_fetch): pluggable fetch backend with DeepSeek Fetch as first alternative
Combine independent locale additions and regenerate integrated route index.
2026-11-14 23:00:23 +08:00
Bingxi Zhao (Frank)
68220257af Merge PR #2568: feat(guardian): show scoped Reading progress and quiz records
Combine independent locale additions and regenerate integrated route index.
2026-11-14 23:00:03 +08:00
Bingxi Zhao (Frank)
c60e0e0331 Merge PR #2576: feat(reading): record question-linked help without replacing the quiz
Keep server-only quiz answer keys before persisting help results; retain relationship and extension-policy revalidation.
2026-11-14 22:59:16 +08:00
Bingxi Zhao (Frank)
fa3debf4b4 Merge PR #2560: fix(reading): keep quiz answer keys on the server 2026-11-14 22:58:53 +08:00
Bingxi Zhao (Frank)
a768f739a2 Merge PR #2578: fix(book): don't advance revision when refresh-fingerprints is refused 2026-11-14 22:58:50 +08:00
Bingxi Zhao (Frank)
d76a4cbe7e Merge PR #2526: fix: resolve workspace KB scope past dead registrations; keep the progress stream off the activity lease
Regenerate the lazy router index against the integrated route sources.
2026-11-14 22:58:00 +08:00
Bingxi Zhao (Frank)
f691217179 Merge PR #2589: fix(mcp): pass the server name into the OAuth store during Test
Regenerate the lazy router index against the integrated route sources.
2026-11-14 22:57:40 +08:00
Bingxi Zhao (Frank)
54324f8318 Merge PR #2674: fix: reject partner session branches that already exist
Preserve both image-only partner history coverage and existing-destination validation tests; combined partner suite: 146 passed.
2026-11-14 22:57:24 +08:00
qq1069730908
9bc95d6bee fix: regenerate router index for chat patch 2026-11-14 20:06:58 +08:00
mpichini1
48e1e66c23 fix(api): refresh partner router index fingerprint 2026-11-14 10:14:47 +01:00
mpichini1
44dee85814 fix: reject partner session branches that already exist 2026-11-13 19:26:35 +01:00
mpichini1
64626e3015 fix: deliver task stream terminal events when subscriber queues fill 2026-11-13 19:14:00 +01:00
Junlin Li
560a80a17f fix: explain missing LLM access in chat 2026-11-12 16:58:52 +08:00
ZQR1101
e2d16b5b5e chore(book): regenerate router index for the chapter CRUD endpoints
Adding the four chapter routes changed the router source fingerprint, so
the tracked lazy-routing index must be rebuilt via scripts/build_router_index.py
to keep test_repository_index_matches_router_sources green.
2026-11-11 20:45:37 +08:00
ZQR1101
71a05602d5 feat(book): post-generation chapter CRUD without recompiling
Add / rename / reorder / delete chapters after generation through REST
endpoints mirroring the block-CRUD handlers. New chapters are pending
shells; already-compiled pages are never recompiled or discarded. Each
edit carries the chapter's order/title onto its pages so the reader-visible
sequence follows, and delete prunes only its own pages plus the concept
graph, prerequisites, and progress refs.

Part of #2571
2026-11-11 17:45:37 +08:00
evan188199-tech
4847abff1b chore(api): regenerate router_index after the MCP Test name fix (#2587)
Signed-off-by: evan188199-tech <238371241+evan188199-tech@users.noreply.github.com>
2026-11-10 16:06:32 +08:00
evan188199-tech
585d7656c7 fix(mcp): pass the server name into the OAuth store during Test (#2587)
POST /api/space/mcp/servers/{name}/test discarded the path name, so a
probe of an OAuth-backed server built its token store with '' and every
Test answered "ValueError: Unsafe MCP server name for an OAuth store: ''"
— including for a server that was authorized and connected.

probe_server now takes a server_name (the name the saved connection
would address the grant under) and the space router passes the path
name for OAuth configs. A scratch name no grant could live under (an
unnamed draft) is answered the way an unauthorized server is instead of
the store's refusal; non-OAuth probes stay nameless as before.

Fixes #2587

Signed-off-by: evan188199-tech <238371241+evan188199-tech@users.noreply.github.com>
2026-11-10 15:35:07 +08:00
evan188199-tech
b04ac1bbc0 fix(book): run refresh-fingerprints refusal gate before claiming revision
A rejected POST /api/books/{id}/refresh-fingerprints (force=false, stale
pages not yet recompiled) bumped and persisted book.revision before the
engine refused it, so the client's expected_revision went stale and the
force=true retry always lost the revision race (409 forever).

Run the engine's refusal check (new read-only preflight
check_refresh_kb_fingerprints -> ensure_can_refresh_fingerprints) before
_claim_content_mutation; a rejected dismissal is now side-effect free and
the force retry with the same expected_revision succeeds. Regenerate the
router index fingerprint.
2026-11-10 00:47:45 +08:00
Yin
caee2c5ff6 feat(reading): persist question-linked help receipts and events 2026-11-10 00:12:58 +08:00
Yin
a420707623 feat(guardian): show scoped reading progress and quiz records 2026-11-09 23:07:32 +08:00
Yin
9e4db3c292 fix(api): synchronize router index after quiz response change 2026-11-09 22:45:38 +08:00
Yin
5d16a6a2f0 fix(reading): keep quiz answer keys on the server 2026-11-09 22:17:03 +08:00
Daniele Lucarelli
377bf10fa9 feat(i18n): add Italian (it) localization 2026-11-09 08:48:31 +00:00
evan188199-tech
aaf19c6352 fix: regenerate router_index after web-fetch settings routes (#2448) 2026-11-09 16:47:49 +08:00