* 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> |
||
|---|---|---|
| apps/web | ||
| packages/sdk | ||
| src | ||
| .dockerignore | ||
| .gitignore | ||
| package.json | ||
| pnpm-lock.yaml | ||
| pnpm-workspace.yaml | ||
| README.md | ||
| tsconfig.json | ||
| turbo.json | ||
Super Multica
A multi-component architecture for distributed agent systems.
Project Structure
src/
├── agent/ # Agent module
│ ├── profile/ # Agent profile management
│ ├── session/ # Session persistence
│ └── tools/ # Agent tools (exec, process)
├── gateway/ # Gateway module
├── client/ # Client module
└── shared/ # Shared types and utilities
Getting Started
pnpm install
pnpm dev
Agent CLI
Use the agent module directly from the CLI for isolated testing.
# New sessions get a UUIDv7 ID (shown on start)
pnpm agent:cli "hello"
# [session: 019c0b0a-b111-765c-8bbd-f4149beac9c4]
# Continue a session
pnpm agent:cli --session 019c0b0a-b111-765c-8bbd-f4149beac9c4 "what did I say?"
# Or use a custom session name
pnpm agent:cli --session demo "remember my name is Alice"
pnpm agent:cli --session demo "what's my name?"
# Override provider/model
pnpm agent:cli --provider openai --model gpt-4o-mini "hi"
# Use an agent profile
pnpm agent:cli --profile my-agent "hello"
# Set thinking level
pnpm agent:cli --thinking high "solve this complex problem"
Sessions
Sessions persist conversation history to ~/.super-multica/sessions/<id>/. Each session includes:
session.jsonl- Message history in JSONL formatmeta.json- Session metadata (provider, model, thinking level)
Sessions use UUIDv7 for IDs by default, providing time-ordered unique identifiers. The agent automatically handles context compaction when conversations grow too long.
Agent Profiles
Agent profiles define identity, personality, tools, and memory for an agent. Profiles are stored as markdown files in ~/.super-multica/agent-profiles/<id>/.
Profile CLI
# Create a new profile with default templates
pnpm agent:profile new my-agent
# List all profiles
pnpm agent:profile list
# Show profile contents
pnpm agent:profile show my-agent
# Open profile directory in file manager
pnpm agent:profile edit my-agent
Profile Structure
Each profile contains:
identity.md- Agent name and rolesoul.md- Personality and behavioral constraintstools.md- Tool usage instructionsmemory.md- Persistent knowledgebootstrap.md- Initial conversation context
Agent Tools
exec
Execute short-lived shell commands and return output.
exec({ command: "ls -la", cwd: "/path/to/dir", timeoutMs: 30000 })
process
Manage long-running background processes (servers, watchers, daemons). Output is buffered (up to 64KB) and terminated processes are automatically cleaned up after 1 hour.
# Start a background process (returns immediately with process ID)
process({ action: "start", command: "npm run dev" })
# Check process status
process({ action: "status", id: "<process-id>" })
# Read process output
process({ action: "output", id: "<process-id>" })
# Stop a process
process({ action: "stop", id: "<process-id>" })
# Clean up terminated processes
process({ action: "cleanup" })
Scripts
pnpm dev- Run in development modepnpm agent:cli- Run the agent CLI for module-level testingpnpm agent:profile- Manage agent profilespnpm build- Build for productionpnpm start- Run production buildpnpm typecheck- Type check without emitting