@smartagentkit/sdk 0.1.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.
@@ -0,0 +1,743 @@
1
+ import { Address, Hex, Chain } from 'viem';
2
+ import * as _rhinestone_module_sdk from '@rhinestone/module-sdk';
3
+ import { Session, EnableSessionData } from '@rhinestone/module-sdk';
4
+ export { ActionData, EnableSessionData, PolicyData, Session, SmartSessionMode } from '@rhinestone/module-sdk';
5
+
6
+ /** BIP-39 mnemonic phrase with optional HD derivation index */
7
+ interface MnemonicCredential {
8
+ mnemonic: string;
9
+ /** HD derivation index (default: 0) — derives m/44'/60'/0'/0/{index} */
10
+ addressIndex?: number;
11
+ }
12
+ /**
13
+ * A signer credential: either a raw private key (0x-prefixed hex)
14
+ * or a BIP-39 mnemonic phrase.
15
+ *
16
+ * @example
17
+ * // Private key
18
+ * const key: SignerKey = "0xac09...f2ff80";
19
+ *
20
+ * // Mnemonic (default account index 0)
21
+ * const key: SignerKey = { mnemonic: "test test test..." };
22
+ *
23
+ * // Mnemonic with specific derivation index
24
+ * const key: SignerKey = { mnemonic: "test test test...", addressIndex: 2 };
25
+ */
26
+ type SignerKey = Hex | MnemonicCredential;
27
+ interface SmartAgentKitConfig {
28
+ /** The chain to deploy on */
29
+ chain: Chain;
30
+ /** RPC URL for the chain */
31
+ rpcUrl: string;
32
+ /** Bundler URL (Pimlico, Alchemy, etc.) */
33
+ bundlerUrl: string;
34
+ /** Optional paymaster URL for gas sponsorship */
35
+ paymasterUrl?: string;
36
+ /** Deployed module contract addresses (required for wallet creation) */
37
+ moduleAddresses?: ModuleAddresses;
38
+ }
39
+ interface ModuleAddresses {
40
+ /** SpendingLimitHook contract address */
41
+ spendingLimitHook: Address;
42
+ /** AllowlistHook contract address */
43
+ allowlistHook: Address;
44
+ /** EmergencyPauseHook contract address */
45
+ emergencyPauseHook: Address;
46
+ /** AutomationExecutor contract address (optional, Sprint 3) */
47
+ automationExecutor?: Address;
48
+ }
49
+ interface AgentWallet {
50
+ /** The smart account address */
51
+ address: Address;
52
+ /** The owner address (human/multisig with override control) */
53
+ owner: Address;
54
+ /** Chain the wallet is deployed on */
55
+ chain: Chain;
56
+ /** Whether the wallet is deployed on-chain yet */
57
+ isDeployed: boolean;
58
+ /** Installed policy modules */
59
+ policies: InstalledPolicy[];
60
+ /** Active session keys */
61
+ sessions: ActiveSession[];
62
+ }
63
+ interface CreateWalletParams {
64
+ /** Owner address — retains override/recovery control */
65
+ owner: Address;
66
+ /** Private key of the owner for signing the deployment. Provide this OR ownerMnemonic. */
67
+ ownerPrivateKey?: Hex;
68
+ /** BIP-39 mnemonic phrase of the owner. Provide this OR ownerPrivateKey. */
69
+ ownerMnemonic?: string;
70
+ /** HD derivation index (default: 0). Only used with ownerMnemonic. */
71
+ addressIndex?: number;
72
+ /** Policy modules to install at deployment */
73
+ policies?: PolicyConfig[];
74
+ /** Or use a named preset */
75
+ preset?: PresetName;
76
+ /** Preset-specific initialization parameters */
77
+ presetParams?: Record<string, unknown>;
78
+ /** Optional CREATE2 salt for deterministic address */
79
+ salt?: bigint;
80
+ }
81
+ type PresetName = "defi-trader" | "treasury-agent" | "payment-agent" | "minimal";
82
+ type PolicyConfig = SpendingLimitPolicy | AllowlistPolicy | EmergencyPausePolicy | AutomationPolicy;
83
+ interface SpendingLimitPolicy {
84
+ type: "spending-limit";
85
+ limits: TokenLimit[];
86
+ }
87
+ interface TokenLimit {
88
+ /** Token address (use "0x0000...0000" for native ETH) */
89
+ token: Address;
90
+ /** Maximum amount per window (in token's smallest unit, e.g., wei) */
91
+ limit: bigint;
92
+ /** Window duration in seconds */
93
+ window: number;
94
+ }
95
+ interface AllowlistPolicy {
96
+ type: "allowlist";
97
+ mode: "allow" | "block";
98
+ targets: TargetPermission[];
99
+ /** Infrastructure addresses blocked from being called as targets (hooks, multiplexer, executor) */
100
+ protectedAddresses?: Address[];
101
+ }
102
+ interface TargetPermission {
103
+ /** Contract address to allow/block */
104
+ address: Address;
105
+ /** Function selector (e.g., "0xa9059cbb" for transfer). Omit for wildcard (all functions).
106
+ * NOTE: "0x00000000" is NOT a wildcard — it matches empty calldata (ETH transfers only).
107
+ * The actual wildcard selector is 0x431e2cf5 (bytes4(keccak256("WILDCARD"))). */
108
+ selector?: Hex;
109
+ }
110
+ interface EmergencyPausePolicy {
111
+ type: "emergency-pause";
112
+ /** Address authorized to pause/unpause (typically the owner) */
113
+ guardian: Address;
114
+ /** Auto-unpause after this many seconds (0 = manual only) */
115
+ autoUnpauseAfter?: number;
116
+ }
117
+ interface AutomationPolicy {
118
+ type: "automation";
119
+ tasks: AutomationTask[];
120
+ }
121
+ interface AutomationTask {
122
+ id: string;
123
+ /** Address of the automation service (e.g., Gelato relay) */
124
+ caller: Address;
125
+ /** Target contract to call */
126
+ target: Address;
127
+ /** ETH value to send */
128
+ value?: bigint;
129
+ /** Calldata for the target function */
130
+ calldata: Hex;
131
+ /** Minimum seconds between executions */
132
+ cooldown: number;
133
+ /** Maximum number of executions (0 = unlimited) */
134
+ maxExecutions?: number;
135
+ }
136
+ interface CreateSessionParams {
137
+ /** The session key address (generated or provided) */
138
+ sessionKey: Address;
139
+ /** Allowed actions for this session */
140
+ actions: SessionAction[];
141
+ /** Expiry timestamp (Unix seconds) */
142
+ expiresAt: number;
143
+ /** Optional: spending limits specific to this session */
144
+ spendingLimits?: TokenLimit[];
145
+ }
146
+ interface SessionAction {
147
+ /** Target contract address */
148
+ target: Address;
149
+ /** Allowed function selector */
150
+ selector: Hex;
151
+ /** Optional: parameter-level restrictions */
152
+ rules?: SessionRule[];
153
+ }
154
+ interface SessionRule {
155
+ /** Byte offset in calldata to check */
156
+ offset: bigint;
157
+ /** Comparison condition */
158
+ condition: "equal" | "greater" | "less" | "notEqual";
159
+ /** Reference value to compare against */
160
+ value: Hex;
161
+ }
162
+ interface ActiveSession {
163
+ sessionKey: Address;
164
+ actions: SessionAction[];
165
+ expiresAt: number;
166
+ isActive: boolean;
167
+ }
168
+ interface ExecuteParams {
169
+ /** Target contract address */
170
+ target: Address;
171
+ /** ETH value to send */
172
+ value?: bigint;
173
+ /** Calldata for the function call */
174
+ data?: Hex;
175
+ /** Session key private key to sign with (if using session-based execution) */
176
+ sessionKey?: Hex;
177
+ }
178
+ interface ExecuteBatchParams {
179
+ calls: ExecuteParams[];
180
+ sessionKey?: Hex;
181
+ }
182
+ interface InstalledPolicy {
183
+ moduleAddress: Address;
184
+ moduleType: number;
185
+ name: string;
186
+ config: PolicyConfig;
187
+ }
188
+ /**
189
+ * Shared interface for SmartAgentKit clients.
190
+ * Both the real SmartAgentKitClient and MockSmartAgentKitClient implement this.
191
+ */
192
+ interface ISmartAgentKitClient {
193
+ createWallet(params: CreateWalletParams): Promise<AgentWallet>;
194
+ connectWallet(walletAddress: Address, ownerKey: SignerKey): Promise<void>;
195
+ execute(wallet: AgentWallet, params: ExecuteParams): Promise<Hex>;
196
+ executeBatch(wallet: AgentWallet, params: ExecuteBatchParams): Promise<Hex>;
197
+ getRemainingAllowance(walletAddress: Address, token: Address): Promise<bigint>;
198
+ isPaused(walletAddress: Address): Promise<boolean>;
199
+ getBalances(walletAddress: Address): Promise<{
200
+ eth: bigint;
201
+ tokens: {
202
+ address: Address;
203
+ symbol: string;
204
+ balance: bigint;
205
+ }[];
206
+ }>;
207
+ pause(walletAddress: Address, guardianKey: SignerKey): Promise<Hex>;
208
+ unpause(walletAddress: Address, guardianKey: SignerKey): Promise<Hex>;
209
+ createSession(wallet: AgentWallet, params: CreateSessionParams, ownerKey: SignerKey): Promise<{
210
+ sessionKey: Address;
211
+ privateKey: Hex;
212
+ permissionId: Hex;
213
+ }>;
214
+ revokeSession(wallet: AgentWallet, permissionId: Hex, ownerKey: SignerKey): Promise<void>;
215
+ getActiveSessions(walletAddress: Address): ActiveSession[];
216
+ }
217
+
218
+ declare class SmartAgentKitClient implements ISmartAgentKitClient {
219
+ private config;
220
+ private publicClient;
221
+ private walletClients;
222
+ private sessions;
223
+ constructor(config: SmartAgentKitConfig);
224
+ /**
225
+ * Deploy a new policy-governed smart wallet for an AI agent.
226
+ *
227
+ * The wallet is a Safe smart account with ERC-7579 modules. A
228
+ * HookMultiPlexer is installed as the single hook, and sub-hooks
229
+ * (SpendingLimit, Allowlist, EmergencyPause) are routed through it.
230
+ *
231
+ * The deployment and policy initialization happen atomically in
232
+ * the first UserOperation.
233
+ */
234
+ createWallet(params: CreateWalletParams): Promise<AgentWallet>;
235
+ /**
236
+ * Reconnect to an existing wallet for executing transactions.
237
+ * Accepts a private key or mnemonic credential.
238
+ */
239
+ connectWallet(walletAddress: Address, ownerKey: SignerKey): Promise<void>;
240
+ predictAddress(_owner: Address, _salt?: bigint): Promise<Address>;
241
+ addPolicy(_wallet: AgentWallet, _policy: PolicyConfig, _ownerPrivateKey: Hex): Promise<void>;
242
+ removePolicy(_wallet: AgentWallet, _moduleAddress: Address, _ownerPrivateKey: Hex): Promise<void>;
243
+ getPolicies(_walletAddress: Address): Promise<InstalledPolicy[]>;
244
+ /**
245
+ * Create a session key for an AI agent.
246
+ *
247
+ * Generates a new ECDSA key pair and enables it as a session key on
248
+ * the smart account via Smart Sessions. The session is scoped to
249
+ * specific target contracts, function selectors, and time window.
250
+ *
251
+ * @returns The session key address, private key, and permission ID.
252
+ */
253
+ createSession(wallet: AgentWallet, params: CreateSessionParams, ownerKey: SignerKey): Promise<{
254
+ sessionKey: Address;
255
+ privateKey: Hex;
256
+ permissionId: Hex;
257
+ }>;
258
+ /**
259
+ * Revoke a session key, permanently disabling it.
260
+ */
261
+ revokeSession(wallet: AgentWallet, permissionId: Hex, _ownerKey: SignerKey): Promise<void>;
262
+ /**
263
+ * Get active sessions for a wallet.
264
+ */
265
+ getActiveSessions(walletAddress: Address): ActiveSession[];
266
+ /**
267
+ * Execute a single transaction from the agent wallet.
268
+ * The transaction is submitted as a UserOperation through the bundler.
269
+ * Hooks (spending limits, allowlist, pause) are enforced on-chain.
270
+ */
271
+ execute(wallet: AgentWallet, params: ExecuteParams): Promise<Hex>;
272
+ /**
273
+ * Execute a batch of transactions atomically from the agent wallet.
274
+ * All calls are encoded into a single UserOperation with batch mode.
275
+ */
276
+ executeBatch(wallet: AgentWallet, params: ExecuteBatchParams): Promise<Hex>;
277
+ /**
278
+ * Get the remaining spending allowance for a token on a wallet.
279
+ * Reads directly from the SpendingLimitHook contract.
280
+ */
281
+ getRemainingAllowance(walletAddress: Address, token: Address): Promise<bigint>;
282
+ /**
283
+ * Check if a wallet is currently paused.
284
+ * Reads directly from the EmergencyPauseHook contract.
285
+ */
286
+ isPaused(walletAddress: Address): Promise<boolean>;
287
+ /**
288
+ * Get the native ETH balance of a wallet.
289
+ */
290
+ getBalances(walletAddress: Address): Promise<{
291
+ eth: bigint;
292
+ tokens: {
293
+ address: Address;
294
+ symbol: string;
295
+ balance: bigint;
296
+ }[];
297
+ }>;
298
+ /**
299
+ * Pause a wallet. Must be called by the configured guardian.
300
+ * This is NOT a UserOp — it's a direct call to the EmergencyPauseHook.
301
+ */
302
+ pause(walletAddress: Address, guardianKey: SignerKey): Promise<Hex>;
303
+ /**
304
+ * Unpause a wallet. Must be called by the configured guardian.
305
+ */
306
+ unpause(walletAddress: Address, guardianKey: SignerKey): Promise<Hex>;
307
+ private resolvePolicies;
308
+ private requireModuleAddresses;
309
+ /**
310
+ * Build and send the first UserOp that initializes all sub-hooks
311
+ * and adds them to the HookMultiPlexer.
312
+ *
313
+ * This batch includes for each sub-hook:
314
+ * 1. onInstall(initData) — initialize the sub-hook for this account
315
+ * 2. setTrustedForwarder(hookMultiPlexer) — so sub-hooks resolve the
316
+ * correct account when called through the multiplexer
317
+ * 3. addHook(hookAddress, GLOBAL) on HookMultiPlexer — register the
318
+ * sub-hook for all transactions
319
+ */
320
+ private initializePolicies;
321
+ /**
322
+ * Push the 3 calls needed to initialize a sub-hook:
323
+ * 1. onInstall(initData) on the sub-hook
324
+ * 2. setTrustedForwarder(multiplexer) on the sub-hook
325
+ * 3. addHook(hookAddr, GLOBAL) on the HookMultiPlexer
326
+ */
327
+ private pushSubHookInitCalls;
328
+ private mapPoliciesToInstalled;
329
+ private getWalletClient;
330
+ }
331
+
332
+ /**
333
+ * Pre-built policy combinations for common agent types.
334
+ *
335
+ * Each preset returns an array of PolicyConfig objects that are
336
+ * installed on the wallet at deployment time.
337
+ */
338
+ declare const PRESETS: Record<PresetName, (owner: Address, params?: Record<string, unknown>) => PolicyConfig[]>;
339
+
340
+ interface EncodedPolicy {
341
+ moduleAddress: Address;
342
+ moduleType: number;
343
+ initData: Hex;
344
+ }
345
+ /**
346
+ * Encode a policy configuration into the format needed for module installation.
347
+ *
348
+ * The encoded data matches the Solidity `onInstall` decoder for each module:
349
+ *
350
+ * - **SpendingLimitHook:** `abi.encode(address trustedForwarder, TokenLimitInit[])` where each entry is
351
+ * `(address token, uint256 limit, uint48 windowDuration)`
352
+ *
353
+ * - **AllowlistHook:** `abi.encode(address trustedForwarder, uint8 mode, TargetPermission[], address[] protectedAddresses)`
354
+ * where each permission is `(address target, bytes4 selector)` and protectedAddresses are infrastructure contracts
355
+ *
356
+ * - **EmergencyPauseHook:** `abi.encode(address trustedForwarder, address guardian, uint48 autoUnpauseAfter)`
357
+ *
358
+ * @param policy - The policy configuration to encode.
359
+ * @param moduleAddresses - Optional map of module addresses per chain. If not
360
+ * provided, module addresses will be set to zero (for SDK-level
361
+ * configuration before deployment addresses are known).
362
+ * @param trustedForwarder - The HookMultiPlexer address to set as trusted forwarder.
363
+ * Defaults to zero address (for direct usage without multiplexer).
364
+ * @returns The encoded policy with module address, type, and init data.
365
+ */
366
+ declare function encodePolicyInitData(policy: PolicyConfig, moduleAddresses?: {
367
+ spendingLimitHook?: Address;
368
+ allowlistHook?: Address;
369
+ emergencyPauseHook?: Address;
370
+ automationExecutor?: Address;
371
+ }, trustedForwarder?: Address): EncodedPolicy;
372
+ /**
373
+ * Encode SpendingLimitHook init data.
374
+ *
375
+ * Solidity: `abi.decode(data, (address, TokenLimitInit[]))`
376
+ * where `TokenLimitInit` is `(address token, uint256 limit, uint48 windowDuration)`
377
+ */
378
+ declare function encodeSpendingLimitInitData(policy: SpendingLimitPolicy, trustedForwarder?: Address): Hex;
379
+ /**
380
+ * Encode AllowlistHook init data.
381
+ *
382
+ * Solidity: `abi.decode(data, (address, uint8, TargetPermission[], address[]))`
383
+ * where `TargetPermission` is `(address target, bytes4 selector)`
384
+ * and mode 0 = ALLOWLIST, 1 = BLOCKLIST
385
+ *
386
+ * The protectedAddresses array should include all infrastructure contract addresses
387
+ * (other hooks, HookMultiPlexer, AutomationExecutor) that must never be callable
388
+ * as execution targets, regardless of mode.
389
+ *
390
+ * NOTE: The wildcard selector is 0x431e2cf5 (keccak256("WILDCARD") truncated to 4 bytes).
391
+ * Do NOT use 0x00000000 as wildcard — that represents empty calldata (ETH transfers).
392
+ */
393
+ declare function encodeAllowlistInitData(policy: AllowlistPolicy, trustedForwarder?: Address): Hex;
394
+ /**
395
+ * Encode EmergencyPauseHook init data.
396
+ *
397
+ * Solidity: `abi.decode(data, (address, address, uint48))`
398
+ * trustedForwarder + guardian address + autoUnpauseAfter in seconds
399
+ */
400
+ declare function encodeEmergencyPauseInitData(policy: EmergencyPausePolicy, trustedForwarder?: Address): Hex;
401
+
402
+ /** ERC-7579 module type: Validator */
403
+ declare const MODULE_TYPE_VALIDATOR = 1;
404
+ /** ERC-7579 module type: Executor */
405
+ declare const MODULE_TYPE_EXECUTOR = 2;
406
+ /** ERC-7579 module type: Fallback */
407
+ declare const MODULE_TYPE_FALLBACK = 3;
408
+ /** ERC-7579 module type: Hook */
409
+ declare const MODULE_TYPE_HOOK = 4;
410
+ /** Native ETH represented as the zero address */
411
+ declare const NATIVE_TOKEN: Address;
412
+ /** ERC-4337 EntryPoint v0.7 (canonical address on all chains) */
413
+ declare const ENTRYPOINT_V07: Address;
414
+ /** Safe7579 module address (canonical) */
415
+ declare const SAFE_7579_MODULE: Address;
416
+ /** Safe7579 launchpad address (canonical) */
417
+ declare const SAFE_7579_LAUNCHPAD: Address;
418
+ /** Rhinestone module registry attester */
419
+ declare const RHINESTONE_ATTESTER: Address;
420
+ /** Time window constants (in seconds) */
421
+ declare const WINDOW_1_HOUR = 3600;
422
+ declare const WINDOW_1_DAY = 86400;
423
+ declare const WINDOW_1_WEEK = 604800;
424
+ declare const SPENDING_LIMIT_HOOK_ABI: readonly [{
425
+ readonly name: "setSpendingLimit";
426
+ readonly type: "function";
427
+ readonly inputs: readonly [{
428
+ readonly name: "token";
429
+ readonly type: "address";
430
+ }, {
431
+ readonly name: "limit";
432
+ readonly type: "uint256";
433
+ }, {
434
+ readonly name: "windowDuration";
435
+ readonly type: "uint48";
436
+ }];
437
+ readonly outputs: readonly [];
438
+ readonly stateMutability: "nonpayable";
439
+ }, {
440
+ readonly name: "removeSpendingLimit";
441
+ readonly type: "function";
442
+ readonly inputs: readonly [{
443
+ readonly name: "token";
444
+ readonly type: "address";
445
+ }];
446
+ readonly outputs: readonly [];
447
+ readonly stateMutability: "nonpayable";
448
+ }, {
449
+ readonly name: "getRemainingAllowance";
450
+ readonly type: "function";
451
+ readonly inputs: readonly [{
452
+ readonly name: "account";
453
+ readonly type: "address";
454
+ }, {
455
+ readonly name: "token";
456
+ readonly type: "address";
457
+ }];
458
+ readonly outputs: readonly [{
459
+ readonly name: "remaining";
460
+ readonly type: "uint256";
461
+ }];
462
+ readonly stateMutability: "view";
463
+ }, {
464
+ readonly name: "configs";
465
+ readonly type: "function";
466
+ readonly inputs: readonly [{
467
+ readonly name: "account";
468
+ readonly type: "address";
469
+ }, {
470
+ readonly name: "token";
471
+ readonly type: "address";
472
+ }];
473
+ readonly outputs: readonly [{
474
+ readonly name: "limit";
475
+ readonly type: "uint256";
476
+ }, {
477
+ readonly name: "spent";
478
+ readonly type: "uint256";
479
+ }, {
480
+ readonly name: "windowDuration";
481
+ readonly type: "uint48";
482
+ }, {
483
+ readonly name: "windowStart";
484
+ readonly type: "uint48";
485
+ }];
486
+ readonly stateMutability: "view";
487
+ }];
488
+ declare const ALLOWLIST_HOOK_ABI: readonly [{
489
+ readonly name: "addPermission";
490
+ readonly type: "function";
491
+ readonly inputs: readonly [{
492
+ readonly name: "target";
493
+ readonly type: "address";
494
+ }, {
495
+ readonly name: "selector";
496
+ readonly type: "bytes4";
497
+ }];
498
+ readonly outputs: readonly [];
499
+ readonly stateMutability: "nonpayable";
500
+ }, {
501
+ readonly name: "removePermission";
502
+ readonly type: "function";
503
+ readonly inputs: readonly [{
504
+ readonly name: "target";
505
+ readonly type: "address";
506
+ }, {
507
+ readonly name: "selector";
508
+ readonly type: "bytes4";
509
+ }];
510
+ readonly outputs: readonly [];
511
+ readonly stateMutability: "nonpayable";
512
+ }, {
513
+ readonly name: "setMode";
514
+ readonly type: "function";
515
+ readonly inputs: readonly [{
516
+ readonly name: "mode";
517
+ readonly type: "uint8";
518
+ }];
519
+ readonly outputs: readonly [];
520
+ readonly stateMutability: "nonpayable";
521
+ }, {
522
+ readonly name: "isTargetAllowed";
523
+ readonly type: "function";
524
+ readonly inputs: readonly [{
525
+ readonly name: "account";
526
+ readonly type: "address";
527
+ }, {
528
+ readonly name: "target";
529
+ readonly type: "address";
530
+ }, {
531
+ readonly name: "selector";
532
+ readonly type: "bytes4";
533
+ }];
534
+ readonly outputs: readonly [{
535
+ readonly name: "";
536
+ readonly type: "bool";
537
+ }];
538
+ readonly stateMutability: "view";
539
+ }];
540
+ declare const EMERGENCY_PAUSE_HOOK_ABI: readonly [{
541
+ readonly name: "pause";
542
+ readonly type: "function";
543
+ readonly inputs: readonly [{
544
+ readonly name: "account";
545
+ readonly type: "address";
546
+ }];
547
+ readonly outputs: readonly [];
548
+ readonly stateMutability: "nonpayable";
549
+ }, {
550
+ readonly name: "unpause";
551
+ readonly type: "function";
552
+ readonly inputs: readonly [{
553
+ readonly name: "account";
554
+ readonly type: "address";
555
+ }];
556
+ readonly outputs: readonly [];
557
+ readonly stateMutability: "nonpayable";
558
+ }, {
559
+ readonly name: "isPaused";
560
+ readonly type: "function";
561
+ readonly inputs: readonly [{
562
+ readonly name: "account";
563
+ readonly type: "address";
564
+ }];
565
+ readonly outputs: readonly [{
566
+ readonly name: "";
567
+ readonly type: "bool";
568
+ }];
569
+ readonly stateMutability: "view";
570
+ }, {
571
+ readonly name: "setGuardian";
572
+ readonly type: "function";
573
+ readonly inputs: readonly [{
574
+ readonly name: "newGuardian";
575
+ readonly type: "address";
576
+ }];
577
+ readonly outputs: readonly [];
578
+ readonly stateMutability: "nonpayable";
579
+ }, {
580
+ readonly name: "setAutoUnpauseTimeout";
581
+ readonly type: "function";
582
+ readonly inputs: readonly [{
583
+ readonly name: "timeout";
584
+ readonly type: "uint48";
585
+ }];
586
+ readonly outputs: readonly [];
587
+ readonly stateMutability: "nonpayable";
588
+ }];
589
+ /** HookMultiPlexer canonical address (same on all chains) */
590
+ declare const HOOK_MULTIPLEXER_ADDRESS: Address;
591
+ /** HookType enum matching HookMultiPlexer.sol */
592
+ declare const HOOK_TYPE_GLOBAL = 0;
593
+ /** HookMultiPlexer.addHook ABI (for GLOBAL/VALUE/DELEGATECALL hooks) */
594
+ declare const HOOK_MULTIPLEXER_ABI: readonly [{
595
+ readonly name: "addHook";
596
+ readonly type: "function";
597
+ readonly inputs: readonly [{
598
+ readonly name: "hook";
599
+ readonly type: "address";
600
+ }, {
601
+ readonly name: "hookType";
602
+ readonly type: "uint8";
603
+ }];
604
+ readonly outputs: readonly [];
605
+ readonly stateMutability: "nonpayable";
606
+ }, {
607
+ readonly name: "removeHook";
608
+ readonly type: "function";
609
+ readonly inputs: readonly [{
610
+ readonly name: "hook";
611
+ readonly type: "address";
612
+ }, {
613
+ readonly name: "hookType";
614
+ readonly type: "uint8";
615
+ }];
616
+ readonly outputs: readonly [];
617
+ readonly stateMutability: "nonpayable";
618
+ }];
619
+ /**
620
+ * Deployed module addresses per chain.
621
+ *
622
+ * @remarks This record is intentionally empty. After deploying contracts
623
+ * to a specific chain, populate this map or (preferably) supply addresses
624
+ * via `SmartAgentKitConfig.moduleAddresses` at runtime.
625
+ *
626
+ * @internal Exported for advanced usage; most users should configure
627
+ * addresses through SmartAgentKitConfig instead of relying on this map.
628
+ */
629
+ declare const MODULE_ADDRESSES: Record<string, {
630
+ hookMultiPlexer: Address;
631
+ spendingLimitHook: Address;
632
+ allowlistHook: Address;
633
+ emergencyPauseHook: Address;
634
+ automationExecutor: Address;
635
+ }>;
636
+
637
+ /**
638
+ * Built-in deployment addresses per chain.
639
+ *
640
+ * Populated automatically by `deploy.sh` after contract deployment.
641
+ * When addresses are available, the SDK can auto-resolve them by chain ID,
642
+ * removing the need to manually specify `moduleAddresses` in config.
643
+ */
644
+ declare const DEPLOYMENTS: Record<number, ModuleAddresses>;
645
+
646
+ /**
647
+ * Base error class for SmartAgentKit SDK errors.
648
+ */
649
+ declare class SmartAgentKitError extends Error {
650
+ constructor(message: string, options?: ErrorOptions);
651
+ }
652
+ /**
653
+ * Thrown when wallet creation fails.
654
+ */
655
+ declare class WalletCreationError extends SmartAgentKitError {
656
+ constructor(message: string, cause?: unknown);
657
+ }
658
+ /**
659
+ * Thrown when a policy configuration is invalid.
660
+ */
661
+ declare class PolicyConfigError extends SmartAgentKitError {
662
+ constructor(message: string, cause?: unknown);
663
+ }
664
+ /**
665
+ * Thrown when transaction execution fails.
666
+ */
667
+ declare class ExecutionError extends SmartAgentKitError {
668
+ constructor(message: string, cause?: unknown);
669
+ }
670
+ /**
671
+ * Thrown when a spending limit would be exceeded.
672
+ */
673
+ declare class SpendingLimitExceededError extends SmartAgentKitError {
674
+ readonly token: string;
675
+ readonly attempted: bigint;
676
+ readonly remaining: bigint;
677
+ constructor(token: string, attempted: bigint, remaining: bigint);
678
+ }
679
+ /**
680
+ * Thrown when the wallet is paused.
681
+ */
682
+ declare class WalletPausedError extends SmartAgentKitError {
683
+ readonly walletAddress: string;
684
+ constructor(walletAddress: string);
685
+ }
686
+ /**
687
+ * Thrown when a session key is invalid or expired.
688
+ */
689
+ declare class SessionError extends SmartAgentKitError {
690
+ constructor(message: string, cause?: unknown);
691
+ }
692
+
693
+ /** Smart Sessions module address (canonical on all chains) */
694
+ declare const SMART_SESSIONS_ADDRESS: Address;
695
+ /** OwnableValidator — used as session key validator for ECDSA keys */
696
+ declare const OWNABLE_VALIDATOR_ADDRESS: Address;
697
+ /**
698
+ * Build a Smart Sessions `Session` struct from our SDK params.
699
+ *
700
+ * The session is scoped to:
701
+ * - Specific target contracts + function selectors (from actions)
702
+ * - Time-bound via TimeFramePolicy (from expiresAt)
703
+ * - Optional spending limits via SpendingLimitsPolicy
704
+ *
705
+ * @param sessionKeyAddress - The session key's public address (ECDSA)
706
+ * @param params - SDK-level session params
707
+ * @param chainId - Target chain ID
708
+ * @param sessionValidatorAddress - Override for the session validator contract
709
+ */
710
+ declare function buildSession(sessionKeyAddress: Address, params: CreateSessionParams, chainId: bigint, sessionValidatorAddress?: Address): Session;
711
+ /**
712
+ * Get the Smart Sessions Module for installation on the account.
713
+ * This module enables session key support on the smart account.
714
+ *
715
+ * @param sessions - Optional initial sessions to enable at install time
716
+ */
717
+ declare function getSmartSessionsModule(sessions?: Session[]): _rhinestone_module_sdk.Module;
718
+ /**
719
+ * Compute the permission ID for a session.
720
+ * This is a deterministic hash of the session configuration.
721
+ */
722
+ declare function computePermissionId(session: Session): Hex;
723
+ /**
724
+ * Encode a session signature for a UserOp in USE mode.
725
+ * Used when the session is already enabled on the account.
726
+ */
727
+ declare function encodeUseSessionSignature(permissionId: Hex, signature: Hex): Hex;
728
+ /**
729
+ * Encode a session signature for a UserOp in ENABLE mode.
730
+ * Used when enabling and using a session in the same UserOp.
731
+ */
732
+ declare function encodeEnableSessionSignature(permissionId: Hex, signature: Hex, enableSessionData: EnableSessionData): Hex;
733
+ /**
734
+ * Get the execution action to remove (revoke) a session.
735
+ * Returns a call that can be batched into a UserOp.
736
+ */
737
+ declare function getRemoveAction(permissionId: Hex): {
738
+ to: Address;
739
+ value: bigint;
740
+ data: Hex;
741
+ };
742
+
743
+ export { ALLOWLIST_HOOK_ABI, type ActiveSession, type AgentWallet, type AllowlistPolicy, type AutomationPolicy, type CreateSessionParams, type CreateWalletParams, DEPLOYMENTS, EMERGENCY_PAUSE_HOOK_ABI, ENTRYPOINT_V07, type EmergencyPausePolicy, type EncodedPolicy, type ExecuteBatchParams, type ExecuteParams, ExecutionError, HOOK_MULTIPLEXER_ABI, HOOK_MULTIPLEXER_ADDRESS, HOOK_TYPE_GLOBAL, type ISmartAgentKitClient, type InstalledPolicy, MODULE_ADDRESSES, MODULE_TYPE_EXECUTOR, MODULE_TYPE_FALLBACK, MODULE_TYPE_HOOK, MODULE_TYPE_VALIDATOR, type MnemonicCredential, type ModuleAddresses, NATIVE_TOKEN, OWNABLE_VALIDATOR_ADDRESS, PRESETS, type PolicyConfig, PolicyConfigError, type PresetName, RHINESTONE_ATTESTER, SAFE_7579_LAUNCHPAD, SAFE_7579_MODULE, SMART_SESSIONS_ADDRESS, SPENDING_LIMIT_HOOK_ABI, type SessionAction, SessionError, type SessionRule, type SignerKey, SmartAgentKitClient, type SmartAgentKitConfig, SmartAgentKitError, SpendingLimitExceededError, type SpendingLimitPolicy, type TargetPermission, type TokenLimit, WINDOW_1_DAY, WINDOW_1_HOUR, WINDOW_1_WEEK, WalletCreationError, WalletPausedError, buildSession, computePermissionId, encodeAllowlistInitData, encodeEmergencyPauseInitData, encodeEnableSessionSignature, encodePolicyInitData, encodeSpendingLimitInitData, encodeUseSessionSignature, getRemoveAction as getRemoveSessionAction, getSmartSessionsModule };