@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
|
@@ -5,7 +5,8 @@ import { boolOption, intOption, positional, stringOption } from "../command.js";
|
|
|
5
5
|
import { Contracts } from "../contracts.js";
|
|
6
6
|
import { CavelonError, ExitCode, usageError } from "../errors.js";
|
|
7
7
|
import { drivenByAgent } from "../agent-env.js";
|
|
8
|
-
import { confirmation,
|
|
8
|
+
import { confirmation, confirmInTerminal, confirmTokenRequired, PERSON_CONFIRMS_HELP, personApproves, personRoute, shellTokenRequired } from "../confirm-token.js";
|
|
9
|
+
import { actingTarget, targetLine, targetText } from "../acting.js";
|
|
9
10
|
import { clip, keyValues } from "../format.js";
|
|
10
11
|
import { readTextFile, writeFileAtomic } from "../fsutil.js";
|
|
11
12
|
import { uncommitted } from "../git.js";
|
|
@@ -16,8 +17,10 @@ import { defaultChangeLine, defaultCommands, named, readDefaultRoute, setDefault
|
|
|
16
17
|
import { ceilingHint, LIMIT_ABOVE_CEILING, parseLimits, readLimits } from "../limits.js";
|
|
17
18
|
import { digest, fileDigest, fileDigests, listPreviews, loadPreview, previewExpiry, readItemFiles, readPulledFiles, rememberAppliedFiles, retiredPreview, retirePreviews, savePreview, writePulledFiles, writeState, } from "../local-state.js";
|
|
18
19
|
import { catalogEntry, checkPackage, KIT_CODES, packageVersionOf } from "../package-check.js";
|
|
20
|
+
import { applyQueryNotes, connectorOffer, NEEDS_SUPERADMIN_CODE, queryBlockedHint, queryChanges, readQueryBaseline, rememberQueries } from "../database-queries.js";
|
|
19
21
|
import { cliFix, similarCodes } from "../code-hints.js";
|
|
20
22
|
import { KIT_ERROR_CODES } from "../kit-codes.js";
|
|
23
|
+
import { confirmationPointer } from "../change-confirmation.js";
|
|
21
24
|
import { pairOrderHint, pairOrderPointer } from "../pair-order.js";
|
|
22
25
|
import { readPackage, tenantWideSections, writePackage } from "../package-files.js";
|
|
23
26
|
import { blockerDetails, blockerLines, changeLines, fieldChanges, locateBlockers, notApplied, notAppliedLines, tenantWideReport } from "../preview-report.js";
|
|
@@ -28,9 +31,10 @@ import { isUuid, requireInstance } from "../session.js";
|
|
|
28
31
|
import { listedPages } from "./docs.js";
|
|
29
32
|
import { readInventory, readInventoryKinds, writeInventory } from "./inventory.js";
|
|
30
33
|
import { checkedBy, MODEL_UNKNOWN_CODE, missingInventory, REFERENCE_UNKNOWN_CODE } from "../package-references.js";
|
|
31
|
-
import { cavelonCommand, printedCommand, spoken } from "../printed.js";
|
|
32
|
-
import {
|
|
33
|
-
import { maySetSecrets, SECRET_SETTER } from "../secret-access.js";
|
|
34
|
+
import { cavelonCommand, personCommand, printedCommand, spoken } from "../printed.js";
|
|
35
|
+
import { secretStep, variableSetCommand } from "./values.js";
|
|
36
|
+
import { maySetSecrets, SECRET_SETTER, SECRET_SETTER_IN_ADMIN, secretsInAdminOnly, VARIABLE_SETTER } from "../secret-access.js";
|
|
37
|
+
import { ACTIVATOR, accessFor, accessOf, mayActivate, operationAccess, principalOf } from "../access.js";
|
|
34
38
|
const HARNESS_OPTION = { type: "string", value: "<harness>", description: "The solution (harness): its name, slug or id; default: env file, then cavelon.yaml." };
|
|
35
39
|
const ENV_OPTION = { type: "string", value: "<name>", description: "Use env/<name>.yaml: its tenant, solution and runtime bindings." };
|
|
36
40
|
export function requireSolution(session, harness) {
|
|
@@ -252,6 +256,7 @@ export const pull = {
|
|
|
252
256
|
}
|
|
253
257
|
const report = await writePackage(project.root, project.layout, exported, schema, options);
|
|
254
258
|
await writePulledFiles(project.root, [...report.written, ...report.unchanged], placed);
|
|
259
|
+
await rememberQueries(project.root, exported, schema, "pull", ctx.io.now());
|
|
255
260
|
if (harness && !project.harness)
|
|
256
261
|
await setProjectKey(project, "harness", harness.slug);
|
|
257
262
|
if (version && project.packageVersion !== version)
|
|
@@ -345,6 +350,7 @@ async function validatePackage(ctx, project, offline) {
|
|
|
345
350
|
limits: await limitsFor(ctx, offline),
|
|
346
351
|
inventory,
|
|
347
352
|
solution: project.harness,
|
|
353
|
+
queryBaseline: await readQueryBaseline(project.root),
|
|
348
354
|
});
|
|
349
355
|
return { disk, findings, schema, schemaVersion: schema["x-package-version"] ?? version ?? null, used, skipped };
|
|
350
356
|
}
|
|
@@ -368,7 +374,7 @@ export const validate = {
|
|
|
368
374
|
"changes, so its copy is read again after a minute (CAVELON_CONTRACT_TTL_SECONDS), or checked with the ETag the instance\n" +
|
|
369
375
|
"sent with it; --verbose says which copy was used.\n" +
|
|
370
376
|
"Warns (never fails) when a fan-out or Map loop's max_concurrency is above the instance's branch width, and when the\n" +
|
|
371
|
-
"tenant runs fan-outs and Map loops in sequence, from the limits the instance last published.\n" +
|
|
377
|
+
"tenant runs fan-outs and Map loops in sequence, from the limits the instance last published for the tenant.\n" +
|
|
372
378
|
"References to skills, tools, knowledge bases, solutions and models outside the package are checked against the tenant's\n" +
|
|
373
379
|
"lists in .cavelon/inventory.json (pull, models list); a list no command has read yet is read now, unless --offline, and a\n" +
|
|
374
380
|
"check that cannot be made is named (`skipped` in --json). A reference that is in neither is a warning, as it may be created\n" +
|
|
@@ -444,10 +450,10 @@ export const validate = {
|
|
|
444
450
|
function valueNeeds(list) {
|
|
445
451
|
return (list ?? []).map((n) => (typeof n === "string" ? { name: n } : n)).filter((n) => typeof n.name === "string" && n.name !== "");
|
|
446
452
|
}
|
|
447
|
-
function setCommands(preview, env) {
|
|
453
|
+
function setCommands(preview, env, inAdmin = false) {
|
|
448
454
|
const needs = preview.target_needs ?? {};
|
|
449
455
|
return {
|
|
450
|
-
secrets: valueNeeds(needs.secrets).map((n) =>
|
|
456
|
+
secrets: valueNeeds(needs.secrets).map((n) => secretStep(n.name, inAdmin, env)),
|
|
451
457
|
variables: valueNeeds(needs.variables).map((n) => variableSetCommand(n.name, env)),
|
|
452
458
|
};
|
|
453
459
|
}
|
|
@@ -468,16 +474,21 @@ function counts(map) {
|
|
|
468
474
|
function list(items, max = 10) {
|
|
469
475
|
return items.length > max ? `${items.slice(0, max).join(", ")} and ${items.length - max} more` : items.join(", ");
|
|
470
476
|
}
|
|
471
|
-
function needsLines(needs) {
|
|
477
|
+
function needsLines(needs, access) {
|
|
472
478
|
const lines = [];
|
|
473
479
|
const secrets = valueNeeds(needs.secrets);
|
|
474
480
|
if (secrets.length) {
|
|
475
|
-
const
|
|
476
|
-
|
|
481
|
+
const inAdmin = secretsInAdminOnly(access?.principal) === true;
|
|
482
|
+
const each = needLines(secrets, (name) => secretStep(name, inAdmin), cavelonCommand("secrets", "list", "--missing"));
|
|
483
|
+
const who = inAdmin ? "a person sets them, signed in to the Admin; never the agent" : "a person runs these in a terminal, or sets them in the Admin; never the agent";
|
|
484
|
+
lines.push(["needs secrets", `${each}\n (${who})`]);
|
|
477
485
|
}
|
|
478
486
|
const variables = valueNeeds(needs.variables);
|
|
479
|
-
if (variables.length)
|
|
480
|
-
|
|
487
|
+
if (variables.length) {
|
|
488
|
+
const each = needLines(variables, (name) => variableSetCommand(name), cavelonCommand("variables", "list"));
|
|
489
|
+
const who = operationAccess(access, "PUT /api/v1/variables/{name}").allowed === false ? `\n (this credential may not set variables. ${VARIABLE_SETTER})` : "";
|
|
490
|
+
lines.push(["needs variables", each + who]);
|
|
491
|
+
}
|
|
481
492
|
const grants = (needs.oauth_grants ?? []).map((g) => [g.kind, g.tool_slug, g.capability].filter(Boolean).join(" "));
|
|
482
493
|
if (grants.length)
|
|
483
494
|
lines.push(["needs grants", `${list(grants)} (a person connects them in the Admin)`]);
|
|
@@ -534,7 +545,7 @@ export function previewText(p, context = {}) {
|
|
|
534
545
|
const ignored = [...(p.ignored?.sections ?? []), ...(p.ignored?.fields ?? [])];
|
|
535
546
|
if (ignored.length)
|
|
536
547
|
lines.push(["ignored", list(ignored)]);
|
|
537
|
-
const skipped = notApplied(p.ignored?.not_applied, context.disk?.package, context.harness);
|
|
548
|
+
const skipped = notApplied(p.ignored?.not_applied, context.disk?.package, context.harness, mayActivate(context.access));
|
|
538
549
|
if (skipped.length)
|
|
539
550
|
lines.push(["not applied", notAppliedLines(skipped)]);
|
|
540
551
|
const impact = p.impact ?? {};
|
|
@@ -550,7 +561,7 @@ export function previewText(p, context = {}) {
|
|
|
550
561
|
const limits = Object.entries(budget.limits ?? {}).map(([k, v]) => `${k} ${v}`).join(", ");
|
|
551
562
|
lines.push([`loop ${budget.node_slug}`, `${limits}${budget.worst_case_cost != null ? `; worst case ${JSON.stringify(budget.worst_case_cost)}` : ""}`]);
|
|
552
563
|
}
|
|
553
|
-
lines.push(...needsLines(p.target_needs ?? {}));
|
|
564
|
+
lines.push(...needsLines(p.target_needs ?? {}, context.access));
|
|
554
565
|
return keyValues(lines);
|
|
555
566
|
}
|
|
556
567
|
function previewReport(p, context) {
|
|
@@ -561,7 +572,7 @@ function previewReport(p, context) {
|
|
|
561
572
|
const changes = fieldChanges(p.changes);
|
|
562
573
|
if (changes.length)
|
|
563
574
|
out.field_changes = changes;
|
|
564
|
-
const skipped = notApplied(p.ignored?.not_applied, context.disk?.package, context.harness);
|
|
575
|
+
const skipped = notApplied(p.ignored?.not_applied, context.disk?.package, context.harness, mayActivate(context.access));
|
|
565
576
|
if (skipped.length)
|
|
566
577
|
out.not_applied = skipped;
|
|
567
578
|
return out;
|
|
@@ -687,6 +698,9 @@ async function instanceHolds(ctx, project, stored) {
|
|
|
687
698
|
const planned = await writePackage(project.root, project.layout, exported, schema, { dryRun: true });
|
|
688
699
|
return new Set(planned.unchanged);
|
|
689
700
|
}
|
|
701
|
+
function personApplyCommand(stored) {
|
|
702
|
+
return personCommand("apply", ...(stored.env ? ["--env", stored.env] : []), "--confirm", stored.preview_id);
|
|
703
|
+
}
|
|
690
704
|
async function confirmPreview(ctx, project, previewId, allowStale) {
|
|
691
705
|
const stored = await loadPreview(project.root, previewId);
|
|
692
706
|
const session = await ctx.session();
|
|
@@ -714,15 +728,27 @@ async function confirmPreview(ctx, project, previewId, allowStale) {
|
|
|
714
728
|
});
|
|
715
729
|
}
|
|
716
730
|
const client = await ctx.client();
|
|
717
|
-
|
|
731
|
+
const keyTenant = session.tokenKind === "api_key" ? (await actingTarget(ctx)).tenant?.id : undefined;
|
|
732
|
+
const actsIn = client.target.tenantId ?? keyTenant;
|
|
733
|
+
if (stored.tenant_id && actsIn && actsIn !== stored.tenant_id) {
|
|
718
734
|
throw new CavelonError(ExitCode.conflict, {
|
|
719
735
|
code: "preview_other_tenant",
|
|
720
|
-
message: `Preview ${previewId} was made for tenant ${stored.tenant_id}, but this command acts in ${
|
|
736
|
+
message: `Preview ${previewId} was made for tenant ${stored.tenant_id}, but this command acts in ${actsIn}.`,
|
|
721
737
|
hint: "Run the confirm command the preview printed; it names the preview's --env and --tenant. Or preview again here.",
|
|
722
738
|
});
|
|
723
739
|
}
|
|
724
740
|
if (stored.tenant_id && session.tokenKind !== "api_key")
|
|
725
741
|
client.target.tenantId = stored.tenant_id;
|
|
742
|
+
const driven = drivenByAgent(ctx);
|
|
743
|
+
const guarded = stored.request[INCLUDE_TENANT_WIDE] === true || stored.request.package.manifest?.scope === "full_config";
|
|
744
|
+
if (driven && stored.person_reason !== null) {
|
|
745
|
+
const into = stored.harness ? `solution ${stored.harness.slug}` : "the tenant";
|
|
746
|
+
const reason = stored.person_reason ?? "was stored by an older cavelon, which did not record whether it needs a person";
|
|
747
|
+
await personApproves(ctx, driven, { tool: "apply", what: `Import preview ${stored.preview_id} into ${into}: it ${reason}.`, command: personApplyCommand(stored), guarded });
|
|
748
|
+
}
|
|
749
|
+
else if (!driven)
|
|
750
|
+
ctx.approved = { guarded };
|
|
751
|
+
const acting = await actingTarget(ctx);
|
|
726
752
|
const disk = await readPackage(project.root, project.layout);
|
|
727
753
|
const changed = await filesChangedSince(project, stored, disk);
|
|
728
754
|
if (digest(disk.package) !== stored.package_digest) {
|
|
@@ -749,8 +775,9 @@ async function confirmPreview(ctx, project, previewId, allowStale) {
|
|
|
749
775
|
...others.map((p) => ({ preview_id: p.preview_id, reason: "superseded", at: now, by: stored.preview_id })),
|
|
750
776
|
]);
|
|
751
777
|
await rememberImported(ctx, project, stored, disk, changed);
|
|
778
|
+
await rememberQueries(project.root, stored.request.package, (await schemaFor(ctx, packageVersionOf(stored.request.package), false)).schema, "apply", ctx.io.now());
|
|
752
779
|
const summary = (result.summary ?? {});
|
|
753
|
-
const still = setCommands(stored.preview, stored.env ?? undefined);
|
|
780
|
+
const still = setCommands(stored.preview, stored.env ?? undefined, secretsInAdminOnly((await accessFor(client))?.principal) === true);
|
|
754
781
|
const sharedSent = stored.request[INCLUDE_TENANT_WIDE] === true;
|
|
755
782
|
const resultReport = tenantWideReport(result.tenant_wide);
|
|
756
783
|
const sharedReport = resultReport ?? (sharedSent ? tenantWideReport(stored.preview.tenant_wide) : undefined);
|
|
@@ -763,6 +790,7 @@ async function confirmPreview(ctx, project, previewId, allowStale) {
|
|
|
763
790
|
: undefined;
|
|
764
791
|
const text = keyValues([
|
|
765
792
|
["applied", `preview ${stored.preview_id}${stored.harness ? ` to ${stored.harness.slug}` : ""}${stored.env ? ` (env ${stored.env})` : ""}`],
|
|
793
|
+
["acted on", targetText(acting)],
|
|
766
794
|
["tenant-wide", sharedText],
|
|
767
795
|
["created", counts(summary?.creates) || undefined],
|
|
768
796
|
["updated", counts(summary?.updates) || undefined],
|
|
@@ -771,7 +799,7 @@ async function confirmPreview(ctx, project, previewId, allowStale) {
|
|
|
771
799
|
["set secrets", still.secrets.length ? indented(still.secrets) + "\n (a person runs these; never the agent)" : undefined],
|
|
772
800
|
["set variables", still.variables.length ? indented(still.variables) : undefined],
|
|
773
801
|
]);
|
|
774
|
-
const data = { applied: true, preview_id: stored.preview_id, env: stored.env, harness: stored.harness, result };
|
|
802
|
+
const data = { applied: true, preview_id: stored.preview_id, env: stored.env, harness: stored.harness, target: acting, result };
|
|
775
803
|
if (sharedSent || sharedImported.length) {
|
|
776
804
|
data.tenant_wide = {
|
|
777
805
|
applied: resultReport ? resultReport.applied : true,
|
|
@@ -819,6 +847,8 @@ function requirementsChanged(error, stored, session, catalog, disk) {
|
|
|
819
847
|
if (pair && !known.has(pair.code))
|
|
820
848
|
known.set(pair.code, pair.hint);
|
|
821
849
|
}
|
|
850
|
+
if (details.some((b) => b.code === NEEDS_SUPERADMIN_CODE))
|
|
851
|
+
known.set(NEEDS_SUPERADMIN_CODE, queryBlockedHint(sectionFiles(disk, ["tools"])));
|
|
822
852
|
return new CavelonError(ExitCode.conflict, {
|
|
823
853
|
code: error.code,
|
|
824
854
|
status: error.status,
|
|
@@ -893,8 +923,10 @@ export const apply = {
|
|
|
893
923
|
"still needs (secrets and variables with the command that sets each, grants, runtime bindings, trigger identities), loop\n" +
|
|
894
924
|
"budgets and ignored sections, and is stored in .cavelon/. A preview never creates the solution: one the env file names\n" +
|
|
895
925
|
"that is not on the instance yet gets the `cavelon harness new` command that creates it as a draft. A person sets the\n" +
|
|
896
|
-
"secrets (`cavelon secrets set <name
|
|
897
|
-
"Show a preview that reaches an active solution or env/prod to a person before confirming.
|
|
926
|
+
"secrets (`cavelon secrets set <name>`, or in the Admin where the instance lets no token set one), never the agent.\n" +
|
|
927
|
+
"Show a preview that reaches an active solution or env/prod to a person before confirming. Such a preview (show_to_person:\n" +
|
|
928
|
+
"tenant-wide sections, an active solution, deletions, env/prod) a coding agent cannot confirm: over MCP the client asks\n" +
|
|
929
|
+
"the person, and from an agent's shell the person runs the confirm in their own terminal. A stale preview exits 4 and\n" +
|
|
898
930
|
"imports nothing: one whose target changed on the instance since, one whose package files changed since (what they\n" +
|
|
899
931
|
"hold, not their formatting; --allow-stale imports what the preview showed anyway), and one older than a day. So does\n" +
|
|
900
932
|
"an import its own check refuses when it applies, naming each blocker. --discard <id|all> forgets stored previews;\n" +
|
|
@@ -905,6 +937,7 @@ export const apply = {
|
|
|
905
937
|
readOnly: false,
|
|
906
938
|
destructive: true,
|
|
907
939
|
mcpTool: "apply",
|
|
940
|
+
operations: ["POST /api/v1/agent-graph/import"],
|
|
908
941
|
options: {
|
|
909
942
|
env: ENV_OPTION,
|
|
910
943
|
harness: HARNESS_OPTION,
|
|
@@ -983,13 +1016,20 @@ export const apply = {
|
|
|
983
1016
|
request[INCLUDE_TENANT_WIDE] = true;
|
|
984
1017
|
if (tenantWide && solutionImport && !shared.length)
|
|
985
1018
|
ctx.warn("--include-tenant-wide: the package holds no tenant-wide section, so this import changes nothing the whole tenant shares.");
|
|
1019
|
+
const baseline = await readQueryBaseline(project.root);
|
|
1020
|
+
const queries = applyQueryNotes(disk.package, baseline ? queryChanges(disk.package, schema, baseline) : [], connectorOffer((await (await ctx.contracts()).capabilities())));
|
|
1021
|
+
for (const warning of queries.warnings)
|
|
1022
|
+
ctx.warn(warning);
|
|
986
1023
|
const client = await ctx.client();
|
|
987
1024
|
const preview = await callStable(ctx, "POST", "/api/v1/agent-graph/import/preview", "previewing imports", {
|
|
988
1025
|
body: request,
|
|
989
1026
|
timeoutMs: 120_000,
|
|
990
1027
|
});
|
|
991
1028
|
const target = harness ? { id: harness.id, slug: harness.slug } : null;
|
|
992
|
-
const
|
|
1029
|
+
const acting = await actingTarget(ctx);
|
|
1030
|
+
const data = { previewed: true, ...preview, env: envFile?.name ?? null, harness: target, target: acting };
|
|
1031
|
+
if (queries.data)
|
|
1032
|
+
data.database_queries = queries.data;
|
|
993
1033
|
const reported = solutionImport ? tenantWideReport(preview.tenant_wide) : undefined;
|
|
994
1034
|
const sections = reported?.sections ?? shared;
|
|
995
1035
|
const applied = reported ? reported.applied : tenantWide || !takes;
|
|
@@ -1025,10 +1065,11 @@ export const apply = {
|
|
|
1025
1065
|
: sharedLeftOut.length
|
|
1026
1066
|
? `tenant-wide: ${sharedLeftOut.join(", ")} left out (\`${cavelonCommand("apply", "--include-tenant-wide")}\` imports them, for every solution of the tenant${reachText ? `; they would reach ${reachText}` : ""})`
|
|
1027
1067
|
: undefined;
|
|
1028
|
-
const
|
|
1068
|
+
const access = await accessFor(await ctx.client());
|
|
1069
|
+
const commands = setCommands(preview, undefined, secretsInAdminOnly(access?.principal) === true);
|
|
1029
1070
|
if (commands.secrets.length || commands.variables.length)
|
|
1030
1071
|
data.set_commands = commands;
|
|
1031
|
-
const context = { disk, harness: harness?.slug };
|
|
1072
|
+
const context = { disk, harness: harness?.slug, access };
|
|
1032
1073
|
Object.assign(data, previewReport(preview, context));
|
|
1033
1074
|
if (!preview.ready) {
|
|
1034
1075
|
const pair = pairOrderHint(await catalogFor(ctx, false), [
|
|
@@ -1043,6 +1084,10 @@ export const apply = {
|
|
|
1043
1084
|
: undefined;
|
|
1044
1085
|
if (sharedHint)
|
|
1045
1086
|
data.tenant_wide_hint = sharedHint;
|
|
1087
|
+
const queryBlocked = blockerDetails(preview.blocker_details).some((b) => b.code === NEEDS_SUPERADMIN_CODE);
|
|
1088
|
+
const queryHint = queryBlocked ? queryBlockedHint(sectionFiles(disk, ["tools"])) : undefined;
|
|
1089
|
+
if (queryHint)
|
|
1090
|
+
data.database_query_hint = queryHint;
|
|
1046
1091
|
return {
|
|
1047
1092
|
data,
|
|
1048
1093
|
text: [
|
|
@@ -1051,6 +1096,7 @@ export const apply = {
|
|
|
1051
1096
|
"",
|
|
1052
1097
|
...(pair ? [`hint: ${pair.hint}`] : []),
|
|
1053
1098
|
...(sharedHint ? [`hint: ${sharedHint}`] : []),
|
|
1099
|
+
...(queryHint ? [`hint: ${queryHint}`] : []),
|
|
1054
1100
|
`The preview has blockers; fix them and run \`${cavelonCommand("apply")}\` again.`,
|
|
1055
1101
|
].join("\n"),
|
|
1056
1102
|
exitCode: ExitCode.validation,
|
|
@@ -1073,32 +1119,44 @@ export const apply = {
|
|
|
1073
1119
|
if (!preview.preview_id) {
|
|
1074
1120
|
ctx.warn("This instance's preview returns no preview id, so `apply --confirm` cannot import exactly it; update the instance.");
|
|
1075
1121
|
}
|
|
1122
|
+
const reason = personReason(preview, harness, mode, envFile?.name, sharedImported, reaches);
|
|
1076
1123
|
if (preview.preview_id) {
|
|
1077
1124
|
const stored = {
|
|
1078
1125
|
preview_id: preview.preview_id,
|
|
1079
1126
|
created_at: ctx.io.now().toISOString(),
|
|
1080
1127
|
instance: url,
|
|
1081
|
-
tenant_id: client.target.tenantId ?? null,
|
|
1128
|
+
tenant_id: client.target.tenantId ?? acting.tenant?.id ?? null,
|
|
1082
1129
|
env: envFile?.name ?? null,
|
|
1083
1130
|
harness: target,
|
|
1084
1131
|
package_digest: digest(disk.package),
|
|
1085
1132
|
file_digests: await fileDigests(project.root, sourceFiles(disk)),
|
|
1086
1133
|
request,
|
|
1087
1134
|
preview,
|
|
1135
|
+
person_reason: reason ?? null,
|
|
1088
1136
|
};
|
|
1089
1137
|
await savePreview(project.root, stored);
|
|
1090
1138
|
const at = ctx.io.now().toISOString();
|
|
1091
1139
|
const expired = (await listPreviews(project.root, ctx.io.now())).filter((old) => old.expired);
|
|
1092
1140
|
await retirePreviews(project.root, expired.map((old) => ({ preview_id: old.preview_id, reason: "expired", at })));
|
|
1093
1141
|
}
|
|
1094
|
-
const reason = personReason(preview, harness, mode, envFile?.name, sharedImported, reaches);
|
|
1095
1142
|
data.show_to_person = Boolean(reason);
|
|
1096
|
-
const
|
|
1143
|
+
const driven = drivenByAgent(ctx);
|
|
1144
|
+
const route = driven && reason && preview.preview_id ? personRoute(ctx, driven) : undefined;
|
|
1145
|
+
if (route)
|
|
1146
|
+
data.needs_person = route;
|
|
1147
|
+
const confirmLine = !preview.preview_id
|
|
1148
|
+
? undefined
|
|
1149
|
+
: route === "terminal"
|
|
1150
|
+
? confirmInTerminal(personApplyCommand({ preview_id: preview.preview_id, env: envFile?.name ?? null }))
|
|
1151
|
+
: route === "client"
|
|
1152
|
+
? `${cavelonCommand("apply", "--confirm", preview.preview_id)}; the client then asks the person to approve it`
|
|
1153
|
+
: cavelonCommand("apply", "--confirm", preview.preview_id);
|
|
1097
1154
|
const text = [
|
|
1098
1155
|
`Preview of ${project.layout.package}/ for ${harness ? `solution ${harness.slug}${harness.status ? ` (${harness.status})` : ""}` : "the tenant"}${envFile ? ` [env ${envFile.name}]` : ""}:`,
|
|
1099
1156
|
previewText(preview, context),
|
|
1100
1157
|
...(sharedLine ? [sharedLine] : []),
|
|
1101
1158
|
"",
|
|
1159
|
+
targetLine(acting),
|
|
1102
1160
|
...(preview.preview_id ? [`preview id: ${preview.preview_id}`] : []),
|
|
1103
1161
|
...(reason ? [`This ${reason}: show this preview to a person before confirming.`] : []),
|
|
1104
1162
|
...(confirmLine ? [`Import exactly this: ${confirmLine}`] : []),
|
|
@@ -1243,7 +1301,7 @@ export const explain = {
|
|
|
1243
1301
|
? processingStepCapHint(await readLimits(ctx).catch(() => undefined))
|
|
1244
1302
|
: ceiling
|
|
1245
1303
|
? ceilingHint(await readLimits(ctx).catch(() => undefined))
|
|
1246
|
-
: pairOrderPointer(entry.code);
|
|
1304
|
+
: (pairOrderPointer(entry.code) ?? confirmationPointer(entry.code));
|
|
1247
1305
|
const kitHint = kitText ? spoken(kitText) : undefined;
|
|
1248
1306
|
const pages = capacity === MODEL_ENDPOINT_BUSY ? [CAPACITY_TUTORIAL_PAGE, CAPACITY_CONCEPT_PAGE] : [CAPACITY_CONCEPT_PAGE, CAPACITY_TUTORIAL_PAGE];
|
|
1249
1307
|
const read = capacity ? (await listedPages(ctx, pages)).map((page) => ({ page, command: cavelonCommand("docs", "get", page) })) : [];
|
|
@@ -1270,7 +1328,7 @@ export const explain = {
|
|
|
1270
1328
|
["meaning", entry.message],
|
|
1271
1329
|
["fix", hint ?? undefined],
|
|
1272
1330
|
["with the CLI", cli],
|
|
1273
|
-
[capacity || stepCap || ceiling ? "raise" : "order", kitHint],
|
|
1331
|
+
[capacity || stepCap || ceiling ? "raise" : confirmationPointer(entry.code) ? "with cavelon" : "order", kitHint],
|
|
1274
1332
|
["why", entry.explanation ? clip(entry.explanation.replace(/\s+/g, " "), 600) : undefined],
|
|
1275
1333
|
["docs", docs],
|
|
1276
1334
|
["read", read.length ? read.map((r) => r.command).join("; ") : undefined],
|
|
@@ -1297,11 +1355,16 @@ function missingSecrets(blockers) {
|
|
|
1297
1355
|
}
|
|
1298
1356
|
return [...names];
|
|
1299
1357
|
}
|
|
1300
|
-
function missingSecretsLine(names, may) {
|
|
1358
|
+
function missingSecretsLine(names, may, inAdmin) {
|
|
1301
1359
|
const which = `Secret${names.length === 1 ? "" : "s"} ${names.join(", ")} ${names.length === 1 ? "is" : "are"} not set`;
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1360
|
+
if (inAdmin === true)
|
|
1361
|
+
return `${which}: ${SECRET_SETTER_IN_ADMIN} (never the agent).`;
|
|
1362
|
+
const commands = names.map((n) => secretStep(n, false)).join("; ");
|
|
1363
|
+
if (may === false) {
|
|
1364
|
+
return inAdmin === false
|
|
1365
|
+
? `${which}, and this token's role cannot set secrets. ${SECRET_SETTER_IN_ADMIN}.`
|
|
1366
|
+
: `${which}, and this token's role cannot set secrets. ${SECRET_SETTER}: ${commands}`;
|
|
1367
|
+
}
|
|
1305
1368
|
return `${which}: a person sets ${names.length === 1 ? "it" : "each"} (never the agent): ${commands}`;
|
|
1306
1369
|
}
|
|
1307
1370
|
const count = (value) => (typeof value === "number" ? value : null);
|
|
@@ -1331,10 +1394,11 @@ export async function solutionState(ctx, ref) {
|
|
|
1331
1394
|
state.ready_to_activate = typeof readiness.ready_to_activate === "boolean" ? readiness.ready_to_activate : null;
|
|
1332
1395
|
state.blockers = (readiness.blockers ?? []).map((b) => clip(String(b.label ?? b.key ?? b.detail ?? "?"), 80));
|
|
1333
1396
|
const secrets = missingSecrets(readiness.blockers ?? []);
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
state.missing_secrets = { names: secrets, may_set: maySetSecrets(principal) };
|
|
1337
|
-
|
|
1397
|
+
const principal = await principalOf(await ctx.client());
|
|
1398
|
+
if (secrets.length)
|
|
1399
|
+
state.missing_secrets = { names: secrets, may_set: maySetSecrets(principal), set_in_admin: secretsInAdminOnly(principal) };
|
|
1400
|
+
if (harness.status !== "active")
|
|
1401
|
+
state.may_activate = mayActivate(accessOf(principal));
|
|
1338
1402
|
if ("latest_test_run" in readiness) {
|
|
1339
1403
|
const run = readiness.latest_test_run;
|
|
1340
1404
|
const summary = run?.summary ?? {};
|
|
@@ -1368,10 +1432,10 @@ export function solutionStateLines(state) {
|
|
|
1368
1432
|
: undefined;
|
|
1369
1433
|
const lines = [["state", [state.harness.status, ready].filter(Boolean).join(", ")]];
|
|
1370
1434
|
if (state.missing_secrets)
|
|
1371
|
-
lines.push(["secrets", missingSecretsLine(state.missing_secrets.names, state.missing_secrets.may_set)]);
|
|
1435
|
+
lines.push(["secrets", missingSecretsLine(state.missing_secrets.names, state.missing_secrets.may_set, state.missing_secrets.set_in_admin ?? null)]);
|
|
1372
1436
|
const route = state.default_route;
|
|
1373
1437
|
if (route)
|
|
1374
|
-
lines.push(["default route", defaultRouteText(state.harness, route)]);
|
|
1438
|
+
lines.push(["default route", defaultRouteText(state.harness, route, state.may_activate ?? null)]);
|
|
1375
1439
|
const run = state.latest_test_run;
|
|
1376
1440
|
if (run === null)
|
|
1377
1441
|
lines.push(["last test run", "none yet (`cavelon test run`)"]);
|
|
@@ -1385,12 +1449,14 @@ export function solutionStateLines(state) {
|
|
|
1385
1449
|
lines.push(["state error", state.unavailable]);
|
|
1386
1450
|
return lines;
|
|
1387
1451
|
}
|
|
1388
|
-
function defaultRouteText(harness, route) {
|
|
1452
|
+
function defaultRouteText(harness, route, may) {
|
|
1389
1453
|
if (route.is_default === null)
|
|
1390
1454
|
return "unknown (this instance does not say which solution is the default)";
|
|
1391
1455
|
if (route.is_default)
|
|
1392
1456
|
return "yes: the tenant's chat and widget answer with it where a conversation names no solution";
|
|
1393
1457
|
const now = route.current ? named(route.current) : "no solution";
|
|
1458
|
+
if (harness.status !== "active" && may === false)
|
|
1459
|
+
return `no: ${now} answers the tenant's chat and widget; only an active solution can be the default, and to activate it ${ACTIVATOR}`;
|
|
1394
1460
|
const how = harness.status === "active" ? cavelonCommand("harness", "default", harness.slug) : cavelonCommand("activate", "--harness", harness.slug, "--make-default");
|
|
1395
1461
|
return `no: ${now} answers the tenant's chat and widget; preview a change with ${how}`;
|
|
1396
1462
|
}
|
|
@@ -1416,7 +1482,7 @@ function readinessText(checks, warnings) {
|
|
|
1416
1482
|
...(warnings.length ? ["Warnings:", ...warnings.map((w) => ` - ${w}`)] : []),
|
|
1417
1483
|
];
|
|
1418
1484
|
}
|
|
1419
|
-
async function defaultRouteAfterActivation(ctx, harness, input) {
|
|
1485
|
+
async function defaultRouteAfterActivation(ctx, harness, input, defaultConfirmed = false) {
|
|
1420
1486
|
const make = boolOption(input, "make-default");
|
|
1421
1487
|
let route;
|
|
1422
1488
|
try {
|
|
@@ -1430,8 +1496,12 @@ async function defaultRouteAfterActivation(ctx, harness, input) {
|
|
|
1430
1496
|
if (route.current?.id === harness.id)
|
|
1431
1497
|
return { data: { default_route: { is_default: true, current } }, lines: [`${named(harness)} is the tenant's default route.`] };
|
|
1432
1498
|
const commands = defaultCommands(harness.slug);
|
|
1433
|
-
const gate = make
|
|
1434
|
-
|
|
1499
|
+
const gate = make && !defaultConfirmed
|
|
1500
|
+
? await confirmation(ctx, input, "activate", { harness: harness.id, from: current?.id ?? null }, {
|
|
1501
|
+
person: { what: defaultChangeLine(harness, route), words: ["activate", "--harness", harness.slug, "--make-default", "--confirm"] },
|
|
1502
|
+
})
|
|
1503
|
+
: undefined;
|
|
1504
|
+
if (gate?.confirmed || (make && defaultConfirmed)) {
|
|
1435
1505
|
try {
|
|
1436
1506
|
await setDefaultRoute(ctx, harness.id);
|
|
1437
1507
|
}
|
|
@@ -1456,7 +1526,7 @@ async function defaultRouteAfterActivation(ctx, harness, input) {
|
|
|
1456
1526
|
const confirm = cavelonCommand("activate", "--harness", harness.slug, "--make-default", "--confirm");
|
|
1457
1527
|
return {
|
|
1458
1528
|
data: { default_route: { is_default: false, known: route.known, current, preview: commands.preview, confirm: gate.confirm(confirm), ...gate.fields } },
|
|
1459
|
-
lines: [defaultChangeLine(harness, route), ...(gate.mismatch ? [gate.mismatch] : []), `Show this to a person; with their yes: ${gate.confirm(confirm)}`],
|
|
1529
|
+
lines: [defaultChangeLine(harness, route), gate.where, ...(gate.mismatch ? [gate.mismatch] : []), `Show this to a person; with their yes: ${gate.confirm(confirm)}`],
|
|
1460
1530
|
...(gate.exitCode ? { exitCode: gate.exitCode } : {}),
|
|
1461
1531
|
};
|
|
1462
1532
|
}
|
|
@@ -1466,38 +1536,77 @@ async function defaultRouteAfterActivation(ctx, harness, input) {
|
|
|
1466
1536
|
];
|
|
1467
1537
|
return { data: { default_route: { is_default: false, known: route.known, current, preview: commands.preview, confirm: commands.confirm } }, lines };
|
|
1468
1538
|
}
|
|
1539
|
+
async function reachOf(ctx, harness) {
|
|
1540
|
+
const channels = typeof harness.channel_count === "number" ? harness.channel_count : null;
|
|
1541
|
+
const triggers = await callStable(ctx, "GET", "/api/v1/triggers", "listing triggers", { params: { harness_id: [harness.id] } })
|
|
1542
|
+
.then((list) => list.filter((t) => t.harness_id === harness.id && t.is_active).map((t) => ({ id: t.id, slug: t.slug, name: t.name, type: t.trigger_type })))
|
|
1543
|
+
.catch(() => null);
|
|
1544
|
+
return { channels, triggers };
|
|
1545
|
+
}
|
|
1546
|
+
function reachText(harness, reach) {
|
|
1547
|
+
const parts = [];
|
|
1548
|
+
if (reach.channels)
|
|
1549
|
+
parts.push(`${reach.channels} channel${reach.channels === 1 ? "" : "s"}`);
|
|
1550
|
+
if (reach.triggers?.length)
|
|
1551
|
+
parts.push(`the active trigger${reach.triggers.length === 1 ? "" : "s"} ${reach.triggers.map((t) => `${t.slug} (${t.type})`).join(", ")}`);
|
|
1552
|
+
const unknown = [
|
|
1553
|
+
...(reach.channels === null ? ["whether a channel reaches it (no channel_count)"] : []),
|
|
1554
|
+
...(reach.triggers === null ? ["which triggers start its runs (the trigger list could not be read)"] : []),
|
|
1555
|
+
];
|
|
1556
|
+
const lines = [
|
|
1557
|
+
parts.length
|
|
1558
|
+
? `Activating ${named(harness)} puts it live for what reaches it: ${parts.join("; ")}. From then on it answers them.`
|
|
1559
|
+
: `Activating ${named(harness)} puts it live.`,
|
|
1560
|
+
];
|
|
1561
|
+
if (unknown.length)
|
|
1562
|
+
lines.push(`This instance does not say ${unknown.join(", or ")}, so the activation waits for a confirm.`);
|
|
1563
|
+
return lines.join("\n");
|
|
1564
|
+
}
|
|
1469
1565
|
export const activate = {
|
|
1470
1566
|
name: "activate",
|
|
1471
1567
|
summary: "Activate a solution through the readiness gate (never by force); says whether it is the tenant's default route.",
|
|
1472
1568
|
description: "Only when every readiness check passes, and with a personal access token only when it was created with \"may activate\".\n" +
|
|
1473
1569
|
"Activating without the evidence stays a person's decision in the Admin.\n" +
|
|
1570
|
+
"A solution that a channel or an active trigger reaches goes live for them at once, so its activation previews first\n" +
|
|
1571
|
+
"and only --confirm activates it; so does one on an instance that does not say what reaches it. Show the preview to a\n" +
|
|
1572
|
+
"person and confirm only with their yes. A draft that nothing reaches activates without --confirm.\n" +
|
|
1474
1573
|
"Afterwards it says whether the solution is the tenant's default route (the one the tenant's chat and widget answer with\n" +
|
|
1475
1574
|
"where no solution is named). --make-default previews making it the default; with --confirm as well, it changes it. That\n" +
|
|
1476
1575
|
"changes live traffic: show the preview to a person and confirm only with their yes. `cavelon harness default` does the\n" +
|
|
1477
|
-
"same for an active solution
|
|
1576
|
+
"same for an active solution.\n" +
|
|
1577
|
+
PERSON_CONFIRMS_HELP,
|
|
1478
1578
|
readOnly: false,
|
|
1479
1579
|
idempotent: true,
|
|
1480
1580
|
mcpTool: "activate",
|
|
1581
|
+
operations: ["POST /api/v1/harnesses/{harness_id}/activate"],
|
|
1481
1582
|
options: {
|
|
1482
1583
|
harness: HARNESS_OPTION,
|
|
1483
1584
|
env: ENV_OPTION,
|
|
1484
1585
|
"make-default": { type: "boolean", description: "Also make it the tenant's default route: previews the change; with --confirm, makes it." },
|
|
1485
|
-
confirm: {
|
|
1586
|
+
confirm: {
|
|
1587
|
+
type: "boolean",
|
|
1588
|
+
mcpToken: true,
|
|
1589
|
+
description: "With --make-default: change the default route; for a solution a channel or trigger reaches: activate it (after a person saw the preview).",
|
|
1590
|
+
},
|
|
1486
1591
|
},
|
|
1487
|
-
examples: [
|
|
1592
|
+
examples: [
|
|
1593
|
+
"cavelon activate",
|
|
1594
|
+
"cavelon activate --confirm",
|
|
1595
|
+
"cavelon activate --make-default",
|
|
1596
|
+
"cavelon activate --make-default --confirm",
|
|
1597
|
+
"cavelon activate --make-default --confirm <token>",
|
|
1598
|
+
],
|
|
1488
1599
|
async run(ctx, input) {
|
|
1489
1600
|
const session = await ctx.session();
|
|
1490
1601
|
const { ref, source } = harnessRef(session, input);
|
|
1491
1602
|
if (!ref)
|
|
1492
1603
|
throw usageError("Which solution?", "Pass --harness <name or slug> (`cavelon harness list` shows them), or set harness in cavelon.yaml or the env file.");
|
|
1493
|
-
|
|
1494
|
-
throw usageError("--confirm only applies to --make-default.", "Activation itself needs no confirmation; the default route does.");
|
|
1495
|
-
}
|
|
1604
|
+
const make = boolOption(input, "make-default");
|
|
1496
1605
|
if (ctx.mode === "mcp" && input.options.confirm === true)
|
|
1497
1606
|
throw confirmTokenRequired("activate");
|
|
1498
1607
|
const driven = drivenByAgent(ctx);
|
|
1499
1608
|
if (driven?.by === "agent" && input.options.confirm === true) {
|
|
1500
|
-
throw shellTokenRequired(cavelonCommand("activate", "--harness", ref, "--make-default"
|
|
1609
|
+
throw shellTokenRequired(cavelonCommand("activate", "--harness", ref, ...(make ? ["--make-default"] : [])));
|
|
1501
1610
|
}
|
|
1502
1611
|
const client = await ctx.client();
|
|
1503
1612
|
const principal = await readPrincipal(client);
|
|
@@ -1527,7 +1636,7 @@ export const activate = {
|
|
|
1527
1636
|
const pair = pairOrderHint(await catalogFor(ctx, false), blockers.flatMap((b) => [b.message ?? undefined, b.detail ?? undefined]));
|
|
1528
1637
|
const secrets = missingSecrets(blockers);
|
|
1529
1638
|
const maySet = maySetSecrets(principal);
|
|
1530
|
-
const secretsLine = secrets.length ? missingSecretsLine(secrets, maySet) : undefined;
|
|
1639
|
+
const secretsLine = secrets.length ? missingSecretsLine(secrets, maySet, secretsInAdminOnly(principal)) : undefined;
|
|
1531
1640
|
return {
|
|
1532
1641
|
data: {
|
|
1533
1642
|
activated: false,
|
|
@@ -1549,13 +1658,61 @@ export const activate = {
|
|
|
1549
1658
|
exitCode: ExitCode.validation,
|
|
1550
1659
|
};
|
|
1551
1660
|
}
|
|
1661
|
+
const reach = await reachOf(ctx, harness);
|
|
1662
|
+
const live = Boolean(reach.channels) || Boolean(reach.triggers?.length) || reach.channels === null || reach.triggers === null;
|
|
1663
|
+
let defaultConfirmed = false;
|
|
1664
|
+
if (live) {
|
|
1665
|
+
const route = make ? await readDefaultRoute(ctx).catch(() => undefined) : undefined;
|
|
1666
|
+
const change = {
|
|
1667
|
+
harness: harness.id,
|
|
1668
|
+
activate: true,
|
|
1669
|
+
channels: reach.channels,
|
|
1670
|
+
triggers: reach.triggers?.map((t) => t.id) ?? null,
|
|
1671
|
+
...(make ? { make_default: true, from: route?.current?.id ?? null } : {}),
|
|
1672
|
+
};
|
|
1673
|
+
const words = ["activate", "--harness", harness.slug, ...(make ? ["--make-default"] : []), "--confirm"];
|
|
1674
|
+
const gate = await confirmation(ctx, input, "activate", change, {
|
|
1675
|
+
person: {
|
|
1676
|
+
what: [reachText(harness, reach), ...(make && route && route.current?.id !== harness.id ? [defaultChangeLine(harness, route)] : [])].join("\n"),
|
|
1677
|
+
words,
|
|
1678
|
+
},
|
|
1679
|
+
});
|
|
1680
|
+
if (!gate.confirmed) {
|
|
1681
|
+
const confirm = gate.confirm(cavelonCommand(...words));
|
|
1682
|
+
const routeLine = make && route && route.current?.id !== harness.id ? [defaultChangeLine(harness, route)] : [];
|
|
1683
|
+
return {
|
|
1684
|
+
data: {
|
|
1685
|
+
activated: false,
|
|
1686
|
+
would: "activate",
|
|
1687
|
+
harness,
|
|
1688
|
+
reach: { channels: reach.channels, triggers: reach.triggers },
|
|
1689
|
+
checks,
|
|
1690
|
+
warnings,
|
|
1691
|
+
readiness,
|
|
1692
|
+
...(make ? { default_route: { current: route?.current ? { id: route.current.id, slug: route.current.slug, name: route.current.name } : null, known: route?.known ?? false } } : {}),
|
|
1693
|
+
confirm,
|
|
1694
|
+
...gate.fields,
|
|
1695
|
+
},
|
|
1696
|
+
text: [
|
|
1697
|
+
reachText(harness, reach),
|
|
1698
|
+
...routeLine,
|
|
1699
|
+
...readinessText(checks, warnings),
|
|
1700
|
+
gate.where,
|
|
1701
|
+
...(gate.mismatch ? [gate.mismatch] : []),
|
|
1702
|
+
`Nothing was activated. Show this to a person; with their yes: ${confirm}`,
|
|
1703
|
+
].join("\n"),
|
|
1704
|
+
...(gate.exitCode ? { exitCode: gate.exitCode } : {}),
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
defaultConfirmed = make;
|
|
1708
|
+
}
|
|
1552
1709
|
const activated = await callStable(ctx, "POST", "/api/v1/harnesses/{harness_id}/activate", "activating solutions", {
|
|
1553
1710
|
params: { harness_id: [harness.id] },
|
|
1554
1711
|
body: { force: false },
|
|
1555
1712
|
});
|
|
1556
|
-
const route = await defaultRouteAfterActivation(ctx, activated, input);
|
|
1713
|
+
const route = await defaultRouteAfterActivation(ctx, activated, input, defaultConfirmed);
|
|
1557
1714
|
return {
|
|
1558
|
-
data: { activated: true, harness: activated, checks, warnings, readiness, ...route.data },
|
|
1715
|
+
data: { activated: true, harness: activated, ...(live ? { reach } : {}), checks, warnings, readiness, ...route.data },
|
|
1559
1716
|
text: [`Activated ${activated.name} (${activated.slug}); status ${activated.status}.`, ...readinessText(checks, warnings), ...route.lines].join("\n"),
|
|
1560
1717
|
...(route.failed ? { exitCode: ExitCode.failure } : route.exitCode ? { exitCode: route.exitCode } : {}),
|
|
1561
1718
|
};
|