Commit Graph

27 Commits

Author SHA1 Message Date
Bingxi Zhao (Frank)
f2e0f4ed1e fix(codex): persist rejected refresh grants until credentials change (#1454) 2026-10-07 23:52:17 +08:00
evan188199-tech
0802510450 fix: log silently swallowed failures in five services (#1707)
* fix(codex): log a warning when token revocation fails during logout

Logout previously swallowed revocation failures silently, leaving the
remote token possibly valid with no operator trace. Log only the error
kind and HTTP status (never credential material) and keep clearing the
local credentials as before.

* fix(llm): warn when CodeBuddy tool-call interrupt or drain fails

A silent except-pass after receiving tool_calls let the SDK keep
generating in the background when interrupt() failed, quietly draining
quota. Log a warning (exception type + short reason) for interrupt and
drain failures; return value semantics unchanged.

* fix(memory): log corrupt snapshot files instead of skipping silently

read_notebook_entities / read_cowriter_entities / read_book_entities
swallowed (OSError, json.JSONDecodeError) with a bare continue, so a
corrupt notebook file or manifest silently dropped content from the
memory snapshot. Each skip now logs a warning with the file path and
reason (no file content); snapshot results are otherwise unchanged.

* fix(notebook): log unreadable files instead of skipping them silently during index rebuild

* fix(question): log failed error-event delivery in mimic websocket

The mimic generation error handler swallowed secondary failures of the
error send_json with a bare 'except Exception: pass', so a delivery
failure left the frontend without any reason and nothing in the logs.
Split the handler: closed/disconnecting clients (RuntimeError,
WebSocketDisconnect) stay debug-level, any other send failure is logged
as a warning with traceback. Cleanup paths keep their best-effort
narrow handling. Focused tests cover both branches.

* test(codebuddy): make credential fixture expiry relative to now

test_load_credentials_parses_session wrote a hard-coded expiresAt of
1791055241000 (2026-10-03 15:40:41 UTC) and asserted is_expired() is
False. Once that instant passed the assertion flipped, so the test now
fails on every Python version for every branch.

Derive expiresAt / refreshExpiresAt from time.time() so the fixture
always describes a live session, and assert against the value written.

---------

Co-authored-by: XZH <cto@xzh.ai>
Co-authored-by: Bingxi Zhao (Frank) <13051345080@163.com>
2026-10-07 20:37:27 +08:00
Bingxi Zhao (Frank)
3f77d8e4eb Classify terminal Codex refresh rejection separately from outages 2026-09-23 10:49:26 +08:00
Bingxi Zhao (Frank)
a35935dc33 Merge PR #1466 Codex credential failure cooldown 2026-09-23 10:29:19 +08:00
Bingxi Zhao (Frank)
18266fbef3 Merge PR #1317 Codex client version discovery 2026-09-23 10:29:14 +08:00
Bingxi Zhao
9cba3bdfaf Merge pull request #1157 from NoxsMedia/fix/codex-luna-none-reasoning
fix(codex): expose Luna none reasoning effort
2026-09-21 13:14:39 +08:00
Bingxi Zhao (Frank)
da856ad670 release: v1.6.9
Ship folder-based workspaces and data migration, daily practice, redesigned
provider and model settings, and streaming conversation improvements.
Synchronize README translations and document the archive/permanent-delete
upgrade behavior in assets/releases/ver1-6-9.md.

Reduce initial JavaScript by deduplicating English resources and loading
animation features after hydration. Keep the existing route size budgets.
Update regression fixtures and browser audits for scoped URLs and the new
settings and learning interfaces.
2026-09-21 02:30:40 +08:00
ZQR1101
3b467ac0eb fix(codex): fail fast on a credential that no longer refreshes instead of re-prompting every turn (#1454) 2026-09-15 02:52:19 +08:00
NoxsMedia
1f4a1cbcf4 chore: sync Codex reasoning support with dev 2026-09-10 23:36:42 +00:00
ZJPex
cd7c720eb1 feat(codex): automatically discover client versions for model catalog refresh
Discover stable npm metadata during login and explicit refresh with account-scoped version fallback and cache isolation.

Guard 200 and 304 cache publication under the credential storage lock: unconditional publication previously let late responses recreate logged-out caches or overwrite newer login history.

Refs #1296
2026-09-08 18:33:02 +08:00
Bingxi Zhao (Frank)
01615d6c97 fix(codex): let a Docker sign-in finish from the pasted callback address
The provider redirects the browser to a loopback listener. Under Docker
that listener runs inside the container and the standard compose file
publishes only the Web and API ports, so the browser lands on a page it
cannot load while the sign-in waits until it expires. The card treated
localhost as native local execution and offered nothing else: the remote
guidance was gated behind a non-loopback hostname, so the one deployment
that most needs a way back in was the one that never saw it (#1252).

The browser can read that address even when this process cannot receive
it, so pasting it back is the recovery path. It goes to a new
authenticated endpoint on the Web origin, which resolves the caller's
*own* pending operation rather than scanning every login in the process
— the loopback route has to identify itself by OAuth state because it
arrives without a session, and this one does not.

``parse_oauth_callback_url`` is where the address is judged, once: it
must be this login's registered redirect URI down to scheme, host, port
and path, and a repeated OAuth parameter is ambiguous rather than
untidy, so it is refused instead of resolved to one of the two. The
string is parsed and dropped — never fetched, never stored, never
echoed. Past the parse it is ``receive_callback``, so the state check,
PKCE, the registered redirect URI and owner binding are the existing
ones rather than a second implementation of them.

The form now appears whenever a login is waiting, local or remote; the
SSH command stays remote-only, because that advice is.
2026-09-08 09:53:42 +08:00
NoxsMedia
6750a4f79b chore: sync PR #1157 with current dev 2026-09-07 23:33:46 +00:00
NoxsMedia
6cfbbe93dc fix(codex): update model catalog compatibility version 2026-09-06 09:00:50 +00:00
NoxsMedia
9e053f1298 fix(codex): normalize cached Luna reasoning levels 2026-09-02 02:00:14 +00:00
NoxsMedia
3fcaa618bf fix(codex): expose Luna none reasoning effort 2026-09-02 02:00:14 +00:00
Bingxi Zhao (Frank)
f2b7828bc4 fix: correct the provider PRs merged this round
An adversarial pass over #818 / #789 / #780 after merging.

**Codex sign-ins from before this week stopped working (#789).**
``validate_runtime_profile`` compared the profile's ``codex_account_binding``
for equality, but that key is written only by ``sync_codex_catalog`` — every
managed profile published by #690/#774 has none, so ``None != <hash>`` made
each of them look like another account's and locked its owner out of Codex
until they re-ran "Refresh models". Absent now reads as legacy; a binding
that is present and different is still an account switch and still refused.

**Overriding reasoning effort for one turn returned 409 (#789).** The same
function also required the request's effort to be byte-equal to the value
stored in the catalog. Effort is a per-request knob, not part of the identity
that ties a config to a token — the check now stops at model membership.
Its test asserted the old behaviour and has been rewritten around what the
function is actually for.

**The reasoning-effort endpoint left the runtime caches stale (#789).** It
writes the catalog the runtime resolves against, like every other catalog
write in this router, but skipped ``_invalidate_runtime_caches()``.

**OrcaRouter claimed Anthropic prompt caching (#818).** ``supports_prompt_caching``
makes ``_build_kwargs`` inject ``cache_control`` blocks into any ``anthropic/*``
or ``claude*`` request — an OpenRouter extension. No other gateway sets it and
nothing established the second one accepts it; a strict gateway would 400 every
Claude turn. Also fixed ``anthropic/claude-sonnet-4.6`` in the fallback list,
which the rest of the repo spells with dashes, so a user picking it from our
own menu would have got "model not found".

**OrcaRouter inserted itself into the curated menus (#818).** The featured
lists are hand-picked and rendered as a positional numbered menu, so adding an
entry shifted Ollama from [10] to [11]. The registry entry alone already makes
a provider reachable via "Show all" and the Settings dropdown; which providers
are featured is a maintainer decision. The README paragraph goes with it — no
other provider has per-provider prose there, and it would have been translated
into ten languages.
2026-08-13 00:07:06 +08:00
NoxsMedia
104e844b55 feat(codex): persist managed reasoning effort overrides (#789)
* feat(codex): persist managed reasoning effort overrides

* fix(codex): protect managed catalog refresh state

* feat(codex): allow user reasoning overrides

Expose only owner-scoped managed Codex model metadata and validate updates against provider-supported reasoning levels. Add ordinary-user settings controls without granting model catalog or provider administration access.

* fix(codex): bind reasoning overrides to OAuth account

Persist only a one-way account binding on managed Codex profiles. Hide and reject stale or legacy-unbound reasoning controls until a successful catalog refresh, and do not carry overrides across account switches.

* fix(codex): reject stale cross-account overrides

* fix(codex): isolate account switches at runtime
2026-08-12 23:38:15 +08:00
Bingxi Zhao (Frank)
4041c75d8e feat(multi-user): let each account sign in to its own Codex (#781)
A Codex token authorizes one person's ChatGPT plan, so the profile is
correctly never grantable — but the OAuth endpoints were admin-only too,
which left ordinary users unable to reach Codex by any route: they could
neither be given the administrator's profile nor sign in for themselves.

What made per-user sign-in unsafe was where the profile landed:
``get_model_catalog_service()`` resolves a non-admin to the ADMIN catalog, so
a user's sync would have published their profile into the shared one. A
sign-in now publishes into the owner's own catalog, keyed by the same owner
resolution as the credential store, so a login and its profile can never
land in different places. Ordinary users get
``data/users/<uid>/settings/model_catalog.json``; an administrator gets the
shared catalog exactly as before.

``redacted_model_access`` — the one place grants are resolved — gains those
personal rows (source="personal") for the caller's OWN id only, so the
option list, the capability gate, and selection validation agree without
three separate merges, and an administrator inspecting somebody's grants
still sees only what they assigned. The resolution path merges the same
profiles so a personal selection resolves to a real profile, with the
owner's copy winning over a shared profile of the same managed id (the ids
are per-provider constants, and the administrator's copy lists their models,
not the user's).

Runtime token ownership needed no change: the provider already reads the
token per owner. Endpoint gating is narrower rather than absent — a partner
is refused, since it is a synthetic user whose owner is a real account and
admitting one would mean acting on that person's login, sign-out included.

The restricted-user Settings → LLM page grows the connect/refresh/sign-out
card (no catalog, no credentials), and a sign-in now drops the cached model
options so a freshly connected account does not keep seeing the old list.
2026-08-07 21:09:40 +08:00
Bingxi Zhao (Frank)
9af5f890f4 fix(runtime): spell the server-side backend address as the IPv4 loopback everywhere
#784 fixed the launcher, but the same address is rendered on two other paths
that kept "localhost": the Docker entrypoint (render_environment) and the
last-resort default in web/proxy.ts. On a dual-stack host that name resolves
to ::1 first while uvicorn binds 0.0.0.0 (IPv4 only), so every rewritten
/api/* request fails to connect — the launcher and container paths are meant
to stay in sync, and after #784 they no longer did.

Also disambiguates the two same-named _optional_positive_int helpers added by
#774: catalog's drops junk from a live API response, contracts' rejects it as
cache corruption. Same name, opposite behaviour — the strict one is now
_require_optional_positive_int and says why it differs.
2026-08-06 19:30:49 +08:00
NoxsMedia
1f37e859b9 fix(codex): preserve context window metadata (#774) 2026-08-06 19:19:30 +08:00
Bingxi Zhao (Frank)
740ec413a0 release: v1.5.7
Per-account MCP Services and CLI Apps — the two ways a deployment plugs in
tools DeepTutor never shipped — plus the isolation that makes them safe on a
shared install.

- MCP Services: a 45-entry curated store of hosted servers each account
  installs for itself, OAuth 2.1 (PKCE + dynamic client registration) for the
  servers that require it, static keys held by reference and resolved in memory
  at connect time, stdio refused for self-service. Settings no longer
  configures MCP; /settings/mcp redirects to the store.
- CLI Apps: 101 tools snapshotted from the two CLI-Anything registries.
  Installs are admin-only, the registry's install_cmd is parsed into an argv we
  build rather than executed, npm install scripts are forced off, and 66
  first-party entries are pinned to one reviewed commit. Apps land in
  data/cli-apps, one environment each, mounted read-only into the runner.
- Credentials that authorise a person move to data/system, the one branch the
  exec sandbox never mounts: Codex tokens relocate themselves on first use
  (refusing to follow a symlink), per-user MCP configs and keys land beside
  them.
- Grants gain a cli_apps whitelist with the same deny-by-default posture as
  MCP tools; a per-turn registry view keeps one owner's provider tools out of
  the process-global registry and refuses an unauthorised tool at execute, not
  just in the manifest.
- The composer reports what filled this turn's context window, a gutter rail
  jumps back through long conversations, and the workspace collapses to a
  drawer on small screens.
- The composer keeps focus after sending and across tab switches (#720);
  released images carry provenance and SBOM attestations (#722).

README prose, all ten translated READMEs, and the docs-site pages that named
Settings → MCP are updated to match. Release notes:
assets/releases/ver1-5-7.md
2026-07-31 00:25:48 +08:00
Bingxi Zhao (Frank)
7a5102a8cd fix(codex-auth): route the OAuth callback by state, not by request user
The remote callback endpoint added in #716 cannot be authenticated: the
browser reaches /auth/callback on the far end of the user's own tunnel,
a different origin from the DeepTutor Web session, so no cookie is sent.
The user ContextVar is only ever set inside require_auth, which left
get_codex_oauth_service() resolving every callback to the default root
while the login operation lived under data/users/<id> — so remote Codex
sign-in returned login_not_active for every non-administrator.

Deliver by OAuth state instead. The state is a secret this process
minted for exactly one login and is compared in constant time, which is
already the trust model the loopback listener uses; no new authorization
surface is opened. Delivery keeps the endpoint's existing status codes:
409 when nothing is waiting, 400 when a login is waiting but the state
does not match.

The PR's endpoint tests monkeypatched the service factory, so user
resolution was never exercised; they now patch the delivery seam, and
three service-level tests cover routing to a non-default instance.
2026-07-28 19:20:57 +08:00
TyrionH-is-coding
1117e6fe93 fix(codex-auth): guide remote Codex OAuth loopback callbacks (#716)
For a remote or containerized deployment the browser's localhost is the
user's workstation while the OAuth listener runs on the server, so a
reverse proxy cannot deliver http://localhost:1455/auth/callback to that
private listener and Codex sign-in could never complete.

Keep the listener loopback-only and forward just the exact browser
callback path through the Web origin to a state-validating broker. The
settings card and CLI now show the real callback address, the SSH tunnel
command, an explicit authorize action and a countdown, and survive a page
reload; the deployment docs cover the Docker host-port and reverse-proxy
caveats.

The listener stays bound to loopback and ports 1455/1457 are never
published; the Web bridge rewrites only /auth/callback; the broker
requires an active operation and a constant-time state match; callback
responses are no-store HTML that never echo the code or state; PKCE and
the token exchange are unchanged. Binding the listener with
start_serving=False also closes a window where a connection could be
accepted before the callback object existed.
2026-07-28 19:20:27 +08:00
Bingxi Zhao (Frank)
97632b71fe refactor: land #713/#710/#707 on their proper seams
Follow-up to the three PRs merged for #711, #709 and #707 — same fixes,
moved onto the seam each one belongs to, plus the regression tests they
shipped without.

#711 — partner Codex login. The prefix sniffing lived inside the
credential store, so codex_auth had to know what a partner is. Add
`get_owner_path_service()` next to `get_current_path_service()`, where
scope resolution already lives, and `is_partner_user_id()` next to the
prefix that defines it. codex_auth now just asks for the owner's root.

#709 — missing web/node_modules. Split the side-effecting install out of
`_resolve_frontend()` into `_ensure_web_dependencies()`; the resolver
goes back to resolving, and the launcher's second resolve pass is a
single `Path.exists()`.

#707 — book spine and visualize. The blocking calls bypassed
`BaseAgent.call_llm` for the factory directly, which silently dropped the
image attachments the analysis stage is handed, the trace metadata the
Activity panel renders, and the per-agent api_key/base_url/binding
routing. Route all three through the agent seam; blocking behaviour and
its rationale are unchanged.
2026-07-27 21:23:33 +08:00
connectedGraph
e64f5bdcd0 fix(codex-auth): resolve credentials to admin root for partner scopes (#713)
When chatting with a partner or executing subtasks under partner context, the system installs a synthetic user scope (e.g. partner_ada) and redirects PathService workspace root to data/partners/<id>/workspace.

As a result, _codex_user_root() resolved to the partner's virtual user root where no Codex credentials existed, immediately failing with:
Error calling Codex: Sign in to Codex before using this model.

Fix: Detect if the current user ID belongs to a synthetic partner (starts with PARTNER_USER_PREFIX) and resolve to the admin/owner's user root instead, allowing partners to inherit and use the owner's active Codex login token.

Closes #711
2026-07-27 20:54:41 +08:00
Bingxi Zhao (Frank)
47d05809ea release: v1.5.5
Maintenance release on top of v1.5.4, with two new ways to bring a model.

- OpenAI Codex is a first-party OAuth provider (#690): browser sign-in
  against your own ChatGPT plan replaces the API-key fields, credentials
  stay in <user-root>/private/openai-codex/ with owner-only permissions,
  and the managed profile is owner-bound so it is never handed out through
  grants or made active over an already-configured LLM.
- Eden AI joins as the 35th LLM binding (#671), an OpenAI-compatible
  gateway addressed as <provider>/<model>.
- Knowledge bases answer from a real document inventory instead of
  guessing from retrieval hits: a per-KB inventory rides the system prompt
  and a new kb_files tool enumerates on demand with glob/substring
  filters, mounted under rag's gate and deniable per partner.
- The rag tool cites the chunks, entities, and reports retrieval actually
  returned (#694) rather than an echo of its own query; the local LightRAG
  pipeline still surfaces nothing to cite.
- GraphRAG indexing runs on a worker thread with its own asyncio loop
  (#695), so UVICORN_LOOP=asyncio is no longer needed, and two config
  faults that broke the first run are fixed (#699).
- Assorted: unique optimistic message ids (#698, a v1.5.4 regression that
  dropped the assistant reply from the visible thread), partner-chat
  manual scrolling respected (#704), claude-opus-5 recognized as
  effort-based (#703), Kimi models omit temperature outright, and
  deeptutor start keeps relaying logs on legacy Windows code pages (#702).
- Typing: narrow the loopback callback server to asyncio.Server and gate
  the msvcrt lock path on sys.platform so it type-checks off Windows.

Release notes: assets/releases/ver1-5-5.md
2026-07-26 23:19:09 +08:00
TyrionH-is-coding
c3d1dd0b15 feat(llm): add first-party OpenAI Codex OAuth provider (#690)
Replaces the oauth_cli_kit indirection with DeepTutor's own PKCE loopback
sign-in, an account-scoped live model catalog, and a Settings card that exposes
only the OAuth surface. Credentials live in `<user-root>/private/openai-codex/`
with owner-only permissions, atomic writes, and a generation guard that stops a
late refresh from resurrecting a signed-out session; `~/.codex` is never read or
modified. A CLI path shares the same service.

A Codex token authorizes one person's ChatGPT plan, so credentials anchor to the
signing-in account's own root and the managed profile is marked `owner_bound`:
`redacted_model_access` drops it for every caller, and it is not offered as an
assignable model. Signing in publishes the profile but only activates it when no
LLM is configured yet, so it never repoints a deployment that already has one.

Also from review: reschedule the status poll so one dropped response cannot
strand the card on "waiting"; defer the catalog reload when the operator has
unsaved edits instead of discarding them; log the real cause behind the generic
provider error; stop promising a retry when the token refresh actually failed;
bind both loopback stacks since `localhost` may resolve to either; and drop the
provider metadata fields nothing consumed.
2026-07-26 22:27:54 +08:00