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,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
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * oneie onboard — deterministically walk a fresh agent through the platform's
3
+ * agent-onboarding lifecycle (text/agent-onboarding-lifecycle.md): registered
4
+ * → bootstrapped → active → settled → adopted.
5
+ *
6
+ * Reuses the same zero-to-live call `one init` uses (POST /api/provision/agent)
7
+ * for register+bootstrap — both stages are tracked server-side automatically
8
+ * (no extra calls from here). Adds the read-back + guide layer `init` doesn't:
9
+ * after provisioning, reads the real stage_transition log via lifecycle:mine
10
+ * and tells the agent exactly what unlocks each remaining stage.
11
+ *
12
+ * Idempotent: if this directory already has ONE_API_KEY, skips provisioning
13
+ * and just reports current lifecycle position.
14
+ */
15
+ import { Command } from 'commander';
16
+ export declare function onboardCmd(): Command;
@@ -0,0 +1,146 @@
1
+ /**
2
+ * oneie onboard — deterministically walk a fresh agent through the platform's
3
+ * agent-onboarding lifecycle (text/agent-onboarding-lifecycle.md): registered
4
+ * → bootstrapped → active → settled → adopted.
5
+ *
6
+ * Reuses the same zero-to-live call `one init` uses (POST /api/provision/agent)
7
+ * for register+bootstrap — both stages are tracked server-side automatically
8
+ * (no extra calls from here). Adds the read-back + guide layer `init` doesn't:
9
+ * after provisioning, reads the real stage_transition log via lifecycle:mine
10
+ * and tells the agent exactly what unlocks each remaining stage.
11
+ *
12
+ * Idempotent: if this directory already has ONE_API_KEY, skips provisioning
13
+ * and just reports current lifecycle position.
14
+ */
15
+ import { Command } from 'commander';
16
+ import { writeFileSync, mkdirSync, renameSync, chmodSync } from 'node:fs';
17
+ import { resolve, join } from 'node:path';
18
+ import { homedir } from 'node:os';
19
+ import { mergeEnv, writeEnvLocal } from './env.js';
20
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://one.ie';
21
+ const CONFIG_DIR = resolve(homedir(), '.config', 'oneie');
22
+ const KEY_FILE = resolve(CONFIG_DIR, 'key');
23
+ function writeKey(value) {
24
+ mkdirSync(CONFIG_DIR, { recursive: true });
25
+ const tmp = join(CONFIG_DIR, '.key.tmp');
26
+ writeFileSync(tmp, value, { mode: 0o600 });
27
+ chmodSync(tmp, 0o600);
28
+ renameSync(tmp, KEY_FILE);
29
+ }
30
+ async function ask(base, key, receiver, data) {
31
+ const res = await fetch(`${base}/api/ask/${encodeURIComponent(receiver)}`, {
32
+ method: 'POST',
33
+ headers: { 'Content-Type': 'application/json', ...(key ? { Authorization: `Bearer ${key}` } : {}) },
34
+ body: JSON.stringify({ data }),
35
+ });
36
+ const json = (await res.json().catch(() => ({})));
37
+ if (!res.ok)
38
+ throw new Error(`${receiver} → ${res.status}: ${JSON.stringify(json)}`);
39
+ return json;
40
+ }
41
+ // The 5 stages, in order, and what unlocks each one — mirrors
42
+ // SEED_DEFS['agent-onboarding'] in one.ie/web/src/lib/lifecycle/seed.ts.
43
+ // Kept here as plain data (not fetched) so `onboard` works even before the
44
+ // agent has a key to call the substrate with.
45
+ const STAGE_GUIDE = {
46
+ registered: 'done — your identity exists (uid + apiKey minted).',
47
+ bootstrapped: 'done — your own workspace exists (gid + aid + scopedKey minted).',
48
+ active: 'publish a capability or place a market offer: `one agent publish` or `one trade market`.',
49
+ settled: 'complete a sale: `one trade hire` (as a buyer) or accept + settle an offer (as the seller).',
50
+ adopted: 'get adopted by another workspace — accept an invite, or have your capability hired long-term.',
51
+ };
52
+ const STAGE_ORDER = ['registered', 'bootstrapped', 'active', 'settled', 'adopted'];
53
+ function out(cmd, data) {
54
+ const isJson = cmd.parent?.opts().json;
55
+ if (isJson) {
56
+ process.stdout.write(JSON.stringify(data) + '\n');
57
+ return;
58
+ }
59
+ if (data.ok === false) {
60
+ process.stderr.write(`✗ ${data.error ?? 'failed'}\n`);
61
+ return;
62
+ }
63
+ const stages = data.stages ?? [];
64
+ process.stdout.write(`✓ onboarded as ${data.uid ?? '?'}\n`);
65
+ process.stdout.write(` workspace: ${data.workspace ?? '?'}\n`);
66
+ process.stdout.write(` url: ${data.url ?? '?'}\n\n`);
67
+ process.stdout.write(' lifecycle: register → bootstrap → active → settled → adopted\n');
68
+ for (const s of stages) {
69
+ process.stdout.write(` ${s.done ? '✓' : '·'} ${s.id.padEnd(12)} ${s.guide}\n`);
70
+ }
71
+ }
72
+ export function onboardCmd() {
73
+ const cmd = new Command('onboard')
74
+ .description('Zero-to-live onboarding + a deterministic guide through the agent lifecycle')
75
+ .option('--name <name>', 'Workspace / agent display name')
76
+ .option('--api <url>', 'API base URL', DEFAULT_API)
77
+ .option('--write-env', 'Also write ONE_API_KEY to .env.local in the current directory', true)
78
+ .action(async (opts) => {
79
+ const dir = process.cwd();
80
+ const base = opts.api.replace(/\/$/, '');
81
+ const env = mergeEnv(dir);
82
+ let apiKey = env.ONE_API_KEY ?? env.ONEIE_API_KEY ?? '';
83
+ // regKey is the uid-bound registration key — distinct from apiKey (the
84
+ // workspace-scoped key `apiKey` resolves to). lifecycle:mine and any
85
+ // other uid-scoped receiver need THIS key: ctx.ownerSlug from `apiKey`
86
+ // resolves to the workspace's aid, which has zero stage_transition rows.
87
+ let regKey = env.ONE_REG_KEY ?? '';
88
+ let uid = env.ONE_UID ?? '';
89
+ let workspace = env.AGENCY_WSID ?? env.AGENCY_SLUG ?? '';
90
+ if (!apiKey) {
91
+ // Register + bootstrap in one call — the same zero-to-live path `one
92
+ // init` uses, POST /api/provision/agent. Both stages are tracked
93
+ // server-side the moment this call lands; nothing extra to do here.
94
+ const res = await fetch(`${base}/api/provision/agent`, {
95
+ method: 'POST',
96
+ headers: { 'Content-Type': 'application/json' },
97
+ body: JSON.stringify({ name: opts.name ?? 'My Agent', live: true }),
98
+ });
99
+ const json = (await res.json().catch(() => ({})));
100
+ if (!res.ok || !json.apiKey) {
101
+ out(cmd, { ok: false, error: json.error ?? `provision failed (${res.status})` });
102
+ process.exitCode = 1;
103
+ return;
104
+ }
105
+ uid = String(json.uid);
106
+ workspace = String(json.workspace);
107
+ apiKey = json.apiKey;
108
+ regKey = json.regKey ?? '';
109
+ writeKey(apiKey);
110
+ if (opts.writeEnv) {
111
+ writeEnvLocal(dir, { ONE_API_KEY: apiKey, ONE_API_URL: base, ONE_REG_KEY: regKey, ONE_UID: uid, AGENCY_WSID: workspace });
112
+ }
113
+ }
114
+ // Read back the real stage_transition log — the deterministic proof,
115
+ // not an assertion this command makes up. lifecycle:mine is self-scoped
116
+ // (entity_id = the caller's own uid, attested by the bearer key) —
117
+ // MUST be called with regKey, not apiKey (see note above).
118
+ const reached = new Set();
119
+ if (regKey) {
120
+ try {
121
+ const mine = await ask(base, regKey, 'lifecycle:mine', {});
122
+ const rows = (mine.result?.rows) ?? [];
123
+ for (const r of rows)
124
+ reached.add(r.to_stage);
125
+ }
126
+ catch {
127
+ // lifecycle:mine itself failing (e.g. no DB in a local dev target)
128
+ // must never block reporting what we already know from provisioning.
129
+ }
130
+ }
131
+ if (uid) {
132
+ reached.add('registered');
133
+ reached.add('bootstrapped');
134
+ }
135
+ const stages = STAGE_ORDER.map((id) => ({ id, done: reached.has(id), guide: STAGE_GUIDE[id] }));
136
+ out(cmd, {
137
+ ok: true,
138
+ uid: uid || '(unknown — no ONE_UID in env; re-run in a fresh dir to see it)',
139
+ workspace,
140
+ url: workspace ? `${base}/u/${workspace}` : base,
141
+ key: `${KEY_FILE} (0600)`,
142
+ stages,
143
+ });
144
+ });
145
+ return cmd;
146
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function pluginCmd(): Command;
@@ -0,0 +1,184 @@
1
+ import { Command } from 'commander';
2
+ import { mkdirSync } from 'node:fs';
3
+ import { spawnSync } from 'node:child_process';
4
+ import { jsonMode, resolveBase, resolveKey } from './lib/client.js';
5
+ function out(label, data, cmd) {
6
+ if (cmd ? jsonMode(cmd) : process.env.ONEIE_JSON) {
7
+ process.stdout.write(JSON.stringify({ cmd: label, ...data }) + '\n');
8
+ }
9
+ else {
10
+ const ok = data.ok !== false;
11
+ const pairs = Object.entries(data)
12
+ .filter(([k]) => k !== 'ok')
13
+ .map(([k, v]) => `${k}=${JSON.stringify(v)}`)
14
+ .join(' ');
15
+ console.log(`${ok ? '✓' : '✗'} ${label} ${pairs}`);
16
+ }
17
+ }
18
+ function apiBase(opts) {
19
+ return resolveBase(opts, 'https://one.ie');
20
+ }
21
+ function bearerHeaders(workspace) {
22
+ const key = resolveKey();
23
+ return key && workspace ? { Authorization: `Bearer ${workspace}:${key}` } : {};
24
+ }
25
+ // npm pack wraps a package's contents under a "package/" root — strip-components=1 lands
26
+ // the real package.json + src/ directly at ./plugin-<name>/, same as a real npm install would.
27
+ function extractTarball(bytes, targetDir) {
28
+ mkdirSync(targetDir, { recursive: true });
29
+ const tar = spawnSync('tar', ['-xz', '--strip-components=1', '-C', targetDir], {
30
+ input: bytes,
31
+ stdio: ['pipe', 'inherit', 'inherit'],
32
+ });
33
+ if (tar.status !== 0)
34
+ throw new Error(`tar failed extracting to ${targetDir}`);
35
+ }
36
+ export function pluginCmd() {
37
+ const cmd = new Command('plugin').description('Manage ONE plugins');
38
+ cmd
39
+ .command('list')
40
+ .description('List available plugins and their pricing')
41
+ .option('--api <url>', 'API base URL')
42
+ .action(async (opts) => {
43
+ let res;
44
+ try {
45
+ res = await fetch(`${apiBase(opts)}/api/plugins`);
46
+ }
47
+ catch (e) {
48
+ console.error(`Error: ${e instanceof Error ? e.message : e}`);
49
+ process.exit(1);
50
+ }
51
+ const body = (await res.json());
52
+ if (!res.ok || !body.plugins) {
53
+ out('plugin:list', { ok: false, error: 'fetch_failed', status: res.status });
54
+ process.exit(1);
55
+ }
56
+ for (const p of body.plugins) {
57
+ console.log(` ${p.name.padEnd(12)} ${p.title.padEnd(16)} $${p.price_usd}/mo ${p.description}`);
58
+ }
59
+ out('plugin:list', { ok: true, count: body.plugins.length });
60
+ });
61
+ cmd
62
+ .command('add <name>')
63
+ .description('Install a plugin — pulls source when workspace is entitled')
64
+ .option('--workspace <slug>', 'Workspace slug (default: ONEIE_WORKSPACE env)')
65
+ .option('--api <url>', 'API base URL')
66
+ .action(async (name, opts) => {
67
+ const workspace = opts.workspace ?? process.env.ONEIE_WORKSPACE;
68
+ if (!workspace) {
69
+ console.error('Error: --workspace or ONEIE_WORKSPACE required');
70
+ process.exit(1);
71
+ }
72
+ let res;
73
+ try {
74
+ res = await fetch(`${apiBase(opts)}/api/plugins/${name}/source`, {
75
+ headers: bearerHeaders(workspace),
76
+ });
77
+ }
78
+ catch (e) {
79
+ console.error(`Error: ${e instanceof Error ? e.message : e}`);
80
+ process.exit(1);
81
+ }
82
+ // Paid plugins (PAID_FEATURES) stream a real gzip tarball on 200; free plugins keep
83
+ // the JSON pointer to their public npm package. Discriminate before parsing the body.
84
+ if (res.ok && res.headers.get('content-type')?.startsWith('application/gzip')) {
85
+ const bytes = new Uint8Array(await res.arrayBuffer());
86
+ const targetDir = `./plugin-${name}`;
87
+ try {
88
+ extractTarball(bytes, targetDir);
89
+ }
90
+ catch (e) {
91
+ out('plugin:add', { ok: false, error: 'extract_failed', plugin: name, detail: e instanceof Error ? e.message : String(e) });
92
+ process.exit(1);
93
+ }
94
+ out('plugin:add', { ok: true, plugin: name, extracted: true, path: targetDir });
95
+ return;
96
+ }
97
+ const body = (await res.json());
98
+ if (res.status === 402) {
99
+ out('plugin:add', {
100
+ ok: false,
101
+ error: 'not_entitled',
102
+ plugin: name,
103
+ hint: body.hint ?? `Purchase the ${name} plugin at https://one.ie/marketplace`,
104
+ });
105
+ process.exit(1);
106
+ }
107
+ if (!res.ok) {
108
+ out('plugin:add', { ok: false, error: body.error ?? 'unknown', plugin: name, status: res.status });
109
+ process.exit(1);
110
+ }
111
+ out('plugin:add', { ok: true, plugin: name, source: body.source, install: body.install });
112
+ });
113
+ cmd
114
+ .command('buy <name>')
115
+ .description('Buy a plugin — card (default) or the workspace credit pool (--credits)')
116
+ .option('--workspace <slug>', 'Workspace slug (default: ONEIE_WORKSPACE env)')
117
+ .option('--credits', 'Pay from the workspace credit pool instead of card')
118
+ .option('--api <url>', 'API base URL')
119
+ .action(async (name, opts) => {
120
+ const workspace = opts.workspace ?? process.env.ONEIE_WORKSPACE;
121
+ if (!workspace) {
122
+ console.error('Error: --workspace or ONEIE_WORKSPACE required');
123
+ process.exit(1);
124
+ }
125
+ const method = opts.credits ? 'credits' : 'stripe';
126
+ let res;
127
+ try {
128
+ res = await fetch(`${apiBase(opts)}/api/ask/plugins:buy`, {
129
+ method: 'POST',
130
+ headers: { ...bearerHeaders(workspace), 'Content-Type': 'application/json' },
131
+ body: JSON.stringify({ data: { name, method } }),
132
+ });
133
+ }
134
+ catch (e) {
135
+ console.error(`Error: ${e instanceof Error ? e.message : e}`);
136
+ process.exit(1);
137
+ }
138
+ const env = (await res.json().catch(() => ({})));
139
+ const r = env.result ?? {};
140
+ if (!res.ok || env.outcome !== 'result' || r.error) {
141
+ out('plugin:buy', { ok: false, plugin: name, error: r.error ?? env.outcome ?? 'failed', status: res.status });
142
+ process.exit(1);
143
+ }
144
+ if (method === 'credits') {
145
+ out('plugin:buy', { ok: true, plugin: name, method, entitled: r.entitled, credits_spent: r.credits_spent, install: `one plugin add ${name}` });
146
+ }
147
+ else {
148
+ out('plugin:buy', { ok: true, plugin: name, method, checkout_url: r.url, note: 'Open checkout_url to pay, then: one plugin add ' + name });
149
+ }
150
+ });
151
+ cmd
152
+ .command('grant <name>')
153
+ .description('Resell a plugin to a client you control — grants the entitlement, no charge')
154
+ .requiredOption('--to <client>', 'Client workspace slug to grant the plugin to')
155
+ .option('--workspace <slug>', 'Your (reseller) workspace slug (default: ONEIE_WORKSPACE env)')
156
+ .option('--api <url>', 'API base URL')
157
+ .action(async (name, opts) => {
158
+ const workspace = opts.workspace ?? process.env.ONEIE_WORKSPACE;
159
+ if (!workspace) {
160
+ console.error('Error: --workspace or ONEIE_WORKSPACE required');
161
+ process.exit(1);
162
+ }
163
+ let res;
164
+ try {
165
+ res = await fetch(`${apiBase(opts)}/api/ask/plugins:grant`, {
166
+ method: 'POST',
167
+ headers: { ...bearerHeaders(workspace), 'Content-Type': 'application/json' },
168
+ body: JSON.stringify({ data: { name, for: opts.to } }),
169
+ });
170
+ }
171
+ catch (e) {
172
+ console.error(`Error: ${e instanceof Error ? e.message : e}`);
173
+ process.exit(1);
174
+ }
175
+ const env = (await res.json().catch(() => ({})));
176
+ const r = env.result ?? {};
177
+ if (!res.ok || env.outcome !== 'result' || r.error) {
178
+ out('plugin:grant', { ok: false, plugin: name, client: opts.to, error: r.error ?? env.outcome ?? 'failed', status: res.status });
179
+ process.exit(1);
180
+ }
181
+ out('plugin:grant', { ok: true, plugin: name, client: opts.to, already: r.already ?? false, note: `Client ${opts.to} is now entitled to ${name}` });
182
+ });
183
+ return cmd;
184
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function pushCmd(): Command;
@@ -0,0 +1,114 @@
1
+ import { Command } from 'commander';
2
+ import { compileNode } from './compiler.js';
3
+ import { mergeEnv } from './env.js';
4
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
5
+ function apiKey(env) {
6
+ return env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
7
+ }
8
+ async function ask(base, headers, receiver, data) {
9
+ try {
10
+ const res = await fetch(`${base}/api/ask/${encodeURIComponent(receiver)}`, {
11
+ method: 'POST', headers, body: JSON.stringify({ data }),
12
+ });
13
+ if (!res.ok)
14
+ return { ok: false, result: {} };
15
+ const json = (await res.json().catch(() => ({})));
16
+ return { ok: true, result: json.result ?? {} };
17
+ }
18
+ catch {
19
+ return { ok: false, result: {} };
20
+ }
21
+ }
22
+ /** workflow:create resolves the target from requireSlug(ctx), so child workflows need that
23
+ * workspace's own owner key. The configured (possibly parent) key can mint it via the walk. */
24
+ async function mintOwnerKey(base, headers, slug) {
25
+ const r = await ask(base, headers, 'world:mint-owner-key', { slug, label: 'push' });
26
+ const k = r.result.key ?? r.result.ownerKey ?? r.result.scopedKey;
27
+ return typeof k === 'string' && k ? k : null;
28
+ }
29
+ export function pushCmd() {
30
+ return new Command('push')
31
+ .description('Compile ai/ + data/ folders and push to substrate')
32
+ .argument('[path]', 'Node root directory (default: cwd)')
33
+ .option('--client <slug>', 'Apply client override from clients/<slug>/')
34
+ .option('--dry-run', 'Validate and print plan without making substrate calls')
35
+ .option('--api <url>', 'API base URL', DEFAULT_API)
36
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
37
+ .action(async (path, opts) => {
38
+ const dir = path ?? process.cwd();
39
+ const env = mergeEnv(dir);
40
+ const agencySlug = env.AGENCY_SLUG;
41
+ if (!agencySlug) {
42
+ process.stderr.write('AGENCY_SLUG missing — run `one setup` first\n');
43
+ process.exit(1);
44
+ }
45
+ const { compiled, errors } = await compileNode(dir, agencySlug, { clientSlug: opts.client, dryRun: opts.dryRun });
46
+ if (errors.length) {
47
+ for (const e of errors)
48
+ process.stderr.write(` error: ${e.path}: ${e.message}\n`);
49
+ process.exit(1);
50
+ }
51
+ if (opts.dryRun) {
52
+ process.stdout.write(`[dry-run] ${compiled.length} item(s) would push:\n`);
53
+ for (const item of compiled) {
54
+ const steps = item.applyDiff ? ` (+${item.applyDiff.add.length} steps)` : '';
55
+ process.stdout.write(` ${item.receiver} ${item.path}${steps}\n`);
56
+ }
57
+ return;
58
+ }
59
+ const base = (opts.api ?? DEFAULT_API).replace(/\/$/, '');
60
+ const key = opts.key ?? apiKey(env);
61
+ const authHeaders = { 'Content-Type': 'application/json' };
62
+ if (key)
63
+ authHeaders['Authorization'] = `Bearer ${key}`;
64
+ const isWorkflow = (i) => i.receiver === 'workflow:create';
65
+ let ok = 0;
66
+ // Standard items (agents, skills, context, lifecycles, types …) — explicit-slug receivers
67
+ // authorize via the ownership walk, so the configured key covers owned child workspaces.
68
+ for (const item of compiled.filter((i) => !isWorkflow(i))) {
69
+ const res = await fetch(`${base}/api/ask/${encodeURIComponent(item.receiver)}`, {
70
+ method: 'POST', headers: authHeaders, body: JSON.stringify({ data: item.payload }),
71
+ });
72
+ if (res.ok)
73
+ ok++;
74
+ else
75
+ process.stderr.write(` failed: ${item.receiver} ${res.status}\n`);
76
+ }
77
+ // Workflows — two-phase (create → apply-diff) under a workspace-owner key, idempotent by name.
78
+ const wfItems = compiled.filter(isWorkflow);
79
+ if (wfItems.length) {
80
+ const wfKey = (await mintOwnerKey(base, authHeaders, agencySlug)) ?? key;
81
+ const wfHeaders = { 'Content-Type': 'application/json', Authorization: `Bearer ${wfKey}` };
82
+ // Existing workflows by name → delete a same-name match before recreating (clean re-push).
83
+ const list = await ask(base, wfHeaders, 'workflow:list', {});
84
+ const rows = (Array.isArray(list.result) ? list.result : (list.result.workflows ?? list.result.items ?? []));
85
+ const byName = new Map();
86
+ for (const w of rows) {
87
+ const n = String(w.name ?? '');
88
+ const id = String(w.id ?? w.workflowId ?? '');
89
+ if (n && id)
90
+ byName.set(n, [...(byName.get(n) ?? []), id]);
91
+ }
92
+ for (const item of wfItems) {
93
+ const name = String(item.payload.name ?? '');
94
+ for (const id of byName.get(name) ?? [])
95
+ await ask(base, wfHeaders, 'workflow:delete', { workflowId: id });
96
+ const created = await ask(base, wfHeaders, 'workflow:create', item.payload);
97
+ const wid = created.result.workflowId ?? created.result.id;
98
+ if (!created.ok || typeof wid !== 'string') {
99
+ process.stderr.write(` failed: workflow:create ${name}\n`);
100
+ continue;
101
+ }
102
+ if (item.applyDiff) {
103
+ const applied = await ask(base, wfHeaders, 'workflow:apply-diff', { workflowId: wid, diff: item.applyDiff });
104
+ if (!applied.ok || applied.result.ok === false) {
105
+ process.stderr.write(` failed: workflow:apply-diff ${name}\n`);
106
+ continue;
107
+ }
108
+ }
109
+ ok++;
110
+ }
111
+ }
112
+ process.stdout.write(`Pushed ${ok}/${compiled.length} item(s).\n`);
113
+ });
114
+ }
@@ -0,0 +1,21 @@
1
+ export interface AgencyPL {
2
+ slug: string;
3
+ name: string | null;
4
+ plan: string;
5
+ markup_pct: number;
6
+ pool: number;
7
+ }
8
+ export interface ClientPL {
9
+ slug: string;
10
+ name: string | null;
11
+ plan: string;
12
+ funded: number;
13
+ burned: number;
14
+ margin: number;
15
+ balance: number;
16
+ cap: number | null;
17
+ }
18
+ /** The CLIENT/PLAN/FUNDED/… table — shared by `status` (with the agency P&L
19
+ * header) and `client list` (bare, no header). */
20
+ export declare function renderClientTable(clients: ClientPL[], markupPct: number): string;
21
+ export declare function renderStatus(agency: AgencyPL, clients: ClientPL[]): string;
@@ -0,0 +1,32 @@
1
+ const fmt = (n) => n.toLocaleString('en-US');
2
+ const capFmt = (n) => (n == null ? '—' : fmt(n));
3
+ function pad(cells, widths) {
4
+ return cells.map((c, i) => c.padEnd(widths[i])).join(' ').replace(/\s+$/, '');
5
+ }
6
+ /** The CLIENT/PLAN/FUNDED/… table — shared by `status` (with the agency P&L
7
+ * header) and `client list` (bare, no header). */
8
+ export function renderClientTable(clients, markupPct) {
9
+ const header = ['CLIENT', 'PLAN', 'FUNDED', 'BURNED', `MARGIN(${markupPct}%)`, 'BALANCE', 'CAP'];
10
+ const rows = clients.map((c) => [
11
+ c.slug, c.plan, fmt(c.funded), fmt(c.burned), fmt(c.margin), fmt(c.balance), capFmt(c.cap),
12
+ ]);
13
+ const widths = header.map((h, i) => Math.max(h.length, ...rows.map((r) => r[i].length), 0));
14
+ const totalBurned = clients.reduce((s, c) => s + c.burned, 0);
15
+ const totalMargin = clients.reduce((s, c) => s + c.margin, 0);
16
+ const out = [];
17
+ out.push(pad(header, widths));
18
+ for (const r of rows)
19
+ out.push(pad(r, widths));
20
+ if (clients.length === 0)
21
+ out.push(' (no clients yet — `one client add <slug>`)');
22
+ else
23
+ out.push(`\n total burned ${fmt(totalBurned)} · margin ${fmt(totalMargin)} ← your margin this period`);
24
+ return out.join('\n');
25
+ }
26
+ export function renderStatus(agency, clients) {
27
+ const out = [];
28
+ out.push(`Agency: ${agency.name ?? agency.slug} (${agency.slug}) plan=${agency.plan} markup=${agency.markup_pct}% pool=${fmt(agency.pool)} cr`);
29
+ out.push('');
30
+ out.push(renderClientTable(clients, agency.markup_pct));
31
+ return out.join('\n');
32
+ }
@@ -0,0 +1,6 @@
1
+ import { Command } from 'commander';
2
+ /** No key in env — provision one via the same open call `init` uses, then
3
+ * reconcile the returned slug down into .env.local + workspace.toml. The
4
+ * route mints its own slug; it does not accept a desired one (contract #4). */
5
+ export declare function keylessSetup(dir: string, cfgPath: string | undefined, web: string): Promise<void>;
6
+ export declare function setupCmd(): Command;