Commit graph

388 commits

Author SHA1 Message Date
Naiyuan Qing
ef4e57ffdd refactor(sdk): unify message types with pi-ai source of truth
Replace hand-written message/content types in @multica/sdk with
`import type` from @mariozechner/pi-ai and @mariozechner/pi-agent-core.
This ensures compile-time correctness and eliminates type drift between
backend and frontend (e.g. "tool_use" vs "toolCall", "tool_result" vs
"toolResult").

- stream.ts: re-export TextContent, ThinkingContent, ToolCall,
  ImageContent from pi-ai; use AgentEvent from pi-agent-core
- rpc.ts: AgentMessageItem = pi-ai Message (no more manual mirroring)
- connection-store.ts: use SDK types instead of inline hand-written ones
- ContentBlock now includes ImageContent to match backend reality

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 17:13:01 +08:00
Naiyuan Qing
caee37c631 chore: init tool call styles branch 2026-02-04 15:54:17 +08:00
Naiyuan Qing
096b284cef
Merge pull request #80 from multica-ai/feat/web-qr-scanner
feat(ui): add QR code scanner to ConnectPrompt
2026-02-04 15:44:02 +08:00
Naiyuan Qing
39f2683b35 chore(web): gitignore self-signed HTTPS certificates
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 15:41:17 +08:00
Naiyuan Qing
2f5dbcdde9 feat(ui): add QR code scanner to ConnectPrompt
Add browser-based QR scanning as an alternative to paste mode in the
ConnectPrompt component. Mobile users can scan the Desktop QR code
directly instead of manually copying connection codes.

- Add qr-scanner dependency (WebWorker-based decoding, BarcodeDetector support)
- Create use-qr-scanner hook wrapping camera lifecycle and cleanup
- Create QrScannerView component with viewfinder overlay
- ConnectPrompt auto-detects mobile (touch + narrow viewport) and defaults to scan mode
- Lazy-load scanner component for zero initial bundle impact
- Graceful fallback to paste mode on permission denial or no camera

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 15:41:12 +08:00
Jiang Bohan
cea3336256 docs(desktop): update TODO list with core improvements
Remove completed items (device authorization, tools testing, token verification).
Add new priorities:
- Memory tool and memory.md unification
- Profile loading optimization (truncation)
- Agent self-iteration capability
- Local IPC direct communication mode

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 14:59:52 +08:00
Bohan Jiang
5760b86e80
Merge pull request #79 from multica-ai/feat/agent-style-setting
feat(desktop): add agent communication style setting
2026-02-04 14:48:29 +08:00
Jiang Bohan
5d102c0241 feat(desktop): add style selector to agent settings dialog
- Add IPC handlers for profile:getStyle and profile:setStyle
- Add style dropdown with 6 preset options in agent settings UI
- Display style descriptions to help users choose

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 14:42:29 +08:00
Jiang Bohan
4df39448be feat(agent): add communication style setting to profile
- Add AgentStyle type with 6 preset options (professional, friendly, etc.)
- Add getStyle/setStyle methods to ProfileManager
- Update soul.md template to include style section
- Add reloadSystemPrompt support for style changes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 14:42:23 +08:00
LinYushen
cfe2b8f2df
Merge pull request #78 from multica-ai/ws-auth-handshake
feat: WebSocket auth handshake with device verification
2026-02-04 14:20:02 +08:00
yushen
f63a67e341 refactor(hub): improve device whitelist persistence format
- Rename storage path from ~/.super-multica/devices/ to
  ~/.super-multica/client-devices/ for clarity
- Change JSON format from bare array to { version, devices[] }
  dict for future extensibility
- Auto-migrate legacy array format on load

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 14:16:59 +08:00
yushen
db69e0d08d fix(desktop): remove unsupported asChild prop from AlertDialogDescription
Radix UI version in this project doesn't support asChild on
AlertDialogDescription. Use inline spans with block display instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 14:12:14 +08:00
yushen
240f25b2be fix(desktop): remove unused setupDeviceConfirmation import
The import was redundant since it's already re-exported directly.
Fixes eslint no-unused-vars error in CI.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 14:07:46 +08:00
yushen
c3ded8da41 merge: resolve conflicts with origin/main
Merge remote main branch, keeping both device verification (ws-auth-handshake)
and agent settings/profile features from main.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 14:04:47 +08:00
yushen
c604085065 fix(desktop): address review issues in device verification flow
- Add 60s timeout to pending device confirms to prevent Promise leaks
  when client disconnects before user responds
- Add offDeviceConfirmRequest to preload and clean up IPC listener on
  component unmount to prevent duplicate listener accumulation
- Extract duplicated parseUserAgent into shared lib/parse-user-agent.ts
- Clean up expired tokens in DeviceStore.registerToken to prevent
  memory accumulation from unscanned QR codes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:54:09 +08:00
yushen
ef9b5af221 fix(hub): send error response to unverified device instead of silent drop
When an unverified device sends a non-RPC message, reply with an
"error" action containing UNAUTHORIZED code so the client knows
verification is required.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:46:29 +08:00
yushen
fcbe96645c feat(desktop): add verified device list and rich confirm dialog
Add DeviceList component on home page showing verified devices with
parsed User-Agent info (browser, OS) and relative time. Add useDevices
hook with listDevices/revokeDevice IPC. Update DeviceConfirmDialog to
show human-readable device info (e.g. "Chrome on macOS") instead of
raw device ID.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:43:54 +08:00
yushen
c581183839 feat(hub): store device metadata in whitelist and pass to confirm handler
Extend DeviceEntry with optional DeviceMeta field. Verify handler
extracts meta from params and passes it through to onConfirmDevice
callback and deviceStore.allowDevice for persistence.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:43:48 +08:00
yushen
dd701a2472 feat(sdk): collect device metadata during verify handshake
Auto-collect navigator.userAgent, platform, and language in the SDK
verify RPC payload. Add DeviceMeta type. Hub receives this metadata
for display in the Desktop UI device list and confirmation dialog.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:43:41 +08:00
yushen
ff827f05e4 feat(desktop): add device confirmation dialog and token registration IPC
Add DeviceConfirmDialog component that shows an AlertDialog when a new
device requests connection, letting the user Allow or Reject. Wire up
Electron IPC for token registration and device confirmation flow between
main process and renderer. Register QR code tokens with Hub on generate
and refresh.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:27:41 +08:00
yushen
3d13c28cfc feat(store): pass hubId and token to GatewayClient for verification
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:27:33 +08:00
yushen
b2c0711676 feat(hub): add device verification with token + whitelist + user confirmation
Add DeviceStore for managing one-time tokens and persistent device
whitelist. Create async verify RPC handler that validates tokens and
awaits Desktop user confirmation for first-time connections. Whitelisted
devices (reconnections) pass through instantly. Add message guard to
reject unverified device traffic.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:27:29 +08:00
yushen
0eac2b2a23 feat(sdk): add auto-verify handshake after gateway registration
Embed transparent verification logic in GatewayClient that automatically
sends an RPC "verify" request to the Hub after REGISTERED event. Adds
hubId, token, and verifyTimeout options. Upper-layer callers see no change
— "registered" state means both gateway registration and Hub verification
are complete. Failures surface via onError callback.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:27:23 +08:00
Jiang Bohan
1dc7539018 refactor(desktop): remove Profile ID display from home page
User-facing UI should not show internal profile IDs.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:26:40 +08:00
Jiang Bohan
a4f8cbd978 feat(desktop): improve profile IPC and error handling
- Add reloadSystemPrompt call after profile updates
- Add error handling and logging for Hub initialization
- Clean up debug logs from agent IPC handlers

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:26:40 +08:00
Jiang Bohan
fa03ae6e62 feat(agent): add soul.md support for agent identity
- Add getSoulContent/updateSoulContent to ProfileManager
- Create soul.md with agent name when updating profile name
- Add reloadSystemPrompt() method to Agent and AsyncAgent
- Include soul.md content in system prompt build

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:26:40 +08:00
Jiang Bohan
82f0ccbe85 docs(desktop): clean up README
Remove completed implementation details, keep only TODO items.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:26:40 +08:00
Jiang Bohan
bdc2006e0e feat(desktop): add agent settings dialog
Add UI for editing agent name and user preferences:
- AgentSettingsDialog component with name input and user.md textarea
- Agent Settings section on Home page with Edit button
- Auto-reload agent info when settings are saved

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:26:40 +08:00
Jiang Bohan
a157c6546d feat(desktop): add profile IPC handlers
Add IPC handlers for profile management:
- profile:get - Get profile name and user content
- profile:updateName - Update agent display name
- profile:updateUser - Update user.md content

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:26:40 +08:00
Jiang Bohan
a80c858ce5 feat(agent): add profile name and user content management
Add methods to ProfileManager, Agent, and AsyncAgent for:
- Getting/setting agent display name (stored in config.json)
- Getting/setting user.md content

This enables the desktop app to manage agent settings.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:26:40 +08:00
Naiyuan Qing
e9ed53b615
Merge pull request #77 from multica-ai/feat/clean-web-store
refactor(store+ui): consolidate stores, add skeleton loading, fetch history on reconnect
2026-02-04 10:32:53 +08:00
Naiyuan Qing
24b75d3398 chore: update lockfile after removing sonner from store
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 10:21:38 +08:00
Naiyuan Qing
986b08be48 chore(web): replace old icons with company logo
- Add logo.svg as the new brand logo
- Generate logo-192x192.png and logo-512x512.png from SVG for PWA
- Update app-header, manifest, and layout to reference new logo files
- Remove old icon.png, icon-192x192.png, icon-512x512.png

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 10:20:02 +08:00
Naiyuan Qing
972c887b43 refactor(apps): simplify layout components to pure navigation shells
- desktop layout.tsx: remove connection logic, keep header + tabs + outlet
- web app-header.tsx: remove connection logic, keep logo + theme toggle

Connection lifecycle is now owned by the shared Chat component.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 10:12:57 +08:00
Naiyuan Qing
62267aaf19 refactor(ui): split Chat into focused components with skeleton loading
- Extract ConnectPrompt: self-contained connection code input
- Extract MessageList: pure display of messages with streaming support
- Add ChatSkeleton: skeleton placeholder shown during reconnection
- Chat component: three-state rendering (skeleton → connect → messages),
  keeps <main ref> always mounted so useScrollFade works correctly
- Remove hub-sidebar.tsx (dead code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 10:12:51 +08:00
Naiyuan Qing
162a86dff4 refactor(store): consolidate 3 stores into ConnectionStore + MessagesStore
Replace useGatewayStore, useHubStore, useDeviceId, and useHubInit with:
- ConnectionStore: WebSocket lifecycle, deviceId persistence via Zustand persist,
  fetch message history on registration via getAgentMessages RPC
- MessagesStore: simplified to current-agent-only, sendMessage accepts SendContext
  to break circular import with ConnectionStore
- useAutoConnect: returns { loading } for skeleton UI, skips connect if already
  connected (fixes Electron tab-switch reconnect), no cleanup disconnect

Removes: gateway.ts, hub.ts, hub-init.ts, device-id.ts, sonner dep from store

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 10:12:45 +08:00
Jiayuan Zhang
32c406a2a4
Merge pull request #76 from multica-ai/forrestchang/desktop-qr-refresh
Shorten desktop QR code expiry
2026-02-03 21:24:47 +08:00
Jiayuan Zhang
eee6cf1341 fix(desktop): refresh qr every 30s 2026-02-03 21:21:54 +08:00
Jiayuan Zhang
f3261d312d
Merge pull request #75 from multica-ai/chore/pnpm-allow-build-scripts
chore(pnpm): allow electron and esbuild build scripts
2026-02-03 20:52:15 +08:00
Jiayuan Zhang
995be9d53b chore(pnpm): allow electron and esbuild build scripts
pnpm 10 blocks post-install scripts by default for security.
Added onlyBuiltDependencies to allow electron and esbuild to run
their required install scripts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:51:17 +08:00
Naiyuan Qing
91044dea0f
Merge pull request #74 from multica-ai/feat/connection-code
feat: connection code flow with cross-platform Chat
2026-02-03 20:35:13 +08:00
Naiyuan Qing
dacbfa9e3d refactor(ui): purify Chat component and move header to app layouts
- Remove all props from Chat (showHeader, headerActions) making it a
  zero-config pure chat component with only connection input, messages,
  and send functionality
- Create AppHeader client component for web app with brand, theme
  toggle, disconnect button, and useHubInit
- Add disconnect button to desktop layout header
- Add reset() action to hub store to eliminate duplicated state reset
- Remove unused token field from gateway store
- Remove dead code: connection-bar.tsx
- Guard handleConnect against empty deviceId race condition

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:31:24 +08:00
Naiyuan Qing
b6d7626239 fix(store): use string prefix + URLSearchParams for connection URL parsing
The URL constructor parses non-standard protocols (multica://)
differently across engines — Chromium may return empty hostname
while Node.js returns "connect". Replace new URL() with simple
startsWith check and URLSearchParams to ensure consistent behavior
in both web and Electron environments.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:13:51 +08:00
Naiyuan Qing
ff80cf0732 feat(desktop): integrate Chat component into desktop app
Add @multica/store and zustand to desktop dependencies. Replace
placeholder chat page with the shared Chat component. Add Toaster
for toast notifications and remove padding on the chat route.
Change Chat root from h-dvh to h-full for container adaptability.
Add showHeader prop to Chat; desktop passes showHeader={false}
since it has its own layout header.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:08:30 +08:00
Naiyuan Qing
a088875118 refactor(ui): move theme toggle from Chat to web app layout
Chat component no longer depends on next-themes, making it safe to use
in the desktop app. Theme toggle is now a fixed button in the web layout.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:02:48 +08:00
Naiyuan Qing
bb223d8a8c Merge branch 'main' into feat/connection-code 2026-02-03 19:42:41 +08:00
Naiyuan Qing
2bd87ccf5c theme buttom 2026-02-03 19:42:14 +08:00
Bohan Jiang
a995169278
Merge pull request #73 from multica-ai/feat/admin-app
feat(desktop): implement Admin App with Tools and Skills management
2026-02-03 19:29:19 +08:00
Jiang Bohan
f5a0d986a2 fix(desktop): resolve TypeScript build errors
- Disable noUnusedLocals/noUnusedParameters in desktop tsconfig
  (external src/ files have unused imports that fail strict checking)
- Add TSchema constraint to wrapTool generic to satisfy AgentTool type

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 19:26:25 +08:00
Jiang Bohan
0b83a7c416 fix(desktop): add 'registered' to ConnectionState type
Fix TypeScript error TS2367 by adding 'registered' state to match
SDK's ConnectionState type definition.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 19:20:45 +08:00