71 Commits
Author SHA1 Message Date
moesnow 1a214a5a9e fix(mcp): secure live read-only queries and retain tool hints 2026-10-24 16:26:22 +08:00
digua 45cfe87037 fix(ai): complete analysis time parameter metadata 2026-09-22 18:23:42 +08:00
Chris ChengandClaude Opus 5 6e27968bb0 feat(tools): localize tool descriptions by locale for every runtime
Tool and parameter descriptions were handed to the LLM in Chinese on every
runtime regardless of locale: the English metadata table in
packages/tools/src/tool-metadata.ts had no caller, the desktop translateTool
looked up i18n keys that exist in no locale file, and the MCP server had no
locale at all.

Fill the table for every tool whose definition text is Chinese (37 entries,
only translating what the definitions write in Chinese so the two copies
cannot drift), and route the four consumers through getLocalizedToolMetadata:
the cross-chat agent adapters, the CLI Web agent adapter, the desktop shared
tool adapter (replacing the dead translateTool), and the MCP server, which
now resolves its locale from config.locale.lang or the system locale for both
the standalone binary and the chatlab mcp subcommand.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 16:54:06 +08:00
liuyy2 aea7e2540c fix(ai): respect time ranges in analysis tools 2026-09-21 18:45:55 +08:00
digua f4017b0adf feat(ai): link memories to source messages 2026-08-26 22:23:04 +08:00
digua 4b405b8114 feat(ai): rank global memories by relevance 2026-08-26 13:46:58 +08:00
digua c69a927615 fix(ai): keep global memory always enabled
Remove the proactive-memory preference and its cross-platform runtime plumbing so memory behavior has one clear contract. Normalize away the obsolete setting and keep source type limited to provenance.
2026-08-24 22:35:47 +08:00
digua 77c4dec9e6 fix(ai): enforce current-turn memory scopes
Share entities resolved during one Agent run so natural-language subject changes can safely use memory. Validate entity memory scope before permanent deletion to prevent stale IDs from deleting another subject's memory.
2026-08-24 22:35:47 +08:00
digua 85bf46b168 feat(ai): add self memory management 2026-08-24 22:35:47 +08:00
digua 04916041b4 fix(ai): bind memory tools to current entity selection 2026-08-24 22:35:47 +08:00
digua ed8ab84b4b feat(ai): integrate memory with global agent 2026-08-24 22:35:47 +08:00
digua f9ba12e535 fix(ai): harden cross-chat analysis results
Resolve private ranking display names, apply privacy preprocessing consistently across cached recaps and structural labels, and bound model-visible overview payloads to the configured tool budget.
2026-08-24 00:25:35 +08:00
digua 05d9b34f30 chore(ai): finalize global statistics integration 2026-08-24 00:25:35 +08:00
digua 207c41afaa feat(ai): expose cached global activity summaries 2026-08-24 00:25:35 +08:00
digua dff4f4dfa8 feat(ai): support ranged cross-chat overviews 2026-08-24 00:25:35 +08:00
digua 277edaff96 feat(ai): rank group sessions globally 2026-08-24 00:25:35 +08:00
digua 6d64333675 feat(ai): rank private contacts globally 2026-08-24 00:25:35 +08:00
digua 75eff70e23 feat(ai): improve cross-chat evidence retrieval 2026-08-24 00:25:35 +08:00
digua 6c07610778 fix(ai): align cross-chat relative time ranges 2026-08-24 00:25:35 +08:00
digua a6557608c6 fix(ai): harden shared interaction analysis
Keep shared-interaction evidence, pagination, and token truncation accurate while bounding anchor inputs, proximity scans, contact discovery, and reply aggregation. Resolve participants across all imported history and isolate damaged database candidates without changing the final analysis tree.
2026-08-23 16:19:57 +08:00
digua d79e4733dd feat(ai): inspect shared contact interactions 2026-08-23 16:19:57 +08:00
digua 10e0825578 fix(ai): harden contact session inspection
Use the all-history contact snapshot and validate raw session candidates inside the cancellable scan loop. Bound model-visible structural results to the configured token budget while preserving full tool details and continuation metadata.
2026-08-22 20:29:40 +08:00
digua f26c6f6eba feat(ai): inspect contact activity across sessions 2026-08-22 20:29:40 +08:00
digua fbcc0f299f fix(ai): budget cross-chat entity results
Keep full entity resolution details available to the application while bounding the model-visible payload with the runtime tokenizer. Preserve coverage and truncation metadata, prioritize usable scopes fairly, and cap ambiguity hints to avoid duplicate unbounded source lists.
2026-08-22 17:09:23 +08:00
digua dc3bd82c90 fix(ai): enforce cross-chat execution budgets
Count complete tool payloads with the runtime tokenizer so Chinese evidence respects the configured model context budget.\n\nResolve contact sources incrementally with cancellation checks and targeted member lookups to keep long cross-chat investigations responsive.
2026-08-22 17:09:23 +08:00
digua d1a6c711fe feat(ai): add isolated cross-chat agent 2026-08-22 17:09:23 +08:00
digua 2e624f6beb feat(ai): stream tool execution progress 2026-08-18 17:27:48 +08:00
digua cf1aee9e5b refactor(ai): upgrade pi runtime and define execution semantics 2026-08-18 17:27:48 +08:00
digua 883fa0896d docs(search): record FTS removal benchmarks 2026-08-03 17:28:19 +08:00
digua 256e93605a refactor(database): remove legacy session FTS 2026-08-03 17:28:19 +08:00
digua 4777ca9f63 fix(web-ai): harden Web WASM AI chat
Stabilize browser model setup, tool execution, retries, cancellation, and error reporting.
2026-07-27 00:09:33 +08:00
digua 7dcf5d9070 feat(web): add Web WASM AI chat 2026-07-27 00:09:33 +08:00
digua 5a5fae880a refactor: remove redundant re-export proxies 2026-07-16 20:09:18 +08:00
digua 16ee4d8348 refactor(ai): unify desktop tool adapters 2026-07-13 20:42:27 +08:00
digua 801e7fc66a fix(cli): harden agent query safeguards
Tighten agent-facing query validation, privacy guards, SQL result handling, config writes, and LIKE search semantics for the CLI query workflow.
2026-07-04 15:12:50 +08:00
digua fd97c55681 feat(query): extend shared chat query capabilities 2026-07-04 15:12:50 +08:00
digua 434334b203 feat(semantic-index): run local embeddings in lazy worker 2026-06-23 14:18:32 +08:00
diguaandClaude Sonnet 4.6 7df673f62f test: add openTestSqliteDatabase helper to fix native binding mismatch
Centralise the better-sqlite3 native-binding selection for tests in
tests/helpers/sqlite.mts so test files consistently use the CLI-side
binding (apps/cli/native/better_sqlite3.node) rather than the default
one, which may be compiled for a different Node.js ABI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-23 14:18:32 +08:00
diguaandClaude Sonnet 4.6 39393cf38d refactor: remove dead code and simplify over-engineered abstractions
- Delete NotificationBus interface (no implementations, no callers)
- Delete useAsyncData/useMultipleAsyncData composables (zero import sites)
- Inline CHART_CAPABILITY_SKILL_ID into tool-catalog.ts (was a single-constant file)
- Inline AsyncSqlExecutor into message-query-functions.ts (was a single-interface file)
- Rename tools TimeFilter → ToolTimeRange to eliminate name collision with shared-types
- Shrink useToast wrapper: two interfaces → one type, 40 lines → 17 lines
- Simplify deepMerge: remove recursion, config is at most 1 level deep

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-23 14:18:32 +08:00
digua abd05981c6 fix(ai): semantic index core reliability and evidence text
Prevent stale semantic index writes by checking write guard before
persisting chunks; make rebuild detection explicit on app restart via
reactivate() path; preserve full evidence snippet text without truncation;
add regression test for same-second chunk tie-breaking in mapMessageToChunk.
2026-06-21 16:18:39 +08:00
diguaandClaude Sonnet 4.6 69ac64791e fix(ai): fix evidence tool classification and semantic search time filter
retrieve-chat-evidence:
- repair semantic cleanup and keyword time filter; pass context timeFilter
  (seconds→ms) when no explicit date params are provided
- classifyGroup: skip Chinese keyword matching for non-Chinese locales and
  update the English LLM instruction to allow judgment on uncertain groups,
  so English-language chats are not permanently stuck at "cannot confirm"
- mergeCandidates: replace ID-range overlap check with timestamp overlap
  so keyword hits are not incorrectly dropped after incremental imports
  backfill older messages with non-monotonic IDs

semantic-search-current-chat:
- forward context.timeFilter (seconds→ms) to searchForTool so the tool
  respects session time range the same way other retrieval tools do

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-21 16:18:39 +08:00
digua 2ec99e5880 feat(ai): streamline agent tool results 2026-06-21 16:18:39 +08:00
digua 5d20429af7 fix(tools): support multi-keyword message search 2026-06-21 16:18:39 +08:00
diguaandCursor d58168a029 fix(ai): correct evidence snippet time unit and strip per-message times
Evidence messages carry millisecond timestamps but the preprocessing pipeline
renders times assuming seconds (multiplies by 1000), producing absurd years
(e.g. 56150) inside semantic snippets. Convert ms back to seconds before
rendering. Also strip the per-line time prefix from semantic snippets so the
evidence block shows a single group time instead of a time on every message,
and drop the redundant time span in the group header. Adds regression tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 16:18:39 +08:00
diguaandCursor 402b78b683 feat(ai): render evidence content block with click-through tracing
Add a structured "evidence" content block produced by retrieve_chat_evidence:
extract the payload from tool results, persist it in AI chat history, and
render grouped, desensitized sources in EvidenceBlock.vue. Sources open the
chat record drawer at the matched message for traceability. Evidence payload
types move to @openchatlab/core so tools, node-runtime and the frontend share
one definition. Includes zh-CN/en-US/ja-JP/zh-TW i18n.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 16:18:39 +08:00
diguaandCursor b248e48787 feat(ai): route evidence questions to retrieve_chat_evidence via planner
Add an "evidence" planner intent and tiered retrieval guidance so
fact/occurrence/count questions are routed to retrieve_chat_evidence
instead of a single low-level search path.

- planner: new evidence intent + prompt strategy suggesting only
  retrieve_chat_evidence for that step
- semantic-search guidance: three-tier tool selection (evidence > semantic > keyword)
- expose retrieve_chat_evidence as an always-on Agent tool (desktop special
  append; CLI via AGENT_TOOL_REGISTRY core), semantic tool stays dynamic
- export evidence tool + payload types from @openchatlab/tools
- TDD: planner evidence-intent test

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 16:18:39 +08:00
diguaandCursor 27a5bbf9bf feat(ai): apply millisecond time-range filter to semantic retrieval
Thread an optional timeFilter through SemanticSearchToolOptions →
searchForTool → search → hybridSearch so evidence retrieval no longer
mixes time ranges between semantic and keyword paths.

- hybridSearch filters dense + FTS-mapped chunks by startTs/endTs overlap
  (millisecond, single-sided supported) and amplifies the candidate pool
  when filtering to avoid under-recall
- retrieve_chat_evidence now passes its parsed ms range to the semantic path
- TDD: hybrid-search overlap unit tests + service wiring test

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 16:18:39 +08:00
diguaandCursor 6886eb3dc6 feat(ai): add retrieve_chat_evidence tool with evidence payload protocol
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>
2026-06-21 16:18:39 +08:00
diguaandCursor b9599da1c8 feat(semantic-index): expose semantic search via routes, agent tool and pipeline
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>
2026-06-21 16:18:39 +08:00
LeoandLeo 28fedbd815 fix(ai): recover from analysis tool timeouts (#229)
Co-authored-by: Leo <jxy0811@users.noreply.github.com>
2026-06-16 11:30:02 +08:00