|
| 1 | +# Project Structure |
| 2 | + |
| 3 | +Open Alice is a pnpm monorepo with Turborepo build orchestration. |
| 4 | + |
| 5 | +``` |
| 6 | +packages/ |
| 7 | +├── ibkr/ # @traderalice/ibkr — IBKR TWS API TypeScript port |
| 8 | +└── opentypebb/ # @traderalice/opentypebb — OpenBB platform TS port |
| 9 | +ui/ # React frontend (Vite, 13 pages) |
| 10 | +src/ |
| 11 | +├── main.ts # Composition root — wires everything together |
| 12 | +├── core/ |
| 13 | +│ ├── agent-center.ts # Top-level AI orchestration, owns ProviderRouter |
| 14 | +│ ├── ai-provider-manager.ts # GenerateRouter + StreamableResult + AskOptions |
| 15 | +│ ├── tool-center.ts # Centralized tool registry (Vercel + MCP export) |
| 16 | +│ ├── mcp-export.ts # Shared MCP export layer with type coercion |
| 17 | +│ ├── session.ts # JSONL session store + format converters |
| 18 | +│ ├── compaction.ts # Auto-summarize long context windows |
| 19 | +│ ├── config.ts # Zod-validated config loader |
| 20 | +│ ├── event-log.ts # Append-only JSONL event log |
| 21 | +│ ├── connector-center.ts # ConnectorCenter — push delivery + last-interacted tracking |
| 22 | +│ ├── async-channel.ts # AsyncChannel for streaming provider events to SSE |
| 23 | +│ ├── tool-call-log.ts # Tool invocation logging |
| 24 | +│ ├── media.ts # MediaAttachment extraction |
| 25 | +│ ├── media-store.ts # Media file persistence |
| 26 | +│ └── types.ts # Plugin, EngineContext interfaces |
| 27 | +├── ai-providers/ |
| 28 | +│ ├── vercel-ai-sdk/ # Vercel AI SDK ToolLoopAgent wrapper |
| 29 | +│ ├── agent-sdk/ # Claude backend (@anthropic-ai/claude-agent-sdk, OAuth + API key) |
| 30 | +│ └── mock/ # Mock provider (testing) |
| 31 | +├── domain/ |
| 32 | +│ ├── trading/ # Unified multi-account trading, guard pipeline, git-like commits |
| 33 | +│ │ ├── account-manager.ts # UTA lifecycle (init, reconnect, enable/disable) + registry |
| 34 | +│ │ ├── git-persistence.ts # Git state load/save |
| 35 | +│ │ ├── brokers/ |
| 36 | +│ │ │ ├── registry.ts # Broker self-registration (configSchema + configFields + fromConfig) |
| 37 | +│ │ │ ├── alpaca/ # Alpaca (US equities) |
| 38 | +│ │ │ ├── ccxt/ # CCXT (100+ crypto exchanges) |
| 39 | +│ │ │ ├── ibkr/ # Interactive Brokers (TWS/Gateway) |
| 40 | +│ │ │ └── mock/ # In-memory test broker |
| 41 | +│ │ ├── git/ # Trading-as-Git engine (stage → commit → push) |
| 42 | +│ │ ├── guards/ # Pre-execution safety checks (position size, cooldown, whitelist) |
| 43 | +│ │ └── snapshot/ # Periodic + event-driven account state capture, equity curve |
| 44 | +│ ├── market-data/ # Structured data layer (opentypebb in-process + OpenBB API remote) |
| 45 | +│ │ ├── equity/ # Equity data + SymbolIndex (SEC/TMX local cache) |
| 46 | +│ │ ├── crypto/ # Crypto data layer |
| 47 | +│ │ ├── currency/ # Currency/forex data layer |
| 48 | +│ │ ├── commodity/ # Commodity data layer (EIA, spot prices) |
| 49 | +│ │ ├── economy/ # Macro economy data layer |
| 50 | +│ │ └── client/ # Data backend clients (opentypebb SDK, openbb-api) |
| 51 | +│ ├── analysis/ # Indicators, technical analysis |
| 52 | +│ ├── news/ # RSS collector + archive search |
| 53 | +│ ├── brain/ # Cognitive state (memory, emotion) |
| 54 | +│ └── thinking/ # Safe expression evaluator |
| 55 | +├── tool/ # AI tool definitions — thin bridge from domain to ToolCenter |
| 56 | +│ ├── trading.ts # Trading tools (delegates to domain/trading) |
| 57 | +│ ├── equity.ts # Equity fundamental tools |
| 58 | +│ ├── market.ts # Symbol search tools |
| 59 | +│ ├── analysis.ts # Indicator calculation tools |
| 60 | +│ ├── news.ts # News archive tools |
| 61 | +│ ├── brain.ts # Cognition tools |
| 62 | +│ ├── thinking.ts # Reasoning tools |
| 63 | +│ ├── browser.ts # Browser automation tools (wraps openclaw) |
| 64 | +│ └── session.ts # Session awareness tools |
| 65 | +├── server/ |
| 66 | +│ ├── mcp.ts # MCP protocol server |
| 67 | +│ └── opentypebb.ts # Embedded OpenBB-compatible HTTP API (optional) |
| 68 | +├── connectors/ |
| 69 | +│ ├── web/ # Web UI (Hono, SSE streaming, sub-channels) |
| 70 | +│ ├── telegram/ # Telegram bot (grammY, magic link auth, /trading panel) |
| 71 | +│ ├── mcp-ask/ # MCP Ask connector (external agent conversation) |
| 72 | +│ └── mock/ # Mock connector (testing) |
| 73 | +├── task/ |
| 74 | +│ ├── cron/ # Cron scheduling (engine, listener, AI tools) |
| 75 | +│ └── heartbeat/ # Periodic heartbeat with structured response protocol |
| 76 | +└── openclaw/ # ⚠️ Frozen — DO NOT MODIFY |
| 77 | +data/ |
| 78 | +├── config/ # JSON configuration files |
| 79 | +├── sessions/ # JSONL conversation histories (web/, telegram/, cron/) |
| 80 | +├── brain/ # Agent memory and emotion logs |
| 81 | +├── cache/ # API response caches |
| 82 | +├── trading/ # Trading commit history + snapshots (per-account) |
| 83 | +├── news-collector/ # Persistent news archive (JSONL) |
| 84 | +├── cron/ # Cron job definitions (jobs.json) |
| 85 | +├── event-log/ # Persistent event log (events.jsonl) |
| 86 | +├── tool-calls/ # Tool invocation logs |
| 87 | +└── media/ # Uploaded attachments |
| 88 | +default/ # Factory defaults (persona, heartbeat, skills) |
| 89 | +docs/ # Documentation |
| 90 | +``` |
0 commit comments