@oneie/cli 5.8.0 → 5.9.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 (270) hide show
  1. package/README.md +114 -6
  2. package/dist/package.json +37 -11
  3. package/dist/src/age-1k8hs4ec.js +1 -0
  4. package/dist/src/client-n6fpnd9f.js +1 -0
  5. package/dist/src/evm-tx-cqhm9rtt.js +1 -0
  6. package/dist/src/hl-run-0pv1e0p2.js +1 -0
  7. package/dist/src/index-f5vhzspa.js +12 -0
  8. package/dist/src/index-h3nrt8bx.js +4 -0
  9. package/dist/src/index-st6k9vhc.js +2062 -0
  10. package/dist/src/index.js +1122 -134
  11. package/dist/src/message-key-yczrxszr.js +1 -0
  12. package/dist/src/message-lock-thr851d5.js +5 -0
  13. package/dist/src/sweep-order-jrq2hkye.js +1 -0
  14. package/dist/src/sweep-runner-jftw9em7.js +1 -0
  15. package/package.json +37 -11
  16. package/dist/src/agent.d.ts +0 -75
  17. package/dist/src/agent.js +0 -1334
  18. package/dist/src/agentverse.d.ts +0 -26
  19. package/dist/src/agentverse.js +0 -171
  20. package/dist/src/args.d.ts +0 -9
  21. package/dist/src/args.js +0 -61
  22. package/dist/src/auth.d.ts +0 -6
  23. package/dist/src/auth.js +0 -121
  24. package/dist/src/balances.d.ts +0 -89
  25. package/dist/src/balances.js +0 -202
  26. package/dist/src/banner.d.ts +0 -1
  27. package/dist/src/banner.js +0 -17
  28. package/dist/src/broadcast.d.ts +0 -8
  29. package/dist/src/broadcast.js +0 -175
  30. package/dist/src/catalog.d.ts +0 -12
  31. package/dist/src/catalog.js +0 -76
  32. package/dist/src/ceiling.d.ts +0 -36
  33. package/dist/src/ceiling.js +0 -189
  34. package/dist/src/chat.d.ts +0 -2
  35. package/dist/src/chat.js +0 -92
  36. package/dist/src/check.d.ts +0 -11
  37. package/dist/src/check.js +0 -53
  38. package/dist/src/client.d.ts +0 -5
  39. package/dist/src/client.js +0 -157
  40. package/dist/src/compiler.d.ts +0 -36
  41. package/dist/src/compiler.js +0 -366
  42. package/dist/src/config.d.ts +0 -24
  43. package/dist/src/config.js +0 -70
  44. package/dist/src/connect.d.ts +0 -2
  45. package/dist/src/connect.js +0 -64
  46. package/dist/src/coordinate.d.ts +0 -3
  47. package/dist/src/coordinate.js +0 -58
  48. package/dist/src/create.d.ts +0 -2
  49. package/dist/src/create.js +0 -113
  50. package/dist/src/credits.d.ts +0 -29
  51. package/dist/src/credits.js +0 -88
  52. package/dist/src/deploy.d.ts +0 -2
  53. package/dist/src/deploy.js +0 -19
  54. package/dist/src/dev.d.ts +0 -2
  55. package/dist/src/dev.js +0 -75
  56. package/dist/src/device-flow.d.ts +0 -57
  57. package/dist/src/device-flow.js +0 -173
  58. package/dist/src/doctor.d.ts +0 -26
  59. package/dist/src/doctor.js +0 -146
  60. package/dist/src/draw.d.ts +0 -18
  61. package/dist/src/draw.js +0 -156
  62. package/dist/src/endpoint.d.ts +0 -2
  63. package/dist/src/endpoint.js +0 -250
  64. package/dist/src/env.d.ts +0 -3
  65. package/dist/src/env.js +0 -37
  66. package/dist/src/eval.d.ts +0 -2
  67. package/dist/src/eval.js +0 -43
  68. package/dist/src/fn.d.ts +0 -2
  69. package/dist/src/fn.js +0 -70
  70. package/dist/src/group.d.ts +0 -2
  71. package/dist/src/group.js +0 -117
  72. package/dist/src/hl-run.d.ts +0 -119
  73. package/dist/src/hl-run.js +0 -480
  74. package/dist/src/hl.d.ts +0 -17
  75. package/dist/src/hl.js +0 -148
  76. package/dist/src/index.d.ts +0 -2
  77. package/dist/src/init.d.ts +0 -76
  78. package/dist/src/init.js +0 -278
  79. package/dist/src/join.d.ts +0 -11
  80. package/dist/src/join.js +0 -297
  81. package/dist/src/key-publish.d.ts +0 -40
  82. package/dist/src/key-publish.js +0 -232
  83. package/dist/src/key-seal.d.ts +0 -21
  84. package/dist/src/key-seal.js +0 -142
  85. package/dist/src/key-sweep.d.ts +0 -93
  86. package/dist/src/key-sweep.js +0 -270
  87. package/dist/src/key.d.ts +0 -26
  88. package/dist/src/key.js +0 -338
  89. package/dist/src/lib/age-plugin.d.ts +0 -51
  90. package/dist/src/lib/age-plugin.js +0 -130
  91. package/dist/src/lib/agent-env.d.ts +0 -12
  92. package/dist/src/lib/agent-env.js +0 -48
  93. package/dist/src/lib/api-path.d.ts +0 -2
  94. package/dist/src/lib/api-path.js +0 -40
  95. package/dist/src/lib/asker.d.ts +0 -34
  96. package/dist/src/lib/asker.js +0 -126
  97. package/dist/src/lib/check-words.d.ts +0 -57
  98. package/dist/src/lib/check-words.js +0 -144
  99. package/dist/src/lib/client.d.ts +0 -20
  100. package/dist/src/lib/client.js +0 -71
  101. package/dist/src/lib/env-sealed.d.ts +0 -53
  102. package/dist/src/lib/env-sealed.js +0 -184
  103. package/dist/src/lib/flow-tag.d.ts +0 -86
  104. package/dist/src/lib/flow-tag.js +0 -230
  105. package/dist/src/lib/hl-core/actions.d.ts +0 -99
  106. package/dist/src/lib/hl-core/actions.js +0 -69
  107. package/dist/src/lib/hl-core/eip712.d.ts +0 -33
  108. package/dist/src/lib/hl-core/eip712.js +0 -107
  109. package/dist/src/lib/hl-core/errors.d.ts +0 -10
  110. package/dist/src/lib/hl-core/errors.js +0 -15
  111. package/dist/src/lib/hl-core/exchange.d.ts +0 -24
  112. package/dist/src/lib/hl-core/exchange.js +0 -47
  113. package/dist/src/lib/hl-core/index.d.ts +0 -13
  114. package/dist/src/lib/hl-core/index.js +0 -14
  115. package/dist/src/lib/hl-core/meta.d.ts +0 -57
  116. package/dist/src/lib/hl-core/meta.js +0 -110
  117. package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
  118. package/dist/src/lib/hl-core/msgpack.js +0 -136
  119. package/dist/src/lib/hl-core/net.d.ts +0 -2
  120. package/dist/src/lib/hl-core/net.js +0 -7
  121. package/dist/src/lib/hl-core/signing.d.ts +0 -103
  122. package/dist/src/lib/hl-core/signing.js +0 -295
  123. package/dist/src/lib/hl-core/wire.d.ts +0 -34
  124. package/dist/src/lib/hl-core/wire.js +0 -81
  125. package/dist/src/lib/invoked-as.d.ts +0 -2
  126. package/dist/src/lib/invoked-as.js +0 -24
  127. package/dist/src/lib/journey-words.d.ts +0 -84
  128. package/dist/src/lib/journey-words.js +0 -363
  129. package/dist/src/lib/journey.d.ts +0 -150
  130. package/dist/src/lib/journey.js +0 -264
  131. package/dist/src/lib/key-receipt.d.ts +0 -48
  132. package/dist/src/lib/key-receipt.js +0 -116
  133. package/dist/src/lib/key-source.d.ts +0 -9
  134. package/dist/src/lib/key-source.js +0 -33
  135. package/dist/src/lib/keyfile.d.ts +0 -136
  136. package/dist/src/lib/keyfile.js +0 -397
  137. package/dist/src/lib/launch-claude.d.ts +0 -5
  138. package/dist/src/lib/launch-claude.js +0 -45
  139. package/dist/src/lib/lock-lookup.d.ts +0 -40
  140. package/dist/src/lib/lock-lookup.js +0 -92
  141. package/dist/src/lib/message-seal.d.ts +0 -63
  142. package/dist/src/lib/message-seal.js +0 -150
  143. package/dist/src/lib/net-choice.d.ts +0 -28
  144. package/dist/src/lib/net-choice.js +0 -72
  145. package/dist/src/lib/network.d.ts +0 -22
  146. package/dist/src/lib/network.js +0 -50
  147. package/dist/src/lib/next-words.d.ts +0 -105
  148. package/dist/src/lib/next-words.js +0 -298
  149. package/dist/src/lib/paths.d.ts +0 -41
  150. package/dist/src/lib/paths.js +0 -91
  151. package/dist/src/lib/plan-draw.d.ts +0 -56
  152. package/dist/src/lib/plan-draw.js +0 -219
  153. package/dist/src/lib/plan-live.d.ts +0 -20
  154. package/dist/src/lib/plan-live.js +0 -192
  155. package/dist/src/lib/qr.d.ts +0 -21
  156. package/dist/src/lib/qr.js +0 -402
  157. package/dist/src/lib/roster.d.ts +0 -20
  158. package/dist/src/lib/roster.js +0 -79
  159. package/dist/src/lib/sale-card.d.ts +0 -117
  160. package/dist/src/lib/sale-card.js +0 -261
  161. package/dist/src/lib/shop-init.d.ts +0 -62
  162. package/dist/src/lib/shop-init.js +0 -63
  163. package/dist/src/lib/sui-grpc-send.d.ts +0 -90
  164. package/dist/src/lib/sui-grpc-send.js +0 -128
  165. package/dist/src/lib/swap-core.d.ts +0 -163
  166. package/dist/src/lib/swap-core.js +0 -405
  167. package/dist/src/lib/tasks-digest.d.ts +0 -66
  168. package/dist/src/lib/tasks-digest.js +0 -200
  169. package/dist/src/lib/tasks-graph.d.ts +0 -79
  170. package/dist/src/lib/tasks-graph.js +0 -463
  171. package/dist/src/lib/tasks-lens.d.ts +0 -31
  172. package/dist/src/lib/tasks-lens.js +0 -47
  173. package/dist/src/lib/tasks-next.d.ts +0 -25
  174. package/dist/src/lib/tasks-next.js +0 -103
  175. package/dist/src/lib/tasks-prove.d.ts +0 -15
  176. package/dist/src/lib/tasks-prove.js +0 -68
  177. package/dist/src/lib/tasks-route.d.ts +0 -29
  178. package/dist/src/lib/tasks-route.js +0 -151
  179. package/dist/src/lib/tasks-score.d.ts +0 -36
  180. package/dist/src/lib/tasks-score.js +0 -152
  181. package/dist/src/lib/tasks-workspace.d.ts +0 -18
  182. package/dist/src/lib/tasks-workspace.js +0 -73
  183. package/dist/src/lib/timed-fetch.d.ts +0 -33
  184. package/dist/src/lib/timed-fetch.js +0 -59
  185. package/dist/src/lib/vault-read.d.ts +0 -24
  186. package/dist/src/lib/vault-read.js +0 -77
  187. package/dist/src/lib/vaultfile.d.ts +0 -103
  188. package/dist/src/lib/vaultfile.js +0 -249
  189. package/dist/src/lib/wallet-money.d.ts +0 -222
  190. package/dist/src/lib/wallet-money.js +0 -578
  191. package/dist/src/lib/wallet-request.d.ts +0 -50
  192. package/dist/src/lib/wallet-request.js +0 -86
  193. package/dist/src/links.d.ts +0 -5
  194. package/dist/src/links.js +0 -45
  195. package/dist/src/media.d.ts +0 -29
  196. package/dist/src/media.js +0 -487
  197. package/dist/src/message-receipt.d.ts +0 -25
  198. package/dist/src/message-receipt.js +0 -71
  199. package/dist/src/message.d.ts +0 -13
  200. package/dist/src/message.js +0 -92
  201. package/dist/src/move.d.ts +0 -36
  202. package/dist/src/move.js +0 -152
  203. package/dist/src/network-cmd.d.ts +0 -17
  204. package/dist/src/network-cmd.js +0 -74
  205. package/dist/src/next.d.ts +0 -12
  206. package/dist/src/next.js +0 -67
  207. package/dist/src/onboard.d.ts +0 -16
  208. package/dist/src/onboard.js +0 -149
  209. package/dist/src/plugin.d.ts +0 -2
  210. package/dist/src/plugin.js +0 -193
  211. package/dist/src/push.d.ts +0 -2
  212. package/dist/src/push.js +0 -115
  213. package/dist/src/render.d.ts +0 -21
  214. package/dist/src/render.js +0 -32
  215. package/dist/src/secrets-device.d.ts +0 -32
  216. package/dist/src/secrets-device.js +0 -127
  217. package/dist/src/secrets-give.d.ts +0 -125
  218. package/dist/src/secrets-give.js +0 -236
  219. package/dist/src/secrets-list.d.ts +0 -27
  220. package/dist/src/secrets-list.js +0 -84
  221. package/dist/src/secrets-run.d.ts +0 -31
  222. package/dist/src/secrets-run.js +0 -182
  223. package/dist/src/secrets.d.ts +0 -33
  224. package/dist/src/secrets.js +0 -200
  225. package/dist/src/setup.d.ts +0 -6
  226. package/dist/src/setup.js +0 -127
  227. package/dist/src/ship.d.ts +0 -2
  228. package/dist/src/ship.js +0 -18
  229. package/dist/src/shop-buy.d.ts +0 -16
  230. package/dist/src/shop-buy.js +0 -101
  231. package/dist/src/shop.d.ts +0 -10
  232. package/dist/src/shop.js +0 -112
  233. package/dist/src/skill-parser.d.ts +0 -14
  234. package/dist/src/skill-parser.js +0 -113
  235. package/dist/src/skill.d.ts +0 -2
  236. package/dist/src/skill.js +0 -493
  237. package/dist/src/slug.d.ts +0 -2
  238. package/dist/src/slug.js +0 -6
  239. package/dist/src/social.d.ts +0 -2
  240. package/dist/src/social.js +0 -106
  241. package/dist/src/staff.d.ts +0 -2
  242. package/dist/src/staff.js +0 -104
  243. package/dist/src/start.d.ts +0 -27
  244. package/dist/src/start.js +0 -225
  245. package/dist/src/status.d.ts +0 -2
  246. package/dist/src/status.js +0 -52
  247. package/dist/src/substrate.d.ts +0 -2
  248. package/dist/src/substrate.js +0 -258
  249. package/dist/src/swap.d.ts +0 -93
  250. package/dist/src/swap.js +0 -622
  251. package/dist/src/tasks.d.ts +0 -2
  252. package/dist/src/tasks.js +0 -743
  253. package/dist/src/templates.d.ts +0 -1
  254. package/dist/src/templates.js +0 -213
  255. package/dist/src/thread.d.ts +0 -2
  256. package/dist/src/thread.js +0 -52
  257. package/dist/src/trade.d.ts +0 -2
  258. package/dist/src/trade.js +0 -91
  259. package/dist/src/trail.d.ts +0 -2
  260. package/dist/src/trail.js +0 -41
  261. package/dist/src/validate.d.ts +0 -13
  262. package/dist/src/validate.js +0 -35
  263. package/dist/src/wallet-money.d.ts +0 -158
  264. package/dist/src/wallet-money.js +0 -664
  265. package/dist/src/wallet.d.ts +0 -169
  266. package/dist/src/wallet.js +0 -973
  267. package/dist/src/workflow.d.ts +0 -2
  268. package/dist/src/workflow.js +0 -169
  269. package/dist/src/write.d.ts +0 -43
  270. package/dist/src/write.js +0 -180
@@ -1,113 +0,0 @@
1
- import { Command } from 'commander';
2
- import { mkdirSync, readFileSync, writeFileSync, existsSync } from 'node:fs';
3
- import { resolve, join } from 'node:path';
4
- import { spawnSync } from 'node:child_process';
5
- import { displayBanner } from './banner.js';
6
- import { maybeLaunchClaude } from './lib/launch-claude.js';
7
- import { isAgentEnvironment } from './lib/agent-env.js';
8
- const SAFE_REF = /^[A-Za-z0-9._/-]+$/;
9
- function downloadTarball(url, targetDir) {
10
- mkdirSync(targetDir, { recursive: true });
11
- // No shell — pipe curl stdout directly into tar stdin as a buffer
12
- const curl = spawnSync('curl', ['-fsSL', '--location', url], {
13
- maxBuffer: 512 * 1024 * 1024,
14
- stdio: ['ignore', 'pipe', 'inherit'],
15
- });
16
- if (curl.status !== 0 || !curl.stdout)
17
- throw new Error(`curl failed: ${url}`);
18
- const tar = spawnSync('tar', ['-xz', '--strip-components=1', '-C', targetDir], {
19
- input: curl.stdout,
20
- stdio: ['pipe', 'inherit', 'inherit'],
21
- });
22
- if (tar.status !== 0)
23
- throw new Error(`tar failed extracting to ${targetDir}`);
24
- }
25
- export function createCmd() {
26
- const cmd = new Command('create').description('Scaffold a new ONE node');
27
- // ── one create [name] ───────────────────────────────────────────────────
28
- // github.com/one-ie/one is itself one node — ai/ data/ site/ workspace.toml
29
- // at its root — so scaffolding is a plain whole-repo download, no subdir
30
- // composition. .claude/ + .mcp.json come along for free: open the scaffold
31
- // in Claude Code and it's connected from its first `git init`.
32
- cmd
33
- .command('node [name]', { isDefault: true })
34
- .description('Scaffold a ONE business node from github.com/one-ie/one — free plan, no credit card')
35
- .option('--ref <ref>', 'Git ref to download', 'main')
36
- .option('--slug <slug>', 'Workspace slug (written into workspace.toml)')
37
- .option('--name <name>', 'Display name (written into workspace.toml)')
38
- .action(async (dirName, opts) => {
39
- if (!SAFE_REF.test(opts.ref)) {
40
- process.stderr.write(`Invalid ref: ${opts.ref}\n`);
41
- process.exit(1);
42
- }
43
- const humanTTY = !isAgentEnvironment();
44
- if (humanTTY)
45
- displayBanner();
46
- const label = dirName ?? opts.slug ?? 'my-business';
47
- const dir = resolve(process.cwd(), label);
48
- if (existsSync(dir)) {
49
- process.stderr.write(`Directory already exists: ${dir}\n`);
50
- process.exit(1);
51
- }
52
- process.stdout.write(`Creating business node at ${dir}...\n`);
53
- downloadTarball(`https://api.github.com/repos/one-ie/one/tarball/${opts.ref}`, dir);
54
- const tomlPath = join(dir, 'workspace.toml');
55
- if (existsSync(tomlPath) && (opts.slug ?? opts.name)) {
56
- let toml = readFileSync(tomlPath, 'utf8');
57
- if (opts.slug)
58
- toml = toml.replace(/^slug\s*=\s*"[^"]*"/m, `slug = "${opts.slug}"`);
59
- if (opts.name)
60
- toml = toml.replace(/^name\s*=\s*"[^"]*"/m, `name = "${opts.name}"`);
61
- writeFileSync(tomlPath, toml);
62
- }
63
- process.stdout.write(`\nNode created — free plan, no credit card.\n\n`);
64
- process.stdout.write(`Next steps:\n`);
65
- process.stdout.write(` cd ${label}\n`);
66
- process.stdout.write(` bun install\n`);
67
- process.stdout.write(` cp .env.example .env.local\n`);
68
- process.stdout.write(` # Edit .env.local — set WORKSPACE_OWNER_EMAIL\n`);
69
- if (!opts.slug)
70
- process.stdout.write(` # Edit workspace.toml — set slug and name\n`);
71
- process.stdout.write(` one setup\n`);
72
- await maybeLaunchClaude(dir);
73
- });
74
- // ── one create partner [name] ────────────────────────────────────────────
75
- cmd
76
- .command('partner [name]')
77
- .description('Scaffold a new partner node from github.com/one-ie/partner')
78
- .option('--ref <ref>', 'Git ref to download', 'main')
79
- .option('--slug <slug>', 'Your partner slug (written into partner.toml)')
80
- .option('--name <name>', 'Your display name (written into partner.toml)')
81
- .action((dirName, opts) => {
82
- if (!SAFE_REF.test(opts.ref)) {
83
- process.stderr.write(`Invalid ref: ${opts.ref}\n`);
84
- process.exit(1);
85
- }
86
- const label = dirName ?? opts.slug ?? 'my-partner';
87
- const dir = resolve(process.cwd(), label);
88
- if (existsSync(dir)) {
89
- process.stderr.write(`Directory already exists: ${dir}\n`);
90
- process.exit(1);
91
- }
92
- process.stdout.write(`Creating partner node at ${dir}...\n`);
93
- downloadTarball(`https://api.github.com/repos/one-ie/partner/tarball/${opts.ref}`, dir);
94
- const tomlPath = join(dir, 'partner.toml');
95
- if (existsSync(tomlPath) && (opts.slug ?? opts.name)) {
96
- let toml = readFileSync(tomlPath, 'utf8');
97
- if (opts.slug)
98
- toml = toml.replace(/^slug\s*=\s*"[^"]*"/m, `slug = "${opts.slug}"`);
99
- if (opts.name)
100
- toml = toml.replace(/^name\s*=\s*"[^"]*"/m, `name = "${opts.name}"`);
101
- writeFileSync(tomlPath, toml);
102
- }
103
- process.stdout.write(`\nPartner node created.\n\n`);
104
- process.stdout.write(`Next steps:\n`);
105
- process.stdout.write(` cd ${label}\n`);
106
- process.stdout.write(` cp .env.example .env.local\n`);
107
- process.stdout.write(` # Edit .env.local — set ONE_API_KEY\n`);
108
- if (!opts.slug)
109
- process.stdout.write(` # Edit partner.toml — set slug and name\n`);
110
- process.stdout.write(` one setup\n`);
111
- });
112
- return cmd;
113
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * credits.ts — `one credits buy <usd>`: an agent buys ONE credits with its own coins, through
3
- * x402, with no person in the loop. The same three calls text/agent-path.md walk 8 made by hand:
4
- *
5
- * 1. quote POST /api/x402 {slug, amount} → 402 with payOptions (address + exact amount per chain)
6
- * 2. pay the vault in --dir sends EXACTLY amountAtomic to the quoted address (suiSendGrpc,
7
- * the CLI's one Sui signer). The amount identifies the quote, so it is never rounded.
8
- * 3. settle POST /api/x402 {slug, amount, tx_digest, chain} → credits granted, or a named refusal.
9
- *
10
- * The quote names the PLATFORM treasury pay verifies (Tony's key since Release 2). Dry by default:
11
- * without --live it prints the quote and signs nothing. Sui only today — pay's x402 verifies
12
- * native SUI there (USDC on Sui settles through the /credits escrow, a signed-in person's rail).
13
- */
14
- import { Command } from 'commander';
15
- interface PayOption {
16
- quoteId?: string;
17
- chain: string;
18
- asset: string;
19
- currency: string;
20
- amountExact: string;
21
- amountAtomic: string;
22
- decimals: number;
23
- address: string;
24
- expiresAt: number;
25
- }
26
- /** The one option this verb pays: Sui, native coin. Anything else is refused by name. */
27
- export declare function pickSuiOption(options: PayOption[]): PayOption | null;
28
- export declare function creditsCmd(): Command;
29
- export {};
@@ -1,88 +0,0 @@
1
- /**
2
- * credits.ts — `one credits buy <usd>`: an agent buys ONE credits with its own coins, through
3
- * x402, with no person in the loop. The same three calls text/agent-path.md walk 8 made by hand:
4
- *
5
- * 1. quote POST /api/x402 {slug, amount} → 402 with payOptions (address + exact amount per chain)
6
- * 2. pay the vault in --dir sends EXACTLY amountAtomic to the quoted address (suiSendGrpc,
7
- * the CLI's one Sui signer). The amount identifies the quote, so it is never rounded.
8
- * 3. settle POST /api/x402 {slug, amount, tx_digest, chain} → credits granted, or a named refusal.
9
- *
10
- * The quote names the PLATFORM treasury pay verifies (Tony's key since Release 2). Dry by default:
11
- * without --live it prints the quote and signs nothing. Sui only today — pay's x402 verifies
12
- * native SUI there (USDC on Sui settles through the /credits escrow, a signed-in person's rail).
13
- */
14
- import { Command } from 'commander';
15
- import { authHeaders, out, resolveBase } from './lib/client.js';
16
- import { suiSendGrpc } from './lib/sui-grpc-send.js';
17
- import { SUI_NATIVE } from './lib/wallet-money.js';
18
- import { unlock } from './wallet.js';
19
- import { netLine, resolveNet } from './lib/net-choice.js';
20
- const SUI_ADDR = /^0x[0-9a-f]{64}$/i;
21
- /** The one option this verb pays: Sui, native coin. Anything else is refused by name. */
22
- export function pickSuiOption(options) {
23
- const o = options.find((x) => x.chain === 'SUI' && x.asset === 'NATIVE');
24
- return o && SUI_ADDR.test(o.address) && /^\d+$/.test(o.amountAtomic) && BigInt(o.amountAtomic) > 0n ? o : null;
25
- }
26
- async function x402(base, body) {
27
- const res = await fetch(`${base.replace(/\/$/, '')}/api/x402`, { method: 'POST', headers: { ...authHeaders(), 'content-type': 'application/json' }, body: JSON.stringify(body) });
28
- return { status: res.status, json: (await res.json().catch(() => ({}))) };
29
- }
30
- export function creditsCmd() {
31
- const cmd = new Command('credits').description('Buy ONE credits with your own coins (x402) — the agent pays, no person in the loop');
32
- cmd.command('buy <usd>')
33
- .description('Quote, pay the exact quoted SUI from the vault in --dir, settle — credits land on --slug. Dry unless --live')
34
- .requiredOption('--slug <slug>', 'The workspace the credits land on (an agent: its own id)')
35
- .option('--dir <vault>', 'The sealed vault that pays', '.')
36
- .option('--net <network>', 'mainnet | testnet (default: ONE_NETWORK, then `one network`, then the deploy)')
37
- .option('--api <url>', 'one.ie base URL')
38
- .option('--rpc <url>', 'Sui gRPC base URL override')
39
- .option('--live', 'Pay and settle. Without it: the quote only')
40
- .action(async (usd, o, sub) => {
41
- const t0 = Date.now();
42
- const amount = Number(usd);
43
- if (!/^\d+(\.\d{1,2})?$/.test(usd) || !(amount > 0))
44
- return out(sub, { ok: false, error: 'bad_amount', detail: 'dollars, e.g. 1 or 0.50' });
45
- const nc = await resolveNet(o.net, o.api);
46
- if (!nc.ok)
47
- return out(sub, nc);
48
- const net = nc.net;
49
- const base = resolveBase({ api: o.api }, 'https://one.ie');
50
- const q = await x402(base, { slug: o.slug, amount });
51
- if (q.status !== 402 || q.json.status !== 'payment_required')
52
- return out(sub, { ok: false, error: 'no_quote', status: q.status, detail: q.json.error ?? q.json });
53
- const opt = pickSuiOption(q.json.payOptions ?? []);
54
- if (!opt)
55
- return out(sub, { ok: false, error: 'no_sui_option', chains: (q.json.payOptions ?? []).map((x) => `${x.chain}/${x.asset}`) });
56
- const quote = { usd: amount, pay: `${opt.amountExact} SUI`, to: opt.address, quoteId: opt.quoteId, expiresAt: opt.expiresAt, net, networkFrom: nc.from, says: netLine(nc) };
57
- if (!o.live)
58
- return out(sub, { ok: true, dry: true, quote, next: 'add --live to pay it from the vault in --dir and settle' });
59
- const opened = await unlock(o.dir);
60
- if ('error' in opened)
61
- return out(sub, { ok: false, error: 'vault_locked', detail: opened.error });
62
- const key = opened.keys.find((k) => k.chain === 'sui');
63
- if (!key)
64
- return out(sub, { ok: false, error: 'no_sui_key_in_vault' });
65
- let digest;
66
- let finalMs;
67
- try {
68
- const sent = await suiSendGrpc({ asset: 'SUI', coinType: SUI_NATIVE, from: key.address, to: opt.address, amountUnits: BigInt(opt.amountAtomic), privateKeyHex: key.privateKeyHex, rpc: o.rpc, net });
69
- digest = sent.digest;
70
- finalMs = sent.finalMs;
71
- }
72
- catch (e) {
73
- const err = e;
74
- return out(sub, { ok: false, error: err.code ?? 'send_failed', detail: err.message, ...(err.digest ? { digest: err.digest } : {}), quote });
75
- }
76
- // Settle. The verifier reads the chain; a just-final tx may need a moment to index.
77
- let s = { status: 0, json: {} };
78
- for (let i = 0; i < 5; i++) {
79
- s = await x402(base, { slug: o.slug, amount, tx_digest: digest, chain: 'SUI' });
80
- if (s.status === 200 || (s.status !== 402 && s.status < 500))
81
- break;
82
- await new Promise((r) => setTimeout(r, 2000));
83
- }
84
- const ok = s.status === 200;
85
- return out(sub, { ok, ...(ok ? {} : { error: 'not_settled', status: s.status }), digest, explorer: `https://suiscan.xyz/${net}/tx/${digest}`, payer: key.address, quote, settled: s.json, finalMs, wallMs: Date.now() - t0 });
86
- });
87
- return cmd;
88
- }
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function deployCmd(): Command;
@@ -1,19 +0,0 @@
1
- import { Command } from 'commander';
2
- import { spawnSync } from 'node:child_process';
3
- import { existsSync } from 'node:fs';
4
- export function deployCmd() {
5
- return new Command('deploy')
6
- .description('Deploy site/ to Cloudflare Pages via wrangler')
7
- .argument('[path]', 'Path to deploy (default: site/dist)')
8
- .option('--project <name>', 'Cloudflare Pages project name')
9
- .action((path, opts) => {
10
- const target = path ?? (existsSync('site/dist') ? 'site/dist' : 'dist');
11
- const args = ['pages', 'deploy', target];
12
- if (opts.project)
13
- args.push('--project-name', opts.project);
14
- process.stdout.write(`Deploying ${target}...\n`);
15
- const result = spawnSync('wrangler', args, { stdio: 'inherit' });
16
- if (result.status !== 0)
17
- process.exit(result.status ?? 1);
18
- });
19
- }
package/dist/src/dev.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function devCmd(): Command;
package/dist/src/dev.js DELETED
@@ -1,75 +0,0 @@
1
- import { Command } from 'commander';
2
- import { spawn } from 'node:child_process';
3
- import { existsSync, readFileSync } from 'node:fs';
4
- import { resolve } from 'node:path';
5
- export function devCmd() {
6
- const cmd = new Command('dev')
7
- .description('Run the full Cloudflare stack locally (build + migrate + wrangler dev)')
8
- .option('-p, --port <port>', 'HTTP port', '8787')
9
- .option('--ip <ip>', 'Bind address', '127.0.0.1')
10
- .option('--remote', 'Use remote bindings (real D1/KV/R2)', false)
11
- .option('--skip-build', 'Skip astro build before wrangler dev', false)
12
- .option('--skip-migrate', 'Skip D1 migrations', false)
13
- .option('--cwd <path>', 'Project directory (must contain wrangler.toml)', process.cwd())
14
- .action(async (opts) => {
15
- const cwd = resolve(opts.cwd);
16
- const wranglerToml = resolve(cwd, 'wrangler.toml');
17
- if (!existsSync(wranglerToml)) {
18
- process.stderr.write(`no wrangler.toml at ${cwd}\n`);
19
- process.exit(1);
20
- }
21
- if (opts.remote) {
22
- // Remote mode: full build → migrate → wrangler dev --remote
23
- if (!opts.skipBuild) {
24
- const built = await run('npm', ['run', 'build'], cwd);
25
- if (built !== 0)
26
- process.exit(built);
27
- }
28
- if (!opts.skipMigrate) {
29
- for (const binding of d1Bindings(wranglerToml)) {
30
- const code = await run('npx', ['wrangler', 'd1', 'migrations', 'apply', binding, '--remote'], cwd);
31
- if (code !== 0) {
32
- process.stderr.write(`d1 migrations failed for ${binding}\n`);
33
- process.exit(code);
34
- }
35
- }
36
- }
37
- const args = ['dev', '--port', opts.port, '--ip', opts.ip, '--remote'];
38
- const code = await run('npx', ['wrangler', ...args], cwd);
39
- process.exit(code);
40
- }
41
- else {
42
- // Local mode: astro dev with Vite HMR
43
- if (!opts.skipMigrate) {
44
- for (const binding of d1Bindings(wranglerToml)) {
45
- const code = await run('npx', ['wrangler', 'd1', 'migrations', 'apply', binding, '--local'], cwd);
46
- if (code !== 0) {
47
- process.stderr.write(`d1 migrations failed for ${binding}\n`);
48
- process.exit(code);
49
- }
50
- }
51
- }
52
- const code = await run('npm', ['run', 'dev'], cwd);
53
- process.exit(code);
54
- }
55
- });
56
- return cmd;
57
- }
58
- function d1Bindings(wranglerToml) {
59
- const text = readFileSync(wranglerToml, 'utf8');
60
- const blocks = text.match(/\[\[d1_databases\]\][^[]*/g) ?? [];
61
- const bindings = [];
62
- for (const block of blocks) {
63
- const m = block.match(/binding\s*=\s*["']([^"']+)["']/);
64
- if (m)
65
- bindings.push(m[1]);
66
- }
67
- return bindings;
68
- }
69
- function run(bin, args, cwd) {
70
- return new Promise(resolveP => {
71
- const child = spawn(bin, args, { cwd, stdio: 'inherit', env: process.env });
72
- child.on('exit', code => resolveP(code ?? 0));
73
- child.on('error', err => { process.stderr.write(`${err.message}\n`); resolveP(1); });
74
- });
75
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * device-flow.ts — RFC 8628 device-authorization-grant primitives
3
- *
4
- * Pure functions. auth.ts orchestrates; this module only does I/O
5
- * against the network + browser open. No Commander, no key-write here.
6
- */
7
- export interface DeviceCodeResponse {
8
- device_code: string;
9
- user_code: string;
10
- verification_uri: string;
11
- expires_in: number;
12
- interval: number;
13
- }
14
- export interface TokenResponse {
15
- access_token: string;
16
- token_type: string;
17
- expires_in?: number;
18
- refresh_token?: string;
19
- scope?: string;
20
- userId?: string;
21
- }
22
- /** Returned by pollForToken when still waiting */
23
- export interface PollPending {
24
- status: 'pending' | 'slow_down';
25
- }
26
- /** Returned by pollForToken on success */
27
- export interface PollSuccess {
28
- status: 'success';
29
- token: TokenResponse;
30
- }
31
- /** Returned by pollForToken on terminal error */
32
- export interface PollError {
33
- status: 'error';
34
- code: string;
35
- message: string;
36
- }
37
- export type PollResult = PollPending | PollSuccess | PollError;
38
- export declare function requestDeviceCode(base: string, clientId: string, scope: string): Promise<DeviceCodeResponse>;
39
- /**
40
- * Open `url` in the default browser.
41
- * Tries `open` package first; falls back to platform child_process.execSync.
42
- */
43
- export declare function openBrowser(url: string): Promise<void>;
44
- /**
45
- * Poll until token, expiry, or terminal error.
46
- *
47
- * Respects server `interval` (RFC 8628 §3.5).
48
- * Backs off on `slow_down` by doubling interval (minimum +5 s per RFC).
49
- *
50
- * @param base API base URL (e.g. https://one.ie)
51
- * @param clientId OAuth client_id
52
- * @param deviceCode device_code from requestDeviceCode
53
- * @param intervalSec initial polling interval from server
54
- * @param expiresIn seconds until device_code expires
55
- * @returns TokenResponse on success, throws on failure/expiry
56
- */
57
- export declare function pollForToken(base: string, clientId: string, deviceCode: string, intervalSec: number, expiresIn: number): Promise<TokenResponse>;
@@ -1,173 +0,0 @@
1
- /**
2
- * device-flow.ts — RFC 8628 device-authorization-grant primitives
3
- *
4
- * Pure functions. auth.ts orchestrates; this module only does I/O
5
- * against the network + browser open. No Commander, no key-write here.
6
- */
7
- import { execSync } from 'node:child_process';
8
- // ---------------------------------------------------------------------------
9
- // Step (a): Request device code
10
- // ---------------------------------------------------------------------------
11
- export async function requestDeviceCode(base, clientId, scope) {
12
- const url = `${base}/api/auth/mcp/device/code`;
13
- const res = await fetch(url, {
14
- method: 'POST',
15
- headers: { 'Content-Type': 'application/json' },
16
- body: JSON.stringify({ client_id: clientId, scope }),
17
- });
18
- if (!res.ok) {
19
- let detail = '';
20
- try {
21
- detail = await res.text();
22
- }
23
- catch { /* ignore */ }
24
- throw new Error(`device-code request failed ${res.status}: ${detail}`);
25
- }
26
- const data = (await res.json());
27
- if (!data.device_code || !data.user_code || !data.verification_uri) {
28
- throw new Error('Malformed device-code response from server');
29
- }
30
- return data;
31
- }
32
- // ---------------------------------------------------------------------------
33
- // Step (b): Open browser
34
- // ---------------------------------------------------------------------------
35
- /**
36
- * Open `url` in the default browser.
37
- * Tries `open` package first; falls back to platform child_process.execSync.
38
- */
39
- export async function openBrowser(url) {
40
- // Attempt dynamic import of `open` package (optional dep)
41
- try {
42
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
- const mod = await import('open');
44
- const openFn = mod.default ?? mod;
45
- if (typeof openFn === 'function') {
46
- await openFn(url);
47
- return;
48
- }
49
- }
50
- catch {
51
- // `open` not installed — fall back to child_process
52
- }
53
- const platform = process.platform;
54
- let cmd;
55
- if (platform === 'darwin') {
56
- cmd = 'open';
57
- }
58
- else if (platform === 'win32') {
59
- cmd = 'start';
60
- }
61
- else {
62
- cmd = 'xdg-open';
63
- }
64
- try {
65
- execSync(`${cmd} "${url}"`, { stdio: 'ignore' });
66
- }
67
- catch (err) {
68
- // Non-fatal: user can open manually
69
- if (process.env.DEBUG) {
70
- process.stderr.write(`browser open failed: ${err.message}\n`);
71
- }
72
- }
73
- }
74
- // ---------------------------------------------------------------------------
75
- // Step (c): Poll for token
76
- // ---------------------------------------------------------------------------
77
- /**
78
- * Single poll attempt against `/api/auth/mcp/device/token`.
79
- * Returns a PollResult discriminated union.
80
- */
81
- async function pollOnce(base, clientId, deviceCode) {
82
- const url = `${base}/api/auth/mcp/device/token`;
83
- let res;
84
- try {
85
- res = await fetch(url, {
86
- method: 'POST',
87
- headers: { 'Content-Type': 'application/json' },
88
- body: JSON.stringify({ device_code: deviceCode, client_id: clientId }),
89
- });
90
- }
91
- catch (err) {
92
- return { status: 'error', code: 'network_error', message: err.message };
93
- }
94
- // 200 = success
95
- if (res.ok) {
96
- const token = (await res.json());
97
- if (!token.access_token) {
98
- return { status: 'error', code: 'invalid_response', message: 'access_token missing' };
99
- }
100
- return { status: 'success', token };
101
- }
102
- // OAuth error body
103
- let body = {};
104
- try {
105
- body = (await res.json());
106
- }
107
- catch { /* ignore */ }
108
- const code = body.error ?? 'unknown';
109
- switch (code) {
110
- case 'authorization_pending':
111
- return { status: 'pending' };
112
- case 'slow_down':
113
- return { status: 'slow_down' };
114
- case 'expired_token':
115
- case 'access_denied':
116
- case 'invalid_grant':
117
- case 'invalid_client':
118
- return {
119
- status: 'error',
120
- code,
121
- message: body.error_description ?? code,
122
- };
123
- default:
124
- return {
125
- status: 'error',
126
- code,
127
- message: body.error_description ?? `HTTP ${res.status}`,
128
- };
129
- }
130
- }
131
- /**
132
- * Poll until token, expiry, or terminal error.
133
- *
134
- * Respects server `interval` (RFC 8628 §3.5).
135
- * Backs off on `slow_down` by doubling interval (minimum +5 s per RFC).
136
- *
137
- * @param base API base URL (e.g. https://one.ie)
138
- * @param clientId OAuth client_id
139
- * @param deviceCode device_code from requestDeviceCode
140
- * @param intervalSec initial polling interval from server
141
- * @param expiresIn seconds until device_code expires
142
- * @returns TokenResponse on success, throws on failure/expiry
143
- */
144
- export async function pollForToken(base, clientId, deviceCode, intervalSec, expiresIn) {
145
- const deadline = Date.now() + expiresIn * 1000;
146
- let currentInterval = Math.max(intervalSec, 5); // never below 5 s
147
- while (Date.now() < deadline) {
148
- await sleep(currentInterval * 1000);
149
- const result = await pollOnce(base, clientId, deviceCode);
150
- if (result.status === 'success') {
151
- return result.token;
152
- }
153
- if (result.status === 'slow_down') {
154
- // RFC 8628 §3.5: increase interval by 5 s minimum
155
- currentInterval += 5;
156
- continue;
157
- }
158
- if (result.status === 'pending') {
159
- continue;
160
- }
161
- // Terminal error — narrow off the discriminant so code/message are present
162
- if (result.status === 'error') {
163
- throw new Error(`auth failed [${result.code}]: ${result.message}`);
164
- }
165
- }
166
- throw new Error('Device code expired. Run `oneie auth login` to try again.');
167
- }
168
- // ---------------------------------------------------------------------------
169
- // Internal helpers
170
- // ---------------------------------------------------------------------------
171
- function sleep(ms) {
172
- return new Promise((resolve) => setTimeout(resolve, ms));
173
- }
@@ -1,26 +0,0 @@
1
- import { Command } from 'commander';
2
- /** api.one.ie (the gateway) answers `GET /health`; one.ie/web has no /health
3
- * route, so a HEAD / 200 is the reachability signal there — same host split
4
- * askPath() already makes for /ask. */
5
- export declare function isGatewayHost(base: string): boolean;
6
- export declare function checkReachability(base: string, timeoutMs?: number): Promise<{
7
- ok: boolean;
8
- ms: number;
9
- }>;
10
- export interface DoctorCheck {
11
- name: string;
12
- ok: boolean;
13
- detail: string;
14
- }
15
- export interface DoctorResult {
16
- ok: boolean;
17
- checks: DoctorCheck[];
18
- }
19
- export declare function runDoctor(dir: string, opts?: {
20
- api?: string;
21
- keyFile?: string;
22
- }): Promise<DoctorResult>;
23
- /** No `auth:whoami` receiver exists — an authenticated `dashboard:usage` call
24
- * proves the key is live, alongside the env echo. */
25
- export declare function whoamiCmd(): Command;
26
- export declare function doctorCmd(): Command;