Commit Graph

978 Commits

Author SHA1 Message Date
TyrionH-is-coding
effbb82798 fix(llm): enable SiliconFlow native tool calls 2026-06-22 22:48:42 +08:00
Bingxi Zhao (Frank)
59f499b2c3 docs(readme): correct Docker networking to the in-container proxy model
#577 moved /api and /ws behind a request-time Next.js proxy (web/proxy.ts),
so the browser only talks to :3782 and the frontend forwards to the backend
server-side. Update the Docker quickstart accordingly:

- drop the :8001 host mapping from the default `docker run`; publishing it is
  now optional (direct API access only)
- replace the "map both ports / no in-container proxy" warning with the
  single-port reality
- rewrite the reverse-proxy guidance: single-container needs no API base (point
  the proxy at :3782); only split deployments set next_public_api_base, which is
  read server-side and never sent to the browser

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
v1.4.10
2026-06-21 15:00:56 +08:00
Bingxi Zhao (Frank)
42941faaff fix prs 2026-06-21 14:43:41 +08:00
Bingxi Zhao (Frank)
5eafa0c2fb refactor(multi-user): consolidate partner-turn detection + align MCP grant UI
Follow-up refinements on top of #579 (deny MCP tools until explicitly
granted), tightening decoupling and front/back consistency:

- Decouple: extract the duplicated `metadata.source == "partner"` check
  (deferred-tools, exec gate, tool composition, cron owner routing) into a
  single `AgenticChatPipeline._is_partner_turn` helper, so the partner
  authority-via-metadata contract has one definition instead of four
  inline copies.
- Frontend parity: the backend now denies MCP for non-admin users when the
  grant omits `mcp_tools`, but GrantEditor still showed `null` as
  "Default · all" / "all MCP". Make ModeSwitch's default-mode label
  caller-supplied, label the MCP section "Default · none" / "no MCP", and
  add a one-line rationale so admins are not misled into granting nothing.

Built-in optional tools keep `null = all`; only MCP tools fail closed.

Tests: ruff clean; pytest multi_user/mcp/partners/chat (545 passed);
web tsc + eslint clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-21 13:48:00 +08:00
Bingxi Zhao (Frank)
90046374b3 Merge pull request #579: deny MCP tools until explicitly granted 2026-06-21 13:44:42 +08:00
hinotoi-agent
dab6347e59 fix: deny ungranted MCP tools for non-admin users 2026-06-21 11:03:24 +08:00
Bingxi Zhao (Frank)
86ff120668 fix(profile): harden avatar fallback, admin ring in sidebar, dedupe auth-status fetch
Follow-up nits on the #573 profile/avatar work:
- UserAvatar: validate an icon marker's icon/color against the known sets and
  fall back to the deterministic avatar for unknown values. The backend
  _ICON_MARKER_RE accepts any [a-z0-9-] color, so a hand-set marker like
  "icon⭐bogus" previously rendered an invisible avatar
  (AVATAR_COLORS[unknown] === undefined).
- ProfileLink: pass role to UserAvatar so admins get the amber ring in the
  sidebar, matching the "amber ring at every size" intent.
- useAuthStatus: share one in-flight /api/v1/auth/status request across the
  hook's consumers (sidebar Admin/Logout/Profile links) so a page load makes a
  single call instead of one per consumer; cleared once settled so a later
  mount (after login/logout) refetches.

Verified: tsc, eslint, web node tests (142).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-21 01:11:48 +08:00
Bingxi Zhao (Frank)
2729b75dde Merge pull request #573: user profile page with avatar
Self-service /profile page (account info, icon/image avatar, sign out)
implementing the profile half of #553. Contributed by @IliaAvdeev.

Integration performed during merge onto current dev:
- Migrate ProfileLink and the profile page off the removed AUTH_ENABLED
  build-time export to runtime auth status (auth.ts was refactored on dev
  by #577). ProfileLink reads the full status via fetchAuthStatus (it needs
  username/avatar, which the useAuthStatus hook does not expose); the page
  gates on status.enabled.
- Resolve en/zh locale conflicts as a union of dev and PR keys.
- Honor EXIF orientation in createImageBitmap so the primary decode path
  matches the <img> fallback.
- Drop an unreachable AUTH_ENABLED render guard in the profile page.

Verified locally: tsc, eslint, ruff, web node tests (142), pytest
tests/multi_user (81 passed).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 23:57:21 +08:00
Bingxi Zhao (Frank)
1d9a4a904d fix(logging): silence routine 200 access-log spam on all launch paths
The backend was logging every request (the chatty frontend polling of
/settings, /tools, /knowledge/list, /settings/llm-options, ...) as
`::1:0 - "GET ... 200 OK"`. uvicorn's per-request access log was only disabled
in run_server.py (access_log=False); the `deeptutor start` launcher and the
Docker entrypoints invoked uvicorn directly with it still on, so the 200s
leaked.

- launcher.py + Dockerfile (production start-backend.sh and the dev supervisord
  program): add `--no-access-log` so all launch paths match run_server.py.
- Funnel access logging through the existing selective_access_log middleware
  (non-200 only), but log via a `deeptutor.access` logger with its own INFO
  stdout handler (propagate=False). Previously it used `uvicorn.access`, which
  has no handler once uvicorn's access log is off, and the root console handler
  runs at WARNING — so non-200s were being silently dropped. Now 200s are quiet
  and 4xx/5xx still surface.
- Rewrite the middleware test to capture on the deeptutor.access logger directly
  (it no longer propagates to root).

Verified: live server with --no-access-log logs nothing for 200s and prints
`127.0.0.1 - "GET /api/v1/... HTTP/1.1" 404` for a 404. ruff + pytest (2447) green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 22:01:01 +08:00
Bingxi Zhao
7bbc4bbf83 Merge pull request #577: rootless-podman hardening + request-time proxy
Harden the published image for rootless podman with a read-only rootfs, and
move URL/auth knowledge from build-time sed to a request-time proxy (web/proxy.ts).
Includes follow-up fixes: JSON-backed DEEPTUTOR_* env wiring for both Docker and
the PyPI launcher (correct auth.json key), runtime client auth resolution,
100MB-safe upload proxy buffer, updated tests, and corrected docs.

Closes #576. Co-authored with @enihcam.
2026-06-20 21:15:17 +08:00
Bingxi Zhao (Frank)
8c4f394220 docs(containerization): correct proxy model (browser only needs :3782)
CONTAINERIZATION.md described the old browser-talks-to-:8001-directly model,
which contradicts the PR's own server-side proxy design. Clarify that the
browser only ever talks to the frontend origin (:3782); /api/* and /ws/* are
forwarded to the backend inside the container, so publishing :8001 is optional.
Rewrite the remote/reverse-proxy section (single-container needs no API base;
next_public_api_base is only for split deployments) and the troubleshooting note.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 21:12:56 +08:00
Bingxi Zhao (Frank)
37049c3d33 fix(web): resolve client auth state at runtime; size proxy body for uploads
Two gaps in the PR's frontend changes:

1. Client auth awareness was permanently false. api.ts/auth.ts read
   process.env.DEEPTUTOR_AUTH_ENABLED in browser code, but Next.js only inlines
   NEXT_PUBLIC_ vars into the bundle — so the Sign-out / Admin affordances never
   rendered and apiFetch's 401 -> /login redirect never fired when auth was on.
   Resolve auth state at runtime from the backend instead: fetchAuthStatus()
   records it via setRuntimeAuthEnabled(), and components observe it through the
   new useAuthStatus() hook. Works on Docker (read-only rootfs), PyPI, and dev
   with no build-time baking. (The server-side gate in proxy.ts is unaffected.)

2. KB document uploads >10MB were truncated. All /api/* now flows through the
   proxy, whose body buffer defaults to 10MB while the backend accepts 100MB
   (DocumentValidator.MAX_FILE_SIZE). Raise experimental.proxyClientMaxBodySize
   to 110MB so uploads aren't silently cut off.

Adds a regression test that a 401 does NOT redirect when auth is disabled.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 21:12:56 +08:00
Bingxi Zhao (Frank)
dfa0c9b1ea fix(deploy): wire DEEPTUTOR_* proxy env via single JSON-backed exporter
The PR's relative-path + proxy.ts rewrite design depends on two env vars
(DEEPTUTOR_API_BASE_URL, DEEPTUTOR_AUTH_ENABLED) read server-side by the
Next.js middleware. As submitted they were only set by the Docker entrypoint,
and the auth one read a non-existent auth.json key — so auth enforcement was
silently disabled and the PyPI `deeptutor start` path was unwired.

- Export both vars from render_environment() (the single JSON-backed source of
  truth), so the Docker entrypoint AND the `deeptutor start` launcher get them
  consistently. DEEPTUTOR_API_BASE_URL falls back to localhost:<backend_port>.
- launcher.py: set both in common_env using the resolved backend_url, so they
  track port-conflict reassignment.
- Dockerfile: drop the duplicated, buggy per-var heredocs (one read the wrong
  key `auth_enabled` instead of `enabled`, leaving the proxy auth gate always
  off); the export_runtime_settings_to_env eval now provides both. Add them to
  the env-unset list for hygiene.
- Update the two placeholder tests to assert the new proxy-based design instead
  of the removed build-time sed mechanism; add DEEPTUTOR_* coverage in
  test_runtime_settings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 21:12:40 +08:00
Bingxi Zhao (Frank)
dd47638133 Merge remote-tracking branch 'origin/dev' into feature/rootless-podman-hardening 2026-06-20 20:56:14 +08:00
Bingxi Zhao (Frank)
f8349fc1e5 Release v1.4.9
Settings polish and a Mastery -> Question Bank link:
- Search settings show only the connection fields the selected provider uses
- Connection profiles can be renamed and auto-name after their provider
- Graded Mastery Path questions sync into the session Question Bank
- Fix untranslated Settings-tour Tools step (en/zh) + guard test
- Refresh README / translated READMEs for the current v1.4.6+ UI

Bump __version__ to 1.4.9, add assets/releases/ver1-4-9.md, restore the
v1.4.7/v1.4.8 README rows dropped by an earlier docs-update commit, and
compress every README release row to <=30 words.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
v1.4.9
2026-06-19 20:05:19 +08:00
Bingxi Zhao (Frank)
e7b47cfb55 update multi-language docs 2026-06-19 19:50:45 +08:00
Bingxi Zhao (Frank)
b364ffc593 minor fixes & docs update 2026-06-19 17:34:13 +08:00
Bingxi Zhao (Frank)
1db0abce8f Merge pull request #572 from HKUDS/fix/settings-tour-en-placeholders
# Conflicts:
#	web/locales/en/app.json
2026-06-19 17:06:39 +08:00
Bingxi Zhao (Frank)
0f25bdf38c Merge pull request #571 from HKUDS/feat/settings-profile-naming
# Conflicts:
#	web/components/settings/ServiceConfigEditor.tsx
2026-06-19 17:06:04 +08:00
Bingxi Zhao (Frank)
9710b9db9a Merge pull request #570 from HKUDS/fix/search-settings-conditional-fields 2026-06-19 17:05:29 +08:00
Bingxi Zhao (Frank)
88c2565389 release: v1.4.8
Partners become consultable agents and gain their own memory.

- My Agents now lists your Partners next to local Claude Code / Codex;
  connect one and the turn runs on `consult_subagent` against the
  partner's own chat loop, streaming its trace live. Every consult in a
  DeepTutor chat threads into one archived partner session.
- Partners get a split memory model via three always-on tools that
  replace chat's read_memory/write_memory on partner turns:
  partner_read (owner shared + own), partner_memorize (own only),
  partner_search (own history). The per-Partner memory toggles are gone.
- A `partner:` history reference resolves a partner transcript
  (admin-only) into a DeepTutor chat as third-party context.

Release-prep fixes for a clean CI parity run:
- partner.py: replace mypy-misparsed `# type:` dict-entry comments with
  a proper variable annotation.
- claude_models.py: `# nosec B606 B607` on the PATH-resolved `os.execvp`
  in the forked PTY child (no shell; pre-existed since v1.4.7).

Bump __version__ to 1.4.8, add assets/releases/ver1-4-8.md, README row.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
v1.4.8
2026-06-18 22:16:31 +08:00
Bingxi Zhao (Frank)
7871955ab5 fix:partners & improve my agents 2026-06-18 22:00:59 +08:00
Bingxi Zhao (Frank)
1bf11d13e7 prepare 1.4.7 v1.4.7 2026-06-18 00:22:48 +08:00
enihcam
cd2621014a docs(containerization): add CONTAINERIZATION.md + README pointer
CONTAINERIZATION.md (7 sections):
  * Overview -- the architectural change (URL knowledge moves from
    build-time sed to request-time proxy rewriter) and the three
    deployment shapes that follow.
  * Docker (default) -- docker run with -p 3782/8001 and a
    deeptutor-data volume; remote / reverse-proxy deployment via
    system.json; host LLM providers (Ollama / LM Studio / etc.)
    via host.docker.internal.
  * Podman / rootless / read-only rootfs -- the compose.yaml walk-
    through, why each tmpfs/keep-id/read-only line is there, and a
    portable podman run equivalent. Notes the known
    /var/run/supervisord.pid follow-up.
  * Runtime configuration -- the data/user/settings/*.json layout
    and the no-compose-env-vars rule.
  * PocketBase -- the corrected mount path, single-user caveat.
  * Troubleshooting -- the four most likely first-boot issues.
  * Security notes -- non-root user, RO rootfs, keep-id, sandbox
    runner trade-off, CORS, auth gating.

README.md gets a one-line pointer in the 'Option 3 -- Docker'
section, right after the GHCR image list.
2026-06-17 21:41:01 +08:00
enihcam
90f2f6afee feat(deploy): add podman compose.yaml + .env.example for rootless
Tested rootless-podman deployment shape:

  * read_only: true on every service
  * userns_mode: keep-id (host UID 1000 -> container UID 1000)
  * tmpfs mounts for /tmp, /run, /var/run, /var/log, /root, /home
  * bind mounts on ./data (no named volumes: podman auto-creates
    them with the userns-mapped root UID 100000, which 755's
    incorrectly against the host)
  * loopback-only port bindings (drop the 127.0.0.1: prefix to
    expose on all interfaces)
  * PocketBase sidecar uses the corrected /pb_data, /pb_public,
    /pb_hooks mount paths from the docker-compose fix.

The entrypoint chowns /app/data and gosu-drops to the unprivileged
deeptutor user (UID 1000) before starting supervisord, so under
userns_mode: keep-id the running process is your host user.

.env.example carries only the host-side loopback bindings and TZ. URL
knowledge lives in data/user/settings/system.json (read by the
entrypoint on every start -> DEEPTUTOR_API_BASE_URL -> proxy.ts). No
compose env var for the API base.
2026-06-17 21:41:01 +08:00
enihcam
e7991d6056 fix(docker-compose): correct pocketbase mount path
The upstream ghcr.io/muchobien/pocketbase image's entrypoint uses
absolute paths (no /pb/ prefix): --dir=/pb_data --publicDir=/pb_public
--hooksDir=/pb_hooks. The previous example mounted at /pb/pb_data and
crashed on first start with 'mkdir /pb_data: read-only file system'.
Split the single mount into three matching the upstream entrypoint:
/pb_data, /pb_public, /pb_hooks.
2026-06-17 21:41:01 +08:00
enihcam
46681b572c feat(docker): harden image for rootless/RO rootfs + drop runtime sed
The frontend no longer bakes the backend URL into the bundle at build
time and mutates it with sed on every container start. Instead:

  * web/lib/api.ts: apiUrl and wsUrl become one-line pass-throughs, so
    the browser fetches relative paths through the frontend
    (:3782/api/...). All existing call sites keep working unchanged.
  * web/proxy.ts: catches /api/* and /ws/* and rewrites them to
    DEEPTUTOR_API_BASE_URL at request time, reading
    DEEPTUTOR_AUTH_ENABLED for the auth-redirect check.
  * web/lib/auth.ts: switches from NEXT_PUBLIC_AUTH_ENABLED (build-time)
    to DEEPTUTOR_AUTH_ENABLED (set by the entrypoint on every start).
  * Dockerfile: drops the .env.local placeholder block, the sed -i in
    start-frontend.sh, and the runtime API-base fallback chain. Adds
    gosu, bakes a non-root 'deeptutor' user (UID 1000), and has the
    entrypoint chown /app/data and export DEEPTUTOR_API_BASE_URL and
    DEEPTUTOR_AUTH_ENABLED from data/user/settings/*.json on every
    start. supervisord is now invoked under 'gosu deeptutor'.
  * web/tests/api-resolve-base.test.ts: deleted (its 8 tests reference
    resolveBase / isApiBasePlaceholder, both gone; apiUrl/wsUrl are
    now pass-throughs so the rest is meaningless). The auth-redirect
    test is updated to prime DEEPTUTOR_AUTH_ENABLED instead.
2026-06-17 21:40:58 +08:00
Bingxi Zhao (Frank)
7d3a06ca8f fix: repair v1.4.6 CI failures (lint + RAG/partner test isolation)
The v1.4.6 squash shipped three CI-red issues that the release pre-commit
gate could not see (ruff hook runs with --exit-zero; the release process
never runs pytest):

- partners WS chat referenced an undefined `mgr` (ruff F821, and a real
  runtime NameError on the partner WebSocket chat path) — bind
  `mgr = get_partner_manager()` in the handler, matching the file's idiom.
- GraphRAG initialize/search tests drove write_settings() through the real
  catalog, which has no active embedding model in CI — pin fake llm +
  embedding configs in `_stub_build`, the same way the LightRAG test does.
- PageIndex `test_factory_dispatches_by_provider` constructed a real
  LlamaIndexPipeline whose __init__ resolves the embedding catalog — stub
  `_configure_settings`, matching the LlamaIndex pipeline tests.
- New `test_chat_does_not_auto_start_stopped_partner` spawned a real
  PartnerRunner task and cancelled it across TestClient per-request event
  loops — drive the start/stop/chat sequence through one shared loop via a
  context-managed TestClient.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 11:28:18 +08:00
Bingxi Zhao (Frank)
7ac3a3ba79 release: v1.4.6
A broad consolidation release across four product surfaces.

- Learning Space: Space becomes a learning dashboard; My Agents imports
  local Claude Code / Codex chat history into resumable agents (with an
  objective explore_context briefing so the tutor never role-plays the
  user); Memory is promoted to a top-level /memory route; Partner
  conversations flow into Memory; EduHub skills install inline.
- Knowledge Center: /knowledge rebuilt as a console with per-engine
  detail pages; GraphRAG / PageIndex / LightRAG engines join LlamaIndex;
  linked-KB read-only mounts; Obsidian live-vault capability.
- Settings: pluggable document parsing (MinerU / Docling / MarkItDown)
  with a content-addressed cache and MinerU cloud/local backends; voice
  TTS/STT; image & video generation; rebuilt settings navigation.
- Platform: per-user capability gating by assigned model; Solve rebuilt
  on the chat loop with a per-step gate and mid-run failure fallback;
  username login + inline errors; CLI skill publish/update; picker
  polish; math-before-citation render fix.

Docs were split out to a standalone site, so site/ is now landing-page
only. Bumps __version__ to 1.4.6 and adds assets/releases/ver1-4-6.md.

Folds in mypy fixes surfaced by pre-commit (mineru/local Path typing,
knowledge/manager no-redef, explore_context token kwargs, CLI
set_dist_tag capability probe) plus prettier reformatting of
previously-committed web files.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
v1.4.6
2026-06-17 10:50:44 +08:00
Bingxi Zhao (Frank)
7ed16cf48a update tests 2026-06-17 10:30:25 +08:00
Bingxi Zhao (Frank)
c9d387e2b6 super super great great update 2026-06-17 00:56:27 +08:00
Ilia Avdeev
8c89cd7779 test: identity, router, and avatar unit tests 2026-06-14 17:43:23 +02:00
Ilia Avdeev
7901368bb2 feat: user profile page with avatar (icons + image upload) 2026-06-14 17:43:13 +02:00
Ilia Avdeev
5cc14cad3f test: guard against untranslated placeholder values 2026-06-14 15:21:29 +02:00
Ilia Avdeev
0b31b8650c fix: translate missing English settings-tour steps 2026-06-14 15:21:19 +02:00
Ilia Avdeev
d6f51c357c test: cover profile auto-naming helper 2026-06-14 14:52:27 +02:00
Ilia Avdeev
17e0547ae2 feat: discoverable profile rename and auto-name by provider 2026-06-14 14:52:27 +02:00
Ilia Avdeev
01956943c1 test: cover search provider field-visibility matrix 2026-06-14 13:56:41 +02:00
Ilia Avdeev
bd32753a9f fix: show only provider-relevant fields in Search settings 2026-06-14 13:56:41 +02:00
Bingxi Zhao (Frank)
47f0003d5e refactor: generalize native provider adapter 2026-06-14 16:16:14 +08:00
Bingxi Zhao (Frank)
568fcb08e2 Merge remote-tracking branch 'refs/remotes/origin/pr/550' into codex/merge-six-prs
# Conflicts:
#	web/components/sidebar/SidebarShell.tsx
2026-06-14 16:12:48 +08:00
Bingxi Zhao (Frank)
def2f0ceb8 Merge remote-tracking branch 'refs/remotes/origin/pr/542' into codex/merge-six-prs 2026-06-14 16:12:15 +08:00
Bingxi Zhao (Frank)
2c8a94e79a Merge remote-tracking branch 'refs/remotes/origin/pr/540' into codex/merge-six-prs 2026-06-14 16:12:15 +08:00
Bingxi Zhao (Frank)
b155d41ddb Merge remote-tracking branch 'refs/remotes/origin/pr/559' into codex/merge-six-prs 2026-06-14 16:12:15 +08:00
Bingxi Zhao (Frank)
584c9f084b Merge remote-tracking branch 'refs/remotes/origin/pr/558' into codex/merge-six-prs 2026-06-14 16:12:15 +08:00
Bingxi Zhao (Frank)
11cfa6c27e Merge remote-tracking branch 'refs/remotes/origin/pr/549' into codex/merge-six-prs 2026-06-14 16:12:15 +08:00
Bingxi Zhao
26f791295c Merge pull request #568 from IliaAvdeev/fix/capability-access-gating
fix: gate LLM features for users without an assigned model
2026-06-14 15:43:20 +08:00
Bingxi Zhao (Frank)
d5c6d6ba54 refactor: reuse single LLM gate in turn runtime; drop unwired guard
The turn path (chat/partners/mastery via turn_runtime) already enforces
LLM-grant access at its single enforcement point and surfaces a clear
terminal "no model assigned" rejection — so require_llm_access was never
wired to any endpoint and only duplicated that logic. Drop it (and its
guard-only tests) and have turn_runtime reuse has_capability_access, giving
the gate one source of truth shared with the frontend lock.

Frontend fixes kept from the original PR plus two corrections:
- capabilityForPath now matches on a path-segment boundary, so a sibling
  route like /booket can't be swallowed by the /book prefix (+ regression).
- fix the misleading Knowledge sidebar comment — Knowledge needs no
  per-user grant and is never gated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 14:56:14 +08:00
Bingxi Zhao
360966a8ab Update README.md 2026-06-14 12:42:16 +08:00
Ilia Avdeev
a40a525a1d test: cover capability gate helper and guard 2026-06-13 21:26:22 +02:00