oneie 3.8.2 → 4.0.0

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 (373) 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/src/broadcast.d.ts +6 -0
  11. package/dist/src/broadcast.js +150 -0
  12. package/dist/src/catalog.d.ts +2 -0
  13. package/dist/src/catalog.js +78 -0
  14. package/dist/src/chat.d.ts +2 -0
  15. package/dist/src/chat.js +92 -0
  16. package/dist/src/client.d.ts +5 -0
  17. package/dist/src/client.js +151 -0
  18. package/dist/src/compiler.d.ts +36 -0
  19. package/dist/src/compiler.js +314 -0
  20. package/dist/src/config.d.ts +24 -0
  21. package/dist/src/config.js +70 -0
  22. package/dist/src/connect.d.ts +2 -0
  23. package/dist/src/connect.js +64 -0
  24. package/dist/src/coordinate.d.ts +3 -0
  25. package/dist/src/coordinate.js +58 -0
  26. package/dist/src/create.d.ts +2 -0
  27. package/dist/src/create.js +106 -0
  28. package/dist/src/deploy.d.ts +2 -0
  29. package/dist/src/deploy.js +19 -0
  30. package/dist/src/dev.d.ts +2 -0
  31. package/dist/src/dev.js +75 -0
  32. package/dist/src/device-flow.d.ts +57 -0
  33. package/dist/src/device-flow.js +173 -0
  34. package/dist/src/doctor.d.ts +26 -0
  35. package/dist/src/doctor.js +91 -0
  36. package/dist/src/env.d.ts +3 -0
  37. package/dist/src/env.js +37 -0
  38. package/dist/src/eval.d.ts +2 -0
  39. package/dist/src/eval.js +42 -0
  40. package/dist/src/fn.d.ts +2 -0
  41. package/dist/src/fn.js +73 -0
  42. package/dist/src/group.d.ts +2 -0
  43. package/dist/src/group.js +115 -0
  44. package/dist/src/index.d.ts +2 -0
  45. package/dist/src/index.js +101 -0
  46. package/dist/src/init.d.ts +11 -0
  47. package/dist/src/init.js +121 -0
  48. package/dist/src/lib/agent-env.d.ts +5 -0
  49. package/dist/src/lib/agent-env.js +25 -0
  50. package/dist/src/lib/api-path.d.ts +1 -0
  51. package/dist/src/lib/api-path.js +9 -0
  52. package/dist/src/lib/client.d.ts +16 -0
  53. package/dist/src/lib/client.js +57 -0
  54. package/dist/src/links.d.ts +5 -0
  55. package/dist/src/links.js +44 -0
  56. package/dist/src/onboard.d.ts +16 -0
  57. package/dist/src/onboard.js +146 -0
  58. package/dist/src/plugin.d.ts +2 -0
  59. package/dist/src/plugin.js +184 -0
  60. package/dist/src/push.d.ts +2 -0
  61. package/dist/src/push.js +114 -0
  62. package/dist/src/render.d.ts +20 -0
  63. package/dist/src/render.js +32 -0
  64. package/dist/src/setup.d.ts +6 -0
  65. package/dist/src/setup.js +118 -0
  66. package/dist/src/ship.d.ts +2 -0
  67. package/dist/src/ship.js +18 -0
  68. package/dist/src/skill-parser.d.ts +14 -0
  69. package/dist/src/skill-parser.js +113 -0
  70. package/dist/src/skill.d.ts +2 -0
  71. package/dist/src/skill.js +377 -0
  72. package/dist/src/slug.d.ts +2 -0
  73. package/dist/src/slug.js +6 -0
  74. package/dist/src/social.d.ts +2 -0
  75. package/dist/src/social.js +87 -0
  76. package/dist/src/staff.d.ts +2 -0
  77. package/dist/src/staff.js +93 -0
  78. package/dist/src/status.d.ts +2 -0
  79. package/dist/src/status.js +38 -0
  80. package/dist/src/substrate.d.ts +2 -0
  81. package/dist/src/substrate.js +243 -0
  82. package/dist/src/templates.d.ts +1 -0
  83. package/dist/src/templates.js +205 -0
  84. package/dist/src/trade.d.ts +2 -0
  85. package/dist/src/trade.js +95 -0
  86. package/dist/src/trail.d.ts +2 -0
  87. package/dist/src/trail.js +41 -0
  88. package/dist/src/validate.d.ts +13 -0
  89. package/dist/src/validate.js +35 -0
  90. package/dist/src/wallet.d.ts +9 -0
  91. package/dist/src/wallet.js +209 -0
  92. package/package.json +26 -54
  93. package/LICENSE.md +0 -89
  94. package/dist/admin/build.d.ts +0 -15
  95. package/dist/admin/build.d.ts.map +0 -1
  96. package/dist/admin/build.js +0 -295
  97. package/dist/admin/build.js.map +0 -1
  98. package/dist/admin/index.d.ts +0 -24
  99. package/dist/admin/index.d.ts.map +0 -1
  100. package/dist/admin/index.js +0 -98
  101. package/dist/admin/index.js.map +0 -1
  102. package/dist/admin/list.d.ts +0 -14
  103. package/dist/admin/list.d.ts.map +0 -1
  104. package/dist/admin/list.js +0 -90
  105. package/dist/admin/list.js.map +0 -1
  106. package/dist/admin/manifest.d.ts +0 -86
  107. package/dist/admin/manifest.d.ts.map +0 -1
  108. package/dist/admin/manifest.js +0 -183
  109. package/dist/admin/manifest.js.map +0 -1
  110. package/dist/admin/monorepo.d.ts +0 -25
  111. package/dist/admin/monorepo.d.ts.map +0 -1
  112. package/dist/admin/monorepo.js +0 -59
  113. package/dist/admin/monorepo.js.map +0 -1
  114. package/dist/admin/release.d.ts +0 -17
  115. package/dist/admin/release.d.ts.map +0 -1
  116. package/dist/admin/release.js +0 -144
  117. package/dist/admin/release.js.map +0 -1
  118. package/dist/admin/sync.d.ts +0 -14
  119. package/dist/admin/sync.d.ts.map +0 -1
  120. package/dist/admin/sync.js +0 -104
  121. package/dist/admin/sync.js.map +0 -1
  122. package/dist/admin/validate.d.ts +0 -15
  123. package/dist/admin/validate.d.ts.map +0 -1
  124. package/dist/admin/validate.js +0 -169
  125. package/dist/admin/validate.js.map +0 -1
  126. package/dist/banner.d.ts +0 -2
  127. package/dist/banner.d.ts.map +0 -1
  128. package/dist/banner.js +0 -15
  129. package/dist/banner.js.map +0 -1
  130. package/dist/clone-docs.d.ts +0 -17
  131. package/dist/clone-docs.d.ts.map +0 -1
  132. package/dist/clone-docs.js +0 -62
  133. package/dist/clone-docs.js.map +0 -1
  134. package/dist/clone-web.d.ts +0 -12
  135. package/dist/clone-web.d.ts.map +0 -1
  136. package/dist/clone-web.js +0 -50
  137. package/dist/clone-web.js.map +0 -1
  138. package/dist/commands/agent.d.ts +0 -20
  139. package/dist/commands/agent.d.ts.map +0 -1
  140. package/dist/commands/agent.js +0 -315
  141. package/dist/commands/agent.js.map +0 -1
  142. package/dist/commands/ask.d.ts +0 -4
  143. package/dist/commands/ask.d.ts.map +0 -1
  144. package/dist/commands/ask.js +0 -8
  145. package/dist/commands/ask.js.map +0 -1
  146. package/dist/commands/bounty.d.ts +0 -4
  147. package/dist/commands/bounty.d.ts.map +0 -1
  148. package/dist/commands/bounty.js +0 -24
  149. package/dist/commands/bounty.js.map +0 -1
  150. package/dist/commands/buy.d.ts +0 -19
  151. package/dist/commands/buy.d.ts.map +0 -1
  152. package/dist/commands/buy.js +0 -63
  153. package/dist/commands/buy.js.map +0 -1
  154. package/dist/commands/capabilities.d.ts +0 -4
  155. package/dist/commands/capabilities.d.ts.map +0 -1
  156. package/dist/commands/capabilities.js +0 -18
  157. package/dist/commands/capabilities.js.map +0 -1
  158. package/dist/commands/claw.d.ts +0 -4
  159. package/dist/commands/claw.d.ts.map +0 -1
  160. package/dist/commands/claw.js +0 -14
  161. package/dist/commands/claw.js.map +0 -1
  162. package/dist/commands/commend.d.ts +0 -4
  163. package/dist/commands/commend.d.ts.map +0 -1
  164. package/dist/commands/commend.js +0 -13
  165. package/dist/commands/commend.js.map +0 -1
  166. package/dist/commands/completion.d.ts +0 -4
  167. package/dist/commands/completion.d.ts.map +0 -1
  168. package/dist/commands/completion.js +0 -49
  169. package/dist/commands/completion.js.map +0 -1
  170. package/dist/commands/config.d.ts +0 -4
  171. package/dist/commands/config.d.ts.map +0 -1
  172. package/dist/commands/config.js +0 -78
  173. package/dist/commands/config.js.map +0 -1
  174. package/dist/commands/deploy.d.ts +0 -4
  175. package/dist/commands/deploy.d.ts.map +0 -1
  176. package/dist/commands/deploy.js +0 -45
  177. package/dist/commands/deploy.js.map +0 -1
  178. package/dist/commands/doctor.d.ts +0 -4
  179. package/dist/commands/doctor.d.ts.map +0 -1
  180. package/dist/commands/doctor.js +0 -72
  181. package/dist/commands/doctor.js.map +0 -1
  182. package/dist/commands/domain.d.ts +0 -4
  183. package/dist/commands/domain.d.ts.map +0 -1
  184. package/dist/commands/domain.js +0 -19
  185. package/dist/commands/domain.js.map +0 -1
  186. package/dist/commands/export.d.ts +0 -4
  187. package/dist/commands/export.d.ts.map +0 -1
  188. package/dist/commands/export.js +0 -15
  189. package/dist/commands/export.js.map +0 -1
  190. package/dist/commands/fade.d.ts +0 -4
  191. package/dist/commands/fade.d.ts.map +0 -1
  192. package/dist/commands/fade.js +0 -15
  193. package/dist/commands/fade.js.map +0 -1
  194. package/dist/commands/flag.d.ts +0 -4
  195. package/dist/commands/flag.d.ts.map +0 -1
  196. package/dist/commands/flag.js +0 -13
  197. package/dist/commands/flag.js.map +0 -1
  198. package/dist/commands/forget.d.ts +0 -4
  199. package/dist/commands/forget.d.ts.map +0 -1
  200. package/dist/commands/forget.js +0 -16
  201. package/dist/commands/forget.js.map +0 -1
  202. package/dist/commands/frontier.d.ts +0 -4
  203. package/dist/commands/frontier.d.ts.map +0 -1
  204. package/dist/commands/frontier.js +0 -11
  205. package/dist/commands/frontier.js.map +0 -1
  206. package/dist/commands/health.d.ts +0 -4
  207. package/dist/commands/health.d.ts.map +0 -1
  208. package/dist/commands/health.js +0 -11
  209. package/dist/commands/health.js.map +0 -1
  210. package/dist/commands/highways.d.ts +0 -4
  211. package/dist/commands/highways.d.ts.map +0 -1
  212. package/dist/commands/highways.js +0 -14
  213. package/dist/commands/highways.js.map +0 -1
  214. package/dist/commands/hire.d.ts +0 -4
  215. package/dist/commands/hire.d.ts.map +0 -1
  216. package/dist/commands/hire.js +0 -16
  217. package/dist/commands/hire.js.map +0 -1
  218. package/dist/commands/init.d.ts +0 -17
  219. package/dist/commands/init.d.ts.map +0 -1
  220. package/dist/commands/init.js +0 -308
  221. package/dist/commands/init.js.map +0 -1
  222. package/dist/commands/invite.d.ts +0 -4
  223. package/dist/commands/invite.d.ts.map +0 -1
  224. package/dist/commands/invite.js +0 -37
  225. package/dist/commands/invite.js.map +0 -1
  226. package/dist/commands/know.d.ts +0 -4
  227. package/dist/commands/know.d.ts.map +0 -1
  228. package/dist/commands/know.js +0 -8
  229. package/dist/commands/know.js.map +0 -1
  230. package/dist/commands/launch.d.ts +0 -4
  231. package/dist/commands/launch.d.ts.map +0 -1
  232. package/dist/commands/launch.js +0 -16
  233. package/dist/commands/launch.js.map +0 -1
  234. package/dist/commands/mark.d.ts +0 -4
  235. package/dist/commands/mark.d.ts.map +0 -1
  236. package/dist/commands/mark.js +0 -15
  237. package/dist/commands/mark.js.map +0 -1
  238. package/dist/commands/pay.d.ts +0 -4
  239. package/dist/commands/pay.d.ts.map +0 -1
  240. package/dist/commands/pay.js +0 -21
  241. package/dist/commands/pay.js.map +0 -1
  242. package/dist/commands/pipe.d.ts +0 -4
  243. package/dist/commands/pipe.d.ts.map +0 -1
  244. package/dist/commands/pipe.js +0 -35
  245. package/dist/commands/pipe.js.map +0 -1
  246. package/dist/commands/publish.d.ts +0 -4
  247. package/dist/commands/publish.d.ts.map +0 -1
  248. package/dist/commands/publish.js +0 -23
  249. package/dist/commands/publish.js.map +0 -1
  250. package/dist/commands/recall.d.ts +0 -4
  251. package/dist/commands/recall.d.ts.map +0 -1
  252. package/dist/commands/recall.js +0 -12
  253. package/dist/commands/recall.js.map +0 -1
  254. package/dist/commands/repl.d.ts +0 -4
  255. package/dist/commands/repl.d.ts.map +0 -1
  256. package/dist/commands/repl.js +0 -56
  257. package/dist/commands/repl.js.map +0 -1
  258. package/dist/commands/reveal.d.ts +0 -4
  259. package/dist/commands/reveal.d.ts.map +0 -1
  260. package/dist/commands/reveal.js +0 -11
  261. package/dist/commands/reveal.js.map +0 -1
  262. package/dist/commands/revenue.d.ts +0 -4
  263. package/dist/commands/revenue.d.ts.map +0 -1
  264. package/dist/commands/revenue.js +0 -11
  265. package/dist/commands/revenue.js.map +0 -1
  266. package/dist/commands/select.d.ts +0 -4
  267. package/dist/commands/select.d.ts.map +0 -1
  268. package/dist/commands/select.js +0 -19
  269. package/dist/commands/select.js.map +0 -1
  270. package/dist/commands/sell.d.ts +0 -15
  271. package/dist/commands/sell.d.ts.map +0 -1
  272. package/dist/commands/sell.js +0 -49
  273. package/dist/commands/sell.js.map +0 -1
  274. package/dist/commands/signal.d.ts +0 -4
  275. package/dist/commands/signal.d.ts.map +0 -1
  276. package/dist/commands/signal.js +0 -8
  277. package/dist/commands/signal.js.map +0 -1
  278. package/dist/commands/stats.d.ts +0 -4
  279. package/dist/commands/stats.d.ts.map +0 -1
  280. package/dist/commands/stats.js +0 -11
  281. package/dist/commands/stats.js.map +0 -1
  282. package/dist/commands/status.d.ts +0 -4
  283. package/dist/commands/status.d.ts.map +0 -1
  284. package/dist/commands/status.js +0 -18
  285. package/dist/commands/status.js.map +0 -1
  286. package/dist/commands/subscribe.d.ts +0 -14
  287. package/dist/commands/subscribe.d.ts.map +0 -1
  288. package/dist/commands/subscribe.js +0 -33
  289. package/dist/commands/subscribe.js.map +0 -1
  290. package/dist/commands/sync.d.ts +0 -4
  291. package/dist/commands/sync.d.ts.map +0 -1
  292. package/dist/commands/sync.js +0 -20
  293. package/dist/commands/sync.js.map +0 -1
  294. package/dist/commands/tail.d.ts +0 -4
  295. package/dist/commands/tail.d.ts.map +0 -1
  296. package/dist/commands/tail.js +0 -51
  297. package/dist/commands/tail.js.map +0 -1
  298. package/dist/commands/warn.d.ts +0 -4
  299. package/dist/commands/warn.d.ts.map +0 -1
  300. package/dist/commands/warn.js +0 -15
  301. package/dist/commands/warn.js.map +0 -1
  302. package/dist/copy-claude-config.d.ts +0 -2
  303. package/dist/copy-claude-config.d.ts.map +0 -1
  304. package/dist/copy-claude-config.js +0 -32
  305. package/dist/copy-claude-config.js.map +0 -1
  306. package/dist/create-org-profile.d.ts +0 -10
  307. package/dist/create-org-profile.d.ts.map +0 -1
  308. package/dist/create-org-profile.js +0 -136
  309. package/dist/create-org-profile.js.map +0 -1
  310. package/dist/create-user-profile.d.ts +0 -9
  311. package/dist/create-user-profile.d.ts.map +0 -1
  312. package/dist/create-user-profile.js +0 -115
  313. package/dist/create-user-profile.js.map +0 -1
  314. package/dist/index.d.ts +0 -3
  315. package/dist/index.d.ts.map +0 -1
  316. package/dist/index.js +0 -365
  317. package/dist/index.js.map +0 -1
  318. package/dist/lib/agent-detection.d.ts +0 -19
  319. package/dist/lib/agent-detection.d.ts.map +0 -1
  320. package/dist/lib/agent-detection.js +0 -87
  321. package/dist/lib/agent-detection.js.map +0 -1
  322. package/dist/lib/args.d.ts +0 -11
  323. package/dist/lib/args.d.ts.map +0 -1
  324. package/dist/lib/args.js +0 -57
  325. package/dist/lib/args.js.map +0 -1
  326. package/dist/lib/config.d.ts +0 -12
  327. package/dist/lib/config.d.ts.map +0 -1
  328. package/dist/lib/config.js +0 -38
  329. package/dist/lib/config.js.map +0 -1
  330. package/dist/lib/detect.d.ts +0 -45
  331. package/dist/lib/detect.d.ts.map +0 -1
  332. package/dist/lib/detect.js +0 -221
  333. package/dist/lib/detect.js.map +0 -1
  334. package/dist/lib/http.d.ts +0 -9
  335. package/dist/lib/http.d.ts.map +0 -1
  336. package/dist/lib/http.js +0 -25
  337. package/dist/lib/http.js.map +0 -1
  338. package/dist/lib/output.d.ts +0 -5
  339. package/dist/lib/output.d.ts.map +0 -1
  340. package/dist/lib/output.js +0 -32
  341. package/dist/lib/output.js.map +0 -1
  342. package/dist/lib/sdk.d.ts +0 -10
  343. package/dist/lib/sdk.d.ts.map +0 -1
  344. package/dist/lib/sdk.js +0 -22
  345. package/dist/lib/sdk.js.map +0 -1
  346. package/dist/lib/telemetry.d.ts +0 -4
  347. package/dist/lib/telemetry.d.ts.map +0 -1
  348. package/dist/lib/telemetry.js +0 -61
  349. package/dist/lib/telemetry.js.map +0 -1
  350. package/dist/sync-agents.d.ts +0 -5
  351. package/dist/sync-agents.d.ts.map +0 -1
  352. package/dist/sync-agents.js +0 -28
  353. package/dist/sync-agents.js.map +0 -1
  354. package/dist/sync-ontology.d.ts +0 -4
  355. package/dist/sync-ontology.d.ts.map +0 -1
  356. package/dist/sync-ontology.js +0 -40
  357. package/dist/sync-ontology.js.map +0 -1
  358. package/dist/utils/file-resolver.d.ts +0 -83
  359. package/dist/utils/file-resolver.d.ts.map +0 -1
  360. package/dist/utils/file-resolver.js +0 -194
  361. package/dist/utils/file-resolver.js.map +0 -1
  362. package/dist/utils/installation-setup.d.ts +0 -88
  363. package/dist/utils/installation-setup.d.ts.map +0 -1
  364. package/dist/utils/installation-setup.js +0 -409
  365. package/dist/utils/installation-setup.js.map +0 -1
  366. package/dist/utils/launch-claude.d.ts +0 -7
  367. package/dist/utils/launch-claude.d.ts.map +0 -1
  368. package/dist/utils/launch-claude.js +0 -86
  369. package/dist/utils/launch-claude.js.map +0 -1
  370. package/dist/utils/validation.d.ts +0 -48
  371. package/dist/utils/validation.d.ts.map +0 -1
  372. package/dist/utils/validation.js +0 -73
  373. package/dist/utils/validation.js.map +0 -1
@@ -0,0 +1,42 @@
1
+ import { Command } from 'commander';
2
+ import { existsSync } from 'node:fs';
3
+ export function evalCmd() {
4
+ const cmd = new Command('eval')
5
+ .description('Run agent-behavior evals from *.eval.ts files (tool + signal receipts)')
6
+ .argument('[path]', 'File or directory of *.eval.ts', 'evals')
7
+ .option('--channels <url>', 'Channels base URL', process.env.ONEIE_CHANNELS_URL ?? 'https://channels.one.ie')
8
+ .option('--events <url>', 'Events base URL', process.env.ONEIE_BASE_URL ?? 'https://one.ie')
9
+ .action(async (path, opts) => {
10
+ const out = (data) => process.stdout.write(JSON.stringify(data) + '\n');
11
+ if (!existsSync(path)) {
12
+ out({ ok: false, error: `not found: ${path}` });
13
+ return;
14
+ }
15
+ try {
16
+ const { runEvals } = await import('@oneie/evals');
17
+ const results = await runEvals(path, {
18
+ channelsUrl: opts.channels.replace(/\/$/, ''),
19
+ eventsUrl: opts.events.replace(/\/$/, ''),
20
+ groqApiKey: process.env.GROQ_API_KEY,
21
+ });
22
+ const failed = results.filter((r) => r.failed > 0).length;
23
+ out({ ok: failed === 0, total: results.length, passed: results.length - failed, results });
24
+ if (failed > 0)
25
+ process.exitCode = 1;
26
+ }
27
+ catch (err) {
28
+ const msg = err.message;
29
+ // @oneie/evals is a dev/monorepo-only dependency — it is intentionally not bundled in the
30
+ // published CLI (it is an unpublished workspace sibling, and shipping it as a runtime dep
31
+ // broke `npm i -g @oneie/cli`). Degrade with a clear message instead of a cryptic loader error.
32
+ const missing = /Cannot find (module|package)|ERR_MODULE_NOT_FOUND|@oneie\/evals/.test(msg);
33
+ out({
34
+ ok: false,
35
+ error: missing
36
+ ? 'The `eval` command needs the @oneie/evals package, which is not bundled in the published CLI. Run it from the ONE monorepo, or install @oneie/evals alongside the CLI.'
37
+ : msg,
38
+ });
39
+ }
40
+ });
41
+ return cmd;
42
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function fnCmd(): Command;
package/dist/src/fn.js ADDED
@@ -0,0 +1,73 @@
1
+ import { Command } from 'commander';
2
+ import { FN_MAP, FN_MAP_VERSION } from '@oneie/sdk/generated/fn-map';
3
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
4
+ const ALLOWLIST = new Set([
5
+ 'actionable_hypotheses', 'active_frontiers', 'active_objectives',
6
+ 'actor_classification', 'actors_by_kind', 'actors_by_tag', 'actors_for',
7
+ 'attractive_tasks', 'blocked_tasks', 'cheapest_provider', 'exploratory_tasks',
8
+ 'highways', 'optimal_route', 'promising_frontiers', 'suggest_route', 'total_contribution',
9
+ ]);
10
+ function apiKey() {
11
+ return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
12
+ }
13
+ function base(opts) {
14
+ return (opts.api ?? DEFAULT_API).replace(/\/$/, '');
15
+ }
16
+ async function api(url, body) {
17
+ const h = { 'Content-Type': 'application/json' };
18
+ const k = apiKey();
19
+ if (k)
20
+ h['Authorization'] = `Bearer ${k}`;
21
+ const res = await fetch(url, { method: 'POST', headers: h, body: JSON.stringify(body) });
22
+ if (!res.ok) {
23
+ const text = await res.text().catch(() => '');
24
+ process.stderr.write(`fn:run → ${res.status}\n${text}\n`);
25
+ process.exit(1);
26
+ }
27
+ return res.json();
28
+ }
29
+ export function fnCmd() {
30
+ const cmd = new Command('fn').description(`Execute an allowlisted TypeDB function (FN_MAP v${FN_MAP_VERSION})`);
31
+ cmd
32
+ .command('list')
33
+ .description('List all allowlisted functions')
34
+ .action(() => {
35
+ const rows = Array.from(ALLOWLIST).map((name) => {
36
+ const entry = FN_MAP[name];
37
+ const params = entry?.params.map((p) => p.name).join(', ') ?? '';
38
+ return ` ${name.padEnd(28)}${params ? `(${params})` : '()'} → ${entry?.returnKind ?? '?'}`;
39
+ });
40
+ process.stdout.write(`Allowlisted functions (FN_MAP v${FN_MAP_VERSION}):\n${rows.join('\n')}\n`);
41
+ });
42
+ cmd
43
+ .command('run <name>')
44
+ .description('Execute a function by name')
45
+ .option('--args <json>', 'Function arguments as JSON object (keys without $ prefix)')
46
+ .option('--workspace <slug>', 'Workspace slug')
47
+ .option('--api <url>', 'API base URL', DEFAULT_API)
48
+ .action(async (name, opts) => {
49
+ if (!ALLOWLIST.has(name)) {
50
+ process.stderr.write(`error: '${name}' is not in the allowlist. Run 'one fn list' to see available functions.\n`);
51
+ process.exit(1);
52
+ }
53
+ let args = {};
54
+ if (opts.args) {
55
+ try {
56
+ args = JSON.parse(opts.args);
57
+ }
58
+ catch {
59
+ process.stderr.write('error: --args must be valid JSON\n');
60
+ process.exit(1);
61
+ }
62
+ }
63
+ const prefixed = {};
64
+ for (const [k, v] of Object.entries(args)) {
65
+ prefixed[k.startsWith('$') ? k : `$${k}`] = v;
66
+ }
67
+ const result = await api(`${base(opts)}/api/ask/fn%3Arun`, {
68
+ data: { fn: name, args: prefixed, workspace: opts.workspace },
69
+ });
70
+ process.stdout.write(JSON.stringify(result, null, 2) + '\n');
71
+ });
72
+ return cmd;
73
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function groupCmd(): Command;
@@ -0,0 +1,115 @@
1
+ import { Command } from 'commander';
2
+ import { createReadStream, existsSync } from 'node:fs';
3
+ import { createInterface } from 'node:readline';
4
+ import { out, resolveBase, resolveKey } from './lib/client.js';
5
+ const DEFAULT_API = resolveBase({}, 'https://one.ie');
6
+ function readApiKey() {
7
+ const key = resolveKey();
8
+ return key || null;
9
+ }
10
+ async function parseCsv(file) {
11
+ const rows = [];
12
+ const rl = createInterface({ input: createReadStream(file), crlfDelay: Infinity });
13
+ let headers = [];
14
+ let first = true;
15
+ for await (const line of rl) {
16
+ const cells = line.split(',').map((c) => c.trim());
17
+ if (first) {
18
+ headers = cells.map((h) => h.toLowerCase());
19
+ first = false;
20
+ continue;
21
+ }
22
+ if (!cells.length || cells.every((c) => !c))
23
+ continue;
24
+ const row = {};
25
+ headers.forEach((h, i) => { row[h] = cells[i] ?? ''; });
26
+ if (!row.slug && !row.name)
27
+ continue;
28
+ rows.push({ slug: row.slug, name: row.name, contacts: row.contacts || undefined });
29
+ }
30
+ return rows;
31
+ }
32
+ export function groupCmd() {
33
+ const cmd = new Command('group').description('Group management');
34
+ cmd
35
+ .command('bulk-create')
36
+ .description('Bulk-provision Groups from a CSV file (idempotent — skips existing slugs)')
37
+ .requiredOption('--csv <path>', 'CSV file with slug,name[,contacts] columns')
38
+ .option('--segment <segment>', 'ICP segment tag written to each workspace_settings row', 'ICP-1')
39
+ .option('--plan <plan>', 'Billing plan for each group', 'studio')
40
+ .option('--parent <slug>', 'Parent group slug (defaults to authenticated workspace)')
41
+ .option('--batch-size <n>', 'Rows per HTTP batch', '50')
42
+ .option('--api <url>', 'API base URL', DEFAULT_API)
43
+ .option('--dry-run', 'Print plan without writing to D1')
44
+ .action(async (opts) => {
45
+ if (!existsSync(opts.csv)) {
46
+ out(cmd, { ok: false, error: `CSV file not found: ${opts.csv}` });
47
+ return;
48
+ }
49
+ const key = readApiKey();
50
+ if (!key && !opts.dryRun) {
51
+ out(cmd, { ok: false, error: 'no API key — set ONEIE_API_KEY or run: oneie auth login' });
52
+ return;
53
+ }
54
+ const rows = await parseCsv(opts.csv);
55
+ if (rows.length === 0) {
56
+ out(cmd, { ok: false, error: 'CSV contains no valid rows (need slug,name columns)' });
57
+ return;
58
+ }
59
+ const batchSize = parseInt(opts.batchSize, 10);
60
+ const base = opts.api.replace(/\/$/, '');
61
+ const endpoint = `${base}/api/provision/bulk`;
62
+ let totalOwners = 0;
63
+ let totalDuplicates = 0;
64
+ let batchN = 0;
65
+ const batches = [];
66
+ for (let i = 0; i < rows.length; i += batchSize)
67
+ batches.push(rows.slice(i, i + batchSize));
68
+ for (const batch of batches) {
69
+ batchN++;
70
+ if (opts.dryRun) {
71
+ process.stdout.write(`[dry-run] batch ${batchN}/${batches.length} rows=${batch.length}\n`);
72
+ totalOwners += batch.length;
73
+ continue;
74
+ }
75
+ const body = {
76
+ rows: batch.map((r) => ({ slug: r.slug, name: r.name })),
77
+ opts: {
78
+ parentSlug: opts.parent,
79
+ plan: opts.plan,
80
+ segment: opts.segment,
81
+ },
82
+ };
83
+ const res = await fetch(endpoint, {
84
+ method: 'POST',
85
+ headers: {
86
+ 'Content-Type': 'application/json',
87
+ ...(key ? { Authorization: `Bearer ${key}` } : {}),
88
+ },
89
+ body: JSON.stringify(body),
90
+ });
91
+ if (!res.ok) {
92
+ const text = await res.text();
93
+ out(cmd, { ok: false, error: `batch ${batchN} failed (${res.status}): ${text}` });
94
+ return;
95
+ }
96
+ const json = (await res.json());
97
+ const created = json.counts?.owners ?? batch.length;
98
+ const dupes = json.duplicates ?? 0;
99
+ totalOwners += created;
100
+ totalDuplicates += dupes;
101
+ process.stdout.write(`batch ${batchN}/${batches.length} created=${created} skipped=${dupes}\n`);
102
+ }
103
+ out(cmd, {
104
+ ok: true,
105
+ total_rows: rows.length,
106
+ created: totalOwners,
107
+ duplicates: totalDuplicates,
108
+ batches: batchN,
109
+ plan: opts.plan,
110
+ segment: opts.segment,
111
+ dry_run: opts.dryRun ?? false,
112
+ });
113
+ });
114
+ return cmd;
115
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { agentCmd } from './agent.js';
4
+ import { skillCmd } from './skill.js';
5
+ import { authCmd, buildLoginCommand } from './auth.js';
6
+ import { doctorCmd, whoamiCmd } from './doctor.js';
7
+ import { isAgentEnvironment } from './lib/agent-env.js';
8
+ import { devCmd } from './dev.js';
9
+ import { groupCmd } from './group.js';
10
+ import { socialCmd } from './social.js';
11
+ import { connectCmd } from './connect.js';
12
+ import { broadcastCmd, newsletterCmd } from './broadcast.js';
13
+ import { chatCmd } from './chat.js';
14
+ import { linksCmd } from './links.js';
15
+ import { staffCmd } from './staff.js';
16
+ import { substrateCommands } from './substrate.js';
17
+ import { evalCmd } from './eval.js';
18
+ import { setupCmd } from './setup.js';
19
+ import { clientCmd } from './client.js';
20
+ import { walletCmd } from './wallet.js';
21
+ import { pushCmd } from './push.js';
22
+ import { deployCmd } from './deploy.js';
23
+ import { statusCmd } from './status.js';
24
+ import { shipCmd } from './ship.js';
25
+ import { catalogCommands } from './catalog.js';
26
+ import { tradeCommands } from './trade.js';
27
+ import { coordinateCommands } from './coordinate.js';
28
+ import { createCmd } from './create.js';
29
+ import { fnCmd } from './fn.js';
30
+ import { trailCmd } from './trail.js';
31
+ import { initCmd } from './init.js';
32
+ import { onboardCmd } from './onboard.js';
33
+ import { pluginCmd } from './plugin.js';
34
+ import { readFileSync } from 'node:fs';
35
+ import { fileURLToPath } from 'node:url';
36
+ import { resolve, dirname } from 'node:path';
37
+ const __dirname = dirname(fileURLToPath(import.meta.url));
38
+ const pkg = JSON.parse(readFileSync(resolve(__dirname, '../package.json'), 'utf8'));
39
+ const program = new Command()
40
+ .name('oneie')
41
+ .description('ONE — agent CLI')
42
+ .version(pkg.version)
43
+ .option('--json', 'Output structured JSON');
44
+ program.addCommand(agentCmd());
45
+ program.addCommand(skillCmd());
46
+ program.addCommand(authCmd());
47
+ program.addCommand(devCmd());
48
+ program.addCommand(groupCmd());
49
+ program.addCommand(socialCmd());
50
+ program.addCommand(connectCmd());
51
+ program.addCommand(broadcastCmd());
52
+ program.addCommand(chatCmd());
53
+ program.addCommand(newsletterCmd());
54
+ program.addCommand(linksCmd());
55
+ program.addCommand(staffCmd());
56
+ program.addCommand(evalCmd());
57
+ program.addCommand(setupCmd());
58
+ program.addCommand(clientCmd());
59
+ program.addCommand(doctorCmd());
60
+ program.addCommand(whoamiCmd());
61
+ program.addCommand(buildLoginCommand());
62
+ program.addCommand(walletCmd());
63
+ program.addCommand(pushCmd());
64
+ program.addCommand(deployCmd());
65
+ program.addCommand(statusCmd());
66
+ program.addCommand(shipCmd());
67
+ catalogCommands(program);
68
+ tradeCommands(program);
69
+ coordinateCommands(program);
70
+ substrateCommands(program);
71
+ program.addCommand(createCmd());
72
+ program.addCommand(fnCmd());
73
+ program.addCommand(trailCmd());
74
+ program.addCommand(initCmd());
75
+ program.addCommand(onboardCmd());
76
+ program.addCommand(pluginCmd());
77
+ // Bare `oneie` (no args, no --help/--version): route the audience to its
78
+ // journey instead of commander's default help dump. Never an interactive
79
+ // prompt — agent env and human TTY both get a printed block (contract #10).
80
+ if (process.argv.length === 2) {
81
+ if (isAgentEnvironment()) {
82
+ process.stdout.write('oneie — no workspace yet.\n' +
83
+ ' oneie init --write-env # provision a workspace, no account required\n' +
84
+ ' oneie onboard # provision + walk the lifecycle stages\n' +
85
+ ' oneie --help # full command reference\n');
86
+ }
87
+ else {
88
+ process.stdout.write('oneie — ONE, the agent CLI.\n\n' +
89
+ ' npx oneie create <name> # scaffold a new workspace\n' +
90
+ ' oneie --help # full command reference\n');
91
+ }
92
+ process.exit(0);
93
+ }
94
+ program.parseAsync(process.argv).catch((err) => {
95
+ const isJson = process.argv.includes('--json');
96
+ if (isJson)
97
+ process.stdout.write(JSON.stringify({ ok: false, error: err.message }) + '\n');
98
+ else
99
+ process.stderr.write(err.message + '\n');
100
+ process.exit(1);
101
+ });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * oneie init — provision a workspace in one command.
3
+ *
4
+ * Calls POST /api/provision/agent with the provided options, writes the
5
+ * returned scoped key to ~/.config/oneie/key, and prints the workspace URL
6
+ * + invite link.
7
+ *
8
+ * No prior account or API key required. The server mints everything.
9
+ */
10
+ import { Command } from 'commander';
11
+ export declare function initCmd(): Command;
@@ -0,0 +1,121 @@
1
+ /**
2
+ * oneie init — provision a workspace in one command.
3
+ *
4
+ * Calls POST /api/provision/agent with the provided options, writes the
5
+ * returned scoped key to ~/.config/oneie/key, and prints the workspace URL
6
+ * + invite link.
7
+ *
8
+ * No prior account or API key required. The server mints everything.
9
+ */
10
+ import { Command } from 'commander';
11
+ import { writeFileSync, mkdirSync } from 'node:fs';
12
+ import { resolve } from 'node:path';
13
+ import { homedir } from 'node:os';
14
+ import { renameSync, chmodSync } from 'node:fs';
15
+ import { join } from 'node:path';
16
+ import { mergeEnv, writeEnvLocal } from './env.js';
17
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
18
+ const CONFIG_DIR = resolve(homedir(), '.config', 'oneie');
19
+ const KEY_FILE = resolve(CONFIG_DIR, 'key');
20
+ function writeKey(value) {
21
+ mkdirSync(CONFIG_DIR, { recursive: true });
22
+ const tmp = join(CONFIG_DIR, '.key.tmp');
23
+ writeFileSync(tmp, value, { mode: 0o600 });
24
+ chmodSync(tmp, 0o600);
25
+ renameSync(tmp, KEY_FILE);
26
+ }
27
+ function out(cmd, data) {
28
+ const isJson = cmd.parent?.opts().json;
29
+ if (isJson) {
30
+ process.stdout.write(JSON.stringify(data) + '\n');
31
+ }
32
+ else if (data.ok) {
33
+ const lines = Object.entries(data)
34
+ .filter(([k]) => k !== 'ok')
35
+ .map(([k, v]) => ` ${k}: ${v}`)
36
+ .join('\n');
37
+ process.stdout.write(`✓ workspace ready\n${lines}\n`);
38
+ }
39
+ else {
40
+ process.stderr.write(`✗ ${data.error ?? 'failed'}\n`);
41
+ }
42
+ }
43
+ function defaultAgentMd(name) {
44
+ const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
45
+ return `---
46
+ name: ${slug}
47
+ kind: agent
48
+ title: ${name}
49
+ model: claude-sonnet-4-6
50
+ channels: [web, api]
51
+ group: default
52
+ sensitivity: 0.5
53
+ lifecycle: active
54
+ ---
55
+
56
+ You are ${name}. Answer questions clearly and helpfully.
57
+ When you complete a task, summarise what you did in one sentence.
58
+ `;
59
+ }
60
+ export function initCmd() {
61
+ const cmd = new Command('init')
62
+ .description('Provision a new workspace in one command — no account required')
63
+ .option('--name <name>', 'Workspace / agent display name')
64
+ .option('--email <email>', 'Owner email — receives an invite link')
65
+ .option('--skills <refs>', 'Comma-separated skill refs to import (e.g. cold-email,calendar-lookup)')
66
+ .option('--no-content', 'Skip generating a starter agent.md')
67
+ .option('--api <url>', 'API base URL', DEFAULT_API)
68
+ .option('--write-env', 'Also write ONE_API_KEY to .env.local in the current directory')
69
+ .action(async (opts) => {
70
+ const dir = process.cwd();
71
+ if (opts.writeEnv) {
72
+ const env = mergeEnv(dir);
73
+ if (env.ONE_API_KEY) {
74
+ out(cmd, { ok: true, note: 'already connected — .env.local has ONE_API_KEY' });
75
+ return;
76
+ }
77
+ }
78
+ const name = opts.name ?? 'My Agent';
79
+ const skills = opts.skills ? opts.skills.split(',').map(s => s.trim()).filter(Boolean) : [];
80
+ const content = opts.content !== false ? defaultAgentMd(name) : undefined;
81
+ const body = { name, live: true };
82
+ if (content)
83
+ body.content = content;
84
+ if (skills.length)
85
+ body.skills = skills;
86
+ if (opts.email)
87
+ body.invite = { email: opts.email, role: 'owner' };
88
+ let res;
89
+ try {
90
+ res = await fetch(`${opts.api.replace(/\/$/, '')}/api/provision/agent`, {
91
+ method: 'POST',
92
+ headers: { 'Content-Type': 'application/json' },
93
+ body: JSON.stringify(body),
94
+ });
95
+ }
96
+ catch (err) {
97
+ out(cmd, { ok: false, error: `network error: ${err.message}` });
98
+ return;
99
+ }
100
+ const json = await res.json();
101
+ if (!res.ok) {
102
+ out(cmd, { ok: false, ...json });
103
+ return;
104
+ }
105
+ const { workspace, apiKey, inviteUrl } = json;
106
+ writeKey(apiKey);
107
+ if (opts.writeEnv) {
108
+ writeEnvLocal(dir, { ONE_API_KEY: apiKey, ONE_API_URL: opts.api });
109
+ }
110
+ out(cmd, {
111
+ ok: true,
112
+ workspace,
113
+ url: `${opts.api.replace(/\/$/, '')}/u/${workspace}`,
114
+ key: `${KEY_FILE} (0600)`,
115
+ ...(opts.writeEnv ? { env: `${dir}/.env.local`, mcp: 'export ONE_API_KEY before launching Claude Code — MCP reads the shell env, not .env.local directly' } : {}),
116
+ ...(inviteUrl ? { invite: inviteUrl } : {}),
117
+ ...(skills.length ? { skills: skills.join(', ') } : {}),
118
+ });
119
+ });
120
+ return cmd;
121
+ }
@@ -0,0 +1,5 @@
1
+ /** The specific coding agent driving this shell, if env vars name one. */
2
+ export declare function agentType(env?: NodeJS.ProcessEnv): string | undefined;
3
+ /** True when stdout isn't a human's terminal (agent shell, CI, piped) or a
4
+ * known agent env var is set — never used to gate a prompt, only the greeting. */
5
+ export declare function isAgentEnvironment(env?: NodeJS.ProcessEnv, isTTY?: boolean): boolean;
@@ -0,0 +1,25 @@
1
+ // Port of legacy 3.8.3's agent-detection.js — env-var/TTY checks only, zero
2
+ // deps. Lets the bare `oneie` front door route each audience to its journey
3
+ // instead of dumping --help.
4
+ const AGENT_ENV_MARKERS = {
5
+ CLAUDECODE: 'claude-code',
6
+ CLAUDE_CODE: 'claude-code',
7
+ CURSOR_TRACE_ID: 'cursor',
8
+ WINDSURF: 'windsurf',
9
+ GITHUB_COPILOT_CLI: 'copilot',
10
+ };
11
+ /** The specific coding agent driving this shell, if env vars name one. */
12
+ export function agentType(env = process.env) {
13
+ for (const [marker, name] of Object.entries(AGENT_ENV_MARKERS)) {
14
+ if (env[marker])
15
+ return name;
16
+ }
17
+ if (env.CI)
18
+ return 'ci';
19
+ return undefined;
20
+ }
21
+ /** True when stdout isn't a human's terminal (agent shell, CI, piped) or a
22
+ * known agent env var is set — never used to gate a prompt, only the greeting. */
23
+ export function isAgentEnvironment(env = process.env, isTTY = process.stdout.isTTY) {
24
+ return Boolean(agentType(env)) || !isTTY;
25
+ }
@@ -0,0 +1 @@
1
+ export declare function askPath(base: string, receiver: string): string;
@@ -0,0 +1,9 @@
1
+ // The api.one.ie GATEWAY serves substrate ops at the short form (/ask/<receiver>,
2
+ // mapped internally to one-prod's /api/ask/<receiver> — api/src/substrate-binding.ts
3
+ // PATH_MAP). Calling /api/ask/ directly against the gateway 404s (verified live
4
+ // 2026-07-03). one.ie/web itself only answers the long form. Pick the path that
5
+ // matches whichever host --api actually points at, rather than hardcoding one.
6
+ export function askPath(base, receiver) {
7
+ const isGateway = new URL(base).hostname === 'api.one.ie';
8
+ return `${base}${isGateway ? '/ask' : '/api/ask'}/${encodeURIComponent(receiver)}`;
9
+ }
@@ -0,0 +1,16 @@
1
+ import type { Command } from 'commander';
2
+ /** --api flag > ONE_API_URL (canonical) > ONEIE_BASE_URL (legacy) > fallback. ONE_BASE_URL is retired. */
3
+ export declare function resolveBase(opts?: {
4
+ api?: string;
5
+ }, fallback?: string): string;
6
+ /** ONE_API_KEY (canonical) > ONEIE_API_KEY (legacy) > ~/.config/oneie/key. */
7
+ export declare function resolveKey(opts?: {
8
+ key?: string;
9
+ }): string;
10
+ export declare function authHeaders(opts?: {
11
+ key?: string;
12
+ }): Record<string, string>;
13
+ /** Walks cmd.parent all the way to root — never a fixed depth. ONEIE_JSON env is retired. */
14
+ export declare function jsonMode(cmd: Command): boolean;
15
+ /** ok/error human line (`ok k=v k=v`), or the same data as one JSON line under --json. */
16
+ export declare function out(cmd: Command, data: Record<string, unknown>): void;
@@ -0,0 +1,57 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { resolve } from 'node:path';
4
+ // Every command resolves base URL, key, and --json the same way — this module
5
+ // is the one place that knows the env contract. Composes askPath() from
6
+ // ./api-path.js for the gateway-vs-web path split; does not replace it.
7
+ const KEY_FILE = resolve(homedir(), '.config', 'oneie', 'key');
8
+ /** --api flag > ONE_API_URL (canonical) > ONEIE_BASE_URL (legacy) > fallback. ONE_BASE_URL is retired. */
9
+ export function resolveBase(opts = {}, fallback = 'https://one.ie') {
10
+ const base = opts.api ?? process.env.ONE_API_URL ?? process.env.ONEIE_BASE_URL ?? fallback;
11
+ return base.replace(/\/$/, '');
12
+ }
13
+ /** ONE_API_KEY (canonical) > ONEIE_API_KEY (legacy) > ~/.config/oneie/key. */
14
+ export function resolveKey(opts = {}) {
15
+ if (opts.key)
16
+ return opts.key;
17
+ if (process.env.ONE_API_KEY)
18
+ return process.env.ONE_API_KEY;
19
+ if (process.env.ONEIE_API_KEY)
20
+ return process.env.ONEIE_API_KEY;
21
+ if (existsSync(KEY_FILE))
22
+ return readFileSync(KEY_FILE, 'utf8').trim();
23
+ return '';
24
+ }
25
+ export function authHeaders(opts = {}) {
26
+ const h = { 'Content-Type': 'application/json' };
27
+ const k = resolveKey(opts);
28
+ if (k)
29
+ h['Authorization'] = `Bearer ${k}`;
30
+ return h;
31
+ }
32
+ /** Walks cmd.parent all the way to root — never a fixed depth. ONEIE_JSON env is retired. */
33
+ export function jsonMode(cmd) {
34
+ let c = cmd;
35
+ while (c) {
36
+ if (c.opts().json)
37
+ return true;
38
+ c = c.parent ?? undefined;
39
+ }
40
+ return false;
41
+ }
42
+ /** ok/error human line (`ok k=v k=v`), or the same data as one JSON line under --json. */
43
+ export function out(cmd, data) {
44
+ if (jsonMode(cmd)) {
45
+ process.stdout.write(JSON.stringify(data) + '\n');
46
+ return;
47
+ }
48
+ if (data.ok === false) {
49
+ process.stderr.write(`error ${data.error ?? 'unknown'}\n`);
50
+ process.exitCode = 1;
51
+ return;
52
+ }
53
+ const pairs = Object.entries(data)
54
+ .filter(([k]) => k !== 'ok')
55
+ .map(([k, v]) => `${k}=${JSON.stringify(v)}`);
56
+ process.stdout.write(`ok ${pairs.join(' ')}\n`);
57
+ }
@@ -0,0 +1,5 @@
1
+ import { Command } from 'commander';
2
+ /** `one links` — mint personalised, actor-bound tracked links from the terminal.
3
+ * Thin wrapper over the `links:create` receiver via ask() (no new route). The
4
+ * receiver walks authority server-side; the API key identifies the caller. */
5
+ export declare function linksCmd(): Command;
@@ -0,0 +1,44 @@
1
+ import { Command } from 'commander';
2
+ import { authHeaders, resolveBase } from './lib/client.js';
3
+ const DEFAULT_API = resolveBase({}, 'https://api.one.ie');
4
+ async function ask(api, receiver, data) {
5
+ const res = await fetch(`${api.replace(/\/$/, '')}/api/ask/${encodeURIComponent(receiver)}`, {
6
+ method: 'POST',
7
+ headers: authHeaders(),
8
+ body: JSON.stringify({ data }),
9
+ });
10
+ if (!res.ok) {
11
+ process.stderr.write(`POST /api/ask/${receiver} → ${res.status}\n`);
12
+ process.exit(1);
13
+ }
14
+ return res.json();
15
+ }
16
+ function out(data) {
17
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
18
+ }
19
+ /** `one links` — mint personalised, actor-bound tracked links from the terminal.
20
+ * Thin wrapper over the `links:create` receiver via ask() (no new route). The
21
+ * receiver walks authority server-side; the API key identifies the caller. */
22
+ export function linksCmd() {
23
+ const cmd = new Command('links').description('Create personalised, actor-bound tracked links');
24
+ cmd
25
+ .command('create <actorId>')
26
+ .description('Create a tracked link bound to a contact (rung-4 identity on click)')
27
+ .option('--to <path>', "Destination path, e.g. '/pricing'", '/')
28
+ .option('--context <text>', "Context injected into the agent's system prompt")
29
+ .option('--greeting <text>', "Override the chat agent's opening line")
30
+ .option('--campaign <id>', 'Group clicks under a campaign')
31
+ .option('--expires <days>', 'Link TTL in days (omit = never)')
32
+ .option('--api <url>', 'API base URL', DEFAULT_API)
33
+ .action(async (actorId, opts) => {
34
+ out(await ask(opts.api, 'links:create', {
35
+ actorId,
36
+ destination: opts.to,
37
+ context: opts.context,
38
+ greeting: opts.greeting,
39
+ campaignId: opts.campaign,
40
+ expiresInDays: opts.expires ? Number(opts.expires) : undefined,
41
+ }));
42
+ });
43
+ return cmd;
44
+ }