Commit graph

61 commits

Author SHA1 Message Date
yushen
0d1f48cf53 refactor(agent): rename env vars to LLM_PROVIDER and provider-specific MODEL
- AGENT_PROVIDER → LLM_PROVIDER
- AGENT_MODEL → provider-specific env vars (e.g., OPENAI_MODEL, DEEPSEEK_MODEL)
- Add resolveModelId function matching resolveApiKey/resolveBaseUrl pattern

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 13:20:20 +08:00
yushen
236863acd4 feat(agent): support AGENT_PROVIDER and AGENT_MODEL env vars
Add environment variable support for provider/model defaults:
- AGENT_PROVIDER: default LLM provider (fallback: kimi-coding)
- AGENT_MODEL: default model name
- Auto-load .env via tsx --env-file in agent:cli script

Priority: CLI args > env vars > session meta > defaults.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 13:15:11 +08:00
yushen
9858576abe feat(agent): support custom API key and base URL configuration
Add apiKey and baseUrl options to AgentOptions, with support for:
- Explicit values via CLI args (--api-key, --base-url)
- Provider-specific environment variables (e.g., OPENAI_BASE_URL)
- Generic fallback format (PROVIDER_BASE_URL)

Priority: CLI args > env vars > library defaults.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 13:12:24 +08:00
LinYushen
6f8c9ef383
Merge pull request #26 from multica-ai/view-recent-commits
feat(agent): add SyncAgent/AsyncAgent wrappers and integrate with Hub
2026-01-30 12:51:08 +08:00
yushen
0212b02f4e Merge remote-tracking branch 'origin/main' into view-recent-commits
# Conflicts:
#	.gitignore
2026-01-30 12:50:20 +08:00
yushen
e0615dbe69 chore: add .env to gitignore
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 12:48:22 +08:00
yushen
49540e63e7 refactor(hub): replace mock Agent with AsyncAgent
Hub now uses AsyncAgent from src/agent/ instead of its own Agent
implementation. Deleted hub/agent.ts and hub/channel.ts as they
are no longer needed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:58:21 +08:00
yushen
da80ba1cb0 refactor(agent): simplify AsyncAgent to use result.text instead of stream interception
Replace stdout/stderr stream interception with direct result.text push
to Channel. Also fix queued tasks still executing after close().

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:52:01 +08:00
yushen
6e82219630 feat(agent): add SyncAgent and AsyncAgent wrapper classes
Introduce two wrapper classes around the core Agent:
- SyncAgent: exposes run() for synchronous request-response usage
- AsyncAgent: exposes write()/read()/close() for non-blocking streaming via Channel

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:37:09 +08:00
Naiyuan Qing
438b1bd8d1
Merge pull request #25 from multica-ai/feat/extract-packages-ui
feat: extract shared packages (ui, store) and scaffold desktop app
2026-01-30 11:35:20 +08:00
Naiyuan Qing
6cc3a375e7 chore(desktop): clean up build artifacts and unused code
- Add dist-electron and release to .gitignore
- Remove tracked dist-electron build outputs from git
- Remove unused createRequire import in electron/main.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:34:09 +08:00
Naiyuan Qing
d7d2861a79 feat(store): add shared Zustand store package with counter example
- Create packages/store with @multica/store package
- Add zustand to pnpm catalog for version consistency
- Add counter store as cross-platform state example
- Integrate counter into ComponentExample for verification
- Add tsconfig path mappings for web and desktop
- Add @multica/store to Next.js transpilePackages
- Add @multica/store dependency to packages/ui

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:34:09 +08:00
Naiyuan Qing
eb5c388a80 refactor(ui): reorganize components into ui/ subdirectory and share layout
- Move shadcn components from src/components/ to src/components/ui/
- Move component-example and example from apps/web to packages/ui
- Update package.json exports with separate components/* and components/ui/* paths
- Update components.json ui alias in both packages/ui and apps/web
- Add missing @import "shadcn/tailwind.css" to globals.css
- Add new UI components: sheet, sidebar, skeleton, switch
- Update apps/web and apps/desktop to use shared ComponentExample

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:34:09 +08:00
Naiyuan Qing
141af9e9f1 feat(desktop): integrate @multica/ui shared components
Add @multica/ui workspace dependency with @tailwindcss/vite plugin
for CSS processing. Import globals.css for theme and replace template
UI with shared Button component. Remove unused template CSS files.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:34:09 +08:00
Naiyuan Qing
6431829b0c chore: unify shared deps with pnpm catalogs
Add catalog section to pnpm-workspace.yaml for react, react-dom,
@types/react, @types/react-dom, @types/node, and typescript.
Update all package.json files to use catalog: protocol.
Upgrade desktop from React 18 to 19. Rename to @multica/desktop.
Add dev:desktop script to root.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:34:09 +08:00
Naiyuan Qing
ff026b122d feat(desktop): scaffold Electron app with Vite
Add initial Electron desktop app using vite-plugin-electron template
with React and TypeScript.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:34:09 +08:00
Naiyuan Qing
663a9ec2a7 chore: update lockfile for packages/ui dependencies
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:34:05 +08:00
Naiyuan Qing
ae2a28037b chore: update .gitignore for monorepo build outputs
Add rules for .next, .turbo, build, tsbuildinfo, env files, and
platform-specific binaries (dmg, app, apk, ipa).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:34:05 +08:00
Naiyuan Qing
5c240ab363 refactor(web): update imports to use @multica/ui package
Replace local UI component and utility imports with @multica/ui
subpath imports. Remove old components/ui/ directory, lib/utils.ts,
and globals.css. Configure postcss, next.config, and tsconfig for
monorepo UI package consumption.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:34:05 +08:00
Naiyuan Qing
c1129ff37d feat(ui): extract components, utils, and styles from apps/web
Move 13 shadcn UI components, cn() utility, and theme CSS variables
to packages/ui for cross-platform reuse. Add @source directives for
Tailwind v4 content scanning.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:34:05 +08:00
Naiyuan Qing
e1443720eb feat(ui): create @multica/ui package skeleton
Shared UI package for web, electron, and mobile. Uses subpath exports
following the official shadcn monorepo template pattern.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:34:05 +08:00
LinYushen
1bf2b47fca
Merge pull request #24 from multica-ai/ldnvnbl/hub-gateway-config
Add gateway URL configuration to Hub Console
2026-01-30 11:01:39 +08:00
yushen
6deac2f76a Add gateway URL configuration to Hub Console
Allow changing the gateway connection URL at runtime via a new
PUT /hub/gateway endpoint and a corresponding input form in the
console UI.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:01:06 +08:00
Jiayuan
52d55829e5
docs: update README with current architecture (#23)
- Add context-window, skills, hub modules to project structure
- Add apps/web, packages/sdk, and skills directories
- Document new tools: glob, web_fetch, web_search
- Add context window management section
- Add skills system documentation with format and eligibility
- Add distributed architecture section (gateway, hub)
- Reorganize scripts section by category

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 05:37:47 +08:00
Jiayuan
4b71e3ccef
docs(agent): add web tools to profile templates (#22)
Add documentation for web_fetch and web_search tools to the default
agent profile templates. Also adds additional options info for glob
and usage guidelines for the web tools.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 05:33:27 +08:00
Jiayuan
50ae997ab4
feat(agent): add skills system with profile integration (#21)
* chore(deps): add yaml package for skill parsing

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

* feat(agent): add skills system

Implement a skills system inspired by moltbot's approach:

- Skills are markdown files (SKILL.md) with YAML frontmatter
- Multi-source loading with precedence: bundled < user < workspace
- Eligibility filtering based on platform, binaries, and env vars
- Skills are automatically included in agent system prompt
- New AgentOptions: enableSkills, skillsBaseDir, extraSkillDirs

Includes two bundled skills:
- commit: Git commit helper with conventional commit guidelines
- code-review: Code review checklist and best practices

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

* refactor(skills): use profile-based skills instead of workspace

Change skill loading from workspace-based (.skills/) to profile-based:
- Skills now load from ~/.super-multica/agent-profiles/<profileId>/skills/
- Remove workspace and user skill sources
- Simplify to only bundled and profile sources
- Profile skills have higher precedence than bundled

This is more appropriate for non-coding agents where skills are
associated with agent identity rather than working directory.

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 05:21:57 +08:00
Jiayuan
9b3ffd1e90
feat(agent): add web_fetch and web_search tools (#20)
* chore(deps): add web tools dependencies

Add undici, @mozilla/readability, linkedom, and turndown for
web fetching and HTML content extraction capabilities.

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

* feat(agent): add web_fetch and web_search tools

Port network tools from moltbot with the following features:

web_fetch:
- Fetch and extract readable content from URLs
- Dual extraction mode: readability (smart) or turndown (full page)
- SSRF protection (blocks private IPs, localhost)
- Response caching with TTL
- Redirect handling

web_search:
- Brave Search API for traditional results
- Perplexity API for AI-synthesized answers
- Region/language settings
- Freshness filtering (Brave only)
- Auto-detects provider from available API keys

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

* feat(agent): register web_fetch and web_search tools

Add web tools to the agent's tool registry.

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 05:09:16 +08:00
Jiayuan
028c3a2911
docs(agent): update tools template with complete tool documentation (#19)
Add documentation for glob tool, exec auto-backgrounding, and process
actions. Reorganize into File Operations and Command Execution sections
with usage guidelines.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 04:40:20 +08:00
Jiayuan
95e6ae439d
feat(agent): add glob tool for file pattern matching (#18)
Add a glob tool that allows agents to find files matching glob patterns.
Features:
- Supports standard glob patterns (e.g., **/*.ts, src/**/*.{js,jsx})
- Results sorted by modification time (most recent first)
- Configurable result limit and ignore patterns
- Default ignores for node_modules, .git, dist, etc.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 04:33:01 +08:00
Jiayuan
5931e8f84e
feat(agent): add auto-backgrounding and process management (#17)
* feat(agent): add auto-backgrounding to exec tool

- Add yieldMs parameter to exec tool (default 5s) - commands that don't
  complete within this time automatically run in background
- Create shared process-registry.ts for unified process management
- Refactor process.ts to use shared registry
- Add --debug CLI flag for session message logging
- Signal isolation: backgrounded processes ignore abort signals

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

* fix(session): preserve tool_use/tool_result pairs during compaction

Previously, session compaction simply kept the last N messages, which
could break tool_use/tool_result pairs if the cut point fell between
them. This caused "tool_call_id is not found" errors from the API.

Now compaction finds a safe cut point that starts from either:
- A user message without tool_result
- An assistant message whose tool_use is needed by the next tool_result

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

* feat(session): use Kimi as default model for summary compaction

- Auto-detect MOONSHOT_API_KEY from environment
- Use moonshot-v1-128k (cheaper than k2-thinking)
- Fall back to tokens mode if API key not available

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

* docs: add rule to never use git commit --amend

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

* docs: clarify git amend rule for immediate fixes

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 04:22:42 +08:00
Jiayuan
e2e8cc15d6
docs: add CLAUDE.md with atomic commits instructions (#16) 2026-01-30 04:05:05 +08:00
Jiayuan
3a435aac8a
docs: translate comments from Chinese to English (#15)
Translate all comments, JSDoc strings, and documentation text from Chinese to English across 19 files for improved accessibility and consistency with the broader developer community.

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-30 04:01:14 +08:00
Jiayuan
67cd46a072
feat(agent): add context window management with token-aware compaction (#14)
* feat(agent): add context window guard to prevent token overflow

Implement token-aware context management that validates context window
size on agent initialization and provides intelligent message compaction
based on actual token usage rather than simple message count.

Key changes:
- Add context-window module with guard, token estimation, and types
- Support both "count" (legacy) and "tokens" (new default) compaction modes
- Warn when context window < 32K tokens, block when < 16K tokens
- Trigger compaction at 80% utilization, target 50% after compaction

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

* feat(agent): add summary-based compaction using LLM

Implement intelligent compaction that uses LLM to generate summaries
of older messages instead of simply truncating them. This preserves
important context like key decisions, TODOs, and technical details.

Key changes:
- Add summarization.ts with compactMessagesWithSummary functions
- Support chunked summarization for very large histories
- Add "summary" compaction mode alongside "count" and "tokens"
- Auto-resolve API key from environment based on provider
- Graceful fallback to "tokens" mode if model/apiKey unavailable

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 03:46:11 +08:00
Jiayuan
3024e89071
Merge pull request #13 from multica-ai/forrestchang/interactive-cli
feat(agent): add interactive CLI for agent interaction
2026-01-30 03:31:09 +08:00
Jiayuan
14d22640e3 feat(agent): add interactive CLI for agent interaction
Introduce a new interactive CLI that provides a REPL interface for continuous conversation with the agent. Features include multi-line input mode, session management, built-in commands, and streaming output integration with existing agent infrastructure.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-30 03:29:45 +08:00
Jiayuan
dc1fba6a9b
Merge pull request #12 from multica-ai/forrestchang/agent-arch-review
feat(agent): implement agent profile system
2026-01-30 03:15:57 +08:00
Jiayuan
c8cb7c1a5a docs: enhance README with session management details
- Add UUIDv7 session ID examples and continuation workflow
- Add new Sessions section documenting storage format
- Add --thinking CLI option example
- Document process tool output buffering and auto-cleanup

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 03:12:57 +08:00
Jiayuan
6e8307e09b docs: update README with profile system and tools documentation
- Document agent profile system and profile CLI commands
- Document exec and process tools with usage examples
- Update project structure to reflect new directories

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 03:11:29 +08:00
Jiayuan
99473af854 fix(agent): prevent memory leak and buffer overflow in process tool
- Add TTL-based auto-cleanup for terminated processes (1 hour)
- Add 'cleanup' action for manual removal of terminated processes
- Fix buffer overflow when single chunk exceeds MAX_OUTPUT_BUFFER
- Track terminatedAt timestamp for cleanup eligibility

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 03:08:24 +08:00
Jiayuan
200b2cefda feat(agent): add profile system and improve tools
- Add Agent Profile module for managing agent identity, soul, tools,
  memory, and bootstrap configuration
- Add profile CLI (pnpm agent:profile) for creating/listing/showing profiles
- Default sessionId to UUIDv7 instead of "default"
- Expose Agent.sessionId as public readonly property
- Improve exec/process tools error handling (no more crashes on spawn errors)
- Add 'output' action to process tool for reading stdout/stderr
- Better tool descriptions to guide agent in choosing exec vs process

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:47:30 +08:00
Jiayuan
46a6cb3061
Merge pull request #10 from multica-ai/feat/exec-process-tools
feat(agent): add exec/process tools
2026-01-30 01:54:00 +08:00
Jiayuan
1097ef5144 feat(agent): add exec/process tools 2026-01-30 01:52:10 +08:00
Jiayuan
3e7fa97296 chore(agent): drop bash tool alias 2026-01-30 01:51:29 +08:00
Jiayuan
307e7fa8ee
Merge pull request #9 from multica-ai/refactor/agent-structure
Refactor/agent structure
2026-01-30 01:40:01 +08:00
Jiayuan
c189eb7188
Merge pull request #7 from multica-ai/feat/session-persistence
feat(agent): session persistence
2026-01-30 01:34:46 +08:00
Jiayuan
674a88c61e docs: add agent CLI usage 2026-01-30 01:33:08 +08:00
Jiayuan
49122e252b feat(agent): add session persistence and compaction 2026-01-30 01:29:21 +08:00
Jiayuan
dd0fd2fd3b
Merge pull request #6 from multica-ai/refactor/agent-structure
refactor(agent): split runner/tools/output
2026-01-30 01:15:31 +08:00
Jiayuan
5fdae53687 refactor(agent): split runner, tools, output, types 2026-01-30 01:12:48 +08:00
Jiayuan
c0e3dabf25
Merge pull request #5 from multica-ai/feat/agent-cli
feat(agent): integrate pi-agent core and add test CLI
2026-01-30 01:06:39 +08:00