@oneie/cli 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,261 +0,0 @@
1
- /**
2
- * The sale, drawn for a terminal — `one shop card`. The same four offers, two rails and six channels the
3
- * home band, the chat and the film draw, as text no wider than 70 characters.
4
- *
5
- * SOURCE: one.ie/web/src/lib/sale/showcase.ts. The CLI is published on its own and cannot import the web
6
- * package at runtime, so the words are copied here. tests/sale-card.test.ts reads that file as text and
7
- * goes red when a name, price, cadence, rail or channel label drifts — change both together.
8
- *
9
- * Every line is a picture: nothing here mints, fetches or charges. A monthly subscription is card only.
10
- * Card money goes to the seller's Stripe; USDC to the seller's own wallet. ONE holds neither.
11
- */
12
- import { asciiOf } from './journey-words.js';
13
- // Copied from showcase.ts SALE_OFFERS (href dropped: a terminal never opens a route).
14
- export const SALE_OFFERS = [
15
- {
16
- kind: 'product', kindLabel: 'Product', name: 'Sold, the book', detail: 'The playbook, every chapter',
17
- price: '$20', cents: 2000, cadence: '', verb: 'Buy', stamp: 'Paid',
18
- link: 'one.ie/books/sold', live: false, rails: ['card', 'crypto'],
19
- },
20
- {
21
- kind: 'service', kindLabel: 'Service', name: 'Strategy call', detail: '30 minutes · Thursday 10:00',
22
- price: '$100', cents: 10000, cadence: '', verb: 'Book', stamp: 'Booked',
23
- link: 'one.ie/call', live: false, rails: ['card', 'crypto'],
24
- },
25
- {
26
- kind: 'subscription', kindLabel: 'Subscription', name: 'The Sold community', detail: 'People and agents, selling together',
27
- price: '$100', cents: 10000, cadence: '/month', verb: 'Join', stamp: 'Joined',
28
- link: 'one.ie/sold', live: true, rails: ['card'],
29
- },
30
- {
31
- kind: 'course', kindLabel: 'Course', name: 'Sold', detail: 'The course, with a month of the community',
32
- price: '$100', cents: 10000, cadence: '', verb: 'Enrol', stamp: 'Enrolled',
33
- link: 'one.ie/sold', live: true, rails: ['card', 'crypto'],
34
- },
35
- ];
36
- export const SALE_RAILS = [
37
- { id: 'card', label: 'Card', issuer: 'ONE', lands: "Paid into the seller's Stripe" },
38
- { id: 'crypto', label: 'USDC', issuer: 'USDC · Sui', lands: "Paid to the seller's own wallet" },
39
- ];
40
- export const SALE_CHANNELS = [
41
- { id: 'web', label: 'Web page', bar: 'yourshop.example', native: true },
42
- { id: 'chat', label: 'Chat', bar: 'Chat', native: true },
43
- { id: 'whatsapp', label: 'WhatsApp', bar: 'WhatsApp', native: false },
44
- { id: 'instagram', label: 'Instagram', bar: 'Instagram', native: false },
45
- { id: 'sms', label: 'SMS', bar: 'Messages', native: false },
46
- { id: 'email', label: 'Email', bar: 'Inbox', native: false },
47
- ];
48
- export const SALE_COPY = {
49
- opens: 'the link opens on the card',
50
- cardOnly: 'Monthly is card only.',
51
- example: 'Example sale. Nothing here is a real payment.',
52
- exampleOffer: 'Example price.',
53
- address: '0x5a1e…0e01',
54
- settled: 'On Sui',
55
- shop: 'Your shop',
56
- from: 'hello@yourshop.example',
57
- ask: 'How much is it?',
58
- time: '10:02',
59
- emailFrom: 'From',
60
- emailSubject: 'Subject',
61
- emailPay: 'Pay',
62
- };
63
- export const SALE_KIND_IDS = SALE_OFFERS.map((o) => o.kind);
64
- export const SALE_RAIL_IDS = SALE_RAILS.map((r) => r.id);
65
- export const SALE_CHANNEL_IDS = SALE_CHANNELS.map((c) => c.id);
66
- export const saleOffer = (kind) => SALE_OFFERS.find((o) => o.kind === kind) ?? SALE_OFFERS[0];
67
- export const saleRail = (id) => SALE_RAILS.find((r) => r.id === id) ?? SALE_RAILS[0];
68
- export const saleChannel = (id) => SALE_CHANNELS.find((c) => c.id === id) ?? SALE_CHANNELS[0];
69
- /** Asking a card-only offer for crypto gives card — the same rule the web face follows. */
70
- export const saleRailFor = (offer, rail) => (offer.rails.includes(rail) ? rail : offer.rails[0]);
71
- export const salePrice = (offer) => `${offer.price}${offer.cadence}`;
72
- export const salePay = (offer) => `${offer.verb} · ${salePrice(offer)}`;
73
- /** From cents, so a dollar price never rounds into a different coin amount. */
74
- export function saleUsdc(offer) {
75
- const whole = offer.cents % 100 === 0;
76
- return `${whole ? offer.cents / 100 : (offer.cents / 100).toFixed(2)} USDC`;
77
- }
78
- export const salePayOn = (offer, rail) => saleRailFor(offer, rail) === 'crypto' ? `${offer.verb} · ${saleUsdc(offer)}` : salePay(offer);
79
- export function saleMessage(channel, offer) {
80
- const p = salePrice(offer);
81
- switch (channel) {
82
- case 'chat': return `${offer.name} is ${p}. Pay here.`;
83
- case 'email': return `${offer.name}, ${p}. Pay with the button below.`;
84
- case 'sms': return `${offer.name} is ${p}. Pay here:`;
85
- case 'instagram': return `It's ${p}. Here's the link:`;
86
- case 'whatsapp': return `${offer.name} is ${p}. Pay here:`;
87
- default: return `${offer.name}, ${p}.`;
88
- }
89
- }
90
- export const saleSubject = (offer) => `Your ${offer.kindLabel.toLowerCase()}: ${offer.name}`;
91
- /** The `?via=` tag is how /sales counts which channel a sale came through. */
92
- export const saleLink = (offer, channel) => channel === 'web' || channel === 'chat' ? offer.link : `${offer.link}?via=${channel}`;
93
- /** A string from a flag, or null: the CLI refuses a word it does not know rather than drawing the default. */
94
- export const saleKindOf = (v) => pick(v, SALE_KIND_IDS);
95
- export const saleRailOf = (v) => pick(v, SALE_RAIL_IDS);
96
- export const saleChannelOf = (v) => pick(v, SALE_CHANNEL_IDS);
97
- function pick(v, ids) {
98
- const s = typeof v === 'string' ? v.trim().toLowerCase() : '';
99
- return ids.includes(s) ? s : null;
100
- }
101
- // ── drawing ──────────────────────────────────────────────────────────────────
102
- /** The skill's limit (.claude/skills/ascii): every line fits a phone and a chat panel. */
103
- export const SALE_MAX_WIDTH = 70;
104
- const CARD_IN = 44; // card content; the card is 48 wide
105
- const FRAME_IN = 62; // frame content; the frame is 66 wide
106
- const INDENT = ' ';
107
- const len = (s) => [...s].length;
108
- function wrap(text, width) {
109
- const lines = [];
110
- let line = '';
111
- for (const w of text.split(' ')) {
112
- if (line && len(line) + 1 + len(w) > width) {
113
- lines.push(line);
114
- line = w;
115
- }
116
- else
117
- line = line ? `${line} ${w}` : w;
118
- }
119
- if (line)
120
- lines.push(line);
121
- return lines;
122
- }
123
- /**
124
- * Boxes are padded AFTER each cell is made ASCII, so "…" becoming "..." widens the cell, not the border.
125
- */
126
- function boxer(inner, ascii) {
127
- const g = (s) => (ascii ? asciiOf(s) : s);
128
- const [tl, tr, bl, br, h, v] = ascii ? ['+', '+', '+', '+', '-', '|'] : ['╭', '╮', '╰', '╯', '─', '│'];
129
- const fit = (s) => {
130
- const t = g(s);
131
- return len(t) > inner ? [...t].slice(0, inner).join('') : t;
132
- };
133
- const row = (s = '') => { const t = fit(s); return `${v} ${t}${' '.repeat(inner - len(t))} ${v}`; };
134
- return {
135
- top: `${tl}${h.repeat(inner + 2)}${tr}`,
136
- bottom: `${bl}${h.repeat(inner + 2)}${br}`,
137
- row,
138
- /** Left and right in one row, at least two spaces apart. */
139
- split: (l, r) => {
140
- const a = g(l), b = g(r);
141
- return row(`${a}${' '.repeat(Math.max(2, inner - len(a) - len(b)))}${b}`);
142
- },
143
- right: (s) => { const t = fit(s); return `${v} ${' '.repeat(inner - len(t))}${t} ${v}`; },
144
- center: (s) => {
145
- const t = fit(s), pad = inner - len(t), left = Math.floor(pad / 2);
146
- return `${v} ${' '.repeat(left)}${t}${' '.repeat(pad - left)} ${v}`;
147
- },
148
- };
149
- }
150
- /** One offer as a payment card, on the rail it can really take. */
151
- export function saleCardLines(kind, opts = {}) {
152
- const offer = saleOffer(kind);
153
- const asked = opts.rail ?? 'card';
154
- const rail = saleRailFor(offer, asked);
155
- const copy = saleRail(rail);
156
- const b = boxer(CARD_IN, Boolean(opts.ascii));
157
- const crypto = rail === 'crypto';
158
- const price = crypto ? saleUsdc(offer) : salePrice(offer);
159
- const paid = opts.phase === 'paid';
160
- const stamp = `✓ ${offer.stamp}${paid && crypto ? ` · ${SALE_COPY.settled}` : ''}`;
161
- return [
162
- b.top,
163
- b.split(copy.issuer, offer.kindLabel),
164
- b.row(),
165
- b.row(offer.name),
166
- ...wrap(offer.detail, CARD_IN).map((l) => b.row(l)),
167
- b.row(),
168
- offer.live ? b.row(price) : b.split(price, SALE_COPY.exampleOffer),
169
- ...(crypto ? [b.row(SALE_COPY.address)] : []),
170
- b.row(),
171
- b.row(paid ? stamp : `[ ${salePayOn(offer, rail)} ]`),
172
- b.row(),
173
- // Asked for USDC on a monthly offer: say why the card face is drawn, not silently swap.
174
- ...(rail !== asked ? [b.row(SALE_COPY.cardOnly)] : []),
175
- b.row(`${copy.label} · ${copy.lands}`),
176
- b.bottom,
177
- ];
178
- }
179
- /** The card inside a channel's thread: who, the agent's words and link, then the card it opens on. */
180
- export function saleFrameLines(kind, channel, opts = {}) {
181
- const offer = saleOffer(kind);
182
- const c = saleChannel(channel);
183
- const b = boxer(FRAME_IN, Boolean(opts.ascii));
184
- const msg = saleMessage(channel, offer);
185
- const link = saleLink(offer, channel);
186
- const said = (text) => wrap(text, FRAME_IN).map((l) => b.row(l));
187
- const head = (() => {
188
- switch (channel) {
189
- case 'web': return [b.row(c.bar)];
190
- case 'chat': return [b.row(c.bar)];
191
- case 'sms': return [b.center(SALE_COPY.shop), b.center(c.bar)];
192
- case 'email': return [b.split(c.bar, SALE_COPY.time)];
193
- default: return [b.row(`${SALE_COPY.shop} · ${c.bar}`)];
194
- }
195
- })();
196
- const body = (() => {
197
- switch (channel) {
198
- case 'web': return [];
199
- case 'chat': return said(msg);
200
- case 'whatsapp':
201
- case 'instagram':
202
- return [b.right(SALE_COPY.ask), b.row(), ...said(msg), b.row(link), b.row(SALE_COPY.time)];
203
- case 'sms':
204
- return [b.center(SALE_COPY.time), b.row(), ...said(msg), b.row(link)];
205
- case 'email':
206
- return [
207
- b.row(`${SALE_COPY.emailFrom.padEnd(8)}${SALE_COPY.shop} ${SALE_COPY.from}`),
208
- b.row(`${SALE_COPY.emailSubject.padEnd(8)}${saleSubject(offer)}`),
209
- b.row(),
210
- ...said(msg),
211
- ...said(offer.detail),
212
- b.row(),
213
- b.row(`[ ${SALE_COPY.emailPay} ${salePrice(offer)} ] ${link}`),
214
- ];
215
- }
216
- })();
217
- return [
218
- b.top,
219
- ...head,
220
- b.row(),
221
- ...body,
222
- ...(body.length ? [b.row()] : []),
223
- ...(c.native ? [] : [b.row(`↓ ${SALE_COPY.opens}`), b.row()]),
224
- ...saleCardLines(kind, opts).map((l) => b.row(INDENT + l)),
225
- b.bottom,
226
- ];
227
- }
228
- /** The whole drawing: one offer or several, framed or bare, with the example line once at the end. */
229
- export function drawSale(kinds, opts = {}) {
230
- const blocks = kinds.map((k) => (opts.channel ? saleFrameLines(k, opts.channel, opts) : saleCardLines(k, opts)).join('\n'));
231
- return [...blocks, opts.ascii ? asciiOf(SALE_COPY.example) : SALE_COPY.example].join('\n\n') + '\n';
232
- }
233
- /** The same sale as data, for --json and for an agent: what would be drawn, never a payment. */
234
- export function saleJson(kinds, opts = {}) {
235
- const asked = opts.rail ?? 'card';
236
- return {
237
- ok: true,
238
- example: true,
239
- note: SALE_COPY.example,
240
- offers: kinds.map((k) => {
241
- const offer = saleOffer(k);
242
- const rail = saleRailFor(offer, asked);
243
- return {
244
- kind: offer.kind,
245
- name: offer.name,
246
- price: salePrice(offer),
247
- cents: offer.cents,
248
- live: offer.live,
249
- rail,
250
- ...(rail !== asked ? { cardOnly: SALE_COPY.cardOnly } : {}),
251
- pay: salePayOn(offer, rail),
252
- // --paid must change the data too, or an agent reading --json sees a flag it passed do nothing.
253
- ...(opts.phase === 'paid' ? { stamp: `${offer.stamp}${rail === 'crypto' ? ` · ${SALE_COPY.settled}` : ''}` } : {}),
254
- lands: saleRail(rail).lands,
255
- ...(opts.channel
256
- ? { channel: opts.channel, message: saleMessage(opts.channel, offer), link: saleLink(offer, opts.channel) }
257
- : { link: offer.link }),
258
- };
259
- }),
260
- };
261
- }
@@ -1,62 +0,0 @@
1
- /**
2
- * `one shop init` — the terminal half of the shop pack.
3
- *
4
- * Pure on purpose: every round trip arrives through `deps.ask`, so the whole
5
- * command is exercised without a network and without a key. `src/shop.ts` is
6
- * the commander wiring and holds no logic of its own.
7
- *
8
- * TWO RECEIVERS, ONE OF WHICH MAY NOT BE THERE YET.
9
- * `pages:instantiate-shop-pack` ships. `pages:fill-shop-pack` is C9.3 of
10
- * `text/ecommerce-site-todo.md` and lands in parallel with this — and an
11
- * unknown receiver DISSOLVES, which answers HTTP 200. So the fill leg is read
12
- * for its outcome and reported separately: `seeded` and `filled` are two facts,
13
- * and a shop whose pages exist but carry no facts must not report as either a
14
- * clean success or a total failure.
15
- */
16
- export interface AskEnvelope {
17
- outcome?: string;
18
- result?: {
19
- ok?: boolean;
20
- slug?: string;
21
- error?: string;
22
- pages?: Array<{
23
- pageSlug?: string;
24
- slug?: string;
25
- }>;
26
- filled?: number;
27
- };
28
- }
29
- export interface ShopInitDeps {
30
- ask(receiver: string, data: unknown): Promise<AskEnvelope>;
31
- }
32
- export interface ShopInitResult {
33
- ok: boolean;
34
- workspace: string;
35
- /** The page slugs the seed reported, first one first. */
36
- pages: string[];
37
- /** Was a fill asked for, and did it happen. */
38
- filled: boolean;
39
- fillRequested: boolean;
40
- error?: string;
41
- fillError?: string;
42
- }
43
- /** One reading of an `/api/ask` answer. A dissolve and a refusal both arrive as 200. */
44
- export declare function readEnvelope(env: AskEnvelope, receiver: string): {
45
- ok: true;
46
- result: NonNullable<AskEnvelope['result']>;
47
- } | {
48
- ok: false;
49
- error: string;
50
- };
51
- /** Parse a facts file. A file that is not an object is refused by name, never coerced. */
52
- export declare function parseFacts(raw: string): {
53
- ok: true;
54
- facts: Record<string, unknown>;
55
- } | {
56
- ok: false;
57
- error: string;
58
- };
59
- export declare function shopInit(deps: ShopInitDeps, opts: {
60
- workspace: string;
61
- facts?: Record<string, unknown>;
62
- }): Promise<ShopInitResult>;
@@ -1,63 +0,0 @@
1
- /**
2
- * `one shop init` — the terminal half of the shop pack.
3
- *
4
- * Pure on purpose: every round trip arrives through `deps.ask`, so the whole
5
- * command is exercised without a network and without a key. `src/shop.ts` is
6
- * the commander wiring and holds no logic of its own.
7
- *
8
- * TWO RECEIVERS, ONE OF WHICH MAY NOT BE THERE YET.
9
- * `pages:instantiate-shop-pack` ships. `pages:fill-shop-pack` is C9.3 of
10
- * `text/ecommerce-site-todo.md` and lands in parallel with this — and an
11
- * unknown receiver DISSOLVES, which answers HTTP 200. So the fill leg is read
12
- * for its outcome and reported separately: `seeded` and `filled` are two facts,
13
- * and a shop whose pages exist but carry no facts must not report as either a
14
- * clean success or a total failure.
15
- */
16
- /** One reading of an `/api/ask` answer. A dissolve and a refusal both arrive as 200. */
17
- export function readEnvelope(env, receiver) {
18
- if (env.outcome && env.outcome !== 'result')
19
- return { ok: false, error: `${receiver} ${env.outcome}` };
20
- const result = env.result;
21
- if (!result?.ok)
22
- return { ok: false, error: result?.error ?? `${receiver} returned no result` };
23
- return { ok: true, result };
24
- }
25
- /** Parse a facts file. A file that is not an object is refused by name, never coerced. */
26
- export function parseFacts(raw) {
27
- let parsed;
28
- try {
29
- parsed = JSON.parse(raw);
30
- }
31
- catch (e) {
32
- return { ok: false, error: `facts file is not valid JSON: ${e.message}` };
33
- }
34
- if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
35
- return { ok: false, error: 'facts file must be a JSON object of ShopBusinessFacts' };
36
- }
37
- return { ok: true, facts: parsed };
38
- }
39
- export async function shopInit(deps, opts) {
40
- const fillRequested = opts.facts !== undefined;
41
- const base = { ok: false, workspace: opts.workspace, pages: [], filled: false, fillRequested };
42
- if (!opts.workspace)
43
- return { ...base, error: 'no workspace — pass --workspace <slug>' };
44
- const seedEnv = await deps.ask('pages:instantiate-shop-pack', { slug: opts.workspace });
45
- const seed = readEnvelope(seedEnv, 'pages:instantiate-shop-pack');
46
- if (!seed.ok)
47
- return { ...base, error: seed.error };
48
- // The receiver answers with all twelve role pages in `pages`; the bare `slug`
49
- // (the home page) is the fallback for an older worker that predates them.
50
- const listed = Array.isArray(seed.result.pages) ? seed.result.pages : [];
51
- const pages = listed.map(p => p.slug).filter((s) => typeof s === 'string' && s.length > 0);
52
- if (!pages.length && seed.result.slug)
53
- pages.push(seed.result.slug);
54
- if (!pages.length)
55
- return { ...base, error: 'the pack seeded no pages' };
56
- if (!fillRequested)
57
- return { ...base, ok: true, pages };
58
- const fillEnv = await deps.ask('pages:fill-shop-pack', { slug: opts.workspace, facts: opts.facts });
59
- const fill = readEnvelope(fillEnv, 'pages:fill-shop-pack');
60
- if (!fill.ok)
61
- return { ...base, ok: true, pages, fillError: fill.error };
62
- return { ...base, ok: true, pages, filled: true };
63
- }
@@ -1,90 +0,0 @@
1
- /**
2
- * sui-grpc-send.ts — every Sui transaction the CLI signs, over gRPC (suiExecGrpc); a transfer is one build of it.
3
- *
4
- * Sui JSON-RPC is switched off on every public fullnode ("JSON-RPC on public fullnodes has
5
- * been deprecated"), so the send goes over Mysten's gRPC fullnodes — the same endpoints and
6
- * `client.core.executeTransaction` shape one.ie/web/src/lib/sui-transport.ts uses (copied, never
7
- * imported: the CLI ships alone). `@mysten/sui` loads on demand so a command that never sends
8
- * pays nothing for it.
9
- *
10
- * Never hangs, never re-sends: the digest is known BEFORE the node is asked (it is the hash of
11
- * the bytes we signed), so a node that goes quiet is refused by name with that digest in hand.
12
- */
13
- import type { Net } from './wallet-money.js';
14
- export declare const SUI_GRPC: Record<Net, string>;
15
- export interface SuiSendReq {
16
- asset: 'SUI' | 'USDC' | 'ETH';
17
- coinType: string;
18
- from: string;
19
- to: string;
20
- amountUnits: bigint;
21
- privateKeyHex: string;
22
- /** An optional gRPC base URL override; default is Mysten's public fullnode for `net`. */
23
- rpc?: string;
24
- net: Net;
25
- /** Arrive as this many equal coins (the first carries the remainder). Absent or 1 = one coin. */
26
- split?: number;
27
- }
28
- export interface SuiSendDone {
29
- digest: string;
30
- /** computation + storage − rebate, in MIST (never below 0). */
31
- gasMist: bigint;
32
- /** Wall-clock from signing to the node returning the certified effects, in ms. */
33
- finalMs: number;
34
- }
35
- type Loader = (spec: string) => Promise<Record<string, unknown>>;
36
- /** A variable specifier: no bundler or typechecker pulls @mysten/sui in; it loads from the person's own install. */
37
- export declare const loadSpec: Loader;
38
- /** A named failure that may carry the digest of a transaction that might still land. */
39
- export declare class SuiSendError extends Error {
40
- code: string;
41
- digest?: string | undefined;
42
- constructor(code: string, message: string, digest?: string | undefined);
43
- }
44
- export declare const gasMistOf: (g: {
45
- computationCost?: string;
46
- storageCost?: string;
47
- storageRebate?: string;
48
- } | undefined) => bigint;
49
- /** Any Sui transaction this CLI signs: `build` adds the commands, the vault key signs here. */
50
- export interface SuiExecReq {
51
- net: Net;
52
- from: string;
53
- privateKeyHex: string;
54
- /** An optional gRPC base URL override; default is Mysten's public fullnode for `net`. */
55
- rpc?: string;
56
- build: (tx: any, txm: any, sender: string) => void;
57
- }
58
- /** An object the transaction created, with its type and where it went. */
59
- export interface SuiCreated {
60
- objectId: string;
61
- type: string;
62
- /** The address that holds it, `shared`, `package`, or `other`. */
63
- owner: string;
64
- }
65
- export interface SuiExecDone extends SuiSendDone {
66
- created: SuiCreated[];
67
- }
68
- /**
69
- * The one Sui signer. Build, sign, execute over gRPC, read back the effects. Every Sui act the
70
- * CLI does — a send, a publish, a ceiling call — is this function with a different `build`.
71
- */
72
- export declare function suiExecGrpc(r: SuiExecReq, load?: Loader, deadlineMs?: number): Promise<SuiExecDone>;
73
- /** One transfer of `amountUnits` of `coinType` — suiExecGrpc with a one-line build. */
74
- export declare function suiSendGrpc(r: SuiSendReq, load?: Loader, deadlineMs?: number): Promise<SuiSendDone>;
75
- /** What the chain says about some objects right now: type, holder and (when asked) the Move fields. */
76
- export interface SuiObjectRead {
77
- objectId: string;
78
- type: string;
79
- owner: string;
80
- json?: Record<string, unknown> | null;
81
- error?: string;
82
- }
83
- /** Read objects back over gRPC — a digest you did not read back is not proof. */
84
- export declare function suiReadObjects(net: Net, objectIds: string[], opts?: {
85
- rpc?: string;
86
- json?: boolean;
87
- }, load?: Loader): Promise<SuiObjectRead[]>;
88
- /** 1_234_000_000 MIST → "1.234 SUI" (trailing zeros trimmed, at least one digit). */
89
- export declare function mistToSui(mist: bigint): string;
90
- export {};
@@ -1,128 +0,0 @@
1
- export const SUI_GRPC = {
2
- mainnet: 'https://fullnode.mainnet.sui.io:443',
3
- testnet: 'https://fullnode.testnet.sui.io:443',
4
- };
5
- /** A variable specifier: no bundler or typechecker pulls @mysten/sui in; it loads from the person's own install. */
6
- export const loadSpec = (spec) => import(spec);
7
- /** A named failure that may carry the digest of a transaction that might still land. */
8
- export class SuiSendError extends Error {
9
- code;
10
- digest;
11
- constructor(code, message, digest) {
12
- super(message);
13
- this.code = code;
14
- this.digest = digest;
15
- }
16
- }
17
- const withDeadline = (p, ms, code, digest) => new Promise((resolve, reject) => {
18
- const t = setTimeout(() => reject(new SuiSendError(code, `the node did not answer within ${Math.round(ms / 1000)} s`, digest)), ms);
19
- p.then((v) => { clearTimeout(t); resolve(v); }, (e) => { clearTimeout(t); reject(e); });
20
- });
21
- export const gasMistOf = (g) => {
22
- if (!g)
23
- return 0n;
24
- const n = BigInt(g.computationCost ?? 0) + BigInt(g.storageCost ?? 0) - BigInt(g.storageRebate ?? 0);
25
- return n > 0n ? n : 0n;
26
- };
27
- const ownerOf = (o, state) => state === 'PackageWrite' ? 'package' : o?.$kind === 'AddressOwner' ? String(o.AddressOwner) : o?.$kind === 'Shared' ? 'shared' : 'other';
28
- /**
29
- * The one Sui signer. Build, sign, execute over gRPC, read back the effects. Every Sui act the
30
- * CLI does — a send, a publish, a ceiling call — is this function with a different `build`.
31
- */
32
- export async function suiExecGrpc(r, load = loadSpec, deadlineMs = 30_000) {
33
- let kp, grpc, txm; // eslint-disable-line @typescript-eslint/no-explicit-any
34
- try {
35
- ;
36
- [kp, grpc, txm] = await Promise.all([load('@mysten/sui/keypairs/ed25519'), load('@mysten/sui/grpc'), load('@mysten/sui/transactions')]);
37
- }
38
- catch {
39
- throw new SuiSendError('sui_signer_unavailable', 'install @mysten/sui beside oneie (npm i @mysten/sui)');
40
- }
41
- const hex = r.privateKeyHex.replace(/^0x/, '');
42
- const keypair = kp.Ed25519Keypair.fromSecretKey(Uint8Array.from((hex.match(/.{2}/g) ?? []).map((x) => parseInt(x, 16))));
43
- if (String(keypair.toSuiAddress()).toLowerCase() !== r.from.toLowerCase())
44
- throw new SuiSendError('vault_key_mismatch', 'the vault key does not derive the sending address');
45
- const baseUrl = (r.rpc ?? SUI_GRPC[r.net]).replace(/\/$/, '');
46
- const client = new grpc.SuiGrpcClient({ network: r.net, baseUrl });
47
- const tx = new txm.Transaction();
48
- tx.setSender(keypair.toSuiAddress());
49
- r.build(tx, txm, keypair.toSuiAddress());
50
- let bytes;
51
- try {
52
- bytes = await withDeadline(tx.build({ client }), deadlineMs, 'sui_node_unreachable');
53
- }
54
- catch (e) {
55
- if (e instanceof SuiSendError)
56
- throw new SuiSendError('sui_node_unreachable', `${new URL(baseUrl).host}: ${e.message}. Nothing was signed.`);
57
- const m = e.message ?? String(e);
58
- if (/fetch failed|ECONN|ENOTFOUND|EAI_AGAIN|ETIMEDOUT|unavailable|network/i.test(m))
59
- throw new SuiSendError('sui_node_unreachable', `${new URL(baseUrl).host}: ${m}. Nothing was signed. Pass --rpc <a gRPC base URL> to use another node.`);
60
- throw new SuiSendError('sui_build_failed', `${m}. Nothing was signed.`);
61
- }
62
- // The digest of the very bytes we are about to sign — derived from them, never asked of a node, so it cannot hang.
63
- const digest = String(txm.TransactionDataBuilder.getDigestFromBytes(bytes));
64
- const t0 = Date.now();
65
- const { signature } = await keypair.signTransaction(bytes);
66
- let res; // eslint-disable-line @typescript-eslint/no-explicit-any
67
- try {
68
- res = await withDeadline(client.core.executeTransaction({ transaction: bytes, signatures: [signature], include: { effects: true, objectTypes: true } }), deadlineMs, 'sui_unconfirmed', digest);
69
- }
70
- catch (e) {
71
- if (e instanceof SuiSendError)
72
- throw e;
73
- // Did the network take it anyway? Ask by digest before telling anyone it failed.
74
- throw new SuiSendError('sui_unconfirmed', `${e.message}. It may still have landed`, digest);
75
- }
76
- const finalMs = Date.now() - t0;
77
- const done = res?.Transaction ?? res?.FailedTransaction;
78
- if (!done)
79
- throw new SuiSendError('sui_unconfirmed', 'the node answered without a transaction', digest);
80
- if (done.status?.success !== true)
81
- throw new SuiSendError('sui_transfer_failed', String(done.status?.error?.message ?? 'the transaction failed on chain'), String(done.digest ?? digest));
82
- // Read-your-write for whoever looks next; not part of finalMs and never allowed to fail a landed send.
83
- try {
84
- await withDeadline(client.core.waitForTransaction({ digest: String(done.digest ?? digest) }), 10_000, 'wait_timeout');
85
- }
86
- catch { /* landed already */ }
87
- const types = done.objectTypes ?? {};
88
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
- const created = (done.effects?.changedObjects ?? [])
90
- .filter((c) => c.idOperation === 'Created')
91
- .map((c) => ({ objectId: String(c.objectId), type: String(types[c.objectId] ?? (c.outputState === 'PackageWrite' ? 'package' : '')), owner: ownerOf(c.outputOwner, c.outputState) }));
92
- return { digest: String(done.digest ?? digest), gasMist: gasMistOf(done.effects?.gasUsed), finalMs, created };
93
- }
94
- /** One transfer of `amountUnits` of `coinType` — suiExecGrpc with a one-line build. */
95
- export async function suiSendGrpc(r, load = loadSpec, deadlineMs = 30_000) {
96
- const { digest, gasMist, finalMs } = await suiExecGrpc({
97
- net: r.net, rpc: r.rpc, from: r.from, privateKeyHex: r.privateKeyHex,
98
- build: (tx, txm) => {
99
- const coin = txm.coinWithBalance({ type: r.coinType, balance: r.amountUnits });
100
- const n = r.split && r.split > 1 ? r.split : 1;
101
- if (n === 1)
102
- return tx.transferObjects([coin], tx.pure.address(r.to));
103
- const amounts = Array.from({ length: n - 1 }, () => r.amountUnits / BigInt(n));
104
- const parts = tx.splitCoins(coin, amounts.map((a) => tx.pure.u64(a)));
105
- tx.transferObjects([coin, ...amounts.map((_, i) => parts[i])], tx.pure.address(r.to));
106
- },
107
- }, load, deadlineMs);
108
- return { digest, gasMist, finalMs };
109
- }
110
- /** Read objects back over gRPC — a digest you did not read back is not proof. */
111
- export async function suiReadObjects(net, objectIds, opts = {}, load = loadSpec) {
112
- const grpc = await load('@mysten/sui/grpc').catch(() => { throw new SuiSendError('sui_signer_unavailable', 'install @mysten/sui beside oneie (npm i @mysten/sui)'); });
113
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
114
- const client = new grpc.SuiGrpcClient({ network: net, baseUrl: (opts.rpc ?? SUI_GRPC[net]).replace(/\/$/, '') });
115
- const res = await withDeadline(client.core.getObjects({ objectIds, include: opts.json ? { json: true } : {} }), 20_000, 'sui_node_unreachable');
116
- return res.objects.map((o, i) => {
117
- if (o instanceof Error)
118
- return { objectId: objectIds[i], type: '', owner: '', error: o.message };
119
- const ob = o;
120
- return { objectId: ob.objectId, type: String(ob.type ?? ''), owner: ownerOf(ob.owner), ...(opts.json ? { json: ob.json ?? null } : {}) };
121
- });
122
- }
123
- /** 1_234_000_000 MIST → "1.234 SUI" (trailing zeros trimmed, at least one digit). */
124
- export function mistToSui(mist) {
125
- const w = (mist / 1000000000n).toString();
126
- const f = (mist % 1000000000n).toString().padStart(9, '0').replace(/0+$/, '');
127
- return f ? `${w}.${f}` : w;
128
- }