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.
Files changed (125) hide show
  1. package/README.md +6 -17
  2. package/dist/alive-3J3CHOQP.js +21 -0
  3. package/dist/{chunk-SKQQOEWH.js → chunk-3QJREVMX.js} +5 -7
  4. package/dist/{chunk-SKQQOEWH.js.map → chunk-3QJREVMX.js.map} +1 -1
  5. package/dist/{chunk-BOAI23CX.js → chunk-6KA4HFX5.js} +21 -15
  6. package/dist/chunk-6KA4HFX5.js.map +1 -0
  7. package/dist/chunk-6W5GYG3W.js +128 -0
  8. package/dist/chunk-6W5GYG3W.js.map +1 -0
  9. package/dist/{chunk-4L7KMA7P.js → chunk-7H3RN4WJ.js} +7 -9
  10. package/dist/{chunk-4L7KMA7P.js.map → chunk-7H3RN4WJ.js.map} +1 -1
  11. package/dist/{chunk-O7CUHHYU.js → chunk-7R37M6WV.js} +7 -9
  12. package/dist/{chunk-O7CUHHYU.js.map → chunk-7R37M6WV.js.map} +1 -1
  13. package/dist/{chunk-LAIZ2AQA.js → chunk-A5H3E5QA.js} +2 -2
  14. package/dist/{update-RJDA5ZY3.js → chunk-AO54FM4H.js} +147 -26
  15. package/dist/chunk-AO54FM4H.js.map +1 -0
  16. package/dist/{chunk-VNNXAYJE.js → chunk-BRHREK7E.js} +2 -2
  17. package/dist/{chunk-YQOQ6XEI.js → chunk-DJYAPACT.js} +35 -33
  18. package/dist/chunk-DJYAPACT.js.map +1 -0
  19. package/dist/{chunk-GU4GGKYP.js → chunk-DYSDQE7S.js} +36 -2
  20. package/dist/chunk-DYSDQE7S.js.map +1 -0
  21. package/dist/{chunk-YKM2ZTA2.js → chunk-FQ6DHINU.js} +36 -38
  22. package/dist/{chunk-YKM2ZTA2.js.map → chunk-FQ6DHINU.js.map} +1 -1
  23. package/dist/{chunk-6ZSGER3A.js → chunk-FZTSGQVK.js} +2 -2
  24. package/dist/{chunk-AWKQSKUL.js → chunk-KAMRYUK2.js} +2 -2
  25. package/dist/{chunk-2TYQD22Q.js → chunk-MNTQMZJB.js} +6 -8
  26. package/dist/{chunk-2TYQD22Q.js.map → chunk-MNTQMZJB.js.map} +1 -1
  27. package/dist/{chunk-VIOUZW7Z.js → chunk-QTND6XWJ.js} +159 -35
  28. package/dist/chunk-QTND6XWJ.js.map +1 -0
  29. package/dist/chunk-RLPLYUME.js +115 -0
  30. package/dist/{chunk-HC3QEZKT.js.map → chunk-RLPLYUME.js.map} +1 -1
  31. package/dist/{chunk-5NEHH2E5.js → chunk-UEOWNDQG.js} +8 -10
  32. package/dist/{chunk-5NEHH2E5.js.map → chunk-UEOWNDQG.js.map} +1 -1
  33. package/dist/{chunk-OHZYNZSD.js → chunk-UOW5JXYY.js} +5 -7
  34. package/dist/{chunk-OHZYNZSD.js.map → chunk-UOW5JXYY.js.map} +1 -1
  35. package/dist/chunk-VSUHGRVB.js +1455 -0
  36. package/dist/chunk-VSUHGRVB.js.map +1 -0
  37. package/dist/{chunk-64SE3QC5.js → chunk-W6JX4LYF.js} +12 -4
  38. package/dist/chunk-W6JX4LYF.js.map +1 -0
  39. package/dist/{chunk-5FGO6TYT.js → chunk-XVTD7UWR.js} +3 -5
  40. package/dist/{chunk-5FGO6TYT.js.map → chunk-XVTD7UWR.js.map} +1 -1
  41. package/dist/{chunk-X7I343ZY.js → chunk-YFJJYHVG.js} +2 -2
  42. package/dist/{chunk-XVYATBKD.js → chunk-ZG6ZZLO7.js} +898 -521
  43. package/dist/chunk-ZG6ZZLO7.js.map +1 -0
  44. package/dist/{chunk-DATCR7AU.js → chunk-ZO3X5NPG.js} +4 -6
  45. package/dist/{chunk-DATCR7AU.js.map → chunk-ZO3X5NPG.js.map} +1 -1
  46. package/dist/{chunk-VXIBZ6W5.js → chunk-ZP5PV3JB.js} +3 -3
  47. package/dist/{chunk-G4AM2SOL.js → chunk-ZP7AHN7Z.js} +4 -6
  48. package/dist/{chunk-G4AM2SOL.js.map → chunk-ZP7AHN7Z.js.map} +1 -1
  49. package/dist/{cli-6JNIPZQ6.js → cli-234DNHN6.js} +54 -53
  50. package/dist/{cli-6JNIPZQ6.js.map → cli-234DNHN6.js.map} +1 -1
  51. package/dist/{config-G75YT6NC.js → config-IY2OJCAK.js} +10 -13
  52. package/dist/{doctor-3GMDOW4Y.js → doctor-2UZZF44A.js} +267 -242
  53. package/dist/doctor-2UZZF44A.js.map +1 -0
  54. package/dist/{fund-3IPR5YRJ.js → fund-RZ2QFULK.js} +92 -38
  55. package/dist/{fund-3IPR5YRJ.js.map → fund-RZ2QFULK.js.map} +1 -1
  56. package/dist/hook-command-PZHKS7ES.js +31 -0
  57. package/dist/hosts/claude/.claude-plugin/marketplace.json +19 -0
  58. package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +14 -0
  59. package/dist/hosts/claude/tenjin/.mcp.json +11 -0
  60. package/dist/hosts/claude/tenjin/hooks/hooks.json +206 -0
  61. package/dist/index.js +12 -3
  62. package/dist/index.js.map +1 -1
  63. package/dist/install-O5FJ5EP3.js +48 -0
  64. package/dist/{install-identity-PM4AGFFX.js → install-identity-QM44IQ6Z.js} +7 -8
  65. package/dist/{install-wallet-6756NOB5.js → install-wallet-Z52EDLPB.js} +14 -15
  66. package/dist/{install-wallet-6756NOB5.js.map → install-wallet-Z52EDLPB.js.map} +1 -1
  67. package/dist/{mcp-33FAAZ7F.js → mcp-33HAADDF.js} +80 -67
  68. package/dist/{mcp-33FAAZ7F.js.map → mcp-33HAADDF.js.map} +1 -1
  69. package/dist/package-RT24HTTP.js +37 -0
  70. package/dist/{pay-XOYR4PCH.js → pay-IR2V76FX.js} +16 -17
  71. package/dist/{payments-UTQDBO7H.js → payments-GFV4HU5R.js} +9 -10
  72. package/dist/{payments-UTQDBO7H.js.map → payments-GFV4HU5R.js.map} +1 -1
  73. package/dist/{send-CVGNOQW3.js → send-PI4NUA7I.js} +12 -14
  74. package/dist/{send-CVGNOQW3.js.map → send-PI4NUA7I.js.map} +1 -1
  75. package/dist/{status-NACN4DGX.js → status-ZUHTJK46.js} +6 -7
  76. package/dist/{status-NACN4DGX.js.map → status-ZUHTJK46.js.map} +1 -1
  77. package/dist/{status-line-3IQKGRUH.js → status-line-2G5JPQAE.js} +6 -7
  78. package/dist/{status-line-3IQKGRUH.js.map → status-line-2G5JPQAE.js.map} +1 -1
  79. package/dist/uninstall-THKUH5ZT.js +136 -0
  80. package/dist/uninstall-THKUH5ZT.js.map +1 -0
  81. package/dist/update-NPZDP24E.js +18 -0
  82. package/dist/update-NPZDP24E.js.map +1 -0
  83. package/dist/{wallet-B3FVHNTS.js → wallet-53EFH4M5.js} +11 -12
  84. package/dist/wallet-53EFH4M5.js.map +1 -0
  85. package/docs/agent-permissions.md +27 -17
  86. package/package.json +1 -1
  87. package/dist/chunk-64SE3QC5.js.map +0 -1
  88. package/dist/chunk-BOAI23CX.js.map +0 -1
  89. package/dist/chunk-DSNXKUXI.js +0 -172
  90. package/dist/chunk-DSNXKUXI.js.map +0 -1
  91. package/dist/chunk-GU4GGKYP.js.map +0 -1
  92. package/dist/chunk-H2L33M7F.js +0 -944
  93. package/dist/chunk-H2L33M7F.js.map +0 -1
  94. package/dist/chunk-HC3QEZKT.js +0 -87
  95. package/dist/chunk-JLEF5WHM.js +0 -132
  96. package/dist/chunk-JLEF5WHM.js.map +0 -1
  97. package/dist/chunk-MAQUL5BD.js +0 -99
  98. package/dist/chunk-MAQUL5BD.js.map +0 -1
  99. package/dist/chunk-PY7MQUKP.js +0 -755
  100. package/dist/chunk-PY7MQUKP.js.map +0 -1
  101. package/dist/chunk-TGLKKLQG.js +0 -11
  102. package/dist/chunk-TGLKKLQG.js.map +0 -1
  103. package/dist/chunk-VIOUZW7Z.js.map +0 -1
  104. package/dist/chunk-XVYATBKD.js.map +0 -1
  105. package/dist/chunk-YQOQ6XEI.js.map +0 -1
  106. package/dist/doctor-3GMDOW4Y.js.map +0 -1
  107. package/dist/hook-command-ZXX4FT4N.js +0 -32
  108. package/dist/install-6OROTYHZ.js +0 -72
  109. package/dist/status-line-wiring-QXBOOY2T.js +0 -31
  110. package/dist/uninstall-NYFKSYW4.js +0 -175
  111. package/dist/uninstall-NYFKSYW4.js.map +0 -1
  112. package/dist/update-RJDA5ZY3.js.map +0 -1
  113. /package/dist/{config-G75YT6NC.js.map → alive-3J3CHOQP.js.map} +0 -0
  114. /package/dist/{chunk-LAIZ2AQA.js.map → chunk-A5H3E5QA.js.map} +0 -0
  115. /package/dist/{chunk-VNNXAYJE.js.map → chunk-BRHREK7E.js.map} +0 -0
  116. /package/dist/{chunk-6ZSGER3A.js.map → chunk-FZTSGQVK.js.map} +0 -0
  117. /package/dist/{chunk-AWKQSKUL.js.map → chunk-KAMRYUK2.js.map} +0 -0
  118. /package/dist/{chunk-X7I343ZY.js.map → chunk-YFJJYHVG.js.map} +0 -0
  119. /package/dist/{chunk-VXIBZ6W5.js.map → chunk-ZP5PV3JB.js.map} +0 -0
  120. /package/dist/{hook-command-ZXX4FT4N.js.map → config-IY2OJCAK.js.map} +0 -0
  121. /package/dist/{install-6OROTYHZ.js.map → hook-command-PZHKS7ES.js.map} +0 -0
  122. /package/dist/{install-identity-PM4AGFFX.js.map → install-O5FJ5EP3.js.map} +0 -0
  123. /package/dist/{pay-XOYR4PCH.js.map → install-identity-QM44IQ6Z.js.map} +0 -0
  124. /package/dist/{status-line-wiring-QXBOOY2T.js.map → package-RT24HTTP.js.map} +0 -0
  125. /package/dist/{wallet-B3FVHNTS.js.map → pay-IR2V76FX.js.map} +0 -0
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "tenjin",
3
+ "version": "0.1.0-alpha.28",
4
+ "description": "Tenjin picks the right tool when your agent needs one, and one wallet on this machine pays for every call.",
5
+ "author": {
6
+ "name": "Tenjin",
7
+ "url": "https://tenjin.sh"
8
+ },
9
+ "homepage": "https://tenjin.sh/agents",
10
+ "repository": "https://github.com/BackTrackCo/tenjin-agent",
11
+ "metadata": {
12
+ "tenjin-cli": "0.1.0-alpha.28"
13
+ }
14
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "mcpServers": {
3
+ "router": {
4
+ "command": "tenjin",
5
+ "args": [
6
+ "mcp",
7
+ "--plugin"
8
+ ]
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,206 @@
1
+ {
2
+ "hooks": {
3
+ "SessionStart": [
4
+ {
5
+ "hooks": [
6
+ {
7
+ "type": "command",
8
+ "command": "tenjin hook alive",
9
+ "timeout": 5
10
+ }
11
+ ]
12
+ }
13
+ ],
14
+ "UserPromptSubmit": [
15
+ {
16
+ "hooks": [
17
+ {
18
+ "type": "mcp_tool",
19
+ "server": "plugin:tenjin:router",
20
+ "tool": "hook",
21
+ "input": {
22
+ "kind": "prompt",
23
+ "hook_event_name": "${hook_event_name}",
24
+ "session_id": "${session_id}",
25
+ "transcript_path": "${transcript_path}",
26
+ "cwd": "${cwd}",
27
+ "prompt": "${prompt}"
28
+ },
29
+ "timeout": 5
30
+ }
31
+ ]
32
+ }
33
+ ],
34
+ "PreToolUse": [
35
+ {
36
+ "matcher": "WebSearch|WebFetch",
37
+ "hooks": [
38
+ {
39
+ "type": "mcp_tool",
40
+ "server": "plugin:tenjin:router",
41
+ "tool": "hook",
42
+ "input": {
43
+ "kind": "native",
44
+ "hook_event_name": "${hook_event_name}",
45
+ "session_id": "${session_id}",
46
+ "transcript_path": "${transcript_path}",
47
+ "cwd": "${cwd}",
48
+ "tool_name": "${tool_name}",
49
+ "tool_input": "${tool_input}",
50
+ "tool_use_id": "${tool_use_id}",
51
+ "agent_id": "${agent_id}",
52
+ "agent_type": "${agent_type}"
53
+ },
54
+ "timeout": 5
55
+ }
56
+ ]
57
+ },
58
+ {
59
+ "matcher": "Agent|Task",
60
+ "hooks": [
61
+ {
62
+ "type": "mcp_tool",
63
+ "server": "plugin:tenjin:router",
64
+ "tool": "hook",
65
+ "input": {
66
+ "kind": "agent",
67
+ "hook_event_name": "${hook_event_name}",
68
+ "session_id": "${session_id}",
69
+ "transcript_path": "${transcript_path}",
70
+ "cwd": "${cwd}",
71
+ "tool_name": "${tool_name}",
72
+ "tool_input": "${tool_input}",
73
+ "tool_use_id": "${tool_use_id}",
74
+ "agent_id": "${agent_id}",
75
+ "agent_type": "${agent_type}"
76
+ },
77
+ "timeout": 5
78
+ }
79
+ ]
80
+ },
81
+ {
82
+ "matcher": "AskUserQuestion",
83
+ "hooks": [
84
+ {
85
+ "type": "mcp_tool",
86
+ "server": "plugin:tenjin:router",
87
+ "tool": "hook",
88
+ "input": {
89
+ "kind": "ask",
90
+ "hook_event_name": "${hook_event_name}",
91
+ "session_id": "${session_id}",
92
+ "transcript_path": "${transcript_path}",
93
+ "cwd": "${cwd}",
94
+ "tool_name": "${tool_name}",
95
+ "tool_input": "${tool_input}",
96
+ "tool_use_id": "${tool_use_id}",
97
+ "agent_id": "${agent_id}",
98
+ "agent_type": "${agent_type}"
99
+ },
100
+ "timeout": 5
101
+ }
102
+ ]
103
+ },
104
+ {
105
+ "matcher": "mcp__plugin_tenjin_router__hook",
106
+ "hooks": [
107
+ {
108
+ "type": "command",
109
+ "command": "echo '{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"deny\",\"permissionDecisionReason\":\"Only the Tenjin hooks call this tool. To make a lookup, call mcp__plugin_tenjin_router__request.\"}}'",
110
+ "timeout": 5
111
+ }
112
+ ]
113
+ },
114
+ {
115
+ "matcher": "mcp__plugin_tenjin_router__request",
116
+ "hooks": [
117
+ {
118
+ "type": "command",
119
+ "command": "echo '{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"allow\",\"permissionDecisionReason\":\"Tenjin lookup\"}}'",
120
+ "timeout": 5
121
+ }
122
+ ]
123
+ }
124
+ ],
125
+ "PostToolUse": [
126
+ {
127
+ "matcher": "WebSearch|WebFetch",
128
+ "hooks": [
129
+ {
130
+ "type": "mcp_tool",
131
+ "server": "plugin:tenjin:router",
132
+ "tool": "hook",
133
+ "input": {
134
+ "kind": "shortfall",
135
+ "hook_event_name": "${hook_event_name}",
136
+ "session_id": "${session_id}",
137
+ "transcript_path": "${transcript_path}",
138
+ "cwd": "${cwd}",
139
+ "tool_name": "${tool_name}",
140
+ "tool_input": "${tool_input}",
141
+ "tool_use_id": "${tool_use_id}",
142
+ "agent_id": "${agent_id}",
143
+ "agent_type": "${agent_type}",
144
+ "tool_response": "${tool_response}",
145
+ "error": "${error}",
146
+ "is_interrupt": "${is_interrupt}"
147
+ },
148
+ "timeout": 15
149
+ }
150
+ ]
151
+ },
152
+ {
153
+ "matcher": "AskUserQuestion",
154
+ "hooks": [
155
+ {
156
+ "type": "mcp_tool",
157
+ "server": "plugin:tenjin:router",
158
+ "tool": "hook",
159
+ "input": {
160
+ "kind": "answer",
161
+ "hook_event_name": "${hook_event_name}",
162
+ "session_id": "${session_id}",
163
+ "transcript_path": "${transcript_path}",
164
+ "cwd": "${cwd}",
165
+ "tool_name": "${tool_name}",
166
+ "tool_input": "${tool_input}",
167
+ "tool_use_id": "${tool_use_id}",
168
+ "agent_id": "${agent_id}",
169
+ "agent_type": "${agent_type}",
170
+ "tool_response": "${tool_response}"
171
+ },
172
+ "timeout": 5
173
+ }
174
+ ]
175
+ }
176
+ ],
177
+ "PostToolUseFailure": [
178
+ {
179
+ "matcher": "WebSearch|WebFetch",
180
+ "hooks": [
181
+ {
182
+ "type": "mcp_tool",
183
+ "server": "plugin:tenjin:router",
184
+ "tool": "hook",
185
+ "input": {
186
+ "kind": "shortfall",
187
+ "hook_event_name": "${hook_event_name}",
188
+ "session_id": "${session_id}",
189
+ "transcript_path": "${transcript_path}",
190
+ "cwd": "${cwd}",
191
+ "tool_name": "${tool_name}",
192
+ "tool_input": "${tool_input}",
193
+ "tool_use_id": "${tool_use_id}",
194
+ "agent_id": "${agent_id}",
195
+ "agent_type": "${agent_type}",
196
+ "tool_response": "${tool_response}",
197
+ "error": "${error}",
198
+ "is_interrupt": "${is_interrupt}"
199
+ },
200
+ "timeout": 15
201
+ }
202
+ ]
203
+ }
204
+ ]
205
+ }
206
+ }
package/dist/index.js CHANGED
@@ -22,14 +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-3IQKGRUH.js");
25
+ const { statusLineMain } = await import("./status-line-2G5JPQAE.js");
26
26
  await statusLineMain();
27
27
  process.exit(0);
28
28
  }
29
+ if (process.argv.length === 4 && process.argv[2] === "hook" && process.argv[3] === "alive") {
30
+ const [{ aliveMain }, { dataDir: dataDir2 }, { default: pkg }] = await Promise.all([
31
+ import("./alive-3J3CHOQP.js"),
32
+ import("./paths-MUXHUOCM.js"),
33
+ import("./package-RT24HTTP.js")
34
+ ]);
35
+ await aliveMain({ dataDir: dataDir2(process.env), version: pkg.version });
36
+ process.exit(0);
37
+ }
29
38
  var { useEnvProxy } = await import("./env-proxy-XL4P73MZ.js");
30
39
  useEnvProxy(process.env);
31
- var { main } = await import("./cli-6JNIPZQ6.js");
32
- var { enableCliIdentity } = await import("./install-identity-PM4AGFFX.js");
40
+ var { main } = await import("./cli-234DNHN6.js");
41
+ var { enableCliIdentity } = await import("./install-identity-QM44IQ6Z.js");
33
42
  var { dataDir } = await import("./paths-MUXHUOCM.js");
34
43
  enableCliIdentity(dataDir(process.env));
35
44
  process.exit(await main(process.argv.slice(2)));
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n// Bin entry. The Node version guard runs BEFORE importing anything else — no\n// static imports above it — so an out-of-support runtime gets one JSON error\n// envelope plus a human stderr line instead of a syntax/parse crash from a\n// lazily-loaded module written in newer syntax. Kept in conservative syntax.\nconst MIN_NODE_MAJOR = 22;\n\nconst nodeMajor = Number.parseInt(process.versions.node.split('.')[0] ?? '', 10);\n\nif (Number.isNaN(nodeMajor) || nodeMajor < MIN_NODE_MAJOR) {\n const envelope = {\n schemaVersion: 1,\n command: 'preflight',\n ok: false,\n error: {\n code: 'NODE_UNSUPPORTED',\n message: `Tenjin CLI requires Node ${MIN_NODE_MAJOR} or newer (found ${process.versions.node}).`,\n fix: `Install Node ${MIN_NODE_MAJOR} or newer`,\n },\n };\n process.stdout.write(`${JSON.stringify(envelope, null, 2)}\\n`);\n process.stderr.write(`error: Node ${MIN_NODE_MAJOR}+ required, found ${process.versions.node}\\n`);\n process.exit(1);\n}\n\n// THE STATUS LINE NEVER LOADS THE CLI. Claude Code runs it once a second for as\n// long as a session is open, and commander, zod and the command tree are parse\n// cost it has no use for. Only the bare invocation is diverted; `--help` and\n// every flag fall through to the command tree, which registers it like any verb.\nif (process.argv.length === 3 && process.argv[2] === 'status-line') {\n const { statusLineMain } = await import('./router/status-line');\n await statusLineMain();\n process.exit(0);\n}\n\n// After the status line, which sends no request: every other process from this\n// bin (the CLI, the hooks, `tenjin mcp`) honours HTTPS_PROXY and NO_PROXY.\nconst { useEnvProxy } = await import('./lib/env-proxy');\nuseEnvProxy(process.env);\n\nconst { main } = await import('./cli');\n// Here and not in `main`, so an in-process test of the command tree sends no\n// telemetry and mints no install id; see lib/install-identity.\nconst { enableCliIdentity } = await import('./lib/install-identity');\nconst { dataDir } = await import('./lib/paths');\nenableCliIdentity(dataDir(process.env));\nprocess.exit(await main(process.argv.slice(2)));\n\n// Marks this file a module so top-level await is legal; emits nothing.\nexport {};\n"],"mappings":";;;;AAKA,IAAM,iBAAiB;AAEvB,IAAM,YAAY,OAAO,SAAS,QAAQ,SAAS,KAAK,MAAM,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE;AAE/E,IAAI,OAAO,MAAM,SAAS,KAAK,YAAY,gBAAgB;AACzD,QAAM,WAAW;AAAA,IACf,eAAe;AAAA,IACf,SAAS;AAAA,IACT,IAAI;AAAA,IACJ,OAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS,4BAA4B,cAAc,oBAAoB,QAAQ,SAAS,IAAI;AAAA,MAC5F,KAAK,gBAAgB,cAAc;AAAA,IACrC;AAAA,EACF;AACA,UAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AAAA,CAAI;AAC7D,UAAQ,OAAO,MAAM,eAAe,cAAc,qBAAqB,QAAQ,SAAS,IAAI;AAAA,CAAI;AAChG,UAAQ,KAAK,CAAC;AAChB;AAMA,IAAI,QAAQ,KAAK,WAAW,KAAK,QAAQ,KAAK,CAAC,MAAM,eAAe;AAClE,QAAM,EAAE,eAAe,IAAI,MAAM,OAAO,2BAAsB;AAC9D,QAAM,eAAe;AACrB,UAAQ,KAAK,CAAC;AAChB;AAIA,IAAM,EAAE,YAAY,IAAI,MAAM,OAAO,yBAAiB;AACtD,YAAY,QAAQ,GAAG;AAEvB,IAAM,EAAE,KAAK,IAAI,MAAM,OAAO,mBAAO;AAGrC,IAAM,EAAE,kBAAkB,IAAI,MAAM,OAAO,gCAAwB;AACnE,IAAM,EAAE,QAAQ,IAAI,MAAM,OAAO,qBAAa;AAC9C,kBAAkB,QAAQ,QAAQ,GAAG,CAAC;AACtC,QAAQ,KAAK,MAAM,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n// Bin entry. The Node version guard runs BEFORE importing anything else — no\n// static imports above it — so an out-of-support runtime gets one JSON error\n// envelope plus a human stderr line instead of a syntax/parse crash from a\n// lazily-loaded module written in newer syntax. Kept in conservative syntax.\nconst MIN_NODE_MAJOR = 22;\n\nconst nodeMajor = Number.parseInt(process.versions.node.split('.')[0] ?? '', 10);\n\nif (Number.isNaN(nodeMajor) || nodeMajor < MIN_NODE_MAJOR) {\n const envelope = {\n schemaVersion: 1,\n command: 'preflight',\n ok: false,\n error: {\n code: 'NODE_UNSUPPORTED',\n message: `Tenjin CLI requires Node ${MIN_NODE_MAJOR} or newer (found ${process.versions.node}).`,\n fix: `Install Node ${MIN_NODE_MAJOR} or newer`,\n },\n };\n process.stdout.write(`${JSON.stringify(envelope, null, 2)}\\n`);\n process.stderr.write(`error: Node ${MIN_NODE_MAJOR}+ required, found ${process.versions.node}\\n`);\n process.exit(1);\n}\n\n// THE STATUS LINE NEVER LOADS THE CLI. Claude Code runs it once a second for as\n// long as a session is open, and commander, zod and the command tree are parse\n// cost it has no use for. Only the bare invocation is diverted; `--help` and\n// every flag fall through to the command tree, which registers it like any verb.\nif (process.argv.length === 3 && process.argv[2] === 'status-line') {\n const { statusLineMain } = await import('./router/status-line');\n await statusLineMain();\n process.exit(0);\n}\n\n// THE PLUGIN'S SessionStart LEG NEVER LOADS THE CLI EITHER. It runs before\n// every session starts, writes two small files and prints nothing, so it\n// takes the same shortcut. A flag falls through to the command tree.\nif (process.argv.length === 4 && process.argv[2] === 'hook' && process.argv[3] === 'alive') {\n const [{ aliveMain }, { dataDir }, { default: pkg }] = await Promise.all([\n import('./router/alive'),\n import('./lib/paths'),\n import('../package.json'),\n ]);\n await aliveMain({ dataDir: dataDir(process.env), version: pkg.version });\n process.exit(0);\n}\n\n// After the status line, which sends no request: every other process from this\n// bin (the CLI, the hooks, `tenjin mcp`) honours HTTPS_PROXY and NO_PROXY.\nconst { useEnvProxy } = await import('./lib/env-proxy');\nuseEnvProxy(process.env);\n\nconst { main } = await import('./cli');\n// Here and not in `main`, so an in-process test of the command tree sends no\n// telemetry and mints no install id; see lib/install-identity.\nconst { enableCliIdentity } = await import('./lib/install-identity');\nconst { dataDir } = await import('./lib/paths');\nenableCliIdentity(dataDir(process.env));\nprocess.exit(await main(process.argv.slice(2)));\n\n// Marks this file a module so top-level await is legal; emits nothing.\nexport {};\n"],"mappings":";;;;AAKA,IAAM,iBAAiB;AAEvB,IAAM,YAAY,OAAO,SAAS,QAAQ,SAAS,KAAK,MAAM,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE;AAE/E,IAAI,OAAO,MAAM,SAAS,KA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M,OAAO,qBAAa;AAC9C,kBAAkB,QAAQ,QAAQ,GAAG,CAAC;AACtC,QAAQ,KAAK,MAAM,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC;","names":["dataDir"]}
@@ -0,0 +1,48 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ AFTER_CALL_TIMEOUT_SECONDS,
4
+ DISCLOSURE,
5
+ NEW_SESSION_STEP,
6
+ RELOAD_STEP,
7
+ ROUTE_HOOK_TIMEOUT_SECONDS,
8
+ loadStep,
9
+ migrateSettingsInstall,
10
+ pluginProof,
11
+ runRouterInstall,
12
+ settingsInstallPaths
13
+ } from "./chunk-VSUHGRVB.js";
14
+ import "./chunk-W6JX4LYF.js";
15
+ import "./chunk-ZG6ZZLO7.js";
16
+ import "./chunk-AKWGE6JQ.js";
17
+ import "./chunk-DYSDQE7S.js";
18
+ import "./chunk-A36LQPHV.js";
19
+ import "./chunk-P7LABKCW.js";
20
+ import "./chunk-MEFB5KHA.js";
21
+ import "./chunk-B2L53TMK.js";
22
+ import "./chunk-AO54FM4H.js";
23
+ import "./chunk-7H3RN4WJ.js";
24
+ import "./chunk-XVTD7UWR.js";
25
+ import "./chunk-ZO3X5NPG.js";
26
+ import "./chunk-6W5GYG3W.js";
27
+ import "./chunk-S4SAZ7OD.js";
28
+ import "./chunk-UOW5JXYY.js";
29
+ import "./chunk-2I4QTOLB.js";
30
+ import "./chunk-ZP7AHN7Z.js";
31
+ import "./chunk-FZTSGQVK.js";
32
+ import "./chunk-QTND6XWJ.js";
33
+ import "./chunk-K6AXXYCG.js";
34
+ import "./chunk-RLPLYUME.js";
35
+ import "./chunk-ZXTAQYNA.js";
36
+ export {
37
+ AFTER_CALL_TIMEOUT_SECONDS,
38
+ DISCLOSURE,
39
+ NEW_SESSION_STEP,
40
+ RELOAD_STEP,
41
+ ROUTE_HOOK_TIMEOUT_SECONDS,
42
+ loadStep,
43
+ migrateSettingsInstall,
44
+ pluginProof,
45
+ runRouterInstall,
46
+ settingsInstallPaths
47
+ };
48
+ //# sourceMappingURL=install-O5FJ5EP3.js.map
@@ -6,15 +6,14 @@ import {
6
6
  noteBaseUrlFlag,
7
7
  readOrCreateInstallId,
8
8
  tenjinOrigins
9
- } from "./chunk-SKQQOEWH.js";
10
- import "./chunk-OHZYNZSD.js";
11
- import "./chunk-HC3QEZKT.js";
9
+ } from "./chunk-3QJREVMX.js";
10
+ import "./chunk-UOW5JXYY.js";
12
11
  import "./chunk-2I4QTOLB.js";
13
- import "./chunk-G4AM2SOL.js";
14
- import "./chunk-6ZSGER3A.js";
15
- import "./chunk-VIOUZW7Z.js";
16
- import "./chunk-JLEF5WHM.js";
12
+ import "./chunk-ZP7AHN7Z.js";
13
+ import "./chunk-FZTSGQVK.js";
14
+ import "./chunk-QTND6XWJ.js";
17
15
  import "./chunk-K6AXXYCG.js";
16
+ import "./chunk-RLPLYUME.js";
18
17
  import "./chunk-ZXTAQYNA.js";
19
18
  export {
20
19
  enableCliIdentity,
@@ -24,4 +23,4 @@ export {
24
23
  readOrCreateInstallId,
25
24
  tenjinOrigins
26
25
  };
27
- //# sourceMappingURL=install-identity-PM4AGFFX.js.map
26
+ //# sourceMappingURL=install-identity-QM44IQ6Z.js.map
@@ -1,16 +1,22 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  runWalletCreate
4
- } from "./chunk-2TYQD22Q.js";
4
+ } from "./chunk-MNTQMZJB.js";
5
5
  import "./chunk-PZ5N6BAL.js";
6
- import "./chunk-VNNXAYJE.js";
6
+ import "./chunk-BRHREK7E.js";
7
7
  import {
8
8
  describeWallet,
9
9
  resolveWalletProvider,
10
10
  walletFileExists
11
- } from "./chunk-O7CUHHYU.js";
12
- import "./chunk-VXIBZ6W5.js";
13
- import "./chunk-X7I343ZY.js";
11
+ } from "./chunk-7R37M6WV.js";
12
+ import "./chunk-ZP5PV3JB.js";
13
+ import "./chunk-YFJJYHVG.js";
14
+ import {
15
+ confirmChoice
16
+ } from "./chunk-P7LABKCW.js";
17
+ import "./chunk-MEFB5KHA.js";
18
+ import "./chunk-B2L53TMK.js";
19
+ import "./chunk-XVTD7UWR.js";
14
20
  import "./chunk-AWQPGIR6.js";
15
21
  import "./chunk-N35E6CM2.js";
16
22
  import "./chunk-JRGFKVAZ.js";
@@ -19,18 +25,11 @@ import "./chunk-EGELTSPU.js";
19
25
  import "./chunk-KG3D7FIF.js";
20
26
  import "./chunk-RBJPAZFI.js";
21
27
  import "./chunk-BPMWXTFX.js";
22
- import {
23
- confirmChoice
24
- } from "./chunk-P7LABKCW.js";
25
- import "./chunk-MEFB5KHA.js";
26
- import "./chunk-B2L53TMK.js";
27
- import "./chunk-5FGO6TYT.js";
28
28
  import "./chunk-2I4QTOLB.js";
29
- import "./chunk-6ZSGER3A.js";
30
- import "./chunk-VIOUZW7Z.js";
29
+ import "./chunk-FZTSGQVK.js";
31
30
  import {
32
31
  CliError
33
- } from "./chunk-JLEF5WHM.js";
32
+ } from "./chunk-QTND6XWJ.js";
34
33
  import "./chunk-K6AXXYCG.js";
35
34
  import "./chunk-ZXTAQYNA.js";
36
35
 
@@ -105,4 +104,4 @@ export {
105
104
  resolveWallet,
106
105
  walletValue
107
106
  };
108
- //# sourceMappingURL=install-wallet-6756NOB5.js.map
107
+ //# sourceMappingURL=install-wallet-Z52EDLPB.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,SAA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Q,IAAI,UAAU,OAAO,GAAG;AACxD;AAEA,eAAe,sBAAsB,KAAsC;AACzE,UAAQ,MAAM,eAAe,sBAAsB,GAAG,CAAC,GAAG;AAC5D;AAEA,eAAe,oBACb,KACA,YACA,KACiB;AACjB,QAAM,SAAS,MAAM,gBAAgB,KAAK;AAAA,IACxC,GAAI,eAAe,SAAY,EAAE,WAAW,IAAI,CAAC;AAAA,IACjD,GAAI,QAAQ,SAAY,EAAE,IAAI,IAAI,CAAC;AAAA,EACrC,CAAC;AACD,SAAQ,OAAO,KAA6B;AAC9C;AAGA,SAAS,eAAe,OAAiC;AACvD,SAAO,cAAc,OAAO,IAAI;AAClC;","names":[]}
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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