Commit graph

719 commits

Author SHA1 Message Date
Jiang Bohan
f9b193d467 fix(desktop): use default import for electron-updater CJS module
electron-updater is a CommonJS module — ESM named imports fail at
runtime. Switch to default import with destructuring.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 20:20:47 +08:00
Bohan Jiang
cd078969fe
Merge pull request #125 from multica-ai/Bohan-J/desktop-auto-update
feat(desktop): add auto-update functionality
2026-02-11 20:09:36 +08:00
Bohan Jiang
b22ad5a559
Merge pull request #129 from multica-ai/fix/desktop-heartbeat-ack-filter
fix: hide heartbeat messages from desktop chat UI
2026-02-11 19:53:27 +08:00
Jiang Bohan
c49ab1fee4 fix(heartbeat): use internal run to hide heartbeat from chat history
The heartbeat runner used agent.write() (normal write), which persisted
both the heartbeat prompt and HEARTBEAT_OK response as regular messages
visible in the UI chat history.

Switch to runInternalForResult() — a new AsyncAgent method that runs
via runInternal() (messages marked internal: true, rolled back from
in-memory state). This hides both the heartbeat prompt and response
from the UI entirely, while still persisting to JSONL for diagnostics.

The previous commit's event-stream heartbeat ACK filter remains as a
defense-in-depth layer for edge cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 19:41:57 +08:00
Jiang Bohan
8d6a803739 fix(agent): filter heartbeat ACK messages from desktop event stream
The heartbeat runner uses agent.write() (normal write), so heartbeat
ACK responses like "HEARTBEAT_OK" were not suppressed by the internal
run filter and leaked into the desktop UI chat. The Gateway path was
already fixed (Hub has delayed-start + isHeartbeatAckEvent filtering),
but the local Desktop path through AsyncAgent had no such filtering.

Add createFilteredHandler() to AsyncAgent that buffers message_start
for assistant messages and checks subsequent events with
isHeartbeatAckEvent(). Pure heartbeat ACKs are suppressed end-to-end;
all other messages are forwarded normally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 19:34:23 +08:00
Jiang Bohan
e9efb66fb2 Merge remote-tracking branch 'origin/main' into Bohan-J/desktop-auto-update 2026-02-11 19:06:15 +08:00
Bohan Jiang
16cd5d0aaf
Merge pull request #126 from multica-ai/feat/subagent-announce-delivery
feat(subagent): two-tier announce delivery, provider inheritance, error propagation
2026-02-11 19:04:39 +08:00
Jiang Bohan
af3a42a00e fix(subagent): forward announcement summary to UI stream
Changed forwardAssistant from false to true in sendAnnounceDirect() so
the assistant's summary response is streamed to the desktop UI in
real-time. The announcement prompt stays internal (hidden from UI), but
the user now sees the completion notification.

Previously, persistAssistantSummary saved the response to JSONL but
never emitted events to the UI subscriber, leaving users with no
visible feedback after subagent tasks completed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 18:58:32 +08:00
Jiang Bohan
47cbf60687 fix(agent): reload tools after setProvider to fix stale closure
setProvider() updated toolsOptions.provider but didn't reload tool
instances. The sessions_spawn tool captured the old provider in its
closure at creation time, causing subagents to inherit a stale provider.

Now calls resolveTools() + setTools() after updating toolsOptions so
sessions_spawn gets a fresh closure with the correct provider.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 18:58:24 +08:00
Jiang Bohan
d7a02182ab feat(subagent): add announce:"silent" mode for deferred coalesced announcements
Add an `announce` parameter to sessions_spawn that controls when findings
are delivered to the parent agent:

- "immediate" (default): announce per-completion (existing behavior)
- "silent": defer until ALL silent runs from the same requester complete,
  then deliver ONE coalesced announcement with all findings

This enables workflows like "spawn 10 parallel subagents to collect data,
then summarize everything at once" without intermediate results.

Changes:
- types.ts: add `announce` field to SubagentRunRecord & RegisterSubagentRunParams
- sessions-spawn.ts: add `announce` parameter to tool schema
- registry.ts: split checkAndAnnounce into immediate/silent groups,
  extract announceGroup helper, use count-match guard for silent readiness
- sections.ts: add announce mode guidance to system prompt
- registry.test.ts: add silent mode tests (field storage, group isolation)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 17:40:00 +08:00
Jiayuan Zhang
a7c194c823
Merge pull request #127 from multica-ai/forrestchang/finance-domain
feat: add finance data domain with DCF valuation and research skills
2026-02-11 17:27:01 +08:00
Jiang Bohan
de928cfe2b fix(agent): add NO_REPLY detection utility for filtering silent replies
Extract SILENT_REPLY_TOKEN and isSilentReplyText() into a shared
module. Detects NO_REPLY at the start or end of text (with optional
whitespace/punctuation) to filter out silent announcement responses
that should not be forwarded to the user.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 17:16:22 +08:00
Jiang Bohan
d01fcffe32 docs(subagent): add architecture flowchart and README
Document the full subagent lifecycle: spawn, concurrency queue,
execution, completion handling, two-tier announcement delivery,
and record archival. Include provider inheritance chain and
error propagation diagrams.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 17:10:12 +08:00
Jiang Bohan
58ec56234c feat(subagent): improve system prompts for error reporting and timeout
Add error reporting rule to subagent system prompt: subagents must
explicitly report tool failures and missing credentials in their
final message. Add timeout guidelines to parent system prompt with
recommended values by task complexity (10-30 min).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 17:10:05 +08:00
Jiang Bohan
716e69ac39 feat(subagent): add anti-polling guards to sessions_list
When subagents are still running, sessions_list now returns an
explicit instruction telling the LLM not to poll again and wait
for automatic result delivery. Normalizes status display to
uppercase ([RUNNING], [OK], [ERROR]).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 17:09:56 +08:00
Jiang Bohan
121b644df4 fix(subagent): inherit parent provider in spawned subagents
Pass parent's resolvedProvider through the tool chain (tools.ts →
sessions-spawn.ts → hub.createSubagent) so subagents use the same
LLM provider as the parent. Previously subagents fell back to the
hardcoded default provider, causing API key errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 17:09:49 +08:00
Jiang Bohan
2e6d419c27 feat(subagent): deferred record cleanup and error propagation
Replace immediate record deletion with archiveAtMs-based deferred
cleanup (60min retention). This keeps records queryable via
sessions_list after completion. Add sweeper to clean expired records.
Check childAgent.lastRunError after waitForIdle to detect failed runs
that resolve the promise without throwing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 17:09:42 +08:00
Jiang Bohan
299c947893 feat(agent): expose isRunning and lastRunError on Agent and AsyncAgent
Add isRunning flag to Agent (runner.ts) for detecting active runs.
Add lastRunError to AsyncAgent for propagating child run errors to
the registry. Fix duplicate message emission in writeInternal by
resetting forwardInternalAssistant before persistAssistantSummary.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 17:09:33 +08:00
Jiang Bohan
45db13cbdd feat(subagent): add two-tier announce delivery with debounced queue
Add announce-queue.ts for batching nearby subagent completions with
debounce (1s) and collect mode. Implement two-tier delivery in
announce.ts: queue when parent is busy, writeInternal when idle.
All delivery uses writeInternal() to mark messages as internal,
preventing announcement bubbles from appearing in the UI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 17:09:26 +08:00
Jiayuan Zhang
4e5c99a97f feat(ui): show task context for sessions_spawn in chat UI
Display the label (or truncated task) as subtitle for SpawnSession tool
calls, so users can see what each spawned session is working on.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 16:59:16 +08:00
Jiayuan Zhang
5a3dc6c1e1 feat(ui): add data tool display config in chat UI
Add chart icon, smart subtitle (shows action + ticker, e.g. "price_snapshot AAPL"),
and running state label for the data tool in the tool call UI component.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 16:54:42 +08:00
Jiayuan Zhang
d80e97648c fix(core): read data tool API key from credentials.json5
Use credentialManager.getToolConfig("data") as the primary source for
the Financial Datasets API key, with FINANCIAL_DATASETS_API_KEY env var
as fallback. Also add data tool entry to the credentials template.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 16:45:46 +08:00
Jiayuan Zhang
6e28513ec5 feat(skills): add finance research and DCF valuation skills
- finance-research: guides agent on financial data retrieval and analysis
  workflows using the data tool
- dcf-valuation: 8-step DCF valuation workflow with sector WACC reference
  data, sensitivity analysis, and validation checks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 16:44:05 +08:00
Jiayuan Zhang
d47594d7b2 feat(core): add unified data tool with finance domain support
Introduces a `data` tool that provides structured access to the Financial
Datasets API (financialdatasets.ai). Supports 18 finance actions covering
stock prices, financial statements, key metrics, SEC filings, analyst
estimates, insider trades, news, and crypto data.

Designed as a stable interface — the backend can be swapped from direct
API calls to a Multica Data Service without changing the tool schema.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 16:43:58 +08:00
Jiang Bohan
0459769746 feat(desktop): add auto-update functionality
Implement one-click desktop auto-update with version checking, download progress, and automatic installation. Includes toast notification UI in bottom-right corner showing update status (checking, available, downloading, ready, or error).

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-02-11 13:59:58 +08:00
Naiyuan Qing
7562009a83
Merge pull request #124 from multica-ai/fix/desktop-branding-cleanup
fix(desktop): update branding and fix code signing
2026-02-11 10:02:28 +08:00
Naiyuan Qing
c0db46e200 fix(desktop): add required metadata for Linux deb build
Add description, author, and homepage fields to package.json
required by electron-builder when building .deb packages on Linux CI.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-11 09:55:12 +08:00
Naiyuan Qing
2c9d1939c0 fix(desktop): update branding and fix code signing for development
- Change productName from "YourAppName" to "Multica"
- Change appId from "YourAppID" to "com.multica.app"
- Add app icons (icns, ico, png) for all platforms
- Disable hardenedRuntime to fix ad-hoc signing on ARM Macs
- Add build:desktop script to root package.json
- Simplify desktop .gitignore with !build/ exception
- Remove unused asarUnpack and entitlements config

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-11 09:49:18 +08:00
Jiayuan Zhang
c58a836f03
Merge pull request #123 from multica-ai/forrestchang/desktop-onboarding
feat(desktop): add 4-step onboarding flow
2026-02-11 00:20:57 +08:00
Jiayuan Zhang
ff7395960d fix(desktop): remove unused availableProviders destructuring
Fixes eslint no-unused-vars warning that fails CI with --max-warnings 0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 00:16:02 +08:00
Jiayuan Zhang
7af64a12e2 fix(desktop): clear forceOnboarding flag on onboarding completion
completeOnboarding() only set completed=true but never cleared the
forceOnboarding flag, causing OnboardingGuard to redirect back to
onboarding in an infinite loop when --force-onboarding was used.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 00:12:15 +08:00
Jiayuan Zhang
afe51d325d fix(core): rebuild system prompt after provider switch
setProvider() updated the resolved provider and model but did not
rebuild the system prompt, so the runtime info line still showed the
old provider/model (e.g. claude-code/claude-opus-4-6) after switching.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 00:12:08 +08:00
Jiayuan Zhang
0135951ac6 feat(desktop): allow reconfiguration of already-configured providers
Previously, configured providers only showed a checkmark with no way to
reconfigure them. Now shows a "Reconfigure" button alongside the checkmark.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 23:40:36 +08:00
Jiayuan Zhang
c24ac8a098 fix(core): fix OpenRouter model resolution and add fallback for custom models
Registry model IDs used hyphens (claude-sonnet-4-5) but pi-ai expects
dots (claude-sonnet-4.5). Also adds a fallback model config for OpenRouter
models not in pi-ai's registry, since OpenRouter supports thousands of models.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 23:40:31 +08:00
Jiayuan Zhang
5c5bf46a95 fix(desktop): fix Try It step UI overflow and missing chat input
Add min-w-0 to SamplePrompt text container so truncate works in
flex layout. Always show ChatView when agent is ready so the message
input is visible (ChatView has its own empty state).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 23:29:23 +08:00
Jiayuan Zhang
e9c91ccc66 fix(desktop): allow selecting configured providers in setup step
Remove strict model validation from provider:set IPC handler that
rejected custom models not in the static registry list (broke OpenRouter
with user-typed models). Add error display to setup page.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 23:23:22 +08:00
Jiayuan Zhang
04d227c9fe feat(desktop): persist onboarding state with --force-onboarding flag
Use Zustand persist middleware with localStorage to remember onboarding
completion across app restarts. Only the completed flag is persisted;
transient UI state resets each launch. Add --force-onboarding CLI flag
to re-show onboarding even when already completed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 23:15:10 +08:00
Jiayuan Zhang
ab65f4cadf refactor(desktop): replace OpenRouter model dropdown with text input
Remove Combobox component and use a plain text input for model name,
allowing users to enter any model identifier manually.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 23:15:03 +08:00
Jiayuan Zhang
a143187da1 feat(desktop): add provider connection test to API key dialog
Save & Test flow: saves API key, then sends a minimal prompt to verify
the provider is reachable. Shows phase-based status (saving/testing/
success/error) with auto-close on success.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 23:02:45 +08:00
Jiayuan Zhang
d7ccbf066e feat(core): add testProvider method to AsyncAgent
Queued through the serialization queue to safely switch provider,
send a minimal test prompt, and restore the previous provider.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 23:02:39 +08:00
Jiayuan Zhang
9290fd1212 feat(desktop): add searchable model dropdown for OpenRouter
Replace plain text input with Combobox for model selection. Users can
search and select from the provider's model list via dropdown.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 22:52:00 +08:00
Jiayuan Zhang
9240e31fcb fix(desktop): improve Try It right panel visual separation
Replace bg-muted/30 with border-l for a clean separator between the
prompt list and ChatView panels.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 22:47:16 +08:00
Jiayuan Zhang
0c4f8796d7 fix(desktop): require active provider before Continue in setup step
Changed check from availableProviders.length > 0 to current?.available,
so Continue is only enabled when a provider is both configured and
selected as the active default.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 22:44:36 +08:00
Jiayuan Zhang
3e04422df6 feat(desktop): use interactive sample prompts in Try It step
Replace simple prompts with ones that demonstrate real agent
capabilities: web search, project analysis, and shell execution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 22:41:07 +08:00
Jiayuan Zhang
60e71ce4c8 fix(desktop): require successful Telegram connection before Continue
Continue button is now disabled until the bot status is 'running'.
Skip remains available when no token has been entered.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 22:41:02 +08:00
Jiayuan Zhang
bc24b58026 feat(desktop): wire Try It step to real agent chat
Replace fake sample prompts with real agent interaction. Clicking a
prompt sends it via localChat and shows the live ChatView on the right
panel with streaming responses.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 22:34:59 +08:00
Jiayuan Zhang
7691f81376 feat(desktop): add model name input for OpenRouter configuration
OpenRouter requires both API key and model name. Adds optional model
input field to ApiKeyDialog, enabled via showModelInput prop.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 22:25:46 +08:00
Jiayuan Zhang
e0812017f1 fix(desktop): only show active provider when actually available
Prevents pre-selecting an unconfigured provider and enabling Continue
when no provider is configured. Also passes modelId through on success.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 22:25:41 +08:00
Jiayuan Zhang
4de9947a02 feat(desktop): add 4-step onboarding flow
Add complete onboarding wizard: Permissions > Provider > Connect > Try it

Step 1 (Permissions): Privacy & Trust acknowledgements with toggles for
file system, shell execution, LLM requests, and local storage access.

Step 2 (Provider): LLM provider setup with 4 supported providers
(Kimi Code, Claude Code OAuth, Codex OAuth, OpenRouter), default
provider selection via radio indicator, and contextual setup tutorials
in the right panel that change on hover.

Step 3 (Connect): Optional Telegram bot connection with token input and
BotFather tutorial. Reuses existing useChannels() hook.

Step 4 (Try it): Sample prompts and completion.

Includes OnboardingGuard, Zustand store (no persist - resets on launch),
breadcrumb stepper with progress bar, and left-right split layout.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 22:17:20 +08:00
Jiayuan Zhang
16fe40bfc2 feat(desktop): hide native title bar with macOS hiddenInset style
Add titleBarStyle hiddenInset and trafficLightPosition to BrowserWindow.
Add drag region to main layout header with no-drag on interactive elements.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 22:17:07 +08:00