@cello-protocol/cli 0.0.43 → 0.0.45
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/dist/arg-parse.d.ts +20 -0
- package/dist/arg-parse.d.ts.map +1 -0
- package/dist/arg-parse.js +30 -0
- package/dist/arg-parse.js.map +1 -0
- package/dist/bin/cello.d.ts +8 -5
- package/dist/bin/cello.d.ts.map +1 -1
- package/dist/bin/cello.js +42 -172
- package/dist/bin/cello.js.map +1 -1
- package/dist/cli-args.d.ts +27 -19
- package/dist/cli-args.d.ts.map +1 -1
- package/dist/cli-args.js +48 -87
- package/dist/cli-args.js.map +1 -1
- package/dist/commands.d.ts +12 -0
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +34 -0
- package/dist/commands.js.map +1 -1
- package/dist/json-out.d.ts +41 -0
- package/dist/json-out.d.ts.map +1 -0
- package/dist/json-out.js +60 -0
- package/dist/json-out.js.map +1 -0
- package/dist/parity-commands.d.ts +161 -0
- package/dist/parity-commands.d.ts.map +1 -0
- package/dist/parity-commands.js +317 -0
- package/dist/parity-commands.js.map +1 -0
- package/dist/registry.d.ts +69 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +641 -0
- package/dist/registry.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared argv parsing primitives.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from cli-args.ts (DOD-CLI-PARITY-1 Phase 0) so that BOTH the registry (which parses a
|
|
5
|
+
* command's args inside its run()) and cli-args (which validates them before dispatch) can use it
|
|
6
|
+
* without an import cycle: cli-args → registry → arg-parse, never back.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Split a subcommand's argv into the `--agent <name>` flag and the remaining positionals.
|
|
10
|
+
*
|
|
11
|
+
* Extracted originally (MONIKER-1 review Finding 1) because the old inline filter used
|
|
12
|
+
* `i === agentIdx + 1` unguarded: with --agent ABSENT, agentIdx is -1 and the predicate silently
|
|
13
|
+
* dropped positional index 0 — `cello moniker set Bob` / `cello contact list` printed usage instead
|
|
14
|
+
* of dispatching. The flag's value is excluded ONLY when the flag exists.
|
|
15
|
+
*/
|
|
16
|
+
export declare function splitAgentFlag(args: string[]): {
|
|
17
|
+
agent: string | undefined;
|
|
18
|
+
positional: string[];
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=arg-parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arg-parse.d.ts","sourceRoot":"","sources":["../src/arg-parse.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;IAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CAalG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared argv parsing primitives.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from cli-args.ts (DOD-CLI-PARITY-1 Phase 0) so that BOTH the registry (which parses a
|
|
5
|
+
* command's args inside its run()) and cli-args (which validates them before dispatch) can use it
|
|
6
|
+
* without an import cycle: cli-args → registry → arg-parse, never back.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Split a subcommand's argv into the `--agent <name>` flag and the remaining positionals.
|
|
10
|
+
*
|
|
11
|
+
* Extracted originally (MONIKER-1 review Finding 1) because the old inline filter used
|
|
12
|
+
* `i === agentIdx + 1` unguarded: with --agent ABSENT, agentIdx is -1 and the predicate silently
|
|
13
|
+
* dropped positional index 0 — `cello moniker set Bob` / `cello contact list` printed usage instead
|
|
14
|
+
* of dispatching. The flag's value is excluded ONLY when the flag exists.
|
|
15
|
+
*/
|
|
16
|
+
export function splitAgentFlag(args) {
|
|
17
|
+
// POSIX `--` end-of-flags terminator (review F1): everything after the first `--` is a positional
|
|
18
|
+
// VALUE, verbatim — so a value that starts with `-` (a negative number, or an away text like
|
|
19
|
+
// "- back Monday") can be passed. --agent is recognized only BEFORE the terminator.
|
|
20
|
+
const ddIdx = args.indexOf("--");
|
|
21
|
+
const flagScan = ddIdx === -1 ? args : args.slice(0, ddIdx);
|
|
22
|
+
const afterTerminator = ddIdx === -1 ? [] : args.slice(ddIdx + 1);
|
|
23
|
+
const agentIdx = flagScan.indexOf("--agent");
|
|
24
|
+
const agent = agentIdx !== -1 ? flagScan[agentIdx + 1] : undefined;
|
|
25
|
+
const positional = flagScan
|
|
26
|
+
.filter((a, i) => !(a === "--agent" || (agentIdx !== -1 && i === agentIdx + 1)))
|
|
27
|
+
.concat(afterTerminator);
|
|
28
|
+
return { agent, positional };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=arg-parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arg-parse.js","sourceRoot":"","sources":["../src/arg-parse.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,IAAc;IAC3C,kGAAkG;IAClG,6FAA6F;IAC7F,oFAAoF;IACpF,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,QAAQ,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC5D,MAAM,eAAe,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,MAAM,UAAU,GAAG,QAAQ;SACxB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;SAC/E,MAAM,CAAC,eAAe,CAAC,CAAC;IAC3B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC/B,CAAC"}
|
package/dist/bin/cello.d.ts
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* cello — the CELLO CLI binary.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* DOD-CLI-PARITY-1 Phase 0: this file no longer contains a dispatch switch. Every command lives in
|
|
6
|
+
* the registry (src/registry.ts), which is also what renders `cello --help` and per-command help —
|
|
7
|
+
* so dispatch, the command table, and the help text cannot drift apart. Adding a command means
|
|
8
|
+
* adding one registry entry; this binary does not change.
|
|
9
|
+
*
|
|
10
|
+
* The bash-adapter contract (§3): a command's JSON result goes to stdout, a structured failure goes
|
|
11
|
+
* to stderr VERBATIM, and the exit code branches on it — so any bash-capable agent can drive a
|
|
12
|
+
* CELLO node with `cello <cmd> | jq` and `$?`, with no MCP dependency.
|
|
10
13
|
*/
|
|
11
14
|
export {};
|
|
12
15
|
//# sourceMappingURL=cello.d.ts.map
|
package/dist/bin/cello.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cello.d.ts","sourceRoot":"","sources":["../../src/bin/cello.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"cello.d.ts","sourceRoot":"","sources":["../../src/bin/cello.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG"}
|
package/dist/bin/cello.js
CHANGED
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* cello — the CELLO CLI binary.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* DOD-CLI-PARITY-1 Phase 0: this file no longer contains a dispatch switch. Every command lives in
|
|
6
|
+
* the registry (src/registry.ts), which is also what renders `cello --help` and per-command help —
|
|
7
|
+
* so dispatch, the command table, and the help text cannot drift apart. Adding a command means
|
|
8
|
+
* adding one registry entry; this binary does not change.
|
|
9
|
+
*
|
|
10
|
+
* The bash-adapter contract (§3): a command's JSON result goes to stdout, a structured failure goes
|
|
11
|
+
* to stderr VERBATIM, and the exit code branches on it — so any bash-capable agent can drive a
|
|
12
|
+
* CELLO node with `cello <cmd> | jq` and `$?`, with no MCP dependency.
|
|
10
13
|
*/
|
|
11
14
|
import { homedir } from "node:os";
|
|
12
15
|
import { join, dirname } from "node:path";
|
|
13
16
|
import { createRequire } from "node:module";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
17
|
+
import { KNOWN_COMMANDS, USAGE, checkArgs, helpForCommand } from "../cli-args.js";
|
|
18
|
+
import { findCommand } from "../registry.js";
|
|
16
19
|
const logger = {
|
|
17
20
|
debug(event, context) {
|
|
18
21
|
const line = JSON.stringify({ level: "debug", event, ...context, ts: new Date().toISOString() });
|
|
@@ -38,173 +41,40 @@ const require = createRequire(import.meta.url);
|
|
|
38
41
|
const daemonPkgPath = require.resolve("@cello-protocol/daemon/package.json");
|
|
39
42
|
const daemonBin = join(dirname(daemonPkgPath), "dist/bin/cello-daemon.js");
|
|
40
43
|
async function main() {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
44
|
+
const spec = command ? findCommand(command) : undefined;
|
|
45
|
+
if (!spec || !KNOWN_COMMANDS.has(command)) {
|
|
46
|
+
// No command, or one we don't have: print the described command table.
|
|
47
|
+
process.stdout.write(USAGE + "\n");
|
|
48
|
+
process.exit(command ? 1 : 0);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const args = process.argv.slice(3);
|
|
52
|
+
// M8B F2: answer --help/-h on every subcommand and REJECT unknown flags BEFORE dispatch, so a
|
|
53
|
+
// flag can never be coerced into a positional argument.
|
|
54
|
+
const check = checkArgs(command, args);
|
|
55
|
+
if (check.kind === "help") {
|
|
56
|
+
process.stdout.write(helpForCommand(command) + "\n");
|
|
57
|
+
process.exit(0);
|
|
58
|
+
return;
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// DOD-LOGOUT-WAIT-1: logout now WAITS for the daemon to actually die before claiming
|
|
65
|
-
// "Daemon stopped." — the immediate progress line tells the operator the command
|
|
66
|
-
// activated and the short pause is expected.
|
|
67
|
-
result = await logout(celloDir, (line) => process.stdout.write(line + "\n"));
|
|
68
|
-
break;
|
|
69
|
-
case "status":
|
|
70
|
-
result = await status(celloDir);
|
|
71
|
-
break;
|
|
72
|
-
case "register": {
|
|
73
|
-
// cello register <agent> [preAuthToken] (token falls back to CELLO_PREAUTH_TOKEN
|
|
74
|
-
// so it need not appear in shell history). Optional phone stub follows.
|
|
75
|
-
const agent = process.argv[3] ?? "";
|
|
76
|
-
const preAuthToken = process.argv[4] ?? process.env.CELLO_PREAUTH_TOKEN ?? "";
|
|
77
|
-
const phoneStub = process.argv[5] ?? "";
|
|
78
|
-
// M8C-ONBOARD-WARN-1 (revised 2026-07-06, Andre): the pre-auth exposure "note" is REMOVED
|
|
79
|
-
// entirely. A single-use, 24h, consumed-on-success token has no meaningful exposure risk, so
|
|
80
|
-
// the note only drew attention to a non-issue ("this thing you weren't worried about? don't
|
|
81
|
-
// worry about it") — pure noise on the core onboarding path. No warning at all is correct.
|
|
82
|
-
result = await register(celloDir, agent, preAuthToken, phoneStub);
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
case "create-agent": {
|
|
86
|
-
// cello create-agent <name> — create a fresh local agent identity (PERSIST-002 AC-004).
|
|
87
|
-
const name = process.argv[3] ?? "";
|
|
88
|
-
result = await createAgent(celloDir, name);
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
case "remove-agent": {
|
|
92
|
-
// cello remove-agent <name> — retire a local agent (one-way) and free its name (REMOVE-001).
|
|
93
|
-
const name = process.argv[3] ?? "";
|
|
94
|
-
result = await removeAgent(celloDir, name);
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
case "refresh": {
|
|
98
|
-
// cello refresh <name> — proactive share refresh / epoch rollover (M8B DOD-REFRESH-1).
|
|
99
|
-
const name = process.argv[3] ?? "";
|
|
100
|
-
result = await refreshShares(celloDir, name);
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
case "receipts": {
|
|
104
|
-
// cello receipts <name> — list the agent's stored relay ordering receipts (M8B DOD-RELAYSIG-1).
|
|
105
|
-
const name = process.argv[3] ?? "";
|
|
106
|
-
result = await relayReceipts(celloDir, name);
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
case "sessions": {
|
|
110
|
-
// cello sessions [--open|--closed|--failed|--all] [--limit N] — the full session history.
|
|
111
|
-
// Defaults to open (live + resumable) so failed/closed don't flood it; the daemon caps the
|
|
112
|
-
// count. (`cello status` only ever shows live/resumable, never this full list.)
|
|
113
|
-
const args = process.argv.slice(3);
|
|
114
|
-
let filter;
|
|
115
|
-
if (args.includes("--all"))
|
|
116
|
-
filter = "all";
|
|
117
|
-
else if (args.includes("--closed"))
|
|
118
|
-
filter = "closed";
|
|
119
|
-
else if (args.includes("--failed"))
|
|
120
|
-
filter = "failed";
|
|
121
|
-
else if (args.includes("--open"))
|
|
122
|
-
filter = "open";
|
|
123
|
-
const limitIdx = args.indexOf("--limit");
|
|
124
|
-
let limit;
|
|
125
|
-
if (limitIdx !== -1 && args[limitIdx + 1] !== undefined) {
|
|
126
|
-
const n = Number(args[limitIdx + 1]);
|
|
127
|
-
if (Number.isFinite(n) && n > 0)
|
|
128
|
-
limit = Math.floor(n);
|
|
129
|
-
}
|
|
130
|
-
result = await sessions(celloDir, { filter, limit });
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
case "contact": {
|
|
134
|
-
// cello contact add <pubkey> [--agent <name>] | remove <pubkey> [--agent <name>] | list [--agent <name>]
|
|
135
|
-
const { agent, positional } = splitAgentFlag(process.argv.slice(3));
|
|
136
|
-
const [sub, pubkey] = positional;
|
|
137
|
-
if (sub === "add" && pubkey) {
|
|
138
|
-
result = await contactAdd(celloDir, pubkey, agent);
|
|
139
|
-
}
|
|
140
|
-
else if (sub === "remove" && pubkey) {
|
|
141
|
-
result = await contactRemove(celloDir, pubkey, agent);
|
|
142
|
-
}
|
|
143
|
-
else if (sub === "list") {
|
|
144
|
-
result = await contactList(celloDir, agent);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
result = { exitCode: 1, output: "Usage: cello contact add|remove <pubkey> [--agent <name>] | cello contact list [--agent <name>]" };
|
|
148
|
-
}
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
case "moniker": {
|
|
152
|
-
// cello moniker set <name> [--agent <agent>] | cello moniker clear [--agent <agent>] (MONIKER-1)
|
|
153
|
-
const { agent, positional } = splitAgentFlag(process.argv.slice(3));
|
|
154
|
-
const [sub, name] = positional;
|
|
155
|
-
if (sub === "set" && name) {
|
|
156
|
-
result = await monikerSet(celloDir, name, agent);
|
|
157
|
-
}
|
|
158
|
-
else if (sub === "clear" && !name) {
|
|
159
|
-
result = await monikerSet(celloDir, null, agent);
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
result = { exitCode: 1, output: helpForCommand("moniker") };
|
|
163
|
-
}
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
case "telegram": {
|
|
167
|
-
// cello telegram set-token <bot_token> <allowlisted_chat_id>
|
|
168
|
-
const sub = process.argv[3];
|
|
169
|
-
const botToken = process.argv[4];
|
|
170
|
-
const chatId = process.argv[5];
|
|
171
|
-
if (sub === "set-token" && botToken && chatId) {
|
|
172
|
-
result = await telegramSetToken(celloDir, botToken, chatId);
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
result = { exitCode: 1, output: "Usage: cello telegram set-token <bot_token> <allowlisted_chat_id>" };
|
|
176
|
-
}
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
case "install": {
|
|
180
|
-
// cello install hermes --agent <name> [--hermes-home <path>] (HERMES-001)
|
|
181
|
-
const args = process.argv.slice(3);
|
|
182
|
-
const agentIdx = args.indexOf("--agent");
|
|
183
|
-
const homeIdx = args.indexOf("--hermes-home");
|
|
184
|
-
// Find the target positional, excluding both flags AND their values — so
|
|
185
|
-
// `cello install --agent alice hermes` still resolves target=hermes (mirrors
|
|
186
|
-
// the `contact` case's positional filter).
|
|
187
|
-
const target = args.find((a, i) => !a.startsWith("-") &&
|
|
188
|
-
!(agentIdx !== -1 && i === agentIdx + 1) &&
|
|
189
|
-
!(homeIdx !== -1 && i === homeIdx + 1));
|
|
190
|
-
if (target !== "hermes") {
|
|
191
|
-
result = { exitCode: 1, output: helpForCommand("install") };
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
const { installHermes } = await import("../hermes/install-hermes.js");
|
|
195
|
-
result = await installHermes({
|
|
196
|
-
agentName: agentIdx !== -1 ? (args[agentIdx + 1] ?? "") : "",
|
|
197
|
-
hermesHome: homeIdx !== -1 ? args[homeIdx + 1] : undefined,
|
|
198
|
-
});
|
|
199
|
-
break;
|
|
200
|
-
}
|
|
201
|
-
default:
|
|
202
|
-
// M8B F1: the usage string lists EVERY command (refresh/receipts were missing).
|
|
203
|
-
process.stdout.write(USAGE + "\n");
|
|
204
|
-
process.exit(command ? 1 : 0);
|
|
205
|
-
return;
|
|
60
|
+
if (check.kind === "unknown_flag") {
|
|
61
|
+
process.stderr.write(`Unknown flag '${check.flag}' for 'cello ${command}'.\n`);
|
|
62
|
+
process.stdout.write(helpForCommand(command) + "\n");
|
|
63
|
+
process.exit(1);
|
|
64
|
+
return;
|
|
206
65
|
}
|
|
207
|
-
|
|
66
|
+
const ctx = {
|
|
67
|
+
celloDir,
|
|
68
|
+
daemonBin,
|
|
69
|
+
logger,
|
|
70
|
+
onProgress: (line) => process.stdout.write(line + "\n"),
|
|
71
|
+
};
|
|
72
|
+
const result = await spec.run(ctx, args);
|
|
73
|
+
// Report the outcome, never the intent: stdout carries the result, stderr the structured failure.
|
|
74
|
+
if (result.stdout.length > 0)
|
|
75
|
+
process.stdout.write(result.stdout + "\n");
|
|
76
|
+
if (result.stderr.length > 0)
|
|
77
|
+
process.stderr.write(result.stderr + "\n");
|
|
208
78
|
process.exit(result.exitCode);
|
|
209
79
|
}
|
|
210
80
|
main().catch((err) => {
|
package/dist/bin/cello.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cello.js","sourceRoot":"","sources":["../../src/bin/cello.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"cello.js","sourceRoot":"","sources":["../../src/bin/cello.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAA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IAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/cli-args.d.ts
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* CLI argument handling — validation that runs BEFORE dispatch, kept out of src/bin/cello.ts so the
|
|
3
3
|
* usage surface is testable without spawning the binary.
|
|
4
4
|
*
|
|
5
|
-
* F1: USAGE lists EVERY dispatchable command
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* M8B riders F1/F2 (原): USAGE lists EVERY dispatchable command; every subcommand answers --help/-h;
|
|
6
|
+
* an unrecognized flag is REJECTED rather than coerced into a positional (previously
|
|
7
|
+
* `cello register --help` tried to register an agent literally named "--help").
|
|
8
|
+
*
|
|
9
|
+
* DOD-CLI-PARITY-1 Phase 0: this module no longer OWNS the command list, the help text, or the flag
|
|
10
|
+
* table — it DERIVES all three from the registry (registry.ts), the single source of truth. That is
|
|
11
|
+
* what makes drift between dispatch, `cello --help`, and `cello <cmd> --help` structurally
|
|
12
|
+
* impossible rather than merely discouraged.
|
|
13
|
+
*/
|
|
14
|
+
import { COMMANDS } from "./registry.js";
|
|
15
|
+
export { splitAgentFlag } from "./arg-parse.js";
|
|
16
|
+
/** Every dispatchable command — derived, so it cannot fall out of step with the registry. */
|
|
17
|
+
export declare const KNOWN_COMMANDS: ReadonlySet<string>;
|
|
18
|
+
export type KnownCommand = string;
|
|
19
|
+
/**
|
|
20
|
+
* The top-level `cello --help`.
|
|
21
|
+
*
|
|
22
|
+
* CC-7 (P2-5 / DOD-ONBOARD-HELP-1): opens with what CELLO is + the onboarding path a first-time
|
|
23
|
+
* user needs. DOD-CLI-PARITY-1 §7 closes the remaining gap — the command list is now a DESCRIBED
|
|
24
|
+
* table rendered from each registry entry's `summary` (it used to be a single pipe-delimited blob
|
|
25
|
+
* with no per-command descriptions). Arguments stay in per-command `--help`.
|
|
9
26
|
*/
|
|
10
|
-
export declare const KNOWN_COMMANDS: Set<"login" | "logout" | "status" | "register" | "create-agent" | "remove-agent" | "refresh" | "receipts" | "sessions" | "contact" | "moniker" | "telegram" | "install">;
|
|
11
|
-
export type KnownCommand = typeof KNOWN_COMMANDS extends Set<infer T> ? T : never;
|
|
12
27
|
export declare const USAGE: string;
|
|
28
|
+
/** Per-command help — the registry entry's own text, verbatim. */
|
|
13
29
|
export declare function helpForCommand(command: string): string;
|
|
14
30
|
export type ArgsCheck = {
|
|
15
31
|
kind: "ok";
|
|
@@ -22,21 +38,13 @@ export type ArgsCheck = {
|
|
|
22
38
|
/**
|
|
23
39
|
* F2: validate a subcommand's arguments BEFORE dispatch.
|
|
24
40
|
* - --help / -h ANYWHERE → help. This is a dedicated pre-scan so help wins even when it
|
|
25
|
-
* follows an unknown flag or sits where
|
|
41
|
+
* follows an unknown flag or sits where a value-consuming flag would swallow it — asking for
|
|
26
42
|
* help must never be masked by another argument error.
|
|
27
43
|
* - any other dash-prefixed token the command does not recognize → unknown_flag
|
|
28
44
|
* (never silently coerced into a positional).
|
|
45
|
+
* - after a POSIX `--` terminator, everything is a positional VALUE, verbatim.
|
|
29
46
|
*/
|
|
30
|
-
/**
|
|
31
|
-
* Split a subcommand's argv into the `--agent <name>` flag and the remaining positionals.
|
|
32
|
-
* Extracted (MONIKER-1 review Finding 1) because the old inline filter used
|
|
33
|
-
* `i === agentIdx + 1` unguarded: with --agent ABSENT, agentIdx is -1 and the predicate
|
|
34
|
-
* silently dropped positional index 0 — `cello moniker set Bob` / `cello contact list`
|
|
35
|
-
* printed usage instead of dispatching. The flag's value is excluded ONLY when the flag exists.
|
|
36
|
-
*/
|
|
37
|
-
export declare function splitAgentFlag(args: string[]): {
|
|
38
|
-
agent: string | undefined;
|
|
39
|
-
positional: string[];
|
|
40
|
-
};
|
|
41
47
|
export declare function checkArgs(command: string, args: string[]): ArgsCheck;
|
|
48
|
+
/** The registry, re-exported for callers that want to enumerate commands (e.g. the dispatcher). */
|
|
49
|
+
export { COMMANDS };
|
|
42
50
|
//# sourceMappingURL=cli-args.d.ts.map
|
package/dist/cli-args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAA4D,MAAM,eAAe,CAAC;AAInG,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,6FAA6F;AAC7F,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,CAA2B,CAAC;AAE3E,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,QAiBiF,CAAC;AAEpG,kEAAkE;AAClE,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,GACd;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3C;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,CAapE;AAED,mGAAmG;AACnG,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/cli-args.js
CHANGED
|
@@ -1,117 +1,78 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* CLI argument handling — validation that runs BEFORE dispatch, kept out of src/bin/cello.ts so the
|
|
3
3
|
* usage surface is testable without spawning the binary.
|
|
4
4
|
*
|
|
5
|
-
* F1: USAGE lists EVERY dispatchable command
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* M8B riders F1/F2 (原): USAGE lists EVERY dispatchable command; every subcommand answers --help/-h;
|
|
6
|
+
* an unrecognized flag is REJECTED rather than coerced into a positional (previously
|
|
7
|
+
* `cello register --help` tried to register an agent literally named "--help").
|
|
8
|
+
*
|
|
9
|
+
* DOD-CLI-PARITY-1 Phase 0: this module no longer OWNS the command list, the help text, or the flag
|
|
10
|
+
* table — it DERIVES all three from the registry (registry.ts), the single source of truth. That is
|
|
11
|
+
* what makes drift between dispatch, `cello --help`, and `cello <cmd> --help` structurally
|
|
12
|
+
* impossible rather than merely discouraged.
|
|
13
|
+
*/
|
|
14
|
+
import { COMMANDS, commandNames, findCommand, flagsFor, renderCommandsTable } from "./registry.js";
|
|
15
|
+
// Re-exported for the dispatch layer and existing callers (its home is arg-parse.ts, which both
|
|
16
|
+
// this module and the registry depend on — see the import-cycle note there).
|
|
17
|
+
export { splitAgentFlag } from "./arg-parse.js";
|
|
18
|
+
/** Every dispatchable command — derived, so it cannot fall out of step with the registry. */
|
|
19
|
+
export const KNOWN_COMMANDS = new Set(commandNames());
|
|
20
|
+
/**
|
|
21
|
+
* The top-level `cello --help`.
|
|
22
|
+
*
|
|
23
|
+
* CC-7 (P2-5 / DOD-ONBOARD-HELP-1): opens with what CELLO is + the onboarding path a first-time
|
|
24
|
+
* user needs. DOD-CLI-PARITY-1 §7 closes the remaining gap — the command list is now a DESCRIBED
|
|
25
|
+
* table rendered from each registry entry's `summary` (it used to be a single pipe-delimited blob
|
|
26
|
+
* with no per-command descriptions). Arguments stay in per-command `--help`.
|
|
9
27
|
*/
|
|
10
|
-
import { MONIKER_RE } from "@cello-protocol/protocol-types";
|
|
11
|
-
export const KNOWN_COMMANDS = new Set([
|
|
12
|
-
"login",
|
|
13
|
-
"logout",
|
|
14
|
-
"status",
|
|
15
|
-
"register",
|
|
16
|
-
"create-agent",
|
|
17
|
-
"remove-agent",
|
|
18
|
-
"refresh",
|
|
19
|
-
"receipts",
|
|
20
|
-
"sessions",
|
|
21
|
-
"contact",
|
|
22
|
-
"moniker",
|
|
23
|
-
"telegram",
|
|
24
|
-
"install",
|
|
25
|
-
]);
|
|
26
|
-
// CC-7 (P2-5 / DOD-ONBOARD-HELP-1): the top level opens with what CELLO is + the onboarding path a
|
|
27
|
-
// first-time user needs, then the command list. (Per-command `cello <cmd> --help` was already good.)
|
|
28
28
|
export const USAGE = "CELLO — a peer-to-peer identity & trust layer for agent-to-agent communication.\n" +
|
|
29
29
|
"\n" +
|
|
30
30
|
"First-time setup: cello login → cello create-agent <name> → cello register <name> <token> → cello status\n" +
|
|
31
31
|
" (get <token> from the CELLO Operations Agent on Telegram; 'cello login' starts the local daemon.)\n" +
|
|
32
32
|
"\n" +
|
|
33
|
-
"Usage: cello <
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"create-agent": "Usage: cello create-agent <name> — create a new LOCAL agent identity (does not touch the directory).\n" +
|
|
47
|
-
// MONIKER-0 AC2: the regex text is DERIVED from the shared constant, never hand-typed.
|
|
48
|
-
` Name rule: 1–64 characters, letters/digits/'-'/'_' only, no spaces (regex ${MONIKER_RE.source}).\n` +
|
|
49
|
-
" Next step: 'cello register <name> <pre-auth-token>' to register it with the directory.",
|
|
50
|
-
"remove-agent": "Usage: cello remove-agent <name> — retires a local agent (one-way) and frees its name.",
|
|
51
|
-
refresh: "Usage: cello refresh <name> — proactively refresh the agent's threshold shares (new epoch).",
|
|
52
|
-
receipts: "Usage: cello receipts <name> — list the agent's stored relay ordering receipts.",
|
|
53
|
-
sessions: "Usage: cello sessions [--open|--closed|--failed|--all] [--limit N] — list session history (defaults to open).",
|
|
54
|
-
contact: "Usage: cello contact add <pubkey> [--agent <name>] | cello contact remove <pubkey> [--agent <name>] | cello contact list [--agent <name>]\n" +
|
|
55
|
-
" Per-agent contact whitelist (M8C-CONTACT-1). --agent defaults to the current/sole-online agent.\n" +
|
|
56
|
-
" Contacts are added automatically too: initiating a session to X, or accepting X's inbound request, adds X.\n" +
|
|
57
|
-
" Example: cello contact list --agent alice",
|
|
58
|
-
moniker: "Usage: cello moniker set <name> [--agent <agent>] | cello moniker clear [--agent <agent>]\n" +
|
|
59
|
-
" The agent's OUTBOUND name — what a counterparty's doorbell shows (MONIKER-1). Defaults to the agent name; 'set' stores an override, 'clear' restores the default.\n" +
|
|
60
|
-
// MONIKER-0 AC2: the regex text is DERIVED from the shared constant, never hand-typed.
|
|
61
|
-
` Name rule: 1–64 characters, letters/digits/'-'/'_' only, no spaces (regex ${MONIKER_RE.source}).\n` +
|
|
62
|
-
" Local-only: never sent to the directory; the receiver treats it as an unverified hint (like caller ID).\n" +
|
|
63
|
-
" Example: cello moniker set Wonderland_Alice --agent alice",
|
|
64
|
-
telegram: "Usage: cello telegram set-token <bot_token> <allowlisted_chat_id> — configure the daemon-owned Telegram doorbell (M8C-TGDOOR-1).\n" +
|
|
65
|
-
" Starts a single long-lived poller immediately; the operator chat given is the ONLY one that ever receives doorbell events.",
|
|
66
|
-
install: "Usage: cello install hermes --agent <name> [--hermes-home <path>] — wire the local CELLO daemon into a Hermes Agent installation.\n" +
|
|
67
|
-
" Scaffolds the CELLO platform-adapter plugin into the Hermes home (default ~/.hermes), binds CELLO_AGENT_NAME in its .env,\n" +
|
|
68
|
-
" and registers via 'hermes plugins enable cello' + 'hermes mcp add cello'. Idempotent — re-run to upgrade.\n" +
|
|
69
|
-
" After installing, restart the gateway: hermes gateway restart",
|
|
70
|
-
};
|
|
33
|
+
"Usage: cello <command> [args]\n" +
|
|
34
|
+
"\n" +
|
|
35
|
+
renderCommandsTable() +
|
|
36
|
+
"\n" +
|
|
37
|
+
"\n" +
|
|
38
|
+
"Run 'cello <command> --help' for details on any command.\n" +
|
|
39
|
+
// Scoped deliberately: only the parity commands (jsonOut) honor the full §3 contract — JSON on
|
|
40
|
+
// stdout, structured error on stderr. The older commands (login, register, …) still print human
|
|
41
|
+
// text, and their failures go to stdout. Claiming the contract for EVERY command would be a
|
|
42
|
+
// promise the binary does not keep, made to precisely the reader who would script against it.
|
|
43
|
+
"The session and agent commands (agents, use-agent, initiate, send, receive, close, …) print JSON\n" +
|
|
44
|
+
"and exit non-zero on failure, so any bash-capable agent can drive CELLO with no MCP dependency.";
|
|
45
|
+
/** Per-command help — the registry entry's own text, verbatim. */
|
|
71
46
|
export function helpForCommand(command) {
|
|
72
|
-
return
|
|
47
|
+
return findCommand(command)?.help ?? USAGE;
|
|
73
48
|
}
|
|
74
|
-
/** Flags each command recognizes. `--limit` consumes the following value. */
|
|
75
|
-
const COMMAND_FLAGS = {
|
|
76
|
-
sessions: new Set(["--open", "--closed", "--failed", "--all", "--limit"]),
|
|
77
|
-
contact: new Set(["--agent"]),
|
|
78
|
-
moniker: new Set(["--agent"]),
|
|
79
|
-
install: new Set(["--agent", "--hermes-home"]),
|
|
80
|
-
};
|
|
81
49
|
/**
|
|
82
50
|
* F2: validate a subcommand's arguments BEFORE dispatch.
|
|
83
51
|
* - --help / -h ANYWHERE → help. This is a dedicated pre-scan so help wins even when it
|
|
84
|
-
* follows an unknown flag or sits where
|
|
52
|
+
* follows an unknown flag or sits where a value-consuming flag would swallow it — asking for
|
|
85
53
|
* help must never be masked by another argument error.
|
|
86
54
|
* - any other dash-prefixed token the command does not recognize → unknown_flag
|
|
87
55
|
* (never silently coerced into a positional).
|
|
56
|
+
* - after a POSIX `--` terminator, everything is a positional VALUE, verbatim.
|
|
88
57
|
*/
|
|
89
|
-
/**
|
|
90
|
-
* Split a subcommand's argv into the `--agent <name>` flag and the remaining positionals.
|
|
91
|
-
* Extracted (MONIKER-1 review Finding 1) because the old inline filter used
|
|
92
|
-
* `i === agentIdx + 1` unguarded: with --agent ABSENT, agentIdx is -1 and the predicate
|
|
93
|
-
* silently dropped positional index 0 — `cello moniker set Bob` / `cello contact list`
|
|
94
|
-
* printed usage instead of dispatching. The flag's value is excluded ONLY when the flag exists.
|
|
95
|
-
*/
|
|
96
|
-
export function splitAgentFlag(args) {
|
|
97
|
-
const agentIdx = args.indexOf("--agent");
|
|
98
|
-
const agent = agentIdx !== -1 ? args[agentIdx + 1] : undefined;
|
|
99
|
-
const positional = args.filter((a, i) => !(a === "--agent" || (agentIdx !== -1 && i === agentIdx + 1)));
|
|
100
|
-
return { agent, positional };
|
|
101
|
-
}
|
|
102
58
|
export function checkArgs(command, args) {
|
|
103
59
|
if (args.some((a) => a === "--help" || a === "-h"))
|
|
104
60
|
return { kind: "help" };
|
|
105
|
-
const known =
|
|
61
|
+
const known = flagsFor(command);
|
|
106
62
|
for (let i = 0; i < args.length; i++) {
|
|
107
63
|
const arg = args[i];
|
|
64
|
+
if (arg === "--")
|
|
65
|
+
break; // POSIX end-of-flags — everything after is a positional value
|
|
108
66
|
if (arg.startsWith("-")) {
|
|
109
|
-
|
|
67
|
+
const spec = known.get(arg);
|
|
68
|
+
if (!spec)
|
|
110
69
|
return { kind: "unknown_flag", flag: arg };
|
|
111
|
-
if (
|
|
112
|
-
i++; //
|
|
70
|
+
if (spec.consumesValue)
|
|
71
|
+
i++; // its value is not itself a flag
|
|
113
72
|
}
|
|
114
73
|
}
|
|
115
74
|
return { kind: "ok" };
|
|
116
75
|
}
|
|
76
|
+
/** The registry, re-exported for callers that want to enumerate commands (e.g. the dispatcher). */
|
|
77
|
+
export { COMMANDS };
|
|
117
78
|
//# sourceMappingURL=cli-args.js.map
|
package/dist/cli-args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAA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