tenjin-cli 0.1.0-alpha.27 → 0.1.0-alpha.28
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.
- package/README.md +6 -17
- package/dist/alive-3J3CHOQP.js +21 -0
- package/dist/{chunk-SKQQOEWH.js → chunk-3QJREVMX.js} +5 -7
- package/dist/{chunk-SKQQOEWH.js.map → chunk-3QJREVMX.js.map} +1 -1
- package/dist/{chunk-BOAI23CX.js → chunk-6KA4HFX5.js} +21 -15
- package/dist/chunk-6KA4HFX5.js.map +1 -0
- package/dist/chunk-6W5GYG3W.js +128 -0
- package/dist/chunk-6W5GYG3W.js.map +1 -0
- package/dist/{chunk-4L7KMA7P.js → chunk-7H3RN4WJ.js} +7 -9
- package/dist/{chunk-4L7KMA7P.js.map → chunk-7H3RN4WJ.js.map} +1 -1
- package/dist/{chunk-O7CUHHYU.js → chunk-7R37M6WV.js} +7 -9
- package/dist/{chunk-O7CUHHYU.js.map → chunk-7R37M6WV.js.map} +1 -1
- package/dist/{chunk-LAIZ2AQA.js → chunk-A5H3E5QA.js} +2 -2
- package/dist/{update-RJDA5ZY3.js → chunk-AO54FM4H.js} +147 -26
- package/dist/chunk-AO54FM4H.js.map +1 -0
- package/dist/{chunk-VNNXAYJE.js → chunk-BRHREK7E.js} +2 -2
- package/dist/{chunk-YQOQ6XEI.js → chunk-DJYAPACT.js} +35 -33
- package/dist/chunk-DJYAPACT.js.map +1 -0
- package/dist/{chunk-GU4GGKYP.js → chunk-DYSDQE7S.js} +36 -2
- package/dist/chunk-DYSDQE7S.js.map +1 -0
- package/dist/{chunk-YKM2ZTA2.js → chunk-FQ6DHINU.js} +36 -38
- package/dist/{chunk-YKM2ZTA2.js.map → chunk-FQ6DHINU.js.map} +1 -1
- package/dist/{chunk-6ZSGER3A.js → chunk-FZTSGQVK.js} +2 -2
- package/dist/{chunk-AWKQSKUL.js → chunk-KAMRYUK2.js} +2 -2
- package/dist/{chunk-2TYQD22Q.js → chunk-MNTQMZJB.js} +6 -8
- package/dist/{chunk-2TYQD22Q.js.map → chunk-MNTQMZJB.js.map} +1 -1
- package/dist/{chunk-VIOUZW7Z.js → chunk-QTND6XWJ.js} +159 -35
- package/dist/chunk-QTND6XWJ.js.map +1 -0
- package/dist/chunk-RLPLYUME.js +115 -0
- package/dist/{chunk-HC3QEZKT.js.map → chunk-RLPLYUME.js.map} +1 -1
- package/dist/{chunk-5NEHH2E5.js → chunk-UEOWNDQG.js} +8 -10
- package/dist/{chunk-5NEHH2E5.js.map → chunk-UEOWNDQG.js.map} +1 -1
- package/dist/{chunk-OHZYNZSD.js → chunk-UOW5JXYY.js} +5 -7
- package/dist/{chunk-OHZYNZSD.js.map → chunk-UOW5JXYY.js.map} +1 -1
- package/dist/chunk-VSUHGRVB.js +1455 -0
- package/dist/chunk-VSUHGRVB.js.map +1 -0
- package/dist/{chunk-64SE3QC5.js → chunk-W6JX4LYF.js} +12 -4
- package/dist/chunk-W6JX4LYF.js.map +1 -0
- package/dist/{chunk-5FGO6TYT.js → chunk-XVTD7UWR.js} +3 -5
- package/dist/{chunk-5FGO6TYT.js.map → chunk-XVTD7UWR.js.map} +1 -1
- package/dist/{chunk-X7I343ZY.js → chunk-YFJJYHVG.js} +2 -2
- package/dist/{chunk-XVYATBKD.js → chunk-ZG6ZZLO7.js} +898 -521
- package/dist/chunk-ZG6ZZLO7.js.map +1 -0
- package/dist/{chunk-DATCR7AU.js → chunk-ZO3X5NPG.js} +4 -6
- package/dist/{chunk-DATCR7AU.js.map → chunk-ZO3X5NPG.js.map} +1 -1
- package/dist/{chunk-VXIBZ6W5.js → chunk-ZP5PV3JB.js} +3 -3
- package/dist/{chunk-G4AM2SOL.js → chunk-ZP7AHN7Z.js} +4 -6
- package/dist/{chunk-G4AM2SOL.js.map → chunk-ZP7AHN7Z.js.map} +1 -1
- package/dist/{cli-6JNIPZQ6.js → cli-234DNHN6.js} +54 -53
- package/dist/{cli-6JNIPZQ6.js.map → cli-234DNHN6.js.map} +1 -1
- package/dist/{config-G75YT6NC.js → config-IY2OJCAK.js} +10 -13
- package/dist/{doctor-3GMDOW4Y.js → doctor-2UZZF44A.js} +267 -242
- package/dist/doctor-2UZZF44A.js.map +1 -0
- package/dist/{fund-3IPR5YRJ.js → fund-RZ2QFULK.js} +92 -38
- package/dist/{fund-3IPR5YRJ.js.map → fund-RZ2QFULK.js.map} +1 -1
- package/dist/hook-command-PZHKS7ES.js +31 -0
- package/dist/hosts/claude/.claude-plugin/marketplace.json +19 -0
- package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +14 -0
- package/dist/hosts/claude/tenjin/.mcp.json +11 -0
- package/dist/hosts/claude/tenjin/hooks/hooks.json +206 -0
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/install-O5FJ5EP3.js +48 -0
- package/dist/{install-identity-PM4AGFFX.js → install-identity-QM44IQ6Z.js} +7 -8
- package/dist/{install-wallet-6756NOB5.js → install-wallet-Z52EDLPB.js} +14 -15
- package/dist/{install-wallet-6756NOB5.js.map → install-wallet-Z52EDLPB.js.map} +1 -1
- package/dist/{mcp-33FAAZ7F.js → mcp-33HAADDF.js} +80 -67
- package/dist/{mcp-33FAAZ7F.js.map → mcp-33HAADDF.js.map} +1 -1
- package/dist/package-RT24HTTP.js +37 -0
- package/dist/{pay-XOYR4PCH.js → pay-IR2V76FX.js} +16 -17
- package/dist/{payments-UTQDBO7H.js → payments-GFV4HU5R.js} +9 -10
- package/dist/{payments-UTQDBO7H.js.map → payments-GFV4HU5R.js.map} +1 -1
- package/dist/{send-CVGNOQW3.js → send-PI4NUA7I.js} +12 -14
- package/dist/{send-CVGNOQW3.js.map → send-PI4NUA7I.js.map} +1 -1
- package/dist/{status-NACN4DGX.js → status-ZUHTJK46.js} +6 -7
- package/dist/{status-NACN4DGX.js.map → status-ZUHTJK46.js.map} +1 -1
- package/dist/{status-line-3IQKGRUH.js → status-line-2G5JPQAE.js} +6 -7
- package/dist/{status-line-3IQKGRUH.js.map → status-line-2G5JPQAE.js.map} +1 -1
- package/dist/uninstall-THKUH5ZT.js +136 -0
- package/dist/uninstall-THKUH5ZT.js.map +1 -0
- package/dist/update-NPZDP24E.js +18 -0
- package/dist/update-NPZDP24E.js.map +1 -0
- package/dist/{wallet-B3FVHNTS.js → wallet-53EFH4M5.js} +11 -12
- package/dist/wallet-53EFH4M5.js.map +1 -0
- package/docs/agent-permissions.md +27 -17
- package/package.json +1 -1
- package/dist/chunk-64SE3QC5.js.map +0 -1
- package/dist/chunk-BOAI23CX.js.map +0 -1
- package/dist/chunk-DSNXKUXI.js +0 -172
- package/dist/chunk-DSNXKUXI.js.map +0 -1
- package/dist/chunk-GU4GGKYP.js.map +0 -1
- package/dist/chunk-H2L33M7F.js +0 -944
- package/dist/chunk-H2L33M7F.js.map +0 -1
- package/dist/chunk-HC3QEZKT.js +0 -87
- package/dist/chunk-JLEF5WHM.js +0 -132
- package/dist/chunk-JLEF5WHM.js.map +0 -1
- package/dist/chunk-MAQUL5BD.js +0 -99
- package/dist/chunk-MAQUL5BD.js.map +0 -1
- package/dist/chunk-PY7MQUKP.js +0 -755
- package/dist/chunk-PY7MQUKP.js.map +0 -1
- package/dist/chunk-TGLKKLQG.js +0 -11
- package/dist/chunk-TGLKKLQG.js.map +0 -1
- package/dist/chunk-VIOUZW7Z.js.map +0 -1
- package/dist/chunk-XVYATBKD.js.map +0 -1
- package/dist/chunk-YQOQ6XEI.js.map +0 -1
- package/dist/doctor-3GMDOW4Y.js.map +0 -1
- package/dist/hook-command-ZXX4FT4N.js +0 -32
- package/dist/install-6OROTYHZ.js +0 -72
- package/dist/status-line-wiring-QXBOOY2T.js +0 -31
- package/dist/uninstall-NYFKSYW4.js +0 -175
- package/dist/uninstall-NYFKSYW4.js.map +0 -1
- package/dist/update-RJDA5ZY3.js.map +0 -1
- /package/dist/{config-G75YT6NC.js.map → alive-3J3CHOQP.js.map} +0 -0
- /package/dist/{chunk-LAIZ2AQA.js.map → chunk-A5H3E5QA.js.map} +0 -0
- /package/dist/{chunk-VNNXAYJE.js.map → chunk-BRHREK7E.js.map} +0 -0
- /package/dist/{chunk-6ZSGER3A.js.map → chunk-FZTSGQVK.js.map} +0 -0
- /package/dist/{chunk-AWKQSKUL.js.map → chunk-KAMRYUK2.js.map} +0 -0
- /package/dist/{chunk-X7I343ZY.js.map → chunk-YFJJYHVG.js.map} +0 -0
- /package/dist/{chunk-VXIBZ6W5.js.map → chunk-ZP5PV3JB.js.map} +0 -0
- /package/dist/{hook-command-ZXX4FT4N.js.map → config-IY2OJCAK.js.map} +0 -0
- /package/dist/{install-6OROTYHZ.js.map → hook-command-PZHKS7ES.js.map} +0 -0
- /package/dist/{install-identity-PM4AGFFX.js.map → install-O5FJ5EP3.js.map} +0 -0
- /package/dist/{pay-XOYR4PCH.js.map → install-identity-QM44IQ6Z.js.map} +0 -0
- /package/dist/{status-line-wiring-QXBOOY2T.js.map → package-RT24HTTP.js.map} +0 -0
- /package/dist/{wallet-B3FVHNTS.js.map → pay-IR2V76FX.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
CliError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QTND6XWJ.js";
|
|
5
5
|
|
|
6
6
|
// src/lib/money.ts
|
|
7
7
|
var USDC_DECIMALS = 6;
|
|
@@ -49,4 +49,4 @@ export {
|
|
|
49
49
|
toMoney,
|
|
50
50
|
formatUsdDisplay
|
|
51
51
|
};
|
|
52
|
-
//# sourceMappingURL=chunk-
|
|
52
|
+
//# sourceMappingURL=chunk-FZTSGQVK.js.map
|
|
@@ -2,7 +2,7 @@ import { createRequire as __tenjinCreateRequire } from 'node:module'; const requ
|
|
|
2
2
|
import {
|
|
3
3
|
writeFileAtomic,
|
|
4
4
|
writeFileAtomicExclusive
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-QTND6XWJ.js";
|
|
6
6
|
|
|
7
7
|
// src/router/progress.ts
|
|
8
8
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -375,4 +375,4 @@ export {
|
|
|
375
375
|
pruneSessions,
|
|
376
376
|
renderProgress
|
|
377
377
|
};
|
|
378
|
-
//# sourceMappingURL=chunk-
|
|
378
|
+
//# sourceMappingURL=chunk-KAMRYUK2.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-PZ5N6BAL.js";
|
|
5
5
|
import {
|
|
6
6
|
getUsdcBalance
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-BRHREK7E.js";
|
|
8
8
|
import {
|
|
9
9
|
commitLocalWallet,
|
|
10
10
|
createLocalWallet,
|
|
@@ -17,21 +17,19 @@ import {
|
|
|
17
17
|
verifyAndPreserveOutgoingWallet,
|
|
18
18
|
walletExistsError,
|
|
19
19
|
walletFileExists
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-7R37M6WV.js";
|
|
21
21
|
import {
|
|
22
22
|
LockTimeoutError,
|
|
23
23
|
withFileLock
|
|
24
24
|
} from "./chunk-MEFB5KHA.js";
|
|
25
25
|
import {
|
|
26
26
|
toMoney
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-FZTSGQVK.js";
|
|
28
28
|
import {
|
|
29
|
+
CliError,
|
|
29
30
|
loadRawConfig,
|
|
30
31
|
resolveSettings
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import {
|
|
33
|
-
CliError
|
|
34
|
-
} from "./chunk-JLEF5WHM.js";
|
|
32
|
+
} from "./chunk-QTND6XWJ.js";
|
|
35
33
|
import {
|
|
36
34
|
walletPath
|
|
37
35
|
} from "./chunk-K6AXXYCG.js";
|
|
@@ -246,4 +244,4 @@ export {
|
|
|
246
244
|
runWalletShow,
|
|
247
245
|
runWalletBalance
|
|
248
246
|
};
|
|
249
|
-
//# sourceMappingURL=chunk-
|
|
247
|
+
//# sourceMappingURL=chunk-MNTQMZJB.js.map
|
|
@@ -1 +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,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+
{"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,UA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AAI,qBAAqB,SAAY,EAAE,iBAAiB,IAAI,CAAC;AAAA,MAC7D,GAAI,oBAAoB,UAAa,gBAAgB,SAAS,IAAI,EAAE,gBAAgB,IAAI,CAAC;AAAA,MACzF;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;AAEA,eAAsB,iBACpB,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":[]}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
CliError,
|
|
4
|
-
HARNESSES,
|
|
5
|
-
writeFileAtomic
|
|
6
|
-
} from "./chunk-JLEF5WHM.js";
|
|
7
2
|
import {
|
|
8
3
|
balanceCachePath,
|
|
9
4
|
configPath
|
|
@@ -12,6 +7,66 @@ import {
|
|
|
12
7
|
__export
|
|
13
8
|
} from "./chunk-ZXTAQYNA.js";
|
|
14
9
|
|
|
10
|
+
// src/lib/atomic-json.ts
|
|
11
|
+
import { chmod, link, mkdir, open, rename, rm, writeFile } from "node:fs/promises";
|
|
12
|
+
import { randomBytes } from "node:crypto";
|
|
13
|
+
import { basename, dirname, join } from "node:path";
|
|
14
|
+
var isWindows = process.platform === "win32";
|
|
15
|
+
async function writeFileAtomic(targetPath, data, opts = {}) {
|
|
16
|
+
const dir = dirname(targetPath);
|
|
17
|
+
const fileMode = opts.mode ?? 420;
|
|
18
|
+
const dirMode = opts.dirMode ?? 493;
|
|
19
|
+
await mkdir(dir, { recursive: true, ...isWindows ? {} : { mode: dirMode } });
|
|
20
|
+
const tmpPath = join(dir, `.${basename(targetPath)}.${randomBytes(6).toString("hex")}.tmp`);
|
|
21
|
+
try {
|
|
22
|
+
await writeFile(tmpPath, data, isWindows ? void 0 : { mode: fileMode });
|
|
23
|
+
if (!isWindows) await chmod(tmpPath, fileMode);
|
|
24
|
+
await rename(tmpPath, targetPath);
|
|
25
|
+
} catch (err) {
|
|
26
|
+
await rm(tmpPath, { force: true }).catch(() => void 0);
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function writeFileAtomicExclusive(targetPath, data, opts = {}) {
|
|
31
|
+
const dir = dirname(targetPath);
|
|
32
|
+
const fileMode = opts.mode ?? 420;
|
|
33
|
+
const dirMode = opts.dirMode ?? 493;
|
|
34
|
+
await mkdir(dir, { recursive: true, ...isWindows ? {} : { mode: dirMode } });
|
|
35
|
+
if (isWindows) {
|
|
36
|
+
const handle = await open(targetPath, "wx");
|
|
37
|
+
try {
|
|
38
|
+
await handle.writeFile(data);
|
|
39
|
+
await handle.sync();
|
|
40
|
+
} finally {
|
|
41
|
+
await handle.close();
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const tmpPath = join(dir, `.${basename(targetPath)}.${randomBytes(6).toString("hex")}.tmp`);
|
|
46
|
+
try {
|
|
47
|
+
const handle = await open(tmpPath, "wx", fileMode);
|
|
48
|
+
try {
|
|
49
|
+
await handle.writeFile(data);
|
|
50
|
+
await handle.chmod(fileMode);
|
|
51
|
+
await handle.sync();
|
|
52
|
+
} finally {
|
|
53
|
+
await handle.close();
|
|
54
|
+
}
|
|
55
|
+
await link(tmpPath, targetPath);
|
|
56
|
+
await fsyncDir(dir);
|
|
57
|
+
} finally {
|
|
58
|
+
await rm(tmpPath, { force: true }).catch(() => void 0);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async function fsyncDir(dir) {
|
|
62
|
+
const handle = await open(dir, "r");
|
|
63
|
+
try {
|
|
64
|
+
await handle.sync();
|
|
65
|
+
} finally {
|
|
66
|
+
await handle.close();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
15
70
|
// node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
16
71
|
var external_exports = {};
|
|
17
72
|
__export(external_exports, {
|
|
@@ -518,7 +573,7 @@ __export(core_exports2, {
|
|
|
518
573
|
parse: () => parse,
|
|
519
574
|
parseAsync: () => parseAsync,
|
|
520
575
|
prettifyError: () => prettifyError,
|
|
521
|
-
process: () =>
|
|
576
|
+
process: () => process2,
|
|
522
577
|
regexes: () => regexes_exports,
|
|
523
578
|
registry: () => registry,
|
|
524
579
|
safeDecode: () => safeDecode,
|
|
@@ -11443,7 +11498,7 @@ function initializeContext(params) {
|
|
|
11443
11498
|
external: params?.external ?? void 0
|
|
11444
11499
|
};
|
|
11445
11500
|
}
|
|
11446
|
-
function
|
|
11501
|
+
function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
11447
11502
|
var _a3;
|
|
11448
11503
|
const def = schema._zod.def;
|
|
11449
11504
|
const seen = ctx.seen.get(schema);
|
|
@@ -11480,7 +11535,7 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
11480
11535
|
if (parent) {
|
|
11481
11536
|
if (!result.ref)
|
|
11482
11537
|
result.ref = parent;
|
|
11483
|
-
|
|
11538
|
+
process2(parent, ctx, params);
|
|
11484
11539
|
ctx.seen.get(parent).isParent = true;
|
|
11485
11540
|
}
|
|
11486
11541
|
}
|
|
@@ -11768,14 +11823,14 @@ function isTransforming(_schema, _ctx) {
|
|
|
11768
11823
|
}
|
|
11769
11824
|
var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
11770
11825
|
const ctx = initializeContext({ ...params, processors });
|
|
11771
|
-
|
|
11826
|
+
process2(schema, ctx);
|
|
11772
11827
|
extractDefs(ctx, schema);
|
|
11773
11828
|
return finalize(ctx, schema);
|
|
11774
11829
|
};
|
|
11775
11830
|
var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
11776
11831
|
const { libraryOptions, target } = params ?? {};
|
|
11777
11832
|
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
11778
|
-
|
|
11833
|
+
process2(schema, ctx);
|
|
11779
11834
|
extractDefs(ctx, schema);
|
|
11780
11835
|
return finalize(ctx, schema);
|
|
11781
11836
|
};
|
|
@@ -12021,7 +12076,7 @@ var arrayProcessor = (schema, ctx, _json, params) => {
|
|
|
12021
12076
|
if (typeof maximum === "number")
|
|
12022
12077
|
json2.maxItems = maximum;
|
|
12023
12078
|
json2.type = "array";
|
|
12024
|
-
json2.items =
|
|
12079
|
+
json2.items = process2(def.element, ctx, {
|
|
12025
12080
|
...params,
|
|
12026
12081
|
path: [...params.path, "items"]
|
|
12027
12082
|
});
|
|
@@ -12033,7 +12088,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
12033
12088
|
json2.properties = {};
|
|
12034
12089
|
const shape = def.shape;
|
|
12035
12090
|
for (const key in shape) {
|
|
12036
|
-
json2.properties[key] =
|
|
12091
|
+
json2.properties[key] = process2(shape[key], ctx, {
|
|
12037
12092
|
...params,
|
|
12038
12093
|
path: [...params.path, "properties", key]
|
|
12039
12094
|
});
|
|
@@ -12056,7 +12111,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
12056
12111
|
if (ctx.io === "output")
|
|
12057
12112
|
json2.additionalProperties = false;
|
|
12058
12113
|
} else if (def.catchall) {
|
|
12059
|
-
json2.additionalProperties =
|
|
12114
|
+
json2.additionalProperties = process2(def.catchall, ctx, {
|
|
12060
12115
|
...params,
|
|
12061
12116
|
path: [...params.path, "additionalProperties"]
|
|
12062
12117
|
});
|
|
@@ -12065,7 +12120,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
12065
12120
|
var unionProcessor = (schema, ctx, json2, params) => {
|
|
12066
12121
|
const def = schema._zod.def;
|
|
12067
12122
|
const isExclusive = def.inclusive === false;
|
|
12068
|
-
const options = def.options.map((x, i) =>
|
|
12123
|
+
const options = def.options.map((x, i) => process2(x, ctx, {
|
|
12069
12124
|
...params,
|
|
12070
12125
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
12071
12126
|
}));
|
|
@@ -12077,11 +12132,11 @@ var unionProcessor = (schema, ctx, json2, params) => {
|
|
|
12077
12132
|
};
|
|
12078
12133
|
var intersectionProcessor = (schema, ctx, json2, params) => {
|
|
12079
12134
|
const def = schema._zod.def;
|
|
12080
|
-
const a =
|
|
12135
|
+
const a = process2(def.left, ctx, {
|
|
12081
12136
|
...params,
|
|
12082
12137
|
path: [...params.path, "allOf", 0]
|
|
12083
12138
|
});
|
|
12084
|
-
const b =
|
|
12139
|
+
const b = process2(def.right, ctx, {
|
|
12085
12140
|
...params,
|
|
12086
12141
|
path: [...params.path, "allOf", 1]
|
|
12087
12142
|
});
|
|
@@ -12098,11 +12153,11 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
12098
12153
|
json2.type = "array";
|
|
12099
12154
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
12100
12155
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
12101
|
-
const prefixItems = def.items.map((x, i) =>
|
|
12156
|
+
const prefixItems = def.items.map((x, i) => process2(x, ctx, {
|
|
12102
12157
|
...params,
|
|
12103
12158
|
path: [...params.path, prefixPath, i]
|
|
12104
12159
|
}));
|
|
12105
|
-
const rest = def.rest ?
|
|
12160
|
+
const rest = def.rest ? process2(def.rest, ctx, {
|
|
12106
12161
|
...params,
|
|
12107
12162
|
path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
|
|
12108
12163
|
}) : null;
|
|
@@ -12142,7 +12197,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
12142
12197
|
const keyBag = keyType._zod.bag;
|
|
12143
12198
|
const patterns = keyBag?.patterns;
|
|
12144
12199
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
12145
|
-
const valueSchema =
|
|
12200
|
+
const valueSchema = process2(def.valueType, ctx, {
|
|
12146
12201
|
...params,
|
|
12147
12202
|
path: [...params.path, "patternProperties", "*"]
|
|
12148
12203
|
});
|
|
@@ -12152,12 +12207,12 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
12152
12207
|
}
|
|
12153
12208
|
} else {
|
|
12154
12209
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
12155
|
-
json2.propertyNames =
|
|
12210
|
+
json2.propertyNames = process2(def.keyType, ctx, {
|
|
12156
12211
|
...params,
|
|
12157
12212
|
path: [...params.path, "propertyNames"]
|
|
12158
12213
|
});
|
|
12159
12214
|
}
|
|
12160
|
-
json2.additionalProperties =
|
|
12215
|
+
json2.additionalProperties = process2(def.valueType, ctx, {
|
|
12161
12216
|
...params,
|
|
12162
12217
|
path: [...params.path, "additionalProperties"]
|
|
12163
12218
|
});
|
|
@@ -12172,7 +12227,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
12172
12227
|
};
|
|
12173
12228
|
var nullableProcessor = (schema, ctx, json2, params) => {
|
|
12174
12229
|
const def = schema._zod.def;
|
|
12175
|
-
const inner =
|
|
12230
|
+
const inner = process2(def.innerType, ctx, params);
|
|
12176
12231
|
const seen = ctx.seen.get(schema);
|
|
12177
12232
|
if (ctx.target === "openapi-3.0") {
|
|
12178
12233
|
seen.ref = def.innerType;
|
|
@@ -12183,20 +12238,20 @@ var nullableProcessor = (schema, ctx, json2, params) => {
|
|
|
12183
12238
|
};
|
|
12184
12239
|
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
12185
12240
|
const def = schema._zod.def;
|
|
12186
|
-
|
|
12241
|
+
process2(def.innerType, ctx, params);
|
|
12187
12242
|
const seen = ctx.seen.get(schema);
|
|
12188
12243
|
seen.ref = def.innerType;
|
|
12189
12244
|
};
|
|
12190
12245
|
var defaultProcessor = (schema, ctx, json2, params) => {
|
|
12191
12246
|
const def = schema._zod.def;
|
|
12192
|
-
|
|
12247
|
+
process2(def.innerType, ctx, params);
|
|
12193
12248
|
const seen = ctx.seen.get(schema);
|
|
12194
12249
|
seen.ref = def.innerType;
|
|
12195
12250
|
json2.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
12196
12251
|
};
|
|
12197
12252
|
var prefaultProcessor = (schema, ctx, json2, params) => {
|
|
12198
12253
|
const def = schema._zod.def;
|
|
12199
|
-
|
|
12254
|
+
process2(def.innerType, ctx, params);
|
|
12200
12255
|
const seen = ctx.seen.get(schema);
|
|
12201
12256
|
seen.ref = def.innerType;
|
|
12202
12257
|
if (ctx.io === "input")
|
|
@@ -12204,7 +12259,7 @@ var prefaultProcessor = (schema, ctx, json2, params) => {
|
|
|
12204
12259
|
};
|
|
12205
12260
|
var catchProcessor = (schema, ctx, json2, params) => {
|
|
12206
12261
|
const def = schema._zod.def;
|
|
12207
|
-
|
|
12262
|
+
process2(def.innerType, ctx, params);
|
|
12208
12263
|
const seen = ctx.seen.get(schema);
|
|
12209
12264
|
seen.ref = def.innerType;
|
|
12210
12265
|
let catchValue;
|
|
@@ -12219,32 +12274,32 @@ var pipeProcessor = (schema, ctx, _json, params) => {
|
|
|
12219
12274
|
const def = schema._zod.def;
|
|
12220
12275
|
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
12221
12276
|
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
12222
|
-
|
|
12277
|
+
process2(innerType, ctx, params);
|
|
12223
12278
|
const seen = ctx.seen.get(schema);
|
|
12224
12279
|
seen.ref = innerType;
|
|
12225
12280
|
};
|
|
12226
12281
|
var readonlyProcessor = (schema, ctx, json2, params) => {
|
|
12227
12282
|
const def = schema._zod.def;
|
|
12228
|
-
|
|
12283
|
+
process2(def.innerType, ctx, params);
|
|
12229
12284
|
const seen = ctx.seen.get(schema);
|
|
12230
12285
|
seen.ref = def.innerType;
|
|
12231
12286
|
json2.readOnly = true;
|
|
12232
12287
|
};
|
|
12233
12288
|
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
12234
12289
|
const def = schema._zod.def;
|
|
12235
|
-
|
|
12290
|
+
process2(def.innerType, ctx, params);
|
|
12236
12291
|
const seen = ctx.seen.get(schema);
|
|
12237
12292
|
seen.ref = def.innerType;
|
|
12238
12293
|
};
|
|
12239
12294
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
12240
12295
|
const def = schema._zod.def;
|
|
12241
|
-
|
|
12296
|
+
process2(def.innerType, ctx, params);
|
|
12242
12297
|
const seen = ctx.seen.get(schema);
|
|
12243
12298
|
seen.ref = def.innerType;
|
|
12244
12299
|
};
|
|
12245
12300
|
var lazyProcessor = (schema, ctx, _json, params) => {
|
|
12246
12301
|
const innerType = schema._zod.innerType;
|
|
12247
|
-
|
|
12302
|
+
process2(innerType, ctx, params);
|
|
12248
12303
|
const seen = ctx.seen.get(schema);
|
|
12249
12304
|
seen.ref = innerType;
|
|
12250
12305
|
};
|
|
@@ -12296,7 +12351,7 @@ function toJSONSchema(input, params) {
|
|
|
12296
12351
|
const defs = {};
|
|
12297
12352
|
for (const entry of registry2._idmap.entries()) {
|
|
12298
12353
|
const [_, schema] = entry;
|
|
12299
|
-
|
|
12354
|
+
process2(schema, ctx2);
|
|
12300
12355
|
}
|
|
12301
12356
|
const schemas = {};
|
|
12302
12357
|
const external = {
|
|
@@ -12319,7 +12374,7 @@ function toJSONSchema(input, params) {
|
|
|
12319
12374
|
return { schemas };
|
|
12320
12375
|
}
|
|
12321
12376
|
const ctx = initializeContext({ ...params, processors: allProcessors });
|
|
12322
|
-
|
|
12377
|
+
process2(input, ctx);
|
|
12323
12378
|
extractDefs(ctx, input);
|
|
12324
12379
|
return finalize(ctx, input);
|
|
12325
12380
|
}
|
|
@@ -12377,7 +12432,7 @@ var JSONSchemaGenerator = class {
|
|
|
12377
12432
|
* This must be called before emit().
|
|
12378
12433
|
*/
|
|
12379
12434
|
process(schema, _params = { path: [], schemaPath: [] }) {
|
|
12380
|
-
return
|
|
12435
|
+
return process2(schema, this.ctx, _params);
|
|
12381
12436
|
}
|
|
12382
12437
|
/**
|
|
12383
12438
|
* Emit the final JSON Schema after processing.
|
|
@@ -14526,6 +14581,65 @@ function date4(params) {
|
|
|
14526
14581
|
// node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
14527
14582
|
config(en_default());
|
|
14528
14583
|
|
|
14584
|
+
// src/lib/errors.ts
|
|
14585
|
+
var EXIT_BY_CODE = {
|
|
14586
|
+
NODE_UNSUPPORTED: 1,
|
|
14587
|
+
USAGE: 2,
|
|
14588
|
+
CONFIG_INVALID: 2,
|
|
14589
|
+
WALLET_EXISTS: 3,
|
|
14590
|
+
WALLET_MISSING: 1,
|
|
14591
|
+
WALLET_INVALID_KEY: 1,
|
|
14592
|
+
PROVIDER_ERROR: 1,
|
|
14593
|
+
RPC_ERROR: 1,
|
|
14594
|
+
API_UNREACHABLE: 1,
|
|
14595
|
+
CONTRACT_MISMATCH: 1,
|
|
14596
|
+
REFUSED: 3,
|
|
14597
|
+
NETWORK_ERROR: 1,
|
|
14598
|
+
INTERNAL: 1,
|
|
14599
|
+
NOT_IMPLEMENTED: 1,
|
|
14600
|
+
POLICY_REFUSED: 3,
|
|
14601
|
+
PAYMENT_FAILED: 4,
|
|
14602
|
+
RESOURCE_NOT_FOUND: 1,
|
|
14603
|
+
SEARCH_NOT_FOUND: 1,
|
|
14604
|
+
RATE_LIMITED: 1,
|
|
14605
|
+
// A publish awaiting confirmation or hard-blocked is understood-but-refused (3),
|
|
14606
|
+
// the same posture as POLICY_REFUSED; a write that failed after approval is a
|
|
14607
|
+
// settlement-class failure (4), like PAYMENT_FAILED.
|
|
14608
|
+
NEEDS_CONFIRMATION: 3,
|
|
14609
|
+
PUBLISH_BLOCKED: 3,
|
|
14610
|
+
PUBLISH_FAILED: 4,
|
|
14611
|
+
// A send that reverted or stalled AFTER the human approved it and it was
|
|
14612
|
+
// broadcast: the post-decision failure class (4), like PAYMENT_FAILED.
|
|
14613
|
+
SEND_FAILED: 4,
|
|
14614
|
+
// A delete the operator confirmed and the server then refused: same class.
|
|
14615
|
+
DELETE_FAILED: 4,
|
|
14616
|
+
UPDATE_FAILED: 1,
|
|
14617
|
+
// Refused BEFORE any signature existed: the Bazaar lane's fail-closed check.
|
|
14618
|
+
REGISTRY_MISMATCH: 3,
|
|
14619
|
+
// The seller's 402 challenge does not fit this process's header limit, so the
|
|
14620
|
+
// terms could not be read and nothing was sent. Understood and refused (3),
|
|
14621
|
+
// not a transport failure: the connection was fine and a retry changes
|
|
14622
|
+
// nothing without an operator raising `--max-http-header-size`.
|
|
14623
|
+
CHALLENGE_TOO_LARGE: 3
|
|
14624
|
+
};
|
|
14625
|
+
function exitCodeFor(code) {
|
|
14626
|
+
return EXIT_BY_CODE[code];
|
|
14627
|
+
}
|
|
14628
|
+
var CliError = class extends Error {
|
|
14629
|
+
code;
|
|
14630
|
+
exitCode;
|
|
14631
|
+
fix;
|
|
14632
|
+
details;
|
|
14633
|
+
constructor(code, message, opts = {}) {
|
|
14634
|
+
super(message, opts.cause !== void 0 ? { cause: opts.cause } : void 0);
|
|
14635
|
+
this.name = "CliError";
|
|
14636
|
+
this.code = code;
|
|
14637
|
+
this.exitCode = opts.exitCode ?? exitCodeFor(code);
|
|
14638
|
+
this.fix = opts.fix;
|
|
14639
|
+
this.details = opts.details;
|
|
14640
|
+
}
|
|
14641
|
+
};
|
|
14642
|
+
|
|
14529
14643
|
// src/lib/production-origin.ts
|
|
14530
14644
|
var PRODUCTION_ORIGIN = "https://tenjin.sh";
|
|
14531
14645
|
var PRODUCTION_HOST = new URL(PRODUCTION_ORIGIN).host;
|
|
@@ -14635,6 +14749,11 @@ async function recallBalance(path, address, now) {
|
|
|
14635
14749
|
|
|
14636
14750
|
// src/lib/config.ts
|
|
14637
14751
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
14752
|
+
|
|
14753
|
+
// src/adapters/types.ts
|
|
14754
|
+
var HARNESSES = ["claude", "codex"];
|
|
14755
|
+
|
|
14756
|
+
// src/lib/config.ts
|
|
14638
14757
|
var atomicString = external_exports.string().regex(/^\d+$/, "expected an atomic USDC integer string");
|
|
14639
14758
|
var PublishModeSchema = external_exports.enum(["review", "auto", "full-auto"]);
|
|
14640
14759
|
var AckServerWarningsSchema = external_exports.enum(["mode", "on", "off"]);
|
|
@@ -15136,6 +15255,9 @@ function isNotFound(err) {
|
|
|
15136
15255
|
}
|
|
15137
15256
|
|
|
15138
15257
|
export {
|
|
15258
|
+
writeFileAtomic,
|
|
15259
|
+
writeFileAtomicExclusive,
|
|
15260
|
+
fsyncDir,
|
|
15139
15261
|
$constructor,
|
|
15140
15262
|
defineLazy,
|
|
15141
15263
|
clone,
|
|
@@ -15167,9 +15289,11 @@ export {
|
|
|
15167
15289
|
custom,
|
|
15168
15290
|
preprocess,
|
|
15169
15291
|
external_exports,
|
|
15292
|
+
CliError,
|
|
15170
15293
|
PRODUCTION_ORIGIN,
|
|
15171
15294
|
isSameDeployment,
|
|
15172
15295
|
knownDeploymentOrigins,
|
|
15296
|
+
HARNESSES,
|
|
15173
15297
|
USDC_ADDRESS,
|
|
15174
15298
|
readUsdcBalance,
|
|
15175
15299
|
readUsdcBalanceWithFallback,
|
|
@@ -15199,4 +15323,4 @@ export {
|
|
|
15199
15323
|
resolveSettings,
|
|
15200
15324
|
resolveExperimentalBazaar
|
|
15201
15325
|
};
|
|
15202
|
-
//# sourceMappingURL=chunk-
|
|
15326
|
+
//# sourceMappingURL=chunk-QTND6XWJ.js.map
|