@cavelon/cli 0.1.10 → 0.1.12
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 +34 -15
- package/dist/access.js +194 -0
- package/dist/acting.js +123 -0
- package/dist/agent-env.js +20 -2
- package/dist/change-confirmation.js +93 -0
- package/dist/commands/api.js +77 -30
- package/dist/commands/chat.js +16 -8
- package/dist/commands/db.js +474 -0
- package/dist/commands/docs.js +83 -7
- package/dist/commands/index.js +7 -0
- package/dist/commands/limits-set.js +11 -5
- package/dist/commands/loops.js +72 -9
- package/dist/commands/models.js +12 -6
- package/dist/commands/sandboxes.js +7 -2
- package/dist/commands/session.js +111 -24
- package/dist/commands/setup.js +1 -1
- package/dist/commands/solution.js +211 -54
- package/dist/commands/tenants.js +55 -12
- package/dist/commands/values.js +104 -23
- package/dist/commands/work.js +13 -5
- package/dist/confirm-token.js +90 -7
- package/dist/context.js +5 -1
- package/dist/contracts.js +37 -12
- package/dist/database-queries.js +301 -0
- package/dist/fsutil.js +14 -0
- package/dist/http.js +69 -3
- package/dist/install.js +30 -0
- package/dist/invoke.js +12 -2
- package/dist/kit-codes.js +9 -2
- package/dist/mcp.js +106 -19
- package/dist/openapi.js +7 -0
- package/dist/package-check.js +19 -0
- package/dist/preview-report.js +2 -2
- package/dist/principal.js +24 -2
- package/dist/printed.js +5 -0
- package/dist/secret-access.js +30 -9
- package/dist/session.js +36 -8
- package/dist/skills/cavelon-authoring/SKILL.md +93 -10
- package/dist/skills/cavelon-long-running/SKILL.md +18 -8
- package/dist/skills/cavelon-loop/SKILL.md +126 -41
- package/dist/skills/cavelon-testing/SKILL.md +32 -3
- package/dist/trace-view.js +10 -0
- package/dist/update-check.js +2 -2
- package/dist/user-config.js +24 -0
- package/package.json +1 -1
package/dist/commands/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { promises as fs } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { AGENT_VARIABLES, drivenByAgent } from "../agent-env.js";
|
|
4
|
-
import { CURSOR_OPTION, intOption, listOption, pageOf, positional, stringOption, } from "../command.js";
|
|
4
|
+
import { boolOption, CURSOR_OPTION, intOption, listOption, pageOf, positional, stringOption, } from "../command.js";
|
|
5
5
|
import { CavelonError, ExitCode, usageError, validationError } from "../errors.js";
|
|
6
6
|
import { clip, moreHint, table } from "../format.js";
|
|
7
7
|
import { readAll } from "../io.js";
|
|
@@ -9,8 +9,10 @@ import { callOperation, previewRequest } from "../invoke.js";
|
|
|
9
9
|
import { confinedPath } from "../paths.js";
|
|
10
10
|
import { describeSchema, findOperation, jsonBodySchema, matchedLoosely, operations, schemaTypes, secretFields, secretPaths } from "../openapi.js";
|
|
11
11
|
import { harnessNotFoundError, lookupHarness } from "../harness-ref.js";
|
|
12
|
-
import { CONFIRM_TOKEN, confirmToken, confirmTokenRequired,
|
|
13
|
-
import {
|
|
12
|
+
import { CONFIRM_TOKEN, confirmInTerminal, confirmThroughClient, confirmToken, confirmTokenRequired, personApproves, personRoute } from "../confirm-token.js";
|
|
13
|
+
import { actingTarget, targetLine } from "../acting.js";
|
|
14
|
+
import { accessFor, operationAccess } from "../access.js";
|
|
15
|
+
import { cavelonCommand, fill, personCommand } from "../printed.js";
|
|
14
16
|
export const JSON_BODY_DEPRECATED = "`--json <body>` as the request body is deprecated and will be removed in a later release; pass the body with --body. " +
|
|
15
17
|
"--json alone prints JSON, as on every command.";
|
|
16
18
|
export function splitJsonBody(args, warn) {
|
|
@@ -96,7 +98,8 @@ function parseParams(input) {
|
|
|
96
98
|
const FOR_A_PERSON = [
|
|
97
99
|
{
|
|
98
100
|
does: "changes a secret",
|
|
99
|
-
hint: "A person sets a secret in
|
|
101
|
+
hint: "A person sets a secret in the Admin under Settings › Secrets, or, on an instance that still takes a token there, in their own " +
|
|
102
|
+
"terminal with `cavelon secrets set <name>` (or deletes it with `cavelon secrets delete <name>`).",
|
|
100
103
|
match: (word) => word.includes("secret"),
|
|
101
104
|
},
|
|
102
105
|
{
|
|
@@ -118,7 +121,7 @@ export function keptForPerson(op, all) {
|
|
|
118
121
|
if (all.some((o) => o.personOnly)) {
|
|
119
122
|
if (!op.personOnly?.marked)
|
|
120
123
|
return undefined;
|
|
121
|
-
const hint = byPathWords(op)?.hint ?? `A person runs it: in Cavelon, or in their terminal with \`cavelon api ${op.alias}\`.`;
|
|
124
|
+
const hint = byPathWords(op)?.hint ?? `A person runs it: in Cavelon, or in their own terminal with \`cavelon api ${op.alias}\`.`;
|
|
122
125
|
return { source: "instance", ...(op.personOnly.reason ? { reason: op.personOnly.reason } : {}), hint };
|
|
123
126
|
}
|
|
124
127
|
if (op.readOnly)
|
|
@@ -127,12 +130,7 @@ export function keptForPerson(op, all) {
|
|
|
127
130
|
return rule ? { source: "kit", reason: rule.does, hint: rule.hint } : undefined;
|
|
128
131
|
}
|
|
129
132
|
function notSentBy(driven) {
|
|
130
|
-
return driven.by === "mcp"
|
|
131
|
-
? "no tool sends it, with or without confirm."
|
|
132
|
-
: `cavelon api does not send it when a coding agent runs it (${driven.variable} is set), with or without --confirm.`;
|
|
133
|
-
}
|
|
134
|
-
function personHint(hint, driven) {
|
|
135
|
-
return driven.by === "mcp" ? hint : `${hint} A person's own terminal is not guarded: it does not set ${driven.variable}.`;
|
|
133
|
+
return driven.by === "mcp" ? "no tool sends it, with or without confirm." : "cavelon api does not send it when a coding agent runs it, with or without --confirm.";
|
|
136
134
|
}
|
|
137
135
|
function refusal(op, kept, driven) {
|
|
138
136
|
const named = `${op.alias} (${op.method} ${op.path})`;
|
|
@@ -160,7 +158,7 @@ function secretRefusal(op, fields, driven) {
|
|
|
160
158
|
code: "secret_field_for_a_person",
|
|
161
159
|
message: `The request to ${op.alias} sets ${named}, which the instance marks as a secret value (x-cavelon-secret); ` +
|
|
162
160
|
`a person enters secret values, so ${notSentBy(driven)}`,
|
|
163
|
-
hint:
|
|
161
|
+
hint: `A person sets a secret value in their own terminal with \`${cavelonCommand("secrets", "set", fill("name"))}\`, or enters it in the Admin. Leave the field out to send the rest.`,
|
|
164
162
|
details: { fields },
|
|
165
163
|
});
|
|
166
164
|
}
|
|
@@ -202,10 +200,11 @@ export const api = {
|
|
|
202
200
|
"--json <body> still works for now but is deprecated: --json alone prints JSON, as on every command.\n" +
|
|
203
201
|
"The body is checked against the operation's schema before it is sent.\n" +
|
|
204
202
|
"As an MCP tool, or run by a coding agent (" +
|
|
205
|
-
AGENT_VARIABLES.filter((v) => v.variable !== "CAVELON_AGENT").map((v) => v.variable).join(", ") +
|
|
203
|
+
AGENT_VARIABLES.filter((v) => v.variable !== "CAVELON_AGENT").map((v) => (v.value ? `${v.variable}=${v.value}` : v.variable)).join(", ") +
|
|
206
204
|
"\nor CAVELON_AGENT=1 is set), an operation that changes something returns what it would send and a confirm token,\n" +
|
|
207
|
-
"and sends it only with that token:
|
|
208
|
-
"
|
|
205
|
+
"and sends it only with that token and the person's yes: as an MCP tool, confirm: \"<token>\", after which the client\n" +
|
|
206
|
+
"asks the person; from an agent's shell, the person sends it from their own terminal. A changed request needs a new\n" +
|
|
207
|
+
"preview; confirm: true is refused.\n" +
|
|
209
208
|
"Run by an agent, one the instance marks for a person only (x-cavelon-person-only) is refused, as is a body that\n" +
|
|
210
209
|
"sets a field the instance marks as a secret value (x-cavelon-secret) and a file outside the solution folder. On an\n" +
|
|
211
210
|
"instance that marks no operation, one that changes a secret, creates or revokes a credential or decides an\n" +
|
|
@@ -267,8 +266,8 @@ export const api = {
|
|
|
267
266
|
throw new CavelonError(ExitCode.needsAction, {
|
|
268
267
|
code: "operation_for_a_person",
|
|
269
268
|
message: refusal(op, kept, driven),
|
|
270
|
-
hint:
|
|
271
|
-
details: { source: kept.source, ...(kept.reason ? { reason: kept.reason } : {})
|
|
269
|
+
hint: kept.hint,
|
|
270
|
+
details: { source: kept.source, ...(kept.reason ? { reason: kept.reason } : {}) },
|
|
272
271
|
});
|
|
273
272
|
}
|
|
274
273
|
const secrets = secretsIn(doc, op, args);
|
|
@@ -276,10 +275,20 @@ export const api = {
|
|
|
276
275
|
throw secretRefusal(op, secrets, driven);
|
|
277
276
|
}
|
|
278
277
|
if (driven && !op.readOnly) {
|
|
279
|
-
const
|
|
278
|
+
const words = [
|
|
279
|
+
"api",
|
|
280
|
+
name,
|
|
281
|
+
...(input.positionals.params ?? []),
|
|
282
|
+
...listOption(input, "param").flatMap((p) => ["-p", p]),
|
|
283
|
+
...(rawBody !== undefined ? ["--body", rawBody] : []),
|
|
284
|
+
...listOption(input, "file").flatMap((f) => ["--file", f]),
|
|
285
|
+
];
|
|
286
|
+
const preview = await previewUnlessConfirmed(ctx, input, doc, op, args, driven, personCommand(...words));
|
|
280
287
|
if (preview)
|
|
281
288
|
return preview;
|
|
282
289
|
}
|
|
290
|
+
if (!driven && !op.readOnly)
|
|
291
|
+
ctx.approved = { guarded: false };
|
|
283
292
|
const client = await ctx.client();
|
|
284
293
|
const result = await callOperation(ctx, client, doc, op, args);
|
|
285
294
|
if (output) {
|
|
@@ -299,7 +308,7 @@ export const api = {
|
|
|
299
308
|
return { data, text };
|
|
300
309
|
},
|
|
301
310
|
};
|
|
302
|
-
async function previewUnlessConfirmed(ctx, input, doc, op, args, driven) {
|
|
311
|
+
async function previewUnlessConfirmed(ctx, input, doc, op, args, driven, command) {
|
|
303
312
|
const given = input.options.confirm;
|
|
304
313
|
if (given === true)
|
|
305
314
|
throw confirmTokenRequired("api");
|
|
@@ -307,19 +316,23 @@ async function previewUnlessConfirmed(ctx, input, doc, op, args, driven) {
|
|
|
307
316
|
const files = (args.files ?? []).map((f) => ({ field: f.field, file: path.relative(ctx.io.cwd, f.path) || f.path }));
|
|
308
317
|
const session = await ctx.session();
|
|
309
318
|
const token = confirmToken({ url: session.url, tenant: session.tenant }, "api", { request, files });
|
|
310
|
-
|
|
319
|
+
const route = personRoute(ctx, driven);
|
|
320
|
+
if (typeof given === "string" && given === token) {
|
|
321
|
+
await personApproves(ctx, driven, { tool: "api", what: `Send ${request.method} ${request.path} (${op.alias}).`, command });
|
|
311
322
|
return undefined;
|
|
323
|
+
}
|
|
312
324
|
const stale = typeof given === "string" && given !== "";
|
|
313
325
|
const bare = given === "" && driven.by === "agent";
|
|
314
|
-
const confirm =
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const
|
|
318
|
-
const lines = [`Would send ${request.method} ${request.path}. Nothing was sent.`];
|
|
326
|
+
const confirm = route === "client" ? confirmThroughClient("api", token) : confirmInTerminal(command);
|
|
327
|
+
const target = await actingTarget(ctx);
|
|
328
|
+
const shown = { operation: op.alias, ...request, ...(files.length ? { files } : {}), target, sent: false };
|
|
329
|
+
const lines = [`Would send ${request.method} ${request.path}. Nothing was sent.`, targetLine(target)];
|
|
319
330
|
if (stale)
|
|
320
331
|
lines.push("The confirm token is not this request's: the request changed since its preview, or the token is another one's.");
|
|
321
332
|
if (bare && driven.by === "agent")
|
|
322
|
-
lines.push(
|
|
333
|
+
lines.push("A coding agent cannot send it: the person sends it from their own terminal.");
|
|
334
|
+
if (op.confirmation)
|
|
335
|
+
lines.push(`The instance asks for the person's confirmation of it (x-cavelon-confirmation)${op.confirmationWhen ? `: ${op.confirmationWhen}` : ""}`);
|
|
323
336
|
if (Object.keys(request.query).length)
|
|
324
337
|
lines.push(`Query: ${JSON.stringify(request.query)}`);
|
|
325
338
|
if (Object.keys(request.headers).length)
|
|
@@ -330,7 +343,15 @@ async function previewUnlessConfirmed(ctx, input, doc, op, args, driven) {
|
|
|
330
343
|
lines.push(`File: ${f.field} = ${f.file}`);
|
|
331
344
|
lines.push(confirm);
|
|
332
345
|
return {
|
|
333
|
-
data: {
|
|
346
|
+
data: {
|
|
347
|
+
...shown,
|
|
348
|
+
...(route === "client" ? { confirm_token: token } : {}),
|
|
349
|
+
confirm,
|
|
350
|
+
needs_person: route,
|
|
351
|
+
...(op.confirmation ? { instance_confirmation: op.confirmationWhen ?? true } : {}),
|
|
352
|
+
...(stale ? { token_mismatch: true } : {}),
|
|
353
|
+
...(bare ? { token_required: true } : {}),
|
|
354
|
+
},
|
|
334
355
|
text: lines.join("\n"),
|
|
335
356
|
...(stale ? { exitCode: ExitCode.conflict } : bare ? { exitCode: ExitCode.needsAction } : {}),
|
|
336
357
|
};
|
|
@@ -347,11 +368,13 @@ export const apiList = {
|
|
|
347
368
|
method: { type: "string", value: "<method>", description: "Only this HTTP method (GET, POST, …)." },
|
|
348
369
|
tags: { type: "boolean", description: "List the tags with their operation counts instead." },
|
|
349
370
|
limit: { type: "string", value: "<n>", description: "Return at most n operations (default 50, 0 for all)." },
|
|
371
|
+
usable: { type: "boolean", description: "Leave out the operations the instance says this credential may not send." },
|
|
350
372
|
cursor: CURSOR_OPTION,
|
|
351
373
|
},
|
|
352
374
|
async run(ctx, input) {
|
|
353
375
|
const doc = await (await ctx.contracts()).openapi();
|
|
354
376
|
let ops = operations(doc);
|
|
377
|
+
const access = await listAccess(ctx);
|
|
355
378
|
if (input.options.tags === true) {
|
|
356
379
|
const counts = new Map();
|
|
357
380
|
for (const op of ops)
|
|
@@ -373,6 +396,10 @@ export const apiList = {
|
|
|
373
396
|
if (search) {
|
|
374
397
|
ops = ops.filter((o) => [o.operationId, o.path, o.summary ?? ""].some((s) => s.toLowerCase().includes(search)));
|
|
375
398
|
}
|
|
399
|
+
const usableOnly = boolOption(input, "usable");
|
|
400
|
+
const marks = new Map(ops.map((o) => [o, operationAccess(access, `${o.method} ${o.path}`)]));
|
|
401
|
+
if (usableOnly)
|
|
402
|
+
ops = ops.filter((o) => marks.get(o).allowed !== false);
|
|
376
403
|
const wanted = intOption(input, "limit", { min: 0, max: 1000, fallback: 50 });
|
|
377
404
|
const limit = wanted === 0 ? Math.max(ops.length, 1) : wanted;
|
|
378
405
|
const page = pageOf(ops.map((o) => ({
|
|
@@ -383,16 +410,31 @@ export const apiList = {
|
|
|
383
410
|
summary: o.summary ?? null,
|
|
384
411
|
tags: o.tags,
|
|
385
412
|
read_only: o.readOnly,
|
|
413
|
+
...accessFields(marks.get(o)),
|
|
386
414
|
})), limit, stringOption(input, "cursor"));
|
|
387
|
-
const flags = [tag ? ["--tag", tag] : [], method ? ["--method", method] : [], search ? ["--search", search] : []].flat();
|
|
415
|
+
const flags = [tag ? ["--tag", tag] : [], method ? ["--method", method] : [], search ? ["--search", search] : [], usableOnly ? ["--usable"] : []].flat();
|
|
416
|
+
const marked = page.items.some((i) => i.may_send === false);
|
|
388
417
|
return {
|
|
389
|
-
data: page,
|
|
390
|
-
text: table(page.items, ["operation", "method", "path", "summary"]) +
|
|
418
|
+
data: { ...page, credential_published: Boolean(access) },
|
|
419
|
+
text: table(page.items.map((i) => ({ ...i, access: i.needs_a_person ? "a person" : i.needs?.length ? `needs ${i.needs.join(" and ")}` : "" })), marked ? ["operation", "method", "path", "access", "summary"] : ["operation", "method", "path", "summary"]) +
|
|
391
420
|
`\n${page.items.length} of ${page.total}` +
|
|
421
|
+
(marked ? `\nOperations with an access entry are ones this credential may not send, as the instance says; --usable leaves them out.` : "") +
|
|
392
422
|
moreHint(page.next_cursor, cavelonCommand("api", "list", ...flags)),
|
|
393
423
|
};
|
|
394
424
|
},
|
|
395
425
|
};
|
|
426
|
+
async function listAccess(ctx) {
|
|
427
|
+
try {
|
|
428
|
+
const session = await ctx.session();
|
|
429
|
+
return session.token ? await accessFor(await ctx.client()) : undefined;
|
|
430
|
+
}
|
|
431
|
+
catch {
|
|
432
|
+
return undefined;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
function accessFields(mark) {
|
|
436
|
+
return { may_send: mark.allowed, needs_a_person: mark.person ?? null, needs: mark.missing ?? null };
|
|
437
|
+
}
|
|
396
438
|
export const apiDescribe = {
|
|
397
439
|
name: "api describe",
|
|
398
440
|
summary: "Show one operation's parameters, body and responses.",
|
|
@@ -421,6 +463,7 @@ export const apiDescribe = {
|
|
|
421
463
|
read_only: op.readOnly,
|
|
422
464
|
person_only: kept ? { source: kept.source, reason: kept.reason ?? null, hint: kept.hint } : null,
|
|
423
465
|
secret_fields: secrets,
|
|
466
|
+
confirmation: op.confirmation ? { required: true, when: op.confirmationWhen ?? null } : null,
|
|
424
467
|
tags: op.tags,
|
|
425
468
|
summary: op.summary ?? null,
|
|
426
469
|
description: op.description ? clip(op.description, 1500) : null,
|
|
@@ -444,6 +487,10 @@ export const apiDescribe = {
|
|
|
444
487
|
}
|
|
445
488
|
if (secrets.length)
|
|
446
489
|
lines.push(`Secret values (x-cavelon-secret): ${secrets.join(", ")}. A person enters them; an agent leaves them out.`);
|
|
490
|
+
if (op.confirmation) {
|
|
491
|
+
lines.push(`A person confirms it (x-cavelon-confirmation)${op.confirmationWhen ? `: ${op.confirmationWhen}` : "."} cavelon asks the instance for the ` +
|
|
492
|
+
"confirmation once the person approved the call: in their own terminal, or in the MCP client's dialog.");
|
|
493
|
+
}
|
|
447
494
|
if (data.description && data.description !== op.summary)
|
|
448
495
|
lines.push("", data.description);
|
|
449
496
|
if (data.parameters.length) {
|
package/dist/commands/chat.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseDuration, positional, stringOption } from "../command.js";
|
|
2
|
-
import { confirmation, confirmTokenRequired } from "../confirm-token.js";
|
|
2
|
+
import { confirmation, confirmTokenRequired, PERSON_CONFIRMS_HELP } from "../confirm-token.js";
|
|
3
3
|
import { named, readDefaultRoute } from "../default-route.js";
|
|
4
4
|
import { CavelonError, ExitCode, usageError } from "../errors.js";
|
|
5
5
|
import { clip } from "../format.js";
|
|
@@ -7,6 +7,7 @@ import { harnessNotFoundError, lookupHarness } from "../harness-ref.js";
|
|
|
7
7
|
import { callStable, workflowOperation } from "../invoke.js";
|
|
8
8
|
import { cavelonCommand, fill } from "../printed.js";
|
|
9
9
|
import { MCP_MAX_WAIT_MS } from "./async.js";
|
|
10
|
+
import { accessFor, activationStep, mayActivate } from "../access.js";
|
|
10
11
|
function harnessRef(session, input) {
|
|
11
12
|
const option = stringOption(input, "harness");
|
|
12
13
|
if (option)
|
|
@@ -30,13 +31,13 @@ const HARNESS_OPTION = {
|
|
|
30
31
|
};
|
|
31
32
|
const ENV_OPTION = { type: "string", value: "<name>", description: "Use env/<name>.yaml: its tenant and solution." };
|
|
32
33
|
const DEFAULT_CHAT_TIMEOUT = "2m";
|
|
33
|
-
function chatError(error, harness) {
|
|
34
|
+
function chatError(error, harness, may = null) {
|
|
34
35
|
if (!(error instanceof CavelonError) || error.status !== 409)
|
|
35
36
|
return error;
|
|
36
37
|
const hint = !harness
|
|
37
38
|
? `Nothing answers on the tenant's default route yet: name a solution with --harness, or make an active one the default (\`${cavelonCommand("harness", "default", fill("solution"))}\`).`
|
|
38
39
|
: harness.status !== "active"
|
|
39
|
-
? `${named(harness)} is ${harness.status}: a draft answers only a person's token (as a Playground run), never a tenant API key. Use a personal access token, or activate it first (
|
|
40
|
+
? `${named(harness)} is ${harness.status}: a draft answers only a person's token (as a Playground run), never a tenant API key. Use a personal access token, or activate it first (${activationStep(may, cavelonCommand("activate", "--harness", harness.slug))}).`
|
|
40
41
|
: "A session belongs to the solution it started with: leave out --session to start a new one.";
|
|
41
42
|
return new CavelonError(error.exitCode, { code: error.code, status: error.status, message: error.message, hint, docs: error.docs, details: error.details });
|
|
42
43
|
}
|
|
@@ -51,6 +52,7 @@ export const chat = {
|
|
|
51
52
|
readOnly: false,
|
|
52
53
|
mcpEffect: "Starts or continues a conversation with the solution and runs its agents (model usage, its tools' actions); changes no configuration.",
|
|
53
54
|
mcpTool: "chat",
|
|
55
|
+
operations: ["POST /api/v1/chat"],
|
|
54
56
|
positionals: [{ name: "message", description: "What the user says.", required: true }],
|
|
55
57
|
options: {
|
|
56
58
|
harness: HARNESS_OPTION,
|
|
@@ -79,7 +81,7 @@ export const chat = {
|
|
|
79
81
|
answer = await callStable(ctx, "POST", "/api/v1/chat", "chatting with a solution", { body, timeoutMs: timeout });
|
|
80
82
|
}
|
|
81
83
|
catch (error) {
|
|
82
|
-
throw chatError(error, harness);
|
|
84
|
+
throw chatError(error, harness, error instanceof CavelonError && error.status === 409 ? mayActivate(await accessFor(await ctx.client())) : null);
|
|
83
85
|
}
|
|
84
86
|
const target = harness ? { id: harness.id, slug: harness.slug, name: harness.name, status: harness.status } : null;
|
|
85
87
|
if (answer.retrieval_warning)
|
|
@@ -112,11 +114,13 @@ export const deactivate = {
|
|
|
112
114
|
"through its readiness gate). Without --confirm nothing changes: the preview says what would stop. Show it to a person\n" +
|
|
113
115
|
"and confirm only with their yes. The tenant's default route is refused before anything is sent: make another solution\n" +
|
|
114
116
|
"the default first (`cavelon harness default <solution>`). An instance that publishes no deactivate route is said so; a\n" +
|
|
115
|
-
"person deactivates in the Admin there
|
|
117
|
+
"person deactivates in the Admin there.\n" +
|
|
118
|
+
PERSON_CONFIRMS_HELP,
|
|
116
119
|
readOnly: false,
|
|
117
120
|
destructive: true,
|
|
118
121
|
idempotent: true,
|
|
119
122
|
mcpTool: "deactivate",
|
|
123
|
+
operations: ["POST /api/v1/harnesses/{harness_id}/deactivate"],
|
|
120
124
|
options: {
|
|
121
125
|
harness: HARNESS_OPTION,
|
|
122
126
|
env: ENV_OPTION,
|
|
@@ -157,14 +161,16 @@ export const deactivate = {
|
|
|
157
161
|
});
|
|
158
162
|
}
|
|
159
163
|
const confirmCommand = cavelonCommand("deactivate", "--harness", harness.slug, "--confirm");
|
|
160
|
-
const gate = await confirmation(ctx, input, "deactivate", { harness: harness.id, status: harness.status }
|
|
164
|
+
const gate = await confirmation(ctx, input, "deactivate", { harness: harness.id, status: harness.status }, {
|
|
165
|
+
person: { what: `Deactivate ${named(harness)}: it goes inactive and out of live traffic.`, words: ["deactivate", "--harness", harness.slug, "--confirm"] },
|
|
166
|
+
});
|
|
161
167
|
if (!gate.confirmed) {
|
|
162
168
|
const known = route?.known ? "" : " (this instance does not say which solution is the default route)";
|
|
163
169
|
return {
|
|
164
170
|
data: { changed: false, harness: target, would: "deactivate", confirm: gate.confirm(confirmCommand), ...gate.fields },
|
|
165
171
|
text: [
|
|
166
172
|
`Deactivating ${named(harness)} sets it inactive and takes it out of live traffic: the conversations, channels and API keys that name it are no longer answered by it until it is activated again${known}.`,
|
|
167
|
-
...(gate.mismatch ? [gate.mismatch] : []),
|
|
173
|
+
gate.where, ...(gate.mismatch ? [gate.mismatch] : []),
|
|
168
174
|
`Show this to a person; with their yes: ${gate.confirm(confirmCommand)}`,
|
|
169
175
|
].join("\n"),
|
|
170
176
|
...(gate.exitCode ? { exitCode: gate.exitCode } : {}),
|
|
@@ -175,7 +181,9 @@ export const deactivate = {
|
|
|
175
181
|
});
|
|
176
182
|
return {
|
|
177
183
|
data: { changed: true, harness: { ...target, status: updated?.status ?? target.status } },
|
|
178
|
-
text: `Deactivated ${named(harness)}; status ${updated?.status ?? "unknown"}.
|
|
184
|
+
text: `Deactivated ${named(harness)}; status ${updated?.status ?? "unknown"}. ${mayActivate(await accessFor(await ctx.client())) === false
|
|
185
|
+
? "A person who may activate puts it back through its readiness gate, in the Admin; this credential may not activate."
|
|
186
|
+
: `\`${cavelonCommand("activate", "--harness", harness.slug)}\` puts it back through its readiness gate.`}`,
|
|
179
187
|
};
|
|
180
188
|
},
|
|
181
189
|
};
|