Commit Graph

973 Commits

Author SHA1 Message Date
matevip
020a87ee7e feat(skill): ACP integration for external coding agents 2026-05-01 09:49:22 +08:00
matevip
f0991f543f feat(skill): skill template gallery + author wizard MVP 2026-05-01 09:49:14 +08:00
matevip
359600c77f feat(skill): per-skill LESSONS.md + self-evolution v1 2026-05-01 09:49:07 +08:00
matevip
d927521d51 feat(skill): install/uninstall split + Requirements API + provider router 2026-05-01 09:48:59 +08:00
matevip
688b37b652 feat(skill): features matrix + effective-tool expansion 2026-05-01 09:48:39 +08:00
matevip
323ba1b82e feat(skill): manifest schema + parser (additive) 2026-05-01 09:48:32 +08:00
matevip
4f3276b9e6 fix(skill): mark docs-only vs scripts+docs in Available Skills prompt (issue #49) 2026-04-30 18:04:11 +08:00
matevip
46ac58500c fix(skill): correct pagination total and sort order on SkillMarket (issue #48) 2026-04-30 17:45:02 +08:00
matevip
a0c6ed5a86 fix(agent): vision gate + history media drop + friendlier skip notice 2026-04-30 17:26:13 +08:00
matevip
47bdb97a3a fix(agent): per-model multimodal capability resolution (issue #44) 2026-04-30 17:25:51 +08:00
matevip
101aa3209e fix(skill): stop the LLM from calling skill names as tools (issue #46)
When a user-installed skill (e.g. RedisOps) was bound to an agent, the
model frequently called the skill name directly as a tool, hit
"Tool not found: RedisOps", and either gave up or fell back to shell
guessing. Two compounding causes:

1. The system prompt block injected by SkillRuntimeService listed each
   skill as `- **RedisOps** — desc`, which is the same format used for
   tool catalogs and primed the model to call the names directly. The
   "how to use" instructions referenced `read_skill_file` /
   `run_skill_script` — names that don't exist in the tool registry,
   so even a compliant LLM couldn't follow them.

2. ToolExecutionExecutor's `callback == null` branches returned a bare
   "Tool not found: <name>" string. The model had no recovery signal
   and no hint that the name it called was actually a skill.

Fix is two-layered:

- Prompt rewrite (SkillRuntimeService.buildSkillPromptEnhancement): lead
  with an explicit warning that skills are NOT directly callable, use the
  correct camelCase tool names (readSkillFile / runSkillScript), include
  a concrete worked example anchored to the first enabled skill, and
  render the listing as a markdown table so it stops looking like a
  callable tool list. listAvailableSkills tool description and output
  follow the same pattern.

- Runtime safety net (ToolExecutionExecutor): when toolCallbackMap.get
  misses, check if the requested name (case-insensitive) matches an
  active skill. If so, return a precise hint telling the LLM the right
  invocation pattern instead of the bare error. Wired through both the
  main execute path and the pre-approved replay path. SkillRuntimeService
  is attached via a setter from AgentGraphBuilder so the executor's many
  legacy constructors stay untouched, and it's nullable so isolated
  tests still work.

Adds 5 unit tests covering: skill match -> hint, case-insensitive match,
no-match -> bare error, no SkillRuntimeService wired -> bare error,
pre-approved replay path -> hint.

Reported and reproduced by @pipima9950-glitch in issue #46.
2026-04-30 16:36:30 +08:00
matevip
d20b440ce5 fix(skill): preserve skillContent/configJson on security scan write-back (issue #45)
SkillPackageResolver.persistScanOutcome built a fresh SkillEntity with only
id + scan fields, then called updateById. SkillEntity declares six columns
with @TableField(updateStrategy = FieldStrategy.ALWAYS) — name_zh, name_en,
config_json, source_code, skill_content, security_scan_result — so the
ALWAYS strategy emits UPDATE statements that write NULL to every one of
those columns not set on the partial entity.

Effect: every security re-scan that produced a status/findings change
silently wiped skill_content, config_json, source_code, name_zh, name_en
on the row. After importing a custom skill, the first scan tick destroyed
the imported content.

Fix: switch to LambdaUpdateWrapper so the UPDATE only touches the three
scan columns we actually want to change. Other skillMapper.updateById
call sites (SkillService, BuiltinSkillSeedService) pass DB-hydrated
existing entities and are unaffected.

Reported and diagnosed by @pipima9950-glitch in issue #45.
2026-04-30 15:28:56 +08:00
matevip
977e181949 feat(cron): unify output, add reminder task type, in-flight progress UI
Three layers landed together because they share the same routing /
lifecycle plumbing:

1. Cron output unification
   - New CronConversationResolver routes web-origin jobs to the per-workspace
     tasks_<wsId> conversation; IM-bound jobs go to the channel session
     conversation when one exists (matched by senderId then targetId);
     legacy cron_<id> remains as the fallback.
   - CronJobLifecycleService inserts a system-role header divider when a
     run starts so users browsing the unified tasks_<wsId> view can tell
     which job started a run. BaseAgent.sanitizeForLlm filters these
     headers so they never reach the model.
   - WorkspaceService seeds tasks_<wsId> on workspace creation; V65
     migration backfills existing workspaces.
   - DeliveryConfig gains a userId field so IM session lookup can match
     by senderId (replyToken-based targetId is not stable across runs).
   - ConversationVO recognizes tasks_/cron_ underscore prefix as cron
     source. MessageList renders the system header as a labeled divider.
   - ChatConsole pins tasks_* conversations and tracks per-conversation
     read state so new cron output gets a visible unread dot.

2. Reminder task type
   - New task_type='reminder' in CronJobEntity + service validation.
   - CronJobRunner short-circuits 'reminder' jobs: hands trigger_message
     to finishRunAndPublish verbatim, no LLM call. Fixes a regression
     where reminders were rephrased into echoed wrappers.
   - New create_reminder tool alongside create_cron_job, with descriptions
     tightened so the model picks the right one (verbatim push vs LLM
     query that needs computation).
   - CronJobs.vue gets a third radio option + dedicated reminder field.

3. In-flight progress placeholder
   - Cron uses non-streaming chat()/execute(); tool-heavy ReAct loops
     can run 1-5 minutes between start and finish with no visible
     state, looking hung.
   - New GET /api/v1/cron-jobs/active-runs returns runs in status=running
     for a conversation. ChatConsole polls it on the existing 4s tick
     (and on conversation switch) and shows a spinner bar with elapsed
     time. When run count drops to zero, it refetches messages so the
     assistant bubble appears within ~1s of finish.
2026-04-30 15:01:24 +08:00
matevip
efbc858868 fix(skill): align ClawHub client with actual marketplace API (issue #42) 2026-04-30 10:25:21 +08:00
matevip
b40cbfb0a1 fix(tool): clean up EXTERNAL_CDP profile dir + Chrome subprocesses on session stop 2026-04-30 10:25:00 +08:00
matevip
6390abdecc fix(llm): apply read timeout to streaming chat WebClient (openai-compat + anthropic) 2026-04-30 08:54:46 +08:00
matevip
92a7508dac fix(channel): mirror plan-execute events to web sse for im-routed conversations 2026-04-30 08:54:32 +08:00
matevip
1864801c90 fix(tool): browser_use Windows compat + stop LLM treating it as web search 2026-04-30 08:54:15 +08:00
matevip
0aee2a1ca5 fix(agent): raise per-step tool-call ceiling to 100, soften limit-exceeded prompt 2026-04-30 07:00:42 +08:00
matevip
ca5387ed65 fix(agent): always write FINAL_SUMMARY in DirectAnswerNode 2026-04-30 07:00:24 +08:00
matevip
3db4230142 feat(channels): redesign list page — show only configured channels, add hero empty state 2026-04-30 06:59:47 +08:00
matevip
a11f0586ba feat(channels): three-step onboarding wizard with live credential verify 2026-04-30 00:26:38 +08:00
matevip
7cfb511948 fix(cron): rename conversation id prefix from 'cron:' to 'cron_' (issue #36) 2026-04-29 15:58:43 +08:00
matevip
0a5b1989f3 fix(cron): isolate cron jobs by workspace (issue #37) 2026-04-29 15:49:04 +08:00
matevip
0ecfec474e fix(conversation): tolerate non-path-safe ids when cleaning attachments (issue #36) 2026-04-29 15:07:36 +08:00
matevip
172784bc5f docs(readme): lead with team / IT-deployable positioning
Add a callout above the existing intro to make the wedge explicit:
multi-user workspaces, approval-gated sensitive actions, full audit trail,
production-grade health monitoring, per-channel error isolation.
One JAR on your own machine, zero data egress.
2026-04-29 14:10:12 +08:00
matevip
e759ad4a1b sync: settings UI polish, channel reliability fixes, DeepSeek cross-turn fix
- Settings → Models: inline API key, frosted drawer, dark-mode polish, provider icons, i18n sweep
- WeChat Work channel: rebuild HttpClient on reconnect, dedup failure signals, route auth_succeed errcode!=0 through failure handler
- Channel framework: per-adapter error isolation, QR auth SPI, health indicators
- Agent: patch cross-turn assistants for DeepSeek thinking-mode
- GitHub: bilingual issue templates with required fields
2026-04-29 11:22:47 +08:00
matevip
709a0db200 fix(chat): surface stored path for uploaded attachments
Chat attachments with non-ASCII filenames (e.g. Chinese) get sanitized
at upload time — `人人有虾.docx` is stored as `1777391026594_____.docx`.
Tools then receive only the original filename via '[Attachment] foo.docx'
and fail with 'file not found'.

- renderMessageContent now appends the actual server-side path so any
  tool the LLM picks (read_file / extract_document_text /
  detect_file_type) gets a path that resolves directly.
- New ChatUploadResolver helper performs basename-suffix matching inside
  the conversation's chat-upload directory; ReadFileTool, DocumentExtractTool
  and FileTypeDetectorTool fall through to it when the literal path does
  not exist (defense in depth for cases where the LLM ignores the path
  hint).

Refs https://github.com/matevip/mateclaw/issues/29
2026-04-28 23:59:27 +08:00
matevip
ae820f0f94 fix(workspace): make default-workspace owner bootstrap first-run-only
Replace the per-startup admin reconciliation in
WorkspaceSchemaMigration.ensureDefaultWorkspaceMembership() with a
one-shot bootstrap. Once the default workspace has any owner, the
method returns immediately, so an operator's deliberate removal of an
admin from the default workspace persists across restarts. If no owner
exists yet, pick the lowest-id active admin and add them as owner; if
no admin exists at all, log a warning and skip rather than failing
startup.

Refs https://github.com/matevip/mateclaw/issues/29
2026-04-28 23:41:56 +08:00
matevip
a73b640c87 fix(workspace): scope default workspace backfill to admins only
Restart-time backfill in WorkspaceSchemaMigration was inserting every
existing user into the default workspace and copying mate_user.role
('user'/'admin') into mate_workspace_member.role, whose valid domain is
{owner, admin, member, viewer}. Result: non-admin users assigned to
other workspaces were silently re-attached to the default workspace
with role='user', failing roleLevel() lookup and 403'ing on Agents.

- Filter the INSERT on u.role = 'admin' and hard-code the membership
  role to 'owner', removing the role-domain mismatch and the
  workspace-isolation violation in one change.
- Add V60__fix_invalid_workspace_member_roles.sql (h2 + mysql) to
  drop already-corrupted default-workspace rows for users who have a
  valid membership elsewhere, and downgrade the orphan rows to
  'member' so those users aren't locked out entirely.

Refs https://github.com/matevip/mateclaw/issues/29
2026-04-28 23:40:21 +08:00
matevip
b4697f2806 fix(cron): post-deploy bug bundle — flakiness, scheduler, channel UI
User-reported field issues + a deeper code audit revealed multiple
overlapping bugs in the prior cron-channel delivery change. This fixes
all six.

#1 — Concurrency race on ToolExecutionExecutor (root cause of 'sometimes
   succeeds, sometimes fails' tool calls). The volatile instance fields
   currentRequesterId / currentWorkspaceBasePath / currentChatOrigin
   were shared by every conversation routed through the same per-agent
   executor; one user mid-build-loop while another's execute()
   overwrote the field would cross-contaminate the captured values into
   PreparedToolCall. Fix: kill the instance fields, thread
   origin/requester/workspace as method params straight into
   PreparedToolCall snapshot. Comment pins the rule so it cannot regress.

#2 — CHAT_ORIGIN missing from KeyStrategyFactory (latent timebomb,
   masked by spring-ai-alibaba-graph-core's non-filtering builder path).
   Without an addStrategy registration, multi-node state merges in long
   ReAct / Plan-Execute loops drop the key, ActionNode reads
   ChatOrigin.EMPTY, and the cron persists with channel_id=NULL. Also
   caught 4 more keys that were latently unregistered:
   WORKSPACE_BASE_PATH, STOP_REQUESTED, RETURN_DIRECT_TRIGGERED,
   DIRECT_TOOL_OUTPUTS. All five now registered in both ReAct and
   Plan-Execute factories.

#3 — CronJobs UI didn't surface channel binding. CronJobDTO carried
   channelId / deliveryConfig but the list page never rendered them.
   Added: (a) 'channel' column on list page, (b) channel + targetId
   rows in the detail modal, (c) backend batch-loads channel names via
   ChannelMapper.selectBatchIds so the column shows the human-readable
   name, (d) i18n keys (zh + en), (e) channelName field on TS CronJob
   type.

#4a — DingTalk targetId expiry. ChannelChatOriginFactory.resolveTargetId
   used to prefer ChannelMessage.replyToken which for DingTalk encodes
   a sessionWebhook URL that expires ~90 minutes after the inbound
   message. Cron persisted with that webhook then dies with 401/403 and
   marks NOT_DELIVERED forever. Fix: prefer the stable chatId, fall
   back to senderId — both work indefinitely via DingTalk's Robot API.

#4b — Scheduler pool exhaustion under long LLM. CronJobService's
   ThreadPoolTaskScheduler ran with poolSize=4 AND the LLM call lived
   on the scheduler thread. Four concurrent crons saturated the pool
   and the 5th silently missed its tick. Fix: keep scheduler tiny (it
   just fires triggers) and offload runAgent to a dedicated
   virtual-thread executor (cron-execute-* threads). LLM workload is
   I/O-bound — virtual threads scale to thousands at trivial cost.

#5 — Minor latent bugs:
   - AbstractCronResultDelivery.claimRun used .in(... 'NONE','PENDING',null),
     but SQL IN never matches NULL. Rewrote as IS NULL OR IN
     (NONE,PENDING) so legacy pre-V57 rows can still claim.
   - CronDeliveryListener.onCompletedRaw was an empty @EventListener
     with a wrong-headed comment about test fallbackExecution. Removed.
   - CronJobTool.resolveAgentId silently returned 1L when origin
     lacked an agentId — would silently bind to whatever agent #1
     happens to be. Replaced with explicit error so wiring bugs surface
     immediately instead of producing scheduled-but-never-runs crons.

State-key registration guard. New StateKeyRegistrationCoverageTest
scans MateClawStateKeys via reflection and parses
AgentGraphBuilder.java to extract every
.addStrategy(MateClawStateKeys.X, ...). Asserts every non-_NODE
constant appears in at least one factory. Caught the 4 unregistered
keys above on first run; will catch any future 'forgot to register'
regression.

Tests: 33 unit/arch tests + 27 regression in touched areas — all green.
Vue typecheck clean.

Refs: #25, #16
2026-04-28 21:45:07 +08:00
matevip
4011050ceb feat(cron): channel delivery via ChatOrigin + Spring AI ToolContext
Replaces the prior ThreadLocal context plumbing with explicit Spring AI
ToolContext threading carried by an immutable ChatOrigin value object,
so a cron created from inside WeChat (or any IM channel) delivers its
results back to the originating channel.

Architecture
- ChatOrigin / ChannelTarget value objects + per-entry-point factories
  (ChannelChatOriginFactory in vip.mate.channel, CronChatOriginFactory
  in vip.mate.cron — symmetric, no cyclic deps).
- LocaleAwareToolCallback now forwards call(String, ToolContext) and
  getToolMetadata so the decorator chain cannot silently drop the origin.
- AgentService 6-method overhaul + ChatOriginHolder bridge into
  StateGraph buildInitialState which writes CHAT_ORIGIN; ActionNode +
  StepExecutionNode forward it to ToolExecutionExecutor.
- ToolExecutionExecutor builds ToolContext per call; 8/8 tools migrated
  (CronJobTool, WorkspacePathGuard, Video/Image/Browser/ReadFile/Music,
  DelegateAgentTool with parent-origin inheritance).
- CronJobRunner + CronJobLifecycleService 3-segment REQUIRES_NEW model
  (T1 startRun / no-tx runAgent / T2 finishRunAndPublish); ArchUnit
  pins CronJobRunner as @Transactional-free.
- CronResultDelivery Strategy + AbstractCronResultDelivery Template
  with SQL CAS idempotency on mate_cron_job_run.delivery_status —
  replaces the prior process-local Caffeine TTL, cluster-safe.
- CronJobCompletedEvent + @Async @TransactionalEventListener(AFTER_COMMIT);
  cronDeliveryExecutor (core=2, max=4, queue=1000, AbortPolicy + audit).
- CronRunStaleCleanup @Scheduled(5min) sweeps PENDING-15min and
  status='running'-30min in one query each.
- CronJobRunner.wrapWithDeliveryGuard prepends a system note for
  channel-bound crons to suppress hallucinated 'install CLI to send
  WeChat' suggestions.
- ApprovalWorkflowService Memento: persist ChatOrigin snapshot on
  create, restore on replay so cross-restart approvals keep channel
  binding; ChannelMessageRouter + ChatController web-replay both prefer
  the Memento and fall back to fresh-build.
- ChannelManager.sendToChannel 4-arg DeliveryOptions overload;
  ChannelAdapter#proactiveSend default 4-arg pass-through; Slack
  overrides for thread_ts and Telegram overrides for message_thread_id.
- CronJobs UI: read-only 'last delivery' badge driven by
  CronJobMapper.selectListWithDeliveryStatus subquery.

Schema migrations V57/V58/V59 (V56 was already taken by an unrelated
provider migration — Flyway processes versions in order regardless of
gaps):
- V57: mate_cron_job_run delivery_status / target / error + composite
       index (delivery_status, started_at) covering the cleanup sweep.
- V58: mate_cron_job channel_id (indexed) + delivery_config TEXT (JSON
       via MyBatis Plus JacksonTypeHandler).
- V59: mate_tool_approval chat_origin TEXT (Memento).
All idempotent in both H2 (IF NOT EXISTS) and MySQL (INFORMATION_SCHEMA
guard + PREPARE).

ArchUnit guards (test scope, archunit-junit5 1.3.0):
- every concrete vip.mate.* ToolCallback must override
  call(String, ToolContext) — pins the decorator-forward fix.
- CronJobRunner must NOT carry @Transactional on the class or any
  method — pins the 3-segment lifecycle rule.

Tests: 32 new unit tests + 21 regression tests in touched areas, all
53 green:
- ChatOriginTest (6) — value-object invariants + JSON round-trip.
- LocaleAwareToolCallbackToolContextTest (2) — decorator forward.
- DeliveryConfigTest (4) — Jackson round-trip + forward-compat.
- ToolCallbackToolContextForwardArchTest (2) — both ArchUnit guards.
- CronJobRunnerDeliveryGuardTest (3) — channel-cron prefix injection.
- AbstractCronResultDeliveryTest (4) — claim CAS + concurrent CAS.
- ChannelCronResultDeliveryTest (6) — supports / doDeliver / errors.
- ApprovalReplayContinuityTest (5) — Memento round-trip + corrupt
  payload fallback + unknown-field tolerance.

Refs: #25, #16
2026-04-28 21:43:58 +08:00
matevip
69f065e212 fix(llm): support Volcano Ark base URLs and surface friendly errors
- Generalize the OpenAI-compatible chat/models path resolver so any
  baseUrl ending in /v{N} (Ark /v3, Zhipu /v4, ...) drops the duplicate
  /v1 prefix. Volcano Engine test-connection and chat were posting to
  /api/v3/v1/chat/completions and getting 404.
- Replace the six pre-seeded Doubao alias rows (doubao-1.5-*) with five
  valid Ark direct-call ids (doubao-seed-1-8-251228 etc.) and flip
  support_model_discovery=TRUE so users can refresh their account's
  actual catalog. Aliases were marketing names, not API names, so every
  call hit InvalidEndpointOrModel.NotFound.
- Translate Ark business errors into actionable Chinese hints: include
  the response body in the error chain, match ModelNotOpen and
  InvalidEndpointOrModel codes, extract the offending model id, and
  classify them as MODEL_NOT_FOUND so failover skips retries.
2026-04-28 19:26:58 +08:00
matevip
6a3df2a6e0 feat(llm): enabled column for providers + Add Provider drawer
Adds explicit user-intent gating to the provider catalog. Fresh installs
get an empty dropdown by default — built-in cloud + local providers
(OpenAI, Anthropic, Ollama, LM Studio, MLX, llama.cpp, etc.) live in a
new 'Add Provider' drawer until the user opts them in. Existing installs
upgrade conservatively: V55 promotes any provider with evidence of use
(real api_key, OAuth token, recent chat usage, or current default model).

Backend
- V55 migration (H2 + MySQL): adds enabled BOOLEAN DEFAULT FALSE on
  mate_model_provider, plus 4 promote-to-true UPDATE rules. Also
  CREATE INDEX idx_message_runtime_provider_time so the 30-day usage
  lookup doesn't full-scan mate_message on heavy users.
- ModelProviderEntity, ProviderInfoDTO: enabled field.
- ModelProviderService:
    * listProviders() now filters WHERE enabled = TRUE — chat path,
      ModelSelector, Settings/Models main grid see only opted-in rows.
    * listCatalog() new — full catalog (enabled + disabled) for the drawer.
    * setEnabled(id, enabled) flips the flag, publishes
      ModelConfigChangedEvent (re-probe via the existing listener), and
      on disable auto-promotes a replacement default model when the
      disabled provider owned the current default. Returns EnableResult
      so the frontend can fire a toast.
    * createCustomProvider sets enabled=true (user just made the row).
- ProviderInitProbe.listConfiguredProviders also filters enabled=true —
  no point probing rows the user can't see.
- ModelConfigController: GET /catalog, POST /{id}/enable, POST /{id}/disable.
- Plugin-registered ChatModels are unaffected — they live in
  pluginChatModels (in-memory map), don't go through DB listProviders,
  so the enabled filter doesn't strand them.

Frontend
- New types: ProviderInfo.enabled, EnableResult.
- New API: catalog / enableProvider / disableProvider.
- New composable useProviderEnablement: catalog ref, drawerOpen,
  togglingId, loadCatalog, openDrawer / closeDrawer, enableProvider,
  disableProvider (fires defaultSwitchedToast on auto-switch).
- AddProviderDrawer.vue: lazy-loaded, reuses DoctorDrawer's Teleport +
  overlay + slide-in panel pattern. Two groups (cloud / local),
  unenabled rows surface to the top of each group, enabled rows show
  an 'Enabled' badge instead of a button. Mobile: full-screen sheet
  that slides up from below.
- ProviderCard: new 'Disable' button with soft-danger styling on
  enabled providers — soft-hide that keeps the config; user can
  re-enable from the drawer.
- Settings/Models index.vue:
    * Two top CTAs: 'Enable Provider' (drawer) and 'Custom' (existing
      custom-create modal) — distinct workflows, both surfaced.
    * Empty state with prominent 'Enable Provider' CTA when zero
      enabled providers — paired with onMounted auto-open of the
      drawer (sessionStorage guard so closing it doesn't bring it
      back on the next route visit in the same session).
    * Deep-link: ?addProvider=1 query forces the drawer open and
      strips itself after, so a back/forward doesn't re-fire the open.
- ModelSelector: when groups.length === 0 and not searching, show
  'No providers configured -> Configure' CTA linking to
  /settings/models?addProvider=1 — the natural flow when a fresh
  user opens chat before configuring anything.
- i18n: 13 new keys per locale (zh-CN + en-US) plus common.close.

Migration safety
- Conservative default policy: only rows with concrete evidence of
  use are auto-enabled; everything else stays hidden. Upgrade users
  may notice unused built-ins disappearing from their dropdown —
  that's the intended cleanup.
- mate_message index added so the 30-day usage rule doesn't full-scan
  on large installations; FlywayRepairConfig handles redeploy idempotency.

Tests
- ModelProviderServiceEnableTest covers all 7 enable/disable branches:
  flag flip + event publish, no-op on already-{enabled,disabled},
  default-switch when disabled provider owned current default,
  no-switch when default belongs elsewhere, no-replacement returns
  unchanged, getDefaultModel exception path, candidates with no
  models are skipped.
- ProviderInitProbeTest: helper provider() now sets enabled=true so
  the new probe filter doesn't strand existing fixtures.
- vip.mate.llm.** suite: 125 tests green. vue-tsc 0 errors. Browser
  page renders with both new buttons + drawer.
2026-04-28 15:03:40 +08:00
matevip
62b94b522f fix(dingtalk): make inbound images visible to vision model and chat UI
Three knots untangled so an image sent from DingTalk lands in both the
LLM's multimodal prompt and the chat history bubble:

- Prefer MessageContent.downloadCode (universal, used by the new
  api.dingtalk.com messageFiles/download) over pictureDownloadCode
  (legacy oapi field). Sending the legacy code to the new API got
  HTTP 500 unknownError, which was the original 'image not recognized'.
- After fetching bytes, persist to ~/.mateclaw/media/dingtalk/ so vision
  can read via FileSystemResource, AND stuff the same bytes into
  GeneratedFileCache so the UI gets an /api/v1/files/generated/{id} URL
  to render. Without the URL the message bubble showed an empty card.
- Carry filename / contentType / size on the MessageContentPart so the
  chat history doesn't fall back to the 'unknown' caption.

Same treatment applied to the richText branch (inline images from the
PC client) and threaded through the Stream SDK path.

Bundles in the prerequisite ChannelManager wiring of GeneratedFileCache
into DingTalkChannelAdapter and the new DingTalkMediaUploader used by
the outbound attachment flow that this work depends on.

Known limit: GeneratedFileCache TTL is 10 min — fresh refreshes work,
but viewing the image after a JVM restart needs a stable on-disk
serving endpoint, which is intentionally out of scope here.
2026-04-28 14:59:59 +08:00
matevip
c0c642380a feat(llm): provider liveness model + honor requireApiKey on chat path
Phase 1 of the model-module refactor: combine pool / cooldown / probe-
completion signals into a single Liveness state surfaced through the
provider DTO, so the dropdown stops listing providers that are provably
unreachable. Zero schema change; one PR backend + frontend.

Backend
- Liveness enum with five mutually-exclusive states: LIVE, COOLDOWN,
  REMOVED, UNPROBED, UNCONFIGURED. Computed in ModelProviderService
  from AvailableProviderPool / ProviderHealthTracker / ProviderInitProbe
  snapshots batched once per listProviders() call.
- ProviderInitProbe.hasBeenProbed exposes a monotonic Set so the UI
  can distinguish 'still booting' from 'probed and removed' — without
  it the startup window flashes false REMOVED states.
- ProviderInfoDTO gains liveness + unavailableReason +
  cooldownRemainingMs + lastProbedAtMs. The legacy 'available' boolean
  stays but is now derived from liveness == LIVE so the chat fallback
  walker and the dropdown agree about what's usable.
- ProviderInitProbe injected into ModelProviderService via
  ObjectProvider to break the startup cycle (probe already depends on
  the service).

Frontend
- ProviderInfo type extended with liveness + the three detail fields.
- ModelSelector filters UNCONFIGURED + REMOVED out of the dropdown,
  shows COOLDOWN / UNPROBED with a status dot and dimmed rows that the
  user can still click to override.
- ProviderCard renders a five-state badge driven by liveness instead
  of the old configured + pool-entry combo. Reprobe button now keys
  off liveness in {REMOVED, COOLDOWN}.
- useProviders drops loadProviderPool / providerPool — pool data ships
  inline on each ProviderInfo, saves a round trip per page load and
  keeps a single source of truth.
- i18n: 8 new keys across zh-CN and en-US for liveness labels and the
  cooldown countdown tooltips.

Bonus fix (discovered during verification): AgentGraphBuilder.buildOpenAiApi
hard-required a usable API key on every OpenAI-compat provider, ignoring
the per-provider requireApiKey flag. That bug stranded keyless local
runtimes (LM Studio / MLX / llama.cpp) the moment a user actually
launched them; Ollama only worked by accident because its seed row
carries a placeholder string in api_key. keyRequired now honors
requireApiKey, and Spring AI's NoopApiKey is used when no key is needed
so the Authorization header is omitted entirely.

Test
- ModelProviderServiceLivenessTest covers all five Liveness states +
  the probe-bean-absent fallback branch.
- vip.mate.llm.** suite (118 tests) green; vue-tsc clean.
- End-to-end browser sanity: 27 raw providers reduce to 6 LIVE groups
  in the chat dropdown; LM Studio / MLX / llama.cpp render REMOVED red
  badges with reprobe buttons; cloud providers without keys show
  UNCONFIGURED.
2026-04-28 14:59:11 +08:00
matevip
5bef83a156 fix(dingtalk): forward voice messages by reading recognition from stream payload
The stream SDK delivers voice messages as ChatbotMessage with msgtype=audio
and the server-side ASR result already filled into MessageContent.recognition
(same shape as WeCom's voice.content). The adapter's handleStreamMessage
only read msg.getText(), which is null for audio events, so the message
landed in handleWebhook with no msgtype, fell through to the default text
branch, found null content, and got dropped at 'Empty message content,
ignoring'. From the user's side: send a voice, nothing happens, no log of
the attempt.

Two surgical edits:
- handleStreamMessage now checks getContent().getRecognition() first; if
  present and non-blank, builds payload {msgtype: audio, audio: {recognition}}
  before falling back to the existing text path. The earlier comment about
  richText being handled inside handleWebhook was wrong — picture and
  richText also need their fields propagated through the payload Map; left
  a TODO for them.
- handleWebhook gains an explicit case 'audio' branch that pulls text out
  of audio.recognition and pushes it onto contentParts.
- ChannelMessage.inputMode now reflects 'voice' when msgtype=audio,
  mirroring feishu's behavior so downstream code (memory-extraction
  filters, voice-themed system prompts) can tell text vs voice turns apart.

No STT call required — DingTalk transcribes server-side and ships text in
the webhook, so this is a 0-network, 0-config fix.
2026-04-28 11:13:13 +08:00
matevip
acf6eccb3a feat(dingtalk): one-click bot creation via OAuth device flow
Mirrors the feishu one-click flow: scan a QR with the DingTalk app,
approve, and the bot's client_id / client_secret get auto-filled instead
of forcing the user through the open-dev console. Saves about seven
manual steps per channel setup.

Backend
- Bump dingtalk-stream from 1.3.5 to 1.3.12. Diff against the classes we
  depend on (OpenDingTalkStreamClient, ChatbotMessage, MessageContent,
  GenericEventListener) is empty — pure point-release bumps, no API churn.
- New DingTalkAppRegistrationService: synchronously runs init + begin
  against /app/registration/{init,begin} on oapi.dingtalk.com to obtain
  the device_code and verification URL, then spawns a daemon worker that
  polls /app/registration/poll every 5s until SUCCESS / FAIL / EXPIRED is
  returned. Sessions evict after 7 minutes, worker has a 6-minute hard
  runtime cap, transient HTTP errors do not terminate the loop. Same
  shape as the feishu service, but written from scratch because the
  dingtalk-stream SDK doesn't wrap this OAuth device flow.
- Two new endpoints under /api/v1/channels/webhook:
  POST /dingtalk/register/begin returns session_id;
  GET  /dingtalk/register/status returns status + qrcode_img (data URI
  PNG, ZXing-encoded from the verification URL, matching the feishu and
  weixin flows). Status surface: waiting / confirmed / expired / denied.

Frontend
- channelApi.dingtalkRegisterBegin / dingtalkRegisterStatus.
- New useDingTalkAppRegister composable, structurally identical to
  useFeishuAppRegister minus the domain argument. Stops polling on
  terminal status, fires onConfirmed with {clientId, clientSecret}.
- ChannelEditModal: dingtalk-register-card rendered when channelType is
  dingtalk, scoped DingTalk blue (#1f79ff) to differentiate from feishu's
  indigo. onConfirmed writes channelConfig.client_id / client_secret so
  the existing form fields update reactively.
- i18n: channels.dingtalkRegister.* keys for title / hint / button states
  / scan / confirmed / expired / denied / startFailed.
2026-04-28 11:12:22 +08:00
matevip
a27898507c feat(feishu): one-click app creation via official SDK device-flow registration
Saves the user the entire 'go to the open platform -> create an enterprise
app -> copy App ID and Secret' detour. Click a button in the channel form,
scan the QR code, confirm authorization, credentials are auto-filled.

Backend
- Bump com.larksuite.oapi:oapi-sdk from 2.5.3 to 2.6.1, which adds the
  scene/registration package wrapping the device-code flow.
- New FeishuAppRegistrationService: each begin() creates a sessionId,
  spawns a worker thread, runs the SDK's blocking RegisterApp.register
  with onQRCode and onStatusChange wired into a per-session state machine
  (PENDING -> WAITING -> CONFIRMED / EXPIRED / DENIED / ERROR). The
  session caches the QR data URI so ZXing only encodes once per attempt.
  Sessions evict after 5 minutes so closed browsers don't leak the map.
- Two new webhook endpoints under /api/v1/channels/webhook/feishu:
  POST /register/begin returns session_id, GET /register/status returns
  status + qrcode_img (data URI base64 PNG, ZXing-encoded from the SDK's
  verification URL — the raw URL would render as a broken image, so the
  encoding step matches the WeCom flow).
- SDK detail caught the hard way: don't pass .domain() or .larkDomain().
  The SDK defaults are accounts.feishu.cn / accounts.larksuite.com (the
  registration endpoints). open.feishu.cn is the open-API endpoint, a
  completely different service. Passing the wrong one makes the SDK parse
  HTML as JSON and emit invalid_response.

Frontend
- channelApi: feishuRegisterBegin / feishuRegisterStatus.
- New useFeishuAppRegister composable: state machine that begins the
  session, polls status every 2s, prefers qrcode_img over qrcode_url for
  the <img> src, stops on terminal status, fires onConfirmed with
  {appId, appSecret}.
- ChannelEditModal: a new feishu-register-card above the wecom one. The
  composable's onConfirmed writes channelConfig.app_id / app_secret, so
  the existing form fields update reactively.
- i18n: channels.feishuRegister.* keys for title / hint / button states /
  scan / confirmed / expired / denied / error.
2026-04-28 11:11:36 +08:00
matevip
b982d4a2d0 feat(feishu): default connection to WebSocket and hide webhook UI when unused
Backend (FeishuChannelAdapter):
- Default connection_mode flips webhook -> websocket on doStart and doReconnect.
- Stale event filter: drop events whose message.create_time is older than
  stale_event_threshold_seconds (default 30s) so SDK reconnect replays do not
  re-trigger the agent.
- Silent disconnect watchdog runs every 60s; if no events arrive for
  silent_disconnect_threshold_seconds (default 1800s) after the first event,
  call onDisconnected to force a reconnect cycle. Setting the threshold to 0
  disables the watchdog. The watchdog is scheduled before wsClient.start() on
  the bring-up path because that call blocks indefinitely.
- Quoted message context: when a reply has parent_id set, fetch the parent
  via GET /open-apis/im/v1/messages/{id}, summarize per msg_type (text / post
  first paragraph / [Image]/[File]/[Audio]/[Video] placeholders, capped at
  200 chars), and prepend [Quoted: ...] to both content text and the first
  content part. LRU-cached (200) per message_id.
- AbstractChannelAdapter gains getConfigLong helper for numeric config keys.

Frontend:
- types/index.ts feishu fields: default connection_mode is websocket; the
  recommended option moves to the top; verification_token and encrypt_key
  get showIf so they only render in webhook mode; new enable_quoted_context
  switch (default on) exposes the quoted-message feature.
- ChannelEditModal builds a feishu-specific WEBHOOK_GUIDES path that picks
  webhookStep vs websocketStep based on connection_mode, so users only see
  steps for the mode they're using.
- i18n: split feishu.step3/step4 into webhookStep/websocketStep, rename
  step5 to permissionStep. Channel type labels in zh-CN drop bilingual
  prefix (e.g. 'Feishu / Lark (飞书)' -> '飞书').

Migrations:
- V52 was a no-op the first time it ran (matched compact JSON only) and
  Flyway refused to re-run after the SQL was fixed. V52 is documented as a
  no-op; V53 carries the actual UPDATE with REPLACE covering both compact
  and pretty-printed JSON, and an idempotent WHERE for rows already on
  websocket. h2 and mysql variants stay in lockstep.
2026-04-28 11:09:17 +08:00
matevip
5b24a599ca fix(agent): resolve agent tool bindings by class/bean/function name aliases (#24)
Issue #24: tools selected in the agent binding UI had no effect at runtime.
mate_tool.name stores the Java class name (e.g. "BrowserUseTool") and was
written into mate_agent_tool.tool_name, but AgentToolSet.withAllowedToolsOnly
matched by the @Tool function name (e.g. "browser_use") — so every binding
was silently filtered out.

Fix: AgentToolSet builds an alias index per ToolCallback indexed by every
equivalent identifier — function name, Spring bean name, and Java class
simple name. withAllowedToolsOnly / withDeniedToolsFiltered / excluding
all accept any of these aliases, mirroring how Spring's BeanFactory accepts
bean names + aliases.

ToolRegistry.getEnabledToolSet now threads a bean→beanName resolver into
the new AgentToolSet.fromCallbacks(...) overload. Existing two-arg callers
keep working; tests pass without changes.

Zero data migration: stale mate_agent_tool rows that previously had no
effect now resolve correctly via the class-name alias.
2026-04-27 23:51:48 +08:00
matevip
e64752a830 fix(approval): unify tool-approval state machine across DB / message metadata / memory
- Reconcile approval status atomically: DB row, message metadata, in-memory store
- Approve and deny both flip the tool-call card + timeline segment to a terminal
  state on the gate message — no more orange spinner stuck after a decision
- Frontend hydrate matches by pendingId and reverse-converges to expired so a
  refresh after server-side timeout / consume clears the banner without restart
- Stop sweep, GC timeout, and JVM restart all close the loop with consistent
  state
- Remove the dead REST /approve endpoint + matching frontend client export so
  there is only one resolve path to maintain
2026-04-27 22:25:27 +08:00
matevip
4898b79d49 fix(agent): strip tool_choice="auto" so strict OpenAI-compatible servers accept the request
Some self-hosted OpenAI-compatible serving frameworks return a 400 Bad Request
with a generic Pydantic "body=None / Field required" error when the outbound
request carries tool_choice="auto" but the server was launched without an
auto-tool-choice opt-in flag. The error message hides the real cause: the
request is rejected at validation time before the body is parsed, so the
upstream client sees only the generic body-missing error.

Per the OpenAI spec, omitting tool_choice when tools is non-empty is
functionally equivalent to "auto" — the server defaults to auto-pick.
Adding a stripAutoToolChoice patcher to the buildOpenAiApi chain:

- changes nothing on compliant servers (OpenAI / DashScope / DeepSeek / Kimi
  default to auto when tools are present)
- unblocks strict OpenAI-compatible self-hosted endpoints

Explicit values other than "auto" ({"none", "required", or a function
descriptor}) are passed through unchanged.

Run on both chatCompletionEntity and chatCompletionStream paths so both
buffered and streaming calls benefit.
2026-04-27 20:35:24 +08:00
matevip
03c8584910 fix(channels): resolve issue #19 — non-admin member errors on channel page
Three bugs surfaced when a non-admin workspace member opened the channel
admin page:

- vue-i18n "Invalid linked format" when '@' appeared in message strings
  without the linked-format escape. Replaced literal '@' with vue-i18n v9
  literal interpolation {'@'} in both zh-CN.ts and en-US.ts (6 strings:
  QQ guide step3, accessControl requireMention/Tooltip).

- 403 from WorkspaceAccessInterceptor was being treated as 401 by the
  axios interceptor and the chat SSE handler, clearing the token and
  redirecting to /login. Split the two:
    * 401 = authentication failure  -> handleAuthFailure (logout)
    * 403 = authorization failure   -> keep session, surface to caller
  Now a member who lacks workspace permission sees a toast instead of
  being silently logged out.

- Two backend exception sites threw with the default code=500 for what
  is semantically an auth/authz event, contradicting the codes returned
  elsewhere for the same business event:
    * AuthService.login() bad credentials  500 -> 401
    * WorkspaceService.requirePermission() 500 -> 403
  This aligns service-layer denials with SecurityConfig (401 for missing
  JWT) and WorkspaceAccessInterceptor (403 for permission denied), so
  the same business event always produces the same code.
2026-04-27 19:31:46 +08:00
matevip
2f93d53737 refactor(approval): unify state machine across DB/metadata/memory
Foundation for the ghost-approval root-cause fix.

Adds ResolveOutcome / MetadataDecision; rewrites ApprovalWorkflowService so
every resolve / consume / timeout / supersede transitions through one
two-phase contract: snapshot → DB UPDATE conditional on status=PENDING →
metadata reconciliation → afterCommit memory mutation. ChatController,
ChannelMessageRouter, and ApprovalController all switch to the workflow;
ApprovalService.resolve / resolveAndConsume / consumeApproved /
cancelStalePending / denyAllByConversation are physically removed so
DB-bypass is no longer reachable at compile time.

Specific fixes:
- recoverFromDb preserves DB pendingId + createdAt (was generating fresh
  random ids, breaking every later DB sync)
- effectiveExpireAt = expireAt ?? createdAt + PENDING_TTL: legacy rows
  with NULL expireAt no longer resurrect as live PENDING after restart
- markPendingApprovalsResolved flips pendingApproval.status + currentPhase
  + MessageEntity.status atomically (was only flipping the first field;
  message.status uses existing completed/stopped, not approved/denied,
  to stay within the frontend Message.status union)
- GC scheduler moves to ApprovalWorkflowService; timeouts and overflow
  evictions now sync DB + metadata + memory through markTimeout
- DB UPDATE rows=0 returns alreadyResolved (concurrent-resolve safe);
  exception propagates so @Transactional rolls back; memory stays untouched
- expireRecoveredRow gates metadata write on DB success (was writing
  metadata even when DB update failed, producing the worst-case ghost)
- Mockito JDK 21 agent attach fixed via maven-dependency-plugin properties
  + surefire argLine (no more flaky self-attach across machines)

Tests: 34 new across 4 classes (recovery, resolve, GC, metadata sync).
Full suite: 788 / 788.
2026-04-27 19:30:52 +08:00
matevip
349f4d7d3c refactor(bootstrap): drop legacy tools-sync.sql in favor of per-tool Flyway migrations
The two tools-sync scripts ran on every startup and used H2 MERGE INTO
... KEY(id), which overwrites every column on existing rows. That
silently reverted UI-toggled `enabled` and was the proximate cause of
a recent WriteFileTool/EditFileTool outage.

They were also a strict subset of the fresh-install seed (data-zh.sql /
data-en.sql register all 19 builtins; the sync scripts only 16) and out
of date. Per-tool Flyway migrations (V3, V31) are already the canonical
'register a new builtin' path, so the sync layer was duplicated and
error-prone.

Delete both files and the runToolSyncScript() loader. Tool descriptions
shown to the LLM come from @Tool annotations in code, not the DB row,
so removing per-startup metadata refresh has no functional impact.
2026-04-27 14:00:08 +08:00
matevip
b4ebab65c7 feat(tool): docx image embedding + multi-file render
Two follow-up improvements on top of renderDocxFromFile so the docx
pipeline can handle real long-form deliverables instead of just
prose-only memos.

Image embedding (P1).
MarkdownDocxRenderer now recognizes single-line ![alt](path) markdown
and embeds the referenced file via POI's XWPFRun.addPicture():
- PNG / JPG / GIF / BMP read straight from disk
- SVG rasterized via Apache Batik (PNGTranscoder, target width 1400px)
  before embedding — OOXML stores raster images, so any vector source
  needs conversion. Batik runs in-JVM, no rsvg-convert / cairo on host.
- Pictures are pinned to roughly the printable page width (≈ 5.77 in
  for A4 minus default 1800-twip margins) and given a 4:3 height
  fallback. Mixing images inline with other paragraph text is not
  supported by design — the markdown subset assumes one image per
  block paragraph. Inline images would require splitting paragraphs
  across runs with explicit positioning, well beyond what this
  renderer covers.
- Failure modes (missing file, unsupported format, Batik blowing up)
  emit an italicised "[image: alt — reason]" placeholder so the rest
  of the document still renders; the agent can read its own log to
  see why the picture didn't make it.
- Adds two transitive deps via pom: batik-transcoder + batik-codec at
  1.18, ~10 MB combined. Worth it given the alternative is shelling
  out to system tooling.

Multi-file render (P2-lite).
New tool renderDocxFromFiles(List<String> filePaths, filename, pageSize)
reads several markdown files in order and renders one combined docx.
Lets the agent split a 30-page proposal into cover.md / ch1.md /
ch2.md / appendix.md and produce a single deliverable in one tool
call. Each path goes through WorkspacePathGuard.validatePath; any
empty or unreadable file aborts with a typed error so the agent
fixes its file list before retrying. Files are joined with a blank
line — no separator markup is injected, headings carry over cleanly.

I deliberately did NOT build the heavier mutable-docx state
("appendDocxChapter / finalizeDocx") flavor of P2: the multi-file
form covers the same workflow with no per-conversation state to
clean up, and the agent can iterate by rewriting the chapter file
and re-running the tool. Stateful append can come later if a
streaming use case actually shows up.

renderDocx and renderDocxFromFile @Tool descriptions updated to point
the agent at renderDocxFromFile for >5 KB markdown and to advertise
the new image-embedding capability.
2026-04-27 08:42:03 +08:00
matevip
9ed9ee6ca7 feat(tool): add renderDocxFromFile to bypass LLM token cost on large markdown
renderDocx requires the markdown body to flow through the LLM as a
tool argument. For an 80 KB project proposal that's ≈ 20 K tokens of
streaming output spent just to repeat back content the model already
wrote to disk a turn earlier — multi-minute generation, real money.

renderDocxFromFile takes a file path instead. The agent uses
write_file / edit_file to assemble the markdown locally, then calls
this tool with just the path. JVM reads the file in one IO syscall
and feeds it to the existing MarkdownDocxRenderer. Token cost drops
from ≈ 20 K to ≈ 50 (the path string).

Behavior:
- Path resolution honors WorkspacePathGuard, same boundary as
  read_file / write_file. No path traversal.
- UTF-8 read; rejects empty / missing / non-regular paths with
  typed error messages so the agent can recover.
- Output cached in GeneratedFileCache and returned as a relative
  /api/v1/files/generated/{id} link, with the same anti-host-
  hallucination instruction renderDocx already carries.
- Same supported markdown subset (headings, bold, lists, tables).
  Image references (![alt](path)) still render as raw text — full
  image embedding (P1) and SVG → PNG conversion (also P1) need
  Apache Batik plus image-rendering plumbing in MarkdownDocxRenderer
  and is tracked separately. Chapter-mode merge (P2) likewise needs
  its own plumbing.

The @Tool description tells the agent to prefer this path when
markdown exceeds ~5 KB and shows the full write_file →
renderDocxFromFile workflow inline.
2026-04-27 08:36:37 +08:00
matevip
cc3c9a8618 fix(ux): preserve in-flight turn on tab switch + raise max_iterations cap to 100
Three small but high-impact fixes that all surfaced together while
verifying the long-form generation flow.

1. ChatConsole onBeforeUnmount no longer kills the backend turn.
   Previously, switching tabs / route navigation / any cause that
   unmounted the chat view called stopChatGeneration(), which POSTs
   /chat/{cid}/stop and aborts the in-flight LLM call. The user
   reported a turn dying mid-generation just from switching pages.
   Replaced with resetForNewConversation() — front-end SSE disconnect
   only, no /stop. Backend keeps running; pollActivity / status probe
   reconnects on return. Aligns with the existing comment in
   selectConversation: "let A's backend agent run continue running."

2. Agent max_iterations raised 25 → 100 with a hard ceiling.
   The previous 25-step ceiling caused LimitExceededNode to fire on
   substantive multi-tool tasks (document generation + image conversion
   + retry loops). 100 matches QwenPaw's _MAX_MAX_ITERATIONS upper
   bound. New plumbing:
   - BaseAgent.MAX_ITERATIONS_HARD_CEILING = 100 public constant
   - BaseAgent default field 25 → 100 (Java-side fallback)
   - AgentGraphBuilder clamps any per-agent DB override to the
     ceiling at runtime; if the row holds 200, runtime sees 100 and
     a WARN is logged with the original value.
   - V47 migration (h2 + mysql) idempotently bumps the three default
     seeded agents (1000000001, 1000000002, 1000000003) only if they
     still hold the old defaults (25 / 20). User-customized values
     are not touched.
   - data-en/zh/-mysql-en/-mysql-zh seed files updated to 100 for
     fresh installs.

3. DocxRenderTool tells the LLM not to prepend a host to the URL.
   DeepSeek and Claude have both been observed wrapping the
   /api/v1/files/generated/{id} relative path returned by renderDocx
   into an absolute URL with a hallucinated domain (e.g.
   https://ai-tools-system.com/...), breaking the download link in
   the rendered chat bubble. The tool's return string now appends an
   explicit "must use the relative path verbatim, do not add any
   https:// or http:// prefix" instruction, which Claude and
   DeepSeek both honor.
2026-04-27 08:17:17 +08:00
matevip
0476447ab6 fix(agent): persist mid-turn narrative, queue follow-ups without dispose, flush on shutdown
A bundle of stability fixes that all surfaced together while running
the same long-form generation task across multiple turns. Each one
addresses a distinct way the previous behavior silently dropped
content the user had already seen on screen.

1. Mid-turn narrative persistence (StateGraphReActAgent +
   SummarizingNode). Intermediate ReasoningNode rounds and
   SummarizingNode broadcast their content_delta directly to the
   SSE channel for live display, but the StreamAccumulator only
   received the final answer. After refresh the assistant message
   showed only tool_call cards with no body text.
   StateGraphReActAgent now also forwards STREAMED_CONTENT (already
   set per round) as a persistOnly StreamDelta whenever it changes,
   so every narrative chunk lands in the accumulator's content
   buffer and gets written to mate_message. SummarizingNode now
   writes its summary into the same key so summarize narratives
   persist too.

2. Follow-up message queue, not dispose (ChatController#interruptStream).
   Sending a new message while a turn was running called
   requestInterrupt, which dispose()d the active Reactor chain mid
   LLM call. That cancelled the in-flight generation, lost partial
   tokens, and left the user staring at a half-finished bubble.
   The endpoint now uses enqueueMessage in all paths, matching
   the "wait for current turn, then run" behavior. The old
   requestInterrupt API is kept for any future force-replace UI
   but no caller routes to it.

3. Queued user message ordering (ChatStreamTracker.QueuedInput +
   ChatController.startQueuedMessage). interruptStream used to save
   the queued user message immediately, before the in-flight
   assistant message finalized in doOnError. listMessages orders
   by create_time ASC, so the queued user message ended up above
   the assistant reply it was supposed to follow. QueuedInput now
   carries contentParts; persistence is delayed to startQueuedMessage,
   which runs only after Asst-N is on disk.

4. JVM shutdown flush (ChatStreamTracker @PreDestroy +
   emergencySaveAccumulator). A mvn spring-boot:run restart used to
   wipe in-flight turns: SSE emitter timed out, ShutdownHook fired,
   HikariPool closed before doOnError could save. ChatStreamTracker
   now exposes an emergency-save callback per RunState; ChatController
   registers one per stream that snapshots the accumulator and
   writes status="interrupted_shutdown". @PreDestroy walks active
   runs, invokes the callback, then disposes. Spring's reverse-order
   bean teardown keeps ConversationService and Hikari alive long
   enough for the save to complete.

5. Observation thresholds for summarize (GraphObservationProperties +
   application.yml). The previous total-chars threshold of 12 KB
   triggered summarize after one or two RFC reads, costing a 40 to
   80 second compaction LLM call per loop. Tuned to: total 200 KB,
   single 16 KB, large-result 32 KB, rounds safety net 25. Java
   field defaults reverted to the conservative original values so
   application.yml stays the source of truth.

6. Frontend thinking segmentation (useChat.ts thinking_delta +
   phase). Multi-round ReAct turns merged every reasoning + summarize
   round's thinking into one segment, accumulating to 9 KB+ in a
   single bubble. thinking_delta now uses findLast(running) so a
   tool_call_started or phase transition closes the previous segment
   and the next delta opens a fresh one. phase event also closes
   running thinking/content segments.

7. Other small things bundled: removed a debug metadata-keys log
   that flooded the log file with one line per stream chunk; fixed
   three stale tests that didn't compile after earlier constructor
   changes (WikiLogServiceTest, WikiOverviewSpliceTest,
   WikiProcessingServiceLazyTest); added rfc-066 documenting the
   unified message queue + priority refactor as the next logical
   step on top of these stabilizations.

Verified end-to-end with multiple full sessions: a four-minute
generation that produced the expected docx and a follow-up enqueue
that ran cleanly after the previous turn naturally completed,
without the old "Disposable unavailable" interrupt path.
2026-04-27 07:51:49 +08:00
matevip
941653d185 fix(agent): also drop the queue guard in doOnError path
Same bug as the prior queue-drop fix in doOnComplete, but in the
sister branch that fires when the agent's reactive stream errors
out (CancellationException from a user stop). The guard

  cr.queuedInput() != null && !(isUserStop && !isInterruptFollowup)

mis-classified "user stopped, no interrupt-with-followup, but a
message is in the queue" as an explicit abort and silently dropped
the freshly-typed follow-up.

The frontend's enqueue path never sets interruptType — it just
calls requestStop + offers to messageQueue. Whoever puts a message
in the queue means it; just run it. Aligns with doOnComplete and
the four other queue-launch sites in this controller.
2026-04-27 07:51:18 +08:00
matevip
fcdb3fc15e fix(agent): break self-replicating 400, narration, args truncation, queue drop
A series of cross-cutting stability fixes that surfaced together
during a long debugging session.

reasoning_content / Claude prefill self-replicating 400:

- ChatController persists typed errors (content starts with '[错误] ')
  with status='error', so the failure text stops being re-sent as
  multi-turn context — DeepSeek thinking 400 ('reasoning_content
  must be passed back') and Claude 400 ('does not support assistant
  message prefill') used to recursively re-create themselves every
  retry by polluting history.
- BaseAgent.sanitizeForLlm filters status='error' / '[错误] ' prefix
  assistant messages from history before LLM dispatch.
- BaseAgent.fetchHistoryMessages defensively drops trailing
  AssistantMessages — Claude rejects assistant-tail prompts.
- NodeStreamingChatHelper.dropTrailingAssistant runs the same
  defense at every doStreamCall pre-egress, so the in-turn
  summarizing→reasoning transition (which leaves an assistant
  scaffold at the tail) doesn't trip Claude either.
- AgentGraphBuilder.FallbackPolicy.DEEPSEEK switched (null,true,true)
  → (' ',false,true), aligning with KIMI/OPENAI's tolerant ' '
  fallback. The previous 'force explicit 400' design was the
  self-replicating loop's prime mover.

narration + tool args truncation:

- ReasoningNode.DEFAULT_MAX_OUTPUT_TOKENS 4096 → 16384. The 4k cap
  was decapitating renderDocx tool_call args mid-stream when the
  model emitted a long content field on top of thinking content;
  the resulting 'invalid JSON' aborted execution silently.
- ReasoningNode appends a hermes-style TOOL_USE_ENFORCEMENT clause
  to every system prompt: 'when you say you will perform an action,
  call the tool now in the same response — narration is a protocol
  violation'. Treats 'now I will generate the docx' (and never
  actually calling renderDocx) as a forbidden pattern.
- ToolExecutionExecutor.normalizeToolExecutionError reframes the
  JSON-truncated error as actionable instructions: 're-call the
  same tool now with shorter content or split into multiple
  sequential calls; do NOT describe the result as text'.

side fixes from the same evening:

- ChatController doOnComplete skips completionPublisher.publish
  when isError=true, keeping memory extraction off the garbage path.
- ChatController doOnComplete queued-message guard simplified to
  'cr.queuedInput() != null', matching the other 4 sites in the
  controller. The previous 'isInterruptFollowup || !wasStopped'
  guard silently dropped queued messages when the user did
  Stop-then-Enqueue (wasStopped=true && interruptType=null), losing
  the freshly-typed follow-up message.
- prompts/graph/summarize-system.txt now distinguishes 'single
  task' (default; output one cohesive summary) from 'multiple
  independent sub-tasks' (use the子任务 N format). Stops the
  summarizer from inventing '子任务 1: PRO-027' decomposition for
  unitary requests like 'write me a project proposal'.
2026-04-27 07:51:01 +08:00
matevip
187197e804 fix(sse): preserve done event for late reconnect window 2026-04-27 07:50:35 +08:00
matevip
4a15027a98 feat(wiki): download original raw material file 2026-04-26 20:46:52 +08:00
matevip
0d78beb44f fix(wiki): batch-create per-slug retry — recover unparseable JSON, bump to 2 attempts 2026-04-26 20:37:09 +08:00
matevip
76956cf990 fix(tool): read_file falls back to chat-upload attachment by basename 2026-04-26 20:24:00 +08:00
matevip
30e7e67bb6 feat(wiki): LLM-narrated overview section with debounced regen + Recent Updates list + scaffold self-heal 2026-04-26 19:53:12 +08:00
matevip
e2df16893e fix(wiki): smaller batch-create + resume button for partial generation 2026-04-26 18:42:27 +08:00
matevip
b7c911f01d feat(stt): DashScope realtime voice + language-aware routing + TalkMode polish
- DashScope paraformer-realtime-v2 WebSocket streaming
- Language-aware provider routing: Whisper for English, Paraformer for Chinese
- PCM WAV recording replaces WebM (provider filename bug + diagnostics)
- TalkMode push-to-talk fixes (audio drop, WS connecting race)
- Vite dev proxy WebSocket upgrade fix
- WebSocket binary buffer 8KB → 8MB (Tomcat default truncated voice clips)
- Audio chunk pacing at 100ms (DashScope returned 0 chars otherwise)
- Resolved language hint propagation + raw frame logging
- V46 seed idempotency fix on UI-toggled STT row
- Diagnostic cleanup after debugging session
2026-04-26 16:37:55 +08:00
matevip
4d7c6593c4 feat(minimax): expand video model catalog + add CN endpoint support 2026-04-26 08:34:35 +08:00
matevip
410c6c28cd feat(deepseek): integrate DeepSeek V4 (flash + pro) with thinking-mode support 2026-04-26 08:34:34 +08:00
matevip
dfb9fc2cac fix(model-catalog): claude-sonnet-4-7 doesn't exist — Sonnet stays at 4.6 2026-04-26 08:34:12 +08:00
matevip
b9c4f40028 refactor(anthropic): cleanup — deduplicate diagnostic statics, remove dead cache-options code 2026-04-26 08:34:12 +08:00
matevip
dbdb585eed fix(anthropic): rewrite system field to array to pass OAuth anti-abuse gate 2026-04-26 08:34:12 +08:00
matevip
5c2482c307 fix(anthropic): log outgoing request headers on 429 2026-04-26 08:34:12 +08:00
matevip
ed3ff54f0c fix(anthropic): drop (external, cli) UA suffix — it's the anti-abuse fingerprint 2026-04-26 08:34:11 +08:00
matevip
84cb442446 fix(anthropic): log anthropic-ratelimit-* headers on 429 2026-04-26 08:34:11 +08:00
matevip
aabf2b8c32 fix(anthropic): add anthropic-dangerous-direct-browser-access + accept headers 2026-04-26 08:34:11 +08:00
matevip
ae6467a5dc fix(anthropic): bidirectional mcp_ tool-name prefix on OAuth requests 2026-04-26 08:34:10 +08:00
matevip
44548e3010 fix(anthropic): inject Claude Code identity into system prompt 2026-04-26 08:34:10 +08:00
matevip
1d5bb58e9b fix(anthropic): allow ANTHROPIC_CLAUDE_CODE in StateGraph whitelist 2026-04-26 08:34:09 +08:00
matevip
fb4c013ad8 feat(anthropic): surface Claude Code OAuth in admin UI 2026-04-26 08:34:09 +08:00
matevip
a7938b0e68 feat(anthropic): wire Claude Code OAuth into chat model 2026-04-26 08:34:08 +08:00
matevip
8539fb9407 feat(anthropic): Claude Code OAuth credential plumbing 2026-04-26 08:34:08 +08:00
matevip
9187aed273 fix(oauth): support remote-server deployment via MANUAL_PASTE flow 2026-04-26 08:34:08 +08:00
matevip
23a6d16778 feat(model-catalog): add Claude 4.7 + GPT-5.5 sampling-params handling 2026-04-26 08:32:45 +08:00
matevip
fac5ff2838 feat(image-gen): add gpt-image-2 to OpenAiImageProvider 2026-04-26 08:32:44 +08:00
matevip
3f10553186 fix(sse): distinguish stream_not_local vs completed on reconnect 2026-04-26 08:32:44 +08:00
matevip
0b55d5a227 feat(agent): Utf8SseEmitter + returnDirect end-to-end chain test 2026-04-26 08:32:44 +08:00
matevip
4a95e7dfe4 feat(tool): tool returnDirect and sensitive-data quarantine 2026-04-25 19:02:35 +08:00
matevip
c13d9b4c88 feat(wiki): expose method=tika short-circuit on extract_document_text 2026-04-25 19:02:35 +08:00
matevip
c752c1f2ae feat(wiki): Tika as last-resort document extractor 2026-04-25 19:02:34 +08:00
matevip
6474d0e6be feat(wiki): normalized relation boost + reason in search results 2026-04-25 19:02:34 +08:00
matevip
a1e40d6eae feat(wiki): enrich batch — N pages per LLM call 2026-04-25 19:02:34 +08:00
matevip
ca4c447250 feat(wiki): enrich prompt knows what's already linked 2026-04-25 19:02:34 +08:00
matevip
8ef523f953 feat(wiki): archived pages drawer in Wiki UI 2026-04-25 19:02:33 +08:00
matevip
51566a47a4 chore(wiki): externalize compile prompts; doc archive tools + admin endpoints 2026-04-25 19:02:33 +08:00
matevip
58b49f6e20 feat(wiki): structured no-evidence compile + ops admin endpoints 2026-04-25 19:02:33 +08:00
matevip
5206d65be7 fix(wiki): eager 0-pages = partial when chunks indexed; per-KB structured route; archived filter completion 2026-04-25 19:02:33 +08:00
matevip
3f25064ef9 fix(wiki): cancel in-flight LLM work when raw is deleted 2026-04-25 19:02:32 +08:00
matevip
1e62dbad47 feat(wiki): PR-7 archived soft-archive 2026-04-25 19:02:32 +08:00
matevip
850d59c04f feat(wiki): PR-6b structured-output route phase (opt-in) 2026-04-25 19:02:32 +08:00
matevip
c8af19cae2 feat(wiki): PR-2b/2c overview rebuilder + activity log 2026-04-25 19:02:31 +08:00
matevip
f4d4e973df feat(wiki): PR-5b enrichment via replacement plan 2026-04-25 19:02:31 +08:00
matevip
9c59092d9c feat(wiki): PR-6 skeleton — DTOs for structured eager output 2026-04-25 09:56:19 +08:00
matevip
ec0aaf7da6 feat(wiki): PR-5 wikilink alias parsing + relation seed filter 2026-04-25 09:56:19 +08:00
matevip
b41496ed46 feat(wiki): PR-4 on-demand compile + multi-page read tools 2026-04-25 09:56:19 +08:00
matevip
e4818a8ee2 feat(wiki): PR-3 eager pipeline honors per-step model config 2026-04-25 09:56:19 +08:00
matevip
1281153aa8 feat(wiki): PR-2 system pages — overview/log scaffold + locked + filters 2026-04-25 09:56:18 +08:00
matevip
9746271ea5 feat(wiki): PR-1c preprocessor + chunk metadata + search exposure 2026-04-25 09:56:18 +08:00
matevip
80725c9ac7 feat(wiki): PR-1b lazy ingest — chunk+embed, no page generation 2026-04-25 09:56:18 +08:00
matevip
50d9ff2b3d feat(wiki): PR-1a infra — content hash split, chunk metadata columns, kb-default model 2026-04-25 09:56:17 +08:00
matevip
7b038522aa fix(skill): also accept Spring bean names as tool-dep identifiers 2026-04-24 23:24:52 +08:00
matevip
4c861006dc fix(skill): resolve tool deps by runtime function name, not class/bean name 2026-04-24 23:24:34 +08:00
matevip
52a9a785c1 fix(search): bundled SearXNG sidecar actually works out of the box 2026-04-24 22:08:42 +08:00
matevip
d17b06f454 fix(browser): serialize diagnose findings manually; Hutool cannot reflect on records 2026-04-24 21:38:25 +08:00
matevip
83567e95f0 fix(browser): multi-strategy launcher + self-diagnostics for win/linux 2026-04-24 21:37:46 +08:00
matevip
a3289d2780 fix(ui): gate thinking toggle on supportsThinking (broad), not supportsReasoningEffort 2026-04-24 18:16:28 +08:00
matevip
c249dbcb17 feat(llm): expose supportsReasoningEffort on ModelInfoDTO 2026-04-24 18:16:18 +08:00
matevip
84370566de test(agent): cover patchReasoningContent consumer 2026-04-24 18:16:12 +08:00
matevip
72a0b5fc81 feat(search): SEARXNG_BASE_URL env-var fallback and expand wiki chunk column
- docker-compose.yml: pass SEARXNG_BASE_URL into mateclaw-server so the
  app can reach the searxng sidecar container out of the box (default
  http://searxng:8080).
- SystemSettingService: resolveSearxngBaseUrl() now falls back to the
  SEARXNG_BASE_URL env var when no DB value is set, so Docker users no
  longer need to configure it manually in the UI.
- V38 migration (h2 + mysql): expand mate_wiki_chunk.content from TEXT
  (64KB) to MEDIUMTEXT (16MB) so large Chinese chunks (~30k chars
  ≈ 90KB UTF-8) no longer overflow.
2026-04-24 13:48:39 +08:00
matevip
27c4c3e5e2 feat(wiki): config UI overhaul — model strategy, search preview modal, graph fullscreen 2026-04-24 10:03:45 +08:00
matevip
4f67e31887 fix(wiki): eliminate per-chunk duplicate updates and fix token overflow 2026-04-24 06:55:21 +08:00
matevip
d04d90dfc5 feat(wiki): grouped page list, pageCount on raw materials, frosted-glass UI 2026-04-24 06:55:21 +08:00
matevip
c50977785a fix(wiki): internal link navigation and source citation guidance 2026-04-24 06:55:20 +08:00
matevip
4be867a3e6 feat(wiki): ingest optimization — BatchCreate, document analysis, retry 2026-04-24 06:55:20 +08:00
matevip
58ec60a5b8 feat(skill-market): bilingual skill display names (nameZh / nameEn) 2026-04-24 06:55:20 +08:00
matevip
a8f4236d90 fix(pagination): auto-detect DbType for correct total counts on MySQL 2026-04-24 06:55:19 +08:00
matevip
af8c2fe6a9 feat(skill-market): security scan visibility, rescan action, pagination fix 2026-04-24 06:55:19 +08:00
matevip
aa6e2b6afe feat(skill-market): paginated skill list with search and frosted-glass UI 2026-04-24 06:55:19 +08:00
matevip
1073890e64 feat(skill): BuiltinSkillSeedService — close SQL/SKILL.md double-write 2026-04-24 06:55:18 +08:00
matevip
edaf762878 feat(tool): native Java DocxRender tool — eliminate Node.js subprocess 2026-04-23 16:31:13 +08:00
matevip
9740d46fbc fix(delegate): distinguish outcome/blank/rawLength in parallel delegation, translate all comments to English 2026-04-23 08:09:48 +08:00
matevip
9632edb008 fix(webchat): persist assistant reply and publish memory event on stream end 2026-04-23 08:09:48 +08:00
matevip
869e0c47e6 refactor(memory): unify ConversationCompletedEvent publish 2026-04-23 08:09:48 +08:00
matevip
2e15369465 fix(delegate): fix parallel timeout + add real-time per-child visibility 2026-04-23 08:09:48 +08:00
matevip
aed905efb7 feat(agent): implement Lane E — JDK 21 virtual threads, Spring AI observability, BeanOutputConverter 2026-04-22 21:00:40 +08:00
matevip
320e13b975 fix(agent): review fixes for Lane D — D-2 strategy split, D-4 naming, D-5 docs, D-6 instrumentation 2026-04-22 10:13:13 +08:00
matevip
23133ea45d perf(agent): implement Lane D performance fixes 2026-04-22 10:13:07 +08:00
matevip
f8c7e5271b fix(embedding): skip unconfigured provider in embedding model resolution 2026-04-22 10:12:57 +08:00
matevip
bc002fd302 fix(delegate): address P2 review findings for multi-agent delegation 2026-04-22 10:12:52 +08:00
matevip
11fa7487d0 fix(delegate): reliability patches for multi-agent delegation 2026-04-22 10:12:48 +08:00
matevip
d8f008e427 fix(embedding): skip unconfigured provider in embedding model resolution 2026-04-22 05:08:21 +08:00
matevip
639d1c80d4 fix(delegate): address P2 review findings for multi-agent delegation 2026-04-22 05:08:15 +08:00
matevip
8762a79ec9 fix(delegate): reliability patches for multi-agent delegation 2026-04-22 05:08:08 +08:00
matevip
2eebdf2a47 fix(memory): HiL edit uses exact key match, not substring contains 2026-04-21 17:34:34 +08:00
matevip
b02f2ebfee fix(memory): HiL edit binds key to report's candidate entries 2026-04-21 17:34:28 +08:00
matevip
be9dfdf727 fix(memory): HiL edit validates key exists in MEMORY.md sections 2026-04-21 17:34:22 +08:00
matevip
e69aa2be04 fix(memory): P2 review fixes — API boundaries + identity + experimental flag 2026-04-21 17:34:15 +08:00
matevip
84c8f8f9a0 fix(memory): P1 review fixes — close 4 semantic gaps in data truth layer 2026-04-21 17:34:10 +08:00
matevip
0351cc369e feat(memory): memory audit fixes — 4 missing items 2026-04-21 15:28:26 +08:00
matevip
0a776f96fd feat(memory): batch 1 — 4 core fact projection fixes 2026-04-21 15:28:09 +08:00
matevip
c252cf50a4 docs: update README title and tagline 2026-04-21 09:27:42 +08:00
matevip
eece5e96f5 feat(memory): dream-v2 E3-E5 — Forget + Contradictions + Feedback API 2026-04-21 04:58:57 +08:00
matevip
d983a1e02e feat(memory): dream-v2 E2 — Fact query tools + FactMemoryProvider 2026-04-21 04:58:52 +08:00
matevip
acc6f448db feat(memory): dream-v2 E1 — Fact Projection foundation 2026-04-21 04:58:47 +08:00
matevip
bf4cebb7b3 feat(memory): dream-v2 D3 — Diff viewer + SSE + Focused Dream dialog 2026-04-21 04:58:43 +08:00
matevip
8ecc6d10ca feat(memory): dream-v2 D2 — Morning Card + HiL (Confirm/Edit) 2026-04-21 04:58:33 +08:00
matevip
90067d1c9f feat(memory): dream-v2 D1 — Memory Timeline view (frontend + backend) 2026-04-21 04:58:26 +08:00
matevip
155bab1739 fix(llm): skip unconfigured provider when resolving default model 2026-04-20 21:50:01 +08:00
matevip
70c90d814d feat(memory): Dream v2 Phase 1 engine — consolidate refactor, focused endpoint, monthly archive
Five-commit bundle brings the Dream v2 P1 engine layer online, sitting
on top of the lifecycle mediator foundation already merged.

B.1-B.4 · Schema + records
- Flyway V26 (dream_report) + V27 (memory_recall review fields),
  both h2 and mysql
- DreamReportEntity + DreamMode + DreamStatus enum + record types
- DreamReportMapper repository layer

B.5-B.8 · Consolidate refactor + focused dream
- MemoryEmergenceService refactored for plug-in dream modes
- MemoryRecallService extended with promoted/rejected review fields
- Focused dream endpoint + prompt template
- MemoryController exposes the review/trigger surface

B.9-B.10 · Monthly archive service
- MemoryArchiveService rolls cold promoted entries into archival rows
  and reclaims daily_count storage
- DreamingScheduler runs archive job on its own schedule

B.12-B.14 · Tests
- MemoryArchiveServiceTest
- DreamFlagGuardTest
- DreamV2AcceptanceIT (end-to-end acceptance under feature flag)

Plus a verification script + HTTP e2e kit in the private test/ dir,
used for local staged rollout — not part of the open-source
distribution.

All features stay gated behind the mate.memory.dream.* flags from
Phase 1. Enable per-phase after staging validation.
2026-04-20 20:21:03 +08:00
matevip
907c6eff8c fix(memory): add success-path debug logs to MemoryLifecycleMediator
beforeLlmCall / afterLlmCall / onSessionEnd only logged on failure,
making flag on/off indistinguishable in logs. Add debug lines on the
success path so lifecycle activation is observable.
2026-04-20 17:34:40 +08:00
matevip
74928d615d feat(memory): Dream v2 Phase 1 — lifecycle mediator foundation
Wire memory-facing events (turn-started, turn-completed, session-ended,
memory-written) through a single MemoryLifecycleMediator so
MemoryProvider implementations can hook into the agent conversational
flow without spreading side-effects across the runtime.

Ten atomic steps shipped under feat/dream-v2-p1-lifecycle:

- A.1 + A.2: MemoryLifecycleMediator class + TurnContext value object
- A.3: TurnStartedEvent / TurnCompletedEvent domain events
- A.4: MemoryLifecycleEventListener bean for Spring event plumbing
- A.5: MemoryProvider.onMemoryWrite default method (backward compatible)
- A.7: wire the mediator into AgentService at the right hook points
- A.8: LifecycleFlagGuardTest — feature flag must gate every hook
- A.9: MemoryLifecycleMediatorTest — unit coverage per hook
- A.10: LifecycleRecallCountIT — F4 regression across the stack

Feature flags (all default OFF; enable per phase after staging):
- mate.memory.lifecycle-mediator-enabled
- mate.memory.dream.focused-enabled
- mate.memory.dream.archive-enabled

This is Phase 1 foundation only — focused-dream and archive-dream
providers arrive in later phases.
2026-04-20 17:31:21 +08:00
matevip
0301d5628e fix(wiki): JobStageBar stuck at queued — add job stage transitions
Root cause: processRawMaterial() created a job record at queued stage
but never called jobService.transition() during processing. The job row
stayed at queued forever, so the stage bar never advanced.

Backend (WikiProcessingService):
- Transition job to ROUTING immediately after creation
- Transition to PHASE_A_RUNNING before chunk processing begins
- Transition to COMPLETED/PARTIAL/FAILED at the end based on finalStatus
- Transition to FAILED in the catch block on unhandled exceptions

Backend (WikiProcessingJobService.transition):
- Handle FAILED, PARTIAL terminal stages (set finishedAt + status)
- Handle non-terminal intermediate stages (set status to running)

Frontend (JobStageBar.vue):
- Add stageMapping for backend stages not shown as dots: phase_a_done →
  phase_b_running, failed/partial/cancelled → completed position
- Guard stageIndex() against -1 (unknown stages default to all-pending)
- Terminal failure states show red failed dot instead of pulsing active
2026-04-19 20:53:35 +08:00
matevip
af8f712986 fix(failover): source fallback chain from the pool, not is_default flags
Two related changes that align buildFallbackChain with how users actually
think about failover.

1) Source = configured providers (was: only providers with fallback_priority > 0)
   Earlier the chain was strictly "providers the user explicitly opted in via
   fallback_priority > 0". A healthy in-pool provider with priority=0 was
   silently excluded — surprising since the pool was supposed to be the source
   of truth for "what is usable". After this change:
     - Candidates  = every configured provider
     - Pool gating = same as before (in-pool members only at build time;
                     runtime walker re-checks)
     - Order       = agent prefs (PR-3) → fallback_priority asc (>0) →
                     priority==0 alphabetical
   So fallback_priority is now purely an ordering hint, never an exclusion.

2) Per-provider model picker = default OR first-enabled (was: default only)
   Previously a provider was skipped if no chat model on it had is_default=true.
   That is admin friction with no benefit — every provider had to be visited in
   Settings just to mark a default before it could appear in failover. New
   pickFallbackModel():
     - first try getDefaultModelByProvider — user explicit pick wins
     - otherwise take the first enabled chat model on the provider
     - skip only if neither exists

User-visible effect on the deployment that surfaced this:
  - kimi-code primary fails (401 — real auth issue, separate from this bug)
  - Pool short-circuits primary → walker fires
  - Walker now sees dashscope (in-pool) AND ollama (in-pool) as candidates,
    even though neither has fallback_priority set
  - dashscope first enabled qwen model is picked → request succeeds via
    dashscope without anyone touching Settings

45 failover-related tests still green (unit-level chain-build behavior is
backward-compatible; only the candidate set and model-selection lookups
changed, both broadening the chain rather than narrowing it).
2026-04-19 20:34:58 +08:00
matevip
a171f2ac0e fix(wiki): recover raw materials stuck in processing on server restart
Root cause: recoverOnStartup() only reset mate_wiki_processing_job rows,
not mate_wiki_raw_material. claimForProcessing() only accepts pending,
so restart-orphaned processing rows were permanently stuck — frontend
showed "preparing..." forever.

Fix:
- Add WikiRawMaterialService.recoverStuckRawMaterialsOnStartup():
  resets processing→pending, clears progress fields, fires
  WikiProcessingEvent when autoProcessOnUpload is enabled
- WikiAutoConfiguration: call raw recovery after job recovery
- Execution order: job table first (queued), then raw table (pending)

Test: WikiRawMaterialRecoveryTest — 4 cases: reset + events, reset
without events (autoProcess=false), noop on empty.
2026-04-19 19:37:50 +08:00
matevip
cbcb7229b6 fix(wiki): citation drawer shows real data instead of empty fallbacks
Root cause: PageCitationWithRaw record only had id/pageId/chunkId/rawId/
paragraphIdx/anchorText/confidence — missing rawTitle, chunkOrdinal,
startOffset, endOffset, snippet. Frontend displayed Source + Chunk ?
for every card.

Backend:
- Extend PageCitationWithRaw with rawTitle, chunkOrdinal, startOffset,
  endOffset, snippet fields
- Expand listWithRawByPageId SQL to LEFT JOIN mate_wiki_raw_material for
  title, JOIN mate_wiki_chunk for ordinal/offsets/content snippet (first
  200 chars via SUBSTRING)

Frontend:
- CitationDrawer: replace hardcoded Source / Chunk ? / offset with
  i18n keys
- Add 4 new i18n keys: citationUnknownSource, citationChunkN,
  citationChunkUnknown, citationOffset (zh-CN + en-US)
2026-04-19 19:36:57 +08:00
matevip
527a67374d fix(failover): probe URL construction + permissive 4xx/5xx handling
Two real bugs the user restart surfaced — both turned healthy providers
into HARD-removed false positives.

Bug #1 — URL duplication
  OpenAiCompatibleListModelsProbe always concatenated /v1/models, so
  providers whose Base URL already includes the version segment got the
  wrong URL:
    LMStudio  http://localhost:1234/v1     → /v1/v1/models  → 404
    ZhipuAI   .../api/paas/v4              → /v4/v1/models  → 404
  Fix: detect a trailing /vN suffix and append /models instead. Six unit
  tests in OpenAiCompatibleListModelsProbeTest lock the rule down.

Bug #2 — 404 false positives
  Kimi for Coding API does not expose /v1/models even though chat works
  fine, so the probe correctly received a 404 and incorrectly HARD-removed
  the provider from the pool. Other vendors will hit the same — listing
  is not a universal contract.
  Fix: classify HTTP responses semantically.
    401 / 403  → HARD remove (real auth failure)
    404 / 405 / 410 → fail-open (endpoint missing, server may be alive)
    other 4xx / 5xx → fail-open (probe inconclusive — let chat decide)
    network errors → fail (unreachable)
  This is the same philosophy as ChatGPTOAuthStatusProbe: when we cannot
  cheaply confirm health, we do not proactively penalize the provider.
  Same logic applied to Anthropic + DashScope probes for consistency.

Net effect on the user deployment after restart:
  - kimi-code stays in pool (404 → fail-open) → primary path works again
  - lmstudio + zhipu-cn also stay in pool (URL bug fixed)
  - dashscope + ollama unchanged (real 200 OK)

Tests: 6 new for resolveModelsPath. The 2 unrelated WikiRawMaterialDedupTest
failures pre-date this commit and live in ba86bea.
2026-04-19 19:36:38 +08:00
matevip
4700d0312d fix(wiki): deduplicate raw material uploads across all processing statuses
Root cause: addFile()/addText() hash dedup only matched rows with
status=completed, so the same file uploaded while in partial/pending/
processing/failed status would create a duplicate row.

Fix:
- Remove .eq(processingStatus, "completed") from dedup queries — match
  any non-deleted row with the same content hash in the KB
- On dedup hit: completed/pending/processing → return as-is;
  partial/failed → trigger reprocess (partial enters resume branch)
- Clean up the newly uploaded temp file when dedup discards it
- Frontend: uploadRawFile/addRawText check for existing id in the list
  before unshift to prevent visual duplicates

Test: WikiRawMaterialDedupTest — 10 cases covering all 5 statuses,
reprocess triggers for partial/failed, no-op for others, insert only
when no match.
2026-04-19 19:36:13 +08:00
matevip
6c15622b59 refactor(llm): RFC-009 PR-0b — migrate DashScope + Anthropic helpers out of AgentGraphBuilder
PR-0 only installed the strategy seam; the actual ~600 LOC of provider-
specific construction stayed in AgentGraphBuilder as transitional public
helpers. PR-0b moves the DashScope + Anthropic halves into their builders
proper. (OpenAI larger refactor — 5 sub-helpers including Kimi/o-series
special cases — is left for a follow-up PR-0c.)

AgentDashScopeChatModelBuilder now owns:
  - buildDashScopeApi (with provider/env/reflection key+url fallback chain)
  - buildDashScopeOptions (model/temp/max-tokens/topP + built-in search)
  - normalizeDashScopeBaseUrl (strip /compatible-mode/, return null for SDK default)
  - readApiKeyFromDefaultChatModel + readBaseUrlFromDefaultChatModel +
    readDashScopeApiFromDefaultChatModel (reflection-based final fallback)
  - isBuiltinSearchEnabled (renamed from isDashScopeSearchEnabled, called
    by AgentGraphBuilder.build via the now-injected dashScopeBuilder ref)

AgentAnthropicChatModelBuilder now owns:
  - buildAnthropicApi (key validation, applyHttpTimeouts duplicated locally)
  - buildAnthropicOptions (extended-thinking budget mapping low/medium/high/max
    → 4k/8k/16k/32k, temperature=1 enforcement, RFC-014 prompt cache options)

AgentGraphBuilder dropped:
  - DashScope: ~120 LOC (api + options + 4 helpers + isDashScopeSearchEnabled)
  - Anthropic: ~75 LOC (api + options)
  - DashScopeChatModel + DashScopeConnectionProperties fields (unused after move)
  - Deprecated single-fallback buildFallbackModel (no callers, superseded
    by buildFallbackChain since RFC-009 PR-1)
  - 5 imports for moved DashScope/Anthropic types

Net: -154 LOC in AgentGraphBuilder (1721 → 1567), +372 across the two new
builders. Strategy seam is now real for 3 of 4 protocols (ChatGPT was
already standalone, OpenAI is PR-0c). 220/220 tests still green — no
behavior change.
2026-04-19 19:22:57 +08:00
matevip
3d213eb281 chore: sync multiple commits from private dev
Covers 15 upstream commits (private mirror → public):

Multi-provider failover (RFC-009):
- PR-0: extract ChatModelBuilder strategy seam
- PR-1a: AvailableProviderPool data structure
- PR-1b: startup provider liveness probe + 4 protocol strategies
- PR-1c: wire AvailableProviderPool into runtime chat-model selection
- PR-1d: provider pool REST endpoint + UI badges
- PR-1e: manual reprobe trigger + auto-reprobe on provider config change
- PR-3: per-agent provider preferences (agents can override the
  org-wide fallback chain)

Wiki subsystem (RFC-029~033):
- Relation model, resilient background jobs, light-weight processing
  path, retrieval enhancement, frontend redesign (single landing commit)
- Follow-up fixes: null guards + stats query + i18n polish, move
  WikiProcessingJobMapper to repository/ for @MapperScan, align
  implementation with RFC-029~031 spec
- Copy pass: replace "富化 / enrich" wording with clearer "链接 / link"
- Style: switch enrich/repair buttons to @element-plus/icons-vue
2026-04-19 18:37:44 +08:00
matevip
3b11a3def6 fix(failover): AUTH_ERROR triggers fallback chain + UI splits provider 401 from session expiry
Two related issues from the Kimi-401 user report:

1. Backend (NodeStreamingChatHelper): a primary AUTH_ERROR (e.g. Kimi 401
   with an invalid API key) returned immediately without trying the
   fallback chain — a fallback provider with a different, valid key
   never got a chance. Even with DashScope correctly configured as the
   fallback, the user chat dead-ended on a 401.

   The original assumption ("auth never self-heals so do not retry")
   holds for the primary same-model retry loop but is wrong for the
   fallback chain — different providers have different keys. Apply the
   same break-into-fallback policy that BILLING and MODEL_NOT_FOUND
   already use. recordPrimary(false) is preserved so the cooldown
   counter still accumulates.

2. Frontend (chatError.ts + i18n): the error-text matching for
   /认证|auth|unauthorized|401/i was so broad it matched the substring
   "auth" inside URLs like https://api.kimi.com/.../auth, classifying
   any model 401 as user "session expired" and rendering the misleading
   "页面将自动跳转到登录页" copy. (The redirect itself only fires from
   /api/v1/auth/* axios paths and SSE-connection 401s, not from this
   payload-text path — but the copy alone is the worst kind of false
   alarm.)

   Add a new ChatErrorCategory provider_auth_error and split the
   pattern matching: narrow auth_expired (HTTP 401 / 登录已过期 /
   session expired / 凭证失效) is matched FIRST, then the broad
   401-ish pattern routes to provider_auth_error. BACKEND_ERROR_TYPE_MAP
   for AUTH_ERROR is also remapped, since structured backend payloads
   currently always come from LLM providers — never from our own
   /api/v1/auth path.

Tests
- NodeStreamingChatHelperFailoverTest (5 cases): primary 401 →
  fallback succeeds; chain skips auth-failing fallback to next healthy
  one; whole-chain failure surfaces last AUTH_ERROR (no silent drop);
  BILLING regression unchanged; primary-success path does not touch
  chain
- Browser preview verified: new i18n keys resolve in en-US, classifier
  correctly routes "[错误] 401 from kimi.com" → provider_auth_error
  while "[错误] HTTP 401 from /api/v1/auth/ping" stays auth_expired
- 186 tests pass (was 181 + 5 new); vue-tsc clean

Do-not-touch list: handleAuthFailure() in useStream/api/index.ts (real
session-expiry path) is unmodified — only the misclassification
upstream is fixed. auth_expired i18n copy is unchanged.
2026-04-19 17:45:15 +08:00
matevip
7ba8fe602b feat(llm): track primary health + split BILLING / MODEL_NOT_FOUND from generic client errors
Track the primary model health, not just fallback entries
- NodeStreamingChatHelper accepts primaryProviderId via a new 5-arg
  constructor; AgentGraphBuilder passes ModelConfigEntity.getProvider()
- Before the 5-retry primary loop, check
  healthTracker.isInCooldown(primaryProviderId): if true, log + broadcast
  "主模型暂时不可用(冷却中),直接尝试备选模型..." and short-circuit
  straight to the fallback chain. Prevents a degraded primary from
  burning 30+ seconds of backoff on every conversation turn.
- recordPrimary(success/failure) now fires on every primary verdict —
  AUTH, BILLING, MODEL_NOT_FOUND, EMPTY_RESPONSE, generic UNKNOWN, and
  the explicit success path. Three consecutive failures push the
  primary provider into cooldown automatically.
- Legacy 1/2/3-arg constructors leave primaryProviderId null; tracking
  silently disables for them so existing tests/wiring keep working.

Split BILLING and MODEL_NOT_FOUND out of CLIENT_ERROR / AUTH_ERROR
- BILLING (HTTP 402, "insufficient_quota", "credit balance is too low",
  "billing_hard_limit_reached", "quota exceeded"): payment failure on
  primary does not kill the call — a different provider may have credits.
  Skips same-model retries and heads to fallback chain.
- MODEL_NOT_FOUND (HTTP 404, "Model not exist", "model_not_found",
  DashScope "[InvalidParameter] url error"): unknown model id will not
  start working on retry. Was previously misclassified as CLIENT_ERROR
  and terminated the whole call; now routes to fallback so a different
  provider can attempt with its default model.
- classifyError ordering matters: BILLING / MODEL_NOT_FOUND are matched
  BEFORE the generic 400 / Bad Request branch, otherwise they would be
  swallowed by CLIENT_ERROR.

Tests
- ErrorClassificationTest: 11 tests, covers multi-vendor error phrasing
  for both new types + regression checks that 401 / 429 / 400 still
  classify as before
- NodeStreamingChatHelperFallbackChainTest: +2 tests verifying
  primaryProviderId persistence on the new constructor and null on
  legacy ones
- 181 tests pass (was 168 + 13 new)
2026-04-19 17:10:27 +08:00
matevip
7b12c5f0c9 feat(llm): provider health tracker + UI editor for failover priority
UI — Failover priority editor
- ProviderConfigRequest + ProviderInfoDTO carry fallbackPriority
- ModelProviderService.updateProviderConfig persists it (null = unchanged);
  toProviderInfo exposes the current value to the UI (defaults to 0)
- ProviderConfigModal advanced panel exposes a number input with hint
- ProviderCard shows a "Fallback #N" badge for chain members so the
  priority order is visible at a glance without opening the modal
- 5 new i18n keys (zh + en) — verified to resolve at runtime via i18n.global.t

Backend — Per-provider health tracker
- ProviderHealthTracker: ConcurrentHashMap-backed counters; N consecutive
  failures (default 3) push the provider into a cooldown window (default
  5 min) during which the chain walker skips it. Success resets both
  counter and cooldown atomically. Lazy expiry on lookup so dead entries
  do not accumulate.
- ProviderHealthProperties exposed under mateclaw.llm.failover.health.*
  with sane production defaults
- New FallbackEntry record (providerId + ChatModel) replaces raw
  List<ChatModel> in the chain so the walker can correlate cooldown
  state to entries; AgentGraphBuilder.buildFallbackChain returns the
  new type
- NodeStreamingChatHelper takes the tracker through a new 4-arg
  constructor and consults it before each fallback call; records
  success/failure on each chain attempt. Legacy 2/3-arg constructors
  preserved as @Deprecated wrappers (synthetic providerId means no
  health tracking on the legacy path — that path is opt-out anyway)

Tests
- ProviderHealthTrackerTest (9 tests): below/at threshold, success
  reset, cooldown expiry (via reflection on the min-clamp setter),
  disabled-tracker no-op, null-providerId safety, per-provider
  isolation, snapshot output
- NodeStreamingChatHelperFallbackChainTest updated to FallbackEntry
  field type — verifies providerId + ChatModel survive the chain
- 168 tests pass (was 159 + 9 new)

Verification
- mvn test green; vue-tsc clean; live UI confirms i18n resolution
2026-04-19 16:57:03 +08:00
matevip
ed37e81e7e feat(llm): multi-model failover chain driven by per-provider priority
Replaces the hardcoded single-DashScope fallback with a DB-driven
ordered chain. Same-provider primary deployments (e.g., DashScope
qwen-max) finally get a real fallback; if any provider in the chain
returns an empty body or transient failure, the next is tried.

Schema — DB-driven chain
- mate_model_provider gains `fallback_priority INT DEFAULT 0`. Positive
  values define try-order; 0 = not in chain. Migration V21 (h2 + mysql)
  seeds DashScope as priority 1 to preserve existing behavior.
- ModelProviderService.listFallbackChain() returns providers ordered by
  priority ascending.
- ModelProviderEntity gains the new field.

Runtime — chain walk + empty-response trigger
- AgentGraphBuilder.buildFallbackChain(primaryConfig) returns a
  List<ChatModel>, identity-filtering the primary by (providerId,
  modelName) — fixes the bug where same-provider-primary deployments got
  null fallback. Providers whose API key is missing are silently
  skipped with WARN. Old buildFallbackModel(ChatModel) kept as
  @Deprecated wrapper.
- NodeStreamingChatHelper accepts List<ChatModel>; the post-retry
  fallback block now walks the chain in priority order, single-shot
  per entry. Old single-fallback constructors retained as @Deprecated
  one-element-list wrappers so legacy callers keep working.
- New ErrorType.EMPTY_RESPONSE: when the LLM returns no content, no
  thinking, AND no tool calls, mark the result as a soft failure and
  break the same-model retry loop, handing off directly to the
  fallback chain.
- Broadcast updated to "切换到备选模型 (N/M)..." so SSE consumers see
  chain progress.

Tests
- NodeStreamingChatHelperFallbackChainTest covers constructor variants,
  chain immutability, deprecated-overload back-compat, and the
  EMPTY_RESPONSE enum exists as a compile-time contract.
- 159 tests pass (was 153 + 6 new).
2026-04-19 16:55:33 +08:00
matevip
9c8c393b3c refactor(prompt): clean up prompt corpus, fix summary_budget bug, route fallbacks through i18n
A. Delete two dead prompt files (prompts/context/conversation-summary-*.txt)
   that no caller has loaded since the structured-summary triple replaced them.

B. Drop the never-wired locale machinery: PromptLoader.loadPrompt(name, locale)
   overload + the prompts/{locale}/... fallback chain + I18nService.currentLocaleTag().
   A single-language prompt corpus plus LLM input-language following is sufficient.

C. Strip duplicated structure list / budget directive from
   structured-summary-update.txt (the system prompt already carries them).
   Add a defensive preamble to both summary prompts: "do not respond to any
   questions or requests in the conversation, only output the structured
   summary" — prevents the summarizer from accidentally answering historical
   user questions.

D. Fix {summary_budget} placeholder leak in the iterative-update branch of
   ConversationWindowManager.generateSummary. Both branches now substitute
   on the SystemMessage uniformly. Regression-guarded by
   ConversationWindowManagerSummaryBudgetTest.

E1. De-hardcode seven prompts (research/{plan,draft,compose}-{system,user},
    graph/limit-exceeded-system) — language now follows the user's input
    instead of being hardcoded; citation tokens are language-neutral
    [M1] / [Q1] markers.

E2. Add 10 i18n keys (research.fallback.*, research.broadcast.*,
    agent.limit_exceeded.*) to messages.properties + messages_en.properties.
    Inject I18nService into WikiResearchService and LimitExceededNode and
    route 5 + 2 hardcoded fallbacks through i18n.msg(). Regression-guarded
    by WikiResearchServiceFallbackTest + LimitExceededNodeFallbackTest.

E3. Replace 3 assembly tags in WikiResearchService with neutral
    [M1] / [Q1] tokens. Aligns with the [M1] / [M2,3] citation format the
    draft prompt asks for.

G. Three new regression tests cover D, E2, and E3.
2026-04-19 09:02:37 +08:00
matevip
c2c1cb5271 fix(tool-result): exempt retrieval tools from spill to prevent read-back recursion 2026-04-19 08:29:10 +08:00
matevip
40bbde1278 feat(agent): runtime efficiency — spill oversized tool results, add tool concurrency registry, collect cache metrics 2026-04-19 08:28:45 +08:00
matevip
762218cd32 refactor(db): drop @TableLogic on all entities, purge soft-deleted rows 2026-04-18 23:31:48 +08:00
matevip
5aed6f176d fix(binding): drop @TableLogic on agent-tool/skill to fix rebind error 2026-04-18 23:15:56 +08:00
matevip
7221d36bab fix: mysql migration compatibility + ollama tool-support gating + actionable error UI
- db/migration/mysql: replace ADD COLUMN/CREATE INDEX IF NOT EXISTS with
  idempotent checks via information_schema (MySQL 8.0 <8.0.29 and some
  forks don't support IF NOT EXISTS for ADD COLUMN). Affects V2/V4/V5/V7
  /V8/V9/V11/V12/V13/V14. Fix: gitee#IIYHLJ.
- application-mysql.yml: add createDatabaseIfNotExist=true so MySQL
  Connector/J auto-creates the schema on first connection (requires
  CREATE privilege — documented fallback for restricted accounts).
- llm/OllamaAutoDiscoveryRunner: rewrite seed tag when fuzzy-matching,
  prefer exact tag for default; skip models without tool support when
  auto-activating a default (prevents the phantom ':latest' trap when
  users pulled a specific size).
- agent/graph/NodeStreamingChatHelper: detect 'does not support tools'
  and 'model not found' errors from Ollama and emit actionable Chinese
  prompts guiding users to qwen3 / qwen2.5:7b+ / llama3.1:8b+ etc.
- ui/MessageBubble + types/chatError: surface the backend's actionable
  rawMessage in the failed-message card instead of a generic '未知错误';
  strip redundant prefixes (Bad request: / [错误] / LLM 调用失败:) since
  the title already conveys the category.
2026-04-17 11:17:27 +08:00
matevip
a3e6724cf4 fix(chat): channel conversation sync + running indicator
- ChannelMessageRouter: include assistantMessageId in message_complete
  and done broadcasts so ChatConsole observers can reconcile the
  streaming placeholder to the persisted DB row by id instead of
  falling back to the FIFO 'claim' heuristic (which occasionally
  dropped the assistant bubble on external channel conversations).
  Capture the id from ConversationService.saveMessage in both the
  sync agentService.chat path and the streaming processWithStreaming
  path; switch to HashMap since Map.of rejects null values when save
  is skipped (e.g. under approval).

- ChatConsole: add a 'running' indicator on the sidebar so users can
  tell which conversations have an in-flight agent run. Pulsing amber
  dot on the channel icon (both expanded and collapsed modes) plus a
  '生成中…' / 'Generating…' pill in expanded mode.

- ChatConsole: don't cancel the previous conversation's streaming run
  when switching conversations — let it keep running in the background
  and reconcile when the user comes back.
2026-04-17 10:03:56 +08:00
matevip
b35c29767c feat(chat): realtime sync for external channel conversations 2026-04-17 08:25:32 +08:00
matevip
8fbe30d7ac feat(auth): password change dialog + workspace member provisioning improvements 2026-04-17 00:11:10 +08:00
matevip
c4883e108c fix(llm): pre-filter non-chat DashScope modalities + quieter probe logging 2026-04-16 18:15:48 +08:00
matevip
adfe23cd2c fix(llm): classify DashScope 'url error' as client error + broaden dot-version purge 2026-04-16 18:15:35 +08:00
matevip
8a25d723f0 fix(chat): reset stale stopRequested flag on new stream register 2026-04-16 18:13:34 +08:00
matevip
ba086d75f2 fix(llm): purge unavailable DashScope models + protocol-aware discovery probe 2026-04-16 18:13:13 +08:00
matevip
b3c6b5a654 fix(wiki): sub-segment mean-pool embedding for chunks exceeding model token limit 2026-04-16 17:12:17 +08:00
matevip
25978ceb12 feat(llm): UI-configurable embedding models with per-KB binding and dynamic factory 2026-04-16 17:12:00 +08:00
matevip
04ad281ffd fix(skill): use getModel instead of nonexistent getById in SkillSynthesisService 2026-04-16 17:11:46 +08:00
matevip
1fdf87b31e feat(wiki): semantic hybrid search + chunk persistence + deep research pipeline 2026-04-16 17:11:31 +08:00
matevip
a6e9a17208 feat(skill): Agent-autonomous skill synthesis — create/edit/patch via @Tool with security scanning 2026-04-16 17:10:59 +08:00
matevip
7d8d16e458 feat: 5 defensive hardenings
- ConversationWindowManager: cap reserve token at 50% of effective max
  to prevent negative historyBudget on small-context models (8K/16K)
- common.security.SecretEquals: new constant-time comparison utility
  (MessageDigest.isEqual wrapper) for secrets/tokens/signatures
- WeixinChannelAdapter: migrate context_token comparison to SecretEquals
- FeishuChannelAdapter: fail-fast on empty encrypt_key when connection_mode=webhook
- TelegramChannelAdapter: sanitize attachment captions — strip control bytes
  (\p{Cc} except \t\r\n) + format chars (\p{Cf}) + 4096 char cap
- AgentGraphBuilder: fallback Anthropic max_tokens to 4096 on null/0/negative

Tests: SecretEqualsTest (5) + TelegramCaptionSanitizeTest (5) — all green.
2026-04-15 22:14:55 +08:00
matevip
4a4b39249e chore(channel): remove stale external-reference comments; fix(wiki): canonical slug lookup on merge path 2026-04-15 16:44:02 +08:00
matevip
ef8120413c feat(wiki): real-time SSE progress + parallel page generation + partial-resume; fix concurrent slug collisions; fix skill overwrite + hub retry 2026-04-15 10:34:11 +08:00
matevip
2a2f862257 feat(wiki): per-raw progress bar in raw-material card (RFC-012 M2 v2 UI) 2026-04-14 18:56:45 +08:00
matevip
f285db22d0 fix(wiki): surface LLM root cause + fail fast on DNS/TLS/refused (RFC-012 M1 follow-up v2) 2026-04-14 18:24:49 +08:00
matevip
62ac1fb79c fix(wiki): route emits metadata only; per-page create + merge in phase B (RFC-012 M2 v2) 2026-04-14 18:11:35 +08:00
matevip
26d45b0e35 fix(agent): use JdkClientHttpRequestFactory for LLM RestClient (gzip + HTTP/2) 2026-04-14 17:53:44 +08:00
matevip
4fb6a83eb6 feat(wiki): two-phase digest — route + per-page merge (RFC-012 M2) 2026-04-14 17:39:50 +08:00
matevip
a369e8055d fix(wiki): bound LLM retry + http read timeout (RFC-012 M1 follow-up) 2026-04-14 16:05:37 +08:00
matevip
b9ed8219ba feat(wiki): parallel processing + resilient LLM retry + hash-based skip (RFC-012 M1) 2026-04-14 15:18:03 +08:00
matevip
0adb3dddf1 feat(plugin): Plugin SDK + UI layout improvements 2026-04-13 18:38:03 +08:00
matevip
97e101ab52 feat(channel): auto-start on create, multi-account UX, wecom mixed message 2026-04-13 17:10:34 +08:00
matevip
881badd15f feat(channel): weixin voice ASR fallback, wecom mixed message handling 2026-04-13 16:38:09 +08:00
matevip
d5e3502829 fix(wiki): backend hardening + batch delete UI 2026-04-13 15:37:12 +08:00
matevip
e4679796b8 feat(wiki): performance + quality + delete redesign (RFC-008) 2026-04-13 09:35:26 +08:00
matevip
80b7b8e126 feat(agent): multi-agent delegation with parallel execution (RFC-004) 2026-04-12 23:40:27 +08:00
matevip
46f77c281b fix(agent): complete RFC-001 — Anthropic thinking, iteration budget, UI fixes 2026-04-12 17:28:15 +08:00
matevip
2a8b90365b feat(agent): add deep thinking toggle (RFC-001) 2026-04-12 11:29:32 +08:00
matevip
379422101c refactor(ui): minimalist login redesign, MCP fixes, Flyway upgrade compatibility 2026-04-11 23:01:08 +08:00
matevip
b613a5de11 feat(tool): add CronJobTool for chat-based scheduled tasks + Flyway V2/V3 migrations 2026-04-11 19:51:28 +08:00
matevip
b3c1f8403d feat(skill): add ZIP file import for skill installation 2026-04-11 19:29:01 +08:00
matevip
d3b72929c7 fix(security): login rate limiting, SQL injection fix, error boundary 2026-04-11 18:31:51 +08:00
matevip
8dbb437e40 fix(security): remove debug console.log and hide internal error details 2026-04-11 18:26:41 +08:00
matevip
fe83b72d67 fix(security): harden JWT, CORS, and H2 Console for production 2026-04-11 18:21:17 +08:00
matevip
408ad980dd feat(i18n): complete remaining i18n — DefaultToolGuard, LLM/Datasource services, Channels UI 2026-04-11 18:02:03 +08:00
matevip
af9addaaec feat(i18n): structured i18n keys for exceptions and auto-translate 100+ error messages 2026-04-11 17:52:25 +08:00
matevip
81ff1bf491 feat(i18n): complete backend i18n — guard rules, tool errors, response codes 2026-04-11 17:26:58 +08:00
matevip
aa09345403 feat(i18n): add backend internationalization — tool descriptions, error messages, guard rules, runtime context 2026-04-11 17:08:43 +08:00
matevip
cc28f665f1 feat(db): introduce Flyway migration framework and unify H2/MySQL schemas
- Add Flyway baseline migration (V1) for both H2 and MySQL
- Remove 5 legacy SchemaMigration ApplicationRunner classes
- Add WorkspacePathGuard for file tool sandbox enforcement
- Inject workspace basePath context into agent graph state and tool executor
- Add workspace basePath config UI in frontend
- Fix workspace slug preservation on update
2026-04-11 16:34:09 +08:00
matevip
f98f4d68b9 refactor(ui): publish tested chat UI simplification 2026-04-11 14:25:37 +08:00
matevip
bfd1cbac56 feat(chat): ChatGPT tool calling + fix cross-turn message pollution 2026-04-11 08:46:21 +08:00
matevip
f08581daa7 fix(guard): detect find -delete as dangerous shell command 2026-04-11 00:35:59 +08:00
matevip
f28ad8d9d4 fix(chat): preserve refresh history and thinking order 2026-04-11 00:16:33 +08:00
matevip
367dd4bed0 fix(agent): preserve per-subtask results in multi-task answer synthesis, add listAvailableSkills tool 2026-04-10 17:10:02 +08:00
matevip
ba34f1eed3 fix(chat): preserve intermediate reasoning in segments via phase-based splitting 2026-04-10 07:58:19 +08:00
matevip
dafdcb4182 feat(chat): segmented message display, progressive loading, and real-time segment persistence 2026-04-10 07:36:24 +08:00
matevip
ec7ea038e7 feat(agent): context compression upgrade, 429 retry, iteration limit & repetition fixes 2026-04-10 00:52:26 +08:00
matevip
250a5f6d46 feat(memory): multi-layer memory system with pluggable provider architecture 2026-04-09 22:26:19 +08:00
matevip
a219f92410 feat: productize webchat channel config 2026-04-09 21:28:47 +08:00
matevip
1c2acfd2e9 refactor(ux): simplify interactions and humanize UI with Jobs-inspired review 2026-04-09 20:56:50 +08:00
matevip
5124842526 feat(platform): workspace isolation, info architecture, and UI redesign 2026-04-09 16:29:02 +08:00
matevip
d44ba0cdd8 fix(security): close workspace isolation gaps and audit context loss 2026-04-09 14:19:51 +08:00
matevip
3506c55bc8 feat(platform): Phase 3 Sprint 1-3 — permission, agent binding, dashboard 2026-04-09 11:58:20 +08:00
matevip
3d58a48eae feat(platform): add workspace foundation and channel execution upgrades 2026-04-09 10:29:16 +08:00
matevip
f6a3a1592a feat(ux): Phase 1 — onboarding, doctor, templates, navigation convergence 2026-04-09 00:32:35 +08:00
matevip
c568b4faa8 fix(db): unify schema and seed data across H2/MySQL, en/zh 2026-04-08 16:30:33 +08:00
matevip
f6102c4733 fix(wiki): auto-resolve kbId, improve search and processing robustness 2026-04-08 16:09:22 +08:00
matevip
642360a773 feat(wiki): add LLM Wiki knowledge base system 2026-04-08 10:55:50 +08:00
matevip
7007ea844d feat: add TTS, STT, music generation, video providers (Runway/MiniMax), image providers (Google Imagen/MiniMax), and tool registry fix 2026-04-08 08:49:09 +08:00
matevip
43acd2bf94 feat(image,tts): add image generation with 4 providers and TTS with 3 providers 2026-04-07 22:14:31 +08:00
matevip
fe3a7f7b01 feat(video): add video generation capability with 4 providers and async task infrastructure 2026-04-07 19:14:27 +08:00
matevip
c3eeca7171 feat(search): add advanced params, caching, security wrapping, and dual-search coexistence 2026-04-07 18:00:04 +08:00
matevip
b750306028 feat(search): add SearchProvider chain with keyless fallback (DuckDuckGo + SearXNG) 2026-04-07 16:52:42 +08:00
matevip
afe8466fa5 feat(llm): add OpenAI ChatGPT OAuth login for Plus/Pro member access 2026-04-07 15:32:55 +08:00
matevip
69afc4e68a fix(memory): code review fixes for dreaming and tool execution 2026-04-07 09:22:37 +08:00
matevip
d3f2a310e8 feat(agent): context pruning, thinking recovery, channel health monitor 2026-04-07 07:39:14 +08:00
matevip
5fc60ec513 feat(agent): smart truncation, stale stream cleanup, configurable tool timeouts, and new indexes 2026-04-07 06:39:46 +08:00
matevip
e6be23a040 perf(memory): fix N+1 queries, remove redundant SHA-256, cap DREAMS.md growth 2026-04-07 01:42:57 +08:00
matevip
a8613fb05c fix(agent): improve execution stability to prevent premature task exits 2026-04-07 01:34:40 +08:00
matevip
2ac7cc4af4 feat(stream): add fine-grained phase status hints for frontend UX 2026-04-07 00:40:38 +08:00
matevip
d5f1d19306 feat(memory): add active retrieval tracking, multi-gate filtering, DREAMS.md diary and dreaming status API 2026-04-06 23:35:27 +08:00
matevip
015abcef96 feat(memory): add Dreaming recall tracking and scored emergence 2026-04-06 22:25:47 +08:00
matevip
9d727c607a fix(skill): sync workspace when builtin skill is updated or version bumped 2026-04-06 17:28:39 +08:00
matevip
3940cfd1ce feat(datasource): add auto ECharts visualization for SQL query results 2026-04-06 14:53:22 +08:00
matevip
10dfe35d49 feat(datasource): add SQL query skill for natural language database querying 2026-04-06 13:40:40 +08:00
matevip
8c8cb5fa48 fix(model): remove legacy dashscope-only restriction from model validation 2026-04-06 12:41:27 +08:00
matevip
647fa9ab94 fix(guard): check column existence before ALTER TABLE to suppress H2 duplicate column errors 2026-04-06 12:37:12 +08:00
matevip
08d1a89c0e feat(model): auto-activate Ollama model as default on startup discovery 2026-04-06 12:34:12 +08:00
matevip
fd1462bf03 feat(model): auto-activate default model when provider API key is configured 2026-04-06 12:21:17 +08:00
matevip
4a99382004 fix(browser): fix idle watchdog leak on repeated start/stop cycles 2026-04-06 12:01:09 +08:00
matevip
6756577428 fix(browser): add Windows and Docker Chromium launch args 2026-04-06 11:47:10 +08:00
matevip
91cd03c0da fix(agent): resolve image path from mediaId for IM channel multimodal injection 2026-04-06 10:57:34 +08:00
matevip
af40fbd7de feat(channel): add file upload support for WeChat and WeCom channels 2026-04-06 10:51:07 +08:00
matevip
eb78032752 feat(video): support video upload, preview, and multimodal analysis 2026-04-06 09:42:54 +08:00
matevip
49aae91e90 fix(agent): skip SVG in multimodal injection and stop retrying 400 errors 2026-04-06 08:38:39 +08:00
matevip
7bcdbf4523 fix(pdf,chat): fix OCR trigger misjudgment, false success, and duplicate image injection 2026-04-06 08:18:04 +08:00
matevip
d8cf5acf0f feat(chat,pdf): scanned PDF OCR fallback and authenticated attachment display 2026-04-06 07:48:28 +08:00
matevip
cc0569440e fix(chat): harden multimodal attachment handling across all paths 2026-04-06 07:03:11 +08:00
matevip
84a205509b feat(chat): multimodal image injection and upload UX improvements 2026-04-05 23:58:42 +08:00
matevip
99befe0d25 fix(agent): prevent ReAct degenerate repetition and harden loop termination 2026-04-05 22:34:03 +08:00
matevip
732bb13f47 fix(security): resolve SPA frontend route refresh returning 401 2026-04-05 18:20:40 +08:00
matevip
c8f3a12925 fix(i18n): dynamically set window title from language pack instead of hardcoding 2026-04-05 16:34:15 +08:00
matevip
bcf37d95fe fix(guard): align tool guard rule names with runtime @Tool method names and add audit config 2026-04-05 12:00:50 +08:00
matevip
ef1f22356f feat(ui): group model providers by local/cloud with section headers 2026-04-05 08:32:55 +08:00
matevip
c335baf14d fix(llm): sort local providers first by using DESC order on is_local 2026-04-05 07:51:01 +08:00
matevip
d2d78b855e feat(llm): auto-detect Ollama on startup with pre-configured local models 2026-04-05 07:42:20 +08:00
matevip
4f60043549 refactor(server): replace Knife4j with SpringDoc OpenAPI 2.8.16 2026-04-05 07:24:00 +08:00
matevip
cccd364993 fix(llm): fix Zhipu connection test and update models to GLM-5-Turbo 2026-04-05 07:09:56 +08:00
matevip
2c3d805521 feat(agent): add multi-agent delegation tool for agent-to-agent collaboration 2026-04-04 23:26:34 +08:00
matevip
579d60125b Initial commit: MateClaw — Java + Vue 3 AI Assistant System
Full-stack AI assistant built on Spring AI Alibaba.
Features: ReAct Agent, Plan-and-Execute, MCP Protocol, Multi-Model, Multi-Channel.

Apache-2.0 License
2026-04-04 19:03:49 +08:00