auramaxx 1.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +112 -0
  3. package/bin/aurawallet.js +121 -0
  4. package/docs/ADAPTERS.md +467 -0
  5. package/docs/API.md +2679 -0
  6. package/docs/APPS.md +198 -0
  7. package/docs/ARCHITECTURE.md +350 -0
  8. package/docs/AUTH.md +698 -0
  9. package/docs/BEST-PRACTICES.md +121 -0
  10. package/docs/CLI.md +61 -0
  11. package/docs/DEVELOPING-APPS.md +452 -0
  12. package/docs/EXTENSION.md +97 -0
  13. package/docs/JOBS.md +33 -0
  14. package/docs/MCP.md +76 -0
  15. package/docs/PROTOCOL.md +142 -0
  16. package/docs/SETUP.md +219 -0
  17. package/docs/WORKSPACE.md +672 -0
  18. package/docs/agent-auth.md +63 -0
  19. package/docs/aura-file.md +48 -0
  20. package/docs/credentials.md +53 -0
  21. package/docs/external/getting-started.md +65 -0
  22. package/docs/external/overview.md +45 -0
  23. package/docs/external/use-cases.md +48 -0
  24. package/docs/external/why-aura.md +35 -0
  25. package/docs/jobs/connect-agent.md +77 -0
  26. package/docs/jobs/migrate-from-dotenv.md +79 -0
  27. package/docs/jobs/recover-from-lockout.md +72 -0
  28. package/docs/jobs/secure-ci.md +63 -0
  29. package/docs/oauth2.md +42 -0
  30. package/docs/passkeys.md +60 -0
  31. package/docs/security.md +540 -0
  32. package/docs/specs/aura-open-protocol.md +61 -0
  33. package/docs/specs/aura-provider-plugin.md +24 -0
  34. package/docs/specs/aura-registry-model.md +31 -0
  35. package/docs/specs/fixtures/invalid-bad-key.aura +1 -0
  36. package/docs/specs/fixtures/invalid-bad-unicode-escape.aura +1 -0
  37. package/docs/specs/fixtures/invalid-duplicate-key.aura +2 -0
  38. package/docs/specs/fixtures/valid-basic.aura +4 -0
  39. package/docs/specs/fixtures/valid-provider-ref.aura +1 -0
  40. package/docs/specs/fixtures/valid-quoted-escapes.aura +2 -0
  41. package/docs/templates/RELEASE_NOTES_TEMPLATE.md +22 -0
  42. package/docs/totp.md +40 -0
  43. package/docs/wallet/AI.md +508 -0
  44. package/docs/wallet/DEVELOPING-STRATEGIES.md +713 -0
  45. package/docs/wallet/README.md +47 -0
  46. package/docs/wallet/STRATEGY.md +89 -0
  47. package/next.config.ts +21 -0
  48. package/package.json +151 -0
  49. package/postcss.config.mjs +8 -0
  50. package/prisma/migrations/20260214170000_baseline/migration.sql +511 -0
  51. package/prisma/migrations/20260216214537_add_passkey_model/migration.sql +18 -0
  52. package/prisma/migrations/20260217150500_add_credential_access_audit/migration.sql +31 -0
  53. package/prisma/migrations/migration_lock.toml +3 -0
  54. package/prisma/schema.prisma +447 -0
  55. package/public/logo-chevron.svg +31 -0
  56. package/public/logo-concentric.svg +31 -0
  57. package/public/logo-crosshatch.svg +39 -0
  58. package/public/logo-dashed.svg +39 -0
  59. package/public/logo-horizontal.svg +31 -0
  60. package/public/logo-m56.svg +64 -0
  61. package/public/logo.webp +0 -0
  62. package/scripts/add-app.js +245 -0
  63. package/scripts/init.sh +57 -0
  64. package/scripts/migrate-apikeys-to-credentials.ts +35 -0
  65. package/scripts/sandbox-agent-flow.sh +235 -0
  66. package/scripts/sandbox.sh +175 -0
  67. package/scripts/validate-job-docs.mjs +125 -0
  68. package/server/abi/SwapHelper.json +438 -0
  69. package/server/cli/approval.ts +447 -0
  70. package/server/cli/commands/app.ts +204 -0
  71. package/server/cli/commands/cron.ts +24 -0
  72. package/server/cli/commands/doctor.ts +1007 -0
  73. package/server/cli/commands/env.ts +456 -0
  74. package/server/cli/commands/init.ts +752 -0
  75. package/server/cli/commands/mcp.ts +125 -0
  76. package/server/cli/commands/restore.ts +314 -0
  77. package/server/cli/commands/shell-hook.ts +468 -0
  78. package/server/cli/commands/start.ts +62 -0
  79. package/server/cli/commands/status.ts +59 -0
  80. package/server/cli/commands/stop.ts +14 -0
  81. package/server/cli/commands/token.ts +180 -0
  82. package/server/cli/commands/unlock.ts +49 -0
  83. package/server/cli/commands/vault.ts +417 -0
  84. package/server/cli/index.ts +328 -0
  85. package/server/cli/lib/aura-parser.ts +64 -0
  86. package/server/cli/lib/credential-create.ts +74 -0
  87. package/server/cli/lib/credential-resolve.ts +254 -0
  88. package/server/cli/lib/dotenv-migrate.ts +116 -0
  89. package/server/cli/lib/dotenv-parser.ts +146 -0
  90. package/server/cli/lib/http.ts +91 -0
  91. package/server/cli/lib/init-steps.ts +76 -0
  92. package/server/cli/lib/local-agent-trust.ts +45 -0
  93. package/server/cli/lib/process.ts +136 -0
  94. package/server/cli/lib/prompt.ts +85 -0
  95. package/server/cli/lib/theme.ts +240 -0
  96. package/server/cli/socket.ts +570 -0
  97. package/server/cli/transport-client.ts +50 -0
  98. package/server/cron/index.ts +137 -0
  99. package/server/cron/job.ts +31 -0
  100. package/server/cron/jobs/balance-sync.ts +436 -0
  101. package/server/cron/jobs/incoming-scan.ts +506 -0
  102. package/server/cron/jobs/native-price.ts +70 -0
  103. package/server/cron/jobs/orphan-cleanup.ts +40 -0
  104. package/server/cron/jobs/strategy-runner.ts +175 -0
  105. package/server/cron/scheduler.ts +125 -0
  106. package/server/index.ts +406 -0
  107. package/server/lib/adapters/factory.ts +110 -0
  108. package/server/lib/adapters/index.ts +19 -0
  109. package/server/lib/adapters/router.ts +297 -0
  110. package/server/lib/adapters/telegram.ts +645 -0
  111. package/server/lib/adapters/types.ts +89 -0
  112. package/server/lib/adapters/webhook.ts +95 -0
  113. package/server/lib/address.ts +49 -0
  114. package/server/lib/agent-auth/contracts.ts +1194 -0
  115. package/server/lib/agent-profiles.ts +328 -0
  116. package/server/lib/ai.ts +285 -0
  117. package/server/lib/api-registry/contracts.ts +86 -0
  118. package/server/lib/api-registry/validation.ts +172 -0
  119. package/server/lib/apikey-migration.ts +189 -0
  120. package/server/lib/app-installer.ts +505 -0
  121. package/server/lib/app-tokens.ts +247 -0
  122. package/server/lib/auth.ts +314 -0
  123. package/server/lib/batch.ts +242 -0
  124. package/server/lib/cold.ts +874 -0
  125. package/server/lib/config.ts +381 -0
  126. package/server/lib/credential-access-audit.ts +85 -0
  127. package/server/lib/credential-access-policy.ts +110 -0
  128. package/server/lib/credential-health.ts +343 -0
  129. package/server/lib/credential-import.ts +487 -0
  130. package/server/lib/credential-scope.ts +87 -0
  131. package/server/lib/credential-shares.ts +190 -0
  132. package/server/lib/credential-transport.ts +342 -0
  133. package/server/lib/credential-vault.ts +77 -0
  134. package/server/lib/credentials.ts +333 -0
  135. package/server/lib/crypto.ts +8 -0
  136. package/server/lib/db.ts +15 -0
  137. package/server/lib/defaults.ts +366 -0
  138. package/server/lib/dex/index.ts +80 -0
  139. package/server/lib/dex/relay.ts +235 -0
  140. package/server/lib/dex/types.ts +59 -0
  141. package/server/lib/dex/uniswap.ts +370 -0
  142. package/server/lib/e2e-agent/artifacts.ts +36 -0
  143. package/server/lib/e2e-agent/contracts.ts +112 -0
  144. package/server/lib/e2e-agent/validation.ts +135 -0
  145. package/server/lib/encrypt.ts +128 -0
  146. package/server/lib/error.ts +20 -0
  147. package/server/lib/events.ts +205 -0
  148. package/server/lib/hot.ts +357 -0
  149. package/server/lib/key-fingerprint.ts +28 -0
  150. package/server/lib/logger.ts +331 -0
  151. package/server/lib/network.ts +137 -0
  152. package/server/lib/notifications.ts +219 -0
  153. package/server/lib/oauth2-refresh.ts +241 -0
  154. package/server/lib/oursecret.ts +54 -0
  155. package/server/lib/passkey-credential.ts +360 -0
  156. package/server/lib/passkey.ts +68 -0
  157. package/server/lib/permissions.ts +248 -0
  158. package/server/lib/pino.ts +24 -0
  159. package/server/lib/policy-preview.ts +138 -0
  160. package/server/lib/price.ts +338 -0
  161. package/server/lib/prices.ts +34 -0
  162. package/server/lib/project-scope.ts +239 -0
  163. package/server/lib/resolve-action.ts +427 -0
  164. package/server/lib/resolve.ts +36 -0
  165. package/server/lib/sessions.ts +632 -0
  166. package/server/lib/solana/connection.ts +26 -0
  167. package/server/lib/solana/jupiter.ts +128 -0
  168. package/server/lib/solana/transfer.ts +108 -0
  169. package/server/lib/solana/wallet.ts +136 -0
  170. package/server/lib/strategy/emits.ts +21 -0
  171. package/server/lib/strategy/engine.ts +1305 -0
  172. package/server/lib/strategy/executor.ts +115 -0
  173. package/server/lib/strategy/hook-context.ts +158 -0
  174. package/server/lib/strategy/hooks.ts +990 -0
  175. package/server/lib/strategy/index.ts +28 -0
  176. package/server/lib/strategy/installer.ts +305 -0
  177. package/server/lib/strategy/loader.ts +256 -0
  178. package/server/lib/strategy/message.ts +235 -0
  179. package/server/lib/strategy/repository.ts +218 -0
  180. package/server/lib/strategy/session-logger.ts +693 -0
  181. package/server/lib/strategy/sources.ts +288 -0
  182. package/server/lib/strategy/state.ts +189 -0
  183. package/server/lib/strategy/templates.ts +403 -0
  184. package/server/lib/strategy/tick.ts +404 -0
  185. package/server/lib/strategy/types.ts +230 -0
  186. package/server/lib/swap.ts +3 -0
  187. package/server/lib/temp.ts +86 -0
  188. package/server/lib/token-metadata.ts +86 -0
  189. package/server/lib/token-safety.ts +200 -0
  190. package/server/lib/token-search.ts +444 -0
  191. package/server/lib/totp.ts +194 -0
  192. package/server/lib/transactions.ts +123 -0
  193. package/server/lib/transport.ts +75 -0
  194. package/server/lib/txhistory/decoder.ts +262 -0
  195. package/server/lib/txhistory/enricher.ts +652 -0
  196. package/server/lib/txhistory/index.ts +391 -0
  197. package/server/lib/txhistory/signatures.ts +59 -0
  198. package/server/lib/verified-summary.ts +421 -0
  199. package/server/mcp/profile-policy.ts +30 -0
  200. package/server/mcp/server.ts +619 -0
  201. package/server/mcp/tools.ts +523 -0
  202. package/server/middleware/auth.ts +119 -0
  203. package/server/middleware/requestLogger.ts +84 -0
  204. package/server/routes/actions.ts +459 -0
  205. package/server/routes/adapters.ts +703 -0
  206. package/server/routes/addressbook.ts +113 -0
  207. package/server/routes/ai.ts +34 -0
  208. package/server/routes/apikeys.ts +295 -0
  209. package/server/routes/apps.ts +601 -0
  210. package/server/routes/auth.ts +457 -0
  211. package/server/routes/backup.ts +340 -0
  212. package/server/routes/batch.ts +270 -0
  213. package/server/routes/bookmarks.ts +162 -0
  214. package/server/routes/credential-shares.ts +198 -0
  215. package/server/routes/credential-vaults.ts +154 -0
  216. package/server/routes/credentials.ts +1290 -0
  217. package/server/routes/dashboard.ts +71 -0
  218. package/server/routes/defaults.ts +124 -0
  219. package/server/routes/fund.ts +229 -0
  220. package/server/routes/import.ts +352 -0
  221. package/server/routes/launch.ts +665 -0
  222. package/server/routes/lock.ts +54 -0
  223. package/server/routes/logs.ts +68 -0
  224. package/server/routes/nuke.ts +111 -0
  225. package/server/routes/passkey-credentials.ts +99 -0
  226. package/server/routes/passkey.ts +346 -0
  227. package/server/routes/portfolio.ts +217 -0
  228. package/server/routes/price.ts +63 -0
  229. package/server/routes/resolve.ts +31 -0
  230. package/server/routes/security.ts +45 -0
  231. package/server/routes/send-evm.ts +241 -0
  232. package/server/routes/send-solana.ts +281 -0
  233. package/server/routes/send.ts +178 -0
  234. package/server/routes/setup.ts +210 -0
  235. package/server/routes/strategy.ts +894 -0
  236. package/server/routes/swap-evm.ts +353 -0
  237. package/server/routes/swap-solana.ts +177 -0
  238. package/server/routes/swap.ts +356 -0
  239. package/server/routes/token.ts +247 -0
  240. package/server/routes/unlock.ts +403 -0
  241. package/server/routes/wallet-assets.ts +361 -0
  242. package/server/routes/wallet-transactions.ts +515 -0
  243. package/server/routes/wallet.ts +710 -0
  244. package/server/types.ts +146 -0
  245. package/skills/aurawallet/SKILL.md +739 -0
  246. package/skills/aurawallet-setup/SKILL.md +74 -0
  247. package/skills/security-review/SKILL.md +148 -0
  248. package/src/app/api/agent-requests/route.ts +30 -0
  249. package/src/app/api/apps/install/route.ts +126 -0
  250. package/src/app/api/apps/manifests/route.ts +16 -0
  251. package/src/app/api/apps/static/[...path]/route.ts +57 -0
  252. package/src/app/api/events/route.ts +92 -0
  253. package/src/app/api/page.tsx +212 -0
  254. package/src/app/api/workspace/[id]/apps/[wid]/route.ts +119 -0
  255. package/src/app/api/workspace/[id]/apps/route.ts +81 -0
  256. package/src/app/api/workspace/[id]/export/route.ts +67 -0
  257. package/src/app/api/workspace/[id]/route.ts +168 -0
  258. package/src/app/api/workspace/auth.ts +34 -0
  259. package/src/app/api/workspace/config/route.ts +106 -0
  260. package/src/app/api/workspace/import/route.ts +127 -0
  261. package/src/app/api/workspace/route.ts +116 -0
  262. package/src/app/app/page.tsx +2122 -0
  263. package/src/app/apple-icon.png +0 -0
  264. package/src/app/docs/page.tsx +178 -0
  265. package/src/app/favicon.ico +0 -0
  266. package/src/app/globals.css +572 -0
  267. package/src/app/health/page.tsx +5 -0
  268. package/src/app/hello/page.tsx +15 -0
  269. package/src/app/icon.png +0 -0
  270. package/src/app/layout.tsx +34 -0
  271. package/src/app/page.tsx +986 -0
  272. package/src/app/providers.tsx +90 -0
  273. package/src/app/share/[token]/page.tsx +295 -0
  274. package/src/components/ChainSelector.tsx +144 -0
  275. package/src/components/HumanActionBar.tsx +695 -0
  276. package/src/components/NotificationDrawer.tsx +129 -0
  277. package/src/components/apps/AgentKeysApp.tsx +490 -0
  278. package/src/components/apps/App.tsx +153 -0
  279. package/src/components/apps/AppGrid.tsx +15 -0
  280. package/src/components/apps/DetailedAddressDrawer.tsx +325 -0
  281. package/src/components/apps/DraggableApp.tsx +562 -0
  282. package/src/components/apps/IFrameApp.tsx +73 -0
  283. package/src/components/apps/LogsApp.tsx +360 -0
  284. package/src/components/apps/SendApp.tsx +394 -0
  285. package/src/components/apps/SetupWizardApp.tsx +1004 -0
  286. package/src/components/apps/SystemDefaultsApp.tsx +845 -0
  287. package/src/components/apps/ThirdPartyApp.tsx +428 -0
  288. package/src/components/apps/TokenApp.tsx +319 -0
  289. package/src/components/apps/TransactionsApp.tsx +438 -0
  290. package/src/components/apps/WalletDetailApp.tsx +1505 -0
  291. package/src/components/apps/index.ts +13 -0
  292. package/src/components/design-system/Button.tsx +53 -0
  293. package/src/components/design-system/ChainIndicator.tsx +65 -0
  294. package/src/components/design-system/ChainSelector.tsx +137 -0
  295. package/src/components/design-system/ConfirmationModal.tsx +106 -0
  296. package/src/components/design-system/ConfirmationPopover.tsx +81 -0
  297. package/src/components/design-system/Drawer.tsx +123 -0
  298. package/src/components/design-system/FilterDropdown.tsx +72 -0
  299. package/src/components/design-system/Modal.tsx +206 -0
  300. package/src/components/design-system/Popover.tsx +142 -0
  301. package/src/components/design-system/TextInput.tsx +85 -0
  302. package/src/components/design-system/Toggle.tsx +58 -0
  303. package/src/components/design-system/index.ts +11 -0
  304. package/src/components/docs/DocsThemeToggle.tsx +49 -0
  305. package/src/components/health/CredentialHealthDashboard.tsx +214 -0
  306. package/src/components/icons/ChainIcons.tsx +72 -0
  307. package/src/components/layout/AppStoreDrawer.tsx +369 -0
  308. package/src/components/layout/ContentArea.tsx +21 -0
  309. package/src/components/layout/TabBar.tsx +278 -0
  310. package/src/components/layout/WalletSidebar.tsx +1033 -0
  311. package/src/components/layout/index.ts +4 -0
  312. package/src/components/marketing/AuraWalletSpecOverlay.tsx +635 -0
  313. package/src/components/marketing/DeviceMorphExperience.tsx +216 -0
  314. package/src/components/vault/ApiKeysConsole.tsx +1080 -0
  315. package/src/components/vault/AuditConsole.tsx +584 -0
  316. package/src/components/vault/CredentialDetail.tsx +455 -0
  317. package/src/components/vault/CredentialEmpty.tsx +55 -0
  318. package/src/components/vault/CredentialField.tsx +361 -0
  319. package/src/components/vault/CredentialForm.tsx +1212 -0
  320. package/src/components/vault/CredentialList.tsx +165 -0
  321. package/src/components/vault/CredentialRow.tsx +97 -0
  322. package/src/components/vault/CredentialShareModal.tsx +178 -0
  323. package/src/components/vault/CredentialVault.tsx +754 -0
  324. package/src/components/vault/CredentialWalletWidget.tsx +103 -0
  325. package/src/components/vault/ImportCredentialsModal.tsx +515 -0
  326. package/src/components/vault/LargeTypeModal.tsx +64 -0
  327. package/src/components/vault/PasswordGenerator.tsx +224 -0
  328. package/src/components/vault/TOTPDisplay.tsx +123 -0
  329. package/src/components/vault/VaultSidebar.tsx +413 -0
  330. package/src/components/vault/types.ts +54 -0
  331. package/src/context/AuthContext.tsx +337 -0
  332. package/src/context/PriceContext.tsx +113 -0
  333. package/src/context/ThemeContext.tsx +164 -0
  334. package/src/context/WebSocketContext.tsx +269 -0
  335. package/src/context/WorkspaceContext.tsx +668 -0
  336. package/src/hooks/index.ts +3 -0
  337. package/src/hooks/useAgentActions.ts +368 -0
  338. package/src/hooks/useBalance.ts +103 -0
  339. package/src/hooks/useBalances.ts +129 -0
  340. package/src/instrumentation.ts +12 -0
  341. package/src/lib/api.ts +449 -0
  342. package/src/lib/app-loader.ts +148 -0
  343. package/src/lib/app-registry.ts +178 -0
  344. package/src/lib/app-sdk.ts +157 -0
  345. package/src/lib/audit-console-adapter.ts +151 -0
  346. package/src/lib/auth-client.ts +75 -0
  347. package/src/lib/config.ts +74 -0
  348. package/src/lib/crypto.ts +112 -0
  349. package/src/lib/db.ts +21 -0
  350. package/src/lib/docs.ts +390 -0
  351. package/src/lib/events.ts +361 -0
  352. package/src/lib/pino.ts +24 -0
  353. package/src/lib/theme-handlers.ts +168 -0
  354. package/src/lib/theme.ts +351 -0
  355. package/src/lib/tokenData.ts +378 -0
  356. package/src/lib/vault-crypto.ts +129 -0
  357. package/src/lib/websocket-server.ts +302 -0
  358. package/src/lib/websocket-setup.ts +79 -0
  359. package/src/lib/wordlist.ts +2050 -0
  360. package/src/lib/workspace-handlers.ts +285 -0
  361. package/start.sh +80 -0
  362. package/tailwind.config.ts +99 -0
  363. package/tsconfig.json +42 -0
package/docs/APPS.md ADDED
@@ -0,0 +1,198 @@
1
+ # Apps
2
+
3
+ Overview of the AuraWallet app system — what apps are, how to install them, and how to create a minimal one.
4
+
5
+ For the full developer reference (manifest format, SDK API, theming, security model, strategy hooks, examples), see [DEVELOPING-APPS.md](./DEVELOPING-APPS.md).
6
+
7
+ ---
8
+
9
+ ## Overview
10
+
11
+ Apps are self-contained HTML applications that run inside sandboxed iframes on the AuraWallet dashboard. There are two kinds:
12
+
13
+ - **Built-in apps** -- React components registered in `src/lib/app-registry.ts` (wallets, logs, send, etc.)
14
+ - **Installed apps** -- standalone HTML+JS bundles installed as folders under `apps/`
15
+
16
+ Apps can also be extended with AI capabilities by adding strategy fields (`ticker`, `hooks`, `sources`, etc.) to the manifest. This activates the AI engine, turning the app into a strategy that runs on a schedule or responds to messages. See [STRATEGY.md](./wallet/STRATEGY.md) for an overview and [DEVELOPING-STRATEGIES.md](./wallet/DEVELOPING-STRATEGIES.md) for the full reference.
17
+
18
+ Installed apps consist of two files in a folder inside `apps/`:
19
+
20
+ ```
21
+ apps/
22
+ my-app/
23
+ app.md <-- manifest (YAML frontmatter + description)
24
+ index.html <-- app entry point (HTML + inline JS/CSS)
25
+ ```
26
+
27
+ The system discovers apps at runtime by scanning `apps/*/app.md`. Each app's `index.html` is served via `/api/apps/static/<folder>/index.html`, then loaded into a sandboxed iframe as a blob URL with the SDK and theme CSS injected.
28
+
29
+ ### How It Works (Lifecycle)
30
+
31
+ ```
32
+ 1. Server starts: scans apps/ → creates scoped Bearer tokens for each app
33
+ 2. GET /api/apps/manifests returns parsed manifest data to the App Store UI
34
+ 3. User clicks "ADD" in App Store
35
+ 4. ThirdPartyApp component fetches /api/apps/static/<id>/index.html
36
+ 5. ThirdPartyApp fetches GET /apps/<id>/token to get the app's Bearer token
37
+ 6. Host injects: theme CSS + token globals + App SDK script + app HTML
38
+ 7. Combined HTML is turned into a blob URL and loaded in a sandboxed iframe
39
+ 8. SDK makes direct fetch() calls to Express :4242/apps/<id>/storage/* with Bearer token
40
+ 9. SDK makes direct fetch() calls to Express :4242/apps/<id>/message for send()
41
+ 10. SDK proxies external API requests through Express :4242/apps/<id>/fetch
42
+ 11. postMessage used only for on() subscriptions (host-bridged)
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Installing Apps
48
+
49
+ Apps can be installed from git repos, tarballs, zips, or local paths using the CLI or the dashboard UI.
50
+
51
+ ### CLI
52
+
53
+ ```bash
54
+ # Install from a git repo
55
+ npx aurawallet app install github.com/user/my-app
56
+
57
+ # Install from a git repo subdirectory
58
+ npx aurawallet app install github.com/user/repo#path=apps/my-app
59
+
60
+ # Install from a local path
61
+ npx aurawallet app install ./path/to/app
62
+
63
+ # Install from a tarball or zip
64
+ npx aurawallet app install https://example.com/app.tar.gz
65
+
66
+ # Override the app folder name
67
+ npx aurawallet app install github.com/user/app --name custom-id
68
+
69
+ # Overwrite an existing app
70
+ npx aurawallet app install github.com/user/app --force
71
+
72
+ # List all installed apps
73
+ npx aurawallet app list
74
+
75
+ # Update a app from its original source
76
+ npx aurawallet app update my-app
77
+
78
+ # Remove a app
79
+ npx aurawallet app remove my-app
80
+
81
+ # Remove without confirmation prompt
82
+ npx aurawallet app remove my-app --yes
83
+ ```
84
+
85
+ ### Dashboard UI
86
+
87
+ 1. Open the App Store drawer (click the "+" button on the dashboard)
88
+ 2. Select the **ALL** or **INSTALLED** tab
89
+ 3. Paste a source URL into the "Install from URL" input at the top
90
+ 4. Click **INSTALL** (or press Enter)
91
+ 5. The app appears in the installed list immediately
92
+
93
+ ### Supported Sources
94
+
95
+ | Pattern | Type | Example |
96
+ |---------|------|---------|
97
+ | Starts with `.` or `/` | Local copy | `./apps/my-app` |
98
+ | Ends with `.tar.gz` / `.tgz` | Tarball download | `https://example.com/app.tar.gz` |
99
+ | Ends with `.zip` | Zip download | `https://example.com/app.zip` |
100
+ | Everything else | Git clone | `github.com/user/repo` |
101
+ | `#path=subdir` fragment | Subdirectory | `github.com/user/repo#path=apps/foo` |
102
+
103
+ ### Validation
104
+
105
+ The installer validates each app before copying it to `apps/`:
106
+
107
+ - `app.md` must exist with valid YAML frontmatter
108
+ - `index.html` is loaded if present (optional — headless apps use a default UI)
109
+ - No symlinks escaping the app directory
110
+ - No file larger than 5MB
111
+ - Total size under 20MB
112
+ - No ID conflict with existing apps (unless `--force`)
113
+
114
+ ### Provenance
115
+
116
+ Each installed app gets a `.source.json` file recording where it was installed from:
117
+
118
+ ```json
119
+ {
120
+ "type": "git",
121
+ "url": "https://github.com/user/my-app.git",
122
+ "ref": null,
123
+ "subdir": null,
124
+ "installedAt": "2026-02-10T12:00:00.000Z"
125
+ }
126
+ ```
127
+
128
+ This file is used by `npx aurawallet app update <id>` to re-install from the original source.
129
+
130
+ ---
131
+
132
+ ## Quick Start
133
+
134
+ Create a minimal app in 3 steps:
135
+
136
+ ### 1. Create the folder
137
+
138
+ ```bash
139
+ mkdir apps/hello-world
140
+ ```
141
+
142
+ ### 2. Create the manifest (`apps/hello-world/app.md`)
143
+
144
+ ```markdown
145
+ ---
146
+ name: Hello World
147
+ icon: Smile
148
+ category: general
149
+ size: 1x1
150
+ permissions:
151
+ data:
152
+ ---
153
+
154
+ A minimal example app that displays a greeting.
155
+ ```
156
+
157
+ ### 3. Create the entry point (`apps/hello-world/index.html`)
158
+
159
+ ```html
160
+ <!DOCTYPE html>
161
+ <html>
162
+ <head>
163
+ <style>
164
+ body {
165
+ font-family: ui-monospace, monospace;
166
+ background: var(--color-surface, #fff);
167
+ color: var(--color-text, #0a0a0a);
168
+ display: flex;
169
+ align-items: center;
170
+ justify-content: center;
171
+ height: 100vh;
172
+ font-size: 12px;
173
+ }
174
+ </style>
175
+ </head>
176
+ <body>
177
+ <div>Hello from a app!</div>
178
+ </body>
179
+ </html>
180
+ ```
181
+
182
+ The app will appear in the App Store under the "INSTALLED" tab. Click "ADD" to place it on your workspace.
183
+
184
+ ---
185
+
186
+ ## Built-in Apps
187
+
188
+ These apps ship with AuraWallet and appear in the App Store under "BUILT-IN":
189
+
190
+ | Type | Title | Description |
191
+ |------|-------|-------------|
192
+ | `wallets` | WALLETS | View and manage all wallet tiers |
193
+ | `logs` | EVENT LOGS | Real-time event log viewer |
194
+ | `send` | SEND | Send transactions from hot wallets |
195
+ | `agentKeys` | AGENT KEYS | View and manage agent tokens |
196
+ | `status` | STATUS | Server and connection status |
197
+ | `walletDetail` | WALLET | Detailed view of a single wallet |
198
+ | `iframe` | IFRAME | Embed any URL in an iframe |
@@ -0,0 +1,350 @@
1
+ # System Architecture
2
+
3
+ Technical overview of AuraWallet's processes, subsystems, and data flow.
4
+
5
+ ---
6
+
7
+ ## Process Model
8
+
9
+ AuraWallet runs as four cooperating processes on a single machine:
10
+
11
+ ```
12
+ ┌────────────────────┐ ┌────────────────────┐
13
+ │ Express :4242 │ │ Dashboard :4747 │
14
+ │ Wallet API │◄────│ Next.js UI │
15
+ │ 25 route modules │ │ API routes │
16
+ └────────┬───────────┘ └────────┬────────────┘
17
+ │ │
18
+ │ ┌─────────────────┘
19
+ │ │
20
+ ▼ ▼
21
+ ┌────────────────────┐ ┌────────────────────┐
22
+ │ WebSocket :4748 │◄────│ Cron (background) │
23
+ │ Event broadcast │ │ 4 scheduled jobs │
24
+ │ Client fan-out │ │ No HTTP port │
25
+ └────────────────────┘ └────────────────────┘
26
+ ```
27
+
28
+ | Process | Port | Technology | Entry Point |
29
+ |---------|------|------------|-------------|
30
+ | **Express** | 4242 | Express.js | `server/index.ts` |
31
+ | **Cron** | None | Node.js (setTimeout scheduler) | `server/cron/index.ts` |
32
+ | **MCP** | None (stdio) | `@modelcontextprotocol/sdk` | `server/mcp/server.ts` |
33
+ | **Dashboard** | 4747 (HTTP) / 4748 (WS) | Next.js 14 | `src/` |
34
+
35
+ All processes communicate through WebSocket broadcasts and HTTP calls to the Express server. Data directory: `~/.aurawallet/` (SQLite DB, vault files, config — outside repo).
36
+
37
+ ---
38
+
39
+ ## Express Server
40
+
41
+ ### Startup Sequence
42
+
43
+ 1. Run `prisma migrate deploy` (apply pending DB migrations)
44
+ 2. Preload SystemDefaults cache from DB (hot-reloadable config)
45
+ 3. Recover crashed strategy sessions + cleanup old logs
46
+ 4. Auto-unlock vault if `VAULT_PASSWORD` env var set
47
+ 5. Start Express on `127.0.0.1:4242`
48
+ 6. Load approval adapters from DB (Telegram, webhooks)
49
+ 7. Start ApprovalRouter (connects to WebSocket for events)
50
+ 8. Schedule daily strategy summaries
51
+
52
+ ### Middleware Stack
53
+
54
+ ```
55
+ Request
56
+
57
+ ├─ CORS (allow all origins — blob:// iframes use opaque origin)
58
+ ├─ JSON body parser
59
+ ├─ Rate limiters (hot-reloadable via SystemDefaults)
60
+ │ ├─ Brute-force: 5/15min → /unlock, /setup, /actions, /nuke, /backup
61
+ │ ├─ Auth: 10/min → /auth
62
+ │ ├─ Transaction: 30/min → /send, /swap, /fund, /launch (keyed by hashed token)
63
+ │ └─ General: 100/min → everything else
64
+ ├─ Request/response logging (structured JSON + event storage)
65
+ └─ Error handler (500 + pino logger)
66
+ ```
67
+
68
+ ### Graceful Shutdown
69
+
70
+ SIGTERM/SIGINT → stop approval router → close HTTP server → end active strategy sessions. Force exit after 35s if shutdown hangs.
71
+
72
+ ---
73
+
74
+ ## Route Categories
75
+
76
+ 25 route modules grouped by function:
77
+
78
+ ### Auth & Setup
79
+
80
+ | Route File | Key Endpoints | Auth |
81
+ |------------|---------------|------|
82
+ | `setup.ts` | `POST /setup` | Public (creates vault) |
83
+ | `unlock.ts` | `GET /unlock`, `POST /unlock`, `POST /unlock/:vaultId` | Public (password required) |
84
+ | `lock.ts` | `POST /lock`, `POST /lock/:vaultId` | Admin |
85
+ | `auth.ts` | `POST /auth`, `GET /auth/:id`, `POST /auth/validate`, `GET /auth/connect` | Public / Any token |
86
+ | `actions.ts` | `POST /actions`, `POST /actions/token`, `POST /actions/:id/resolve`, `GET /actions/tokens` | Admin / action:create |
87
+
88
+ ### Wallet Operations
89
+
90
+ | Route File | Key Endpoints | Auth |
91
+ |------------|---------------|------|
92
+ | `wallet.ts` | `GET /wallets`, `POST /wallet/create`, `POST /wallet/rename`, `POST /wallet/:addr/export` | wallet:list / wallet:create:* / wallet:rename / wallet:export |
93
+ | `send.ts` | `POST /send`, `POST /send/estimate` | send:hot / send:temp |
94
+ | `fund.ts` | `POST /fund` | fund (limit enforced) |
95
+ | `swap.ts` | `POST /swap` | swap |
96
+ | `launch.ts` | `POST /launch`, `POST /launch/collect-fees` | launch |
97
+ | `batch.ts` | `POST /batch` | Public (auth per sub-request) |
98
+
99
+ ### Data & Queries
100
+
101
+ | Route File | Key Endpoints | Auth |
102
+ |------------|---------------|------|
103
+ | `price.ts` | `GET /price/:address` | Public |
104
+ | `token.ts` | `GET /token/search`, `GET /token/safety/:addr`, `GET /token/holders/:addr` | Public |
105
+ | `portfolio.ts` | `GET /wallet/:addr/assets`, `GET /wallet/:addr/transactions` | wallet:list |
106
+ | `resolve.ts` | ENS/address resolution | Public |
107
+ | `defaults.ts` | `GET /defaults`, `PATCH /defaults/:key` | Admin |
108
+
109
+ ### Admin & Extensions
110
+
111
+ | Route File | Key Endpoints | Auth |
112
+ |------------|---------------|------|
113
+ | `strategy.ts` | `GET /strategies`, `POST /strategies/:id/toggle`, `PUT /strategies/:id/config` | strategy:read / strategy:manage |
114
+ | `apps.ts` | `GET/PUT/DELETE /apps/:id/storage/:key`, `POST /apps/:id/message` | app:storage |
115
+ | `adapters.ts` | `GET/POST /adapters`, `POST /adapters/test`, `POST /adapters/restart` | adapter:manage |
116
+ | `apikeys.ts` | `GET /apikeys`, `POST /apikeys`, `POST /apikeys/validate` | apikey:get / apikey:set |
117
+ | `backup.ts` | Backup/export endpoints | Admin |
118
+ | `bookmarks.ts` | `GET/POST/DELETE /bookmarks` | bookmark:write |
119
+ | `addressbook.ts` | `GET/POST/DELETE /address-labels` | addressbook:write |
120
+ | `ai.ts` | `GET /ai/status` | Admin |
121
+ | `nuke.ts` | `POST /nuke` | Admin |
122
+
123
+ ---
124
+
125
+ ## Cron Server
126
+
127
+ Runs as a separate Node process with no HTTP port. Uses setTimeout-based scheduler (not system cron). Jobs skip if already running (no concurrent ticks).
128
+
129
+ ### Jobs
130
+
131
+ | Job | ID | Default Interval | Purpose |
132
+ |-----|----|-----------------|---------|
133
+ | **Balance Sync** | `balance-sync` | 30s | Fetches native balances (ETH/SOL) and tracked asset balances per wallet/chain via RPC |
134
+ | **Incoming Scan** | `incoming-scan` | 10s | Scans blockchain for incoming transactions; emits `transaction:detected` events |
135
+ | **Native Price** | `native-price` | 5min | Updates native currency prices (ETH, SOL → USD) from CoinGecko |
136
+ | **Strategy Runner** | `strategy-runner` | 1s | Orchestrates tick cycles for all active strategies |
137
+
138
+ ### Communication
139
+
140
+ Events emitted via HTTP POST to `http://localhost:4748/broadcast`, which the WebSocket server fans out to all connected clients (dashboards, apps, adapters).
141
+
142
+ All intervals are configurable via SystemDefaults keys (hot-reloadable without restart).
143
+
144
+ ---
145
+
146
+ ## MCP Server
147
+
148
+ Stdio transport — no HTTP port. Used by Claude Code (auto-discovered via `.mcp.json`), Claude Desktop, Cursor, VS Code, Windsurf.
149
+
150
+ | Component | Purpose |
151
+ |-----------|---------|
152
+ | **Tools** | `wallet_api` (HTTP proxy), `request_human_action` (escalation) — socket/bootstrap auth handles session token activation |
153
+ | **Resources** | `docs://api`, `docs://auth`, `docs://guide`, `docs://setup-guide` — on-demand doc access |
154
+ | **Shared definitions** | `server/mcp/tools.ts` powers MCP, Anthropic SDK, and CLI paths |
155
+
156
+ See [MCP.md](./MCP.md) for configuration and tool reference.
157
+
158
+ ---
159
+
160
+ ## Dashboard
161
+
162
+ Next.js 14 application serving the UI and API routes.
163
+
164
+ | Port | Protocol | Purpose |
165
+ |------|----------|---------|
166
+ | 4747 | HTTP | Dashboard UI (`/app`), Next.js API routes (`/api/*`) |
167
+ | 4748 | WebSocket | Real-time event broadcast to all clients |
168
+
169
+ ### Key Components
170
+
171
+ - **WorkspaceContext** — Manages app grid state (drag-and-drop layout)
172
+ - **WebSocketContext** — Connects to WS, receives and distributes events
173
+ - **AppGrid** — Renders workspace apps in a grid layout
174
+ - **IFrameApp** — Renders third-party apps with `sandbox="allow-scripts allow-forms"` (no `allow-same-origin`)
175
+ - **HumanActionBar** — Shows pending approvals with approve/reject UI
176
+
177
+ ### WebSocket Protocol
178
+
179
+ Events flow: Cron/Express → `POST http://localhost:4748/broadcast` → WS server fans out to all connected clients. Event types include `balance:updated`, `action:created`, `strategy:result`, `transaction:detected`, etc.
180
+
181
+ ---
182
+
183
+ ## Subsystem: Strategy Engine
184
+
185
+ 16+ files in `server/lib/strategy/`. Strategies extend apps by adding scheduling and hook fields to the `app.md` manifest placed in `apps/`.
186
+
187
+ ### State Machine (Single Tick)
188
+
189
+ ```
190
+ FETCH SOURCES
191
+ └─ Load external data (HTTP, API keys)
192
+
193
+ CALL TICK HOOK (AI)
194
+ ├─ System prompt + hook instructions
195
+ ├─ Context: sources, state, config, permissions
196
+ └─ Output: intents[] + state updates
197
+
198
+ APPROVAL PHASE (if config.approve=true)
199
+ ├─ Create HumanAction → emit via WebSocket
200
+ └─ Wait for human approval (2min timeout)
201
+
202
+ EXECUTE EACH INTENT
203
+ ├─ Call execute hook (AI validates + transforms)
204
+ └─ Execute action (on-chain tx, API call)
205
+
206
+ CALL RESULT HOOK
207
+ ├─ Process outcomes + state updates
208
+ └─ Queue follow-up intents (max depth: 3)
209
+ ```
210
+
211
+ ### Tick Tiers
212
+
213
+ | Tier | Interval | Use Case |
214
+ |------|----------|----------|
215
+ | `sniper` | 10s | High-frequency trading |
216
+ | `active` | 30s | Active management, rebalancing |
217
+ | `standard` | 60s | Normal strategies |
218
+ | `slow` | 5min | Periodic checks |
219
+ | `maintenance` | 1hr | Cleanup, logging, admin tasks |
220
+
221
+ ### Hook Dispatch
222
+
223
+ | Hook | When | Purpose |
224
+ |------|------|---------|
225
+ | `init` | Strategy enabled | One-time setup, initialize state |
226
+ | `tick` | Each tick cycle | Main decision loop, output intents |
227
+ | `execute` | Per intent | Validate and transform before action |
228
+ | `result` | After execution | Process outcomes, queue follow-ups |
229
+ | `message` | Human message received | Handle queued chat replies |
230
+
231
+ ### Context Deduplication
232
+
233
+ Source data + state are hashed each tick. If the hash matches `lastContextHash`, the LLM call is skipped (reduces cost, prevents duplicate actions).
234
+
235
+ ---
236
+
237
+ ## Subsystem: App System
238
+
239
+ Apps are HTML files + `app.md` manifests placed in `apps/`. They run in sandboxed iframes with scoped tokens.
240
+
241
+ ### Iframe Sandbox
242
+
243
+ ```html
244
+ <iframe src={url} sandbox="allow-scripts allow-forms" />
245
+ ```
246
+
247
+ No `allow-same-origin` — apps cannot access parent DOM, cookies, or localStorage. Communication via `postMessage` only.
248
+
249
+ ### App Token Registry
250
+
251
+ - One token per app, created at server startup from `app.md` manifests
252
+ - Token has app's declared permissions + `app:storage`
253
+ - Token injected into iframe as `window.__AURA_TOKEN__`
254
+ - Revoked on uninstall, invalidated on restart
255
+
256
+ ### Storage API
257
+
258
+ Apps get persistent key-value storage scoped to their app ID via REST endpoints:
259
+
260
+ - `GET /apps/:id/storage/:key` — Read
261
+ - `PUT /apps/:id/storage/:key` — Write
262
+ - `DELETE /apps/:id/storage/:key` — Delete
263
+
264
+ ---
265
+
266
+ ## Subsystem: Approval Adapters
267
+
268
+ All approval channels converge on `POST /actions/:id/resolve`.
269
+
270
+ ```
271
+ ┌── Dashboard UI
272
+
273
+ Agent → POST /auth ─┼── CLI terminal
274
+
275
+ ├── Telegram bot
276
+
277
+ └── Webhook → target POSTs back to /actions/:id/resolve
278
+ ```
279
+
280
+ | Adapter | Bidirectional | Description |
281
+ |---------|:---:|-------------|
282
+ | **Telegram** | Yes | Bot with inline keyboard buttons (Approve/Reject). Long-polling via raw fetch. Supports chat mode |
283
+ | **Webhook** | No | POSTs action events to configured URL. Optional HMAC-SHA256 signature. Notification-only |
284
+ | **Internal Router** | Yes | CLI approval listener (`npx aurawallet cli`) for headless environments |
285
+
286
+ The **ApprovalRouter** connects to WebSocket, subscribes to `action:created` events, and fans out notifications to all configured adapters.
287
+
288
+ ---
289
+
290
+ ## Data Model
291
+
292
+ ### Filesystem (`~/.aurawallet/`)
293
+
294
+ | Path | Purpose |
295
+ |------|---------|
296
+ | `aurawallet.db` | SQLite database (all tables below) |
297
+ | `vault-primary.json` | Primary vault (encrypted seed phrase) |
298
+ | `vault-*.json` | Additional vaults |
299
+ | `config.json` | Chain configs, server port |
300
+ | `logs/` | Hook audit logs, strategy session logs |
301
+
302
+ ### Key Database Tables
303
+
304
+ | Table | Purpose |
305
+ |-------|---------|
306
+ | `HotWallet` | Hot/temp wallets — address, encryptedPrivateKey, tokenHash (owner), chain |
307
+ | `HumanAction` | Pending/resolved approvals — type, amount, status, metadata |
308
+ | `AgentToken` | Token registry (display only) — tokenHash, agentId, permissions, spent |
309
+ | `Event` | Audit trail — type, source, data (JSON), timestamp |
310
+ | `Strategy` | Strategy records — manifest, config, state, enabled, lastTickAt |
311
+ | `ApiKey` | External API keys — service, name, key |
312
+ | `Transaction` | Transaction history — walletAddress, txHash, type, amount, chain |
313
+ | `TrackedAsset` | Watched tokens — walletAddress, tokenAddress, symbol, balance |
314
+ | `NativeBalance` | Native coin balances per wallet/chain |
315
+ | `NativePrice` | Exchange rates (ETH, SOL → USD) |
316
+ | `Workspace` | Dashboard tabs — name, slug, order |
317
+ | `WorkspaceApp` | App instances — workspaceId, appType, position, config |
318
+
319
+ ---
320
+
321
+ ## Dependency Flow
322
+
323
+ ```
324
+ ┌─────────────────────────────────────────────────────────────────┐
325
+ │ HUMAN │
326
+ │ Browser (Dashboard :4747) / Telegram / CLI terminal │
327
+ └──────────┬──────────────────────────────────┬────────────────────┘
328
+ │ HTTP │ WebSocket
329
+ ▼ ▼
330
+ ┌─────────────────────┐ ┌──────────────────────┐
331
+ │ Express :4242 │──── HTTP ───►│ WebSocket :4748 │
332
+ │ Wallet API │ │ Event broadcast │
333
+ │ Strategy Engine │ └──────────┬───────────┘
334
+ │ Approval Router │ │
335
+ └─────────┬───────────┘ │
336
+ │ │
337
+ │ Prisma │ Events
338
+ ▼ ▼
339
+ ┌─────────────────────┐ ┌──────────────────────┐
340
+ │ SQLite DB │ │ Cron Server │
341
+ │ ~/.aurawallet/ │◄─── Prisma ──│ balance-sync │
342
+ │ aurawallet.db │ │ incoming-scan │
343
+ └─────────────────────┘ │ native-price │
344
+ │ strategy-runner │
345
+ ┌─────────────────────┐ └──────────────────────┘
346
+ │ MCP Server │
347
+ │ stdio transport │──── HTTP ───► Express :4242
348
+ │ Claude/Cursor/etc │
349
+ └─────────────────────┘
350
+ ```