@cello-protocol/cli 0.0.306 → 0.0.308
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/.claude-plugin/marketplace.json +15 -0
- package/README.md +107 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +602 -0
- package/dist/daemon/account-page-assets.d.ts +4 -0
- package/dist/daemon/account-page-assets.js +160 -0
- package/dist/daemon/account-page.d.ts +14 -0
- package/dist/daemon/account-page.js +104 -0
- package/dist/daemon/address.d.ts +10 -0
- package/dist/daemon/address.js +34 -0
- package/dist/daemon/away.d.ts +31 -0
- package/dist/daemon/away.js +65 -0
- package/dist/daemon/channel-store.d.ts +112 -0
- package/dist/daemon/channel-store.js +284 -0
- package/dist/daemon/channels.d.ts +46 -0
- package/dist/daemon/channels.js +1049 -0
- package/dist/daemon/contacts.d.ts +26 -0
- package/dist/daemon/contacts.js +74 -0
- package/dist/daemon/engine.d.ts +82 -0
- package/dist/daemon/engine.js +2882 -0
- package/dist/daemon/errors.d.ts +5 -0
- package/dist/daemon/errors.js +16 -0
- package/dist/daemon/governance.d.ts +66 -0
- package/dist/daemon/governance.js +514 -0
- package/dist/daemon/guards.d.ts +36 -0
- package/dist/daemon/guards.js +140 -0
- package/dist/daemon/issuer-client.d.ts +56 -0
- package/dist/daemon/issuer-client.js +143 -0
- package/dist/daemon/link.d.ts +30 -0
- package/dist/daemon/link.js +191 -0
- package/dist/daemon/log.d.ts +1 -0
- package/dist/daemon/log.js +4 -0
- package/dist/daemon/main.d.ts +1 -0
- package/dist/daemon/main.js +513 -0
- package/dist/daemon/paths.d.ts +6 -0
- package/dist/daemon/paths.js +21 -0
- package/dist/daemon/pii.d.ts +24 -0
- package/dist/daemon/pii.js +147 -0
- package/dist/daemon/policy-cadence.d.ts +33 -0
- package/dist/daemon/policy-cadence.js +59 -0
- package/dist/daemon/policy-proposals.d.ts +41 -0
- package/dist/daemon/policy-proposals.js +83 -0
- package/dist/daemon/policy-store.d.ts +47 -0
- package/dist/daemon/policy-store.js +144 -0
- package/dist/daemon/presented.d.ts +36 -0
- package/dist/daemon/presented.js +94 -0
- package/dist/daemon/rate-limit.d.ts +17 -0
- package/dist/daemon/rate-limit.js +44 -0
- package/dist/daemon/reach.d.ts +62 -0
- package/dist/daemon/reach.js +204 -0
- package/dist/daemon/screening.d.ts +97 -0
- package/dist/daemon/screening.js +362 -0
- package/dist/daemon/settings.d.ts +125 -0
- package/dist/daemon/settings.js +73 -0
- package/dist/daemon/signal-rules.d.ts +55 -0
- package/dist/daemon/signal-rules.js +127 -0
- package/dist/daemon/signal-store.d.ts +53 -0
- package/dist/daemon/signal-store.js +114 -0
- package/dist/daemon/store.d.ts +189 -0
- package/dist/daemon/store.js +477 -0
- package/dist/daemon/tiers.d.ts +14 -0
- package/dist/daemon/tiers.js +9 -0
- package/dist/daemon/wallet.d.ts +73 -0
- package/dist/daemon/wallet.js +429 -0
- package/dist/daemon/who-label.d.ts +3 -0
- package/dist/daemon/who-label.js +11 -0
- package/dist/guidance.d.ts +39 -0
- package/dist/guidance.js +98 -0
- package/dist/hermes-bridge.d.ts +34 -0
- package/dist/hermes-bridge.js +223 -0
- package/dist/install-mcp.d.ts +6 -0
- package/dist/install-mcp.js +77 -0
- package/dist/ipc/client.d.ts +18 -0
- package/dist/ipc/client.js +107 -0
- package/dist/ipc/operations.d.ts +30 -0
- package/dist/ipc/operations.js +846 -0
- package/dist/ipc/protocol.d.ts +21 -0
- package/dist/ipc/protocol.js +1 -0
- package/dist/issuer-list-sign.d.ts +12 -0
- package/dist/issuer-list-sign.js +43 -0
- package/dist/local-operations.d.ts +2 -0
- package/dist/local-operations.js +73 -0
- package/dist/mcp-tools.d.ts +14 -0
- package/dist/mcp-tools.js +45 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +160 -0
- package/dist/protocol/aead.d.ts +4 -0
- package/dist/protocol/aead.js +35 -0
- package/dist/protocol/cbor.d.ts +40 -0
- package/dist/protocol/cbor.js +106 -0
- package/dist/protocol/chain.d.ts +44 -0
- package/dist/protocol/chain.js +126 -0
- package/dist/protocol/channel.d.ts +153 -0
- package/dist/protocol/channel.js +298 -0
- package/dist/protocol/encode.d.ts +6 -0
- package/dist/protocol/encode.js +21 -0
- package/dist/protocol/identity.d.ts +27 -0
- package/dist/protocol/identity.js +94 -0
- package/dist/protocol/issuer-list.d.ts +56 -0
- package/dist/protocol/issuer-list.js +193 -0
- package/dist/protocol/issuer-roots.d.ts +6 -0
- package/dist/protocol/issuer-roots.js +10 -0
- package/dist/protocol/key-agreement.d.ts +20 -0
- package/dist/protocol/key-agreement.js +88 -0
- package/dist/protocol/merkle.d.ts +16 -0
- package/dist/protocol/merkle.js +166 -0
- package/dist/protocol/ml-dsa.d.ts +28 -0
- package/dist/protocol/ml-dsa.js +58 -0
- package/dist/protocol/ml-kem.d.ts +14 -0
- package/dist/protocol/ml-kem.js +57 -0
- package/dist/protocol/pq-errors.d.ts +9 -0
- package/dist/protocol/pq-errors.js +23 -0
- package/dist/protocol/pq-warnings.d.ts +1 -0
- package/dist/protocol/pq-warnings.js +18 -0
- package/dist/protocol/presented-signals.d.ts +17 -0
- package/dist/protocol/presented-signals.js +92 -0
- package/dist/protocol/salt.d.ts +5 -0
- package/dist/protocol/salt.js +47 -0
- package/dist/protocol/seal.d.ts +58 -0
- package/dist/protocol/seal.js +220 -0
- package/dist/protocol/signal.d.ts +54 -0
- package/dist/protocol/signal.js +266 -0
- package/dist/protocol/status.d.ts +41 -0
- package/dist/protocol/status.js +64 -0
- package/dist/protocol/structures.d.ts +359 -0
- package/dist/protocol/structures.js +296 -0
- package/dist/protocol/transcript.d.ts +61 -0
- package/dist/protocol/transcript.js +319 -0
- package/dist/protocol/wire.d.ts +212 -0
- package/dist/protocol/wire.js +161 -0
- package/dist/require-node.d.ts +1 -0
- package/dist/require-node.js +10 -0
- package/dist/screener/affordance.d.ts +1 -0
- package/dist/screener/affordance.js +2 -0
- package/dist/screener/classifier-selfcheck.d.ts +29 -0
- package/dist/screener/classifier-selfcheck.js +56 -0
- package/dist/screener/exfil.d.ts +11 -0
- package/dist/screener/exfil.js +45 -0
- package/dist/screener/gitleaks-rules.d.ts +9 -0
- package/dist/screener/gitleaks-rules.js +226 -0
- package/dist/screener/inbound.d.ts +25 -0
- package/dist/screener/inbound.js +102 -0
- package/dist/screener/injection-classifier-onnx.d.ts +20 -0
- package/dist/screener/injection-classifier-onnx.js +89 -0
- package/dist/screener/injection-classifier-wasm.d.ts +2 -0
- package/dist/screener/injection-classifier-wasm.js +97 -0
- package/dist/screener/injection-patterns.d.ts +8 -0
- package/dist/screener/injection-patterns.js +48 -0
- package/dist/screener/injection-windows.d.ts +9 -0
- package/dist/screener/injection-windows.js +37 -0
- package/dist/screener/language.d.ts +15 -0
- package/dist/screener/language.js +71 -0
- package/dist/screener/linear-regex.d.ts +8 -0
- package/dist/screener/linear-regex.js +27 -0
- package/dist/screener/model-installer.d.ts +14 -0
- package/dist/screener/model-installer.js +61 -0
- package/dist/screener/outbound.d.ts +19 -0
- package/dist/screener/outbound.js +62 -0
- package/dist/screener/sanitize.d.ts +44 -0
- package/dist/screener/sanitize.js +361 -0
- package/dist/screener/scan-variants.d.ts +5 -0
- package/dist/screener/scan-variants.js +146 -0
- package/dist/screener/screener-model-manifest.d.ts +16 -0
- package/dist/screener/screener-model-manifest.js +20 -0
- package/dist/screener/screener-state.d.ts +29 -0
- package/dist/screener/screener-state.js +119 -0
- package/dist/screener/secrets.d.ts +18 -0
- package/dist/screener/secrets.js +84 -0
- package/dist/screener/worker.d.ts +6 -0
- package/dist/screener/worker.js +83 -0
- package/dist/setup.d.ts +9 -0
- package/dist/setup.js +259 -0
- package/dist/shipped-issuer-list.d.ts +1 -0
- package/dist/shipped-issuer-list.js +3 -0
- package/dist/signals-text.d.ts +46 -0
- package/dist/signals-text.js +81 -0
- package/dist/verify-seal.d.ts +9 -0
- package/dist/verify-seal.js +30 -0
- package/hermes/plugin/__init__.py +1066 -0
- package/hermes/plugin/plugin.yaml +30 -0
- package/hermes/skills/cello-bridge-setup/SKILL.md +48 -0
- package/hermes/skills/cello-policy/SKILL.md +44 -0
- package/package.json +48 -16
- package/plugins/cello/.claude-plugin/plugin.json +19 -0
- package/plugins/cello/.mcp.json +7 -0
- package/plugins/cello/skills/cello/SKILL.md +117 -0
- package/dist/arg-parse.d.ts +0 -19
- package/dist/arg-parse.d.ts.map +0 -1
- package/dist/arg-parse.js +0 -29
- package/dist/arg-parse.js.map +0 -1
- package/dist/bin/cello.d.ts +0 -15
- package/dist/bin/cello.d.ts.map +0 -1
- package/dist/bin/cello.js +0 -110
- package/dist/bin/cello.js.map +0 -1
- package/dist/cli-args.d.ts +0 -62
- package/dist/cli-args.d.ts.map +0 -1
- package/dist/cli-args.js +0 -129
- package/dist/cli-args.js.map +0 -1
- package/dist/commands.d.ts +0 -196
- package/dist/commands.d.ts.map +0 -1
- package/dist/commands.js +0 -1544
- package/dist/commands.js.map +0 -1
- package/dist/hermes/assets.d.ts +0 -41
- package/dist/hermes/assets.d.ts.map +0 -1
- package/dist/hermes/assets.js +0 -2281
- package/dist/hermes/assets.js.map +0 -1
- package/dist/hermes/install-hermes.d.ts +0 -50
- package/dist/hermes/install-hermes.d.ts.map +0 -1
- package/dist/hermes/install-hermes.js +0 -232
- package/dist/hermes/install-hermes.js.map +0 -1
- package/dist/json-out.d.ts +0 -41
- package/dist/json-out.d.ts.map +0 -1
- package/dist/json-out.js +0 -59
- package/dist/json-out.js.map +0 -1
- package/dist/node-runtime-guard-init.d.ts +0 -6
- package/dist/node-runtime-guard-init.d.ts.map +0 -1
- package/dist/node-runtime-guard-init.js +0 -7
- package/dist/node-runtime-guard-init.js.map +0 -1
- package/dist/node-runtime-guard.d.ts +0 -48
- package/dist/node-runtime-guard.d.ts.map +0 -1
- package/dist/node-runtime-guard.js +0 -79
- package/dist/node-runtime-guard.js.map +0 -1
- package/dist/parity-commands.d.ts +0 -427
- package/dist/parity-commands.d.ts.map +0 -1
- package/dist/parity-commands.js +0 -953
- package/dist/parity-commands.js.map +0 -1
- package/dist/registry.d.ts +0 -120
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -2169
- package/dist/registry.js.map +0 -1
- package/dist/screener-commands.d.ts +0 -85
- package/dist/screener-commands.d.ts.map +0 -1
- package/dist/screener-commands.js +0 -313
- package/dist/screener-commands.js.map +0 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { stat } from "node:fs/promises";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { pathToFileURL } from "node:url";
|
|
12
|
+
import { createRequire } from "node:module";
|
|
13
|
+
import { SCREENER_MODEL, localPathOf } from "./screener-model-manifest.js";
|
|
14
|
+
import { sha256File } from "./model-installer.js";
|
|
15
|
+
import { celloHome } from "../daemon/paths.js";
|
|
16
|
+
export function screenerModelDir() {
|
|
17
|
+
return join(celloHome(), "screener", SCREENER_MODEL.revision);
|
|
18
|
+
}
|
|
19
|
+
export const SCREENER_RUNTIME_MODULE = "@huggingface/transformers";
|
|
20
|
+
export function screenerRuntimeDir() {
|
|
21
|
+
return join(celloHome(), "screener-runtime");
|
|
22
|
+
}
|
|
23
|
+
export function resolveScreenerRuntime() {
|
|
24
|
+
try {
|
|
25
|
+
const require = createRequire(join(screenerRuntimeDir(), "resolver.cjs"));
|
|
26
|
+
return require.resolve(SCREENER_RUNTIME_MODULE);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export async function runtimeAvailable(importImpl) {
|
|
33
|
+
const doImport = importImpl ?? ((s) => import(__rewriteRelativeImportExtension(/* @vite-ignore */ s)));
|
|
34
|
+
const resolved = resolveScreenerRuntime();
|
|
35
|
+
for (const specifier of [...(resolved ? [pathToFileURL(resolved).href] : []), SCREENER_RUNTIME_MODULE]) {
|
|
36
|
+
try {
|
|
37
|
+
await doImport(specifier);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
export async function screenerState(opts) {
|
|
46
|
+
const verify = opts.verifyDigests ?? true;
|
|
47
|
+
let present = 0;
|
|
48
|
+
let problem;
|
|
49
|
+
const absent = [];
|
|
50
|
+
for (const f of SCREENER_MODEL.files) {
|
|
51
|
+
const path = join(opts.dir, localPathOf(f));
|
|
52
|
+
let size;
|
|
53
|
+
try {
|
|
54
|
+
size = (await stat(path)).size;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
absent.push(localPathOf(f)); // judged below: some present + some absent is a half-written install
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
present++;
|
|
61
|
+
if (problem !== undefined)
|
|
62
|
+
continue;
|
|
63
|
+
if (size !== f.size) {
|
|
64
|
+
problem = `${localPathOf(f)} is ${size} bytes, expected ${f.size}`;
|
|
65
|
+
}
|
|
66
|
+
else if (verify && (await sha256File(path)) !== f.sha256) {
|
|
67
|
+
problem = `${localPathOf(f)} does not match its pinned SHA-256 — the file is not the one we verified`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const expected = SCREENER_MODEL.files.length;
|
|
71
|
+
const model = { filesPresent: present, filesExpected: expected, verified: present === expected && problem === undefined };
|
|
72
|
+
const base = { revision: SCREENER_MODEL.revision, model, runtimePresent: opts.runtimePresent };
|
|
73
|
+
if (present > 0 && present < expected) {
|
|
74
|
+
return { ...base, state: "broken", missing: [], problem: problem ?? `${absent.length} model file(s) missing: ${absent.join(", ")}` };
|
|
75
|
+
}
|
|
76
|
+
if (present === expected && problem !== undefined) {
|
|
77
|
+
return { ...base, state: "broken", missing: [], problem };
|
|
78
|
+
}
|
|
79
|
+
const missing = [];
|
|
80
|
+
if (present === 0)
|
|
81
|
+
missing.push("model");
|
|
82
|
+
if (!opts.runtimePresent)
|
|
83
|
+
missing.push("runtime");
|
|
84
|
+
if (missing.length === 2)
|
|
85
|
+
return { ...base, state: "not_installed", missing };
|
|
86
|
+
if (missing.length === 1)
|
|
87
|
+
return { ...base, state: "half_installed", missing };
|
|
88
|
+
return { ...base, state: "ready", missing: [] };
|
|
89
|
+
}
|
|
90
|
+
export function classifierLoadable(s) {
|
|
91
|
+
if (s.state === "ready")
|
|
92
|
+
return { load: true };
|
|
93
|
+
if (s.state === "broken") {
|
|
94
|
+
return { load: false, reason: `model FAILED verification and was NOT loaded: ${s.problem ?? "unknown fault"} — repair it with 'cello screener install --repair'` };
|
|
95
|
+
}
|
|
96
|
+
return { load: false, reason: `classifier not installed (${s.state}) — install it with 'cello screener install'` };
|
|
97
|
+
}
|
|
98
|
+
export function describeScreenerState(s, layer2) {
|
|
99
|
+
const fix = "Run: cello screener install";
|
|
100
|
+
const rev = s.revision.slice(0, 8);
|
|
101
|
+
switch (s.state) {
|
|
102
|
+
case "ready":
|
|
103
|
+
if (layer2 === "active:native")
|
|
104
|
+
return `Screening: 2 of 2 layers active (classifier ${rev} verified).`;
|
|
105
|
+
if (layer2 === "active:wasm") {
|
|
106
|
+
return `Screening: 2 of 2 layers active (classifier ${rev} verified, running on WASM — this CPU's native path gives wrong scores; long messages screen more slowly).`;
|
|
107
|
+
}
|
|
108
|
+
if (layer2?.startsWith("off:")) {
|
|
109
|
+
return `Screening: 1 of 2 layers active — the classifier is BROKEN: ${layer2.slice(4)}. Reinstalling will not fix this; the pattern layer still screens.`;
|
|
110
|
+
}
|
|
111
|
+
return `Screening: classifier ${rev} installed and verified; the security gateway has not reported whether it scores correctly on this machine — check 'cello status' while the daemon runs.`;
|
|
112
|
+
case "not_installed":
|
|
113
|
+
return `Screening: 1 of 2 layers active (classifier not installed). ${fix}`;
|
|
114
|
+
case "half_installed":
|
|
115
|
+
return `Screening: 1 of 2 layers active — the ${s.missing.join(" and ")} is missing, so the classifier cannot run. ${fix}`;
|
|
116
|
+
case "broken":
|
|
117
|
+
return `Screening: 1 of 2 layers active — the classifier is BROKEN: ${s.problem ?? "unknown fault"}. ${fix}`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function secretRuleIds(): string[] | null;
|
|
2
|
+
export declare function secretRuleDigestInputs(): Array<{
|
|
3
|
+
id: string;
|
|
4
|
+
src: string;
|
|
5
|
+
}> | null;
|
|
6
|
+
export declare function compileSecretRules(): {
|
|
7
|
+
compiled: number;
|
|
8
|
+
total: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function secretRulesReady(): boolean;
|
|
11
|
+
export interface SecretFinding {
|
|
12
|
+
ruleId: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SecretScanResult {
|
|
15
|
+
text: string;
|
|
16
|
+
findings: SecretFinding[];
|
|
17
|
+
}
|
|
18
|
+
export declare function redactSecrets(input: string): SecretScanResult;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { LinearRegex } from "./linear-regex.js";
|
|
2
|
+
import { GITLEAKS_RULES, GITLEAKS_STOPWORDS, GITLEAKS_ALLOW_REGEXES } from "./gitleaks-rules.js";
|
|
3
|
+
let RULES = null;
|
|
4
|
+
export function secretRuleIds() {
|
|
5
|
+
return RULES === null ? null : RULES.map((r) => r.id);
|
|
6
|
+
}
|
|
7
|
+
export function secretRuleDigestInputs() {
|
|
8
|
+
return RULES === null ? null : RULES.map((r) => ({ id: r.id, src: r.src }));
|
|
9
|
+
}
|
|
10
|
+
let STOPWORDS = [];
|
|
11
|
+
let ALLOW = [];
|
|
12
|
+
export function compileSecretRules() {
|
|
13
|
+
const compiled = [];
|
|
14
|
+
for (const r of GITLEAKS_RULES) {
|
|
15
|
+
try {
|
|
16
|
+
compiled.push({ id: r.id, src: r.regex, re: new LinearRegex(r.regex), keywords: r.keywords, entropy: r.entropy });
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
RULES = compiled;
|
|
22
|
+
STOPWORDS = GITLEAKS_STOPWORDS.map((s) => s.toLowerCase());
|
|
23
|
+
ALLOW = GITLEAKS_ALLOW_REGEXES.map((s) => {
|
|
24
|
+
try {
|
|
25
|
+
return new LinearRegex(s);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}).filter((x) => x !== null);
|
|
31
|
+
return { compiled: compiled.length, total: GITLEAKS_RULES.length };
|
|
32
|
+
}
|
|
33
|
+
export function secretRulesReady() {
|
|
34
|
+
return RULES !== null;
|
|
35
|
+
}
|
|
36
|
+
function shannonBits(s) {
|
|
37
|
+
const freq = new Map();
|
|
38
|
+
for (const ch of s)
|
|
39
|
+
freq.set(ch, (freq.get(ch) ?? 0) + 1);
|
|
40
|
+
let h = 0;
|
|
41
|
+
for (const c of freq.values()) {
|
|
42
|
+
const p = c / s.length;
|
|
43
|
+
h -= p * Math.log2(p);
|
|
44
|
+
}
|
|
45
|
+
return h;
|
|
46
|
+
}
|
|
47
|
+
function isFalsePositive(value, ruleEntropy) {
|
|
48
|
+
const lower = value.toLowerCase();
|
|
49
|
+
if (STOPWORDS.some((sw) => lower.includes(sw)))
|
|
50
|
+
return true;
|
|
51
|
+
if (ALLOW.some((re) => re.test(value)))
|
|
52
|
+
return true;
|
|
53
|
+
if (ruleEntropy > 0 && shannonBits(value) < ruleEntropy)
|
|
54
|
+
return true;
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
export function redactSecrets(input) {
|
|
58
|
+
if (!RULES)
|
|
59
|
+
return { text: input, findings: [] };
|
|
60
|
+
let text = input;
|
|
61
|
+
const findings = [];
|
|
62
|
+
const lowerContent = input.toLowerCase();
|
|
63
|
+
for (const rule of RULES) {
|
|
64
|
+
if (rule.keywords.length > 0 && !rule.keywords.some((k) => lowerContent.includes(k)))
|
|
65
|
+
continue;
|
|
66
|
+
const secrets = new Set();
|
|
67
|
+
let offset = 0;
|
|
68
|
+
let guard = 0;
|
|
69
|
+
while (offset < text.length && guard++ < 1000) {
|
|
70
|
+
const m = rule.re.exec(text.slice(offset));
|
|
71
|
+
if (!m || m.index === undefined)
|
|
72
|
+
break;
|
|
73
|
+
const value = (m[1] ?? m[0]) || "";
|
|
74
|
+
if (value && !isFalsePositive(value, rule.entropy))
|
|
75
|
+
secrets.add(value);
|
|
76
|
+
offset += m.index + Math.max(1, m[0].length);
|
|
77
|
+
}
|
|
78
|
+
for (const value of secrets) {
|
|
79
|
+
text = text.split(value).join(`[REDACTED:${rule.id}]`);
|
|
80
|
+
findings.push({ ruleId: rule.id });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return { text, findings };
|
|
84
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// The screening thread. It holds the model and never touches a socket or the database. It does one step when told to,
|
|
2
|
+
// so the main thread decides what runs next, and a short message never waits longer than one step.
|
|
3
|
+
import { readBodyBytes } from "../protocol/structures.js";
|
|
4
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
5
|
+
import { loadInjectionClassifier } from "./injection-classifier-onnx.js";
|
|
6
|
+
import { loadWasmInjectionClassifier } from "./injection-classifier-wasm.js";
|
|
7
|
+
import { compileInjectionPatterns, injectionPatternsReady } from "./injection-patterns.js";
|
|
8
|
+
import { screenInbound } from "./inbound.js";
|
|
9
|
+
import { selectClassifierBackend } from "./classifier-selfcheck.js";
|
|
10
|
+
import { initLinearRegex } from "./linear-regex.js";
|
|
11
|
+
import { screenOutbound } from "./outbound.js";
|
|
12
|
+
import { classifierLoadable, runtimeAvailable, screenerModelDir, screenerState } from "./screener-state.js";
|
|
13
|
+
import { compileSecretRules } from "./secrets.js";
|
|
14
|
+
const port = parentPort;
|
|
15
|
+
if (!port)
|
|
16
|
+
throw new Error("the screener worker must run as a worker thread");
|
|
17
|
+
async function loadModel() {
|
|
18
|
+
const dir = screenerModelDir();
|
|
19
|
+
const status = await screenerState({ dir, runtimePresent: await runtimeAvailable() });
|
|
20
|
+
const loadable = classifierLoadable(status);
|
|
21
|
+
if (!loadable.load)
|
|
22
|
+
return { classifier: null, fact: { state: status.state, running: false, backend: null, reason: loadable.reason ?? null } };
|
|
23
|
+
const selection = await selectClassifierBackend({
|
|
24
|
+
native: () => loadInjectionClassifier(dir, workerData.modelThreads),
|
|
25
|
+
wasm: () => loadWasmInjectionClassifier(dir),
|
|
26
|
+
log: () => undefined,
|
|
27
|
+
});
|
|
28
|
+
return { classifier: selection.classifier, fact: { state: status.state, running: selection.classifier !== null, backend: selection.backend === "off" ? null : selection.backend, reason: selection.classifier ? null : selection.layer2 } };
|
|
29
|
+
}
|
|
30
|
+
await initLinearRegex();
|
|
31
|
+
compileInjectionPatterns();
|
|
32
|
+
const secretRules = compileSecretRules();
|
|
33
|
+
if (!injectionPatternsReady() || secretRules.compiled === 0)
|
|
34
|
+
throw new Error("the deterministic screener's rules didn't compile");
|
|
35
|
+
const outboundOnly = workerData.role === "outbound";
|
|
36
|
+
const model = outboundOnly ? { classifier: null, fact: { state: "not_used", running: false, backend: null, reason: null } } : await loadModel();
|
|
37
|
+
const jobs = new Map();
|
|
38
|
+
function readText(body) {
|
|
39
|
+
try {
|
|
40
|
+
return readBodyBytes(body)?.text ?? null;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function step(id) {
|
|
47
|
+
const job = jobs.get(id);
|
|
48
|
+
if (!job)
|
|
49
|
+
throw new Error(`no screening job ${id}`);
|
|
50
|
+
const next = await job.next();
|
|
51
|
+
if (next.done) {
|
|
52
|
+
jobs.delete(id);
|
|
53
|
+
port?.postMessage({ type: "done", id, verdict: next.value });
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
port?.postMessage({ type: "stepped", id, measured: next.value.measured });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
port.on("message", (request) => {
|
|
60
|
+
if (request.type === "outbound") {
|
|
61
|
+
try {
|
|
62
|
+
port.postMessage({ type: "outbound", id: request.id, verdict: screenOutbound(request.text, request.keys, request.pii) });
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
port.postMessage({ type: "failed", id: request.id, message: err instanceof Error ? err.message : String(err) });
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (request.type === "start") {
|
|
70
|
+
const text = readText(request.body);
|
|
71
|
+
// Text nobody can read is shown to nobody, so there's nothing to screen.
|
|
72
|
+
if (text === null || text === "") {
|
|
73
|
+
port.postMessage({ type: "done", id: request.id, verdict: { verdict: "allow", delivered: null, findings: [], reason: null, score: null, ran: { deterministic: false, model: false, model_failed_copies: 0 } } });
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
jobs.set(request.id, screenInbound(text, request.level === "full" ? model.classifier : null, request.language));
|
|
77
|
+
}
|
|
78
|
+
step(request.id).catch((err) => {
|
|
79
|
+
jobs.delete(request.id);
|
|
80
|
+
port.postMessage({ type: "failed", id: request.id, message: err instanceof Error ? err.message : String(err) });
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
port.postMessage({ type: "ready", model: model.fact, rules: { patterns: true, secrets: secretRules.compiled } });
|
package/dist/setup.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IpcClient } from "./ipc/client.ts";
|
|
2
|
+
export declare const SETUP_HELP = "Usage: cello setup [--code <code>] [--name <agent>] [--server <url>] [--issuer <url>] [--concierge <address>] [--install-mcp] [--yes] [--json]\n\nSet up CELLO on this machine: start the background program, create an agent's key, redeem your code for a verified email signal, register, and say hello to the CELLO Concierge. Run it again and it changes nothing.\n\n --code The code from your admission email. A second agent on this machine doesn't need one. Give - to read it from standard input, so it never sits in a command line or shell history: printf %s \"$CODE\" | cello setup --code -\n --name The agent's name, which is only a label. The default is agent.\n --server The server, the first time only. The default is wss://server.celloprotocol.com/v1.\n --issuer The issuer, if it isn't the default.\n --concierge The agent to call at the end. Give none to skip the call this once, and keep the setting as it is.\n --yes Start the background program without asking.\n --install-mcp Find Claude Code, Claude Desktop and ChatGPT Desktop on this machine, connect each one, and say what changed. Without it, setup only prints the Claude Code commands.\n --json Answer in JSON.\n";
|
|
3
|
+
export interface SetupHost {
|
|
4
|
+
startDaemon(server: string | undefined): Promise<IpcClient>;
|
|
5
|
+
ask(question: string): Promise<string>;
|
|
6
|
+
rememberAgent(agentId: string): void;
|
|
7
|
+
caller: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function setup(args: string[], host: SetupHost): Promise<number>;
|
package/dist/setup.js
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
// `cello setup`: from nothing to an agent with its verified email, on a server, with a reply on screen.
|
|
2
|
+
// Each step says what it did, and each failure says what to do next, with JSON behind a flag.
|
|
3
|
+
import { existsSync, renameSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { createConnection } from "node:net";
|
|
6
|
+
import { celloHome, databasePath, holdsOldVersion, oldVersionMessage, socketPath } from "./daemon/paths.js";
|
|
7
|
+
import { DEFAULT_SERVER_URL } from "./daemon/settings.js";
|
|
8
|
+
import { HOW_TO_GET_A_CODE } from "./daemon/wallet.js";
|
|
9
|
+
import { installMcp } from "./install-mcp.js";
|
|
10
|
+
import { DaemonGone, DaemonRefused, IpcClient } from "./ipc/client.js";
|
|
11
|
+
const CONNECT_WAIT_TRIES = 50;
|
|
12
|
+
const CONNECT_WAIT_MS = 200;
|
|
13
|
+
const REPLY_WAIT_SECONDS = 60;
|
|
14
|
+
const HELLO = "Hello. I've just been set up.";
|
|
15
|
+
export const SETUP_HELP = `Usage: cello setup [--code <code>] [--name <agent>] [--server <url>] [--issuer <url>] [--concierge <address>] [--install-mcp] [--yes] [--json]
|
|
16
|
+
|
|
17
|
+
Set up CELLO on this machine: start the background program, create an agent's key, redeem your code for a verified email signal, register, and say hello to the CELLO Concierge. Run it again and it changes nothing.
|
|
18
|
+
|
|
19
|
+
--code The code from your admission email. A second agent on this machine doesn't need one. Give - to read it from standard input, so it never sits in a command line or shell history: printf %s "$CODE" | cello setup --code -
|
|
20
|
+
--name The agent's name, which is only a label. The default is agent.
|
|
21
|
+
--server The server, the first time only. The default is ${DEFAULT_SERVER_URL}.
|
|
22
|
+
--issuer The issuer, if it isn't the default.
|
|
23
|
+
--concierge The agent to call at the end. Give none to skip the call this once, and keep the setting as it is.
|
|
24
|
+
--yes Start the background program without asking.
|
|
25
|
+
--install-mcp Find Claude Code, Claude Desktop and ChatGPT Desktop on this machine, connect each one, and say what changed. Without it, setup only prints the Claude Code commands.
|
|
26
|
+
--json Answer in JSON.
|
|
27
|
+
`;
|
|
28
|
+
class SetupFailed extends Error {
|
|
29
|
+
code;
|
|
30
|
+
constructor(code, message) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.code = code;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function options(args) {
|
|
36
|
+
const known = { code: true, name: true, server: true, issuer: true, concierge: true, yes: false, json: false, "install-mcp": false };
|
|
37
|
+
const found = {};
|
|
38
|
+
for (let i = 0; i < args.length; i++) {
|
|
39
|
+
const name = args[i].replace(/^--/, "");
|
|
40
|
+
if (!args[i].startsWith("--") || !(name in known))
|
|
41
|
+
throw new SetupFailed("bad_argument", `setup has no option ${args[i]}. Run: cello setup --help`);
|
|
42
|
+
if (!known[name]) {
|
|
43
|
+
found[name] = true;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const value = args[++i];
|
|
47
|
+
if (!value)
|
|
48
|
+
throw new SetupFailed("bad_argument", `--${name} needs a value. Run: cello setup --help`);
|
|
49
|
+
found[name] = value;
|
|
50
|
+
}
|
|
51
|
+
return found;
|
|
52
|
+
}
|
|
53
|
+
const CODE_WAIT_MS = 30_000;
|
|
54
|
+
// Reads to the end of standard input, and gives up after a while, so a pipe nobody closes can't hold setup for good.
|
|
55
|
+
function codeFromStandardInput() {
|
|
56
|
+
if (process.stdin.isTTY)
|
|
57
|
+
throw new SetupFailed("code_not_piped", "--code - reads the code from standard input, and this is a terminal. Pipe it in, for example: printf %s \"$CODE\" | cello setup --code -");
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const chunks = [];
|
|
60
|
+
const timer = setTimeout(() => {
|
|
61
|
+
process.stdin.destroy();
|
|
62
|
+
reject(new SetupFailed("code_not_received", `No code arrived on standard input within ${CODE_WAIT_MS / 1000} seconds, and nothing was used.`));
|
|
63
|
+
}, CODE_WAIT_MS);
|
|
64
|
+
process.stdin.on("data", (chunk) => chunks.push(chunk));
|
|
65
|
+
process.stdin.on("error", (err) => { clearTimeout(timer); reject(new SetupFailed("code_not_received", `Standard input failed (${err.message}), and nothing was used.`)); });
|
|
66
|
+
process.stdin.on("end", () => {
|
|
67
|
+
clearTimeout(timer);
|
|
68
|
+
const code = Buffer.concat(chunks).toString("utf8").trim();
|
|
69
|
+
if (code === "")
|
|
70
|
+
reject(new SetupFailed("code_empty", "Standard input held no code, and nothing was used."));
|
|
71
|
+
else
|
|
72
|
+
resolve(code);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const answers = (path) => new Promise((resolve) => {
|
|
77
|
+
const probe = createConnection(path);
|
|
78
|
+
probe.once("connect", () => { probe.destroy(); resolve(true); });
|
|
79
|
+
probe.once("error", () => resolve(false));
|
|
80
|
+
});
|
|
81
|
+
// Old data stays until a person says, and then it's moved whole, never deleted.
|
|
82
|
+
async function moveOldVersion(host, say) {
|
|
83
|
+
const home = celloHome();
|
|
84
|
+
if (!holdsOldVersion(home))
|
|
85
|
+
return;
|
|
86
|
+
const target = `${home}-old`;
|
|
87
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY)
|
|
88
|
+
throw new SetupFailed("old_version_data", oldVersionMessage(home));
|
|
89
|
+
if (await answers(join(home, "daemon.sock")) || await answers(join(home, "gateway.sock")))
|
|
90
|
+
throw new SetupFailed("old_version_running", `The old version of CELLO is still running from ${home}. Stop it, or restart this machine, then run the same command again. Nothing changed.`);
|
|
91
|
+
if (existsSync(target))
|
|
92
|
+
throw new SetupFailed("old_version_data", `${home} holds data from the old version, and ${target} already exists, so it can't be moved there. Move one of them yourself, then run the same command again. Nothing changed.`);
|
|
93
|
+
say(`${home} holds data from the old version of CELLO, which this version can't read. Its agents don't carry over.`);
|
|
94
|
+
const answer = (await host.ask(`Move it to ${target}? [y/N] `)).toLowerCase();
|
|
95
|
+
if (answer !== "y" && answer !== "yes")
|
|
96
|
+
throw new SetupFailed("declined", "Nothing was moved, and setup can't go on until it is.");
|
|
97
|
+
renameSync(home, target);
|
|
98
|
+
say(`Moved it to ${target}.`);
|
|
99
|
+
}
|
|
100
|
+
async function daemon(host, server, yes, say) {
|
|
101
|
+
try {
|
|
102
|
+
const running = await IpcClient.connect(socketPath());
|
|
103
|
+
const status = await running.call("status");
|
|
104
|
+
if (server && status.server !== server)
|
|
105
|
+
throw new SetupFailed("other_server", `CELLO is already running for ${status.server}, not ${server}. To change it, run cello logout, and use a separate CELLO_HOME.`);
|
|
106
|
+
return running;
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
if (!(err instanceof DaemonGone))
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
const firstTime = !existsSync(databasePath());
|
|
113
|
+
const explain = `CELLO runs a small background program on this machine. It holds your agents' keys and conversations in an encrypted database in ${celloHome()}, and talks to ${server ?? (firstTime ? DEFAULT_SERVER_URL : "your server")}. Messages are end-to-end encrypted, so that server can't read them. It runs until you run cello logout or restart this machine.`;
|
|
114
|
+
if (!yes) {
|
|
115
|
+
if (!process.stdin.isTTY)
|
|
116
|
+
throw new SetupFailed("consent_required", `${explain} Nothing was started. Run this at a terminal to be asked, or with --yes if the person who owns this machine agreed.`);
|
|
117
|
+
say(explain);
|
|
118
|
+
const answer = (await host.ask("Start it? [y/N] ")).toLowerCase();
|
|
119
|
+
if (answer !== "y" && answer !== "yes")
|
|
120
|
+
throw new SetupFailed("declined", "Nothing was started or changed.");
|
|
121
|
+
}
|
|
122
|
+
// The default goes in only for empty data. After that, the database says which server this is.
|
|
123
|
+
const client = await host.startDaemon(server ?? (firstTime ? DEFAULT_SERVER_URL : undefined));
|
|
124
|
+
say("The background program is running.");
|
|
125
|
+
return client;
|
|
126
|
+
}
|
|
127
|
+
async function waitForServer(client) {
|
|
128
|
+
let status = await client.call("status");
|
|
129
|
+
for (let i = 0; i < CONNECT_WAIT_TRIES && !status.connected; i++) {
|
|
130
|
+
await new Promise((resolve) => setTimeout(resolve, CONNECT_WAIT_MS));
|
|
131
|
+
status = await client.call("status");
|
|
132
|
+
}
|
|
133
|
+
if (!status.connected)
|
|
134
|
+
throw new SetupFailed("server_unreachable", `Couldn't reach ${status.server}${status.problem ? ` (${status.problem})` : ""}. Your code wasn't used. Check your connection, then run the same command again.`);
|
|
135
|
+
return status.server;
|
|
136
|
+
}
|
|
137
|
+
async function callConcierge(client, agent, address, caller) {
|
|
138
|
+
const fields = { agent, caller };
|
|
139
|
+
const started = await client.call("initiate_session", { ...fields, target: address });
|
|
140
|
+
await client.call("send", { ...fields, session_id: started.session_id, text: HELLO, signal: "over" });
|
|
141
|
+
const deadline = Date.now() + REPLY_WAIT_SECONDS * 1000;
|
|
142
|
+
try {
|
|
143
|
+
while (Date.now() < deadline) {
|
|
144
|
+
const left = Math.max(1, Math.ceil((deadline - Date.now()) / 1000));
|
|
145
|
+
await client.call("wait", { ...fields, timeout_seconds: left }, (left + 10) * 1000);
|
|
146
|
+
const read = await client.call("receive", { ...fields, session_id: started.session_id });
|
|
147
|
+
const text = read.messages.find((message) => typeof message.text === "string")?.text;
|
|
148
|
+
if (typeof text === "string")
|
|
149
|
+
return { replied: true, text };
|
|
150
|
+
}
|
|
151
|
+
return { replied: false, problem: `no reply within ${REPLY_WAIT_SECONDS} seconds` };
|
|
152
|
+
}
|
|
153
|
+
finally {
|
|
154
|
+
await client.call("close_session", { ...fields, session_id: started.session_id }).catch(() => undefined);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async function heardFrom(client, agent, address) {
|
|
158
|
+
const { sessions } = await client.call("sessions", { agent, all: true });
|
|
159
|
+
return sessions.some((session) => address.startsWith(session.with_id) && session.position >= 2);
|
|
160
|
+
}
|
|
161
|
+
async function heardOnThisMachine(client, address) {
|
|
162
|
+
const { agents } = await client.call("status", {});
|
|
163
|
+
for (const one of agents)
|
|
164
|
+
if (await heardFrom(client, one.agent_id, address))
|
|
165
|
+
return true;
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
export async function setup(args, host) {
|
|
169
|
+
const asJson = args.includes("--json");
|
|
170
|
+
const say = (line) => { if (!asJson)
|
|
171
|
+
process.stdout.write(`${line}\n`); };
|
|
172
|
+
const refuse = (code, message) => {
|
|
173
|
+
process.stderr.write(asJson ? `${JSON.stringify({ error: code, message })}\n` : `${message}\n`);
|
|
174
|
+
return 1;
|
|
175
|
+
};
|
|
176
|
+
let client;
|
|
177
|
+
try {
|
|
178
|
+
const flags = options(args);
|
|
179
|
+
const text = (name) => (typeof flags[name] === "string" ? flags[name] : undefined);
|
|
180
|
+
// --code - takes the code from standard input, so it never sits in a command line or in shell history.
|
|
181
|
+
const code = text("code") === "-" ? await codeFromStandardInput() : text("code");
|
|
182
|
+
await moveOldVersion(host, say);
|
|
183
|
+
if (!code && !existsSync(databasePath()))
|
|
184
|
+
return refuse("code_required", HOW_TO_GET_A_CODE);
|
|
185
|
+
client = await daemon(host, text("server"), flags["yes"] === true, say);
|
|
186
|
+
const server = await waitForServer(client);
|
|
187
|
+
for (const [flag, setting] of [["issuer", "issuer_url"], ["concierge", "concierge_address"]]) {
|
|
188
|
+
const value = text(flag);
|
|
189
|
+
// "none" is for this run only: it changes no setting, so a test or a script can set up without calling anyone.
|
|
190
|
+
if (value && !(flag === "concierge" && value.toLowerCase() === "none"))
|
|
191
|
+
await client.call("settings_set", { name: setting, value, caller: host.caller });
|
|
192
|
+
}
|
|
193
|
+
const skipConcierge = text("concierge")?.toLowerCase() === "none";
|
|
194
|
+
const agent = await client.call("enroll_agent", { name: text("name"), code });
|
|
195
|
+
say(agent.already_set_up ? `${agent.name} is already set up, so nothing changed, and no code was used.` : `${agent.name} has its verified email signal.`);
|
|
196
|
+
if (!agent.online)
|
|
197
|
+
throw new SetupFailed("not_registered", `${agent.name} has its signal, and the server didn't take it: ${agent.note ?? "no reason given"}. Your code is safe. Run the same command again.`);
|
|
198
|
+
const held = await client.call("signals_list", { agent: agent.agent_id });
|
|
199
|
+
if (held.signals.some((signal) => signal.type === "email" && !signal.counts_as_verified))
|
|
200
|
+
say("This machine doesn't recognise that issuer yet, because it isn't on a signed issuer list here, so the signal shows as unknown.");
|
|
201
|
+
say(`Your agent's address, which is what you share:\n${agent.address}`);
|
|
202
|
+
host.rememberAgent(agent.agent_id);
|
|
203
|
+
const settings = await client.call("settings", {});
|
|
204
|
+
const concierge = settings.settings.find((setting) => setting.name === "concierge_address")?.value;
|
|
205
|
+
let reply = null;
|
|
206
|
+
// The Concierge helps once per machine. Once it has answered any agent here, a new one isn't introduced again.
|
|
207
|
+
const called = !skipConcierge && typeof concierge === "string" && await heardOnThisMachine(client, concierge);
|
|
208
|
+
if (skipConcierge) {
|
|
209
|
+
say("Not calling the Concierge, as asked.");
|
|
210
|
+
}
|
|
211
|
+
else if (called) {
|
|
212
|
+
say("The Concierge has already answered an agent on this machine, so it isn't called again.");
|
|
213
|
+
}
|
|
214
|
+
else if (typeof concierge === "string" && concierge !== "") {
|
|
215
|
+
say("Calling the CELLO Concierge, an agent run by CELLO...");
|
|
216
|
+
try {
|
|
217
|
+
reply = await callConcierge(client, agent.agent_id, concierge, host.caller);
|
|
218
|
+
}
|
|
219
|
+
catch (err) {
|
|
220
|
+
if (!(err instanceof DaemonRefused))
|
|
221
|
+
throw err;
|
|
222
|
+
reply = { replied: false, problem: err.message };
|
|
223
|
+
}
|
|
224
|
+
finally {
|
|
225
|
+
await client.call("stop_using_agent", { agent: agent.agent_id, caller: host.caller }).catch(() => undefined);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
say("There's no Concierge to call yet, so this hasn't shown a reply from another agent.");
|
|
230
|
+
}
|
|
231
|
+
if (reply?.replied)
|
|
232
|
+
say(`The Concierge replied, in its own words:\n"${reply.text.replace(/\p{Cc}/gu, " ")}"`);
|
|
233
|
+
if (reply && !reply.replied)
|
|
234
|
+
throw new SetupFailed("concierge_silent", `Your agent is set up, and the Concierge didn't answer: ${reply.problem}. Run the same command again to retry. Nothing is lost.`);
|
|
235
|
+
const installed = flags["install-mcp"] === true ? installMcp() : null;
|
|
236
|
+
for (const line of installed ?? [])
|
|
237
|
+
say(`${line.app}: ${line.outcome.replace("_", " ")}. ${line.detail}`);
|
|
238
|
+
if (!installed) {
|
|
239
|
+
say("Next, to use it from Claude Code:");
|
|
240
|
+
say(' claude plugin marketplace add "$(npm root -g)/@cello-protocol/cli"');
|
|
241
|
+
say(" claude plugin install cello@cello-protocol");
|
|
242
|
+
say(" claude --dangerously-load-development-channels plugin:cello@cello-protocol");
|
|
243
|
+
say("Or let setup connect the apps on this machine: cello setup --install-mcp");
|
|
244
|
+
}
|
|
245
|
+
if (asJson)
|
|
246
|
+
process.stdout.write(`${JSON.stringify({ ok: true, server, name: agent.name, agent_id: agent.agent_id, address: agent.address, already_set_up: agent.already_set_up === true, signals_held: agent.signals_held ?? null, concierge: reply, install_mcp: installed })}\n`);
|
|
247
|
+
return installed?.some((line) => line.outcome === "failed") ? 1 : 0;
|
|
248
|
+
}
|
|
249
|
+
catch (err) {
|
|
250
|
+
if (err instanceof SetupFailed || err instanceof DaemonRefused)
|
|
251
|
+
return refuse(err.code, err.message);
|
|
252
|
+
if (err instanceof DaemonGone)
|
|
253
|
+
return refuse(err.code, "The background program stopped during setup. Run the same command again.");
|
|
254
|
+
throw err;
|
|
255
|
+
}
|
|
256
|
+
finally {
|
|
257
|
+
client?.close();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SHIPPED_ISSUER_LIST: string | null;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// The signed issuer list this client ships with, in base64: signed by two root keys on 6 November 2026, naming
|
|
2
|
+
// trust.celloprotocol.com, valid 365 days. The daemon replaces it with a newer list fetched from the issuer.
|
|
3
|
+
export const SHIPPED_ISSUER_LIST = "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";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
interface SignalLine {
|
|
2
|
+
signal_hash: string;
|
|
3
|
+
type: string;
|
|
4
|
+
issuer_address: string;
|
|
5
|
+
issuer_standing: string;
|
|
6
|
+
status: string;
|
|
7
|
+
consent_state: string;
|
|
8
|
+
same_operator?: boolean;
|
|
9
|
+
default_present: boolean;
|
|
10
|
+
public?: boolean;
|
|
11
|
+
issued_at: number;
|
|
12
|
+
expires_at: number | null;
|
|
13
|
+
notes: string[];
|
|
14
|
+
subject_kind: string;
|
|
15
|
+
issuer_kind: string;
|
|
16
|
+
issuer_pubkey: string;
|
|
17
|
+
supersedes_hash: string | null;
|
|
18
|
+
counts_as_verified: boolean;
|
|
19
|
+
schema_version?: number;
|
|
20
|
+
payload?: unknown;
|
|
21
|
+
}
|
|
22
|
+
export declare function signalsListText(result: {
|
|
23
|
+
signals: SignalLine[];
|
|
24
|
+
not_shown: number;
|
|
25
|
+
}): string;
|
|
26
|
+
export declare function signalViewText(s: SignalLine): string;
|
|
27
|
+
export declare function publicSignalsText(result: {
|
|
28
|
+
agent: string;
|
|
29
|
+
signals: SignalLine[];
|
|
30
|
+
refused: {
|
|
31
|
+
fault: string;
|
|
32
|
+
message: string;
|
|
33
|
+
}[];
|
|
34
|
+
}): string;
|
|
35
|
+
export declare function presentedText(result: {
|
|
36
|
+
session_id: string;
|
|
37
|
+
from: string;
|
|
38
|
+
theirs: SignalLine[];
|
|
39
|
+
refused: {
|
|
40
|
+
fault: string;
|
|
41
|
+
message: string;
|
|
42
|
+
}[];
|
|
43
|
+
theirs_unreadable: boolean;
|
|
44
|
+
yours_sent: number;
|
|
45
|
+
}): string;
|
|
46
|
+
export {};
|