auramaxx 0.0.1
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.
- package/LICENSE +26 -0
- package/README.md +77 -0
- package/apps/desktop-electron/main.js +428 -0
- package/bin/auramaxx.js +1063 -0
- package/docs/ADAPTERS.md +466 -0
- package/docs/AGENT_SETUP.md +159 -0
- package/docs/API.md +127 -0
- package/docs/APPS.md +199 -0
- package/docs/ARCHITECTURE.md +235 -0
- package/docs/AUTH.md +318 -0
- package/docs/BEST-PRACTICES.md +82 -0
- package/docs/CLI.md +141 -0
- package/docs/DESKTOP_ELECTRON.md +26 -0
- package/docs/DEVELOPING-APPS.md +453 -0
- package/docs/MCP.md +122 -0
- package/docs/PACKAGING_POLICY.md +19 -0
- package/docs/PERMISSION.md +137 -0
- package/docs/PROTOCOL.md +142 -0
- package/docs/README.md +50 -0
- package/docs/SKILLS.md +132 -0
- package/docs/TROUBLESHOOTING.md +376 -0
- package/docs/WORKSPACE.md +673 -0
- package/docs/agent-auth.md +14 -0
- package/docs/api/authentication.md +79 -0
- package/docs/api/secrets/api-keys.md +28 -0
- package/docs/api/secrets/credentials.md +80 -0
- package/docs/api/secrets/sharing.md +48 -0
- package/docs/api/system.md +41 -0
- package/docs/api/wallets/apps-strategies.md +66 -0
- package/docs/api/wallets/core.md +46 -0
- package/docs/api/wallets/data-portfolio.md +42 -0
- package/docs/aura-file.md +48 -0
- package/docs/core-concepts/FEATURES.md +114 -0
- package/docs/credentials.md +120 -0
- package/docs/external/HOW_TO_AURAMAXX/GETTING_SECRETS.md +33 -0
- package/docs/external/HOW_TO_AURAMAXX/README.md +45 -0
- package/docs/external/getting-started.md +10 -0
- package/docs/external/overview.md +19 -0
- package/docs/external/persona-paths.md +7 -0
- package/docs/external/share-secret.md +76 -0
- package/docs/external/why-aura.md +7 -0
- package/docs/security.md +227 -0
- package/docs/templates/RELEASE_NOTES_TEMPLATE.md +22 -0
- package/docs/wallet/AI.md +508 -0
- package/docs/wallet/DEVELOPING-STRATEGIES.md +713 -0
- package/docs/wallet/README.md +47 -0
- package/docs/wallet/STRATEGY.md +89 -0
- package/next.config.ts +28 -0
- package/package.json +167 -0
- package/postcss.config.mjs +8 -0
- package/prisma/migrations/20260214170000_baseline/migration.sql +511 -0
- package/prisma/migrations/20260216214537_add_passkey_model/migration.sql +18 -0
- package/prisma/migrations/20260217150500_add_credential_access_audit/migration.sql +31 -0
- package/prisma/migrations/20260222090000_update_admin_ttl_default/migration.sql +10 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +447 -0
- package/public/logo.webp +0 -0
- package/scripts/add-app.js +245 -0
- package/server/abi/SwapHelper.json +438 -0
- package/server/cli/approval.ts +447 -0
- package/server/cli/commands/actions.ts +474 -0
- package/server/cli/commands/api.ts +220 -0
- package/server/cli/commands/apikey.ts +277 -0
- package/server/cli/commands/app.ts +204 -0
- package/server/cli/commands/auth.ts +464 -0
- package/server/cli/commands/cron.ts +24 -0
- package/server/cli/commands/diary.ts +274 -0
- package/server/cli/commands/doctor.ts +1247 -0
- package/server/cli/commands/env.ts +476 -0
- package/server/cli/commands/experimental.ts +69 -0
- package/server/cli/commands/init.ts +798 -0
- package/server/cli/commands/lock.ts +157 -0
- package/server/cli/commands/mcp.ts +285 -0
- package/server/cli/commands/quickhack.ts +86 -0
- package/server/cli/commands/release-check.ts +231 -0
- package/server/cli/commands/restore.ts +314 -0
- package/server/cli/commands/service.ts +320 -0
- package/server/cli/commands/shell-hook.ts +512 -0
- package/server/cli/commands/skill.ts +216 -0
- package/server/cli/commands/start.ts +139 -0
- package/server/cli/commands/status.ts +59 -0
- package/server/cli/commands/stop.ts +36 -0
- package/server/cli/commands/token.ts +180 -0
- package/server/cli/commands/unlock.ts +50 -0
- package/server/cli/commands/vault.ts +1323 -0
- package/server/cli/commands/wallet.ts +209 -0
- package/server/cli/index.ts +280 -0
- package/server/cli/lib/approval-poll.ts +94 -0
- package/server/cli/lib/aura-parser.ts +64 -0
- package/server/cli/lib/credential-create.ts +74 -0
- package/server/cli/lib/credential-resolve.ts +280 -0
- package/server/cli/lib/dotenv-migrate.ts +116 -0
- package/server/cli/lib/dotenv-parser.ts +146 -0
- package/server/cli/lib/escalation.ts +57 -0
- package/server/cli/lib/http.ts +91 -0
- package/server/cli/lib/init-steps.ts +76 -0
- package/server/cli/lib/local-agent-trust.ts +45 -0
- package/server/cli/lib/lock-unlock-helper.ts +71 -0
- package/server/cli/lib/process.ts +162 -0
- package/server/cli/lib/prompt.ts +294 -0
- package/server/cli/lib/theme.ts +240 -0
- package/server/cli/socket.ts +579 -0
- package/server/cli/transport-client.ts +50 -0
- package/server/cron/index.ts +137 -0
- package/server/cron/job.ts +31 -0
- package/server/cron/jobs/balance-sync.ts +436 -0
- package/server/cron/jobs/incoming-scan.ts +506 -0
- package/server/cron/jobs/native-price.ts +70 -0
- package/server/cron/jobs/orphan-cleanup.ts +40 -0
- package/server/cron/jobs/strategy-runner.ts +175 -0
- package/server/cron/scheduler.ts +125 -0
- package/server/index.ts +420 -0
- package/server/lib/adapters/factory.ts +119 -0
- package/server/lib/adapters/index.ts +19 -0
- package/server/lib/adapters/router.ts +297 -0
- package/server/lib/adapters/telegram.ts +645 -0
- package/server/lib/adapters/types.ts +89 -0
- package/server/lib/adapters/webhook.ts +95 -0
- package/server/lib/address.ts +49 -0
- package/server/lib/agent-auth/contracts.ts +1194 -0
- package/server/lib/agent-profiles.ts +419 -0
- package/server/lib/ai.ts +285 -0
- package/server/lib/api-registry/contracts.ts +86 -0
- package/server/lib/api-registry/validation.ts +172 -0
- package/server/lib/apikey-migration.ts +258 -0
- package/server/lib/app-installer.ts +505 -0
- package/server/lib/app-tokens.ts +247 -0
- package/server/lib/approval-link.ts +27 -0
- package/server/lib/auth.ts +314 -0
- package/server/lib/auto-execute.ts +160 -0
- package/server/lib/batch.ts +242 -0
- package/server/lib/cold.ts +1048 -0
- package/server/lib/config.ts +408 -0
- package/server/lib/credential-access-audit.ts +85 -0
- package/server/lib/credential-access-policy.ts +111 -0
- package/server/lib/credential-health.ts +343 -0
- package/server/lib/credential-import.ts +608 -0
- package/server/lib/credential-scope.ts +102 -0
- package/server/lib/credential-shares.ts +190 -0
- package/server/lib/credential-transport.ts +533 -0
- package/server/lib/credential-vault.ts +77 -0
- package/server/lib/credentials.ts +422 -0
- package/server/lib/crypto.ts +8 -0
- package/server/lib/db.ts +58 -0
- package/server/lib/defaults.ts +386 -0
- package/server/lib/dex/index.ts +80 -0
- package/server/lib/dex/relay.ts +235 -0
- package/server/lib/dex/types.ts +59 -0
- package/server/lib/dex/uniswap.ts +370 -0
- package/server/lib/diary.ts +34 -0
- package/server/lib/dont-ask-again-policy.ts +41 -0
- package/server/lib/e2e-agent/artifacts.ts +36 -0
- package/server/lib/e2e-agent/contracts.ts +112 -0
- package/server/lib/e2e-agent/validation.ts +135 -0
- package/server/lib/encrypt.ts +114 -0
- package/server/lib/error.ts +20 -0
- package/server/lib/events.ts +217 -0
- package/server/lib/feature-flags.ts +93 -0
- package/server/lib/hot.ts +357 -0
- package/server/lib/human-action-summary.ts +80 -0
- package/server/lib/key-fingerprint.ts +28 -0
- package/server/lib/logger.ts +340 -0
- package/server/lib/network.ts +137 -0
- package/server/lib/notifications.ts +230 -0
- package/server/lib/oauth2-refresh.ts +241 -0
- package/server/lib/oursecret.ts +71 -0
- package/server/lib/passkey-credential.ts +360 -0
- package/server/lib/passkey.ts +68 -0
- package/server/lib/permissions.ts +299 -0
- package/server/lib/pino.ts +24 -0
- package/server/lib/policy-preview.ts +138 -0
- package/server/lib/price.ts +338 -0
- package/server/lib/prices.ts +34 -0
- package/server/lib/project-scope.ts +297 -0
- package/server/lib/resolve-action.ts +328 -0
- package/server/lib/resolve.ts +36 -0
- package/server/lib/secret-gist-share.ts +296 -0
- package/server/lib/sessions.ts +634 -0
- package/server/lib/socket-path.ts +56 -0
- package/server/lib/solana/connection.ts +26 -0
- package/server/lib/solana/jupiter.ts +128 -0
- package/server/lib/solana/transfer.ts +108 -0
- package/server/lib/solana/wallet.ts +136 -0
- package/server/lib/strategy/emits.ts +21 -0
- package/server/lib/strategy/engine.ts +1305 -0
- package/server/lib/strategy/executor.ts +115 -0
- package/server/lib/strategy/hook-context.ts +159 -0
- package/server/lib/strategy/hooks.ts +990 -0
- package/server/lib/strategy/index.ts +28 -0
- package/server/lib/strategy/installer.ts +305 -0
- package/server/lib/strategy/loader.ts +256 -0
- package/server/lib/strategy/message.ts +237 -0
- package/server/lib/strategy/repository.ts +218 -0
- package/server/lib/strategy/session-logger.ts +693 -0
- package/server/lib/strategy/sources.ts +288 -0
- package/server/lib/strategy/state.ts +189 -0
- package/server/lib/strategy/templates.ts +403 -0
- package/server/lib/strategy/tick.ts +404 -0
- package/server/lib/strategy/types.ts +230 -0
- package/server/lib/swap.ts +3 -0
- package/server/lib/temp.ts +86 -0
- package/server/lib/token-metadata.ts +86 -0
- package/server/lib/token-safety.ts +200 -0
- package/server/lib/token-search.ts +444 -0
- package/server/lib/totp.ts +194 -0
- package/server/lib/transactions.ts +123 -0
- package/server/lib/transport.ts +84 -0
- package/server/lib/txhistory/decoder.ts +262 -0
- package/server/lib/txhistory/enricher.ts +652 -0
- package/server/lib/txhistory/index.ts +391 -0
- package/server/lib/txhistory/signatures.ts +59 -0
- package/server/lib/update-check.ts +35 -0
- package/server/lib/verified-summary.ts +414 -0
- package/server/lib/view-registry.ts +80 -0
- package/server/mcp/profile-policy.ts +30 -0
- package/server/mcp/server.ts +1589 -0
- package/server/mcp/tools.ts +276 -0
- package/server/middleware/auth.ts +119 -0
- package/server/middleware/requestLogger.ts +84 -0
- package/server/routes/actions.ts +539 -0
- package/server/routes/adapters.ts +711 -0
- package/server/routes/addressbook.ts +113 -0
- package/server/routes/ai.ts +34 -0
- package/server/routes/apikeys.ts +343 -0
- package/server/routes/apps.ts +601 -0
- package/server/routes/auth.ts +406 -0
- package/server/routes/backup.ts +404 -0
- package/server/routes/batch.ts +270 -0
- package/server/routes/bookmarks.ts +162 -0
- package/server/routes/credential-shares.ts +380 -0
- package/server/routes/credential-vaults.ts +159 -0
- package/server/routes/credentials.ts +1782 -0
- package/server/routes/dashboard.ts +97 -0
- package/server/routes/defaults.ts +124 -0
- package/server/routes/flags.ts +11 -0
- package/server/routes/fund.ts +225 -0
- package/server/routes/heartbeat.ts +375 -0
- package/server/routes/import.ts +364 -0
- package/server/routes/launch.ts +665 -0
- package/server/routes/lock.ts +54 -0
- package/server/routes/logs.ts +68 -0
- package/server/routes/nuke.ts +111 -0
- package/server/routes/passkey-credentials.ts +99 -0
- package/server/routes/passkey.ts +366 -0
- package/server/routes/portfolio.ts +217 -0
- package/server/routes/price.ts +63 -0
- package/server/routes/resolve.ts +31 -0
- package/server/routes/security.ts +45 -0
- package/server/routes/send-evm.ts +241 -0
- package/server/routes/send-solana.ts +281 -0
- package/server/routes/send.ts +178 -0
- package/server/routes/setup.ts +210 -0
- package/server/routes/strategy.ts +894 -0
- package/server/routes/swap-evm.ts +352 -0
- package/server/routes/swap-solana.ts +176 -0
- package/server/routes/swap.ts +356 -0
- package/server/routes/token.ts +247 -0
- package/server/routes/unlock.ts +467 -0
- package/server/routes/views.ts +41 -0
- package/server/routes/wallet-assets.ts +361 -0
- package/server/routes/wallet-transactions.ts +515 -0
- package/server/routes/wallet.ts +709 -0
- package/server/types.ts +146 -0
- package/shared/credential-field-schema.ts +248 -0
- package/skills/auramaxx/HEARTBEAT.md +78 -0
- package/skills/auramaxx/SKILL.md +745 -0
- package/skills/auramaxx/docs/AGENT_SETUP.md +155 -0
- package/skills/auramaxx/docs/API.md +127 -0
- package/skills/auramaxx/docs/AUTH.md +318 -0
- package/skills/auramaxx/docs/CLI.md +130 -0
- package/skills/auramaxx/docs/MCP.md +122 -0
- package/skills/auramaxx/docs/TROUBLESHOOTING.md +357 -0
- package/skills/auramaxx/docs/WORKSPACE.md +673 -0
- package/skills/auramaxx/docs/security.md +227 -0
- package/skills/task-lifecycle/SKILL.md +378 -0
- package/src/app/api/[...doc]/page.tsx +36 -0
- package/src/app/api/agent-requests/route.ts +30 -0
- package/src/app/api/apps/install/route.ts +132 -0
- package/src/app/api/apps/manifests/route.ts +16 -0
- package/src/app/api/apps/static/[...path]/route.ts +57 -0
- package/src/app/api/docs/plain/route.ts +74 -0
- package/src/app/api/events/route.ts +92 -0
- package/src/app/api/page.tsx +290 -0
- package/src/app/api/workspace/[id]/apps/[wid]/route.ts +119 -0
- package/src/app/api/workspace/[id]/apps/route.ts +81 -0
- package/src/app/api/workspace/[id]/export/route.ts +67 -0
- package/src/app/api/workspace/[id]/route.ts +168 -0
- package/src/app/api/workspace/auth.ts +40 -0
- package/src/app/api/workspace/config/route.ts +121 -0
- package/src/app/api/workspace/import/route.ts +127 -0
- package/src/app/api/workspace/route.ts +116 -0
- package/src/app/app-legacy-do-not-use/page.tsx +2245 -0
- package/src/app/apple-icon.png +0 -0
- package/src/app/approve/[actionId]/page.tsx +409 -0
- package/src/app/docs/DocsPageContent.tsx +269 -0
- package/src/app/docs/[...doc]/page.tsx +41 -0
- package/src/app/docs/page.tsx +38 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +819 -0
- package/src/app/health/page.tsx +5 -0
- package/src/app/hello/page.tsx +102 -0
- package/src/app/icon.png +0 -0
- package/src/app/layout.tsx +39 -0
- package/src/app/page.tsx +1964 -0
- package/src/app/privacy/page.tsx +63 -0
- package/src/app/providers.tsx +87 -0
- package/src/app/share/[token]/page.tsx +295 -0
- package/src/app/terms/page.tsx +80 -0
- package/src/components/ChainSelector.tsx +44 -0
- package/src/components/HumanActionBar.tsx +697 -0
- package/src/components/NotificationDrawer.tsx +387 -0
- package/src/components/PasskeyEnrollmentPrompt.tsx +235 -0
- package/src/components/apps/AgentKeysApp.tsx +490 -0
- package/src/components/apps/App.tsx +153 -0
- package/src/components/apps/AppGrid.tsx +15 -0
- package/src/components/apps/DetailedAddressDrawer.tsx +325 -0
- package/src/components/apps/DraggableApp.tsx +562 -0
- package/src/components/apps/IFrameApp.tsx +73 -0
- package/src/components/apps/LogsApp.tsx +360 -0
- package/src/components/apps/SendApp.tsx +394 -0
- package/src/components/apps/SetupWizardApp.tsx +1004 -0
- package/src/components/apps/SystemDefaultsApp.tsx +845 -0
- package/src/components/apps/ThirdPartyApp.tsx +428 -0
- package/src/components/apps/TokenApp.tsx +319 -0
- package/src/components/apps/TransactionsApp.tsx +438 -0
- package/src/components/apps/WalletDetailApp.tsx +1505 -0
- package/src/components/apps/index.ts +13 -0
- package/src/components/design-system/Button.tsx +88 -0
- package/src/components/design-system/ChainIndicator.tsx +65 -0
- package/src/components/design-system/ChainSelector.tsx +147 -0
- package/src/components/design-system/ConfirmationModal.tsx +107 -0
- package/src/components/design-system/ConfirmationPopover.tsx +81 -0
- package/src/components/design-system/DownloadButton.tsx +149 -0
- package/src/components/design-system/Drawer.tsx +133 -0
- package/src/components/design-system/FilterDropdown.tsx +183 -0
- package/src/components/design-system/ItemPicker.tsx +157 -0
- package/src/components/design-system/Modal.tsx +296 -0
- package/src/components/design-system/Popover.tsx +142 -0
- package/src/components/design-system/TextInput.tsx +85 -0
- package/src/components/design-system/Toggle.tsx +65 -0
- package/src/components/design-system/TyvekCollapsibleSection.tsx +55 -0
- package/src/components/design-system/index.ts +14 -0
- package/src/components/docs/ClientSideMarkdown.tsx +51 -0
- package/src/components/docs/DocsSearchBar.tsx +118 -0
- package/src/components/docs/DocsThemeToggle.tsx +38 -0
- package/src/components/docs/PersistentDocGroup.tsx +91 -0
- package/src/components/docs/ShareUrlButton.tsx +33 -0
- package/src/components/docs/SidebarScrollMemory.tsx +56 -0
- package/src/components/health/CredentialHealthDashboard.tsx +214 -0
- package/src/components/icons/ChainIcons.tsx +72 -0
- package/src/components/layout/AppStoreDrawer.tsx +369 -0
- package/src/components/layout/ContentArea.tsx +21 -0
- package/src/components/layout/CreateViewModal.tsx +88 -0
- package/src/components/layout/LeftRail.tsx +114 -0
- package/src/components/layout/TabBar.tsx +284 -0
- package/src/components/layout/WalletSidebar.tsx +1030 -0
- package/src/components/layout/index.ts +6 -0
- package/src/components/marketing/AuraMaxxSpecOverlay.tsx +653 -0
- package/src/components/marketing/DeviceMorphExperience.tsx +216 -0
- package/src/components/vault/ApiKeysConsole.tsx +1272 -0
- package/src/components/vault/AuditConsole.tsx +600 -0
- package/src/components/vault/CredentialDetail.tsx +625 -0
- package/src/components/vault/CredentialEmpty.tsx +55 -0
- package/src/components/vault/CredentialField.tsx +583 -0
- package/src/components/vault/CredentialForm.tsx +1484 -0
- package/src/components/vault/CredentialList.tsx +265 -0
- package/src/components/vault/CredentialRow.tsx +130 -0
- package/src/components/vault/CredentialShareModal.tsx +273 -0
- package/src/components/vault/CredentialVault.tsx +1662 -0
- package/src/components/vault/CredentialWalletWidget.tsx +103 -0
- package/src/components/vault/DocsConsole.tsx +113 -0
- package/src/components/vault/ImportCredentialsModal.tsx +578 -0
- package/src/components/vault/LargeTypeModal.tsx +88 -0
- package/src/components/vault/PasswordGenerator.tsx +232 -0
- package/src/components/vault/TOTPDisplay.tsx +108 -0
- package/src/components/vault/TotpSetupPanel.tsx +198 -0
- package/src/components/vault/VaultSidebar.tsx +881 -0
- package/src/components/vault/credentialFormName.ts +91 -0
- package/src/components/vault/hooks/useVaultKeyboardShortcuts.ts +69 -0
- package/src/components/vault/types.ts +56 -0
- package/src/context/AuthContext.tsx +365 -0
- package/src/context/PriceContext.tsx +113 -0
- package/src/context/ThemeContext.tsx +164 -0
- package/src/context/WebSocketContext.tsx +269 -0
- package/src/context/WorkspaceContext.tsx +668 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useAgentActions.ts +552 -0
- package/src/hooks/useBalance.ts +103 -0
- package/src/hooks/useBalances.ts +129 -0
- package/src/hooks/useTheme.ts +156 -0
- package/src/instrumentation.ts +12 -0
- package/src/lib/api-docs.ts +154 -0
- package/src/lib/api.ts +474 -0
- package/src/lib/app-loader.ts +148 -0
- package/src/lib/app-registry.ts +178 -0
- package/src/lib/app-sdk.ts +157 -0
- package/src/lib/audit-console-adapter.ts +151 -0
- package/src/lib/auth-client.ts +75 -0
- package/src/lib/config.ts +74 -0
- package/src/lib/credential-field-schema.ts +11 -0
- package/src/lib/crypto.ts +112 -0
- package/src/lib/db.ts +21 -0
- package/src/lib/docs.ts +544 -0
- package/src/lib/events.ts +363 -0
- package/src/lib/pino.ts +24 -0
- package/src/lib/theme-handlers.ts +168 -0
- package/src/lib/theme.ts +351 -0
- package/src/lib/tokenData.ts +378 -0
- package/src/lib/totp-import.ts +57 -0
- package/src/lib/vault-crypto.ts +129 -0
- package/src/lib/view-registry.ts +57 -0
- package/src/lib/websocket-server.ts +302 -0
- package/src/lib/websocket-setup.ts +79 -0
- package/src/lib/wordlist.ts +2050 -0
- package/src/lib/workspace-handlers.ts +285 -0
- package/start.sh +170 -0
- package/tailwind.config.ts +99 -0
- package/tsconfig.json +42 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP helpers for CLI commands
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const DEFAULT_SERVER_URL = 'http://localhost:4242';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get the wallet server URL from env or default
|
|
9
|
+
*/
|
|
10
|
+
export function serverUrl(): string {
|
|
11
|
+
return process.env.WALLET_SERVER_URL || DEFAULT_SERVER_URL;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Fetch JSON from the wallet server
|
|
16
|
+
*/
|
|
17
|
+
export async function fetchJson<T = unknown>(
|
|
18
|
+
path: string,
|
|
19
|
+
opts: { method?: string; body?: unknown; token?: string } = {}
|
|
20
|
+
): Promise<T> {
|
|
21
|
+
const url = `${serverUrl()}${path}`;
|
|
22
|
+
const headers: Record<string, string> = { 'Content-Type': 'application/json' };
|
|
23
|
+
if (opts.token) {
|
|
24
|
+
headers['Authorization'] = `Bearer ${opts.token}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const response = await fetch(url, {
|
|
28
|
+
method: opts.method || (opts.body ? 'POST' : 'GET'),
|
|
29
|
+
headers,
|
|
30
|
+
body: opts.body ? JSON.stringify(opts.body) : undefined,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const data = await response.json() as T & { error?: string };
|
|
34
|
+
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
throw new Error((data as { error?: string }).error || `HTTP ${response.status}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Fetch the server's RSA public key for password encryption
|
|
44
|
+
*/
|
|
45
|
+
export async function fetchPublicKey(): Promise<string> {
|
|
46
|
+
const data = await fetchJson<{ publicKey: string }>('/auth/connect');
|
|
47
|
+
return data.publicKey;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Check if the wallet server is running
|
|
52
|
+
*/
|
|
53
|
+
export async function isServerRunning(): Promise<boolean> {
|
|
54
|
+
try {
|
|
55
|
+
await fetchJson('/health');
|
|
56
|
+
return true;
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Poll /health until the server is up, or timeout
|
|
64
|
+
*/
|
|
65
|
+
export async function waitForServer(timeoutMs: number = 15000): Promise<void> {
|
|
66
|
+
const start = Date.now();
|
|
67
|
+
while (Date.now() - start < timeoutMs) {
|
|
68
|
+
if (await isServerRunning()) return;
|
|
69
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
70
|
+
}
|
|
71
|
+
throw new Error(`Server did not start within ${timeoutMs / 1000}s`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Setup status from GET /setup
|
|
76
|
+
*/
|
|
77
|
+
export interface SetupStatus {
|
|
78
|
+
hasWallet: boolean;
|
|
79
|
+
unlocked: boolean;
|
|
80
|
+
address: string | null;
|
|
81
|
+
adapters?: { telegram: boolean; webhook: boolean };
|
|
82
|
+
apiKeys?: { alchemy: boolean; anthropic: boolean };
|
|
83
|
+
defaultChain?: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Fetch setup status from the wallet server
|
|
88
|
+
*/
|
|
89
|
+
export async function fetchSetupStatus(): Promise<SetupStatus> {
|
|
90
|
+
return fetchJson<SetupStatus>('/setup');
|
|
91
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem + Prisma setup steps for init command
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import * as fs from 'fs';
|
|
7
|
+
import * as os from 'os';
|
|
8
|
+
import { execSync } from 'child_process';
|
|
9
|
+
import { findProjectRoot } from './process';
|
|
10
|
+
|
|
11
|
+
function getDataDir(): string {
|
|
12
|
+
return process.env.WALLET_DATA_DIR || path.join(os.homedir(), '.auramaxx');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Create the ~/.auramaxx/ directory structure
|
|
17
|
+
*/
|
|
18
|
+
export function ensureDirectories(): void {
|
|
19
|
+
const dataDir = getDataDir();
|
|
20
|
+
const dirs = [
|
|
21
|
+
dataDir,
|
|
22
|
+
path.join(dataDir, 'hot'),
|
|
23
|
+
path.join(dataDir, 'pending'),
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
for (const dir of dirs) {
|
|
27
|
+
if (!fs.existsSync(dir)) {
|
|
28
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Root-level tmp/backups directories are no longer created here.
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Run Prisma migrations against ~/.auramaxx/auramaxx.db
|
|
37
|
+
*/
|
|
38
|
+
export function runMigrations(root?: string): void {
|
|
39
|
+
const projectRoot = root || findProjectRoot();
|
|
40
|
+
const dbUrl = process.env.DATABASE_URL || `file:${getDataDir()}/auramaxx.db`;
|
|
41
|
+
const env = { ...process.env, DATABASE_URL: dbUrl };
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
// Try deploy first (production-style, no prompts)
|
|
45
|
+
execSync('npx prisma migrate deploy', {
|
|
46
|
+
cwd: projectRoot,
|
|
47
|
+
env,
|
|
48
|
+
stdio: 'pipe',
|
|
49
|
+
});
|
|
50
|
+
} catch {
|
|
51
|
+
// Fallback to dev migration (creates migration if needed)
|
|
52
|
+
execSync('npx prisma migrate dev --name init', {
|
|
53
|
+
cwd: projectRoot,
|
|
54
|
+
env,
|
|
55
|
+
stdio: 'pipe',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Generate the Prisma client
|
|
62
|
+
*/
|
|
63
|
+
export function generatePrismaClient(root?: string): void {
|
|
64
|
+
const projectRoot = root || findProjectRoot();
|
|
65
|
+
execSync('npx prisma generate', {
|
|
66
|
+
cwd: projectRoot,
|
|
67
|
+
stdio: 'pipe',
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Check if a primary vault file already exists
|
|
73
|
+
*/
|
|
74
|
+
export function hasVault(): boolean {
|
|
75
|
+
return fs.existsSync(path.join(getDataDir(), 'vault-primary.json'));
|
|
76
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { LocalAgentProfileMode } from '../../lib/agent-profiles';
|
|
2
|
+
import { fetchJson } from './http';
|
|
3
|
+
|
|
4
|
+
export interface LocalAgentTrustDefaults {
|
|
5
|
+
profile: LocalAgentProfileMode;
|
|
6
|
+
profileVersion: 'v1';
|
|
7
|
+
autoApprove: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function resolveLocalAgentModeChoice(input: string): LocalAgentProfileMode {
|
|
11
|
+
const normalized = input.trim().toLowerCase();
|
|
12
|
+
if (normalized === '2' || normalized === 'strict') return 'strict';
|
|
13
|
+
if (normalized === '3' || normalized === 'admin') return 'admin';
|
|
14
|
+
return 'dev';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function toLocalAgentTrustDefaults(profile: LocalAgentProfileMode): LocalAgentTrustDefaults {
|
|
18
|
+
return {
|
|
19
|
+
profile,
|
|
20
|
+
profileVersion: 'v1',
|
|
21
|
+
autoApprove: profile !== 'strict',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function persistLocalAgentTrustDefaults(token: string, profile: LocalAgentProfileMode): Promise<LocalAgentTrustDefaults> {
|
|
26
|
+
const defaults = toLocalAgentTrustDefaults(profile);
|
|
27
|
+
|
|
28
|
+
await fetchJson('/defaults/trust.localProfile', {
|
|
29
|
+
method: 'PATCH',
|
|
30
|
+
body: { value: defaults.profile },
|
|
31
|
+
token,
|
|
32
|
+
});
|
|
33
|
+
await fetchJson('/defaults/trust.localProfileVersion', {
|
|
34
|
+
method: 'PATCH',
|
|
35
|
+
body: { value: defaults.profileVersion },
|
|
36
|
+
token,
|
|
37
|
+
});
|
|
38
|
+
await fetchJson('/defaults/trust.localAutoApprove', {
|
|
39
|
+
method: 'PATCH',
|
|
40
|
+
body: { value: defaults.autoApprove },
|
|
41
|
+
token,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return defaults;
|
|
45
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
|
+
import { promptSelect } from './prompt';
|
|
3
|
+
import { getErrorMessage } from '../../lib/error';
|
|
4
|
+
|
|
5
|
+
export interface LockUnlockHelperInput {
|
|
6
|
+
context: string;
|
|
7
|
+
error?: unknown;
|
|
8
|
+
statusCode?: number;
|
|
9
|
+
payload?: unknown;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function dashboardUrl(): string {
|
|
13
|
+
const port = process.env.DASHBOARD_PORT || '4747';
|
|
14
|
+
return `http://localhost:${port}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function toSearchableText(input: LockUnlockHelperInput): string {
|
|
18
|
+
const parts: string[] = [];
|
|
19
|
+
if (input.error) parts.push(getErrorMessage(input.error));
|
|
20
|
+
if (typeof input.payload === 'string') parts.push(input.payload);
|
|
21
|
+
if (input.payload && typeof input.payload === 'object') {
|
|
22
|
+
try {
|
|
23
|
+
parts.push(JSON.stringify(input.payload));
|
|
24
|
+
} catch {
|
|
25
|
+
// ignore
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return parts.join(' ').toLowerCase();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function isLikelyLockError(input: LockUnlockHelperInput): boolean {
|
|
32
|
+
if (input.statusCode === 423) return true;
|
|
33
|
+
const text = toSearchableText(input);
|
|
34
|
+
const hasLockWord = text.includes('locked') || text.includes('unlock');
|
|
35
|
+
const hasVaultContext = text.includes('vault') || text.includes('wallet') || text.includes('daemon');
|
|
36
|
+
return hasLockWord && hasVaultContext;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function printSharedGuidance(context: string): void {
|
|
40
|
+
console.error(`\nVault is locked (${context}).`);
|
|
41
|
+
console.error(`1) Unlock in dashboard: ${dashboardUrl()}`);
|
|
42
|
+
console.error('2) Unlock in terminal now (hidden password): auramaxx unlock');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function maybeHandleLockError(input: LockUnlockHelperInput): Promise<boolean> {
|
|
46
|
+
if (!isLikelyLockError(input)) return false;
|
|
47
|
+
|
|
48
|
+
const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
49
|
+
printSharedGuidance(input.context);
|
|
50
|
+
|
|
51
|
+
if (!interactive) {
|
|
52
|
+
console.error('Non-interactive shell detected; run `auramaxx unlock` and retry.');
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const choice = await promptSelect('Choose unlock path:', [
|
|
57
|
+
{ value: 'dashboard', label: 'dashboard', aliases: ['1', 'open'] },
|
|
58
|
+
{ value: 'terminal', label: 'terminal (unlock now)', aliases: ['2', 'cli'] },
|
|
59
|
+
], 'terminal');
|
|
60
|
+
|
|
61
|
+
if (choice === 'terminal') {
|
|
62
|
+
const result = spawnSync('npx', ['auramaxx', 'unlock'], { stdio: 'inherit', env: process.env });
|
|
63
|
+
if (result.status !== 0) {
|
|
64
|
+
console.error('Terminal unlock did not complete successfully.');
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
console.error(`Open ${dashboardUrl()} and unlock, then retry your command.`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process management for CLI commands
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { spawn, ChildProcess, execSync } from 'child_process';
|
|
6
|
+
import { randomBytes } from 'crypto';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
import * as fs from 'fs';
|
|
9
|
+
import { resolveAuraSocketPath } from '../../lib/socket-path';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Find the project root by walking up from __dirname to find the package.json.
|
|
13
|
+
*/
|
|
14
|
+
export function findProjectRoot(): string {
|
|
15
|
+
let dir = __dirname;
|
|
16
|
+
for (let i = 0; i < 10; i++) {
|
|
17
|
+
const pkgPath = path.join(dir, 'package.json');
|
|
18
|
+
if (fs.existsSync(pkgPath)) {
|
|
19
|
+
try {
|
|
20
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
21
|
+
if (pkg.name === 'auramaxx') return dir;
|
|
22
|
+
} catch {
|
|
23
|
+
// Not valid JSON, keep going
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const parent = path.dirname(dir);
|
|
27
|
+
if (parent === dir) break;
|
|
28
|
+
dir = parent;
|
|
29
|
+
}
|
|
30
|
+
throw new Error('Could not find auramaxx project root');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Stop any running AuraMaxx server processes
|
|
35
|
+
*/
|
|
36
|
+
export function stopServer(): void {
|
|
37
|
+
// In sandbox mode, don't kill other processes — the sandbox script manages its own
|
|
38
|
+
if (process.env.SANDBOX_MODE) return;
|
|
39
|
+
|
|
40
|
+
// Kill by command-line pattern (catches tsx shim + npx wrapper)
|
|
41
|
+
const patterns = [
|
|
42
|
+
'tsx server/index.ts',
|
|
43
|
+
'tsx watch server/index.ts',
|
|
44
|
+
'tsx server/cron/index.ts',
|
|
45
|
+
'next dev -p 4747',
|
|
46
|
+
'next start -p 4747',
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
for (const pattern of patterns) {
|
|
50
|
+
try {
|
|
51
|
+
execSync(`pkill -f "${pattern}" 2>/dev/null`, { stdio: 'ignore' });
|
|
52
|
+
} catch {
|
|
53
|
+
// Process not found, that's fine
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Also kill by port — catches node worker processes that tsx spawns
|
|
58
|
+
// (the worker command line doesn't contain "tsx server/index.ts")
|
|
59
|
+
const ports = [
|
|
60
|
+
process.env.WALLET_SERVER_PORT || '4242',
|
|
61
|
+
process.env.DASHBOARD_PORT || '4747',
|
|
62
|
+
];
|
|
63
|
+
for (const port of ports) {
|
|
64
|
+
try {
|
|
65
|
+
execSync(`lsof -ti TCP:${port} -s TCP:LISTEN | xargs kill 2>/dev/null`, { stdio: 'ignore' });
|
|
66
|
+
} catch {
|
|
67
|
+
// Nothing listening, that's fine
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Give processes a moment to die
|
|
72
|
+
try {
|
|
73
|
+
execSync('sleep 0.5', { stdio: 'ignore' });
|
|
74
|
+
} catch {
|
|
75
|
+
// Ignore
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Start the AuraMaxx server processes
|
|
81
|
+
* Returns child processes for cleanup
|
|
82
|
+
*/
|
|
83
|
+
export function startServer(opts: { headless?: boolean; debug?: boolean; background?: boolean } = {}): ChildProcess[] {
|
|
84
|
+
const root = findProjectRoot();
|
|
85
|
+
const children: ChildProcess[] = [];
|
|
86
|
+
|
|
87
|
+
// Set BYPASS_RATE_LIMIT for local dev
|
|
88
|
+
// Generate a shared secret so the cron server can authenticate with the wallet server's internal endpoints.
|
|
89
|
+
// Regenerated every start, so it's ephemeral like the SIGNING_KEY.
|
|
90
|
+
const cronSecret = randomBytes(32).toString('hex');
|
|
91
|
+
const env = { ...process.env, BYPASS_RATE_LIMIT: 'true', STRATEGY_CRON_SHARED_SECRET: cronSecret };
|
|
92
|
+
const useNodeTsxLoader = process.env.SANDBOX_MODE === 'true' || process.env.AURA_FORCE_NODE_TSX === '1';
|
|
93
|
+
const tsRunnerCmd = useNodeTsxLoader ? process.execPath : 'npx';
|
|
94
|
+
const tsRunnerArgs = (entryFile: string) =>
|
|
95
|
+
useNodeTsxLoader ? ['--import', 'tsx', entryFile] : ['tsx', entryFile];
|
|
96
|
+
const debug = opts.debug === true;
|
|
97
|
+
const stdioMode: 'ignore' | 'inherit' = debug ? 'inherit' : 'ignore';
|
|
98
|
+
// Only detach children in background mode. In foreground mode, children stay
|
|
99
|
+
// in the same process group so they die together with the parent on Cmd+C.
|
|
100
|
+
const detached = opts.background === true;
|
|
101
|
+
|
|
102
|
+
// Start Express server
|
|
103
|
+
const server = spawn(tsRunnerCmd, tsRunnerArgs('server/index.ts'), {
|
|
104
|
+
cwd: root,
|
|
105
|
+
env,
|
|
106
|
+
stdio: stdioMode,
|
|
107
|
+
detached,
|
|
108
|
+
});
|
|
109
|
+
if (detached) server.unref();
|
|
110
|
+
children.push(server);
|
|
111
|
+
|
|
112
|
+
// Start cron server
|
|
113
|
+
const cron = spawn(tsRunnerCmd, tsRunnerArgs('server/cron/index.ts'), {
|
|
114
|
+
cwd: root,
|
|
115
|
+
env,
|
|
116
|
+
stdio: stdioMode,
|
|
117
|
+
detached,
|
|
118
|
+
});
|
|
119
|
+
if (detached) cron.unref();
|
|
120
|
+
children.push(cron);
|
|
121
|
+
|
|
122
|
+
// Start Next.js dashboard unless headless
|
|
123
|
+
if (!opts.headless) {
|
|
124
|
+
const dashboardPort = process.env.DASHBOARD_PORT || '4747';
|
|
125
|
+
const dashboard = spawn('npx', ['next', 'dev', '-p', dashboardPort], {
|
|
126
|
+
cwd: root,
|
|
127
|
+
env,
|
|
128
|
+
stdio: stdioMode,
|
|
129
|
+
detached,
|
|
130
|
+
});
|
|
131
|
+
if (detached) dashboard.unref();
|
|
132
|
+
children.push(dashboard);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return children;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Clean up temp files (lock files, socket files)
|
|
140
|
+
*/
|
|
141
|
+
export function cleanupTempFiles(): void {
|
|
142
|
+
const uid = process.getuid?.() ?? 'unknown';
|
|
143
|
+
const socketPath = resolveAuraSocketPath({
|
|
144
|
+
uid,
|
|
145
|
+
serverPort: process.env.WALLET_SERVER_PORT,
|
|
146
|
+
serverUrl: process.env.WALLET_SERVER_URL,
|
|
147
|
+
});
|
|
148
|
+
const files = [
|
|
149
|
+
`/tmp/aura-cli-${uid}.lock`,
|
|
150
|
+
socketPath,
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
for (const file of files) {
|
|
154
|
+
try {
|
|
155
|
+
if (fs.existsSync(file)) {
|
|
156
|
+
fs.unlinkSync(file);
|
|
157
|
+
}
|
|
158
|
+
} catch {
|
|
159
|
+
// Ignore cleanup errors
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|