agent-stream-runner: pass timeFilter and maxMessagesLimit from request
params into the tool context so evidence and retrieval tools respect the
active session time range in CLI Web sessions, matching the desktop runner.
tool-adapter: pass preprocessConfig, anonymizeNames and ownerPlatformId to
applyPreprocessingPipeline in the rawMessages branch so desensitization and
name anonymization apply to search_messages / recent_messages results,
matching the desktop adapter behavior.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Introduce a high-level evidence retrieval tool for fact/occurrence/count
questions. It resolves auto mode, runs semantic + keyword paths, de-identifies
keyword snippets via an injected desensitizeMessages callback, applies a
tool-layer millisecond time-range fallback (keyword path can't rely on the CLI
provider's timeFilter), and merges/dedupes candidates into conservative groups.
- Add ChatEvidencePayload / group / source types and EvidenceTimeRangeMs to tools
- Register tool in AGENT_TOOL_REGISTRY only (Agent-only, excluded from MCP)
- Inject desensitizeMessages (preprocessMessages) in desktop + CLI adapters
- TDD: tool + registry unit tests
Co-authored-by: Cursor <cursoragent@cursor.com>
Add shared /_web/ai/semantic-index HTTP routes and wire the service into
CLI web and Electron internal API. Introduce the semantic_search_current_chat
agent tool (AGENT-only, not MCP) with desensitized output and a narrowed
service interface, forward the semantic-search context through the CLI and
Desktop tool adapters, and integrate on-demand semantic search into the
agent pipeline with guidance and a max-result-token evidence budget.
Co-authored-by: Cursor <cursoragent@cursor.com>
Remove the deprecated always-on RAG system and introduce the new
semantic-index core: parent/child chunker with version/hash derivation,
embedding providers (local + OpenAI-compatible) and profiles, sqlite-vec
vector store, dense+FTS+RRF hybrid retrieval, evidence assembly, serial
warmup job queue and single-session runner, session business-state store,
and the SemanticIndexService that ties them together. Add an independent
config store and a dedicated vector directory via the path providers.
Co-authored-by: Cursor <cursoragent@cursor.com>
In CLI Web mode, the frontend displays __APP_VERSION__ injected from the
root package.json at build time (0.26.2), while the server-side getVersion()
reads apps/cli/package.json at runtime (stuck at 0.25.1). This caused
buildWebUpdateCheckResult to compare remote 0.26.2 against local 0.25.1,
permanently reporting a false update notice even when the user was already
on the latest version.
Fix apps/cli/package.json to 0.26.2 to align with the product version.
Also extend set_release_version.sh to keep apps/cli/package.json in sync
with the root package.json on every release, preventing the drift from
recurring. apps/desktop/package.json is intentionally kept at 0.0.0 (the
desktop runtime uses app.getVersion() with __APP_VERSION__ fallback).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The sync module creates its own PreferencesManager at server startup,
separate from the one shared by web routes. When the user configures their
identity through the web UI, the web routes' manager writes to disk and
updates its own cache, but the sync module's manager retains a stale cache
from startup. Subsequent pull imports then call tryApplyOwnerProfile with
the stale cache, returning no_profile and skipping owner assignment even
though a profile exists on disk.
Fix: invalidate the sync manager's cache before each onSessionImported
callback so the fresh profile is always read from disk.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PullEngine gains an onSessionImported hook (hook errors never fail the
pull), wired in both the CLI server and Electron main to silently fill
session owner from the stored platform profile. The chatlab import CLI
command does the same after a successful import.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Extend TokenUsage types across the full data pipeline to include
cacheReadTokens and cacheWriteTokens. The ChatStatusBar tooltip now
shows cache hit information when available. This is a generic
implementation that works with any API provider reporting cache metrics,
not limited to DeepSeek.
Co-authored-by: Cursor <cursoragent@cursor.com>
Message-retrieval tools mirror rawMessages inside data, and the
preprocessing pipeline rendered that array into the tool result text as
"rawMessages: [object Object], [object Object], ..." — roughly 1.7KB of
junk per call (~400-500 wasted tokens) that also polluted the truncated
result text persisted for history replay.
- formatToolResultAsText skips the rawMessages key (raw message objects
are already rendered via the formatted messages list)
- CLI tool adapter strips rawMessages from extraDetails before invoking
the pipeline, matching the existing desktop adapter behavior
Regression tests fail without the fix at both the format layer and the
CLI adapter layer.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
MCP server checks the gate at startup and exits before opening stdio if
the data directory requires a newer runtime. Desktop HTTP API maps
DataDirCompatibilityError (including wrapped causes) to a 409 response
so the renderer can surface a clear upgrade prompt.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Harden the startup migration path: fail fast and show an error dialog if
schema migration cannot complete. Repair the gate retroactively for
databases that were already migrated before the gate system existed.
Raise the gate after every import path (full import, incremental import,
stream import) and after opening any database that already carries a
current-segment schema. Centralise gate-raising inside DatabaseManager so
call sites cannot accidentally skip it.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use the packaged app version (not Electron's dev-mode 0.0.0) across all
compatibility checks. Make DatabaseManager require a RuntimeIdentity so
every gate write carries a verified version and kind.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Enable esbuild minification for main/preload (was renderer-only by default),
reducing main process bundle by ~55%. Extract cl100k_base BPE rank table out
of the synchronous startup path via dynamic import — it now lands in its own
chunk and is loaded on first agent run instead of at app startup.
Also fix Windows CI step to use PowerShell syntax for version injection.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Unify the merge workflow (parse/conflicts/execute/clear/export-for-merge)
across CLI, Electron, and web-serve into a single set of shared routes in
@openchatlab/http-routes.
Key changes:
- Move MergeSessionCache from CLI to node-runtime shared package
- Add dual-mode parse route (multipart upload for web, JSON filePath for Electron)
- Integrate merge routes into Electron internal API server with @fastify/multipart
- Create installMergeShims() with filePath-to-handle mapping for frontend
- Remove Electron merge IPC handlers, merger module, and preload bridges (~790 lines deleted)
- Address CodeX review: CHAT_DB_TABLES in openDatabase, no chatApi patching,
outputName sanitization, resp.ok checks, @fastify/multipart in desktop deps
Co-authored-by: Cursor <cursoragent@cursor.com>
Improve auth hook security: restructure URL classification to fix
/_web/* bypass when requireAuth is active, use HMAC-SHA256 for constant-
time token comparison, remove dead webModeEnabled code.
Improve frontend auth flow: extract initializeApp() with watch-based
re-init after login, add getToken callback for real-time store reads,
unify SSE 401 handling via fetchWithAuth, switch default storage to
sessionStorage, add router guard consuming meta.public.
Add "Remember this device" checkbox on login page with dual
localStorage/sessionStorage strategy and safety warning.
Add 23 unit tests for auth hook matrix and http client.
Co-authored-by: Cursor <cursoragent@cursor.com>
When enabled, all /_web/* routes require Bearer token authentication,
same as /api/v1/*. This hardens security for server/headless/public
deployments where the same-origin assumption doesn't hold.
- Add `require_auth` field to config schema (default: false)
- Add `setRequireAuth()` to auth hook, conditionally enforce auth on /_web/*
- Support `--require-auth` in both `chatlab start` and `--daemon` mode
- Read from config.api.require_auth or CLI flag override
Co-authored-by: Cursor <cursoragent@cursor.com>
在 Web 生产模式(chatlab start)下,浏览器无法直连 chatlab.fun(CORS 限制),
导致首页底部社交链接(如小红书)及云端助手/技能预设拉取失败。
Vite dev proxy 已有对应配置,但生产 Fastify server 缺少该代理,现补全。
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>