kawasekit 0.1.0-beta.5 → 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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../node_modules/.pnpm/dotenv@17.4.2/node_modules/dotenv/lib/main.js","../../src/account/session-key.ts","../../src/chains/avalanche.ts","../../src/chains/ethereum.ts","../../src/chains/kaia.ts","../../src/chains/polygon.ts","../../src/chains/types.ts","../../src/chains/index.ts","../../src/tokens/jpyc.ts","../../src/client/transfer-jpyc.ts","../../src/policy/daily-limit.ts","../../src/session/errors.ts","../../src/session/envelope.ts","../../src/session/issue.ts","../../src/session/restore.ts","../../src/session/revoke.ts","../../src/session/rotate.ts","../../cli/lib/env.ts","../../cli/lib/chain.ts","../../cli/commands/account.ts","../../cli/commands/init.ts","../../cli/commands/policy.ts","../../cli/commands/session-key.ts","../../cli/commands/transfer.ts","../../cli/index.ts"],"names":["path","getEntryPoint","KERNEL_V3_1","signerToEcdsaValidator","toECDSASigner","toPermissionValidator","createKernelAccount","viemAvalanche","viemAvalancheFuji","viemMainnet","viemSepolia","viemKaia","viemKairos","viemPolygon","viemPolygonAmoy","isAddress","encodeFunctionData","toCallPolicy","CallPolicyVersion","ParamCondition","toRateLimitPolicy","serializePermissionAccount","getAddress","deserializePermissionAccount","uninstallPlugin","loadDotenv","privateKeyToAccount","createPublicClient","http","createZeroDevPaymasterClient","createKernelAccountClient","program","resolve","existsSync","writeFileSync","parseUnits","randomBytes","readFileSync","Command"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,YAAA,GAAA,UAAA,CAAA;AAAA,EAAA,kEAAA,CAAA,OAAA,EAAA,MAAA,EAAA;AAAA,IAAA,IAAM,EAAA,GAAK,UAAQ,IAAI,CAAA;AACvB,IAAA,IAAM,IAAA,GAAO,UAAQ,MAAM,CAAA;AAC3B,IAAA,IAAM,EAAA,GAAK,U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AAwB;AAExF,IAAM,OAAA,GAAU,IAAIO,iBAAA,EAAQ;AAC5B,OAAA,CACE,IAAA,CAAK,WAAW,CAAA,CAChB,WAAA;AAAA,EACA;AACD,CAAA,CACC,QAAQ,WAAW,CAAA;AAErB,mBAAA,CAAoB,OAAO,CAAA;AAC3B,sBAAA,CAAuB,OAAO,CAAA;AAC9B,uBAAA,CAAwB,OAAO,CAAA;AAC/B,qBAAA,CAAsB,OAAO,CAAA;AAC7B,yBAAA,CAA0B,OAAO,CAAA;AAEjC,OAAA,CAAQ,UAAA,EAAW,CAAE,KAAA,CAAM,CAAC,KAAA,KAAmB;AAC9C,EAAA,OAAA,CAAQ,MAAM,KAAA,YAAiB,KAAA,GAAQ,MAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CAAC,CAAA;AACpE,EAAA,OAAA,CAAQ,QAAA,GAAW,CAAA;AACpB,CAAC,CAAA","file":"index.cjs","sourcesContent":["const fs = require('fs')\nconst path = require('path')\nconst os = require('os')\nconst crypto = require('crypto')\n\n// Array of tips to display randomly\nconst TIPS = [\n '◈ encrypted .env [www.dotenvx.com]',\n '◈ secrets for agents [www.dotenvx.com]',\n '⌁ auth for agents [www.vestauth.com]',\n '⌘ custom filepath { path: \\'/custom/path/.env\\' }',\n '⌘ enable debugging { debug: true }',\n '⌘ override existing { override: true }',\n '⌘ suppress logs { quiet: true }',\n '⌘ multiple files { path: [\\'.env.local\\', \\'.env\\'] }'\n]\n\n// Get a random tip from the tips array\nfunction _getRandomTip () {\n return TIPS[Math.floor(Math.random() * TIPS.length)]\n}\n\nfunction parseBoolean (value) {\n if (typeof value === 'string') {\n return !['false', '0', 'no', 'off', ''].includes(value.toLowerCase())\n }\n return Boolean(value)\n}\n\nfunction supportsAnsi () {\n return process.stdout.isTTY // && process.env.TERM !== 'dumb'\n}\n\nfunction dim (text) {\n return supportsAnsi() ? `\\x1b[2m${text}\\x1b[0m` : text\n}\n\nconst LINE = /(?:^|^)\\s*(?:export\\s+)?([\\w.-]+)(?:\\s*=\\s*?|:\\s+?)(\\s*'(?:\\\\'|[^'])*'|\\s*\"(?:\\\\\"|[^\"])*\"|\\s*`(?:\\\\`|[^`])*`|[^#\\r\\n]+)?\\s*(?:#.*)?(?:$|$)/mg\n\n// Parse src into an Object\nfunction parse (src) {\n const obj = {}\n\n // Convert buffer to string\n let lines = src.toString()\n\n // Convert line breaks to same format\n lines = lines.replace(/\\r\\n?/mg, '\\n')\n\n let match\n while ((match = LINE.exec(lines)) != null) {\n const key = match[1]\n\n // Default undefined or null to empty string\n let value = (match[2] || '')\n\n // Remove whitespace\n value = value.trim()\n\n // Check if double quoted\n const maybeQuote = value[0]\n\n // Remove surrounding quotes\n value = value.replace(/^(['\"`])([\\s\\S]*)\\1$/mg, '$2')\n\n // Expand newlines if double quoted\n if (maybeQuote === '\"') {\n value = value.replace(/\\\\n/g, '\\n')\n value = value.replace(/\\\\r/g, '\\r')\n }\n\n // Add to object\n obj[key] = value\n }\n\n return obj\n}\n\nfunction _parseVault (options) {\n options = options || {}\n\n const vaultPath = _vaultPath(options)\n options.path = vaultPath // parse .env.vault\n const result = DotenvModule.configDotenv(options)\n if (!result.parsed) {\n const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)\n err.code = 'MISSING_DATA'\n throw err\n }\n\n // handle scenario for comma separated keys - for use with key rotation\n // example: DOTENV_KEY=\"dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod\"\n const keys = _dotenvKey(options).split(',')\n const length = keys.length\n\n let decrypted\n for (let i = 0; i < length; i++) {\n try {\n // Get full key\n const key = keys[i].trim()\n\n // Get instructions for decrypt\n const attrs = _instructions(result, key)\n\n // Decrypt\n decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key)\n\n break\n } catch (error) {\n // last key\n if (i + 1 >= length) {\n throw error\n }\n // try next key\n }\n }\n\n // Parse decrypted .env string\n return DotenvModule.parse(decrypted)\n}\n\nfunction _warn (message) {\n console.error(`⚠ ${message}`)\n}\n\nfunction _debug (message) {\n console.log(`┆ ${message}`)\n}\n\nfunction _log (message) {\n console.log(`◇ ${message}`)\n}\n\nfunction _dotenvKey (options) {\n // prioritize developer directly setting options.DOTENV_KEY\n if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {\n return options.DOTENV_KEY\n }\n\n // secondary infra already contains a DOTENV_KEY environment variable\n if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {\n return process.env.DOTENV_KEY\n }\n\n // fallback to empty string\n return ''\n}\n\nfunction _instructions (result, dotenvKey) {\n // Parse DOTENV_KEY. Format is a URI\n let uri\n try {\n uri = new URL(dotenvKey)\n } catch (error) {\n if (error.code === 'ERR_INVALID_URL') {\n const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n throw error\n }\n\n // Get decrypt key\n const key = uri.password\n if (!key) {\n const err = new Error('INVALID_DOTENV_KEY: Missing key part')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n // Get environment\n const environment = uri.searchParams.get('environment')\n if (!environment) {\n const err = new Error('INVALID_DOTENV_KEY: Missing environment part')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n // Get ciphertext payload\n const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`\n const ciphertext = result.parsed[environmentKey] // DOTENV_VAULT_PRODUCTION\n if (!ciphertext) {\n const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)\n err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT'\n throw err\n }\n\n return { ciphertext, key }\n}\n\nfunction _vaultPath (options) {\n let possibleVaultPath = null\n\n if (options && options.path && options.path.length > 0) {\n if (Array.isArray(options.path)) {\n for (const filepath of options.path) {\n if (fs.existsSync(filepath)) {\n possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`\n }\n }\n } else {\n possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`\n }\n } else {\n possibleVaultPath = path.resolve(process.cwd(), '.env.vault')\n }\n\n if (fs.existsSync(possibleVaultPath)) {\n return possibleVaultPath\n }\n\n return null\n}\n\nfunction _resolveHome (envPath) {\n return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath\n}\n\nfunction _configVault (options) {\n const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || (options && options.debug))\n const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet))\n\n if (debug || !quiet) {\n _log('loading env from encrypted .env.vault')\n }\n\n const parsed = DotenvModule._parseVault(options)\n\n let processEnv = process.env\n if (options && options.processEnv != null) {\n processEnv = options.processEnv\n }\n\n DotenvModule.populate(processEnv, parsed, options)\n\n return { parsed }\n}\n\nfunction configDotenv (options) {\n const dotenvPath = path.resolve(process.cwd(), '.env')\n let encoding = 'utf8'\n let processEnv = process.env\n if (options && options.processEnv != null) {\n processEnv = options.processEnv\n }\n let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || (options && options.debug))\n let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || (options && options.quiet))\n\n if (options && options.encoding) {\n encoding = options.encoding\n } else {\n if (debug) {\n _debug('no encoding is specified (UTF-8 is used by default)')\n }\n }\n\n let optionPaths = [dotenvPath] // default, look for .env\n if (options && options.path) {\n if (!Array.isArray(options.path)) {\n optionPaths = [_resolveHome(options.path)]\n } else {\n optionPaths = [] // reset default\n for (const filepath of options.path) {\n optionPaths.push(_resolveHome(filepath))\n }\n }\n }\n\n // Build the parsed data in a temporary object (because we need to return it). Once we have the final\n // parsed data, we will combine it with process.env (or options.processEnv if provided).\n let lastError\n const parsedAll = {}\n for (const path of optionPaths) {\n try {\n // Specifying an encoding returns a string instead of a buffer\n const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }))\n\n DotenvModule.populate(parsedAll, parsed, options)\n } catch (e) {\n if (debug) {\n _debug(`failed to load ${path} ${e.message}`)\n }\n lastError = e\n }\n }\n\n const populated = DotenvModule.populate(processEnv, parsedAll, options)\n\n // handle user settings DOTENV_CONFIG_ options inside .env file(s)\n debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug)\n quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet)\n\n if (debug || !quiet) {\n const keysCount = Object.keys(populated).length\n const shortPaths = []\n for (const filePath of optionPaths) {\n try {\n const relative = path.relative(process.cwd(), filePath)\n shortPaths.push(relative)\n } catch (e) {\n if (debug) {\n _debug(`failed to load ${filePath} ${e.message}`)\n }\n lastError = e\n }\n }\n\n _log(`injected env (${keysCount}) from ${shortPaths.join(',')} ${dim(`// tip: ${_getRandomTip()}`)}`)\n }\n\n if (lastError) {\n return { parsed: parsedAll, error: lastError }\n } else {\n return { parsed: parsedAll }\n }\n}\n\n// Populates process.env from .env file\nfunction config (options) {\n // fallback to original dotenv if DOTENV_KEY is not set\n if (_dotenvKey(options).length === 0) {\n return DotenvModule.configDotenv(options)\n }\n\n const vaultPath = _vaultPath(options)\n\n // dotenvKey exists but .env.vault file does not exist\n if (!vaultPath) {\n _warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`)\n\n return DotenvModule.configDotenv(options)\n }\n\n return DotenvModule._configVault(options)\n}\n\nfunction decrypt (encrypted, keyStr) {\n const key = Buffer.from(keyStr.slice(-64), 'hex')\n let ciphertext = Buffer.from(encrypted, 'base64')\n\n const nonce = ciphertext.subarray(0, 12)\n const authTag = ciphertext.subarray(-16)\n ciphertext = ciphertext.subarray(12, -16)\n\n try {\n const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce)\n aesgcm.setAuthTag(authTag)\n return `${aesgcm.update(ciphertext)}${aesgcm.final()}`\n } catch (error) {\n const isRange = error instanceof RangeError\n const invalidKeyLength = error.message === 'Invalid key length'\n const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data'\n\n if (isRange || invalidKeyLength) {\n const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n } else if (decryptionFailed) {\n const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY')\n err.code = 'DECRYPTION_FAILED'\n throw err\n } else {\n throw error\n }\n }\n}\n\n// Populate process.env with parsed values\nfunction populate (processEnv, parsed, options = {}) {\n const debug = Boolean(options && options.debug)\n const override = Boolean(options && options.override)\n const populated = {}\n\n if (typeof parsed !== 'object') {\n const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')\n err.code = 'OBJECT_REQUIRED'\n throw err\n }\n\n // Set process.env\n for (const key of Object.keys(parsed)) {\n if (Object.prototype.hasOwnProperty.call(processEnv, key)) {\n if (override === true) {\n processEnv[key] = parsed[key]\n populated[key] = parsed[key]\n }\n\n if (debug) {\n if (override === true) {\n _debug(`\"${key}\" is already defined and WAS overwritten`)\n } else {\n _debug(`\"${key}\" is already defined and was NOT overwritten`)\n }\n }\n } else {\n processEnv[key] = parsed[key]\n populated[key] = parsed[key]\n }\n }\n\n return populated\n}\n\nconst DotenvModule = {\n configDotenv,\n _configVault,\n _parseVault,\n config,\n decrypt,\n parse,\n populate\n}\n\nmodule.exports.configDotenv = DotenvModule.configDotenv\nmodule.exports._configVault = DotenvModule._configVault\nmodule.exports._parseVault = DotenvModule._parseVault\nmodule.exports.config = DotenvModule.config\nmodule.exports.decrypt = DotenvModule.decrypt\nmodule.exports.parse = DotenvModule.parse\nmodule.exports.populate = DotenvModule.populate\n\nmodule.exports = DotenvModule\n","/**\n * Agent smart account = Kernel v3.1 + ECDSA sudo validator + session-key\n * permission validator.\n *\n * The owner EOA keeps full control (sudo) and can revoke / rotate the session\n * key at any time. The session key is the day-to-day signer the AI agent\n * holds; whatever policies you attach (see {@link createJpycDailyLimitPolicies})\n * are enforced at the ERC-4337 validation phase by ZeroDev's\n * `PermissionValidator`. Violating userOps revert before execution — they\n * never spend any of the smart account's funds, and a sponsored bundler\n * cannot be tricked into paying for them either.\n *\n * @packageDocumentation\n */\n\nimport { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\nimport type { Policy } from \"@zerodev/permissions\";\nimport { toPermissionValidator } from \"@zerodev/permissions\";\nimport { toECDSASigner } from \"@zerodev/permissions/signers\";\nimport type { CreateKernelAccountReturnType } from \"@zerodev/sdk\";\nimport { createKernelAccount } from \"@zerodev/sdk\";\nimport { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\nimport type { EntryPointType, GetKernelVersion } from \"@zerodev/sdk/types\";\nimport type { Chain, LocalAccount, PublicClient, Transport } from \"viem\";\n\n/** Parameters for {@link createAgentSmartAccount}. */\nexport interface CreateAgentSmartAccountParams {\n\t/**\n\t * viem `PublicClient` used to read on-chain state during account derivation.\n\t */\n\treadonly publicClient: PublicClient<Transport, Chain | undefined>;\n\t/**\n\t * The owner EOA. Retains sudo authority — can install new plugins,\n\t * revoke / rotate the session key, and bypass any policy.\n\t */\n\treadonly ownerSigner: LocalAccount;\n\t/**\n\t * The day-to-day signer the agent holds. Authority is limited to whatever\n\t * `policies` allow — by default it can do nothing.\n\t */\n\treadonly sessionKeySigner: LocalAccount;\n\t/**\n\t * ZeroDev policies (e.g. {@link createJpycDailyLimitPolicies}) the session\n\t * key must satisfy at userOp validation time.\n\t */\n\treadonly policies: readonly Policy[];\n\t/**\n\t * EntryPoint version + address. Defaults to v0.7 at the canonical\n\t * ERC-4337 entry-point address.\n\t */\n\treadonly entryPoint?: EntryPointType<\"0.7\">;\n\t/** Kernel version. Defaults to {@link KERNEL_V3_1}. */\n\treadonly kernelVersion?: GetKernelVersion<\"0.7\">;\n}\n\n/**\n * Builds a Kernel v3.1 smart account with sudo (owner) + regular (session key)\n * validators wired up.\n *\n * @example\n * ```ts\n * import { parseUnits } from \"viem\";\n * import { privateKeyToAccount } from \"viem/accounts\";\n * import {\n * createAgentSmartAccount,\n * createJpycDailyLimitPolicies,\n * getJpycAddress,\n * JPYC_DECIMALS,\n * polygonAmoy,\n * } from \"kawasekit\";\n *\n * const owner = privateKeyToAccount(process.env.OWNER_PRIVATE_KEY as `0x${string}`);\n * const sessionKey = privateKeyToAccount(process.env.SESSION_KEY_PRIVATE_KEY as `0x${string}`);\n *\n * const account = await createAgentSmartAccount({\n * publicClient,\n * ownerSigner: owner,\n * sessionKeySigner: sessionKey,\n * policies: createJpycDailyLimitPolicies({\n * jpycAddress: getJpycAddress(polygonAmoy.id),\n * maxPerTransfer: parseUnits(\"100\", JPYC_DECIMALS),\n * maxTransfersPerDay: 10,\n * }),\n * });\n * ```\n */\nexport async function createAgentSmartAccount(\n\tparams: CreateAgentSmartAccountParams,\n): Promise<CreateKernelAccountReturnType<\"0.7\">> {\n\tconst entryPoint = params.entryPoint ?? getEntryPoint(\"0.7\");\n\tconst kernelVersion = params.kernelVersion ?? KERNEL_V3_1;\n\n\tconst sudoValidator = await signerToEcdsaValidator(params.publicClient, {\n\t\tsigner: params.ownerSigner,\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\n\tconst modularSessionSigner = await toECDSASigner({ signer: params.sessionKeySigner });\n\n\tconst permissionValidator = await toPermissionValidator(params.publicClient, {\n\t\tsigner: modularSessionSigner,\n\t\tpolicies: [...params.policies],\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\n\treturn createKernelAccount(params.publicClient, {\n\t\tplugins: {\n\t\t\tsudo: sudoValidator,\n\t\t\tregular: permissionValidator,\n\t\t},\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n}\n","import { avalanche as viemAvalanche, avalancheFuji as viemAvalancheFuji } from \"viem/chains\";\nimport type { KawaseChain } from \"./types\";\n\n/**\n * Avalanche C-Chain — priority 3 production chain.\n *\n * Snowman BFT gives sub-`2 s` **deterministic finality**, so\n * `defaultConfirmations` of `2` is ample — deep confirmations add latency for\n * no extra safety. JPYC is live at the same address as the other chains.\n *\n * The x402 EOA-payer path works today; the smart-account path via ZeroDev is\n * not yet verified on Avalanche.\n */\nexport const avalanche = {\n\t...viemAvalanche,\n\tisTestnet: false,\n\tdefaultConfirmations: 2,\n\tblockTimeMs: 2_000,\n} satisfies KawaseChain;\n\n/**\n * Avalanche Fuji testnet. JPYC is live at the same address as the other chains\n * (confirmed via a read-only on-chain `name()` == \"JPY Coin\" / `symbol()` ==\n * \"JPYC\" check, 2026-05-31). Real x402 settlement here has not been exercised.\n */\nexport const avalancheFuji = {\n\t...viemAvalancheFuji,\n\tisTestnet: true,\n\tdefaultConfirmations: 1,\n\tblockTimeMs: 2_000,\n} satisfies KawaseChain;\n","import { mainnet as viemMainnet, sepolia as viemSepolia } from \"viem/chains\";\nimport type { KawaseChain } from \"./types\";\n\n/**\n * Ethereum mainnet — priority 4 production chain (institutional use cases).\n *\n * Casper FFG finalises in epochs (~12.8 min). `defaultConfirmations` of `32`\n * (~6.4 min at ~12 s blocks) gives finalised-grade safety. **Do NOT use\n * Polygon's `4` here** — 4 blocks (~48 s) is nowhere near finalised, and would\n * re-open the settle-reorg gap (threat 2.8). The facilitator auto-sizes\n * `receiptTimeoutMs` from this depth (~10 min), so the default does not time\n * out. JPYC is live at the same address as the other chains.\n */\nexport const ethereum = {\n\t...viemMainnet,\n\tisTestnet: false,\n\tdefaultConfirmations: 32,\n\tblockTimeMs: 12_000,\n} satisfies KawaseChain;\n\n/**\n * Sepolia — Ethereum testnet. JPYC is live at the same address as the other\n * chains (confirmed via a read-only on-chain `name()` == \"JPY Coin\" / `symbol()`\n * == \"JPYC\" check, 2026-05-31). Real x402 settlement here has not been exercised.\n */\nexport const sepolia = {\n\t...viemSepolia,\n\tisTestnet: true,\n\tdefaultConfirmations: 4,\n\tblockTimeMs: 12_000,\n} satisfies KawaseChain;\n","import { kaia as viemKaia, kairos as viemKairos } from \"viem/chains\";\nimport type { KawaseChain } from \"./types\";\n\n/**\n * Kaia mainnet — priority 2 production chain.\n *\n * Kaia (Klaytn + Finschia) runs IBFT consensus with **immediate finality** — a\n * single confirmed block is final — so `defaultConfirmations` is `1` (do NOT\n * copy Polygon's `4`). JPYC is live at the same address as the other chains\n * (`src/tokens/jpyc.ts`).\n *\n * Note: ZeroDev does not support Kaia, so the **smart-account path** (session\n * keys, sponsored UserOps) is not yet available here — it is planned via\n * Pimlico (M5-3 Phase 2). The **x402 EOA-payer path** works today.\n */\nexport const kaia = {\n\t...viemKaia,\n\tisTestnet: false,\n\tdefaultConfirmations: 1,\n\tblockTimeMs: 1_000,\n} satisfies KawaseChain;\n\n/**\n * Kairos — Kaia testnet. JPYC is available via the Kaia faucet at the same\n * address as mainnet; suitable for the same Amoy→Polygon-style testnet→mainnet\n * verification pattern.\n */\nexport const kairos = {\n\t...viemKairos,\n\tisTestnet: true,\n\tdefaultConfirmations: 1,\n\tblockTimeMs: 1_000,\n} satisfies KawaseChain;\n","import { polygon as viemPolygon, polygonAmoy as viemPolygonAmoy } from \"viem/chains\";\nimport type { KawaseChain } from \"./types\";\n\n/**\n * Polygon mainnet — priority 1 production chain.\n *\n * Built on viem's `polygon` definition (official RPC URLs, block explorers,\n * and `POL` native currency) plus kawasekit metadata. Polygon PoS is\n * probabilistic; the default `4` confirmations ≈ ~8 s of soft finality.\n */\nexport const polygon = {\n\t...viemPolygon,\n\tisTestnet: false,\n\tdefaultConfirmations: 4,\n\tblockTimeMs: 2_000,\n} satisfies KawaseChain;\n\n/**\n * Polygon Amoy testnet — the primary kawasekit development target.\n *\n * Built on viem's `polygonAmoy` definition. JPYC is also live on Amoy at the\n * same address as mainnet; see `src/tokens/jpyc.ts`.\n */\nexport const polygonAmoy = {\n\t...viemPolygonAmoy,\n\tisTestnet: true,\n\tdefaultConfirmations: 1,\n\tblockTimeMs: 2_000,\n} satisfies KawaseChain;\n","import type { Chain } from \"viem\";\n\n/**\n * A viem {@link Chain} extended with kawasekit-specific routing + finality\n * metadata.\n *\n * All standard chain fields (`id`, `rpcUrls`, `blockExplorers`,\n * `nativeCurrency`, …) are inherited from viem's `Chain`. kawasekit adds only\n * the fields below; per-token deployment info lives in `src/tokens/`.\n *\n * `defaultConfirmations` / `blockTimeMs` are **config-as-data**: the facilitator\n * reads them instead of branching on chain identity, so finality depth is a\n * per-chain property rather than a code path (cf. the finality-tuning recipe at\n * `docs/recipes/facilitator-finality-tuning.md`).\n *\n * @example\n * ```ts\n * import { polygon } from \"kawasekit\";\n *\n * console.log(polygon.id); // 137\n * console.log(polygon.isTestnet); // false\n * console.log(polygon.defaultConfirmations); // 4\n * ```\n */\nexport interface KawaseChain extends Chain {\n\t/** `true` for test networks, `false` for production networks. */\n\treadonly isTestnet: boolean;\n\t/**\n\t * Default settle confirmation depth for this chain (threat 2.8 / §6.6). Set\n\t * by the chain's finality model, **not** copied across chains: probabilistic\n\t * chains (Polygon) need depth; deterministic-finality chains (Avalanche\n\t * Snowman, Kaia IBFT) need `1-2`; Ethereum needs ~`32`. Operators override\n\t * via `CreateSelfFacilitatorParams.confirmations`.\n\t */\n\treadonly defaultConfirmations: number;\n\t/**\n\t * Approximate block time in milliseconds. Used to auto-size the settle\n\t * `receiptTimeoutMs` default from the confirmation depth, and as the basis\n\t * for the finality-tuning recipe's wall-time estimates.\n\t */\n\treadonly blockTimeMs: number;\n}\n\n/** Base URL of the ZeroDev v3 RPC service. */\nconst ZERODEV_RPC_BASE = \"https://rpc.zerodev.app/api/v3\";\n\n/**\n * Builds the ZeroDev v3 RPC URL for a chain.\n *\n * In ZeroDev v3 a single URL serves as **both** the ERC-4337 bundler endpoint\n * and the paymaster endpoint. Obtain a project ID from\n * {@link https://dashboard.zerodev.app}.\n *\n * Note: ZeroDev does not support every kawasekit chain (e.g. Kaia uses Pimlico\n * for the smart-account path). This helper only builds the URL string; it does\n * not assert ZeroDev availability. The x402 EOA-payer path does not use ZeroDev.\n *\n * @param chain - A kawasekit-supported chain.\n * @param projectId - ZeroDev project ID.\n * @returns Fully-qualified ZeroDev v3 RPC URL.\n *\n * @example\n * ```ts\n * import { polygonAmoy, zerodevRpcUrl } from \"kawasekit\";\n *\n * const rpc = zerodevRpcUrl(polygonAmoy, \"my-zerodev-project-id\");\n * // https://rpc.zerodev.app/api/v3/my-zerodev-project-id/chain/80002\n * ```\n */\nexport function zerodevRpcUrl(chain: KawaseChain, projectId: string): string {\n\treturn `${ZERODEV_RPC_BASE}/${projectId}/chain/${chain.id}`;\n}\n","import { avalanche, avalancheFuji } from \"./avalanche\";\nimport { ethereum, sepolia } from \"./ethereum\";\nimport { kaia, kairos } from \"./kaia\";\nimport { polygon, polygonAmoy } from \"./polygon\";\nimport { type KawaseChain, zerodevRpcUrl } from \"./types\";\n\nexport {\n\tavalanche,\n\tavalancheFuji,\n\tethereum,\n\ttype KawaseChain,\n\tkaia,\n\tkairos,\n\tpolygon,\n\tpolygonAmoy,\n\tsepolia,\n\tzerodevRpcUrl,\n};\n\n/**\n * All chains kawasekit supports, in priority order (CLAUDE.md chain priority:\n * Polygon → Kaia → Avalanche → Ethereum, each with its testnet).\n *\n * Exposed as a `readonly` tuple — **not** a `Map` — so that bundlers can\n * tree-shake chains a consumer never references.\n *\n * JPYC liveness is a separate axis (`src/tokens/jpyc.ts`): a chain can be\n * supported here while JPYC is not yet live on it (Avalanche Fuji / Sepolia).\n *\n * @example\n * ```ts\n * import { supportedChains } from \"kawasekit\";\n *\n * for (const chain of supportedChains) {\n * \tconsole.log(chain.id, chain.name);\n * }\n * ```\n */\nexport const supportedChains = [\n\tpolygon,\n\tpolygonAmoy,\n\tkaia,\n\tkairos,\n\tavalanche,\n\tavalancheFuji,\n\tethereum,\n\tsepolia,\n] as const;\n\n/**\n * Union of every chain ID kawasekit supports\n * (`137 | 80002 | 8217 | 1001 | 43114 | 43113 | 1 | 11155111`).\n *\n * Derived from {@link supportedChains}, so adding a chain there extends this\n * type automatically.\n */\nexport type SupportedChainId = (typeof supportedChains)[number][\"id\"];\n\n/** A single member of {@link supportedChains}, with its literal `id`. */\ntype SupportedChain = (typeof supportedChains)[number];\n\n/**\n * Internal chain lookup, built once at module scope.\n *\n * This `Map` is an implementation detail and is intentionally **not**\n * exported: the public API exposes the {@link supportedChains} tuple instead,\n * so importing one chain does not pull in all of them.\n */\nconst chainsById: ReadonlyMap<number, SupportedChain> = new Map(\n\tsupportedChains.map((chain) => [chain.id, chain]),\n);\n\n/**\n * Error thrown when a chain ID kawasekit does not support is requested.\n *\n * @example\n * ```ts\n * import { ChainNotSupportedError, getChain } from \"kawasekit\";\n *\n * try {\n * \tgetChain(1);\n * } catch (error) {\n * \tif (error instanceof ChainNotSupportedError) {\n * \t\tconsole.error(error.message);\n * \t}\n * }\n * ```\n */\nexport class ChainNotSupportedError extends Error {\n\tconstructor(chainId: number) {\n\t\tconst supported = supportedChains.map((chain) => chain.id).join(\", \");\n\t\tsuper(\n\t\t\t`Chain ID ${chainId} is not supported by kawasekit. ` + `Supported chain IDs: ${supported}.`,\n\t\t);\n\t\tthis.name = \"ChainNotSupportedError\";\n\t}\n}\n\n/**\n * Type guard that narrows an arbitrary chain ID to a {@link SupportedChainId}.\n *\n * @param chainId - The numeric chain ID to test.\n * @returns `true` if kawasekit supports this chain ID.\n *\n * @example\n * ```ts\n * import { isSupportedChainId } from \"kawasekit\";\n *\n * const id = 80002;\n * if (isSupportedChainId(id)) {\n * \t// `id` is now narrowed to SupportedChainId\n * }\n * ```\n */\nexport function isSupportedChainId(chainId: number): chainId is SupportedChainId {\n\treturn chainsById.has(chainId);\n}\n\n/**\n * Looks up a supported chain by its numeric chain ID.\n *\n * The returned chain's `id` is narrowed to {@link SupportedChainId}.\n *\n * @param chainId - The numeric chain ID to look up.\n * @returns The matching {@link KawaseChain}.\n * @throws {ChainNotSupportedError} If `chainId` is not supported.\n *\n * @example\n * ```ts\n * import { getChain } from \"kawasekit\";\n *\n * const chain = getChain(80002); // Polygon Amoy\n * console.log(chain.name);\n * ```\n */\nexport function getChain(chainId: number): SupportedChain {\n\tconst chain = chainsById.get(chainId);\n\tif (chain === undefined) {\n\t\tthrow new ChainNotSupportedError(chainId);\n\t}\n\treturn chain;\n}\n","/**\n * JPYC stablecoin metadata, deployments, and ABI.\n *\n * JPYC is a Japanese yen-pegged stablecoin issued by JPYC Inc. under the\n * revised Payment Services Act as 電子決済手段 (electronic payment\n * instrument). The new (\"v2\") JPYC, launched 2025-10, lives at the same\n * address on every chain where it is deployed.\n *\n * @packageDocumentation\n */\n\nimport type { Address } from \"viem\";\nimport type { SupportedChainId } from \"../chains\";\nimport {\n\tavalanche,\n\tavalancheFuji,\n\tethereum,\n\tkaia,\n\tkairos,\n\tpolygon,\n\tpolygonAmoy,\n\tsepolia,\n} from \"../chains\";\n\n/** ERC-20 decimals for JPYC. Constant across every chain. */\nexport const JPYC_DECIMALS = 18;\n\n/**\n * EIP-712 domain hint for off-chain authorization signing (EIP-3009, EIP-2612).\n *\n * The real JPYC contract does not expose `version()` publicly — it lives in an\n * `internal VERSION` state variable set during proxy initialization. The\n * canonical value is `\"1\"`, matching the FiatToken lineage; the\n * {@link signTransferWithAuthorization} helper accepts an override if a future\n * deployment changes this.\n *\n * `name` is \"JPY Coin\" — the on-chain `name()` value on every live deployment.\n */\nexport const JPYC_EIP712_DOMAIN_HINT = {\n\tname: \"JPY Coin\",\n\tversion: \"1\",\n} as const;\n\n/**\n * Address shared by every live JPYC deployment.\n *\n * Verified on:\n * - Ethereum : https://etherscan.io/token/0xE7C3D8C9a439feDe00D2600032D5dB0Be71C3c29\n * - Polygon : https://polygonscan.com/token/0xe7c3d8c9a439fede00d2600032d5db0be71c3c29\n * - Polygon Amoy : https://amoy.polygonscan.com/token/0xe7c3d8c9a439fede00d2600032d5db0be71c3c29\n * - Avalanche : https://snowtrace.io/token/0xE7C3D8C9a439feDe00D2600032D5dB0Be71C3c29\n *\n * Do NOT confuse with the legacy 前払式支払手段 JPYC at `0x431D5dFF...`.\n */\nexport const JPYC_V2_ADDRESS: Address = \"0xE7C3D8C9a439feDe00D2600032D5dB0Be71C3c29\";\n\n/** A JPYC deployment on a single chain. */\nexport interface JpycDeployment {\n\treadonly chainId: SupportedChainId;\n\treadonly address: Address;\n\t/** `true` if the token is live on this chain right now. */\n\treadonly isLive: boolean;\n}\n\n/**\n * JPYC deployments keyed by chain.\n *\n * JPYC v2 uses the **same address** (`JPYC_V2_ADDRESS`) on every chain where it\n * is live. `isLive` is the separate \"is JPYC actually deployed here yet?\" axis.\n * All eight supported chains are live at this address: the four mainnets\n * (Polygon, Kaia, Avalanche, Ethereum) + Amoy + Kairos + Avalanche Fuji +\n * Sepolia. Kaia/Kairos/Avalanche/Fuji/Sepolia were confirmed by a read-only\n * on-chain check (`name() == \"JPY Coin\"`, `symbol() == \"JPYC\"` at `0xE7C3…`,\n * 2026-05-31); Polygon/Amoy/Ethereum are established. `isLive: false` + the\n * {@link JpycNotAvailableError} path remain for any future chain added before\n * its JPYC deployment lands.\n */\nexport const jpycDeployments: { readonly [chainId in SupportedChainId]: JpycDeployment } = {\n\t[polygon.id]: { chainId: polygon.id, address: JPYC_V2_ADDRESS, isLive: true },\n\t[polygonAmoy.id]: { chainId: polygonAmoy.id, address: JPYC_V2_ADDRESS, isLive: true },\n\t[kaia.id]: { chainId: kaia.id, address: JPYC_V2_ADDRESS, isLive: true },\n\t[kairos.id]: { chainId: kairos.id, address: JPYC_V2_ADDRESS, isLive: true },\n\t[avalanche.id]: { chainId: avalanche.id, address: JPYC_V2_ADDRESS, isLive: true },\n\t[ethereum.id]: { chainId: ethereum.id, address: JPYC_V2_ADDRESS, isLive: true },\n\t[avalancheFuji.id]: { chainId: avalancheFuji.id, address: JPYC_V2_ADDRESS, isLive: true },\n\t[sepolia.id]: { chainId: sepolia.id, address: JPYC_V2_ADDRESS, isLive: true },\n};\n\n/**\n * Thrown when JPYC is not deployed on the requested chain.\n *\n * Today this is unreachable (every {@link SupportedChainId} has a live\n * deployment), but the error class is exported for future chains (Kaia) where\n * JPYC is still in development.\n */\nexport class JpycNotAvailableError extends Error {\n\tconstructor(chainId: number) {\n\t\tsuper(`JPYC is not yet deployed on chain ID ${chainId}.`);\n\t\tthis.name = \"JpycNotAvailableError\";\n\t}\n}\n\n/**\n * Returns the JPYC contract address for a kawasekit-supported chain.\n *\n * @param chainId - A {@link SupportedChainId}.\n * @returns The JPYC contract address on that chain.\n * @throws {JpycNotAvailableError} If JPYC is not live on the chain.\n *\n * @example\n * ```ts\n * import { getJpycAddress, polygonAmoy } from \"kawasekit\";\n *\n * const address = getJpycAddress(polygonAmoy.id);\n * ```\n */\nexport function getJpycAddress(chainId: SupportedChainId): Address {\n\tconst deployment = jpycDeployments[chainId];\n\tif (!deployment.isLive) {\n\t\tthrow new JpycNotAvailableError(chainId);\n\t}\n\treturn deployment.address;\n}\n\n/**\n * Minimal JPYC ABI: ERC-20 + EIP-3009 surface that kawasekit needs.\n *\n * Excludes permit / mint / blocklist / pause — kawasekit only reads balance,\n * sends `transfer()` via UserOp, and constructs / submits EIP-3009\n * authorizations. Bringing in the full FiatTokenV1 ABI would be wasted bytes.\n */\nexport const jpycAbi = [\n\t// ----- ERC-20 read -----\n\t{\n\t\ttype: \"function\",\n\t\tname: \"name\",\n\t\tstateMutability: \"view\",\n\t\tinputs: [],\n\t\toutputs: [{ name: \"\", type: \"string\" }],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"symbol\",\n\t\tstateMutability: \"view\",\n\t\tinputs: [],\n\t\toutputs: [{ name: \"\", type: \"string\" }],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"decimals\",\n\t\tstateMutability: \"view\",\n\t\tinputs: [],\n\t\toutputs: [{ name: \"\", type: \"uint8\" }],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"totalSupply\",\n\t\tstateMutability: \"view\",\n\t\tinputs: [],\n\t\toutputs: [{ name: \"\", type: \"uint256\" }],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"balanceOf\",\n\t\tstateMutability: \"view\",\n\t\tinputs: [{ name: \"account\", type: \"address\" }],\n\t\toutputs: [{ name: \"\", type: \"uint256\" }],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"allowance\",\n\t\tstateMutability: \"view\",\n\t\tinputs: [\n\t\t\t{ name: \"owner\", type: \"address\" },\n\t\t\t{ name: \"spender\", type: \"address\" },\n\t\t],\n\t\toutputs: [{ name: \"\", type: \"uint256\" }],\n\t},\n\t// ----- ERC-20 write -----\n\t{\n\t\ttype: \"function\",\n\t\tname: \"transfer\",\n\t\tstateMutability: \"nonpayable\",\n\t\tinputs: [\n\t\t\t{ name: \"to\", type: \"address\" },\n\t\t\t{ name: \"value\", type: \"uint256\" },\n\t\t],\n\t\toutputs: [{ name: \"\", type: \"bool\" }],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"transferFrom\",\n\t\tstateMutability: \"nonpayable\",\n\t\tinputs: [\n\t\t\t{ name: \"from\", type: \"address\" },\n\t\t\t{ name: \"to\", type: \"address\" },\n\t\t\t{ name: \"value\", type: \"uint256\" },\n\t\t],\n\t\toutputs: [{ name: \"\", type: \"bool\" }],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"approve\",\n\t\tstateMutability: \"nonpayable\",\n\t\tinputs: [\n\t\t\t{ name: \"spender\", type: \"address\" },\n\t\t\t{ name: \"value\", type: \"uint256\" },\n\t\t],\n\t\toutputs: [{ name: \"\", type: \"bool\" }],\n\t},\n\t// ----- EIP-3009 -----\n\t{\n\t\ttype: \"function\",\n\t\tname: \"transferWithAuthorization\",\n\t\tstateMutability: \"nonpayable\",\n\t\tinputs: [\n\t\t\t{ name: \"from\", type: \"address\" },\n\t\t\t{ name: \"to\", type: \"address\" },\n\t\t\t{ name: \"value\", type: \"uint256\" },\n\t\t\t{ name: \"validAfter\", type: \"uint256\" },\n\t\t\t{ name: \"validBefore\", type: \"uint256\" },\n\t\t\t{ name: \"nonce\", type: \"bytes32\" },\n\t\t\t{ name: \"v\", type: \"uint8\" },\n\t\t\t{ name: \"r\", type: \"bytes32\" },\n\t\t\t{ name: \"s\", type: \"bytes32\" },\n\t\t],\n\t\toutputs: [],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"receiveWithAuthorization\",\n\t\tstateMutability: \"nonpayable\",\n\t\tinputs: [\n\t\t\t{ name: \"from\", type: \"address\" },\n\t\t\t{ name: \"to\", type: \"address\" },\n\t\t\t{ name: \"value\", type: \"uint256\" },\n\t\t\t{ name: \"validAfter\", type: \"uint256\" },\n\t\t\t{ name: \"validBefore\", type: \"uint256\" },\n\t\t\t{ name: \"nonce\", type: \"bytes32\" },\n\t\t\t{ name: \"v\", type: \"uint8\" },\n\t\t\t{ name: \"r\", type: \"bytes32\" },\n\t\t\t{ name: \"s\", type: \"bytes32\" },\n\t\t],\n\t\toutputs: [],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"cancelAuthorization\",\n\t\tstateMutability: \"nonpayable\",\n\t\tinputs: [\n\t\t\t{ name: \"authorizer\", type: \"address\" },\n\t\t\t{ name: \"nonce\", type: \"bytes32\" },\n\t\t\t{ name: \"v\", type: \"uint8\" },\n\t\t\t{ name: \"r\", type: \"bytes32\" },\n\t\t\t{ name: \"s\", type: \"bytes32\" },\n\t\t],\n\t\toutputs: [],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"authorizationState\",\n\t\tstateMutability: \"view\",\n\t\tinputs: [\n\t\t\t{ name: \"authorizer\", type: \"address\" },\n\t\t\t{ name: \"nonce\", type: \"bytes32\" },\n\t\t],\n\t\toutputs: [{ name: \"\", type: \"bool\" }],\n\t},\n\t// ----- Events kawasekit needs to decode -----\n\t{\n\t\ttype: \"event\",\n\t\tname: \"Transfer\",\n\t\tinputs: [\n\t\t\t{ name: \"from\", type: \"address\", indexed: true },\n\t\t\t{ name: \"to\", type: \"address\", indexed: true },\n\t\t\t{ name: \"value\", type: \"uint256\", indexed: false },\n\t\t],\n\t},\n\t{\n\t\ttype: \"event\",\n\t\tname: \"Approval\",\n\t\tinputs: [\n\t\t\t{ name: \"owner\", type: \"address\", indexed: true },\n\t\t\t{ name: \"spender\", type: \"address\", indexed: true },\n\t\t\t{ name: \"value\", type: \"uint256\", indexed: false },\n\t\t],\n\t},\n\t{\n\t\ttype: \"event\",\n\t\tname: \"AuthorizationUsed\",\n\t\tinputs: [\n\t\t\t{ name: \"authorizer\", type: \"address\", indexed: true },\n\t\t\t{ name: \"nonce\", type: \"bytes32\", indexed: true },\n\t\t],\n\t},\n\t{\n\t\ttype: \"event\",\n\t\tname: \"AuthorizationCanceled\",\n\t\tinputs: [\n\t\t\t{ name: \"authorizer\", type: \"address\", indexed: true },\n\t\t\t{ name: \"nonce\", type: \"bytes32\", indexed: true },\n\t\t],\n\t},\n] as const;\n","/**\n * High-level helper: transfer JPYC from a Kernel smart account via a sponsored\n * UserOp.\n *\n * This is the canonical \"agent payment\" path for M2. The flow:\n * 1. Resolve the JPYC contract address for `kernelClient.chain`.\n * 2. Encode `JPYC.transfer(to, amount)` calldata.\n * 3. Wrap it as a Kernel call and submit via `sendUserOperation`.\n * 4. Wait for the bundler receipt and return both hashes.\n *\n * EIP-3009 `transferWithAuthorization` cannot be used here: JPYC's signature\n * verification is pure `ecrecover`, so a smart account cannot be `from`. See\n * `src/tokens/eip3009.ts` for the EOA-payer path.\n *\n * @packageDocumentation\n */\n\nimport type { KernelAccountClient } from \"@zerodev/sdk\";\nimport type { Address, Chain, Hex, Transport } from \"viem\";\nimport { encodeFunctionData, isAddress } from \"viem\";\nimport type { SmartAccount } from \"viem/account-abstraction\";\nimport { isSupportedChainId, type SupportedChainId } from \"../chains\";\nimport { getJpycAddress, jpycAbi } from \"../tokens/jpyc\";\n\n/** A {@link KernelAccountClient} that is fully configured (chain + account). */\nexport type ConfiguredKernelClient = KernelAccountClient<Transport, Chain, SmartAccount>;\n\n/** Parameters for {@link transferJpyc}. */\nexport interface TransferJpycParams {\n\t/** Recipient address. */\n\treadonly to: Address;\n\t/**\n\t * Raw token amount in the token's smallest unit (JPYC has 18 decimals).\n\t *\n\t * @example\n\t * ```ts\n\t * import { parseUnits } from \"viem\";\n\t * import { JPYC_DECIMALS } from \"kawasekit\";\n\t *\n\t * parseUnits(\"100\", JPYC_DECIMALS); // 100 JPYC\n\t * ```\n\t */\n\treadonly amount: bigint;\n\t/**\n\t * Optional. Defaults to waiting for the bundler receipt before returning.\n\t * Set to `false` to return after the UserOp is submitted but before it\n\t * lands on chain — useful when the caller wants to do its own polling.\n\t */\n\treadonly waitForReceipt?: boolean;\n}\n\n/** Result of a {@link transferJpyc} call. */\nexport interface TransferJpycResult {\n\treadonly userOpHash: Hex;\n\t/** `null` when `waitForReceipt: false` was requested. */\n\treadonly transactionHash: Hex | null;\n\t/** `true` if the bundler receipt reported success; `null` if not awaited. */\n\treadonly success: boolean | null;\n}\n\n/** Thrown when {@link transferJpyc} is called with invalid arguments. */\nexport class TransferJpycInputError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(`transferJpyc: ${message}`);\n\t\tthis.name = \"TransferJpycInputError\";\n\t}\n}\n\n/**\n * Transfer JPYC from the Kernel smart account to `to` via a sponsored UserOp.\n *\n * @example\n * ```ts\n * import { parseUnits } from \"viem\";\n * import { JPYC_DECIMALS, transferJpyc } from \"kawasekit\";\n *\n * const { userOpHash, transactionHash } = await transferJpyc(kernelClient, {\n * to: \"0xBeef0000000000000000000000000000DEADBEEF\",\n * amount: parseUnits(\"100\", JPYC_DECIMALS),\n * });\n * ```\n */\nexport async function transferJpyc(\n\tkernelClient: ConfiguredKernelClient,\n\tparams: TransferJpycParams,\n): Promise<TransferJpycResult> {\n\tif (!isAddress(params.to, { strict: false })) {\n\t\tthrow new TransferJpycInputError(`\\`to\\` is not a valid address: ${params.to}`);\n\t}\n\tif (params.amount <= 0n) {\n\t\tthrow new TransferJpycInputError(`\\`amount\\` must be positive, got ${params.amount}.`);\n\t}\n\n\tconst chainId = kernelClient.chain.id;\n\tif (!isSupportedChainId(chainId)) {\n\t\tthrow new TransferJpycInputError(`Chain ID ${chainId} is not a kawasekit-supported chain.`);\n\t}\n\tconst jpycAddress = getJpycAddress(chainId satisfies SupportedChainId);\n\n\tconst data = encodeFunctionData({\n\t\tabi: jpycAbi,\n\t\tfunctionName: \"transfer\",\n\t\targs: [params.to, params.amount],\n\t});\n\n\tconst callData = await kernelClient.account.encodeCalls([{ to: jpycAddress, value: 0n, data }]);\n\n\tconst userOpHash = await kernelClient.sendUserOperation({ callData });\n\n\tif (params.waitForReceipt === false) {\n\t\treturn { userOpHash, transactionHash: null, success: null };\n\t}\n\n\tconst receipt = await kernelClient.waitForUserOperationReceipt({ hash: userOpHash });\n\treturn {\n\t\tuserOpHash,\n\t\ttransactionHash: receipt.receipt.transactionHash,\n\t\tsuccess: receipt.success,\n\t};\n}\n","/**\n * Daily-limit spending policy for JPYC, built on ZeroDev's Permission System.\n *\n * Composes two ZeroDev policies:\n * 1. **callPolicy** — locks the session key to `JPYC.transfer(to, value)`\n * with `value ≤ maxPerTransfer`. Recipient is unrestricted in M2;\n * add allowlisting in M3 when use cases firm up.\n * 2. **rateLimitPolicy** — caps userOp count to `maxTransfersPerDay` in any\n * 24-hour rolling window.\n *\n * Effective daily cap = `maxPerTransfer × maxTransfersPerDay`. This is not a\n * cumulative-amount tracker (ZeroDev doesn't ship one), but the agent cannot\n * exceed either dimension, so the spirit of \"daily limit\" holds.\n *\n * @packageDocumentation\n */\n\nimport type { Policy } from \"@zerodev/permissions\";\nimport {\n\tCallPolicyVersion,\n\tParamCondition,\n\ttoCallPolicy,\n\ttoRateLimitPolicy,\n} from \"@zerodev/permissions/policies\";\nimport type { Address } from \"viem\";\nimport { jpycAbi } from \"../tokens/jpyc\";\n\n/** One day in seconds — the period for {@link createJpycDailyLimitPolicies}. */\nexport const ONE_DAY_SECONDS = 86_400;\n\n/** Parameters for {@link createJpycDailyLimitPolicies}. */\nexport interface CreateJpycDailyLimitPoliciesParams {\n\t/** JPYC contract address on the target chain. */\n\treadonly jpycAddress: Address;\n\t/** Maximum JPYC (in raw units) the session key may move in one transfer. */\n\treadonly maxPerTransfer: bigint;\n\t/** Maximum number of transfer userOps the session key may submit per day. */\n\treadonly maxTransfersPerDay: number;\n\t/**\n\t * ZeroDev callPolicy on-chain version. Defaults to V0_0_4 (latest at the\n\t * time of writing). Bump only after auditing the new version's semantics.\n\t */\n\treadonly callPolicyVersion?: CallPolicyVersion;\n}\n\n/**\n * Builds the ZeroDev policy bundle that enforces a JPYC daily spend limit.\n *\n * Plug the returned policies into `toPermissionValidator({ policies, … })`\n * — see {@link createAgentSmartAccount} for the common wiring.\n *\n * @example\n * ```ts\n * import { parseUnits } from \"viem\";\n * import {\n * createJpycDailyLimitPolicies,\n * getJpycAddress,\n * JPYC_DECIMALS,\n * polygonAmoy,\n * } from \"kawasekit\";\n *\n * const policies = createJpycDailyLimitPolicies({\n * jpycAddress: getJpycAddress(polygonAmoy.id),\n * maxPerTransfer: parseUnits(\"100\", JPYC_DECIMALS), // 100 JPYC / tx\n * maxTransfersPerDay: 10, // 10 tx / day\n * // effective daily cap = 1000 JPYC\n * });\n * ```\n */\nexport function createJpycDailyLimitPolicies(\n\tparams: CreateJpycDailyLimitPoliciesParams,\n): readonly [Policy, Policy] {\n\tif (params.maxPerTransfer <= 0n) {\n\t\tthrow new Error(\n\t\t\t`createJpycDailyLimitPolicies: maxPerTransfer must be positive, got ${params.maxPerTransfer}.`,\n\t\t);\n\t}\n\tif (!Number.isInteger(params.maxTransfersPerDay) || params.maxTransfersPerDay < 1) {\n\t\tthrow new Error(\n\t\t\t`createJpycDailyLimitPolicies: maxTransfersPerDay must be a positive integer, got ${params.maxTransfersPerDay}.`,\n\t\t);\n\t}\n\n\tconst callPolicy = toCallPolicy({\n\t\tpolicyVersion: params.callPolicyVersion ?? CallPolicyVersion.V0_0_4,\n\t\tpermissions: [\n\t\t\t{\n\t\t\t\ttarget: params.jpycAddress,\n\t\t\t\tabi: jpycAbi,\n\t\t\t\tfunctionName: \"transfer\",\n\t\t\t\targs: [\n\t\t\t\t\t// Recipient: any address allowed (no allowlist in M2).\n\t\t\t\t\tnull,\n\t\t\t\t\t// value: must be ≤ maxPerTransfer.\n\t\t\t\t\t{\n\t\t\t\t\t\tcondition: ParamCondition.LESS_THAN_OR_EQUAL,\n\t\t\t\t\t\tvalue: params.maxPerTransfer,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst rateLimitPolicy = toRateLimitPolicy({\n\t\tinterval: ONE_DAY_SECONDS,\n\t\tcount: params.maxTransfersPerDay,\n\t});\n\n\treturn [callPolicy, rateLimitPolicy] as const;\n}\n","/**\n * Typed errors thrown by the `kawasekit/session` modules.\n *\n * Centralised so consumers can `instanceof`-discriminate without importing\n * deep paths.\n *\n * @packageDocumentation\n */\n\nimport type { Address } from \"viem\";\n\n/**\n * Thrown when {@link parseSessionEnvelope} encounters an envelope whose\n * `kawasekitVersion` does not match the current\n * {@link KAWASEKIT_SESSION_ENVELOPE_VERSION}.\n *\n * The version field is intentionally a string (\"1\") so that future migrations\n * can introduce non-numeric variants (e.g. \"1-jwe\") without breaking the\n * parser ordering.\n */\nexport class SessionEnvelopeVersionError extends Error {\n\treadonly expected: string;\n\treadonly received: unknown;\n\n\tconstructor(expected: string, received: unknown) {\n\t\tsuper(\n\t\t\t`Session envelope version mismatch: expected ${JSON.stringify(expected)}, got ${JSON.stringify(received)}.`,\n\t\t);\n\t\tthis.name = \"SessionEnvelopeVersionError\";\n\t\tthis.expected = expected;\n\t\tthis.received = received;\n\t}\n}\n\n/**\n * Thrown by `restoreSessionAccount()` when an envelope's `chainId` differs\n * from the chain the consumer is restoring on. Catches the common mistake of\n * issuing on Polygon Amoy and trying to restore on Polygon mainnet.\n */\nexport class SessionEnvelopeChainMismatchError extends Error {\n\treadonly envelopeChainId: number;\n\treadonly clientChainId: number;\n\n\tconstructor(envelopeChainId: number, clientChainId: number) {\n\t\tsuper(\n\t\t\t`Session envelope is for chain ${envelopeChainId} but the restore client is on chain ${clientChainId}.`,\n\t\t);\n\t\tthis.name = \"SessionEnvelopeChainMismatchError\";\n\t\tthis.envelopeChainId = envelopeChainId;\n\t\tthis.clientChainId = clientChainId;\n\t}\n}\n\n/**\n * Thrown by `restoreSessionAccount()` when the session-key signer the consumer\n * passes does not match the `sessionKeyAddress` recorded in the envelope.\n *\n * Defence against accidentally restoring with the wrong private key — which\n * would otherwise succeed locally and only fail at UserOp validation time.\n */\nexport class SessionEnvelopeSignerMismatchError extends Error {\n\treadonly envelopeSignerAddress: Address;\n\treadonly providedSignerAddress: Address;\n\n\tconstructor(envelopeSignerAddress: Address, providedSignerAddress: Address) {\n\t\tsuper(\n\t\t\t`Session envelope was issued for signer ${envelopeSignerAddress}, but the provided session-key signer is ${providedSignerAddress}.`,\n\t\t);\n\t\tthis.name = \"SessionEnvelopeSignerMismatchError\";\n\t\tthis.envelopeSignerAddress = envelopeSignerAddress;\n\t\tthis.providedSignerAddress = providedSignerAddress;\n\t}\n}\n\n/**\n * Thrown when {@link parseSessionEnvelope} cannot decode the input as a\n * structurally valid envelope (malformed JSON, missing fields, bad types).\n */\nexport class SessionEnvelopeParseError extends Error {\n\treadonly reason: string;\n\n\tconstructor(reason: string, options?: { cause?: unknown }) {\n\t\tsuper(`Failed to parse session envelope: ${reason}`, options);\n\t\tthis.name = \"SessionEnvelopeParseError\";\n\t\tthis.reason = reason;\n\t}\n}\n","/**\n * `KawasekitSessionEnvelope` — kawasekit's typed wrapper around ZeroDev's\n * opaque `serializePermissionAccount` blob.\n *\n * Why wrap ZeroDev's blob rather than use it directly?\n *\n * - **Fail-fast on restore**: chainId / version / signer mismatches surface as\n * typed errors instead of confusing UserOp-time reverts.\n * - **Host-UI affordances**: `expiresAt` and `policySummary` are advisory\n * fields a wallet can render (\"this session expires in 2 hours, max 100\n * JPYC/day\") before handing the blob to {@link restoreSessionAccount}.\n * - **Version pin**: when ZeroDev changes their serialization format we bump\n * {@link KAWASEKIT_SESSION_ENVELOPE_VERSION} and provide a migration; the\n * inner `serialized` field stays opaque.\n *\n * Wire format: a single JSON string. Bigint fields (`expiresAt`,\n * `policySummary.maxPerTransfer`) round-trip via decimal-string encoding so\n * the JSON itself is portable through any transport (env var, HTTP header,\n * file).\n *\n * @packageDocumentation\n */\n\nimport { type Address, isAddress } from \"viem\";\nimport { isSupportedChainId, type SupportedChainId } from \"../chains\";\nimport { SessionEnvelopeParseError, SessionEnvelopeVersionError } from \"./errors\";\n\n/**\n * Current envelope format version. Bumped when the envelope schema changes\n * in a way that breaks backward compatibility.\n */\nexport const KAWASEKIT_SESSION_ENVELOPE_VERSION = \"1\" as const;\n\n/** Type of {@link KAWASEKIT_SESSION_ENVELOPE_VERSION}. */\nexport type KawasekitSessionEnvelopeVersion = typeof KAWASEKIT_SESSION_ENVELOPE_VERSION;\n\n/**\n * Advisory summary of the spending policy attached to a session key. Useful\n * for host UI; **not** consulted at validation time (the on-chain validator\n * is the source of truth).\n */\nexport interface KawasekitSessionPolicySummary {\n\treadonly jpycAddress: Address;\n\treadonly maxPerTransfer: bigint;\n\treadonly maxTransfersPerDay: number;\n}\n\n/** kawasekit's typed envelope around a ZeroDev session-key serialization. */\nexport interface KawasekitSessionEnvelope {\n\treadonly kawasekitVersion: KawasekitSessionEnvelopeVersion;\n\treadonly chainId: SupportedChainId;\n\treadonly smartAccountAddress: Address;\n\treadonly sessionKeyAddress: Address;\n\t/** Optional unix-seconds expiry. Advisory + ideally enforced by a `TimestampPolicy`. */\n\treadonly expiresAt?: bigint;\n\treadonly policySummary?: KawasekitSessionPolicySummary;\n\t/** Opaque ZeroDev `serializePermissionAccount` output. */\n\treadonly serialized: string;\n}\n\n// ---------------------------------------------------------------------------\n// Wire (JSON) shape\n// ---------------------------------------------------------------------------\n\n/**\n * Internal: the JSON shape we (de)serialize to/from. Bigint fields are stored\n * as decimal strings. Kept separate from {@link KawasekitSessionEnvelope} so\n * the public type stays bigint-friendly while the wire stays string-only.\n */\ninterface SessionEnvelopeJson {\n\treadonly kawasekitVersion: string;\n\treadonly chainId: number;\n\treadonly smartAccountAddress: string;\n\treadonly sessionKeyAddress: string;\n\treadonly expiresAt?: string;\n\treadonly policySummary?: {\n\t\treadonly jpycAddress: string;\n\t\treadonly maxPerTransfer: string;\n\t\treadonly maxTransfersPerDay: number;\n\t};\n\treadonly serialized: string;\n}\n\n// ---------------------------------------------------------------------------\n// Validation helpers\n// ---------------------------------------------------------------------------\n\nconst UINT_DECIMAL = /^(0|[1-9][0-9]*)$/;\n\nfunction assertAddress(value: unknown, field: string): Address {\n\tif (typeof value !== \"string\" || !isAddress(value, { strict: false })) {\n\t\tthrow new SessionEnvelopeParseError(`\\`${field}\\` is not a valid address: ${String(value)}`);\n\t}\n\treturn value as Address;\n}\n\nfunction assertString(value: unknown, field: string): string {\n\tif (typeof value !== \"string\" || value === \"\") {\n\t\tthrow new SessionEnvelopeParseError(`\\`${field}\\` must be a non-empty string`);\n\t}\n\treturn value;\n}\n\nfunction assertNumber(value: unknown, field: string): number {\n\tif (typeof value !== \"number\" || !Number.isFinite(value)) {\n\t\tthrow new SessionEnvelopeParseError(`\\`${field}\\` must be a finite number`);\n\t}\n\treturn value;\n}\n\nfunction parseBigIntString(value: unknown, field: string): bigint {\n\tif (typeof value !== \"string\" || !UINT_DECIMAL.test(value)) {\n\t\tthrow new SessionEnvelopeParseError(\n\t\t\t`\\`${field}\\` must be a non-negative decimal string: ${String(value)}`,\n\t\t);\n\t}\n\treturn BigInt(value);\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Serialises a {@link KawasekitSessionEnvelope} to a transportable JSON string.\n *\n * The output is plain UTF-8 JSON (no base64). Callers who need\n * URL-/header-safe transport can base64-encode the result themselves.\n *\n * @example\n * ```ts\n * import { serializeSessionEnvelope } from \"kawasekit\";\n *\n * const blob = serializeSessionEnvelope(envelope);\n * fs.writeFileSync(\"agent.session\", blob);\n * ```\n */\nexport function serializeSessionEnvelope(envelope: KawasekitSessionEnvelope): string {\n\tconst json: SessionEnvelopeJson = {\n\t\tkawasekitVersion: envelope.kawasekitVersion,\n\t\tchainId: envelope.chainId,\n\t\tsmartAccountAddress: envelope.smartAccountAddress,\n\t\tsessionKeyAddress: envelope.sessionKeyAddress,\n\t\tserialized: envelope.serialized,\n\t\t...(envelope.expiresAt !== undefined ? { expiresAt: envelope.expiresAt.toString() } : {}),\n\t\t...(envelope.policySummary !== undefined\n\t\t\t? {\n\t\t\t\t\tpolicySummary: {\n\t\t\t\t\t\tjpycAddress: envelope.policySummary.jpycAddress,\n\t\t\t\t\t\tmaxPerTransfer: envelope.policySummary.maxPerTransfer.toString(),\n\t\t\t\t\t\tmaxTransfersPerDay: envelope.policySummary.maxTransfersPerDay,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t};\n\treturn JSON.stringify(json);\n}\n\n/**\n * Parses a JSON string back into a {@link KawasekitSessionEnvelope}, asserting\n * shape and version invariants.\n *\n * @throws {SessionEnvelopeParseError} On malformed JSON or structural errors.\n * @throws {SessionEnvelopeVersionError} On `kawasekitVersion` mismatch.\n *\n * @example\n * ```ts\n * import { parseSessionEnvelope } from \"kawasekit\";\n *\n * const envelope = parseSessionEnvelope(fs.readFileSync(\"agent.session\", \"utf8\"));\n * ```\n */\nexport function parseSessionEnvelope(input: string): KawasekitSessionEnvelope {\n\tlet raw: unknown;\n\ttry {\n\t\traw = JSON.parse(input);\n\t} catch (cause) {\n\t\tthrow new SessionEnvelopeParseError(\"input is not valid JSON\", { cause });\n\t}\n\tif (raw === null || typeof raw !== \"object\" || Array.isArray(raw)) {\n\t\tthrow new SessionEnvelopeParseError(\"input is not a JSON object\");\n\t}\n\tconst obj = raw as {\n\t\tkawasekitVersion?: unknown;\n\t\tchainId?: unknown;\n\t\tsmartAccountAddress?: unknown;\n\t\tsessionKeyAddress?: unknown;\n\t\tserialized?: unknown;\n\t\texpiresAt?: unknown;\n\t\tpolicySummary?: unknown;\n\t};\n\n\tif (obj.kawasekitVersion !== KAWASEKIT_SESSION_ENVELOPE_VERSION) {\n\t\tthrow new SessionEnvelopeVersionError(KAWASEKIT_SESSION_ENVELOPE_VERSION, obj.kawasekitVersion);\n\t}\n\tconst chainIdNum = assertNumber(obj.chainId, \"chainId\");\n\tif (!isSupportedChainId(chainIdNum)) {\n\t\tthrow new SessionEnvelopeParseError(`chainId ${chainIdNum} is not a kawasekit-supported chain`);\n\t}\n\tconst chainId: SupportedChainId = chainIdNum;\n\tconst smartAccountAddress = assertAddress(obj.smartAccountAddress, \"smartAccountAddress\");\n\tconst sessionKeyAddress = assertAddress(obj.sessionKeyAddress, \"sessionKeyAddress\");\n\tconst serialized = assertString(obj.serialized, \"serialized\");\n\n\tconst expiresAt =\n\t\tobj.expiresAt !== undefined ? parseBigIntString(obj.expiresAt, \"expiresAt\") : undefined;\n\n\tlet policySummary: KawasekitSessionPolicySummary | undefined;\n\tif (obj.policySummary !== undefined) {\n\t\tif (\n\t\t\tobj.policySummary === null ||\n\t\t\ttypeof obj.policySummary !== \"object\" ||\n\t\t\tArray.isArray(obj.policySummary)\n\t\t) {\n\t\t\tthrow new SessionEnvelopeParseError(\"`policySummary` must be a JSON object\");\n\t\t}\n\t\tconst ps = obj.policySummary as {\n\t\t\tjpycAddress?: unknown;\n\t\t\tmaxPerTransfer?: unknown;\n\t\t\tmaxTransfersPerDay?: unknown;\n\t\t};\n\t\tpolicySummary = {\n\t\t\tjpycAddress: assertAddress(ps.jpycAddress, \"policySummary.jpycAddress\"),\n\t\t\tmaxPerTransfer: parseBigIntString(ps.maxPerTransfer, \"policySummary.maxPerTransfer\"),\n\t\t\tmaxTransfersPerDay: assertNumber(ps.maxTransfersPerDay, \"policySummary.maxTransfersPerDay\"),\n\t\t};\n\t}\n\n\tconst base = {\n\t\tkawasekitVersion: KAWASEKIT_SESSION_ENVELOPE_VERSION,\n\t\tchainId,\n\t\tsmartAccountAddress,\n\t\tsessionKeyAddress,\n\t\tserialized,\n\t} as const;\n\tif (expiresAt !== undefined && policySummary !== undefined) {\n\t\treturn { ...base, expiresAt, policySummary };\n\t}\n\tif (expiresAt !== undefined) {\n\t\treturn { ...base, expiresAt };\n\t}\n\tif (policySummary !== undefined) {\n\t\treturn { ...base, policySummary };\n\t}\n\treturn base;\n}\n","/**\n * `issueSessionKey()` — owner-side primitive that builds a Kernel agent\n * account and wraps ZeroDev's `serializePermissionAccount` output in a\n * {@link KawasekitSessionEnvelope}.\n *\n * The envelope is portable: callers can hand it to an agent on a different\n * machine, the agent passes it to {@link restoreSessionAccount} along with the\n * session-key private key, and it ends up holding a `KernelAccountClient`\n * scoped to the policies installed at issue time.\n *\n * The owner retains sudo authority on-chain and can revoke at any time via\n * `revokeSessionKey()` (task 2.5).\n *\n * @packageDocumentation\n */\n\nimport type { Policy } from \"@zerodev/permissions\";\nimport { serializePermissionAccount } from \"@zerodev/permissions\";\nimport { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\nimport type { EntryPointType, GetKernelVersion } from \"@zerodev/sdk/types\";\nimport type { Chain, LocalAccount, PublicClient, Transport } from \"viem\";\nimport { createAgentSmartAccount } from \"../account/session-key\";\nimport { isSupportedChainId, type SupportedChainId } from \"../chains\";\nimport {\n\tKAWASEKIT_SESSION_ENVELOPE_VERSION,\n\ttype KawasekitSessionEnvelope,\n\ttype KawasekitSessionPolicySummary,\n} from \"./envelope\";\n\n/** Parameters for {@link issueSessionKey}. */\nexport interface IssueSessionKeyParams {\n\t/**\n\t * viem `PublicClient` on the chain the smart account will live on. Its\n\t * `chain.id` MUST be a {@link SupportedChainId} and is recorded in the\n\t * envelope so restore-time mismatches fail fast.\n\t */\n\treadonly publicClient: PublicClient<Transport, Chain>;\n\t/** Owner EOA — retains sudo authority. */\n\treadonly ownerSigner: LocalAccount;\n\t/** Session-key EOA — the day-to-day signer the agent will hold. */\n\treadonly sessionKeySigner: LocalAccount;\n\t/**\n\t * Policies the session key must satisfy at userOp validation time\n\t * (e.g. {@link createJpycDailyLimitPolicies}).\n\t */\n\treadonly policies: readonly Policy[];\n\t/** Optional advisory expiry (unix seconds). Recorded in the envelope. */\n\treadonly expiresAt?: bigint;\n\t/** Optional advisory policy summary for host UI. */\n\treadonly policySummary?: KawasekitSessionPolicySummary;\n\t/** EntryPoint override. Defaults to v0.7. */\n\treadonly entryPoint?: EntryPointType<\"0.7\">;\n\t/** Kernel version override. Defaults to {@link KERNEL_V3_1}. */\n\treadonly kernelVersion?: GetKernelVersion<\"0.7\">;\n}\n\n/**\n * Issues a fresh session key for an agent smart account.\n *\n * Notes:\n * - The session-key **private key is not embedded** in the returned envelope.\n * The agent must receive the private key out-of-band; the envelope alone is\n * not enough to spend.\n * - The smart account is **not deployed** by this call. It will be deployed\n * on first userOp from `restoreSessionAccount`.\n *\n * @example\n * ```ts\n * import { parseUnits } from \"viem\";\n * import { privateKeyToAccount } from \"viem/accounts\";\n * import {\n * createJpycDailyLimitPolicies,\n * getJpycAddress,\n * issueSessionKey,\n * JPYC_DECIMALS,\n * polygonAmoy,\n * serializeSessionEnvelope,\n * } from \"kawasekit\";\n *\n * const owner = privateKeyToAccount(process.env.OWNER_PRIVATE_KEY as `0x${string}`);\n * const sessionKey = privateKeyToAccount(process.env.SESSION_KEY_PRIVATE_KEY as `0x${string}`);\n *\n * const envelope = await issueSessionKey({\n * publicClient,\n * ownerSigner: owner,\n * sessionKeySigner: sessionKey,\n * policies: createJpycDailyLimitPolicies({\n * jpycAddress: getJpycAddress(polygonAmoy.id),\n * maxPerTransfer: parseUnits(\"100\", JPYC_DECIMALS),\n * maxTransfersPerDay: 10,\n * }),\n * policySummary: {\n * jpycAddress: getJpycAddress(polygonAmoy.id),\n * maxPerTransfer: parseUnits(\"100\", JPYC_DECIMALS),\n * maxTransfersPerDay: 10,\n * },\n * });\n *\n * fs.writeFileSync(\"agent.session\", serializeSessionEnvelope(envelope));\n * ```\n */\nexport async function issueSessionKey(\n\tparams: IssueSessionKeyParams,\n): Promise<KawasekitSessionEnvelope> {\n\tconst chainId = params.publicClient.chain.id;\n\tif (!isSupportedChainId(chainId)) {\n\t\tthrow new Error(\n\t\t\t`issueSessionKey: publicClient.chain.id ${chainId} is not a kawasekit-supported chain`,\n\t\t);\n\t}\n\tconst supportedChainId: SupportedChainId = chainId;\n\tconst entryPoint = params.entryPoint ?? getEntryPoint(\"0.7\");\n\tconst kernelVersion = params.kernelVersion ?? KERNEL_V3_1;\n\n\tconst account = await createAgentSmartAccount({\n\t\tpublicClient: params.publicClient,\n\t\townerSigner: params.ownerSigner,\n\t\tsessionKeySigner: params.sessionKeySigner,\n\t\tpolicies: params.policies,\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\n\tconst serialized = await serializePermissionAccount(account);\n\n\tconst base = {\n\t\tkawasekitVersion: KAWASEKIT_SESSION_ENVELOPE_VERSION,\n\t\tchainId: supportedChainId,\n\t\tsmartAccountAddress: account.address,\n\t\tsessionKeyAddress: params.sessionKeySigner.address,\n\t\tserialized,\n\t} as const;\n\tif (params.expiresAt !== undefined && params.policySummary !== undefined) {\n\t\treturn {\n\t\t\t...base,\n\t\t\texpiresAt: params.expiresAt,\n\t\t\tpolicySummary: params.policySummary,\n\t\t};\n\t}\n\tif (params.expiresAt !== undefined) {\n\t\treturn { ...base, expiresAt: params.expiresAt };\n\t}\n\tif (params.policySummary !== undefined) {\n\t\treturn { ...base, policySummary: params.policySummary };\n\t}\n\treturn base;\n}\n","/**\n * `restoreSessionAccount()` — agent-side primitive that unwraps a\n * {@link KawasekitSessionEnvelope} back into a usable Kernel account scoped\n * to the policies installed at issue time.\n *\n * Three invariants are checked **before** touching ZeroDev's deserialization\n * so that misconfiguration manifests as a typed error here, not a confusing\n * UserOp-time revert:\n *\n * 1. `envelope.kawasekitVersion` matches the current envelope version\n * (already enforced by {@link parseSessionEnvelope}; re-checked here for\n * callers who construct the envelope object directly).\n * 2. `envelope.chainId === publicClient.chain.id`.\n * 3. `envelope.sessionKeyAddress` matches the provided `sessionKeySigner`.\n *\n * @packageDocumentation\n */\n\nimport { deserializePermissionAccount } from \"@zerodev/permissions\";\nimport { toECDSASigner } from \"@zerodev/permissions/signers\";\nimport type { CreateKernelAccountReturnType } from \"@zerodev/sdk\";\nimport { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\nimport type { EntryPointType, GetKernelVersion } from \"@zerodev/sdk/types\";\nimport { type Chain, getAddress, type LocalAccount, type PublicClient, type Transport } from \"viem\";\nimport { KAWASEKIT_SESSION_ENVELOPE_VERSION, type KawasekitSessionEnvelope } from \"./envelope\";\nimport {\n\tSessionEnvelopeChainMismatchError,\n\tSessionEnvelopeSignerMismatchError,\n\tSessionEnvelopeVersionError,\n} from \"./errors\";\n\n/** Parameters for {@link restoreSessionAccount}. */\nexport interface RestoreSessionAccountParams {\n\t/** Must be on the same chain the envelope was issued for. */\n\treadonly publicClient: PublicClient<Transport, Chain>;\n\t/** Envelope produced by {@link issueSessionKey} (or parsed via {@link parseSessionEnvelope}). */\n\treadonly envelope: KawasekitSessionEnvelope;\n\t/**\n\t * The session-key signer the agent holds. Its address MUST equal\n\t * `envelope.sessionKeyAddress` — otherwise the restored account would\n\t * sign userOps that the on-chain permission validator rejects.\n\t */\n\treadonly sessionKeySigner: LocalAccount;\n\t/** EntryPoint override. Defaults to v0.7. */\n\treadonly entryPoint?: EntryPointType<\"0.7\">;\n\t/** Kernel version override. Defaults to {@link KERNEL_V3_1}. */\n\treadonly kernelVersion?: GetKernelVersion<\"0.7\">;\n}\n\n/**\n * Rebuilds the Kernel account from an envelope + the session-key signer.\n *\n * @throws {SessionEnvelopeVersionError} If `envelope.kawasekitVersion` does\n * not match the current envelope version.\n * @throws {SessionEnvelopeChainMismatchError} If `envelope.chainId !==\n * publicClient.chain.id`.\n * @throws {SessionEnvelopeSignerMismatchError} If `sessionKeySigner.address !==\n * envelope.sessionKeyAddress`.\n *\n * @example\n * ```ts\n * import { createPublicClient, http } from \"viem\";\n * import { privateKeyToAccount } from \"viem/accounts\";\n * import {\n * parseSessionEnvelope,\n * polygonAmoy,\n * restoreSessionAccount,\n * } from \"kawasekit\";\n *\n * const publicClient = createPublicClient({\n * chain: polygonAmoy,\n * transport: http(),\n * });\n * const envelope = parseSessionEnvelope(fs.readFileSync(\"agent.session\", \"utf8\"));\n * const sessionKey = privateKeyToAccount(process.env.SESSION_KEY_PRIVATE_KEY as `0x${string}`);\n *\n * const account = await restoreSessionAccount({\n * publicClient,\n * envelope,\n * sessionKeySigner: sessionKey,\n * });\n * ```\n */\nexport async function restoreSessionAccount(\n\tparams: RestoreSessionAccountParams,\n): Promise<CreateKernelAccountReturnType<\"0.7\">> {\n\tconst { publicClient, envelope, sessionKeySigner } = params;\n\n\tif (envelope.kawasekitVersion !== KAWASEKIT_SESSION_ENVELOPE_VERSION) {\n\t\tthrow new SessionEnvelopeVersionError(\n\t\t\tKAWASEKIT_SESSION_ENVELOPE_VERSION,\n\t\t\tenvelope.kawasekitVersion,\n\t\t);\n\t}\n\tif (publicClient.chain.id !== envelope.chainId) {\n\t\tthrow new SessionEnvelopeChainMismatchError(envelope.chainId, publicClient.chain.id);\n\t}\n\tif (getAddress(sessionKeySigner.address) !== getAddress(envelope.sessionKeyAddress)) {\n\t\tthrow new SessionEnvelopeSignerMismatchError(\n\t\t\tenvelope.sessionKeyAddress,\n\t\t\tsessionKeySigner.address,\n\t\t);\n\t}\n\n\tconst entryPoint = params.entryPoint ?? getEntryPoint(\"0.7\");\n\tconst kernelVersion = params.kernelVersion ?? KERNEL_V3_1;\n\tconst modularSigner = await toECDSASigner({ signer: sessionKeySigner });\n\n\treturn deserializePermissionAccount(\n\t\tpublicClient,\n\t\tentryPoint,\n\t\tkernelVersion,\n\t\tenvelope.serialized,\n\t\tmodularSigner,\n\t);\n}\n","/**\n * `revokeSessionKey()` — owner-side primitive that uninstalls a session-key\n * permission validator from the agent's smart account.\n *\n * Implementation strategy (per plan §risk #3): ZeroDev does not expose a\n * dedicated revoke helper, so we re-derive the `PermissionPlugin` from the\n * envelope's `sessionKeyAddress` + the same policies that were installed at\n * issue time, then submit a sudo UserOp via `@zerodev/sdk`'s\n * {@link uninstallPlugin} action. After the receipt, the session key can no\n * longer sign UserOps the validator would accept.\n *\n * In-flight UserOps already submitted to the bundler but not yet mined can\n * still settle before the uninstall transaction lands. A future \"soft revoke\"\n * via `invalidateNonce` on the session-key validator's nonce key will close\n * that race; tracked for M5 (the helper signature accepts an\n * `invalidateInFlightNonces` option today and throws `\"not implemented\"` to\n * lock in the API shape). Until M5 lands, see\n * `docs/recipes/revoke-race-mitigation.md` for the four-layer operator\n * playbook (SDK call → merchant kill-switch → paymaster sponsorship\n * freeze → bundler mempool monitoring).\n *\n * @packageDocumentation\n */\n\nimport type { Policy } from \"@zerodev/permissions\";\nimport { toPermissionValidator } from \"@zerodev/permissions\";\nimport { toECDSASigner } from \"@zerodev/permissions/signers\";\nimport { uninstallPlugin } from \"@zerodev/sdk\";\nimport { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\nimport type { EntryPointType, GetKernelVersion } from \"@zerodev/sdk/types\";\nimport { getAddress, type Hash, type LocalAccount } from \"viem\";\nimport type { ConfiguredKernelClient } from \"../client/transfer-jpyc\";\nimport type { KawasekitSessionEnvelope } from \"./envelope\";\nimport { SessionEnvelopeSignerMismatchError } from \"./errors\";\n\n/** Parameters for {@link revokeSessionKey}. */\nexport interface RevokeSessionKeyParams {\n\t/**\n\t * The owner's sudo Kernel client — the only entity that can call\n\t * `uninstallValidation` on the agent account.\n\t *\n\t * **CRITICAL: must be a SUDO-ONLY kernel account** (i.e.\n\t * `createKernelAccount(publicClient, { plugins: { sudo: ecdsaValidator } })`\n\t * — no `regular` plugin). If you pass a client whose account also has the\n\t * session-key permission validator wired as `regular`, ZeroDev signs\n\t * userOps with that validator by default and the spending policy will\n\t * reject `uninstallValidation` at the validation phase (`AA23 reverted`).\n\t *\n\t * The counterfactual smart-account address only depends on the sudo\n\t * validator in Kernel v3.1, so a sudo-only client points at the SAME\n\t * account as one built with both sudo + regular.\n\t *\n\t * Its `account.address` MUST equal `envelope.smartAccountAddress`.\n\t */\n\treadonly ownerKernelClient: ConfiguredKernelClient;\n\t/** The envelope of the session being revoked. */\n\treadonly envelope: KawasekitSessionEnvelope;\n\t/**\n\t * A LocalAccount whose address equals `envelope.sessionKeyAddress`. Used\n\t * to reconstruct the validator's on-chain identifier; no signing is\n\t * actually performed with this account during revoke.\n\t */\n\treadonly sessionKeySigner: LocalAccount;\n\t/**\n\t * The policies that were installed at issue time. ZeroDev does not store\n\t * these on-chain in a retrievable form, so the caller MUST re-supply\n\t * them. Mismatches surface as an `uninstallValidation` revert at userOp\n\t * validation time.\n\t */\n\treadonly policies: readonly Policy[];\n\t/**\n\t * Future option: also invalidate the session-key validator's nonce key\n\t * to kill in-flight UserOps. Not implemented today — passing `true`\n\t * throws. Tracked for M5; see `docs/THREAT_MODEL.md` §6.3 and\n\t * `docs/recipes/revoke-race-mitigation.md` for the operator playbook to\n\t * use until then.\n\t */\n\treadonly invalidateInFlightNonces?: boolean;\n\t/** EntryPoint override. Defaults to v0.7. */\n\treadonly entryPoint?: EntryPointType<\"0.7\">;\n\t/** Kernel version override. Defaults to {@link KERNEL_V3_1}. */\n\treadonly kernelVersion?: GetKernelVersion<\"0.7\">;\n\t/**\n\t * If `false`, return after submitting the UserOp without waiting for the\n\t * bundler receipt. Default `true` (wait).\n\t */\n\treadonly waitForReceipt?: boolean;\n}\n\n/** Result of {@link revokeSessionKey}. */\nexport interface RevokeSessionKeyResult {\n\t/** Hash of the uninstall UserOp. */\n\treadonly userOpHash: Hash;\n\t/** Bundler transaction hash, present when `waitForReceipt` (default true). */\n\treadonly transactionHash: Hash | null;\n\t/** `true` if the bundler reported success, `null` if not awaited. */\n\treadonly success: boolean | null;\n}\n\n/**\n * Uninstalls a session-key permission validator from the agent's smart\n * account. After the returned UserOp lands, the session key can no longer\n * authorise actions.\n *\n * @throws {SessionEnvelopeSignerMismatchError} If `sessionKeySigner.address`\n * does not match `envelope.sessionKeyAddress`.\n * @throws {Error} If `invalidateInFlightNonces` is `true` (planned for M5;\n * see `docs/THREAT_MODEL.md` §6.3 and\n * `docs/recipes/revoke-race-mitigation.md` for the four-layer\n * operator playbook to use until then).\n *\n * @example\n * ```ts\n * import { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\n * import { createKernelAccount, createKernelAccountClient } from \"@zerodev/sdk\";\n * import { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\n * import { revokeSessionKey } from \"kawasekit\";\n *\n * // Build a SUDO-ONLY kernel account for the owner — see param JSDoc.\n * const sudoValidator = await signerToEcdsaValidator(publicClient, {\n * signer: owner,\n * entryPoint: getEntryPoint(\"0.7\"),\n * kernelVersion: KERNEL_V3_1,\n * });\n * const ownerSudoAccount = await createKernelAccount(publicClient, {\n * plugins: { sudo: sudoValidator },\n * entryPoint: getEntryPoint(\"0.7\"),\n * kernelVersion: KERNEL_V3_1,\n * });\n * const ownerKernelClient = createKernelAccountClient({\n * account: ownerSudoAccount,\n * chain,\n * client: publicClient,\n * bundlerTransport,\n * paymaster,\n * });\n *\n * await revokeSessionKey({\n * ownerKernelClient,\n * envelope,\n * sessionKeySigner,\n * policies: createJpycDailyLimitPolicies({ ... }),\n * });\n * ```\n */\nexport async function revokeSessionKey(\n\tparams: RevokeSessionKeyParams,\n): Promise<RevokeSessionKeyResult> {\n\tconst { ownerKernelClient, envelope, sessionKeySigner, policies } = params;\n\n\tif (params.invalidateInFlightNonces === true) {\n\t\tthrow new Error(\n\t\t\t\"revokeSessionKey: `invalidateInFlightNonces` is not implemented yet — the helper signature accepts the option to lock in the API shape, but in-flight nonce invalidation lands in M5. Hard revoke via uninstallPlugin is what runs today; see docs/recipes/revoke-race-mitigation.md for the four-layer operator playbook to use until then.\",\n\t\t);\n\t}\n\n\tif (getAddress(sessionKeySigner.address) !== getAddress(envelope.sessionKeyAddress)) {\n\t\tthrow new SessionEnvelopeSignerMismatchError(\n\t\t\tenvelope.sessionKeyAddress,\n\t\t\tsessionKeySigner.address,\n\t\t);\n\t}\n\n\tif (getAddress(ownerKernelClient.account.address) !== getAddress(envelope.smartAccountAddress)) {\n\t\tthrow new Error(\n\t\t\t`revokeSessionKey: ownerKernelClient is bound to ${ownerKernelClient.account.address}, but envelope is for ${envelope.smartAccountAddress}.`,\n\t\t);\n\t}\n\n\tconst entryPoint = params.entryPoint ?? getEntryPoint(\"0.7\");\n\tconst kernelVersion = params.kernelVersion ?? KERNEL_V3_1;\n\n\tif (ownerKernelClient.client === undefined) {\n\t\tthrow new Error(\n\t\t\t\"revokeSessionKey: ownerKernelClient.client is undefined — pass `client: publicClient` when constructing the Kernel client so the validator can be reconstructed.\",\n\t\t);\n\t}\n\n\tconst modularSigner = await toECDSASigner({ signer: sessionKeySigner });\n\tconst permissionPlugin = await toPermissionValidator(ownerKernelClient.client, {\n\t\tsigner: modularSigner,\n\t\tpolicies: [...policies],\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\n\tconst userOpHash = await uninstallPlugin(ownerKernelClient, {\n\t\tplugin: permissionPlugin,\n\t});\n\n\tif (params.waitForReceipt === false) {\n\t\treturn { userOpHash, transactionHash: null, success: null };\n\t}\n\n\tconst receipt = await ownerKernelClient.waitForUserOperationReceipt({\n\t\thash: userOpHash,\n\t});\n\treturn {\n\t\tuserOpHash,\n\t\ttransactionHash: receipt.receipt.transactionHash,\n\t\tsuccess: receipt.success,\n\t};\n}\n","/**\n * `rotateSessionKey()` — a thin compositional helper that revokes the\n * current session key and issues a new one in sequence.\n *\n * Compose-don't-conflate: rotate is just `revoke` followed by `issue`. Both\n * primitives are exposed individually so callers who need finer control\n * (e.g. revoke now, issue tomorrow with different policies) can chain them\n * themselves.\n *\n * @packageDocumentation\n */\n\nimport type { KawasekitSessionEnvelope } from \"./envelope\";\nimport { type IssueSessionKeyParams, issueSessionKey } from \"./issue\";\nimport {\n\ttype RevokeSessionKeyParams,\n\ttype RevokeSessionKeyResult,\n\trevokeSessionKey,\n} from \"./revoke\";\n\n/** Parameters for {@link rotateSessionKey}. */\nexport interface RotateSessionKeyParams {\n\t/** Inputs for revoking the current session. `waitForReceipt` is forced `true`. */\n\treadonly revoke: Omit<RevokeSessionKeyParams, \"waitForReceipt\">;\n\t/** Inputs for issuing the replacement session. */\n\treadonly issue: IssueSessionKeyParams;\n}\n\n/** Result of {@link rotateSessionKey}. */\nexport interface RotateSessionKeyResult {\n\t/** Outcome of the revoke step. */\n\treadonly revoke: RevokeSessionKeyResult;\n\t/** The freshly issued replacement envelope. */\n\treadonly envelope: KawasekitSessionEnvelope;\n}\n\n/**\n * Atomically rotate the agent's session key: revoke the old, issue the new.\n *\n * The revoke is always awaited to the bundler receipt — issuing a replacement\n * before the old key is actually disarmed would leave two valid signers at\n * once, defeating the point.\n *\n * @example\n * ```ts\n * import { rotateSessionKey } from \"kawasekit\";\n *\n * const { revoke, envelope } = await rotateSessionKey({\n * revoke: {\n * ownerKernelClient,\n * envelope: oldEnvelope,\n * sessionKeySigner: oldSessionKeySigner,\n * policies: oldPolicies,\n * },\n * issue: {\n * publicClient,\n * ownerSigner,\n * sessionKeySigner: newSessionKeySigner,\n * policies: newPolicies,\n * },\n * });\n * ```\n */\nexport async function rotateSessionKey(\n\tparams: RotateSessionKeyParams,\n): Promise<RotateSessionKeyResult> {\n\tconst revoke = await revokeSessionKey({ ...params.revoke, waitForReceipt: true });\n\tconst envelope = await issueSessionKey(params.issue);\n\treturn { revoke, envelope };\n}\n","/**\n * Environment loading helpers shared by every CLI command.\n *\n * The CLI loads `.env` from the current working directory (so a user can\n * `cd ~/my-agent-project && kawasekit transfer …` and have their secrets\n * picked up automatically) but every command also accepts the same value\n * as an explicit `--xxx` flag for ad-hoc use.\n */\n\nimport { config as loadDotenv } from \"dotenv\";\nimport type { Hex } from \"viem\";\n\nlet dotenvLoaded = false;\n\n/**\n * Ensure `.env` from the current working directory has been merged into\n * `process.env`. Safe to call multiple times — subsequent calls are no-ops.\n */\nexport function ensureDotenvLoaded(): void {\n\tif (dotenvLoaded) return;\n\t// `quiet: true` suppresses dotenv v17's promotional \"injecting env … (tip:\n\t// …)\" banner — a CLI loading secrets should not print to stdout, and it\n\t// otherwise leaks onto `--version` / `--help` output.\n\tloadDotenv({ override: false, quiet: true });\n\tdotenvLoaded = true;\n}\n\n/**\n * Resolve a value that may come from either an explicit CLI flag or a\n * named environment variable. Returns the flag value if present, otherwise\n * the env value, otherwise `undefined`.\n */\nexport function resolveValue(flagValue: string | undefined, envName: string): string | undefined {\n\tif (flagValue !== undefined && flagValue.trim() !== \"\") return flagValue;\n\tensureDotenvLoaded();\n\tconst raw = process.env[envName];\n\tif (raw === undefined || raw.trim() === \"\") return undefined;\n\treturn raw;\n}\n\n/**\n * Like {@link resolveValue} but throws a CLI-flavoured error if no value\n * was found. Use for inputs the command genuinely cannot proceed without.\n */\nexport function requireValue(flagValue: string | undefined, envName: string, hint: string): string {\n\tconst value = resolveValue(flagValue, envName);\n\tif (value === undefined) {\n\t\tthrow new Error(\n\t\t\t`Missing required value: pass --${hint} or set ${envName} in your environment / .env file.`,\n\t\t);\n\t}\n\treturn value;\n}\n\n/**\n * Validates a value as a 0x-prefixed 32-byte hex private key and returns it\n * typed as `Hex`. Throws with a CLI-friendly message on malformed input.\n */\nexport function asPrivateKey(value: string, source: string): Hex {\n\tif (!/^0x[0-9a-fA-F]{64}$/.test(value)) {\n\t\tthrow new Error(\n\t\t\t`${source} must be a 0x-prefixed 32-byte hex string (got ${value.length} chars).`,\n\t\t);\n\t}\n\treturn value as Hex;\n}\n\n/**\n * Resolves a required private key from a `--private-key` flag or an env var.\n */\nexport function requirePrivateKey(\n\tflagValue: string | undefined,\n\tenvName: string,\n\thint: string,\n): Hex {\n\treturn asPrivateKey(requireValue(flagValue, envName, hint), envName);\n}\n","/**\n * Chain selection shared by every CLI command that touches a network.\n *\n * Every command accepts a `--chain` flag whose value is one of the\n * kawasekit chain keys (`polygon`, `polygonAmoy`). The string is mapped to\n * the corresponding `KawaseChain` and a `network: \"mainnet\" | \"testnet\"`\n * literal that the SDK's M4-1 fail-fast guards expect.\n *\n * No default — the CLI requires an explicit choice so a user cannot silently\n * point a testnet config at mainnet (or vice versa).\n */\n\nimport { polygon, polygonAmoy } from \"../../src\";\nimport { resolveValue } from \"./env\";\n\nexport type CliChainKey = \"polygon\" | \"polygonAmoy\";\n\nexport interface CliChainProfile {\n\treadonly key: CliChainKey;\n\treadonly chain: typeof polygon | typeof polygonAmoy;\n\treadonly network: \"mainnet\" | \"testnet\";\n\treadonly explorerTxBase: string;\n\treadonly displayName: string;\n}\n\nexport function resolveChain(flagValue: string | undefined): CliChainProfile {\n\tconst key = flagValue;\n\tif (key === \"polygon\") {\n\t\treturn {\n\t\t\tkey,\n\t\t\tchain: polygon,\n\t\t\tnetwork: \"mainnet\",\n\t\t\texplorerTxBase: \"https://polygonscan.com/tx/\",\n\t\t\tdisplayName: \"Polygon mainnet (137)\",\n\t\t};\n\t}\n\tif (key === \"polygonAmoy\") {\n\t\treturn {\n\t\t\tkey,\n\t\t\tchain: polygonAmoy,\n\t\t\tnetwork: \"testnet\",\n\t\t\texplorerTxBase: \"https://amoy.polygonscan.com/tx/\",\n\t\t\tdisplayName: \"Polygon Amoy testnet (80002)\",\n\t\t};\n\t}\n\tthrow new Error(\n\t\t`--chain must be one of \"polygon\" (mainnet) or \"polygonAmoy\" (testnet). Got ${JSON.stringify(key ?? \"<missing>\")}.`,\n\t);\n}\n\n/**\n * Mainnet broadcast guard. Throws if the chosen chain is mainnet but the\n * operator has not explicitly set `KAWASEKIT_ALLOW_MAINNET=1`. CLI subcommands\n * that broadcast real-funds transactions MUST call this before any RPC work.\n */\nexport function assertMainnetGuard(profile: CliChainProfile): void {\n\tif (profile.network !== \"mainnet\") return;\n\tconst gate = resolveValue(undefined, \"KAWASEKIT_ALLOW_MAINNET\");\n\tif (gate !== \"1\") {\n\t\tthrow new Error(\n\t\t\t\"Refusing to broadcast on Polygon mainnet without explicit consent. Set KAWASEKIT_ALLOW_MAINNET=1 to acknowledge that this command will spend real funds.\",\n\t\t);\n\t}\n}\n","import { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\nimport {\n\tcreateKernelAccount,\n\tcreateKernelAccountClient,\n\tcreateZeroDevPaymasterClient,\n} from \"@zerodev/sdk\";\nimport { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\nimport type { Command } from \"commander\";\nimport { createPublicClient, http } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { zerodevRpcUrl } from \"../../src\";\nimport { assertMainnetGuard, resolveChain } from \"../lib/chain\";\nimport { requirePrivateKey, requireValue } from \"../lib/env\";\n\ninterface AccountCreateOptions {\n\treadonly chain?: string;\n\treadonly ownerPrivateKey?: string;\n\treadonly zerodevProjectId?: string;\n\treadonly deploy?: boolean;\n}\n\nasync function runAccountCreate(options: AccountCreateOptions): Promise<void> {\n\tconst profile = resolveChain(options.chain);\n\tif (options.deploy === true) {\n\t\tassertMainnetGuard(profile);\n\t}\n\n\tconst ownerKey = requirePrivateKey(\n\t\toptions.ownerPrivateKey,\n\t\t\"OWNER_PRIVATE_KEY\",\n\t\t\"owner-private-key\",\n\t);\n\tconst projectId = requireValue(\n\t\toptions.zerodevProjectId,\n\t\t\"ZERODEV_PROJECT_ID\",\n\t\t\"zerodev-project-id\",\n\t);\n\n\tconst owner = privateKeyToAccount(ownerKey);\n\tconst rpcUrl = zerodevRpcUrl(profile.chain, projectId);\n\tconst publicClient = createPublicClient({ chain: profile.chain, transport: http(rpcUrl) });\n\n\tconst entryPoint = getEntryPoint(\"0.7\");\n\tconst kernelVersion = KERNEL_V3_1;\n\tconst sudoValidator = await signerToEcdsaValidator(publicClient, {\n\t\tsigner: owner,\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\tconst account = await createKernelAccount(publicClient, {\n\t\tplugins: { sudo: sudoValidator },\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\n\tconsole.log(\"Chain: \", profile.displayName);\n\tconsole.log(\"Owner (EOA): \", owner.address);\n\tconsole.log(\"Smart account address: \", account.address);\n\n\tif (options.deploy !== true) {\n\t\tconsole.log(\n\t\t\t\"\\n(counterfactual — pass --deploy to broadcast a sponsored UserOp that deploys the account.)\",\n\t\t);\n\t\treturn;\n\t}\n\n\tconsole.log(\"\\nDeploying via a sponsored self-call UserOp...\");\n\tconst paymasterClient = createZeroDevPaymasterClient({\n\t\tchain: profile.chain,\n\t\ttransport: http(rpcUrl),\n\t});\n\tconst kernelClient = createKernelAccountClient({\n\t\taccount,\n\t\tchain: profile.chain,\n\t\tclient: publicClient,\n\t\tbundlerTransport: http(rpcUrl),\n\t\tpaymaster: {\n\t\t\tgetPaymasterData: (userOperation) => paymasterClient.sponsorUserOperation({ userOperation }),\n\t\t},\n\t});\n\tconst userOpHash = await kernelClient.sendUserOperation({\n\t\tcallData: await account.encodeCalls([{ to: account.address, value: 0n, data: \"0x\" }]),\n\t});\n\tconsole.log(\"userOp hash: \", userOpHash);\n\tconst receipt = await kernelClient.waitForUserOperationReceipt({ hash: userOpHash });\n\tconst txHash = receipt.receipt.transactionHash;\n\tconsole.log(\"bundle tx hash: \", txHash);\n\tconsole.log(\"explorer: \", `${profile.explorerTxBase}${txHash}`);\n}\n\nexport function registerAccountCommand(program: Command): void {\n\tconst account = program.command(\"account\").description(\"Smart-account lifecycle commands\");\n\n\taccount\n\t\t.command(\"create\")\n\t\t.description(\"Compute (or deploy) the smart-account address for an owner key\")\n\t\t.requiredOption(\"--chain <chain>\", '\"polygon\" | \"polygonAmoy\"')\n\t\t.option(\"--owner-private-key <hex>\", \"Owner EOA private key (or env OWNER_PRIVATE_KEY)\")\n\t\t.option(\"--zerodev-project-id <id>\", \"ZeroDev project ID (or env ZERODEV_PROJECT_ID)\")\n\t\t.option(\n\t\t\t\"--deploy\",\n\t\t\t\"Broadcast a sponsored self-call UserOp that deploys the account (mainnet requires KAWASEKIT_ALLOW_MAINNET=1)\",\n\t\t)\n\t\t.action(async (options: AccountCreateOptions) => {\n\t\t\tawait runAccountCreate(options);\n\t\t});\n}\n","import { existsSync, writeFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport type { Command } from \"commander\";\n\n/**\n * `kawasekit init` — writes a starter `.env.example` into the current\n * working directory and prints next steps. Idempotent unless `--force`.\n *\n * The starter env is intentionally narrow: only the variables a brand-new\n * kawasekit consumer needs to follow the README quick-start. Operators add\n * additional vars (X402_*, KAWASEKIT_X402_CHAIN, KAWASEKIT_ALLOW_MAINNET, …)\n * as they reach those sections of the docs.\n */\nconst STARTER_ENV_EXAMPLE = `# kawasekit — environment variables\n#\n# Copy this file to \\`.env\\` and fill in real values:\n# cp .env.example .env\n#\n# NEVER commit the real \\`.env\\` file. It is gitignored on purpose.\n\n# Private key of the smart-account OWNER (the EOA signer).\n# 0x-prefixed 32-byte hex. Use a throwaway testnet key for testnet work.\nOWNER_PRIVATE_KEY=0x...\n\n# ZeroDev project ID. Create a project at https://dashboard.zerodev.app\n# and copy its ID here. Used for bundler + paymaster sponsorship.\nZERODEV_PROJECT_ID=\n\n# Recipient of the test transfer. Defaults to the smart account itself.\n# JPYC_RECIPIENT=0x...\n`;\n\ninterface InitOptions {\n\treadonly force?: boolean;\n}\n\nasync function runInit(options: InitOptions): Promise<void> {\n\tconst targetPath = resolve(process.cwd(), \".env.example\");\n\tconst alreadyExists = existsSync(targetPath);\n\tif (alreadyExists && options.force !== true) {\n\t\tconsole.log(`.env.example already exists at ${targetPath} — pass --force to overwrite.`);\n\t\tconsole.log(`Next: copy it to .env and fill in the required values.`);\n\t\treturn;\n\t}\n\twriteFileSync(targetPath, STARTER_ENV_EXAMPLE, \"utf8\");\n\tconsole.log(`${alreadyExists ? \"Overwrote\" : \"Wrote\"} ${targetPath}`);\n\tconsole.log(`Next: copy it to .env (cp .env.example .env) and fill in the required values.`);\n}\n\nexport function registerInitCommand(program: Command): void {\n\tprogram\n\t\t.command(\"init\")\n\t\t.description(\"Scaffold a starter .env.example in the current directory\")\n\t\t.option(\"--force\", \"Overwrite an existing .env.example\")\n\t\t.action(async (options: InitOptions) => {\n\t\t\tawait runInit(options);\n\t\t});\n}\n","import type { Command } from \"commander\";\nimport { getAddress, parseUnits } from \"viem\";\nimport { createJpycDailyLimitPolicies, getJpycAddress, JPYC_DECIMALS } from \"../../src\";\nimport { resolveChain } from \"../lib/chain\";\n\ninterface PolicyCreateOptions {\n\treadonly chain?: string;\n\treadonly maxPerTx?: string;\n\treadonly maxPerDay?: string;\n\treadonly jpycAddress?: string;\n}\n\nfunction parsePositiveInt(value: string, label: string): number {\n\tconst n = Number.parseInt(value, 10);\n\tif (!Number.isFinite(n) || n <= 0) {\n\t\tthrow new Error(`${label} must be a positive integer, got ${JSON.stringify(value)}.`);\n\t}\n\treturn n;\n}\n\nasync function runPolicyCreate(options: PolicyCreateOptions): Promise<void> {\n\tconst profile = resolveChain(options.chain);\n\tconst maxPerTxHuman = options.maxPerTx ?? \"100\";\n\tconst maxPerDay = parsePositiveInt(options.maxPerDay ?? \"10\", \"--max-per-day\");\n\tconst maxPerTransfer = parseUnits(maxPerTxHuman, JPYC_DECIMALS);\n\n\tconst jpycAddress = options.jpycAddress\n\t\t? getAddress(options.jpycAddress)\n\t\t: getJpycAddress(profile.chain.id);\n\n\t// Build the actual policy array — this validates the inputs end-to-end\n\t// using the same path the SDK will at issue time, so a `policy create`\n\t// dry-run catches malformed inputs before the operator commits to issuing.\n\tconst policies = createJpycDailyLimitPolicies({\n\t\tjpycAddress,\n\t\tmaxPerTransfer,\n\t\tmaxTransfersPerDay: maxPerDay,\n\t});\n\n\tconst summary = {\n\t\tchain: profile.displayName,\n\t\tjpycAddress,\n\t\tmaxPerTransfer: {\n\t\t\thuman: maxPerTxHuman,\n\t\t\twei: maxPerTransfer.toString(),\n\t\t},\n\t\tmaxTransfersPerDay: maxPerDay,\n\t\tpolicyCount: policies.length,\n\t\tnote: \"Dry-run. No on-chain action taken. Use `kawasekit session-key issue` with the same --max-per-tx / --max-per-day to install these on a session validator.\",\n\t};\n\n\tconsole.log(JSON.stringify(summary, null, 2));\n}\n\nexport function registerPolicyCommand(program: Command): void {\n\tconst policy = program.command(\"policy\").description(\"Policy builder + inspector\");\n\tpolicy\n\t\t.command(\"create\")\n\t\t.description(\"Dry-run the daily-limit policy and print the resolved parameters as JSON\")\n\t\t.requiredOption(\"--chain <chain>\", '\"polygon\" | \"polygonAmoy\"')\n\t\t.option(\"--max-per-tx <human>\", 'Per-transfer cap in decimal JPYC. Default \"100\".')\n\t\t.option(\"--max-per-day <count>\", 'Maximum transfers per 24h window. Default \"10\".')\n\t\t.option(\n\t\t\t\"--jpyc-address <address>\",\n\t\t\t\"JPYC contract address override. Defaults to the canonical kawasekit address for the chosen chain.\",\n\t\t)\n\t\t.action(async (options: PolicyCreateOptions) => {\n\t\t\tawait runPolicyCreate(options);\n\t\t});\n}\n","import { randomBytes } from \"node:crypto\";\nimport { readFileSync, writeFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\nimport {\n\tcreateKernelAccount,\n\tcreateKernelAccountClient,\n\tcreateZeroDevPaymasterClient,\n} from \"@zerodev/sdk\";\nimport { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\nimport type { Command } from \"commander\";\nimport { createPublicClient, getAddress, type Hex, http, parseUnits } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport {\n\tcreateJpycDailyLimitPolicies,\n\tgetJpycAddress,\n\tissueSessionKey,\n\tJPYC_DECIMALS,\n\ttype KawasekitSessionEnvelope,\n\tparseSessionEnvelope,\n\trestoreSessionAccount,\n\trevokeSessionKey,\n\trotateSessionKey,\n\tserializeSessionEnvelope,\n\tzerodevRpcUrl,\n} from \"../../src\";\nimport { assertMainnetGuard, type CliChainProfile, resolveChain } from \"../lib/chain\";\nimport { asPrivateKey, requirePrivateKey, requireValue } from \"../lib/env\";\n\ninterface PolicyFlags {\n\treadonly maxPerTx?: string;\n\treadonly maxPerDay?: string;\n\treadonly jpycAddress?: string;\n}\n\nfunction buildPolicies(\n\tprofile: CliChainProfile,\n\tflags: PolicyFlags,\n): ReturnType<typeof createJpycDailyLimitPolicies> {\n\tconst jpycAddress = flags.jpycAddress\n\t\t? getAddress(flags.jpycAddress)\n\t\t: getJpycAddress(profile.chain.id);\n\tconst maxPerTransfer = parseUnits(flags.maxPerTx ?? \"100\", JPYC_DECIMALS);\n\tconst maxTransfersPerDay = Number.parseInt(flags.maxPerDay ?? \"10\", 10);\n\treturn createJpycDailyLimitPolicies({\n\t\tjpycAddress,\n\t\tmaxPerTransfer,\n\t\tmaxTransfersPerDay,\n\t});\n}\n\nfunction generateEphemeralSessionKey(): Hex {\n\treturn `0x${randomBytes(32).toString(\"hex\")}` as Hex;\n}\n\nfunction loadEnvelope(envelopePath: string): KawasekitSessionEnvelope {\n\tconst raw = readFileSync(resolve(process.cwd(), envelopePath), \"utf8\");\n\treturn parseSessionEnvelope(raw);\n}\n\n// ---------------------------------------------------------------------------\n// session-key issue\n// ---------------------------------------------------------------------------\n\ninterface IssueOptions extends PolicyFlags {\n\treadonly chain?: string;\n\treadonly ownerPrivateKey?: string;\n\treadonly zerodevProjectId?: string;\n\treadonly sessionPrivateKey?: string;\n\treadonly ephemeralSession?: boolean;\n\treadonly output?: string;\n}\n\nasync function runIssue(options: IssueOptions): Promise<void> {\n\tconst profile = resolveChain(options.chain);\n\tconst ownerKey = requirePrivateKey(\n\t\toptions.ownerPrivateKey,\n\t\t\"OWNER_PRIVATE_KEY\",\n\t\t\"owner-private-key\",\n\t);\n\tconst projectId = requireValue(\n\t\toptions.zerodevProjectId,\n\t\t\"ZERODEV_PROJECT_ID\",\n\t\t\"zerodev-project-id\",\n\t);\n\tconst sessionKey =\n\t\toptions.ephemeralSession === true\n\t\t\t? generateEphemeralSessionKey()\n\t\t\t: asPrivateKey(\n\t\t\t\t\trequireValue(options.sessionPrivateKey, \"SESSION_KEY_PRIVATE_KEY\", \"session-private-key\"),\n\t\t\t\t\t\"SESSION_KEY_PRIVATE_KEY\",\n\t\t\t\t);\n\tconst owner = privateKeyToAccount(ownerKey);\n\tconst session = privateKeyToAccount(sessionKey);\n\n\tconst rpcUrl = zerodevRpcUrl(profile.chain, projectId);\n\tconst publicClient = createPublicClient({ chain: profile.chain, transport: http(rpcUrl) });\n\tconst policies = buildPolicies(profile, options);\n\n\tconst envelope = await issueSessionKey({\n\t\tpublicClient,\n\t\townerSigner: owner,\n\t\tsessionKeySigner: session,\n\t\tpolicies,\n\t\tpolicySummary: {\n\t\t\tjpycAddress: options.jpycAddress\n\t\t\t\t? getAddress(options.jpycAddress)\n\t\t\t\t: getJpycAddress(profile.chain.id),\n\t\t\tmaxPerTransfer: parseUnits(options.maxPerTx ?? \"100\", JPYC_DECIMALS),\n\t\t\tmaxTransfersPerDay: Number.parseInt(options.maxPerDay ?? \"10\", 10),\n\t\t},\n\t});\n\n\tconst wire = serializeSessionEnvelope(envelope);\n\tconsole.log(\"Chain: \", profile.displayName);\n\tconsole.log(\"Owner (EOA): \", owner.address);\n\tconsole.log(\n\t\t\"Session key (EOA): \",\n\t\tsession.address,\n\t\toptions.ephemeralSession === true ? \"(fresh ephemeral, this run only)\" : \"\",\n\t);\n\tconsole.log(\"Smart account: \", envelope.smartAccountAddress);\n\n\tif (options.output !== undefined) {\n\t\tconst outPath = resolve(process.cwd(), options.output);\n\t\twriteFileSync(outPath, wire, \"utf8\");\n\t\tconsole.log(\"Envelope written to: \", outPath);\n\t} else {\n\t\tconsole.log(\"\\n--- envelope (JSON) ---\");\n\t\tconsole.log(wire);\n\t}\n\n\tif (options.ephemeralSession === true) {\n\t\tconsole.log(\n\t\t\t\"\\n⚠️ The ephemeral session-key private key is NOT stored anywhere. Save it now if you need to restore later:\",\n\t\t);\n\t\tconsole.log(\" SESSION_KEY_PRIVATE_KEY=\", sessionKey);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// session-key restore\n// ---------------------------------------------------------------------------\n\ninterface RestoreOptions {\n\treadonly chain?: string;\n\treadonly zerodevProjectId?: string;\n\treadonly sessionPrivateKey?: string;\n\treadonly envelope?: string;\n}\n\nasync function runRestore(options: RestoreOptions): Promise<void> {\n\tconst profile = resolveChain(options.chain);\n\tconst projectId = requireValue(\n\t\toptions.zerodevProjectId,\n\t\t\"ZERODEV_PROJECT_ID\",\n\t\t\"zerodev-project-id\",\n\t);\n\tconst sessionKey = requirePrivateKey(\n\t\toptions.sessionPrivateKey,\n\t\t\"SESSION_KEY_PRIVATE_KEY\",\n\t\t\"session-private-key\",\n\t);\n\tconst envelopePath = requireValue(options.envelope, \"KAWASEKIT_ENVELOPE_PATH\", \"envelope\");\n\tconst envelope = loadEnvelope(envelopePath);\n\n\tconst rpcUrl = zerodevRpcUrl(profile.chain, projectId);\n\tconst publicClient = createPublicClient({ chain: profile.chain, transport: http(rpcUrl) });\n\n\tconst account = await restoreSessionAccount({\n\t\tpublicClient,\n\t\tenvelope,\n\t\tsessionKeySigner: privateKeyToAccount(sessionKey),\n\t});\n\n\tconsole.log(\"Chain: \", profile.displayName);\n\tconsole.log(\"Envelope chainId: \", envelope.chainId);\n\tconsole.log(\"Envelope smart account: \", envelope.smartAccountAddress);\n\tconsole.log(\"Restored account: \", account.address);\n\tif (getAddress(account.address) !== getAddress(envelope.smartAccountAddress)) {\n\t\tthrow new Error(\n\t\t\t\"Restored account address does not match the envelope's smart-account address.\",\n\t\t);\n\t}\n\tconsole.log(\"\\n✅ Envelope restored — the agent can now sign UserOps with the session key.\");\n}\n\n// ---------------------------------------------------------------------------\n// session-key revoke\n// ---------------------------------------------------------------------------\n\ninterface RevokeOptions extends PolicyFlags {\n\treadonly chain?: string;\n\treadonly ownerPrivateKey?: string;\n\treadonly zerodevProjectId?: string;\n\treadonly sessionPrivateKey?: string;\n\treadonly envelope?: string;\n}\n\nasync function runRevoke(options: RevokeOptions): Promise<void> {\n\tconst profile = resolveChain(options.chain);\n\tassertMainnetGuard(profile);\n\n\tconst ownerKey = requirePrivateKey(\n\t\toptions.ownerPrivateKey,\n\t\t\"OWNER_PRIVATE_KEY\",\n\t\t\"owner-private-key\",\n\t);\n\tconst projectId = requireValue(\n\t\toptions.zerodevProjectId,\n\t\t\"ZERODEV_PROJECT_ID\",\n\t\t\"zerodev-project-id\",\n\t);\n\tconst sessionKey = requirePrivateKey(\n\t\toptions.sessionPrivateKey,\n\t\t\"SESSION_KEY_PRIVATE_KEY\",\n\t\t\"session-private-key\",\n\t);\n\tconst envelopePath = requireValue(options.envelope, \"KAWASEKIT_ENVELOPE_PATH\", \"envelope\");\n\tconst envelope = loadEnvelope(envelopePath);\n\n\tconst owner = privateKeyToAccount(ownerKey);\n\tconst session = privateKeyToAccount(sessionKey);\n\tconst rpcUrl = zerodevRpcUrl(profile.chain, projectId);\n\tconst publicClient = createPublicClient({ chain: profile.chain, transport: http(rpcUrl) });\n\n\t// Build a sudo-only kernel client — revoke MUST go through the ECDSA\n\t// validator, not the session-key permission validator. See SDK JSDoc in\n\t// src/session/revoke.ts.\n\tconst entryPoint = getEntryPoint(\"0.7\");\n\tconst kernelVersion = KERNEL_V3_1;\n\tconst sudoValidator = await signerToEcdsaValidator(publicClient, {\n\t\tsigner: owner,\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\tconst sudoAccount = await createKernelAccount(publicClient, {\n\t\tplugins: { sudo: sudoValidator },\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\tconst paymasterClient = createZeroDevPaymasterClient({\n\t\tchain: profile.chain,\n\t\ttransport: http(rpcUrl),\n\t});\n\tconst ownerKernelClient = createKernelAccountClient({\n\t\taccount: sudoAccount,\n\t\tchain: profile.chain,\n\t\tclient: publicClient,\n\t\tbundlerTransport: http(rpcUrl),\n\t\tpaymaster: {\n\t\t\tgetPaymasterData: (userOperation) => paymasterClient.sponsorUserOperation({ userOperation }),\n\t\t},\n\t});\n\n\tconst policies = buildPolicies(profile, options);\n\tconsole.log(\"Chain: \", profile.displayName);\n\tconsole.log(\"Owner (EOA): \", owner.address);\n\tconsole.log(\"Session key (EOA): \", session.address);\n\tconsole.log(\"Smart account: \", envelope.smartAccountAddress);\n\tconsole.log(\"\\nRevoking session validator (uninstallValidation)...\");\n\n\tconst result = await revokeSessionKey({\n\t\townerKernelClient,\n\t\tenvelope,\n\t\tsessionKeySigner: session,\n\t\tpolicies,\n\t});\n\tconsole.log(\"userOp hash: \", result.userOpHash);\n\tconsole.log(\"bundle tx hash: \", result.transactionHash);\n\tif (result.transactionHash) {\n\t\tconsole.log(\"explorer: \", `${profile.explorerTxBase}${result.transactionHash}`);\n\t}\n\tif (!result.success) {\n\t\tthrow new Error(\"Revoke UserOp reported failure.\");\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// session-key rotate\n// ---------------------------------------------------------------------------\n\ninterface RotateOptions extends PolicyFlags {\n\treadonly chain?: string;\n\treadonly ownerPrivateKey?: string;\n\treadonly zerodevProjectId?: string;\n\treadonly oldSessionPrivateKey?: string;\n\treadonly oldEnvelope?: string;\n\treadonly newSessionPrivateKey?: string;\n\treadonly ephemeralNewSession?: boolean;\n\treadonly output?: string;\n}\n\nasync function runRotate(options: RotateOptions): Promise<void> {\n\tconst profile = resolveChain(options.chain);\n\tassertMainnetGuard(profile);\n\n\tconst ownerKey = requirePrivateKey(\n\t\toptions.ownerPrivateKey,\n\t\t\"OWNER_PRIVATE_KEY\",\n\t\t\"owner-private-key\",\n\t);\n\tconst projectId = requireValue(\n\t\toptions.zerodevProjectId,\n\t\t\"ZERODEV_PROJECT_ID\",\n\t\t\"zerodev-project-id\",\n\t);\n\tconst oldSessionKey = requirePrivateKey(\n\t\toptions.oldSessionPrivateKey,\n\t\t\"SESSION_KEY_PRIVATE_KEY\",\n\t\t\"old-session-private-key\",\n\t);\n\tconst oldEnvelopePath = requireValue(\n\t\toptions.oldEnvelope,\n\t\t\"KAWASEKIT_ENVELOPE_PATH\",\n\t\t\"old-envelope\",\n\t);\n\tconst oldEnvelope = loadEnvelope(oldEnvelopePath);\n\n\tconst newSessionKey =\n\t\toptions.ephemeralNewSession === true\n\t\t\t? generateEphemeralSessionKey()\n\t\t\t: asPrivateKey(\n\t\t\t\t\trequireValue(\n\t\t\t\t\t\toptions.newSessionPrivateKey,\n\t\t\t\t\t\t\"SESSION_KEY_PRIVATE_KEY_NEW\",\n\t\t\t\t\t\t\"new-session-private-key\",\n\t\t\t\t\t),\n\t\t\t\t\t\"new session private key\",\n\t\t\t\t);\n\n\tconst owner = privateKeyToAccount(ownerKey);\n\tconst oldSession = privateKeyToAccount(oldSessionKey);\n\tconst newSession = privateKeyToAccount(newSessionKey);\n\n\tconst rpcUrl = zerodevRpcUrl(profile.chain, projectId);\n\tconst publicClient = createPublicClient({ chain: profile.chain, transport: http(rpcUrl) });\n\tconst entryPoint = getEntryPoint(\"0.7\");\n\tconst kernelVersion = KERNEL_V3_1;\n\tconst sudoValidator = await signerToEcdsaValidator(publicClient, {\n\t\tsigner: owner,\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\tconst sudoAccount = await createKernelAccount(publicClient, {\n\t\tplugins: { sudo: sudoValidator },\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\tconst paymasterClient = createZeroDevPaymasterClient({\n\t\tchain: profile.chain,\n\t\ttransport: http(rpcUrl),\n\t});\n\tconst ownerKernelClient = createKernelAccountClient({\n\t\taccount: sudoAccount,\n\t\tchain: profile.chain,\n\t\tclient: publicClient,\n\t\tbundlerTransport: http(rpcUrl),\n\t\tpaymaster: {\n\t\t\tgetPaymasterData: (userOperation) => paymasterClient.sponsorUserOperation({ userOperation }),\n\t\t},\n\t});\n\n\tconst policies = buildPolicies(profile, options);\n\tconst policySummary = {\n\t\tjpycAddress: options.jpycAddress\n\t\t\t? getAddress(options.jpycAddress)\n\t\t\t: getJpycAddress(profile.chain.id),\n\t\tmaxPerTransfer: parseUnits(options.maxPerTx ?? \"100\", JPYC_DECIMALS),\n\t\tmaxTransfersPerDay: Number.parseInt(options.maxPerDay ?? \"10\", 10),\n\t};\n\n\tconsole.log(\"Chain: \", profile.displayName);\n\tconsole.log(\"Owner (EOA): \", owner.address);\n\tconsole.log(\"Old session key (EOA): \", oldSession.address);\n\tconsole.log(\"New session key (EOA): \", newSession.address);\n\tconsole.log(\"Smart account: \", oldEnvelope.smartAccountAddress);\n\tconsole.log(\"\\nRotating: revoke old → issue new (awaits revoke receipt)...\");\n\n\tconst { revoke, envelope } = await rotateSessionKey({\n\t\trevoke: {\n\t\t\townerKernelClient,\n\t\t\tenvelope: oldEnvelope,\n\t\t\tsessionKeySigner: oldSession,\n\t\t\tpolicies,\n\t\t},\n\t\tissue: {\n\t\t\tpublicClient,\n\t\t\townerSigner: owner,\n\t\t\tsessionKeySigner: newSession,\n\t\t\tpolicies,\n\t\t\tpolicySummary,\n\t\t},\n\t});\n\tconsole.log(\"revoke userOp hash: \", revoke.userOpHash);\n\tconsole.log(\"revoke bundle tx: \", revoke.transactionHash);\n\tif (revoke.transactionHash) {\n\t\tconsole.log(\"revoke explorer: \", `${profile.explorerTxBase}${revoke.transactionHash}`);\n\t}\n\tif (!revoke.success) {\n\t\tthrow new Error(\"Revoke step failed — new envelope was NOT issued.\");\n\t}\n\n\tconst wire = serializeSessionEnvelope(envelope);\n\tif (options.output !== undefined) {\n\t\tconst outPath = resolve(process.cwd(), options.output);\n\t\twriteFileSync(outPath, wire, \"utf8\");\n\t\tconsole.log(\"\\nNew envelope written: \", outPath);\n\t} else {\n\t\tconsole.log(\"\\n--- new envelope (JSON) ---\");\n\t\tconsole.log(wire);\n\t}\n\tif (options.ephemeralNewSession === true) {\n\t\tconsole.log(\n\t\t\t\"\\n⚠️ The new ephemeral session-key private key is NOT stored anywhere. Save it now if you need to restore later:\",\n\t\t);\n\t\tconsole.log(\" SESSION_KEY_PRIVATE_KEY=\", newSessionKey);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Command registration\n// ---------------------------------------------------------------------------\n\nexport function registerSessionKeyCommand(program: Command): void {\n\tconst sessionKey = program\n\t\t.command(\"session-key\")\n\t\t.description(\"Issue / restore / revoke / rotate agent session keys\");\n\n\tsessionKey\n\t\t.command(\"issue\")\n\t\t.description(\"Owner issues a session-key envelope for the agent\")\n\t\t.requiredOption(\"--chain <chain>\", '\"polygon\" | \"polygonAmoy\"')\n\t\t.option(\"--owner-private-key <hex>\", \"Owner EOA private key (or env OWNER_PRIVATE_KEY)\")\n\t\t.option(\"--zerodev-project-id <id>\", \"ZeroDev project ID (or env ZERODEV_PROJECT_ID)\")\n\t\t.option(\n\t\t\t\"--session-private-key <hex>\",\n\t\t\t\"Session EOA private key (or env SESSION_KEY_PRIVATE_KEY)\",\n\t\t)\n\t\t.option(\n\t\t\t\"--ephemeral-session\",\n\t\t\t\"Generate a fresh ephemeral session key for this run (use for production rotation; printed at end, never stored automatically)\",\n\t\t)\n\t\t.option(\"--max-per-tx <human>\", 'Per-transfer cap in decimal JPYC. Default \"100\".')\n\t\t.option(\"--max-per-day <count>\", 'Maximum transfers per 24h window. Default \"10\".')\n\t\t.option(\n\t\t\t\"--jpyc-address <address>\",\n\t\t\t\"JPYC contract override. Defaults to the canonical kawasekit address.\",\n\t\t)\n\t\t.option(\"--output <path>\", \"Write the envelope JSON to this path instead of stdout.\")\n\t\t.action(async (options: IssueOptions) => {\n\t\t\tawait runIssue(options);\n\t\t});\n\n\tsessionKey\n\t\t.command(\"restore\")\n\t\t.description(\"Agent restores a smart-account client from an envelope file\")\n\t\t.requiredOption(\"--chain <chain>\", '\"polygon\" | \"polygonAmoy\"')\n\t\t.option(\"--zerodev-project-id <id>\", \"ZeroDev project ID (or env ZERODEV_PROJECT_ID)\")\n\t\t.option(\n\t\t\t\"--session-private-key <hex>\",\n\t\t\t\"Session EOA private key (or env SESSION_KEY_PRIVATE_KEY)\",\n\t\t)\n\t\t.option(\"--envelope <path>\", \"Path to the envelope JSON file\")\n\t\t.action(async (options: RestoreOptions) => {\n\t\t\tawait runRestore(options);\n\t\t});\n\n\tsessionKey\n\t\t.command(\"revoke\")\n\t\t.description(\"Owner revokes a session key by uninstalling its permission validator\")\n\t\t.requiredOption(\"--chain <chain>\", '\"polygon\" | \"polygonAmoy\"')\n\t\t.option(\"--owner-private-key <hex>\", \"Owner EOA private key (or env OWNER_PRIVATE_KEY)\")\n\t\t.option(\"--zerodev-project-id <id>\", \"ZeroDev project ID (or env ZERODEV_PROJECT_ID)\")\n\t\t.option(\"--session-private-key <hex>\", \"Session EOA private key the validator was issued under\")\n\t\t.option(\"--envelope <path>\", \"Path to the envelope JSON file to revoke\")\n\t\t.option(\n\t\t\t\"--max-per-tx <human>\",\n\t\t\t'Per-transfer cap (must match issue-time value). Default \"100\".',\n\t\t)\n\t\t.option(\n\t\t\t\"--max-per-day <count>\",\n\t\t\t'Daily transfer count (must match issue-time value). Default \"10\".',\n\t\t)\n\t\t.option(\"--jpyc-address <address>\", \"JPYC contract override.\")\n\t\t.action(async (options: RevokeOptions) => {\n\t\t\tawait runRevoke(options);\n\t\t});\n\n\tsessionKey\n\t\t.command(\"rotate\")\n\t\t.description(\"Revoke the old session and issue a new one in one shot (atomic-ish)\")\n\t\t.requiredOption(\"--chain <chain>\", '\"polygon\" | \"polygonAmoy\"')\n\t\t.option(\"--owner-private-key <hex>\", \"Owner EOA private key (or env OWNER_PRIVATE_KEY)\")\n\t\t.option(\"--zerodev-project-id <id>\", \"ZeroDev project ID (or env ZERODEV_PROJECT_ID)\")\n\t\t.option(\n\t\t\t\"--old-session-private-key <hex>\",\n\t\t\t\"Old session-key private key (or env SESSION_KEY_PRIVATE_KEY)\",\n\t\t)\n\t\t.option(\"--old-envelope <path>\", \"Path to the old envelope JSON file\")\n\t\t.option(\n\t\t\t\"--new-session-private-key <hex>\",\n\t\t\t\"New session-key private key (or env SESSION_KEY_PRIVATE_KEY_NEW)\",\n\t\t)\n\t\t.option(\n\t\t\t\"--ephemeral-new-session\",\n\t\t\t\"Generate a fresh ephemeral new session key for this rotation\",\n\t\t)\n\t\t.option(\"--max-per-tx <human>\", 'Per-transfer cap (same for old + new). Default \"100\".')\n\t\t.option(\"--max-per-day <count>\", 'Daily transfer count (same for old + new). Default \"10\".')\n\t\t.option(\"--jpyc-address <address>\", \"JPYC contract override.\")\n\t\t.option(\"--output <path>\", \"Write the new envelope JSON to this path.\")\n\t\t.action(async (options: RotateOptions) => {\n\t\t\tawait runRotate(options);\n\t\t});\n}\n","import { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\nimport {\n\tcreateKernelAccount,\n\tcreateKernelAccountClient,\n\tcreateZeroDevPaymasterClient,\n} from \"@zerodev/sdk\";\nimport { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\nimport type { Command } from \"commander\";\nimport { type Address, createPublicClient, getAddress, http, parseUnits } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { getJpycAddress, JPYC_DECIMALS, jpycAbi, transferJpyc, zerodevRpcUrl } from \"../../src\";\nimport { assertMainnetGuard, resolveChain } from \"../lib/chain\";\nimport { requirePrivateKey, requireValue, resolveValue } from \"../lib/env\";\n\ninterface TransferOptions {\n\treadonly chain?: string;\n\treadonly ownerPrivateKey?: string;\n\treadonly zerodevProjectId?: string;\n\treadonly to?: string;\n\treadonly amount?: string;\n}\n\nasync function runTransfer(options: TransferOptions): Promise<void> {\n\tconst profile = resolveChain(options.chain);\n\tassertMainnetGuard(profile);\n\n\tconst ownerKey = requirePrivateKey(\n\t\toptions.ownerPrivateKey,\n\t\t\"OWNER_PRIVATE_KEY\",\n\t\t\"owner-private-key\",\n\t);\n\tconst projectId = requireValue(\n\t\toptions.zerodevProjectId,\n\t\t\"ZERODEV_PROJECT_ID\",\n\t\t\"zerodev-project-id\",\n\t);\n\tconst amountHuman = options.amount ?? resolveValue(undefined, \"JPYC_AMOUNT_HUMAN\") ?? \"1\";\n\tconst amount = parseUnits(amountHuman, JPYC_DECIMALS);\n\n\tconst owner = privateKeyToAccount(ownerKey);\n\tconst rpcUrl = zerodevRpcUrl(profile.chain, projectId);\n\tconst publicClient = createPublicClient({ chain: profile.chain, transport: http(rpcUrl) });\n\tconst entryPoint = getEntryPoint(\"0.7\");\n\tconst kernelVersion = KERNEL_V3_1;\n\tconst sudoValidator = await signerToEcdsaValidator(publicClient, {\n\t\tsigner: owner,\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\tconst account = await createKernelAccount(publicClient, {\n\t\tplugins: { sudo: sudoValidator },\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\tconst paymasterClient = createZeroDevPaymasterClient({\n\t\tchain: profile.chain,\n\t\ttransport: http(rpcUrl),\n\t});\n\tconst kernelClient = createKernelAccountClient({\n\t\taccount,\n\t\tchain: profile.chain,\n\t\tclient: publicClient,\n\t\tbundlerTransport: http(rpcUrl),\n\t\tpaymaster: {\n\t\t\tgetPaymasterData: (userOperation) => paymasterClient.sponsorUserOperation({ userOperation }),\n\t\t},\n\t});\n\n\tconst jpycAddress = getJpycAddress(profile.chain.id);\n\tconst balance = (await publicClient.readContract({\n\t\taddress: jpycAddress,\n\t\tabi: jpycAbi,\n\t\tfunctionName: \"balanceOf\",\n\t\targs: [account.address],\n\t})) as bigint;\n\n\tconst recipientRaw = options.to ?? resolveValue(undefined, \"JPYC_RECIPIENT\") ?? account.address;\n\tconst recipient: Address = getAddress(recipientRaw);\n\n\tconsole.log(\"Chain: \", profile.displayName);\n\tconsole.log(\"Owner (EOA): \", owner.address);\n\tconsole.log(\"Smart account: \", account.address);\n\tconsole.log(\"JPYC contract: \", jpycAddress);\n\tconsole.log(\"Smart-account JPYC balance:\", balance.toString(), \"wei\");\n\tconsole.log(\"Recipient: \", recipient);\n\tconsole.log(\"Amount: \", amountHuman, \"JPYC =\", amount.toString(), \"wei\");\n\n\tif (amount === 0n) {\n\t\tthrow new Error(\"--amount must be greater than 0.\");\n\t}\n\tif (balance < amount) {\n\t\tthrow new Error(\n\t\t\t`Smart account has insufficient JPYC. Need ${amount.toString()} wei, has ${balance.toString()} wei. Fund ${account.address} before retrying.`,\n\t\t);\n\t}\n\n\tconsole.log(`\\nSending ${amountHuman} JPYC via sponsored UserOp...`);\n\tconst result = await transferJpyc(kernelClient, { to: recipient, amount });\n\tconsole.log(\"userOp hash: \", result.userOpHash);\n\tconsole.log(\"bundle tx hash: \", result.transactionHash);\n\tif (result.transactionHash) {\n\t\tconsole.log(\"explorer: \", `${profile.explorerTxBase}${result.transactionHash}`);\n\t}\n\tif (!result.success) {\n\t\tthrow new Error(\"UserOp reported failure — see explorer for revert reason.\");\n\t}\n}\n\nexport function registerTransferCommand(program: Command): void {\n\tprogram\n\t\t.command(\"transfer\")\n\t\t.description(\"Send JPYC from a smart account via a sponsored UserOp\")\n\t\t.requiredOption(\"--chain <chain>\", '\"polygon\" | \"polygonAmoy\"')\n\t\t.option(\"--owner-private-key <hex>\", \"Owner EOA private key (or env OWNER_PRIVATE_KEY)\")\n\t\t.option(\"--zerodev-project-id <id>\", \"ZeroDev project ID (or env ZERODEV_PROJECT_ID)\")\n\t\t.option(\n\t\t\t\"--to <address>\",\n\t\t\t\"Recipient address. Defaults to the smart account itself (loop-back) when unset.\",\n\t\t)\n\t\t.option(\"--amount <human>\", 'Amount in decimal JPYC (e.g. 0.001). Default \"1\".')\n\t\t.action(async (options: TransferOptions) => {\n\t\t\tawait runTransfer(options);\n\t\t});\n}\n","#!/usr/bin/env node\n\n/**\n * kawasekit CLI entry.\n *\n * Subcommands:\n * init — scaffold .env.example\n * account create — derive / deploy a smart account\n * transfer — send JPYC via sponsored UserOp\n * policy create — dry-run the daily-limit policy\n * session-key issue|restore|revoke|rotate\n * — agent session-key lifecycle\n *\n * Every subcommand that touches a network requires `--chain polygon|polygonAmoy`.\n * Mainnet broadcasts additionally require `KAWASEKIT_ALLOW_MAINNET=1` in the\n * environment.\n */\n\nimport { Command } from \"commander\";\nimport { registerAccountCommand } from \"./commands/account\";\nimport { registerInitCommand } from \"./commands/init\";\nimport { registerPolicyCommand } from \"./commands/policy\";\nimport { registerSessionKeyCommand } from \"./commands/session-key\";\nimport { registerTransferCommand } from \"./commands/transfer\";\n\n// `.env` is loaded lazily by resolveValue / requireValue (cli/lib/env.ts),\n// only when a command actually reads a value — so `--version` / `--help`\n// never touch the filesystem or the environment.\n//\n// __KAWASEKIT_VERSION__ is replaced at build time by tsup's `define` (see\n// tsup.config.ts) with the literal package.json version. When the CLI runs\n// from un-built source (tsx, the cli-smoke tests) the identifier is undefined;\n// the `typeof` guard avoids a ReferenceError and falls back to a dev marker.\ndeclare const __KAWASEKIT_VERSION__: string;\nconst CLI_VERSION = typeof __KAWASEKIT_VERSION__ === \"string\" ? __KAWASEKIT_VERSION__ : \"0.0.0-dev\";\n\nconst program = new Command();\nprogram\n\t.name(\"kawasekit\")\n\t.description(\n\t\t\"kawasekit — CLI for the kawasekit SDK (AI-agent stablecoin payments, Japan-first, JPYC-native).\",\n\t)\n\t.version(CLI_VERSION);\n\nregisterInitCommand(program);\nregisterAccountCommand(program);\nregisterTransferCommand(program);\nregisterPolicyCommand(program);\nregisterSessionKeyCommand(program);\n\nprogram.parseAsync().catch((error: unknown) => {\n\tconsole.error(error instanceof Error ? error.message : String(error));\n\tprocess.exitCode = 1;\n});\n"]}
1
+ {"version":3,"sources":["../../node_modules/.pnpm/dotenv@17.4.2/node_modules/dotenv/lib/main.js","../../src/account/session-key.ts","../../src/chains/avalanche.ts","../../src/chains/ethereum.ts","../../src/chains/kaia.ts","../../src/chains/polygon.ts","../../src/chains/types.ts","../../src/chains/index.ts","../../src/tokens/jpyc.ts","../../src/client/transfer-jpyc.ts","../../src/policy/daily-limit.ts","../../src/session/errors.ts","../../src/session/envelope.ts","../../src/session/issue.ts","../../src/session/restore.ts","../../src/session/revoke.ts","../../src/session/rotate.ts","../../cli/lib/env.ts","../../cli/lib/chain.ts","../../cli/commands/account.ts","../../cli/commands/init.ts","../../cli/commands/policy.ts","../../cli/commands/session-key.ts","../../cli/commands/transfer.ts","../../cli/index.ts"],"names":["path","getEntryPoint","KERNEL_V3_1","signerToEcdsaValidator","toECDSASigner","toPermissionValidator","createKernelAccount","viemAvalanche","viemAvalancheFuji","viemMainnet","viemSepolia","viemKaia","viemKairos","viemPolygon","viemPolygonAmoy","isAddress","encodeFunctionData","toCallPolicy","CallPolicyVersion","ParamCondition","toRateLimitPolicy","serializePermissionAccount","getAddress","deserializePermissionAccount","uninstallPlugin","loadDotenv","privateKeyToAccount","createPublicClient","http","createZeroDevPaymasterClient","createKernelAccountClient","program","resolve","existsSync","writeFileSync","parseUnits","randomBytes","readFileSync","Command"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,YAAA,GAAA,UAAA,CAAA;AAAA,EAAA,kEAAA,CAAA,OAAA,EAAA,MAAA,EAAA;AAAA,IAAA,IAAM,EAAA,GAAK,UAAQ,IAAI,CAAA;AACvB,IAAA,IAAM,IAAA,GAAO,UAAQ,MAAM,CAAA;AAC3B,IAAA,IAAM,EAAA,GAAK,UAAQ,IAAI,CAAA;AACvB,IAAA,IAAM,MAAA,GAAS,UAAQ,QAAQ,CAAA;AAG/B,IAAA,IAAM,IAAA,GAAO;AAAA,MACX,yCAAA;AAAA,MACA,6CAAA;AAAA,MACA,2CAAA;AAAA,MACA,sDAAA;AAAA,MACA,yCAAA;AAAA,MACA,6CAAA;AAAA,MACA,sCAAA;AAAA,MACA;AAAA,KACF;AAGA,IAAA,SAAS,aAAA,GAAiB;AACxB,MAAA,OAAO,IAAA,CAAK,KAAK,KAAA,CAAM,IAAA,CAAK,QAAO,GAAI,IAAA,CAAK,MAAM,CAAC,CAAA;AAAA,IACrD;AAEA,IAAA,SAAS,aAAc,KAAA,EAAO;AAC5B,MAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,QAAA,OAAO,CAAC,CAAC,OAAA,EAAS,GAAA,EAAK,IAAA,EAAM,KAAA,EAAO,EAAE,CAAA,CAAE,QAAA,CAAS,KAAA,CAAM,WAAA,EAAa,CAAA;AAAA,MACtE;AACA,MAAA,OAAO,QAAQ,KAAK,CAAA;AAAA,IACtB;AAEA,IAAA,SAAS,YAAA,GAAgB;AACvB,MAAA,OA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M,IAAI,MAAM,gEAA2D,CAAA;AAAA,EAC5E;AACD;AAEO,SAAS,wBAAwBS,QAAAA,EAAwB;AAC/D,EAAAA,SACE,OAAA,CAAQ,UAAU,EAClB,WAAA,CAAY,uDAAuD,EACnE,cAAA,CAAe,iBAAA,EAAmB,2BAA2B,CAAA,CAC7D,OAAO,2BAAA,EAA6B,kDAAkD,EACtF,MAAA,CAAO,2BAAA,EAA6B,gDAAgD,CAAA,CACpF,MAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,IAEA,MAAA,CAAO,kBAAA,EAAoB,mDAAmD,CAAA,CAC9E,MAAA,CAAO,OAAO,OAAA,KAA6B;AAC3C,IAAA,MAAM,YAAY,OAAO,CAAA;AAAA,EAC1B,CAAC,CAAA;AACH;;;ACzFA,IAAM,WAAA,GAA0D,OAAA,CAAwB;AAExF,IAAM,OAAA,GAAU,IAAIO,iBAAA,EAAQ;AAC5B,OAAA,CACE,IAAA,CAAK,WAAW,CAAA,CAChB,WAAA;AAAA,EACA;AACD,CAAA,CACC,QAAQ,WAAW,CAAA;AAErB,mBAAA,CAAoB,OAAO,CAAA;AAC3B,sBAAA,CAAuB,OAAO,CAAA;AAC9B,uBAAA,CAAwB,OAAO,CAAA;AAC/B,qBAAA,CAAsB,OAAO,CAAA;AAC7B,yBAAA,CAA0B,OAAO,CAAA;AAEjC,OAAA,CAAQ,UAAA,EAAW,CAAE,KAAA,CAAM,CAAC,KAAA,KAAmB;AAC9C,EAAA,OAAA,CAAQ,MAAM,KAAA,YAAiB,KAAA,GAAQ,MAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CAAC,CAAA;AACpE,EAAA,OAAA,CAAQ,QAAA,GAAW,CAAA;AACpB,CAAC,CAAA","file":"index.cjs","sourcesContent":["const fs = require('fs')\nconst path = require('path')\nconst os = require('os')\nconst crypto = require('crypto')\n\n// Array of tips to display randomly\nconst TIPS = [\n '◈ encrypted .env [www.dotenvx.com]',\n '◈ secrets for agents [www.dotenvx.com]',\n '⌁ auth for agents [www.vestauth.com]',\n '⌘ custom filepath { path: \\'/custom/path/.env\\' }',\n '⌘ enable debugging { debug: true }',\n '⌘ override existing { override: true }',\n '⌘ suppress logs { quiet: true }',\n '⌘ multiple files { path: [\\'.env.local\\', \\'.env\\'] }'\n]\n\n// Get a random tip from the tips array\nfunction _getRandomTip () {\n return TIPS[Math.floor(Math.random() * TIPS.length)]\n}\n\nfunction parseBoolean (value) {\n if (typeof value === 'string') {\n return !['false', '0', 'no', 'off', ''].includes(value.toLowerCase())\n }\n return Boolean(value)\n}\n\nfunction supportsAnsi () {\n return process.stdout.isTTY // && process.env.TERM !== 'dumb'\n}\n\nfunction dim (text) {\n return supportsAnsi() ? `\\x1b[2m${text}\\x1b[0m` : text\n}\n\nconst LINE = /(?:^|^)\\s*(?:export\\s+)?([\\w.-]+)(?:\\s*=\\s*?|:\\s+?)(\\s*'(?:\\\\'|[^'])*'|\\s*\"(?:\\\\\"|[^\"])*\"|\\s*`(?:\\\\`|[^`])*`|[^#\\r\\n]+)?\\s*(?:#.*)?(?:$|$)/mg\n\n// Parse src into an Object\nfunction parse (src) {\n const obj = {}\n\n // Convert buffer to string\n let lines = src.toString()\n\n // Convert line breaks to same format\n lines = lines.replace(/\\r\\n?/mg, '\\n')\n\n let match\n while ((match = LINE.exec(lines)) != null) {\n const key = match[1]\n\n // Default undefined or null to empty string\n let value = (match[2] || '')\n\n // Remove whitespace\n value = value.trim()\n\n // Check if double quoted\n const maybeQuote = value[0]\n\n // Remove surrounding quotes\n value = value.replace(/^(['\"`])([\\s\\S]*)\\1$/mg, '$2')\n\n // Expand newlines if double quoted\n if (maybeQuote === '\"') {\n value = value.replace(/\\\\n/g, '\\n')\n value = value.replace(/\\\\r/g, '\\r')\n }\n\n // Add to object\n obj[key] = value\n }\n\n return obj\n}\n\nfunction _parseVault (options) {\n options = options || {}\n\n const vaultPath = _vaultPath(options)\n options.path = vaultPath // parse .env.vault\n const result = DotenvModule.configDotenv(options)\n if (!result.parsed) {\n const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)\n err.code = 'MISSING_DATA'\n throw err\n }\n\n // handle scenario for comma separated keys - for use with key rotation\n // example: DOTENV_KEY=\"dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod\"\n const keys = _dotenvKey(options).split(',')\n const length = keys.length\n\n let decrypted\n for (let i = 0; i < length; i++) {\n try {\n // Get full key\n const key = keys[i].trim()\n\n // Get instructions for decrypt\n const attrs = _instructions(result, key)\n\n // Decrypt\n decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key)\n\n break\n } catch (error) {\n // last key\n if (i + 1 >= length) {\n throw error\n }\n // try next key\n }\n }\n\n // Parse decrypted .env string\n return DotenvModule.parse(decrypted)\n}\n\nfunction _warn (message) {\n console.error(`⚠ ${message}`)\n}\n\nfunction _debug (message) {\n console.log(`┆ ${message}`)\n}\n\nfunction _log (message) {\n console.log(`◇ ${message}`)\n}\n\nfunction _dotenvKey (options) {\n // prioritize developer directly setting options.DOTENV_KEY\n if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {\n return options.DOTENV_KEY\n }\n\n // secondary infra already contains a DOTENV_KEY environment variable\n if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {\n return process.env.DOTENV_KEY\n }\n\n // fallback to empty string\n return ''\n}\n\nfunction _instructions (result, dotenvKey) {\n // Parse DOTENV_KEY. Format is a URI\n let uri\n try {\n uri = new URL(dotenvKey)\n } catch (error) {\n if (error.code === 'ERR_INVALID_URL') {\n const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n throw error\n }\n\n // Get decrypt key\n const key = uri.password\n if (!key) {\n const err = new Error('INVALID_DOTENV_KEY: Missing key part')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n // Get environment\n const environment = uri.searchParams.get('environment')\n if (!environment) {\n const err = new Error('INVALID_DOTENV_KEY: Missing environment part')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n // Get ciphertext payload\n const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`\n const ciphertext = result.parsed[environmentKey] // DOTENV_VAULT_PRODUCTION\n if (!ciphertext) {\n const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)\n err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT'\n throw err\n }\n\n return { ciphertext, key }\n}\n\nfunction _vaultPath (options) {\n let possibleVaultPath = null\n\n if (options && options.path && options.path.length > 0) {\n if (Array.isArray(options.path)) {\n for (const filepath of options.path) {\n if (fs.existsSync(filepath)) {\n possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`\n }\n }\n } else {\n possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`\n }\n } else {\n possibleVaultPath = path.resolve(process.cwd(), '.env.vault')\n }\n\n if (fs.existsSync(possibleVaultPath)) {\n return possibleVaultPath\n }\n\n return null\n}\n\nfunction _resolveHome (envPath) {\n return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath\n}\n\nfunction _configVault (options) {\n const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || (options && options.debug))\n const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet))\n\n if (debug || !quiet) {\n _log('loading env from encrypted .env.vault')\n }\n\n const parsed = DotenvModule._parseVault(options)\n\n let processEnv = process.env\n if (options && options.processEnv != null) {\n processEnv = options.processEnv\n }\n\n DotenvModule.populate(processEnv, parsed, options)\n\n return { parsed }\n}\n\nfunction configDotenv (options) {\n const dotenvPath = path.resolve(process.cwd(), '.env')\n let encoding = 'utf8'\n let processEnv = process.env\n if (options && options.processEnv != null) {\n processEnv = options.processEnv\n }\n let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || (options && options.debug))\n let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || (options && options.quiet))\n\n if (options && options.encoding) {\n encoding = options.encoding\n } else {\n if (debug) {\n _debug('no encoding is specified (UTF-8 is used by default)')\n }\n }\n\n let optionPaths = [dotenvPath] // default, look for .env\n if (options && options.path) {\n if (!Array.isArray(options.path)) {\n optionPaths = [_resolveHome(options.path)]\n } else {\n optionPaths = [] // reset default\n for (const filepath of options.path) {\n optionPaths.push(_resolveHome(filepath))\n }\n }\n }\n\n // Build the parsed data in a temporary object (because we need to return it). Once we have the final\n // parsed data, we will combine it with process.env (or options.processEnv if provided).\n let lastError\n const parsedAll = {}\n for (const path of optionPaths) {\n try {\n // Specifying an encoding returns a string instead of a buffer\n const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }))\n\n DotenvModule.populate(parsedAll, parsed, options)\n } catch (e) {\n if (debug) {\n _debug(`failed to load ${path} ${e.message}`)\n }\n lastError = e\n }\n }\n\n const populated = DotenvModule.populate(processEnv, parsedAll, options)\n\n // handle user settings DOTENV_CONFIG_ options inside .env file(s)\n debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug)\n quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet)\n\n if (debug || !quiet) {\n const keysCount = Object.keys(populated).length\n const shortPaths = []\n for (const filePath of optionPaths) {\n try {\n const relative = path.relative(process.cwd(), filePath)\n shortPaths.push(relative)\n } catch (e) {\n if (debug) {\n _debug(`failed to load ${filePath} ${e.message}`)\n }\n lastError = e\n }\n }\n\n _log(`injected env (${keysCount}) from ${shortPaths.join(',')} ${dim(`// tip: ${_getRandomTip()}`)}`)\n }\n\n if (lastError) {\n return { parsed: parsedAll, error: lastError }\n } else {\n return { parsed: parsedAll }\n }\n}\n\n// Populates process.env from .env file\nfunction config (options) {\n // fallback to original dotenv if DOTENV_KEY is not set\n if (_dotenvKey(options).length === 0) {\n return DotenvModule.configDotenv(options)\n }\n\n const vaultPath = _vaultPath(options)\n\n // dotenvKey exists but .env.vault file does not exist\n if (!vaultPath) {\n _warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`)\n\n return DotenvModule.configDotenv(options)\n }\n\n return DotenvModule._configVault(options)\n}\n\nfunction decrypt (encrypted, keyStr) {\n const key = Buffer.from(keyStr.slice(-64), 'hex')\n let ciphertext = Buffer.from(encrypted, 'base64')\n\n const nonce = ciphertext.subarray(0, 12)\n const authTag = ciphertext.subarray(-16)\n ciphertext = ciphertext.subarray(12, -16)\n\n try {\n const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce)\n aesgcm.setAuthTag(authTag)\n return `${aesgcm.update(ciphertext)}${aesgcm.final()}`\n } catch (error) {\n const isRange = error instanceof RangeError\n const invalidKeyLength = error.message === 'Invalid key length'\n const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data'\n\n if (isRange || invalidKeyLength) {\n const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n } else if (decryptionFailed) {\n const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY')\n err.code = 'DECRYPTION_FAILED'\n throw err\n } else {\n throw error\n }\n }\n}\n\n// Populate process.env with parsed values\nfunction populate (processEnv, parsed, options = {}) {\n const debug = Boolean(options && options.debug)\n const override = Boolean(options && options.override)\n const populated = {}\n\n if (typeof parsed !== 'object') {\n const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')\n err.code = 'OBJECT_REQUIRED'\n throw err\n }\n\n // Set process.env\n for (const key of Object.keys(parsed)) {\n if (Object.prototype.hasOwnProperty.call(processEnv, key)) {\n if (override === true) {\n processEnv[key] = parsed[key]\n populated[key] = parsed[key]\n }\n\n if (debug) {\n if (override === true) {\n _debug(`\"${key}\" is already defined and WAS overwritten`)\n } else {\n _debug(`\"${key}\" is already defined and was NOT overwritten`)\n }\n }\n } else {\n processEnv[key] = parsed[key]\n populated[key] = parsed[key]\n }\n }\n\n return populated\n}\n\nconst DotenvModule = {\n configDotenv,\n _configVault,\n _parseVault,\n config,\n decrypt,\n parse,\n populate\n}\n\nmodule.exports.configDotenv = DotenvModule.configDotenv\nmodule.exports._configVault = DotenvModule._configVault\nmodule.exports._parseVault = DotenvModule._parseVault\nmodule.exports.config = DotenvModule.config\nmodule.exports.decrypt = DotenvModule.decrypt\nmodule.exports.parse = DotenvModule.parse\nmodule.exports.populate = DotenvModule.populate\n\nmodule.exports = DotenvModule\n","/**\n * Agent smart account = Kernel v3.1 + ECDSA sudo validator + session-key\n * permission validator.\n *\n * The owner EOA keeps full control (sudo) and can revoke / rotate the session\n * key at any time. The session key is the day-to-day signer the AI agent\n * holds; whatever policies you attach (see {@link createJpycDailyLimitPolicies})\n * are enforced at the ERC-4337 validation phase by ZeroDev's\n * `PermissionValidator`. Violating userOps revert before execution — they\n * never spend any of the smart account's funds, and a sponsored bundler\n * cannot be tricked into paying for them either.\n *\n * @packageDocumentation\n */\n\nimport { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\nimport type { Policy } from \"@zerodev/permissions\";\nimport { toPermissionValidator } from \"@zerodev/permissions\";\nimport { toECDSASigner } from \"@zerodev/permissions/signers\";\nimport type { CreateKernelAccountReturnType } from \"@zerodev/sdk\";\nimport { createKernelAccount } from \"@zerodev/sdk\";\nimport { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\nimport type { EntryPointType, GetKernelVersion } from \"@zerodev/sdk/types\";\nimport type { Chain, LocalAccount, PublicClient, Transport } from \"viem\";\n\n/** Parameters for {@link createAgentSmartAccount}. */\nexport interface CreateAgentSmartAccountParams {\n\t/**\n\t * viem `PublicClient` used to read on-chain state during account derivation.\n\t */\n\treadonly publicClient: PublicClient<Transport, Chain | undefined>;\n\t/**\n\t * The owner EOA. Retains sudo authority — can install new plugins,\n\t * revoke / rotate the session key, and bypass any policy.\n\t */\n\treadonly ownerSigner: LocalAccount;\n\t/**\n\t * The day-to-day signer the agent holds. Authority is limited to whatever\n\t * `policies` allow — by default it can do nothing.\n\t */\n\treadonly sessionKeySigner: LocalAccount;\n\t/**\n\t * ZeroDev policies (e.g. {@link createJpycDailyLimitPolicies}) the session\n\t * key must satisfy at userOp validation time.\n\t */\n\treadonly policies: readonly Policy[];\n\t/**\n\t * EntryPoint version + address. Defaults to v0.7 at the canonical\n\t * ERC-4337 entry-point address.\n\t */\n\treadonly entryPoint?: EntryPointType<\"0.7\">;\n\t/** Kernel version. Defaults to {@link KERNEL_V3_1}. */\n\treadonly kernelVersion?: GetKernelVersion<\"0.7\">;\n}\n\n/**\n * Builds a Kernel v3.1 smart account with sudo (owner) + regular (session key)\n * validators wired up.\n *\n * @example\n * ```ts\n * import { parseUnits } from \"viem\";\n * import { privateKeyToAccount } from \"viem/accounts\";\n * import {\n * createAgentSmartAccount,\n * createJpycDailyLimitPolicies,\n * getJpycAddress,\n * JPYC_DECIMALS,\n * polygonAmoy,\n * } from \"kawasekit\";\n *\n * const owner = privateKeyToAccount(process.env.OWNER_PRIVATE_KEY as `0x${string}`);\n * const sessionKey = privateKeyToAccount(process.env.SESSION_KEY_PRIVATE_KEY as `0x${string}`);\n *\n * const account = await createAgentSmartAccount({\n * publicClient,\n * ownerSigner: owner,\n * sessionKeySigner: sessionKey,\n * policies: createJpycDailyLimitPolicies({\n * jpycAddress: getJpycAddress(polygonAmoy.id),\n * maxPerTransfer: parseUnits(\"100\", JPYC_DECIMALS),\n * maxTransfersPerDay: 10,\n * }),\n * });\n * ```\n */\nexport async function createAgentSmartAccount(\n\tparams: CreateAgentSmartAccountParams,\n): Promise<CreateKernelAccountReturnType<\"0.7\">> {\n\tconst entryPoint = params.entryPoint ?? getEntryPoint(\"0.7\");\n\tconst kernelVersion = params.kernelVersion ?? KERNEL_V3_1;\n\n\tconst sudoValidator = await signerToEcdsaValidator(params.publicClient, {\n\t\tsigner: params.ownerSigner,\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\n\tconst modularSessionSigner = await toECDSASigner({ signer: params.sessionKeySigner });\n\n\tconst permissionValidator = await toPermissionValidator(params.publicClient, {\n\t\tsigner: modularSessionSigner,\n\t\tpolicies: [...params.policies],\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\n\treturn createKernelAccount(params.publicClient, {\n\t\tplugins: {\n\t\t\tsudo: sudoValidator,\n\t\t\tregular: permissionValidator,\n\t\t},\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n}\n","import { avalanche as viemAvalanche, avalancheFuji as viemAvalancheFuji } from \"viem/chains\";\nimport type { KawaseChain } from \"./types\";\n\n/**\n * Avalanche C-Chain — priority 3 production chain.\n *\n * Snowman BFT gives sub-`2 s` **deterministic finality**, so\n * `defaultConfirmations` of `2` is ample — deep confirmations add latency for\n * no extra safety. JPYC is live at the same address as the other chains.\n *\n * The x402 EOA-payer path works today; the smart-account path via ZeroDev is\n * not yet verified on Avalanche.\n */\nexport const avalanche = {\n\t...viemAvalanche,\n\tisTestnet: false,\n\tdefaultConfirmations: 2,\n\tblockTimeMs: 2_000,\n} satisfies KawaseChain;\n\n/**\n * Avalanche Fuji testnet. JPYC is live at the same address as the other chains\n * (confirmed via a read-only on-chain `name()` == \"JPY Coin\" / `symbol()` ==\n * \"JPYC\" check, 2026-05-31). Real x402 settlement here has not been exercised.\n */\nexport const avalancheFuji = {\n\t...viemAvalancheFuji,\n\tisTestnet: true,\n\tdefaultConfirmations: 1,\n\tblockTimeMs: 2_000,\n} satisfies KawaseChain;\n","import { mainnet as viemMainnet, sepolia as viemSepolia } from \"viem/chains\";\nimport type { KawaseChain } from \"./types\";\n\n/**\n * Ethereum mainnet — priority 4 production chain (institutional use cases).\n *\n * Casper FFG finalises in epochs (~12.8 min). `defaultConfirmations` of `32`\n * (~6.4 min at ~12 s blocks) gives finalised-grade safety. **Do NOT use\n * Polygon's `4` here** — 4 blocks (~48 s) is nowhere near finalised, and would\n * re-open the settle-reorg gap (threat 2.8). The facilitator auto-sizes\n * `receiptTimeoutMs` from this depth (~10 min), so the default does not time\n * out. JPYC is live at the same address as the other chains.\n */\nexport const ethereum = {\n\t...viemMainnet,\n\tisTestnet: false,\n\tdefaultConfirmations: 32,\n\tblockTimeMs: 12_000,\n} satisfies KawaseChain;\n\n/**\n * Sepolia — Ethereum testnet. JPYC is live at the same address as the other\n * chains (confirmed via a read-only on-chain `name()` == \"JPY Coin\" / `symbol()`\n * == \"JPYC\" check, 2026-05-31). Real x402 settlement here has not been exercised.\n */\nexport const sepolia = {\n\t...viemSepolia,\n\tisTestnet: true,\n\tdefaultConfirmations: 4,\n\tblockTimeMs: 12_000,\n} satisfies KawaseChain;\n","import { kaia as viemKaia, kairos as viemKairos } from \"viem/chains\";\nimport type { KawaseChain } from \"./types\";\n\n/**\n * Kaia mainnet — priority 2 production chain.\n *\n * Kaia (Klaytn + Finschia) runs IBFT consensus with **immediate finality** — a\n * single confirmed block is final — so `defaultConfirmations` is `1` (do NOT\n * copy Polygon's `4`). JPYC is live at the same address as the other chains\n * (`src/tokens/jpyc.ts`).\n *\n * Note: ZeroDev does not support Kaia, so the **smart-account path** (session\n * keys, sponsored UserOps) is not yet available here — it is planned via\n * Pimlico (M5-3 Phase 2). The **x402 EOA-payer path** works today.\n */\nexport const kaia = {\n\t...viemKaia,\n\tisTestnet: false,\n\tdefaultConfirmations: 1,\n\tblockTimeMs: 1_000,\n} satisfies KawaseChain;\n\n/**\n * Kairos — Kaia testnet. JPYC is available via the Kaia faucet at the same\n * address as mainnet; suitable for the same Amoy→Polygon-style testnet→mainnet\n * verification pattern.\n */\nexport const kairos = {\n\t...viemKairos,\n\tisTestnet: true,\n\tdefaultConfirmations: 1,\n\tblockTimeMs: 1_000,\n} satisfies KawaseChain;\n","import { polygon as viemPolygon, polygonAmoy as viemPolygonAmoy } from \"viem/chains\";\nimport type { KawaseChain } from \"./types\";\n\n/**\n * Polygon mainnet — priority 1 production chain.\n *\n * Built on viem's `polygon` definition (official RPC URLs, block explorers,\n * and `POL` native currency) plus kawasekit metadata. Polygon PoS is\n * probabilistic; the default `4` confirmations ≈ ~8 s of soft finality.\n */\nexport const polygon = {\n\t...viemPolygon,\n\tisTestnet: false,\n\tdefaultConfirmations: 4,\n\tblockTimeMs: 2_000,\n} satisfies KawaseChain;\n\n/**\n * Polygon Amoy testnet — the primary kawasekit development target.\n *\n * Built on viem's `polygonAmoy` definition. JPYC is also live on Amoy at the\n * same address as mainnet; see `src/tokens/jpyc.ts`.\n */\nexport const polygonAmoy = {\n\t...viemPolygonAmoy,\n\tisTestnet: true,\n\tdefaultConfirmations: 1,\n\tblockTimeMs: 2_000,\n} satisfies KawaseChain;\n","import type { Chain } from \"viem\";\n\n/**\n * A viem {@link Chain} extended with kawasekit-specific routing + finality\n * metadata.\n *\n * All standard chain fields (`id`, `rpcUrls`, `blockExplorers`,\n * `nativeCurrency`, …) are inherited from viem's `Chain`. kawasekit adds only\n * the fields below; per-token deployment info lives in `src/tokens/`.\n *\n * `defaultConfirmations` / `blockTimeMs` are **config-as-data**: the facilitator\n * reads them instead of branching on chain identity, so finality depth is a\n * per-chain property rather than a code path (cf. the finality-tuning recipe at\n * `docs/recipes/facilitator-finality-tuning.md`).\n *\n * @example\n * ```ts\n * import { polygon } from \"kawasekit\";\n *\n * console.log(polygon.id); // 137\n * console.log(polygon.isTestnet); // false\n * console.log(polygon.defaultConfirmations); // 4\n * ```\n */\nexport interface KawaseChain extends Chain {\n\t/** `true` for test networks, `false` for production networks. */\n\treadonly isTestnet: boolean;\n\t/**\n\t * Default settle confirmation depth for this chain (threat 2.8 / §6.6). Set\n\t * by the chain's finality model, **not** copied across chains: probabilistic\n\t * chains (Polygon) need depth; deterministic-finality chains (Avalanche\n\t * Snowman, Kaia IBFT) need `1-2`; Ethereum needs ~`32`. Operators override\n\t * via `CreateSelfFacilitatorParams.confirmations`.\n\t */\n\treadonly defaultConfirmations: number;\n\t/**\n\t * Approximate block time in milliseconds. Used to auto-size the settle\n\t * `receiptTimeoutMs` default from the confirmation depth, and as the basis\n\t * for the finality-tuning recipe's wall-time estimates.\n\t */\n\treadonly blockTimeMs: number;\n}\n\n/** Base URL of the ZeroDev v3 RPC service. */\nconst ZERODEV_RPC_BASE = \"https://rpc.zerodev.app/api/v3\";\n\n/**\n * Builds the ZeroDev v3 RPC URL for a chain.\n *\n * In ZeroDev v3 a single URL serves as **both** the ERC-4337 bundler endpoint\n * and the paymaster endpoint. Obtain a project ID from\n * {@link https://dashboard.zerodev.app}.\n *\n * Note: ZeroDev does not support every kawasekit chain (e.g. Kaia uses Pimlico\n * for the smart-account path). This helper only builds the URL string; it does\n * not assert ZeroDev availability. The x402 EOA-payer path does not use ZeroDev.\n *\n * @param chain - A kawasekit-supported chain.\n * @param projectId - ZeroDev project ID.\n * @returns Fully-qualified ZeroDev v3 RPC URL.\n *\n * @example\n * ```ts\n * import { polygonAmoy, zerodevRpcUrl } from \"kawasekit\";\n *\n * const rpc = zerodevRpcUrl(polygonAmoy, \"my-zerodev-project-id\");\n * // https://rpc.zerodev.app/api/v3/my-zerodev-project-id/chain/80002\n * ```\n */\nexport function zerodevRpcUrl(chain: KawaseChain, projectId: string): string {\n\treturn `${ZERODEV_RPC_BASE}/${projectId}/chain/${chain.id}`;\n}\n","import { avalanche, avalancheFuji } from \"./avalanche\";\nimport { ethereum, sepolia } from \"./ethereum\";\nimport { kaia, kairos } from \"./kaia\";\nimport { polygon, polygonAmoy } from \"./polygon\";\nimport { type KawaseChain, zerodevRpcUrl } from \"./types\";\n\nexport {\n\tavalanche,\n\tavalancheFuji,\n\tethereum,\n\ttype KawaseChain,\n\tkaia,\n\tkairos,\n\tpolygon,\n\tpolygonAmoy,\n\tsepolia,\n\tzerodevRpcUrl,\n};\n\n/**\n * All chains kawasekit supports, in priority order (CLAUDE.md chain priority:\n * Polygon → Kaia → Avalanche → Ethereum, each with its testnet).\n *\n * Exposed as a `readonly` tuple — **not** a `Map` — so that bundlers can\n * tree-shake chains a consumer never references.\n *\n * JPYC liveness is a separate axis (`src/tokens/jpyc.ts`): a chain can be\n * supported here while JPYC is not yet live on it (Avalanche Fuji / Sepolia).\n *\n * @example\n * ```ts\n * import { supportedChains } from \"kawasekit\";\n *\n * for (const chain of supportedChains) {\n * \tconsole.log(chain.id, chain.name);\n * }\n * ```\n */\nexport const supportedChains = [\n\tpolygon,\n\tpolygonAmoy,\n\tkaia,\n\tkairos,\n\tavalanche,\n\tavalancheFuji,\n\tethereum,\n\tsepolia,\n] as const;\n\n/**\n * Union of every chain ID kawasekit supports\n * (`137 | 80002 | 8217 | 1001 | 43114 | 43113 | 1 | 11155111`).\n *\n * Derived from {@link supportedChains}, so adding a chain there extends this\n * type automatically.\n */\nexport type SupportedChainId = (typeof supportedChains)[number][\"id\"];\n\n/** A single member of {@link supportedChains}, with its literal `id`. */\ntype SupportedChain = (typeof supportedChains)[number];\n\n/**\n * Internal chain lookup, built once at module scope.\n *\n * This `Map` is an implementation detail and is intentionally **not**\n * exported: the public API exposes the {@link supportedChains} tuple instead,\n * so importing one chain does not pull in all of them.\n */\nconst chainsById: ReadonlyMap<number, SupportedChain> = new Map(\n\tsupportedChains.map((chain) => [chain.id, chain]),\n);\n\n/**\n * Error thrown when a chain ID kawasekit does not support is requested.\n *\n * @example\n * ```ts\n * import { ChainNotSupportedError, getChain } from \"kawasekit\";\n *\n * try {\n * \tgetChain(1);\n * } catch (error) {\n * \tif (error instanceof ChainNotSupportedError) {\n * \t\tconsole.error(error.message);\n * \t}\n * }\n * ```\n */\nexport class ChainNotSupportedError extends Error {\n\tconstructor(chainId: number) {\n\t\tconst supported = supportedChains.map((chain) => chain.id).join(\", \");\n\t\tsuper(\n\t\t\t`Chain ID ${chainId} is not supported by kawasekit. ` + `Supported chain IDs: ${supported}.`,\n\t\t);\n\t\tthis.name = \"ChainNotSupportedError\";\n\t}\n}\n\n/**\n * Type guard that narrows an arbitrary chain ID to a {@link SupportedChainId}.\n *\n * @param chainId - The numeric chain ID to test.\n * @returns `true` if kawasekit supports this chain ID.\n *\n * @example\n * ```ts\n * import { isSupportedChainId } from \"kawasekit\";\n *\n * const id = 80002;\n * if (isSupportedChainId(id)) {\n * \t// `id` is now narrowed to SupportedChainId\n * }\n * ```\n */\nexport function isSupportedChainId(chainId: number): chainId is SupportedChainId {\n\treturn chainsById.has(chainId);\n}\n\n/**\n * Looks up a supported chain by its numeric chain ID.\n *\n * The returned chain's `id` is narrowed to {@link SupportedChainId}.\n *\n * @param chainId - The numeric chain ID to look up.\n * @returns The matching {@link KawaseChain}.\n * @throws {ChainNotSupportedError} If `chainId` is not supported.\n *\n * @example\n * ```ts\n * import { getChain } from \"kawasekit\";\n *\n * const chain = getChain(80002); // Polygon Amoy\n * console.log(chain.name);\n * ```\n */\nexport function getChain(chainId: number): SupportedChain {\n\tconst chain = chainsById.get(chainId);\n\tif (chain === undefined) {\n\t\tthrow new ChainNotSupportedError(chainId);\n\t}\n\treturn chain;\n}\n","/**\n * JPYC stablecoin metadata, deployments, and ABI.\n *\n * JPYC is a Japanese yen-pegged stablecoin issued by JPYC Inc. under the\n * revised Payment Services Act as 電子決済手段 (electronic payment\n * instrument). The new (\"v2\") JPYC, launched 2025-10, lives at the same\n * address on every chain where it is deployed.\n *\n * @packageDocumentation\n */\n\nimport type { Address } from \"viem\";\nimport type { SupportedChainId } from \"../chains\";\nimport {\n\tavalanche,\n\tavalancheFuji,\n\tethereum,\n\tkaia,\n\tkairos,\n\tpolygon,\n\tpolygonAmoy,\n\tsepolia,\n} from \"../chains\";\n\n/** ERC-20 decimals for JPYC. Constant across every chain. */\nexport const JPYC_DECIMALS = 18;\n\n/**\n * EIP-712 domain hint for off-chain authorization signing (EIP-3009, EIP-2612).\n *\n * The real JPYC contract does not expose `version()` publicly — it lives in an\n * `internal VERSION` state variable set during proxy initialization. The\n * canonical value is `\"1\"`, matching the FiatToken lineage; the\n * {@link signTransferWithAuthorization} helper accepts an override if a future\n * deployment changes this.\n *\n * `name` is \"JPY Coin\" — the on-chain `name()` value on every live deployment.\n */\nexport const JPYC_EIP712_DOMAIN_HINT = {\n\tname: \"JPY Coin\",\n\tversion: \"1\",\n} as const;\n\n/**\n * Address shared by every live JPYC deployment.\n *\n * Verified on:\n * - Ethereum : https://etherscan.io/token/0xE7C3D8C9a439feDe00D2600032D5dB0Be71C3c29\n * - Polygon : https://polygonscan.com/token/0xe7c3d8c9a439fede00d2600032d5db0be71c3c29\n * - Polygon Amoy : https://amoy.polygonscan.com/token/0xe7c3d8c9a439fede00d2600032d5db0be71c3c29\n * - Avalanche : https://snowtrace.io/token/0xE7C3D8C9a439feDe00D2600032D5dB0Be71C3c29\n *\n * Do NOT confuse with the legacy 前払式支払手段 JPYC at `0x431D5dFF...`.\n */\nexport const JPYC_V2_ADDRESS: Address = \"0xE7C3D8C9a439feDe00D2600032D5dB0Be71C3c29\";\n\n/** A JPYC deployment on a single chain. */\nexport interface JpycDeployment {\n\treadonly chainId: SupportedChainId;\n\treadonly address: Address;\n\t/** `true` if the token is live on this chain right now. */\n\treadonly isLive: boolean;\n}\n\n/**\n * JPYC deployments keyed by chain.\n *\n * JPYC v2 uses the **same address** (`JPYC_V2_ADDRESS`) on every chain where it\n * is live. `isLive` is the separate \"is JPYC actually deployed here yet?\" axis.\n * All eight supported chains are live at this address: the four mainnets\n * (Polygon, Kaia, Avalanche, Ethereum) + Amoy + Kairos + Avalanche Fuji +\n * Sepolia. Kaia/Kairos/Avalanche/Fuji/Sepolia were confirmed by a read-only\n * on-chain check (`name() == \"JPY Coin\"`, `symbol() == \"JPYC\"` at `0xE7C3…`,\n * 2026-05-31); Polygon/Amoy/Ethereum are established. `isLive: false` + the\n * {@link JpycNotAvailableError} path remain for any future chain added before\n * its JPYC deployment lands.\n */\nexport const jpycDeployments: { readonly [chainId in SupportedChainId]: JpycDeployment } = {\n\t[polygon.id]: { chainId: polygon.id, address: JPYC_V2_ADDRESS, isLive: true },\n\t[polygonAmoy.id]: { chainId: polygonAmoy.id, address: JPYC_V2_ADDRESS, isLive: true },\n\t[kaia.id]: { chainId: kaia.id, address: JPYC_V2_ADDRESS, isLive: true },\n\t[kairos.id]: { chainId: kairos.id, address: JPYC_V2_ADDRESS, isLive: true },\n\t[avalanche.id]: { chainId: avalanche.id, address: JPYC_V2_ADDRESS, isLive: true },\n\t[ethereum.id]: { chainId: ethereum.id, address: JPYC_V2_ADDRESS, isLive: true },\n\t[avalancheFuji.id]: { chainId: avalancheFuji.id, address: JPYC_V2_ADDRESS, isLive: true },\n\t[sepolia.id]: { chainId: sepolia.id, address: JPYC_V2_ADDRESS, isLive: true },\n};\n\n/**\n * Thrown when JPYC is not deployed on the requested chain.\n *\n * Today this is unreachable (every {@link SupportedChainId} has a live\n * deployment), but the error class is exported for future chains (Kaia) where\n * JPYC is still in development.\n */\nexport class JpycNotAvailableError extends Error {\n\tconstructor(chainId: number) {\n\t\tsuper(`JPYC is not yet deployed on chain ID ${chainId}.`);\n\t\tthis.name = \"JpycNotAvailableError\";\n\t}\n}\n\n/**\n * Returns the JPYC contract address for a kawasekit-supported chain.\n *\n * @param chainId - A {@link SupportedChainId}.\n * @returns The JPYC contract address on that chain.\n * @throws {JpycNotAvailableError} If JPYC is not live on the chain.\n *\n * @example\n * ```ts\n * import { getJpycAddress, polygonAmoy } from \"kawasekit\";\n *\n * const address = getJpycAddress(polygonAmoy.id);\n * ```\n */\nexport function getJpycAddress(chainId: SupportedChainId): Address {\n\tconst deployment = jpycDeployments[chainId];\n\tif (!deployment.isLive) {\n\t\tthrow new JpycNotAvailableError(chainId);\n\t}\n\treturn deployment.address;\n}\n\n/**\n * Minimal JPYC ABI: ERC-20 + EIP-3009 surface that kawasekit needs.\n *\n * Excludes permit / mint / blocklist / pause — kawasekit only reads balance,\n * sends `transfer()` via UserOp, and constructs / submits EIP-3009\n * authorizations. Bringing in the full FiatTokenV1 ABI would be wasted bytes.\n */\nexport const jpycAbi = [\n\t// ----- ERC-20 read -----\n\t{\n\t\ttype: \"function\",\n\t\tname: \"name\",\n\t\tstateMutability: \"view\",\n\t\tinputs: [],\n\t\toutputs: [{ name: \"\", type: \"string\" }],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"symbol\",\n\t\tstateMutability: \"view\",\n\t\tinputs: [],\n\t\toutputs: [{ name: \"\", type: \"string\" }],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"decimals\",\n\t\tstateMutability: \"view\",\n\t\tinputs: [],\n\t\toutputs: [{ name: \"\", type: \"uint8\" }],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"totalSupply\",\n\t\tstateMutability: \"view\",\n\t\tinputs: [],\n\t\toutputs: [{ name: \"\", type: \"uint256\" }],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"balanceOf\",\n\t\tstateMutability: \"view\",\n\t\tinputs: [{ name: \"account\", type: \"address\" }],\n\t\toutputs: [{ name: \"\", type: \"uint256\" }],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"allowance\",\n\t\tstateMutability: \"view\",\n\t\tinputs: [\n\t\t\t{ name: \"owner\", type: \"address\" },\n\t\t\t{ name: \"spender\", type: \"address\" },\n\t\t],\n\t\toutputs: [{ name: \"\", type: \"uint256\" }],\n\t},\n\t// ----- ERC-20 write -----\n\t{\n\t\ttype: \"function\",\n\t\tname: \"transfer\",\n\t\tstateMutability: \"nonpayable\",\n\t\tinputs: [\n\t\t\t{ name: \"to\", type: \"address\" },\n\t\t\t{ name: \"value\", type: \"uint256\" },\n\t\t],\n\t\toutputs: [{ name: \"\", type: \"bool\" }],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"transferFrom\",\n\t\tstateMutability: \"nonpayable\",\n\t\tinputs: [\n\t\t\t{ name: \"from\", type: \"address\" },\n\t\t\t{ name: \"to\", type: \"address\" },\n\t\t\t{ name: \"value\", type: \"uint256\" },\n\t\t],\n\t\toutputs: [{ name: \"\", type: \"bool\" }],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"approve\",\n\t\tstateMutability: \"nonpayable\",\n\t\tinputs: [\n\t\t\t{ name: \"spender\", type: \"address\" },\n\t\t\t{ name: \"value\", type: \"uint256\" },\n\t\t],\n\t\toutputs: [{ name: \"\", type: \"bool\" }],\n\t},\n\t// ----- EIP-3009 -----\n\t{\n\t\ttype: \"function\",\n\t\tname: \"transferWithAuthorization\",\n\t\tstateMutability: \"nonpayable\",\n\t\tinputs: [\n\t\t\t{ name: \"from\", type: \"address\" },\n\t\t\t{ name: \"to\", type: \"address\" },\n\t\t\t{ name: \"value\", type: \"uint256\" },\n\t\t\t{ name: \"validAfter\", type: \"uint256\" },\n\t\t\t{ name: \"validBefore\", type: \"uint256\" },\n\t\t\t{ name: \"nonce\", type: \"bytes32\" },\n\t\t\t{ name: \"v\", type: \"uint8\" },\n\t\t\t{ name: \"r\", type: \"bytes32\" },\n\t\t\t{ name: \"s\", type: \"bytes32\" },\n\t\t],\n\t\toutputs: [],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"receiveWithAuthorization\",\n\t\tstateMutability: \"nonpayable\",\n\t\tinputs: [\n\t\t\t{ name: \"from\", type: \"address\" },\n\t\t\t{ name: \"to\", type: \"address\" },\n\t\t\t{ name: \"value\", type: \"uint256\" },\n\t\t\t{ name: \"validAfter\", type: \"uint256\" },\n\t\t\t{ name: \"validBefore\", type: \"uint256\" },\n\t\t\t{ name: \"nonce\", type: \"bytes32\" },\n\t\t\t{ name: \"v\", type: \"uint8\" },\n\t\t\t{ name: \"r\", type: \"bytes32\" },\n\t\t\t{ name: \"s\", type: \"bytes32\" },\n\t\t],\n\t\toutputs: [],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"cancelAuthorization\",\n\t\tstateMutability: \"nonpayable\",\n\t\tinputs: [\n\t\t\t{ name: \"authorizer\", type: \"address\" },\n\t\t\t{ name: \"nonce\", type: \"bytes32\" },\n\t\t\t{ name: \"v\", type: \"uint8\" },\n\t\t\t{ name: \"r\", type: \"bytes32\" },\n\t\t\t{ name: \"s\", type: \"bytes32\" },\n\t\t],\n\t\toutputs: [],\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tname: \"authorizationState\",\n\t\tstateMutability: \"view\",\n\t\tinputs: [\n\t\t\t{ name: \"authorizer\", type: \"address\" },\n\t\t\t{ name: \"nonce\", type: \"bytes32\" },\n\t\t],\n\t\toutputs: [{ name: \"\", type: \"bool\" }],\n\t},\n\t// ----- Events kawasekit needs to decode -----\n\t{\n\t\ttype: \"event\",\n\t\tname: \"Transfer\",\n\t\tinputs: [\n\t\t\t{ name: \"from\", type: \"address\", indexed: true },\n\t\t\t{ name: \"to\", type: \"address\", indexed: true },\n\t\t\t{ name: \"value\", type: \"uint256\", indexed: false },\n\t\t],\n\t},\n\t{\n\t\ttype: \"event\",\n\t\tname: \"Approval\",\n\t\tinputs: [\n\t\t\t{ name: \"owner\", type: \"address\", indexed: true },\n\t\t\t{ name: \"spender\", type: \"address\", indexed: true },\n\t\t\t{ name: \"value\", type: \"uint256\", indexed: false },\n\t\t],\n\t},\n\t{\n\t\ttype: \"event\",\n\t\tname: \"AuthorizationUsed\",\n\t\tinputs: [\n\t\t\t{ name: \"authorizer\", type: \"address\", indexed: true },\n\t\t\t{ name: \"nonce\", type: \"bytes32\", indexed: true },\n\t\t],\n\t},\n\t{\n\t\ttype: \"event\",\n\t\tname: \"AuthorizationCanceled\",\n\t\tinputs: [\n\t\t\t{ name: \"authorizer\", type: \"address\", indexed: true },\n\t\t\t{ name: \"nonce\", type: \"bytes32\", indexed: true },\n\t\t],\n\t},\n] as const;\n","/**\n * High-level helper: transfer JPYC from a Kernel smart account via a sponsored\n * UserOp.\n *\n * This is the canonical \"agent payment\" path for M2. The flow:\n * 1. Resolve the JPYC contract address for `kernelClient.chain`.\n * 2. Encode `JPYC.transfer(to, amount)` calldata.\n * 3. Wrap it as a Kernel call and submit via `sendUserOperation`.\n * 4. Wait for the bundler receipt and return both hashes.\n *\n * EIP-3009 `transferWithAuthorization` cannot be used here: JPYC's signature\n * verification is pure `ecrecover`, so a smart account cannot be `from`. See\n * `src/tokens/eip3009.ts` for the EOA-payer path.\n *\n * @packageDocumentation\n */\n\nimport type { KernelAccountClient } from \"@zerodev/sdk\";\nimport type { Address, Chain, Hex, Transport } from \"viem\";\nimport { encodeFunctionData, isAddress } from \"viem\";\nimport type { SmartAccount } from \"viem/account-abstraction\";\nimport { isSupportedChainId, type SupportedChainId } from \"../chains\";\nimport { getJpycAddress, jpycAbi } from \"../tokens/jpyc\";\n\n/** A {@link KernelAccountClient} that is fully configured (chain + account). */\nexport type ConfiguredKernelClient = KernelAccountClient<Transport, Chain, SmartAccount>;\n\n/** Parameters for {@link transferJpyc}. */\nexport interface TransferJpycParams {\n\t/** Recipient address. */\n\treadonly to: Address;\n\t/**\n\t * Raw token amount in the token's smallest unit (JPYC has 18 decimals).\n\t *\n\t * @example\n\t * ```ts\n\t * import { parseUnits } from \"viem\";\n\t * import { JPYC_DECIMALS } from \"kawasekit\";\n\t *\n\t * parseUnits(\"100\", JPYC_DECIMALS); // 100 JPYC\n\t * ```\n\t */\n\treadonly amount: bigint;\n\t/**\n\t * Optional. Defaults to waiting for the bundler receipt before returning.\n\t * Set to `false` to return after the UserOp is submitted but before it\n\t * lands on chain — useful when the caller wants to do its own polling.\n\t */\n\treadonly waitForReceipt?: boolean;\n}\n\n/** Result of a {@link transferJpyc} call. */\nexport interface TransferJpycResult {\n\treadonly userOpHash: Hex;\n\t/** `null` when `waitForReceipt: false` was requested. */\n\treadonly transactionHash: Hex | null;\n\t/** `true` if the bundler receipt reported success; `null` if not awaited. */\n\treadonly success: boolean | null;\n}\n\n/** Thrown when {@link transferJpyc} is called with invalid arguments. */\nexport class TransferJpycInputError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(`transferJpyc: ${message}`);\n\t\tthis.name = \"TransferJpycInputError\";\n\t}\n}\n\n/**\n * Transfer JPYC from the Kernel smart account to `to` via a sponsored UserOp.\n *\n * @example\n * ```ts\n * import { parseUnits } from \"viem\";\n * import { JPYC_DECIMALS, transferJpyc } from \"kawasekit\";\n *\n * const { userOpHash, transactionHash } = await transferJpyc(kernelClient, {\n * to: \"0xBeef0000000000000000000000000000DEADBEEF\",\n * amount: parseUnits(\"100\", JPYC_DECIMALS),\n * });\n * ```\n */\nexport async function transferJpyc(\n\tkernelClient: ConfiguredKernelClient,\n\tparams: TransferJpycParams,\n): Promise<TransferJpycResult> {\n\tif (!isAddress(params.to, { strict: false })) {\n\t\tthrow new TransferJpycInputError(`\\`to\\` is not a valid address: ${params.to}`);\n\t}\n\tif (params.amount <= 0n) {\n\t\tthrow new TransferJpycInputError(`\\`amount\\` must be positive, got ${params.amount}.`);\n\t}\n\n\tconst chainId = kernelClient.chain.id;\n\tif (!isSupportedChainId(chainId)) {\n\t\tthrow new TransferJpycInputError(`Chain ID ${chainId} is not a kawasekit-supported chain.`);\n\t}\n\tconst jpycAddress = getJpycAddress(chainId satisfies SupportedChainId);\n\n\tconst data = encodeFunctionData({\n\t\tabi: jpycAbi,\n\t\tfunctionName: \"transfer\",\n\t\targs: [params.to, params.amount],\n\t});\n\n\tconst callData = await kernelClient.account.encodeCalls([{ to: jpycAddress, value: 0n, data }]);\n\n\tconst userOpHash = await kernelClient.sendUserOperation({ callData });\n\n\tif (params.waitForReceipt === false) {\n\t\treturn { userOpHash, transactionHash: null, success: null };\n\t}\n\n\tconst receipt = await kernelClient.waitForUserOperationReceipt({ hash: userOpHash });\n\treturn {\n\t\tuserOpHash,\n\t\ttransactionHash: receipt.receipt.transactionHash,\n\t\tsuccess: receipt.success,\n\t};\n}\n","/**\n * Daily-limit spending policy for JPYC, built on ZeroDev's Permission System.\n *\n * Composes two ZeroDev policies:\n * 1. **callPolicy** — locks the session key to `JPYC.transfer(to, value)`\n * with `value ≤ maxPerTransfer`. Recipient is unrestricted in M2;\n * add allowlisting in M3 when use cases firm up.\n * 2. **rateLimitPolicy** — caps userOp count to `maxTransfersPerDay` in any\n * 24-hour rolling window.\n *\n * Effective daily cap = `maxPerTransfer × maxTransfersPerDay`. This is not a\n * cumulative-amount tracker (ZeroDev doesn't ship one), but the agent cannot\n * exceed either dimension, so the spirit of \"daily limit\" holds.\n *\n * @packageDocumentation\n */\n\nimport type { Policy } from \"@zerodev/permissions\";\nimport {\n\tCallPolicyVersion,\n\tParamCondition,\n\ttoCallPolicy,\n\ttoRateLimitPolicy,\n} from \"@zerodev/permissions/policies\";\nimport type { Address } from \"viem\";\nimport { jpycAbi } from \"../tokens/jpyc\";\n\n/** One day in seconds — the period for {@link createJpycDailyLimitPolicies}. */\nexport const ONE_DAY_SECONDS = 86_400;\n\n/** Parameters for {@link createJpycDailyLimitPolicies}. */\nexport interface CreateJpycDailyLimitPoliciesParams {\n\t/** JPYC contract address on the target chain. */\n\treadonly jpycAddress: Address;\n\t/** Maximum JPYC (in raw units) the session key may move in one transfer. */\n\treadonly maxPerTransfer: bigint;\n\t/** Maximum number of transfer userOps the session key may submit per day. */\n\treadonly maxTransfersPerDay: number;\n\t/**\n\t * ZeroDev callPolicy on-chain version. Defaults to V0_0_4 (latest at the\n\t * time of writing). Bump only after auditing the new version's semantics.\n\t */\n\treadonly callPolicyVersion?: CallPolicyVersion;\n}\n\n/**\n * Builds the ZeroDev policy bundle that enforces a JPYC daily spend limit.\n *\n * Plug the returned policies into `toPermissionValidator({ policies, … })`\n * — see {@link createAgentSmartAccount} for the common wiring.\n *\n * @example\n * ```ts\n * import { parseUnits } from \"viem\";\n * import {\n * createJpycDailyLimitPolicies,\n * getJpycAddress,\n * JPYC_DECIMALS,\n * polygonAmoy,\n * } from \"kawasekit\";\n *\n * const policies = createJpycDailyLimitPolicies({\n * jpycAddress: getJpycAddress(polygonAmoy.id),\n * maxPerTransfer: parseUnits(\"100\", JPYC_DECIMALS), // 100 JPYC / tx\n * maxTransfersPerDay: 10, // 10 tx / day\n * // effective daily cap = 1000 JPYC\n * });\n * ```\n */\nexport function createJpycDailyLimitPolicies(\n\tparams: CreateJpycDailyLimitPoliciesParams,\n): readonly [Policy, Policy] {\n\tif (params.maxPerTransfer <= 0n) {\n\t\tthrow new Error(\n\t\t\t`createJpycDailyLimitPolicies: maxPerTransfer must be positive, got ${params.maxPerTransfer}.`,\n\t\t);\n\t}\n\tif (!Number.isInteger(params.maxTransfersPerDay) || params.maxTransfersPerDay < 1) {\n\t\tthrow new Error(\n\t\t\t`createJpycDailyLimitPolicies: maxTransfersPerDay must be a positive integer, got ${params.maxTransfersPerDay}.`,\n\t\t);\n\t}\n\n\tconst callPolicy = toCallPolicy({\n\t\tpolicyVersion: params.callPolicyVersion ?? CallPolicyVersion.V0_0_4,\n\t\tpermissions: [\n\t\t\t{\n\t\t\t\ttarget: params.jpycAddress,\n\t\t\t\tabi: jpycAbi,\n\t\t\t\tfunctionName: \"transfer\",\n\t\t\t\targs: [\n\t\t\t\t\t// Recipient: any address allowed (no allowlist in M2).\n\t\t\t\t\tnull,\n\t\t\t\t\t// value: must be ≤ maxPerTransfer.\n\t\t\t\t\t{\n\t\t\t\t\t\tcondition: ParamCondition.LESS_THAN_OR_EQUAL,\n\t\t\t\t\t\tvalue: params.maxPerTransfer,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst rateLimitPolicy = toRateLimitPolicy({\n\t\tinterval: ONE_DAY_SECONDS,\n\t\tcount: params.maxTransfersPerDay,\n\t});\n\n\treturn [callPolicy, rateLimitPolicy] as const;\n}\n","/**\n * Typed errors thrown by the `kawasekit/session` modules.\n *\n * Centralised so consumers can `instanceof`-discriminate without importing\n * deep paths.\n *\n * @packageDocumentation\n */\n\nimport type { Address } from \"viem\";\n\n/**\n * Thrown when {@link parseSessionEnvelope} encounters an envelope whose\n * `kawasekitVersion` does not match the current\n * {@link KAWASEKIT_SESSION_ENVELOPE_VERSION}.\n *\n * The version field is intentionally a string (\"1\") so that future migrations\n * can introduce non-numeric variants (e.g. \"1-jwe\") without breaking the\n * parser ordering.\n */\nexport class SessionEnvelopeVersionError extends Error {\n\treadonly expected: string;\n\treadonly received: unknown;\n\n\tconstructor(expected: string, received: unknown) {\n\t\tsuper(\n\t\t\t`Session envelope version mismatch: expected ${JSON.stringify(expected)}, got ${JSON.stringify(received)}.`,\n\t\t);\n\t\tthis.name = \"SessionEnvelopeVersionError\";\n\t\tthis.expected = expected;\n\t\tthis.received = received;\n\t}\n}\n\n/**\n * Thrown by `restoreSessionAccount()` when an envelope's `chainId` differs\n * from the chain the consumer is restoring on. Catches the common mistake of\n * issuing on Polygon Amoy and trying to restore on Polygon mainnet.\n */\nexport class SessionEnvelopeChainMismatchError extends Error {\n\treadonly envelopeChainId: number;\n\treadonly clientChainId: number;\n\n\tconstructor(envelopeChainId: number, clientChainId: number) {\n\t\tsuper(\n\t\t\t`Session envelope is for chain ${envelopeChainId} but the restore client is on chain ${clientChainId}.`,\n\t\t);\n\t\tthis.name = \"SessionEnvelopeChainMismatchError\";\n\t\tthis.envelopeChainId = envelopeChainId;\n\t\tthis.clientChainId = clientChainId;\n\t}\n}\n\n/**\n * Thrown by `restoreSessionAccount()` when the session-key signer the consumer\n * passes does not match the `sessionKeyAddress` recorded in the envelope.\n *\n * Defence against accidentally restoring with the wrong private key — which\n * would otherwise succeed locally and only fail at UserOp validation time.\n */\nexport class SessionEnvelopeSignerMismatchError extends Error {\n\treadonly envelopeSignerAddress: Address;\n\treadonly providedSignerAddress: Address;\n\n\tconstructor(envelopeSignerAddress: Address, providedSignerAddress: Address) {\n\t\tsuper(\n\t\t\t`Session envelope was issued for signer ${envelopeSignerAddress}, but the provided session-key signer is ${providedSignerAddress}.`,\n\t\t);\n\t\tthis.name = \"SessionEnvelopeSignerMismatchError\";\n\t\tthis.envelopeSignerAddress = envelopeSignerAddress;\n\t\tthis.providedSignerAddress = providedSignerAddress;\n\t}\n}\n\n/**\n * Thrown when {@link parseSessionEnvelope} cannot decode the input as a\n * structurally valid envelope (malformed JSON, missing fields, bad types).\n */\nexport class SessionEnvelopeParseError extends Error {\n\treadonly reason: string;\n\n\tconstructor(reason: string, options?: { cause?: unknown }) {\n\t\tsuper(`Failed to parse session envelope: ${reason}`, options);\n\t\tthis.name = \"SessionEnvelopeParseError\";\n\t\tthis.reason = reason;\n\t}\n}\n","/**\n * `KawasekitSessionEnvelope` — kawasekit's typed wrapper around ZeroDev's\n * opaque `serializePermissionAccount` blob.\n *\n * Why wrap ZeroDev's blob rather than use it directly?\n *\n * - **Fail-fast on restore**: chainId / version / signer mismatches surface as\n * typed errors instead of confusing UserOp-time reverts.\n * - **Host-UI affordances**: `expiresAt` and `policySummary` are advisory\n * fields a wallet can render (\"this session expires in 2 hours, max 100\n * JPYC/day\") before handing the blob to {@link restoreSessionAccount}.\n * - **Version pin**: when ZeroDev changes their serialization format we bump\n * {@link KAWASEKIT_SESSION_ENVELOPE_VERSION} and provide a migration; the\n * inner `serialized` field stays opaque.\n *\n * Wire format: a single JSON string. Bigint fields (`expiresAt`,\n * `policySummary.maxPerTransfer`) round-trip via decimal-string encoding so\n * the JSON itself is portable through any transport (env var, HTTP header,\n * file).\n *\n * @packageDocumentation\n */\n\nimport { type Address, isAddress } from \"viem\";\nimport { isSupportedChainId, type SupportedChainId } from \"../chains\";\nimport { SessionEnvelopeParseError, SessionEnvelopeVersionError } from \"./errors\";\n\n/**\n * Current envelope format version. Bumped when the envelope schema changes\n * in a way that breaks backward compatibility.\n */\nexport const KAWASEKIT_SESSION_ENVELOPE_VERSION = \"1\" as const;\n\n/** Type of {@link KAWASEKIT_SESSION_ENVELOPE_VERSION}. */\nexport type KawasekitSessionEnvelopeVersion = typeof KAWASEKIT_SESSION_ENVELOPE_VERSION;\n\n/**\n * Advisory summary of the spending policy attached to a session key. Useful\n * for host UI; **not** consulted at validation time (the on-chain validator\n * is the source of truth).\n */\nexport interface KawasekitSessionPolicySummary {\n\treadonly jpycAddress: Address;\n\treadonly maxPerTransfer: bigint;\n\treadonly maxTransfersPerDay: number;\n}\n\n/** kawasekit's typed envelope around a ZeroDev session-key serialization. */\nexport interface KawasekitSessionEnvelope {\n\treadonly kawasekitVersion: KawasekitSessionEnvelopeVersion;\n\treadonly chainId: SupportedChainId;\n\treadonly smartAccountAddress: Address;\n\treadonly sessionKeyAddress: Address;\n\t/** Optional unix-seconds expiry. Advisory + ideally enforced by a `TimestampPolicy`. */\n\treadonly expiresAt?: bigint;\n\treadonly policySummary?: KawasekitSessionPolicySummary;\n\t/** Opaque ZeroDev `serializePermissionAccount` output. */\n\treadonly serialized: string;\n}\n\n// ---------------------------------------------------------------------------\n// Wire (JSON) shape\n// ---------------------------------------------------------------------------\n\n/**\n * Internal: the JSON shape we (de)serialize to/from. Bigint fields are stored\n * as decimal strings. Kept separate from {@link KawasekitSessionEnvelope} so\n * the public type stays bigint-friendly while the wire stays string-only.\n */\ninterface SessionEnvelopeJson {\n\treadonly kawasekitVersion: string;\n\treadonly chainId: number;\n\treadonly smartAccountAddress: string;\n\treadonly sessionKeyAddress: string;\n\treadonly expiresAt?: string;\n\treadonly policySummary?: {\n\t\treadonly jpycAddress: string;\n\t\treadonly maxPerTransfer: string;\n\t\treadonly maxTransfersPerDay: number;\n\t};\n\treadonly serialized: string;\n}\n\n// ---------------------------------------------------------------------------\n// Validation helpers\n// ---------------------------------------------------------------------------\n\nconst UINT_DECIMAL = /^(0|[1-9][0-9]*)$/;\n\nfunction assertAddress(value: unknown, field: string): Address {\n\tif (typeof value !== \"string\" || !isAddress(value, { strict: false })) {\n\t\tthrow new SessionEnvelopeParseError(`\\`${field}\\` is not a valid address: ${String(value)}`);\n\t}\n\treturn value as Address;\n}\n\nfunction assertString(value: unknown, field: string): string {\n\tif (typeof value !== \"string\" || value === \"\") {\n\t\tthrow new SessionEnvelopeParseError(`\\`${field}\\` must be a non-empty string`);\n\t}\n\treturn value;\n}\n\nfunction assertNumber(value: unknown, field: string): number {\n\tif (typeof value !== \"number\" || !Number.isFinite(value)) {\n\t\tthrow new SessionEnvelopeParseError(`\\`${field}\\` must be a finite number`);\n\t}\n\treturn value;\n}\n\nfunction parseBigIntString(value: unknown, field: string): bigint {\n\tif (typeof value !== \"string\" || !UINT_DECIMAL.test(value)) {\n\t\tthrow new SessionEnvelopeParseError(\n\t\t\t`\\`${field}\\` must be a non-negative decimal string: ${String(value)}`,\n\t\t);\n\t}\n\treturn BigInt(value);\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Serialises a {@link KawasekitSessionEnvelope} to a transportable JSON string.\n *\n * The output is plain UTF-8 JSON (no base64). Callers who need\n * URL-/header-safe transport can base64-encode the result themselves.\n *\n * @example\n * ```ts\n * import { serializeSessionEnvelope } from \"kawasekit\";\n *\n * const blob = serializeSessionEnvelope(envelope);\n * fs.writeFileSync(\"agent.session\", blob);\n * ```\n */\nexport function serializeSessionEnvelope(envelope: KawasekitSessionEnvelope): string {\n\tconst json: SessionEnvelopeJson = {\n\t\tkawasekitVersion: envelope.kawasekitVersion,\n\t\tchainId: envelope.chainId,\n\t\tsmartAccountAddress: envelope.smartAccountAddress,\n\t\tsessionKeyAddress: envelope.sessionKeyAddress,\n\t\tserialized: envelope.serialized,\n\t\t...(envelope.expiresAt !== undefined ? { expiresAt: envelope.expiresAt.toString() } : {}),\n\t\t...(envelope.policySummary !== undefined\n\t\t\t? {\n\t\t\t\t\tpolicySummary: {\n\t\t\t\t\t\tjpycAddress: envelope.policySummary.jpycAddress,\n\t\t\t\t\t\tmaxPerTransfer: envelope.policySummary.maxPerTransfer.toString(),\n\t\t\t\t\t\tmaxTransfersPerDay: envelope.policySummary.maxTransfersPerDay,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t};\n\treturn JSON.stringify(json);\n}\n\n/**\n * Parses a JSON string back into a {@link KawasekitSessionEnvelope}, asserting\n * shape and version invariants.\n *\n * @throws {SessionEnvelopeParseError} On malformed JSON or structural errors.\n * @throws {SessionEnvelopeVersionError} On `kawasekitVersion` mismatch.\n *\n * @example\n * ```ts\n * import { parseSessionEnvelope } from \"kawasekit\";\n *\n * const envelope = parseSessionEnvelope(fs.readFileSync(\"agent.session\", \"utf8\"));\n * ```\n */\nexport function parseSessionEnvelope(input: string): KawasekitSessionEnvelope {\n\tlet raw: unknown;\n\ttry {\n\t\traw = JSON.parse(input);\n\t} catch (cause) {\n\t\tthrow new SessionEnvelopeParseError(\"input is not valid JSON\", { cause });\n\t}\n\tif (raw === null || typeof raw !== \"object\" || Array.isArray(raw)) {\n\t\tthrow new SessionEnvelopeParseError(\"input is not a JSON object\");\n\t}\n\tconst obj = raw as {\n\t\tkawasekitVersion?: unknown;\n\t\tchainId?: unknown;\n\t\tsmartAccountAddress?: unknown;\n\t\tsessionKeyAddress?: unknown;\n\t\tserialized?: unknown;\n\t\texpiresAt?: unknown;\n\t\tpolicySummary?: unknown;\n\t};\n\n\tif (obj.kawasekitVersion !== KAWASEKIT_SESSION_ENVELOPE_VERSION) {\n\t\tthrow new SessionEnvelopeVersionError(KAWASEKIT_SESSION_ENVELOPE_VERSION, obj.kawasekitVersion);\n\t}\n\tconst chainIdNum = assertNumber(obj.chainId, \"chainId\");\n\tif (!isSupportedChainId(chainIdNum)) {\n\t\tthrow new SessionEnvelopeParseError(`chainId ${chainIdNum} is not a kawasekit-supported chain`);\n\t}\n\tconst chainId: SupportedChainId = chainIdNum;\n\tconst smartAccountAddress = assertAddress(obj.smartAccountAddress, \"smartAccountAddress\");\n\tconst sessionKeyAddress = assertAddress(obj.sessionKeyAddress, \"sessionKeyAddress\");\n\tconst serialized = assertString(obj.serialized, \"serialized\");\n\n\tconst expiresAt =\n\t\tobj.expiresAt !== undefined ? parseBigIntString(obj.expiresAt, \"expiresAt\") : undefined;\n\n\tlet policySummary: KawasekitSessionPolicySummary | undefined;\n\tif (obj.policySummary !== undefined) {\n\t\tif (\n\t\t\tobj.policySummary === null ||\n\t\t\ttypeof obj.policySummary !== \"object\" ||\n\t\t\tArray.isArray(obj.policySummary)\n\t\t) {\n\t\t\tthrow new SessionEnvelopeParseError(\"`policySummary` must be a JSON object\");\n\t\t}\n\t\tconst ps = obj.policySummary as {\n\t\t\tjpycAddress?: unknown;\n\t\t\tmaxPerTransfer?: unknown;\n\t\t\tmaxTransfersPerDay?: unknown;\n\t\t};\n\t\tpolicySummary = {\n\t\t\tjpycAddress: assertAddress(ps.jpycAddress, \"policySummary.jpycAddress\"),\n\t\t\tmaxPerTransfer: parseBigIntString(ps.maxPerTransfer, \"policySummary.maxPerTransfer\"),\n\t\t\tmaxTransfersPerDay: assertNumber(ps.maxTransfersPerDay, \"policySummary.maxTransfersPerDay\"),\n\t\t};\n\t}\n\n\tconst base = {\n\t\tkawasekitVersion: KAWASEKIT_SESSION_ENVELOPE_VERSION,\n\t\tchainId,\n\t\tsmartAccountAddress,\n\t\tsessionKeyAddress,\n\t\tserialized,\n\t} as const;\n\tif (expiresAt !== undefined && policySummary !== undefined) {\n\t\treturn { ...base, expiresAt, policySummary };\n\t}\n\tif (expiresAt !== undefined) {\n\t\treturn { ...base, expiresAt };\n\t}\n\tif (policySummary !== undefined) {\n\t\treturn { ...base, policySummary };\n\t}\n\treturn base;\n}\n","/**\n * `issueSessionKey()` — owner-side primitive that builds a Kernel agent\n * account and wraps ZeroDev's `serializePermissionAccount` output in a\n * {@link KawasekitSessionEnvelope}.\n *\n * The envelope is portable: callers can hand it to an agent on a different\n * machine, the agent passes it to {@link restoreSessionAccount} along with the\n * session-key private key, and it ends up holding a `KernelAccountClient`\n * scoped to the policies installed at issue time.\n *\n * The owner retains sudo authority on-chain and can revoke at any time via\n * `revokeSessionKey()` (task 2.5).\n *\n * @packageDocumentation\n */\n\nimport type { Policy } from \"@zerodev/permissions\";\nimport { serializePermissionAccount } from \"@zerodev/permissions\";\nimport { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\nimport type { EntryPointType, GetKernelVersion } from \"@zerodev/sdk/types\";\nimport type { Chain, LocalAccount, PublicClient, Transport } from \"viem\";\nimport { createAgentSmartAccount } from \"../account/session-key\";\nimport { isSupportedChainId, type SupportedChainId } from \"../chains\";\nimport {\n\tKAWASEKIT_SESSION_ENVELOPE_VERSION,\n\ttype KawasekitSessionEnvelope,\n\ttype KawasekitSessionPolicySummary,\n} from \"./envelope\";\n\n/** Parameters for {@link issueSessionKey}. */\nexport interface IssueSessionKeyParams {\n\t/**\n\t * viem `PublicClient` on the chain the smart account will live on. Its\n\t * `chain.id` MUST be a {@link SupportedChainId} and is recorded in the\n\t * envelope so restore-time mismatches fail fast.\n\t */\n\treadonly publicClient: PublicClient<Transport, Chain>;\n\t/** Owner EOA — retains sudo authority. */\n\treadonly ownerSigner: LocalAccount;\n\t/** Session-key EOA — the day-to-day signer the agent will hold. */\n\treadonly sessionKeySigner: LocalAccount;\n\t/**\n\t * Policies the session key must satisfy at userOp validation time\n\t * (e.g. {@link createJpycDailyLimitPolicies}).\n\t */\n\treadonly policies: readonly Policy[];\n\t/** Optional advisory expiry (unix seconds). Recorded in the envelope. */\n\treadonly expiresAt?: bigint;\n\t/** Optional advisory policy summary for host UI. */\n\treadonly policySummary?: KawasekitSessionPolicySummary;\n\t/** EntryPoint override. Defaults to v0.7. */\n\treadonly entryPoint?: EntryPointType<\"0.7\">;\n\t/** Kernel version override. Defaults to {@link KERNEL_V3_1}. */\n\treadonly kernelVersion?: GetKernelVersion<\"0.7\">;\n}\n\n/**\n * Issues a fresh session key for an agent smart account.\n *\n * Notes:\n * - The session-key **private key is not embedded** in the returned envelope.\n * The agent must receive the private key out-of-band; the envelope alone is\n * not enough to spend.\n * - The smart account is **not deployed** by this call. It will be deployed\n * on first userOp from `restoreSessionAccount`.\n *\n * @example\n * ```ts\n * import { parseUnits } from \"viem\";\n * import { privateKeyToAccount } from \"viem/accounts\";\n * import {\n * createJpycDailyLimitPolicies,\n * getJpycAddress,\n * issueSessionKey,\n * JPYC_DECIMALS,\n * polygonAmoy,\n * serializeSessionEnvelope,\n * } from \"kawasekit\";\n *\n * const owner = privateKeyToAccount(process.env.OWNER_PRIVATE_KEY as `0x${string}`);\n * const sessionKey = privateKeyToAccount(process.env.SESSION_KEY_PRIVATE_KEY as `0x${string}`);\n *\n * const envelope = await issueSessionKey({\n * publicClient,\n * ownerSigner: owner,\n * sessionKeySigner: sessionKey,\n * policies: createJpycDailyLimitPolicies({\n * jpycAddress: getJpycAddress(polygonAmoy.id),\n * maxPerTransfer: parseUnits(\"100\", JPYC_DECIMALS),\n * maxTransfersPerDay: 10,\n * }),\n * policySummary: {\n * jpycAddress: getJpycAddress(polygonAmoy.id),\n * maxPerTransfer: parseUnits(\"100\", JPYC_DECIMALS),\n * maxTransfersPerDay: 10,\n * },\n * });\n *\n * fs.writeFileSync(\"agent.session\", serializeSessionEnvelope(envelope));\n * ```\n */\nexport async function issueSessionKey(\n\tparams: IssueSessionKeyParams,\n): Promise<KawasekitSessionEnvelope> {\n\tconst chainId = params.publicClient.chain.id;\n\tif (!isSupportedChainId(chainId)) {\n\t\tthrow new Error(\n\t\t\t`issueSessionKey: publicClient.chain.id ${chainId} is not a kawasekit-supported chain`,\n\t\t);\n\t}\n\tconst supportedChainId: SupportedChainId = chainId;\n\tconst entryPoint = params.entryPoint ?? getEntryPoint(\"0.7\");\n\tconst kernelVersion = params.kernelVersion ?? KERNEL_V3_1;\n\n\tconst account = await createAgentSmartAccount({\n\t\tpublicClient: params.publicClient,\n\t\townerSigner: params.ownerSigner,\n\t\tsessionKeySigner: params.sessionKeySigner,\n\t\tpolicies: params.policies,\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\n\tconst serialized = await serializePermissionAccount(account);\n\n\tconst base = {\n\t\tkawasekitVersion: KAWASEKIT_SESSION_ENVELOPE_VERSION,\n\t\tchainId: supportedChainId,\n\t\tsmartAccountAddress: account.address,\n\t\tsessionKeyAddress: params.sessionKeySigner.address,\n\t\tserialized,\n\t} as const;\n\tif (params.expiresAt !== undefined && params.policySummary !== undefined) {\n\t\treturn {\n\t\t\t...base,\n\t\t\texpiresAt: params.expiresAt,\n\t\t\tpolicySummary: params.policySummary,\n\t\t};\n\t}\n\tif (params.expiresAt !== undefined) {\n\t\treturn { ...base, expiresAt: params.expiresAt };\n\t}\n\tif (params.policySummary !== undefined) {\n\t\treturn { ...base, policySummary: params.policySummary };\n\t}\n\treturn base;\n}\n","/**\n * `restoreSessionAccount()` — agent-side primitive that unwraps a\n * {@link KawasekitSessionEnvelope} back into a usable Kernel account scoped\n * to the policies installed at issue time.\n *\n * Three invariants are checked **before** touching ZeroDev's deserialization\n * so that misconfiguration manifests as a typed error here, not a confusing\n * UserOp-time revert:\n *\n * 1. `envelope.kawasekitVersion` matches the current envelope version\n * (already enforced by {@link parseSessionEnvelope}; re-checked here for\n * callers who construct the envelope object directly).\n * 2. `envelope.chainId === publicClient.chain.id`.\n * 3. `envelope.sessionKeyAddress` matches the provided `sessionKeySigner`.\n *\n * @packageDocumentation\n */\n\nimport { deserializePermissionAccount } from \"@zerodev/permissions\";\nimport { toECDSASigner } from \"@zerodev/permissions/signers\";\nimport type { CreateKernelAccountReturnType } from \"@zerodev/sdk\";\nimport { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\nimport type { EntryPointType, GetKernelVersion } from \"@zerodev/sdk/types\";\nimport { type Chain, getAddress, type LocalAccount, type PublicClient, type Transport } from \"viem\";\nimport { KAWASEKIT_SESSION_ENVELOPE_VERSION, type KawasekitSessionEnvelope } from \"./envelope\";\nimport {\n\tSessionEnvelopeChainMismatchError,\n\tSessionEnvelopeSignerMismatchError,\n\tSessionEnvelopeVersionError,\n} from \"./errors\";\n\n/** Parameters for {@link restoreSessionAccount}. */\nexport interface RestoreSessionAccountParams {\n\t/** Must be on the same chain the envelope was issued for. */\n\treadonly publicClient: PublicClient<Transport, Chain>;\n\t/** Envelope produced by {@link issueSessionKey} (or parsed via {@link parseSessionEnvelope}). */\n\treadonly envelope: KawasekitSessionEnvelope;\n\t/**\n\t * The session-key signer the agent holds. Its address MUST equal\n\t * `envelope.sessionKeyAddress` — otherwise the restored account would\n\t * sign userOps that the on-chain permission validator rejects.\n\t */\n\treadonly sessionKeySigner: LocalAccount;\n\t/** EntryPoint override. Defaults to v0.7. */\n\treadonly entryPoint?: EntryPointType<\"0.7\">;\n\t/** Kernel version override. Defaults to {@link KERNEL_V3_1}. */\n\treadonly kernelVersion?: GetKernelVersion<\"0.7\">;\n}\n\n/**\n * Rebuilds the Kernel account from an envelope + the session-key signer.\n *\n * @throws {SessionEnvelopeVersionError} If `envelope.kawasekitVersion` does\n * not match the current envelope version.\n * @throws {SessionEnvelopeChainMismatchError} If `envelope.chainId !==\n * publicClient.chain.id`.\n * @throws {SessionEnvelopeSignerMismatchError} If `sessionKeySigner.address !==\n * envelope.sessionKeyAddress`.\n *\n * @example\n * ```ts\n * import { createPublicClient, http } from \"viem\";\n * import { privateKeyToAccount } from \"viem/accounts\";\n * import {\n * parseSessionEnvelope,\n * polygonAmoy,\n * restoreSessionAccount,\n * } from \"kawasekit\";\n *\n * const publicClient = createPublicClient({\n * chain: polygonAmoy,\n * transport: http(),\n * });\n * const envelope = parseSessionEnvelope(fs.readFileSync(\"agent.session\", \"utf8\"));\n * const sessionKey = privateKeyToAccount(process.env.SESSION_KEY_PRIVATE_KEY as `0x${string}`);\n *\n * const account = await restoreSessionAccount({\n * publicClient,\n * envelope,\n * sessionKeySigner: sessionKey,\n * });\n * ```\n */\nexport async function restoreSessionAccount(\n\tparams: RestoreSessionAccountParams,\n): Promise<CreateKernelAccountReturnType<\"0.7\">> {\n\tconst { publicClient, envelope, sessionKeySigner } = params;\n\n\tif (envelope.kawasekitVersion !== KAWASEKIT_SESSION_ENVELOPE_VERSION) {\n\t\tthrow new SessionEnvelopeVersionError(\n\t\t\tKAWASEKIT_SESSION_ENVELOPE_VERSION,\n\t\t\tenvelope.kawasekitVersion,\n\t\t);\n\t}\n\tif (publicClient.chain.id !== envelope.chainId) {\n\t\tthrow new SessionEnvelopeChainMismatchError(envelope.chainId, publicClient.chain.id);\n\t}\n\tif (getAddress(sessionKeySigner.address) !== getAddress(envelope.sessionKeyAddress)) {\n\t\tthrow new SessionEnvelopeSignerMismatchError(\n\t\t\tenvelope.sessionKeyAddress,\n\t\t\tsessionKeySigner.address,\n\t\t);\n\t}\n\n\tconst entryPoint = params.entryPoint ?? getEntryPoint(\"0.7\");\n\tconst kernelVersion = params.kernelVersion ?? KERNEL_V3_1;\n\tconst modularSigner = await toECDSASigner({ signer: sessionKeySigner });\n\n\treturn deserializePermissionAccount(\n\t\tpublicClient,\n\t\tentryPoint,\n\t\tkernelVersion,\n\t\tenvelope.serialized,\n\t\tmodularSigner,\n\t);\n}\n","/**\n * `revokeSessionKey()` — owner-side primitive that uninstalls a session-key\n * permission validator from the agent's smart account.\n *\n * Implementation strategy (per plan §risk #3): ZeroDev does not expose a\n * dedicated revoke helper, so we re-derive the `PermissionPlugin` from the\n * envelope's `sessionKeyAddress` + the same policies that were installed at\n * issue time, then submit a sudo UserOp via `@zerodev/sdk`'s\n * {@link uninstallPlugin} action. After the receipt, the session key can no\n * longer sign UserOps the validator would accept.\n *\n * In-flight UserOps already submitted to the bundler but not yet mined can\n * still settle before the uninstall transaction lands. A future \"soft revoke\"\n * via `invalidateNonce` on the session-key validator's nonce key will close\n * that race; tracked for M5 (the helper signature accepts an\n * `invalidateInFlightNonces` option today and throws `\"not implemented\"` to\n * lock in the API shape). Until M5 lands, see\n * `docs/recipes/revoke-race-mitigation.md` for the four-layer operator\n * playbook (SDK call → merchant kill-switch → paymaster sponsorship\n * freeze → bundler mempool monitoring).\n *\n * @packageDocumentation\n */\n\nimport type { Policy } from \"@zerodev/permissions\";\nimport { toPermissionValidator } from \"@zerodev/permissions\";\nimport { toECDSASigner } from \"@zerodev/permissions/signers\";\nimport { uninstallPlugin } from \"@zerodev/sdk\";\nimport { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\nimport type { EntryPointType, GetKernelVersion } from \"@zerodev/sdk/types\";\nimport { getAddress, type Hash, type LocalAccount } from \"viem\";\nimport type { ConfiguredKernelClient } from \"../client/transfer-jpyc\";\nimport type { KawasekitSessionEnvelope } from \"./envelope\";\nimport { SessionEnvelopeSignerMismatchError } from \"./errors\";\n\n/** Parameters for {@link revokeSessionKey}. */\nexport interface RevokeSessionKeyParams {\n\t/**\n\t * The owner's sudo Kernel client — the only entity that can call\n\t * `uninstallValidation` on the agent account.\n\t *\n\t * **CRITICAL: must be a SUDO-ONLY kernel account** (i.e.\n\t * `createKernelAccount(publicClient, { plugins: { sudo: ecdsaValidator } })`\n\t * — no `regular` plugin). If you pass a client whose account also has the\n\t * session-key permission validator wired as `regular`, ZeroDev signs\n\t * userOps with that validator by default and the spending policy will\n\t * reject `uninstallValidation` at the validation phase (`AA23 reverted`).\n\t *\n\t * The counterfactual smart-account address only depends on the sudo\n\t * validator in Kernel v3.1, so a sudo-only client points at the SAME\n\t * account as one built with both sudo + regular.\n\t *\n\t * Its `account.address` MUST equal `envelope.smartAccountAddress`.\n\t */\n\treadonly ownerKernelClient: ConfiguredKernelClient;\n\t/** The envelope of the session being revoked. */\n\treadonly envelope: KawasekitSessionEnvelope;\n\t/**\n\t * A LocalAccount whose address equals `envelope.sessionKeyAddress`. Used\n\t * to reconstruct the validator's on-chain identifier; no signing is\n\t * actually performed with this account during revoke.\n\t */\n\treadonly sessionKeySigner: LocalAccount;\n\t/**\n\t * The policies that were installed at issue time. ZeroDev does not store\n\t * these on-chain in a retrievable form, so the caller MUST re-supply\n\t * them. Mismatches surface as an `uninstallValidation` revert at userOp\n\t * validation time.\n\t */\n\treadonly policies: readonly Policy[];\n\t/**\n\t * Future option: also invalidate the session-key validator's nonce key\n\t * to kill in-flight UserOps. Not implemented today — passing `true`\n\t * throws. Tracked for M5; see `docs/THREAT_MODEL.md` §6.3 and\n\t * `docs/recipes/revoke-race-mitigation.md` for the operator playbook to\n\t * use until then.\n\t */\n\treadonly invalidateInFlightNonces?: boolean;\n\t/** EntryPoint override. Defaults to v0.7. */\n\treadonly entryPoint?: EntryPointType<\"0.7\">;\n\t/** Kernel version override. Defaults to {@link KERNEL_V3_1}. */\n\treadonly kernelVersion?: GetKernelVersion<\"0.7\">;\n\t/**\n\t * If `false`, return after submitting the UserOp without waiting for the\n\t * bundler receipt. Default `true` (wait).\n\t */\n\treadonly waitForReceipt?: boolean;\n}\n\n/** Result of {@link revokeSessionKey}. */\nexport interface RevokeSessionKeyResult {\n\t/** Hash of the uninstall UserOp. */\n\treadonly userOpHash: Hash;\n\t/** Bundler transaction hash, present when `waitForReceipt` (default true). */\n\treadonly transactionHash: Hash | null;\n\t/** `true` if the bundler reported success, `null` if not awaited. */\n\treadonly success: boolean | null;\n}\n\n/**\n * Uninstalls a session-key permission validator from the agent's smart\n * account. After the returned UserOp lands, the session key can no longer\n * authorise actions.\n *\n * @throws {SessionEnvelopeSignerMismatchError} If `sessionKeySigner.address`\n * does not match `envelope.sessionKeyAddress`.\n * @throws {Error} If `invalidateInFlightNonces` is `true` (planned for M5;\n * see `docs/THREAT_MODEL.md` §6.3 and\n * `docs/recipes/revoke-race-mitigation.md` for the four-layer\n * operator playbook to use until then).\n *\n * @example\n * ```ts\n * import { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\n * import { createKernelAccount, createKernelAccountClient } from \"@zerodev/sdk\";\n * import { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\n * import { revokeSessionKey } from \"kawasekit\";\n *\n * // Build a SUDO-ONLY kernel account for the owner — see param JSDoc.\n * const sudoValidator = await signerToEcdsaValidator(publicClient, {\n * signer: owner,\n * entryPoint: getEntryPoint(\"0.7\"),\n * kernelVersion: KERNEL_V3_1,\n * });\n * const ownerSudoAccount = await createKernelAccount(publicClient, {\n * plugins: { sudo: sudoValidator },\n * entryPoint: getEntryPoint(\"0.7\"),\n * kernelVersion: KERNEL_V3_1,\n * });\n * const ownerKernelClient = createKernelAccountClient({\n * account: ownerSudoAccount,\n * chain,\n * client: publicClient,\n * bundlerTransport,\n * paymaster,\n * });\n *\n * await revokeSessionKey({\n * ownerKernelClient,\n * envelope,\n * sessionKeySigner,\n * policies: createJpycDailyLimitPolicies({ ... }),\n * });\n * ```\n */\nexport async function revokeSessionKey(\n\tparams: RevokeSessionKeyParams,\n): Promise<RevokeSessionKeyResult> {\n\tconst { ownerKernelClient, envelope, sessionKeySigner, policies } = params;\n\n\tif (params.invalidateInFlightNonces === true) {\n\t\tthrow new Error(\n\t\t\t\"revokeSessionKey: `invalidateInFlightNonces` is not implemented yet — the helper signature accepts the option to lock in the API shape, but in-flight nonce invalidation lands in M5. Hard revoke via uninstallPlugin is what runs today; see docs/recipes/revoke-race-mitigation.md for the four-layer operator playbook to use until then.\",\n\t\t);\n\t}\n\n\tif (getAddress(sessionKeySigner.address) !== getAddress(envelope.sessionKeyAddress)) {\n\t\tthrow new SessionEnvelopeSignerMismatchError(\n\t\t\tenvelope.sessionKeyAddress,\n\t\t\tsessionKeySigner.address,\n\t\t);\n\t}\n\n\tif (getAddress(ownerKernelClient.account.address) !== getAddress(envelope.smartAccountAddress)) {\n\t\tthrow new Error(\n\t\t\t`revokeSessionKey: ownerKernelClient is bound to ${ownerKernelClient.account.address}, but envelope is for ${envelope.smartAccountAddress}.`,\n\t\t);\n\t}\n\n\tconst entryPoint = params.entryPoint ?? getEntryPoint(\"0.7\");\n\tconst kernelVersion = params.kernelVersion ?? KERNEL_V3_1;\n\n\tif (ownerKernelClient.client === undefined) {\n\t\tthrow new Error(\n\t\t\t\"revokeSessionKey: ownerKernelClient.client is undefined — pass `client: publicClient` when constructing the Kernel client so the validator can be reconstructed.\",\n\t\t);\n\t}\n\n\tconst modularSigner = await toECDSASigner({ signer: sessionKeySigner });\n\tconst permissionPlugin = await toPermissionValidator(ownerKernelClient.client, {\n\t\tsigner: modularSigner,\n\t\tpolicies: [...policies],\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\n\tconst userOpHash = await uninstallPlugin(ownerKernelClient, {\n\t\tplugin: permissionPlugin,\n\t});\n\n\tif (params.waitForReceipt === false) {\n\t\treturn { userOpHash, transactionHash: null, success: null };\n\t}\n\n\tconst receipt = await ownerKernelClient.waitForUserOperationReceipt({\n\t\thash: userOpHash,\n\t});\n\treturn {\n\t\tuserOpHash,\n\t\ttransactionHash: receipt.receipt.transactionHash,\n\t\tsuccess: receipt.success,\n\t};\n}\n","/**\n * `rotateSessionKey()` — a thin compositional helper that revokes the\n * current session key and issues a new one in sequence.\n *\n * Compose-don't-conflate: rotate is just `revoke` followed by `issue`. Both\n * primitives are exposed individually so callers who need finer control\n * (e.g. revoke now, issue tomorrow with different policies) can chain them\n * themselves.\n *\n * @packageDocumentation\n */\n\nimport type { KawasekitSessionEnvelope } from \"./envelope\";\nimport { type IssueSessionKeyParams, issueSessionKey } from \"./issue\";\nimport {\n\ttype RevokeSessionKeyParams,\n\ttype RevokeSessionKeyResult,\n\trevokeSessionKey,\n} from \"./revoke\";\n\n/** Parameters for {@link rotateSessionKey}. */\nexport interface RotateSessionKeyParams {\n\t/** Inputs for revoking the current session. `waitForReceipt` is forced `true`. */\n\treadonly revoke: Omit<RevokeSessionKeyParams, \"waitForReceipt\">;\n\t/** Inputs for issuing the replacement session. */\n\treadonly issue: IssueSessionKeyParams;\n}\n\n/** Result of {@link rotateSessionKey}. */\nexport interface RotateSessionKeyResult {\n\t/** Outcome of the revoke step. */\n\treadonly revoke: RevokeSessionKeyResult;\n\t/** The freshly issued replacement envelope. */\n\treadonly envelope: KawasekitSessionEnvelope;\n}\n\n/**\n * Atomically rotate the agent's session key: revoke the old, issue the new.\n *\n * The revoke is always awaited to the bundler receipt — issuing a replacement\n * before the old key is actually disarmed would leave two valid signers at\n * once, defeating the point.\n *\n * @example\n * ```ts\n * import { rotateSessionKey } from \"kawasekit\";\n *\n * const { revoke, envelope } = await rotateSessionKey({\n * revoke: {\n * ownerKernelClient,\n * envelope: oldEnvelope,\n * sessionKeySigner: oldSessionKeySigner,\n * policies: oldPolicies,\n * },\n * issue: {\n * publicClient,\n * ownerSigner,\n * sessionKeySigner: newSessionKeySigner,\n * policies: newPolicies,\n * },\n * });\n * ```\n */\nexport async function rotateSessionKey(\n\tparams: RotateSessionKeyParams,\n): Promise<RotateSessionKeyResult> {\n\tconst revoke = await revokeSessionKey({ ...params.revoke, waitForReceipt: true });\n\tconst envelope = await issueSessionKey(params.issue);\n\treturn { revoke, envelope };\n}\n","/**\n * Environment loading helpers shared by every CLI command.\n *\n * The CLI loads `.env` from the current working directory (so a user can\n * `cd ~/my-agent-project && kawasekit transfer …` and have their secrets\n * picked up automatically) but every command also accepts the same value\n * as an explicit `--xxx` flag for ad-hoc use.\n */\n\nimport { config as loadDotenv } from \"dotenv\";\nimport type { Hex } from \"viem\";\n\nlet dotenvLoaded = false;\n\n/**\n * Ensure `.env` from the current working directory has been merged into\n * `process.env`. Safe to call multiple times — subsequent calls are no-ops.\n */\nexport function ensureDotenvLoaded(): void {\n\tif (dotenvLoaded) return;\n\t// `quiet: true` suppresses dotenv v17's promotional \"injecting env … (tip:\n\t// …)\" banner — a CLI loading secrets should not print to stdout, and it\n\t// otherwise leaks onto `--version` / `--help` output.\n\tloadDotenv({ override: false, quiet: true });\n\tdotenvLoaded = true;\n}\n\n/**\n * Resolve a value that may come from either an explicit CLI flag or a\n * named environment variable. Returns the flag value if present, otherwise\n * the env value, otherwise `undefined`.\n */\nexport function resolveValue(flagValue: string | undefined, envName: string): string | undefined {\n\tif (flagValue !== undefined && flagValue.trim() !== \"\") return flagValue;\n\tensureDotenvLoaded();\n\tconst raw = process.env[envName];\n\tif (raw === undefined || raw.trim() === \"\") return undefined;\n\treturn raw;\n}\n\n/**\n * Like {@link resolveValue} but throws a CLI-flavoured error if no value\n * was found. Use for inputs the command genuinely cannot proceed without.\n */\nexport function requireValue(flagValue: string | undefined, envName: string, hint: string): string {\n\tconst value = resolveValue(flagValue, envName);\n\tif (value === undefined) {\n\t\tthrow new Error(\n\t\t\t`Missing required value: pass --${hint} or set ${envName} in your environment / .env file.`,\n\t\t);\n\t}\n\treturn value;\n}\n\n/**\n * Validates a value as a 0x-prefixed 32-byte hex private key and returns it\n * typed as `Hex`. Throws with a CLI-friendly message on malformed input.\n */\nexport function asPrivateKey(value: string, source: string): Hex {\n\tif (!/^0x[0-9a-fA-F]{64}$/.test(value)) {\n\t\tthrow new Error(\n\t\t\t`${source} must be a 0x-prefixed 32-byte hex string (got ${value.length} chars).`,\n\t\t);\n\t}\n\treturn value as Hex;\n}\n\n/**\n * Resolves a required private key from a `--private-key` flag or an env var.\n */\nexport function requirePrivateKey(\n\tflagValue: string | undefined,\n\tenvName: string,\n\thint: string,\n): Hex {\n\treturn asPrivateKey(requireValue(flagValue, envName, hint), envName);\n}\n","/**\n * Chain selection shared by every CLI command that touches a network.\n *\n * Every command accepts a `--chain` flag whose value is one of the\n * kawasekit chain keys (`polygon`, `polygonAmoy`). The string is mapped to\n * the corresponding `KawaseChain` and a `network: \"mainnet\" | \"testnet\"`\n * literal that the SDK's M4-1 fail-fast guards expect.\n *\n * No default — the CLI requires an explicit choice so a user cannot silently\n * point a testnet config at mainnet (or vice versa).\n */\n\nimport { polygon, polygonAmoy } from \"../../src\";\nimport { resolveValue } from \"./env\";\n\nexport type CliChainKey = \"polygon\" | \"polygonAmoy\";\n\nexport interface CliChainProfile {\n\treadonly key: CliChainKey;\n\treadonly chain: typeof polygon | typeof polygonAmoy;\n\treadonly network: \"mainnet\" | \"testnet\";\n\treadonly explorerTxBase: string;\n\treadonly displayName: string;\n}\n\nexport function resolveChain(flagValue: string | undefined): CliChainProfile {\n\tconst key = flagValue;\n\tif (key === \"polygon\") {\n\t\treturn {\n\t\t\tkey,\n\t\t\tchain: polygon,\n\t\t\tnetwork: \"mainnet\",\n\t\t\texplorerTxBase: \"https://polygonscan.com/tx/\",\n\t\t\tdisplayName: \"Polygon mainnet (137)\",\n\t\t};\n\t}\n\tif (key === \"polygonAmoy\") {\n\t\treturn {\n\t\t\tkey,\n\t\t\tchain: polygonAmoy,\n\t\t\tnetwork: \"testnet\",\n\t\t\texplorerTxBase: \"https://amoy.polygonscan.com/tx/\",\n\t\t\tdisplayName: \"Polygon Amoy testnet (80002)\",\n\t\t};\n\t}\n\tthrow new Error(\n\t\t`--chain must be one of \"polygon\" (mainnet) or \"polygonAmoy\" (testnet). Got ${JSON.stringify(key ?? \"<missing>\")}.`,\n\t);\n}\n\n/**\n * Mainnet broadcast guard. Throws if the chosen chain is mainnet but the\n * operator has not explicitly set `KAWASEKIT_ALLOW_MAINNET=1`. CLI subcommands\n * that broadcast real-funds transactions MUST call this before any RPC work.\n */\nexport function assertMainnetGuard(profile: CliChainProfile): void {\n\tif (profile.network !== \"mainnet\") return;\n\tconst gate = resolveValue(undefined, \"KAWASEKIT_ALLOW_MAINNET\");\n\tif (gate !== \"1\") {\n\t\tthrow new Error(\n\t\t\t\"Refusing to broadcast on Polygon mainnet without explicit consent. Set KAWASEKIT_ALLOW_MAINNET=1 to acknowledge that this command will spend real funds.\",\n\t\t);\n\t}\n}\n","import { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\nimport {\n\tcreateKernelAccount,\n\tcreateKernelAccountClient,\n\tcreateZeroDevPaymasterClient,\n} from \"@zerodev/sdk\";\nimport { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\nimport type { Command } from \"commander\";\nimport { createPublicClient, http } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { zerodevRpcUrl } from \"../../src\";\nimport { assertMainnetGuard, resolveChain } from \"../lib/chain\";\nimport { requirePrivateKey, requireValue } from \"../lib/env\";\n\ninterface AccountCreateOptions {\n\treadonly chain?: string;\n\treadonly ownerPrivateKey?: string;\n\treadonly zerodevProjectId?: string;\n\treadonly deploy?: boolean;\n}\n\nasync function runAccountCreate(options: AccountCreateOptions): Promise<void> {\n\tconst profile = resolveChain(options.chain);\n\tif (options.deploy === true) {\n\t\tassertMainnetGuard(profile);\n\t}\n\n\tconst ownerKey = requirePrivateKey(\n\t\toptions.ownerPrivateKey,\n\t\t\"OWNER_PRIVATE_KEY\",\n\t\t\"owner-private-key\",\n\t);\n\tconst projectId = requireValue(\n\t\toptions.zerodevProjectId,\n\t\t\"ZERODEV_PROJECT_ID\",\n\t\t\"zerodev-project-id\",\n\t);\n\n\tconst owner = privateKeyToAccount(ownerKey);\n\tconst rpcUrl = zerodevRpcUrl(profile.chain, projectId);\n\tconst publicClient = createPublicClient({ chain: profile.chain, transport: http(rpcUrl) });\n\n\tconst entryPoint = getEntryPoint(\"0.7\");\n\tconst kernelVersion = KERNEL_V3_1;\n\tconst sudoValidator = await signerToEcdsaValidator(publicClient, {\n\t\tsigner: owner,\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\tconst account = await createKernelAccount(publicClient, {\n\t\tplugins: { sudo: sudoValidator },\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\n\tconsole.log(\"Chain: \", profile.displayName);\n\tconsole.log(\"Owner (EOA): \", owner.address);\n\tconsole.log(\"Smart account address: \", account.address);\n\n\tif (options.deploy !== true) {\n\t\tconsole.log(\n\t\t\t\"\\n(counterfactual — pass --deploy to broadcast a sponsored UserOp that deploys the account.)\",\n\t\t);\n\t\treturn;\n\t}\n\n\tconsole.log(\"\\nDeploying via a sponsored self-call UserOp...\");\n\tconst paymasterClient = createZeroDevPaymasterClient({\n\t\tchain: profile.chain,\n\t\ttransport: http(rpcUrl),\n\t});\n\tconst kernelClient = createKernelAccountClient({\n\t\taccount,\n\t\tchain: profile.chain,\n\t\tclient: publicClient,\n\t\tbundlerTransport: http(rpcUrl),\n\t\tpaymaster: {\n\t\t\tgetPaymasterData: (userOperation) => paymasterClient.sponsorUserOperation({ userOperation }),\n\t\t},\n\t});\n\tconst userOpHash = await kernelClient.sendUserOperation({\n\t\tcallData: await account.encodeCalls([{ to: account.address, value: 0n, data: \"0x\" }]),\n\t});\n\tconsole.log(\"userOp hash: \", userOpHash);\n\tconst receipt = await kernelClient.waitForUserOperationReceipt({ hash: userOpHash });\n\tconst txHash = receipt.receipt.transactionHash;\n\tconsole.log(\"bundle tx hash: \", txHash);\n\tconsole.log(\"explorer: \", `${profile.explorerTxBase}${txHash}`);\n}\n\nexport function registerAccountCommand(program: Command): void {\n\tconst account = program.command(\"account\").description(\"Smart-account lifecycle commands\");\n\n\taccount\n\t\t.command(\"create\")\n\t\t.description(\"Compute (or deploy) the smart-account address for an owner key\")\n\t\t.requiredOption(\"--chain <chain>\", '\"polygon\" | \"polygonAmoy\"')\n\t\t.option(\"--owner-private-key <hex>\", \"Owner EOA private key (or env OWNER_PRIVATE_KEY)\")\n\t\t.option(\"--zerodev-project-id <id>\", \"ZeroDev project ID (or env ZERODEV_PROJECT_ID)\")\n\t\t.option(\n\t\t\t\"--deploy\",\n\t\t\t\"Broadcast a sponsored self-call UserOp that deploys the account (mainnet requires KAWASEKIT_ALLOW_MAINNET=1)\",\n\t\t)\n\t\t.action(async (options: AccountCreateOptions) => {\n\t\t\tawait runAccountCreate(options);\n\t\t});\n}\n","import { existsSync, writeFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport type { Command } from \"commander\";\n\n/**\n * `kawasekit init` — writes a starter `.env.example` into the current\n * working directory and prints next steps. Idempotent unless `--force`.\n *\n * The starter env is intentionally narrow: only the variables a brand-new\n * kawasekit consumer needs to follow the README quick-start. Operators add\n * additional vars (X402_*, KAWASEKIT_X402_CHAIN, KAWASEKIT_ALLOW_MAINNET, …)\n * as they reach those sections of the docs.\n */\nconst STARTER_ENV_EXAMPLE = `# kawasekit — environment variables\n#\n# Copy this file to \\`.env\\` and fill in real values:\n# cp .env.example .env\n#\n# NEVER commit the real \\`.env\\` file. It is gitignored on purpose.\n\n# Private key of the smart-account OWNER (the EOA signer).\n# 0x-prefixed 32-byte hex. Use a throwaway testnet key for testnet work.\nOWNER_PRIVATE_KEY=0x...\n\n# ZeroDev project ID. Create a project at https://dashboard.zerodev.app\n# and copy its ID here. Used for bundler + paymaster sponsorship.\nZERODEV_PROJECT_ID=\n\n# Recipient of the test transfer. Defaults to the smart account itself.\n# JPYC_RECIPIENT=0x...\n`;\n\ninterface InitOptions {\n\treadonly force?: boolean;\n}\n\nasync function runInit(options: InitOptions): Promise<void> {\n\tconst targetPath = resolve(process.cwd(), \".env.example\");\n\tconst alreadyExists = existsSync(targetPath);\n\tif (alreadyExists && options.force !== true) {\n\t\tconsole.log(`.env.example already exists at ${targetPath} — pass --force to overwrite.`);\n\t\tconsole.log(`Next: copy it to .env and fill in the required values.`);\n\t\treturn;\n\t}\n\twriteFileSync(targetPath, STARTER_ENV_EXAMPLE, \"utf8\");\n\tconsole.log(`${alreadyExists ? \"Overwrote\" : \"Wrote\"} ${targetPath}`);\n\tconsole.log(`Next: copy it to .env (cp .env.example .env) and fill in the required values.`);\n}\n\nexport function registerInitCommand(program: Command): void {\n\tprogram\n\t\t.command(\"init\")\n\t\t.description(\"Scaffold a starter .env.example in the current directory\")\n\t\t.option(\"--force\", \"Overwrite an existing .env.example\")\n\t\t.action(async (options: InitOptions) => {\n\t\t\tawait runInit(options);\n\t\t});\n}\n","import type { Command } from \"commander\";\nimport { getAddress, parseUnits } from \"viem\";\nimport { createJpycDailyLimitPolicies, getJpycAddress, JPYC_DECIMALS } from \"../../src\";\nimport { resolveChain } from \"../lib/chain\";\n\ninterface PolicyCreateOptions {\n\treadonly chain?: string;\n\treadonly maxPerTx?: string;\n\treadonly maxPerDay?: string;\n\treadonly jpycAddress?: string;\n}\n\nfunction parsePositiveInt(value: string, label: string): number {\n\tconst n = Number.parseInt(value, 10);\n\tif (!Number.isFinite(n) || n <= 0) {\n\t\tthrow new Error(`${label} must be a positive integer, got ${JSON.stringify(value)}.`);\n\t}\n\treturn n;\n}\n\nasync function runPolicyCreate(options: PolicyCreateOptions): Promise<void> {\n\tconst profile = resolveChain(options.chain);\n\tconst maxPerTxHuman = options.maxPerTx ?? \"100\";\n\tconst maxPerDay = parsePositiveInt(options.maxPerDay ?? \"10\", \"--max-per-day\");\n\tconst maxPerTransfer = parseUnits(maxPerTxHuman, JPYC_DECIMALS);\n\n\tconst jpycAddress = options.jpycAddress\n\t\t? getAddress(options.jpycAddress)\n\t\t: getJpycAddress(profile.chain.id);\n\n\t// Build the actual policy array — this validates the inputs end-to-end\n\t// using the same path the SDK will at issue time, so a `policy create`\n\t// dry-run catches malformed inputs before the operator commits to issuing.\n\tconst policies = createJpycDailyLimitPolicies({\n\t\tjpycAddress,\n\t\tmaxPerTransfer,\n\t\tmaxTransfersPerDay: maxPerDay,\n\t});\n\n\tconst summary = {\n\t\tchain: profile.displayName,\n\t\tjpycAddress,\n\t\tmaxPerTransfer: {\n\t\t\thuman: maxPerTxHuman,\n\t\t\twei: maxPerTransfer.toString(),\n\t\t},\n\t\tmaxTransfersPerDay: maxPerDay,\n\t\tpolicyCount: policies.length,\n\t\tnote: \"Dry-run. No on-chain action taken. Use `kawasekit session-key issue` with the same --max-per-tx / --max-per-day to install these on a session validator.\",\n\t};\n\n\tconsole.log(JSON.stringify(summary, null, 2));\n}\n\nexport function registerPolicyCommand(program: Command): void {\n\tconst policy = program.command(\"policy\").description(\"Policy builder + inspector\");\n\tpolicy\n\t\t.command(\"create\")\n\t\t.description(\"Dry-run the daily-limit policy and print the resolved parameters as JSON\")\n\t\t.requiredOption(\"--chain <chain>\", '\"polygon\" | \"polygonAmoy\"')\n\t\t.option(\"--max-per-tx <human>\", 'Per-transfer cap in decimal JPYC. Default \"100\".')\n\t\t.option(\"--max-per-day <count>\", 'Maximum transfers per 24h window. Default \"10\".')\n\t\t.option(\n\t\t\t\"--jpyc-address <address>\",\n\t\t\t\"JPYC contract address override. Defaults to the canonical kawasekit address for the chosen chain.\",\n\t\t)\n\t\t.action(async (options: PolicyCreateOptions) => {\n\t\t\tawait runPolicyCreate(options);\n\t\t});\n}\n","import { randomBytes } from \"node:crypto\";\nimport { readFileSync, writeFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\nimport {\n\tcreateKernelAccount,\n\tcreateKernelAccountClient,\n\tcreateZeroDevPaymasterClient,\n} from \"@zerodev/sdk\";\nimport { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\nimport type { Command } from \"commander\";\nimport { createPublicClient, getAddress, type Hex, http, parseUnits } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport {\n\tcreateJpycDailyLimitPolicies,\n\tgetJpycAddress,\n\tissueSessionKey,\n\tJPYC_DECIMALS,\n\ttype KawasekitSessionEnvelope,\n\tparseSessionEnvelope,\n\trestoreSessionAccount,\n\trevokeSessionKey,\n\trotateSessionKey,\n\tserializeSessionEnvelope,\n\tzerodevRpcUrl,\n} from \"../../src\";\nimport { assertMainnetGuard, type CliChainProfile, resolveChain } from \"../lib/chain\";\nimport { asPrivateKey, requirePrivateKey, requireValue } from \"../lib/env\";\n\ninterface PolicyFlags {\n\treadonly maxPerTx?: string;\n\treadonly maxPerDay?: string;\n\treadonly jpycAddress?: string;\n}\n\nfunction buildPolicies(\n\tprofile: CliChainProfile,\n\tflags: PolicyFlags,\n): ReturnType<typeof createJpycDailyLimitPolicies> {\n\tconst jpycAddress = flags.jpycAddress\n\t\t? getAddress(flags.jpycAddress)\n\t\t: getJpycAddress(profile.chain.id);\n\tconst maxPerTransfer = parseUnits(flags.maxPerTx ?? \"100\", JPYC_DECIMALS);\n\tconst maxTransfersPerDay = Number.parseInt(flags.maxPerDay ?? \"10\", 10);\n\treturn createJpycDailyLimitPolicies({\n\t\tjpycAddress,\n\t\tmaxPerTransfer,\n\t\tmaxTransfersPerDay,\n\t});\n}\n\nfunction generateEphemeralSessionKey(): Hex {\n\treturn `0x${randomBytes(32).toString(\"hex\")}` as Hex;\n}\n\nfunction loadEnvelope(envelopePath: string): KawasekitSessionEnvelope {\n\tconst raw = readFileSync(resolve(process.cwd(), envelopePath), \"utf8\");\n\treturn parseSessionEnvelope(raw);\n}\n\n// ---------------------------------------------------------------------------\n// session-key issue\n// ---------------------------------------------------------------------------\n\ninterface IssueOptions extends PolicyFlags {\n\treadonly chain?: string;\n\treadonly ownerPrivateKey?: string;\n\treadonly zerodevProjectId?: string;\n\treadonly sessionPrivateKey?: string;\n\treadonly ephemeralSession?: boolean;\n\treadonly output?: string;\n}\n\nasync function runIssue(options: IssueOptions): Promise<void> {\n\tconst profile = resolveChain(options.chain);\n\tconst ownerKey = requirePrivateKey(\n\t\toptions.ownerPrivateKey,\n\t\t\"OWNER_PRIVATE_KEY\",\n\t\t\"owner-private-key\",\n\t);\n\tconst projectId = requireValue(\n\t\toptions.zerodevProjectId,\n\t\t\"ZERODEV_PROJECT_ID\",\n\t\t\"zerodev-project-id\",\n\t);\n\tconst sessionKey =\n\t\toptions.ephemeralSession === true\n\t\t\t? generateEphemeralSessionKey()\n\t\t\t: asPrivateKey(\n\t\t\t\t\trequireValue(options.sessionPrivateKey, \"SESSION_KEY_PRIVATE_KEY\", \"session-private-key\"),\n\t\t\t\t\t\"SESSION_KEY_PRIVATE_KEY\",\n\t\t\t\t);\n\tconst owner = privateKeyToAccount(ownerKey);\n\tconst session = privateKeyToAccount(sessionKey);\n\n\tconst rpcUrl = zerodevRpcUrl(profile.chain, projectId);\n\tconst publicClient = createPublicClient({ chain: profile.chain, transport: http(rpcUrl) });\n\tconst policies = buildPolicies(profile, options);\n\n\tconst envelope = await issueSessionKey({\n\t\tpublicClient,\n\t\townerSigner: owner,\n\t\tsessionKeySigner: session,\n\t\tpolicies,\n\t\tpolicySummary: {\n\t\t\tjpycAddress: options.jpycAddress\n\t\t\t\t? getAddress(options.jpycAddress)\n\t\t\t\t: getJpycAddress(profile.chain.id),\n\t\t\tmaxPerTransfer: parseUnits(options.maxPerTx ?? \"100\", JPYC_DECIMALS),\n\t\t\tmaxTransfersPerDay: Number.parseInt(options.maxPerDay ?? \"10\", 10),\n\t\t},\n\t});\n\n\tconst wire = serializeSessionEnvelope(envelope);\n\tconsole.log(\"Chain: \", profile.displayName);\n\tconsole.log(\"Owner (EOA): \", owner.address);\n\tconsole.log(\n\t\t\"Session key (EOA): \",\n\t\tsession.address,\n\t\toptions.ephemeralSession === true ? \"(fresh ephemeral, this run only)\" : \"\",\n\t);\n\tconsole.log(\"Smart account: \", envelope.smartAccountAddress);\n\n\tif (options.output !== undefined) {\n\t\tconst outPath = resolve(process.cwd(), options.output);\n\t\twriteFileSync(outPath, wire, \"utf8\");\n\t\tconsole.log(\"Envelope written to: \", outPath);\n\t} else {\n\t\tconsole.log(\"\\n--- envelope (JSON) ---\");\n\t\tconsole.log(wire);\n\t}\n\n\tif (options.ephemeralSession === true) {\n\t\tconsole.log(\n\t\t\t\"\\n⚠️ The ephemeral session-key private key is NOT stored anywhere. Save it now if you need to restore later:\",\n\t\t);\n\t\tconsole.log(\" SESSION_KEY_PRIVATE_KEY=\", sessionKey);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// session-key restore\n// ---------------------------------------------------------------------------\n\ninterface RestoreOptions {\n\treadonly chain?: string;\n\treadonly zerodevProjectId?: string;\n\treadonly sessionPrivateKey?: string;\n\treadonly envelope?: string;\n}\n\nasync function runRestore(options: RestoreOptions): Promise<void> {\n\tconst profile = resolveChain(options.chain);\n\tconst projectId = requireValue(\n\t\toptions.zerodevProjectId,\n\t\t\"ZERODEV_PROJECT_ID\",\n\t\t\"zerodev-project-id\",\n\t);\n\tconst sessionKey = requirePrivateKey(\n\t\toptions.sessionPrivateKey,\n\t\t\"SESSION_KEY_PRIVATE_KEY\",\n\t\t\"session-private-key\",\n\t);\n\tconst envelopePath = requireValue(options.envelope, \"KAWASEKIT_ENVELOPE_PATH\", \"envelope\");\n\tconst envelope = loadEnvelope(envelopePath);\n\n\tconst rpcUrl = zerodevRpcUrl(profile.chain, projectId);\n\tconst publicClient = createPublicClient({ chain: profile.chain, transport: http(rpcUrl) });\n\n\tconst account = await restoreSessionAccount({\n\t\tpublicClient,\n\t\tenvelope,\n\t\tsessionKeySigner: privateKeyToAccount(sessionKey),\n\t});\n\n\tconsole.log(\"Chain: \", profile.displayName);\n\tconsole.log(\"Envelope chainId: \", envelope.chainId);\n\tconsole.log(\"Envelope smart account: \", envelope.smartAccountAddress);\n\tconsole.log(\"Restored account: \", account.address);\n\tif (getAddress(account.address) !== getAddress(envelope.smartAccountAddress)) {\n\t\tthrow new Error(\n\t\t\t\"Restored account address does not match the envelope's smart-account address.\",\n\t\t);\n\t}\n\tconsole.log(\"\\n✅ Envelope restored — the agent can now sign UserOps with the session key.\");\n}\n\n// ---------------------------------------------------------------------------\n// session-key revoke\n// ---------------------------------------------------------------------------\n\ninterface RevokeOptions extends PolicyFlags {\n\treadonly chain?: string;\n\treadonly ownerPrivateKey?: string;\n\treadonly zerodevProjectId?: string;\n\treadonly sessionPrivateKey?: string;\n\treadonly envelope?: string;\n}\n\nasync function runRevoke(options: RevokeOptions): Promise<void> {\n\tconst profile = resolveChain(options.chain);\n\tassertMainnetGuard(profile);\n\n\tconst ownerKey = requirePrivateKey(\n\t\toptions.ownerPrivateKey,\n\t\t\"OWNER_PRIVATE_KEY\",\n\t\t\"owner-private-key\",\n\t);\n\tconst projectId = requireValue(\n\t\toptions.zerodevProjectId,\n\t\t\"ZERODEV_PROJECT_ID\",\n\t\t\"zerodev-project-id\",\n\t);\n\tconst sessionKey = requirePrivateKey(\n\t\toptions.sessionPrivateKey,\n\t\t\"SESSION_KEY_PRIVATE_KEY\",\n\t\t\"session-private-key\",\n\t);\n\tconst envelopePath = requireValue(options.envelope, \"KAWASEKIT_ENVELOPE_PATH\", \"envelope\");\n\tconst envelope = loadEnvelope(envelopePath);\n\n\tconst owner = privateKeyToAccount(ownerKey);\n\tconst session = privateKeyToAccount(sessionKey);\n\tconst rpcUrl = zerodevRpcUrl(profile.chain, projectId);\n\tconst publicClient = createPublicClient({ chain: profile.chain, transport: http(rpcUrl) });\n\n\t// Build a sudo-only kernel client — revoke MUST go through the ECDSA\n\t// validator, not the session-key permission validator. See SDK JSDoc in\n\t// src/session/revoke.ts.\n\tconst entryPoint = getEntryPoint(\"0.7\");\n\tconst kernelVersion = KERNEL_V3_1;\n\tconst sudoValidator = await signerToEcdsaValidator(publicClient, {\n\t\tsigner: owner,\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\tconst sudoAccount = await createKernelAccount(publicClient, {\n\t\tplugins: { sudo: sudoValidator },\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\tconst paymasterClient = createZeroDevPaymasterClient({\n\t\tchain: profile.chain,\n\t\ttransport: http(rpcUrl),\n\t});\n\tconst ownerKernelClient = createKernelAccountClient({\n\t\taccount: sudoAccount,\n\t\tchain: profile.chain,\n\t\tclient: publicClient,\n\t\tbundlerTransport: http(rpcUrl),\n\t\tpaymaster: {\n\t\t\tgetPaymasterData: (userOperation) => paymasterClient.sponsorUserOperation({ userOperation }),\n\t\t},\n\t});\n\n\tconst policies = buildPolicies(profile, options);\n\tconsole.log(\"Chain: \", profile.displayName);\n\tconsole.log(\"Owner (EOA): \", owner.address);\n\tconsole.log(\"Session key (EOA): \", session.address);\n\tconsole.log(\"Smart account: \", envelope.smartAccountAddress);\n\tconsole.log(\"\\nRevoking session validator (uninstallValidation)...\");\n\n\tconst result = await revokeSessionKey({\n\t\townerKernelClient,\n\t\tenvelope,\n\t\tsessionKeySigner: session,\n\t\tpolicies,\n\t});\n\tconsole.log(\"userOp hash: \", result.userOpHash);\n\tconsole.log(\"bundle tx hash: \", result.transactionHash);\n\tif (result.transactionHash) {\n\t\tconsole.log(\"explorer: \", `${profile.explorerTxBase}${result.transactionHash}`);\n\t}\n\tif (!result.success) {\n\t\tthrow new Error(\"Revoke UserOp reported failure.\");\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// session-key rotate\n// ---------------------------------------------------------------------------\n\ninterface RotateOptions extends PolicyFlags {\n\treadonly chain?: string;\n\treadonly ownerPrivateKey?: string;\n\treadonly zerodevProjectId?: string;\n\treadonly oldSessionPrivateKey?: string;\n\treadonly oldEnvelope?: string;\n\treadonly newSessionPrivateKey?: string;\n\treadonly ephemeralNewSession?: boolean;\n\treadonly output?: string;\n}\n\nasync function runRotate(options: RotateOptions): Promise<void> {\n\tconst profile = resolveChain(options.chain);\n\tassertMainnetGuard(profile);\n\n\tconst ownerKey = requirePrivateKey(\n\t\toptions.ownerPrivateKey,\n\t\t\"OWNER_PRIVATE_KEY\",\n\t\t\"owner-private-key\",\n\t);\n\tconst projectId = requireValue(\n\t\toptions.zerodevProjectId,\n\t\t\"ZERODEV_PROJECT_ID\",\n\t\t\"zerodev-project-id\",\n\t);\n\tconst oldSessionKey = requirePrivateKey(\n\t\toptions.oldSessionPrivateKey,\n\t\t\"SESSION_KEY_PRIVATE_KEY\",\n\t\t\"old-session-private-key\",\n\t);\n\tconst oldEnvelopePath = requireValue(\n\t\toptions.oldEnvelope,\n\t\t\"KAWASEKIT_ENVELOPE_PATH\",\n\t\t\"old-envelope\",\n\t);\n\tconst oldEnvelope = loadEnvelope(oldEnvelopePath);\n\n\tconst newSessionKey =\n\t\toptions.ephemeralNewSession === true\n\t\t\t? generateEphemeralSessionKey()\n\t\t\t: asPrivateKey(\n\t\t\t\t\trequireValue(\n\t\t\t\t\t\toptions.newSessionPrivateKey,\n\t\t\t\t\t\t\"SESSION_KEY_PRIVATE_KEY_NEW\",\n\t\t\t\t\t\t\"new-session-private-key\",\n\t\t\t\t\t),\n\t\t\t\t\t\"new session private key\",\n\t\t\t\t);\n\n\tconst owner = privateKeyToAccount(ownerKey);\n\tconst oldSession = privateKeyToAccount(oldSessionKey);\n\tconst newSession = privateKeyToAccount(newSessionKey);\n\n\tconst rpcUrl = zerodevRpcUrl(profile.chain, projectId);\n\tconst publicClient = createPublicClient({ chain: profile.chain, transport: http(rpcUrl) });\n\tconst entryPoint = getEntryPoint(\"0.7\");\n\tconst kernelVersion = KERNEL_V3_1;\n\tconst sudoValidator = await signerToEcdsaValidator(publicClient, {\n\t\tsigner: owner,\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\tconst sudoAccount = await createKernelAccount(publicClient, {\n\t\tplugins: { sudo: sudoValidator },\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\tconst paymasterClient = createZeroDevPaymasterClient({\n\t\tchain: profile.chain,\n\t\ttransport: http(rpcUrl),\n\t});\n\tconst ownerKernelClient = createKernelAccountClient({\n\t\taccount: sudoAccount,\n\t\tchain: profile.chain,\n\t\tclient: publicClient,\n\t\tbundlerTransport: http(rpcUrl),\n\t\tpaymaster: {\n\t\t\tgetPaymasterData: (userOperation) => paymasterClient.sponsorUserOperation({ userOperation }),\n\t\t},\n\t});\n\n\tconst policies = buildPolicies(profile, options);\n\tconst policySummary = {\n\t\tjpycAddress: options.jpycAddress\n\t\t\t? getAddress(options.jpycAddress)\n\t\t\t: getJpycAddress(profile.chain.id),\n\t\tmaxPerTransfer: parseUnits(options.maxPerTx ?? \"100\", JPYC_DECIMALS),\n\t\tmaxTransfersPerDay: Number.parseInt(options.maxPerDay ?? \"10\", 10),\n\t};\n\n\tconsole.log(\"Chain: \", profile.displayName);\n\tconsole.log(\"Owner (EOA): \", owner.address);\n\tconsole.log(\"Old session key (EOA): \", oldSession.address);\n\tconsole.log(\"New session key (EOA): \", newSession.address);\n\tconsole.log(\"Smart account: \", oldEnvelope.smartAccountAddress);\n\tconsole.log(\"\\nRotating: revoke old → issue new (awaits revoke receipt)...\");\n\n\tconst { revoke, envelope } = await rotateSessionKey({\n\t\trevoke: {\n\t\t\townerKernelClient,\n\t\t\tenvelope: oldEnvelope,\n\t\t\tsessionKeySigner: oldSession,\n\t\t\tpolicies,\n\t\t},\n\t\tissue: {\n\t\t\tpublicClient,\n\t\t\townerSigner: owner,\n\t\t\tsessionKeySigner: newSession,\n\t\t\tpolicies,\n\t\t\tpolicySummary,\n\t\t},\n\t});\n\tconsole.log(\"revoke userOp hash: \", revoke.userOpHash);\n\tconsole.log(\"revoke bundle tx: \", revoke.transactionHash);\n\tif (revoke.transactionHash) {\n\t\tconsole.log(\"revoke explorer: \", `${profile.explorerTxBase}${revoke.transactionHash}`);\n\t}\n\tif (!revoke.success) {\n\t\tthrow new Error(\"Revoke step failed — new envelope was NOT issued.\");\n\t}\n\n\tconst wire = serializeSessionEnvelope(envelope);\n\tif (options.output !== undefined) {\n\t\tconst outPath = resolve(process.cwd(), options.output);\n\t\twriteFileSync(outPath, wire, \"utf8\");\n\t\tconsole.log(\"\\nNew envelope written: \", outPath);\n\t} else {\n\t\tconsole.log(\"\\n--- new envelope (JSON) ---\");\n\t\tconsole.log(wire);\n\t}\n\tif (options.ephemeralNewSession === true) {\n\t\tconsole.log(\n\t\t\t\"\\n⚠️ The new ephemeral session-key private key is NOT stored anywhere. Save it now if you need to restore later:\",\n\t\t);\n\t\tconsole.log(\" SESSION_KEY_PRIVATE_KEY=\", newSessionKey);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Command registration\n// ---------------------------------------------------------------------------\n\nexport function registerSessionKeyCommand(program: Command): void {\n\tconst sessionKey = program\n\t\t.command(\"session-key\")\n\t\t.description(\"Issue / restore / revoke / rotate agent session keys\");\n\n\tsessionKey\n\t\t.command(\"issue\")\n\t\t.description(\"Owner issues a session-key envelope for the agent\")\n\t\t.requiredOption(\"--chain <chain>\", '\"polygon\" | \"polygonAmoy\"')\n\t\t.option(\"--owner-private-key <hex>\", \"Owner EOA private key (or env OWNER_PRIVATE_KEY)\")\n\t\t.option(\"--zerodev-project-id <id>\", \"ZeroDev project ID (or env ZERODEV_PROJECT_ID)\")\n\t\t.option(\n\t\t\t\"--session-private-key <hex>\",\n\t\t\t\"Session EOA private key (or env SESSION_KEY_PRIVATE_KEY)\",\n\t\t)\n\t\t.option(\n\t\t\t\"--ephemeral-session\",\n\t\t\t\"Generate a fresh ephemeral session key for this run (use for production rotation; printed at end, never stored automatically)\",\n\t\t)\n\t\t.option(\"--max-per-tx <human>\", 'Per-transfer cap in decimal JPYC. Default \"100\".')\n\t\t.option(\"--max-per-day <count>\", 'Maximum transfers per 24h window. Default \"10\".')\n\t\t.option(\n\t\t\t\"--jpyc-address <address>\",\n\t\t\t\"JPYC contract override. Defaults to the canonical kawasekit address.\",\n\t\t)\n\t\t.option(\"--output <path>\", \"Write the envelope JSON to this path instead of stdout.\")\n\t\t.action(async (options: IssueOptions) => {\n\t\t\tawait runIssue(options);\n\t\t});\n\n\tsessionKey\n\t\t.command(\"restore\")\n\t\t.description(\"Agent restores a smart-account client from an envelope file\")\n\t\t.requiredOption(\"--chain <chain>\", '\"polygon\" | \"polygonAmoy\"')\n\t\t.option(\"--zerodev-project-id <id>\", \"ZeroDev project ID (or env ZERODEV_PROJECT_ID)\")\n\t\t.option(\n\t\t\t\"--session-private-key <hex>\",\n\t\t\t\"Session EOA private key (or env SESSION_KEY_PRIVATE_KEY)\",\n\t\t)\n\t\t.option(\"--envelope <path>\", \"Path to the envelope JSON file\")\n\t\t.action(async (options: RestoreOptions) => {\n\t\t\tawait runRestore(options);\n\t\t});\n\n\tsessionKey\n\t\t.command(\"revoke\")\n\t\t.description(\"Owner revokes a session key by uninstalling its permission validator\")\n\t\t.requiredOption(\"--chain <chain>\", '\"polygon\" | \"polygonAmoy\"')\n\t\t.option(\"--owner-private-key <hex>\", \"Owner EOA private key (or env OWNER_PRIVATE_KEY)\")\n\t\t.option(\"--zerodev-project-id <id>\", \"ZeroDev project ID (or env ZERODEV_PROJECT_ID)\")\n\t\t.option(\"--session-private-key <hex>\", \"Session EOA private key the validator was issued under\")\n\t\t.option(\"--envelope <path>\", \"Path to the envelope JSON file to revoke\")\n\t\t.option(\n\t\t\t\"--max-per-tx <human>\",\n\t\t\t'Per-transfer cap (must match issue-time value). Default \"100\".',\n\t\t)\n\t\t.option(\n\t\t\t\"--max-per-day <count>\",\n\t\t\t'Daily transfer count (must match issue-time value). Default \"10\".',\n\t\t)\n\t\t.option(\"--jpyc-address <address>\", \"JPYC contract override.\")\n\t\t.action(async (options: RevokeOptions) => {\n\t\t\tawait runRevoke(options);\n\t\t});\n\n\tsessionKey\n\t\t.command(\"rotate\")\n\t\t.description(\"Revoke the old session and issue a new one in one shot (atomic-ish)\")\n\t\t.requiredOption(\"--chain <chain>\", '\"polygon\" | \"polygonAmoy\"')\n\t\t.option(\"--owner-private-key <hex>\", \"Owner EOA private key (or env OWNER_PRIVATE_KEY)\")\n\t\t.option(\"--zerodev-project-id <id>\", \"ZeroDev project ID (or env ZERODEV_PROJECT_ID)\")\n\t\t.option(\n\t\t\t\"--old-session-private-key <hex>\",\n\t\t\t\"Old session-key private key (or env SESSION_KEY_PRIVATE_KEY)\",\n\t\t)\n\t\t.option(\"--old-envelope <path>\", \"Path to the old envelope JSON file\")\n\t\t.option(\n\t\t\t\"--new-session-private-key <hex>\",\n\t\t\t\"New session-key private key (or env SESSION_KEY_PRIVATE_KEY_NEW)\",\n\t\t)\n\t\t.option(\n\t\t\t\"--ephemeral-new-session\",\n\t\t\t\"Generate a fresh ephemeral new session key for this rotation\",\n\t\t)\n\t\t.option(\"--max-per-tx <human>\", 'Per-transfer cap (same for old + new). Default \"100\".')\n\t\t.option(\"--max-per-day <count>\", 'Daily transfer count (same for old + new). Default \"10\".')\n\t\t.option(\"--jpyc-address <address>\", \"JPYC contract override.\")\n\t\t.option(\"--output <path>\", \"Write the new envelope JSON to this path.\")\n\t\t.action(async (options: RotateOptions) => {\n\t\t\tawait runRotate(options);\n\t\t});\n}\n","import { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\nimport {\n\tcreateKernelAccount,\n\tcreateKernelAccountClient,\n\tcreateZeroDevPaymasterClient,\n} from \"@zerodev/sdk\";\nimport { getEntryPoint, KERNEL_V3_1 } from \"@zerodev/sdk/constants\";\nimport type { Command } from \"commander\";\nimport { type Address, createPublicClient, getAddress, http, parseUnits } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { getJpycAddress, JPYC_DECIMALS, jpycAbi, transferJpyc, zerodevRpcUrl } from \"../../src\";\nimport { assertMainnetGuard, resolveChain } from \"../lib/chain\";\nimport { requirePrivateKey, requireValue, resolveValue } from \"../lib/env\";\n\ninterface TransferOptions {\n\treadonly chain?: string;\n\treadonly ownerPrivateKey?: string;\n\treadonly zerodevProjectId?: string;\n\treadonly to?: string;\n\treadonly amount?: string;\n}\n\nasync function runTransfer(options: TransferOptions): Promise<void> {\n\tconst profile = resolveChain(options.chain);\n\tassertMainnetGuard(profile);\n\n\tconst ownerKey = requirePrivateKey(\n\t\toptions.ownerPrivateKey,\n\t\t\"OWNER_PRIVATE_KEY\",\n\t\t\"owner-private-key\",\n\t);\n\tconst projectId = requireValue(\n\t\toptions.zerodevProjectId,\n\t\t\"ZERODEV_PROJECT_ID\",\n\t\t\"zerodev-project-id\",\n\t);\n\tconst amountHuman = options.amount ?? resolveValue(undefined, \"JPYC_AMOUNT_HUMAN\") ?? \"1\";\n\tconst amount = parseUnits(amountHuman, JPYC_DECIMALS);\n\n\tconst owner = privateKeyToAccount(ownerKey);\n\tconst rpcUrl = zerodevRpcUrl(profile.chain, projectId);\n\tconst publicClient = createPublicClient({ chain: profile.chain, transport: http(rpcUrl) });\n\tconst entryPoint = getEntryPoint(\"0.7\");\n\tconst kernelVersion = KERNEL_V3_1;\n\tconst sudoValidator = await signerToEcdsaValidator(publicClient, {\n\t\tsigner: owner,\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\tconst account = await createKernelAccount(publicClient, {\n\t\tplugins: { sudo: sudoValidator },\n\t\tentryPoint,\n\t\tkernelVersion,\n\t});\n\tconst paymasterClient = createZeroDevPaymasterClient({\n\t\tchain: profile.chain,\n\t\ttransport: http(rpcUrl),\n\t});\n\tconst kernelClient = createKernelAccountClient({\n\t\taccount,\n\t\tchain: profile.chain,\n\t\tclient: publicClient,\n\t\tbundlerTransport: http(rpcUrl),\n\t\tpaymaster: {\n\t\t\tgetPaymasterData: (userOperation) => paymasterClient.sponsorUserOperation({ userOperation }),\n\t\t},\n\t});\n\n\tconst jpycAddress = getJpycAddress(profile.chain.id);\n\tconst balance = (await publicClient.readContract({\n\t\taddress: jpycAddress,\n\t\tabi: jpycAbi,\n\t\tfunctionName: \"balanceOf\",\n\t\targs: [account.address],\n\t})) as bigint;\n\n\tconst recipientRaw = options.to ?? resolveValue(undefined, \"JPYC_RECIPIENT\") ?? account.address;\n\tconst recipient: Address = getAddress(recipientRaw);\n\n\tconsole.log(\"Chain: \", profile.displayName);\n\tconsole.log(\"Owner (EOA): \", owner.address);\n\tconsole.log(\"Smart account: \", account.address);\n\tconsole.log(\"JPYC contract: \", jpycAddress);\n\tconsole.log(\"Smart-account JPYC balance:\", balance.toString(), \"wei\");\n\tconsole.log(\"Recipient: \", recipient);\n\tconsole.log(\"Amount: \", amountHuman, \"JPYC =\", amount.toString(), \"wei\");\n\n\tif (amount === 0n) {\n\t\tthrow new Error(\"--amount must be greater than 0.\");\n\t}\n\tif (balance < amount) {\n\t\tthrow new Error(\n\t\t\t`Smart account has insufficient JPYC. Need ${amount.toString()} wei, has ${balance.toString()} wei. Fund ${account.address} before retrying.`,\n\t\t);\n\t}\n\n\tconsole.log(`\\nSending ${amountHuman} JPYC via sponsored UserOp...`);\n\tconst result = await transferJpyc(kernelClient, { to: recipient, amount });\n\tconsole.log(\"userOp hash: \", result.userOpHash);\n\tconsole.log(\"bundle tx hash: \", result.transactionHash);\n\tif (result.transactionHash) {\n\t\tconsole.log(\"explorer: \", `${profile.explorerTxBase}${result.transactionHash}`);\n\t}\n\tif (!result.success) {\n\t\tthrow new Error(\"UserOp reported failure — see explorer for revert reason.\");\n\t}\n}\n\nexport function registerTransferCommand(program: Command): void {\n\tprogram\n\t\t.command(\"transfer\")\n\t\t.description(\"Send JPYC from a smart account via a sponsored UserOp\")\n\t\t.requiredOption(\"--chain <chain>\", '\"polygon\" | \"polygonAmoy\"')\n\t\t.option(\"--owner-private-key <hex>\", \"Owner EOA private key (or env OWNER_PRIVATE_KEY)\")\n\t\t.option(\"--zerodev-project-id <id>\", \"ZeroDev project ID (or env ZERODEV_PROJECT_ID)\")\n\t\t.option(\n\t\t\t\"--to <address>\",\n\t\t\t\"Recipient address. Defaults to the smart account itself (loop-back) when unset.\",\n\t\t)\n\t\t.option(\"--amount <human>\", 'Amount in decimal JPYC (e.g. 0.001). Default \"1\".')\n\t\t.action(async (options: TransferOptions) => {\n\t\t\tawait runTransfer(options);\n\t\t});\n}\n","#!/usr/bin/env node\n\n/**\n * kawasekit CLI entry.\n *\n * Subcommands:\n * init — scaffold .env.example\n * account create — derive / deploy a smart account\n * transfer — send JPYC via sponsored UserOp\n * policy create — dry-run the daily-limit policy\n * session-key issue|restore|revoke|rotate\n * — agent session-key lifecycle\n *\n * Every subcommand that touches a network requires `--chain polygon|polygonAmoy`.\n * Mainnet broadcasts additionally require `KAWASEKIT_ALLOW_MAINNET=1` in the\n * environment.\n */\n\nimport { Command } from \"commander\";\nimport { registerAccountCommand } from \"./commands/account\";\nimport { registerInitCommand } from \"./commands/init\";\nimport { registerPolicyCommand } from \"./commands/policy\";\nimport { registerSessionKeyCommand } from \"./commands/session-key\";\nimport { registerTransferCommand } from \"./commands/transfer\";\n\n// `.env` is loaded lazily by resolveValue / requireValue (cli/lib/env.ts),\n// only when a command actually reads a value — so `--version` / `--help`\n// never touch the filesystem or the environment.\n//\n// __KAWASEKIT_VERSION__ is replaced at build time by tsup's `define` (see\n// tsup.config.ts) with the literal package.json version. When the CLI runs\n// from un-built source (tsx, the cli-smoke tests) the identifier is undefined;\n// the `typeof` guard avoids a ReferenceError and falls back to a dev marker.\ndeclare const __KAWASEKIT_VERSION__: string;\nconst CLI_VERSION = typeof __KAWASEKIT_VERSION__ === \"string\" ? __KAWASEKIT_VERSION__ : \"0.0.0-dev\";\n\nconst program = new Command();\nprogram\n\t.name(\"kawasekit\")\n\t.description(\n\t\t\"kawasekit — CLI for the kawasekit SDK (AI-agent stablecoin payments, Japan-first, JPYC-native).\",\n\t)\n\t.version(CLI_VERSION);\n\nregisterInitCommand(program);\nregisterAccountCommand(program);\nregisterTransferCommand(program);\nregisterPolicyCommand(program);\nregisterSessionKeyCommand(program);\n\nprogram.parseAsync().catch((error: unknown) => {\n\tconsole.error(error instanceof Error ? error.message : String(error));\n\tprocess.exitCode = 1;\n});\n"]}