Skip to content

v0.9: Unified trading, OpenTypeBB, Agent SDK, SSE streaming#41

Merged
luokerenx4 merged 23 commits intomasterfrom
dev
Mar 12, 2026
Merged

v0.9: Unified trading, OpenTypeBB, Agent SDK, SSE streaming#41
luokerenx4 merged 23 commits intomasterfrom
dev

Conversation

@luokerenx4
Copy link
Copy Markdown
Contributor

Summary

57 commits, 513 files changed (+34k/-9k). This is a major release covering four themes: unified trading architecture, TypeScript-native market data, third AI provider, and frontend streaming.

1. Unified Trading Architecture

  • Multi-account trading — unified Contract, ITradingAccount, AccountManager abstractions across CCXT (crypto) and Alpaca (equities)
  • Platform + Account modelplatforms.json defines exchange types, accounts.json holds credentials and guards. Legacy crypto.json/securities.json still supported
  • Guard pipeline — merged crypto + securities guards into a single extensible pipeline (max position size, cooldown, symbol whitelist)
  • Git-like workflow — renamed wallet*trading* tools. Stage → commit → push with 8-char SHA hashes
  • Tool routing — unified source parameter across all trading tools for multi-account dispatch
  • IBKR-aligned OrderRequest — added modifyOrder, removed adjustLeverage
  • Unified symbol searchequitySearch + cryptoSearch + currencySearch merged into marketSearchForResearch
  • Alpaca improvements — realized PnL via FILL activities, init retry with exponential backoff
  • CCXT improvements — read-only mode for keyless market data, sequential loadMarkets with per-type retries

2. OpenTypeBB — TypeScript-Native Market Data

  • Replaced Python OpenBB sidecar with in-process opentypebb SDK (packages/opentypebb/)
  • Coverage — equity, crypto, commodity, currency, macro economy, news, derivatives
  • ~40 economy/commodity routes — FRED, OECD, BLS, EIA providers
  • Backend selector — choose between SDK mode and optional embedded HTTP API server (port 6901)
  • No external dependencies — no Python, no sidecar process, just TypeScript

3. Agent SDK — Third AI Provider

  • @anthropic-ai/claude-agent-sdk as a new provider backend alongside Claude Code CLI and Vercel AI SDK
  • Streaming event layer — all three providers now push tool_use / tool_result / text events via AsyncChannel
  • Architecture refactor — Engine deleted, AgentCenter is now the top-level orchestration center. connector-registryconnector-center
  • Per-channel AI config — web sub-channels can override provider/model/baseUrl/apiKey independently

4. Frontend — SSE Streaming & UI Polish

  • Real-time SSE streaming — tool call spinners, incremental text display, thinking dots during generation gaps
  • Sub-channel support — popover channel selector, per-channel config modal
  • React Router — URL-based navigation across all pages
  • 3 rounds of UI polish — redesigned chat input, sidebar, card system, shared components, transitions, toast system, send spinner, mobile fixes
  • Expanded pages — Portfolio redesign, Trading config CRUD with modal dialogs, DataSources redesign, AI Provider page, Heartbeat page, Tools page, Connectors page

5. Housekeeping

  • AGPL-3.0 relicense
  • Hono security bump (4.12.5)
  • README updated for all architectural changes
  • Dead code cleanup, stale reference fixes

Breaking Changes

  • Engine class removed — callers should use AgentCenter directly
  • connector-registry.ts renamed to connector-center.ts
  • src/providers/ moved to src/ai-providers/
  • wallet* tool names renamed to trading*
  • equitySearch / cryptoSearch / currencySearch merged into marketSearchForResearch
  • model.json config file removed
  • adjustLeverage removed from OrderRequest

Test plan

  • pnpm build — backend + UI compile clean
  • pnpm test — all tests pass
  • Start with pnpm dev, open localhost:3002
  • Send a message — verify SSE streaming (tool spinners → checkmarks → text)
  • Switch AI provider via Settings — verify claude-code / vercel-ai-sdk / agent-sdk all work
  • Create a sub-channel with custom AI config — verify independent model routing
  • Trading flow — stage order, commit, push (paper/sandbox account)
  • Heartbeat fires on schedule and delivers via ConnectorCenter
  • Cron job creation and execution via Web UI
  • Portfolio page loads positions and PnL from connected accounts

🤖 Generated with Claude Code

luokerenx4 and others added 23 commits March 10, 2026 22:19
… interface

- Rename _opts → opts in askWithSession; wire opts.systemPrompt to agent
  cache key so per-call system prompt overrides are respected
- Replace ambiguous 'engine' source tag with 'vercel-ai' across provider,
  session type, default value, web-plugin, and engine.spec
- Clean up AskOptions comments: document per-provider behavior instead of
  "Claude Code only" annotations

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Vendor OpenTypeBB (TypeScript port of OpenBB, 11 providers, 114 fetcher
models, 109 routes) into packages/opentypebb/ and wire it as SDK clients,
eliminating the Python sidecar dependency (localhost:6900).

- Add packages/opentypebb/ as vendored dependency (link: protocol)
- Add SDK infrastructure: executor singleton, route-map builder, base-client
- Add 6 SDK clients (128 methods) mirroring the HTTP client interfaces
- Add duck-typed interfaces (EquityClientLike etc.) for adapter compatibility
- Add buildSDKCredentials() for credential mapping to executor format
- Switch main.ts from HTTP clients to SDK clients (~10 lines)
- Extension adapters unchanged (zero logic changes, only import types)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
open-alice runs via `tsx src/main.ts` which transpiles .ts on-the-fly.
The previous exports pointed to dist/ (compiled JS), meaning a build
step was required after clone. Now exports point directly to src/*.ts,
letting tsx handle transpilation. dist/ is no longer needed at runtime.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ones

Replace flat linear layout with two visually separated zones that reflect
the fundamental difference between structured market data (OpenBB) and
accumulative open intelligence (news feeds).

- Remove SDKSelector "Active Sources" section; enable/disable moves into
  each zone's header toggle
- Add Zone component: bordered card with title, subtitle, badge, and toggle
- Market Data Engine zone: unified asset provider grid merges per-class
  provider select with inline API key input and test button; utility/macro
  providers (FRED, BLS, EIA, etc.) in separate collapsible section
- Open Intelligence zone: feeds list promoted to primary position above
  settings; settings rendered in compact two-column layout
- Add PROVIDER_KEY_MAP to drive which providers need keys and their key names
- Fix handleKeyChange to merge full providerKeys before saving, preventing
  asset vs utility key sections from clobbering each other

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Expose two independent config dimensions in the Market Data Engine:

1. Data backend selection (sdk | openbb):
   - SDK: uses opentypebb in-process executor (default, no external deps)
   - OpenBB: connects to an external OpenBB HTTP server via apiUrl
   - main.ts conditionally instantiates SDK or HTTP clients based on config
   - Connection URL field now only shown when external backend is selected

2. Embedded OpenBB API server:
   - New src/openbb/api-server.ts starts an opentypebb Hono HTTP server
   - Exposes OpenBB-compatible /api/v1/* endpoints for external tools
   - Configurable port (default 6901), toggle in UI
   - Runs independently of which backend Alice uses internally

Config schema additions (src/core/config.ts):
  - openbb.dataBackend: 'sdk' | 'openbb' (default: 'sdk')
  - openbb.apiServer: { enabled: boolean, port: number } (default: off/6901)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Market data feature now describes opentypebb as no-sidecar-required
- openbb.json config row updated with dataBackend and apiServer fields
- Project structure expanded with sdk/, api-server.ts, and credential-map.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…LS, EIA providers

Implements Phase 12 of the OpenBB migration: populate all missing economy
and commodity endpoints so the SDK's 42 economy methods and 6 commodity
methods resolve to real fetchers instead of throwing "No SDK route".

New providers: BLS (labor statistics), EIA (energy data), Stub (shipping placeholders).
New sub-routers: survey (9 routes), GDP (3), shipping (4 stubs), commodity/price (1).
FRED helpers extracted into shared utility for 18 Federal Reserve fetchers.
OECD helpers extracted for 6 new international data fetchers.
Total route count: 143 (up from ~103).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Web UI now supports multiple independent chat channels. Each channel has
its own session (isolated context), and can optionally override the system
prompt, AI provider/model, and tool permissions.

Backend:
- AskOptions: add disabledTools and provider fields
- ProviderRouter: per-request provider override before falling back to config
- VercelAIProvider: filter tools by disabledTools (skip agent cache when active)
- ClaudeCodeProvider: merge disabledTools into disallowedTools
- WebPlugin: multi-session + per-channel SSE routing
- Chat routes: accept channelId in POST, channel query in history/events
- New channels CRUD route (GET/POST/PUT/DELETE /api/channels)
- Config: webSubchannelSchema + read/write helpers for web-subchannels.json

Frontend:
- Channel tab bar in ChatPage with create/delete support
- API client for channels CRUD
- chat.send/history/connectSSE accept channel parameter

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace tab bar with minimal # icon popover for channel switching.
Sub-channel view shows thin context bar with back navigation.
Add ChannelConfigModal for editing label, system prompt, provider,
and per-channel tool permissions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The world news tool was not useful for the trading agent. Remove it
from the news adapter, clean up the piggyback wrapper, and drop the
unused worldProvider parameter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…l/apiKey)

Channels can now specify exact LLM provider, model ID, base URL, and API key
under a nested vercelAiSdk config. Model factory accepts ModelOverride for
per-request model creation. UI shows conditional config section when backend
is set to Vercel AI SDK.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduce @anthropic-ai/claude-agent-sdk as a new provider alongside
claude-code CLI and vercel-ai-sdk. The Agent SDK spawns Claude Code
as a typed subprocess with in-process MCP tool injection, env-based
API key injection (from ai-provider.json), and per-channel overrides.

New files:
- ai-providers/agent-sdk/tool-bridge.ts — ToolCenter → createSdkMcpServer
- ai-providers/agent-sdk/query.ts — wraps query() with env/config
- ai-providers/agent-sdk/session.ts — 7-step session management
- ai-providers/agent-sdk/agent-sdk-provider.ts — AIProvider impl

Config/routing extended across config.ts, ai-provider.ts, ai-config.ts,
session.ts, main.ts, web routes, and Telegram plugin.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Agent SDK as third option in backend toggle, channel config
dropdown, and per-channel override (model/baseUrl/apiKey).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduce StreamableResult (PromiseLike + AsyncIterable) so that
askWithSession() exposes intermediate tool_use / tool_result / text
events to upper layers while keeping full backward compatibility
for existing `await` callers.

- Add ProviderEvent union type and StreamableResult class (tee pattern)
- Add AsyncChannel push-to-pull bridge for callback-based providers
- Convert all three providers (Claude Code, Agent SDK, Vercel AI SDK)
  to return StreamableResult via async generators
- Add onToolUse callback to Claude Code and Agent SDK configs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- ChatInput: send button activates on text input (gray→blue), focus glow,
  Shift+Enter hint, arrow icon
- ChatMessage: fix redundant ml-8 ternary, add JSON syntax highlighting
  to tool call display, speed up thinking dots (1.4s→0.9s)
- Sidebar: add left accent bar on active nav item, ping animation on
  SSE disconnect status
- Form system: new Card component, Section auto-wraps in Card for visual
  grouping, Field gets font-medium label + optional description prop,
  inputClass gets rounded-lg + focus glow
- All Section-based pages (Settings, AI Provider, Connectors, Dev) get
  card containers and tighter spacing (space-y-8→space-y-5)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Extract PageHeader component (title/description/right slot), apply to all 9 pages
- Add StateViews (Spinner, PageLoading, EmptyState), replace inline loading/empty states
- Redesign notification style: left accent bar + bell icon instead of centered amber box
- Normalize table row hover (bg-tertiary/30) across Portfolio, Events, Heartbeat, Dev
- Add page transition fade animation (150ms) via useLocation key swap
- Enhance scroll-to-bottom button: larger hit target, new message count badge
- HeartbeatPage table: overflow-hidden → overflow-x-auto for mobile scroll

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- EventsPage: migrate to PageHeader, tab switcher in right slot
- ChatInput: show spinner in send button while waiting for response
- Add Toast component (context + provider + useToast hook), auto-dismiss 3s
- DevPage SendSection: replace inline result/error with toast notifications
- Sidebar: backdrop overlay fade in/out (200ms transition-opacity)
- ChatPage: channel popover max-width for small screens

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…wn, Engine deleted

Phase 1: AgentCenter absorbs session management (append, compact, persist)
from all three providers. Providers become slim GenerateProvider adapters
that only call their backend and yield ProviderEvents. Shared utilities
(stripImageData, buildChatHistoryPrompt, tool permissions) extracted to
provider-utils.ts. GenerateRouter replaces ProviderRouter.

Phase 2: Connector interface gains optional sendStream() for real-time
streaming. Web connector implements it (pushes ProviderEvents via SSE).
Chat POST handler streams events to SSE clients as they arrive.
ConnectorCenter gains notifyStream() with drain-and-fallback for
connectors without streaming support.

Phase 3: Delete Engine (thin facade), delete duplicated session.ts files
from claude-code and agent-sdk providers, clean up old AIProvider
interface and ProviderRouter, update all consumers (telegram, web,
mcp-ask, cron, heartbeat) from ctx.engine to ctx.agentCenter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ress

Show tool call indicators (spinner/checkmark) and accumulate text in
real-time as the backend streams ProviderEvents, replacing the static
ThinkingIndicator during generation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…xt generation

- Capture streaming tool calls via ref so they survive POST return, then
  persist them as a tool_calls DisplayItem in the message list
- Show thinking dots below completed tool list when all tools are done
  but text hasn't arrived yet, preventing the UI from appearing frozen

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…r rename

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@luokerenx4 luokerenx4 merged commit 9e3b1bf into master Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant