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,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* auramaxx lock — Lock vaults from CLI
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
bootstrapViaAuthRequest,
|
|
7
|
+
bootstrapViaSocket,
|
|
8
|
+
generateEphemeralKeypair,
|
|
9
|
+
type ProfileIssuanceSelection,
|
|
10
|
+
} from '../../lib/credential-transport';
|
|
11
|
+
import { getErrorMessage } from '../../lib/error';
|
|
12
|
+
import { printHelp } from '../lib/theme';
|
|
13
|
+
import { serverUrl } from '../lib/http';
|
|
14
|
+
|
|
15
|
+
type JsonObject = Record<string, unknown>;
|
|
16
|
+
|
|
17
|
+
function showHelp(): void {
|
|
18
|
+
printHelp('LOCK', 'npx auramaxx lock [all|vault <vaultId>] [options]', [
|
|
19
|
+
{ name: 'all', desc: 'Lock all vaults and revoke active sessions (default)' },
|
|
20
|
+
{ name: 'vault <vaultId>', desc: 'Lock a specific vault id' },
|
|
21
|
+
], [
|
|
22
|
+
'Options:',
|
|
23
|
+
' --token <token> Bearer token (default: AURA_TOKEN or socket fallback)',
|
|
24
|
+
' --profile <id> /auth fallback profile when socket bootstrap is blocked',
|
|
25
|
+
' --profile-version <v> /auth fallback profile version',
|
|
26
|
+
' --profile-overrides <json> Tighten-only profile override JSON',
|
|
27
|
+
' --json JSON output',
|
|
28
|
+
'',
|
|
29
|
+
'Examples:',
|
|
30
|
+
' npx auramaxx lock',
|
|
31
|
+
' npx auramaxx lock all',
|
|
32
|
+
' npx auramaxx lock vault primary',
|
|
33
|
+
]);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getFlagValue(args: string[], flag: string): string | undefined {
|
|
37
|
+
const idx = args.indexOf(flag);
|
|
38
|
+
return idx >= 0 ? args[idx + 1] : undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function parseProfileSelection(args: string[]): ProfileIssuanceSelection {
|
|
42
|
+
const profile = getFlagValue(args, '--profile');
|
|
43
|
+
const profileVersion = getFlagValue(args, '--profile-version');
|
|
44
|
+
const profileOverridesRaw = getFlagValue(args, '--profile-overrides');
|
|
45
|
+
|
|
46
|
+
let profileOverrides: JsonObject | undefined;
|
|
47
|
+
if (profileOverridesRaw) {
|
|
48
|
+
const parsed = JSON.parse(profileOverridesRaw) as unknown;
|
|
49
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
50
|
+
throw new Error('--profile-overrides must be a JSON object');
|
|
51
|
+
}
|
|
52
|
+
profileOverrides = parsed as JsonObject;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
...(profile ? { profile } : {}),
|
|
57
|
+
...(profileVersion ? { profileVersion } : {}),
|
|
58
|
+
...(profileOverrides ? { profileOverrides } : {}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function resolveBearerToken(args: string[]): Promise<string> {
|
|
63
|
+
const explicit = getFlagValue(args, '--token') || process.env.AURA_TOKEN;
|
|
64
|
+
if (explicit) return explicit;
|
|
65
|
+
|
|
66
|
+
const selection = parseProfileSelection(args);
|
|
67
|
+
const keypair = generateEphemeralKeypair();
|
|
68
|
+
|
|
69
|
+
if (selection.profile) {
|
|
70
|
+
const result = await bootstrapViaAuthRequest(serverUrl(), 'cli-lock', keypair, {
|
|
71
|
+
...selection,
|
|
72
|
+
noWait: true,
|
|
73
|
+
onStatus: (message) => console.error(message),
|
|
74
|
+
});
|
|
75
|
+
if (result.approveUrl) {
|
|
76
|
+
console.error(`Approve at: ${result.approveUrl}`);
|
|
77
|
+
}
|
|
78
|
+
console.error(`After approval, re-run with: AURA_TOKEN=<token> npx auramaxx lock ...`);
|
|
79
|
+
console.error(`Or use: npx auramaxx auth request --profile ${selection.profile} --raw-token`);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
return await bootstrapViaSocket('cli-lock', keypair);
|
|
85
|
+
} catch (socketErr) {
|
|
86
|
+
return bootstrapViaAuthRequest(serverUrl(), 'cli-lock', keypair, {
|
|
87
|
+
...selection,
|
|
88
|
+
onStatus: (message) => console.error(message),
|
|
89
|
+
}).catch((authErr) => {
|
|
90
|
+
throw new Error(`${getErrorMessage(socketErr)}\n${getErrorMessage(authErr)}`);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function postJson(path: string, token: string): Promise<Record<string, unknown>> {
|
|
96
|
+
const res = await fetch(`${serverUrl()}${path}`, {
|
|
97
|
+
method: 'POST',
|
|
98
|
+
headers: {
|
|
99
|
+
'Authorization': `Bearer ${token}`,
|
|
100
|
+
'Content-Type': 'application/json',
|
|
101
|
+
},
|
|
102
|
+
signal: AbortSignal.timeout(10_000),
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const data = await res.json().catch(() => ({})) as Record<string, unknown>;
|
|
106
|
+
if (!res.ok) {
|
|
107
|
+
throw new Error(String(data.error || `HTTP ${res.status}`));
|
|
108
|
+
}
|
|
109
|
+
return data;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function main(): Promise<void> {
|
|
113
|
+
const args = process.argv.slice(2);
|
|
114
|
+
const subcommand = args[0] || 'all';
|
|
115
|
+
|
|
116
|
+
if (subcommand === '--help' || subcommand === '-h') {
|
|
117
|
+
showHelp();
|
|
118
|
+
process.exit(0);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
const json = args.includes('--json');
|
|
123
|
+
const token = await resolveBearerToken(args);
|
|
124
|
+
|
|
125
|
+
let data: Record<string, unknown>;
|
|
126
|
+
if (subcommand === 'all') {
|
|
127
|
+
data = await postJson('/lock', token);
|
|
128
|
+
} else if (subcommand === 'vault') {
|
|
129
|
+
const vaultId = args[1];
|
|
130
|
+
if (!vaultId) {
|
|
131
|
+
throw new Error('Usage: npx auramaxx lock vault <vaultId>');
|
|
132
|
+
}
|
|
133
|
+
data = await postJson(`/lock/${encodeURIComponent(vaultId)}`, token);
|
|
134
|
+
} else {
|
|
135
|
+
// Default shorthand: `lock <vaultId>` locks that vault; `lock` already handled above.
|
|
136
|
+
data = await postJson(`/lock/${encodeURIComponent(subcommand)}`, token);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (json) {
|
|
140
|
+
console.log(JSON.stringify(data, null, 2));
|
|
141
|
+
} else {
|
|
142
|
+
console.log(String((data as { message?: unknown }).message || 'Lock request completed.'));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
process.exit((data as { success?: unknown }).success === false ? 1 : 0);
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.error(`Lock command failed: ${getErrorMessage(error)}`);
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
153
|
+
main().catch((error) => {
|
|
154
|
+
console.error(`Lock command failed: ${getErrorMessage(error)}`);
|
|
155
|
+
process.exit(1);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* auramaxx mcp — Start the MCP server (stdio transport)
|
|
3
|
+
*
|
|
4
|
+
* Spawned by MCP clients (Codex CLI, Claude Code/Desktop, Cursor, VS Code, Windsurf, etc.) via config:
|
|
5
|
+
* { "command": "npx", "args": ["auramaxx", "mcp"], "env": { "AURA_TOKEN": "<token>" } }
|
|
6
|
+
*
|
|
7
|
+
* Flags:
|
|
8
|
+
* --install Auto-detect local client MCP config entries (does not start server)
|
|
9
|
+
* --run Start MCP server after processing install/setup flags
|
|
10
|
+
* --setup Install MCP config entries, then start MCP server
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import fs from 'fs';
|
|
14
|
+
import path from 'path';
|
|
15
|
+
import os from 'os';
|
|
16
|
+
import { spawnSync } from 'child_process';
|
|
17
|
+
import { getErrorMessage } from '../../lib/error';
|
|
18
|
+
|
|
19
|
+
const args = process.argv.slice(2);
|
|
20
|
+
|
|
21
|
+
const shouldInstall = args.includes('--install') || args.includes('--setup');
|
|
22
|
+
const shouldRun = args.includes('--run') || args.includes('--setup') || !shouldInstall;
|
|
23
|
+
|
|
24
|
+
if (shouldInstall) {
|
|
25
|
+
installMcpConfigs();
|
|
26
|
+
}
|
|
27
|
+
if (shouldRun) {
|
|
28
|
+
// The MCP server runs on import — connects stdio transport and registers tools
|
|
29
|
+
import('../../mcp/server.js');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface IdeTarget {
|
|
33
|
+
name: string;
|
|
34
|
+
configPath: string;
|
|
35
|
+
global: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type InstallStatus = 'configured' | 'already-configured' | 'not-found' | 'error';
|
|
39
|
+
|
|
40
|
+
interface InstallResult {
|
|
41
|
+
status: InstallStatus;
|
|
42
|
+
detail?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function installMcpConfigs(): void {
|
|
46
|
+
const home = os.homedir();
|
|
47
|
+
const walletBase = process.env.WALLET_SERVER_URL?.trim() || undefined;
|
|
48
|
+
|
|
49
|
+
const targets: IdeTarget[] = [
|
|
50
|
+
{
|
|
51
|
+
name: 'Claude Code',
|
|
52
|
+
configPath: path.join(process.cwd(), '.mcp.json'),
|
|
53
|
+
global: false,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'Claude Desktop',
|
|
57
|
+
configPath: path.join(home, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json'),
|
|
58
|
+
global: true,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'Cursor',
|
|
62
|
+
configPath: path.join(home, '.cursor', 'mcp.json'),
|
|
63
|
+
global: true,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'VS Code',
|
|
67
|
+
configPath: path.join(process.cwd(), '.vscode', 'mcp.json'),
|
|
68
|
+
global: false,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'Windsurf',
|
|
72
|
+
configPath: path.join(home, '.windsurf', 'mcp.json'),
|
|
73
|
+
global: true,
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
console.log('\n AuraMaxx MCP Installer');
|
|
78
|
+
console.log(' ───────────────────────\n');
|
|
79
|
+
|
|
80
|
+
let updated = 0;
|
|
81
|
+
let skipped = 0;
|
|
82
|
+
let notFound = 0;
|
|
83
|
+
let errors = 0;
|
|
84
|
+
|
|
85
|
+
for (const target of targets) {
|
|
86
|
+
const configDir = path.dirname(target.configPath);
|
|
87
|
+
|
|
88
|
+
// Only touch configs for IDEs that are actually present.
|
|
89
|
+
// Do not create new IDE directories implicitly.
|
|
90
|
+
if (!fs.existsSync(configDir)) {
|
|
91
|
+
console.log(` ${target.name}: not found (${configDir} not found)`);
|
|
92
|
+
notFound++;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Read existing config or start fresh. If the file is malformed, skip it
|
|
97
|
+
// instead of overwriting user data with {}.
|
|
98
|
+
let config: Record<string, unknown> = {};
|
|
99
|
+
if (fs.existsSync(target.configPath)) {
|
|
100
|
+
try {
|
|
101
|
+
const raw = fs.readFileSync(target.configPath, 'utf-8');
|
|
102
|
+
config = JSON.parse(raw);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
const message = getErrorMessage(error);
|
|
105
|
+
console.log(` ${target.name}: skipped (invalid JSON in ${target.configPath}: ${message})`);
|
|
106
|
+
errors++;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Check if canonical entry already exists
|
|
112
|
+
if (
|
|
113
|
+
config.mcpServers !== undefined &&
|
|
114
|
+
(typeof config.mcpServers !== 'object' || config.mcpServers === null || Array.isArray(config.mcpServers))
|
|
115
|
+
) {
|
|
116
|
+
console.log(` ${target.name}: skipped (mcpServers must be an object in ${target.configPath})`);
|
|
117
|
+
errors++;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const mcpServers = (config.mcpServers || {}) as Record<string, unknown>;
|
|
122
|
+
const existingEntry = isPlainObject(mcpServers.auramaxx) ? mcpServers.auramaxx as Record<string, unknown> : undefined;
|
|
123
|
+
const nextEntry = buildJsonMcpEntry(existingEntry, walletBase);
|
|
124
|
+
if (existingEntry && sameJson(existingEntry, nextEntry)) {
|
|
125
|
+
console.log(` ${target.name}: already configured`);
|
|
126
|
+
skipped++;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Merge canonical entry.
|
|
131
|
+
mcpServers.auramaxx = nextEntry;
|
|
132
|
+
config.mcpServers = mcpServers;
|
|
133
|
+
|
|
134
|
+
fs.writeFileSync(target.configPath, JSON.stringify(config, null, 2) + '\n');
|
|
135
|
+
console.log(` ${target.name}: configured (${target.configPath})`);
|
|
136
|
+
updated++;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const codexResult = installCodexMcp(home, walletBase);
|
|
140
|
+
if (codexResult.status === 'configured') {
|
|
141
|
+
const detail = codexResult.detail ? ` (${codexResult.detail})` : '';
|
|
142
|
+
console.log(` Codex CLI: configured (${path.join(home, '.codex', 'config.toml')})${detail}`);
|
|
143
|
+
updated++;
|
|
144
|
+
} else if (codexResult.status === 'already-configured') {
|
|
145
|
+
console.log(' Codex CLI: already configured');
|
|
146
|
+
skipped++;
|
|
147
|
+
} else if (codexResult.status === 'not-found') {
|
|
148
|
+
const detail = codexResult.detail ? ` (${codexResult.detail})` : '';
|
|
149
|
+
console.log(` Codex CLI: not found${detail}`);
|
|
150
|
+
notFound++;
|
|
151
|
+
} else {
|
|
152
|
+
const detail = codexResult.detail ? ` (${codexResult.detail})` : '';
|
|
153
|
+
console.log(` Codex CLI: skipped due to error${detail}`);
|
|
154
|
+
errors++;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
console.log('');
|
|
158
|
+
console.log(` Done: ${updated} updated, ${skipped} already configured, ${notFound} not found, ${errors} skipped due to errors`);
|
|
159
|
+
console.log('');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function buildJsonMcpEntry(existing: Record<string, unknown> | undefined, walletBase: string | undefined): Record<string, unknown> {
|
|
163
|
+
const next: Record<string, unknown> = isPlainObject(existing) ? { ...existing } : {};
|
|
164
|
+
next.command = 'npx';
|
|
165
|
+
next.args = ['auramaxx', 'mcp'];
|
|
166
|
+
|
|
167
|
+
const env = isPlainObject(existing?.env) ? { ...(existing?.env as Record<string, unknown>) } : {};
|
|
168
|
+
if (walletBase) {
|
|
169
|
+
env.WALLET_SERVER_URL = walletBase;
|
|
170
|
+
} else {
|
|
171
|
+
delete env.WALLET_SERVER_URL;
|
|
172
|
+
}
|
|
173
|
+
if (Object.keys(env).length > 0) {
|
|
174
|
+
next.env = env;
|
|
175
|
+
} else {
|
|
176
|
+
delete next.env;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return next;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function installCodexMcp(home: string, walletBase: string | undefined): InstallResult {
|
|
183
|
+
const probe = spawnSync('codex', ['mcp', 'list'], {
|
|
184
|
+
encoding: 'utf8',
|
|
185
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
186
|
+
});
|
|
187
|
+
if (probe.error) {
|
|
188
|
+
const code = (probe.error as NodeJS.ErrnoException).code;
|
|
189
|
+
if (code === 'ENOENT') {
|
|
190
|
+
return { status: 'not-found', detail: 'codex not in PATH' };
|
|
191
|
+
}
|
|
192
|
+
return { status: 'error', detail: getErrorMessage(probe.error) };
|
|
193
|
+
}
|
|
194
|
+
if ((probe.status ?? 1) !== 0) {
|
|
195
|
+
return { status: 'error', detail: sanitizeCommandOutput(probe.stderr || probe.stdout) };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
let needsUpdate = true;
|
|
199
|
+
const existing = spawnSync('codex', ['mcp', 'get', 'auramaxx', '--json'], {
|
|
200
|
+
encoding: 'utf8',
|
|
201
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
202
|
+
});
|
|
203
|
+
if (!existing.error && (existing.status ?? 1) === 0) {
|
|
204
|
+
try {
|
|
205
|
+
const parsed = JSON.parse(existing.stdout) as {
|
|
206
|
+
transport?: {
|
|
207
|
+
type?: string;
|
|
208
|
+
command?: string;
|
|
209
|
+
args?: unknown;
|
|
210
|
+
env?: Record<string, unknown> | null;
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
if (parsed.transport?.type === 'stdio' && parsed.transport?.command === 'npx') {
|
|
214
|
+
const args = Array.isArray(parsed.transport.args) ? parsed.transport.args : [];
|
|
215
|
+
const argsMatch = args.length === 2 && args[0] === 'auramaxx' && args[1] === 'mcp';
|
|
216
|
+
const env = parsed.transport.env || {};
|
|
217
|
+
const currentWalletBase = typeof env.WALLET_SERVER_URL === 'string' ? env.WALLET_SERVER_URL : undefined;
|
|
218
|
+
if (argsMatch && currentWalletBase === walletBase) {
|
|
219
|
+
needsUpdate = false;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
} catch {
|
|
223
|
+
// Ignore parse failure and reconfigure.
|
|
224
|
+
}
|
|
225
|
+
} else if (existing.error) {
|
|
226
|
+
return { status: 'error', detail: getErrorMessage(existing.error) };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (!needsUpdate) {
|
|
230
|
+
return { status: 'already-configured' };
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const remove = spawnSync('codex', ['mcp', 'remove', 'auramaxx'], {
|
|
234
|
+
encoding: 'utf8',
|
|
235
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
236
|
+
});
|
|
237
|
+
if (remove.error) {
|
|
238
|
+
return { status: 'error', detail: getErrorMessage(remove.error) };
|
|
239
|
+
}
|
|
240
|
+
if ((remove.status ?? 0) !== 0) {
|
|
241
|
+
const stderr = remove.stderr || '';
|
|
242
|
+
const notFound = stderr.includes("No MCP server named 'auramaxx' found");
|
|
243
|
+
if (!notFound) {
|
|
244
|
+
return { status: 'error', detail: sanitizeCommandOutput(remove.stderr || remove.stdout) };
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const addArgs = ['mcp', 'add', 'auramaxx'];
|
|
249
|
+
if (walletBase) {
|
|
250
|
+
addArgs.push('--env', `WALLET_SERVER_URL=${walletBase}`);
|
|
251
|
+
}
|
|
252
|
+
addArgs.push('--', 'npx', 'auramaxx', 'mcp');
|
|
253
|
+
|
|
254
|
+
const add = spawnSync('codex', addArgs, {
|
|
255
|
+
encoding: 'utf8',
|
|
256
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
257
|
+
});
|
|
258
|
+
if (add.error) {
|
|
259
|
+
return { status: 'error', detail: getErrorMessage(add.error) };
|
|
260
|
+
}
|
|
261
|
+
if ((add.status ?? 1) !== 0) {
|
|
262
|
+
return { status: 'error', detail: sanitizeCommandOutput(add.stderr || add.stdout) };
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const detail = walletBase ? `WALLET_SERVER_URL=${walletBase}` : undefined;
|
|
266
|
+
return { status: 'configured', detail };
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
270
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function sameJson(a: Record<string, unknown>, b: Record<string, unknown>): boolean {
|
|
274
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function sanitizeCommandOutput(text?: string): string | undefined {
|
|
278
|
+
if (!text) return undefined;
|
|
279
|
+
const cleaned = text
|
|
280
|
+
.split('\n')
|
|
281
|
+
.map((line) => line.trim())
|
|
282
|
+
.filter((line) => line.length > 0 && !line.startsWith('WARNING: proceeding, even though we could not update PATH'))
|
|
283
|
+
.join(' | ');
|
|
284
|
+
return cleaned || undefined;
|
|
285
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
export const QUICKHACK_NAMES = [
|
|
6
|
+
'LASER_PENGUIN', 'MOON_TACO', 'NINJA_AVOCADO', 'ROBOT_MOCHI', 'COSMIC_WAFFLE',
|
|
7
|
+
'PIXEL_TIGER', 'NEON_POTATO', 'GHOST_RAMEN', 'SOLAR_BURRITO', 'WIZARD_NOODLE',
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
export const QUICKHACK_VALUES = [
|
|
11
|
+
'sk-live-rainbow-otter', 'ghp_plasma-squirrel', 'tok_midnight-boba', 'sec_hyper-lemur', 'key_quantum-kiwi',
|
|
12
|
+
'api_orbit-panda', 'cred_ember-fox', 'vault_velvet-wolf', 'safe_zen-koala', 'core_nova-hawk',
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
export interface QuickhackPlan {
|
|
16
|
+
name: string;
|
|
17
|
+
value: string;
|
|
18
|
+
setArgs: string[];
|
|
19
|
+
injectArgs: string[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const pickFrom = (items: string[], rng: () => number = Math.random): string => {
|
|
23
|
+
const idx = Math.max(0, Math.min(items.length - 1, Math.floor(rng() * items.length)));
|
|
24
|
+
return items[idx];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const buildQuickhackPlan = (rng: () => number = Math.random): QuickhackPlan => {
|
|
28
|
+
const name = pickFrom(QUICKHACK_NAMES, rng);
|
|
29
|
+
const value = pickFrom(QUICKHACK_VALUES, rng);
|
|
30
|
+
return {
|
|
31
|
+
name,
|
|
32
|
+
value,
|
|
33
|
+
setArgs: ['set', name, value, '--type', 'apikey'],
|
|
34
|
+
injectArgs: ['inject', name, '--env', 'AURA_QUICKHACK'],
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../..');
|
|
39
|
+
const auraBin = path.join(root, 'bin', 'auramaxx.js');
|
|
40
|
+
|
|
41
|
+
const runAura = (args: string[]): string =>
|
|
42
|
+
execFileSync(process.execPath, [auraBin, ...args], {
|
|
43
|
+
cwd: root,
|
|
44
|
+
env: process.env,
|
|
45
|
+
encoding: 'utf8',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export async function main(argv: string[] = process.argv.slice(2)): Promise<void> {
|
|
49
|
+
if (argv.includes('--help') || argv.includes('-h')) {
|
|
50
|
+
console.log('Usage: npx auramaxx quickhack [--dry-run]');
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const dryRun = argv.includes('--dry-run');
|
|
55
|
+
const plan = buildQuickhackPlan();
|
|
56
|
+
|
|
57
|
+
const setCmd = `npx auramaxx ${plan.setArgs.join(' ')}`;
|
|
58
|
+
const injectCmd = `npx auramaxx ${plan.injectArgs.join(' ')}`;
|
|
59
|
+
|
|
60
|
+
console.log('Executed commands:');
|
|
61
|
+
console.log(`- ${setCmd}`);
|
|
62
|
+
console.log(`- ${injectCmd}`);
|
|
63
|
+
|
|
64
|
+
let injectOutput = '# dry-run: command execution skipped';
|
|
65
|
+
if (!dryRun) {
|
|
66
|
+
runAura(plan.setArgs);
|
|
67
|
+
injectOutput = runAura(plan.injectArgs).trim();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log('\nEnv output:');
|
|
71
|
+
console.log(injectOutput);
|
|
72
|
+
|
|
73
|
+
console.log('\n## Quickhack tutorial');
|
|
74
|
+
console.log('```bash');
|
|
75
|
+
console.log(setCmd);
|
|
76
|
+
console.log(injectCmd);
|
|
77
|
+
console.log('echo "$AURA_QUICKHACK"');
|
|
78
|
+
console.log('```');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
82
|
+
main().catch((error) => {
|
|
83
|
+
console.error(error?.message || String(error));
|
|
84
|
+
process.exit(1);
|
|
85
|
+
});
|
|
86
|
+
}
|