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,76 +0,0 @@
1
- /**
2
- * oneie init — provision a workspace in one command.
3
- *
4
- * Calls POST /api/provision/agent with the provided options, writes the
5
- * returned scoped key to ~/.config/one/key, and prints the workspace URL
6
- * + invite link.
7
- *
8
- * No prior account or API key required. The server mints everything.
9
- */
10
- import { Command } from 'commander';
11
- /**
12
- * Where the new wallet goes. A vault by default; plaintext only on the flag.
13
- * `keychain` seals it under a random secret held in Apple Keychain — the store an
14
- * agent shell can use, since it has no terminal to type a passphrase into and its
15
- * stdout must never carry the words. Touch ID opens it later.
16
- */
17
- export type WalletStore = {
18
- kind: 'vault';
19
- dir: string;
20
- passphrase: string;
21
- } | {
22
- kind: 'keychain';
23
- dir: string;
24
- } | {
25
- kind: 'plaintext';
26
- file: string;
27
- };
28
- /**
29
- * Can init store a wallet at all, before anything is provisioned? The repo's
30
- * key-material rule (keygen --out, key new --out): words reach disk in the clear
31
- * only behind --yes-i-accept-plaintext-file. Otherwise they are SEALED, and
32
- * sealing needs a passphrase typed at a terminal — so a non-interactive run with
33
- * no flag is refused by name, never quietly downgraded to plaintext.
34
- */
35
- export declare function initWalletRefusal(o: {
36
- wallet: boolean;
37
- plaintext: boolean;
38
- interactive: boolean;
39
- }): string | null;
40
- /**
41
- * Give the new agent a wallet it actually holds: mint a v2 key HERE, store it
42
- * FIRST (sealed in the `wallet new` vault, or the 0600 plaintext file on the
43
- * flag), then prove control of each address to the server and register it. The
44
- * order matters — an address registered before its key is stored is an address
45
- * nobody can ever spend from.
46
- *
47
- * The private key and the words never leave this machine: the server sees the
48
- * four addresses and one signature per address over its own fresh challenge.
49
- */
50
- export declare function provisionLocalWallet(opts: {
51
- api: string;
52
- key: string;
53
- workspace: string;
54
- store: WalletStore;
55
- }): Promise<{
56
- ok: boolean;
57
- file?: string;
58
- sealed?: boolean;
59
- keychain?: boolean;
60
- addresses?: Record<string, string>;
61
- error?: string;
62
- }>;
63
- /**
64
- * The wallet lines of init's receipt. Every command in them must run as printed:
65
- * `cli` is `npx oneie` unless this process came in through the `one` bin (under
66
- * npx, `one` is not on PATH — hit live on oneie@5.3.3), and `--dir` is named
67
- * whenever the vault is not in the folder `wallet open` / `wallet paper` default
68
- * to (`init --dir X` seals it in X).
69
- */
70
- export declare function initWalletReceipt(wallet: Awaited<ReturnType<typeof provisionLocalWallet>>, o: {
71
- workspace: string;
72
- dir: string;
73
- vaultDir: string;
74
- cli: string;
75
- }): Record<string, string>;
76
- export declare function initCmd(): Command;
package/dist/src/init.js DELETED
@@ -1,278 +0,0 @@
1
- /**
2
- * oneie init — provision a workspace in one command.
3
- *
4
- * Calls POST /api/provision/agent with the provided options, writes the
5
- * returned scoped key to ~/.config/one/key, and prints the workspace URL
6
- * + invite link.
7
- *
8
- * No prior account or API key required. The server mints everything.
9
- */
10
- import { Command } from 'commander';
11
- import { mkdirSync, existsSync, rmSync } from 'node:fs';
12
- import { resolve, dirname } from 'node:path';
13
- import { mergeEnv, writeEnvLocal } from './env.js';
14
- import { writeKeyFolder } from './lib/keyfile.js';
15
- import { KEY_FILE, CONFIG_DIR, writeMachineKey } from './lib/paths.js';
16
- import { walletFor, writeKeysFile, registerAgentWallet, sealWallet, promptSecret } from './wallet.js';
17
- import { writeVaultFolder, vaultPath, keychainStore } from './lib/vaultfile.js';
18
- import { mintKeychainSecret } from '@oneie/sdk/vault-file';
19
- import { cliPrefix } from './lib/invoked-as.js';
20
- const DEFAULT_API = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
21
- function out(cmd, data) {
22
- const isJson = cmd.parent?.opts().json;
23
- if (isJson) {
24
- process.stdout.write(JSON.stringify(data) + '\n');
25
- }
26
- else if (data.ok) {
27
- const lines = Object.entries(data)
28
- .filter(([k]) => k !== 'ok')
29
- .map(([k, v]) => ` ${k}: ${v}`)
30
- .join('\n');
31
- process.stdout.write(`✓ workspace ready\n${lines}\n`);
32
- }
33
- else {
34
- process.stderr.write(`✗ ${data.error ?? 'failed'}\n`);
35
- }
36
- }
37
- function defaultAgentMd(name) {
38
- const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
39
- return `---
40
- name: ${slug}
41
- kind: agent
42
- title: ${name}
43
- model: claude-sonnet-4-6
44
- channels: [web, api]
45
- group: default
46
- sensitivity: 0.5
47
- lifecycle: active
48
- ---
49
-
50
- You are ${name}. Answer questions clearly and helpfully.
51
- When you complete a task, summarise what you did in one sentence.
52
- `;
53
- }
54
- /**
55
- * Can init store a wallet at all, before anything is provisioned? The repo's
56
- * key-material rule (keygen --out, key new --out): words reach disk in the clear
57
- * only behind --yes-i-accept-plaintext-file. Otherwise they are SEALED, and
58
- * sealing needs a passphrase typed at a terminal — so a non-interactive run with
59
- * no flag is refused by name, never quietly downgraded to plaintext.
60
- */
61
- export function initWalletRefusal(o) {
62
- if (!o.wallet || o.plaintext || o.interactive)
63
- return null;
64
- return 'wallet_passphrase_unavailable: init seals the new wallet with a passphrase typed at a terminal, and stdin is not one. ' +
65
- 'Pass --yes-i-accept-plaintext-file to write a 0600 plaintext wallet file instead, or --no-wallet to skip the wallet';
66
- }
67
- /**
68
- * Give the new agent a wallet it actually holds: mint a v2 key HERE, store it
69
- * FIRST (sealed in the `wallet new` vault, or the 0600 plaintext file on the
70
- * flag), then prove control of each address to the server and register it. The
71
- * order matters — an address registered before its key is stored is an address
72
- * nobody can ever spend from.
73
- *
74
- * The private key and the words never leave this machine: the server sees the
75
- * four addresses and one signature per address over its own fresh challenge.
76
- */
77
- export async function provisionLocalWallet(opts) {
78
- const target = opts.store.kind === 'plaintext' ? opts.store.file : vaultPath(opts.store.dir);
79
- // Never replace a wallet: it may hold the only copy of the words behind
80
- // addresses already registered and funded (`wallet new` refuses the same way).
81
- if (existsSync(target)) {
82
- return { ok: false, file: target, error: 'wallet_file_exists (kept untouched)' };
83
- }
84
- try {
85
- const { wallet, derivation } = await walletFor({}, () => '');
86
- if (opts.store.kind !== 'plaintext') {
87
- const authPub = wallet.keys.find((k) => k.chain === 'sui')?.publicKeyHex ?? '';
88
- const keychain = opts.store.kind === 'keychain';
89
- const secret = keychain ? mintKeychainSecret() : opts.store.passphrase;
90
- const blob = await sealWallet(wallet.mnemonic, secret, { wrap: keychain ? 'keychain' : 'passphrase', authPub, derivation });
91
- const written = writeVaultFolder(opts.store.dir, { ...blob });
92
- if (!written.ok)
93
- return { ok: false, file: target, error: written.error ?? 'vault not written' };
94
- if (keychain) {
95
- const k = keychainStore(authPub, secret);
96
- // A vault sealed under a secret nobody holds is a wallet nobody can open.
97
- // Remove it before any address is registered, the way `wallet new --keychain` does.
98
- if (!k.ok) {
99
- rmSync(written.path, { force: true });
100
- return { ok: false, file: target, error: `keychain_write_failed (${k.error}) — the wallet was removed, nothing was registered` };
101
- }
102
- }
103
- }
104
- else {
105
- mkdirSync(dirname(opts.store.file), { recursive: true, mode: 0o700 });
106
- writeKeysFile(opts.store.file, JSON.stringify({ mnemonic: wallet.mnemonic, derivation, keys: wallet.keys, workspace: opts.workspace }, null, 2) + '\n', true);
107
- }
108
- const sealed = opts.store.kind !== 'plaintext';
109
- const keychain = opts.store.kind === 'keychain';
110
- const res = await registerAgentWallet({
111
- base: opts.api.replace(/\/$/, ''), key: opts.key, workspace: opts.workspace, actor: opts.workspace, keys: wallet.keys,
112
- });
113
- if (!res.ok)
114
- return { ok: false, file: target, sealed, keychain, error: String(res.error ?? 'wallet:create refused') };
115
- return { ok: true, file: target, sealed, keychain, addresses: (res.addresses ?? {}) };
116
- }
117
- catch (err) {
118
- return { ok: false, file: target, error: err.message };
119
- }
120
- }
121
- /**
122
- * The wallet lines of init's receipt. Every command in them must run as printed:
123
- * `cli` is `npx oneie` unless this process came in through the `one` bin (under
124
- * npx, `one` is not on PATH — hit live on oneie@5.3.3), and `--dir` is named
125
- * whenever the vault is not in the folder `wallet open` / `wallet paper` default
126
- * to (`init --dir X` seals it in X).
127
- */
128
- export function initWalletReceipt(wallet, o) {
129
- const atVault = resolve(o.vaultDir) === resolve(o.dir) ? '' : ` --dir ${o.vaultDir}`;
130
- return {
131
- wallet: wallet.keychain
132
- ? `${wallet.file} (sealed in Apple Keychain — Touch ID opens it; run \`${o.cli} wallet paper${atVault}\` in your own terminal to write the 24 words down)`
133
- : wallet.sealed
134
- ? `${wallet.file} (sealed with your passphrase — \`${o.cli} wallet open${atVault}\` to read it, \`${o.cli} wallet paper${atVault}\` to back it up)`
135
- : `${wallet.file} (0600 PLAINTEXT — the 24 words and keys; back it up, never commit it)`,
136
- ...(wallet.ok ? { addresses: Object.entries(wallet.addresses ?? {}).filter(([, a]) => a).map(([c, a]) => `${c} ${a}`).join(', ') } : {}),
137
- ...(!wallet.ok ? { wallet_error: wallet.sealed === false
138
- ? `${wallet.error} — retry: ${o.cli} wallet register --kind agent --workspace ${o.workspace} --from ${wallet.file}`
139
- : wallet.sealed === true
140
- ? `${wallet.error} — retry: ${o.cli} wallet register --kind agent --workspace ${o.workspace} --dir ${o.vaultDir}`
141
- : `${wallet.error}` } : {}),
142
- };
143
- }
144
- export function initCmd() {
145
- const cmd = new Command('init')
146
- .description('Provision a new workspace in one command — no account required')
147
- .option('--name <name>', 'Workspace / agent display name')
148
- .option('--email <email>', 'Owner email — receives an invite link')
149
- .option('--skills <refs>', 'Comma-separated skill refs to import (e.g. cold-email,calendar-lookup)')
150
- .option('--no-content', 'Skip generating a starter agent.md')
151
- .option('--api <url>', 'API base URL', DEFAULT_API)
152
- .option('--write-env', 'Also write ONE_API_KEY to .env.local in the current directory')
153
- .option('--dir <path>', 'Write the key into THIS project folder (.one/agent.key, 0600, gitignored) instead of the machine-wide ~/.config/one/key')
154
- .option('--ttl-days <n>', 'Key lifetime in days (default 90, max 365)')
155
- .option('--no-wallet', 'Skip minting a local wallet and registering its addresses')
156
- .option('--yes-i-accept-plaintext-file', 'Write the new wallet as a 0600 PLAINTEXT file instead of sealing it with a passphrase — needed for a non-interactive run')
157
- .action(async (opts) => {
158
- const dir = process.cwd();
159
- // Decided BEFORE anything is provisioned: a refusal here creates nothing.
160
- const plaintext = Boolean(opts.yesIAcceptPlaintextFile);
161
- const refusal = initWalletRefusal({ wallet: opts.wallet !== false, plaintext, interactive: Boolean(process.stdin.isTTY) });
162
- if (refusal) {
163
- out(cmd, { ok: false, error: refusal });
164
- process.exitCode = 1;
165
- return;
166
- }
167
- let passphrase = '';
168
- if (opts.wallet !== false && !plaintext) {
169
- passphrase = await promptSecret('Passphrase to seal the new wallet: ');
170
- if (passphrase !== (await promptSecret('Repeat it: '))) {
171
- out(cmd, { ok: false, error: 'passphrases did not match — nothing was created' });
172
- process.exitCode = 1;
173
- return;
174
- }
175
- if (passphrase.length < 8) {
176
- out(cmd, { ok: false, error: 'passphrase too short — nothing was created' });
177
- process.exitCode = 1;
178
- return;
179
- }
180
- }
181
- if (opts.writeEnv) {
182
- const env = mergeEnv(dir);
183
- if (env.ONE_API_KEY) {
184
- out(cmd, { ok: true, note: 'already connected — .env.local has ONE_API_KEY' });
185
- return;
186
- }
187
- }
188
- const name = opts.name ?? 'My Agent';
189
- const skills = opts.skills ? opts.skills.split(',').map(s => s.trim()).filter(Boolean) : [];
190
- const content = opts.content !== false ? defaultAgentMd(name) : undefined;
191
- const body = { name, live: true };
192
- if (content)
193
- body.content = content;
194
- if (skills.length)
195
- body.skills = skills;
196
- if (opts.email)
197
- body.invite = { email: opts.email, role: 'owner' };
198
- if (opts.ttlDays)
199
- body.ttlDays = Number(opts.ttlDays);
200
- let res;
201
- try {
202
- res = await fetch(`${opts.api.replace(/\/$/, '')}/api/provision/agent`, {
203
- method: 'POST',
204
- headers: { 'Content-Type': 'application/json' },
205
- body: JSON.stringify(body),
206
- });
207
- }
208
- catch (err) {
209
- out(cmd, { ok: false, error: `network error: ${err.message}` });
210
- return;
211
- }
212
- const json = await res.json();
213
- if (!res.ok) {
214
- out(cmd, { ok: false, ...json });
215
- return;
216
- }
217
- const { workspace, apiKey, regKey, uid, expiresAt, inviteUrl } = json;
218
- // --dir writes the credential INTO the project, which is narrower than the
219
- // machine-wide default: one project's key, revocable alone, gone when the
220
- // folder is. The ceremony writes the ignore entry BEFORE the key and
221
- // refuses to write a key at all if it cannot — see lib/keyfile.ts.
222
- let keyLocation;
223
- let walletFile = resolve(CONFIG_DIR, 'wallets', `${workspace}.json`);
224
- let vaultDir = dir;
225
- if (opts.dir) {
226
- const res = writeKeyFolder({
227
- dir: opts.dir,
228
- apiKey,
229
- regKey,
230
- workspace,
231
- uid,
232
- api: opts.api,
233
- expiresAt,
234
- });
235
- if (!res.ok) {
236
- out(cmd, { ok: false, error: res.error ?? 'could not write key folder' });
237
- return;
238
- }
239
- keyLocation = `${res.keyPath} (0600, ignored via ${res.ignorePath})`;
240
- if (res.keyPath)
241
- walletFile = resolve(dirname(res.keyPath), 'wallet.json');
242
- vaultDir = opts.dir;
243
- }
244
- else {
245
- // The MACHINE key is regKey, not apiKey (text/agent-handover.md § 0). regKey's actor
246
- // IS the workspace slug, so callerControlsWorkspace (resolvers/_shared.ts:302) and
247
- // requireGroupOwner (world-receivers.ts:210) pass by identity; apiKey is scoped to a
248
- // random actor id and fails deep as `forbidden`. The plugin's tools and every CLI
249
- // command read this one file, so it must hold the key that can act on the workspace.
250
- writeMachineKey(regKey || apiKey);
251
- keyLocation = `${KEY_FILE} (0600)`;
252
- }
253
- if (opts.writeEnv) {
254
- writeEnvLocal(dir, { ONE_API_KEY: apiKey, ONE_API_URL: opts.api });
255
- }
256
- // Non-fatal: the workspace exists either way. A refusal is REPORTED, with
257
- // the file kept, so `one wallet register --kind agent --from <file>` (or
258
- // `--dir <folder>` for the sealed vault) retries.
259
- const wallet = opts.wallet !== false
260
- ? await provisionLocalWallet({
261
- api: opts.api, key: regKey || apiKey, workspace,
262
- store: plaintext ? { kind: 'plaintext', file: walletFile } : { kind: 'vault', dir: vaultDir, passphrase },
263
- })
264
- : null;
265
- out(cmd, {
266
- ok: true,
267
- workspace,
268
- url: `${opts.api.replace(/\/$/, '')}/u/${workspace}`,
269
- key: keyLocation,
270
- ...(expiresAt ? { expires: new Date(expiresAt * 1000).toISOString() } : {}),
271
- ...(opts.writeEnv ? { env: `${dir}/.env.local`, mcp: 'export ONE_API_KEY before launching Claude Code — MCP reads the shell env, not .env.local directly' } : {}),
272
- ...(inviteUrl ? { invite: inviteUrl } : {}),
273
- ...(wallet ? initWalletReceipt(wallet, { workspace, dir, vaultDir, cli: cliPrefix() }) : {}),
274
- ...(skills.length ? { skills: skills.join(', ') } : {}),
275
- });
276
- });
277
- return cmd;
278
- }
@@ -1,11 +0,0 @@
1
- import type { Command } from 'commander';
2
- export declare const JOIN_VERBS: readonly ["request", "requests", "approve"];
3
- /** The door block `oneie --help` ends with. Bare `oneie` runs the journey instead (start.ts). */
4
- export declare function bareDoors(agent: boolean): string;
5
- export declare function joinCommands(program: Command): void;
6
- /**
7
- * `oneie group follow|unfollow <group>` — watch a PUBLIC group
8
- * (text/join-existing-plan.md W3 D2). Mounted on the existing `group` command
9
- * by group.ts, because a top-level `follow` is taken.
10
- */
11
- export declare function watchCommands(group: Command): void;
package/dist/src/join.js DELETED
@@ -1,293 +0,0 @@
1
- import { jsonMode, resolveBase, resolveKey } from './lib/client.js';
2
- import { askPath } from './lib/api-path.js';
3
- // The existing-group door (text/join-existing-plan.md § W2). A newcomer — person
4
- // or agent — becomes someone (`oneie login`), asks a group's owner to let them
5
- // in, and the owner answers. Each verb is one receiver through the ask door; the
6
- // receiver owns authority, validation and the owner notice.
7
- //
8
- // `follow <group>` is NOT a top-level verb: `oneie follow <type>` is already the
9
- // path-selection verb (substrate.ts), and commander 12 throws on a duplicate
10
- // name at registration — before index.ts reaches the bare-argv check — so a
11
- // second `follow` would crash every invocation, bare `oneie` included. Watching
12
- // a group is `oneie group follow <group>` (watchCommands, mounted by group.ts).
13
- const DEFAULT_API = 'https://one.ie';
14
- const ROLES = ['viewer', 'member', 'admin'];
15
- const STATUSES = ['pending', 'approved', 'rejected'];
16
- export const JOIN_VERBS = ['request', 'requests', 'approve'];
17
- /** The door block `oneie --help` ends with. Bare `oneie` runs the journey instead (start.ts). */
18
- export function bareDoors(agent) {
19
- const newGroup = agent
20
- ? ' oneie init --write-env # provision a group, no account required\n' +
21
- ' oneie onboard # provision + walk the lifecycle stages\n'
22
- : ' npx oneie create <name> # scaffold a new group\n';
23
- return ('new group:\n' +
24
- ' npx oneie [--email <owner>] # your key, a product, a test sale, then one link to hand it over\n' +
25
- newGroup +
26
- 'existing group:\n' +
27
- ' oneie login # become someone — no new group\n' +
28
- " oneie request <group> [--reason] # ask the owner to let you in\n" +
29
- " oneie requests [--group <g>] # your asks, or an owner's queue\n" +
30
- ' oneie approve <requestId> [--reject]\n' +
31
- ' oneie group follow <group> # watch a public group\n' +
32
- ' oneie --help # full command reference\n');
33
- }
34
- const NO_KEY = 'no API key — run `oneie login` (or set ONE_API_KEY)';
35
- function fail(cmd, error) {
36
- if (jsonMode(cmd))
37
- process.stdout.write(JSON.stringify({ ok: false, error }) + '\n');
38
- else
39
- process.stderr.write(`error ${error}\n`);
40
- process.exitCode = 1;
41
- }
42
- /** One receiver through the ask door. Throws with the receiver's own reason on any refusal. */
43
- async function ask(api, key, receiver, data) {
44
- const base = resolveBase({ api }, DEFAULT_API);
45
- const res = await fetch(askPath(base, receiver), {
46
- method: 'POST',
47
- headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key}` },
48
- body: JSON.stringify({ data }),
49
- });
50
- const text = await res.text();
51
- let body;
52
- try {
53
- body = text ? JSON.parse(text) : undefined;
54
- }
55
- catch {
56
- throw new Error(`${receiver} → ${res.status} ${text.slice(0, 200)}`);
57
- }
58
- if (!body || !('outcome' in body)) {
59
- if (!res.ok)
60
- throw new Error(`${receiver} → ${res.status} ${text.slice(0, 200)}`);
61
- return body ?? {};
62
- }
63
- if (body.outcome === 'result') {
64
- const r = (body.result ?? {});
65
- if (r.ok === false)
66
- throw new Error(String(r.error ?? `${receiver} refused`));
67
- return r;
68
- }
69
- // A dissolve answers 200 — the signal reached nobody. Name it, never read it as ok.
70
- if (body.outcome === 'dissolved') {
71
- throw new Error(`${receiver} is not live on ${base} yet (dissolved: ${String(body.reason ?? 'no handler')})`);
72
- }
73
- const inner = body.result;
74
- throw new Error(String(inner?.error ?? body.error ?? `${receiver}: ${String(body.outcome)}`));
75
- }
76
- // An unregistered `world:<name>` is not a dissolve on the web door: it is read as
77
- // `world:<tag-expr>` and routed (measured on prod 2026-09-26 — world:list-requests
78
- // answered outcome "result" {routed:"learned", actor:"ceo"}). So an answer missing
79
- // the field the verb exists to return is refused, never printed as empty.
80
- function notLive(receiver, missing, r) {
81
- const routed = r.routed ? ` — routed as a world tag (routed=${String(r.routed)}, actor=${String(r.actor ?? '?')})` : '';
82
- return `${receiver} is not live here yet: answer carried ${missing}${routed}`;
83
- }
84
- /** Resolve the key or refuse; every verb here acts as someone. */
85
- function keyOrFail(cmd) {
86
- const key = resolveKey();
87
- if (!key)
88
- fail(cmd, NO_KEY);
89
- return key || undefined;
90
- }
91
- function cell(v) {
92
- if (v === undefined || v === null || v === '')
93
- return '-';
94
- // A cell is receiver data, and a reason is a stranger's text: no control
95
- // character (ESC, BEL, CR) reaches the terminal.
96
- return String(v).replace(/\p{Cc}+/gu, ' ').replace(/\s+/g, ' ').slice(0, 40);
97
- }
98
- export function joinCommands(program) {
99
- program
100
- .command('request <group>')
101
- .description("Ask a group's owner to let you in — always pends, never auto-grants")
102
- .option('--role <role>', 'Role to ask for: viewer | member | admin')
103
- .option('--reason <text>', 'Why — shown to the owner')
104
- .option('--api <url>', 'API base URL', DEFAULT_API)
105
- .action(async (group, opts, cmd) => {
106
- if (opts.role && !ROLES.includes(opts.role)) {
107
- return fail(cmd, `--role must be one of ${ROLES.join(' | ')} (got "${opts.role}")`);
108
- }
109
- const key = keyOrFail(cmd);
110
- if (!key)
111
- return;
112
- const data = { group };
113
- if (opts.role)
114
- data.role = opts.role;
115
- if (opts.reason)
116
- data.reason = opts.reason;
117
- let r;
118
- try {
119
- r = await ask(opts.api, key, 'world:request-access', data);
120
- }
121
- catch (e) {
122
- return fail(cmd, e.message);
123
- }
124
- if (typeof r.requestId !== 'string')
125
- return fail(cmd, notLive('world:request-access', 'no requestId', r));
126
- if (jsonMode(cmd)) {
127
- process.stdout.write(JSON.stringify({ ok: true, ...r, group }) + '\n');
128
- return;
129
- }
130
- process.stdout.write(`ok requestId=${JSON.stringify(r.requestId)} group=${JSON.stringify(group)}\n`);
131
- if (r.existing === true)
132
- process.stdout.write(`an ask to ${group} was already pending — no new notice sent; check with: oneie requests\n`);
133
- else if (r.notified === true)
134
- process.stdout.write(`the owner of ${group} has been notified — follow the answer with: oneie requests\n`);
135
- else if (r.notified === false)
136
- process.stdout.write(`the owner of ${group} was NOT notified — send them the requestId\n`);
137
- else
138
- process.stdout.write(`pending — the owner answers from their queue; check with: oneie requests\n`);
139
- });
140
- program
141
- .command('requests')
142
- .description("List access requests — your own asks, or an owner's queue for a group")
143
- .option('--group <g>', "Group whose queue to list (owner/admin)")
144
- .option('--status <s>', 'pending | approved | rejected')
145
- .option('--api <url>', 'API base URL', DEFAULT_API)
146
- .action(async (opts, cmd) => {
147
- if (opts.status && !STATUSES.includes(opts.status)) {
148
- return fail(cmd, `--status must be one of ${STATUSES.join(' | ')} (got "${opts.status}")`);
149
- }
150
- const key = keyOrFail(cmd);
151
- if (!key)
152
- return;
153
- const data = {};
154
- if (opts.group)
155
- data.group = opts.group;
156
- if (opts.status)
157
- data.status = opts.status;
158
- let r;
159
- try {
160
- r = await ask(opts.api, key, 'world:list-requests', data);
161
- }
162
- catch (e) {
163
- return fail(cmd, e.message);
164
- }
165
- const list = r.requests ?? r.rows;
166
- if (!Array.isArray(list))
167
- return fail(cmd, notLive('world:list-requests', 'no request list', r));
168
- if (jsonMode(cmd)) {
169
- process.stdout.write(JSON.stringify({ ok: true, ...r }) + '\n');
170
- return;
171
- }
172
- const rows = list;
173
- const total = typeof r.total === 'number' ? r.total : rows.length;
174
- if (rows.length === 0)
175
- process.stdout.write('no requests\n');
176
- else {
177
- const head = ['requestId', 'group', 'role', 'status', 'requester', 'reason'];
178
- const body = rows.map((x) => [
179
- cell(x.requestId ?? x.id),
180
- cell(x.group ?? x.gid),
181
- cell(x.role),
182
- cell(x.status),
183
- cell(x.requester ?? x.actor ?? x.aid ?? x.uid),
184
- cell(x.reason),
185
- ]);
186
- const w = head.map((h, i) => Math.max(h.length, ...body.map((b) => b[i].length)));
187
- for (const line of [head, ...body])
188
- process.stdout.write(line.map((c, i) => c.padEnd(w[i])).join(' ').trimEnd() + '\n');
189
- }
190
- // Absent is not false: only a present `truncated` makes total a floor.
191
- if (r.truncated !== undefined && r.truncated !== false) {
192
- process.stdout.write(`total=${total} truncated — at least ${total}; ${JSON.stringify(r.truncated)}\n`);
193
- }
194
- else {
195
- process.stdout.write(`total=${total}\n`);
196
- }
197
- });
198
- program
199
- .command('approve <requestId>')
200
- .description('Answer an access request — approve by default, --reject to refuse')
201
- .option('--reject', 'Reject instead of approve')
202
- .option('--api <url>', 'API base URL', DEFAULT_API)
203
- .action(async (requestId, opts, cmd) => {
204
- const key = keyOrFail(cmd);
205
- if (!key)
206
- return;
207
- const decision = opts.reject ? 'rejected' : 'approved';
208
- let r;
209
- try {
210
- r = await ask(opts.api, key, 'world:approve-request', { requestId, decision });
211
- }
212
- catch (e) {
213
- return fail(cmd, e.message);
214
- }
215
- // W1 answers `membership` = setMembership's verdict. `failed` (the write
216
- // did not land) or `refused` (the owner guard said no) means the D1
217
- // decision is recorded while the requester still holds no role — the one
218
- // outcome an "ok" line would turn into a lie.
219
- const membership = typeof r.membership === 'string' ? r.membership : undefined;
220
- if (membership === 'failed' || membership === 'refused') {
221
- const error = `approval recorded, but membership was not written (membership=${membership}) — the requester cannot act in the group yet; re-run \`oneie approve ${requestId}\``;
222
- process.exitCode = 1;
223
- if (jsonMode(cmd)) {
224
- process.stdout.write(JSON.stringify({ ...r, ok: false, requestId, decision, error }) + '\n');
225
- }
226
- else {
227
- process.stderr.write(`error ${error}\n`);
228
- }
229
- return;
230
- }
231
- if (jsonMode(cmd)) {
232
- process.stdout.write(JSON.stringify({ ...r, ok: true, requestId, decision }) + '\n');
233
- return;
234
- }
235
- const verdict = membership ? ` membership=${membership}` : '';
236
- process.stdout.write(`ok requestId=${JSON.stringify(requestId)} decision=${JSON.stringify(decision)}${verdict}\n`);
237
- });
238
- }
239
- /**
240
- * `oneie group follow|unfollow <group>` — watch a PUBLIC group
241
- * (text/join-existing-plan.md W3 D2). Mounted on the existing `group` command
242
- * by group.ts, because a top-level `follow` is taken.
243
- */
244
- export function watchCommands(group) {
245
- group
246
- .command('follow <group>')
247
- .description("Watch a public group — its announces reach your inbox (no membership, no role)")
248
- .option('--api <url>', 'API base URL', DEFAULT_API)
249
- .action(async (target, opts, cmd) => {
250
- const key = keyOrFail(cmd);
251
- if (!key)
252
- return;
253
- let r;
254
- try {
255
- r = await ask(opts.api, key, 'groups:follow', { group: target });
256
- }
257
- catch (e) {
258
- return fail(cmd, e.message);
259
- }
260
- if (r.following !== true)
261
- return fail(cmd, notLive('groups:follow', 'no following:true', r));
262
- const slug = typeof r.group === 'string' ? r.group : target;
263
- if (jsonMode(cmd)) {
264
- process.stdout.write(JSON.stringify({ ok: true, ...r, group: slug }) + '\n');
265
- return;
266
- }
267
- process.stdout.write(`ok following ${JSON.stringify(slug)} — its announces now reach your inbox; stop with: oneie group unfollow ${slug}\n`);
268
- });
269
- group
270
- .command('unfollow <group>')
271
- .description('Stop watching a group (a declared subscription on it is left alone)')
272
- .option('--api <url>', 'API base URL', DEFAULT_API)
273
- .action(async (target, opts, cmd) => {
274
- const key = keyOrFail(cmd);
275
- if (!key)
276
- return;
277
- let r;
278
- try {
279
- r = await ask(opts.api, key, 'groups:unfollow', { group: target });
280
- }
281
- catch (e) {
282
- return fail(cmd, e.message);
283
- }
284
- if (r.following !== false)
285
- return fail(cmd, notLive('groups:unfollow', 'no following:false', r));
286
- const slug = typeof r.group === 'string' ? r.group : target;
287
- if (jsonMode(cmd)) {
288
- process.stdout.write(JSON.stringify({ ok: true, ...r, group: slug }) + '\n');
289
- return;
290
- }
291
- process.stdout.write(`ok not following ${JSON.stringify(slug)}\n`);
292
- });
293
- }