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,149 +0,0 @@
1
- /**
2
- * oneie onboard — deterministically walk a fresh agent through the platform's
3
- * agent-onboarding lifecycle (text/agent-onboarding-lifecycle.md): registered
4
- * → bootstrapped → active → settled → adopted.
5
- *
6
- * Reuses the same zero-to-live call `one init` uses (POST /api/provision/agent)
7
- * for register+bootstrap — both stages are tracked server-side automatically
8
- * (no extra calls from here). Adds the read-back + guide layer `init` doesn't:
9
- * after provisioning, reads the real stage_transition log via lifecycle:mine
10
- * and tells the agent exactly what unlocks each remaining stage.
11
- *
12
- * Idempotent: if this directory already has ONE_API_KEY, skips provisioning
13
- * and just reports current lifecycle position.
14
- */
15
- import { Command } from 'commander';
16
- import { mergeEnv, writeEnvLocal } from './env.js';
17
- import { askPath } from './lib/api-path.js';
18
- import { KEY_FILE, readMachineKey, writeMachineKey } from './lib/paths.js';
19
- const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://one.ie';
20
- async function ask(base, key, receiver, data) {
21
- const res = await fetch(askPath(base, receiver), {
22
- method: 'POST',
23
- headers: { 'Content-Type': 'application/json', ...(key ? { Authorization: `Bearer ${key}` } : {}) },
24
- body: JSON.stringify({ data }),
25
- });
26
- const json = (await res.json().catch(() => ({})));
27
- if (!res.ok)
28
- throw new Error(`${receiver} → ${res.status}: ${JSON.stringify(json)}`);
29
- return json;
30
- }
31
- // The 5 stages, in order, and what unlocks each one — mirrors
32
- // SEED_DEFS['agent-onboarding'] in one.ie/web/src/lib/lifecycle/seed.ts.
33
- // Kept here as plain data (not fetched) so `onboard` works even before the
34
- // agent has a key to call the substrate with.
35
- const STAGE_GUIDE = {
36
- registered: 'done — your identity exists (uid + apiKey minted).',
37
- bootstrapped: 'done — your own group exists (gid + aid + scopedKey minted).',
38
- active: 'publish a capability or place a market offer: `one agent publish` or `one trade market`.',
39
- settled: 'complete a sale: `one trade hire` (as a buyer) or accept + settle an offer (as the seller).',
40
- adopted: 'get adopted by another group — accept an invite, or have your capability hired long-term.',
41
- };
42
- const STAGE_ORDER = ['registered', 'bootstrapped', 'active', 'settled', 'adopted'];
43
- function out(cmd, data) {
44
- const isJson = cmd.parent?.opts().json;
45
- if (isJson) {
46
- process.stdout.write(JSON.stringify(data) + '\n');
47
- return;
48
- }
49
- if (data.ok === false) {
50
- process.stderr.write(`✗ ${data.error ?? 'failed'}\n`);
51
- return;
52
- }
53
- const stages = data.stages ?? [];
54
- process.stdout.write(`✓ onboarded as ${data.uid ?? '?'}\n`);
55
- process.stdout.write(` group: ${data.group ?? data.workspace ?? '?'}\n`);
56
- process.stdout.write(` url: ${data.url ?? '?'}\n\n`);
57
- process.stdout.write(' lifecycle: register → bootstrap → active → settled → adopted\n');
58
- for (const s of stages) {
59
- process.stdout.write(` ${s.done ? '✓' : '·'} ${s.id.padEnd(12)} ${s.guide}\n`);
60
- }
61
- }
62
- export function onboardCmd() {
63
- const cmd = new Command('onboard')
64
- .description('Zero-to-live onboarding + a deterministic guide through the agent lifecycle')
65
- .option('--name <name>', 'Workspace / agent display name')
66
- .option('--api <url>', 'API base URL', DEFAULT_API)
67
- // Opt-in, never a default: run from Claude Code, the current directory is the
68
- // user's own project, and a default-on write put a live key into a repo nothing
69
- // guaranteed was gitignored. Commander cannot negate a `true` default, so there
70
- // was no way to turn it off either.
71
- .option('--write-env', 'Also write ONE_API_KEY to .env.local in the current directory')
72
- .action(async (opts) => {
73
- const dir = process.cwd();
74
- const base = opts.api.replace(/\/$/, '');
75
- const env = mergeEnv(dir);
76
- // The machine key counts as "already connected". With .env.local now opt-in,
77
- // reading only the folder would make every repeat run mint a NEW account on an
78
- // unauthenticated door rate-limited by IP alone.
79
- let apiKey = env.ONE_API_KEY ?? env.ONEIE_API_KEY ?? readMachineKey();
80
- // regKey is the uid-bound registration key — distinct from apiKey (the
81
- // workspace-scoped key `apiKey` resolves to). lifecycle:mine and any
82
- // other uid-scoped receiver need THIS key: ctx.ownerSlug from `apiKey`
83
- // resolves to the workspace's aid, which has zero stage_transition rows.
84
- let regKey = env.ONE_REG_KEY ?? '';
85
- let uid = env.ONE_UID ?? '';
86
- let workspace = env.AGENCY_WSID ?? env.AGENCY_SLUG ?? '';
87
- if (!apiKey) {
88
- // Register + bootstrap in one call — the same zero-to-live path `one
89
- // init` uses, POST /api/provision/agent. Both stages are tracked
90
- // server-side the moment this call lands; nothing extra to do here.
91
- const res = await fetch(`${base}/api/provision/agent`, {
92
- method: 'POST',
93
- headers: { 'Content-Type': 'application/json' },
94
- body: JSON.stringify({ name: opts.name ?? 'My Agent', live: true }),
95
- });
96
- const json = (await res.json().catch(() => ({})));
97
- if (!res.ok || !json.apiKey) {
98
- out(cmd, { ok: false, error: json.error ?? `provision failed (${res.status})` });
99
- process.exitCode = 1;
100
- return;
101
- }
102
- uid = String(json.uid);
103
- workspace = String(json.workspace);
104
- apiKey = json.apiKey;
105
- regKey = json.regKey ?? '';
106
- // The MACHINE key is regKey, not apiKey (text/agent-handover.md § 0). regKey's actor
107
- // IS the workspace slug, so callerControlsWorkspace (resolvers/_shared.ts:302) and
108
- // requireGroupOwner (world-receivers.ts:210) pass by identity; apiKey is scoped to a
109
- // random actor id and fails deep as `forbidden`. The plugin's tools and every CLI
110
- // command read this one file, so it must hold the key that can act on the workspace.
111
- writeMachineKey(regKey || apiKey);
112
- if (opts.writeEnv) {
113
- writeEnvLocal(dir, { ONE_API_KEY: apiKey, ONE_API_URL: base, ONE_REG_KEY: regKey, ONE_UID: uid, AGENCY_WSID: workspace });
114
- }
115
- }
116
- // Read back the real stage_transition log — the deterministic proof,
117
- // not an assertion this command makes up. lifecycle:mine is self-scoped
118
- // (entity_id = the caller's own uid, attested by the bearer key) —
119
- // MUST be called with regKey, not apiKey (see note above).
120
- const reached = new Set();
121
- if (regKey) {
122
- try {
123
- const mine = await ask(base, regKey, 'lifecycle:mine', {});
124
- const rows = (mine.result?.rows) ?? [];
125
- for (const r of rows)
126
- reached.add(r.to_stage);
127
- }
128
- catch {
129
- // lifecycle:mine itself failing (e.g. no DB in a local dev target)
130
- // must never block reporting what we already know from provisioning.
131
- }
132
- }
133
- if (uid) {
134
- reached.add('registered');
135
- reached.add('bootstrapped');
136
- }
137
- const stages = STAGE_ORDER.map((id) => ({ id, done: reached.has(id), guide: STAGE_GUIDE[id] }));
138
- out(cmd, {
139
- ok: true,
140
- uid: uid || '(unknown — no ONE_UID in env; re-run in a fresh dir to see it)',
141
- workspace,
142
- group: workspace, // the word a person reads; `workspace` stays for scripts
143
- url: workspace ? `${base}/u/${workspace}` : base,
144
- key: `${KEY_FILE} (0600)`,
145
- stages,
146
- });
147
- });
148
- return cmd;
149
- }
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function pluginCmd(): Command;
@@ -1,193 +0,0 @@
1
- import { Command } from 'commander';
2
- import { mkdirSync } from 'node:fs';
3
- import { spawnSync } from 'node:child_process';
4
- import { jsonMode, resolveBase, resolveKey } from './lib/client.js';
5
- function out(label, data, cmd) {
6
- if (cmd ? jsonMode(cmd) : process.env.ONEIE_JSON) {
7
- process.stdout.write(JSON.stringify({ cmd: label, ...data }) + '\n');
8
- }
9
- else {
10
- const ok = data.ok !== false;
11
- const pairs = Object.entries(data)
12
- .filter(([k]) => k !== 'ok')
13
- .map(([k, v]) => `${k}=${JSON.stringify(v)}`)
14
- .join(' ');
15
- console.log(`${ok ? '✓' : '✗'} ${label} ${pairs}`);
16
- }
17
- }
18
- function apiBase(opts) {
19
- return resolveBase(opts, 'https://one.ie');
20
- }
21
- function bearerHeaders(workspace) {
22
- // THE TOKEN IS THE PLAIN KEY -- the eleventh site of the `${slug}:${key}` bug.
23
- // `requireAuth` (one.ie/web/src/lib/api-auth.ts:317) resolves a world key by
24
- // PREFIX (`one-` / `osk_`), so prepending "<workspace>:" produces
25
- // `one:one-abc...`, which matches no prefix, falls through to session auth and
26
- // 401s. Ten call sites in agent.ts and skill.ts were fixed for exactly this;
27
- // this one was missed, which broke `plugin buy` (POST /api/ask/plugins:buy,
28
- // gated by requireAuth) and `plugin source` for every key-authenticated user.
29
- // The workspace still gates whether we send auth at all -- it just never
30
- // belonged inside the credential.
31
- const key = resolveKey();
32
- return key && workspace ? { Authorization: `Bearer ${key}` } : {};
33
- }
34
- // npm pack wraps a package's contents under a "package/" root — strip-components=1 lands
35
- // the real package.json + src/ directly at ./plugin-<name>/, same as a real npm install would.
36
- function extractTarball(bytes, targetDir) {
37
- mkdirSync(targetDir, { recursive: true });
38
- const tar = spawnSync('tar', ['-xz', '--strip-components=1', '-C', targetDir], {
39
- input: bytes,
40
- stdio: ['pipe', 'inherit', 'inherit'],
41
- });
42
- if (tar.status !== 0)
43
- throw new Error(`tar failed extracting to ${targetDir}`);
44
- }
45
- export function pluginCmd() {
46
- const cmd = new Command('plugin').description('Manage ONE plugins');
47
- cmd
48
- .command('list')
49
- .description('List available plugins and their pricing')
50
- .option('--api <url>', 'API base URL')
51
- .action(async (opts) => {
52
- let res;
53
- try {
54
- res = await fetch(`${apiBase(opts)}/api/plugins`);
55
- }
56
- catch (e) {
57
- console.error(`Error: ${e instanceof Error ? e.message : e}`);
58
- process.exit(1);
59
- }
60
- const body = (await res.json());
61
- if (!res.ok || !body.plugins) {
62
- out('plugin:list', { ok: false, error: 'fetch_failed', status: res.status });
63
- process.exit(1);
64
- }
65
- for (const p of body.plugins) {
66
- console.log(` ${p.name.padEnd(12)} ${p.title.padEnd(16)} $${p.price_usd}/mo ${p.description}`);
67
- }
68
- out('plugin:list', { ok: true, count: body.plugins.length });
69
- });
70
- cmd
71
- .command('add <name>')
72
- .description('Install a plugin — pulls source when workspace is entitled')
73
- .option('--workspace <slug>', 'Workspace slug (default: ONEIE_WORKSPACE env)')
74
- .option('--api <url>', 'API base URL')
75
- .action(async (name, opts) => {
76
- const workspace = opts.workspace ?? process.env.ONEIE_WORKSPACE;
77
- if (!workspace) {
78
- console.error('Error: --workspace or ONEIE_WORKSPACE required');
79
- process.exit(1);
80
- }
81
- let res;
82
- try {
83
- res = await fetch(`${apiBase(opts)}/api/plugins/${name}/source`, {
84
- headers: bearerHeaders(workspace),
85
- });
86
- }
87
- catch (e) {
88
- console.error(`Error: ${e instanceof Error ? e.message : e}`);
89
- process.exit(1);
90
- }
91
- // Paid plugins (PAID_FEATURES) stream a real gzip tarball on 200; free plugins keep
92
- // the JSON pointer to their public npm package. Discriminate before parsing the body.
93
- if (res.ok && res.headers.get('content-type')?.startsWith('application/gzip')) {
94
- const bytes = new Uint8Array(await res.arrayBuffer());
95
- const targetDir = `./plugin-${name}`;
96
- try {
97
- extractTarball(bytes, targetDir);
98
- }
99
- catch (e) {
100
- out('plugin:add', { ok: false, error: 'extract_failed', plugin: name, detail: e instanceof Error ? e.message : String(e) });
101
- process.exit(1);
102
- }
103
- out('plugin:add', { ok: true, plugin: name, extracted: true, path: targetDir });
104
- return;
105
- }
106
- const body = (await res.json());
107
- if (res.status === 402) {
108
- out('plugin:add', {
109
- ok: false,
110
- error: 'not_entitled',
111
- plugin: name,
112
- hint: body.hint ?? `Purchase the ${name} plugin at https://one.ie/marketplace`,
113
- });
114
- process.exit(1);
115
- }
116
- if (!res.ok) {
117
- out('plugin:add', { ok: false, error: body.error ?? 'unknown', plugin: name, status: res.status });
118
- process.exit(1);
119
- }
120
- out('plugin:add', { ok: true, plugin: name, source: body.source, install: body.install });
121
- });
122
- cmd
123
- .command('buy <name>')
124
- .description('Buy a plugin — card (default) or the workspace credit pool (--credits)')
125
- .option('--workspace <slug>', 'Workspace slug (default: ONEIE_WORKSPACE env)')
126
- .option('--credits', 'Pay from the workspace credit pool instead of card')
127
- .option('--api <url>', 'API base URL')
128
- .action(async (name, opts) => {
129
- const workspace = opts.workspace ?? process.env.ONEIE_WORKSPACE;
130
- if (!workspace) {
131
- console.error('Error: --workspace or ONEIE_WORKSPACE required');
132
- process.exit(1);
133
- }
134
- const method = opts.credits ? 'credits' : 'stripe';
135
- let res;
136
- try {
137
- res = await fetch(`${apiBase(opts)}/api/ask/plugins:buy`, {
138
- method: 'POST',
139
- headers: { ...bearerHeaders(workspace), 'Content-Type': 'application/json' },
140
- body: JSON.stringify({ data: { name, method } }),
141
- });
142
- }
143
- catch (e) {
144
- console.error(`Error: ${e instanceof Error ? e.message : e}`);
145
- process.exit(1);
146
- }
147
- const env = (await res.json().catch(() => ({})));
148
- const r = env.result ?? {};
149
- if (!res.ok || env.outcome !== 'result' || r.error) {
150
- out('plugin:buy', { ok: false, plugin: name, error: r.error ?? env.outcome ?? 'failed', status: res.status });
151
- process.exit(1);
152
- }
153
- if (method === 'credits') {
154
- out('plugin:buy', { ok: true, plugin: name, method, entitled: r.entitled, credits_spent: r.credits_spent, install: `one plugin add ${name}` });
155
- }
156
- else {
157
- out('plugin:buy', { ok: true, plugin: name, method, checkout_url: r.url, note: 'Open checkout_url to pay, then: one plugin add ' + name });
158
- }
159
- });
160
- cmd
161
- .command('grant <name>')
162
- .description('Resell a plugin to a client you control — grants the entitlement, no charge')
163
- .requiredOption('--to <client>', 'Client workspace slug to grant the plugin to')
164
- .option('--workspace <slug>', 'Your (reseller) workspace slug (default: ONEIE_WORKSPACE env)')
165
- .option('--api <url>', 'API base URL')
166
- .action(async (name, opts) => {
167
- const workspace = opts.workspace ?? process.env.ONEIE_WORKSPACE;
168
- if (!workspace) {
169
- console.error('Error: --workspace or ONEIE_WORKSPACE required');
170
- process.exit(1);
171
- }
172
- let res;
173
- try {
174
- res = await fetch(`${apiBase(opts)}/api/ask/plugins:grant`, {
175
- method: 'POST',
176
- headers: { ...bearerHeaders(workspace), 'Content-Type': 'application/json' },
177
- body: JSON.stringify({ data: { name, for: opts.to } }),
178
- });
179
- }
180
- catch (e) {
181
- console.error(`Error: ${e instanceof Error ? e.message : e}`);
182
- process.exit(1);
183
- }
184
- const env = (await res.json().catch(() => ({})));
185
- const r = env.result ?? {};
186
- if (!res.ok || env.outcome !== 'result' || r.error) {
187
- out('plugin:grant', { ok: false, plugin: name, client: opts.to, error: r.error ?? env.outcome ?? 'failed', status: res.status });
188
- process.exit(1);
189
- }
190
- out('plugin:grant', { ok: true, plugin: name, client: opts.to, already: r.already ?? false, note: `Client ${opts.to} is now entitled to ${name}` });
191
- });
192
- return cmd;
193
- }
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function pushCmd(): Command;
package/dist/src/push.js DELETED
@@ -1,115 +0,0 @@
1
- import { Command } from 'commander';
2
- import { compileNode } from './compiler.js';
3
- import { mergeEnv } from './env.js';
4
- import { askPath } from './lib/api-path.js';
5
- const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
6
- function apiKey(env) {
7
- return env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
8
- }
9
- async function ask(base, headers, receiver, data) {
10
- try {
11
- const res = await fetch(askPath(base, receiver), {
12
- method: 'POST', headers, body: JSON.stringify({ data }),
13
- });
14
- if (!res.ok)
15
- return { ok: false, result: {} };
16
- const json = (await res.json().catch(() => ({})));
17
- return { ok: true, result: json.result ?? {} };
18
- }
19
- catch {
20
- return { ok: false, result: {} };
21
- }
22
- }
23
- /** workflow:create resolves the target from requireSlug(ctx), so child workflows need that
24
- * workspace's own owner key. The configured (possibly parent) key can mint it via the walk. */
25
- async function mintOwnerKey(base, headers, slug) {
26
- const r = await ask(base, headers, 'world:mint-owner-key', { slug, label: 'push' });
27
- const k = r.result.key ?? r.result.ownerKey ?? r.result.scopedKey;
28
- return typeof k === 'string' && k ? k : null;
29
- }
30
- export function pushCmd() {
31
- return new Command('push')
32
- .description('Compile ai/ + data/ folders and push to substrate')
33
- .argument('[path]', 'Node root directory (default: cwd)')
34
- .option('--client <slug>', 'Apply client override from clients/<slug>/')
35
- .option('--dry-run', 'Validate and print plan without making substrate calls')
36
- .option('--api <url>', 'API base URL', DEFAULT_API)
37
- .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
38
- .action(async (path, opts) => {
39
- const dir = path ?? process.cwd();
40
- const env = mergeEnv(dir);
41
- const agencySlug = env.AGENCY_SLUG;
42
- if (!agencySlug) {
43
- process.stderr.write('AGENCY_SLUG missing — run `one setup` first\n');
44
- process.exit(1);
45
- }
46
- const { compiled, errors } = await compileNode(dir, agencySlug, { clientSlug: opts.client, dryRun: opts.dryRun });
47
- if (errors.length) {
48
- for (const e of errors)
49
- process.stderr.write(` error: ${e.path}: ${e.message}\n`);
50
- process.exit(1);
51
- }
52
- if (opts.dryRun) {
53
- process.stdout.write(`[dry-run] ${compiled.length} item(s) would push:\n`);
54
- for (const item of compiled) {
55
- const steps = item.applyDiff ? ` (+${item.applyDiff.add.length} steps)` : '';
56
- process.stdout.write(` ${item.receiver} ${item.path}${steps}\n`);
57
- }
58
- return;
59
- }
60
- const base = (opts.api ?? DEFAULT_API).replace(/\/$/, '');
61
- const key = opts.key ?? apiKey(env);
62
- const authHeaders = { 'Content-Type': 'application/json' };
63
- if (key)
64
- authHeaders['Authorization'] = `Bearer ${key}`;
65
- const isWorkflow = (i) => i.receiver === 'workflow:create';
66
- let ok = 0;
67
- // Standard items (agents, skills, context, lifecycles, types …) — explicit-slug receivers
68
- // authorize via the ownership walk, so the configured key covers owned child workspaces.
69
- for (const item of compiled.filter((i) => !isWorkflow(i))) {
70
- const res = await fetch(askPath(base, item.receiver), {
71
- method: 'POST', headers: authHeaders, body: JSON.stringify({ data: item.payload }),
72
- });
73
- if (res.ok)
74
- ok++;
75
- else
76
- process.stderr.write(` failed: ${item.receiver} ${res.status}\n`);
77
- }
78
- // Workflows — two-phase (create → apply-diff) under a workspace-owner key, idempotent by name.
79
- const wfItems = compiled.filter(isWorkflow);
80
- if (wfItems.length) {
81
- const wfKey = (await mintOwnerKey(base, authHeaders, agencySlug)) ?? key;
82
- const wfHeaders = { 'Content-Type': 'application/json', Authorization: `Bearer ${wfKey}` };
83
- // Existing workflows by name → delete a same-name match before recreating (clean re-push).
84
- const list = await ask(base, wfHeaders, 'workflow:list', {});
85
- const rows = (Array.isArray(list.result) ? list.result : (list.result.workflows ?? list.result.items ?? []));
86
- const byName = new Map();
87
- for (const w of rows) {
88
- const n = String(w.name ?? '');
89
- const id = String(w.id ?? w.workflowId ?? '');
90
- if (n && id)
91
- byName.set(n, [...(byName.get(n) ?? []), id]);
92
- }
93
- for (const item of wfItems) {
94
- const name = String(item.payload.name ?? '');
95
- for (const id of byName.get(name) ?? [])
96
- await ask(base, wfHeaders, 'workflow:delete', { workflowId: id });
97
- const created = await ask(base, wfHeaders, 'workflow:create', item.payload);
98
- const wid = created.result.workflowId ?? created.result.id;
99
- if (!created.ok || typeof wid !== 'string') {
100
- process.stderr.write(` failed: workflow:create ${name}\n`);
101
- continue;
102
- }
103
- if (item.applyDiff) {
104
- const applied = await ask(base, wfHeaders, 'workflow:apply-diff', { workflowId: wid, diff: item.applyDiff });
105
- if (!applied.ok || applied.result.ok === false) {
106
- process.stderr.write(` failed: workflow:apply-diff ${name}\n`);
107
- continue;
108
- }
109
- }
110
- ok++;
111
- }
112
- }
113
- process.stdout.write(`Pushed ${ok}/${compiled.length} item(s).\n`);
114
- });
115
- }
@@ -1,21 +0,0 @@
1
- export interface AgencyPL {
2
- slug: string;
3
- name: string | null;
4
- plan: string;
5
- markup_pct: number;
6
- pool: number;
7
- }
8
- export interface ClientPL {
9
- slug: string;
10
- name: string | null;
11
- plan: string;
12
- funded: number;
13
- burned: number;
14
- margin: number;
15
- balance: number;
16
- cap: number | null;
17
- }
18
- /** The CLIENT/PLAN/FUNDED/… table — shared by `status` (with the agency P&L
19
- * header) and `client list` (bare, no header). */
20
- export declare function renderClientTable(clients: ClientPL[], markupPct: number): string;
21
- export declare function renderStatus(agency: AgencyPL, clients: ClientPL[]): string;
@@ -1,32 +0,0 @@
1
- const fmt = (n) => n.toLocaleString('en-US');
2
- const capFmt = (n) => (n == null ? '—' : fmt(n));
3
- function pad(cells, widths) {
4
- return cells.map((c, i) => c.padEnd(widths[i])).join(' ').replace(/\s+$/, '');
5
- }
6
- /** The CLIENT/PLAN/FUNDED/… table — shared by `status` (with the agency P&L
7
- * header) and `client list` (bare, no header). */
8
- export function renderClientTable(clients, markupPct) {
9
- const header = ['CLIENT', 'PLAN', 'FUNDED', 'BURNED', `MARGIN(${markupPct}%)`, 'BALANCE', 'CAP'];
10
- const rows = clients.map((c) => [
11
- c.slug, c.plan, fmt(c.funded), fmt(c.burned), fmt(c.margin), fmt(c.balance), capFmt(c.cap),
12
- ]);
13
- const widths = header.map((h, i) => Math.max(h.length, ...rows.map((r) => r[i].length), 0));
14
- const totalBurned = clients.reduce((s, c) => s + c.burned, 0);
15
- const totalMargin = clients.reduce((s, c) => s + c.margin, 0);
16
- const out = [];
17
- out.push(pad(header, widths));
18
- for (const r of rows)
19
- out.push(pad(r, widths));
20
- if (clients.length === 0)
21
- out.push(' (no clients yet — `one client add <slug>`)');
22
- else
23
- out.push(`\n total burned ${fmt(totalBurned)} · margin ${fmt(totalMargin)} ← your margin this period`);
24
- return out.join('\n');
25
- }
26
- export function renderStatus(agency, clients) {
27
- const out = [];
28
- out.push(`Agency: ${agency.name ?? agency.slug} (${agency.slug}) plan=${agency.plan} markup=${agency.markup_pct}% pool=${fmt(agency.pool)} cr`);
29
- out.push('');
30
- out.push(renderClientTable(clients, agency.markup_pct));
31
- return out.join('\n');
32
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * secrets-device.ts — `one secrets add-device`: make this Mac a reader of your sealed files
3
- * (text/secrets.md deliverable 3; text/secrets-todo.md § C3).
4
- *
5
- * Runs `age-plugin-se keygen --access-control current-biometry -o <identity>`: a key born
6
- * in the Mac's Secure Enclave that never leaves the chip. The identity file is only a
7
- * handle to that key (the chip holds the secret), written mode 600 and never overwritten
8
- * without --replace. The `age1se1…` lock is then appended to ~/.one/secrets-readers.json,
9
- * where C1's `seal` finds it.
10
- *
11
- * The access control is NOT a flag. Real use is always `current-biometry`; the test seam
12
- * below is a module value the command line cannot reach.
13
- *
14
- * Nothing the identity holds is read or printed here: the lock comes from
15
- * `age-plugin-se recipients -i`, and age-plugin-se's own output is discarded.
16
- */
17
- import type { Command } from 'commander';
18
- /** The Secure Enclave identity file. ONE_SECRETS_DEVICE moves it (tests). */
19
- export declare function deviceIdentityFile(): string;
20
- /**
21
- * Test seam. Only a test module can set it; there is no flag and no env var for it, so a
22
- * person at a terminal always gets the finger rule. A key made with `none` opens without Touch ID.
23
- */
24
- export declare const deviceSeam: {
25
- accessControl: 'current-biometry' | 'none';
26
- };
27
- interface AddDeviceOpts {
28
- name?: string;
29
- replace?: boolean;
30
- }
31
- export declare function addDeviceAction(o: AddDeviceOpts, c: Command): Promise<void>;
32
- export {};