Commit Graph

1376 Commits

Author SHA1 Message Date
Bingxi Zhao (Frank)
5de30246bd fix(reading): make EPUB pairings durable and explicit 2026-08-26 00:43:15 +08:00
XZH
410711bf7b feat(reading): add explicit bilingual EPUB pairing 2026-08-26 00:40:50 +08:00
Bingxi Zhao
678e904644 Merge pull request #969 from evan188199-tech/codex/epub-faithful-viewer
feat(reading): render EPUBs faithfully in ReaderPane
2026-08-26 00:40:17 +08:00
Bingxi Zhao
7e084df0a4 Merge pull request #986 from zh769394/fix/windows-compatibility
fix: improve Windows cross-platform compatibility across runner, tool…
2026-08-26 00:39:48 +08:00
XZH
e758af8f48 feat(reading): render EPUBs faithfully in ReaderPane 2026-08-26 00:31:24 +08:00
zh769394
61a32bd626 fix: improve Windows cross-platform compatibility across runner, tools, and tests
- Guard resource module import in runner server for non-POSIX platforms
- Use POSIX relative path format in ListDirTool for consistent path separators
- Specify UTF-8 encoding in Weixin channel state loading and prompt tests to avoid GBK UnicodeDecodeError
- Use as_posix() in path assertion tests for cross-platform compatibility
2026-08-26 00:29:52 +08:00
Bingxi Zhao
3dbdb3ddb3 Merge pull request #968 from evan188199-tech/codex/epub-reading-contract
feat(reading): add source-faithful EPUB contract
2026-08-26 00:28:58 +08:00
Bingxi Zhao
188c498f1d Merge pull request #988 from NoxsMedia/fix/codex-tls-fail-closed
fix(codex): fail closed on TLS verification errors
2026-08-26 00:28:43 +08:00
Bingxi Zhao
fa25c0774a Merge pull request #989 from NoxsMedia/fix/lightrag-asymmetric-context
fix(rag): preserve asymmetric embedding context
2026-08-26 00:28:15 +08:00
Bingxi Zhao
7c2d80cf36 Merge pull request #998 from evan188199-tech/codex/book-reader-sequential-navigation
fix(book): read long chapters sequentially before turning pages
2026-08-26 00:27:49 +08:00
Bingxi Zhao
bd87589b0d Merge pull request #1005 from arsaboo/props
Fix llama.cpp context detection for loaded models
2026-08-26 00:27:14 +08:00
Alok Saboo
3b0b66cbd1 feat: extracting context window from llama.cpp metadata 2026-08-25 09:47:25 -04:00
Bingxi Zhao (Frank)
3e82f13042 build(pre-commit): pin ruff to the version CI installs
The hook was on v0.14.7 while `.github/workflows/tests.yml` installs
ruff==0.16.0. The two disagree on real files — 0.14.7 wanted a blank
line removed that 0.16.0 considers already formatted — so the local gate
and the CI gate were judging the same code by different rules, and which
one you satisfied depended on which ran last.

Verified clean on this tree: `pre-commit run --all-files` passes at
v0.16.0 with no rewrites, and `ruff check .` + `ruff format --check .`
at 0.16.0 agree.
2026-08-25 10:55:29 +08:00
XZH
c59b9547d7 fix(book): read long chapters sequentially before turning pages 2026-08-24 19:39:23 -07:00
Bingxi Zhao (Frank)
c600a507a4 fix(tests): stop the partner suite writing to the real account store
`identity` binds `AUTH_DIR = SYSTEM_ROOT / "auth"` at import, so the
partners fixture's `setattr(paths, "SYSTEM_ROOT", tmp)` never reached it:
`save_user` wrote into the developer's own `data/system/auth/users.json`
and read it back. The suite had already deposited an `alice` account
there.

That also made `test_a_linked_sender_gets_their_own_private_history`
depend on who else happened to have an account. The first account in a
store is force-promoted to admin whatever role is asked for, and an
admin's scope *is* the shared pool — so on an empty store alice became
admin and "her private history" and "the shared pool" resolved to one
directory. It passed on a machine with existing accounts and on a full
run, and failed alone and on all four Python versions in CI (v1.5.17's
release commit is red for exactly this).

The fixture now redirects identity's file constants too, and `alice` is
saved after an admin so she is guaranteed non-admin — asserted, so the
precondition cannot rot silently. Product code is unaffected: the
behaviour under test was always correct.

Also collapses the three copies of the api_key reduction into one.
`_primary_api_key` (provider_runtime) is deleted and
`LLMConfig.get_api_key` delegates, both to `keypool.primary_api_key`,
which now treats an empty key as absent in either spelling so its list
and scalar branches agree. Equivalence checked across every configured
shape: "", None, [], [""], ["", "k"], "k", ["k"], ["k1", "k2"].

pytest 5284 passed (was 5276), pre-commit clean, ruff check + format
clean at CI's pinned 0.16.0.
2026-08-25 10:20:26 +08:00
Bingxi Zhao (Frank)
bd80a4d28a release: v1.5.17
Partners stop being a deployment-wide admin resource and become
per-user: three nested rights (manage / use / neither) replace the
blanket admin gate on the router, each member can build and own their
own, and every person's conversations with a partner stay private to
their account. Grants keep working and now offer only admin-managed
partners. Channel runtime state moves from one directory per channel to
one per partner — copied, not moved, and only when its owner is
unambiguous — so two partners can finally run the same channel.

Around that: a knowledge base can track GitHub repositories and re-sync
their Markdown (#903); Antigravity CLI joins My Agents now that Gemini
CLI is retired (#828); personal WeChat signs in from a QR code drawn in
the browser instead of the server log (#951); a chat account can be
linked to a DeepTutor account with /link; containers re-apply the extras
they declare instead of losing them at compose down (#762); and
`deeptutor doctor` answers whether a workspace is ready to run (#959).

Reliability, largely from community PRs: embeddings survive a
rate-limited provider through key rotation, a retry budget and a global
throttle (#962); MinerU parsing and code execution work on Windows
(#844, #964); indexing fails bounded instead of hanging (#946); MinerU
page-layout blocks stop being indexed as content (#949); voice uploads
carry a MIME the transcription API accepts (#945); and reasoning effort
can be overridden per conversation (#641).

Release plumbing: notes in assets/releases/ver1-5-17.md, v1.5.13
archived, __version__ 1.5.17, README Releases row and all eleven
translations synced.

Two defects found by the release gate and fixed here:

- Six partner routes — the four channel-onboarding endpoints and both
  WeChat QR endpoints — kept the _auth-only mount they had inherited
  from the blanket admin gate, so any signed-in account could start a
  QR login for someone else's partner and write a bot token into its
  channel config. All six now declare _MANAGEABLE, and a sweep test
  asserts no {partner_id} route is left ungated.
- A configured api_key became `str | list[str]` when key rotation
  landed, but ten call sites pass it somewhere that takes one key; a
  list would have rendered into an Authorization header verbatim.
  keypool.primary_api_key reduces at each boundary.

Gates: pre-commit (all 15 hooks), ruff check + format, pytest
5276 passed, web 605 node tests, docs build.
v1.5.17
2026-08-25 02:24:35 +08:00
XZH
9daea4d0af fix(reading): reset stale legacy EPUB positions 2026-08-24 08:03:13 -07:00
nox
69286c3583 fix(rag): preserve asymmetric embedding context 2026-08-24 11:58:45 +00:00
nox
19e90e7529 fix(codex): fail closed on TLS verification errors 2026-08-24 11:47:17 +00:00
Bingxi Zhao
87ccedd549 test(partners): assert the admin gate by request, not by route internals (#983)
The admin-gate test from #952 read `route.include_context`. That attribute
only exists from FastAPI 0.141, where `include_router` stopped flattening the
sub-router into the parent app; before that the routes are copied onto
`app.routes` and there is no `include_context` at all. This project pins
`fastapi>=0.100.0` with no upper bound, so the test passed on CI (which
installs the latest) and raised `StopIteration` on any older satisfying
install — `5115 passed, 1 failed` locally on 0.135.1.

No structural assertion works across that range, so assert the actual
property instead: send a valid `role=user` token and require 403. A response
code does not care how the router is represented.

An unauthenticated request would not have been enough — `require_auth` alone
answers that with 401, so downgrading the router from `_admin` to `_auth`
would still have looked gated. With a real non-admin token, both weakenings
(`_admin` → `_auth`, and dropping the dependency entirely) let the request
reach the handler and fail the test. Also patches `AUTH_SECRET`, without
which `decode_token` rejects every token in a bare test environment and the
403 could never be distinguished from a 401.

Co-authored-by: Frank <bingxizhao@novix.science>
2026-08-24 17:54:04 +08:00
evan188199-tech
50f8ccbaa4 feat: split knowledge sync - add GitHub source sync (#903)
* feat(knowledge): add GitHub source sync

* fix(github-sync): contain downloaded paths inside the KB raw dir

Destinations were built as `raw_dir / rel` where `rel` is derived from the
GitHub tree/compare response — remote input. Two shapes escaped: a `..`
segment, and an absolute path, which is the quieter one because
`Path("/kb") / "/etc/x"` is `/etc/x`, silently discarding the base. The only
filters in the way checked the file extension and the glob, so a matching
path would have been written — and, on the removal branch, deleted — outside
the knowledge base.

git rejects both shapes in tree entries today, so this is defence in depth
rather than a live exploit; a downloader still should not delegate to the
remote the question of where it writes. One `_contained_dest` seam now guards
the full-sync write, the incremental write, and the removal, and logs what it
refused.

---------

Co-authored-by: XZH <cto@xzh.ai>
Co-authored-by: Frank <bingxizhao@novix.science>
2026-08-24 16:55:47 +08:00
Valor
efc4a3d3ca fix(rag): surface local LightRAG provenance (#754)
Co-authored-by: Valor <210239105+zrh805@users.noreply.github.com>
Co-authored-by: Frank <bingxizhao@novix.science>
2026-08-24 16:54:25 +08:00
Wong
1625cdd105 fix(embedding): survive provider rate limits — key rotation, retry budget, global throttle (#962)
* T028(Codex交付,ZC核验代提交): KeyPool多key轮换层(provider×model×key池·429冷却·单key兼容) · api_key/api_token字段兼容数组 · 三处接入(embedding/mineru/llm) · 图片描述gather+Semaphore并发化 · 303单测全过(含官方既有测试回归)

* FIX-EMB-429: 火山embedding 429根治(上游PR候选) · ①429重试按Retry-After等30s(滑窗等过) ②resolver从profile读batch_size/batch_delay(火山RPM极低必须限速) · 实测batch5/delay2s下语文reindex突破processing · 三key池x2冷却机制已验

* HARDEN-429: embedding限流重试1→8次+全冷却等待65s再取 · 单key池滑动窗口瞬时429不再报废数小时reindex整跑(08-22三烧教训) · 月度额度429仍8轮后raise不空转

* FIX-UNBOUND: 限流重试槽位for耗尽静默穿落到data引用 · 槽位1+max(MAX_RETRIES,10)兜住8轮限流 · t035镜像UnboundLocalError根因(逻辑走查复现)

* THROTTLE-GLOBAL: embedding跨实例全局节流锁 · 类级锁串行化'间隔+发帖'(多文档并行reindex各自client叠加超RPM=08-22历史库六烧终根因) · batch_delay升级为全局最小间隔 · 手动单发200而进程内全429的分歧由此闭合

* FIX-LOCK: 节流锁asyncio→threading · LlamaIndex _run_in_new_loop每线程新event loop,asyncio.Lock绑创建loop跨loop不互斥(根因三层剥洋葱终层) · 静态方法装饰修正 · 容器内3线程串行化实测2.01s通过

* PR-PREP: 中性化 fork 痕迹注释(中文→英文 provider 通用表述) · 上游v1.5.16已有_as_api_key数组支持,删我方重复实现保留上游版 · 测试148+86全过 · 密钥扫描分支历史+工作树双清(A类指纹0命中,B类28处=上游自带fixture)

* LINT: ruff format 6文件对齐CI(上游基线0债,全是我方引入) + import顺序修正

* FIX-CI: 图片处理块整体采纳上游v1.5.16版(_describe_image新签名+批量embed_contents) · 删越域的fork逐图并发测试(记档将来独立PR) · 592测全过

* FIX-CI: _build_openai_client合并壳与实现(上游sanitize保留+key池数组兼容) · placeholder_key改用primary_key(list哈希修复) · 889测全过

* fix(keypool): never refuse the only key

`KeyPool` is built even for a single-key config, and `next()` raised
`RuntimeError("All API keys are cooling down")` once every key was cooling.
For the common one-key setup that meant two 429s took every LLM and embedding
call down for the full 60s window — and it bypassed the rotation layer's own
429 handling entirely, since the RuntimeError surfaces before
`_KeyRotatingCompletions.create` can mark the strike and re-raise the real
provider error. `sdk_max_retries=0` had already handed retry duty to that
layer.

Cooling is a preference hint, not a circuit breaker: when everything is
cooling, return the key that recovers soonest and let the provider's own 429
surface to be retried.

The existing single-key test asserted the raise while calling itself
"keeps single key compatible" — it now pins the behaviour the name promises,
plus the soonest-recovery ordering for the multi-key case.

---------

Co-authored-by: interia <interia@interiadeMac-mini.local>
Co-authored-by: Frank <bingxizhao@novix.science>
2026-08-24 16:54:14 +08:00
落雨✦
6f0c7fdb47 fix: Windows MinerU parsing — subprocess UTF-8 decoding & render-thread crash (#844)
* fix: Windows robustness — MinerU UTF-8 decode, render-thread crash & atomic-write PermissionError

- mineru/local.py: pass encoding="utf-8", errors="replace" to subprocess.Popen so MinerU's combined stdout/stderr is decoded as UTF-8 instead of the platform default (GBK on zh-CN Windows), which previously crashed with a UnicodeDecodeError (0x8b).
- mineru/models.py: set MINERU_PDF_RENDER_THREADS=1 in model_env_overrides to avoid MinerU's multi-threaded PDF rendering heap-corruption crash (0xc0000409) on Windows.
- services/file_io.py: retry atomic replace on transient PermissionError (e.g. target locked by antivirus/indexer) with exponential backoff, instead of failing the whole write on Windows.

* fix(mineru): gate the render-thread guard to Windows

`MINERU_PDF_RENDER_THREADS=1` was set unconditionally, but the variable is
honored on Linux and macOS too (upstream default 3-4 render workers), so a
Windows-only heap-corruption workaround was serializing page rendering for
every platform. It also sat in `model_env_overrides`, whose contract is the
model-weight download source — and adding a key there broke that function's
exact-equality test.

Move it to its own `render_env_overrides()` next to the other MinerU env
knowledge, guarded on `sys.platform`, and merge it into the subprocess env at
the local-CLI branch in `backend.py`. Only that branch renders pages in this
process tree; cloud mode never does.

---------

Co-authored-by: Frank <bingxizhao@novix.science>
2026-08-24 16:54:05 +08:00
john00010
dcbb1d3393 fix(sandbox): support Windows code execution (#964)
* fix(sandbox): support Windows code execution

* refactor(sandbox): vary only the shell clause in the workspace note

The Windows branch duplicated the whole workspace paragraph, so the note
existed in four near-identical copies (zh/en x posix/windows) that would drift
apart on the next edit. Only the "how do I get a script into a file" clause
actually depends on the host shell, so vary that clause and keep one template
per language.

Also prefer `pwsh` (PowerShell 7+) when it is on PATH — it defaults to UTF-8
and is the version still receiving updates; the generated commands are written
in 5.1-compatible syntax, which 7 accepts too. And hoist `import sys` to module
scope now that two methods need it.

Adds the tests this note never had: each host gets the syntax that works there
(a Bash heredoc is a syntax error in PowerShell, and the model would silently
produce no file), and the host-independent half stays byte-identical.

---------

Co-authored-by: Frank <bingxizhao@novix.science>
2026-08-24 16:52:04 +08:00
ZQR1101
7edddbec61 fix(web): pin chat to late-mounted quiz cards (#960)
* fix(web): pin chat to late-mounted quiz cards

QuizViewer loads after the 4s post-stream scroll window, so mastery quiz cards stay below the fold until the user scrolls. Watch [data-chat-grow] for 12s without re-pinning unrelated details expands.

Related to #955

* fix(web): extend the existing post-stream window for late viewers

The post-stream effect already existed for exactly this case — its comment
names QuizViewer — so a second, parallel MutationObserver with its own 12s
window meant two observers racing for the same pin, each unaware of the
other's deadline.

Fold the extension into that one effect: the window starts at 4s and only a
*newly appearing* ``[data-chat-grow]`` node pushes it out to 12s. Gating on
appearance rather than presence matters — presence alone is satisfied
permanently by any quiz card from an earlier turn, which would have re-pinned
the user on every later DOM mutation, the precise mis-classification the
short window exists to avoid. The teardown timer follows the current
deadline, so a turn with no late viewer stops observing at 4s as before.

---------

Co-authored-by: ZQR1101 <278034003+ZQR1101@users.noreply.github.com>
Co-authored-by: Frank <bingxizhao@novix.science>
2026-08-24 16:52:00 +08:00
0xTidalBore
8d6a6e3a59 fix(llamaindex): fail bounded when indexing stalls (#953)
* fix(llamaindex): fail bounded when indexing stalls

Indexing steps run in a sync executor thread. An embedding provider that
accepts a request but never completes it can stall the executor future
forever: HTTP timeouts only bound a single attempt and provider retries
extend the wait far beyond any reasonable budget. Add a stall guard that
watches the embedding progress heartbeat and raises a clear error once no
progress has been reported for a bounded window (default 10 minutes),
instead of hanging indefinitely.

Fixes #946

* fix(rag): re-arm the stall heartbeat each poll tick

`set_progress_callback` writes to the process-global LlamaIndex `Settings`
embed model, which holds exactly one callback slot. A second indexing job
started while the first runs displaced the first job's heartbeat, so its
`last_progress` stopped advancing and the guard raised `IndexingStallError`
against a job that was indexing normally — turning what used to be merely
lost progress reporting into a hard failure.

Reclaim the slot on every poll tick. Missing a few notifications for one
tick is harmless; never observing our own progress again is not. The guard is
now consciously biased toward false negatives: it can be slow to notice a
genuine stall while another job indexes, and never fails a job that is
making progress.

---------

Co-authored-by: 0xtidalbore <ahmed@itcloud.ca>
Co-authored-by: Frank <bingxizhao@novix.science>
2026-08-24 16:51:56 +08:00
ZQR1101
ac25a5c868 fix(voice): strip MediaRecorder codec params from STT uploads (#948)
* fix(voice): strip MediaRecorder codec params from STT uploads

Chrome sends audio/webm;codecs=opus; OpenAI-compatible transcription APIs reject that as an unknown format.

Fixes #945

* refactor(voice): normalize the STT MIME once, at the wire boundary

The codec-parameter strip was applied at four layers: the recorder hook, the
route, the `transcribe_audio` facade, and `_post_multipart`. Only the last of
those decides what actually goes on the wire, and `openai_compat` is the sole
registered STT adapter, so the two middle copies were pure duplication —
and they made the route's contract ambiguous about who owns the value.

Keep the client-side strip (it sets the Blob type, which is what the browser
puts in the multipart part) and the adapter strip; drop the route and facade
copies along with the now-unused facade re-export. The adapter-level test
already pins the wire contract; the route test now asserts what the route
actually promises — verbatim forwarding.

---------

Co-authored-by: ZQR1101 <278034003+ZQR1101@users.noreply.github.com>
Co-authored-by: Frank <bingxizhao@novix.science>
2026-08-24 16:51:49 +08:00
pederbe
9be3b0cf59 feat(cli): add setup doctor command (#959) 2026-08-24 16:51:44 +08:00
pederbe
1e99da1a93 fix: reject duplicate mastery quiz options (#956) 2026-08-24 16:51:36 +08:00
WeiNing-sara
8333c0b562 fix(cli): declare missing standalone runtime dependencies (#954)
* fix(cli): declare standalone runtime dependencies

* style: satisfy ruff format in the packaging metadata test

`ruff format --check .` is a CI gate and wanted the `open("rb")` call on one
line (99 chars). This was the only red check; every test job passed.

---------

Co-authored-by: Frank <bingxizhao@novix.science>
2026-08-24 16:51:31 +08:00
NoxsMedia
6bc366e567 fix(rag): filter MinerU page-layout blocks before indexing (#949)
* fix(rag): filter MinerU page-layout blocks before indexing

* fix(rag): preserve MinerU decision audit history

* fix(rag): index unrecognized MinerU blocks instead of failing the ingest

`require_accepted()` ran on the live ingest path and raised on any block type
without a policy entry, so a MinerU release that renames or adds a type broke
LightRAG indexing outright — where before this policy existed the block was
simply indexed. `V2_AUXILIARY_EQUIVALENTS` made that concrete and worse: it
recorded the knowledge that a newer parser emits `page_header`/`page_footer`/
`page_aside_text`, wrote it into the audit ledger, and then hard-failed on
exactly those values, because the map was never applied to anything.

Two changes, same principle — filter only what is positively recognized as
page chrome:

- Apply the v2 map. Newer auxiliary names normalize onto the vocabulary the
  policy is written in, so upgrading MinerU keeps filtering chrome instead of
  reporting every layout block as unrecognized. Parser blocks stay unmutated;
  only the classification key is normalized.
- Unknown types are indexed and counted, never dropped and never fatal. An
  unrecognized type is far more likely to be new content than new chrome, so
  the failure mode of guessing wrong should be an unclassified block in the
  index, not a dead knowledge base. The ledger records the count (and only
  the count — document text must never reach an audit file), the pipeline logs
  a warning naming the types, and the attempt outcome `unknown_types` says
  the policy needs extending.

---------

Co-authored-by: nox <work@noxsmedia.com>
Co-authored-by: Frank <bingxizhao@novix.science>
2026-08-24 16:35:00 +08:00
evan188199-tech
c72185aad6 fix(rag): improve local LlamaIndex pipeline compatibility (#864)
* fix(rag): improve local pipeline compatibility

* fix(rag): resolve tqdm progress at call time, not at import

`show_progress: bool = should_show_progress()` is a default argument, so
Python evaluated it once when the module was first imported and froze the
result for the process lifetime. That defeated the fix in both directions:
a server started from a terminal froze `True` and kept writing tqdm bars
into the pipe whose read end can close mid-indexing (the BrokenPipeError
this guards against), while a CLI launched with piped stdout froze `False`
and never showed progress again.

Take `show_progress: bool | None = None` and resolve inside the body of the
two functions that consume the value; the pure forwarders pass `None`
through so the decision is made once, at the point of use.

The accompanying test was green only because pytest captures stdout, so the
frozen default already read `False` — it never exercised the mechanism. It
now asserts both directions and fails under `pytest -s` if the default
argument comes back.

---------

Co-authored-by: XZH <cto@xzh.ai>
Co-authored-by: Frank <bingxizhao@novix.science>
2026-08-24 16:34:55 +08:00
Ademola Balogun
e4dda9ff77 feat: add per-conversation reasoning-effort override (#641) (#958)
* feat: add per-conversation reasoning-effort override (#641)

* refactor(config): parse the LLM selection once

`apply_llm_selection_to_catalog` already calls `LLMSelection.from_payload`,
so resolving the override parsed the same payload a second time — meaning a
malformed `reasoning_effort` was validated and raised from two places.
`from_payload` is idempotent on an already-parsed value, so parse once and
pass the object through.

Also correct the `VALID_REASONING_EFFORTS` comment: it called itself the
single source of truth while pointing at two things that are not the same
vocabulary. `reasoning_params.py` maps a level onto a provider's actual knob,
and the per-backend `efforts` lists say what each subagent CLI accepts (some
are empty — no effort flag at all). This constant is only the
request-validation union.

---------

Co-authored-by: Ademola <ademicho@gmail>
Co-authored-by: Frank <bingxizhao@novix.science>
2026-08-24 16:34:50 +08:00
evan188199-tech
ec4ee2356a feat(partners): add QR channel onboarding (#952)
Co-authored-by: XZH <cto@xzh.ai>
2026-08-24 16:34:29 +08:00
XZH
d3b19f3a2e feat(reading): add source-faithful EPUB contract 2026-08-23 04:38:24 -07:00
Bingxi Zhao (Frank)
8515dfdbe6 release: v1.5.16
Release notes: assets/releases/ver1-5-16.md

Content bundled into this commit:

* Release notes for v1.5.16 and the version bump to 1.5.16.
* README: the Releases row for v1.5.16, and MarginNote 4 added to the two
  places that enumerate the retrieval engines (Key Features, Knowledge
  Center) — the engine list was the only prose the release made stale.
* All 11 translated READMEs patched for that same engine-list change.
* Book: make the reader's row a flex column. v1.5.15 added the capture
  inbox as a second child without it, so `PageReader`'s `h-full`
  collapsed to `auto` — the body stopped scrolling and the page-turn
  footer was clipped away.
* progress_tracker: annotate the progress dict as `dict[str, object]`.
  The i18n work added a dict-valued `message_params` to a mapping mypy
  had inferred as `dict[str, int | str]`.
* prettier on the two MarginNote 4 frontend files it had not yet seen.

Gates: pre-commit (15/15), `ruff check .` clean, pytest 5007 passed /
22 skipped, `npm run test:node` 586/586, and the docs site builds.
v1.5.16
2026-08-22 01:36:30 +08:00
Bingxi Zhao (Frank)
323c4d6e7a feat(knowledge): surface MarginNote 4 in the Knowledge Center grid
The connected source only existed inside the create modal's link list, so
the Knowledge Center home offered Obsidian as something you can connect
and said nothing about MarginNote. Anyone who did not already know to
open the modal and switch to "Link existing" had no way to find it.

Give it the card Obsidian has, in the same place and with the same
behaviour: the connected-library count when there is one, and a click
that opens the unified create flow pre-set to this source.
2026-08-22 00:08:30 +08:00
Bingxi Zhao (Frank)
081a73a15c fix(marginnote4): stop two libraries from claiming one store
Registration checked the name and nothing else, but the default store
path keeps only alphanumerics, `-` and `_`, so "My Lib" and "My/Lib" both
resolve to My_Lib.db. Two libraries sharing that file would merge their
objects, and a device paired to either would sync into both.

Reject at registration instead, naming the library that already owns the
store. The same check covers an explicitly pinned `db_path` pointing at
another library's file.
2026-08-21 23:03:41 +08:00
Bingxi Zhao (Frank)
2af5ba7abf feat(knowledge): give MarginNote 4 libraries a frontend
The connected KB type landed with no way to create one and no way to
pair the add-on that fills it, so the feature was unreachable from the
app.

Connecting: a MarginNote card in the create modal's link sources. It
asks for a name and nothing else — `db_path` is deliberately not sent, so
the store's location keeps one rule and pairing, the add-on's syncs and
the capability binding cannot disagree.

Feeding it: a Devices tab on the library, with the paired-device list,
revoke, and the one-time token shown once at pairing (the server keeps
only a hash). Every call names its library through `X-MN4-KB`, which is
what makes the token findable by the syncs that present it.

The detail view's sections are now derived rather than fixed: a library
owns no raw files and builds no index, so Files / Add documents / Index
versions rendered empty against it, the header read "llamaindex ·
Default embedding" for a pipeline it never runs, Settings offered an
on-disk path that does not exist, and Retry indexing offered to re-run
nothing. Each now reports what the library actually has.
2026-08-21 22:51:05 +08:00
Bingxi Zhao (Frank)
0989dcbbd9 fix(marginnote4): one rule for where a library's store lives
"Pinned `db_path`, else derived from the name" was written twice — in the
capability binding and, in its derived half only, in the HTTP bridge. A
KB that pinned a path therefore paired devices into one file while the
tools read another, so the add-on would have synced into a store nothing
queried. `resolve_db_path` is now the single rule, and the binding, the
pairing endpoints and the device endpoints all go through it.

Deleting the KB now removes that store. Unlike an Obsidian vault it is
ours — `data/user/marginnote4/<name>.db`, created by us — so leaving it
behind both contradicted what the delete says and resurrected every
paired device as soon as a library of the same name was connected again.
Best-effort, on the same reasoning as the index directory above it: an
orphan file beats a config entry stuck in the list.
2026-08-21 22:50:55 +08:00
Bingxi Zhao (Frank)
10297532b5 feat(knowledge): make indexing progress lines translatable
Every progress line the knowledge log box shows was a hardcoded English
string — 22 producers across the initializer, the document adder and the
router, rendered verbatim in the UI. #933 added one more ("Describing
images: m/n"), which is what surfaced the class.

Indexing runs detached from any request, so the backend has no viewer
language and the language of record lives in the browser anyway. So the
wire now carries the English `{{name}}` template plus its values, and the
frontend renders it with `t()` where the language is actually known.
`ProgressTracker.update` fills `message` from that same template, so
every consumer without i18n of its own — logs, the persisted snapshot,
the CLI — reads what it read before, and no call site spells the string
twice.

Untouched producers keep working: `progressMessage()` falls back to the
rendered `message` when no template is named.
2026-08-21 16:58:42 +08:00
Bingxi Zhao (Frank)
ac18b75056 docs(llm): name two contracts the LightRAG convergence relies on
Both were load-bearing and neither said so.

`map_error` returns an existing `LLMError` *itself* rather than a
replacement — re-running the rules would demote a precise error to a
vaguer one, and the LightRAG adapter re-raises the terminal exception and
compares identity. That makes filling in `provider` an in-place write on
the caller's exception; it is the only field the function mutates.

The vision adapter passes `allow_image_fallback=False`, which is a
behaviour change rather than a tidy-up: a model that turns out not to
take images no longer gets a text-only retry. That fallback salvages an
answer elsewhere, but here the image *is* the question, so a description
produced without it would be invented and then indexed as fact.
2026-08-21 16:58:01 +08:00
Bingxi Zhao (Frank)
48ba9d405c fix(chat): bound the provider error body written to the log
The tool-schema rejection log exists so a user can attach
`deeptutor.jsonl` to a bug report. `error_text()` returns the whole body,
and some providers echo the rejected request back — the tool schemas,
sometimes the messages — which would put a copy of the conversation into
a file headed for a public issue.

`logged_error_text()` caps it and says how much it dropped. The parameter
a provider objects to is always near the front, so the diagnostic keeps
working; the compat predicates keep reading the unbounded text.
2026-08-21 16:58:01 +08:00
Bingxi Zhao (Frank)
f58654e0bf fix(marginnote4): close the device bridge's auth boundary
`/sync` and `/heartbeat` are the only endpoints reachable without a
DeepTutor session, and both resolved their store before checking the
credential. Two consequences:

- Constructing a `MarginNoteStore` mkdir's and installs the schema, so an
  unauthenticated `POST /sync` created a database per distinct `X-MN4-KB`
  value. `MarginNoteStore.open_existing` gives the device path a way to
  look without writing; no file, no store, 403.
- Pairing runs under `require_auth` and lands in the caller's own
  workspace, while the device endpoints carry no session and resolve the
  default one. Wherever those differ the token issued at pairing could
  never be found again, so every sync 403'd forever. Both paths now name
  the workspace they mean through one resolver, and pairing refuses
  rather than hand out a credential the sync path cannot read.

Also bound one batch (`objects` / `deleted_ids` / `cursor` / device
name), and promote `_default_db_path` to `default_db_path` since two
other modules already import it across the package boundary.
2026-08-21 16:57:45 +08:00
Bingxi Zhao (Frank)
083ff4fe3d fix(docker): give the development image the web source it compiles from
`docker compose -f docker-compose.dev.yml up` came up with a dead frontend:
the development stage's supervisor program runs `node scripts/dev.mjs`, and
that path does not exist in the image. The stage builds `FROM production`,
whose ./web is `.next/standalone/`, then cherry-picked three files on top.

Verified against a real standalone build — its root holds exactly
`server.js`, `package.json`, a traced `node_modules` and the dist dir. Every
source file and every config is absent, so `scripts/` was only the first
thing to fail; `tsconfig.json`, `tailwind.config.js`, `postcss.config.js`,
`features/`, `types/` and `proxy.ts` were missing too, and the compose mount
list covers none of them either.

So take the builder's web tree wholesale instead of naming files that keep
drifting as web/ grows top-level entries. `--chown` during the copy keeps
node_modules from being re-layered, and the inherited production build is
cleared so `next dev` starts from an empty cache rather than a half-valid
one.

#906 also reported this as two `[program:frontend]` blocks in one supervisor
config, with the fix being to delete the dev.mjs one. That reading is wrong:
the blocks are in different build stages (`FROM production AS development`),
the production image has exactly one and is unaffected, and deleting the dev
block would have made the development image serve a production build with no
hot reload. The production stage is untouched here.

Not build-verified — no Docker daemon available on this machine.
2026-08-21 16:29:06 +08:00
Bingxi Zhao (Frank)
c4a6f1b228 fix(embedding): recover from gateways that require an explicit encoding_format
ModelScope reads a missing `encoding_format` as `''` and refuses the request:
`encoding_format must be 'float' or 'base64', got ''`. So the probe and every
real embedding call failed for #934, while the same config worked through the
vendor SDK, which defaults the field to "float".

The report's root cause is right and its suggested fix keys off the wrong
thing. Special-casing the qwen3-embedding family reads the constraint as
belonging to the model, but it belongs to the gateway, and the gateways
disagree: SiliconFlow rejects the param when it is *present* (#651, which is
why it is omitted), ModelScope when it is *absent*. The same Qwen3-Embedding
weights are served on both sides of that disagreement, so no default and no
model-family rule can satisfy both.

Recover from the provider's own refusal instead. The happy path is
byte-identical — the param is still omitted, so every working config sends
exactly what it sent before — and a 400 that names both the parameter and the
value we are about to send earns one retry with `encoding_format="float"`.
Requiring the body to name "float" is what separates "you must send this"
from "I do not support this", so a gateway in the second camp is not retried
into the same failure. The retry is bounded by the param then being present.

Also notes at the omit site why a default must not be reintroduced there:
it would trade #934 for #651.
2026-08-21 16:25:18 +08:00
Bingxi Zhao (Frank)
f2fac28d7b fix(llm): resolve model-intrinsic overrides from the model, not the route
Kimi models lock temperature server-side and reject any explicit value with
HTTP 400 "invalid temperature: only 1 is allowed for this model". The
moonshot spec has dropped the parameter for them since before v1.5.5, but
the lookup ran over the *configured binding's* spec, so it only fired for
someone who had picked binding="moonshot". #938 picked binding="openai" and
pointed it at Moonshot — what most people do with an OpenAI-compatible
endpoint — and kept getting the 400 two months after the fix landed.

The route is not what enforces the limit, so the route should not be what
decides. `model_overrides_for` states that once: the configured spec wins
when it says something about this model, otherwise the model's own vendor
spec answers. `find_by_model` already skipped gateway and local entries, so
it lands on the vendor whose API enforces the limit; it was simply never
consulted on this path.

This generalises past kimi — every model-intrinsic override was being lost
behind a generic gateway binding, and a spec-less config got none at all.

The override had no test, which is how it stayed half-wired. The added ones
are written as the reporter's scenario, and pin the two things that must not
break: an explicit binding still wins, and the tunable moonshot-v1-* series
(no "kimi" in the name) keeps the caller's temperature.
2026-08-21 16:22:58 +08:00
Bingxi Zhao (Frank)
9e4233c3ae fix(chat): assign streamed tool-call ids instead of appending them
A router in front of an OpenAI-compatible provider re-sends the complete
`id` on every delta chunk rather than only on the first. The chat loop and
the explore capability appended it, so the id grew one copy per chunk —
#937 observed 551, 754, 870, 1566, 9715, 17864 and 47241 characters. Past
the provider's own 64-character ceiling every round died with HTTP 400
`Invalid 'messages[i].tool_calls[0].id': string too long`, the
forced-finish call died the same way, and the turn surfaced as "I could not
produce a useful response from the model output."

The report named one site and declared `name` correct as-is. There were two
sites, and both had the identical defect on `name`, which a repeat corrupts
into an unresolvable `toolnametoolnametoolname` — latent for that
reporter's gateway, fatal for any gateway that repeats the name.

Rather than restate the per-field rule a third and fourth time, converge
the three core-layer sites (chat loop, explore capability, labeled step)
onto one accumulator that states it once: `id` and `name` arrive whole and
are assigned, `arguments` arrives in fragments and is concatenated. That
rule is not new — it is what the services-layer provider's `_accum_tc` has
always done, which is the evidence that assigning `name` is safe across
every gateway users have configured. That accumulator stays where it is:
it reads deltas that may be plain dicts, so folding it in would widen the
blast radius without fixing anything.

Coercing a missing `index` to 0 also removes a latent crash in the labeled
step runner, where a `None` key made the final `sorted()` raise as soon as
one real index appeared.
2026-08-21 16:20:13 +08:00
Bingxi Zhao (Frank)
23ead9e6d6 docs(book): reflow the partition_knowledge_bases docstring 2026-08-21 16:13:21 +08:00