tenjin-cli 0.1.0-alpha.25 → 0.1.0-alpha.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +14 -41
  2. package/dist/{chunk-EG7P4SM6.js → chunk-4HAV6IFE.js} +5 -5
  3. package/dist/{chunk-IYLECN4D.js → chunk-5HS54CLI.js} +2 -2
  4. package/dist/{chunk-CEMXMUIU.js → chunk-5INS5ZZF.js} +35 -6
  5. package/dist/chunk-5INS5ZZF.js.map +1 -0
  6. package/dist/{chunk-CKDD554V.js → chunk-5NUF4BHR.js} +5 -3
  7. package/dist/{chunk-CKDD554V.js.map → chunk-5NUF4BHR.js.map} +1 -1
  8. package/dist/{chunk-NTYQHAIM.js → chunk-65EJJVT3.js} +2 -2
  9. package/dist/{chunk-GT6W3VJM.js → chunk-6JIYGYRB.js} +2 -52
  10. package/dist/chunk-6JIYGYRB.js.map +1 -0
  11. package/dist/{chunk-EOGJKIOG.js → chunk-ALJRB7NG.js} +10 -3
  12. package/dist/chunk-ALJRB7NG.js.map +1 -0
  13. package/dist/chunk-BOAI23CX.js +222 -0
  14. package/dist/chunk-BOAI23CX.js.map +1 -0
  15. package/dist/{chunk-KGTQRJGS.js → chunk-DI7WHXOZ.js} +5 -10
  16. package/dist/{chunk-KGTQRJGS.js.map → chunk-DI7WHXOZ.js.map} +1 -1
  17. package/dist/{chunk-DRXDTITB.js → chunk-EJXIK6WY.js} +9 -9
  18. package/dist/{chunk-ODH7UXIS.js → chunk-GHR4BTNJ.js} +3 -2
  19. package/dist/{chunk-ODH7UXIS.js.map → chunk-GHR4BTNJ.js.map} +1 -1
  20. package/dist/chunk-H4BOQLWW.js +99 -0
  21. package/dist/chunk-H4BOQLWW.js.map +1 -0
  22. package/dist/{chunk-VYONGSMQ.js → chunk-OBPZ36HG.js} +29 -3
  23. package/dist/chunk-OBPZ36HG.js.map +1 -0
  24. package/dist/chunk-PM2MOXJ3.js +66 -0
  25. package/dist/chunk-PM2MOXJ3.js.map +1 -0
  26. package/dist/chunk-PZ5N6BAL.js +268 -0
  27. package/dist/chunk-PZ5N6BAL.js.map +1 -0
  28. package/dist/{chunk-YSW57KUT.js → chunk-VNT3CQFV.js} +17 -17
  29. package/dist/chunk-VNT3CQFV.js.map +1 -0
  30. package/dist/{chunk-SCAE6PW6.js → chunk-W36HL4TB.js} +4 -4
  31. package/dist/{chunk-NYPFOHSJ.js → chunk-WT7DHJNJ.js} +2 -2
  32. package/dist/chunk-XMIVHQ35.js +55 -0
  33. package/dist/chunk-XMIVHQ35.js.map +1 -0
  34. package/dist/{chunk-3ZYPVSIU.js → chunk-YHWBDCGS.js} +234 -41
  35. package/dist/chunk-YHWBDCGS.js.map +1 -0
  36. package/dist/{chunk-CP7O6M55.js → chunk-YLCWI6ZR.js} +61 -20
  37. package/dist/chunk-YLCWI6ZR.js.map +1 -0
  38. package/dist/{chunk-EACMJEF3.js → chunk-Z7R2QDX2.js} +35 -171
  39. package/dist/chunk-Z7R2QDX2.js.map +1 -0
  40. package/dist/chunk-ZLD6MJVJ.js +30 -0
  41. package/dist/chunk-ZLD6MJVJ.js.map +1 -0
  42. package/dist/{cli-4WMGZPBP.js → cli-2U5JB7OQ.js} +34 -31
  43. package/dist/{cli-4WMGZPBP.js.map → cli-2U5JB7OQ.js.map} +1 -1
  44. package/dist/{config-VU6U7QOU.js → config-44EGO636.js} +11 -7
  45. package/dist/{doctor-26JS2SG3.js → doctor-BD42BBEG.js} +136 -94
  46. package/dist/doctor-BD42BBEG.js.map +1 -0
  47. package/dist/env-proxy-KEGEMWKX.js +15 -0
  48. package/dist/{fund-JJN3FRRF.js → fund-WQOOUESE.js} +20 -10
  49. package/dist/{fund-JJN3FRRF.js.map → fund-WQOOUESE.js.map} +1 -1
  50. package/dist/{hook-command-S2V4UNB3.js → hook-command-23LC5NRN.js} +12 -8
  51. package/dist/index.js +4 -2
  52. package/dist/index.js.map +1 -1
  53. package/dist/{install-GXQ33J4G.js → install-REPLHNU7.js} +19 -13
  54. package/dist/{install-identity-HFQUXPSI.js → install-identity-4RDWTLJ2.js} +4 -4
  55. package/dist/{install-wallet-27LTEHBI.js → install-wallet-USHWL7AX.js} +8 -6
  56. package/dist/{install-wallet-27LTEHBI.js.map → install-wallet-USHWL7AX.js.map} +1 -1
  57. package/dist/{mcp-AHCZVD2U.js → mcp-T5SYCLP7.js} +238 -64
  58. package/dist/mcp-T5SYCLP7.js.map +1 -0
  59. package/dist/{pay-3TCOPGCX.js → pay-276DSSYG.js} +10 -9
  60. package/dist/{payments-H3LSBGSL.js → payments-TZYLJXK3.js} +5 -4
  61. package/dist/{payments-H3LSBGSL.js.map → payments-TZYLJXK3.js.map} +1 -1
  62. package/dist/{send-LKCLN5GA.js → send-YHDKZPED.js} +6 -5
  63. package/dist/{send-LKCLN5GA.js.map → send-YHDKZPED.js.map} +1 -1
  64. package/dist/{status-2FDGI4LQ.js → status-X2INT6VD.js} +4 -3
  65. package/dist/{status-2FDGI4LQ.js.map → status-X2INT6VD.js.map} +1 -1
  66. package/dist/{status-line-wiring-ZDBYHNYR.js → status-line-wiring-LW4HFRHB.js} +4 -4
  67. package/dist/{uninstall-ZXWABDHS.js → uninstall-NVTGU7JD.js} +21 -15
  68. package/dist/{uninstall-ZXWABDHS.js.map → uninstall-NVTGU7JD.js.map} +1 -1
  69. package/dist/{update-HEIWVOP5.js → update-QXVH2DE7.js} +17 -10
  70. package/dist/update-QXVH2DE7.js.map +1 -0
  71. package/dist/{wallet-T7JYWI6O.js → wallet-CKKB23D5.js} +8 -6
  72. package/dist/wallet-CKKB23D5.js.map +1 -0
  73. package/docs/agent-permissions.md +14 -4
  74. package/docs/troubleshooting.md +13 -0
  75. package/package.json +2 -1
  76. package/dist/chunk-3ZYPVSIU.js.map +0 -1
  77. package/dist/chunk-CEMXMUIU.js.map +0 -1
  78. package/dist/chunk-CP7O6M55.js.map +0 -1
  79. package/dist/chunk-EACMJEF3.js.map +0 -1
  80. package/dist/chunk-EOGJKIOG.js.map +0 -1
  81. package/dist/chunk-GT6W3VJM.js.map +0 -1
  82. package/dist/chunk-VYONGSMQ.js.map +0 -1
  83. package/dist/chunk-YSW57KUT.js.map +0 -1
  84. package/dist/doctor-26JS2SG3.js.map +0 -1
  85. package/dist/mcp-AHCZVD2U.js.map +0 -1
  86. package/dist/update-HEIWVOP5.js.map +0 -1
  87. /package/dist/{chunk-EG7P4SM6.js.map → chunk-4HAV6IFE.js.map} +0 -0
  88. /package/dist/{chunk-IYLECN4D.js.map → chunk-5HS54CLI.js.map} +0 -0
  89. /package/dist/{chunk-NTYQHAIM.js.map → chunk-65EJJVT3.js.map} +0 -0
  90. /package/dist/{chunk-DRXDTITB.js.map → chunk-EJXIK6WY.js.map} +0 -0
  91. /package/dist/{chunk-SCAE6PW6.js.map → chunk-W36HL4TB.js.map} +0 -0
  92. /package/dist/{chunk-NYPFOHSJ.js.map → chunk-WT7DHJNJ.js.map} +0 -0
  93. /package/dist/{config-VU6U7QOU.js.map → config-44EGO636.js.map} +0 -0
  94. /package/dist/{hook-command-S2V4UNB3.js.map → env-proxy-KEGEMWKX.js.map} +0 -0
  95. /package/dist/{install-GXQ33J4G.js.map → hook-command-23LC5NRN.js.map} +0 -0
  96. /package/dist/{install-identity-HFQUXPSI.js.map → install-REPLHNU7.js.map} +0 -0
  97. /package/dist/{pay-3TCOPGCX.js.map → install-identity-4RDWTLJ2.js.map} +0 -0
  98. /package/dist/{status-line-wiring-ZDBYHNYR.js.map → pay-276DSSYG.js.map} +0 -0
  99. /package/dist/{wallet-T7JYWI6O.js.map → status-line-wiring-LW4HFRHB.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/wallet.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { CliError } from '../lib/errors';\nimport { walletPath } from '../lib/paths';\nimport { withFileLock, LockTimeoutError } from '../lib/lock';\nimport { loadRawConfig, resolveSettings } from '../lib/config';\nimport { toMoney } from '../lib/money';\nimport { getUsdcBalance } from '../lib/usdc';\nimport { addressQrLines } from '../lib/qr';\nimport {\n commitLocalWallet,\n createLocalWallet,\n describeWallet,\n parkOutgoingWallet,\n prepareLocalWallet,\n resolveWalletProvider,\n restoreParkedWallet,\n verifyAndPreserveOutgoingWallet,\n type ArchivedWalletInfo,\n type ResolveWalletProviderOptions,\n} from '../lib/wallet';\nimport { walletExistsError, walletFileExists } from '../lib/wallet/store';\nimport { resolvePassphraseForCreate, type PassphraseSource } from '../lib/wallet/passphrase';\nimport type { PassphraseOverrides } from '../lib/wallet/local';\nimport type { CommandContext, CommandResult } from '../context';\n\nconst FUNDING_LINE =\n 'Fund it with `tenjin wallet fund` (card via Coinbase), or send USDC on Base. $5 covers ~50 typical resources.';\nconst KEY_STORAGE = 'encrypted (keystore v3, scrypt)';\nconst isWindows = process.platform === 'win32';\n\nexport interface WalletCreateOptions {\n /**\n * Explicitly replace the existing active wallet (mirrors the `--yes`-style\n * explicit-flag precedent): the outgoing wallet is ARCHIVED — passphrase\n * verified against its keystore and preserved under its own address, keystore\n * parked beside the new one — never destroyed. Without it, create refuses\n * when a wallet exists. There is always exactly ONE active wallet.\n */\n replace?: boolean;\n /** Test seam for passphrase resolution (keychain exec, TTY prompt, platform). */\n passphrase?: PassphraseOverrides;\n /**\n * The environment TENJIN_WALLET_PASSPHRASE is read from; defaults to\n * process.env. A seam rather than a global read so a caller (and above all a\n * test) can settle the passphrase source WITHOUT mutating the real process\n * environment, which under a parallel runner leaks across whole test files.\n */\n env?: NodeJS.ProcessEnv;\n}\n\nexport async function runWalletCreate(\n ctx: CommandContext,\n opts: WalletCreateOptions = {},\n): Promise<CommandResult> {\n const {\n address,\n walletPath: path,\n source,\n replaced,\n } = await createWalletLocked(ctx.dataDir, opts);\n\n const warnings = custodyWarnings();\n return {\n data: {\n address,\n walletPath: path,\n provider: 'local',\n policyEnforcement: 'client-only',\n keyStorage: KEY_STORAGE,\n passphraseSource: source,\n ...(replaced !== undefined\n ? {\n replaced: {\n address: replaced.address,\n archivedWalletPath: replaced.archivedPath,\n passphrasePreserved: replaced.passphraseLocation,\n ...(replaced.unarchivedReason !== undefined\n ? { unarchivedReason: replaced.unarchivedReason }\n : {}),\n },\n }\n : {}),\n warnings,\n },\n humanLines: [\n `Wallet created: ${address}`,\n `Key stored ${KEY_STORAGE}.`,\n passphraseNote(source, address),\n ...(replaced !== undefined ? replacedNote(replaced, path) : []),\n FUNDING_LINE,\n ...warnings,\n ],\n };\n}\n\n/** Where the outgoing wallet's funds live, why they remain reachable, and how to restore it. */\nfunction replacedNote(replaced: ArchivedWalletInfo, activeWalletPath: string): string[] {\n const passphraseLine =\n replaced.passphraseLocation === 'store'\n ? `its passphrase is preserved in the OS credential store (service tenjin-cli, account ${replaced.account}).`\n : replaced.passphraseLocation === 'env'\n ? 'its passphrase is TENJIN_WALLET_PASSPHRASE — keep that value.'\n : replaced.unarchivedReason === 'rejected-characters'\n ? 'its passphrase was NOT archived: the macOS keychain writer only stores machine-generated (base64url) passphrases, and this typed one contains other characters. Keep it yourself, or set TENJIN_WALLET_PASSPHRASE to it.'\n : replaced.unarchivedReason === 'no-store'\n ? 'its passphrase was NOT archived: this platform has no OS credential store. It exists only where you keep it.'\n : 'its passphrase was NOT archived: the OS credential store write failed. It exists only where you keep it.';\n return [\n `Previous wallet archived: ${replaced.address} still holds any funds sent to it.`,\n `Its keystore was moved to ${replaced.archivedPath}; ${passphraseLine}`,\n `To make it the active wallet again later: move the current ${activeWalletPath} aside first, then \\`mv ${replaced.archivedPath} ${activeWalletPath}\\`.`,\n ];\n}\n\n/**\n * Run the whole create critical section under a cross-process file lock: the\n * existence pre-check, the passphrase generate-and-store, and the no-clobber\n * write. Without the lock these interleave across two concurrent creates — each\n * generates a distinct passphrase and persists it to the OS store BEFORE the\n * exclusive file write, so a different process could win the file while this\n * one's per-address entry names a wallet that never landed. Serializing means\n * the loser blocks until the winner commits, then trips the exists check and\n * exits WALLET_EXISTS having never generated or stored a passphrase. The\n * store-before-write ordering stays (it still guards the single-process crash\n * window), and the exclusive write stays the final authority.\n *\n * The passphrase is resolved inside the prepare step's address callback so the\n * OS-store entry is keyed to the new wallet's own address (issue #32).\n *\n * `--replace` ordering closes the no-active-wallet window: verify-and-preserve\n * the outgoing wallet (no file moves), fully PREPARE the replacement (key,\n * stored passphrase, encrypted keystore — every fallible step) while the old\n * wallet is still active, and only then park the old keystore and commit the\n * new one. A commit failure rolls the park back, so at every exit either the\n * old or the new wallet is the active one.\n */\nasync function createWalletLocked(\n dir: string,\n opts: WalletCreateOptions,\n): Promise<{\n address: string;\n walletPath: string;\n source: PassphraseSource;\n replaced?: ArchivedWalletInfo;\n}> {\n // Ensure the data dir exists so the lock's own mkdir has a parent on a fresh\n // install; the exclusive wallet write below re-ensures it at 0700 regardless.\n await mkdir(dir, { recursive: true, mode: 0o700 });\n const lockPath = join(dir, 'wallet.create.lock');\n try {\n return await withFileLock(lockPath, async () => {\n const env = opts.env ?? process.env;\n let source: PassphraseSource = 'env';\n const passphraseFor = async (forAddress: string): Promise<string> => {\n const resolved = await resolvePassphraseForCreate(\n { env, dir, ...opts.passphrase },\n forAddress,\n );\n source = resolved.source;\n return resolved.passphrase;\n };\n\n if (!(await walletFileExists(dir))) {\n const { address, walletPath: path } = await createLocalWallet(dir, passphraseFor);\n return { address, walletPath: path, source };\n }\n\n if (opts.replace !== true) throw walletExistsError(dir);\n const preserved = await verifyAndPreserveOutgoingWallet({\n dir,\n env,\n ...(opts.passphrase !== undefined ? { passphrase: opts.passphrase } : {}),\n });\n const prepared = await prepareLocalWallet(passphraseFor);\n const archivedPath = await parkOutgoingWallet(dir, preserved.account);\n try {\n const { address, walletPath: path } = await commitLocalWallet(dir, prepared);\n return { address, walletPath: path, source, replaced: { ...preserved, archivedPath } };\n } catch (err) {\n try {\n await restoreParkedWallet(dir, archivedPath);\n } catch (restoreErr) {\n // The no-clobber restore also refuses when a wallet.json appeared out\n // of band (commit EEXIST) — never overwrite it; name both files.\n throw new CliError(\n 'INTERNAL',\n 'Creating the replacement wallet failed after the old wallet was parked, and restoring it also failed.',\n {\n fix: `Your old wallet ${preserved.address} is intact at ${archivedPath} with its passphrase preserved. If a ${walletPath(dir)} now exists, another process wrote it — move it aside first. Then restore with \\`mv ${archivedPath} ${walletPath(dir)}\\`.`,\n cause: restoreErr,\n },\n );\n }\n // Old wallet restored as the active one; say so rather than surfacing a\n // raw fs error (or a WALLET_EXISTS whose fix suggests re-running --replace).\n throw new CliError(\n 'INTERNAL',\n 'Creating the replacement wallet failed; the previous wallet was restored and is the active wallet again.',\n {\n fix: 'Nothing was lost. Fix the underlying error, then retry `tenjin wallet create --replace`.',\n cause: err,\n },\n );\n }\n });\n } catch (err) {\n // A lock timeout is not the user's error; surface it as INTERNAL with the one\n // manual step (there is no auto-steal), keeping the JSON error contract. Every\n // other error — notably the loser's WALLET_EXISTS — propagates unchanged.\n if (err instanceof LockTimeoutError) {\n throw new CliError('INTERNAL', err.message, {\n fix: `If no other tenjin process is running, remove ${lockPath} and retry.`,\n cause: err,\n });\n }\n throw err;\n }\n}\n\n/** Where the encryption passphrase lives, and what the user must remember. */\nfunction passphraseNote(source: PassphraseSource, address: string): string {\n const account = address.toLowerCase();\n switch (source) {\n case 'keychain':\n return `Passphrase saved to your macOS keychain (service tenjin-cli, account ${account}); signing will be transparent on this machine.`;\n case 'dpapi':\n return `Passphrase saved to a DPAPI-encrypted per-wallet file (passphrase.${account}.dpapi), readable only by you on this Windows machine; signing will be transparent here.`;\n case 'secret-service':\n return `Passphrase saved to your Linux keyring (Secret Service, service tenjin-cli, account ${account}); signing will be transparent on this machine.`;\n case 'env':\n return 'Encrypted with TENJIN_WALLET_PASSPHRASE; keep that value to sign.';\n case 'prompt':\n return 'Remember your passphrase: it is required to sign and cannot be recovered.';\n }\n}\n\nexport interface WalletShowOptions extends ResolveWalletProviderOptions {\n /** `--no-qr`: print the address without the QR block at a TTY. */\n qr?: boolean;\n}\n\nexport async function runWalletShow(\n ctx: CommandContext,\n opts: WalletShowOptions = {},\n): Promise<CommandResult> {\n const provider = resolveWalletProvider(ctx, opts);\n const desc = await describeWallet(provider);\n // Diagnostics are the provider's own: a remote provider reports no local file\n // path or perms warning, so `show` never contaminates a remote wallet's output\n // with a stale local wallet.json's state. keyStorage/passphraseSource are the\n // custody posture reported without decrypting or requiring a passphrase.\n const {\n walletPath: path,\n keyStorage,\n passphraseSource,\n archivedWallets,\n warnings,\n } = await provider.diagnostics();\n\n const humanLines = [\n `Address: ${desc.address}`,\n ...(opts.qr !== false && ctx.io.isTTY && !ctx.flags.json\n ? addressQrLines(desc.address, ctx.io.stdout)\n : []),\n `Key source: ${desc.credentialSource}`,\n ];\n if (keyStorage !== undefined) humanLines.push(`Key storage: ${keyStorage}`);\n if (passphraseSource !== undefined) humanLines.push(`Passphrase: ${passphraseSource}`);\n if (archivedWallets !== undefined && archivedWallets.length > 0) {\n // A recovery hint, not a wallet switcher: exactly one wallet is ever active.\n humanLines.push(\n `Archived (replaced) wallets, funds recoverable via their preserved passphrases: ${archivedWallets.join(', ')}`,\n );\n }\n humanLines.push(...warnings);\n\n return {\n data: {\n address: desc.address,\n provider: desc.provider,\n credentialSource: desc.credentialSource,\n policyEnforcement: desc.policyEnforcement,\n ...(path !== undefined ? { walletPath: path } : {}),\n ...(keyStorage !== undefined ? { keyStorage } : {}),\n ...(passphraseSource !== undefined ? { passphraseSource } : {}),\n ...(archivedWallets !== undefined && archivedWallets.length > 0 ? { archivedWallets } : {}),\n warnings,\n },\n humanLines,\n };\n}\n\nexport async function runWalletBalance(\n ctx: CommandContext,\n opts: ResolveWalletProviderOptions = {},\n): Promise<CommandResult> {\n const provider = resolveWalletProvider(ctx, opts);\n const desc = await describeWallet(provider);\n\n const config = await loadRawConfig(ctx.dataDir);\n const rpcUrl = resolveSettings({\n config,\n flags: { baseUrl: ctx.flags.baseUrl },\n env: process.env,\n }).rpcUrl.value;\n\n let atomic: bigint;\n try {\n atomic = await getUsdcBalance(desc.address, rpcUrl);\n } catch (err) {\n throw new CliError('RPC_ERROR', `Could not read the USDC balance from ${rpcUrl}.`, {\n fix: 'Check your network, or set a working RPC with `tenjin config set rpcUrl <url>`.',\n cause: err,\n });\n }\n\n const balance = toMoney(atomic.toString());\n return {\n data: { address: desc.address, balance },\n humanLines: [`Balance: ${balance.usd} USDC on Base`],\n };\n}\n\nfunction custodyWarnings(): string[] {\n const warnings: string[] = [];\n if (hasEnvKey()) {\n warnings.push('TENJIN_WALLET_KEY is set and shadows this file at runtime.');\n }\n if (isWindows) {\n warnings.push('File permissions are not enforced on Windows; the key file is not restricted.');\n }\n return warnings;\n}\n\nfunction hasEnvKey(): boolean {\n const envKey = process.env.TENJIN_WALLET_KEY;\n return envKey !== undefined && envKey.length > 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,YAAY;AAyBrB,IAAM,eACJ;AACF,IAAM,cAAc;AACpB,IAAM,YAAY,QAAQ,aAAa;AAsBvC,eAAsB,gBACpB,KACA,OAA4B,CAAC,GACL;AACxB,QAAM;AAAA,IACJ;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,EACF,IAAI,MAAM,mBAAmB,IAAI,SAAS,IAAI;AAE9C,QAAM,WAAW,gBAAgB;AACjC,SAAO;AAAA,IACL,MAAM;AAAA,MACJ;AAAA,MACA,YAAY;AAAA,MACZ,UAAU;AAAA,MACV,mBAAmB;AAAA,MACnB,YAAY;AAAA,MACZ,kBAAkB;AAAA,MAClB,GAAI,aAAa,SACb;AAAA,QACE,UAAU;AAAA,UACR,SAAS,SAAS;AAAA,UAClB,oBAAoB,SAAS;AAAA,UAC7B,qBAAqB,SAAS;AAAA,UAC9B,GAAI,SAAS,qBAAqB,SAC9B,EAAE,kBAAkB,SAAS,iBAAiB,IAC9C,CAAC;AAAA,QACP;AAAA,MACF,IACA,CAAC;AAAA,MACL;AAAA,IACF;AAAA,IACA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pB,KACA,OAAqC,CAAC,GACd;AACxB,QAAM,WAAW,sBAAsB,KAAK,IAAI;AAChD,QAAM,OAAO,MAAM,eAAe,QAAQ;AAE1C,QAAM,SAAS,MAAM,cAAc,IAAI,OAAO;AAC9C,QAAM,SAAS,gBAAgB;AAAA,IAC7B;AAAA,IACA,OAAO,EAAE,SAAS,IAAI,MAAM,QAAQ;AAAA,IACpC,KAAK,QAAQ;AAAA,EACf,CAAC,EAAE,OAAO;AAEV,MAAI;AACJ,MAAI;AACF,aAAS,MAAM,eAAe,KAAK,SAAS,MAAM;AAAA,EACpD,SAAS,KAAK;AACZ,UAAM,IAAI,SAAS,aAAa,wCAAwC,MAAM,KAAK;AAAA,MACjF,KAAK;AAAA,MACL,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AAEA,QAAM,UAAU,QAAQ,OAAO,SAAS,CAAC;AACzC,SAAO;AAAA,IACL,MAAM,EAAE,SAAS,KAAK,SAAS,QAAQ;AAAA,IACvC,YAAY,CAAC,YAAY,QAAQ,GAAG,eAAe;AAAA,EACrD;AACF;AAEA,SAAS,kBAA4B;AACnC,QAAM,WAAqB,CAAC;AAC5B,MAAI,UAAU,GAAG;AACf,aAAS,KAAK,4DAA4D;AAAA,EAC5E;AACA,MAAI,WAAW;AACb,aAAS,KAAK,+EAA+E;AAAA,EAC/F;AACA,SAAO;AACT;AAEA,SAAS,YAAqB;AAC5B,QAAM,SAAS,QAAQ,IAAI;AAC3B,SAAO,WAAW,UAAa,OAAO,SAAS;AACjD;","names":[]}
@@ -0,0 +1,222 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ MCP_SERVER_NAME,
4
+ REQUEST_TOOL
5
+ } from "./chunk-TGLKKLQG.js";
6
+ import {
7
+ writeFileAtomic
8
+ } from "./chunk-JLEF5WHM.js";
9
+
10
+ // src/router/agent-tools.ts
11
+ import { readdir, readFile } from "node:fs/promises";
12
+ import { dirname, join, resolve } from "node:path";
13
+ var MCP_INHERITING_BUILTINS = /* @__PURE__ */ new Set([
14
+ "general-purpose",
15
+ "Explore",
16
+ "Plan"
17
+ ]);
18
+ var MAX_AGENT_FILE_BYTES = 256 * 1024;
19
+ var TYPE_RE = /^[A-Za-z0-9_.:-]{1,200}$/;
20
+ async function requestToolAccess(agentType, lookup) {
21
+ if (agentType === void 0 || !TYPE_RE.test(agentType)) return "unknown";
22
+ try {
23
+ const text = await findDefinition(agentType, lookup);
24
+ if (text !== null) return accessOf(text);
25
+ return MCP_INHERITING_BUILTINS.has(agentType) ? "allowed" : "unknown";
26
+ } catch {
27
+ return "unknown";
28
+ }
29
+ }
30
+ function accessOf(definition) {
31
+ const frontmatter = frontmatterOf(definition);
32
+ if (frontmatter === null) return "unknown";
33
+ const disallowed = listField(frontmatter, "disallowedTools");
34
+ if (disallowed !== void 0 && disallowed.some(namesRequestTool)) return "excluded";
35
+ const tools = listField(frontmatter, "tools");
36
+ if (tools === void 0) return "allowed";
37
+ return tools.some(namesRequestTool) ? "allowed" : "excluded";
38
+ }
39
+ function namesRequestTool(tool) {
40
+ if (tool === REQUEST_TOOL || tool === `mcp__${MCP_SERVER_NAME}`) return true;
41
+ return tool.endsWith("*") && REQUEST_TOOL.startsWith(tool.slice(0, -1));
42
+ }
43
+ async function agentsWithoutRequestTool(lookup) {
44
+ const found = [];
45
+ const seen = /* @__PURE__ */ new Set();
46
+ for (const directory of agentDirs(lookup)) {
47
+ for (const { name, text } of await definitionsIn(directory)) {
48
+ const type = nameOf(text) ?? name;
49
+ if (seen.has(type)) continue;
50
+ seen.add(type);
51
+ if (accessOf(text) === "excluded") found.push(type);
52
+ }
53
+ }
54
+ return found.sort();
55
+ }
56
+ async function findDefinition(agentType, lookup) {
57
+ for (const directory of agentDirs(lookup)) {
58
+ const text = await definitionIn(directory, agentType);
59
+ if (text !== null) return text;
60
+ }
61
+ const colon = agentType.indexOf(":");
62
+ if (colon > 0) {
63
+ const plugin = agentType.slice(0, colon);
64
+ const agent = agentType.slice(colon + 1);
65
+ for (const root of await pluginRoots(plugin, lookup.homeDir)) {
66
+ const text = await definitionIn(join(root, "agents"), agent);
67
+ if (text !== null) return text;
68
+ }
69
+ }
70
+ return null;
71
+ }
72
+ function agentDirs(lookup) {
73
+ const dirs = [];
74
+ if (lookup.cwd !== void 0 && lookup.cwd.length > 0) {
75
+ let current = resolve(lookup.cwd);
76
+ for (; ; ) {
77
+ dirs.push(join(current, ".claude", "agents"));
78
+ const parent = dirname(current);
79
+ if (parent === current) break;
80
+ current = parent;
81
+ }
82
+ }
83
+ const user = join(resolve(lookup.homeDir), ".claude", "agents");
84
+ return [...dirs.filter((d) => d !== user), user];
85
+ }
86
+ async function definitionIn(directory, agentType) {
87
+ const direct = await readBounded(join(directory, `${agentType}.md`));
88
+ if (direct !== null && (nameOf(direct) ?? agentType) === agentType) return direct;
89
+ for (const { text } of await definitionsIn(directory)) {
90
+ if (nameOf(text) === agentType) return text;
91
+ }
92
+ return null;
93
+ }
94
+ async function definitionsIn(directory) {
95
+ let names;
96
+ try {
97
+ names = (await readdir(directory)).filter((n) => n.endsWith(".md")).slice(0, 200);
98
+ } catch {
99
+ return [];
100
+ }
101
+ const out = [];
102
+ for (const file of names) {
103
+ const text = await readBounded(join(directory, file));
104
+ if (text !== null) out.push({ name: file.slice(0, -3), text });
105
+ }
106
+ return out;
107
+ }
108
+ async function pluginRoots(plugin, homeDir) {
109
+ const raw = await readBounded(join(homeDir, ".claude", "plugins", "installed_plugins.json"));
110
+ if (raw === null) return [];
111
+ const parsed = JSON.parse(raw);
112
+ const roots = [];
113
+ for (const [key, entries] of Object.entries(parsed.plugins ?? {})) {
114
+ if (key.split("@")[0] !== plugin || !Array.isArray(entries)) continue;
115
+ for (const entry of entries) {
116
+ const path = entry.installPath;
117
+ if (typeof path === "string" && path.length > 0) roots.push(path);
118
+ }
119
+ }
120
+ return roots;
121
+ }
122
+ async function readBounded(path) {
123
+ try {
124
+ const text = await readFile(path, "utf8");
125
+ return text.length > MAX_AGENT_FILE_BYTES ? null : text;
126
+ } catch {
127
+ return null;
128
+ }
129
+ }
130
+ function frontmatterOf(text) {
131
+ const lines = text.replace(/^\uFEFF/, "").split(/\r?\n/);
132
+ const open = lines.findIndex((l) => l.trim().length > 0);
133
+ if (open === -1 || lines[open]?.trim() !== "---") return null;
134
+ const end = lines.findIndex((l, i) => i > open && l.trim() === "---");
135
+ return end === -1 ? null : lines.slice(open + 1, end);
136
+ }
137
+ function nameOf(text) {
138
+ const frontmatter = frontmatterOf(text);
139
+ if (frontmatter === null) return null;
140
+ const line = frontmatter.find((l) => /^name\s*:/.test(l));
141
+ const value = line === void 0 ? "" : unquote(line.slice(line.indexOf(":") + 1).trim());
142
+ return value.length > 0 ? value : null;
143
+ }
144
+ function listField(frontmatter, key) {
145
+ const index = frontmatter.findIndex((l) => new RegExp(`^${key}\\s*:`).test(l));
146
+ if (index === -1) return void 0;
147
+ const line = frontmatter[index];
148
+ const inline = line.slice(line.indexOf(":") + 1).trim();
149
+ if (inline.length > 0) {
150
+ const body = inline.startsWith("[") && inline.endsWith("]") ? inline.slice(1, -1) : inline;
151
+ return body.split(",").map((part) => unquote(part.trim())).filter((part) => part.length > 0);
152
+ }
153
+ const items = [];
154
+ for (const next of frontmatter.slice(index + 1)) {
155
+ const item = /^\s+-\s*(.*)$/.exec(next);
156
+ if (item === null) {
157
+ if (next.trim().length === 0) continue;
158
+ break;
159
+ }
160
+ const value = unquote(item[1].trim());
161
+ if (value.length > 0) items.push(value);
162
+ }
163
+ return items;
164
+ }
165
+ function unquote(value) {
166
+ const quoted = /^(['"])(.*)\1$/.exec(value);
167
+ return quoted === null ? value : quoted[2];
168
+ }
169
+
170
+ // src/router/router-memo.ts
171
+ import { createHash } from "node:crypto";
172
+ import { readFile as readFile2, rm } from "node:fs/promises";
173
+ import { join as join2 } from "node:path";
174
+ var UNREACHABLE_BACKOFF_MS = 6e4;
175
+ function memoPath(dataDir, kind, baseUrl) {
176
+ const origin = new URL(baseUrl).origin;
177
+ const key = createHash("sha256").update(origin).digest("hex").slice(0, 16);
178
+ return join2(dataDir, "router-memo", `${kind}-${key}.json`);
179
+ }
180
+ async function readRouterMemo(dataDir, kind, baseUrl, now) {
181
+ try {
182
+ const raw = JSON.parse(await readFile2(memoPath(dataDir, kind, baseUrl), "utf8"));
183
+ if (raw === null || typeof raw !== "object") return null;
184
+ const { at, until, detail } = raw;
185
+ if (typeof at !== "number" || typeof until !== "number") return null;
186
+ if (at > now || until <= now) return null;
187
+ return { at, until, ...typeof detail === "string" ? { detail } : {} };
188
+ } catch {
189
+ return null;
190
+ }
191
+ }
192
+ async function writeRouterMemo(dataDir, kind, baseUrl, memo) {
193
+ const body = {
194
+ at: memo.now,
195
+ until: memo.now + memo.ttlMs,
196
+ ...memo.detail !== void 0 ? { detail: memo.detail.slice(0, 300) } : {}
197
+ };
198
+ try {
199
+ await writeFileAtomic(memoPath(dataDir, kind, baseUrl), `${JSON.stringify(body)}
200
+ `, {
201
+ mode: 384,
202
+ dirMode: 448
203
+ });
204
+ } catch {
205
+ }
206
+ }
207
+ async function clearRouterMemo(dataDir, kind, baseUrl) {
208
+ try {
209
+ await rm(memoPath(dataDir, kind, baseUrl), { force: true });
210
+ } catch {
211
+ }
212
+ }
213
+
214
+ export {
215
+ requestToolAccess,
216
+ agentsWithoutRequestTool,
217
+ UNREACHABLE_BACKOFF_MS,
218
+ readRouterMemo,
219
+ writeRouterMemo,
220
+ clearRouterMemo
221
+ };
222
+ //# sourceMappingURL=chunk-BOAI23CX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/agent-tools.ts","../src/router/router-memo.ts"],"sourcesContent":["import { readdir, readFile } from 'node:fs/promises';\nimport { dirname, join, resolve } from 'node:path';\nimport { MCP_SERVER_NAME, REQUEST_TOOL } from './names';\n\n/**\n * CAN THIS SUBAGENT CALL `request` AT ALL? An offer to an agent whose definition\n * leaves the tool out is a line it cannot act on, and a router call spent to\n * write it. Claude Code defines a custom agent in a Markdown file whose\n * frontmatter may carry `tools:` (an allowlist) and `disallowedTools:`; this\n * reads that, and nothing else, and never writes to it.\n *\n * ONLY `allowed` IS ACTED ON. A subagent is redirected or offered a lookup\n * only when this KNOWS it can make the call: a definition whose tools cover\n * the request tool (or that has no `tools:` and so inherits everything), or a\n * built-in in {@link MCP_INHERITING_BUILTINS}. Every other built-in, and any\n * type with no definition this can find or read, is `unknown`, and `unknown`\n * gets no router call: `claude-code-guide` ships with Bash, Read, WebFetch and\n * WebSearch and no MCP tools, and denying its WebFetch would strand it exactly\n * as #377 reported.\n *\n * WHERE A DEFINITION LIVES, in the harness's own precedence: the project's\n * `.claude/agents` (from `cwd` up to the filesystem root, nearest first), then\n * `~/.claude/agents`, then an installed plugin's `agents/` for a `plugin:agent`\n * type. A file is found by its name first and by its frontmatter `name:`\n * second, because the type is the `name:` and the file name only usually\n * matches it.\n */\n\nexport type RequestToolAccess = 'allowed' | 'excluded' | 'unknown';\n\n/**\n * The built-in agent types that have no definition file and still inherit MCP\n * tools, so can call `mcp__x402__request`. From Claude Code's own Agent tool\n * listing (2.1.28x): `general-purpose` has every tool, and `Explore` and `Plan`\n * exclude only editing and agent tools, never MCP. Built-ins with a fixed tool\n * list, such as `claude-code-guide` (Bash, Read, WebFetch, WebSearch) and\n * `statusline-setup` (Read, Edit), are deliberately absent.\n */\nexport const MCP_INHERITING_BUILTINS: ReadonlySet<string> = new Set([\n 'general-purpose',\n 'Explore',\n 'Plan',\n]);\n\nexport interface AgentLookup {\n cwd?: string;\n homeDir: string;\n}\n\nconst MAX_AGENT_FILE_BYTES = 256 * 1024;\nconst TYPE_RE = /^[A-Za-z0-9_.:-]{1,200}$/;\n\nexport async function requestToolAccess(\n agentType: string | undefined,\n lookup: AgentLookup,\n): Promise<RequestToolAccess> {\n if (agentType === undefined || !TYPE_RE.test(agentType)) return 'unknown';\n try {\n const text = await findDefinition(agentType, lookup);\n if (text !== null) return accessOf(text);\n return MCP_INHERITING_BUILTINS.has(agentType) ? 'allowed' : 'unknown';\n } catch {\n return 'unknown';\n }\n}\n\n/** What one definition's frontmatter says about the request tool. */\nexport function accessOf(definition: string): RequestToolAccess {\n const frontmatter = frontmatterOf(definition);\n if (frontmatter === null) return 'unknown';\n const disallowed = listField(frontmatter, 'disallowedTools');\n if (disallowed !== undefined && disallowed.some(namesRequestTool)) return 'excluded';\n const tools = listField(frontmatter, 'tools');\n if (tools === undefined) return 'allowed';\n return tools.some(namesRequestTool) ? 'allowed' : 'excluded';\n}\n\n/**\n * Does one `tools:` or `disallowedTools:` entry cover the request tool? The\n * tool itself, the bare server, or any `*`-suffixed pattern the tool's name\n * starts with: `*`, `mcp__*`, `mcp__x402__*` and every prefix between.\n */\nfunction namesRequestTool(tool: string): boolean {\n if (tool === REQUEST_TOOL || tool === `mcp__${MCP_SERVER_NAME}`) return true;\n return tool.endsWith('*') && REQUEST_TOOL.startsWith(tool.slice(0, -1));\n}\n\n/**\n * Every custom agent this project and this user define whose tools leave the\n * request tool out, for `doctor` to name. Plugin agents are not listed: their\n * files are not the user's to edit.\n */\nexport async function agentsWithoutRequestTool(lookup: AgentLookup): Promise<string[]> {\n const found: string[] = [];\n const seen = new Set<string>();\n for (const directory of agentDirs(lookup)) {\n for (const { name, text } of await definitionsIn(directory)) {\n const type = nameOf(text) ?? name;\n if (seen.has(type)) continue;\n seen.add(type);\n if (accessOf(text) === 'excluded') found.push(type);\n }\n }\n return found.sort();\n}\n\nasync function findDefinition(agentType: string, lookup: AgentLookup): Promise<string | null> {\n for (const directory of agentDirs(lookup)) {\n const text = await definitionIn(directory, agentType);\n if (text !== null) return text;\n }\n const colon = agentType.indexOf(':');\n if (colon > 0) {\n const plugin = agentType.slice(0, colon);\n const agent = agentType.slice(colon + 1);\n for (const root of await pluginRoots(plugin, lookup.homeDir)) {\n const text = await definitionIn(join(root, 'agents'), agent);\n if (text !== null) return text;\n }\n }\n return null;\n}\n\nfunction agentDirs(lookup: AgentLookup): string[] {\n const dirs: string[] = [];\n if (lookup.cwd !== undefined && lookup.cwd.length > 0) {\n let current = resolve(lookup.cwd);\n for (;;) {\n dirs.push(join(current, '.claude', 'agents'));\n const parent = dirname(current);\n if (parent === current) break;\n current = parent;\n }\n }\n const user = join(resolve(lookup.homeDir), '.claude', 'agents');\n // The user's directory is also an ancestor of most projects; it counts once,\n // in its own place in the order.\n return [...dirs.filter((d) => d !== user), user];\n}\n\nasync function definitionIn(directory: string, agentType: string): Promise<string | null> {\n const direct = await readBounded(join(directory, `${agentType}.md`));\n if (direct !== null && (nameOf(direct) ?? agentType) === agentType) return direct;\n for (const { text } of await definitionsIn(directory)) {\n if (nameOf(text) === agentType) return text;\n }\n return null;\n}\n\nasync function definitionsIn(directory: string): Promise<{ name: string; text: string }[]> {\n let names: string[];\n try {\n names = (await readdir(directory)).filter((n) => n.endsWith('.md')).slice(0, 200);\n } catch {\n return [];\n }\n const out: { name: string; text: string }[] = [];\n for (const file of names) {\n const text = await readBounded(join(directory, file));\n if (text !== null) out.push({ name: file.slice(0, -3), text });\n }\n return out;\n}\n\n/** Install paths `installed_plugins.json` records for `<plugin>@<marketplace>`. */\nasync function pluginRoots(plugin: string, homeDir: string): Promise<string[]> {\n const raw = await readBounded(join(homeDir, '.claude', 'plugins', 'installed_plugins.json'));\n if (raw === null) return [];\n const parsed = JSON.parse(raw) as { plugins?: Record<string, unknown> };\n const roots: string[] = [];\n for (const [key, entries] of Object.entries(parsed.plugins ?? {})) {\n if (key.split('@')[0] !== plugin || !Array.isArray(entries)) continue;\n for (const entry of entries) {\n const path = (entry as { installPath?: unknown }).installPath;\n if (typeof path === 'string' && path.length > 0) roots.push(path);\n }\n }\n return roots;\n}\n\nasync function readBounded(path: string): Promise<string | null> {\n try {\n const text = await readFile(path, 'utf8');\n return text.length > MAX_AGENT_FILE_BYTES ? null : text;\n } catch {\n return null;\n }\n}\n\nfunction frontmatterOf(text: string): string[] | null {\n const lines = text.replace(/^\\uFEFF/, '').split(/\\r?\\n/);\n const open = lines.findIndex((l) => l.trim().length > 0);\n if (open === -1 || lines[open]?.trim() !== '---') return null;\n const end = lines.findIndex((l, i) => i > open && l.trim() === '---');\n return end === -1 ? null : lines.slice(open + 1, end);\n}\n\nfunction nameOf(text: string): string | null {\n const frontmatter = frontmatterOf(text);\n if (frontmatter === null) return null;\n const line = frontmatter.find((l) => /^name\\s*:/.test(l));\n const value = line === undefined ? '' : unquote(line.slice(line.indexOf(':') + 1).trim());\n return value.length > 0 ? value : null;\n}\n\n/**\n * A top-level list field in the three spellings agent files use: `a, b, c`,\n * `[a, b]`, or a block of `- a` lines. `undefined` when the key is absent.\n */\nfunction listField(frontmatter: string[], key: string): string[] | undefined {\n const index = frontmatter.findIndex((l) => new RegExp(`^${key}\\\\s*:`).test(l));\n if (index === -1) return undefined;\n const line = frontmatter[index]!;\n const inline = line.slice(line.indexOf(':') + 1).trim();\n if (inline.length > 0) {\n const body = inline.startsWith('[') && inline.endsWith(']') ? inline.slice(1, -1) : inline;\n return body\n .split(',')\n .map((part) => unquote(part.trim()))\n .filter((part) => part.length > 0);\n }\n const items: string[] = [];\n for (const next of frontmatter.slice(index + 1)) {\n const item = /^\\s+-\\s*(.*)$/.exec(next);\n if (item === null) {\n if (next.trim().length === 0) continue;\n break;\n }\n const value = unquote(item[1]!.trim());\n if (value.length > 0) items.push(value);\n }\n return items;\n}\n\nfunction unquote(value: string): string {\n const quoted = /^(['\"])(.*)\\1$/.exec(value);\n return quoted === null ? value : quoted[2]!;\n}\n","import { createHash } from 'node:crypto';\nimport { readFile, rm } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { writeFileAtomic } from '../lib/atomic-json';\n\n/**\n * ONE MEMO FOR \"DO NOT ASK THE ROUTER YET\", per machine and per router origin,\n * in the data dir, so every hook leg and every `tenjin mcp` process reads the\n * same answer. Two facts use it:\n *\n * - `unreachable`: a routing leg's call could not reach the router (DNS, TLS,\n * a refused connection, a proxy refusing the tunnel; see `isUnreachable`). For\n * {@link UNREACHABLE_BACKOFF_MS} every leg skips the router and the native\n * tool runs at once, instead of each prompt and search waiting out the gate.\n * Doctor's probe ends it early when it reaches the router.\n * - `paid-path-absent`: the router answered no paid path (the fee is off), so\n * calls take the free path without asking for an hour, or until the free\n * path answers `fee_required`.\n *\n * A memo is a file written atomically and read with the clock: one older than\n * its window, or dated in the future, reads as absent, so nothing cleans up\n * after it. An unreadable file reads as absent too: the cost of a lost memo is\n * one more call to the router.\n */\nexport type RouterMemoKind = 'unreachable' | 'paid-path-absent';\n\nexport interface RouterMemo {\n /** When it was written, in epoch ms. */\n at: number;\n /** When it ends, in epoch ms. */\n until: number;\n /** What happened, for doctor. */\n detail?: string;\n}\n\n/** How long routing legs skip a router that did not answer. */\nexport const UNREACHABLE_BACKOFF_MS = 60_000;\n\nfunction memoPath(dataDir: string, kind: RouterMemoKind, baseUrl: string): string {\n const origin = new URL(baseUrl).origin;\n const key = createHash('sha256').update(origin).digest('hex').slice(0, 16);\n return join(dataDir, 'router-memo', `${kind}-${key}.json`);\n}\n\n/** The memo in force at `now`, or null. Never throws. */\nexport async function readRouterMemo(\n dataDir: string,\n kind: RouterMemoKind,\n baseUrl: string,\n now: number,\n): Promise<RouterMemo | null> {\n try {\n const raw = JSON.parse(await readFile(memoPath(dataDir, kind, baseUrl), 'utf8')) as unknown;\n if (raw === null || typeof raw !== 'object') return null;\n const { at, until, detail } = raw as Record<string, unknown>;\n if (typeof at !== 'number' || typeof until !== 'number') return null;\n if (at > now || until <= now) return null;\n return { at, until, ...(typeof detail === 'string' ? { detail } : {}) };\n } catch {\n return null;\n }\n}\n\n/** Starts a memo of `ttlMs` from `now`. Never throws. */\nexport async function writeRouterMemo(\n dataDir: string,\n kind: RouterMemoKind,\n baseUrl: string,\n memo: { now: number; ttlMs: number; detail?: string },\n): Promise<void> {\n const body: RouterMemo = {\n at: memo.now,\n until: memo.now + memo.ttlMs,\n ...(memo.detail !== undefined ? { detail: memo.detail.slice(0, 300) } : {}),\n };\n try {\n await writeFileAtomic(memoPath(dataDir, kind, baseUrl), `${JSON.stringify(body)}\\n`, {\n mode: 0o600,\n dirMode: 0o700,\n });\n } catch {\n // Best effort: a memo that did not land costs one more call.\n }\n}\n\n/** Ends a memo before its window does. Never throws. */\nexport async function clearRouterMemo(\n dataDir: string,\n kind: RouterMemoKind,\n baseUrl: string,\n): Promise<void> {\n try {\n await rm(memoPath(dataDir, kind, baseUrl), { force: true });\n } catch {\n // Best effort: the window ends it anyway.\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,SAAS,gBAAgB;AAClC,SAAS,SAAS,MAAM,eAAe;AAqChC,IAAM,0BAA+C,oBAAI,IAAI;AAAA,EAClE;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAOD,IAAM,uBAAuB,MAAM;AACnC,IAAM,UAAU;AAEhB,eAAsB,kBACpB,WACA,QAC4B;AAC5B,MAAI,cAAc,UAAa,CAAC,QAAQ,KAAK,SAAS,EAAG,QAAO;AAChE,MAAI;AACF,UAAM,OAAO,MAAM,eAAe,WAAW,MAAM;AACnD,QAAI,SAAS,KAAM,QAAO,SAAS,IAAI;AACvC,WAAO,wBAAwB,IAAI,SAAS,IAAI,YAAY;AAAA,EAC9D,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGO,SAAS,SAAS,YAAuC;AAC9D,QAAM,cAAc,cAAc,UAAU;AAC5C,MAAI,gBAAgB,KAAM,QAAO;AACjC,QAAM,aAAa,UAAU,aAAa,iBAAiB;AAC3D,MAAI,eAAe,UAAa,WAAW,KAAK,gBAAgB,EAAG,QAAO;AAC1E,QAAM,QAAQ,UAAU,aAAa,OAAO;AAC5C,MAAI,UAAU,OAAW,QAAO;AAChC,SAAO,MAAM,KAAK,gBAAgB,IAAI,YAAY;AACpD;AAOA,SAAS,iBAAiB,MAAuB;AAC/C,MAAI,SAAS,gBAAgB,SAAS,QAAQ,eAAe,GAAI,QAAO;AACxE,SAAO,KAAK,SAAS,GAAG,KAAK,aAAa,WAAW,KAAK,MAAM,GAAG,EAAE,CAAC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UAAM,EAAE,IAAI,OAAO,OAAO,IAAI;AAC9B,QAAI,OAAO,OAAO,YAAY,OAAO,UAAU,SAAU,QAAO;AAChE,QAAI,KAAK,OAAO,SAAS,IAAK,QAAO;AACrC,WAAO,EAAE,IAAI,OAAO,GAAI,OAAO,WAAW,WAAW,EAAE,OAAO,IAAI,CAAC,EAAG;AAAA,EACxE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGA,eAAsB,gBACpB,SACA,MACA,SACA,MACe;AACf,QAAM,OAAmB;AAAA,IACvB,IAAI,KAAK;AAAA,IACT,OAAO,KAAK,MAAM,KAAK;AAAA,IACvB,GAAI,KAAK,WAAW,SAAY,EAAE,QAAQ,KAAK,OAAO,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC;AAAA,EAC3E;AACA,MAAI;AACF,UAAM,gBAAgB,SAAS,SAAS,MAAM,OAAO,GAAG,GAAG,KAAK,UAAU,IAAI,CAAC;AAAA,GAAM;AAAA,MACnF,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC;AAAA,EACH,QAAQ;AAAA,EAER;AACF;AAGA,eAAsB,gBACpB,SACA,MACA,SACe;AACf,MAAI;AACF,UAAM,GAAG,SAAS,SAAS,MAAM,OAAO,GAAG,EAAE,OAAO,KAAK,CAAC;AAAA,EAC5D,QAAQ;AAAA,EAER;AACF;","names":["readFile","join","join","readFile"]}
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-TGLKKLQG.js";
8
8
  import {
9
9
  package_default
10
- } from "./chunk-ODH7UXIS.js";
10
+ } from "./chunk-GHR4BTNJ.js";
11
11
  import {
12
12
  CliError,
13
13
  HARNESSES,
@@ -1411,7 +1411,7 @@ function skip2(reason, args) {
1411
1411
  return {
1412
1412
  harness: args.harness,
1413
1413
  ...args.path !== void 0 ? { path: args.path } : {},
1414
- hooksDir: args.hooksDir,
1414
+ ...args.hooksDir !== void 0 ? { hooksDir: args.hooksDir } : {},
1415
1415
  entries: 0,
1416
1416
  wrote: false,
1417
1417
  skipped: reason,
@@ -1602,8 +1602,7 @@ async function writeHooks(opts) {
1602
1602
  const declaredPath = opts.settingsPath ?? adapter.registrar.configPath(homeDir, env);
1603
1603
  const steps = adapter.registrar.activation?.(declaredPath);
1604
1604
  const activation = steps !== void 0 ? { activation: steps } : {};
1605
- if (opts.plan !== void 0)
1606
- return writePlainEntries(opts, opts.plan, declaredPath, dir, activation);
1605
+ if (opts.plan !== void 0) return writePlainEntries(opts, opts.plan, declaredPath, activation);
1607
1606
  let started;
1608
1607
  try {
1609
1608
  started = await (opts.start ?? startDaemon)(dataDir2, {
@@ -1708,14 +1707,13 @@ async function tightenFile(path) {
1708
1707
  if (found === null || (found.mode & 63) === 0) return;
1709
1708
  await chmod2(path, 384).catch(() => void 0);
1710
1709
  }
1711
- async function writePlainEntries(opts, plan, declaredPath, dir, activation) {
1710
+ async function writePlainEntries(opts, plan, declaredPath, activation) {
1712
1711
  const harness = opts.adapter.id;
1713
1712
  const found = await inspectHooksFile(declaredPath);
1714
1713
  if ("refusal" in found) {
1715
1714
  return skip2(found.refusal.reason, {
1716
1715
  harness,
1717
1716
  path: found.refusal.path,
1718
- hooksDir: dir,
1719
1717
  warning: found.refusal.message,
1720
1718
  fix: fixFor2(found.refusal.reason)
1721
1719
  });
@@ -1731,7 +1729,6 @@ async function writePlainEntries(opts, plan, declaredPath, dir, activation) {
1731
1729
  const result = {
1732
1730
  harness,
1733
1731
  path,
1734
- hooksDir: dir,
1735
1732
  entries: plan.length,
1736
1733
  wrote: next !== raw,
1737
1734
  ...activation
@@ -1744,7 +1741,6 @@ async function writePlainEntries(opts, plan, declaredPath, dir, activation) {
1744
1741
  return skip2("changed-since-read", {
1745
1742
  harness,
1746
1743
  path,
1747
- hooksDir: dir,
1748
1744
  warning: `${path} changed while it was being updated, so no hooks were registered. Re-run \`tenjin install\`.`,
1749
1745
  fix: fixFor2("changed-since-read")
1750
1746
  });
@@ -1755,7 +1751,6 @@ async function writePlainEntries(opts, plan, declaredPath, dir, activation) {
1755
1751
  return skip2("unwritable", {
1756
1752
  harness,
1757
1753
  path,
1758
- hooksDir: dir,
1759
1754
  warning: `${path} could not be written (${err instanceof Error ? err.message : String(err)}); no hook entry was registered.`,
1760
1755
  fix: fixFor2("unwritable")
1761
1756
  });
@@ -1790,4 +1785,4 @@ export {
1790
1785
  registeredHooks,
1791
1786
  writeHooks
1792
1787
  };
1793
- //# sourceMappingURL=chunk-KGTQRJGS.js.map
1788
+ //# sourceMappingURL=chunk-DI7WHXOZ.js.map