@aura-protocol/cli 0.1.2 → 0.3.0

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 (120) hide show
  1. package/README.md +84 -67
  2. package/bin/aura.js +0 -0
  3. package/dist/commands/confidential.d.ts +1 -1
  4. package/dist/commands/confidential.js +276 -597
  5. package/dist/commands/confidential.js.map +1 -1
  6. package/dist/commands/config.d.ts +1 -1
  7. package/dist/commands/config.js +26 -8
  8. package/dist/commands/config.js.map +1 -1
  9. package/dist/commands/dashboard.d.ts +1 -1
  10. package/dist/commands/dashboard.js +6 -7
  11. package/dist/commands/dashboard.js.map +1 -1
  12. package/dist/commands/dwallet.d.ts +1 -1
  13. package/dist/commands/dwallet.js +52 -41
  14. package/dist/commands/dwallet.js.map +1 -1
  15. package/dist/commands/execution.d.ts +1 -1
  16. package/dist/commands/execution.js +111 -175
  17. package/dist/commands/execution.js.map +1 -1
  18. package/dist/commands/features.d.ts +1 -1
  19. package/dist/commands/features.js +15 -10
  20. package/dist/commands/features.js.map +1 -1
  21. package/dist/commands/generated.d.ts +20 -0
  22. package/dist/commands/generated.js +61 -0
  23. package/dist/commands/generated.js.map +1 -0
  24. package/dist/commands/governance.d.ts +1 -1
  25. package/dist/commands/governance.js +113 -99
  26. package/dist/commands/governance.js.map +1 -1
  27. package/dist/commands/helpers.d.ts +5 -2
  28. package/dist/commands/helpers.js +79 -16
  29. package/dist/commands/helpers.js.map +1 -1
  30. package/dist/commands/instruction-exec.d.ts +27 -0
  31. package/dist/commands/instruction-exec.js +171 -0
  32. package/dist/commands/instruction-exec.js.map +1 -0
  33. package/dist/commands/instruction.d.ts +9 -0
  34. package/dist/commands/instruction.js +81 -0
  35. package/dist/commands/instruction.js.map +1 -0
  36. package/dist/commands/pda.d.ts +1 -1
  37. package/dist/commands/pda.js +15 -7
  38. package/dist/commands/pda.js.map +1 -1
  39. package/dist/commands/treasury.d.ts +1 -1
  40. package/dist/commands/treasury.js +201 -186
  41. package/dist/commands/treasury.js.map +1 -1
  42. package/dist/core/config.d.ts +35 -0
  43. package/dist/core/config.js +97 -0
  44. package/dist/core/config.js.map +1 -0
  45. package/dist/core/context.d.ts +51 -0
  46. package/dist/core/context.js +60 -0
  47. package/dist/core/context.js.map +1 -0
  48. package/dist/core/errors.d.ts +38 -0
  49. package/dist/core/errors.js +138 -0
  50. package/dist/core/errors.js.map +1 -0
  51. package/dist/core/network.d.ts +18 -0
  52. package/dist/core/network.js +38 -0
  53. package/dist/core/network.js.map +1 -0
  54. package/dist/core/runner.d.ts +45 -0
  55. package/dist/core/runner.js +219 -0
  56. package/dist/core/runner.js.map +1 -0
  57. package/dist/core/security.d.ts +28 -0
  58. package/dist/core/security.js +83 -0
  59. package/dist/core/security.js.map +1 -0
  60. package/dist/core/wallet.d.ts +2 -0
  61. package/dist/core/wallet.js +21 -0
  62. package/dist/core/wallet.js.map +1 -0
  63. package/dist/ika.d.ts +0 -9
  64. package/dist/ika.js +0 -48
  65. package/dist/ika.js.map +1 -1
  66. package/dist/index.js +56 -13
  67. package/dist/index.js.map +1 -1
  68. package/dist/lib/domain.d.ts +16 -0
  69. package/dist/lib/domain.js +88 -0
  70. package/dist/lib/domain.js.map +1 -0
  71. package/dist/lib/ika.d.ts +81 -0
  72. package/dist/lib/ika.js +192 -0
  73. package/dist/lib/ika.js.map +1 -0
  74. package/dist/lib/instructions.d.ts +79 -0
  75. package/dist/lib/instructions.js +421 -0
  76. package/dist/lib/instructions.js.map +1 -0
  77. package/dist/lib/protocol.d.ts +99 -0
  78. package/dist/lib/protocol.js +327 -0
  79. package/dist/lib/protocol.js.map +1 -0
  80. package/dist/lib/treasury-view.d.ts +11 -0
  81. package/dist/lib/treasury-view.js +126 -0
  82. package/dist/lib/treasury-view.js.map +1 -0
  83. package/dist/output.js +0 -3
  84. package/dist/output.js.map +1 -1
  85. package/dist/program-instructions.d.ts +1 -1
  86. package/dist/protocol.d.ts +0 -1
  87. package/dist/protocol.js +0 -7
  88. package/dist/protocol.js.map +1 -1
  89. package/dist/treasury-view.js +1 -1
  90. package/dist/treasury-view.js.map +1 -1
  91. package/dist/ui/dashboard.d.ts +7 -0
  92. package/dist/ui/dashboard.js +99 -0
  93. package/dist/ui/dashboard.js.map +1 -0
  94. package/dist/ui/format.d.ts +9 -0
  95. package/dist/ui/format.js +92 -0
  96. package/dist/ui/format.js.map +1 -0
  97. package/dist/ui/output.d.ts +58 -0
  98. package/dist/ui/output.js +208 -0
  99. package/dist/ui/output.js.map +1 -0
  100. package/dist/ui/theme.d.ts +52 -0
  101. package/dist/ui/theme.js +110 -0
  102. package/dist/ui/theme.js.map +1 -0
  103. package/dist/vendor/encrypt/generated/grpc/encrypt_service.d.ts +1 -1
  104. package/dist/vendor/encrypt/generated/grpc/encrypt_service.js +36 -13
  105. package/dist/vendor/encrypt/generated/grpc/encrypt_service.js.map +1 -1
  106. package/dist/vendor/encrypt/grpc.d.ts +2 -2
  107. package/dist/vendor/encrypt/grpc.js +1 -3
  108. package/dist/vendor/encrypt/grpc.js.map +1 -1
  109. package/dist/vendor/ika/bcs-types.js +107 -50
  110. package/dist/vendor/ika/bcs-types.js.map +1 -1
  111. package/dist/vendor/ika/generated/grpc/ika_dwallet.d.ts +1 -1
  112. package/dist/vendor/ika/generated/grpc/ika_dwallet.js +14 -4
  113. package/dist/vendor/ika/generated/grpc/ika_dwallet.js.map +1 -1
  114. package/dist/vendor/ika/grpc.d.ts +1 -1
  115. package/dist/vendor/ika/grpc.js +49 -24
  116. package/dist/vendor/ika/grpc.js.map +1 -1
  117. package/package.json +16 -13
  118. package/dist/ascii.d.ts +0 -1
  119. package/dist/ascii.js +0 -2
  120. package/dist/ascii.js.map +0 -1
@@ -0,0 +1,97 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import path from "node:path";
4
+ import { AURA_PROGRAM_ID, DEVNET_RPC_URL } from "@aura-protocol/sdk-ts";
5
+ export const DEFAULT_CONFIG = {
6
+ rpcUrl: DEVNET_RPC_URL,
7
+ walletPath: "~/.config/solana/id.json",
8
+ cluster: "devnet",
9
+ programId: AURA_PROGRAM_ID.toBase58(),
10
+ defaultAgentId: null,
11
+ };
12
+ export function expandHome(inputPath) {
13
+ if (inputPath === "~") {
14
+ return homedir();
15
+ }
16
+ if (inputPath.startsWith("~/")) {
17
+ return path.join(homedir(), inputPath.slice(2));
18
+ }
19
+ return inputPath;
20
+ }
21
+ export function compactHome(inputPath) {
22
+ const home = homedir();
23
+ if (inputPath === home) {
24
+ return "~";
25
+ }
26
+ if (inputPath.startsWith(`${home}${path.sep}`)) {
27
+ return `~/${inputPath.slice(home.length + 1)}`;
28
+ }
29
+ return inputPath;
30
+ }
31
+ export function getConfigDir() {
32
+ return path.join(homedir(), ".aura");
33
+ }
34
+ export function getConfigPath() {
35
+ return path.join(getConfigDir(), "config.json");
36
+ }
37
+ function isRecord(value) {
38
+ return typeof value === "object" && value !== null && !Array.isArray(value);
39
+ }
40
+ export function readConfigFile() {
41
+ const filePath = getConfigPath();
42
+ if (!existsSync(filePath)) {
43
+ return {};
44
+ }
45
+ const parsed = JSON.parse(readFileSync(filePath, "utf8"));
46
+ if (!isRecord(parsed)) {
47
+ throw new Error(`Config file ${filePath} must contain a JSON object`);
48
+ }
49
+ return {
50
+ rpcUrl: typeof parsed.rpcUrl === "string" ? parsed.rpcUrl : undefined,
51
+ walletPath: typeof parsed.walletPath === "string" ? parsed.walletPath : undefined,
52
+ cluster: typeof parsed.cluster === "string" ? parsed.cluster : undefined,
53
+ programId: typeof parsed.programId === "string" ? parsed.programId : undefined,
54
+ defaultAgentId: typeof parsed.defaultAgentId === "string" ||
55
+ parsed.defaultAgentId === null
56
+ ? parsed.defaultAgentId
57
+ : undefined,
58
+ };
59
+ }
60
+ export function writeConfigFile(config) {
61
+ const filePath = getConfigPath();
62
+ mkdirSync(path.dirname(filePath), { recursive: true });
63
+ writeFileSync(filePath, `${JSON.stringify(config, null, 2)}\n`, "utf8");
64
+ return filePath;
65
+ }
66
+ function pickField(flagValue, envValue, fileValue, defaultValue) {
67
+ if (flagValue !== undefined) {
68
+ return { value: flagValue, source: "flag" };
69
+ }
70
+ if (envValue !== undefined) {
71
+ return { value: envValue, source: "env" };
72
+ }
73
+ if (fileValue !== undefined) {
74
+ return { value: fileValue, source: "config" };
75
+ }
76
+ return { value: defaultValue, source: "default" };
77
+ }
78
+ export function resolveConfig(overrides = {}, env = process.env) {
79
+ const fileConfig = readConfigFile();
80
+ return {
81
+ rpcUrl: pickField(overrides.rpcUrl, env.AURA_RPC_URL ?? env.AURA_DEVNET_RPC_URL ?? env.SOLANA_RPC_URL, fileConfig.rpcUrl, DEFAULT_CONFIG.rpcUrl),
82
+ walletPath: pickField(overrides.walletPath, env.AURA_WALLET_PATH ?? env.PAYER_KEYPAIR, fileConfig.walletPath, DEFAULT_CONFIG.walletPath),
83
+ cluster: pickField(overrides.cluster, env.AURA_CLUSTER, fileConfig.cluster, DEFAULT_CONFIG.cluster),
84
+ programId: pickField(overrides.programId, env.AURA_PROGRAM_ID, fileConfig.programId, DEFAULT_CONFIG.programId),
85
+ defaultAgentId: pickField(overrides.defaultAgentId, env.AURA_DEFAULT_AGENT_ID, fileConfig.defaultAgentId, DEFAULT_CONFIG.defaultAgentId),
86
+ };
87
+ }
88
+ export function flattenResolvedConfig(resolved) {
89
+ return {
90
+ rpcUrl: resolved.rpcUrl.value,
91
+ walletPath: resolved.walletPath.value,
92
+ cluster: resolved.cluster.value,
93
+ programId: resolved.programId.value,
94
+ defaultAgentId: resolved.defaultAgentId.value,
95
+ };
96
+ }
97
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,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AC,gBAAgB,IAAI,GAAG,CAAC,aAAa,EACzC,UAAU,CAAC,UAAU,EACrB,cAAc,CAAC,UAAU,CAC1B;QACD,OAAO,EAAE,SAAS,CAChB,SAAS,CAAC,OAAO,EACjB,GAAG,CAAC,YAAY,EAChB,UAAU,CAAC,OAAO,EAClB,cAAc,CAAC,OAAO,CACvB;QACD,SAAS,EAAE,SAAS,CAClB,SAAS,CAAC,SAAS,EACnB,GAAG,CAAC,eAAe,EACnB,UAAU,CAAC,SAAS,EACpB,cAAc,CAAC,SAAS,CACzB;QACD,cAAc,EAAE,SAAS,CACvB,SAAS,CAAC,cAAc,EACxB,GAAG,CAAC,qBAAqB,EACzB,UAAU,CAAC,cAAc,EACzB,cAAc,CAAC,cAAc,CAC9B;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,QAA+B;IAE/B,OAAO;QACL,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK;QAC7B,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,KAAK;QACrC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK;QAC/B,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,KAAK;QACnC,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,KAAK;KAC9C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { AuraClient } from "@aura-protocol/sdk-ts";
2
+ import { Connection, PublicKey } from "@solana/web3.js";
3
+ import type { Command } from "commander";
4
+ import { type AuraCliConfig, type ResolvedAuraCliConfig } from "./config.js";
5
+ import { type NetworkInfo } from "./network.js";
6
+ import { loadKeypair } from "./wallet.js";
7
+ export interface GlobalOptions {
8
+ rpcUrl?: string;
9
+ wallet?: string;
10
+ programId?: string;
11
+ cluster?: string;
12
+ json?: boolean;
13
+ quiet?: boolean;
14
+ dryRun?: boolean;
15
+ /** Skip interactive confirmations (CI / non-interactive use). */
16
+ yes?: boolean;
17
+ /** Preflight-simulate writes before sending (default true; `--no-simulate`). */
18
+ simulate?: boolean;
19
+ /** Override the compute-unit limit for sent transactions. */
20
+ computeUnits?: number;
21
+ }
22
+ /** Per-invocation send/guard flags derived from global options. */
23
+ export interface CliFlags {
24
+ yes: boolean;
25
+ simulate: boolean;
26
+ computeUnits?: number;
27
+ }
28
+ export interface CliContext {
29
+ output: {
30
+ json: boolean;
31
+ quiet: boolean;
32
+ };
33
+ dryRun: boolean;
34
+ flags: CliFlags;
35
+ resolvedConfig: ResolvedAuraCliConfig;
36
+ config: AuraCliConfig;
37
+ connection: Connection;
38
+ programId: PublicKey;
39
+ network: NetworkInfo;
40
+ client: AuraClient;
41
+ wallet?: ReturnType<typeof loadKeypair>;
42
+ }
43
+ export declare function getGlobalOptions(command: Command): GlobalOptions;
44
+ export declare function resolveGlobalConfig(command: Command): {
45
+ globals: GlobalOptions;
46
+ resolvedConfig: ResolvedAuraCliConfig;
47
+ config: AuraCliConfig;
48
+ };
49
+ export declare function buildCliContext(command: Command, options?: {
50
+ needsWallet?: boolean;
51
+ }): CliContext;
@@ -0,0 +1,60 @@
1
+ import { AuraClient } from "@aura-protocol/sdk-ts";
2
+ import { Connection, PublicKey } from "@solana/web3.js";
3
+ import { flattenResolvedConfig, resolveConfig, } from "./config.js";
4
+ import { classifyNetwork } from "./network.js";
5
+ import { loadKeypair } from "./wallet.js";
6
+ export function getGlobalOptions(command) {
7
+ const raw = command.optsWithGlobals();
8
+ return {
9
+ rpcUrl: typeof raw.rpcUrl === "string" ? raw.rpcUrl : undefined,
10
+ wallet: typeof raw.wallet === "string" ? raw.wallet : undefined,
11
+ programId: typeof raw.programId === "string" ? raw.programId : undefined,
12
+ cluster: typeof raw.cluster === "string" ? raw.cluster : undefined,
13
+ json: raw.json === true,
14
+ quiet: raw.quiet === true,
15
+ dryRun: raw.dryRun === true,
16
+ yes: raw.yes === true,
17
+ // commander sets `simulate` to false only when `--no-simulate` is passed.
18
+ simulate: raw.simulate !== false,
19
+ computeUnits: typeof raw.computeUnits === "number" ? raw.computeUnits : undefined,
20
+ };
21
+ }
22
+ export function resolveGlobalConfig(command) {
23
+ const globals = getGlobalOptions(command);
24
+ const overrides = {
25
+ rpcUrl: globals.rpcUrl,
26
+ walletPath: globals.wallet,
27
+ programId: globals.programId,
28
+ cluster: globals.cluster,
29
+ };
30
+ const resolvedConfig = resolveConfig(overrides);
31
+ const config = flattenResolvedConfig(resolvedConfig);
32
+ return { globals, resolvedConfig, config };
33
+ }
34
+ export function buildCliContext(command, options = {}) {
35
+ const { globals, resolvedConfig, config } = resolveGlobalConfig(command);
36
+ const connection = new Connection(config.rpcUrl, "confirmed");
37
+ const programId = new PublicKey(config.programId);
38
+ const wallet = options.needsWallet === false ? undefined : loadKeypair(config.walletPath);
39
+ const client = new AuraClient({ connection, programId });
40
+ return {
41
+ output: {
42
+ json: globals.json === true,
43
+ quiet: globals.quiet === true,
44
+ },
45
+ dryRun: globals.dryRun === true,
46
+ flags: {
47
+ yes: globals.yes === true,
48
+ simulate: globals.simulate !== false,
49
+ computeUnits: globals.computeUnits,
50
+ },
51
+ resolvedConfig,
52
+ config,
53
+ connection,
54
+ programId,
55
+ network: classifyNetwork(config.rpcUrl),
56
+ client,
57
+ wallet,
58
+ };
59
+ }
60
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/core/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAGL,qBAAqB,EAErB,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAoB,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAyC1C,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,eAAe,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(the single most
5
+ * useful next action), and example commands. The root error boundary renders
6
+ * any thrown value through {@link renderError}, mapping common low-level failures
7
+ * (RPC rate limits, missing wallets, bad inputs, failed simulations) to guidance
8
+ * so users are never left staring at a raw stack trace.
9
+ */
10
+ export interface CliErrorOptions {
11
+ /** Stable machine-readable code, e.g. `WALLET_NOT_FOUND`. */
12
+ code?: string;
13
+ /** The single most useful next action for the user. */
14
+ tip?: string;
15
+ /** Example invocations that would succeed. */
16
+ examples?: string[];
17
+ /** Extra context (e.g. simulation logs) shown under the message. */
18
+ details?: string;
19
+ /** Underlying cause, preserved for debugging. */
20
+ cause?: unknown;
21
+ }
22
+ /** An error with a user-facing tip and optional examples. */
23
+ export declare class CliError extends Error {
24
+ readonly code?: string;
25
+ readonly tip?: string;
26
+ readonly examples?: string[];
27
+ readonly details?: string;
28
+ constructor(message: string, options?: CliErrorOptions);
29
+ /** Builds an error for an invalid flag/argument value, with a usage example. */
30
+ static invalidInput(field: string, expected: string, example?: string): CliError;
31
+ }
32
+ /** Extracts a clean message string from any thrown value. */
33
+ export declare function toMessage(error: unknown): string;
34
+ /**
35
+ * Renders an error to stderr with a leading `✗`, a tip line, and example
36
+ * commands when available. Returns nothing; intended for the root boundary.
37
+ */
38
+ export declare function renderError(error: unknown): void;
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Typed CLI errors and the tip-aware error renderer.
3
+ *
4
+ * `CliError` carries an optional machine `code`, a human `tip` (the single most
5
+ * useful next action), and example commands. The root error boundary renders
6
+ * any thrown value through {@link renderError}, mapping common low-level failures
7
+ * (RPC rate limits, missing wallets, bad inputs, failed simulations) to guidance
8
+ * so users are never left staring at a raw stack trace.
9
+ */
10
+ import { style, symbol } from "../ui/theme.js";
11
+ /** An error with a user-facing tip and optional examples. */
12
+ export class CliError extends Error {
13
+ code;
14
+ tip;
15
+ examples;
16
+ details;
17
+ constructor(message, options = {}) {
18
+ super(message, options.cause !== undefined ? { cause: options.cause } : undefined);
19
+ this.name = "CliError";
20
+ this.code = options.code;
21
+ this.tip = options.tip;
22
+ this.examples = options.examples;
23
+ this.details = options.details;
24
+ }
25
+ /** Builds an error for an invalid flag/argument value, with a usage example. */
26
+ static invalidInput(field, expected, example) {
27
+ return new CliError(`Invalid value for ${style.code(field)}: expected ${expected}.`, {
28
+ code: "INVALID_INPUT",
29
+ tip: `Pass a valid ${expected} for ${field}.`,
30
+ examples: example ? [example] : undefined,
31
+ });
32
+ }
33
+ }
34
+ /**
35
+ * Maps a raw error message to actionable guidance. This is best-effort pattern
36
+ * matching over common Solana/RPC/SDK failures.
37
+ */
38
+ function deriveGuidance(message) {
39
+ const lower = message.toLowerCase();
40
+ if (message.includes("429") ||
41
+ lower.includes("rate limit") ||
42
+ lower.includes("too many requests")) {
43
+ return {
44
+ tip: "The RPC endpoint is rate limiting you. Point at a dedicated endpoint.",
45
+ examples: [
46
+ "aura --rpc-url https://your-rpc.example treasury show --agent-id my-agent",
47
+ ],
48
+ };
49
+ }
50
+ if (lower.includes("could not load wallet") || lower.includes("keypair")) {
51
+ return {
52
+ tip: "Configure a wallet, or pass one explicitly.",
53
+ examples: [
54
+ "aura config init",
55
+ "aura --wallet ~/.config/solana/id.json treasury list",
56
+ ],
57
+ };
58
+ }
59
+ if (lower.includes("account does not exist") ||
60
+ lower.includes("not exist") ||
61
+ lower.includes("could not find")) {
62
+ return {
63
+ tip: "Verify the treasury PDA or agent ID — the account may not be created yet.",
64
+ examples: [
65
+ "aura treasury create --agent-id my-agent --daily-limit 1000 --per-tx-limit 250",
66
+ ],
67
+ };
68
+ }
69
+ if (lower.includes("invalid public key") ||
70
+ lower.includes("non-base58") ||
71
+ lower.includes("base58")) {
72
+ return {
73
+ tip: "A public key argument is not valid base58. Re-check the address you passed.",
74
+ };
75
+ }
76
+ if (lower.includes("insufficient") && lower.includes("lamports")) {
77
+ return {
78
+ tip: "The fee payer is out of SOL. Fund the wallet (devnet: `solana airdrop 2`).",
79
+ };
80
+ }
81
+ if (lower.includes("publickeyhex") ||
82
+ lower.includes("messagemetadatadigest")) {
83
+ return {
84
+ tip: "Re-register the live dWallet with --dwallet-account, --authorized-user, --message-metadata-digest, and --public-key-hex.",
85
+ };
86
+ }
87
+ if (lower.includes("scalar confidential guardrails are not configured")) {
88
+ return {
89
+ tip: "Configure scalar guardrails before proposing a confidential spend.",
90
+ examples: [
91
+ "aura confidential guardrails scalar --agent-id my-agent --daily-limit 5000 --per-tx-limit 1000",
92
+ ],
93
+ };
94
+ }
95
+ if (lower.includes("blockhash") && lower.includes("not found")) {
96
+ return {
97
+ tip: "Transaction expired before confirmation. Retry the command.",
98
+ };
99
+ }
100
+ return {};
101
+ }
102
+ /** Extracts a clean message string from any thrown value. */
103
+ export function toMessage(error) {
104
+ if (error instanceof Error) {
105
+ return error.message;
106
+ }
107
+ return String(error);
108
+ }
109
+ /**
110
+ * Renders an error to stderr with a leading `✗`, a tip line, and example
111
+ * commands when available. Returns nothing; intended for the root boundary.
112
+ */
113
+ export function renderError(error) {
114
+ const message = toMessage(error);
115
+ console.error(`${style.danger(symbol.error)} ${style.danger("Error")}: ${message}`);
116
+ const fromCli = error instanceof CliError ? error : undefined;
117
+ const guidance = deriveGuidance(message);
118
+ const details = fromCli?.details;
119
+ if (details) {
120
+ for (const line of details.split("\n")) {
121
+ console.error(` ${style.muted(line)}`);
122
+ }
123
+ }
124
+ const tip = fromCli?.tip ?? guidance.tip;
125
+ if (tip) {
126
+ console.error(`${style.warn(symbol.info)} ${style.bold("tip")}: ${tip}`);
127
+ }
128
+ const examples = fromCli?.examples ?? guidance.examples;
129
+ if (examples && examples.length > 0) {
130
+ for (const example of examples) {
131
+ console.error(` ${style.muted(symbol.pointer)} ${style.code(example)}`);
132
+ }
133
+ }
134
+ if (fromCli?.code) {
135
+ console.error(style.dim(` (${fromCli.code})`));
136
+ }
137
+ }
138
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":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AAI,QAAQ,CAAC,GAAG,CAAC;IACzC,IAAI,GAAG,EAAE,CAAC;QACR,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC;IACxD,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;IAED,IAAI,OAAO,EAAE,IAAI,EAAE,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * RPC endpoint classification.
3
+ *
4
+ * Used to drive guard rails: a write against a production (mainnet) endpoint
5
+ * gets an explicit confirmation, and the resolved network is surfaced in every
6
+ * transaction preview so users always know where a transaction is going.
7
+ */
8
+ export type ClusterKind = "mainnet" | "devnet" | "testnet" | "localnet" | "custom";
9
+ export interface NetworkInfo {
10
+ kind: ClusterKind;
11
+ /** Human label, e.g. "mainnet-beta" or "devnet". */
12
+ label: string;
13
+ rpcUrl: string;
14
+ /** True for mainnet — the only network treated as production/high-risk. */
15
+ isProduction: boolean;
16
+ }
17
+ /** Classifies an RPC URL into a known Solana cluster. */
18
+ export declare function classifyNetwork(rpcUrl: string): NetworkInfo;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * RPC endpoint classification.
3
+ *
4
+ * Used to drive guard rails: a write against a production (mainnet) endpoint
5
+ * gets an explicit confirmation, and the resolved network is surfaced in every
6
+ * transaction preview so users always know where a transaction is going.
7
+ */
8
+ /** Classifies an RPC URL into a known Solana cluster. */
9
+ export function classifyNetwork(rpcUrl) {
10
+ const lower = rpcUrl.toLowerCase();
11
+ let kind = "custom";
12
+ let label = "custom";
13
+ if (lower.includes("mainnet")) {
14
+ kind = "mainnet";
15
+ label = "mainnet-beta";
16
+ }
17
+ else if (lower.includes("devnet")) {
18
+ kind = "devnet";
19
+ label = "devnet";
20
+ }
21
+ else if (lower.includes("testnet")) {
22
+ kind = "testnet";
23
+ label = "testnet";
24
+ }
25
+ else if (lower.includes("localhost") ||
26
+ lower.includes("127.0.0.1") ||
27
+ lower.includes("0.0.0.0")) {
28
+ kind = "localnet";
29
+ label = "localnet";
30
+ }
31
+ return {
32
+ kind,
33
+ label,
34
+ rpcUrl,
35
+ isProduction: kind === "mainnet",
36
+ };
37
+ }
38
+ //# sourceMappingURL=network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/core/network.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkBH,yDAAyD;AACzD,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACnC,IAAI,IAAI,GAAgB,QAAQ,CAAC;IACjC,IAAI,KAAK,GAAG,QAAQ,CAAC;IAErB,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,IAAI,GAAG,SAAS,CAAC;QACjB,KAAK,GAAG,cAAc,CAAC;IACzB,CAAC;SAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpC,IAAI,GAAG,QAAQ,CAAC;QAChB,KAAK,GAAG,QAAQ,CAAC;IACnB,CAAC;SAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACrC,IAAI,GAAG,SAAS,CAAC;QACjB,KAAK,GAAG,SAAS,CAAC;IACpB,CAAC;SAAM,IACL,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC3B,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC3B,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EACzB,CAAC;QACD,IAAI,GAAG,UAAU,CAAC;QAClB,KAAK,GAAG,UAAU,CAAC;IACrB,CAAC;IAED,OAAO;QACL,IAAI;QACJ,KAAK;QACL,MAAM;QACN,YAAY,EAAE,IAAI,KAAK,SAAS;KACjC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The secure transaction pipeline shared by every command that writes
3
+ * on-chain. Given built instructions and some metadata it will, in order:
4
+ *
5
+ * 1. assemble the transaction (compute-budget + optional heap frame),
6
+ * 2. render a human preview of exactly what will be signed,
7
+ * 3. guard production (mainnet) writes behind an explicit confirmation,
8
+ * 4. confirm sensitive instructions (authority/governance/closures),
9
+ * 5. preflight-simulate and surface compute units + program logs,
10
+ * 6. sign, send, and confirm, printing the signature + explorer link.
11
+ *
12
+ * `--dry-run` stops after the preview and emits the serialized instructions.
13
+ * `--json` suppresses decorative output and returns structured data.
14
+ * `--yes` skips confirmations (for CI). `--no-simulate` skips preflight.
15
+ */
16
+ import { type Signer, type TransactionInstruction } from "@solana/web3.js";
17
+ import type { CliContext } from "./context.js";
18
+ export interface RunMeta {
19
+ /** Short action label, e.g. "Create treasury". */
20
+ action: string;
21
+ /** snake_case instruction name, used to classify risk. */
22
+ instructionName?: string;
23
+ /** Key/value rows summarizing the action, shown in the preview. */
24
+ summary?: [string, string][];
25
+ /** Additional signers beyond the fee-payer wallet. */
26
+ extraSigners?: Signer[];
27
+ /** Override the compute-unit limit. */
28
+ computeUnits?: number;
29
+ /** Request a heap-frame bump (confidential / large instructions). */
30
+ heapFrameBytes?: number;
31
+ /** Force a confirmation prompt regardless of risk classification. */
32
+ confirm?: boolean;
33
+ /** Extra fields merged into the JSON output on success. */
34
+ result?: Record<string, unknown>;
35
+ }
36
+ export interface RunOutcome {
37
+ dryRun: boolean;
38
+ aborted: boolean;
39
+ signature?: string;
40
+ }
41
+ /**
42
+ * Builds, previews, guards, simulates, signs, and sends `instructions`.
43
+ * Honors `--dry-run`, `--json`, `--yes`, `--no-simulate`, and `--compute-units`.
44
+ */
45
+ export declare function runInstructions(ctx: CliContext, instructions: TransactionInstruction[], meta: RunMeta): Promise<RunOutcome>;