How mrmushii/guardian-agent works
Guardian Agent is a policy-bound autonomous portfolio wallet. Its main loop watches an account, evaluates portfolio drift, obtains a bounded agent decision, plans and risk-checks a trade, then routes it through simulation and smart-account execution or owner approval. The web console exposes status, controls, evidence, chat and history. The graph follows README-documented capabilities and indexed imports; unsampled module behavior and some UI-to-route wiring are not inferred.
Main entry points: pipeline.ts Rebalance pipeline · index.ts Persistent watcher · schema.ts Durable application state · context.ts Engine context
Components 26
Monitoring
- Persistent watcher
apps/worker/src/index.ts - Owner notifications
apps/worker/src/notify.ts
Decision and execution
- Engine context
packages/engine/src/context.ts - Rebalance pipeline
packages/engine/src/pipeline.ts - Portfolio assessment
packages/engine/src/portfolio.ts - Multi-asset rebalance
packages/engine/src/multi.ts - Asset evaluation
packages/engine/src/assets.ts - Portfolio valuation
packages/portfolio/src/index.ts - Decision and fallback
packages/agent/src/index.ts - Agent chat
packages/agent/src/chat.ts - Operation simulation
packages/simulation/src/index.ts - Swap quoting
packages/dex/src/index.ts
Policy and account security
- Policy compiler and router
packages/policy/src/compiler.ts - Kernel session authority
packages/account/src/kernel.ts - Session permissions
packages/account/src/permissions.ts
Owner console
- Dashboard console
apps/web/components/Dashboard.tsx - Dashboard API
apps/web/app/api/dashboard/route.ts - Chat API
apps/web/app/api/chat/route.ts - Live timeline API
apps/web/app/api/stream/route.ts - Policy and owner controls
apps/web/app/api/policy/route.ts
State and integrations
- Price feeds
packages/oracle/src/index.ts - Durable application state
packages/db/src/schema.ts
Other components
- Owner
- Wallet activity
- Base smart-account network
- LLM providers
Connections 35
- Wallet activity → Persistent watcher: triggers evaluation
apps/worker/src/index.ts - Persistent watcher → Rebalance pipeline: runs rebalance
apps/worker/src/index.ts - Persistent watcher → Portfolio assessment: reads allocation
apps/worker/src/index.ts - Persistent watcher → Durable application state: records checks
apps/worker/src/index.ts - Persistent watcher → Owner notifications: notifies pending approval
apps/worker/src/index.ts - Persistent watcher → Engine context: creates context
- Rebalance pipeline → Durable application state: claims and reserves
packages/engine/src/pipeline.ts - Rebalance pipeline → Decision and fallback: requests decision
packages/engine/src/pipeline.ts - Rebalance pipeline → Swap quoting: quotes swap
packages/engine/src/pipeline.ts - Rebalance pipeline → Policy compiler and router: applies trade limits
packages/engine/src/pipeline.ts - Rebalance pipeline → Kernel session authority: signs session operation
- Rebalance pipeline → Operation simulation: simulates operation
- Rebalance pipeline → Multi-asset rebalance: supports multi-asset legs
packages/engine/src/pipeline.ts - Rebalance pipeline → Asset evaluation: loads asset state
packages/engine/src/pipeline.ts - Portfolio assessment → Portfolio valuation: assesses allocation
packages/engine/src/portfolio.ts - Decision and fallback → LLM providers: queries models
packages/agent/src/index.ts - Engine context → Durable application state: opens database
packages/engine/src/context.ts - Engine context → Kernel session authority: loads keyring
packages/engine/src/context.ts - Engine context → Decision and fallback: configures models
packages/engine/src/context.ts - Session permissions → Policy compiler and router: compiles authority rules
packages/account/src/permissions.ts - Kernel session authority → Base smart-account network: enforces session authority
- Swap quoting → Base smart-account network: routes swaps
- Price feeds → Base smart-account network: reads chain prices
- Owner → Dashboard console: uses console
- Dashboard console → Dashboard API: requests dashboard data
- Dashboard API → Durable application state: reads account records
apps/web/app/api/dashboard/route.ts - Dashboard API → Policy compiler and router: reads portfolio targets
apps/web/app/api/dashboard/route.ts - Dashboard API → Portfolio assessment: loads portfolio view
apps/web/app/api/dashboard/route.ts - Dashboard console → Chat API: asks agent
- Chat API → Agent chat: requests explanation
apps/web/app/api/chat/route.ts - Chat API → Durable application state: stores conversation audit
apps/web/app/api/chat/route.ts - Dashboard console → Live timeline API: opens live timeline
- Live timeline API → Durable application state: streams audit events
apps/web/app/api/stream/route.ts - Owner → Policy and owner controls: changes policy
- Policy and owner controls → Rebalance pipeline: prepares policy changes