Commit graph

537 commits

Author SHA1 Message Date
yushen
9687e7f2a6 fix(subagent): forward announce replies from internal runs 2026-02-06 18:58:54 +08:00
yushen
f7267f6698 fix(agent): prevent internal run leaks in async streams 2026-02-06 18:38:54 +08:00
yushen
d392238be3 feat(subagent): tag internal orchestration messages and filter from user-facing history
Announcement messages from subagent completion flows were persisted as
regular user messages, polluting conversation history and leaking
orchestration instructions to frontend/CLI.

- Add `internal?: boolean` to SessionEntry message variant
- SessionManager.saveMessage accepts { internal: true } option
- SessionManager.loadMessages filters internal by default
- Agent.runInternal() tags messages as internal, rolls back from memory
- Agent.withRunMutex() prevents concurrent run/runInternal mis-tagging
- AsyncAgent.writeInternal() suppresses event forwarding during internal runs
- Announce flows use writeInternal() instead of write()
- Desktop IPC getHistory reads from session storage (filtered)
- CLI session show parses SessionEntry, supports --show-internal flag

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 18:34:11 +08:00
yushen
9cc89cf297 feat(subagent): add sessions_list tool for viewing spawned sub-tasks
Adds a new `sessions_list` tool to the Subagent tool group, allowing
agents to query the status of their spawned sub-tasks. Supports both
list mode (all runs) and detail mode (specific runId).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 17:58:22 +08:00
yushen
7726079648 fix(subagent): recover delete cleanup after crash 2026-02-06 17:31:21 +08:00
yushen
7f9a0181c8 test(subagent): add coalescing announcement tests
Cover formatCoalescedAnnouncementMessage (single/multi record,
mixed outcomes, missing findings), registry coalescing state
transitions, shutdown capture, and new field serialization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 17:24:44 +08:00
yushen
6786af4aa3 feat(subagent): coalesce announcements into single parent notification
When multiple children complete, buffer findings per-child and only
send one combined announcement to the parent after all unannounced
runs for the same requester have finished. This avoids N separate
LLM calls and gives the parent a complete picture of all results.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 17:24:39 +08:00
Bohan Jiang
91aa433f34
Merge pull request #100 from multica-ai/Bohan-J/cron-job-tool
feat(cron): add cron job scheduling system with Desktop UI
2026-02-06 15:46:41 +08:00
Jiang Bohan
4983debf0c fix(desktop): add cron API type to ElectronAPI interface
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 15:43:55 +08:00
Jiang Bohan
b5eca456ab fix(cron): clarify agent-turn can use all tools in description
The model was confused about payload capabilities. Explicitly state
that agent-turn spawns an isolated agent with ALL tools (exec, write,
web_fetch, etc.) and add usage guidance for choosing between
system-event and agent-turn.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 15:31:29 +08:00
Jiang Bohan
2129feaf3a fix(cron): replace require("fs") with ESM renameSync import
The bundled ESM environment does not support require(). Use the
already-imported fs functions instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 15:21:12 +08:00
Jiang Bohan
a8dd9f2bbb feat(desktop): add Cron Jobs management page
- Add "Cron" tab to navigation bar with Time04Icon
- Add /crons route with CronsPage component
- Add cron IPC handlers (list, toggle, remove) in electron/ipc/cron.ts
- Expose cron API in preload.ts for renderer process
- Add useCronJobs hook for fetching and managing jobs
- Add CronJobList component with status badges, toggle switches,
  delete buttons, relative time display, and empty state

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 15:16:33 +08:00
Jiang Bohan
9bd18472b8 refactor(cron): align tool schema with OpenClaw patterns
- Replace Type.Union(Type.Literal(...)) with flat stringEnum helper
  to avoid anyOf in JSON schema (better LLM provider compatibility)
- Rewrite description to structured ACTIONS/SCHEDULE/PAYLOAD/CONSTRAINTS
  format without markdown headers or code blocks
- Add CRITICAL CONSTRAINTS section for sessionTarget+payload rules

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 15:08:15 +08:00
Jiang Bohan
ab85a01431 fix(cron): improve action parameter description for better model understanding
- Add explicit list of valid actions in parameter description
- Add IMPORTANT note at start of tool description

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 14:59:35 +08:00
Jiang Bohan
ea7a2c837b feat(desktop): add cron tool to Tools page UI
- Add 'group:cron' to TOOL_GROUPS in IPC handler and agent tools
- Add cron tool description and group name to use-tools hook
- Add Time04Icon for cron group in tool-list component
- Add subagent group icon (UserMultipleIcon) for completeness

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 14:47:54 +08:00
Jiang Bohan
321b48a1cf feat(agent): register cron tool in agent toolset
Add createCronTool to the agent's default tools list so agents
can use the cron tool to manage scheduled tasks.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 14:47:54 +08:00
Jiang Bohan
b82409c7c0 feat(hub): integrate cron service lifecycle
- Initialize CronService on Hub startup
- Set executeCronJob as the job executor
- Shutdown CronService on Hub cleanup

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 14:47:54 +08:00
Jiang Bohan
25808cf81d docs: add design documents for cron job and auto-memory-refresh
- cron-job-tool.md: Implementation plan for scheduled task system
- auto-memory-refresh.md: Design for pre-compaction memory flush (future)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 14:47:31 +08:00
Jiang Bohan
f15a28e14a feat(cli): add multica cron commands
Adds CLI support for managing scheduled tasks:
- multica cron status: Show service status
- multica cron list: List all scheduled jobs
- multica cron add: Create new jobs with --at/--every/--cron
- multica cron run: Execute jobs immediately
- multica cron enable/disable: Toggle job status
- multica cron remove: Delete jobs
- multica cron logs: View run history

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 14:47:31 +08:00
Jiang Bohan
9d0cc6fdf6 feat(tools): add cron tool for agent job management
Adds a cron tool that allows agents to create, manage,
and execute scheduled tasks. Supports:
- status: Get service status
- list: List all jobs with optional filters
- add: Create one-shot, interval, or cron jobs
- update: Modify existing jobs
- remove: Delete jobs
- run: Execute jobs immediately
- logs: View run history

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 14:47:31 +08:00
Jiang Bohan
de355cace3 feat(cron): add cron job scheduling module
Implements a timer-based cron job system:
- types.ts: Job types (at, every, cron schedules)
- schedule.ts: Next run computation using croner
- store.ts: Persistent JSON storage with JSONL run logs
- service.ts: CronService with timer management
- execute.ts: Job execution (system-event, agent-turn)

Based on OpenClaw's implementation (MIT License).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 14:47:31 +08:00
Jiang Bohan
00b31e23f5 chore(deps): add croner for cron expression parsing
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 14:47:31 +08:00
LinYushen
3b09d8d44d
Merge pull request #99 from multica-ai/message-aggregation
feat(hub): add message aggregation module for third-party messaging integrations
2026-02-06 12:51:14 +08:00
yushen
f6fab68873 fix(hub): include message_end text in aggregator 2026-02-06 12:44:15 +08:00
yushen
1e71341997 Merge remote-tracking branch 'origin/main' into message-aggregation 2026-02-06 11:55:58 +08:00
LinYushen
24204794d1
Merge pull request #98 from multica-ai/copilothub-web-search
feat(tools): replace web search with Devv Search + HMAC signing
2026-02-06 11:54:56 +08:00
yushen
ec6dbff61c Merge remote-tracking branch 'origin/main' into copilothub-web-search 2026-02-06 11:43:40 +08:00
yushen
efb1495326 fix(hub): fence close must reject info strings per CommonMark spec
The closing fence regex was not checking for an empty info string,
allowing e.g. ```python to incorrectly close an open fence. Also
adds missing test for tool_execution_update passthrough.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 22:23:55 +08:00
yushen
fc0c1781c3 refactor(hub): remove Hub-level aggregation integration
Message aggregation should not be managed by the Hub. The aggregator
is a standalone utility for client adapters to use internally — the
Hub stays clean and only does event forwarding. Third-party messaging
integrations (Discord, Telegram) will use MessageAggregator in their
own adapter layer.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 20:24:25 +08:00
Naiyuan Qing
1e6da205df feat(ui): spin MulticaIcon on hover
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 20:22:29 +08:00
Naiyuan Qing
5e174b8fef fix(ui): responsive horizontal padding on message list
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 20:15:19 +08:00
Naiyuan Qing
21312abd01 feat: chat input padding 2026-02-05 19:02:38 +08:00
Naiyuan Qing
039a625dbd
Merge pull request #96 from multica-ai/feat/message-return
feat(chat): add message history pagination with scroll-up loading
2026-02-05 18:48:56 +08:00
Naiyuan Qing
02f3534f2e chore(chat): set DEFAULT_MESSAGES_LIMIT to 200 for production
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 18:45:15 +08:00
Naiyuan Qing
f7950066bc
Merge pull request #97 from multica-ai/cleanup/remove-old-chat-files
Remove unused Zustand stores from @multica/store
2026-02-05 18:44:48 +08:00
Naiyuan Qing
1fe27a59d0 chore(store): remove unused Zustand stores and slim down package
After the chat refactoring moved state management to @multica/hooks,
the Zustand stores (useConnectionStore, useMessagesStore, useAutoConnect)
are no longer imported by any application code. This removes them along
with their unused dependencies (zustand, uuid, react).

- Delete connection-store.ts, messages.ts, use-auto-connect.ts
- Extract Message/ToolStatus types into types.ts (preserves UI imports)
- Remove saveConnection/loadConnection/clearConnection from connection.ts
- Drop zustand, uuid, react deps from package.json

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 18:41:31 +08:00
Naiyuan Qing
65c2fea1b6 feat(chat): add message history pagination with scroll-up loading
Return latest messages by default instead of oldest. Support paginated
loading of older messages when scrolling up via IntersectionObserver,
with scrollHeight compensation to preserve scroll position.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 18:40:15 +08:00
yushen
c03a60753e feat(hub): integrate message aggregator into Hub event pipeline
Add enableAggregation/disableAggregation methods to Hub for per-agent
aggregation control. When enabled, streaming text deltas are buffered
and emitted as block-reply events instead of raw stream events. The
existing streaming mode remains the default for own clients.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 18:28:14 +08:00
yushen
1859e32a30 feat(hub): add message aggregation module for block-level reply chunking
BlockChunker splits streaming text at natural boundaries (paragraph,
newline, sentence, word) with configurable min/max chars and markdown
fence-safe splitting. MessageAggregator consumes AgentEvents, buffers
text deltas, and emits complete BlockReply objects via callbacks.

Enables future third-party messaging integrations (Discord, Telegram)
that cannot consume raw streaming deltas.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 18:28:08 +08:00
Naiyuan Qing
c2b5ada2ef
Merge pull request #86 from multica-ai/exec-approvals
feat(agent): add exec approval system for command execution
2026-02-05 17:59:43 +08:00
Naiyuan Qing
669cbc791b fix(desktop): resolve eslint exhaustive-deps warnings in useLocalChat
Use chatRef to hold stable reference to useChat return value, avoiding
stale closure issues and satisfying react-hooks/exhaustive-deps rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 17:56:54 +08:00
Naiyuan Qing
9bcb0993b1 Merge remote-tracking branch 'origin/main' into exec-approvals
# Conflicts:
#	apps/desktop/src/hooks/use-local-chat.ts
2026-02-05 17:54:19 +08:00
Naiyuan Qing
bece8f0545 refactor(web): adapt chat page for extracted shared hooks
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 17:51:12 +08:00
yushen
3817e2d8a2 feat(tools): add HMAC-SHA256 request signing to web search
Sign each search request with HMAC-SHA256 using Hub ID, a per-request
nonce (UUIDv7), and unix timestamp. The signed reqId is sent in the
request body to prevent unauthorized API usage.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 17:50:57 +08:00
Naiyuan Qing
607adeb667 feat(desktop): implement local chat with direct IPC and mode switching
Add LocalChat component using useLocalChat hook that communicates with
the Hub via IPC (no Gateway required). Fix streamId extraction to use
event.message.id matching Hub behavior. Fix history to return raw
AgentMessageItem[] instead of flattened strings. Add exec approval
forwarding over IPC. Use conditional rendering for LocalChat to prevent
event leaking from remote sessions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 17:50:55 +08:00
Naiyuan Qing
7a21686505 refactor(hooks,ui): extract useGatewayChat hook and update shared components
Move gateway-specific chat logic into dedicated useGatewayChat hook.
useChat remains a pure state hook with no IO. Update ChatView props,
remove legacy chat.tsx and connect-prompt.tsx.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 17:50:47 +08:00
Naiyuan Qing
874de766ec feat(hub): add local exec approval routing for desktop IPC chat
Add localApprovalHandlers map so exec approval requests can be routed
to the Electron renderer via IPC instead of requiring a Gateway
connection. Expose setLocalApprovalHandler/removeLocalApprovalHandler
and resolveExecApproval on Hub for the IPC layer to use.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 17:50:41 +08:00
yushen
51ba86a8eb refactor(tools): clean up web search naming and remove dead code
Rename CopilotHub references to Devv Search (constants, types, function
names, error message). Remove unused resolveTimeoutSeconds/resolveCacheTtlMs
imports and use constants directly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 17:31:53 +08:00
yushen
630f06eddb chore(tools): update web_search descriptions to Devv Search
Remove "requires API key" wording and rebrand to Devv Search across
tool definition, desktop UI, system prompt, and README.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 17:21:39 +08:00
yushen
8ea2f2a1bf feat(tools): replace web search with CopilotHub API
Remove Brave and Perplexity providers in favor of a single CopilotHub
search endpoint (api-dev.copilothub.ai/web-search). Simplifies schema
to query-only, removes credential dependencies, retains caching.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 17:19:12 +08:00