@atbash/cli 0.5.15 → 0.6.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +338 -0
- package/dist/bin/atbash.js +34 -2
- package/dist/bin/atbash.js.map +1 -1
- package/dist/commands/connect.d.ts +55 -1
- package/dist/commands/connect.js +11 -8
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/github-scan.d.ts +104 -0
- package/dist/commands/github-scan.js +1054 -0
- package/dist/commands/github-scan.js.map +1 -0
- package/dist/commands/held.js +7 -2
- package/dist/commands/held.js.map +1 -1
- package/dist/commands/history.js +4 -1
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/judge-options.d.ts +21 -0
- package/dist/commands/judge-options.js +24 -0
- package/dist/commands/judge-options.js.map +1 -0
- package/dist/commands/judge.js +4 -1
- package/dist/commands/judge.js.map +1 -1
- package/dist/commands/policy.js +4 -1
- package/dist/commands/policy.js.map +1 -1
- package/dist/commands/scan.d.ts +45 -0
- package/dist/commands/scan.js +301 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/setup.d.ts +151 -0
- package/dist/commands/setup.js +944 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/stats.js +3 -1
- package/dist/commands/stats.js.map +1 -1
- package/dist/commands/status.js +4 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/tier.js +4 -1
- package/dist/commands/tier.js.map +1 -1
- package/dist/commands/tools.js +11 -4
- package/dist/commands/tools.js.map +1 -1
- package/dist/commands/whoami.js +4 -1
- package/dist/commands/whoami.js.map +1 -1
- package/dist/lib/grade-llm.d.ts +38 -0
- package/dist/lib/grade-llm.js +64 -0
- package/dist/lib/grade-llm.js.map +1 -0
- package/dist/lib/llm.d.ts +34 -0
- package/dist/lib/llm.js +101 -0
- package/dist/lib/llm.js.map +1 -0
- package/dist/lib/policy.d.ts +40 -0
- package/dist/lib/policy.js +94 -0
- package/dist/lib/policy.js.map +1 -0
- package/dist/lib/risk.d.ts +112 -0
- package/dist/lib/risk.js +288 -0
- package/dist/lib/risk.js.map +1 -0
- package/dist/lib/threats-llm.d.ts +39 -0
- package/dist/lib/threats-llm.js +72 -0
- package/dist/lib/threats-llm.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.toRows = toRows;
|
|
7
|
+
exports.toScanTools = toScanTools;
|
|
8
|
+
exports.countNetworkRequests = countNetworkRequests;
|
|
9
|
+
exports.registerScanCommand = registerScanCommand;
|
|
10
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
11
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
12
|
+
const connect_1 = require("./connect");
|
|
13
|
+
const introspect_mcp_1 = require("./introspect-mcp");
|
|
14
|
+
const risk_1 = require("../lib/risk");
|
|
15
|
+
const grade_llm_1 = require("../lib/grade-llm");
|
|
16
|
+
const threats_llm_1 = require("../lib/threats-llm");
|
|
17
|
+
const policy_1 = require("../lib/policy");
|
|
18
|
+
const llm_1 = require("../lib/llm");
|
|
19
|
+
/** One row per discovered runtime, with its tool names flattened for display. */
|
|
20
|
+
function toRows(agents) {
|
|
21
|
+
return agents.map((a) => {
|
|
22
|
+
const tools = a.type === "declared" && Array.isArray(a.declaredTools)
|
|
23
|
+
? a.declaredTools.map((t) => t.name)
|
|
24
|
+
: a.type === "config" && a.config?.mcpServers
|
|
25
|
+
? Object.keys(a.config.mcpServers)
|
|
26
|
+
: [];
|
|
27
|
+
return { label: a.label, detail: a.detail, kind: a.type, tools };
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The tool surface the risk engine grades.
|
|
32
|
+
*
|
|
33
|
+
* A config's SERVER names are deliberately not included: "gmail" is a server, not
|
|
34
|
+
* a capability, and grading it would invent a finding out of a filename. That is
|
|
35
|
+
* why a config-only machine needs --introspect before it gets a risk report — the
|
|
36
|
+
* scan says so rather than quietly reporting "Low".
|
|
37
|
+
*/
|
|
38
|
+
function toScanTools(agents, introspection) {
|
|
39
|
+
const out = [];
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
const add = (name, description, source) => {
|
|
42
|
+
const key = (0, risk_1.toolKey)(source, name);
|
|
43
|
+
if (!name || seen.has(key))
|
|
44
|
+
return;
|
|
45
|
+
seen.add(key);
|
|
46
|
+
out.push({ name, description, source });
|
|
47
|
+
};
|
|
48
|
+
// Declared runtimes enumerated their own tools locally.
|
|
49
|
+
for (const a of agents) {
|
|
50
|
+
if (a.type === "declared")
|
|
51
|
+
for (const t of a.declaredTools ?? [])
|
|
52
|
+
add(t.name, t.description, a.label);
|
|
53
|
+
}
|
|
54
|
+
// Introspection is the authoritative surface for a config source: the names the
|
|
55
|
+
// server itself advertised, rather than what a config file claims.
|
|
56
|
+
for (const r of introspection) {
|
|
57
|
+
for (const s of r.servers) {
|
|
58
|
+
if (!s.ok)
|
|
59
|
+
continue;
|
|
60
|
+
for (const t of s.tools)
|
|
61
|
+
add(t.name, t.description, `${r.label}/${s.server}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
/** Tool names each MCP server advertised, keyed by server name. */
|
|
67
|
+
function introspectedByServer(results) {
|
|
68
|
+
const out = new Map();
|
|
69
|
+
for (const r of results) {
|
|
70
|
+
for (const s of r.servers) {
|
|
71
|
+
if (s.ok)
|
|
72
|
+
out.set(s.server, s.tools.map((t) => t.name));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Requests that actually left the machine. Only HTTP-transport servers are
|
|
79
|
+
* reached over the network — and then at the URL the user's own config names,
|
|
80
|
+
* never an Atbash host. stdio servers are spawned locally and spoken to over a
|
|
81
|
+
* pipe, so they are not counted here.
|
|
82
|
+
*/
|
|
83
|
+
function countNetworkRequests(results) {
|
|
84
|
+
return results.reduce((n, r) => n + r.servers.filter((s) => s.transport === "http").length, 0);
|
|
85
|
+
}
|
|
86
|
+
const LEVEL_RANK = { Low: 0, Elevated: 1, High: 2 };
|
|
87
|
+
const FAIL_ON = { low: "Low", elevated: "Elevated", high: "High" };
|
|
88
|
+
const SEV_COLOR = {
|
|
89
|
+
high: chalk_1.default.red,
|
|
90
|
+
medium: chalk_1.default.yellow,
|
|
91
|
+
low: chalk_1.default.green,
|
|
92
|
+
};
|
|
93
|
+
function renderThreats(threats) {
|
|
94
|
+
console.log(" " + chalk_1.default.bold("Threat paths") + "\n " + "\u2500".repeat(28));
|
|
95
|
+
console.log(chalk_1.default.dim(" Combinations the per-tool rules cannot see. Model-generated.\n"));
|
|
96
|
+
for (const t of threats) {
|
|
97
|
+
console.log(` ${SEV_COLOR[t.severity](t.severity.padEnd(6))} ${chalk_1.default.bold(t.title)} ${chalk_1.default.dim("\u2014 " + t.category)}`);
|
|
98
|
+
if (t.enabledBy)
|
|
99
|
+
console.log(chalk_1.default.dim(` enabled by: ${t.enabledBy}`));
|
|
100
|
+
if (t.consequence)
|
|
101
|
+
console.log(chalk_1.default.dim(` ${t.consequence}`));
|
|
102
|
+
}
|
|
103
|
+
console.log();
|
|
104
|
+
}
|
|
105
|
+
function renderPolicy(policy) {
|
|
106
|
+
console.log(" " + chalk_1.default.bold("Recommended boundary") + "\n " + "\u2500".repeat(28));
|
|
107
|
+
console.log(` ${chalk_1.default.dim("Mandate:")} ${policy.mandate}\n`);
|
|
108
|
+
console.log(` ${chalk_1.default.bold("Red lines")} ${chalk_1.default.dim("(auto-deny)")}`);
|
|
109
|
+
for (const r of policy.redLines)
|
|
110
|
+
console.log(` \u2022 ${r}`);
|
|
111
|
+
console.log(`\n ${chalk_1.default.bold("Needs approval")}`);
|
|
112
|
+
if (policy.approvals.length === 0)
|
|
113
|
+
console.log(chalk_1.default.dim(" (none)"));
|
|
114
|
+
for (const a of policy.approvals)
|
|
115
|
+
console.log(` \u2022 ${a}`);
|
|
116
|
+
console.log("\n" + chalk_1.default.dim(` ${policy.notes}`) + "\n");
|
|
117
|
+
}
|
|
118
|
+
function renderRisk(report, hasKey, enrichError) {
|
|
119
|
+
const levelColor = report.level === "High" ? chalk_1.default.red : report.level === "Elevated" ? chalk_1.default.yellow : chalk_1.default.green;
|
|
120
|
+
console.log(" " + chalk_1.default.bold("Risk") + "\n " + "─".repeat(28));
|
|
121
|
+
console.log(` Level : ${levelColor.bold(report.level)} ${chalk_1.default.dim(`(${report.score}/100)`)}`);
|
|
122
|
+
console.log(` Method : ${report.method === "llm" ? "deterministic + model-graded" : "deterministic"}`);
|
|
123
|
+
console.log(` ${chalk_1.default.dim(report.summary)}\n`);
|
|
124
|
+
// Secondary paths are extra harms on a tool already listed; showing them inline
|
|
125
|
+
// would read as duplicate findings, so the primary carries the line.
|
|
126
|
+
const primary = report.paths.filter((p) => !p.secondary);
|
|
127
|
+
const shown = primary.slice(0, 12);
|
|
128
|
+
for (const p of shown) {
|
|
129
|
+
const sev = SEV_COLOR[p.severity](p.severity.padEnd(6));
|
|
130
|
+
console.log(` ${sev} ${chalk_1.default.bold(p.tool)} ${chalk_1.default.dim("— " + p.category)}`);
|
|
131
|
+
console.log(` ${chalk_1.default.dim(p.consequence)}`);
|
|
132
|
+
}
|
|
133
|
+
if (primary.length > shown.length) {
|
|
134
|
+
console.log(chalk_1.default.dim(` … ${primary.length - shown.length} more`));
|
|
135
|
+
}
|
|
136
|
+
console.log();
|
|
137
|
+
if (enrichError) {
|
|
138
|
+
console.log(chalk_1.default.yellow(` Model grading unavailable (${enrichError}) — deterministic result kept.\n`));
|
|
139
|
+
}
|
|
140
|
+
const unclassified = primary.filter(risk_1.isUnclassifiedPath).length;
|
|
141
|
+
if (unclassified > 0 && !hasKey) {
|
|
142
|
+
console.log(chalk_1.default.dim(` ${unclassified} tool${unclassified === 1 ? "" : "s"} matched no rule. Pass --api-key <key> to grade\n` +
|
|
143
|
+
" them with your own LLM provider (tool names and descriptions are sent there).\n"));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function render(rows, introspected, introspectRan, report, toolCount, hasKey, enrichError) {
|
|
147
|
+
console.log("\n" + chalk_1.default.bold(" Atbash local scan") + "\n " + "─".repeat(28));
|
|
148
|
+
console.log(` Machine : ${node_os_1.default.hostname()}`);
|
|
149
|
+
console.log(` Found : ${rows.length} runtime${rows.length === 1 ? "" : "s"}\n`);
|
|
150
|
+
if (rows.length === 0) {
|
|
151
|
+
console.log(chalk_1.default.dim(" No agents or MCP configs found in the usual locations.\n"));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
for (const r of rows) {
|
|
155
|
+
console.log(` ${chalk_1.default.bold(r.label)} ${chalk_1.default.dim("— " + r.detail)}`);
|
|
156
|
+
for (const name of r.tools) {
|
|
157
|
+
// A name the server itself advertised is worth more than one read out of a
|
|
158
|
+
// config file, so say which this is rather than presenting them alike.
|
|
159
|
+
const confirmed = introspected.get(name);
|
|
160
|
+
if (confirmed) {
|
|
161
|
+
console.log(` • ${name} ${chalk_1.default.dim(`(${confirmed.length} tool${confirmed.length === 1 ? "" : "s"} confirmed)`)}`);
|
|
162
|
+
for (const t of confirmed.slice(0, 8))
|
|
163
|
+
console.log(chalk_1.default.dim(` - ${t}`));
|
|
164
|
+
if (confirmed.length > 8)
|
|
165
|
+
console.log(chalk_1.default.dim(` … ${confirmed.length - 8} more`));
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
console.log(` • ${name}${introspectRan && r.kind === "config" ? chalk_1.default.dim(" (not reached)") : ""}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
console.log();
|
|
172
|
+
}
|
|
173
|
+
if (toolCount === 0) {
|
|
174
|
+
console.log(chalk_1.default.dim(" No tool surface was resolved, so no risk could be derived. Config files name\n" +
|
|
175
|
+
" servers, not capabilities — add --introspect to ask each server what it\n" +
|
|
176
|
+
" actually advertises.\n"));
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
renderRisk(report, hasKey, enrichError);
|
|
180
|
+
}
|
|
181
|
+
if (!introspectRan) {
|
|
182
|
+
console.log(chalk_1.default.dim(" Tool names above are what the configs declare. Add --introspect to ask\n each MCP server what it actually advertises.\n"));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function registerScanCommand(program) {
|
|
186
|
+
program
|
|
187
|
+
.command("scan")
|
|
188
|
+
.description("Scan this machine for installed agents and MCP tools, grade the risk, and print the report here (the report is never sent anywhere)")
|
|
189
|
+
.option("--home <dir>", "Home directory to scan (for testing)")
|
|
190
|
+
.option("--introspect", "Also ask each configured MCP server which tools it advertises: stdio servers are started locally, HTTP servers are contacted at the URL their own config names. Never calls a tool")
|
|
191
|
+
.option("--api-key <key>", "YOUR LLM provider key (OpenRouter), used to grade tools the built-in rules could not classify. Sends those tool names and descriptions to that provider. Also read from ATBASH_SCAN_API_KEY or OPENROUTER_API_KEY")
|
|
192
|
+
.option("--model <id>", `Model for --api-key grading (default: ${llm_1.DEFAULT_MODEL})`)
|
|
193
|
+
.option("--threats", "Also enumerate CROSS-TOOL threat chains (e.g. read customer data + external send = exfiltration). Requires --api-key; never changes the risk score")
|
|
194
|
+
.option("--policy", "Also print a draft governance boundary derived from the findings: red lines and approval-required actions. Deterministic, no key needed")
|
|
195
|
+
.option("--fail-on <level>", "Exit 1 when the risk level reaches this: low, elevated or high (for CI)")
|
|
196
|
+
.option("--json", "Emit machine-readable JSON instead of formatted text")
|
|
197
|
+
.action(async (opts) => {
|
|
198
|
+
const home = opts.home || node_os_1.default.homedir();
|
|
199
|
+
let failOn;
|
|
200
|
+
if (opts.failOn) {
|
|
201
|
+
failOn = FAIL_ON[opts.failOn.toLowerCase()];
|
|
202
|
+
if (!failOn) {
|
|
203
|
+
console.error(chalk_1.default.red(` Invalid --fail-on "${opts.failOn}". Choose: low, elevated, high.`));
|
|
204
|
+
process.exitCode = 2;
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const agents = (0, connect_1.discover)(home);
|
|
209
|
+
const rows = toRows(agents);
|
|
210
|
+
let introspection = [];
|
|
211
|
+
if (opts.introspect) {
|
|
212
|
+
if (!opts.json)
|
|
213
|
+
console.log(chalk_1.default.dim("\n Asking configured MCP servers to list their tools…"));
|
|
214
|
+
try {
|
|
215
|
+
// The RAW specs, not the ones `discover` returns. Those are sanitized for
|
|
216
|
+
// relay — absolute command paths reduced to a basename, `env`/`headers`
|
|
217
|
+
// dropped — which is right for a payload and fatal for actually starting a
|
|
218
|
+
// server: a command installed outside PATH fails with ENOENT and the report
|
|
219
|
+
// blames the user's server for the scan's own omission. Nothing raw is
|
|
220
|
+
// printed; introspection returns only sanitized names and redacted errors.
|
|
221
|
+
const sources = (0, connect_1.readAllMcpServers)(home);
|
|
222
|
+
introspection = await (0, introspect_mcp_1.introspectServers)(sources);
|
|
223
|
+
}
|
|
224
|
+
catch (err) {
|
|
225
|
+
// Introspection is the optional half: a server that will not start must
|
|
226
|
+
// not cost the user the discovery result they already have.
|
|
227
|
+
if (!opts.json)
|
|
228
|
+
console.error(chalk_1.default.yellow(` Introspection failed: ${err.message}`));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const tools = toScanTools(agents, introspection);
|
|
232
|
+
let report = (0, risk_1.deriveRisk)(tools);
|
|
233
|
+
let networkRequests = countNetworkRequests(introspection);
|
|
234
|
+
// The user's own key, never a platform one. Env vars are accepted so a CI
|
|
235
|
+
// job never has to put a secret in argv, where it is visible in the process
|
|
236
|
+
// list to every other user on the box.
|
|
237
|
+
const apiKey = opts.apiKey || process.env.ATBASH_SCAN_API_KEY || process.env.OPENROUTER_API_KEY;
|
|
238
|
+
let enrichError;
|
|
239
|
+
if (apiKey && tools.length > 0) {
|
|
240
|
+
// Matched on source+name, not name alone: two different MCP servers can
|
|
241
|
+
// expose a same-named tool, and a name-only match would sweep an ALREADY
|
|
242
|
+
// classified tool's real description into the LLM batch just because some
|
|
243
|
+
// other server's same-named tool is unclassified.
|
|
244
|
+
const unclassified = tools.filter((t) => report.paths.some((p) => (0, risk_1.toolKey)(p.source, p.tool) === (0, risk_1.toolKey)(t.source, t.name) && !p.secondary && (0, risk_1.isUnclassifiedPath)(p)));
|
|
245
|
+
if (unclassified.length > 0) {
|
|
246
|
+
if (!opts.json) {
|
|
247
|
+
console.log(chalk_1.default.dim(`\n Grading ${unclassified.length} unclassified tool${unclassified.length === 1 ? "" : "s"} with your provider…`));
|
|
248
|
+
}
|
|
249
|
+
const outcome = await (0, grade_llm_1.gradeToolsWithLlm)(unclassified, { apiKey, model: opts.model });
|
|
250
|
+
networkRequests += outcome.requests;
|
|
251
|
+
enrichError = outcome.error;
|
|
252
|
+
report = (0, risk_1.gradeUnclassifiedPaths)(report, outcome.grades);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
let threats = [];
|
|
256
|
+
let threatError;
|
|
257
|
+
if (opts.threats && tools.length > 0) {
|
|
258
|
+
if (!apiKey) {
|
|
259
|
+
threatError = "no API key — threat chains need one (--api-key, ATBASH_SCAN_API_KEY or OPENROUTER_API_KEY)";
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
if (!opts.json)
|
|
263
|
+
console.log(chalk_1.default.dim("\n Looking for cross-tool threat chains\u2026"));
|
|
264
|
+
const outcome = await (0, threats_llm_1.deriveThreats)(tools, { apiKey, model: opts.model });
|
|
265
|
+
networkRequests += outcome.requests;
|
|
266
|
+
threatError = outcome.error;
|
|
267
|
+
threats = outcome.threats;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// Derived from the report, so it reflects any model grading that ran. The
|
|
271
|
+
// boundary is a SUGGESTION printed here; nothing is deployed anywhere.
|
|
272
|
+
const policy = opts.policy ? (0, policy_1.suggestPolicy)(report) : undefined;
|
|
273
|
+
if (failOn && LEVEL_RANK[report.level] >= LEVEL_RANK[failOn]) {
|
|
274
|
+
process.exitCode = 1;
|
|
275
|
+
}
|
|
276
|
+
if (opts.json) {
|
|
277
|
+
console.log(JSON.stringify({
|
|
278
|
+
ok: true,
|
|
279
|
+
machine: node_os_1.default.hostname(),
|
|
280
|
+
local: true,
|
|
281
|
+
networkRequests,
|
|
282
|
+
agents: rows,
|
|
283
|
+
introspection,
|
|
284
|
+
risk: report,
|
|
285
|
+
...(threats.length > 0 ? { threats } : {}),
|
|
286
|
+
...(policy ? { policy } : {}),
|
|
287
|
+
...(enrichError ? { enrichmentError: enrichError } : {}),
|
|
288
|
+
...(threatError ? { threatError } : {}),
|
|
289
|
+
}, null, 2));
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
render(rows, introspectedByServer(introspection), !!opts.introspect, report, tools.length, !!apiKey, enrichError);
|
|
293
|
+
if (threatError)
|
|
294
|
+
console.log(chalk_1.default.yellow(` Threat analysis unavailable (${threatError}).\n`));
|
|
295
|
+
if (threats.length > 0)
|
|
296
|
+
renderThreats(threats);
|
|
297
|
+
if (policy)
|
|
298
|
+
renderPolicy(policy);
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
//# sourceMappingURL=scan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":";;;;;AA2CA,wBAUC;AAUD,kCAuBC;AAmBD,oDAEC;AA2HD,kDAiIC;AAvWD,sDAAyB;AAEzB,kDAA0B;AAC1B,uCAAoE;AACpE,qDAA+E;AAC/E,sCAQqB;AACrB,gDAAqD;AACrD,oDAAgE;AAChE,0CAAqE;AACrE,oCAA2C;AAyB3C,iFAAiF;AACjF,SAAgB,MAAM,CAAC,MAAe;IACpC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACtB,MAAM,KAAK,GACT,CAAC,CAAC,IAAI,KAAK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|
+
import { Command } from "commander";
|
|
2
|
+
interface KeyMaterial {
|
|
3
|
+
privkey: string;
|
|
4
|
+
/** Present when the source stated one; always re-derived and cross-checked. */
|
|
5
|
+
statedPubkey?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Pull key material out of whatever the owner pointed us at.
|
|
9
|
+
*
|
|
10
|
+
* Accepts every shape Atbash itself produces or documents, so "the file I
|
|
11
|
+
* downloaded from the modal" always works:
|
|
12
|
+
* - `privkey=…` / `pubkey=…` lines (what onboarding downloads, and what the
|
|
13
|
+
* plugin parses)
|
|
14
|
+
* - `{"privKey":…,"pubKey":…}` JSON (the alternate documented key-file form)
|
|
15
|
+
* - a bare 64-hex private key on its own line (someone who copied just the key)
|
|
16
|
+
*
|
|
17
|
+
* Returns null rather than throwing: the caller tries several sources in turn and
|
|
18
|
+
* an unparseable one is a reason to move on, not to abort.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseKeyMaterial(raw: string): KeyMaterial | null;
|
|
21
|
+
/** Normalize to the lowercase 64-hex the SDK validates, or "" if it is not one. */
|
|
22
|
+
export declare function normalizePrivkey(raw: string): string;
|
|
23
|
+
/** Files in a directory that plausibly hold an Atbash agent key, newest first. */
|
|
24
|
+
export declare function keyCandidatesInDir(dir: string): string[];
|
|
25
|
+
interface KeySource {
|
|
26
|
+
material: KeyMaterial;
|
|
27
|
+
/** Human description of WHERE it came from. Never contains the key. */
|
|
28
|
+
from: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Find the agent key, trying every way an owner could plausibly have it.
|
|
32
|
+
*
|
|
33
|
+
* Order is "most explicit first": a flag the owner typed beats a file we guessed
|
|
34
|
+
* at. The last resort is the interactive prompt, and if there is no TTY the
|
|
35
|
+
* caller gets a clear error listing the flags rather than a hang.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveKeySource(opts: {
|
|
38
|
+
key?: string;
|
|
39
|
+
keyFile?: string;
|
|
40
|
+
keysDir?: string;
|
|
41
|
+
home: string;
|
|
42
|
+
/** Set for non-interactive runs (CI, an AI assistant with no TTY). */
|
|
43
|
+
allowPrompt: boolean;
|
|
44
|
+
}): Promise<KeySource | {
|
|
45
|
+
error: string;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* One thing setup will do. Building the whole plan BEFORE touching anything is
|
|
49
|
+
* what makes `--dry-run` truthful: the preview and the run are the same objects,
|
|
50
|
+
* so the preview cannot describe a merge the apply step then performs
|
|
51
|
+
* differently. Every `write` carries its exact final bytes.
|
|
52
|
+
*/
|
|
53
|
+
export type Step = {
|
|
54
|
+
kind: "write";
|
|
55
|
+
label: string;
|
|
56
|
+
file: string;
|
|
57
|
+
mode?: number;
|
|
58
|
+
before: string | null;
|
|
59
|
+
after: string;
|
|
60
|
+
secret?: boolean;
|
|
61
|
+
} | {
|
|
62
|
+
kind: "exec";
|
|
63
|
+
label: string;
|
|
64
|
+
command: string;
|
|
65
|
+
args: string[];
|
|
66
|
+
optionalWhy?: string;
|
|
67
|
+
} | {
|
|
68
|
+
kind: "manual";
|
|
69
|
+
label: string;
|
|
70
|
+
detail: string;
|
|
71
|
+
snippet?: string;
|
|
72
|
+
};
|
|
73
|
+
export interface Plan {
|
|
74
|
+
steps: Step[];
|
|
75
|
+
/** Things the owner must know, printed whether or not anything was written. */
|
|
76
|
+
notes: string[];
|
|
77
|
+
/** Runtimes found on this machine, for the summary line. */
|
|
78
|
+
found: string[];
|
|
79
|
+
}
|
|
80
|
+
/** The key file, in the `key=value` form the plugin and the SDK both parse. */
|
|
81
|
+
export declare function keyFileContents(privkey: string, pubkey: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* True when a JSON file uses JSONC features (comments, trailing commas).
|
|
84
|
+
*
|
|
85
|
+
* We must not auto-merge into one: writing it back with JSON.stringify would
|
|
86
|
+
* silently delete the owner's comments. Detected by the disagreement between the
|
|
87
|
+
* strict and tolerant parsers — strict fails, tolerant succeeds.
|
|
88
|
+
*/
|
|
89
|
+
export declare function isJsonc(text: string): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Merge the Atbash plugin block into an OpenClaw config object, in place.
|
|
92
|
+
*
|
|
93
|
+
* A MERGE, not a replacement — that distinction is the whole reason this command
|
|
94
|
+
* exists. Other plugins already in `allow`, `load.paths` and `entries` are
|
|
95
|
+
* preserved, and an entry from the legacy `@atbash/atbash-plugin` install is
|
|
96
|
+
* updated where it stands rather than being shadowed by a duplicate: the
|
|
97
|
+
* dashboard scan recognizes both keys, so two entries would mean two hooks.
|
|
98
|
+
*
|
|
99
|
+
* `load.paths` gets the real absolute extension path. The published docs show a
|
|
100
|
+
* `<your-username>` placeholder that people paste verbatim, producing a path that
|
|
101
|
+
* does not exist and a plugin that never loads.
|
|
102
|
+
*/
|
|
103
|
+
export declare function mergeOpenclawConfig(config: Record<string, unknown>, home: string): Record<string, unknown>;
|
|
104
|
+
/**
|
|
105
|
+
* Work out everything that needs doing on this machine, without doing any of it.
|
|
106
|
+
*
|
|
107
|
+
* Detection drives the plan rather than a flag the owner picks, for the same
|
|
108
|
+
* reason the scan does: what is actually installed here is knowable, and asking
|
|
109
|
+
* someone to identify their own runtime from a list invites a wrong answer that
|
|
110
|
+
* writes a config for a plugin they do not have.
|
|
111
|
+
*/
|
|
112
|
+
export declare function buildPlan(args: {
|
|
113
|
+
home: string;
|
|
114
|
+
privkey: string;
|
|
115
|
+
pubkey: string;
|
|
116
|
+
/** Skip package installation; write config and the key file only. */
|
|
117
|
+
noInstall: boolean;
|
|
118
|
+
/** Restrict to these runtime ids; empty means "everything detected". */
|
|
119
|
+
only: string[];
|
|
120
|
+
}): Plan;
|
|
121
|
+
/**
|
|
122
|
+
* A minimal line diff, so the preview shows what CHANGES rather than dumping a
|
|
123
|
+
* whole config and leaving the owner to spot the difference. Standard LCS; these
|
|
124
|
+
* files are small enough that the quadratic table is irrelevant.
|
|
125
|
+
*/
|
|
126
|
+
export declare function lineDiff(before: string, after: string): string[];
|
|
127
|
+
/**
|
|
128
|
+
* Print the plan. Used for `--dry-run` and for the confirmation prompt, so what
|
|
129
|
+
* the owner is shown and what they agree to cannot diverge.
|
|
130
|
+
*
|
|
131
|
+
* The key file's CONTENTS are never printed — the whole point of the file is that
|
|
132
|
+
* the private key stays put, and echoing it into a terminal scrollback undoes
|
|
133
|
+
* that. The path, mode and the public key are shown instead.
|
|
134
|
+
*/
|
|
135
|
+
export declare function renderPlan(plan: Plan, pubkey: string): void;
|
|
136
|
+
/**
|
|
137
|
+
* Copy a file aside before overwriting it, without ever clobbering an existing
|
|
138
|
+
* backup — a second run must not overwrite the pristine copy from the first.
|
|
139
|
+
*/
|
|
140
|
+
export declare function backupFile(file: string): string | null;
|
|
141
|
+
export interface ApplyResult {
|
|
142
|
+
written: string[];
|
|
143
|
+
backups: string[];
|
|
144
|
+
ran: string[];
|
|
145
|
+
failures: string[];
|
|
146
|
+
}
|
|
147
|
+
/** Execute the plan. Writes first, then commands, so a failed install still
|
|
148
|
+
* leaves a correct config and key file behind for a manual retry. */
|
|
149
|
+
export declare function applyPlan(plan: Plan): ApplyResult;
|
|
150
|
+
export declare function registerSetupCommand(program: Command): void;
|
|
151
|
+
export {};
|