oneie 5.7.6 → 5.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/README.md +19 -1
  2. package/dist/package.json +7 -8
  3. package/dist/src/age-yefbe8pe.js +1 -0
  4. package/dist/src/evm-tx-ee2q0e3w.js +1 -0
  5. package/dist/src/hl-run-tgrkrk69.js +1 -0
  6. package/dist/src/index-0rj9wdk9.js +4 -0
  7. package/dist/src/index-91y484c2.js +2052 -0
  8. package/dist/src/index-940y3rnv.js +12 -0
  9. package/dist/src/index.js +1047 -121
  10. package/dist/src/message-key-db1xjdkw.js +1 -0
  11. package/dist/src/message-lock-5vr8079x.js +5 -0
  12. package/dist/src/sweep-order-c2p6rk8c.js +1 -0
  13. package/dist/src/sweep-runner-t68xe7vx.js +1 -0
  14. package/package.json +7 -8
  15. package/dist/src/agent.d.ts +0 -75
  16. package/dist/src/agent.js +0 -1334
  17. package/dist/src/agentverse.d.ts +0 -26
  18. package/dist/src/agentverse.js +0 -171
  19. package/dist/src/args.d.ts +0 -9
  20. package/dist/src/args.js +0 -61
  21. package/dist/src/auth.d.ts +0 -6
  22. package/dist/src/auth.js +0 -121
  23. package/dist/src/balances.d.ts +0 -89
  24. package/dist/src/balances.js +0 -202
  25. package/dist/src/banner.d.ts +0 -1
  26. package/dist/src/banner.js +0 -17
  27. package/dist/src/broadcast.d.ts +0 -8
  28. package/dist/src/broadcast.js +0 -175
  29. package/dist/src/catalog.d.ts +0 -12
  30. package/dist/src/catalog.js +0 -76
  31. package/dist/src/chat.d.ts +0 -2
  32. package/dist/src/chat.js +0 -92
  33. package/dist/src/client.d.ts +0 -5
  34. package/dist/src/client.js +0 -157
  35. package/dist/src/compiler.d.ts +0 -36
  36. package/dist/src/compiler.js +0 -366
  37. package/dist/src/config.d.ts +0 -24
  38. package/dist/src/config.js +0 -70
  39. package/dist/src/connect.d.ts +0 -2
  40. package/dist/src/connect.js +0 -64
  41. package/dist/src/coordinate.d.ts +0 -3
  42. package/dist/src/coordinate.js +0 -58
  43. package/dist/src/create.d.ts +0 -2
  44. package/dist/src/create.js +0 -113
  45. package/dist/src/deploy.d.ts +0 -2
  46. package/dist/src/deploy.js +0 -19
  47. package/dist/src/dev.d.ts +0 -2
  48. package/dist/src/dev.js +0 -75
  49. package/dist/src/device-flow.d.ts +0 -57
  50. package/dist/src/device-flow.js +0 -173
  51. package/dist/src/doctor.d.ts +0 -26
  52. package/dist/src/doctor.js +0 -146
  53. package/dist/src/draw.d.ts +0 -18
  54. package/dist/src/draw.js +0 -156
  55. package/dist/src/endpoint.d.ts +0 -2
  56. package/dist/src/endpoint.js +0 -250
  57. package/dist/src/env.d.ts +0 -3
  58. package/dist/src/env.js +0 -37
  59. package/dist/src/eval.d.ts +0 -2
  60. package/dist/src/eval.js +0 -43
  61. package/dist/src/fn.d.ts +0 -2
  62. package/dist/src/fn.js +0 -70
  63. package/dist/src/group.d.ts +0 -2
  64. package/dist/src/group.js +0 -117
  65. package/dist/src/hl-run.d.ts +0 -119
  66. package/dist/src/hl-run.js +0 -480
  67. package/dist/src/hl.d.ts +0 -17
  68. package/dist/src/hl.js +0 -148
  69. package/dist/src/index.d.ts +0 -2
  70. package/dist/src/init.d.ts +0 -76
  71. package/dist/src/init.js +0 -278
  72. package/dist/src/join.d.ts +0 -11
  73. package/dist/src/join.js +0 -293
  74. package/dist/src/key-publish.d.ts +0 -40
  75. package/dist/src/key-publish.js +0 -232
  76. package/dist/src/key-seal.d.ts +0 -21
  77. package/dist/src/key-seal.js +0 -142
  78. package/dist/src/key-sweep.d.ts +0 -93
  79. package/dist/src/key-sweep.js +0 -263
  80. package/dist/src/key.d.ts +0 -26
  81. package/dist/src/key.js +0 -338
  82. package/dist/src/lib/age-plugin.d.ts +0 -51
  83. package/dist/src/lib/age-plugin.js +0 -130
  84. package/dist/src/lib/agent-env.d.ts +0 -12
  85. package/dist/src/lib/agent-env.js +0 -48
  86. package/dist/src/lib/api-path.d.ts +0 -2
  87. package/dist/src/lib/api-path.js +0 -40
  88. package/dist/src/lib/asker.d.ts +0 -34
  89. package/dist/src/lib/asker.js +0 -126
  90. package/dist/src/lib/client.d.ts +0 -20
  91. package/dist/src/lib/client.js +0 -71
  92. package/dist/src/lib/env-sealed.d.ts +0 -53
  93. package/dist/src/lib/env-sealed.js +0 -184
  94. package/dist/src/lib/flow-tag.d.ts +0 -86
  95. package/dist/src/lib/flow-tag.js +0 -230
  96. package/dist/src/lib/hl-core/actions.d.ts +0 -99
  97. package/dist/src/lib/hl-core/actions.js +0 -69
  98. package/dist/src/lib/hl-core/eip712.d.ts +0 -33
  99. package/dist/src/lib/hl-core/eip712.js +0 -107
  100. package/dist/src/lib/hl-core/errors.d.ts +0 -10
  101. package/dist/src/lib/hl-core/errors.js +0 -15
  102. package/dist/src/lib/hl-core/exchange.d.ts +0 -24
  103. package/dist/src/lib/hl-core/exchange.js +0 -47
  104. package/dist/src/lib/hl-core/index.d.ts +0 -13
  105. package/dist/src/lib/hl-core/index.js +0 -14
  106. package/dist/src/lib/hl-core/meta.d.ts +0 -57
  107. package/dist/src/lib/hl-core/meta.js +0 -110
  108. package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
  109. package/dist/src/lib/hl-core/msgpack.js +0 -136
  110. package/dist/src/lib/hl-core/net.d.ts +0 -2
  111. package/dist/src/lib/hl-core/net.js +0 -7
  112. package/dist/src/lib/hl-core/signing.d.ts +0 -103
  113. package/dist/src/lib/hl-core/signing.js +0 -295
  114. package/dist/src/lib/hl-core/wire.d.ts +0 -34
  115. package/dist/src/lib/hl-core/wire.js +0 -81
  116. package/dist/src/lib/invoked-as.d.ts +0 -2
  117. package/dist/src/lib/invoked-as.js +0 -24
  118. package/dist/src/lib/journey-words.d.ts +0 -84
  119. package/dist/src/lib/journey-words.js +0 -360
  120. package/dist/src/lib/journey.d.ts +0 -148
  121. package/dist/src/lib/journey.js +0 -245
  122. package/dist/src/lib/key-receipt.d.ts +0 -48
  123. package/dist/src/lib/key-receipt.js +0 -116
  124. package/dist/src/lib/key-source.d.ts +0 -9
  125. package/dist/src/lib/key-source.js +0 -33
  126. package/dist/src/lib/keyfile.d.ts +0 -136
  127. package/dist/src/lib/keyfile.js +0 -397
  128. package/dist/src/lib/launch-claude.d.ts +0 -5
  129. package/dist/src/lib/launch-claude.js +0 -45
  130. package/dist/src/lib/lock-lookup.d.ts +0 -40
  131. package/dist/src/lib/lock-lookup.js +0 -92
  132. package/dist/src/lib/message-seal.d.ts +0 -63
  133. package/dist/src/lib/message-seal.js +0 -150
  134. package/dist/src/lib/network.d.ts +0 -15
  135. package/dist/src/lib/network.js +0 -41
  136. package/dist/src/lib/paths.d.ts +0 -41
  137. package/dist/src/lib/paths.js +0 -91
  138. package/dist/src/lib/plan-draw.d.ts +0 -56
  139. package/dist/src/lib/plan-draw.js +0 -219
  140. package/dist/src/lib/plan-live.d.ts +0 -20
  141. package/dist/src/lib/plan-live.js +0 -192
  142. package/dist/src/lib/qr.d.ts +0 -21
  143. package/dist/src/lib/qr.js +0 -402
  144. package/dist/src/lib/roster.d.ts +0 -20
  145. package/dist/src/lib/roster.js +0 -79
  146. package/dist/src/lib/sale-card.d.ts +0 -117
  147. package/dist/src/lib/sale-card.js +0 -261
  148. package/dist/src/lib/shop-init.d.ts +0 -62
  149. package/dist/src/lib/shop-init.js +0 -63
  150. package/dist/src/lib/sui-grpc-send.d.ts +0 -50
  151. package/dist/src/lib/sui-grpc-send.js +0 -89
  152. package/dist/src/lib/swap-core.d.ts +0 -163
  153. package/dist/src/lib/swap-core.js +0 -405
  154. package/dist/src/lib/tasks-digest.d.ts +0 -66
  155. package/dist/src/lib/tasks-digest.js +0 -200
  156. package/dist/src/lib/tasks-graph.d.ts +0 -79
  157. package/dist/src/lib/tasks-graph.js +0 -463
  158. package/dist/src/lib/tasks-lens.d.ts +0 -31
  159. package/dist/src/lib/tasks-lens.js +0 -47
  160. package/dist/src/lib/tasks-next.d.ts +0 -25
  161. package/dist/src/lib/tasks-next.js +0 -103
  162. package/dist/src/lib/tasks-prove.d.ts +0 -15
  163. package/dist/src/lib/tasks-prove.js +0 -68
  164. package/dist/src/lib/tasks-route.d.ts +0 -29
  165. package/dist/src/lib/tasks-route.js +0 -151
  166. package/dist/src/lib/tasks-score.d.ts +0 -36
  167. package/dist/src/lib/tasks-score.js +0 -152
  168. package/dist/src/lib/tasks-workspace.d.ts +0 -18
  169. package/dist/src/lib/tasks-workspace.js +0 -73
  170. package/dist/src/lib/vault-read.d.ts +0 -24
  171. package/dist/src/lib/vault-read.js +0 -77
  172. package/dist/src/lib/vaultfile.d.ts +0 -88
  173. package/dist/src/lib/vaultfile.js +0 -222
  174. package/dist/src/lib/wallet-money.d.ts +0 -222
  175. package/dist/src/lib/wallet-money.js +0 -578
  176. package/dist/src/lib/wallet-request.d.ts +0 -50
  177. package/dist/src/lib/wallet-request.js +0 -86
  178. package/dist/src/links.d.ts +0 -5
  179. package/dist/src/links.js +0 -45
  180. package/dist/src/media.d.ts +0 -29
  181. package/dist/src/media.js +0 -487
  182. package/dist/src/message-receipt.d.ts +0 -25
  183. package/dist/src/message-receipt.js +0 -71
  184. package/dist/src/message.d.ts +0 -13
  185. package/dist/src/message.js +0 -92
  186. package/dist/src/onboard.d.ts +0 -16
  187. package/dist/src/onboard.js +0 -149
  188. package/dist/src/plugin.d.ts +0 -2
  189. package/dist/src/plugin.js +0 -193
  190. package/dist/src/push.d.ts +0 -2
  191. package/dist/src/push.js +0 -115
  192. package/dist/src/render.d.ts +0 -21
  193. package/dist/src/render.js +0 -32
  194. package/dist/src/secrets-device.d.ts +0 -32
  195. package/dist/src/secrets-device.js +0 -127
  196. package/dist/src/secrets-give.d.ts +0 -125
  197. package/dist/src/secrets-give.js +0 -236
  198. package/dist/src/secrets-list.d.ts +0 -27
  199. package/dist/src/secrets-list.js +0 -84
  200. package/dist/src/secrets-run.d.ts +0 -31
  201. package/dist/src/secrets-run.js +0 -182
  202. package/dist/src/secrets.d.ts +0 -33
  203. package/dist/src/secrets.js +0 -200
  204. package/dist/src/setup.d.ts +0 -6
  205. package/dist/src/setup.js +0 -127
  206. package/dist/src/ship.d.ts +0 -2
  207. package/dist/src/ship.js +0 -18
  208. package/dist/src/shop.d.ts +0 -10
  209. package/dist/src/shop.js +0 -110
  210. package/dist/src/skill-parser.d.ts +0 -14
  211. package/dist/src/skill-parser.js +0 -113
  212. package/dist/src/skill.d.ts +0 -2
  213. package/dist/src/skill.js +0 -493
  214. package/dist/src/slug.d.ts +0 -2
  215. package/dist/src/slug.js +0 -6
  216. package/dist/src/social.d.ts +0 -2
  217. package/dist/src/social.js +0 -106
  218. package/dist/src/staff.d.ts +0 -2
  219. package/dist/src/staff.js +0 -104
  220. package/dist/src/start.d.ts +0 -15
  221. package/dist/src/start.js +0 -203
  222. package/dist/src/status.d.ts +0 -2
  223. package/dist/src/status.js +0 -52
  224. package/dist/src/substrate.d.ts +0 -2
  225. package/dist/src/substrate.js +0 -258
  226. package/dist/src/swap.d.ts +0 -93
  227. package/dist/src/swap.js +0 -622
  228. package/dist/src/tasks.d.ts +0 -2
  229. package/dist/src/tasks.js +0 -743
  230. package/dist/src/templates.d.ts +0 -1
  231. package/dist/src/templates.js +0 -213
  232. package/dist/src/trade.d.ts +0 -2
  233. package/dist/src/trade.js +0 -91
  234. package/dist/src/trail.d.ts +0 -2
  235. package/dist/src/trail.js +0 -41
  236. package/dist/src/validate.d.ts +0 -13
  237. package/dist/src/validate.js +0 -35
  238. package/dist/src/wallet-money.d.ts +0 -152
  239. package/dist/src/wallet-money.js +0 -564
  240. package/dist/src/wallet.d.ts +0 -167
  241. package/dist/src/wallet.js +0 -855
  242. package/dist/src/workflow.d.ts +0 -2
  243. package/dist/src/workflow.js +0 -166
  244. package/dist/src/write.d.ts +0 -43
  245. package/dist/src/write.js +0 -180
@@ -1,25 +0,0 @@
1
- export declare function usd(credits: number | undefined): string | null;
2
- interface Usage {
3
- model?: string;
4
- tokensIn?: number;
5
- tokensOut?: number;
6
- costCredits?: number;
7
- unmetered?: true;
8
- }
9
- interface Frontier {
10
- model?: string;
11
- usd?: number;
12
- }
13
- interface Reply {
14
- text?: string;
15
- model?: string;
16
- picked?: string;
17
- shape?: string;
18
- reason?: string;
19
- usage?: Usage;
20
- frontier?: Frontier;
21
- }
22
- export declare function renderReceipt(reply: Reply, opts?: {
23
- slug?: string;
24
- }): string;
25
- export {};
@@ -1,71 +0,0 @@
1
- /* Message receipt — no imports */
2
- // Up to 6 significant digits, never scientific: a measured $0.00000042 never prints as $0.
3
- function formatDollar(n) {
4
- return n.toLocaleString('en-US', { maximumSignificantDigits: 6, useGrouping: false });
5
- }
6
- export function usd(credits) {
7
- if (typeof credits !== 'number' || !isFinite(credits) || credits < 0) {
8
- return null;
9
- }
10
- const dollars = credits / 1000;
11
- // A positive figure below what a float can divide down to is still not $0.
12
- if (credits > 0 && !(dollars > 0))
13
- return 'under $0.000001';
14
- return '$' + formatDollar(dollars);
15
- }
16
- export function renderReceipt(reply, opts = {}) {
17
- const model = reply.model ?? reply.usage?.model ?? 'unmeasured';
18
- const reason = reply.reason === 'cold'
19
- ? 'cold'
20
- : reply.reason
21
- ? 'warmed'
22
- : 'unmeasured';
23
- const shape = reply.shape ?? 'unmeasured';
24
- // tokens line
25
- const tokensLine = reply.usage &&
26
- typeof reply.usage.tokensIn === 'number' &&
27
- typeof reply.usage.tokensOut === 'number'
28
- ? `${reply.usage.tokensIn} in / ${reply.usage.tokensOut} out`
29
- : 'unmeasured';
30
- // cost line
31
- let costLine;
32
- if (!reply.usage ||
33
- reply.usage.unmetered ||
34
- typeof reply.usage.costCredits !== 'number') {
35
- costLine = 'unmeasured';
36
- }
37
- else {
38
- const usdStr = usd(reply.usage.costCredits);
39
- if (usdStr === null) {
40
- costLine = 'unmeasured';
41
- }
42
- else {
43
- costLine = `${usdStr} est. (measured tokens × registry price)`;
44
- }
45
- }
46
- // billed line
47
- const slug = opts.slug ?? '<your-group>';
48
- const billedLine = `billed pending → https://one.ie/u/${slug}/stream`;
49
- // frontier line
50
- let frontierLine;
51
- if (reply.frontier &&
52
- typeof reply.frontier.usd === 'number' &&
53
- isFinite(reply.frontier.usd) &&
54
- reply.frontier.usd > 0) {
55
- const frontierDollar = reply.frontier.usd;
56
- const frontierUsdStr = '$' + formatDollar(frontierDollar);
57
- frontierLine = `at ${reply.frontier.model ?? 'model'} list price: ${frontierUsdStr}`;
58
- }
59
- else {
60
- frontierLine = 'at frontier list price: unmeasured';
61
- }
62
- const dashLine = '\u2014'.repeat(3); // three em dashes
63
- const lines = [
64
- `model ${model} \u00b7 ${reason} (shape ${shape})`,
65
- `tokens ${tokensLine}`,
66
- `cost ${costLine}`,
67
- billedLine,
68
- frontierLine,
69
- ];
70
- return dashLine + '\n' + lines.join('\n');
71
- }
@@ -1,13 +0,0 @@
1
- export declare const MESSAGE_TIMEOUT_MS = 30000;
2
- export declare const SIGN_IN = "not signed in \u2014 run: npx oneie login";
3
- export interface MessageIO {
4
- fetch: typeof fetch;
5
- key: string;
6
- base: string;
7
- stdout: (s: string) => void;
8
- stderr: (s: string) => void;
9
- }
10
- export declare function sendMessage(text: string, io: MessageIO, opts?: {
11
- json?: boolean;
12
- }): Promise<number>;
13
- export declare function bareMessageArgv(argv: string[], known: ReadonlySet<string>): string[];
@@ -1,92 +0,0 @@
1
- import { askPath } from './lib/api-path.js';
2
- import { renderReceipt } from './message-receipt.js';
3
- export const MESSAGE_TIMEOUT_MS = 30000;
4
- export const SIGN_IN = 'not signed in — run: npx oneie login';
5
- export async function sendMessage(text, io, opts = {}) {
6
- const trimmed = text.trim();
7
- if (!trimmed) {
8
- io.stderr('usage: oneie message <text...>');
9
- return 2;
10
- }
11
- if (!io.key) {
12
- io.stderr(SIGN_IN);
13
- return 1;
14
- }
15
- const url = askPath(io.base, 'world:route');
16
- let response;
17
- try {
18
- response = await io.fetch(url, {
19
- method: 'POST',
20
- headers: {
21
- 'Content-Type': 'application/json',
22
- Authorization: 'Bearer ' + io.key,
23
- },
24
- body: JSON.stringify({
25
- data: { text: trimmed, reply: true, deliver: false },
26
- timeoutMs: MESSAGE_TIMEOUT_MS,
27
- }),
28
- });
29
- }
30
- catch (err) {
31
- io.stderr(`could not reach ${io.base}: ${err instanceof Error ? err.message : String(err)}`);
32
- return 1;
33
- }
34
- // Check HTTP 401/403 FIRST before parsing body
35
- if (response.status === 401 || response.status === 403) {
36
- io.stderr(SIGN_IN);
37
- return 1;
38
- }
39
- let body;
40
- try {
41
- body = await response.json();
42
- }
43
- catch {
44
- body = {};
45
- }
46
- // Treat null or non-object body as failure
47
- if (body === null || typeof body !== 'object' || Array.isArray(body)) {
48
- io.stderr('no answer');
49
- return 1;
50
- }
51
- // Body-level forbidden/unauthor check (redundant for 401/403 but catches 200 with forbidden)
52
- const isForbidden = (body.error &&
53
- (typeof body.error === 'string'
54
- ? /forbidden|unauthor/i.test(body.error)
55
- : /forbidden|unauthor/i.test(body.error.message || ''))) ||
56
- (body.result?.error &&
57
- /forbidden|unauthor/i.test(typeof body.result.error === 'string'
58
- ? body.result.error
59
- : body.result.error.message || ''));
60
- if (isForbidden) {
61
- io.stderr(SIGN_IN);
62
- return 1;
63
- }
64
- if (body.outcome === 'timeout') {
65
- io.stderr('no answer within 30s — the reply is still running; see https://one.ie/u/<you>/stream');
66
- return 1;
67
- }
68
- const reply = body.result?.reply;
69
- if (opts.json) {
70
- const output = JSON.stringify(reply ?? body.result ?? body, null, 2) + '\n';
71
- io.stdout(output);
72
- return reply?.text ? 0 : 1;
73
- }
74
- const answer = reply?.text;
75
- if (!answer) {
76
- const replyError = reply?.error;
77
- const resultError = body.result?.error;
78
- const bodyError = body.error;
79
- const errMsg = replyError || resultError || bodyError || '';
80
- io.stderr(errMsg ? `no answer: ${errMsg}` : 'no answer');
81
- return 1;
82
- }
83
- io.stdout(answer + '\n');
84
- io.stdout(renderReceipt(reply) + '\n');
85
- return 0;
86
- }
87
- export function bareMessageArgv(argv, known) {
88
- if (argv[2] !== undefined && !argv[2].startsWith('-') && !known.has(argv[2])) {
89
- return [argv[0], argv[1], 'message', ...argv.slice(2)];
90
- }
91
- return argv;
92
- }
@@ -1,16 +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
- export declare function onboardCmd(): Command;
@@ -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;