tenjin-cli 0.1.0-alpha.30 → 0.1.0-alpha.31
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 +65 -116
- package/dist/{_esm-CE7KNONL.js → _esm-MEXZI5DL.js} +4 -4
- package/dist/{alive-3J3CHOQP.js → alive-J64H46HI.js} +14 -4
- package/dist/{chunk-O2FRQ2L2.js → chunk-27EPWVOY.js} +4 -64
- package/dist/chunk-27EPWVOY.js.map +1 -0
- package/dist/{chunk-OSYTBCUC.js → chunk-2XLC3AEX.js} +16 -14
- package/dist/{chunk-OSYTBCUC.js.map → chunk-2XLC3AEX.js.map} +1 -1
- package/dist/chunk-3623BLPV.js +184 -0
- package/dist/chunk-3623BLPV.js.map +1 -0
- package/dist/chunk-3UCIG4TG.js +65 -0
- package/dist/chunk-3UCIG4TG.js.map +1 -0
- package/dist/{chunk-PAYV4XUA.js → chunk-4ZZO6ULA.js} +2 -2
- package/dist/{chunk-VUFAK2LW.js → chunk-5C32RLTA.js} +2 -2
- package/dist/{chunk-VUFAK2LW.js.map → chunk-5C32RLTA.js.map} +1 -1
- package/dist/{chunk-YHKXNYTB.js → chunk-5K5W4S66.js} +2 -2
- package/dist/{chunk-3O2BQIF6.js → chunk-5MARFNSB.js} +273 -482
- package/dist/chunk-5MARFNSB.js.map +1 -0
- package/dist/{chunk-HPWO4O6S.js → chunk-6E5R45ZO.js} +2 -2
- package/dist/{chunk-JMM6YE7J.js → chunk-77TCKDEC.js} +125 -312
- package/dist/chunk-77TCKDEC.js.map +1 -0
- package/dist/{chunk-LFZJM56J.js → chunk-7Q5FDF65.js} +2 -2
- package/dist/chunk-7WEQQJLG.js +68 -0
- package/dist/chunk-7WEQQJLG.js.map +1 -0
- package/dist/{chunk-AWFUPKTM.js → chunk-7WU4OPLP.js} +12 -6
- package/dist/{chunk-AWFUPKTM.js.map → chunk-7WU4OPLP.js.map} +1 -1
- package/dist/{chunk-AEG2PXBP.js → chunk-7ZRL2LBQ.js} +3 -3
- package/dist/{chunk-IOODYAXL.js → chunk-AGZ7PJKY.js} +6 -4
- package/dist/{chunk-IOODYAXL.js.map → chunk-AGZ7PJKY.js.map} +1 -1
- package/dist/{chunk-VFMQTSXG.js → chunk-B7HUUJOK.js} +3 -3
- package/dist/{chunk-EL56RW2J.js → chunk-BL3332HQ.js} +7 -7
- package/dist/{chunk-5LJCEMFD.js → chunk-D65GNPS3.js} +35 -27
- package/dist/{chunk-5LJCEMFD.js.map → chunk-D65GNPS3.js.map} +1 -1
- package/dist/{chunk-P7LABKCW.js → chunk-DOQGNFHM.js} +33 -2
- package/dist/{chunk-P7LABKCW.js.map → chunk-DOQGNFHM.js.map} +1 -1
- package/dist/{chunk-OK2TDZQU.js → chunk-FW75G2W4.js} +7 -5
- package/dist/chunk-FW75G2W4.js.map +1 -0
- package/dist/chunk-GA7JETVM.js +150 -0
- package/dist/chunk-GA7JETVM.js.map +1 -0
- package/dist/{chunk-6W5GYG3W.js → chunk-I3EQFHCD.js} +48 -1
- package/dist/chunk-I3EQFHCD.js.map +1 -0
- package/dist/{chunk-EBVIKMCH.js → chunk-JKKAIPTU.js} +2 -2
- package/dist/{chunk-N35E6CM2.js → chunk-K3I7C2MO.js} +6 -6
- package/dist/{chunk-KYFZTGMC.js → chunk-K72RURN3.js} +5 -3
- package/dist/{chunk-KYFZTGMC.js.map → chunk-K72RURN3.js.map} +1 -1
- package/dist/{chunk-RAULEAZ6.js → chunk-KXQ4UIP7.js} +3 -3
- package/dist/{chunk-VZGAONSJ.js → chunk-KXVP2VKA.js} +5 -5
- package/dist/chunk-LEFIX6RS.js +100 -0
- package/dist/chunk-LEFIX6RS.js.map +1 -0
- package/dist/{chunk-TTBKWWTV.js → chunk-MNXS2U45.js} +246 -83
- package/dist/chunk-MNXS2U45.js.map +1 -0
- package/dist/{chunk-AWQPGIR6.js → chunk-NEFNKLBE.js} +5 -5
- package/dist/chunk-OHRR5OYM.js +63 -0
- package/dist/chunk-OHRR5OYM.js.map +1 -0
- package/dist/{chunk-U6YQ6FRI.js → chunk-P4NH7OUK.js} +31 -11
- package/dist/chunk-P4NH7OUK.js.map +1 -0
- package/dist/chunk-QSCPK4F5.js +145 -0
- package/dist/chunk-QSCPK4F5.js.map +1 -0
- package/dist/chunk-QXP3Z3JN.js +131 -0
- package/dist/chunk-QXP3Z3JN.js.map +1 -0
- package/dist/{chunk-YFQOA5AU.js → chunk-R5LCN54M.js} +4 -4
- package/dist/{chunk-KHE6L6TD.js → chunk-UKY4CHNC.js} +92 -10
- package/dist/chunk-UKY4CHNC.js.map +1 -0
- package/dist/{chunk-QUVVWYJW.js → chunk-UQUOVWBG.js} +8 -6
- package/dist/{chunk-QUVVWYJW.js.map → chunk-UQUOVWBG.js.map} +1 -1
- package/dist/{chunk-HE2MS4QO.js → chunk-V6BSF6OC.js} +17 -13
- package/dist/{chunk-HE2MS4QO.js.map → chunk-V6BSF6OC.js.map} +1 -1
- package/dist/{chunk-WVUSXNIE.js → chunk-WJXLQXJY.js} +6 -2
- package/dist/{chunk-WVUSXNIE.js.map → chunk-WJXLQXJY.js.map} +1 -1
- package/dist/{chunk-NZIP4PA2.js → chunk-WK7F3B2E.js} +2 -2
- package/dist/chunk-XQJXNMSB.js +23 -0
- package/dist/chunk-XQJXNMSB.js.map +1 -0
- package/dist/chunk-Y527D4TV.js +56 -0
- package/dist/chunk-Y527D4TV.js.map +1 -0
- package/dist/{chunk-SPAVAYSW.js → chunk-YFPY4ONH.js} +6 -4
- package/dist/{chunk-SPAVAYSW.js.map → chunk-YFPY4ONH.js.map} +1 -1
- package/dist/{chunk-WO5BJNIB.js → chunk-YVFXE7RR.js} +9 -129
- package/dist/chunk-YVFXE7RR.js.map +1 -0
- package/dist/clack-EZ7TDWQU.js +19 -0
- package/dist/claude-cli-2YKABJJZ.js +31 -0
- package/dist/{cli-O5SN7ZJ4.js → cli-D5OE3URZ.js} +128 -56
- package/dist/{cli-O5SN7ZJ4.js.map → cli-D5OE3URZ.js.map} +1 -1
- package/dist/codex-event-PPNVRRDH.js +16 -0
- package/dist/codex-host-2RJOJW2B.js +28 -0
- package/dist/codex-install-UUZ6QMBQ.js +221 -0
- package/dist/codex-install-UUZ6QMBQ.js.map +1 -0
- package/dist/{config-OJQI27LT.js → config-ZD4OB2DO.js} +18 -12
- package/dist/{doctor-IQQJHGGM.js → doctor-KBR34Q4B.js} +48 -37
- package/dist/doctor-KBR34Q4B.js.map +1 -0
- package/dist/{fund-WEV6DMTD.js → fund-5ITKQGYF.js} +38 -31
- package/dist/{fund-WEV6DMTD.js.map → fund-5ITKQGYF.js.map} +1 -1
- package/dist/hook-command-4TYCHHRL.js +39 -0
- package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
- package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +3 -2
- package/dist/hosts/claude/tenjin/hooks/hooks.json +4 -1
- package/dist/hosts/claude/tenjin/hooks/register.tsx +589 -0
- package/dist/hosts/claude/tenjin/types/index.d.ts +41 -0
- package/dist/hosts/codex/.agents/plugins/marketplace.json +20 -0
- package/dist/hosts/codex/tenjin/.codex-plugin/plugin.json +16 -0
- package/dist/hosts/codex/tenjin/.mcp.json +12 -0
- package/dist/hosts/codex/tenjin/hooks/hooks.json +52 -0
- package/dist/hosts-FWZOV26H.js +216 -0
- package/dist/hosts-FWZOV26H.js.map +1 -0
- package/dist/index.js +5 -5
- package/dist/{install-TUCRF32I.js → install-XWGE4Q7L.js} +38 -21
- package/dist/{install-identity-WHPNMNMQ.js → install-identity-K7EJIQFP.js} +11 -7
- package/dist/{install-wallet-MA27FTQ5.js → install-wallet-XQ6XFZV4.js} +27 -23
- package/dist/{install-wallet-MA27FTQ5.js.map → install-wallet-XQ6XFZV4.js.map} +1 -1
- package/dist/{mcp-QML7ZMPH.js → mcp-3LIJSSJB.js} +184 -58
- package/dist/mcp-3LIJSSJB.js.map +1 -0
- package/dist/{package-LGKYOEPV.js → package-ZKQFDWLE.js} +2 -2
- package/dist/{pay-2C2UBBXJ.js → pay-WHBERZ3W.js} +27 -23
- package/dist/{payments-C44QUFXU.js → payments-KVICEKD2.js} +14 -10
- package/dist/{payments-C44QUFXU.js.map → payments-KVICEKD2.js.map} +1 -1
- package/dist/plugin-registration-5TIA564H.js +54 -0
- package/dist/plugin-registration-5TIA564H.js.map +1 -0
- package/dist/{send-KVJX4XIR.js → send-7G7Y7DLN.js} +25 -19
- package/dist/{send-KVJX4XIR.js.map → send-7G7Y7DLN.js.map} +1 -1
- package/dist/{status-S7C3WMSH.js → status-OF7RH5HM.js} +26 -21
- package/dist/{status-S7C3WMSH.js.map → status-OF7RH5HM.js.map} +1 -1
- package/dist/{status-line-YR2T5HC4.js → status-line-XOUE6MPL.js} +10 -6
- package/dist/{status-line-YR2T5HC4.js.map → status-line-XOUE6MPL.js.map} +1 -1
- package/dist/{uninstall-HY6LKIIT.js → uninstall-JXUAFNDB.js} +30 -21
- package/dist/{uninstall-HY6LKIIT.js.map → uninstall-JXUAFNDB.js.map} +1 -1
- package/dist/update-ZKUERSO2.js +44 -0
- package/dist/update-ZKUERSO2.js.map +1 -0
- package/dist/{usdc-JK4RRFFQ.js → usdc-OGOGEHV2.js} +7 -6
- package/dist/usdc-OGOGEHV2.js.map +1 -0
- package/dist/{viemAdapter-By13KInL-X2VY6CY3.js → viemAdapter-By13KInL-S3DA7DFW.js} +2 -2
- package/dist/viemAdapter-By13KInL-S3DA7DFW.js.map +1 -0
- package/dist/{wallet-PD2IMZDU.js → wallet-2HA6W4R4.js} +24 -20
- package/dist/wallet-2HA6W4R4.js.map +1 -0
- package/docs/agent-permissions.md +21 -5
- package/package.json +1 -1
- package/dist/chunk-3O2BQIF6.js.map +0 -1
- package/dist/chunk-6W5GYG3W.js.map +0 -1
- package/dist/chunk-JMM6YE7J.js.map +0 -1
- package/dist/chunk-KHE6L6TD.js.map +0 -1
- package/dist/chunk-O2FRQ2L2.js.map +0 -1
- package/dist/chunk-OK2TDZQU.js.map +0 -1
- package/dist/chunk-TTBKWWTV.js.map +0 -1
- package/dist/chunk-U6YQ6FRI.js.map +0 -1
- package/dist/chunk-WO5BJNIB.js.map +0 -1
- package/dist/doctor-IQQJHGGM.js.map +0 -1
- package/dist/hook-command-D2P3ILRV.js +0 -32
- package/dist/mcp-QML7ZMPH.js.map +0 -1
- package/dist/update-OJV22LR3.js +0 -36
- /package/dist/{_esm-CE7KNONL.js.map → _esm-MEXZI5DL.js.map} +0 -0
- /package/dist/{alive-3J3CHOQP.js.map → alive-J64H46HI.js.map} +0 -0
- /package/dist/{chunk-PAYV4XUA.js.map → chunk-4ZZO6ULA.js.map} +0 -0
- /package/dist/{chunk-YHKXNYTB.js.map → chunk-5K5W4S66.js.map} +0 -0
- /package/dist/{chunk-HPWO4O6S.js.map → chunk-6E5R45ZO.js.map} +0 -0
- /package/dist/{chunk-LFZJM56J.js.map → chunk-7Q5FDF65.js.map} +0 -0
- /package/dist/{chunk-AEG2PXBP.js.map → chunk-7ZRL2LBQ.js.map} +0 -0
- /package/dist/{chunk-VFMQTSXG.js.map → chunk-B7HUUJOK.js.map} +0 -0
- /package/dist/{chunk-EL56RW2J.js.map → chunk-BL3332HQ.js.map} +0 -0
- /package/dist/{chunk-EBVIKMCH.js.map → chunk-JKKAIPTU.js.map} +0 -0
- /package/dist/{chunk-N35E6CM2.js.map → chunk-K3I7C2MO.js.map} +0 -0
- /package/dist/{chunk-RAULEAZ6.js.map → chunk-KXQ4UIP7.js.map} +0 -0
- /package/dist/{chunk-VZGAONSJ.js.map → chunk-KXVP2VKA.js.map} +0 -0
- /package/dist/{chunk-AWQPGIR6.js.map → chunk-NEFNKLBE.js.map} +0 -0
- /package/dist/{chunk-YFQOA5AU.js.map → chunk-R5LCN54M.js.map} +0 -0
- /package/dist/{chunk-NZIP4PA2.js.map → chunk-WK7F3B2E.js.map} +0 -0
- /package/dist/{config-OJQI27LT.js.map → clack-EZ7TDWQU.js.map} +0 -0
- /package/dist/{hook-command-D2P3ILRV.js.map → claude-cli-2YKABJJZ.js.map} +0 -0
- /package/dist/{install-TUCRF32I.js.map → codex-event-PPNVRRDH.js.map} +0 -0
- /package/dist/{install-identity-WHPNMNMQ.js.map → codex-host-2RJOJW2B.js.map} +0 -0
- /package/dist/{package-LGKYOEPV.js.map → config-ZD4OB2DO.js.map} +0 -0
- /package/dist/{pay-2C2UBBXJ.js.map → hook-command-4TYCHHRL.js.map} +0 -0
- /package/dist/{update-OJV22LR3.js.map → install-XWGE4Q7L.js.map} +0 -0
- /package/dist/{usdc-JK4RRFFQ.js.map → install-identity-K7EJIQFP.js.map} +0 -0
- /package/dist/{viemAdapter-By13KInL-X2VY6CY3.js.map → package-ZKQFDWLE.js.map} +0 -0
- /package/dist/{wallet-PD2IMZDU.js.map → pay-WHBERZ3W.js.map} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"UserPromptSubmit": [
|
|
4
|
+
{
|
|
5
|
+
"hooks": [
|
|
6
|
+
{
|
|
7
|
+
"type": "command",
|
|
8
|
+
"command": "tenjin hook prompt --harness codex",
|
|
9
|
+
"timeout": 5
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"PreToolUse": [
|
|
15
|
+
{
|
|
16
|
+
"matcher": "webrun",
|
|
17
|
+
"hooks": [
|
|
18
|
+
{
|
|
19
|
+
"type": "command",
|
|
20
|
+
"command": "tenjin hook native --harness codex",
|
|
21
|
+
"timeout": 5
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"PostToolUse": [
|
|
27
|
+
{
|
|
28
|
+
"matcher": "webrun",
|
|
29
|
+
"hooks": [
|
|
30
|
+
{
|
|
31
|
+
"type": "command",
|
|
32
|
+
"command": "tenjin hook shortfall --harness codex",
|
|
33
|
+
"timeout": 15
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"PermissionRequest": [
|
|
39
|
+
{
|
|
40
|
+
"matcher": "mcp__router__request",
|
|
41
|
+
"hooks": [
|
|
42
|
+
{
|
|
43
|
+
"type": "command",
|
|
44
|
+
"command": "echo '{\"hookSpecificOutput\":{\"hookEventName\":\"PermissionRequest\",\"decision\":{\"behavior\":\"allow\"}}}'",
|
|
45
|
+
"commandWindows": "echo {\"hookSpecificOutput\":{\"hookEventName\":\"PermissionRequest\",\"decision\":{\"behavior\":\"allow\"}}}",
|
|
46
|
+
"timeout": 5
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
HARNESSES
|
|
4
|
+
} from "./chunk-WJXLQXJY.js";
|
|
5
|
+
import {
|
|
6
|
+
CliError
|
|
7
|
+
} from "./chunk-3UCIG4TG.js";
|
|
8
|
+
import {
|
|
9
|
+
writeFileAtomic
|
|
10
|
+
} from "./chunk-7WEQQJLG.js";
|
|
11
|
+
import "./chunk-ZXTAQYNA.js";
|
|
12
|
+
|
|
13
|
+
// src/router/hosts.ts
|
|
14
|
+
import { readFile, rm } from "node:fs/promises";
|
|
15
|
+
import { homedir } from "node:os";
|
|
16
|
+
import { join } from "node:path";
|
|
17
|
+
var HOSTS_FILE = "installed-hosts.json";
|
|
18
|
+
var LABEL = { claude: "Claude Code", codex: "Codex" };
|
|
19
|
+
async function readInstalledHosts(dataDir) {
|
|
20
|
+
let raw;
|
|
21
|
+
try {
|
|
22
|
+
raw = await readFile(join(dataDir, HOSTS_FILE), "utf8");
|
|
23
|
+
} catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const hosts = JSON.parse(raw).hosts;
|
|
28
|
+
if (!Array.isArray(hosts)) return null;
|
|
29
|
+
return HARNESSES.filter((h) => hosts.includes(h));
|
|
30
|
+
} catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function writeHosts(dataDir, hosts) {
|
|
35
|
+
const path = join(dataDir, HOSTS_FILE);
|
|
36
|
+
if (hosts.length === 0) {
|
|
37
|
+
await rm(path, { force: true });
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
await writeFileAtomic(path, `${JSON.stringify({ hosts }, null, 2)}
|
|
41
|
+
`, { mode: 384 });
|
|
42
|
+
}
|
|
43
|
+
async function claudePluginPresent(env = process.env, home = homedir()) {
|
|
44
|
+
const [{ listedInClaudeFiles }, { folderState }] = await Promise.all([
|
|
45
|
+
import("./doctor-KBR34Q4B.js"),
|
|
46
|
+
import("./plugin-registration-5TIA564H.js")
|
|
47
|
+
]);
|
|
48
|
+
if (await listedInClaudeFiles(env, home)) return true;
|
|
49
|
+
return (await folderState("user", env, home, home)).state === "ours";
|
|
50
|
+
}
|
|
51
|
+
async function recordInstalledHost(dataDir, host, present = () => claudePluginPresent()) {
|
|
52
|
+
const recorded = await readInstalledHosts(dataDir);
|
|
53
|
+
const hosts = recorded ?? (host !== "claude" && await present().catch(() => false) ? ["claude"] : []);
|
|
54
|
+
if (hosts.includes(host)) return;
|
|
55
|
+
await writeHosts(
|
|
56
|
+
dataDir,
|
|
57
|
+
HARNESSES.filter((h) => h === host || hosts.includes(h))
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
async function forgetInstalledHost(dataDir, host) {
|
|
61
|
+
const hosts = await readInstalledHosts(dataDir);
|
|
62
|
+
if (hosts === null || !hosts.includes(host)) return;
|
|
63
|
+
await writeHosts(
|
|
64
|
+
dataDir,
|
|
65
|
+
hosts.filter((h) => h !== host)
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
function agentHost(env) {
|
|
69
|
+
const set = (v) => typeof v === "string" && v.trim().length > 0;
|
|
70
|
+
if (set(env.CLAUDECODE) || set(env.CLAUDE_CODE_SESSION_ID) || set(env.CLAUDE_CODE_EXECPATH)) {
|
|
71
|
+
return "claude";
|
|
72
|
+
}
|
|
73
|
+
if (set(env.CODEX_SESSION_ID)) return "codex";
|
|
74
|
+
return void 0;
|
|
75
|
+
}
|
|
76
|
+
async function detectHosts(env) {
|
|
77
|
+
const [{ readClaudeCode }, { codexVersion }] = await Promise.all([
|
|
78
|
+
import("./claude-cli-2YKABJJZ.js"),
|
|
79
|
+
import("./codex-host-2RJOJW2B.js")
|
|
80
|
+
]);
|
|
81
|
+
const [claude, codex] = await Promise.all([
|
|
82
|
+
readClaudeCode(env, process.cwd()).then(
|
|
83
|
+
(s) => s.version !== null,
|
|
84
|
+
() => false
|
|
85
|
+
),
|
|
86
|
+
codexVersion().then(
|
|
87
|
+
(v) => v !== null,
|
|
88
|
+
() => false
|
|
89
|
+
)
|
|
90
|
+
]);
|
|
91
|
+
return HARNESSES.filter((h) => h === "claude" ? claude : codex);
|
|
92
|
+
}
|
|
93
|
+
async function askHosts(found) {
|
|
94
|
+
const { selectMany } = await import("./clack-EZ7TDWQU.js");
|
|
95
|
+
return selectMany({
|
|
96
|
+
message: "Set up Tenjin for which agents?",
|
|
97
|
+
choices: found.map((h) => ({ value: h, label: LABEL[h] })),
|
|
98
|
+
initialValues: found
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
async function installHosts(args, ctx, deps = {}) {
|
|
102
|
+
if (args.harness !== void 0) return [args.harness];
|
|
103
|
+
if (args.refresh === true || args.project === true) return ["claude"];
|
|
104
|
+
const env = deps.env ?? process.env;
|
|
105
|
+
const agent = agentHost(env);
|
|
106
|
+
if (agent !== void 0) return [agent];
|
|
107
|
+
const found = await (deps.detect ?? detectHosts)(env);
|
|
108
|
+
if (found.length === 0) return ["claude"];
|
|
109
|
+
if (found.length === 1 || args.yes === true) return found;
|
|
110
|
+
const interactive = ctx.flags.json !== true && (deps.isInteractive ?? (ctx.io.isTTY && Boolean(process.stdin.isTTY)));
|
|
111
|
+
if (!interactive) return found;
|
|
112
|
+
const picked = await (deps.ask ?? askHosts)(found);
|
|
113
|
+
if (picked === null || picked.length === 0) {
|
|
114
|
+
throw new CliError("REFUSED", "Install cancelled before anything was written.", {
|
|
115
|
+
fix: "Re-run `tenjin install` and pick at least one agent."
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return HARNESSES.filter((h) => picked.includes(h));
|
|
119
|
+
}
|
|
120
|
+
async function otherHostNote(args, deps = {}) {
|
|
121
|
+
if (args.harness !== void 0 || args.refresh === true || args.project === true) {
|
|
122
|
+
return void 0;
|
|
123
|
+
}
|
|
124
|
+
const env = deps.env ?? process.env;
|
|
125
|
+
const agent = agentHost(env);
|
|
126
|
+
if (agent === void 0) return void 0;
|
|
127
|
+
const other = agent === "claude" ? "codex" : "claude";
|
|
128
|
+
if (!(await (deps.detect ?? detectHosts)(env)).includes(other)) return void 0;
|
|
129
|
+
return `${LABEL[other]} is also installed on this machine. Ask the person: "Should I also set up Tenjin for ${LABEL[other]}?" On yes, run \`tenjin install --harness ${other}\`.`;
|
|
130
|
+
}
|
|
131
|
+
function withNote(out, note) {
|
|
132
|
+
if (note === void 0) return out;
|
|
133
|
+
const data = out.data ?? {};
|
|
134
|
+
const notices = Array.isArray(data.notices) ? data.notices : [];
|
|
135
|
+
return {
|
|
136
|
+
data: { ...data, notices: [...notices, note] },
|
|
137
|
+
humanLines: [...out.humanLines ?? [], note]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
async function recordedHosts(args, dataDir) {
|
|
141
|
+
if (args.harness !== void 0) return [args.harness];
|
|
142
|
+
if (args.project === true) return ["claude"];
|
|
143
|
+
const hosts = await readInstalledHosts(dataDir);
|
|
144
|
+
return hosts === null || hosts.length === 0 ? ["claude"] : hosts;
|
|
145
|
+
}
|
|
146
|
+
async function runEach(hosts, run) {
|
|
147
|
+
const [only] = hosts;
|
|
148
|
+
if (hosts.length === 1 && only !== void 0) return run(only);
|
|
149
|
+
const data = { hosts };
|
|
150
|
+
const humanLines = [];
|
|
151
|
+
for (const host of hosts) {
|
|
152
|
+
const out = await run(host);
|
|
153
|
+
data[host] = out.data;
|
|
154
|
+
humanLines.push(`${LABEL[host]}:`, ...(out.humanLines ?? []).map((l) => ` ${l}`));
|
|
155
|
+
}
|
|
156
|
+
return { data, humanLines };
|
|
157
|
+
}
|
|
158
|
+
async function uninstallEach(hosts, dataDir, project, run) {
|
|
159
|
+
return runEach(hosts, async (host) => {
|
|
160
|
+
const out = await run(host);
|
|
161
|
+
if (!project && !pluginKept(out.data)) await forgetInstalledHost(dataDir, host);
|
|
162
|
+
return out;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function pluginKept(data) {
|
|
166
|
+
const plugin = data?.plugin;
|
|
167
|
+
return plugin !== null && typeof plugin === "object" && plugin.plugin === "kept";
|
|
168
|
+
}
|
|
169
|
+
async function checkEach(hosts, run) {
|
|
170
|
+
const [only] = hosts;
|
|
171
|
+
if (hosts.length === 1 && only !== void 0) return run(only);
|
|
172
|
+
const data = { hosts };
|
|
173
|
+
const humanLines = [];
|
|
174
|
+
const failed = [];
|
|
175
|
+
for (const host of hosts) {
|
|
176
|
+
try {
|
|
177
|
+
const out = await run(host);
|
|
178
|
+
data[host] = out.data;
|
|
179
|
+
humanLines.push(`${LABEL[host]}:`, ...(out.humanLines ?? []).map((l) => ` ${l}`));
|
|
180
|
+
} catch (err) {
|
|
181
|
+
if (!(err instanceof CliError)) throw err;
|
|
182
|
+
data[host] = {
|
|
183
|
+
error: err.message,
|
|
184
|
+
...err.details !== void 0 ? { details: err.details } : {}
|
|
185
|
+
};
|
|
186
|
+
failed.push({ host, err });
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (failed.length === 0) return { data, humanLines };
|
|
190
|
+
throw new CliError(
|
|
191
|
+
"REFUSED",
|
|
192
|
+
failed.map(({ host, err }) => `${LABEL[host]}: ${err.message}`).join(" "),
|
|
193
|
+
{
|
|
194
|
+
details: data,
|
|
195
|
+
fix: failed.map(({ host, err }) => `${LABEL[host]}:
|
|
196
|
+
${err.fix ?? err.message}`).join("\n")
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
export {
|
|
201
|
+
HOSTS_FILE,
|
|
202
|
+
agentHost,
|
|
203
|
+
checkEach,
|
|
204
|
+
claudePluginPresent,
|
|
205
|
+
detectHosts,
|
|
206
|
+
forgetInstalledHost,
|
|
207
|
+
installHosts,
|
|
208
|
+
otherHostNote,
|
|
209
|
+
readInstalledHosts,
|
|
210
|
+
recordInstalledHost,
|
|
211
|
+
recordedHosts,
|
|
212
|
+
runEach,
|
|
213
|
+
uninstallEach,
|
|
214
|
+
withNote
|
|
215
|
+
};
|
|
216
|
+
//# sourceMappingURL=hosts-FWZOV26H.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/hosts.ts"],"sourcesContent":["import { readFile, rm } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport type { CommandContext, CommandResult } from '../context';\nimport { writeFileAtomic } from '../lib/atomic-json';\nimport { CliError } from '../lib/errors';\nimport { HARNESSES, type Harness } from './names';\n\n/**\n * WHICH AGENT HOSTS `install`, `doctor` AND `uninstall` SERVE. Nobody names a\n * host on the normal path: an agent's install goes to the host it runs in, a\n * terminal install to the hosts this machine has (asking when it has both),\n * and doctor and uninstall read the hosts install recorded. `--harness` only\n * overrides.\n */\n\n/** The record install writes in the Tenjin data dir: the hosts it set up. */\nexport const HOSTS_FILE = 'installed-hosts.json';\n\nconst LABEL: Record<Harness, string> = { claude: 'Claude Code', codex: 'Codex' };\n\n/** The hosts install recorded, or null on a machine set up before the record. */\nexport async function readInstalledHosts(dataDir: string): Promise<Harness[] | null> {\n let raw: string;\n try {\n raw = await readFile(join(dataDir, HOSTS_FILE), 'utf8');\n } catch {\n return null;\n }\n try {\n const hosts = (JSON.parse(raw) as { hosts?: unknown }).hosts;\n if (!Array.isArray(hosts)) return null;\n return HARNESSES.filter((h) => hosts.includes(h));\n } catch {\n return null;\n }\n}\n\nasync function writeHosts(dataDir: string, hosts: readonly Harness[]): Promise<void> {\n const path = join(dataDir, HOSTS_FILE);\n if (hosts.length === 0) {\n await rm(path, { force: true });\n return;\n }\n await writeFileAtomic(path, `${JSON.stringify({ hosts }, null, 2)}\\n`, { mode: 0o600 });\n}\n\n/**\n * Is the Claude Code plugin here already, from a release that wrote no record?\n * Claude Code's own plugin list file, as doctor reads it with no binary, or\n * the plugin folder of ours at user scope.\n */\nexport async function claudePluginPresent(\n env: NodeJS.ProcessEnv = process.env,\n home: string = homedir(),\n): Promise<boolean> {\n const [{ listedInClaudeFiles }, { folderState }] = await Promise.all([\n import('./doctor'),\n import('./plugin-registration'),\n ]);\n if (await listedInClaudeFiles(env, home)) return true;\n return (await folderState('user', env, home, home)).state === 'ours';\n}\n\n/**\n * A host whose setup finished. The first record on a machine whose Claude\n * Code plugin came from a release before the record starts with Claude Code,\n * so doctor and uninstall keep covering it.\n */\nexport async function recordInstalledHost(\n dataDir: string,\n host: Harness,\n present: () => Promise<boolean> = () => claudePluginPresent(),\n): Promise<void> {\n const recorded = await readInstalledHosts(dataDir);\n const hosts =\n recorded ?? (host !== 'claude' && (await present().catch(() => false)) ? ['claude'] : []);\n if (hosts.includes(host)) return;\n await writeHosts(\n dataDir,\n HARNESSES.filter((h) => h === host || hosts.includes(h)),\n );\n}\n\nexport async function forgetInstalledHost(dataDir: string, host: Harness): Promise<void> {\n const hosts = await readInstalledHosts(dataDir);\n if (hosts === null || !hosts.includes(host)) return;\n await writeHosts(\n dataDir,\n hosts.filter((h) => h !== host),\n );\n}\n\n/**\n * The host whose agent runs this command, from the variables each exports, or\n * undefined in a person's own terminal. A Claude Code variable wins when both\n * are set, as `readActor` reads them.\n */\nexport function agentHost(env: NodeJS.ProcessEnv): Harness | undefined {\n const set = (v: string | undefined) => typeof v === 'string' && v.trim().length > 0;\n if (set(env.CLAUDECODE) || set(env.CLAUDE_CODE_SESSION_ID) || set(env.CLAUDE_CODE_EXECPATH)) {\n return 'claude';\n }\n if (set(env.CODEX_SESSION_ID)) return 'codex';\n return undefined;\n}\n\n/** The hosts this machine can run: each counts only when its `--version` answers. */\nexport async function detectHosts(env: NodeJS.ProcessEnv): Promise<Harness[]> {\n const [{ readClaudeCode }, { codexVersion }] = await Promise.all([\n import('./claude-cli'),\n import('./codex-host'),\n ]);\n const [claude, codex] = await Promise.all([\n readClaudeCode(env, process.cwd()).then(\n (s) => s.version !== null,\n () => false,\n ),\n codexVersion().then(\n (v) => v !== null,\n () => false,\n ),\n ]);\n return HARNESSES.filter((h) => (h === 'claude' ? claude : codex));\n}\n\nasync function askHosts(found: readonly Harness[]): Promise<Harness[] | null> {\n const { selectMany } = await import('../lib/clack');\n return selectMany<Harness>({\n message: 'Set up Tenjin for which agents?',\n choices: found.map((h) => ({ value: h, label: LABEL[h] })),\n initialValues: found,\n });\n}\n\nexport interface HostDeps {\n env?: NodeJS.ProcessEnv;\n detect?: (env: NodeJS.ProcessEnv) => Promise<Harness[]>;\n ask?: (found: readonly Harness[]) => Promise<Harness[] | null>;\n isInteractive?: boolean;\n}\n\nexport interface InstallHostArgs {\n harness?: Harness;\n project?: boolean;\n refresh?: boolean;\n yes?: boolean;\n}\n\n/**\n * The hosts this install sets up. A refresh and a project install are Claude\n * Code's alone; an agent's install goes to its own host; a terminal install\n * goes to every host found, asking first when there are two and a person can\n * answer. A machine with neither gets the Claude Code setup, which needs no\n * `claude` binary.\n */\nexport async function installHosts(\n args: InstallHostArgs,\n ctx: CommandContext,\n deps: HostDeps = {},\n): Promise<Harness[]> {\n if (args.harness !== undefined) return [args.harness];\n if (args.refresh === true || args.project === true) return ['claude'];\n const env = deps.env ?? process.env;\n const agent = agentHost(env);\n if (agent !== undefined) return [agent];\n const found = await (deps.detect ?? detectHosts)(env);\n if (found.length === 0) return ['claude'];\n if (found.length === 1 || args.yes === true) return found;\n const interactive =\n ctx.flags.json !== true &&\n (deps.isInteractive ?? (ctx.io.isTTY && Boolean(process.stdin.isTTY)));\n if (!interactive) return found;\n const picked = await (deps.ask ?? askHosts)(found);\n if (picked === null || picked.length === 0) {\n throw new CliError('REFUSED', 'Install cancelled before anything was written.', {\n fix: 'Re-run `tenjin install` and pick at least one agent.',\n });\n }\n return HARNESSES.filter((h) => picked.includes(h));\n}\n\n/**\n * Under an agent, the line naming the other host when its `--version` runs\n * too: a yes/no question the agent asks the person, and what a yes runs.\n */\nexport async function otherHostNote(\n args: InstallHostArgs,\n deps: HostDeps = {},\n): Promise<string | undefined> {\n if (args.harness !== undefined || args.refresh === true || args.project === true) {\n return undefined;\n }\n const env = deps.env ?? process.env;\n const agent = agentHost(env);\n if (agent === undefined) return undefined;\n const other: Harness = agent === 'claude' ? 'codex' : 'claude';\n if (!(await (deps.detect ?? detectHosts)(env)).includes(other)) return undefined;\n return `${LABEL[other]} is also installed on this machine. Ask the person: \"Should I also set up Tenjin for ${LABEL[other]}?\" On yes, run \\`tenjin install --harness ${other}\\`.`;\n}\n\n/** The install result with `note` in its `notices` and as its last line. */\nexport function withNote(out: CommandResult, note: string | undefined): CommandResult {\n if (note === undefined) return out;\n const data = (out.data ?? {}) as { notices?: unknown };\n const notices = Array.isArray(data.notices) ? (data.notices as string[]) : [];\n return {\n data: { ...data, notices: [...notices, note] },\n humanLines: [...(out.humanLines ?? []), note],\n };\n}\n\n/** The hosts doctor checks and uninstall removes: the record, else Claude Code. */\nexport async function recordedHosts(\n args: { harness?: Harness; project?: boolean },\n dataDir: string,\n): Promise<Harness[]> {\n if (args.harness !== undefined) return [args.harness];\n if (args.project === true) return ['claude'];\n const hosts = await readInstalledHosts(dataDir);\n return hosts === null || hosts.length === 0 ? ['claude'] : hosts;\n}\n\n/** One run per host, in order. One host keeps its own result shape. */\nexport async function runEach(\n hosts: readonly Harness[],\n run: (host: Harness) => Promise<CommandResult>,\n): Promise<CommandResult> {\n const [only] = hosts;\n if (hosts.length === 1 && only !== undefined) return run(only);\n const data: Record<string, unknown> = { hosts };\n const humanLines: string[] = [];\n for (const host of hosts) {\n const out = await run(host);\n data[host] = out.data;\n humanLines.push(`${LABEL[host]}:`, ...(out.humanLines ?? []).map((l) => ` ${l}`));\n }\n return { data, humanLines };\n}\n\n/**\n * Uninstall over the hosts: a host leaves the record only once its removal\n * left nothing behind. A Claude Code removal that reports the plugin `kept`,\n * or a Codex removal that failed (it throws), keeps the host recorded so a\n * later bare uninstall or doctor still finds it. A project uninstall leaves\n * the user-scope install, so it forgets nothing.\n */\nexport async function uninstallEach(\n hosts: readonly Harness[],\n dataDir: string,\n project: boolean,\n run: (host: Harness) => Promise<CommandResult>,\n): Promise<CommandResult> {\n return runEach(hosts, async (host) => {\n const out = await run(host);\n if (!project && !pluginKept(out.data)) await forgetInstalledHost(dataDir, host);\n return out;\n });\n}\n\n/** The Claude Code removal's `plugin.plugin: 'kept'`: the plugin is still there. */\nfunction pluginKept(data: unknown): boolean {\n const plugin = (data as { plugin?: unknown } | null)?.plugin;\n return (\n plugin !== null &&\n typeof plugin === 'object' &&\n (plugin as { plugin?: unknown }).plugin === 'kept'\n );\n}\n\n/**\n * Doctor over several hosts: every host is checked before any failure is\n * reported, and the failure names each host that failed.\n */\nexport async function checkEach(\n hosts: readonly Harness[],\n run: (host: Harness) => Promise<CommandResult>,\n): Promise<CommandResult> {\n const [only] = hosts;\n if (hosts.length === 1 && only !== undefined) return run(only);\n const data: Record<string, unknown> = { hosts };\n const humanLines: string[] = [];\n const failed: { host: Harness; err: CliError }[] = [];\n for (const host of hosts) {\n try {\n const out = await run(host);\n data[host] = out.data;\n humanLines.push(`${LABEL[host]}:`, ...(out.humanLines ?? []).map((l) => ` ${l}`));\n } catch (err) {\n if (!(err instanceof CliError)) throw err;\n data[host] = {\n error: err.message,\n ...(err.details !== undefined ? { details: err.details } : {}),\n };\n failed.push({ host, err });\n }\n }\n if (failed.length === 0) return { data, humanLines };\n throw new CliError(\n 'REFUSED',\n failed.map(({ host, err }) => `${LABEL[host]}: ${err.message}`).join(' '),\n {\n details: data,\n fix: failed.map(({ host, err }) => `${LABEL[host]}:\\n${err.fix ?? err.message}`).join('\\n'),\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,UAAU,UAAU;AAC7B,SAAS,eAAe;AACxB,SAAS,YAAY;AAed,IAAM,aAAa;AAE1B,IAAM,QAAiC,EAAE,QAAQ,eAAe,OAAO,QAAQ;AAG/E,eAAsB,mBAAmB,SAA4C;AACnF,MAAI;AACJ,MAAI;AACF,UAAM,MAAM,SAAS,KAAK,SAAS,UAAU,GAAG,MAAM;AAAA,EACxD,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI;AACF,UAAM,QAAS,KAAK,MAAM,GAAG,EAA0B;AACvD,QAAI,CAAC,MAAM,QAAQ,KAAK,EAAG,QAAO;AAClC,WAAO,UAAU,OAAO,CAAC,MAAM,MAAM,SAAS,CAAC,CAAC;AAAA,EAClD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,eAAe,WAAW,SAAiB,OAA0C;AACnF,QAAM,OAAO,KAAK,SAAS,UAAU;AACrC,MAAI,MAAM,WAAW,GAAG;AACtB,UAAM,GAAG,MAAM,EAAE,OAAO,KAAK,CAAC;AAC9B;AAAA,EACF;AACA,QAAM,gBAAgB,MAAM,GAAG,KAAK,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAAA,GAAM,EAAE,MAAM,IAAM,CAAC;AACxF;AAOA,eAAsB,oBACpB,MAAyB,QAAQ,KACjC,OAAe,QAAQ,GACL;AAClB,QAAM,CAAC,EAAE,oBAAoB,GAAG,EAAE,YAAY,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,IACnE,OAAO,sBAAU;AAAA,IACjB,OAAO,mCAAuB;AAAA,EAChC,CAAC;AACD,MAAI,MAAM,oBAAoB,KAAK,IAAI,EAAG,QAAO;AACjD,UAAQ,MAAM,YAAY,QAAQ,KAAK,MAAM,IAAI,GA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AG,QAAO,EAAE,MAAM,WAAW;AACnD,QAAM,IAAI;AAAA,IACR;AAAA,IACA,OAAO,IAAI,CAAC,EAAE,MAAM,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,IAAI,OAAO,EAAE,EAAE,KAAK,GAAG;AAAA,IACxE;AAAA,MACE,SAAS;AAAA,MACT,KAAK,OAAO,IAAI,CAAC,EAAE,MAAM,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC;AAAA,EAAM,IAAI,OAAO,IAAI,OAAO,EAAE,EAAE,KAAK,IAAI;AAAA,IAC5F;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -22,23 +22,23 @@ if (Number.isNaN(nodeMajor) || nodeMajor < MIN_NODE_MAJOR) {
|
|
|
22
22
|
process.exit(1);
|
|
23
23
|
}
|
|
24
24
|
if (process.argv.length === 3 && process.argv[2] === "status-line") {
|
|
25
|
-
const { statusLineMain } = await import("./status-line-
|
|
25
|
+
const { statusLineMain } = await import("./status-line-XOUE6MPL.js");
|
|
26
26
|
await statusLineMain();
|
|
27
27
|
process.exit(0);
|
|
28
28
|
}
|
|
29
29
|
if (process.argv.length === 4 && process.argv[2] === "hook" && process.argv[3] === "alive") {
|
|
30
30
|
const [{ aliveMain }, { dataDir: dataDir2 }, { default: pkg }] = await Promise.all([
|
|
31
|
-
import("./alive-
|
|
31
|
+
import("./alive-J64H46HI.js"),
|
|
32
32
|
import("./paths-POPTXJO6.js"),
|
|
33
|
-
import("./package-
|
|
33
|
+
import("./package-ZKQFDWLE.js")
|
|
34
34
|
]);
|
|
35
35
|
await aliveMain({ dataDir: dataDir2(process.env), version: pkg.version });
|
|
36
36
|
process.exit(0);
|
|
37
37
|
}
|
|
38
38
|
var { useEnvProxy } = await import("./env-proxy-XL4P73MZ.js");
|
|
39
39
|
useEnvProxy(process.env);
|
|
40
|
-
var { main } = await import("./cli-
|
|
41
|
-
var { enableCliIdentity } = await import("./install-identity-
|
|
40
|
+
var { main } = await import("./cli-D5OE3URZ.js");
|
|
41
|
+
var { enableCliIdentity } = await import("./install-identity-K7EJIQFP.js");
|
|
42
42
|
var { dataDir } = await import("./paths-POPTXJO6.js");
|
|
43
43
|
enableCliIdentity(dataDir(process.env));
|
|
44
44
|
process.exit(await main(process.argv.slice(2)));
|
|
@@ -1,44 +1,57 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
AFTER_CALL_TIMEOUT_SECONDS,
|
|
4
3
|
DISCLOSURE,
|
|
5
4
|
FUND_COMMAND,
|
|
6
5
|
FUND_QUESTION,
|
|
7
6
|
NEW_SESSION_STEP,
|
|
8
7
|
RELOAD_STEP,
|
|
9
|
-
ROUTE_HOOK_TIMEOUT_SECONDS,
|
|
10
8
|
SHOW_NOT_RUN,
|
|
9
|
+
approveLimits,
|
|
10
|
+
effectiveLimits,
|
|
11
11
|
loadStep,
|
|
12
12
|
migrateSettingsInstall,
|
|
13
|
+
namedLimits,
|
|
13
14
|
pluginProof,
|
|
14
15
|
projectInstallAt,
|
|
15
16
|
projectInstallHere,
|
|
16
17
|
runRouterInstall,
|
|
17
|
-
settingsInstallPaths
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
settingsInstallPaths,
|
|
19
|
+
spendStepFor
|
|
20
|
+
} from "./chunk-77TCKDEC.js";
|
|
21
|
+
import "./chunk-UKY4CHNC.js";
|
|
22
|
+
import "./chunk-KXVP2VKA.js";
|
|
23
|
+
import {
|
|
24
|
+
AFTER_CALL_TIMEOUT_SECONDS,
|
|
25
|
+
ROUTE_HOOK_TIMEOUT_SECONDS
|
|
26
|
+
} from "./chunk-GA7JETVM.js";
|
|
20
27
|
import "./chunk-KOGZDMHO.js";
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-QXP3Z3JN.js";
|
|
29
|
+
import "./chunk-5MARFNSB.js";
|
|
30
|
+
import "./chunk-3623BLPV.js";
|
|
23
31
|
import "./chunk-A36LQPHV.js";
|
|
24
|
-
import "./chunk-
|
|
32
|
+
import "./chunk-QSCPK4F5.js";
|
|
25
33
|
import "./chunk-AKWGE6JQ.js";
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-
|
|
34
|
+
import "./chunk-WJXLQXJY.js";
|
|
35
|
+
import "./chunk-XKESD27X.js";
|
|
36
|
+
import "./chunk-4ZZO6ULA.js";
|
|
29
37
|
import "./chunk-MEFB5KHA.js";
|
|
30
|
-
import "./chunk-KYFZTGMC.js";
|
|
31
38
|
import "./chunk-2SNUOHAT.js";
|
|
32
|
-
import "./chunk-
|
|
33
|
-
import "./chunk-
|
|
39
|
+
import "./chunk-K72RURN3.js";
|
|
40
|
+
import "./chunk-DOQGNFHM.js";
|
|
41
|
+
import "./chunk-YFPY4ONH.js";
|
|
42
|
+
import "./chunk-I3EQFHCD.js";
|
|
34
43
|
import "./chunk-S4SAZ7OD.js";
|
|
35
|
-
import "./chunk-
|
|
44
|
+
import "./chunk-AGZ7PJKY.js";
|
|
36
45
|
import "./chunk-2I4QTOLB.js";
|
|
37
|
-
import "./chunk-
|
|
38
|
-
import "./chunk-
|
|
39
|
-
import "./chunk-
|
|
46
|
+
import "./chunk-7WU4OPLP.js";
|
|
47
|
+
import "./chunk-Y527D4TV.js";
|
|
48
|
+
import "./chunk-YVFXE7RR.js";
|
|
49
|
+
import "./chunk-XQJXNMSB.js";
|
|
50
|
+
import "./chunk-3UCIG4TG.js";
|
|
51
|
+
import "./chunk-27EPWVOY.js";
|
|
52
|
+
import "./chunk-7WEQQJLG.js";
|
|
40
53
|
import "./chunk-SJLTEINJ.js";
|
|
41
|
-
import "./chunk-
|
|
54
|
+
import "./chunk-5C32RLTA.js";
|
|
42
55
|
import "./chunk-ZXTAQYNA.js";
|
|
43
56
|
export {
|
|
44
57
|
AFTER_CALL_TIMEOUT_SECONDS,
|
|
@@ -49,12 +62,16 @@ export {
|
|
|
49
62
|
RELOAD_STEP,
|
|
50
63
|
ROUTE_HOOK_TIMEOUT_SECONDS,
|
|
51
64
|
SHOW_NOT_RUN,
|
|
65
|
+
approveLimits,
|
|
66
|
+
effectiveLimits,
|
|
52
67
|
loadStep,
|
|
53
68
|
migrateSettingsInstall,
|
|
69
|
+
namedLimits,
|
|
54
70
|
pluginProof,
|
|
55
71
|
projectInstallAt,
|
|
56
72
|
projectInstallHere,
|
|
57
73
|
runRouterInstall,
|
|
58
|
-
settingsInstallPaths
|
|
74
|
+
settingsInstallPaths,
|
|
75
|
+
spendStepFor
|
|
59
76
|
};
|
|
60
|
-
//# sourceMappingURL=install-
|
|
77
|
+
//# sourceMappingURL=install-XWGE4Q7L.js.map
|
|
@@ -6,14 +6,18 @@ import {
|
|
|
6
6
|
noteBaseUrlFlag,
|
|
7
7
|
readOrCreateInstallId,
|
|
8
8
|
tenjinOrigins
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-UQUOVWBG.js";
|
|
10
|
+
import "./chunk-AGZ7PJKY.js";
|
|
11
11
|
import "./chunk-2I4QTOLB.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-7WU4OPLP.js";
|
|
13
|
+
import "./chunk-Y527D4TV.js";
|
|
14
|
+
import "./chunk-YVFXE7RR.js";
|
|
15
|
+
import "./chunk-XQJXNMSB.js";
|
|
16
|
+
import "./chunk-3UCIG4TG.js";
|
|
17
|
+
import "./chunk-27EPWVOY.js";
|
|
18
|
+
import "./chunk-7WEQQJLG.js";
|
|
15
19
|
import "./chunk-SJLTEINJ.js";
|
|
16
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-5C32RLTA.js";
|
|
17
21
|
import "./chunk-ZXTAQYNA.js";
|
|
18
22
|
export {
|
|
19
23
|
enableCliIdentity,
|
|
@@ -23,4 +27,4 @@ export {
|
|
|
23
27
|
readOrCreateInstallId,
|
|
24
28
|
tenjinOrigins
|
|
25
29
|
};
|
|
26
|
-
//# sourceMappingURL=install-identity-
|
|
30
|
+
//# sourceMappingURL=install-identity-K7EJIQFP.js.map
|
|
@@ -1,41 +1,45 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
runWalletCreate
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-V6BSF6OC.js";
|
|
5
|
+
import "./chunk-B7HUUJOK.js";
|
|
6
|
+
import "./chunk-5K5W4S66.js";
|
|
7
|
+
import "./chunk-7Q5FDF65.js";
|
|
5
8
|
import "./chunk-ORWL5BSN.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-VFMQTSXG.js";
|
|
8
|
-
import "./chunk-YHKXNYTB.js";
|
|
9
|
-
import "./chunk-LFZJM56J.js";
|
|
10
|
-
import "./chunk-EL56RW2J.js";
|
|
9
|
+
import "./chunk-BL3332HQ.js";
|
|
11
10
|
import {
|
|
12
11
|
describeWallet,
|
|
13
12
|
resolveWalletProvider,
|
|
14
13
|
walletFileExists
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
} from "./chunk-P7LABKCW.js";
|
|
22
|
-
import "./chunk-PAYV4XUA.js";
|
|
23
|
-
import "./chunk-MEFB5KHA.js";
|
|
24
|
-
import "./chunk-KYFZTGMC.js";
|
|
25
|
-
import "./chunk-2SNUOHAT.js";
|
|
26
|
-
import "./chunk-AWQPGIR6.js";
|
|
27
|
-
import "./chunk-N35E6CM2.js";
|
|
28
|
-
import "./chunk-JRGFKVAZ.js";
|
|
14
|
+
} from "./chunk-2XLC3AEX.js";
|
|
15
|
+
import "./chunk-7ZRL2LBQ.js";
|
|
16
|
+
import "./chunk-WK7F3B2E.js";
|
|
17
|
+
import "./chunk-R5LCN54M.js";
|
|
18
|
+
import "./chunk-NEFNKLBE.js";
|
|
19
|
+
import "./chunk-K3I7C2MO.js";
|
|
29
20
|
import "./chunk-5IEP5EGE.js";
|
|
30
21
|
import "./chunk-EGELTSPU.js";
|
|
22
|
+
import "./chunk-JRGFKVAZ.js";
|
|
23
|
+
import "./chunk-TTNESUPQ.js";
|
|
31
24
|
import "./chunk-KG3D7FIF.js";
|
|
32
25
|
import "./chunk-RBJPAZFI.js";
|
|
33
26
|
import "./chunk-BPMWXTFX.js";
|
|
27
|
+
import "./chunk-4ZZO6ULA.js";
|
|
28
|
+
import "./chunk-MEFB5KHA.js";
|
|
29
|
+
import "./chunk-2SNUOHAT.js";
|
|
30
|
+
import "./chunk-K72RURN3.js";
|
|
31
|
+
import {
|
|
32
|
+
confirmChoice
|
|
33
|
+
} from "./chunk-DOQGNFHM.js";
|
|
34
34
|
import "./chunk-2I4QTOLB.js";
|
|
35
|
+
import "./chunk-Y527D4TV.js";
|
|
36
|
+
import "./chunk-YVFXE7RR.js";
|
|
37
|
+
import "./chunk-XQJXNMSB.js";
|
|
35
38
|
import {
|
|
36
39
|
CliError
|
|
37
|
-
} from "./chunk-
|
|
38
|
-
import "./chunk-
|
|
40
|
+
} from "./chunk-3UCIG4TG.js";
|
|
41
|
+
import "./chunk-27EPWVOY.js";
|
|
42
|
+
import "./chunk-7WEQQJLG.js";
|
|
39
43
|
import "./chunk-SJLTEINJ.js";
|
|
40
44
|
import "./chunk-ZXTAQYNA.js";
|
|
41
45
|
|
|
@@ -110,4 +114,4 @@ export {
|
|
|
110
114
|
resolveWallet,
|
|
111
115
|
walletValue
|
|
112
116
|
};
|
|
113
|
-
//# sourceMappingURL=install-wallet-
|
|
117
|
+
//# sourceMappingURL=install-wallet-XQ6XFZV4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/install-wallet.ts"],"sourcesContent":["import { CliError } from '../lib/errors';\nimport { confirmChoice } from '../lib/clack';\nimport { describeWallet, resolveWalletProvider } from '../lib/wallet';\nimport type { PassphraseOverrides } from '../lib/wallet/local';\nimport { walletFileExists } from '../lib/wallet/store';\nimport { runWalletCreate } from './wallet';\nimport type { CommandContext } from '../context';\n\n/**\n * The wallet step `tenjin install` runs: keep the wallet this machine has, or\n * create one. Shared by the router install and the shelf install so the two\n * can never disagree about when a wallet is made or what a skip tells you.\n */\n\n/** The wallet question's literal copy. */\nexport const WALLET_QUESTION = 'Create a wallet now?';\n\n/** The seams the wallet step reads; every one defaults to the real thing. */\nexport interface WalletDeps {\n env?: NodeJS.ProcessEnv;\n /** \"Create a wallet now?\"; defaults to the clack confirm (default yes). */\n confirmWallet?: (label: string) => Promise<boolean>;\n /** Does a wallet already exist? Defaults to walletFileExists(dataDir). */\n walletExists?: (dataDir: string) => Promise<boolean>;\n /** An existing wallet's address. Defaults to the local provider. */\n walletAddress?: (ctx: CommandContext) => Promise<string>;\n /** Create a wallet and return its address. Defaults to runWalletCreate. */\n createWallet?: (ctx: CommandContext) => Promise<string>;\n /**\n * Passphrase-resolution seam forwarded to `wallet create`. Tests MUST set it\n * (or `createWallet`): without it a headless run creates a real wallet, and\n * on macOS that writes to the developer's own login keychain.\n */\n walletPassphrase?: PassphraseOverrides;\n}\n\n/**\n * Why no wallet was created, when none was.\n *\n * `no-passphrase-store` is the one that matters: this machine has no OS\n * credential store that would hold a generated passphrase, and no\n * `TENJIN_WALLET_PASSPHRASE`. There is no fallback here BY DESIGN. A passphrase\n * written to a plain file beside the keystore it unlocks is not a passphrase, so\n * the run creates nothing and says so loudly with both remedies.\n */\nexport type WalletSkipReason = 'no-passphrase-store' | 'create-failed' | 'dry-run' | 'flag';\n\n/**\n * How the wallet step resolved, so rendering stays separate from prompting.\n *\n * `declined` (an answer) and `skipped` (no answer, with a reason) are kept apart\n * deliberately: an install that could not create a key is a different state from\n * one the operator told not to, and only the first needs a remedy.\n */\nexport interface WalletOutcome {\n status: 'existing' | 'created' | 'declined' | 'skipped';\n address?: string;\n /** Only ever set on `skipped`. */\n reason?: WalletSkipReason;\n /** The exact command that changes this outcome, mirroring the CliError contract. */\n fix?: string;\n /** The underlying failure, for a `create-failed` skip. */\n warning?: string;\n}\n\n/** The remedy for each skip, so no skipped state is ever a dead end. */\nfunction walletFix(reason: WalletSkipReason): string {\n switch (reason) {\n case 'no-passphrase-store':\n return 'No OS credential store is available to hold the wallet passphrase. Set TENJIN_WALLET_PASSPHRASE and re-run `tenjin install`, or run `tenjin wallet create` in a terminal to enter one.';\n case 'create-failed':\n return 'Fix the reported problem, then run `tenjin wallet create`.';\n case 'dry-run':\n case 'flag':\n return 'Create one with `tenjin wallet create`.';\n }\n}\n\nexport function walletValue(w: WalletOutcome): string {\n if (w.status === 'existing') return `${w.address} (existing)`;\n if (w.status === 'created') return `${w.address}, $0 - fund with: tenjin wallet fund`;\n if (w.status === 'skipped') return `none (${w.reason}) - ${w.fix}`;\n return 'none - create with: tenjin wallet create';\n}\n\n/**\n * The wallet decision. A wallet is now created BY DEFAULT on both paths, because\n * the loop this command exists to set up does not close without one: `buy` needs\n * a funded key and publish-on-MISS needs a key to sign the write, so a walletless\n * install is a setup that stops at the first useful thing the agent tries.\n *\n * The headless path is the change. It creates without asking, using the\n * passphrase policy `resolvePassphraseForCreate` already enforces: an explicit\n * `TENJIN_WALLET_PASSPHRASE`, else a strong generated passphrase written to the\n * platform's OS credential store and verified by reading it back. When neither is\n * available it creates NOTHING and reports `skipped: no-passphrase-store` with\n * both remedies. There is deliberately no plain-file fallback: a passphrase\n * sitting next to the keystore it unlocks protects nothing, and an install is\n * never the right place to invent one.\n *\n * A creation failure never fails the install. The skills, hooks and permissions\n * this run just wired are all useful without a wallet, so the failure is reported\n * loudly and the command still succeeds.\n */\nexport async function resolveWallet(\n ctx: CommandContext,\n deps: WalletDeps,\n skipReason: 'dry-run' | 'flag' | undefined,\n canPrompt: boolean,\n): Promise<WalletOutcome> {\n const exists = await (deps.walletExists ?? walletFileExists)(ctx.dataDir);\n if (exists) {\n return {\n status: 'existing',\n address: await (deps.walletAddress ?? existingWalletAddress)(ctx),\n };\n }\n if (skipReason !== undefined) {\n return { status: 'skipped', reason: skipReason, fix: walletFix(skipReason) };\n }\n\n // Interactive keeps the question (default yes); headless has nobody to ask and\n // takes the default rather than treating silence as a no.\n if (canPrompt) {\n const confirm = deps.confirmWallet ?? defaultConfirm;\n if (!(await confirm(WALLET_QUESTION))) return { status: 'declined' };\n }\n\n try {\n const create =\n deps.createWallet ??\n ((c: CommandContext) => defaultCreateWallet(c, deps.walletPassphrase, deps.env));\n return { status: 'created', address: await create(ctx) };\n } catch (err) {\n // The one failure with a real remedy: no env passphrase and no OS store, so\n // resolvePassphraseForCreate refused rather than encrypt with a passphrase\n // that has no durable copy. Anything else is reported as itself.\n const reason: WalletSkipReason = isNoPassphraseError(err)\n ? 'no-passphrase-store'\n : 'create-failed';\n return {\n status: 'skipped',\n reason,\n fix: walletFix(reason),\n ...(reason === 'create-failed'\n ? { warning: `The wallet could not be created: ${errorText(err)}` }\n : {}),\n };\n }\n}\n\n/** Is this the passphrase layer refusing because no durable store could serve? */\nfunction isNoPassphraseError(err: unknown): boolean {\n return (\n err instanceof CliError &&\n err.code === 'USAGE' &&\n err.message.includes('No wallet passphrase is available')\n );\n}\n\nfunction errorText(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\nasync function existingWalletAddress(ctx: CommandContext): Promise<string> {\n return (await describeWallet(resolveWalletProvider(ctx))).address;\n}\n\nasync function defaultCreateWallet(\n ctx: CommandContext,\n passphrase?: PassphraseOverrides,\n env?: NodeJS.ProcessEnv,\n): Promise<string> {\n const result = await runWalletCreate(ctx, {\n ...(passphrase !== undefined ? { passphrase } : {}),\n ...(env !== undefined ? { env } : {}),\n });\n return (result.data as { address: string }).address;\n}\n\n/** The shared confirm, defaulting to YES (setup ergonomics); cancel reads as no. */\nfunction defaultConfirm(label: string): Promise<boolean> {\n return confirmChoice(label, true);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/commands/install-wallet.ts"],"sourcesContent":["import { CliError } from '../lib/errors';\nimport { confirmChoice } from '../lib/clack';\nimport { describeWallet, resolveWalletProvider } from '../lib/wallet';\nimport type { PassphraseOverrides } from '../lib/wallet/local';\nimport { walletFileExists } from '../lib/wallet/store';\nimport { runWalletCreate } from './wallet';\nimport type { CommandContext } from '../context';\n\n/**\n * The wallet step `tenjin install` runs: keep the wallet this machine has, or\n * create one. Shared by the router install and the shelf install so the two\n * can never disagree about when a wallet is made or what a skip tells you.\n */\n\n/** The wallet question's literal copy. */\nexport const WALLET_QUESTION = 'Create a wallet now?';\n\n/** The seams the wallet step reads; every one defaults to the real thing. */\nexport interface WalletDeps {\n env?: NodeJS.ProcessEnv;\n /** \"Create a wallet now?\"; defaults to the clack confirm (default yes). */\n confirmWallet?: (label: string) => Promise<boolean>;\n /** Does a wallet already exist? Defaults to walletFileExists(dataDir). */\n walletExists?: (dataDir: string) => Promise<boolean>;\n /** An existing wallet's address. Defaults to the local provider. */\n walletAddress?: (ctx: CommandContext) => Promise<string>;\n /** Create a wallet and return its address. Defaults to runWalletCreate. */\n createWallet?: (ctx: CommandContext) => Promise<string>;\n /**\n * Passphrase-resolution seam forwarded to `wallet create`. Tests MUST set it\n * (or `createWallet`): without it a headless run creates a real wallet, and\n * on macOS that writes to the developer's own login keychain.\n */\n walletPassphrase?: PassphraseOverrides;\n}\n\n/**\n * Why no wallet was created, when none was.\n *\n * `no-passphrase-store` is the one that matters: this machine has no OS\n * credential store that would hold a generated passphrase, and no\n * `TENJIN_WALLET_PASSPHRASE`. There is no fallback here BY DESIGN. A passphrase\n * written to a plain file beside the keystore it unlocks is not a passphrase, so\n * the run creates nothing and says so loudly with both remedies.\n */\nexport type WalletSkipReason = 'no-passphrase-store' | 'create-failed' | 'dry-run' | 'flag';\n\n/**\n * How the wallet step resolved, so rendering stays separate from prompting.\n *\n * `declined` (an answer) and `skipped` (no answer, with a reason) are kept apart\n * deliberately: an install that could not create a key is a different state from\n * one the operator told not to, and only the first needs a remedy.\n */\nexport interface WalletOutcome {\n status: 'existing' | 'created' | 'declined' | 'skipped';\n address?: string;\n /** Only ever set on `skipped`. */\n reason?: WalletSkipReason;\n /** The exact command that changes this outcome, mirroring the CliError contract. */\n fix?: string;\n /** The underlying failure, for a `create-failed` skip. */\n warning?: string;\n}\n\n/** The remedy for each skip, so no skipped state is ever a dead end. */\nfunction walletFix(reason: WalletSkipReason): string {\n switch (reason) {\n case 'no-passphrase-store':\n return 'No OS credential store is available to hold the wallet passphrase. Set TENJIN_WALLET_PASSPHRASE and re-run `tenjin install`, or run `tenjin wallet create` in a terminal to enter one.';\n case 'create-failed':\n return 'Fix the reported problem, then run `tenjin wallet create`.';\n case 'dry-run':\n case 'flag':\n return 'Create one with `tenjin wallet create`.';\n }\n}\n\nexport function walletValue(w: WalletOutcome): string {\n if (w.status === 'existing') return `${w.address} (existing)`;\n if (w.status === 'created') return `${w.address}, $0 - fund with: tenjin wallet fund`;\n if (w.status === 'skipped') return `none (${w.reason}) - ${w.fix}`;\n return 'none - create with: tenjin wallet create';\n}\n\n/**\n * The wallet decision. A wallet is now created BY DEFAULT on both paths, because\n * the loop this command exists to set up does not close without one: `buy` needs\n * a funded key and publish-on-MISS needs a key to sign the write, so a walletless\n * install is a setup that stops at the first useful thing the agent tries.\n *\n * The headless path is the change. It creates without asking, using the\n * passphrase policy `resolvePassphraseForCreate` already enforces: an explicit\n * `TENJIN_WALLET_PASSPHRASE`, else a strong generated passphrase written to the\n * platform's OS credential store and verified by reading it back. When neither is\n * available it creates NOTHING and reports `skipped: no-passphrase-store` with\n * both remedies. There is deliberately no plain-file fallback: a passphrase\n * sitting next to the keystore it unlocks protects nothing, and an install is\n * never the right place to invent one.\n *\n * A creation failure never fails the install. The skills, hooks and permissions\n * this run just wired are all useful without a wallet, so the failure is reported\n * loudly and the command still succeeds.\n */\nexport async function resolveWallet(\n ctx: CommandContext,\n deps: WalletDeps,\n skipReason: 'dry-run' | 'flag' | undefined,\n canPrompt: boolean,\n): Promise<WalletOutcome> {\n const exists = await (deps.walletExists ?? walletFileExists)(ctx.dataDir);\n if (exists) {\n return {\n status: 'existing',\n address: await (deps.walletAddress ?? existingWalletAddress)(ctx),\n };\n }\n if (skipReason !== undefined) {\n return { status: 'skipped', reason: skipReason, fix: walletFix(skipReason) };\n }\n\n // Interactive keeps the question (default yes); headless has nobody to ask and\n // takes the default rather than treating silence as a no.\n if (canPrompt) {\n const confirm = deps.confirmWallet ?? defaultConfirm;\n if (!(await confirm(WALLET_QUESTION))) return { status: 'declined' };\n }\n\n try {\n const create =\n deps.createWallet ??\n ((c: CommandContext) => defaultCreateWallet(c, deps.walletPassphrase, deps.env));\n return { status: 'created', address: await create(ctx) };\n } catch (err) {\n // The one failure with a real remedy: no env passphrase and no OS store, so\n // resolvePassphraseForCreate refused rather than encrypt with a passphrase\n // that has no durable copy. Anything else is reported as itself.\n const reason: WalletSkipReason = isNoPassphraseError(err)\n ? 'no-passphrase-store'\n : 'create-failed';\n return {\n status: 'skipped',\n reason,\n fix: walletFix(reason),\n ...(reason === 'create-failed'\n ? { warning: `The wallet could not be created: ${errorText(err)}` }\n : {}),\n };\n }\n}\n\n/** Is this the passphrase layer refusing because no durable store could serve? */\nfunction isNoPassphraseError(err: unknown): boolean {\n return (\n err instanceof CliError &&\n err.code === 'USAGE' &&\n err.message.includes('No wallet passphrase is available')\n );\n}\n\nfunction errorText(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\nasync function existingWalletAddress(ctx: CommandContext): Promise<string> {\n return (await describeWallet(resolveWalletProvider(ctx))).address;\n}\n\nasync function defaultCreateWallet(\n ctx: CommandContext,\n passphrase?: PassphraseOverrides,\n env?: NodeJS.ProcessEnv,\n): Promise<string> {\n const result = await runWalletCreate(ctx, {\n ...(passphrase !== undefined ? { passphrase } : {}),\n ...(env !== undefined ? { env } : {}),\n });\n return (result.data as { address: string }).address;\n}\n\n/** The shared confirm, defaulting to YES (setup ergonomics); cancel reads as no. */\nfunction defaultConfirm(label: string): Promise<boolean> {\n return confirmChoice(label, true);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,IAAM,kBAAkB;AAmD/B,SAAS,UAAU,QAAkC;AACnD,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,EACX;AACF;AAEO,SAAS,YAAY,GAA0B;AACpD,MAAI,EAAE,WAAW,WAAY,QAAO,GAAG,EAAE,OAAO;AAChD,MAAI,EAAE,WAAW,UAAW,QAAO,GAAG,EAAE,OAAO;AAC/C,MAAI,EAAE,WAAW,UAAW,QAAO,SAAS,EAAE,MAAM,OAAO,EAAE,GAAG;AAChE,SAAO;AACT;AAqBA,eAAsB,cACpB,KACA,MACA,YACA,WACwB;AACxB,QAAM,SAAS,OAAO,KAAK,gBAAgB,kBAAkB,IAAI,OAAO;AACxE,MAAI,QAAQ;AACV,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,SAAS,OAAO,KAAK,iBAAiB,uBAAuB,GAAG;AAAA,IAClE;AAAA,EACF;AACA,MAAI,eAAe,QAAW;AAC5B,WAAO,EAAE,QAAQ,WAAW,QAAQ,YAAY,KAAK,UAAU,UAAU,EAAE;AAAA,EAC7E;AAIA,MAAI,WAAW;AACb,UAAM,UAAU,KAAK,iBAAiB;AACtC,QAAI,CAAE,MAAM,QAAQ,eAAe,EAAI,QAAO,EAAE,QAAQ,WAAW;AAAA,EACrE;AAEA,MAAI;AACF,UAAM,SACJ,KAAK,iBACJ,CAAC,MAAsB,oBAAoB,GAAG,KAAK,kBAAkB,KAAK,GAAG;AAChF,WAAO,EAAE,QAAQ,WAAW,SAAS,MAAM,OAAO,GAAG,EAAE;AAAA,EACzD,SAAS,KAAK;AAIZ,UAAM,SAA2B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