feat: Steward wallet migration Phase 1 — dual provider routing#415
feat: Steward wallet migration Phase 1 — dual provider routing#415
Conversation
…uting - Add WalletProvider interface (packages/lib/services/wallet-provider.ts) - Add StewardClient singleton wrapper (packages/lib/services/steward-client.ts) - Add wallet migration feature flags (packages/lib/config/wallet-provider-flags.ts) - Update agent_server_wallets schema: wallet_provider, steward_agent_id, steward_tenant_id columns - Make privy_wallet_id nullable for Steward-only wallets - Add DB migration 0058 with CHECK constraint ensuring exactly one provider ID - Update server-wallets.ts: dual-provider routing for provisionServerWallet() and executeServerWalletRpc() - New wallets routed to Steward when USE_STEWARD_FOR_NEW_WALLETS=true - Existing Privy wallets continue working unchanged - Install @stwd/sdk@0.3.0 Rollback: set USE_STEWARD_FOR_NEW_WALLETS=false to revert to Privy for all new wallets.
- Add steward-client.ts: lightweight client for querying Steward agent/wallet info - Add GET /api/v1/milady/agents/[agentId]/wallet endpoint for detailed wallet info - Update agent detail API to include walletAddress, walletProvider, walletStatus - Update compat API (toCompatAgent) to include wallet_address, wallet_provider - Update admin docker-containers route to show wallet provider and address - Update managed env to inject STEWARD_API_URL and STEWARD_AGENT_ID - Pass sandboxId through to prepareManagedMiladyEnvironment Docker-backed agents query Steward for wallet data; Privy agents fall back to DB. All Steward calls are best-effort with timeouts — API degrades gracefully.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review — PR #415: Steward Wallet Migration Phase 1Overall the dual-provider architecture is solid and the DB migration is well-structured (additive, zero-downtime, good CHECK constraint). A few issues worth addressing before merge: 🐛 Critical: Wrong agent ID passed to Steward APIIn multiple API routes, Affected files:
Fix: look up
|
The check-types-split.ts script was scanning 'lib/', 'db/', and 'components/' — none of which exist at the project root. The actual source lives at packages/lib, packages/db, and packages/ui/src/components. This meant packages/lib (including feature-gate.ts, use-feature-flags.ts, and feature-flags.ts) was never actually type-checked in CI. The split type-checker silently skipped all those files. Fix: update getDirectoriesToCheck() to use the correct package paths.
…ess fallback - CloudFormation: default-deny direct container port; opt-in via DirectContainerPortCidr param - milady-web-ui: getClientSafeMiladyAgentWebUiUrl returns null instead of falling back to headscale direct access - Dashboard pages: remove webUiUrl gating on connect button (always use pairing flow for running agents) - agent-actions/sandboxes-table: drop getConnectUrl and webUiUrl prop threading - Add cloudformation-template unit test - Gitignore env backup files
Code Review — PR #415: Steward wallet migration Phase 1Overall, this is a well-structured dual-provider abstraction with good backwards-compatibility. The feature flag defaults are conservative, the DB migration is additive and zero-downtime safe, and the test coverage is solid. A few things to address before merging: Bugs / Correctness1. Incorrect wallet_provider: walletInfo?.provider ?? (sandbox.node_id ? "steward" : null),This fallback assumes all Docker agents use Steward — but during the migration period, Docker agents with existing Privy wallets will have 2. import { ..., Copy, ... } from "lucide-react";
3. Comment refers to // STEWARD_AGENT_TOKEN is set during provisioning in docker-sandbox-provider.ts.If this is deferred to a follow-up PR, it's worth an explicit TODO comment. Otherwise containers will launch without the token and Steward auth will fail silently. Performance4. N parallel Steward HTTP calls in admin const enrichedContainers = await Promise.all(
containers.map(async (c) => {
const stewardAgent = await getStewardAgent(c.id);
...
}),
);With the default page size this fires up to 100 concurrent outbound HTTP requests per admin API call. This will be slow under load and could easily saturate or rate-limit the Steward API. Consider:
Code Smell5. Unnecessary const isDockerBacked_early = !!agent.node_id;
const walletInfo = isDockerBacked_early ? await getStewardWalletInfo(...) : null;
const isDockerBacked = isDockerBacked_early;Just use 6. Hard-coded Basescan link ignores non-Base chains href={`https://basescan.org/address/${walletInfo.walletAddress}`}The Minor7. DB query directly in route handler ( const walletRecord = await db.query.agentServerWallets.findFirst(...)Most DB access in this project goes through repository classes ( 8. Migration journal gap — Positives worth noting
|
Summary
Implements Phase 1 of the Privy → Steward wallet migration:
Changes
packages/lib/services/wallet-provider.ts)packages/lib/services/steward-client.ts)server-wallets.ts— new wallets go to Steward whenUSE_STEWARD_FOR_NEW_WALLETS=true, existing Privy wallets unchangedwallet-provider-flags.tswith conservative defaults (Privy remains default)wallet_provider,steward_agent_id,steward_tenant_idcolumns toagent_server_walletswith CHECK constraintTesting
Dependencies
@stwd/sdk@0.3.0(published, zero deps)api.steward.fi(v0.2.0)