@oneie/cli 5.7.6 → 5.8.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 (245) hide show
  1. package/README.md +19 -1
  2. package/dist/package.json +7 -8
  3. package/dist/src/age-yefbe8pe.js +1 -0
  4. package/dist/src/evm-tx-ee2q0e3w.js +1 -0
  5. package/dist/src/hl-run-tgrkrk69.js +1 -0
  6. package/dist/src/index-0rj9wdk9.js +4 -0
  7. package/dist/src/index-91y484c2.js +2052 -0
  8. package/dist/src/index-940y3rnv.js +12 -0
  9. package/dist/src/index.js +1047 -121
  10. package/dist/src/message-key-db1xjdkw.js +1 -0
  11. package/dist/src/message-lock-5vr8079x.js +5 -0
  12. package/dist/src/sweep-order-c2p6rk8c.js +1 -0
  13. package/dist/src/sweep-runner-t68xe7vx.js +1 -0
  14. package/package.json +7 -8
  15. package/dist/src/agent.d.ts +0 -75
  16. package/dist/src/agent.js +0 -1334
  17. package/dist/src/agentverse.d.ts +0 -26
  18. package/dist/src/agentverse.js +0 -171
  19. package/dist/src/args.d.ts +0 -9
  20. package/dist/src/args.js +0 -61
  21. package/dist/src/auth.d.ts +0 -6
  22. package/dist/src/auth.js +0 -121
  23. package/dist/src/balances.d.ts +0 -89
  24. package/dist/src/balances.js +0 -202
  25. package/dist/src/banner.d.ts +0 -1
  26. package/dist/src/banner.js +0 -17
  27. package/dist/src/broadcast.d.ts +0 -8
  28. package/dist/src/broadcast.js +0 -175
  29. package/dist/src/catalog.d.ts +0 -12
  30. package/dist/src/catalog.js +0 -76
  31. package/dist/src/chat.d.ts +0 -2
  32. package/dist/src/chat.js +0 -92
  33. package/dist/src/client.d.ts +0 -5
  34. package/dist/src/client.js +0 -157
  35. package/dist/src/compiler.d.ts +0 -36
  36. package/dist/src/compiler.js +0 -366
  37. package/dist/src/config.d.ts +0 -24
  38. package/dist/src/config.js +0 -70
  39. package/dist/src/connect.d.ts +0 -2
  40. package/dist/src/connect.js +0 -64
  41. package/dist/src/coordinate.d.ts +0 -3
  42. package/dist/src/coordinate.js +0 -58
  43. package/dist/src/create.d.ts +0 -2
  44. package/dist/src/create.js +0 -113
  45. package/dist/src/deploy.d.ts +0 -2
  46. package/dist/src/deploy.js +0 -19
  47. package/dist/src/dev.d.ts +0 -2
  48. package/dist/src/dev.js +0 -75
  49. package/dist/src/device-flow.d.ts +0 -57
  50. package/dist/src/device-flow.js +0 -173
  51. package/dist/src/doctor.d.ts +0 -26
  52. package/dist/src/doctor.js +0 -146
  53. package/dist/src/draw.d.ts +0 -18
  54. package/dist/src/draw.js +0 -156
  55. package/dist/src/endpoint.d.ts +0 -2
  56. package/dist/src/endpoint.js +0 -250
  57. package/dist/src/env.d.ts +0 -3
  58. package/dist/src/env.js +0 -37
  59. package/dist/src/eval.d.ts +0 -2
  60. package/dist/src/eval.js +0 -43
  61. package/dist/src/fn.d.ts +0 -2
  62. package/dist/src/fn.js +0 -70
  63. package/dist/src/group.d.ts +0 -2
  64. package/dist/src/group.js +0 -117
  65. package/dist/src/hl-run.d.ts +0 -119
  66. package/dist/src/hl-run.js +0 -480
  67. package/dist/src/hl.d.ts +0 -17
  68. package/dist/src/hl.js +0 -148
  69. package/dist/src/index.d.ts +0 -2
  70. package/dist/src/init.d.ts +0 -76
  71. package/dist/src/init.js +0 -278
  72. package/dist/src/join.d.ts +0 -11
  73. package/dist/src/join.js +0 -293
  74. package/dist/src/key-publish.d.ts +0 -40
  75. package/dist/src/key-publish.js +0 -232
  76. package/dist/src/key-seal.d.ts +0 -21
  77. package/dist/src/key-seal.js +0 -142
  78. package/dist/src/key-sweep.d.ts +0 -93
  79. package/dist/src/key-sweep.js +0 -263
  80. package/dist/src/key.d.ts +0 -26
  81. package/dist/src/key.js +0 -338
  82. package/dist/src/lib/age-plugin.d.ts +0 -51
  83. package/dist/src/lib/age-plugin.js +0 -130
  84. package/dist/src/lib/agent-env.d.ts +0 -12
  85. package/dist/src/lib/agent-env.js +0 -48
  86. package/dist/src/lib/api-path.d.ts +0 -2
  87. package/dist/src/lib/api-path.js +0 -40
  88. package/dist/src/lib/asker.d.ts +0 -34
  89. package/dist/src/lib/asker.js +0 -126
  90. package/dist/src/lib/client.d.ts +0 -20
  91. package/dist/src/lib/client.js +0 -71
  92. package/dist/src/lib/env-sealed.d.ts +0 -53
  93. package/dist/src/lib/env-sealed.js +0 -184
  94. package/dist/src/lib/flow-tag.d.ts +0 -86
  95. package/dist/src/lib/flow-tag.js +0 -230
  96. package/dist/src/lib/hl-core/actions.d.ts +0 -99
  97. package/dist/src/lib/hl-core/actions.js +0 -69
  98. package/dist/src/lib/hl-core/eip712.d.ts +0 -33
  99. package/dist/src/lib/hl-core/eip712.js +0 -107
  100. package/dist/src/lib/hl-core/errors.d.ts +0 -10
  101. package/dist/src/lib/hl-core/errors.js +0 -15
  102. package/dist/src/lib/hl-core/exchange.d.ts +0 -24
  103. package/dist/src/lib/hl-core/exchange.js +0 -47
  104. package/dist/src/lib/hl-core/index.d.ts +0 -13
  105. package/dist/src/lib/hl-core/index.js +0 -14
  106. package/dist/src/lib/hl-core/meta.d.ts +0 -57
  107. package/dist/src/lib/hl-core/meta.js +0 -110
  108. package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
  109. package/dist/src/lib/hl-core/msgpack.js +0 -136
  110. package/dist/src/lib/hl-core/net.d.ts +0 -2
  111. package/dist/src/lib/hl-core/net.js +0 -7
  112. package/dist/src/lib/hl-core/signing.d.ts +0 -103
  113. package/dist/src/lib/hl-core/signing.js +0 -295
  114. package/dist/src/lib/hl-core/wire.d.ts +0 -34
  115. package/dist/src/lib/hl-core/wire.js +0 -81
  116. package/dist/src/lib/invoked-as.d.ts +0 -2
  117. package/dist/src/lib/invoked-as.js +0 -24
  118. package/dist/src/lib/journey-words.d.ts +0 -84
  119. package/dist/src/lib/journey-words.js +0 -360
  120. package/dist/src/lib/journey.d.ts +0 -148
  121. package/dist/src/lib/journey.js +0 -245
  122. package/dist/src/lib/key-receipt.d.ts +0 -48
  123. package/dist/src/lib/key-receipt.js +0 -116
  124. package/dist/src/lib/key-source.d.ts +0 -9
  125. package/dist/src/lib/key-source.js +0 -33
  126. package/dist/src/lib/keyfile.d.ts +0 -136
  127. package/dist/src/lib/keyfile.js +0 -397
  128. package/dist/src/lib/launch-claude.d.ts +0 -5
  129. package/dist/src/lib/launch-claude.js +0 -45
  130. package/dist/src/lib/lock-lookup.d.ts +0 -40
  131. package/dist/src/lib/lock-lookup.js +0 -92
  132. package/dist/src/lib/message-seal.d.ts +0 -63
  133. package/dist/src/lib/message-seal.js +0 -150
  134. package/dist/src/lib/network.d.ts +0 -15
  135. package/dist/src/lib/network.js +0 -41
  136. package/dist/src/lib/paths.d.ts +0 -41
  137. package/dist/src/lib/paths.js +0 -91
  138. package/dist/src/lib/plan-draw.d.ts +0 -56
  139. package/dist/src/lib/plan-draw.js +0 -219
  140. package/dist/src/lib/plan-live.d.ts +0 -20
  141. package/dist/src/lib/plan-live.js +0 -192
  142. package/dist/src/lib/qr.d.ts +0 -21
  143. package/dist/src/lib/qr.js +0 -402
  144. package/dist/src/lib/roster.d.ts +0 -20
  145. package/dist/src/lib/roster.js +0 -79
  146. package/dist/src/lib/sale-card.d.ts +0 -117
  147. package/dist/src/lib/sale-card.js +0 -261
  148. package/dist/src/lib/shop-init.d.ts +0 -62
  149. package/dist/src/lib/shop-init.js +0 -63
  150. package/dist/src/lib/sui-grpc-send.d.ts +0 -50
  151. package/dist/src/lib/sui-grpc-send.js +0 -89
  152. package/dist/src/lib/swap-core.d.ts +0 -163
  153. package/dist/src/lib/swap-core.js +0 -405
  154. package/dist/src/lib/tasks-digest.d.ts +0 -66
  155. package/dist/src/lib/tasks-digest.js +0 -200
  156. package/dist/src/lib/tasks-graph.d.ts +0 -79
  157. package/dist/src/lib/tasks-graph.js +0 -463
  158. package/dist/src/lib/tasks-lens.d.ts +0 -31
  159. package/dist/src/lib/tasks-lens.js +0 -47
  160. package/dist/src/lib/tasks-next.d.ts +0 -25
  161. package/dist/src/lib/tasks-next.js +0 -103
  162. package/dist/src/lib/tasks-prove.d.ts +0 -15
  163. package/dist/src/lib/tasks-prove.js +0 -68
  164. package/dist/src/lib/tasks-route.d.ts +0 -29
  165. package/dist/src/lib/tasks-route.js +0 -151
  166. package/dist/src/lib/tasks-score.d.ts +0 -36
  167. package/dist/src/lib/tasks-score.js +0 -152
  168. package/dist/src/lib/tasks-workspace.d.ts +0 -18
  169. package/dist/src/lib/tasks-workspace.js +0 -73
  170. package/dist/src/lib/vault-read.d.ts +0 -24
  171. package/dist/src/lib/vault-read.js +0 -77
  172. package/dist/src/lib/vaultfile.d.ts +0 -88
  173. package/dist/src/lib/vaultfile.js +0 -222
  174. package/dist/src/lib/wallet-money.d.ts +0 -222
  175. package/dist/src/lib/wallet-money.js +0 -578
  176. package/dist/src/lib/wallet-request.d.ts +0 -50
  177. package/dist/src/lib/wallet-request.js +0 -86
  178. package/dist/src/links.d.ts +0 -5
  179. package/dist/src/links.js +0 -45
  180. package/dist/src/media.d.ts +0 -29
  181. package/dist/src/media.js +0 -487
  182. package/dist/src/message-receipt.d.ts +0 -25
  183. package/dist/src/message-receipt.js +0 -71
  184. package/dist/src/message.d.ts +0 -13
  185. package/dist/src/message.js +0 -92
  186. package/dist/src/onboard.d.ts +0 -16
  187. package/dist/src/onboard.js +0 -149
  188. package/dist/src/plugin.d.ts +0 -2
  189. package/dist/src/plugin.js +0 -193
  190. package/dist/src/push.d.ts +0 -2
  191. package/dist/src/push.js +0 -115
  192. package/dist/src/render.d.ts +0 -21
  193. package/dist/src/render.js +0 -32
  194. package/dist/src/secrets-device.d.ts +0 -32
  195. package/dist/src/secrets-device.js +0 -127
  196. package/dist/src/secrets-give.d.ts +0 -125
  197. package/dist/src/secrets-give.js +0 -236
  198. package/dist/src/secrets-list.d.ts +0 -27
  199. package/dist/src/secrets-list.js +0 -84
  200. package/dist/src/secrets-run.d.ts +0 -31
  201. package/dist/src/secrets-run.js +0 -182
  202. package/dist/src/secrets.d.ts +0 -33
  203. package/dist/src/secrets.js +0 -200
  204. package/dist/src/setup.d.ts +0 -6
  205. package/dist/src/setup.js +0 -127
  206. package/dist/src/ship.d.ts +0 -2
  207. package/dist/src/ship.js +0 -18
  208. package/dist/src/shop.d.ts +0 -10
  209. package/dist/src/shop.js +0 -110
  210. package/dist/src/skill-parser.d.ts +0 -14
  211. package/dist/src/skill-parser.js +0 -113
  212. package/dist/src/skill.d.ts +0 -2
  213. package/dist/src/skill.js +0 -493
  214. package/dist/src/slug.d.ts +0 -2
  215. package/dist/src/slug.js +0 -6
  216. package/dist/src/social.d.ts +0 -2
  217. package/dist/src/social.js +0 -106
  218. package/dist/src/staff.d.ts +0 -2
  219. package/dist/src/staff.js +0 -104
  220. package/dist/src/start.d.ts +0 -15
  221. package/dist/src/start.js +0 -203
  222. package/dist/src/status.d.ts +0 -2
  223. package/dist/src/status.js +0 -52
  224. package/dist/src/substrate.d.ts +0 -2
  225. package/dist/src/substrate.js +0 -258
  226. package/dist/src/swap.d.ts +0 -93
  227. package/dist/src/swap.js +0 -622
  228. package/dist/src/tasks.d.ts +0 -2
  229. package/dist/src/tasks.js +0 -743
  230. package/dist/src/templates.d.ts +0 -1
  231. package/dist/src/templates.js +0 -213
  232. package/dist/src/trade.d.ts +0 -2
  233. package/dist/src/trade.js +0 -91
  234. package/dist/src/trail.d.ts +0 -2
  235. package/dist/src/trail.js +0 -41
  236. package/dist/src/validate.d.ts +0 -13
  237. package/dist/src/validate.js +0 -35
  238. package/dist/src/wallet-money.d.ts +0 -152
  239. package/dist/src/wallet-money.js +0 -564
  240. package/dist/src/wallet.d.ts +0 -167
  241. package/dist/src/wallet.js +0 -855
  242. package/dist/src/workflow.d.ts +0 -2
  243. package/dist/src/workflow.js +0 -166
  244. package/dist/src/write.d.ts +0 -43
  245. package/dist/src/write.js +0 -180
@@ -1,64 +0,0 @@
1
- import { Command } from 'commander';
2
- import { out, resolveBase, resolveKey } from './lib/client.js';
3
- const DEFAULT_API = resolveBase({}, 'https://one.ie');
4
- function readApiKey() {
5
- const key = resolveKey();
6
- return key || null;
7
- }
8
- // `one connect <channel> --token <t>` — token-paste connect. The CLI never
9
- // implements getMe/setWebhook; it POSTs to the web /api/connect/<channel> route
10
- // which verifies + hands the secret to channels' sealed sink. The token is sent
11
- // once in the request body and is NEVER echoed back to stdout (out() prints
12
- // only the route's response, which carries status + public handle, no secret).
13
- // With no channel argument it lists connection status (GET /api/connect/status).
14
- export function connectCmd() {
15
- const cmd = new Command('connect').description('Connect a channel to your workspace, or list connected channels with no argument');
16
- cmd
17
- .argument('[channel]', 'Channel to connect (telegram); omit to list status')
18
- .option('--token <token>', 'Channel credential (e.g. @BotFather bot token)')
19
- .option('--slug <slug>', 'Workspace slug (defaults to the authenticated owner)')
20
- .option('--api <url>', 'API base URL', DEFAULT_API)
21
- .action(async (channel, opts) => {
22
- const key = readApiKey();
23
- if (!key) {
24
- out(cmd, { ok: false, error: 'no API key — run: oneie auth login' });
25
- return;
26
- }
27
- const base = opts.api.replace(/\/$/, '');
28
- if (!channel) {
29
- // status listing — read-only, never carries credentials either way
30
- const res = await fetch(`${base}/api/connect/status`, {
31
- headers: { Authorization: `Bearer ${key}` },
32
- });
33
- if (!res.ok) {
34
- const data = (await res.json().catch(() => ({})));
35
- out(cmd, { ok: false, error: `${res.status}: ${data.error ?? 'status failed'}` });
36
- return;
37
- }
38
- const data = (await res.json());
39
- const connections = data.connections ?? [];
40
- out(cmd, { ok: true, connected: connections.length, connections });
41
- return;
42
- }
43
- if (!opts.token) {
44
- out(cmd, { ok: false, error: 'token required — e.g. one connect telegram --token <t>' });
45
- return;
46
- }
47
- const body = { token: opts.token };
48
- if (opts.slug)
49
- body.slug = opts.slug;
50
- const res = await fetch(`${base}/api/connect/${encodeURIComponent(channel)}`, {
51
- method: 'POST',
52
- headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key}` },
53
- body: JSON.stringify(body),
54
- });
55
- if (!res.ok) {
56
- const data = (await res.json().catch(() => ({})));
57
- out(cmd, { ok: false, error: `${res.status}: ${data.error ?? 'connect failed'}` });
58
- return;
59
- }
60
- const data = (await res.json());
61
- out(cmd, { ok: true, channel, status: data.status ?? 'active', account: data.username ?? data.inbound });
62
- });
63
- return cmd;
64
- }
@@ -1,3 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const REPUTATION_PENDING: string;
3
- export declare function coordinateCommands(program: Command): void;
@@ -1,58 +0,0 @@
1
- import { askPath } from './lib/api-path.js';
2
- const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
3
- function apiKey() {
4
- return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
5
- }
6
- function base(opts) {
7
- return (opts.api ?? DEFAULT_API).replace(/\/$/, '');
8
- }
9
- function authHeaders() {
10
- const h = { 'Content-Type': 'application/json' };
11
- const k = apiKey();
12
- if (k)
13
- h['Authorization'] = `Bearer ${k}`;
14
- return h;
15
- }
16
- export const REPUTATION_PENDING = 'reputation: pending — meta:reputation is not yet shipped (agent-first follow-on).\n' +
17
- ' Standing lives in TypeDB paths; until the receiver lands, one shows no score (no stub).';
18
- function formatRecall(out) {
19
- const hyps = (out?.hypotheses ?? []);
20
- if (!hyps.length)
21
- return ' (no memory yet — recall returns what this caller has learned)';
22
- return hyps.map((h) => ` · [${h.status}] ${h.claim}${h.confidence != null ? ` (${h.confidence})` : ''}`).join('\n');
23
- }
24
- export function coordinateCommands(program) {
25
- program
26
- .command('recall')
27
- .description('Read cross-session memory (meta:recall)')
28
- .option('--about <term>', 'Filter by keyword')
29
- .option('--limit <n>', 'Max results', '20')
30
- .option('--api <url>', 'API base URL', DEFAULT_API)
31
- .option('--json', 'Output raw JSON')
32
- .action(async (opts) => {
33
- const payload = { limit: Number(opts.limit) };
34
- if (opts.about)
35
- payload.match = opts.about;
36
- const res = await fetch(askPath(base(opts), 'meta:recall'), {
37
- method: 'POST',
38
- headers: authHeaders(),
39
- body: JSON.stringify({ data: payload }),
40
- });
41
- if (!res.ok) {
42
- process.stderr.write(`meta:recall → ${res.status}\n`);
43
- process.exit(1);
44
- }
45
- const data = await res.json();
46
- if (opts.json) {
47
- process.stdout.write(JSON.stringify(data, null, 2) + '\n');
48
- return;
49
- }
50
- process.stdout.write(formatRecall(data) + '\n');
51
- });
52
- program
53
- .command('reputation')
54
- .description('Agent reputation standing (pending)')
55
- .action(() => {
56
- process.stdout.write(REPUTATION_PENDING + '\n');
57
- });
58
- }
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function createCmd(): Command;
@@ -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,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;