Commit graph

148 commits

Author SHA1 Message Date
Jiayuan Zhang
03347d99fd
Merge pull request #62 from multica-ai/forrestchang/agent-error-handling
Fix tool error handling
2026-02-03 02:59:51 +08:00
Jiayuan
0385b0e025 test(agent): convert tool policy test 2026-02-03 02:30:47 +08:00
Naiyuan Qing
7122b12ad5
Merge pull request #61 from multica-ai/feat/text-stream
feat: streaming AI message rendering
2026-02-02 17:45:30 +08:00
Jiang Bohan
c55bb5a864 feat(cli): add /model command for switching models within provider
Add /model command to interactively switch models:
- /model: Show current model and list available models for provider
- /model <name>: Switch to specified model (preserves session)

Example usage:
  /model                    # Shows claude-opus-4-5, claude-sonnet-4-5, etc.
  /model claude-sonnet-4-5  # Switch to sonnet model

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 17:35:40 +08:00
Jiang Bohan
932ecb5dbb refactor(providers): move oauth/ to providers/oauth/ and simplify model names
- Move src/agent/oauth/ to src/agent/providers/oauth/ (parent-child structure)
- Delete deprecated oauth/providers.ts re-export file
- Simplify Claude model names: claude-opus-4-5 (without date suffix)
- Update Codex models to current lineup (gpt-5.2, gpt-5.1-codex, etc.)
- Set claude-opus-4-5 as default model for claude-code provider

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 17:35:35 +08:00
Jiang Bohan
1592e0c211 fix(types): add undefined to optional properties for exactOptionalPropertyTypes
- MemoryStorageOptions.baseDir: add | undefined
- FilterToolsOptions: add | undefined to all optional properties
- CreateToolsOptions: add | undefined to optional properties
2026-02-02 17:20:10 +08:00
Jiang Bohan
6723aa8561 refactor(providers): extract provider management to dedicated module
- Create src/agent/providers/ with registry.ts and resolver.ts
- registry.ts: Provider metadata, status checking, login instructions
- resolver.ts: API key resolution, model resolution
- oauth/providers.ts now re-exports from providers/ (deprecated)
- tools.ts: Remove PROVIDER_ALIAS and DEFAULT_MODELS (moved to providers/)
- Update imports in runner.ts and chat.ts

This separates concerns:
- oauth/ only handles OAuth credential reading
- providers/ manages all provider metadata and resolution
2026-02-02 17:20:02 +08:00
Naiyuan Qing
d04bed8175 feat(agent): add streaming support for AI message generation
AsyncAgent now subscribes to pi-agent-core events (message_start,
message_update, message_end) and forwards incremental text deltas
through a stream callback. Hub registers the callback and sends
stream payloads to the requesting client via Gateway.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 17:18:10 +08:00
Jiang Bohan
35b13f976d feat(runner): validate provider credentials on startup
- Add isOAuthProvider() and isProviderAvailable() helpers
- Show login instructions for OAuth providers without credentials
- Show configuration example for API Key providers without keys
- Fail early with helpful error message instead of cryptic API errors
2026-02-02 17:10:10 +08:00
Jiang Bohan
051e56dbf6 feat(cli): improve /provider command display with ID column
- Add ID column to show actual provider keys for --provider flag
- Add usage examples with actual command syntax
- Improve visual formatting with table headers
2026-02-02 17:10:05 +08:00
Jiang Bohan
da11e65d35 refactor(oauth): rename credentials/ to oauth/ for clarity
Separate OAuth credential reading (external CLI tools) from the main
CredentialManager (API Key configuration in credentials.json5).

- credentials.ts: API Key configuration management
- oauth/: External OAuth credential reading (Claude Code, Codex)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:52:04 +08:00
Jiang Bohan
9504eeab62 feat(cli): add /provider command to show and switch providers
The /provider command shows:
- Current provider and model
- List of available providers (OAuth and API Key)
- Status of each provider (configured/not configured)
- Instructions for switching providers

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:43:05 +08:00
Jiang Bohan
b9ce4da28f feat(runner): support OAuth providers (claude-code, openai-codex)
- Add provider alias mapping (claude-code -> anthropic)
- Resolve API key from OAuth credentials for claude-code and codex
- Add default models for each provider

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:43:00 +08:00
Jiang Bohan
05138029de feat(credentials): add CLI credentials reader for OAuth providers
Add support for reading OAuth credentials from external CLI tools:
- Claude Code: ~/.claude/.credentials.json or macOS Keychain
- Codex: ~/.codex/auth.json or macOS Keychain

Includes provider management with status checking and login instructions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:42:55 +08:00
Naiyuan Qing
ebcab2477a
Merge pull request #57 from multica-ai/feature/ws-migration
feat: migrate frontend to pure WebSocket RPC
2026-02-02 16:35:19 +08:00
Naiyuan Qing
3622f82a7b feat(gateway): add auto-connect, hub discovery via list-devices
- Add LIST_DEVICES event and "hub" device type to SDK
- Add listDevices() method to GatewayClient
- Add handleListDevices handler in Gateway
- Change Hub deviceType from "client" to "hub"
- Refactor gateway store: auto-connect WS, separate hubId selection
- Hub-init: auto-connect on mount, discover hubs on registered
- Hub-sidebar: show discovered hubs list with connect/disconnect UI

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:13:40 +08:00
Jiang Bohan
6f0be4a1cb feat(skills): implement progressive loading for reduced token usage
Changed buildModelSkillsPrompt() to only output skill metadata (name + description)
instead of full instructions. Full instructions are now loaded on-demand when a
skill is triggered via the new buildSkillPromptForInjection() method.

This reduces initial system prompt size significantly for projects with many skills.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-02 16:00:38 +08:00
Naiyuan Qing
1f22c3e578 feat(hub): register RPC handlers for hub, agent, and gateway operations
Add 5 new RPC methods (getHubInfo, listAgents, createAgent, deleteAgent,
updateGateway) mirroring the existing Console HTTP API, enabling pure
WebSocket communication from the frontend.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 15:27:07 +08:00
Jiayuan
32dd62747d fix(agent): soften tool errors 2026-02-02 15:17:17 +08:00
Bohan Jiang
64878d9fe1
Merge pull request #55 from multica-ai/feature/skills-profile-and-autocomplete-fix
feat(skills): add --profile option and fix autocomplete terminal issues
2026-02-02 14:13:06 +08:00
Jiang Bohan
452ba8b5bb fix(autocomplete): improve terminal compatibility and CJK support
- Add terminal support detection to gracefully fallback to simple readline
- Add getStringWidth() for proper CJK character width calculation
- Remove unreliable SAVE_CURSOR/RESTORE_CURSOR ANSI sequences
- Use relative cursor movement for better compatibility
- Handle edge case when cursor is at line boundary

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 14:11:36 +08:00
Jiang Bohan
58eb249e11 docs(skills): add profile-specific installation documentation
Update both English and Chinese README files with:
- CLI examples for --profile option
- Reorganized manual creation as alternative method

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 14:11:36 +08:00
Jiang Bohan
351afb13a7 feat(skills): add --profile option for installing to specific profile
- Add profileId parameter to SkillAddRequest interface
- Add getSkillsDir() helper to determine target directory
- Update CLI to parse --profile/-p option
- Update help text and error messages with new option

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 14:11:36 +08:00
Jiang Bohan
991937897d docs(skills): update CLI commands and add profile skills documentation
- Update skills/README.zh-CN.md: pnpm skills:cli → multica skills
- Add "Adding Profile-Specific Skills" section to both READMEs
- Document manual creation of profile-specific skills

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 14:11:36 +08:00
Jiang Bohan
3797e9e58b docs: update CLI commands to use unified multica format
- Update skills/README.md: pnpm skills:cli → multica skills
- Update tools/README.md: pnpm agent:cli, pnpm tools:cli → multica run, multica tools
- Update tools/README.zh-CN.md: same changes for Chinese docs
- Update test commands: npx tsx → pnpm test

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 14:11:36 +08:00
yushen
1e7d5f66ec feat(hub): add RPC dispatcher with structured error handling
Add RpcDispatcher and RpcError for method dispatch with typed error
codes (METHOD_NOT_FOUND, INVALID_PARAMS, AGENT_NOT_FOUND). Implement
getAgentMessages handler that checks session files on disk, supporting
both active and closed agents. Wire up RPC request/response flow in Hub.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 14:10:09 +08:00
Naiyuan Qing
3d7b13555f refactor(sdk): unify gateway-sdk into @multica/sdk package
Sync latest code from src/shared/gateway-sdk/ into packages/sdk/,
update all backend imports to use @multica/sdk, and remove the
duplicate src/shared/gateway-sdk/ directory.

- Translate Chinese comments to English in SDK source
- Fix package.json exports with default condition
- Add @multica/sdk as workspace dependency for backend
- Update imports in gateway, test-client, and hub

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 13:43:52 +08:00
Jiayuan Zhang
46b7906272
Merge pull request #51 from multica-ai/jiayuan/fix-web-search
fix(web-search): use correct model name based on Perplexity API key type
2026-02-02 00:55:31 +08:00
Jiayuan
52a8b5a612 fix(web-search): use correct model name based on Perplexity API key type
- Direct Perplexity API (pplx-*) uses "sonar-pro" model name
- OpenRouter (sk-or-*) uses "perplexity/sonar-pro" model name
- Refactor inferPerplexityBaseUrl to inferPerplexityConfig returning both baseUrl and model
- Export internal functions for potential reuse

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:49:41 +08:00
Jiayuan
8228643924 feat(skills): auto-sync bundled skills based on version comparison
When loading skills, automatically check if bundled skills have a higher
version than managed skills. If so, update the managed skill to the
newer bundled version.

This ensures users get skill updates when upgrading multica, without
needing manual intervention.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:15:40 +08:00
Jiayuan
a990a1c3ca feat(profile): add interactive setup command for agent profiles
- Add `multica profile setup <id>` command for interactive profile setup
- Create profile-setup skill with conversational setup wizard
- Agent collects user info through natural dialogue and updates profile files
- Supports updating user.md, workspace.md, and config.json

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 23:49:48 +08:00
Jiayuan
e7f84755b3 refactor(profile): simplify profile structure by removing identity and bootstrap
- Remove identity.md and bootstrap.md from profile files
- Merge identity content into soul.md (now contains identity, personality, and behavior)
- Update templates, storage, and types to reflect new structure
- Update tests to match new profile structure

Profile now has 4 files: soul.md, user.md, workspace.md, memory.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 23:49:37 +08:00
Jiayuan
52850920ac refactor(cli): unify CLI with multica command and subcommands
- Create unified entry point at src/agent/cli/index.ts
- Add subcommand modules: run, chat, session, profile, skills, tools, credentials, dev
- Support both 'multica' and 'mu' aliases
- Add session management commands (list, show, delete)
- Integrate dev server commands into CLI

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 23:09:44 +08:00
Jiayuan
f0aa1e1b4d feat(profile): add profile directory path to system prompt
- Update workspace.md template with Profile Files table explaining
  when to update each file
- Inject actual profile directory path in buildSystemPrompt()
- Add getProfileDir() method to ProfileManager
- Agent can now use edit/write tools to update profile files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:11:30 +08:00
Jiayuan
9661226979 feat(profile): enhance templates with user.md and workspace.md
- Enrich soul.md with core truths, boundaries, and continuity guidance
  inspired by moltbot's template design
- Add user.md template for building user profile and preferences
- Add workspace.md template for workspace behavior guidelines
- Update memory.md and bootstrap.md with more structured content
- Update all related storage, types, and test files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:04:35 +08:00
Jiayuan
e571bd5918 refactor(profile): remove tools.md template
The tools.md template content duplicated information already present in
each tool's schema description, causing maintenance burden and potential
inconsistencies. Tool usage guidelines can be added to soul.md if needed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 21:55:22 +08:00
Jiayuan
98a447b7a2 test(cli): add comprehensive tests for output formatting functions
Added 36 tests covering toolDisplayName, formatToolArgs, extractResultDetails, and formatResultSummary functions. Also refactored code to eliminate duplicate truncate function and remove unused variable.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-02-01 02:53:23 +08:00
Jiayuan
5520fec251 feat(cli): add detailed tool info display for glob, web_search, web_fetch
- Add display name mappings for glob, web_search, web_fetch tools
- Show relevant args: glob pattern, search query, URL hostname/path
- Display result summaries: file count, search results count, page title/size
- Add grep result summary showing match count

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 02:40:59 +08:00
Jiayuan
3ee8946e29 feat(credentials): add JSON5 credential system 2026-02-01 02:28:27 +08:00
Jiayuan Zhang
b1d80f29ae
feat(agent): enhance interactive CLI with colors, spinner, and status bar (#43)
* feat(agent): improve interactive CLI with colors, spinner, and status bar

- Add colors.ts module with ANSI terminal color utilities
- Add spinner animation for tool execution feedback
- Add persistent status bar showing session/provider/model
- Apply colors to welcome banner, prompts, commands, and suggestions
- Support NO_COLOR env for accessibility

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

* fix(agent): correct cursor position with ANSI-colored prompts

Strip ANSI escape codes when calculating visual length of prompt
to ensure cursor is positioned correctly after colored text.

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

* fix(agent): prevent duplicate input echo in interactive CLI

Lazy-initialize readline.Interface only when multiline mode is active.
This prevents readline from interfering with autocomplete's raw mode,
which was causing user input to be echoed twice.

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

* refactor(agent): move CLI files to dedicated cli/ directory

Reorganize CLI-related files into src/agent/cli/ for better separation:
- interactive.ts (was interactive-cli.ts)
- non-interactive.ts (was cli.ts)
- profile.ts, skills.ts, tools.ts (was *-cli.ts)
- autocomplete.ts, colors.ts, output.ts (CLI utilities)

Update all imports, package.json scripts, and build configuration.

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:07:07 +08:00
Jiayuan Zhang
b7e1063b3a
Merge pull request #42 from multica-ai/forrestchang/find-skills-location
Simplify skills loading to managed + profile sources
2026-01-31 18:58:32 +08:00
Jiayuan
53bd52b137 feat(agent): add process list action for activity monitoring
Add 'list' action to process tool that displays all registered processes
with their ID, command, status, duration, and source (exec/process).

Example output:
ID                                    COMMAND        STATUS       DURATION  SOURCE
019c139c-dbb7-70ec-ab91-0a7fd2711043  curl -X POST   running         15.2s  [exec]

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:49:16 +08:00
Jiayuan
aaf0522303 feat(cli): display real-time tool execution updates
Handle tool_execution_update events in CLI output to show live progress
while commands are running. Shows the last 60 characters of output on
a single line that updates in place.

This completes the real-time streaming feature added to exec tool.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:40:40 +08:00
Jiayuan
14bcebee2a feat(agent): add real-time streaming updates to exec tool
Utilize the onUpdate callback from pi-agent-core's AgentTool interface
to stream output updates in real-time while commands are executing.

- Accept onUpdate as 4th parameter in execute function
- Emit tailBuffer updates on each stdout/stderr data event
- Stop emitting updates once command is backgrounded (yielded)

This enables UI to show live command output progress via the
tool_execution_update agent event.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:31:50 +08:00
Jiayuan
cbb13b26d1 fix(agent): return collected output when exec auto-backgrounds
Previously, when a command exceeded yieldMs (default 5s) and was
auto-backgrounded, exec returned an empty output string. This caused
agents to misinterpret slow commands (like curl) as failed, leading
to infinite retry loops.

Changes:
- Implement three-layer buffer system (pending 30KB + aggregated 200KB + tail 1KB)
- Return collected output snapshot when backgrounding instead of empty string
- Increase default yieldMs from 5s to 10s for better coverage
- Add auto sweeper for terminated process cleanup (30min TTL)
- Register process immediately on spawn to capture all output

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:31:50 +08:00
Jiayuan
34358645de fix(cli): handle terminal line wrapping in autocomplete input
When input exceeds terminal width, the text wraps to new lines but the
old code only cleared one line, causing screen flashing and duplicate
lines. Now tracks input line count and cursor position across wrapped
lines for proper rendering.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:25:37 +08:00
Jiayuan
d90edea8d0 fix(skills): call initializeManagedSkills in loadAllSkills
Automatically initialize managed skills directory with bundled skills
on first load. This ensures bundled skills are available without
requiring explicit initialization.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:20:59 +08:00
Jiayuan
dafe1085b4 refactor(skills): simplify loading to managed + profile sources
- Remove bundled, extraDirs, and plugin skill sources
- Skills now load from only two sources:
  1. managed (~/.super-multica/skills/) - global skills
  2. profile (~/.super-multica/agent-profiles/<id>/skills/) - profile-specific
- Add initializeManagedSkills() to copy bundled skills on first run
- Delete plugin.ts (multica.plugin.json discovery)
- Update documentation and tests

This simplifies the architecture by treating bundled skills as
managed skills that are initialized once, rather than maintaining
multiple loading sources with complex precedence.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:16:16 +08:00
Jiang Bohan
22d60f889c docs(tools): simplify roadmap and add Chinese translation
- Replace phased roadmap with simple future tools list
- Add Chinese README (README.zh-CN.md)
- Add language switching links between EN/CN docs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
22536fd24c fix(memory): handle exactOptionalPropertyTypes for optional fields
Use spread operator to conditionally add description property
instead of assigning undefined to optional fields.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00