@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,189 +0,0 @@
1
- /**
2
- * ceiling.ts — `one wallet ceiling create | set | show | register`: an agent's on-chain spend
3
- * ceiling (pay/contracts/spend-cap, `SpendCeiling`), driven from the terminal.
4
- *
5
- * create The OWNER's key signs `create_ceiling(agentId, perTx, total)`. The sender becomes
6
- * the ceiling's owner, so the bound is the owner's from the first block and starts
7
- * enabled. Signing opens the owner's vault (Touch ID for a Keychain vault).
8
- * set The OWNER's key signs `update_ceiling` — raise, lower, pause. Over the limit means
9
- * this: only the owner's biometric moves the bound. An agent cannot.
10
- * show The chain's own reading of a ceiling: owner, agent, both bounds, spent, enabled.
11
- * register Hands the ceiling to pay through the `agent:register-ceiling` receiver — the same
12
- * door the SDK, the MCP `ask` tool and the page call. pay checks the object is a
13
- * SpendCeiling for that agent, owned by the agent's claimed human.
14
- *
15
- * Amounts are dollars on the command line and cents on chain (the contract's unit).
16
- * Dry by default: without --live, create and set print the call and sign nothing.
17
- * The package id per network is pay's (pay/backend/src/config.ts `spendCapPackage`);
18
- * tests/ceiling.test.ts fails if this copy drifts from it.
19
- */
20
- import { Command } from 'commander';
21
- import { addressProofMessage, signAddressProof } from '@oneie/sdk/address-proof';
22
- import { askPath } from './lib/api-path.js';
23
- import { authHeaders, out, resolveBase } from './lib/client.js';
24
- import { suiExecGrpc, suiReadObjects } from './lib/sui-grpc-send.js';
25
- import { unlock } from './wallet.js';
26
- import { netLine, resolveNet } from './lib/net-choice.js';
27
- /** pay's spend-cap package per network — a copy, pinned to pay/backend/src/config.ts by test. */
28
- export const SPEND_CAP_PACKAGE = {
29
- testnet: '0xb9665d3555346615460b928ab97cad9d5d1ae84977299e0d92813bd6e7897529',
30
- mainnet: '0xd2bd9146732b0fbe436aa111981f94b22b6c51485d04a566788e685535548930',
31
- };
32
- const OBJ = /^0x[0-9a-f]{64}$/i;
33
- /** "12.34" → 1234 cents; anything else → null. */
34
- export function dollarsToCents(v) {
35
- if (!/^\d{1,9}(\.\d{1,2})?$/.test(v.trim()))
36
- return null;
37
- const [w, f = ''] = v.trim().split('.');
38
- return Number(w) * 100 + Number(f.padEnd(2, '0'));
39
- }
40
- /** The ceiling's Move fields as the gRPC json reading gives them, numbers made numbers. */
41
- export function readCeilingFields(json) {
42
- if (!json)
43
- return null;
44
- const n = (k) => Number(json[k] ?? NaN);
45
- const f = { owner: String(json.owner ?? ''), agentId: String(json.agent_id ?? ''), perTxCents: n('max_per_tx_usd_cents'), totalCents: n('max_total_usd_cents'), spentCents: n('total_spend_usd_cents'), enabled: json.enabled === true };
46
- return Number.isFinite(f.perTxCents) && f.owner ? f : null;
47
- }
48
- function pkgFor(net, override) {
49
- const p = override ?? SPEND_CAP_PACKAGE[net];
50
- return p && OBJ.test(p) ? p : null;
51
- }
52
- async function ownerSign(sub, o, call, build) {
53
- const t0 = Date.now();
54
- const nc = await resolveNet(o.net);
55
- if (!nc.ok)
56
- return out(sub, nc);
57
- const net = nc.net;
58
- const pkg = pkgFor(net, o.package);
59
- if (!pkg)
60
- return out(sub, { ok: false, error: `not_deployed_on_${net}`, detail: 'no spend-cap package on this network — publish it with `one move publish pay/contracts/spend-cap`, or pass --package' });
61
- const plan = { net, networkFrom: nc.from, says: netLine(nc), call: `${pkg}::spend_cap::${call.fn}`, ...call.describe };
62
- if (!o.live)
63
- return out(sub, { ok: true, dry: true, plan, next: 'add --live --dir <owner vault> to sign' });
64
- if (!o.dir)
65
- return out(sub, { ok: false, error: 'dir_required', detail: '--live signs with the OWNER vault in --dir' });
66
- const opened = await unlock(o.dir);
67
- if ('error' in opened)
68
- return out(sub, { ok: false, error: 'vault_locked', detail: opened.error });
69
- const key = opened.keys.find((k) => k.chain === 'sui');
70
- if (!key)
71
- return out(sub, { ok: false, error: 'no_sui_key_in_vault' });
72
- try {
73
- const done = await suiExecGrpc({ net, rpc: o.rpc, from: key.address, privateKeyHex: key.privateKeyHex, build: (tx) => build(tx, pkg) });
74
- const ceiling = done.created.find((c) => /::spend_cap::SpendCeiling$/.test(c.type))?.objectId ?? call.describe.ceiling;
75
- const [read] = ceiling ? await suiReadObjects(net, [ceiling], { rpc: o.rpc, json: true }) : [];
76
- const fields = readCeilingFields(read?.json);
77
- const ok = Boolean(fields && fields.owner.toLowerCase() === key.address.toLowerCase());
78
- return out(sub, { ok, ...(ok ? {} : { error: 'read_back_mismatch' }), net, digest: done.digest, signer: key.address, ceiling, readBack: fields, ms: done.finalMs, wallMs: Date.now() - t0 });
79
- }
80
- catch (e) {
81
- const err = e;
82
- return out(sub, { ok: false, error: err.code ?? 'ceiling_failed', detail: err.message, ...(err.digest ? { digest: err.digest } : {}) });
83
- }
84
- }
85
- export function ceilingCmd() {
86
- const cmd = new Command('ceiling').description("An agent's on-chain spend ceiling — the owner's key sets it, the owner's biometric raises it");
87
- cmd.command('create <agentId>')
88
- .description("OWNER signs create_ceiling: the agent may spend up to --per-tx dollars a payment and --total in all (0 = no total). Starts enabled, owned by the signer")
89
- .requiredOption('--per-tx <usd>', 'Most one payment may be, in dollars')
90
- .option('--total <usd>', 'Cumulative bound in dollars (0 = none)', '0')
91
- .option('--dir <vault>', "The OWNER's sealed vault folder (Keychain / Touch ID)")
92
- .option('--net <network>', 'testnet | mainnet (default: ONE_NETWORK, then `one network`, then the deploy)')
93
- .option('--package <id>', 'spend-cap package id (default: pay\'s for --net)')
94
- .option('--rpc <url>', 'gRPC base URL override')
95
- .option('--live', 'Sign and send')
96
- .action(async (agentId, o, sub) => {
97
- const per = dollarsToCents(o.perTx), total = dollarsToCents(o.total);
98
- if (!agentId.trim())
99
- return out(sub, { ok: false, error: 'agent_id_required' });
100
- if (!per)
101
- return out(sub, { ok: false, error: 'per_tx_not_an_amount' });
102
- if (total === null)
103
- return out(sub, { ok: false, error: 'total_not_an_amount' });
104
- return ownerSign(sub, o, { fn: 'create_ceiling', describe: { agentId, perTxCents: per, totalCents: total } }, (tx, pkg) => tx.moveCall({ target: `${pkg}::spend_cap::create_ceiling`, arguments: [tx.pure.string(agentId), tx.pure.u64(per), tx.pure.u64(total)] }));
105
- });
106
- cmd.command('set <ceilingId>')
107
- .description('OWNER signs update_ceiling: new bounds, and --pause to disable. Raising a limit is this command, under the owner\'s Touch ID')
108
- .requiredOption('--per-tx <usd>', 'Most one payment may be, in dollars')
109
- .option('--total <usd>', 'Cumulative bound in dollars (0 = none)', '0')
110
- .option('--pause', 'Disable the ceiling: every spend against it aborts')
111
- .option('--dir <vault>', "The OWNER's sealed vault folder")
112
- .option('--net <network>', 'testnet | mainnet (default: ONE_NETWORK, then `one network`, then the deploy)')
113
- .option('--package <id>', 'spend-cap package id (default: pay\'s for --net)')
114
- .option('--rpc <url>', 'gRPC base URL override')
115
- .option('--live', 'Sign and send')
116
- .action(async (ceilingId, o, sub) => {
117
- const per = dollarsToCents(o.perTx), total = dollarsToCents(o.total);
118
- if (!OBJ.test(ceilingId))
119
- return out(sub, { ok: false, error: 'ceiling_id_not_an_object_id' });
120
- if (!per)
121
- return out(sub, { ok: false, error: 'per_tx_not_an_amount' });
122
- if (total === null)
123
- return out(sub, { ok: false, error: 'total_not_an_amount' });
124
- const enabled = !o.pause;
125
- return ownerSign(sub, o, { fn: 'update_ceiling', describe: { ceiling: ceilingId, perTxCents: per, totalCents: total, enabled } }, (tx, pkg) => tx.moveCall({ target: `${pkg}::spend_cap::update_ceiling`, arguments: [tx.object(ceilingId), tx.pure.u64(per), tx.pure.u64(total), tx.pure.bool(enabled)] }));
126
- });
127
- cmd.command('show <ceilingId>')
128
- .description("The chain's reading of a ceiling: owner, agent, bounds, spent, enabled")
129
- .option('--net <network>', 'testnet | mainnet (default: ONE_NETWORK, then `one network`, then the deploy)')
130
- .option('--rpc <url>', 'gRPC base URL override')
131
- .action(async (ceilingId, o, sub) => {
132
- const nc = await resolveNet(o.net);
133
- if (!nc.ok)
134
- return out(sub, nc);
135
- const net = nc.net;
136
- if (!OBJ.test(ceilingId))
137
- return out(sub, { ok: false, error: 'ceiling_id_not_an_object_id' });
138
- try {
139
- const [r] = await suiReadObjects(net, [ceilingId], { rpc: o.rpc, json: true });
140
- const fields = readCeilingFields(r?.json);
141
- if (!fields || !/::spend_cap::SpendCeiling$/.test(r.type))
142
- return out(sub, { ok: false, error: 'not_a_spend_ceiling', type: r?.type ?? null });
143
- return out(sub, { ok: true, net, ceiling: ceilingId, type: r.type, ...fields });
144
- }
145
- catch (e) {
146
- return out(sub, { ok: false, error: e.code ?? 'read_failed', detail: e.message });
147
- }
148
- });
149
- cmd.command('register <agentId> <ceilingId>')
150
- .description("Hand the ceiling to pay (agent:register-ceiling) as the agent's claimed owner: with --dir, the owner's vault signs a fresh challenge (Touch ID once it is `wallet secure`d) — no browser needed")
151
- .option('--dir <vault>', "The OWNER's sealed vault: signs a fresh wallet:challenge, the factor an agent cannot produce")
152
- .option('--replace', 'Replace a ceiling already registered for this agent')
153
- .option('--api <url>', 'API base URL')
154
- .action(async (agentId, ceilingId, o, sub) => {
155
- const t0 = Date.now();
156
- if (!OBJ.test(ceilingId))
157
- return out(sub, { ok: false, error: 'ceiling_id_not_an_object_id' });
158
- const base = resolveBase({ api: o.api }, 'https://one.ie').replace(/\/$/, '');
159
- const ask = async (receiver, data) => {
160
- const res = await fetch(askPath(base, receiver), { method: 'POST', headers: authHeaders(), body: JSON.stringify({ data }) });
161
- return (await res.json().catch(() => ({})));
162
- };
163
- let signed = {};
164
- if (o.dir) {
165
- const opened = await unlock(o.dir);
166
- if ('error' in opened)
167
- return out(sub, { ok: false, error: 'vault_locked', detail: opened.error });
168
- const key = opened.keys.find((k) => k.chain === 'sui');
169
- if (!key)
170
- return out(sub, { ok: false, error: 'no_sui_key_in_vault' });
171
- const ch = await ask('wallet:challenge', {});
172
- const c = ch.result ?? {};
173
- if (c['ok'] !== true || typeof c['challenge'] !== 'string')
174
- return out(sub, { ok: false, error: 'no_challenge', detail: ch.error ?? c['error'] });
175
- const message = addressProofMessage({ challenge: c['challenge'], workspace: String(c['workspace']), actor: String(c['actor']), chain: 'sui', address: key.address });
176
- signed = { challenge: c['challenge'], proof: signAddressProof('sui', key.privateKeyHex, message) };
177
- }
178
- try {
179
- const body = await ask('agent:register-ceiling', { agentId, objectId: ceilingId, ...(o.replace ? { replace: true } : {}), ...signed });
180
- if (body.outcome !== 'result')
181
- return out(sub, { ok: false, error: String(body.error ?? body.outcome ?? 'no_answer') });
182
- return out(sub, { ...(body.result ?? {}), ok: body.result?.ok === true, wallMs: Date.now() - t0 });
183
- }
184
- catch (e) {
185
- return out(sub, { ok: false, error: 'unreachable', detail: e.message });
186
- }
187
- });
188
- return cmd;
189
- }
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function chatCmd(): Command;
package/dist/src/chat.js DELETED
@@ -1,92 +0,0 @@
1
- import { Command } from 'commander';
2
- import { authHeaders, resolveBase, resolveKey } from './lib/client.js';
3
- const DEFAULT_API = resolveBase({}, 'https://one.ie');
4
- const DEFAULT_CHANNELS = process.env.CHANNELS_URL ?? 'https://channels.one.ie';
5
- const DEFAULT_SPACES = ['vespio', 'elitemoversca', 'world'];
6
- async function spacePost(api, space, content) {
7
- const res = await fetch(`${api.replace(/\/$/, '')}/api/ask/space:post`, {
8
- method: 'POST',
9
- headers: authHeaders(),
10
- body: JSON.stringify({ data: { space, content } }),
11
- });
12
- if (!res.ok)
13
- return { ok: false, error: `HTTP ${res.status}` };
14
- const j = await res.json();
15
- return j.result ?? { ok: j.outcome === 'result', error: j.error };
16
- }
17
- export function chatCmd() {
18
- const cmd = new Command('chat')
19
- .description('Send messages to Spaces (fan-out) or listen for incoming messages (fan-in)');
20
- // one chat "text" [--to space] [--broadcast]
21
- cmd
22
- .command('send <text>', { isDefault: true })
23
- .description('Send a message to a Space (default: broadcast to all)')
24
- .option('--to <space>', 'Target space slug (default: broadcast to vespio + elitemoversca + world)')
25
- .option('--api <url>', 'API base URL', DEFAULT_API)
26
- .action(async (text, opts) => {
27
- if (opts.to) {
28
- const r = await spacePost(opts.api, opts.to, text);
29
- process.stdout.write(JSON.stringify(r, null, 2) + '\n');
30
- }
31
- else {
32
- const results = await Promise.all(DEFAULT_SPACES.map(s => spacePost(opts.api, s, text)));
33
- results.forEach((r, i) => process.stdout.write(`→ space:${DEFAULT_SPACES[i]} ${r.ok ? r.id : r.error}\n`));
34
- process.stdout.write(`ok broadcast to ${DEFAULT_SPACES.length} spaces\n`);
35
- }
36
- });
37
- // one chat broadcast "text"
38
- cmd
39
- .command('broadcast <text>')
40
- .description('Fan-out to all default spaces (vespio + elitemoversca + world)')
41
- .option('--spaces <list>', 'Comma-separated space slugs', DEFAULT_SPACES.join(','))
42
- .option('--api <url>', 'API base URL', DEFAULT_API)
43
- .action(async (text, opts) => {
44
- const spaces = opts.spaces.split(',').map(s => s.trim()).filter(Boolean);
45
- const results = await Promise.all(spaces.map(s => spacePost(opts.api, s, text)));
46
- results.forEach((r, i) => process.stdout.write(`→ space:${spaces[i]} ${r.ok ? r.id : r.error}\n`));
47
- process.stdout.write(`ok broadcast to ${spaces.length} spaces\n`);
48
- });
49
- // one chat listen <space>
50
- cmd
51
- .command('listen <space>')
52
- .description('Stream incoming messages from a Space via SSE (Ctrl+C to stop)')
53
- .option('--channels <url>', 'Channels base URL', DEFAULT_CHANNELS)
54
- .action(async (space, opts) => {
55
- const group = space.startsWith('space:') ? space : `space:${space}`;
56
- const url = `${opts.channels.replace(/\/$/, '')}/stream/${encodeURIComponent(group)}`;
57
- process.stderr.write(`Listening on ${group} — Ctrl+C to stop\n`);
58
- const key = resolveKey();
59
- const h = { Accept: 'text/event-stream' };
60
- if (key)
61
- h['Authorization'] = `Bearer ${key}`;
62
- const res = await fetch(url, { headers: h });
63
- if (!res.ok || !res.body) {
64
- process.stderr.write(`stream error: ${res.status}\n`);
65
- process.exit(1);
66
- }
67
- const reader = res.body.getReader();
68
- const dec = new TextDecoder();
69
- while (true) {
70
- const { done, value } = await reader.read();
71
- if (done)
72
- break;
73
- const chunk = dec.decode(value);
74
- for (const line of chunk.split('\n')) {
75
- if (!line.startsWith('data:'))
76
- continue;
77
- const raw = line.slice(5).trim();
78
- if (!raw || raw === '[DONE]')
79
- continue;
80
- try {
81
- const msg = JSON.parse(raw);
82
- const t = msg.ts ? new Date(msg.ts).toISOString().slice(11, 19) : '';
83
- process.stdout.write(`[${t}] ${msg.sender ?? '?'}: ${msg.content ?? raw}\n`);
84
- }
85
- catch {
86
- process.stdout.write(raw + '\n');
87
- }
88
- }
89
- }
90
- });
91
- return cmd;
92
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * `one check "<message>"`: before an agent acts on a message that asks it to pay or to
3
- * hand something over. Refuse (a secret), ask your person (a payment, or red flags),
4
- * or nothing to pay. The words are `lib/check-words.ts`.
5
- *
6
- * Exit 0 only for "nothing to pay"; ask is 2 and refuse is 3, so `one check … && pay`
7
- * never goes through. Reads the message from its arguments or --file, never from
8
- * stdin: a stdin no one writes to would hang an agent shell.
9
- */
10
- import { Command } from 'commander';
11
- export declare function checkCmd(): Command;
package/dist/src/check.js DELETED
@@ -1,53 +0,0 @@
1
- /**
2
- * `one check "<message>"`: before an agent acts on a message that asks it to pay or to
3
- * hand something over. Refuse (a secret), ask your person (a payment, or red flags),
4
- * or nothing to pay. The words are `lib/check-words.ts`.
5
- *
6
- * Exit 0 only for "nothing to pay"; ask is 2 and refuse is 3, so `one check … && pay`
7
- * never goes through. Reads the message from its arguments or --file, never from
8
- * stdin: a stdin no one writes to would hang an agent shell.
9
- */
10
- import { Command } from 'commander';
11
- import { readFileSync } from 'node:fs';
12
- import { jsonMode } from './lib/client.js';
13
- import { cliPrefix } from './lib/invoked-as.js';
14
- import { asciiOf } from './lib/journey-words.js';
15
- import { check, checkWords, EXIT } from './lib/check-words.js';
16
- import { readFacts } from './next.js';
17
- export function checkCmd() {
18
- return new Command('check')
19
- .description('Before you act on a message that asks you to pay or to hand something over: refuse, ask your person, or nothing to pay. Never says pay. Exit 0 only for nothing to pay')
20
- .argument('[message...]', 'The message, in quotes')
21
- .option('--file <path>', 'Read the message from a file (an email, an invoice) instead')
22
- .option('--dir <path>', 'The agent\'s folder: its own addresses are read from it', '.')
23
- .action((words, opts, cmd) => {
24
- let text = words.join(' ');
25
- if (opts.file) {
26
- try {
27
- text = readFileSync(opts.file, 'utf8');
28
- }
29
- catch (e) {
30
- text = '';
31
- process.stderr.write(`cannot read ${opts.file}: ${e.message}\n`);
32
- }
33
- }
34
- if (!text.trim()) {
35
- const error = 'give the message: one check "<message>" or one check --file <path>';
36
- if (jsonMode(cmd))
37
- process.stdout.write(JSON.stringify({ ok: false, error }) + '\n');
38
- else
39
- process.stderr.write(`${error}\n`);
40
- process.exitCode = 1;
41
- return;
42
- }
43
- const own = Object.values(readFacts(opts.dir).state?.wallet?.addresses ?? {}).filter((a) => typeof a === 'string');
44
- const c = check(text, cliPrefix(), own);
45
- process.exitCode = EXIT[c.verdict];
46
- if (jsonMode(cmd)) {
47
- process.stdout.write(JSON.stringify({ ok: true, ...c }) + '\n');
48
- return;
49
- }
50
- const words2 = checkWords(c);
51
- process.stdout.write(!process.stdout.isTTY || 'NO_COLOR' in process.env ? asciiOf(words2) : words2);
52
- });
53
- }
@@ -1,5 +0,0 @@
1
- import { Command } from 'commander';
2
- /** `clients/<slug>.toml` — the scaffold `client add` reads. Optional keys are
3
- * commented so `readClient()`'s defaults apply until the operator opts in. */
4
- export declare function clientToml(name: string, slug: string): string;
5
- export declare function clientCmd(): Command;
@@ -1,157 +0,0 @@
1
- import { Command } from 'commander';
2
- import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
3
- import { mergeEnv } from './env.js';
4
- import { readClient } from './config.js';
5
- import { validateClient } from './validate.js';
6
- import { safeSlug } from './slug.js';
7
- import { askPath } from './lib/api-path.js';
8
- import { renderClientTable } from './render.js';
9
- const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
10
- /** `clients/<slug>.toml` — the scaffold `client add` reads. Optional keys are
11
- * commented so `readClient()`'s defaults apply until the operator opts in. */
12
- export function clientToml(name, slug) {
13
- return `slug = "${safeSlug(slug)}"
14
- name = "${name}"
15
- plan = "starter"
16
-
17
- # credits = 0
18
- # markup_pct = 0
19
- # monthly_cap = 0
20
- `;
21
- }
22
- async function ask(base, key, receiver, data) {
23
- const res = await fetch(askPath(base, receiver), {
24
- method: 'POST',
25
- headers: { 'Content-Type': 'application/json', ...(key ? { Authorization: `Bearer ${key}` } : {}) },
26
- body: JSON.stringify({ data }),
27
- });
28
- if (!res.ok) {
29
- const body = await res.text().catch(() => '');
30
- throw new Error(`${receiver} → ${res.status}\n${body}`);
31
- }
32
- const json = await res.json();
33
- // Four-outcome envelope: unwrap { outcome, result } (bare shape passes through).
34
- if (json.outcome === 'failure')
35
- throw new Error(`${receiver} → failure: ${JSON.stringify(json.result ?? {})}`);
36
- return (json.result ?? json);
37
- }
38
- export function clientCmd() {
39
- const cmd = new Command('client').description('Manage client nodes');
40
- cmd.command('new <slug>')
41
- .description('Scaffold clients/<slug>.toml so `client add` works out of the box')
42
- .option('--name <name>', 'Display name (defaults to the slug)')
43
- .action((slug, opts) => {
44
- const dir = process.cwd();
45
- const clean = safeSlug(slug);
46
- const dest = `${dir}/clients/${clean}.toml`;
47
- if (existsSync(dest)) {
48
- process.stderr.write(`already exists: ${dest}\n`);
49
- process.exit(1);
50
- }
51
- mkdirSync(`${dir}/clients`, { recursive: true });
52
- writeFileSync(dest, clientToml(opts.name ?? clean, clean));
53
- process.stdout.write(`Created ${dest}\n one client add ${clean}\n`);
54
- });
55
- cmd.command('list')
56
- .description('The client portfolio (billing:clients)')
57
- .option('--api <url>', 'API base URL', DEFAULT_API)
58
- .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
59
- .option('--json', 'Output raw JSON')
60
- .action(async (opts) => {
61
- const dir = process.cwd();
62
- const env = mergeEnv(dir);
63
- const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? '';
64
- const agencySlug = env.AGENCY_SLUG;
65
- if (!agencySlug) {
66
- process.stderr.write('AGENCY_SLUG missing — run `one setup` first\n');
67
- process.exit(1);
68
- }
69
- // slug required for staff/owner keys — {} resolves the key's personal
70
- // workspace and returns an empty portfolio.
71
- const data = await ask(opts.api.replace(/\/$/, ''), key, 'billing:clients', { slug: agencySlug });
72
- if (opts.json) {
73
- process.stdout.write(JSON.stringify(data, null, 2) + '\n');
74
- return;
75
- }
76
- const clients = (data.clients ?? []);
77
- const markupPct = (data.agency?.markup_pct) ?? 0;
78
- process.stdout.write(renderClientTable(clients, markupPct) + '\n');
79
- });
80
- cmd.command('add <slug>')
81
- .description('Atomically provision a managed client node')
82
- .option('--dry-run', 'Print plan without making substrate calls')
83
- .option('--api <url>', 'API base URL', DEFAULT_API)
84
- .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
85
- .action(async (slug, opts) => {
86
- const dir = process.cwd();
87
- const env = mergeEnv(dir);
88
- const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? '';
89
- const agencySlug = env.AGENCY_SLUG;
90
- if (!agencySlug) {
91
- process.stderr.write('AGENCY_SLUG missing — run `one setup` first\n');
92
- process.exit(1);
93
- }
94
- const config = readClient(`${dir}/clients/${safeSlug(slug)}.toml`);
95
- const errs = validateClient(config);
96
- if (errs.length) {
97
- process.stderr.write(errs.join('\n') + '\n');
98
- process.exit(1);
99
- }
100
- const request = {
101
- name: config.name,
102
- slug: safeSlug(config.slug),
103
- parent: agencySlug,
104
- plan: config.plan,
105
- credit: config.credits,
106
- markup: config.markup_pct,
107
- cap: config.monthly_cap ?? null,
108
- brand: config.brand_lock ?? false,
109
- agents: config.agents,
110
- };
111
- if (opts.dryRun) {
112
- process.stdout.write(`[dry-run] add ${request.slug} → managed under ${agencySlug} (plan=${config.plan}, credits=${config.credits ?? 0})\n`);
113
- return;
114
- }
115
- const result = await ask(opts.api.replace(/\/$/, ''), key, 'world:create-workspace', request);
116
- process.stdout.write(`Added ${request.slug} (managed) → ${String(result.wsid ?? request.slug)}\n`);
117
- });
118
- cmd.command('invite <email>')
119
- .description('Invite a self-serve client (they own the workspace)')
120
- .option('--slug <slug>', 'Client slug (required)')
121
- .option('--dry-run', 'Print plan without making substrate calls')
122
- .option('--api <url>', 'API base URL', DEFAULT_API)
123
- .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
124
- .action(async (email, opts) => {
125
- const dir = process.cwd();
126
- const env = mergeEnv(dir);
127
- const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? '';
128
- const agencySlug = env.AGENCY_SLUG;
129
- if (!agencySlug) {
130
- process.stderr.write('AGENCY_SLUG missing — run `one setup` first\n');
131
- process.exit(1);
132
- }
133
- if (!opts.slug) {
134
- process.stderr.write('--slug required\n');
135
- process.exit(1);
136
- }
137
- const config = readClient(`${dir}/clients/${safeSlug(opts.slug)}.toml`);
138
- const request = {
139
- slug: safeSlug(config.slug),
140
- name: config.name,
141
- email,
142
- plan: config.plan,
143
- credits: config.credits,
144
- markup: config.markup_pct,
145
- cap: config.monthly_cap ?? null,
146
- brand: config.brand_lock ?? false,
147
- agents: config.agents,
148
- };
149
- if (opts.dryRun) {
150
- process.stdout.write(`[dry-run] invite ${request.slug} → self-serve (client owns; ${email})\n`);
151
- return;
152
- }
153
- const result = await ask(opts.api.replace(/\/$/, ''), key, 'world:invite-client', request);
154
- process.stdout.write(`Invite for ${request.slug}: ${String(result.token ?? '(token)')}\n`);
155
- });
156
- return cmd;
157
- }
@@ -1,36 +0,0 @@
1
- export interface CompileItem {
2
- path: string;
3
- receiver: string;
4
- payload: Record<string, unknown>;
5
- /** Workflow two-phase: after `workflow:create` returns an id, push applies this diff. */
6
- applyDiff?: {
7
- add: Record<string, unknown>[];
8
- connect: Record<string, unknown>[];
9
- };
10
- }
11
- /**
12
- * Parse a workflow `.md` into a WorkflowDiff (`{add, connect}` per @oneie/sdk/schemas).
13
- * The deterministic step graph rides in a fenced ```graph JSON block:
14
- * { "steps": [{ "id", "kind", "name", "config": {…} }],
15
- * "edges": [ ["a","b"], { "from":"a", "to":"b", "condition":"…" } ] }
16
- * Prose above the block is human docs. `config` objects are JSON-stringified (the receiver
17
- * wants a string). Frontmatter `trigger:` seeds a trigger step when the graph omits one.
18
- * No graph block → null (the workflow is created as a shell). Unknown kind → throws.
19
- */
20
- export declare function parseWorkflowGraph(md: string, fm: Record<string, string>): {
21
- add: Record<string, unknown>[];
22
- connect: Record<string, unknown>[];
23
- } | null;
24
- export interface CompileResult {
25
- compiled: CompileItem[];
26
- errors: {
27
- path: string;
28
- message: string;
29
- }[];
30
- }
31
- /** Minimal TOML parser: key="v", key=123, key=true, [section], key=["a","b"] */
32
- export declare function parseToml(src: string): Record<string, unknown>;
33
- export declare function compileNode(dir: string, agencySlug: string, opts?: {
34
- clientSlug?: string;
35
- dryRun?: boolean;
36
- }): Promise<CompileResult>;