@ampersend_ai/ampersend-sdk 0.0.11 → 0.0.13

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 (77) hide show
  1. package/dist/ampersend/approval.d.ts +52 -0
  2. package/dist/ampersend/approval.d.ts.map +1 -0
  3. package/dist/ampersend/approval.js +106 -0
  4. package/dist/ampersend/approval.js.map +1 -0
  5. package/dist/ampersend/index.d.ts +1 -0
  6. package/dist/ampersend/index.d.ts.map +1 -1
  7. package/dist/ampersend/index.js +1 -0
  8. package/dist/ampersend/index.js.map +1 -1
  9. package/dist/ampersend/management.d.ts +2 -2
  10. package/dist/ampersend/treasurer.d.ts +2 -1
  11. package/dist/ampersend/treasurer.d.ts.map +1 -1
  12. package/dist/ampersend/treasurer.js +16 -4
  13. package/dist/ampersend/treasurer.js.map +1 -1
  14. package/dist/ampersend/types.d.ts +207 -4
  15. package/dist/ampersend/types.d.ts.map +1 -1
  16. package/dist/ampersend/types.js +107 -2
  17. package/dist/ampersend/types.js.map +1 -1
  18. package/dist/cli/ampersend.js +2 -0
  19. package/dist/cli/ampersend.js.map +1 -1
  20. package/dist/cli/commands/config.d.ts +1 -1
  21. package/dist/cli/commands/config.d.ts.map +1 -1
  22. package/dist/cli/commands/config.js +41 -35
  23. package/dist/cli/commands/config.js.map +1 -1
  24. package/dist/cli/commands/fetch.js +6 -6
  25. package/dist/cli/commands/fetch.js.map +1 -1
  26. package/dist/cli/commands/setup.d.ts +18 -0
  27. package/dist/cli/commands/setup.d.ts.map +1 -0
  28. package/dist/cli/commands/setup.js +151 -0
  29. package/dist/cli/commands/setup.js.map +1 -0
  30. package/dist/cli/config.d.ts +62 -38
  31. package/dist/cli/config.d.ts.map +1 -1
  32. package/dist/cli/config.js +148 -110
  33. package/dist/cli/config.js.map +1 -1
  34. package/dist/smart-account/constants.d.ts +5 -0
  35. package/dist/smart-account/constants.d.ts.map +1 -1
  36. package/dist/smart-account/constants.js +5 -0
  37. package/dist/smart-account/constants.js.map +1 -1
  38. package/dist/smart-account/eip712-types.d.ts +27 -0
  39. package/dist/smart-account/eip712-types.d.ts.map +1 -0
  40. package/dist/smart-account/eip712-types.js +16 -0
  41. package/dist/smart-account/eip712-types.js.map +1 -0
  42. package/dist/smart-account/index.d.ts +2 -1
  43. package/dist/smart-account/index.d.ts.map +1 -1
  44. package/dist/smart-account/index.js +2 -1
  45. package/dist/smart-account/index.js.map +1 -1
  46. package/dist/smart-account/signing.d.ts.map +1 -1
  47. package/dist/smart-account/signing.js +2 -8
  48. package/dist/smart-account/signing.js.map +1 -1
  49. package/dist/version.d.ts +1 -1
  50. package/dist/version.js +1 -1
  51. package/dist/x402/index.d.ts +1 -0
  52. package/dist/x402/index.d.ts.map +1 -1
  53. package/dist/x402/index.js.map +1 -1
  54. package/dist/x402/types.d.ts +36 -0
  55. package/dist/x402/types.d.ts.map +1 -0
  56. package/dist/x402/types.js +9 -0
  57. package/dist/x402/types.js.map +1 -0
  58. package/dist/x402/wallet.d.ts +3 -1
  59. package/dist/x402/wallet.d.ts.map +1 -1
  60. package/dist/x402/wallet.js.map +1 -1
  61. package/dist/x402/wallets/account/wallet.d.ts +5 -3
  62. package/dist/x402/wallets/account/wallet.d.ts.map +1 -1
  63. package/dist/x402/wallets/account/wallet.js +2 -1
  64. package/dist/x402/wallets/account/wallet.js.map +1 -1
  65. package/dist/x402/wallets/index.d.ts +1 -0
  66. package/dist/x402/wallets/index.d.ts.map +1 -1
  67. package/dist/x402/wallets/index.js +1 -0
  68. package/dist/x402/wallets/index.js.map +1 -1
  69. package/dist/x402/wallets/smart-account/cosigned.d.ts +46 -0
  70. package/dist/x402/wallets/smart-account/cosigned.d.ts.map +1 -0
  71. package/dist/x402/wallets/smart-account/cosigned.js +90 -0
  72. package/dist/x402/wallets/smart-account/cosigned.js.map +1 -0
  73. package/dist/x402/wallets/smart-account/wallet.d.ts +8 -1
  74. package/dist/x402/wallets/smart-account/wallet.d.ts.map +1 -1
  75. package/dist/x402/wallets/smart-account/wallet.js +14 -3
  76. package/dist/x402/wallets/smart-account/wallet.js.map +1 -1
  77. package/package.json +1 -1
@@ -1,32 +1,43 @@
1
1
  import { type ConfigStatus, type JsonEnvelope } from "./envelope.ts";
2
+ export declare const CONFIG_FILE: string;
2
3
  export type { ConfigStatus };
3
4
  /** Default API URL (production) */
4
5
  export declare const DEFAULT_API_URL = "https://api.ampersend.ai";
5
- /**
6
- * Generate a config name from agent key address and agent account.
7
- * Format: agentKeyAddress:::agentAccount (both lowercase)
8
- */
9
- export declare function generateConfigName(agentKeyAddress: string, agentAccount: string): string;
6
+ /** Pending approval stored in config */
7
+ export interface PendingApproval {
8
+ token: string;
9
+ agentKey: `0x${string}`;
10
+ expiresAt: string;
11
+ }
10
12
  /** Stored configuration V1 */
11
13
  export interface StoredConfigV1 {
12
14
  version: 1;
13
- agentKey: `0x${string}`;
15
+ agentKey?: `0x${string}`;
14
16
  agentAccount?: `0x${string}`;
15
17
  apiUrl?: string;
18
+ pendingApproval?: PendingApproval;
16
19
  }
17
20
  /** Current stored config type */
18
21
  export type StoredConfig = StoredConfigV1;
19
22
  /** Runtime configuration with derived fields */
20
- export interface RuntimeConfig extends Omit<StoredConfig, "version"> {
21
- agentKeyAddress: `0x${string}`;
23
+ export interface RuntimeConfig {
24
+ agentKey?: `0x${string}`;
25
+ agentAccount?: `0x${string}`;
26
+ apiUrl?: string;
27
+ pendingApproval?: PendingApproval;
22
28
  status: ConfigStatus;
23
29
  }
24
30
  /**
25
- * Read config file if it exists
31
+ * Read config file if it exists.
32
+ * Returns null if the file is missing or corrupt.
26
33
  */
27
34
  export declare function readConfig(): StoredConfig | null;
28
35
  /**
29
- * Get runtime config with status and derived fields
36
+ * Write config file with secure permissions
37
+ */
38
+ export declare function writeConfig(config: Omit<StoredConfig, "version">): void;
39
+ /**
40
+ * Get runtime config with status
30
41
  */
31
42
  export declare function getRuntimeConfig(): RuntimeConfig | null;
32
43
  /**
@@ -34,53 +45,66 @@ export declare function getRuntimeConfig(): RuntimeConfig | null;
34
45
  */
35
46
  export declare function getConfigStatus(): {
36
47
  status: ConfigStatus;
37
- agentKeyAddress?: `0x${string}`;
38
48
  };
39
49
  /**
40
- * Initialize configuration with a new agent key
50
+ * Check if a pending approval has expired locally.
41
51
  */
42
- export declare function initConfig(): JsonEnvelope<{
43
- agentKeyAddress: string;
44
- status: ConfigStatus;
45
- }>;
52
+ export declare function isPendingExpired(pending: PendingApproval): boolean;
46
53
  /**
47
- * Set agent account address to complete configuration
54
+ * Compute the expiration ISO string for a new approval (now + 30min).
48
55
  */
49
- export declare function setAgent(agentAccount: string): JsonEnvelope<{
50
- configName: string;
56
+ export declare function computeApprovalExpiry(): string;
57
+ /**
58
+ * Set active config directly using "agentKey:::agentAccount" format.
59
+ * Replaces the old `config init` + `config set-agent` flow.
60
+ */
61
+ export declare function setConfig(secret: string): JsonEnvelope<{
51
62
  agentKeyAddress: string;
52
63
  agentAccount: string;
53
64
  status: ConfigStatus;
54
65
  }>;
55
66
  /**
56
- * Set API URL (for non-production environments)
67
+ * Set API URL in config. Pass undefined to clear (revert to production default).
57
68
  */
58
- export declare function setApiUrl(apiUrl: string): JsonEnvelope<{
69
+ export declare function setApiUrl(apiUrl: string | undefined): JsonEnvelope<{
59
70
  apiUrl: string;
60
71
  }>;
61
72
  /**
62
- * Clear API URL (revert to production default)
73
+ * Store a pending approval in config.
74
+ * Called by `setup start`.
63
75
  */
64
- export declare function clearApiUrl(): JsonEnvelope<{
65
- apiUrl: string;
66
- }>;
67
- /** Configuration source */
68
- export type ConfigSource = "env" | "file" | "none";
69
- /** Status output options */
70
- export interface StatusOptions {
71
- verbose?: boolean;
72
- }
76
+ export declare function storePendingApproval(pending: PendingApproval): void;
73
77
  /**
74
- * Get current configuration status
75
- * Checks env vars first (takes precedence), then config file
76
- * @param options.verbose - Include raw addresses in output
78
+ * Clear pending approval from config.
77
79
  */
78
- export declare function getStatus(options?: StatusOptions): JsonEnvelope<{
80
+ export declare function clearPendingApproval(): void;
81
+ /**
82
+ * Promote a pending approval to active config.
83
+ * Called by `setup finish` when the approval is resolved.
84
+ */
85
+ export declare function promotePending(agentAccount: `0x${string}`): JsonEnvelope<{
86
+ agentKeyAddress: string;
87
+ agentAccount: string;
79
88
  status: ConfigStatus;
80
- source: ConfigSource;
81
- configName?: string;
89
+ }>;
90
+ /** Configuration source */
91
+ export type CredentialSource = "env" | "file" | "none";
92
+ /** Data returned by getStatus */
93
+ export interface StatusData {
94
+ status: ConfigStatus;
95
+ credentialSource: CredentialSource;
96
+ configPath?: string;
82
97
  agentKeyAddress?: string;
83
98
  agentAccount?: string;
84
99
  apiUrl?: string;
85
- }>;
100
+ pendingApproval?: {
101
+ agentKeyAddress: string;
102
+ expired: boolean;
103
+ };
104
+ }
105
+ /**
106
+ * Get current configuration status.
107
+ * Checks env vars first (takes precedence), then config file.
108
+ */
109
+ export declare function getStatus(): JsonEnvelope<StatusData>;
86
110
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAQA,OAAO,EAAW,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AAU7E,YAAY,EAAE,YAAY,EAAE,CAAA;AAE5B,mCAAmC;AACnC,eAAO,MAAM,eAAe,6BAA6B,CAAA;AAEzD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAExF;AAED,8BAA8B;AAC9B,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,CAAC,CAAA;IACV,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;IACvB,YAAY,CAAC,EAAE,KAAK,MAAM,EAAE,CAAA;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,iCAAiC;AACjC,MAAM,MAAM,YAAY,GAAG,cAAc,CAAA;AAEzC,gDAAgD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,CAAC,EAAE,MAAM,CAAA;IACnB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE;QAChB,eAAe,EAAE,MAAM,CAAA;QACvB,OAAO,EAAE,OAAO,CAAA;KACjB,CAAA;CACF;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,YAAY,CAAC,UAAU,CAAC,CAkEpD"}
@@ -1,24 +1,33 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
+ import { Schema } from "effect";
4
5
  import { isAddress } from "viem";
5
- import { generatePrivateKey, privateKeyToAddress } from "viem/accounts";
6
+ import { privateKeyToAddress } from "viem/accounts";
6
7
  import { parseEnvConfig } from "../ampersend/env.js";
7
8
  import { err, ok } from "./envelope.js";
8
9
  /** Config directory and file paths */
9
10
  const CONFIG_DIR = join(homedir(), ".ampersend");
10
- const CONFIG_FILE = join(CONFIG_DIR, "config.json");
11
+ export const CONFIG_FILE = join(CONFIG_DIR, "config.json");
11
12
  /** Current config version */
12
13
  const CONFIG_VERSION = 1;
14
+ /** Hard-coded approval expiration: 30 minutes */
15
+ const APPROVAL_EXPIRY_MS = 30 * 60 * 1000;
13
16
  /** Default API URL (production) */
14
17
  export const DEFAULT_API_URL = "https://api.ampersend.ai";
15
- /**
16
- * Generate a config name from agent key address and agent account.
17
- * Format: agentKeyAddress:::agentAccount (both lowercase)
18
- */
19
- export function generateConfigName(agentKeyAddress, agentAccount) {
20
- return `${agentKeyAddress.toLowerCase()}:::${agentAccount.toLowerCase()}`;
21
- }
18
+ const HexString = Schema.TemplateLiteral(Schema.Literal("0x"), Schema.String);
19
+ /** Schema for validating stored config read from disk */
20
+ const StoredConfigSchema = Schema.Struct({
21
+ version: Schema.Literal(1),
22
+ agentKey: Schema.optional(HexString),
23
+ agentAccount: Schema.optional(HexString),
24
+ apiUrl: Schema.optional(Schema.String),
25
+ pendingApproval: Schema.optional(Schema.Struct({
26
+ token: Schema.String,
27
+ agentKey: HexString,
28
+ expiresAt: Schema.String,
29
+ })),
30
+ });
22
31
  /**
23
32
  * Ensure config directory exists with secure permissions
24
33
  */
@@ -28,32 +37,33 @@ function ensureConfigDir() {
28
37
  }
29
38
  }
30
39
  /**
31
- * Read config file if it exists
40
+ * Read config file if it exists.
41
+ * Returns null if the file is missing or corrupt.
32
42
  */
33
43
  export function readConfig() {
34
44
  if (!existsSync(CONFIG_FILE)) {
35
45
  return null;
36
46
  }
37
47
  const content = readFileSync(CONFIG_FILE, "utf-8");
38
- const parsed = JSON.parse(content);
39
- // Ensure version field exists (for forward compatibility)
40
- return {
41
- version: 1,
42
- agentKey: parsed.agentKey,
43
- ...(parsed.agentAccount ? { agentAccount: parsed.agentAccount } : {}),
44
- ...(parsed.apiUrl ? { apiUrl: parsed.apiUrl } : {}),
45
- };
48
+ try {
49
+ const parsed = JSON.parse(content);
50
+ return Schema.decodeUnknownSync(StoredConfigSchema)(parsed);
51
+ }
52
+ catch {
53
+ // Corrupt or unrecognised config treat as absent so commands can re-initialise
54
+ return null;
55
+ }
46
56
  }
47
57
  /**
48
58
  * Write config file with secure permissions
49
59
  */
50
- function writeConfig(config) {
60
+ export function writeConfig(config) {
51
61
  ensureConfigDir();
52
62
  const withVersion = { version: CONFIG_VERSION, ...config };
53
63
  writeFileSync(CONFIG_FILE, JSON.stringify(withVersion, null, 2), { mode: 0o600 });
54
64
  }
55
65
  /**
56
- * Get runtime config with status and derived fields
66
+ * Get runtime config with status
57
67
  */
58
68
  export function getRuntimeConfig() {
59
69
  const stored = readConfig();
@@ -61,13 +71,8 @@ export function getRuntimeConfig() {
61
71
  return null;
62
72
  }
63
73
  const { version: _, ...rest } = stored;
64
- const agentKeyAddress = privateKeyToAddress(rest.agentKey);
65
- const status = rest.agentAccount ? "ready" : "pending_agent";
66
- return {
67
- ...rest,
68
- agentKeyAddress,
69
- status,
70
- };
74
+ const status = rest.agentKey && rest.agentAccount ? "ready" : "pending_agent";
75
+ return { ...rest, status };
71
76
  }
72
77
  /**
73
78
  * Get configuration status for error messages
@@ -77,118 +82,143 @@ export function getConfigStatus() {
77
82
  if (!config) {
78
83
  return { status: "not_initialized" };
79
84
  }
80
- return { status: config.status, agentKeyAddress: config.agentKeyAddress };
85
+ return { status: config.status };
81
86
  }
82
87
  /**
83
- * Initialize configuration with a new agent key
88
+ * Check if a pending approval has expired locally.
84
89
  */
85
- export function initConfig() {
86
- const existing = readConfig();
87
- if (existing) {
88
- const agentKeyAddress = privateKeyToAddress(existing.agentKey);
89
- if (existing.agentAccount) {
90
- return err("ALREADY_CONFIGURED", "Already configured. Use `ampersend config status` to view.", {
91
- status: "ready",
92
- agentKeyAddress,
93
- });
94
- }
95
- // Return existing pending config
96
- return ok({ agentKeyAddress, status: "pending_agent" });
97
- }
98
- // Generate new agent key
99
- const agentKey = generatePrivateKey();
100
- const agentKeyAddress = privateKeyToAddress(agentKey);
101
- writeConfig({ agentKey });
102
- return ok({ agentKeyAddress, status: "pending_agent" });
90
+ export function isPendingExpired(pending) {
91
+ return new Date(pending.expiresAt).getTime() <= Date.now();
103
92
  }
104
93
  /**
105
- * Set agent account address to complete configuration
94
+ * Compute the expiration ISO string for a new approval (now + 30min).
106
95
  */
107
- export function setAgent(agentAccount) {
108
- const existing = readConfig();
109
- if (!existing) {
110
- return err("NOT_INITIALIZED", "Not initialized. Run `ampersend config init` first.", { status: "not_initialized" });
96
+ export function computeApprovalExpiry() {
97
+ return new Date(Date.now() + APPROVAL_EXPIRY_MS).toISOString();
98
+ }
99
+ /**
100
+ * Set active config directly using "agentKey:::agentAccount" format.
101
+ * Replaces the old `config init` + `config set-agent` flow.
102
+ */
103
+ export function setConfig(secret) {
104
+ const parts = secret.split(":::");
105
+ if (parts.length !== 2) {
106
+ return err("INVALID_FORMAT", 'Expected format: "agentKey:::agentAccount"');
107
+ }
108
+ const [agentKey, agentAccount] = parts;
109
+ if (!agentKey.startsWith("0x") || agentKey.length !== 66) {
110
+ return err("INVALID_KEY", "Agent key must be a 0x-prefixed 32-byte hex string (66 chars)");
111
111
  }
112
- // Validate address format using viem's isAddress (handles checksum validation)
113
112
  if (!isAddress(agentAccount)) {
114
- return err("INVALID_ADDRESS", "Invalid Ethereum address format.");
113
+ return err("INVALID_ADDRESS", "Invalid Ethereum address format for agent account");
115
114
  }
116
- const agentKeyAddress = privateKeyToAddress(existing.agentKey);
115
+ const existing = readConfig();
117
116
  writeConfig({
118
- agentKey: existing.agentKey,
117
+ agentKey: agentKey,
119
118
  agentAccount: agentAccount,
120
- ...(existing.apiUrl ? { apiUrl: existing.apiUrl } : {}),
119
+ ...(existing?.apiUrl ? { apiUrl: existing.apiUrl } : {}),
120
+ // Preserve pending approval if any
121
+ ...(existing?.pendingApproval ? { pendingApproval: existing.pendingApproval } : {}),
121
122
  });
123
+ const agentKeyAddress = privateKeyToAddress(agentKey);
122
124
  return ok({
123
- configName: generateConfigName(agentKeyAddress, agentAccount),
124
125
  agentKeyAddress,
125
126
  agentAccount,
126
127
  status: "ready",
127
128
  });
128
129
  }
129
130
  /**
130
- * Set API URL (for non-production environments)
131
+ * Set API URL in config. Pass undefined to clear (revert to production default).
131
132
  */
132
133
  export function setApiUrl(apiUrl) {
133
- const existing = readConfig();
134
- if (!existing) {
135
- return err("NOT_INITIALIZED", "Not initialized. Run `ampersend config init` first.", { status: "not_initialized" });
136
- }
137
- // Validate URL format
138
- try {
139
- new URL(apiUrl);
140
- }
141
- catch {
142
- return err("INVALID_URL", "Invalid URL format.");
134
+ if (apiUrl != null) {
135
+ try {
136
+ new URL(apiUrl);
137
+ }
138
+ catch {
139
+ return err("INVALID_URL", "Invalid URL format.");
140
+ }
143
141
  }
142
+ const existing = readConfig();
143
+ writeConfig({
144
+ ...(existing?.agentKey ? { agentKey: existing.agentKey } : {}),
145
+ ...(existing?.agentAccount ? { agentAccount: existing.agentAccount } : {}),
146
+ ...(existing?.pendingApproval ? { pendingApproval: existing.pendingApproval } : {}),
147
+ ...(apiUrl != null ? { apiUrl } : {}),
148
+ });
149
+ return ok({ apiUrl: apiUrl ?? DEFAULT_API_URL });
150
+ }
151
+ /**
152
+ * Store a pending approval in config.
153
+ * Called by `setup start`.
154
+ */
155
+ export function storePendingApproval(pending) {
156
+ const existing = readConfig();
144
157
  writeConfig({
145
- agentKey: existing.agentKey,
146
- ...(existing.agentAccount ? { agentAccount: existing.agentAccount } : {}),
147
- apiUrl,
158
+ ...(existing?.agentKey ? { agentKey: existing.agentKey } : {}),
159
+ ...(existing?.agentAccount ? { agentAccount: existing.agentAccount } : {}),
160
+ ...(existing?.apiUrl ? { apiUrl: existing.apiUrl } : {}),
161
+ pendingApproval: pending,
148
162
  });
149
- return ok({ apiUrl });
150
163
  }
151
164
  /**
152
- * Clear API URL (revert to production default)
165
+ * Clear pending approval from config.
166
+ */
167
+ export function clearPendingApproval() {
168
+ const existing = readConfig();
169
+ if (!existing)
170
+ return;
171
+ const { pendingApproval: _, version: __, ...rest } = existing;
172
+ writeConfig(rest);
173
+ }
174
+ /**
175
+ * Promote a pending approval to active config.
176
+ * Called by `setup finish` when the approval is resolved.
153
177
  */
154
- export function clearApiUrl() {
178
+ export function promotePending(agentAccount) {
155
179
  const existing = readConfig();
156
- if (!existing) {
157
- return err("NOT_INITIALIZED", "Not initialized. Run `ampersend config init` first.", { status: "not_initialized" });
180
+ if (!existing?.pendingApproval) {
181
+ return err("NO_PENDING", "No pending approval to promote");
158
182
  }
183
+ const { agentKey: _oldKey, pendingApproval, version: _, ...rest } = existing;
184
+ const agentKeyAddress = privateKeyToAddress(pendingApproval.agentKey);
185
+ // Promote: pending key becomes active, pending cleared
159
186
  writeConfig({
160
- agentKey: existing.agentKey,
161
- ...(existing.agentAccount ? { agentAccount: existing.agentAccount } : {}),
187
+ ...rest,
188
+ agentKey: pendingApproval.agentKey,
189
+ agentAccount,
190
+ // pendingApproval intentionally omitted — cleared on promote
191
+ });
192
+ return ok({
193
+ agentKeyAddress,
194
+ agentAccount,
195
+ status: "ready",
162
196
  });
163
- return ok({ apiUrl: DEFAULT_API_URL });
164
197
  }
165
198
  /**
166
- * Get current configuration status
167
- * Checks env vars first (takes precedence), then config file
168
- * @param options.verbose - Include raw addresses in output
199
+ * Get current configuration status.
200
+ * Checks env vars first (takes precedence), then config file.
169
201
  */
170
- export function getStatus(options = {}) {
171
- const { verbose = false } = options;
202
+ export function getStatus() {
172
203
  // Check env vars first (takes precedence)
173
204
  try {
174
205
  const envConfig = parseEnvConfig();
175
206
  const apiUrl = envConfig.API_URL;
176
207
  const agentKeyAddress = privateKeyToAddress(envConfig.AGENT_KEY);
177
208
  const agentAccount = envConfig.AGENT_ACCOUNT;
178
- const baseResult = {
209
+ const result = {
179
210
  status: "ready",
180
- source: "env",
181
- configName: generateConfigName(agentKeyAddress, agentAccount),
211
+ credentialSource: "env",
212
+ agentKeyAddress,
213
+ agentAccount,
182
214
  };
183
- if (verbose) {
184
- return ok({
185
- ...baseResult,
186
- agentKeyAddress,
187
- agentAccount,
188
- ...(apiUrl && apiUrl !== DEFAULT_API_URL ? { apiUrl } : {}),
189
- });
215
+ if (existsSync(CONFIG_FILE)) {
216
+ result.configPath = CONFIG_FILE;
190
217
  }
191
- return ok(baseResult);
218
+ if (apiUrl && apiUrl !== DEFAULT_API_URL) {
219
+ result.apiUrl = apiUrl;
220
+ }
221
+ return ok(result);
192
222
  }
193
223
  catch {
194
224
  // No env vars, check file
@@ -196,25 +226,33 @@ export function getStatus(options = {}) {
196
226
  // Check config file
197
227
  const config = getRuntimeConfig();
198
228
  if (!config) {
199
- return ok({ status: "not_initialized", source: "none" });
229
+ return ok({ status: "not_initialized", credentialSource: "none" });
200
230
  }
201
231
  // Determine effective API URL (env var takes precedence over file)
202
232
  const envApiUrl = process.env.AMPERSEND_API_URL;
203
233
  const effectiveApiUrl = envApiUrl ?? config.apiUrl;
204
- const baseResult = {
234
+ const result = {
205
235
  status: config.status,
206
- source: "file",
207
- // Only include configName when ready (both addresses exist)
208
- ...(config.agentAccount ? { configName: generateConfigName(config.agentKeyAddress, config.agentAccount) } : {}),
236
+ credentialSource: "file",
237
+ configPath: CONFIG_FILE,
209
238
  };
210
- if (verbose) {
211
- return ok({
212
- ...baseResult,
213
- agentKeyAddress: config.agentKeyAddress,
214
- ...(config.agentAccount ? { agentAccount: config.agentAccount } : {}),
215
- ...(effectiveApiUrl && effectiveApiUrl !== DEFAULT_API_URL ? { apiUrl: effectiveApiUrl } : {}),
216
- });
217
- }
218
- return ok(baseResult);
239
+ if (config.agentKey) {
240
+ result.agentKeyAddress = privateKeyToAddress(config.agentKey);
241
+ }
242
+ if (config.agentAccount) {
243
+ result.agentAccount = config.agentAccount;
244
+ }
245
+ if (effectiveApiUrl && effectiveApiUrl !== DEFAULT_API_URL) {
246
+ result.apiUrl = effectiveApiUrl;
247
+ }
248
+ // Always show pending approval info if present
249
+ if (config.pendingApproval) {
250
+ const pendingKeyAddress = privateKeyToAddress(config.pendingApproval.agentKey);
251
+ result.pendingApproval = {
252
+ agentKeyAddress: pendingKeyAddress,
253
+ expired: isPendingExpired(config.pendingApproval),
254
+ };
255
+ }
256
+ return ok(result);
219
257
  }
220
258
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAChC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,E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,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC,CAAA;IACpE,CAAC;IAED,mEAAmE;IACnE,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAA;IAC/C,MAAM,eAAe,GAAG,SAAS,IAAI,MAAM,CAAC,MAAM,CAAA;IAElD,MAAM,MAAM,GAAe;QACzB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,gBAAgB,EAAE,MAAM;QACxB,UAAU,EAAE,WAAW;KACxB,CAAA;IAED,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,MAAM,CAAC,eAAe,GAAG,mBAAmB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC/D,CAAC;IAED,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACxB,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAA;IAC3C,CAAC;IAED,IAAI,eAAe,IAAI,eAAe,KAAK,eAAe,EAAE,CAAC;QAC3D,MAAM,CAAC,MAAM,GAAG,eAAe,CAAA;IACjC,CAAC;IAED,+CAA+C;IAC/C,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;QAC3B,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;QAC9E,MAAM,CAAC,eAAe,GAAG;YACvB,eAAe,EAAE,iBAAiB;YAClC,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,eAAe,CAAC;SAClD,CAAA;IACH,CAAC;IAED,OAAO,EAAE,CAAC,MAAM,CAAC,CAAA;AACnB,CAAC"}
@@ -7,4 +7,9 @@
7
7
  * @see https://github.com/rhinestonewtf/sdk/blob/main/src/modules/validators/core.ts
8
8
  */
9
9
  export declare const OWNABLE_VALIDATOR: "0x000000000013fdB5234E4E3162a810F54d9f7E98";
10
+ /**
11
+ * CoSignerValidator address - ERC-7579 validator requiring dual ECDSA signatures
12
+ * Deployed via CREATE2 (same address on all chains)
13
+ */
14
+ export declare const COSIGNER_VALIDATOR: "0x375992f0Eff108D87eAcD355B610bE2263B49bF8";
10
15
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/smart-account/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAG,4CAAqD,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/smart-account/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAG,4CAAqD,CAAA;AAEtF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAG,4CAAqD,CAAA"}
@@ -7,4 +7,9 @@
7
7
  * @see https://github.com/rhinestonewtf/sdk/blob/main/src/modules/validators/core.ts
8
8
  */
9
9
  export const OWNABLE_VALIDATOR = "0x000000000013fdB5234E4E3162a810F54d9f7E98";
10
+ /**
11
+ * CoSignerValidator address - ERC-7579 validator requiring dual ECDSA signatures
12
+ * Deployed via CREATE2 (same address on all chains)
13
+ */
14
+ export const COSIGNER_VALIDATOR = "0x375992f0Eff108D87eAcD355B610bE2263B49bF8";
10
15
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/smart-account/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,4CAAqD,CAAA"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/smart-account/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,4CAAqD,CAAA;AAEtF;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,4CAAqD,CAAA"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Shared EIP-712 type definitions for ERC-3009 TransferWithAuthorization
3
+ */
4
+ /**
5
+ * ERC-3009 TransferWithAuthorization message type
6
+ * Used by USDC and other ERC-3009 compliant tokens for gasless transfers
7
+ */
8
+ export declare const TRANSFER_WITH_AUTHORIZATION_TYPE: readonly [{
9
+ readonly name: "from";
10
+ readonly type: "address";
11
+ }, {
12
+ readonly name: "to";
13
+ readonly type: "address";
14
+ }, {
15
+ readonly name: "value";
16
+ readonly type: "uint256";
17
+ }, {
18
+ readonly name: "validAfter";
19
+ readonly type: "uint256";
20
+ }, {
21
+ readonly name: "validBefore";
22
+ readonly type: "uint256";
23
+ }, {
24
+ readonly name: "nonce";
25
+ readonly type: "bytes32";
26
+ }];
27
+ //# sourceMappingURL=eip712-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eip712-types.d.ts","sourceRoot":"","sources":["../../src/smart-account/eip712-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;EAOnC,CAAA"}