oneie 3.8.3 → 4.0.1

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 (382) hide show
  1. package/LICENSE +86 -0
  2. package/README.md +63 -952
  3. package/dist/package.json +38 -0
  4. package/dist/src/agent.d.ts +2 -0
  5. package/dist/src/agent.js +888 -0
  6. package/dist/src/args.d.ts +9 -0
  7. package/dist/src/args.js +61 -0
  8. package/dist/src/auth.d.ts +6 -0
  9. package/dist/src/auth.js +122 -0
  10. package/dist/{banner.d.ts → src/banner.d.ts} +0 -1
  11. package/dist/src/banner.js +16 -0
  12. package/dist/src/broadcast.d.ts +6 -0
  13. package/dist/src/broadcast.js +150 -0
  14. package/dist/src/catalog.d.ts +2 -0
  15. package/dist/src/catalog.js +78 -0
  16. package/dist/src/chat.d.ts +2 -0
  17. package/dist/src/chat.js +92 -0
  18. package/dist/src/client.d.ts +5 -0
  19. package/dist/src/client.js +151 -0
  20. package/dist/src/compiler.d.ts +36 -0
  21. package/dist/src/compiler.js +314 -0
  22. package/dist/src/config.d.ts +24 -0
  23. package/dist/src/config.js +70 -0
  24. package/dist/src/connect.d.ts +2 -0
  25. package/dist/src/connect.js +64 -0
  26. package/dist/src/coordinate.d.ts +3 -0
  27. package/dist/src/coordinate.js +58 -0
  28. package/dist/src/create.d.ts +2 -0
  29. package/dist/src/create.js +113 -0
  30. package/dist/src/deploy.d.ts +2 -0
  31. package/dist/src/deploy.js +19 -0
  32. package/dist/src/dev.d.ts +2 -0
  33. package/dist/src/dev.js +75 -0
  34. package/dist/src/device-flow.d.ts +57 -0
  35. package/dist/src/device-flow.js +173 -0
  36. package/dist/src/doctor.d.ts +26 -0
  37. package/dist/src/doctor.js +91 -0
  38. package/dist/src/env.d.ts +3 -0
  39. package/dist/src/env.js +37 -0
  40. package/dist/src/eval.d.ts +2 -0
  41. package/dist/src/eval.js +42 -0
  42. package/dist/src/fn.d.ts +2 -0
  43. package/dist/src/fn.js +73 -0
  44. package/dist/src/group.d.ts +2 -0
  45. package/dist/src/group.js +115 -0
  46. package/dist/src/index.d.ts +2 -0
  47. package/dist/src/index.js +102 -0
  48. package/dist/src/init.d.ts +11 -0
  49. package/dist/src/init.js +121 -0
  50. package/dist/src/lib/agent-env.d.ts +5 -0
  51. package/dist/src/lib/agent-env.js +25 -0
  52. package/dist/src/lib/api-path.d.ts +1 -0
  53. package/dist/src/lib/api-path.js +9 -0
  54. package/dist/src/lib/client.d.ts +16 -0
  55. package/dist/src/lib/client.js +57 -0
  56. package/dist/src/lib/launch-claude.d.ts +5 -0
  57. package/dist/src/lib/launch-claude.js +45 -0
  58. package/dist/src/links.d.ts +5 -0
  59. package/dist/src/links.js +44 -0
  60. package/dist/src/onboard.d.ts +16 -0
  61. package/dist/src/onboard.js +146 -0
  62. package/dist/src/plugin.d.ts +2 -0
  63. package/dist/src/plugin.js +184 -0
  64. package/dist/src/push.d.ts +2 -0
  65. package/dist/src/push.js +114 -0
  66. package/dist/src/render.d.ts +21 -0
  67. package/dist/src/render.js +32 -0
  68. package/dist/src/setup.d.ts +6 -0
  69. package/dist/src/setup.js +126 -0
  70. package/dist/src/ship.d.ts +2 -0
  71. package/dist/src/ship.js +18 -0
  72. package/dist/src/skill-parser.d.ts +14 -0
  73. package/dist/src/skill-parser.js +113 -0
  74. package/dist/src/skill.d.ts +2 -0
  75. package/dist/src/skill.js +377 -0
  76. package/dist/src/slug.d.ts +2 -0
  77. package/dist/src/slug.js +6 -0
  78. package/dist/src/social.d.ts +2 -0
  79. package/dist/src/social.js +87 -0
  80. package/dist/src/staff.d.ts +2 -0
  81. package/dist/src/staff.js +93 -0
  82. package/dist/src/status.d.ts +2 -0
  83. package/dist/src/status.js +46 -0
  84. package/dist/src/substrate.d.ts +2 -0
  85. package/dist/src/substrate.js +243 -0
  86. package/dist/src/templates/_node/site/one.config.d.ts +2 -0
  87. package/dist/src/templates/_node/site/one.config.js +22 -0
  88. package/dist/src/templates.d.ts +1 -0
  89. package/dist/src/templates.js +205 -0
  90. package/dist/src/trade.d.ts +2 -0
  91. package/dist/src/trade.js +95 -0
  92. package/dist/src/trail.d.ts +2 -0
  93. package/dist/src/trail.js +41 -0
  94. package/dist/src/validate.d.ts +13 -0
  95. package/dist/src/validate.js +35 -0
  96. package/dist/src/wallet.d.ts +9 -0
  97. package/dist/src/wallet.js +209 -0
  98. package/package.json +26 -54
  99. package/LICENSE.md +0 -89
  100. package/dist/admin/build.d.ts +0 -15
  101. package/dist/admin/build.d.ts.map +0 -1
  102. package/dist/admin/build.js +0 -295
  103. package/dist/admin/build.js.map +0 -1
  104. package/dist/admin/index.d.ts +0 -24
  105. package/dist/admin/index.d.ts.map +0 -1
  106. package/dist/admin/index.js +0 -98
  107. package/dist/admin/index.js.map +0 -1
  108. package/dist/admin/list.d.ts +0 -14
  109. package/dist/admin/list.d.ts.map +0 -1
  110. package/dist/admin/list.js +0 -90
  111. package/dist/admin/list.js.map +0 -1
  112. package/dist/admin/manifest.d.ts +0 -86
  113. package/dist/admin/manifest.d.ts.map +0 -1
  114. package/dist/admin/manifest.js +0 -183
  115. package/dist/admin/manifest.js.map +0 -1
  116. package/dist/admin/monorepo.d.ts +0 -25
  117. package/dist/admin/monorepo.d.ts.map +0 -1
  118. package/dist/admin/monorepo.js +0 -59
  119. package/dist/admin/monorepo.js.map +0 -1
  120. package/dist/admin/release.d.ts +0 -17
  121. package/dist/admin/release.d.ts.map +0 -1
  122. package/dist/admin/release.js +0 -144
  123. package/dist/admin/release.js.map +0 -1
  124. package/dist/admin/sync.d.ts +0 -14
  125. package/dist/admin/sync.d.ts.map +0 -1
  126. package/dist/admin/sync.js +0 -104
  127. package/dist/admin/sync.js.map +0 -1
  128. package/dist/admin/validate.d.ts +0 -15
  129. package/dist/admin/validate.d.ts.map +0 -1
  130. package/dist/admin/validate.js +0 -169
  131. package/dist/admin/validate.js.map +0 -1
  132. package/dist/banner.d.ts.map +0 -1
  133. package/dist/banner.js +0 -15
  134. package/dist/banner.js.map +0 -1
  135. package/dist/clone-docs.d.ts +0 -17
  136. package/dist/clone-docs.d.ts.map +0 -1
  137. package/dist/clone-docs.js +0 -62
  138. package/dist/clone-docs.js.map +0 -1
  139. package/dist/clone-web.d.ts +0 -12
  140. package/dist/clone-web.d.ts.map +0 -1
  141. package/dist/clone-web.js +0 -50
  142. package/dist/clone-web.js.map +0 -1
  143. package/dist/commands/agent.d.ts +0 -20
  144. package/dist/commands/agent.d.ts.map +0 -1
  145. package/dist/commands/agent.js +0 -315
  146. package/dist/commands/agent.js.map +0 -1
  147. package/dist/commands/ask.d.ts +0 -4
  148. package/dist/commands/ask.d.ts.map +0 -1
  149. package/dist/commands/ask.js +0 -8
  150. package/dist/commands/ask.js.map +0 -1
  151. package/dist/commands/bounty.d.ts +0 -4
  152. package/dist/commands/bounty.d.ts.map +0 -1
  153. package/dist/commands/bounty.js +0 -24
  154. package/dist/commands/bounty.js.map +0 -1
  155. package/dist/commands/buy.d.ts +0 -19
  156. package/dist/commands/buy.d.ts.map +0 -1
  157. package/dist/commands/buy.js +0 -63
  158. package/dist/commands/buy.js.map +0 -1
  159. package/dist/commands/capabilities.d.ts +0 -4
  160. package/dist/commands/capabilities.d.ts.map +0 -1
  161. package/dist/commands/capabilities.js +0 -18
  162. package/dist/commands/capabilities.js.map +0 -1
  163. package/dist/commands/claw.d.ts +0 -4
  164. package/dist/commands/claw.d.ts.map +0 -1
  165. package/dist/commands/claw.js +0 -14
  166. package/dist/commands/claw.js.map +0 -1
  167. package/dist/commands/commend.d.ts +0 -4
  168. package/dist/commands/commend.d.ts.map +0 -1
  169. package/dist/commands/commend.js +0 -13
  170. package/dist/commands/commend.js.map +0 -1
  171. package/dist/commands/completion.d.ts +0 -4
  172. package/dist/commands/completion.d.ts.map +0 -1
  173. package/dist/commands/completion.js +0 -49
  174. package/dist/commands/completion.js.map +0 -1
  175. package/dist/commands/config.d.ts +0 -4
  176. package/dist/commands/config.d.ts.map +0 -1
  177. package/dist/commands/config.js +0 -78
  178. package/dist/commands/config.js.map +0 -1
  179. package/dist/commands/deploy.d.ts +0 -4
  180. package/dist/commands/deploy.d.ts.map +0 -1
  181. package/dist/commands/deploy.js +0 -45
  182. package/dist/commands/deploy.js.map +0 -1
  183. package/dist/commands/doctor.d.ts +0 -4
  184. package/dist/commands/doctor.d.ts.map +0 -1
  185. package/dist/commands/doctor.js +0 -72
  186. package/dist/commands/doctor.js.map +0 -1
  187. package/dist/commands/domain.d.ts +0 -4
  188. package/dist/commands/domain.d.ts.map +0 -1
  189. package/dist/commands/domain.js +0 -19
  190. package/dist/commands/domain.js.map +0 -1
  191. package/dist/commands/export.d.ts +0 -4
  192. package/dist/commands/export.d.ts.map +0 -1
  193. package/dist/commands/export.js +0 -15
  194. package/dist/commands/export.js.map +0 -1
  195. package/dist/commands/fade.d.ts +0 -4
  196. package/dist/commands/fade.d.ts.map +0 -1
  197. package/dist/commands/fade.js +0 -15
  198. package/dist/commands/fade.js.map +0 -1
  199. package/dist/commands/flag.d.ts +0 -4
  200. package/dist/commands/flag.d.ts.map +0 -1
  201. package/dist/commands/flag.js +0 -13
  202. package/dist/commands/flag.js.map +0 -1
  203. package/dist/commands/forget.d.ts +0 -4
  204. package/dist/commands/forget.d.ts.map +0 -1
  205. package/dist/commands/forget.js +0 -16
  206. package/dist/commands/forget.js.map +0 -1
  207. package/dist/commands/frontier.d.ts +0 -4
  208. package/dist/commands/frontier.d.ts.map +0 -1
  209. package/dist/commands/frontier.js +0 -11
  210. package/dist/commands/frontier.js.map +0 -1
  211. package/dist/commands/group.d.ts +0 -3
  212. package/dist/commands/group.d.ts.map +0 -1
  213. package/dist/commands/group.js +0 -123
  214. package/dist/commands/group.js.map +0 -1
  215. package/dist/commands/health.d.ts +0 -4
  216. package/dist/commands/health.d.ts.map +0 -1
  217. package/dist/commands/health.js +0 -11
  218. package/dist/commands/health.js.map +0 -1
  219. package/dist/commands/highways.d.ts +0 -4
  220. package/dist/commands/highways.d.ts.map +0 -1
  221. package/dist/commands/highways.js +0 -14
  222. package/dist/commands/highways.js.map +0 -1
  223. package/dist/commands/hire.d.ts +0 -4
  224. package/dist/commands/hire.d.ts.map +0 -1
  225. package/dist/commands/hire.js +0 -16
  226. package/dist/commands/hire.js.map +0 -1
  227. package/dist/commands/init.d.ts +0 -17
  228. package/dist/commands/init.d.ts.map +0 -1
  229. package/dist/commands/init.js +0 -308
  230. package/dist/commands/init.js.map +0 -1
  231. package/dist/commands/invite.d.ts +0 -4
  232. package/dist/commands/invite.d.ts.map +0 -1
  233. package/dist/commands/invite.js +0 -37
  234. package/dist/commands/invite.js.map +0 -1
  235. package/dist/commands/know.d.ts +0 -4
  236. package/dist/commands/know.d.ts.map +0 -1
  237. package/dist/commands/know.js +0 -8
  238. package/dist/commands/know.js.map +0 -1
  239. package/dist/commands/launch.d.ts +0 -4
  240. package/dist/commands/launch.d.ts.map +0 -1
  241. package/dist/commands/launch.js +0 -16
  242. package/dist/commands/launch.js.map +0 -1
  243. package/dist/commands/mark.d.ts +0 -4
  244. package/dist/commands/mark.d.ts.map +0 -1
  245. package/dist/commands/mark.js +0 -15
  246. package/dist/commands/mark.js.map +0 -1
  247. package/dist/commands/pay.d.ts +0 -4
  248. package/dist/commands/pay.d.ts.map +0 -1
  249. package/dist/commands/pay.js +0 -21
  250. package/dist/commands/pay.js.map +0 -1
  251. package/dist/commands/pipe.d.ts +0 -4
  252. package/dist/commands/pipe.d.ts.map +0 -1
  253. package/dist/commands/pipe.js +0 -35
  254. package/dist/commands/pipe.js.map +0 -1
  255. package/dist/commands/publish.d.ts +0 -4
  256. package/dist/commands/publish.d.ts.map +0 -1
  257. package/dist/commands/publish.js +0 -23
  258. package/dist/commands/publish.js.map +0 -1
  259. package/dist/commands/recall.d.ts +0 -4
  260. package/dist/commands/recall.d.ts.map +0 -1
  261. package/dist/commands/recall.js +0 -12
  262. package/dist/commands/recall.js.map +0 -1
  263. package/dist/commands/repl.d.ts +0 -4
  264. package/dist/commands/repl.d.ts.map +0 -1
  265. package/dist/commands/repl.js +0 -56
  266. package/dist/commands/repl.js.map +0 -1
  267. package/dist/commands/reveal.d.ts +0 -4
  268. package/dist/commands/reveal.d.ts.map +0 -1
  269. package/dist/commands/reveal.js +0 -11
  270. package/dist/commands/reveal.js.map +0 -1
  271. package/dist/commands/revenue.d.ts +0 -4
  272. package/dist/commands/revenue.d.ts.map +0 -1
  273. package/dist/commands/revenue.js +0 -11
  274. package/dist/commands/revenue.js.map +0 -1
  275. package/dist/commands/select.d.ts +0 -4
  276. package/dist/commands/select.d.ts.map +0 -1
  277. package/dist/commands/select.js +0 -19
  278. package/dist/commands/select.js.map +0 -1
  279. package/dist/commands/sell.d.ts +0 -15
  280. package/dist/commands/sell.d.ts.map +0 -1
  281. package/dist/commands/sell.js +0 -49
  282. package/dist/commands/sell.js.map +0 -1
  283. package/dist/commands/signal.d.ts +0 -4
  284. package/dist/commands/signal.d.ts.map +0 -1
  285. package/dist/commands/signal.js +0 -8
  286. package/dist/commands/signal.js.map +0 -1
  287. package/dist/commands/stats.d.ts +0 -4
  288. package/dist/commands/stats.d.ts.map +0 -1
  289. package/dist/commands/stats.js +0 -11
  290. package/dist/commands/stats.js.map +0 -1
  291. package/dist/commands/status.d.ts +0 -4
  292. package/dist/commands/status.d.ts.map +0 -1
  293. package/dist/commands/status.js +0 -18
  294. package/dist/commands/status.js.map +0 -1
  295. package/dist/commands/subscribe.d.ts +0 -14
  296. package/dist/commands/subscribe.d.ts.map +0 -1
  297. package/dist/commands/subscribe.js +0 -33
  298. package/dist/commands/subscribe.js.map +0 -1
  299. package/dist/commands/sync.d.ts +0 -4
  300. package/dist/commands/sync.d.ts.map +0 -1
  301. package/dist/commands/sync.js +0 -20
  302. package/dist/commands/sync.js.map +0 -1
  303. package/dist/commands/tail.d.ts +0 -4
  304. package/dist/commands/tail.d.ts.map +0 -1
  305. package/dist/commands/tail.js +0 -51
  306. package/dist/commands/tail.js.map +0 -1
  307. package/dist/commands/warn.d.ts +0 -4
  308. package/dist/commands/warn.d.ts.map +0 -1
  309. package/dist/commands/warn.js +0 -15
  310. package/dist/commands/warn.js.map +0 -1
  311. package/dist/copy-claude-config.d.ts +0 -2
  312. package/dist/copy-claude-config.d.ts.map +0 -1
  313. package/dist/copy-claude-config.js +0 -32
  314. package/dist/copy-claude-config.js.map +0 -1
  315. package/dist/create-org-profile.d.ts +0 -10
  316. package/dist/create-org-profile.d.ts.map +0 -1
  317. package/dist/create-org-profile.js +0 -136
  318. package/dist/create-org-profile.js.map +0 -1
  319. package/dist/create-user-profile.d.ts +0 -9
  320. package/dist/create-user-profile.d.ts.map +0 -1
  321. package/dist/create-user-profile.js +0 -115
  322. package/dist/create-user-profile.js.map +0 -1
  323. package/dist/index.d.ts +0 -3
  324. package/dist/index.d.ts.map +0 -1
  325. package/dist/index.js +0 -375
  326. package/dist/index.js.map +0 -1
  327. package/dist/lib/agent-detection.d.ts +0 -19
  328. package/dist/lib/agent-detection.d.ts.map +0 -1
  329. package/dist/lib/agent-detection.js +0 -87
  330. package/dist/lib/agent-detection.js.map +0 -1
  331. package/dist/lib/args.d.ts +0 -11
  332. package/dist/lib/args.d.ts.map +0 -1
  333. package/dist/lib/args.js +0 -57
  334. package/dist/lib/args.js.map +0 -1
  335. package/dist/lib/config.d.ts +0 -12
  336. package/dist/lib/config.d.ts.map +0 -1
  337. package/dist/lib/config.js +0 -38
  338. package/dist/lib/config.js.map +0 -1
  339. package/dist/lib/detect.d.ts +0 -45
  340. package/dist/lib/detect.d.ts.map +0 -1
  341. package/dist/lib/detect.js +0 -221
  342. package/dist/lib/detect.js.map +0 -1
  343. package/dist/lib/http.d.ts +0 -9
  344. package/dist/lib/http.d.ts.map +0 -1
  345. package/dist/lib/http.js +0 -25
  346. package/dist/lib/http.js.map +0 -1
  347. package/dist/lib/output.d.ts +0 -5
  348. package/dist/lib/output.d.ts.map +0 -1
  349. package/dist/lib/output.js +0 -32
  350. package/dist/lib/output.js.map +0 -1
  351. package/dist/lib/sdk.d.ts +0 -10
  352. package/dist/lib/sdk.d.ts.map +0 -1
  353. package/dist/lib/sdk.js +0 -22
  354. package/dist/lib/sdk.js.map +0 -1
  355. package/dist/lib/telemetry.d.ts +0 -4
  356. package/dist/lib/telemetry.d.ts.map +0 -1
  357. package/dist/lib/telemetry.js +0 -61
  358. package/dist/lib/telemetry.js.map +0 -1
  359. package/dist/sync-agents.d.ts +0 -5
  360. package/dist/sync-agents.d.ts.map +0 -1
  361. package/dist/sync-agents.js +0 -28
  362. package/dist/sync-agents.js.map +0 -1
  363. package/dist/sync-ontology.d.ts +0 -4
  364. package/dist/sync-ontology.d.ts.map +0 -1
  365. package/dist/sync-ontology.js +0 -40
  366. package/dist/sync-ontology.js.map +0 -1
  367. package/dist/utils/file-resolver.d.ts +0 -83
  368. package/dist/utils/file-resolver.d.ts.map +0 -1
  369. package/dist/utils/file-resolver.js +0 -194
  370. package/dist/utils/file-resolver.js.map +0 -1
  371. package/dist/utils/installation-setup.d.ts +0 -88
  372. package/dist/utils/installation-setup.d.ts.map +0 -1
  373. package/dist/utils/installation-setup.js +0 -409
  374. package/dist/utils/installation-setup.js.map +0 -1
  375. package/dist/utils/launch-claude.d.ts +0 -7
  376. package/dist/utils/launch-claude.d.ts.map +0 -1
  377. package/dist/utils/launch-claude.js +0 -86
  378. package/dist/utils/launch-claude.js.map +0 -1
  379. package/dist/utils/validation.d.ts +0 -48
  380. package/dist/utils/validation.d.ts.map +0 -1
  381. package/dist/utils/validation.js +0 -73
  382. package/dist/utils/validation.js.map +0 -1
@@ -0,0 +1,205 @@
1
+ export const TEMPLATES = {
2
+ core: `---
3
+ agentmd: "0.1"
4
+ name: template
5
+ title: Template Agent
6
+ model: anthropic/claude-haiku-4-5
7
+ summary: A helpful agent.
8
+ description: Use when you need to accomplish tasks.
9
+ sensitivity: public
10
+ lifecycle: active
11
+ ---
12
+
13
+ You are a helpful assistant. Complete tasks clearly and concisely.
14
+ `,
15
+ commerce: `---
16
+ agentmd: "0.1"
17
+ name: template
18
+ title: Template Commerce Agent
19
+ model: anthropic/claude-haiku-4-5
20
+ summary: An agent that provides paid services.
21
+ description: Use when you need paid skill execution with x402 payments.
22
+ sensitivity: public
23
+ lifecycle: active
24
+ skills: []
25
+ wallet: ""
26
+ accepts:
27
+ - scheme: exact
28
+ network: "eip155:8453"
29
+ asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
30
+ max: "0.05"
31
+ ---
32
+
33
+ You provide services at a fee. Verify payment before executing paid skills.
34
+ `,
35
+ asi: `---
36
+ agentmd: "0.1"
37
+ name: template
38
+ title: Template ASI Agent
39
+ model: anthropic/claude-opus-4-7
40
+ summary: An autonomous agent registered on Fetch.ai Almanac.
41
+ description: Use for long-running autonomous tasks and multi-agent coordination.
42
+ sensitivity: restricted
43
+ lifecycle: active
44
+ mailbox: true
45
+ agentverse: https://agentverse.ai
46
+ intervals:
47
+ - period: 300
48
+ task: Check for new signals and coordinate with peer agents.
49
+ skills: []
50
+ ---
51
+
52
+ You are an autonomous agent. Coordinate with peers, monitor signals, and act on intervals.
53
+ `,
54
+ 'travel-planner': `---
55
+ agentmd: "0.1"
56
+ name: template
57
+ title: Travel Planner
58
+ model: anthropic/claude-sonnet-4-5
59
+ summary: Creates detailed travel itineraries with real logistics and budgets.
60
+ description: Use when you need personalised travel planning — itinerary, budget, packing.
61
+ sensitivity: public
62
+ lifecycle: active
63
+ tools:
64
+ - emit_card
65
+ - emit_chips
66
+ skills:
67
+ - name: plan
68
+ description: Research and create a day-by-day travel itinerary
69
+ price: 0.10
70
+ tags: [travel, planning, itinerary]
71
+ - name: budget
72
+ description: Estimate trip costs including flights, hotels, meals, activities
73
+ price: 0.05
74
+ tags: [travel, budget, finance]
75
+ ---
76
+
77
+ You are a personal travel planner. You turn destinations and dates into detailed, actionable itineraries — real places, real logistics, real costs.
78
+
79
+ Ask first: where, when, how long, who's going, budget range. Then deliver a day-by-day plan with morning/afternoon/evening blocks, transport options, and booking notes.
80
+ `,
81
+ 'marketing-strategist': `---
82
+ agentmd: "0.1"
83
+ name: template
84
+ title: Marketing Strategist
85
+ model: anthropic/claude-sonnet-4-5
86
+ summary: Audits channels, plans campaigns, writes copy, and reads metrics.
87
+ description: Use when you need strategic marketing thinking plus concrete deliverables.
88
+ sensitivity: public
89
+ lifecycle: active
90
+ tools:
91
+ - emit_card
92
+ - emit_chips
93
+ skills:
94
+ - name: audit
95
+ description: Audit existing marketing channels and surface quick wins
96
+ price: 0.08
97
+ tags: [marketing, audit, analysis]
98
+ - name: campaign
99
+ description: Plan a campaign from brief to launch checklist
100
+ price: 0.12
101
+ tags: [marketing, campaign, strategy]
102
+ - name: copy
103
+ description: Write headlines, CTAs, email subjects, ad copy variants
104
+ price: 0.06
105
+ tags: [marketing, copy, writing]
106
+ ---
107
+
108
+ You are a senior marketing strategist. You think in funnels and ICPs, then translate that into concrete copy and launch plans any team can execute.
109
+
110
+ Start by understanding the product, the customer, and the current state of marketing. Then: audit → recommend → plan → execute.
111
+ `,
112
+ 'support-tier1': `---
113
+ agentmd: "0.1"
114
+ name: template
115
+ title: Support — Tier 1
116
+ model: anthropic/claude-sonnet-4-5
117
+ summary: Resolves common support issues fast; escalates edge cases with full context.
118
+ description: Use as a first-line support agent for how-to, account, and billing questions.
119
+ sensitivity: public
120
+ lifecycle: active
121
+ tools:
122
+ - emit_card
123
+ - emit_chips
124
+ skills:
125
+ - name: triage
126
+ description: Classify the issue and route to the right resolution path
127
+ price: 0.02
128
+ tags: [support, triage, routing]
129
+ - name: resolve
130
+ description: Walk the user through a step-by-step fix
131
+ price: 0.03
132
+ tags: [support, resolution, troubleshooting]
133
+ - name: escalate
134
+ description: Prepare a structured escalation summary for Tier 2
135
+ price: 0.02
136
+ tags: [support, escalation, handoff]
137
+ ---
138
+
139
+ You are a Tier 1 support agent. Your job is to resolve common issues fast, escalate edge cases with full context, and leave every user feeling heard.
140
+
141
+ 1. Acknowledge — one sentence that shows you understand the problem. 2. Triage — classify: account / billing / bug / how-to / feature request. 3. Resolve — walk through it step by step. 4. Escalate — prepare a clean handoff summary.
142
+ `,
143
+ 'sales-discovery': `---
144
+ agentmd: "0.1"
145
+ name: template
146
+ title: Sales Discovery
147
+ model: anthropic/claude-sonnet-4-5
148
+ summary: Qualifies leads, preps discovery calls, handles objections, and structures proposals.
149
+ description: Use to accelerate the discovery-to-proposal stage of your sales process.
150
+ sensitivity: restricted
151
+ lifecycle: active
152
+ tools:
153
+ - emit_card
154
+ - emit_chips
155
+ skills:
156
+ - name: qualify
157
+ description: Run a BANT qualification check on an inbound lead
158
+ price: 0.04
159
+ tags: [sales, qualification, lead]
160
+ - name: discovery
161
+ description: Deep-dive discovery call questions for a specific ICP
162
+ price: 0.06
163
+ tags: [sales, discovery, questions]
164
+ - name: proposal
165
+ description: Outline a custom proposal structure for a qualified account
166
+ price: 0.08
167
+ tags: [sales, proposal, closing]
168
+ ---
169
+
170
+ You are a sales discovery specialist. You help sales reps qualify faster, ask sharper questions, and turn stalled conversations into momentum.
171
+
172
+ Start with the lead context: industry, size, role, how they came in. Then run the right playbook: qualify → discover → handle objections → propose.
173
+ `,
174
+ 'code-reviewer': `---
175
+ agentmd: "0.1"
176
+ name: template
177
+ title: Code Reviewer
178
+ model: anthropic/claude-sonnet-4-5
179
+ summary: Gives concrete, severity-labelled code review findings with actionable fixes.
180
+ description: Use for code review, security audits, performance checks, and refactor suggestions.
181
+ sensitivity: restricted
182
+ lifecycle: active
183
+ tools:
184
+ - emit_card
185
+ - emit_chips
186
+ skills:
187
+ - name: review
188
+ description: Full code review with severity-labelled findings
189
+ price: 0.08
190
+ tags: [engineering, review, quality]
191
+ - name: security
192
+ description: Security-focused audit for OWASP Top 10 and common patterns
193
+ price: 0.10
194
+ tags: [engineering, security, audit]
195
+ - name: refactor
196
+ description: Propose a concrete refactor with before/after diffs
197
+ price: 0.08
198
+ tags: [engineering, refactor, design]
199
+ ---
200
+
201
+ You are a senior code reviewer. You give concrete, actionable feedback that improves code quality without creating review theatre.
202
+
203
+ Label every finding: BLOCKER / MAJOR / MINOR / NIT. Always include the specific line reference and a concrete fix — not vague advice.
204
+ `,
205
+ };
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function tradeCommands(program: Command): void;
@@ -0,0 +1,95 @@
1
+ import { askPath } from './lib/api-path.js';
2
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
3
+ function apiKey() {
4
+ return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
5
+ }
6
+ function base(opts) {
7
+ return (opts.api ?? DEFAULT_API).replace(/\/$/, '');
8
+ }
9
+ function authHeaders() {
10
+ const h = { 'Content-Type': 'application/json' };
11
+ const k = apiKey();
12
+ if (k)
13
+ h['Authorization'] = `Bearer ${k}`;
14
+ return h;
15
+ }
16
+ async function ask(b, receiver, data) {
17
+ const res = await fetch(askPath(b, receiver), {
18
+ method: 'POST',
19
+ headers: authHeaders(),
20
+ body: JSON.stringify({ data }),
21
+ });
22
+ if (!res.ok) {
23
+ process.stderr.write(`${receiver} → ${res.status}\n`);
24
+ process.exit(1);
25
+ }
26
+ return res.json();
27
+ }
28
+ export function tradeCommands(program) {
29
+ program
30
+ .command('market')
31
+ .description('Discover agents and skills on the market')
32
+ .option('--query <text>', 'Search for agents or skills by keyword')
33
+ .option('--api <url>', 'API base URL', DEFAULT_API)
34
+ .option('--json', 'Output raw JSON')
35
+ .action(async (opts) => {
36
+ const b = base(opts);
37
+ const data = opts.query
38
+ ? await ask(b, 'actors:find', { search: opts.query, type: 'agent' })
39
+ : await ask(b, 'market:list', {});
40
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
41
+ });
42
+ program
43
+ .command('hire <skillId>')
44
+ .description('Hire an agent for a skill (use --dry-run to simulate)')
45
+ .option('--dry-run', 'Simulate — no settlement, no cost')
46
+ .option('--api <url>', 'API base URL', DEFAULT_API)
47
+ .option('--provider <uid>', 'Preferred provider UID')
48
+ .option('--budget <n>', 'Credit budget', '0')
49
+ .action(async (skillId, opts) => {
50
+ const payload = { skillId };
51
+ if (opts.provider)
52
+ payload.provider = opts.provider;
53
+ if (opts.budget)
54
+ payload.budget = Number(opts.budget);
55
+ if (opts.dryRun)
56
+ payload.simulate = true;
57
+ const data = await ask(base(opts), 'market:hire', payload);
58
+ if (opts.dryRun)
59
+ process.stdout.write('[dry-run] market:hire simulated — nothing settled\n');
60
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
61
+ });
62
+ program
63
+ .command('bounty <skillId>')
64
+ .description('Post a bounty for a skill (use --dry-run to simulate)')
65
+ .option('--dry-run', 'Simulate — no settlement, no cost')
66
+ .option('--api <url>', 'API base URL', DEFAULT_API)
67
+ .option('--price <n>', 'Bounty price in credits', '0')
68
+ .action(async (skillId, opts) => {
69
+ const payload = { skillId, price: Number(opts.price) };
70
+ if (opts.dryRun)
71
+ payload.simulate = true;
72
+ const data = await ask(base(opts), 'market:bounty', payload);
73
+ if (opts.dryRun)
74
+ process.stdout.write('[dry-run] market:bounty simulated — nothing settled\n');
75
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
76
+ });
77
+ program
78
+ .command('earn')
79
+ .description('Show credit earned summary (pay:weight)')
80
+ .option('--api <url>', 'API base URL', DEFAULT_API)
81
+ .option('--json', 'Output raw JSON')
82
+ .action(async (opts) => {
83
+ const data = await ask(base(opts), 'pay:weight', {});
84
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
85
+ });
86
+ program
87
+ .command('usage')
88
+ .description('Show credit usage dashboard')
89
+ .option('--api <url>', 'API base URL', DEFAULT_API)
90
+ .option('--json', 'Output raw JSON')
91
+ .action(async (opts) => {
92
+ const data = await ask(base(opts), 'dashboard:usage', {});
93
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
94
+ });
95
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function trailCmd(): Command;
@@ -0,0 +1,41 @@
1
+ import { Command } from 'commander';
2
+ import { authHeaders, jsonMode, resolveBase } from './lib/client.js';
3
+ const DEFAULT_API = resolveBase({}, 'https://one.ie');
4
+ export function trailCmd() {
5
+ const cmd = new Command('trail')
6
+ .description('read trail confidence for a tag combination — ranked next tasks from KV')
7
+ .argument('<tags>', 'comma-separated tags, e.g. fn:engineering,builds,deploy')
8
+ .option('--workspace <ws>', 'workspace slug', 'global')
9
+ .option('--limit <n>', 'max results', '10')
10
+ .option('--api <url>', 'api base url', DEFAULT_API)
11
+ .action(async (tags, opts) => {
12
+ const base = resolveBase(opts, 'https://one.ie');
13
+ const sorted = tags.split(',').map((t) => t.trim()).filter(Boolean).sort().join(',');
14
+ const params = new URLSearchParams({ tags: sorted, workspace: opts.workspace, limit: opts.limit });
15
+ const res = await fetch(`${base}/api/export/trail?${params}`, {
16
+ headers: authHeaders(),
17
+ });
18
+ if (!res.ok) {
19
+ const body = await res.text().catch(() => '');
20
+ process.stderr.write(`trail: ${res.status}\n${body}\n`);
21
+ process.exit(1);
22
+ }
23
+ const data = (await res.json());
24
+ if (jsonMode(cmd)) {
25
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
26
+ return;
27
+ }
28
+ process.stdout.write(`fingerprint: ${data.fingerprint}\n`);
29
+ process.stdout.write(`confidence: ${(data.confidence * 100).toFixed(1)}%\n\n`);
30
+ if (!data.tasks.length) {
31
+ process.stdout.write('no trail data for these tags — run some /do cycles with matching tags\n');
32
+ return;
33
+ }
34
+ for (const t of data.tasks) {
35
+ const pct = (t.confidence * 100).toFixed(0).padStart(3);
36
+ const score = t.score.toFixed(2).padStart(6);
37
+ process.stdout.write(` ${pct}% score=${score} ${t.slug}\n`);
38
+ }
39
+ });
40
+ return cmd;
41
+ }
@@ -0,0 +1,13 @@
1
+ export interface ClientShape {
2
+ slug?: string;
3
+ name?: string;
4
+ markup_pct?: number | null;
5
+ monthly_cap?: number | null;
6
+ credits?: number | null;
7
+ }
8
+ export declare function validateClient(c: ClientShape): string[];
9
+ export declare function frontmatter(md: string): Record<string, string>;
10
+ export declare function validateAgent(md: string): {
11
+ name: string;
12
+ errors: string[];
13
+ };
@@ -0,0 +1,35 @@
1
+ export function validateClient(c) {
2
+ const errs = [];
3
+ if (!c.slug)
4
+ errs.push('client: slug required');
5
+ if (!c.name)
6
+ errs.push('client: name required');
7
+ if (c.markup_pct != null && (c.markup_pct < 0 || c.markup_pct > 100))
8
+ errs.push('client: markup_pct must be 0–100');
9
+ if (c.monthly_cap != null && c.monthly_cap < 0)
10
+ errs.push('client: monthly_cap must be ≥ 0');
11
+ if (c.credits != null && c.credits < 0)
12
+ errs.push('client: credits must be ≥ 0');
13
+ return errs;
14
+ }
15
+ export function frontmatter(md) {
16
+ const m = md.match(/^---\n([\s\S]*?)\n---/);
17
+ if (!m)
18
+ return {};
19
+ const out = {};
20
+ for (const line of m[1].split('\n')) {
21
+ const kv = line.match(/^([A-Za-z_][\w-]*)\s*:\s*(.*)$/);
22
+ if (kv)
23
+ out[kv[1]] = kv[2].trim();
24
+ }
25
+ return out;
26
+ }
27
+ export function validateAgent(md) {
28
+ const fm = frontmatter(md);
29
+ const errors = [];
30
+ if (!fm.name)
31
+ errors.push('agent: frontmatter `name` required');
32
+ if (!fm.description)
33
+ errors.push('agent: frontmatter `description` required');
34
+ return { name: fm.name ?? '', errors };
35
+ }
@@ -0,0 +1,9 @@
1
+ import { Command } from 'commander';
2
+ import { askPath } from './lib/api-path.js';
3
+ export { askPath };
4
+ export declare function faucetOk(results: Array<{
5
+ success: boolean;
6
+ }>): boolean;
7
+ export declare function okWrap(result: Record<string, unknown>): Record<string, unknown>;
8
+ export declare function walletCmd(): Command;
9
+ export declare function writeKeysFile(filePath: string, contents: string, accepted: boolean): void;
@@ -0,0 +1,209 @@
1
+ import { Command } from 'commander';
2
+ import { mergeEnv } from './env.js';
3
+ import { writeFileSync, chmodSync, readFileSync } from 'node:fs';
4
+ import { generateWallet, recoverWallet } from '@oneie/sdk/wallet';
5
+ import { askPath } from './lib/api-path.js';
6
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
7
+ // Re-exported for existing callers/tests — canonical implementation now lives
8
+ // in ./lib/api-path.ts so trade.ts/client.ts/coordinate.ts/catalog.ts can share
9
+ // it instead of each hardcoding /api/ask/<receiver> against DEFAULT_API.
10
+ export { askPath };
11
+ // The ask envelope nests the resolver's return under `result`, not at the top
12
+ // level: { outcome:'result'|'timeout'|'dissolved'|'failure', result, signalId,
13
+ // receiver }. Unwrap it here so callers work with the plain wallet:* shape.
14
+ async function ask(base, key, receiver, data) {
15
+ const res = await fetch(askPath(base, receiver), {
16
+ method: 'POST',
17
+ headers: { 'Content-Type': 'application/json', ...(key ? { Authorization: `Bearer ${key}` } : {}) },
18
+ body: JSON.stringify({ data }),
19
+ });
20
+ if (!res.ok) {
21
+ const body = await res.text().catch(() => '');
22
+ throw new Error(`${receiver} → ${res.status}\n${body}`);
23
+ }
24
+ const envelope = (await res.json());
25
+ if (envelope.outcome && envelope.outcome !== 'result') {
26
+ throw new Error(`${receiver} → ${envelope.outcome}`);
27
+ }
28
+ return envelope.result ?? envelope;
29
+ }
30
+ const DEFAULT_PAY = process.env.ONEIE_PAY_URL ?? 'https://pay.one.ie';
31
+ // pay.one.ie is a separate service from the gateway/one.ie ask surface above —
32
+ // its own protocol envelope, POST <payUrl>/ { protocol, data } → { success, data,
33
+ // error? }. faucet_request is public (no credential), matching the threat model:
34
+ // funding ≠ ownership, anyone can fund any address (wallet-plan.md).
35
+ async function payProtocol(payUrl, protocol, data) {
36
+ const res = await fetch(`${payUrl.replace(/\/$/, '')}/`, {
37
+ method: 'POST',
38
+ headers: { 'Content-Type': 'application/json' },
39
+ body: JSON.stringify({ protocol, data }),
40
+ });
41
+ const body = (await res.json().catch(() => ({})));
42
+ if (!res.ok || !body.success) {
43
+ throw new Error(`${protocol} → ${body.error?.message ?? body.error?.code ?? res.status}`);
44
+ }
45
+ return body.data ?? {};
46
+ }
47
+ function resolveAuth(opts) {
48
+ const env = mergeEnv(process.cwd());
49
+ const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? '';
50
+ return { base: opts.api.replace(/\/$/, ''), key };
51
+ }
52
+ function resolveWorkspace(explicit) {
53
+ const env = mergeEnv(process.cwd());
54
+ const workspace = explicit ?? env.AGENCY_SLUG;
55
+ if (!workspace) {
56
+ process.stderr.write('--workspace required (or set AGENCY_SLUG)\n');
57
+ process.exit(1);
58
+ }
59
+ return workspace;
60
+ }
61
+ // A chain with no auto-fund path (ETH/USDC/BTC) legitimately returns success:false
62
+ // with a manualUrls fallback — that's documented, expected behavior (wallet-plan.md:
63
+ // "SUI/SOL auto-fund; ETH/USDC/BTC return a manual URL"), never a call failure.
64
+ // `ok` here means "the request was answered" (payProtocol already throws on a real
65
+ // failure) — per-chain funded/manual status lives in `results`, read that, not `ok`.
66
+ export function faucetOk(results) {
67
+ return results.length > 0;
68
+ }
69
+ // wallet:get/create/transactions return bare data or { error } — no `ok` field
70
+ // of their own. wallet:send already returns { ok, ... }. Normalize both to the
71
+ // { ok, ... } shape out() expects without ever overwriting a real error/false
72
+ // with a hardcoded ok:true.
73
+ export function okWrap(result) {
74
+ if ('ok' in result)
75
+ return result;
76
+ if ('error' in result)
77
+ return { ok: false, ...result };
78
+ return { ok: true, ...result };
79
+ }
80
+ export function walletCmd() {
81
+ const cmd = new Command('wallet').description('Read balances, provision a wallet row, fund from testnet, send crypto — wallet:* receivers + pay.one.ie');
82
+ cmd.command('get')
83
+ .description('Credits, spend ceiling, wallet rows, live chain balances, delegated wallets')
84
+ .option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
85
+ .option('--actor <id>', 'Actor within the workspace (defaults to workspace)')
86
+ .option('--api <url>', 'API base URL', DEFAULT_API)
87
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
88
+ .action(async (opts) => {
89
+ const { base, key } = resolveAuth(opts);
90
+ const workspace = resolveWorkspace(opts.workspace);
91
+ const result = await ask(base, key, 'wallet:get', { workspace, actor: opts.actor });
92
+ out(cmd, okWrap(result));
93
+ });
94
+ cmd.command('create')
95
+ .description('Provision a wallet row for an actor (idempotent)')
96
+ .option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
97
+ .option('--actor <id>', 'Actor to provision (defaults to workspace)')
98
+ .option('--kind <kind>', 'human | agent', 'human')
99
+ .option('--api <url>', 'API base URL', DEFAULT_API)
100
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
101
+ .action(async (opts) => {
102
+ const { base, key } = resolveAuth(opts);
103
+ const workspace = resolveWorkspace(opts.workspace);
104
+ const result = await ask(base, key, 'wallet:create', { workspace, actor: opts.actor, kind: opts.kind });
105
+ out(cmd, okWrap(result));
106
+ });
107
+ cmd.command('transactions')
108
+ .description('Unified transaction feed across every settlement rail')
109
+ .option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
110
+ .option('--limit <n>', 'Max rows (default 100, max 500)', '100')
111
+ .option('--api <url>', 'API base URL', DEFAULT_API)
112
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
113
+ .action(async (opts) => {
114
+ const { base, key } = resolveAuth(opts);
115
+ const workspace = resolveWorkspace(opts.workspace);
116
+ const result = await ask(base, key, 'wallet:transactions', { workspace, limit: Number(opts.limit) });
117
+ out(cmd, okWrap(result));
118
+ });
119
+ cmd.command('faucet <address>')
120
+ .description('Fund an address from a testnet tap — Sui and Solana auto-fund; ETH/USDC/BTC return a manual faucet URL')
121
+ .requiredOption('--chain <chain>', 'sui | sol | eth | usdc | btc | all')
122
+ .option('--network <network>', 'testnet | devnet (Sui only)')
123
+ .option('--pay-url <url>', 'pay.one.ie base URL', DEFAULT_PAY)
124
+ .action(async (address, opts) => {
125
+ const data = await payProtocol(opts.payUrl, 'faucet_request', { chain: opts.chain, address, network: opts.network });
126
+ const results = (data.results ?? []);
127
+ out(cmd, { ok: faucetOk(results), results, manualFaucets: data.manualFaucets });
128
+ });
129
+ cmd.command('send <to>')
130
+ .description('Send crypto via pay.one.ie payment links, incl. Bitcoin — sign the transfer yourself first, pass the tx hash')
131
+ .requiredOption('--chain <chain>', 'SUI | EVM | SOL | BTC | BASE | ARB | OPT')
132
+ .requiredOption('--amount <n>', 'Amount to send')
133
+ .requiredOption('--payment-tx <hash>', 'The transaction hash from signing & broadcasting client-side — this command never signs')
134
+ .option('--workspace <slug>', 'Source workspace (defaults to AGENCY_SLUG)')
135
+ .option('--unit <unit>', 'usd | token', 'usd')
136
+ .option('--currency <currency>', 'NATIVE | USDC', 'NATIVE')
137
+ .option('--user-address <address>', 'Sender address (defaults to --to)')
138
+ .option('--memo <text>', 'Payment memo')
139
+ .option('--api <url>', 'API base URL', DEFAULT_API)
140
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
141
+ .action(async (to, opts) => {
142
+ const { base, key } = resolveAuth(opts);
143
+ const workspace = resolveWorkspace(opts.workspace);
144
+ const result = await ask(base, key, 'wallet:send', {
145
+ workspace, to, chain: opts.chain, amount: Number(opts.amount), paymentTx: opts.paymentTx,
146
+ unit: opts.unit, currency: opts.currency, userAddress: opts.userAddress, memo: opts.memo,
147
+ });
148
+ out(cmd, okWrap(result));
149
+ });
150
+ cmd.command('keygen')
151
+ .description('Generate or recover a self-hosted wallet locally — 4 chains (Sui/EVM/Sol/BTC), fully offline, never touches the network or a server. Prints once by default; use --out for scripted bulk provisioning')
152
+ .option('--recover', 'Recover from a 24-word BIP-39 mnemonic (ONE_WALLET_MNEMONIC env or stdin) instead of generating a fresh one')
153
+ .option('--out <file>', 'Write the mnemonic + keys to a file at mode 0600 instead of printing once')
154
+ .option('--yes-i-accept-plaintext-file', 'Required with --out — acknowledge that unencrypted key material will be written to disk')
155
+ .action(async (opts) => {
156
+ const wallet = opts.recover ? await recoverWallet(readMnemonic()) : await generateWallet();
157
+ const addresses = Object.fromEntries(wallet.keys.map((k) => [k.chain, k.address]));
158
+ if (opts.out) {
159
+ const contents = JSON.stringify({ mnemonic: wallet.mnemonic, keys: wallet.keys }, null, 2) + '\n';
160
+ writeKeysFile(opts.out, contents, Boolean(opts.yesIAcceptPlaintextFile));
161
+ out(cmd, { ok: true, out: opts.out, chains: wallet.keys.map((k) => k.chain), addresses });
162
+ }
163
+ else {
164
+ out(cmd, { ok: true, mnemonic: wallet.mnemonic, addresses, keys: wallet.keys });
165
+ }
166
+ });
167
+ return cmd;
168
+ }
169
+ // Read the recovery mnemonic for `keygen --recover`: ONE_WALLET_MNEMONIC env first
170
+ // (scriptable), else stdin (fd 0). Never a CLI arg — keeps the phrase out of the
171
+ // process table / shell history.
172
+ function readMnemonic() {
173
+ const fromEnv = process.env.ONE_WALLET_MNEMONIC?.trim();
174
+ if (fromEnv)
175
+ return fromEnv;
176
+ try {
177
+ return readFileSync(0, 'utf8').trim();
178
+ }
179
+ catch {
180
+ throw new Error('--recover needs a mnemonic — set ONE_WALLET_MNEMONIC or pipe the phrase on stdin');
181
+ }
182
+ }
183
+ // Write key material to a plaintext file at mode 0600, and ONLY when the operator
184
+ // explicitly accepted the risk. chmod after write in case umask stripped bits at
185
+ // create time. Exported for the demo gate.
186
+ export function writeKeysFile(filePath, contents, accepted) {
187
+ if (!accepted) {
188
+ throw new Error('refusing to write plaintext key material to disk — pass --yes-i-accept-plaintext-file to override');
189
+ }
190
+ writeFileSync(filePath, contents, { mode: 0o600 });
191
+ chmodSync(filePath, 0o600);
192
+ }
193
+ function out(cmd, data) {
194
+ const isJson = cmd.parent?.opts().json;
195
+ if (isJson) {
196
+ process.stdout.write(JSON.stringify(data) + '\n');
197
+ }
198
+ else if (data.ok) {
199
+ const pairs = Object.entries(data)
200
+ .filter(([k]) => k !== 'ok')
201
+ .map(([k, v]) => `${k}=${JSON.stringify(v)}`)
202
+ .join(' ');
203
+ console.log('✓', pairs);
204
+ }
205
+ else {
206
+ const detail = data.error ?? data.errors ?? data.issues ?? data;
207
+ console.error('✗', typeof detail === 'string' ? detail : JSON.stringify(detail));
208
+ }
209
+ }