Port from OpenClaw:
- session-write-lock: file-level write lock with atomic creation, reference
counting, stale lock detection, and process cleanup handlers
- session-file-repair: auto-detect and repair malformed JSONL lines with
backup and atomic rename
- session-transcript-repair: fix tool call/result pairing issues including
displaced results, duplicates, orphans, and missing inputs
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add minLength:1 to sessions_spawn task parameter to prevent empty
task strings. Remove parentSessionId from AgentOptions as the
subagent registry tracks lineage via requesterSessionId.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Call initSubagentRegistry() after setHub() in Hub constructor to
restore persisted runs. Call shutdownSubagentRegistry() before
closing agents in shutdown() to mark active runs as ended.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace for-await stream consumption in watchChildAgent with
waitForIdle() + onClose() callbacks on AsyncAgent. This prevents
conflict with Hub.consumeAgent() which also reads the Channel.
Add shutdownSubagentRegistry() for clean Hub shutdown, guard
Hub access with isHubInitialized(), and clean resumedRuns in sweep.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Register sessions_spawn tool in the tool system with TypeBox schema.
Subagents are blocked from spawning nested subagents via both tool
policy (DEFAULT_SUBAGENT_TOOL_DENY) and runtime guard. Add group:subagent
tool group and parentSessionId to AgentOptions.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add global Hub singleton for cross-module access by subagent tools.
Add createSubagent() method to Hub for spawning ephemeral child agents
with isSubagent flag and custom system prompts.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement subagent registry, persistence store, and announcement flow
for child agent lifecycle management. Includes types, registry with
auto-archive sweeper, session JSONL reading for result extraction,
and formatted announcement message delivery.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Only forward message_start/update/end (assistant role) and
tool_execution_start/end to clients. Drop agent_start, agent_end,
turn_start, turn_end, and tool_execution_update at the Hub layer.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Expose PiAgentCore events through the full backend pipeline:
- Agent.subscribe() transparently forwards engine events
- AsyncAgent pushes all AgentEvent into Channel alongside error Messages
- Hub discriminates ChannelItem and forwards events via StreamAction
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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>
- 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>
- 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
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>
- 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
- Add ID column to show actual provider keys for --provider flag
- Add usage examples with actual command syntax
- Improve visual formatting with table headers
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>
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>
- 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>
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>
- 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>
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>
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>
- 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>
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>
- 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>
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>
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>
- 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>
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>
- 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>
- 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>
- 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>
- 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>
- 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>