oneie 5.8.0 → 5.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -6
- package/dist/package.json +37 -11
- package/dist/src/age-1k8hs4ec.js +1 -0
- package/dist/src/client-n6fpnd9f.js +1 -0
- package/dist/src/evm-tx-cqhm9rtt.js +1 -0
- package/dist/src/hl-run-0pv1e0p2.js +1 -0
- package/dist/src/index-f5vhzspa.js +12 -0
- package/dist/src/index-h3nrt8bx.js +4 -0
- package/dist/src/index-st6k9vhc.js +2062 -0
- package/dist/src/index.js +1122 -134
- package/dist/src/message-key-yczrxszr.js +1 -0
- package/dist/src/message-lock-thr851d5.js +5 -0
- package/dist/src/sweep-order-jrq2hkye.js +1 -0
- package/dist/src/sweep-runner-jftw9em7.js +1 -0
- package/package.json +37 -11
- package/dist/src/agent.d.ts +0 -75
- package/dist/src/agent.js +0 -1334
- package/dist/src/agentverse.d.ts +0 -26
- package/dist/src/agentverse.js +0 -171
- package/dist/src/args.d.ts +0 -9
- package/dist/src/args.js +0 -61
- package/dist/src/auth.d.ts +0 -6
- package/dist/src/auth.js +0 -121
- package/dist/src/balances.d.ts +0 -89
- package/dist/src/balances.js +0 -202
- package/dist/src/banner.d.ts +0 -1
- package/dist/src/banner.js +0 -17
- package/dist/src/broadcast.d.ts +0 -8
- package/dist/src/broadcast.js +0 -175
- package/dist/src/catalog.d.ts +0 -12
- package/dist/src/catalog.js +0 -76
- package/dist/src/ceiling.d.ts +0 -36
- package/dist/src/ceiling.js +0 -189
- package/dist/src/chat.d.ts +0 -2
- package/dist/src/chat.js +0 -92
- package/dist/src/check.d.ts +0 -11
- package/dist/src/check.js +0 -53
- package/dist/src/client.d.ts +0 -5
- package/dist/src/client.js +0 -157
- package/dist/src/compiler.d.ts +0 -36
- package/dist/src/compiler.js +0 -366
- package/dist/src/config.d.ts +0 -24
- package/dist/src/config.js +0 -70
- package/dist/src/connect.d.ts +0 -2
- package/dist/src/connect.js +0 -64
- package/dist/src/coordinate.d.ts +0 -3
- package/dist/src/coordinate.js +0 -58
- package/dist/src/create.d.ts +0 -2
- package/dist/src/create.js +0 -113
- package/dist/src/credits.d.ts +0 -29
- package/dist/src/credits.js +0 -88
- package/dist/src/deploy.d.ts +0 -2
- package/dist/src/deploy.js +0 -19
- package/dist/src/dev.d.ts +0 -2
- package/dist/src/dev.js +0 -75
- package/dist/src/device-flow.d.ts +0 -57
- package/dist/src/device-flow.js +0 -173
- package/dist/src/doctor.d.ts +0 -26
- package/dist/src/doctor.js +0 -146
- package/dist/src/draw.d.ts +0 -18
- package/dist/src/draw.js +0 -156
- package/dist/src/endpoint.d.ts +0 -2
- package/dist/src/endpoint.js +0 -250
- package/dist/src/env.d.ts +0 -3
- package/dist/src/env.js +0 -37
- package/dist/src/eval.d.ts +0 -2
- package/dist/src/eval.js +0 -43
- package/dist/src/fn.d.ts +0 -2
- package/dist/src/fn.js +0 -70
- package/dist/src/group.d.ts +0 -2
- package/dist/src/group.js +0 -117
- package/dist/src/hl-run.d.ts +0 -119
- package/dist/src/hl-run.js +0 -480
- package/dist/src/hl.d.ts +0 -17
- package/dist/src/hl.js +0 -148
- package/dist/src/index.d.ts +0 -2
- package/dist/src/init.d.ts +0 -76
- package/dist/src/init.js +0 -278
- package/dist/src/join.d.ts +0 -11
- package/dist/src/join.js +0 -297
- package/dist/src/key-publish.d.ts +0 -40
- package/dist/src/key-publish.js +0 -232
- package/dist/src/key-seal.d.ts +0 -21
- package/dist/src/key-seal.js +0 -142
- package/dist/src/key-sweep.d.ts +0 -93
- package/dist/src/key-sweep.js +0 -270
- package/dist/src/key.d.ts +0 -26
- package/dist/src/key.js +0 -338
- package/dist/src/lib/age-plugin.d.ts +0 -51
- package/dist/src/lib/age-plugin.js +0 -130
- package/dist/src/lib/agent-env.d.ts +0 -12
- package/dist/src/lib/agent-env.js +0 -48
- package/dist/src/lib/api-path.d.ts +0 -2
- package/dist/src/lib/api-path.js +0 -40
- package/dist/src/lib/asker.d.ts +0 -34
- package/dist/src/lib/asker.js +0 -126
- package/dist/src/lib/check-words.d.ts +0 -57
- package/dist/src/lib/check-words.js +0 -144
- package/dist/src/lib/client.d.ts +0 -20
- package/dist/src/lib/client.js +0 -71
- package/dist/src/lib/env-sealed.d.ts +0 -53
- package/dist/src/lib/env-sealed.js +0 -184
- package/dist/src/lib/flow-tag.d.ts +0 -86
- package/dist/src/lib/flow-tag.js +0 -230
- package/dist/src/lib/hl-core/actions.d.ts +0 -99
- package/dist/src/lib/hl-core/actions.js +0 -69
- package/dist/src/lib/hl-core/eip712.d.ts +0 -33
- package/dist/src/lib/hl-core/eip712.js +0 -107
- package/dist/src/lib/hl-core/errors.d.ts +0 -10
- package/dist/src/lib/hl-core/errors.js +0 -15
- package/dist/src/lib/hl-core/exchange.d.ts +0 -24
- package/dist/src/lib/hl-core/exchange.js +0 -47
- package/dist/src/lib/hl-core/index.d.ts +0 -13
- package/dist/src/lib/hl-core/index.js +0 -14
- package/dist/src/lib/hl-core/meta.d.ts +0 -57
- package/dist/src/lib/hl-core/meta.js +0 -110
- package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
- package/dist/src/lib/hl-core/msgpack.js +0 -136
- package/dist/src/lib/hl-core/net.d.ts +0 -2
- package/dist/src/lib/hl-core/net.js +0 -7
- package/dist/src/lib/hl-core/signing.d.ts +0 -103
- package/dist/src/lib/hl-core/signing.js +0 -295
- package/dist/src/lib/hl-core/wire.d.ts +0 -34
- package/dist/src/lib/hl-core/wire.js +0 -81
- package/dist/src/lib/invoked-as.d.ts +0 -2
- package/dist/src/lib/invoked-as.js +0 -24
- package/dist/src/lib/journey-words.d.ts +0 -84
- package/dist/src/lib/journey-words.js +0 -363
- package/dist/src/lib/journey.d.ts +0 -150
- package/dist/src/lib/journey.js +0 -264
- package/dist/src/lib/key-receipt.d.ts +0 -48
- package/dist/src/lib/key-receipt.js +0 -116
- package/dist/src/lib/key-source.d.ts +0 -9
- package/dist/src/lib/key-source.js +0 -33
- package/dist/src/lib/keyfile.d.ts +0 -136
- package/dist/src/lib/keyfile.js +0 -397
- package/dist/src/lib/launch-claude.d.ts +0 -5
- package/dist/src/lib/launch-claude.js +0 -45
- package/dist/src/lib/lock-lookup.d.ts +0 -40
- package/dist/src/lib/lock-lookup.js +0 -92
- package/dist/src/lib/message-seal.d.ts +0 -63
- package/dist/src/lib/message-seal.js +0 -150
- package/dist/src/lib/net-choice.d.ts +0 -28
- package/dist/src/lib/net-choice.js +0 -72
- package/dist/src/lib/network.d.ts +0 -22
- package/dist/src/lib/network.js +0 -50
- package/dist/src/lib/next-words.d.ts +0 -105
- package/dist/src/lib/next-words.js +0 -298
- package/dist/src/lib/paths.d.ts +0 -41
- package/dist/src/lib/paths.js +0 -91
- package/dist/src/lib/plan-draw.d.ts +0 -56
- package/dist/src/lib/plan-draw.js +0 -219
- package/dist/src/lib/plan-live.d.ts +0 -20
- package/dist/src/lib/plan-live.js +0 -192
- package/dist/src/lib/qr.d.ts +0 -21
- package/dist/src/lib/qr.js +0 -402
- package/dist/src/lib/roster.d.ts +0 -20
- package/dist/src/lib/roster.js +0 -79
- package/dist/src/lib/sale-card.d.ts +0 -117
- package/dist/src/lib/sale-card.js +0 -261
- package/dist/src/lib/shop-init.d.ts +0 -62
- package/dist/src/lib/shop-init.js +0 -63
- package/dist/src/lib/sui-grpc-send.d.ts +0 -90
- package/dist/src/lib/sui-grpc-send.js +0 -128
- package/dist/src/lib/swap-core.d.ts +0 -163
- package/dist/src/lib/swap-core.js +0 -405
- package/dist/src/lib/tasks-digest.d.ts +0 -66
- package/dist/src/lib/tasks-digest.js +0 -200
- package/dist/src/lib/tasks-graph.d.ts +0 -79
- package/dist/src/lib/tasks-graph.js +0 -463
- package/dist/src/lib/tasks-lens.d.ts +0 -31
- package/dist/src/lib/tasks-lens.js +0 -47
- package/dist/src/lib/tasks-next.d.ts +0 -25
- package/dist/src/lib/tasks-next.js +0 -103
- package/dist/src/lib/tasks-prove.d.ts +0 -15
- package/dist/src/lib/tasks-prove.js +0 -68
- package/dist/src/lib/tasks-route.d.ts +0 -29
- package/dist/src/lib/tasks-route.js +0 -151
- package/dist/src/lib/tasks-score.d.ts +0 -36
- package/dist/src/lib/tasks-score.js +0 -152
- package/dist/src/lib/tasks-workspace.d.ts +0 -18
- package/dist/src/lib/tasks-workspace.js +0 -73
- package/dist/src/lib/timed-fetch.d.ts +0 -33
- package/dist/src/lib/timed-fetch.js +0 -59
- package/dist/src/lib/vault-read.d.ts +0 -24
- package/dist/src/lib/vault-read.js +0 -77
- package/dist/src/lib/vaultfile.d.ts +0 -103
- package/dist/src/lib/vaultfile.js +0 -249
- package/dist/src/lib/wallet-money.d.ts +0 -222
- package/dist/src/lib/wallet-money.js +0 -578
- package/dist/src/lib/wallet-request.d.ts +0 -50
- package/dist/src/lib/wallet-request.js +0 -86
- package/dist/src/links.d.ts +0 -5
- package/dist/src/links.js +0 -45
- package/dist/src/media.d.ts +0 -29
- package/dist/src/media.js +0 -487
- package/dist/src/message-receipt.d.ts +0 -25
- package/dist/src/message-receipt.js +0 -71
- package/dist/src/message.d.ts +0 -13
- package/dist/src/message.js +0 -92
- package/dist/src/move.d.ts +0 -36
- package/dist/src/move.js +0 -152
- package/dist/src/network-cmd.d.ts +0 -17
- package/dist/src/network-cmd.js +0 -74
- package/dist/src/next.d.ts +0 -12
- package/dist/src/next.js +0 -67
- package/dist/src/onboard.d.ts +0 -16
- package/dist/src/onboard.js +0 -149
- package/dist/src/plugin.d.ts +0 -2
- package/dist/src/plugin.js +0 -193
- package/dist/src/push.d.ts +0 -2
- package/dist/src/push.js +0 -115
- package/dist/src/render.d.ts +0 -21
- package/dist/src/render.js +0 -32
- package/dist/src/secrets-device.d.ts +0 -32
- package/dist/src/secrets-device.js +0 -127
- package/dist/src/secrets-give.d.ts +0 -125
- package/dist/src/secrets-give.js +0 -236
- package/dist/src/secrets-list.d.ts +0 -27
- package/dist/src/secrets-list.js +0 -84
- package/dist/src/secrets-run.d.ts +0 -31
- package/dist/src/secrets-run.js +0 -182
- package/dist/src/secrets.d.ts +0 -33
- package/dist/src/secrets.js +0 -200
- package/dist/src/setup.d.ts +0 -6
- package/dist/src/setup.js +0 -127
- package/dist/src/ship.d.ts +0 -2
- package/dist/src/ship.js +0 -18
- package/dist/src/shop-buy.d.ts +0 -16
- package/dist/src/shop-buy.js +0 -101
- package/dist/src/shop.d.ts +0 -10
- package/dist/src/shop.js +0 -112
- package/dist/src/skill-parser.d.ts +0 -14
- package/dist/src/skill-parser.js +0 -113
- package/dist/src/skill.d.ts +0 -2
- package/dist/src/skill.js +0 -493
- package/dist/src/slug.d.ts +0 -2
- package/dist/src/slug.js +0 -6
- package/dist/src/social.d.ts +0 -2
- package/dist/src/social.js +0 -106
- package/dist/src/staff.d.ts +0 -2
- package/dist/src/staff.js +0 -104
- package/dist/src/start.d.ts +0 -27
- package/dist/src/start.js +0 -225
- package/dist/src/status.d.ts +0 -2
- package/dist/src/status.js +0 -52
- package/dist/src/substrate.d.ts +0 -2
- package/dist/src/substrate.js +0 -258
- package/dist/src/swap.d.ts +0 -93
- package/dist/src/swap.js +0 -622
- package/dist/src/tasks.d.ts +0 -2
- package/dist/src/tasks.js +0 -743
- package/dist/src/templates.d.ts +0 -1
- package/dist/src/templates.js +0 -213
- package/dist/src/thread.d.ts +0 -2
- package/dist/src/thread.js +0 -52
- package/dist/src/trade.d.ts +0 -2
- package/dist/src/trade.js +0 -91
- package/dist/src/trail.d.ts +0 -2
- package/dist/src/trail.js +0 -41
- package/dist/src/validate.d.ts +0 -13
- package/dist/src/validate.js +0 -35
- package/dist/src/wallet-money.d.ts +0 -158
- package/dist/src/wallet-money.js +0 -664
- package/dist/src/wallet.d.ts +0 -169
- package/dist/src/wallet.js +0 -973
- package/dist/src/workflow.d.ts +0 -2
- package/dist/src/workflow.js +0 -169
- package/dist/src/write.d.ts +0 -43
- package/dist/src/write.js +0 -180
package/dist/src/init.d.ts
DELETED
|
@@ -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
|
-
}
|
package/dist/src/join.d.ts
DELETED
|
@@ -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,297 +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
|
-
'after you are born:\n' +
|
|
27
|
-
' oneie next # where you are, and the one thing to do now\n' +
|
|
28
|
-
' oneie learn <topic> # me · key · wallets · limit · sell · paid · ask · never · course\n' +
|
|
29
|
-
' oneie check "<message>" # a message asks you to pay? refuse, or ask your person\n' +
|
|
30
|
-
'existing group:\n' +
|
|
31
|
-
' oneie login # become someone — no new group\n' +
|
|
32
|
-
" oneie request <group> [--reason] # ask the owner to let you in\n" +
|
|
33
|
-
" oneie requests [--group <g>] # your asks, or an owner's queue\n" +
|
|
34
|
-
' oneie approve <requestId> [--reject]\n' +
|
|
35
|
-
' oneie group follow <group> # watch a public group\n' +
|
|
36
|
-
' oneie --help # full command reference\n');
|
|
37
|
-
}
|
|
38
|
-
const NO_KEY = 'no API key — run `oneie login` (or set ONE_API_KEY)';
|
|
39
|
-
function fail(cmd, error) {
|
|
40
|
-
if (jsonMode(cmd))
|
|
41
|
-
process.stdout.write(JSON.stringify({ ok: false, error }) + '\n');
|
|
42
|
-
else
|
|
43
|
-
process.stderr.write(`error ${error}\n`);
|
|
44
|
-
process.exitCode = 1;
|
|
45
|
-
}
|
|
46
|
-
/** One receiver through the ask door. Throws with the receiver's own reason on any refusal. */
|
|
47
|
-
async function ask(api, key, receiver, data) {
|
|
48
|
-
const base = resolveBase({ api }, DEFAULT_API);
|
|
49
|
-
const res = await fetch(askPath(base, receiver), {
|
|
50
|
-
method: 'POST',
|
|
51
|
-
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key}` },
|
|
52
|
-
body: JSON.stringify({ data }),
|
|
53
|
-
});
|
|
54
|
-
const text = await res.text();
|
|
55
|
-
let body;
|
|
56
|
-
try {
|
|
57
|
-
body = text ? JSON.parse(text) : undefined;
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
throw new Error(`${receiver} → ${res.status} ${text.slice(0, 200)}`);
|
|
61
|
-
}
|
|
62
|
-
if (!body || !('outcome' in body)) {
|
|
63
|
-
if (!res.ok)
|
|
64
|
-
throw new Error(`${receiver} → ${res.status} ${text.slice(0, 200)}`);
|
|
65
|
-
return body ?? {};
|
|
66
|
-
}
|
|
67
|
-
if (body.outcome === 'result') {
|
|
68
|
-
const r = (body.result ?? {});
|
|
69
|
-
if (r.ok === false)
|
|
70
|
-
throw new Error(String(r.error ?? `${receiver} refused`));
|
|
71
|
-
return r;
|
|
72
|
-
}
|
|
73
|
-
// A dissolve answers 200 — the signal reached nobody. Name it, never read it as ok.
|
|
74
|
-
if (body.outcome === 'dissolved') {
|
|
75
|
-
throw new Error(`${receiver} is not live on ${base} yet (dissolved: ${String(body.reason ?? 'no handler')})`);
|
|
76
|
-
}
|
|
77
|
-
const inner = body.result;
|
|
78
|
-
throw new Error(String(inner?.error ?? body.error ?? `${receiver}: ${String(body.outcome)}`));
|
|
79
|
-
}
|
|
80
|
-
// An unregistered `world:<name>` is not a dissolve on the web door: it is read as
|
|
81
|
-
// `world:<tag-expr>` and routed (measured on prod 2026-09-26 — world:list-requests
|
|
82
|
-
// answered outcome "result" {routed:"learned", actor:"ceo"}). So an answer missing
|
|
83
|
-
// the field the verb exists to return is refused, never printed as empty.
|
|
84
|
-
function notLive(receiver, missing, r) {
|
|
85
|
-
const routed = r.routed ? ` — routed as a world tag (routed=${String(r.routed)}, actor=${String(r.actor ?? '?')})` : '';
|
|
86
|
-
return `${receiver} is not live here yet: answer carried ${missing}${routed}`;
|
|
87
|
-
}
|
|
88
|
-
/** Resolve the key or refuse; every verb here acts as someone. */
|
|
89
|
-
function keyOrFail(cmd) {
|
|
90
|
-
const key = resolveKey();
|
|
91
|
-
if (!key)
|
|
92
|
-
fail(cmd, NO_KEY);
|
|
93
|
-
return key || undefined;
|
|
94
|
-
}
|
|
95
|
-
function cell(v) {
|
|
96
|
-
if (v === undefined || v === null || v === '')
|
|
97
|
-
return '-';
|
|
98
|
-
// A cell is receiver data, and a reason is a stranger's text: no control
|
|
99
|
-
// character (ESC, BEL, CR) reaches the terminal.
|
|
100
|
-
return String(v).replace(/\p{Cc}+/gu, ' ').replace(/\s+/g, ' ').slice(0, 40);
|
|
101
|
-
}
|
|
102
|
-
export function joinCommands(program) {
|
|
103
|
-
program
|
|
104
|
-
.command('request <group>')
|
|
105
|
-
.description("Ask a group's owner to let you in — always pends, never auto-grants")
|
|
106
|
-
.option('--role <role>', 'Role to ask for: viewer | member | admin')
|
|
107
|
-
.option('--reason <text>', 'Why — shown to the owner')
|
|
108
|
-
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
109
|
-
.action(async (group, opts, cmd) => {
|
|
110
|
-
if (opts.role && !ROLES.includes(opts.role)) {
|
|
111
|
-
return fail(cmd, `--role must be one of ${ROLES.join(' | ')} (got "${opts.role}")`);
|
|
112
|
-
}
|
|
113
|
-
const key = keyOrFail(cmd);
|
|
114
|
-
if (!key)
|
|
115
|
-
return;
|
|
116
|
-
const data = { group };
|
|
117
|
-
if (opts.role)
|
|
118
|
-
data.role = opts.role;
|
|
119
|
-
if (opts.reason)
|
|
120
|
-
data.reason = opts.reason;
|
|
121
|
-
let r;
|
|
122
|
-
try {
|
|
123
|
-
r = await ask(opts.api, key, 'world:request-access', data);
|
|
124
|
-
}
|
|
125
|
-
catch (e) {
|
|
126
|
-
return fail(cmd, e.message);
|
|
127
|
-
}
|
|
128
|
-
if (typeof r.requestId !== 'string')
|
|
129
|
-
return fail(cmd, notLive('world:request-access', 'no requestId', r));
|
|
130
|
-
if (jsonMode(cmd)) {
|
|
131
|
-
process.stdout.write(JSON.stringify({ ok: true, ...r, group }) + '\n');
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
process.stdout.write(`ok requestId=${JSON.stringify(r.requestId)} group=${JSON.stringify(group)}\n`);
|
|
135
|
-
if (r.existing === true)
|
|
136
|
-
process.stdout.write(`an ask to ${group} was already pending — no new notice sent; check with: oneie requests\n`);
|
|
137
|
-
else if (r.notified === true)
|
|
138
|
-
process.stdout.write(`the owner of ${group} has been notified — follow the answer with: oneie requests\n`);
|
|
139
|
-
else if (r.notified === false)
|
|
140
|
-
process.stdout.write(`the owner of ${group} was NOT notified — send them the requestId\n`);
|
|
141
|
-
else
|
|
142
|
-
process.stdout.write(`pending — the owner answers from their queue; check with: oneie requests\n`);
|
|
143
|
-
});
|
|
144
|
-
program
|
|
145
|
-
.command('requests')
|
|
146
|
-
.description("List access requests — your own asks, or an owner's queue for a group")
|
|
147
|
-
.option('--group <g>', "Group whose queue to list (owner/admin)")
|
|
148
|
-
.option('--status <s>', 'pending | approved | rejected')
|
|
149
|
-
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
150
|
-
.action(async (opts, cmd) => {
|
|
151
|
-
if (opts.status && !STATUSES.includes(opts.status)) {
|
|
152
|
-
return fail(cmd, `--status must be one of ${STATUSES.join(' | ')} (got "${opts.status}")`);
|
|
153
|
-
}
|
|
154
|
-
const key = keyOrFail(cmd);
|
|
155
|
-
if (!key)
|
|
156
|
-
return;
|
|
157
|
-
const data = {};
|
|
158
|
-
if (opts.group)
|
|
159
|
-
data.group = opts.group;
|
|
160
|
-
if (opts.status)
|
|
161
|
-
data.status = opts.status;
|
|
162
|
-
let r;
|
|
163
|
-
try {
|
|
164
|
-
r = await ask(opts.api, key, 'world:list-requests', data);
|
|
165
|
-
}
|
|
166
|
-
catch (e) {
|
|
167
|
-
return fail(cmd, e.message);
|
|
168
|
-
}
|
|
169
|
-
const list = r.requests ?? r.rows;
|
|
170
|
-
if (!Array.isArray(list))
|
|
171
|
-
return fail(cmd, notLive('world:list-requests', 'no request list', r));
|
|
172
|
-
if (jsonMode(cmd)) {
|
|
173
|
-
process.stdout.write(JSON.stringify({ ok: true, ...r }) + '\n');
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
const rows = list;
|
|
177
|
-
const total = typeof r.total === 'number' ? r.total : rows.length;
|
|
178
|
-
if (rows.length === 0)
|
|
179
|
-
process.stdout.write('no requests\n');
|
|
180
|
-
else {
|
|
181
|
-
const head = ['requestId', 'group', 'role', 'status', 'requester', 'reason'];
|
|
182
|
-
const body = rows.map((x) => [
|
|
183
|
-
cell(x.requestId ?? x.id),
|
|
184
|
-
cell(x.group ?? x.gid),
|
|
185
|
-
cell(x.role),
|
|
186
|
-
cell(x.status),
|
|
187
|
-
cell(x.requester ?? x.actor ?? x.aid ?? x.uid),
|
|
188
|
-
cell(x.reason),
|
|
189
|
-
]);
|
|
190
|
-
const w = head.map((h, i) => Math.max(h.length, ...body.map((b) => b[i].length)));
|
|
191
|
-
for (const line of [head, ...body])
|
|
192
|
-
process.stdout.write(line.map((c, i) => c.padEnd(w[i])).join(' ').trimEnd() + '\n');
|
|
193
|
-
}
|
|
194
|
-
// Absent is not false: only a present `truncated` makes total a floor.
|
|
195
|
-
if (r.truncated !== undefined && r.truncated !== false) {
|
|
196
|
-
process.stdout.write(`total=${total} truncated — at least ${total}; ${JSON.stringify(r.truncated)}\n`);
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
process.stdout.write(`total=${total}\n`);
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
program
|
|
203
|
-
.command('approve <requestId>')
|
|
204
|
-
.description('Answer an access request — approve by default, --reject to refuse')
|
|
205
|
-
.option('--reject', 'Reject instead of approve')
|
|
206
|
-
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
207
|
-
.action(async (requestId, opts, cmd) => {
|
|
208
|
-
const key = keyOrFail(cmd);
|
|
209
|
-
if (!key)
|
|
210
|
-
return;
|
|
211
|
-
const decision = opts.reject ? 'rejected' : 'approved';
|
|
212
|
-
let r;
|
|
213
|
-
try {
|
|
214
|
-
r = await ask(opts.api, key, 'world:approve-request', { requestId, decision });
|
|
215
|
-
}
|
|
216
|
-
catch (e) {
|
|
217
|
-
return fail(cmd, e.message);
|
|
218
|
-
}
|
|
219
|
-
// W1 answers `membership` = setMembership's verdict. `failed` (the write
|
|
220
|
-
// did not land) or `refused` (the owner guard said no) means the D1
|
|
221
|
-
// decision is recorded while the requester still holds no role — the one
|
|
222
|
-
// outcome an "ok" line would turn into a lie.
|
|
223
|
-
const membership = typeof r.membership === 'string' ? r.membership : undefined;
|
|
224
|
-
if (membership === 'failed' || membership === 'refused') {
|
|
225
|
-
const error = `approval recorded, but membership was not written (membership=${membership}) — the requester cannot act in the group yet; re-run \`oneie approve ${requestId}\``;
|
|
226
|
-
process.exitCode = 1;
|
|
227
|
-
if (jsonMode(cmd)) {
|
|
228
|
-
process.stdout.write(JSON.stringify({ ...r, ok: false, requestId, decision, error }) + '\n');
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
process.stderr.write(`error ${error}\n`);
|
|
232
|
-
}
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
if (jsonMode(cmd)) {
|
|
236
|
-
process.stdout.write(JSON.stringify({ ...r, ok: true, requestId, decision }) + '\n');
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
const verdict = membership ? ` membership=${membership}` : '';
|
|
240
|
-
process.stdout.write(`ok requestId=${JSON.stringify(requestId)} decision=${JSON.stringify(decision)}${verdict}\n`);
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* `oneie group follow|unfollow <group>` — watch a PUBLIC group
|
|
245
|
-
* (text/join-existing-plan.md W3 D2). Mounted on the existing `group` command
|
|
246
|
-
* by group.ts, because a top-level `follow` is taken.
|
|
247
|
-
*/
|
|
248
|
-
export function watchCommands(group) {
|
|
249
|
-
group
|
|
250
|
-
.command('follow <group>')
|
|
251
|
-
.description("Watch a public group — its announces reach your inbox (no membership, no role)")
|
|
252
|
-
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
253
|
-
.action(async (target, opts, cmd) => {
|
|
254
|
-
const key = keyOrFail(cmd);
|
|
255
|
-
if (!key)
|
|
256
|
-
return;
|
|
257
|
-
let r;
|
|
258
|
-
try {
|
|
259
|
-
r = await ask(opts.api, key, 'groups:follow', { group: target });
|
|
260
|
-
}
|
|
261
|
-
catch (e) {
|
|
262
|
-
return fail(cmd, e.message);
|
|
263
|
-
}
|
|
264
|
-
if (r.following !== true)
|
|
265
|
-
return fail(cmd, notLive('groups:follow', 'no following:true', r));
|
|
266
|
-
const slug = typeof r.group === 'string' ? r.group : target;
|
|
267
|
-
if (jsonMode(cmd)) {
|
|
268
|
-
process.stdout.write(JSON.stringify({ ok: true, ...r, group: slug }) + '\n');
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
process.stdout.write(`ok following ${JSON.stringify(slug)} — its announces now reach your inbox; stop with: oneie group unfollow ${slug}\n`);
|
|
272
|
-
});
|
|
273
|
-
group
|
|
274
|
-
.command('unfollow <group>')
|
|
275
|
-
.description('Stop watching a group (a declared subscription on it is left alone)')
|
|
276
|
-
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
277
|
-
.action(async (target, opts, cmd) => {
|
|
278
|
-
const key = keyOrFail(cmd);
|
|
279
|
-
if (!key)
|
|
280
|
-
return;
|
|
281
|
-
let r;
|
|
282
|
-
try {
|
|
283
|
-
r = await ask(opts.api, key, 'groups:unfollow', { group: target });
|
|
284
|
-
}
|
|
285
|
-
catch (e) {
|
|
286
|
-
return fail(cmd, e.message);
|
|
287
|
-
}
|
|
288
|
-
if (r.following !== false)
|
|
289
|
-
return fail(cmd, notLive('groups:unfollow', 'no following:false', r));
|
|
290
|
-
const slug = typeof r.group === 'string' ? r.group : target;
|
|
291
|
-
if (jsonMode(cmd)) {
|
|
292
|
-
process.stdout.write(JSON.stringify({ ok: true, ...r, group: slug }) + '\n');
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
process.stdout.write(`ok not following ${JSON.stringify(slug)}\n`);
|
|
296
|
-
});
|
|
297
|
-
}
|