Commit graph

302 commits

Author SHA1 Message Date
Jiayuan Zhang
ecb0cd392e chore(docs): remove non-e2e documentation 2026-02-17 00:46:36 +08:00
Jiayuan Zhang
cf94bc32d2 fix(gateway): relax rpc param generic for typed sdk payloads 2026-02-16 12:33:45 +08:00
Jiayuan Zhang
4a2ef835fb feat(gateway): send agent-generated welcome after telegram connect 2026-02-16 12:24:30 +08:00
Jiayuan Zhang
f60551195a chore(agent): remove old sessions_spawn/sessions_list tools and update references
Delete sessions-spawn.ts, sessions-list.ts and their tests. Update CLI
to remove waitForSubagents polling workaround (delegate is synchronous).
Update UI, desktop IPC, SWE-bench, and system prompt tests to use the
new delegate tool name.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 01:09:21 +08:00
Jiayuan Zhang
94ae88ed8b
Merge pull request #208 from multica-ai/forrestchang/compaction-audit
Context window: 4-phase compaction improvements
2026-02-16 00:01:58 +08:00
Naiyuan Qing
fa040404d2
Merge pull request #207 from multica-ai/fix/onboarding-header-centering
fix(desktop): center onboarding step indicator
2026-02-15 22:10:50 +08:00
Naiyuan Qing
1e5174582b fix(desktop): center onboarding step indicator using absolute positioning
Use absolute positioning for the step indicator to achieve true centering
regardless of left/right element widths. This is the standard approach for
header layouts where the center element must be centered relative to the
entire container width, not the remaining flex space.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 22:05:03 +08:00
Jiayuan Zhang
87a83fba1a feat(telegram): add reply context parsing and send new messages for tool narration
- Extract reply_to_message text from Telegram replies and prepend as
  [Replying to: "..."] context so the agent can reference specific messages
- Replace edit-message pattern with new messages for each tool narration,
  improving clarity in the chat flow
- Remove dead code: sendOrEditStatus, editFormatted, statusMessages map

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 21:39:45 +08:00
Jiayuan Zhang
40a2e8ae55 fix(context-window): prioritize config over model for context window resolution
resolveContextWindowInfo now uses config > model > default priority so
explicit --context-window flag overrides model defaults. Also adds
--context-window CLI option to the run command.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 21:37:02 +08:00
Jiayuan Zhang
9f95566616 fix(desktop): make login and onboarding windows draggable on macOS
Login page: replace full-container drag region with a dedicated header
bar, matching the pattern used across the app. The previous approach
applied -webkit-app-region: drag to the entire content container which
could interfere with child element interactions.

Onboarding steps 1-4: move drag region from a tiny 80px left strip to
the entire header element, and mark the ModeToggle as no-drag so it
remains clickable.

Closes MUL-241

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 21:16:27 +08:00
Jiayuan Zhang
e39f9a5dfe feat(cli): wait for sub-agents and output findings in run mode
In CLI mode, the parent Agent is not registered with the Hub, so the
normal announce flow can't deliver sub-agent results. Added polling
mechanism that waits for sub-agents to complete and prints their
findings directly to stdout.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 19:53:26 +08:00
Jiayuan Zhang
b007ddffc8 feat(cli): initialize Hub in run mode for full agent capabilities
Always initialize Hub in CLI run mode to match the Desktop environment
where Hub is always active. This enables sessions_spawn (sub-agent
creation), cron tasks, channel plugins, and other Hub-dependent
features during E2E testing.

Hub constructor is non-blocking — gateway connection failures are
handled gracefully with auto-reconnect. hub.shutdown() in finally
block ensures clean teardown on exit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 18:06:51 +08:00
Jiayuan Zhang
a2c1379c1d feat(cli): add --run-log flag and session dir output for agent-driven E2E testing
Add --run-log CLI flag to enable structured run logging without env var.
Print session directory path to stderr when run-log is enabled so Coding
Agents can easily locate log files for analysis.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 16:03:40 +08:00
Jiayuan Zhang
313f826d58
Merge pull request #200 from multica-ai/forrestchang/fix-telegram-conflict
fix(gateway): handle Telegram 409 conflict and add error resilience
2026-02-15 14:48:25 +08:00
Jiayuan Zhang
fe7c772219 fix(gateway): add process-level error handlers and graceful shutdown
Add unhandledRejection and uncaughtException handlers to prevent the
gateway from crashing on unexpected errors. Add SIGTERM/SIGINT handlers
for graceful shutdown via app.close().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 14:07:50 +08:00
Jiayuan Zhang
5741402a1a fix(telegram): handle 409 polling conflict and add global error boundary
Add bot.catch() to prevent unhandled errors from crashing the polling
loop, and catch the 409 "terminated by other getUpdates request" error
specifically when another bot instance is already running.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 14:07:49 +08:00
Jiayuan Zhang
bd0b380e2e refactor(credentials): remove skills.env.json5 support
Remove centralized skills.env.json5 in favor of per-skill .env files.
Clean up CredentialManager by removing hasEnv/getEnv/getResolvedEnvSnapshot
methods and skills env loading. Update CLI credentials and skills commands.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 13:34:51 +08:00
Naiyuan Qing
c6ca5f3270 refactor(ui): unify container layout and adjust spacing
- Use container utility class consistently across chat components
- Change container max-width from 5xl to 4xl for better readability
- Adjust message bubble padding (p-3 -> p-2)
- Fix logout dropdown alignment and add destructive variant

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 10:47:59 +08:00
yushen
276e9a5b25 fix(web): defer MULTICA_API_URL check to runtime in next.config
Move the env var read into the rewrites function so `next build`
succeeds without MULTICA_API_URL set (it is only needed at runtime).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 06:42:30 +08:00
yushen
4dba1cfdf0 refactor: unify API URL env var to MULTICA_API_URL
Replace scattered API_URL, MAIN_VITE_API_URL, and RENDERER_VITE_API_URL
with a single MULTICA_API_URL across all apps and packages.

- Desktop: use envPrefix to expose MULTICA_* to main process, rename
  RENDERER_VITE_API_URL → RENDERER_VITE_MULTICA_API_URL, remove
  MAIN_VITE_API_URL (now read directly via MULTICA_API_URL)
- Web: add .env.development with MULTICA_API_URL, enforce required check
  in next.config.ts, update .gitignore to allow .env.development
- Core: make MULTICA_API_URL required in api-client (no silent fallback)
- Scripts: pass MULTICA_API_URL in dev-local.sh for web process
- Turbo: update globalEnv from API_URL to MULTICA_API_URL
- Docs: update references to the new env var name

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 06:31:00 +08:00
yushen
25629f97ca fix(gateway): add build stage for workspace packages in Dockerfile
Add intermediate build stage to compile @multica/types, @multica/utils,
and @multica/core before the runtime stage so dist/ artifacts are
available. Also adds @multica/utils as an explicit gateway dependency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 05:46:41 +08:00
Jiayuan Zhang
e9d54e94ab feat(telegram): add inline keyboard onboarding and menu button
Replace plain-text bot messages with HTML-formatted messages and
inline keyboard buttons. Users are now guided through connection
with interactive buttons (How to connect, What is Multica?, Check
status, Help, Reconnect) that edit messages in-place. Add
setChatMenuButton to show commands in the hamburger menu.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 04:11:56 +08:00
Jiayuan Zhang
a131f3b7f5
Remove Multica App tab from Clients page (#190)
* feat(desktop): remove Multica App tab from Clients page

Only Telegram is currently available as a connection method.
Remove the unused "Multica App" tab, tabs UI, and related
components (QRCodeCard, DevicesCard, MulticaAppTab) to simplify
the page.

MUL-252

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(desktop): restore authorized devices list on Clients page

The devices list was accidentally removed along with the Multica App
tab. Add it back below the Telegram card.

MUL-252

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 03:04:53 +08:00
Jiayuan Zhang
9e40e8ca76 chore: update reset scripts and docs for dev data directory
- dev:desktop:reset now cleans both ~/.super-multica and ~/.super-multica-dev
- reset-user-data.sh handles dev directory
- .env.example documents SMC_DATA_DIR

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 00:39:25 +08:00
Jiayuan Zhang
9bfef7126b feat(desktop): add version, gateway, and update check to tray menu
Tray menu now shows:
- Agent status (Idle/Running/Streaming)
- Hub connection status
- Gateway URL
- Show Main Window
- Version number
- Check for Updates
- Quit Multica (⌘Q)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 23:27:10 +08:00
Jiayuan Zhang
c50bdd0f84 fix(desktop): reduce tray icon size to match menu bar conventions
Shrink asterisk glyph from 22x22 to 14x14 within the 22x22 canvas
(28x28 within 44x44 @2x), adding proper padding to align with
other macOS menu bar icons.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 23:18:27 +08:00
Jiayuan Zhang
5e03b4d76b fix(desktop): use asterisk tray icon and show-only menu
- Replace resized app icon with dedicated tray icon matching MulticaIcon
- Remove click-to-toggle behavior, add "Show Main Window" menu item
- Include tray icon PNGs in electron-builder files config

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 23:16:56 +08:00
Jiayuan Zhang
d2e22a6ec7 feat(desktop): add system tray for background agent status
When the main window is closed, the app now stays running with a
menu bar tray icon showing agent/hub status. Users can toggle the
window visibility and quit from the tray menu.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 22:40:28 +08:00
yushen
0b50400a45 fix(desktop): read error body instead of statusText for gateway errors
res.statusText is always empty under HTTP/2, causing "Gateway error: "
with no detail. Now reads the JSON response body to surface the
server's actual error message and always includes the status code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 08:51:46 +08:00
yushen
b3a179971e chore: bump version to 0.1.1
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 08:19:15 +08:00
yushen
eb07f12c49 chore(desktop): add env files for dev/production and update dev scripts
- Track .env.development and .env.production for desktop app
- Add MAIN_VITE_API_URL to all env files
- Remove hardcoded GATEWAY_URL from dev scripts (now in .env.development)
- Update .env.example with full documentation of all env vars

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 07:30:54 +08:00
yushen
ef32078b3c fix(desktop): use RENDERER_VITE_API_URL for renderer API host
Read API host from import.meta.env.RENDERER_VITE_API_URL instead of
hardcoding it, so staging/dev builds point to the correct backend.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 07:30:48 +08:00
yushen
b7477cb646 feat(desktop): bridge MAIN_VITE_API_URL to process.env for packaged builds
In packaged Electron builds, @multica/core is externalized and .env
files are excluded. Bridge import.meta.env.MAIN_VITE_API_URL (injected
at build time by electron-vite) to process.env.MULTICA_API_URL so that
getApiBaseUrl() reads the correct value in staging/test environments.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 07:30:42 +08:00
Jiayuan Zhang
d1570698ac fix(telegram): fix tool narration detection and typing indicator during tool execution
- Detect both "tool_use" (Anthropic) and "toolCall" (Hub) content types
- Re-send typing indicator after sending/editing status message since
  Telegram clears typing state on any message send/edit
- Remove debug file logging (appendFileSync to /tmp)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 03:14:48 +08:00
Jiayuan Zhang
4c1365ff75 fix(telegram): strip existing bold markers in table conversion to prevent overlapping HTML tags
Table cells already containing **bold** markers got double-wrapped,
creating ****text**** which produced overlapping <b><i> tags rejected
by Telegram's HTML parser.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 03:14:41 +08:00
Jiayuan Zhang
dde8cc542a feat(telegram): show editable status message during tool execution
Instead of silently discarding tool narration or spamming separate
messages, send a single editable Telegram message that updates in-place
as the agent works. First tool narration sends a reply; subsequent
narrations edit the same message. The final answer is sent as a new
message.

- Add replyTextEditable/editText to ChannelOutboundAdapter interface
- Implement editFormatted + editable methods in Telegram plugin
- Track statusMessageId in ChannelManager, clear on agent_end/error
- Add sendOrEditStatus to Gateway TelegramService with same behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 02:14:42 +08:00
Jiayuan Zhang
81998e6309 fix(telegram): skip tool narration messages, only send final answer
When the agent uses tools (web search, etc.), it generates intermediate
narration text like "Let me search..." before each tool call. These were
being sent as separate Telegram messages, causing message spam. Now we
detect tool_use blocks in the message content and skip sending those
intermediate messages — only the final answer reaches the user.

Applied to both Desktop channel plugin and Gateway Telegram service.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 02:04:17 +08:00
Jiayuan Zhang
8270762d66 feat(telegram): convert Markdown tables to vertical list format
Telegram doesn't support HTML tables, so pipe-delimited Markdown tables
were rendered as hard-to-read plain text on mobile. This converts tables
to a vertical "Header: Value" format with bold first column before
sending to Telegram.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 01:56:21 +08:00
Jiayuan Zhang
9189883710
Merge pull request #175 from multica-ai/forrestchang/telegram-arch
feat(gateway): Telegram QR-based connection flow with centralized bot
2026-02-14 01:45:46 +08:00
Jiayuan Zhang
eb274d5e0c fix(desktop): resolve lint warnings for react-refresh and unused import
- Extract useQRToken and useCountdown hooks to qr-hooks.ts so qr-code.tsx
  only exports components (fixes react-refresh/only-export-components)
- Remove unused useRef import from connect-step.tsx

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 01:38:04 +08:00
Jiayuan Zhang
d6393c6718 fix(gateway): remove cleanupPendingRequests that rejects all concurrent users
cleanupPendingRequests() iterated the service-wide pendingRequests Map
and rejected every entry. Since it was called from connectUser's catch
block (a per-user error path), one user's connection failure would
spuriously reject other users' in-flight verify RPCs.

The call was also redundant: sendVerifyRpc already cleans up its own
entry in all failure paths (timeout, RPC error, route failure).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 01:31:33 +08:00
Jiayuan Zhang
7af2a0d1b1 fix(desktop): auto-approve Telegram connection during onboarding
DeviceConfirmDialog only exists in the main Layout, so verify
requests were timing out during onboarding. Since the user is
actively generating the QR code, auto-approve and show a success
state instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 01:14:25 +08:00
Jiayuan Zhang
088750326c fix(gateway): persist Telegram users to JSON file when no database
Replaces in-memory Map with file-backed store at
~/.super-multica/gateway/telegram-users.json so user bindings
survive gateway restarts during local development.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 00:48:17 +08:00
Jiayuan Zhang
24b70e6e25 fix(gateway): add in-memory fallback for TelegramUserStore when no database
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 00:45:05 +08:00
Jiayuan Zhang
a7629db01e fix(gateway): enable CORS for HTTP endpoints
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 00:42:29 +08:00
Jiayuan Zhang
b39a0dd2ac feat(desktop): add Telegram QR code to Clients page and Onboarding
- Create TelegramConnectQR component (fetches short code from Gateway)
- Export reusable hooks/components from qr-code.tsx
- Update ChannelsTab with Telegram QR card
- Rewrite ConnectStep for QR-based flow (replaces BotFather token input)
- Re-add ConnectStep to onboarding: Privacy → Provider → Channels → Start

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 00:30:10 +08:00
Jiayuan Zhang
d75a24714d feat(gateway): add Telegram QR deep link connection flow
Add short code store, bot commands (/start, /status, /help), and
POST /telegram/connect-code endpoint for Desktop to create QR codes.
Users scan a QR → Telegram opens → /start {code} → auto-connects.

- ShortCodeStore: in-memory Map with TTL for connection info
- Bot commands registered via setMyCommands
- Refactor handleConnectionLink into shared connectUser method
- Fetch bot username via getMe() for deep link URL

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 00:30:01 +08:00
Jiayuan Zhang
5010d87284 feat(gateway): add long-polling fallback for local Telegram development
When TELEGRAM_WEBHOOK_URL is not set, the bot automatically starts in
long-polling mode (bot.start()) instead of waiting for webhook calls.
This allows local development without ngrok or a public URL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 00:05:19 +08:00
Jiang Bohan
a86709a4cd chore: switch API host from api-dev.copilothub.ai to api.multica.ai
Update all backend API base URLs to use the production multica.ai domain.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 23:25:00 +08:00
Jiayuan Zhang
4cb8b93f93 refactor(desktop): hide manual Telegram bot creation, use official Gateway bot only
Remove the user-facing ability to create custom Telegram bots via BotFather.
Non-technical users should only need to message @multica_bot on Telegram.
- Disable telegramChannel plugin registration in initChannels()
- Remove ConnectStep from onboarding flow (Privacy → Provider → Start)
- Replace TelegramCard with simple text pointing to @multica_bot

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 22:20:39 +08:00