oneie 5.8.0 → 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 (268) hide show
  1. package/dist/package.json +7 -8
  2. package/dist/src/age-yefbe8pe.js +1 -0
  3. package/dist/src/evm-tx-ee2q0e3w.js +1 -0
  4. package/dist/src/hl-run-tgrkrk69.js +1 -0
  5. package/dist/src/index-0rj9wdk9.js +4 -0
  6. package/dist/src/index-91y484c2.js +2052 -0
  7. package/dist/src/index-940y3rnv.js +12 -0
  8. package/dist/src/index.js +1047 -134
  9. package/dist/src/message-key-db1xjdkw.js +1 -0
  10. package/dist/src/message-lock-5vr8079x.js +5 -0
  11. package/dist/src/sweep-order-c2p6rk8c.js +1 -0
  12. package/dist/src/sweep-runner-t68xe7vx.js +1 -0
  13. package/package.json +7 -8
  14. package/dist/src/agent.d.ts +0 -75
  15. package/dist/src/agent.js +0 -1334
  16. package/dist/src/agentverse.d.ts +0 -26
  17. package/dist/src/agentverse.js +0 -171
  18. package/dist/src/args.d.ts +0 -9
  19. package/dist/src/args.js +0 -61
  20. package/dist/src/auth.d.ts +0 -6
  21. package/dist/src/auth.js +0 -121
  22. package/dist/src/balances.d.ts +0 -89
  23. package/dist/src/balances.js +0 -202
  24. package/dist/src/banner.d.ts +0 -1
  25. package/dist/src/banner.js +0 -17
  26. package/dist/src/broadcast.d.ts +0 -8
  27. package/dist/src/broadcast.js +0 -175
  28. package/dist/src/catalog.d.ts +0 -12
  29. package/dist/src/catalog.js +0 -76
  30. package/dist/src/ceiling.d.ts +0 -36
  31. package/dist/src/ceiling.js +0 -189
  32. package/dist/src/chat.d.ts +0 -2
  33. package/dist/src/chat.js +0 -92
  34. package/dist/src/check.d.ts +0 -11
  35. package/dist/src/check.js +0 -53
  36. package/dist/src/client.d.ts +0 -5
  37. package/dist/src/client.js +0 -157
  38. package/dist/src/compiler.d.ts +0 -36
  39. package/dist/src/compiler.js +0 -366
  40. package/dist/src/config.d.ts +0 -24
  41. package/dist/src/config.js +0 -70
  42. package/dist/src/connect.d.ts +0 -2
  43. package/dist/src/connect.js +0 -64
  44. package/dist/src/coordinate.d.ts +0 -3
  45. package/dist/src/coordinate.js +0 -58
  46. package/dist/src/create.d.ts +0 -2
  47. package/dist/src/create.js +0 -113
  48. package/dist/src/credits.d.ts +0 -29
  49. package/dist/src/credits.js +0 -88
  50. package/dist/src/deploy.d.ts +0 -2
  51. package/dist/src/deploy.js +0 -19
  52. package/dist/src/dev.d.ts +0 -2
  53. package/dist/src/dev.js +0 -75
  54. package/dist/src/device-flow.d.ts +0 -57
  55. package/dist/src/device-flow.js +0 -173
  56. package/dist/src/doctor.d.ts +0 -26
  57. package/dist/src/doctor.js +0 -146
  58. package/dist/src/draw.d.ts +0 -18
  59. package/dist/src/draw.js +0 -156
  60. package/dist/src/endpoint.d.ts +0 -2
  61. package/dist/src/endpoint.js +0 -250
  62. package/dist/src/env.d.ts +0 -3
  63. package/dist/src/env.js +0 -37
  64. package/dist/src/eval.d.ts +0 -2
  65. package/dist/src/eval.js +0 -43
  66. package/dist/src/fn.d.ts +0 -2
  67. package/dist/src/fn.js +0 -70
  68. package/dist/src/group.d.ts +0 -2
  69. package/dist/src/group.js +0 -117
  70. package/dist/src/hl-run.d.ts +0 -119
  71. package/dist/src/hl-run.js +0 -480
  72. package/dist/src/hl.d.ts +0 -17
  73. package/dist/src/hl.js +0 -148
  74. package/dist/src/index.d.ts +0 -2
  75. package/dist/src/init.d.ts +0 -76
  76. package/dist/src/init.js +0 -278
  77. package/dist/src/join.d.ts +0 -11
  78. package/dist/src/join.js +0 -297
  79. package/dist/src/key-publish.d.ts +0 -40
  80. package/dist/src/key-publish.js +0 -232
  81. package/dist/src/key-seal.d.ts +0 -21
  82. package/dist/src/key-seal.js +0 -142
  83. package/dist/src/key-sweep.d.ts +0 -93
  84. package/dist/src/key-sweep.js +0 -270
  85. package/dist/src/key.d.ts +0 -26
  86. package/dist/src/key.js +0 -338
  87. package/dist/src/lib/age-plugin.d.ts +0 -51
  88. package/dist/src/lib/age-plugin.js +0 -130
  89. package/dist/src/lib/agent-env.d.ts +0 -12
  90. package/dist/src/lib/agent-env.js +0 -48
  91. package/dist/src/lib/api-path.d.ts +0 -2
  92. package/dist/src/lib/api-path.js +0 -40
  93. package/dist/src/lib/asker.d.ts +0 -34
  94. package/dist/src/lib/asker.js +0 -126
  95. package/dist/src/lib/check-words.d.ts +0 -57
  96. package/dist/src/lib/check-words.js +0 -144
  97. package/dist/src/lib/client.d.ts +0 -20
  98. package/dist/src/lib/client.js +0 -71
  99. package/dist/src/lib/env-sealed.d.ts +0 -53
  100. package/dist/src/lib/env-sealed.js +0 -184
  101. package/dist/src/lib/flow-tag.d.ts +0 -86
  102. package/dist/src/lib/flow-tag.js +0 -230
  103. package/dist/src/lib/hl-core/actions.d.ts +0 -99
  104. package/dist/src/lib/hl-core/actions.js +0 -69
  105. package/dist/src/lib/hl-core/eip712.d.ts +0 -33
  106. package/dist/src/lib/hl-core/eip712.js +0 -107
  107. package/dist/src/lib/hl-core/errors.d.ts +0 -10
  108. package/dist/src/lib/hl-core/errors.js +0 -15
  109. package/dist/src/lib/hl-core/exchange.d.ts +0 -24
  110. package/dist/src/lib/hl-core/exchange.js +0 -47
  111. package/dist/src/lib/hl-core/index.d.ts +0 -13
  112. package/dist/src/lib/hl-core/index.js +0 -14
  113. package/dist/src/lib/hl-core/meta.d.ts +0 -57
  114. package/dist/src/lib/hl-core/meta.js +0 -110
  115. package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
  116. package/dist/src/lib/hl-core/msgpack.js +0 -136
  117. package/dist/src/lib/hl-core/net.d.ts +0 -2
  118. package/dist/src/lib/hl-core/net.js +0 -7
  119. package/dist/src/lib/hl-core/signing.d.ts +0 -103
  120. package/dist/src/lib/hl-core/signing.js +0 -295
  121. package/dist/src/lib/hl-core/wire.d.ts +0 -34
  122. package/dist/src/lib/hl-core/wire.js +0 -81
  123. package/dist/src/lib/invoked-as.d.ts +0 -2
  124. package/dist/src/lib/invoked-as.js +0 -24
  125. package/dist/src/lib/journey-words.d.ts +0 -84
  126. package/dist/src/lib/journey-words.js +0 -363
  127. package/dist/src/lib/journey.d.ts +0 -150
  128. package/dist/src/lib/journey.js +0 -264
  129. package/dist/src/lib/key-receipt.d.ts +0 -48
  130. package/dist/src/lib/key-receipt.js +0 -116
  131. package/dist/src/lib/key-source.d.ts +0 -9
  132. package/dist/src/lib/key-source.js +0 -33
  133. package/dist/src/lib/keyfile.d.ts +0 -136
  134. package/dist/src/lib/keyfile.js +0 -397
  135. package/dist/src/lib/launch-claude.d.ts +0 -5
  136. package/dist/src/lib/launch-claude.js +0 -45
  137. package/dist/src/lib/lock-lookup.d.ts +0 -40
  138. package/dist/src/lib/lock-lookup.js +0 -92
  139. package/dist/src/lib/message-seal.d.ts +0 -63
  140. package/dist/src/lib/message-seal.js +0 -150
  141. package/dist/src/lib/net-choice.d.ts +0 -28
  142. package/dist/src/lib/net-choice.js +0 -72
  143. package/dist/src/lib/network.d.ts +0 -22
  144. package/dist/src/lib/network.js +0 -50
  145. package/dist/src/lib/next-words.d.ts +0 -105
  146. package/dist/src/lib/next-words.js +0 -298
  147. package/dist/src/lib/paths.d.ts +0 -41
  148. package/dist/src/lib/paths.js +0 -91
  149. package/dist/src/lib/plan-draw.d.ts +0 -56
  150. package/dist/src/lib/plan-draw.js +0 -219
  151. package/dist/src/lib/plan-live.d.ts +0 -20
  152. package/dist/src/lib/plan-live.js +0 -192
  153. package/dist/src/lib/qr.d.ts +0 -21
  154. package/dist/src/lib/qr.js +0 -402
  155. package/dist/src/lib/roster.d.ts +0 -20
  156. package/dist/src/lib/roster.js +0 -79
  157. package/dist/src/lib/sale-card.d.ts +0 -117
  158. package/dist/src/lib/sale-card.js +0 -261
  159. package/dist/src/lib/shop-init.d.ts +0 -62
  160. package/dist/src/lib/shop-init.js +0 -63
  161. package/dist/src/lib/sui-grpc-send.d.ts +0 -90
  162. package/dist/src/lib/sui-grpc-send.js +0 -128
  163. package/dist/src/lib/swap-core.d.ts +0 -163
  164. package/dist/src/lib/swap-core.js +0 -405
  165. package/dist/src/lib/tasks-digest.d.ts +0 -66
  166. package/dist/src/lib/tasks-digest.js +0 -200
  167. package/dist/src/lib/tasks-graph.d.ts +0 -79
  168. package/dist/src/lib/tasks-graph.js +0 -463
  169. package/dist/src/lib/tasks-lens.d.ts +0 -31
  170. package/dist/src/lib/tasks-lens.js +0 -47
  171. package/dist/src/lib/tasks-next.d.ts +0 -25
  172. package/dist/src/lib/tasks-next.js +0 -103
  173. package/dist/src/lib/tasks-prove.d.ts +0 -15
  174. package/dist/src/lib/tasks-prove.js +0 -68
  175. package/dist/src/lib/tasks-route.d.ts +0 -29
  176. package/dist/src/lib/tasks-route.js +0 -151
  177. package/dist/src/lib/tasks-score.d.ts +0 -36
  178. package/dist/src/lib/tasks-score.js +0 -152
  179. package/dist/src/lib/tasks-workspace.d.ts +0 -18
  180. package/dist/src/lib/tasks-workspace.js +0 -73
  181. package/dist/src/lib/timed-fetch.d.ts +0 -33
  182. package/dist/src/lib/timed-fetch.js +0 -59
  183. package/dist/src/lib/vault-read.d.ts +0 -24
  184. package/dist/src/lib/vault-read.js +0 -77
  185. package/dist/src/lib/vaultfile.d.ts +0 -103
  186. package/dist/src/lib/vaultfile.js +0 -249
  187. package/dist/src/lib/wallet-money.d.ts +0 -222
  188. package/dist/src/lib/wallet-money.js +0 -578
  189. package/dist/src/lib/wallet-request.d.ts +0 -50
  190. package/dist/src/lib/wallet-request.js +0 -86
  191. package/dist/src/links.d.ts +0 -5
  192. package/dist/src/links.js +0 -45
  193. package/dist/src/media.d.ts +0 -29
  194. package/dist/src/media.js +0 -487
  195. package/dist/src/message-receipt.d.ts +0 -25
  196. package/dist/src/message-receipt.js +0 -71
  197. package/dist/src/message.d.ts +0 -13
  198. package/dist/src/message.js +0 -92
  199. package/dist/src/move.d.ts +0 -36
  200. package/dist/src/move.js +0 -152
  201. package/dist/src/network-cmd.d.ts +0 -17
  202. package/dist/src/network-cmd.js +0 -74
  203. package/dist/src/next.d.ts +0 -12
  204. package/dist/src/next.js +0 -67
  205. package/dist/src/onboard.d.ts +0 -16
  206. package/dist/src/onboard.js +0 -149
  207. package/dist/src/plugin.d.ts +0 -2
  208. package/dist/src/plugin.js +0 -193
  209. package/dist/src/push.d.ts +0 -2
  210. package/dist/src/push.js +0 -115
  211. package/dist/src/render.d.ts +0 -21
  212. package/dist/src/render.js +0 -32
  213. package/dist/src/secrets-device.d.ts +0 -32
  214. package/dist/src/secrets-device.js +0 -127
  215. package/dist/src/secrets-give.d.ts +0 -125
  216. package/dist/src/secrets-give.js +0 -236
  217. package/dist/src/secrets-list.d.ts +0 -27
  218. package/dist/src/secrets-list.js +0 -84
  219. package/dist/src/secrets-run.d.ts +0 -31
  220. package/dist/src/secrets-run.js +0 -182
  221. package/dist/src/secrets.d.ts +0 -33
  222. package/dist/src/secrets.js +0 -200
  223. package/dist/src/setup.d.ts +0 -6
  224. package/dist/src/setup.js +0 -127
  225. package/dist/src/ship.d.ts +0 -2
  226. package/dist/src/ship.js +0 -18
  227. package/dist/src/shop-buy.d.ts +0 -16
  228. package/dist/src/shop-buy.js +0 -101
  229. package/dist/src/shop.d.ts +0 -10
  230. package/dist/src/shop.js +0 -112
  231. package/dist/src/skill-parser.d.ts +0 -14
  232. package/dist/src/skill-parser.js +0 -113
  233. package/dist/src/skill.d.ts +0 -2
  234. package/dist/src/skill.js +0 -493
  235. package/dist/src/slug.d.ts +0 -2
  236. package/dist/src/slug.js +0 -6
  237. package/dist/src/social.d.ts +0 -2
  238. package/dist/src/social.js +0 -106
  239. package/dist/src/staff.d.ts +0 -2
  240. package/dist/src/staff.js +0 -104
  241. package/dist/src/start.d.ts +0 -27
  242. package/dist/src/start.js +0 -225
  243. package/dist/src/status.d.ts +0 -2
  244. package/dist/src/status.js +0 -52
  245. package/dist/src/substrate.d.ts +0 -2
  246. package/dist/src/substrate.js +0 -258
  247. package/dist/src/swap.d.ts +0 -93
  248. package/dist/src/swap.js +0 -622
  249. package/dist/src/tasks.d.ts +0 -2
  250. package/dist/src/tasks.js +0 -743
  251. package/dist/src/templates.d.ts +0 -1
  252. package/dist/src/templates.js +0 -213
  253. package/dist/src/thread.d.ts +0 -2
  254. package/dist/src/thread.js +0 -52
  255. package/dist/src/trade.d.ts +0 -2
  256. package/dist/src/trade.js +0 -91
  257. package/dist/src/trail.d.ts +0 -2
  258. package/dist/src/trail.js +0 -41
  259. package/dist/src/validate.d.ts +0 -13
  260. package/dist/src/validate.js +0 -35
  261. package/dist/src/wallet-money.d.ts +0 -158
  262. package/dist/src/wallet-money.js +0 -664
  263. package/dist/src/wallet.d.ts +0 -169
  264. package/dist/src/wallet.js +0 -973
  265. package/dist/src/workflow.d.ts +0 -2
  266. package/dist/src/workflow.js +0 -169
  267. package/dist/src/write.d.ts +0 -43
  268. package/dist/src/write.js +0 -180
@@ -1,146 +0,0 @@
1
- import { Command } from 'commander';
2
- import { existsSync, readFileSync } from 'node:fs';
3
- import { mergeEnv } from './env.js';
4
- import { resolveBase, resolveKey, authHeaders } from './lib/client.js';
5
- import { readKeyFolder, keyFolderStatus, workspaceFor, KEY_DIR_NAME, LEGACY_KEY_DIR_NAME } from './lib/keyfile.js';
6
- import { KEY_FILE } from './lib/paths.js';
7
- import { askPath } from './lib/api-path.js';
8
- /** api.one.ie (the gateway) answers `GET /health`; one.ie/web has no /health
9
- * route, so a HEAD / 200 is the reachability signal there — same host split
10
- * askPath() already makes for /ask. */
11
- export function isGatewayHost(base) {
12
- return new URL(base).hostname === 'api.one.ie';
13
- }
14
- export async function checkReachability(base, timeoutMs = 5000) {
15
- const start = Date.now();
16
- const controller = new AbortController();
17
- const timer = setTimeout(() => controller.abort(), timeoutMs);
18
- try {
19
- const res = await fetch(isGatewayHost(base) ? `${base}/health` : base, {
20
- method: isGatewayHost(base) ? 'GET' : 'HEAD',
21
- signal: controller.signal,
22
- });
23
- return { ok: res.ok, ms: Date.now() - start };
24
- }
25
- catch {
26
- return { ok: false, ms: Date.now() - start };
27
- }
28
- finally {
29
- clearTimeout(timer);
30
- }
31
- }
32
- export async function runDoctor(dir, opts = {}) {
33
- const keyFile = opts.keyFile ?? KEY_FILE;
34
- const env = mergeEnv(dir);
35
- const checks = [];
36
- // A folder key outranks the machine key, the same order resolveKey uses — so
37
- // doctor reports the credential the commands will actually send.
38
- const folder = readKeyFolder(dir);
39
- // A REFUSED folder key must be explained, not silently skipped. `foreign` means
40
- // a .oneie/agent.key exists here but was minted for another directory — the
41
- // credential-confusion guard. Silence would leave the operator staring at a key
42
- // on disk that nothing uses, with no way to tell that from a bug.
43
- const folderState = keyFolderStatus(dir);
44
- if (folderState === 'foreign' || folderState === 'unsafe' || folderState === 'unreadable') {
45
- checks.push({
46
- name: 'folder-key',
47
- ok: false,
48
- detail: folderState === 'foreign'
49
- ? 'a .oneie/agent.key here was minted for a DIFFERENT directory or machine — ignored. Run `one init --dir .` to mint one for this project.'
50
- : folderState === 'unsafe'
51
- ? 'a .oneie/agent.key here is a symlink, group/world-readable, or owned by another user — ignored. Delete it and re-mint.'
52
- : 'a .oneie/agent.key here is empty or unreadable — ignored.',
53
- });
54
- }
55
- const hasConfig = Boolean(folder) || existsSync(keyFile) || Boolean(env.ONE_API_KEY) || Boolean(env.ONEIE_API_KEY);
56
- checks.push({
57
- name: 'config',
58
- ok: hasConfig,
59
- detail: folder
60
- ? `${dir}/${existsSync(`${dir}/${KEY_DIR_NAME}/agent.key`) ? KEY_DIR_NAME : LEGACY_KEY_DIR_NAME}/agent.key (0600, project)`
61
- : hasConfig
62
- ? `${keyFile} (0600)`
63
- : `${keyFile} missing — run \`one setup\` or \`one login\``,
64
- });
65
- const key = env.ONE_API_KEY ||
66
- env.ONEIE_API_KEY ||
67
- folder?.apiKey ||
68
- (existsSync(keyFile) ? readFileSync(keyFile, 'utf8').trim() : '');
69
- checks.push({ name: 'key', ok: Boolean(key), detail: key ? `${key.slice(0, 4)}***…` : 'no key found' });
70
- // EXPIRY. Keys minted by the anonymous provision door carry a 90-day
71
- // valid_to, and verifyWorldKey enforces it in SQL — so an unwatched folder
72
- // key stops working one day with a bare 401, which `packages/cli/CLAUDE.md`
73
- // documents as indistinguishable from a WRONG key. The metadata already
74
- // records the date; reading it is what turns a scheduled outage into a
75
- // warning. An absent expiresAt means a permanent key, not an unknown one, so
76
- // it reports ok and says so rather than inventing a doubt.
77
- const expiresAt = folder?.meta.expiresAt;
78
- if (typeof expiresAt === 'string') {
79
- const ms = Date.parse(expiresAt);
80
- if (Number.isNaN(ms)) {
81
- checks.push({ name: 'key-expiry', ok: false, detail: `unreadable expiresAt: ${expiresAt}` });
82
- }
83
- else {
84
- const days = Math.floor((ms - Date.now()) / 86_400_000);
85
- checks.push({
86
- name: 'key-expiry',
87
- // Expired is a failure; expiring is not, or doctor cries wolf for 83 days.
88
- ok: days > 0,
89
- detail: days > 14
90
- ? `expires in ${days} days`
91
- : days > 0
92
- ? `expires in ${days} days — renew with \`one init --dir .\``
93
- : `EXPIRED ${-days} days ago — renew with \`one init --dir .\``,
94
- });
95
- }
96
- }
97
- else if (folder) {
98
- checks.push({ name: 'key-expiry', ok: true, detail: 'no expiry recorded (permanent key)' });
99
- }
100
- const base = resolveBase({ api: opts.api });
101
- const reach = await checkReachability(base);
102
- checks.push({ name: 'substrate', ok: reach.ok, detail: `${base} ${reach.ms}ms` });
103
- return { ok: checks.every((c) => c.ok), checks };
104
- }
105
- /** No `auth:whoami` receiver exists — an authenticated `dashboard:usage` call
106
- * proves the key is live, alongside the env echo. */
107
- export function whoamiCmd() {
108
- return new Command('whoami')
109
- .description('Who the key is, which workspace — proves the key is live')
110
- .option('--api <url>', 'API base URL')
111
- .action(async (opts) => {
112
- const dir = process.cwd();
113
- const env = mergeEnv(dir);
114
- const base = resolveBase({ api: opts.api });
115
- const key = resolveKey({});
116
- if (!key) {
117
- process.stderr.write('no key found — run `one setup` or `one login`\n');
118
- process.exitCode = 1;
119
- return;
120
- }
121
- const res = await fetch(askPath(base, 'dashboard:usage'), {
122
- method: 'POST',
123
- headers: authHeaders({}),
124
- body: JSON.stringify({ data: {} }),
125
- });
126
- const live = res.ok;
127
- process.stdout.write(`workspace ${env.WORKSPACE_SLUG ?? workspaceFor(undefined, dir, env) ?? '(unset)'}\n`);
128
- process.stdout.write(`key ${key.slice(0, 4)}***… ${live ? '(live)' : `(unreachable — ${base})`}\n`);
129
- process.stdout.write(`base ${base}\n`);
130
- if (!live)
131
- process.exitCode = 1;
132
- });
133
- }
134
- export function doctorCmd() {
135
- return new Command('doctor')
136
- .description('Config / key / reachability checks — exit 0 or 1 for CI')
137
- .option('--api <url>', 'API base URL to check (defaults to the resolved base)')
138
- .action(async (opts) => {
139
- const result = await runDoctor(process.cwd(), opts);
140
- for (const c of result.checks) {
141
- process.stdout.write(`[${c.ok ? 'ok' : 'fail'}] ${c.name.padEnd(10)} ${c.detail}\n`);
142
- }
143
- if (!result.ok)
144
- process.exitCode = 1;
145
- });
146
- }
@@ -1,18 +0,0 @@
1
- import { Command } from 'commander';
2
- /** Pinned so `bun x` cannot quietly run a different release. ONE_LAZYDRAW overrides. */
3
- export declare const LAZYDRAW_PKG = "lazydraw@0.1.1";
4
- /** tasks:comment's MAX_COMMENT_BYTES (one.ie/web/src/lib/resolvers/tasks.ts). */
5
- export declare const COMMENT_MAX_BYTES = 4000;
6
- /** The argv that runs lazydraw on this machine, or null when neither lazydraw nor bun is reachable. */
7
- export declare function resolveRunner(has?: (bin: string) => boolean): string[] | null;
8
- /** The comment body `attach` posts, or a refusal naming the budget that bit. */
9
- export declare function attachBody(name: string, diagram: string): {
10
- ok: true;
11
- body: string;
12
- bytes: number;
13
- } | {
14
- ok: false;
15
- error: string;
16
- bytes: number;
17
- };
18
- export declare function drawCmd(): Command;
package/dist/src/draw.js DELETED
@@ -1,156 +0,0 @@
1
- import { Command } from 'commander';
2
- import { spawnSync } from 'node:child_process';
3
- import { accessSync, constants } from 'node:fs';
4
- import { delimiter, join } from 'node:path';
5
- import { authHeaders, resolveBase } from './lib/client.js';
6
- import { askPath } from './lib/api-path.js';
7
- // `one draw` — ASCII diagrams in the terminal, via lazydraw
8
- // (github.com/mpospirit/lazydraw, MIT, © Çağrı Gökpunar).
9
- //
10
- // NOT A DEPENDENCY, on purpose. The CLI's runtime deps are exactly commander +
11
- // @oneie/sdk, and lazydraw is a Bun TUI (its bin is `src/cli.ts`, Bun >= 1.3)
12
- // while `one` runs on node. So we spawn it: `lazydraw` if it is on PATH, else
13
- // `bun x lazydraw@<pinned>`. Without Bun there is no editor to open, and the
14
- // command says so in one line instead of a stack trace.
15
- //
16
- // What earns a verb here:
17
- // draw [args…] PASSTHROUGH — `one draw`, `one draw <name>`, `one draw list`,
18
- // `one draw export <name> --basic --fenced -o f` are lazydraw's own.
19
- // attach EARNS IT — exports a drawing and posts it to a task's thread
20
- // through tasks:comment, so a sketch lands on the board row it
21
- // explains. The door caps a comment at 4000 bytes; a bigger
22
- // diagram is REFUSED here with both numbers, never cut mid-line.
23
- /** Pinned so `bun x` cannot quietly run a different release. ONE_LAZYDRAW overrides. */
24
- export const LAZYDRAW_PKG = 'lazydraw@0.1.1';
25
- /** tasks:comment's MAX_COMMENT_BYTES (one.ie/web/src/lib/resolvers/tasks.ts). */
26
- export const COMMENT_MAX_BYTES = 4000;
27
- const DEFAULT_API = 'https://api.one.ie';
28
- function onPath(bin, path = process.env.PATH ?? '') {
29
- for (const dir of path.split(delimiter)) {
30
- if (!dir)
31
- continue;
32
- try {
33
- accessSync(join(dir, bin), constants.X_OK);
34
- return true;
35
- }
36
- catch {
37
- /* next dir */
38
- }
39
- }
40
- return false;
41
- }
42
- /** The argv that runs lazydraw on this machine, or null when neither lazydraw nor bun is reachable. */
43
- export function resolveRunner(has = (b) => onPath(b)) {
44
- if (has('lazydraw'))
45
- return ['lazydraw'];
46
- if (has('bun'))
47
- return ['bun', 'x', process.env.ONE_LAZYDRAW || LAZYDRAW_PKG];
48
- return null;
49
- }
50
- const NO_BUN = 'one draw needs Bun >= 1.3 (lazydraw is a Bun app): curl -fsSL https://bun.sh/install | bash — or `bun install -g lazydraw`';
51
- /** The comment body `attach` posts, or a refusal naming the budget that bit. */
52
- export function attachBody(name, diagram) {
53
- const body = `Diagram \`${name}\` (one draw):\n\n${diagram.trim()}`;
54
- const bytes = Buffer.byteLength(body, 'utf8');
55
- if (!diagram.trim())
56
- return { ok: false, error: `drawing "${name}" exported empty`, bytes };
57
- if (bytes > COMMENT_MAX_BYTES) {
58
- return {
59
- ok: false,
60
- error: `drawing "${name}" is ${bytes} bytes as a comment; tasks:comment keeps ${COMMENT_MAX_BYTES} — not posted (crop it, or export -o and attach the file)`,
61
- bytes,
62
- };
63
- }
64
- return { ok: true, body, bytes };
65
- }
66
- function fail(msg) {
67
- process.stderr.write(`error ${msg}\n`);
68
- process.exitCode = 1;
69
- }
70
- async function askComment(api, data) {
71
- const res = await fetch(askPath(resolveBase({ api }, DEFAULT_API), 'tasks:comment'), {
72
- method: 'POST',
73
- headers: authHeaders(),
74
- body: JSON.stringify({ data }),
75
- });
76
- const text = await res.text();
77
- let o;
78
- try {
79
- o = JSON.parse(text);
80
- }
81
- catch {
82
- throw new Error(`tasks:comment → ${res.status} ${text.slice(0, 200)}`);
83
- }
84
- if (o.outcome && o.outcome !== 'result') {
85
- const inner = (o.result ?? {});
86
- // ok:false LAST — an inner body's own `ok` must never overwrite a failed outcome.
87
- return { ...inner, ok: false, error: inner.error ?? String(o.outcome) };
88
- }
89
- if (!res.ok)
90
- throw new Error(`tasks:comment → ${res.status} ${text.slice(0, 200)}`);
91
- return (o.result ?? o) ?? {};
92
- }
93
- export function drawCmd() {
94
- const cmd = new Command('draw')
95
- .description('ASCII diagrams in the terminal (lazydraw) — `one draw [name]`, `list`, `export`, `attach`')
96
- .argument('[args...]', 'passed to lazydraw: <name|path> · list · export <name> [--basic] [--comment s] [--fenced] [-o f] · --import f')
97
- .allowUnknownOption()
98
- .helpOption('-h, --help', 'show this help (lazydraw’s own: one draw -- --help)')
99
- .action((args) => {
100
- const runner = resolveRunner();
101
- if (!runner)
102
- return fail(NO_BUN);
103
- const [bin, ...pre] = runner;
104
- const r = spawnSync(bin, [...pre, ...args], { stdio: 'inherit' });
105
- if (r.error)
106
- return fail(`${bin}: ${r.error.message}`);
107
- process.exitCode = r.status ?? 1;
108
- });
109
- cmd
110
- .command('attach <name>')
111
- .description('Export a drawing and post it to a task thread (tasks:comment); refuses over the 4000-byte comment cap')
112
- .requiredOption('--task <tid>', 'Task id, e.g. task:01a0…')
113
- .option('--workspace <slug>', 'Workspace the task lives in (one you control)')
114
- .option('--extended', 'Box-drawing characters instead of plain ASCII (+ - |)')
115
- .option('--api <url>', 'API base URL', DEFAULT_API)
116
- .option('--json', 'Print the receipt as JSON')
117
- .action(async (name, opts) => {
118
- const runner = resolveRunner();
119
- if (!runner)
120
- return fail(NO_BUN);
121
- const [bin, ...pre] = runner;
122
- const exportArgs = ['export', name, '--fenced', ...(opts.extended ? [] : ['--basic'])];
123
- const r = spawnSync(bin, [...pre, ...exportArgs], { encoding: 'utf8' });
124
- if (r.error)
125
- return fail(`${bin}: ${r.error.message}`);
126
- if (r.status !== 0)
127
- return fail((r.stderr || `lazydraw export exited ${r.status}`).trim());
128
- const built = attachBody(name, r.stdout);
129
- if (!built.ok)
130
- return fail(built.error);
131
- const res = await askComment(opts.api, {
132
- tid: opts.task,
133
- body: built.body,
134
- ...(opts.workspace ? { workspace: opts.workspace } : {}),
135
- });
136
- // The door's own receipt decides "cut", never our byte count: it trims before
137
- // it measures, so comparing against what we sent reads a newline as a loss.
138
- const submitted = typeof res.submittedBytes === 'number' ? res.submittedBytes : undefined;
139
- const stored = typeof res.storedBytes === 'number' ? res.storedBytes : undefined;
140
- const cut = res.truncated === true || (submitted !== undefined && stored !== undefined && stored < submitted);
141
- const json = opts.json || process.argv.includes('--json');
142
- const failed = res.ok === false || typeof res.error === 'string';
143
- const receipt = { ok: !failed && !cut, tid: opts.task, drawing: name, submittedBytes: submitted, storedBytes: stored, ...(cut ? { truncated: true } : {}), ...(res.error ? { error: res.error } : {}) };
144
- if (json)
145
- process.stdout.write(JSON.stringify(receipt, null, 2) + '\n');
146
- if (failed) {
147
- const landed = typeof res.durability === 'string' ? ` (${res.durability})` : '';
148
- return fail(`tasks:comment refused: ${String(res.error)}${landed}${res.retryable ? ' — retryable, run it again' : ''}`);
149
- }
150
- if (cut)
151
- return fail(`posted but CUT: ${submitted} bytes submitted, ${stored} stored`);
152
- if (!json)
153
- process.stdout.write(`✓ ${name} → ${opts.task} (${built.bytes} bytes)\n`);
154
- });
155
- return cmd;
156
- }
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function endpointCmd(): Command;
@@ -1,250 +0,0 @@
1
- import { Command } from 'commander';
2
- import { authHeaders, jsonMode, resolveBase } from './lib/client.js';
3
- import { askPath } from './lib/api-path.js';
4
- // `one endpoint` — enter your OWN https endpoints once, then name them from a
5
- // workflow step.
6
- //
7
- // WHY A SUBCOMMAND RATHER THAN `one ask endpoint:register`. Three things a raw
8
- // ask cannot do, and each one is a mistake a creator would otherwise make:
9
- //
10
- // add a SECRET is a credential, and pasting it into a shell as JSON puts it
11
- // in the shell history. `--secret-env VAR` reads it from the environment
12
- // instead, and the printed row never echoes it back.
13
- // test `endpoint:call --dryRun` answers the GUARD question without spending a
14
- // request. A creator's first failure is almost always the url, not the
15
- // payload, and this names the reason — https_required, ip_literal,
16
- // private_hostname, dns_unresolved, blocked_address.
17
- // list the sealed secret has no read door anywhere, so the renderer prints
18
- // `secret=yes|no`. A raw ask would print the same JSON; the point is that
19
- // there is nothing else to print, and the column says so out loud.
20
- //
21
- // call IS here too, because a creator who cannot call his own endpoint from the
22
- // terminal cannot tell a broken endpoint from a broken workflow.
23
- const DEFAULT_API = 'https://api.one.ie';
24
- function asker(api) {
25
- const base = resolveBase({ api }, DEFAULT_API);
26
- return async (receiver, data) => {
27
- const res = await fetch(askPath(base, receiver), {
28
- method: 'POST',
29
- headers: authHeaders(),
30
- body: JSON.stringify({ data }),
31
- });
32
- const text = await res.text();
33
- let body;
34
- try {
35
- body = text ? JSON.parse(text) : undefined;
36
- }
37
- catch {
38
- throw new Error(`${receiver} → ${res.status} ${text.slice(0, 200)}`);
39
- }
40
- if (!res.ok && !(body && typeof body === 'object' && 'outcome' in body)) {
41
- throw new Error(`${receiver} → ${res.status} ${text.slice(0, 200)}`);
42
- }
43
- if (!body || typeof body !== 'object')
44
- throw new Error(`${receiver}: empty response`);
45
- const o = body;
46
- if ('outcome' in o) {
47
- if (o.outcome === 'result')
48
- return o.result ?? {};
49
- const inner = o.result;
50
- if (inner && typeof inner === 'object' && ('ok' in inner || 'error' in inner)) {
51
- return { ok: false, ...inner, error: inner.error ?? String(o.outcome) };
52
- }
53
- throw new Error(`${receiver}: ${String(o.outcome)}`);
54
- }
55
- if ('result' in o)
56
- return o.result ?? {};
57
- return o;
58
- };
59
- }
60
- function fail(msg) {
61
- process.stderr.write(`${msg}\n`);
62
- process.exitCode = 1;
63
- }
64
- function renderRows(rows) {
65
- const w = process.stdout;
66
- if (!rows.length) {
67
- w.write('no endpoints registered\n');
68
- return;
69
- }
70
- w.write(`${rows.length} endpoint${rows.length === 1 ? '' : 's'}\n\n`);
71
- for (const r of rows) {
72
- w.write(`${r.name} ${r.method} ${r.url}\n` +
73
- ` returns=${r.returnMode} timeout=${r.timeoutMs}ms max=${r.maxBytes}B ` +
74
- `secret=${r.hasSecret ? `yes (${r.authHeader})` : 'no'} status=${r.status}` +
75
- `${r.lastStatus ? ` last=${r.lastStatus}` : ''}\n`);
76
- }
77
- }
78
- function parseJsonOption(raw) {
79
- if (raw === undefined)
80
- return undefined;
81
- try {
82
- const v = JSON.parse(raw);
83
- if (!v || typeof v !== 'object' || Array.isArray(v))
84
- return 'bad';
85
- return v;
86
- }
87
- catch {
88
- return 'bad';
89
- }
90
- }
91
- export function endpointCmd() {
92
- const cmd = new Command('endpoint').description('Your own https endpoints — register one under a handle, then name it from a workflow `tool` step ' +
93
- '(config: { receiver: "endpoint:call", args: { endpoint: "<handle>", input: {…} } })');
94
- cmd
95
- .command('add <name> <url>')
96
- .description('Register or update an endpoint. The url is SSRF-checked here and again on every call.')
97
- .option('--workspace <slug>', 'Group slug (default: your own). A workspace you may not write is REFUSED, never downgraded.')
98
- .option('--method <m>', 'GET | POST | PUT | PATCH', 'POST')
99
- .option('--returns <mode>', 'json (the answer) | url (a link we fetch and file) | bytes (an image we file)', 'json')
100
- .option('--auth-header <name>', 'Header NAME the secret travels in, e.g. Authorization')
101
- .option('--secret-env <VAR>', 'Read the secret from this environment variable — never from the command line, which the shell records')
102
- .option('--timeout <ms>', 'Per-call timeout. Default 20000, clamped 1000–120000.')
103
- .option('--max-bytes <n>', 'Response byte ceiling. Default 5242880, clamped to 10485760.')
104
- .option('--api <url>', 'API base URL', DEFAULT_API)
105
- .option('--json', 'Print the raw response')
106
- .action(async (name, url, opts, sub) => {
107
- let secret;
108
- if (opts.secretEnv) {
109
- secret = process.env[opts.secretEnv];
110
- // An unset variable is a REFUSAL, not an unauthenticated registration —
111
- // silently registering without the credential would send an anonymous
112
- // request to a host that answers 401, and the creator would debug the url.
113
- if (!secret)
114
- return fail(`--secret-env ${opts.secretEnv} is unset or empty in this environment`);
115
- if (!opts.authHeader)
116
- return fail('--secret-env needs --auth-header (the header the secret travels in)');
117
- }
118
- const data = {
119
- name,
120
- url,
121
- method: opts.method.toUpperCase(),
122
- returnMode: opts.returns,
123
- ...(opts.workspace ? { workspace: opts.workspace } : {}),
124
- ...(opts.authHeader ? { authHeader: opts.authHeader } : {}),
125
- ...(secret ? { secret } : {}),
126
- ...(opts.timeout ? { timeoutMs: Number(opts.timeout) } : {}),
127
- ...(opts.maxBytes ? { maxBytes: Number(opts.maxBytes) } : {}),
128
- };
129
- let res;
130
- try {
131
- res = (await asker(opts.api)('endpoint:register', data));
132
- }
133
- catch (e) {
134
- return fail(e instanceof Error ? e.message : String(e));
135
- }
136
- if (jsonMode(sub))
137
- process.stdout.write(JSON.stringify(res, null, 2) + '\n');
138
- else if (res.ok !== false && res.endpoint)
139
- renderRows([res.endpoint]);
140
- if (res.ok === false)
141
- fail(res.error ?? 'endpoint:register failed');
142
- });
143
- cmd
144
- .command('list')
145
- .description('List registered endpoints. The sealed secret has no read door — the column says yes or no.')
146
- .option('--workspace <slug>', 'Group slug (default: your own)')
147
- .option('--api <url>', 'API base URL', DEFAULT_API)
148
- .option('--json', 'Print the raw response')
149
- .action(async (opts, sub) => {
150
- let res;
151
- try {
152
- res = (await asker(opts.api)('endpoint:list', opts.workspace ? { workspace: opts.workspace } : {}));
153
- }
154
- catch (e) {
155
- return fail(e instanceof Error ? e.message : String(e));
156
- }
157
- if (jsonMode(sub))
158
- process.stdout.write(JSON.stringify(res, null, 2) + '\n');
159
- else if (res.ok !== false)
160
- renderRows(res.endpoints ?? []);
161
- if (res.ok === false)
162
- fail(res.error ?? 'endpoint:list failed');
163
- });
164
- cmd
165
- .command('test <name>')
166
- .description('Run the SSRF guard against a registered endpoint without spending a request — the reason comes back by name')
167
- .option('--workspace <slug>', 'Group slug (default: your own)')
168
- .option('--api <url>', 'API base URL', DEFAULT_API)
169
- .option('--json', 'Print the raw response')
170
- .action(async (name, opts, sub) => {
171
- let res;
172
- try {
173
- res = (await asker(opts.api)('endpoint:call', {
174
- endpoint: name,
175
- dryRun: true,
176
- ...(opts.workspace ? { workspace: opts.workspace } : {}),
177
- }));
178
- }
179
- catch (e) {
180
- return fail(e instanceof Error ? e.message : String(e));
181
- }
182
- if (jsonMode(sub))
183
- process.stdout.write(JSON.stringify(res, null, 2) + '\n');
184
- else if (res.ok !== false)
185
- process.stdout.write(`guard ${res.guard ?? 'passed'} ${res.url ?? ''}\n`);
186
- if (res.ok === false)
187
- fail(res.error ?? 'endpoint:call failed');
188
- });
189
- cmd
190
- .command('call <name>')
191
- .description('Call a registered endpoint for real — the same door a workflow `tool` step uses')
192
- .option('--input <json>', 'The JSON object sent to your endpoint. The ONLY thing that crosses, beside its own sealed credential.')
193
- .option('--returns <mode>', 'Override the row: json | url | bytes')
194
- .option('--workspace <slug>', 'Group slug (default: your own)')
195
- .option('--api <url>', 'API base URL', DEFAULT_API)
196
- .option('--json', 'Print the raw response')
197
- .action(async (name, opts, sub) => {
198
- const input = parseJsonOption(opts.input);
199
- if (input === 'bad')
200
- return fail('--input must be a JSON object, e.g. \'{"title":"hello"}\'');
201
- let res;
202
- try {
203
- res = (await asker(opts.api)('endpoint:call', {
204
- endpoint: name,
205
- ...(input ? { input } : {}),
206
- ...(opts.returns ? { returnMode: opts.returns } : {}),
207
- ...(opts.workspace ? { workspace: opts.workspace } : {}),
208
- }));
209
- }
210
- catch (e) {
211
- return fail(e instanceof Error ? e.message : String(e));
212
- }
213
- if (jsonMode(sub) || res.ok === false) {
214
- process.stdout.write(JSON.stringify(res, null, 2) + '\n');
215
- }
216
- else if (res.url) {
217
- process.stdout.write(`${res.url} ${res.contentType ?? ''} ${res.size ?? '?'}B\n`);
218
- }
219
- else {
220
- process.stdout.write(JSON.stringify(res.json ?? res.text ?? res, null, 2) + '\n');
221
- }
222
- if (res.ok === false)
223
- fail(String(res.error ?? 'endpoint:call failed'));
224
- });
225
- cmd
226
- .command('rm <name>')
227
- .description('Delete a registered endpoint. Deleting something absent answers not_found, never a quiet success.')
228
- .option('--workspace <slug>', 'Group slug (default: your own)')
229
- .option('--api <url>', 'API base URL', DEFAULT_API)
230
- .option('--json', 'Print the raw response')
231
- .action(async (name, opts, sub) => {
232
- let res;
233
- try {
234
- res = (await asker(opts.api)('endpoint:remove', {
235
- name,
236
- ...(opts.workspace ? { workspace: opts.workspace } : {}),
237
- }));
238
- }
239
- catch (e) {
240
- return fail(e instanceof Error ? e.message : String(e));
241
- }
242
- if (jsonMode(sub))
243
- process.stdout.write(JSON.stringify(res, null, 2) + '\n');
244
- else if (res.ok !== false)
245
- process.stdout.write(`removed ${name}\n`);
246
- if (res.ok === false)
247
- fail(res.error ?? 'endpoint:remove failed');
248
- });
249
- return cmd;
250
- }
package/dist/src/env.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export declare function readEnvFile(path: string): Record<string, string>;
2
- export declare function mergeEnv(dir: string): Record<string, string>;
3
- export declare function writeEnvLocal(dir: string, updates: Record<string, string>): void;
package/dist/src/env.js DELETED
@@ -1,37 +0,0 @@
1
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
- const LINE = /^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*?)\s*$/;
3
- export function readEnvFile(path) {
4
- if (!existsSync(path))
5
- return {};
6
- const out = {};
7
- for (const raw of readFileSync(path, 'utf8').split('\n')) {
8
- if (raw.trim().startsWith('#') || !raw.trim())
9
- continue;
10
- const m = raw.match(LINE);
11
- if (m)
12
- out[m[1]] = m[2].replace(/^["']|["']$/g, '');
13
- }
14
- return out;
15
- }
16
- function fromProcess() {
17
- const out = {};
18
- for (const k of ['ONE_API_URL', 'ONE_API_KEY', 'ONEIE_API_KEY', 'AGENCY_SLUG', 'AGENCY_NAME', 'AGENCY_WSID', 'CC_ACTOR_ID', 'WORKSPACE_OWNER_EMAIL', 'WORKSPACE_ID', 'WORKSPACE_SLUG']) {
19
- const v = process.env[k];
20
- if (v)
21
- out[k] = v;
22
- }
23
- return out;
24
- }
25
- export function mergeEnv(dir) {
26
- return {
27
- ...readEnvFile(`${dir}/.env`),
28
- ...readEnvFile(`${dir}/.env.local`),
29
- ...fromProcess(),
30
- };
31
- }
32
- export function writeEnvLocal(dir, updates) {
33
- const path = `${dir}/.env.local`;
34
- const merged = { ...readEnvFile(path), ...updates };
35
- const body = Object.entries(merged).map(([k, v]) => `${k}=${v}`).join('\n') + '\n';
36
- writeFileSync(path, body, 'utf8');
37
- }
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function evalCmd(): Command;
package/dist/src/eval.js DELETED
@@ -1,43 +0,0 @@
1
- import { Command } from 'commander';
2
- import { existsSync } from 'node:fs';
3
- export function evalCmd() {
4
- const cmd = new Command('eval')
5
- .description('Run agent-behavior evals from *.eval.ts files (tool + signal receipts)')
6
- .argument('[path]', 'File or directory of *.eval.ts', 'evals')
7
- .option('--channels <url>', 'Channels base URL', process.env.ONEIE_CHANNELS_URL ?? 'https://channels.one.ie')
8
- .option('--events <url>', 'Events base URL', process.env.ONEIE_BASE_URL ?? 'https://one.ie')
9
- .action(async (path, opts) => {
10
- const out = (data) => process.stdout.write(JSON.stringify(data) + '\n');
11
- if (!existsSync(path)) {
12
- out({ ok: false, error: `not found: ${path}` });
13
- return;
14
- }
15
- try {
16
- const { runEvals } = await import('@oneie/evals');
17
- const results = await runEvals(path, {
18
- channelsUrl: opts.channels.replace(/\/$/, ''),
19
- eventsUrl: opts.events.replace(/\/$/, ''),
20
- groqApiKey: process.env.GROQ_API_KEY,
21
- typesafeApiKey: process.env.TYPESAFE_API_KEY,
22
- });
23
- const failed = results.filter((r) => r.failed > 0).length;
24
- out({ ok: failed === 0, total: results.length, passed: results.length - failed, results });
25
- if (failed > 0)
26
- process.exitCode = 1;
27
- }
28
- catch (err) {
29
- const msg = err.message;
30
- // @oneie/evals is a dev/monorepo-only dependency — it is intentionally not bundled in the
31
- // published CLI (it is an unpublished workspace sibling, and shipping it as a runtime dep
32
- // broke `npm i -g @oneie/cli`). Degrade with a clear message instead of a cryptic loader error.
33
- const missing = /Cannot find (module|package)|ERR_MODULE_NOT_FOUND|@oneie\/evals/.test(msg);
34
- out({
35
- ok: false,
36
- error: missing
37
- ? 'The `eval` command needs the @oneie/evals package, which is not bundled in the published CLI. Run it from the ONE monorepo, or install @oneie/evals alongside the CLI.'
38
- : msg,
39
- });
40
- }
41
- });
42
- return cmd;
43
- }
package/dist/src/fn.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function fnCmd(): Command;