@aragon-agent/cli 0.6.54 → 0.6.56
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/CHANGELOG.md +2912 -2838
- package/README.md +4226 -4042
- package/dist/agent/controller.d.ts +119 -0
- package/dist/agent/controller.js +365 -2
- package/dist/agent/governance-wiring.js +8 -1
- package/dist/agent/redteam-prompt.d.ts +47 -0
- package/dist/agent/redteam-prompt.js +161 -0
- package/dist/agent/redteam-wiring.d.ts +159 -0
- package/dist/agent/redteam-wiring.js +349 -0
- package/dist/agent/system-prompt.d.ts +39 -0
- package/dist/agent/system-prompt.js +18 -0
- package/dist/app/App.d.ts +10 -1
- package/dist/app/App.js +233 -24
- package/dist/app/use-redteam-mode.d.ts +56 -0
- package/dist/app/use-redteam-mode.js +121 -0
- package/dist/cli.js +82 -4
- package/dist/commands/builtins.js +43 -1
- package/dist/commands/catalog.js +5 -0
- package/dist/commands/index-build.js +2 -1
- package/dist/commands/redteam-command.d.ts +22 -0
- package/dist/commands/redteam-command.js +141 -0
- package/dist/commands/registry.d.ts +8 -0
- package/dist/config/app-paths.d.ts +10 -0
- package/dist/config/app-paths.js +12 -0
- package/dist/config/cli-commands.d.ts +29 -0
- package/dist/config/cli-commands.js +76 -1
- package/dist/config/env.d.ts +3 -1
- package/dist/config/env.js +23 -1
- package/dist/config/load.d.ts +22 -0
- package/dist/config/load.js +22 -2
- package/dist/config/redteam-launch.d.ts +77 -0
- package/dist/config/redteam-launch.js +58 -0
- package/dist/config/store.js +21 -1
- package/dist/config/ui-state.d.ts +44 -0
- package/dist/config/ui-state.js +38 -0
- package/dist/exec/bridge/server.d.ts +7 -0
- package/dist/exec/bridge/server.js +6 -2
- package/dist/exec/cli-commands.js +4 -0
- package/dist/exec/index.js +2 -0
- package/dist/exec/options.d.ts +11 -0
- package/dist/exec/options.js +21 -1
- package/dist/gene/block.d.ts +33 -0
- package/dist/gene/block.js +51 -0
- package/dist/gene/capacity.d.ts +74 -0
- package/dist/gene/capacity.js +169 -0
- package/dist/gene/catalog-reconcile.d.ts +13 -0
- package/dist/gene/catalog-reconcile.js +105 -0
- package/dist/gene/catalog-stats.d.ts +27 -0
- package/dist/gene/catalog-stats.js +89 -0
- package/dist/gene/catalog-sync.d.ts +82 -0
- package/dist/gene/catalog-sync.js +324 -0
- package/dist/gene/catalog.d.ts +160 -0
- package/dist/gene/catalog.js +433 -0
- package/dist/gene/cli-commands.d.ts +50 -0
- package/dist/gene/cli-commands.js +500 -0
- package/dist/gene/command-report.d.ts +40 -0
- package/dist/gene/command-report.js +246 -0
- package/dist/gene/command.d.ts +29 -0
- package/dist/gene/command.js +561 -0
- package/dist/gene/commit-apply-types.d.ts +13 -0
- package/dist/gene/commit-apply-types.js +1 -0
- package/dist/gene/commit-compound.d.ts +34 -0
- package/dist/gene/commit-compound.js +212 -0
- package/dist/gene/commit-counts.d.ts +41 -0
- package/dist/gene/commit-counts.js +70 -0
- package/dist/gene/commit-exec.d.ts +42 -0
- package/dist/gene/commit-exec.js +134 -0
- package/dist/gene/commit-head.d.ts +52 -0
- package/dist/gene/commit-head.js +97 -0
- package/dist/gene/commit-plan.d.ts +95 -0
- package/dist/gene/commit-plan.js +68 -0
- package/dist/gene/commit-prepare.d.ts +63 -0
- package/dist/gene/commit-prepare.js +159 -0
- package/dist/gene/commit-types.d.ts +234 -0
- package/dist/gene/commit-types.js +3 -0
- package/dist/gene/curator/agent.d.ts +137 -0
- package/dist/gene/curator/agent.js +203 -0
- package/dist/gene/curator/budget.d.ts +69 -0
- package/dist/gene/curator/budget.js +131 -0
- package/dist/gene/curator/conflicts.d.ts +54 -0
- package/dist/gene/curator/conflicts.js +143 -0
- package/dist/gene/curator/curator.d.ts +170 -0
- package/dist/gene/curator/curator.js +617 -0
- package/dist/gene/curator/deps.d.ts +34 -0
- package/dist/gene/curator/deps.js +48 -0
- package/dist/gene/curator/deterministic.d.ts +62 -0
- package/dist/gene/curator/deterministic.js +287 -0
- package/dist/gene/curator/executors.d.ts +36 -0
- package/dist/gene/curator/executors.js +379 -0
- package/dist/gene/curator/lanes.d.ts +52 -0
- package/dist/gene/curator/lanes.js +99 -0
- package/dist/gene/curator/lease.d.ts +76 -0
- package/dist/gene/curator/lease.js +171 -0
- package/dist/gene/curator/library.d.ts +36 -0
- package/dist/gene/curator/library.js +169 -0
- package/dist/gene/curator/lifecycle.d.ts +52 -0
- package/dist/gene/curator/lifecycle.js +109 -0
- package/dist/gene/curator/maintenance.d.ts +71 -0
- package/dist/gene/curator/maintenance.js +213 -0
- package/dist/gene/curator/probation.d.ts +51 -0
- package/dist/gene/curator/probation.js +71 -0
- package/dist/gene/curator/probe.d.ts +131 -0
- package/dist/gene/curator/probe.js +534 -0
- package/dist/gene/curator/prompt.d.ts +18 -0
- package/dist/gene/curator/prompt.js +128 -0
- package/dist/gene/curator/publish.d.ts +64 -0
- package/dist/gene/curator/publish.js +113 -0
- package/dist/gene/curator/recheck.d.ts +55 -0
- package/dist/gene/curator/recheck.js +103 -0
- package/dist/gene/curator/run-events.d.ts +63 -0
- package/dist/gene/curator/run-events.js +55 -0
- package/dist/gene/curator/similarity.d.ts +13 -0
- package/dist/gene/curator/similarity.js +46 -0
- package/dist/gene/curator/switches.d.ts +78 -0
- package/dist/gene/curator/switches.js +146 -0
- package/dist/gene/curator/task-context.d.ts +93 -0
- package/dist/gene/curator/task-context.js +63 -0
- package/dist/gene/curator/task-runner.d.ts +56 -0
- package/dist/gene/curator/task-runner.js +257 -0
- package/dist/gene/curator/tool-support.d.ts +112 -0
- package/dist/gene/curator/tool-support.js +197 -0
- package/dist/gene/curator/toolkit.d.ts +49 -0
- package/dist/gene/curator/toolkit.js +104 -0
- package/dist/gene/curator/tools-read.d.ts +4 -0
- package/dist/gene/curator/tools-read.js +177 -0
- package/dist/gene/curator/tools-release.d.ts +73 -0
- package/dist/gene/curator/tools-release.js +287 -0
- package/dist/gene/curator/tools-verify.d.ts +47 -0
- package/dist/gene/curator/tools-verify.js +202 -0
- package/dist/gene/curator/tools-write.d.ts +26 -0
- package/dist/gene/curator/tools-write.js +394 -0
- package/dist/gene/curator/tools.d.ts +23 -0
- package/dist/gene/curator/tools.js +21 -0
- package/dist/gene/curator/validate/common.d.ts +87 -0
- package/dist/gene/curator/validate/common.js +132 -0
- package/dist/gene/curator/validate/evidence-tokens.d.ts +36 -0
- package/dist/gene/curator/validate/evidence-tokens.js +139 -0
- package/dist/gene/curator/validate/index.d.ts +23 -0
- package/dist/gene/curator/validate/index.js +62 -0
- package/dist/gene/curator/validate/knowledge.d.ts +25 -0
- package/dist/gene/curator/validate/knowledge.js +216 -0
- package/dist/gene/curator/validate/live-check.d.ts +14 -0
- package/dist/gene/curator/validate/live-check.js +144 -0
- package/dist/gene/curator/validate/ports.d.ts +67 -0
- package/dist/gene/curator/validate/ports.js +1 -0
- package/dist/gene/curator/validate/prompts.d.ts +41 -0
- package/dist/gene/curator/validate/prompts.js +161 -0
- package/dist/gene/curator/validate/skill.d.ts +15 -0
- package/dist/gene/curator/validate/skill.js +251 -0
- package/dist/gene/curator/validate/tool.d.ts +6 -0
- package/dist/gene/curator/validate/tool.js +217 -0
- package/dist/gene/curator/validate/types.d.ts +90 -0
- package/dist/gene/curator/validate/types.js +1 -0
- package/dist/gene/curator/validator-ports.d.ts +38 -0
- package/dist/gene/curator/validator-ports.js +29 -0
- package/dist/gene/diag.d.ts +209 -0
- package/dist/gene/diag.js +549 -0
- package/dist/gene/env.d.ts +10 -0
- package/dist/gene/env.js +214 -0
- package/dist/gene/eval-recorder.d.ts +84 -0
- package/dist/gene/eval-recorder.js +222 -0
- package/dist/gene/explain-transport.d.ts +3 -0
- package/dist/gene/explain-transport.js +39 -0
- package/dist/gene/explain.d.ts +96 -0
- package/dist/gene/explain.js +293 -0
- package/dist/gene/fs.d.ts +39 -0
- package/dist/gene/fs.js +139 -0
- package/dist/gene/fsck.d.ts +68 -0
- package/dist/gene/fsck.js +134 -0
- package/dist/gene/gc-library-sweeps.d.ts +9 -0
- package/dist/gene/gc-library-sweeps.js +220 -0
- package/dist/gene/gc-rejected-set.d.ts +15 -0
- package/dist/gene/gc-rejected-set.js +63 -0
- package/dist/gene/gc-safe.d.ts +12 -0
- package/dist/gene/gc-safe.js +74 -0
- package/dist/gene/gc-scope-sweeps.d.ts +18 -0
- package/dist/gene/gc-scope-sweeps.js +297 -0
- package/dist/gene/gc-types.d.ts +55 -0
- package/dist/gene/gc-types.js +26 -0
- package/dist/gene/gc.d.ts +42 -0
- package/dist/gene/gc.js +129 -0
- package/dist/gene/gene-errors.d.ts +23 -0
- package/dist/gene/gene-errors.js +29 -0
- package/dist/gene/hints.d.ts +91 -0
- package/dist/gene/hints.js +394 -0
- package/dist/gene/hub.d.ts +149 -0
- package/dist/gene/hub.js +371 -0
- package/dist/gene/import-plan.d.ts +80 -0
- package/dist/gene/import-plan.js +294 -0
- package/dist/gene/import-proposal.d.ts +23 -0
- package/dist/gene/import-proposal.js +101 -0
- package/dist/gene/import-skill-port.d.ts +6 -0
- package/dist/gene/import-skill-port.js +53 -0
- package/dist/gene/import-sources.d.ts +48 -0
- package/dist/gene/import-sources.js +140 -0
- package/dist/gene/index-writer.d.ts +36 -0
- package/dist/gene/index-writer.js +101 -0
- package/dist/gene/learn/learn-call.d.ts +63 -0
- package/dist/gene/learn/learn-call.js +157 -0
- package/dist/gene/learn/learn-prompt.d.ts +51 -0
- package/dist/gene/learn/learn-prompt.js +245 -0
- package/dist/gene/learn/learner.d.ts +181 -0
- package/dist/gene/learn/learner.js +426 -0
- package/dist/gene/learn/ledger.d.ts +220 -0
- package/dist/gene/learn/ledger.js +394 -0
- package/dist/gene/learn/proposal-build.d.ts +83 -0
- package/dist/gene/learn/proposal-build.js +211 -0
- package/dist/gene/learn/proposal-guard.d.ts +43 -0
- package/dist/gene/learn/proposal-guard.js +37 -0
- package/dist/gene/learn/signals-port.d.ts +47 -0
- package/dist/gene/learn/signals-port.js +86 -0
- package/dist/gene/maintenance-paths.d.ts +7 -0
- package/dist/gene/maintenance-paths.js +20 -0
- package/dist/gene/maintenance-probation.d.ts +33 -0
- package/dist/gene/maintenance-probation.js +127 -0
- package/dist/gene/maintenance-proposals.d.ts +24 -0
- package/dist/gene/maintenance-proposals.js +68 -0
- package/dist/gene/maintenance-runner.d.ts +92 -0
- package/dist/gene/maintenance-runner.js +262 -0
- package/dist/gene/maintenance-tasks.d.ts +37 -0
- package/dist/gene/maintenance-tasks.js +95 -0
- package/dist/gene/manager-actions.d.ts +12 -0
- package/dist/gene/manager-actions.js +279 -0
- package/dist/gene/manager-approve.d.ts +29 -0
- package/dist/gene/manager-approve.js +84 -0
- package/dist/gene/manager-context.d.ts +90 -0
- package/dist/gene/manager-context.js +201 -0
- package/dist/gene/manager-detail.d.ts +17 -0
- package/dist/gene/manager-detail.js +313 -0
- package/dist/gene/manager-gc.d.ts +13 -0
- package/dist/gene/manager-gc.js +81 -0
- package/dist/gene/manager-library.d.ts +39 -0
- package/dist/gene/manager-library.js +90 -0
- package/dist/gene/manager-list.d.ts +27 -0
- package/dist/gene/manager-list.js +170 -0
- package/dist/gene/manager-queue.d.ts +16 -0
- package/dist/gene/manager-queue.js +124 -0
- package/dist/gene/manager-stats.d.ts +28 -0
- package/dist/gene/manager-stats.js +53 -0
- package/dist/gene/manager-view.d.ts +27 -0
- package/dist/gene/manager-view.js +124 -0
- package/dist/gene/manager.d.ts +56 -0
- package/dist/gene/manager.js +179 -0
- package/dist/gene/orphan-scopes.d.ts +37 -0
- package/dist/gene/orphan-scopes.js +150 -0
- package/dist/gene/paths.d.ts +73 -0
- package/dist/gene/paths.js +239 -0
- package/dist/gene/plan-content.d.ts +73 -0
- package/dist/gene/plan-content.js +522 -0
- package/dist/gene/plan-lifecycle.d.ts +29 -0
- package/dist/gene/plan-lifecycle.js +310 -0
- package/dist/gene/policy.d.ts +71 -0
- package/dist/gene/policy.js +313 -0
- package/dist/gene/project-learning.d.ts +25 -0
- package/dist/gene/project-learning.js +54 -0
- package/dist/gene/propagation.d.ts +48 -0
- package/dist/gene/propagation.js +45 -0
- package/dist/gene/queue-lock.d.ts +22 -0
- package/dist/gene/queue-lock.js +99 -0
- package/dist/gene/queue-record.d.ts +57 -0
- package/dist/gene/queue-record.js +145 -0
- package/dist/gene/queue.d.ts +235 -0
- package/dist/gene/queue.js +764 -0
- package/dist/gene/read.d.ts +61 -0
- package/dist/gene/read.js +252 -0
- package/dist/gene/runlog.d.ts +101 -0
- package/dist/gene/runlog.js +404 -0
- package/dist/gene/schema-lite.d.ts +24 -0
- package/dist/gene/schema-lite.js +159 -0
- package/dist/gene/scope-guard.d.ts +23 -0
- package/dist/gene/scope-guard.js +9 -0
- package/dist/gene/scope-lock.d.ts +48 -0
- package/dist/gene/scope-lock.js +222 -0
- package/dist/gene/scope-verify.d.ts +63 -0
- package/dist/gene/scope-verify.js +123 -0
- package/dist/gene/secrets.d.ts +43 -0
- package/dist/gene/secrets.js +161 -0
- package/dist/gene/service-context.d.ts +43 -0
- package/dist/gene/service-context.js +79 -0
- package/dist/gene/service-prepare.d.ts +25 -0
- package/dist/gene/service-prepare.js +219 -0
- package/dist/gene/service-types.d.ts +196 -0
- package/dist/gene/service-types.js +1 -0
- package/dist/gene/service-view.d.ts +41 -0
- package/dist/gene/service-view.js +69 -0
- package/dist/gene/service.d.ts +114 -0
- package/dist/gene/service.js +761 -0
- package/dist/gene/session-start.d.ts +36 -0
- package/dist/gene/session-start.js +212 -0
- package/dist/gene/store-port.d.ts +88 -0
- package/dist/gene/store-port.js +10 -0
- package/dist/gene/store-rows.d.ts +36 -0
- package/dist/gene/store-rows.js +72 -0
- package/dist/gene/store.d.ts +125 -0
- package/dist/gene/store.js +622 -0
- package/dist/gene/tombstones.d.ts +47 -0
- package/dist/gene/tombstones.js +61 -0
- package/dist/gene/tool-runner.d.ts +47 -0
- package/dist/gene/tool-runner.js +154 -0
- package/dist/gene/tool-screen.d.ts +41 -0
- package/dist/gene/tool-screen.js +227 -0
- package/dist/gene/tools.d.ts +112 -0
- package/dist/gene/tools.js +539 -0
- package/dist/gene/transfer.d.ts +85 -0
- package/dist/gene/transfer.js +433 -0
- package/dist/gene/ui-hints.d.ts +15 -0
- package/dist/gene/ui-hints.js +67 -0
- package/dist/gene/usage-fold-cursor.d.ts +24 -0
- package/dist/gene/usage-fold-cursor.js +115 -0
- package/dist/gene/usage-fold.d.ts +49 -0
- package/dist/gene/usage-fold.js +397 -0
- package/dist/gene/usage.d.ts +67 -0
- package/dist/gene/usage.js +231 -0
- package/dist/gene/version-service.d.ts +118 -0
- package/dist/gene/version-service.js +453 -0
- package/dist/gene/wiring-events.d.ts +43 -0
- package/dist/gene/wiring-events.js +113 -0
- package/dist/gene/wiring-models.d.ts +46 -0
- package/dist/gene/wiring-models.js +81 -0
- package/dist/gene/wiring.d.ts +200 -0
- package/dist/gene/wiring.js +764 -0
- package/dist/governance/prompts/orchestrator-block.js +3 -2
- package/dist/host/controller-factory.d.ts +8 -0
- package/dist/host/controller-factory.js +7 -0
- package/dist/host/gene.d.ts +26 -0
- package/dist/host/gene.js +24 -0
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.js +1 -0
- package/dist/session/checkpoint.d.ts +15 -0
- package/dist/session/checkpoint.js +18 -0
- package/dist/session/persist.d.ts +21 -0
- package/dist/session/persist.js +10 -0
- package/dist/session/startup-session.d.ts +11 -2
- package/dist/session/startup-session.js +12 -2
- package/dist/session/validate-session.js +31 -0
- package/dist/team/runtime.d.ts +16 -0
- package/dist/team/runtime.js +29 -0
- package/dist/team/subagent.d.ts +55 -0
- package/dist/team/subagent.js +46 -2
- package/dist/tools/index.d.ts +60 -2
- package/dist/tools/index.js +68 -10
- package/package.json +3 -3
- package/skills/project-indexer/SKILL.md +275 -147
- package/skills/project-indexer/templates/artifact-hygiene-template.md +14 -0
- package/skills/project-indexer/templates/config-template.md +12 -0
- package/skills/project-indexer/templates/index-template.md +4 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useRedTeamMode`: the terminal's half of red team / security mode (4.3 / 4.8).
|
|
3
|
+
*
|
|
4
|
+
* ASCII ONLY (`app/` is inside the glyph scanner's scope).
|
|
5
|
+
*
|
|
6
|
+
* `App.tsx` is far over the repo's size limit, so the key recognition, the waiver flow and the
|
|
7
|
+
* subscription live here and `App` only wires the result in. The DECISIONS are not here:
|
|
8
|
+
* `planRedTeam` (pure) decides, `RedTeamWiring` (controller) carries out, and this hook is the
|
|
9
|
+
* thin adapter between a keystroke and one `controller.setRedTeam(request)`.
|
|
10
|
+
*
|
|
11
|
+
* EVERY CONTROLLER MEMBER IS OPTIONAL (D-17). Several App-level tests hand `App` a
|
|
12
|
+
* hand-written controller stub that implements only what it needs; an unconditional call would
|
|
13
|
+
* throw `is not a function` at render. A controller without the members reads as "this session
|
|
14
|
+
* has no red team chain": the keys do nothing, no chip is drawn and no toast appears, so those
|
|
15
|
+
* sessions render the bytes they always did (I-1).
|
|
16
|
+
*/
|
|
17
|
+
import { useCallback, useEffect, useReducer, useRef } from 'react';
|
|
18
|
+
import { redTeamToast, } from '@aragon-agent/tui/model/redteam/redteam-mode';
|
|
19
|
+
import { REDTEAM_NOTICE, REDTEAM_TOAST } from '@aragon-agent/tui/ui/redteam-copy';
|
|
20
|
+
import { UNAVAILABLE_RED_TEAM_VIEW } from '../agent/redteam-wiring.js';
|
|
21
|
+
/** How long each level stays on screen. Refusals are longer: they have to be read. */
|
|
22
|
+
export function redTeamToastTtlMs(level) {
|
|
23
|
+
return level === 'warn' ? 3500 : 1800;
|
|
24
|
+
}
|
|
25
|
+
export function useRedTeamMode(args) {
|
|
26
|
+
const { controller } = args;
|
|
27
|
+
const [, bump] = useReducer((n) => n + 1, 0);
|
|
28
|
+
const argsRef = useRef(args);
|
|
29
|
+
argsRef.current = args;
|
|
30
|
+
/** The request that opened the waiver, so accepting re-issues the SAME intent. */
|
|
31
|
+
const awaiting = useRef(null);
|
|
32
|
+
// The view is read at render and never mirrored into App state: a mirror is a second copy
|
|
33
|
+
// that can disagree with the controller.
|
|
34
|
+
const view = controller.getRedTeamView?.() ?? UNAVAILABLE_RED_TEAM_VIEW;
|
|
35
|
+
useEffect(() => controller.subscribeRedTeam?.(() => bump()), [controller]);
|
|
36
|
+
/** Say what an outcome did, and push the banner when the mode just came on. */
|
|
37
|
+
const announce = useCallback((req, outcome) => {
|
|
38
|
+
const live = argsRef.current.controller;
|
|
39
|
+
const current = live.getRedTeamView?.() ?? UNAVAILABLE_RED_TEAM_VIEW;
|
|
40
|
+
const config = live.getConfig?.();
|
|
41
|
+
// "BACK ON" IS ONLY TRUE IF THEY WERE OFF (RV-1 / D-19): both facts are needed.
|
|
42
|
+
const hadBypass = config?.confirmTools === true
|
|
43
|
+
&& config?.redteam?.bypassConfirm !== false;
|
|
44
|
+
const toast = redTeamToast(outcome, {
|
|
45
|
+
request: req.kind,
|
|
46
|
+
scope: current.scope,
|
|
47
|
+
bypassesConfirm: current.bypassesConfirm,
|
|
48
|
+
wasBypassing: outcome.ok && outcome.wasArmed && hadBypass,
|
|
49
|
+
// `askEveryArm` refuses an arming that HAS been accepted (D-10), and the sentence has to
|
|
50
|
+
// say "review", not "not accepted".
|
|
51
|
+
waiverAccepted: current.waiverAccepted,
|
|
52
|
+
});
|
|
53
|
+
if (toast)
|
|
54
|
+
argsRef.current.pushToast(toast.level, toast.text);
|
|
55
|
+
// THE BANNER IS A TRANSCRIPT LINE, not a toast: it is three rows and it has to still be
|
|
56
|
+
// there in a minute (4.6). Printed only on a transition INTO armed.
|
|
57
|
+
if (outcome.ok && outcome.effect === 'applied' && outcome.armed && !outcome.wasArmed) {
|
|
58
|
+
const rows = live.getRedTeamBanner?.();
|
|
59
|
+
if (rows && rows.length > 0)
|
|
60
|
+
argsRef.current.pushNotice?.('warn', rows.join('\n'));
|
|
61
|
+
}
|
|
62
|
+
if (outcome.ok && outcome.effect === 'deferred') {
|
|
63
|
+
argsRef.current.pushNotice?.('info', REDTEAM_NOTICE.armingDeferred);
|
|
64
|
+
}
|
|
65
|
+
}, []);
|
|
66
|
+
const request = useCallback((req) => {
|
|
67
|
+
const live = argsRef.current.controller;
|
|
68
|
+
if (!live.setRedTeam)
|
|
69
|
+
return;
|
|
70
|
+
const outcome = live.setRedTeam(req);
|
|
71
|
+
if (!outcome.ok && outcome.refusal === 'disclaimer') {
|
|
72
|
+
// REMEMBER THE INTENT: accepting the waiver re-issues it, and a `toggle` that opened the
|
|
73
|
+
// overlay must not turn into an `on` if the user had actually asked to turn it OFF.
|
|
74
|
+
awaiting.current = req;
|
|
75
|
+
argsRef.current.openDisclaimer();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
announce(req, outcome);
|
|
79
|
+
}, [announce]);
|
|
80
|
+
const handleKey = useCallback((input, key) => {
|
|
81
|
+
if (!key.ctrl || key.meta)
|
|
82
|
+
return false;
|
|
83
|
+
if (input.toLowerCase() !== 'r')
|
|
84
|
+
return false;
|
|
85
|
+
// THE KEY IS CONSUMED EVEN WHEN THE MODE IS UNAVAILABLE (RV-11): `Ctrl+R` no longer
|
|
86
|
+
// repaints in ANY configuration, and swallowing it silently there would leave a user with
|
|
87
|
+
// no way to tell "off for this session" from "the key is broken". `planRedTeam` answers
|
|
88
|
+
// `unavailable`, and the toast says so once per press.
|
|
89
|
+
if (!argsRef.current.controller.setRedTeam)
|
|
90
|
+
return false;
|
|
91
|
+
// CONSUMED, BUT NOT ACTED ON (the pre-existing overlay guard, kept byte-for-byte): with an
|
|
92
|
+
// overlay open this key belongs to whoever owns the screen, and returning `true` here is
|
|
93
|
+
// what keeps it from reaching anything below in the same handler.
|
|
94
|
+
if (!argsRef.current.canAct())
|
|
95
|
+
return true;
|
|
96
|
+
request({ kind: 'toggle' });
|
|
97
|
+
return true;
|
|
98
|
+
}, [request]);
|
|
99
|
+
const onTurnEnd = useCallback(() => {
|
|
100
|
+
const live = argsRef.current.controller;
|
|
101
|
+
const outcome = live.applyPendingRedTeam?.();
|
|
102
|
+
if (!outcome)
|
|
103
|
+
return;
|
|
104
|
+
// The request that produced it: a landed arming came from `on`, everything else from `off`.
|
|
105
|
+
announce(outcome.ok && outcome.armed ? { kind: 'on' } : { kind: 'off' }, outcome);
|
|
106
|
+
}, [announce]);
|
|
107
|
+
const acceptDisclaimer = useCallback(() => {
|
|
108
|
+
const live = argsRef.current.controller;
|
|
109
|
+
// RECORD FIRST, then re-issue: the state machine refuses an arming before the acceptance
|
|
110
|
+
// is durable, and a waiver recorded after the arm would be a race with a crash (T-A1).
|
|
111
|
+
live.acceptRedTeamWaiver?.();
|
|
112
|
+
const req = awaiting.current ?? { kind: 'on' };
|
|
113
|
+
awaiting.current = null;
|
|
114
|
+
request(req);
|
|
115
|
+
}, [request]);
|
|
116
|
+
const declineDisclaimer = useCallback(() => {
|
|
117
|
+
awaiting.current = null;
|
|
118
|
+
argsRef.current.pushToast('info', REDTEAM_TOAST.declined);
|
|
119
|
+
}, []);
|
|
120
|
+
return { view, request, handleKey, onTurnEnd, acceptDisclaimer, declineDisclaimer };
|
|
121
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,9 @@ import { formatHomeMigrationNotice, migrateToHome } from './config/migrate-home.
|
|
|
13
13
|
import { migrateStateOutOfConfig } from './config/migrate-state-out-of-config.js';
|
|
14
14
|
import { runHistoryCommand } from './config/history-commands.js';
|
|
15
15
|
import { checkGovernanceCommandLine } from './config/governance-launch.js';
|
|
16
|
-
import {
|
|
16
|
+
import { checkRedTeamCommandLine } from './config/redteam-launch.js';
|
|
17
|
+
import { getRedTeamWaiverVersion, isRedTeamEnvOff } from './config/ui-state.js';
|
|
18
|
+
import { COMPACTION_CONFIG_SET_KEYS, FAST_CONFIG_SET_KEYS, LOG_CONFIG_SET_KEYS, RETRY_CONFIG_SET_KEYS, TEAM_CONFIG_SET_KEYS, GOVERNANCE_CONFIG_SET_KEYS, MEMORY_CONFIG_SET_KEYS, applyMemoryConfigSet, GENE_CONFIG_SET_KEYS, applyGeneConfigSet, JOBS_CONFIG_SET_KEYS, TASK_SUMMARY_CONFIG_SET_KEYS, UPDATE_CONFIG_SET_KEYS, applyCompactionConfigSet, applyFastConfigSet, applyLogConfigSet, applyRetryConfigSet, applyTeamConfigSet, applyGovernanceConfigSet, applyJobsConfigSet, applyTaskSummaryConfigSet, applyUpdateConfigSet, runConfigEdit, runConfigGet, runConfigHome, runConfigList, warnIfRedactionDisabled, } from './config/cli-commands.js';
|
|
17
19
|
import { attachAgentEvents, attachTeamEvents, installLogging, setScreenRestore, setSignalTerminator, } from './logging/install.js';
|
|
18
20
|
import { getLogger } from './logging/logger.js';
|
|
19
21
|
import { runLogsCommand } from './logging/cli-commands.js';
|
|
@@ -27,6 +29,7 @@ import { runHeadless } from './agent/headless.js';
|
|
|
27
29
|
// `history` / `skills` convention.
|
|
28
30
|
import { registerExecCommand } from './exec/cli-commands.js';
|
|
29
31
|
import { registerSessionsCommand } from './session/cli-commands.js';
|
|
32
|
+
import { registerGeneCliCommand } from './gene/cli-commands.js';
|
|
30
33
|
import { registerDoctorCommand, registerInfoCommand } from './diagnostics/cli-commands.js';
|
|
31
34
|
import { App } from './app/App.js';
|
|
32
35
|
import { createSessionWriter, makeController, readCliVersion, } from './host/controller-factory.js';
|
|
@@ -216,6 +219,16 @@ function toFlags(opts) {
|
|
|
216
219
|
// defaults `opts.memory` to `true` when it is absent, so only an explicit `false` is
|
|
217
220
|
// forwarded and silence can never read as an override.
|
|
218
221
|
memory: opts.memory === false ? false : undefined,
|
|
222
|
+
// Site three of three for the red team pair. BOTH are forwarded, and both are tri-state:
|
|
223
|
+
// `--redteam` absent is `undefined` (no arming), `--no-redteam` absent is `undefined` (no
|
|
224
|
+
// kill switch). Forwarding silence as `false` here would unregister the chain for every run
|
|
225
|
+
// that passed no flag at all.
|
|
226
|
+
redteam: opts.redteam === true ? true : undefined,
|
|
227
|
+
noRedteam: opts.redteam === false ? true : undefined,
|
|
228
|
+
// Site three of three for `--no-gene`, declared alone like `--no-memory`: commander
|
|
229
|
+
// defaults `opts.gene` to `true` when it is absent, so only an explicit `false` is forwarded
|
|
230
|
+
// (as `noGene: true`) and silence can never read as an override.
|
|
231
|
+
noGene: opts.gene === false ? true : undefined,
|
|
219
232
|
// Site three of three for `--resume` / `--save` -- ELEVEN features, one trap
|
|
220
233
|
// (`mouse` P1-2, `team` P1-4, `todo` C-9, render L4, retry, fast, update,
|
|
221
234
|
// compaction, now session identity). A flag needs the `.option()`
|
|
@@ -394,11 +407,17 @@ async function runInteractive(flags, extras = {}) {
|
|
|
394
407
|
// MUTABLE BECAUSE `/resume` ROTATES IT (D-15). The chip follows through the
|
|
395
408
|
// App's `onIdentity`, and the writer reads `parentId` from here on every write.
|
|
396
409
|
let identity = startup.identity;
|
|
397
|
-
const { controller, confirmBridge, humanInputBridge } = makeController(flags
|
|
410
|
+
const { controller, confirmBridge, humanInputBridge } = makeController(flags, {
|
|
411
|
+
interactive: true,
|
|
412
|
+
// THE ONE LAUNCH PATH THAT MAY START ARMED (4.8). `flags.redteam` is already tri-state and
|
|
413
|
+
// the `preAction` hook has already refused the two impossible combinations, so this is a
|
|
414
|
+
// plain boolean by here - and it is absent for `-p` / `exec` / every subcommand (I-1).
|
|
415
|
+
...(flags.redteam === true ? { redTeamArmed: true } : {}),
|
|
416
|
+
});
|
|
398
417
|
// THE RESTORE HAPPENS BEFORE THE FIRST FRAME. `initialEntries` seeds the
|
|
399
418
|
// reducer, so a resumed transcript is complete on frame one instead of filling
|
|
400
419
|
// in behind the user's eyes.
|
|
401
|
-
startup.apply(controller);
|
|
420
|
+
const redTeamResumeNotice = startup.apply(controller);
|
|
402
421
|
void controller.refreshModelMetadata();
|
|
403
422
|
const config = controller.getConfig();
|
|
404
423
|
const caps = resolveTuiCapabilities({}, config.color);
|
|
@@ -1128,7 +1147,7 @@ async function runInteractive(flags, extras = {}) {
|
|
|
1128
1147
|
vtInputWarning: vtInputSupported ? undefined : { nodeVersion: process.versions.node }, updateBridge: updateEligible ? updateBridge : undefined,
|
|
1129
1148
|
// Absent when nothing can refuse a paste, so a `--no-paste` tree is
|
|
1130
1149
|
// byte-identical to a build without this feature.
|
|
1131
|
-
pasteBridge: pasteOn ? pasteBridge : undefined, terminal: terminalBridge, ...(scrollbackBridge ? { scrollMode: plan.scrollMode, scrollback: scrollbackBridge } : {}), session: identity, sessionBridge: sessionBridge, ...(startup.initialEntries.length > 0 ? { initialEntries: startup.initialEntries } : {}), ...(startup.notice ? { sessionNotice: startup.notice } : {}) }),
|
|
1150
|
+
pasteBridge: pasteOn ? pasteBridge : undefined, terminal: terminalBridge, ...(scrollbackBridge ? { scrollMode: plan.scrollMode, scrollback: scrollbackBridge } : {}), session: identity, sessionBridge: sessionBridge, ...(startup.initialEntries.length > 0 ? { initialEntries: startup.initialEntries } : {}), ...(startup.notice ? { sessionNotice: startup.notice } : {}), ...(redTeamResumeNotice ? { redTeamNotice: redTeamResumeNotice } : {}) }),
|
|
1132
1151
|
// Full-screen owns console.* itself (I-4): Ink's patchConsole writes
|
|
1133
1152
|
// straight to stdout and permanently shifts the fixed frame's accounting.
|
|
1134
1153
|
{
|
|
@@ -1478,6 +1497,12 @@ const CONFIG_SET_KEYS = new Set([
|
|
|
1478
1497
|
// spec 5.6): without this line they fall through to `Unknown config key`, and without the
|
|
1479
1498
|
// matching case in `runConfigSet` the membership set accepts a write that never happens.
|
|
1480
1499
|
...MEMORY_CONFIG_SET_KEYS,
|
|
1500
|
+
// `gene.*` keys are handled by `applyGeneConfigSet`, same reasoning again (gene-bank spec
|
|
1501
|
+
// 14.1): without this line they fall through to `Unknown config key`, and without the
|
|
1502
|
+
// matching branch in `runConfigSetValue` the membership set accepts a write that never
|
|
1503
|
+
// happens. `gene.use` / `gene.autoLearn` are the two user switches (14.2), so a script that
|
|
1504
|
+
// cannot set them cannot honour the user's own off-switch.
|
|
1505
|
+
...GENE_CONFIG_SET_KEYS,
|
|
1481
1506
|
]);
|
|
1482
1507
|
/**
|
|
1483
1508
|
* `aragon config set maxTokens <n|auto|default>`.
|
|
@@ -1667,6 +1692,16 @@ function runConfigSetValue(key, value) {
|
|
|
1667
1692
|
process.stdout.write(`Set ${key} = ${String(merged.memory?.[field])}\n`);
|
|
1668
1693
|
return;
|
|
1669
1694
|
}
|
|
1695
|
+
const genePatch = applyGeneConfigSet(key, value);
|
|
1696
|
+
if (genePatch) {
|
|
1697
|
+
// Echoed from the STORED value, like every section above: `config set gene.probeMode all`
|
|
1698
|
+
// prints `readonly`, and `config set gene.pinnedMax 9999` prints the value clamped against
|
|
1699
|
+
// the stored `capPerType`, which is what the read path will report.
|
|
1700
|
+
const merged = updatePersistedConfig(genePatch);
|
|
1701
|
+
const field = key.slice('gene.'.length);
|
|
1702
|
+
process.stdout.write(`Set ${key} = ${String(merged.gene[field])}\n`);
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1670
1705
|
const patch = {};
|
|
1671
1706
|
switch (key) {
|
|
1672
1707
|
case 'provider':
|
|
@@ -2097,6 +2132,21 @@ function buildProgram() {
|
|
|
2097
2132
|
// Negative-only for the reason `--no-governance` records: it can only ever switch the
|
|
2098
2133
|
// feature off for this launch, and `toFlags` forwards it only when explicitly given.
|
|
2099
2134
|
.option('--no-memory', 'Disable agent memory for this launch (no memory tools or prompt block; not persisted)')
|
|
2135
|
+
// RED TEAM / SECURITY MODE (red-team-security-mode 4.8). The pair is declared POSITIVE FIRST
|
|
2136
|
+
// for the tri-state reason recorded five times above: `redteam.enabled` is persisted and
|
|
2137
|
+
// defaults to `true`, so a negative-only declaration would let commander synthesize `true`
|
|
2138
|
+
// and overwrite a stored `false` on every run that passed no flag at all.
|
|
2139
|
+
//
|
|
2140
|
+
// `--redteam` additionally means "start this session ARMED", which `validateRedTeamLaunch`
|
|
2141
|
+
// refuses in headless mode and before the waiver is accepted - both are cases where nobody
|
|
2142
|
+
// could accept it, and an armed session nobody can leave is worse than no armed session.
|
|
2143
|
+
.option('--redteam', 'Start this session in red team / security mode (needs the waiver accepted)')
|
|
2144
|
+
.option('--no-redteam', 'Disable red team mode for this launch (no chip, no key; not persisted)')
|
|
2145
|
+
// Negative-only for the reason `--no-memory` records: it can only ever switch the Gene Bank
|
|
2146
|
+
// off for this launch (no service, no tools, byte-identical prompt), and `toFlags` forwards
|
|
2147
|
+
// it only when explicitly given. The positive `--gene` / `--gene-learn` belong to the
|
|
2148
|
+
// headless paths and are declared with their behaviour, not here (gene-bank spec 14.3).
|
|
2149
|
+
.option('--no-gene', 'Disable the Gene Bank for this launch (no gene tools or prompt block; not persisted)')
|
|
2100
2150
|
.option('--no-skills', 'Disable the skill system entirely (no catalog, no skill tools)')
|
|
2101
2151
|
.option('--skill <name>', 'Force-load a skill at Level 2 for this run (repeatable)', (value, previous = []) => [...previous, value])
|
|
2102
2152
|
.option('--skills-yes', 'Approve skill installs for this run (CI / headless)')
|
|
@@ -2176,6 +2226,32 @@ function buildProgram() {
|
|
|
2176
2226
|
process.stderr.write(`${check.message}\n`);
|
|
2177
2227
|
process.exit(2);
|
|
2178
2228
|
});
|
|
2229
|
+
/**
|
|
2230
|
+
* The red team flag rules (red-team-security-mode 4.8), in a `preAction` of their own for the
|
|
2231
|
+
* reason the governance hook above records: root-level options, one place, and it covers
|
|
2232
|
+
* `aragon -p` and `aragon exec` too - which is exactly where `--redteam` must be REFUSED.
|
|
2233
|
+
*
|
|
2234
|
+
* The waiver version is read here rather than in `loadConfig` because it lives in `state.json`
|
|
2235
|
+
* (a machine fact, not a preference) and this is the only code path that may open a terminal.
|
|
2236
|
+
*/
|
|
2237
|
+
program.hook('preAction', (root, action) => {
|
|
2238
|
+
const raw = root.opts();
|
|
2239
|
+
const check = checkRedTeamCommandLine({ ...(raw.redteam === true ? { redteam: true } : {}),
|
|
2240
|
+
...(raw.redteam === false ? { noRedteamFlag: false } : {}) }, {
|
|
2241
|
+
commandName: action.name(),
|
|
2242
|
+
isRootAction: action === root,
|
|
2243
|
+
stdinIsTty: !!process.stdin.isTTY,
|
|
2244
|
+
stdoutIsTty: !!process.stdout.isTTY,
|
|
2245
|
+
}, getRedTeamWaiverVersion(),
|
|
2246
|
+
// READ THE VARIABLE DIRECTLY rather than through `readEnvConfig()`: that function also
|
|
2247
|
+
// registers secrets, and a `preAction` hook must not have that side effect for a question
|
|
2248
|
+
// this small. Only the values the other kill switches accept count, and only "off" is one.
|
|
2249
|
+
raw.redteam === false || isRedTeamEnvOff());
|
|
2250
|
+
if (check.ok)
|
|
2251
|
+
return;
|
|
2252
|
+
process.stderr.write(`${check.message}\n`);
|
|
2253
|
+
process.exit(2);
|
|
2254
|
+
});
|
|
2179
2255
|
// aragon config [set <key> <value> | path]
|
|
2180
2256
|
const configCmd = program
|
|
2181
2257
|
.command('config')
|
|
@@ -2291,6 +2367,8 @@ function buildProgram() {
|
|
|
2291
2367
|
makeController: makeExecController,
|
|
2292
2368
|
});
|
|
2293
2369
|
registerSessionsCommand(program);
|
|
2370
|
+
// `aragon gene ...` (gene-bank spec 16.4): list | show | search | export | import | stats | fsck.
|
|
2371
|
+
registerGeneCliCommand(program);
|
|
2294
2372
|
registerInfoCommand(program, toFlags, VERSION);
|
|
2295
2373
|
registerDoctorCommand(program, toFlags);
|
|
2296
2374
|
return program;
|
|
@@ -26,6 +26,7 @@ import { getLogger } from '../logging/logger.js';
|
|
|
26
26
|
import { registerQueueCommand } from './queue-command.js';
|
|
27
27
|
import { registerPromptCommands } from '../prompts/command.js';
|
|
28
28
|
import { registerMemoryCommands } from '../memory/command.js';
|
|
29
|
+
import { registerGeneCommands } from '../gene/command.js';
|
|
29
30
|
import { registerKitCommand } from './kit-command.js';
|
|
30
31
|
import { registerAgentsCommand } from './agents-command.js';
|
|
31
32
|
import { registerSubagentCommand } from './subagent-command.js';
|
|
@@ -33,6 +34,9 @@ import { registerSubagentCommand } from './subagent-command.js';
|
|
|
33
34
|
// and this pair of lines is the whole registration; the `team` entry that used to
|
|
34
35
|
// live in `COMMANDS` above was a CONFIG command and now lives in `Settings > Team`.
|
|
35
36
|
import { registerTeamCommand } from './team-command.js';
|
|
37
|
+
// `/redteam` (red-team-security-mode 4.8): the body is `commands/redteam-command.ts` and this
|
|
38
|
+
// import is the whole registration, the `/team` shape.
|
|
39
|
+
import { registerRedTeamCommand } from './redteam-command.js';
|
|
36
40
|
// THE DRAWER AND THE HEADER LABEL (tui-shortcut-drawer-and-task-summary §4.7):
|
|
37
41
|
// two single-purpose commands in their own modules, registered from here. Both are
|
|
38
42
|
// UNCONDITIONAL, even with `taskSummary.enabled=false`, because they are the only
|
|
@@ -246,6 +250,27 @@ function formatFastStatus(controller) {
|
|
|
246
250
|
`${formatTokens(snapshot.usage.outputTokens)}, cost ${cost}.`);
|
|
247
251
|
return lines.join('\n');
|
|
248
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* The two session-file fields red team mode contributes to a `/save` (4.10).
|
|
255
|
+
*
|
|
256
|
+
* A HELPER RATHER THAN FOUR INLINE LINES because the answer is "the whole object, or nothing":
|
|
257
|
+
* an unarmed session must write NO key, so a `/save` from a session that never used the mode is
|
|
258
|
+
* byte-identical to one written before the feature. `getRedTeamSessionState` is optional on the
|
|
259
|
+
* port (D-17), so a host without the chain simply contributes nothing.
|
|
260
|
+
*/
|
|
261
|
+
function redTeamSaveFields(port) {
|
|
262
|
+
const state = typeof port.getRedTeamSessionState === 'function'
|
|
263
|
+
? port.getRedTeamSessionState()
|
|
264
|
+
: undefined;
|
|
265
|
+
if (state?.armed !== true)
|
|
266
|
+
return {};
|
|
267
|
+
return {
|
|
268
|
+
redTeam: true,
|
|
269
|
+
...(typeof state.waiverVersion === 'number'
|
|
270
|
+
? { redTeamWaiverVersion: state.waiverVersion }
|
|
271
|
+
: {}),
|
|
272
|
+
};
|
|
273
|
+
}
|
|
249
274
|
const COMMANDS = [
|
|
250
275
|
{
|
|
251
276
|
name: 'help',
|
|
@@ -983,6 +1008,9 @@ const COMMANDS = [
|
|
|
983
1008
|
// "not started" that the user had already watched being verified. Read
|
|
984
1009
|
// from the STORE, so a save taken while the capability is off keeps them.
|
|
985
1010
|
acceptance: ctx.controller.getAcceptanceItems(),
|
|
1011
|
+
// The red team posture, so `/save` and the live checkpoint agree about it (4.10). A
|
|
1012
|
+
// disarmed session contributes no key at all, which keeps this file byte-identical.
|
|
1013
|
+
...redTeamSaveFields(ctx.controller),
|
|
986
1014
|
});
|
|
987
1015
|
ctx.notify('info', `Saved session to ${path}`);
|
|
988
1016
|
}
|
|
@@ -1017,7 +1045,11 @@ const COMMANDS = [
|
|
|
1017
1045
|
// live TUI and a no-op at startup, and the second is a VIEW action with
|
|
1018
1046
|
// no controller to hang it on.
|
|
1019
1047
|
ctx.controller.clearAllQueues();
|
|
1020
|
-
|
|
1048
|
+
// The notice is the red team reconciliation (4.10): a session that comes back
|
|
1049
|
+
// DISARMED because the waiver moved has to say so, or the user assumes the mode stuck.
|
|
1050
|
+
const notice = applyRestoredSession(ctx.controller, session);
|
|
1051
|
+
if (notice)
|
|
1052
|
+
ctx.notify('warn', notice);
|
|
1021
1053
|
ctx.dispatch({ type: 'restoreEntries', entries: session.entries });
|
|
1022
1054
|
// A NEW ID, AND A ZEROED COUNTER, IN THAT ORDER (D-15 / D-10 / R-9).
|
|
1023
1055
|
// Without the rotation the next checkpoint would write THIS conversation
|
|
@@ -1355,6 +1387,9 @@ export function registerBuiltinCommands(registry) {
|
|
|
1355
1387
|
registerPromptCommands(registry);
|
|
1356
1388
|
// UNCONDITIONAL, like `/prompts`: with `memory.enabled=false` the command stays and says so.
|
|
1357
1389
|
registerMemoryCommands(registry);
|
|
1390
|
+
// UNCONDITIONAL, like `/memory`: with `gene.enabled=false` (or `--no-gene`) the command stays and
|
|
1391
|
+
// says so (gene-bank spec 16.3). Its capabilities arrive on `CommandContext.gene`.
|
|
1392
|
+
registerGeneCommands(registry);
|
|
1358
1393
|
// The read-only subagent board (tui-subagent-panel §6.4). Same shape again: the
|
|
1359
1394
|
// body is `commands/agents-command.ts` and the registration is this one line.
|
|
1360
1395
|
registerAgentsCommand(registry);
|
|
@@ -1374,6 +1409,10 @@ export function registerBuiltinCommands(registry) {
|
|
|
1374
1409
|
// `/gov` (governance-mode 11.3). Unconditional, like `/team` and for the same reason: the
|
|
1375
1410
|
// session where governance cannot run is exactly where a user asks the command why.
|
|
1376
1411
|
registerGovernanceCommand(registry);
|
|
1412
|
+
// `/redteam` (red-team-security-mode 4.8). UNCONDITIONAL, like `/team` and `/gov`: the session
|
|
1413
|
+
// where the mode cannot run (`--no-redteam`) is exactly the session where a user types
|
|
1414
|
+
// `/redteam status` to find out why, so registering it may not read the config or the waiver.
|
|
1415
|
+
registerRedTeamCommand(registry);
|
|
1377
1416
|
// The keyboard drawer (`Ctrl+G` / `/keys`) and the task label (`/task`). Two
|
|
1378
1417
|
// registrations, no new mechanism: `/keys` sets the panel's pre-filter and opens
|
|
1379
1418
|
// the same overlay `Ctrl+G` opens, and `/task` reports what the header cell says.
|
|
@@ -1393,6 +1432,9 @@ export const BUILTIN_COMMAND_NAMES = ['queue', 'prompts', 'agents', 'subagent',
|
|
|
1393
1432
|
// `commands/team-command.ts`), and this array is the documentation/tests surface
|
|
1394
1433
|
// for every built-in name - the `flatMap` below only sees `COMMANDS`.
|
|
1395
1434
|
'team',
|
|
1435
|
+
// `redteam` joins the list for the reason `team` above records: its body lives in
|
|
1436
|
+
// `commands/redteam-command.ts`, so only this array can document it to the tests.
|
|
1437
|
+
'redteam',
|
|
1396
1438
|
'keys', 'task',
|
|
1397
1439
|
...COMMANDS.flatMap((c) => [
|
|
1398
1440
|
c.name,
|
package/dist/commands/catalog.js
CHANGED
|
@@ -44,9 +44,14 @@ export const BUILTIN_COMMAND_CATALOG = [
|
|
|
44
44
|
{ name: 'kit', aliases: [], description: 'Agent kits: status, list, use for this session' },
|
|
45
45
|
{ name: 'prompts', aliases: [], description: 'Quick prompt library: pick, list, add, edit, remove, reorder' },
|
|
46
46
|
{ name: 'memory', aliases: ['mem'], description: 'Memory manager: list, save, show, remove, mount, auto-load, agent writes' },
|
|
47
|
+
{ name: 'gene', aliases: ['genes'], description: 'Gene Bank: status, search, show, explain, pin, archive, rollback, queue, stats, export, import, import-memory' },
|
|
47
48
|
{ name: 'agents', aliases: [], description: 'Open the subagent board: every child, its facts and its timeline' },
|
|
48
49
|
{ name: 'subagent', aliases: [], description: 'Deprecated alias of /team - same arguments' },
|
|
49
50
|
{ name: 'team', aliases: [], description: 'Force team mode and start now: /team <brief>; /team [on [n]|off|status]' },
|
|
51
|
+
// red-team-security-mode 4.8: the fourth session posture. Listed here for the reason every
|
|
52
|
+
// command above is - the catalog is what the slash menu and the drift test read, so a
|
|
53
|
+
// command that exists only in the registry is one the user cannot discover.
|
|
54
|
+
{ name: 'redteam', aliases: [], description: 'Red team mode: /redteam [status|on|off|scope <one line>]' },
|
|
50
55
|
{ name: 'gov', aliases: [], description: 'Governed multi-agent team: /gov help' },
|
|
51
56
|
{ name: 'keys', aliases: [], description: 'List every keyboard shortcut (opens the drawer)' },
|
|
52
57
|
{ name: 'task', aliases: [], description: 'Show the header task summary (/task refresh regenerates it)' },
|
|
@@ -65,7 +65,8 @@ export function buildIndexConfirmSummary(input) {
|
|
|
65
65
|
`\nRuns the bundled "${INDEX_SKILL_NAME}" skill as a normal agent turn:` +
|
|
66
66
|
`\n- scans the workspace (exclusions apply), extracts exported symbols` +
|
|
67
67
|
`\n- writes .claude-index/index.md and .claude-index/config.md` +
|
|
68
|
-
`\n-
|
|
68
|
+
`\n- writes matching CLAUDE.md and AGENTS.md (project index + optional Clean Code Guidelines)` +
|
|
69
|
+
`\n- adds rules for results in runs/ and checking temporary files before completion` +
|
|
69
70
|
`${existing}` +
|
|
70
71
|
`\nWorkspace: ${input.cwd}` +
|
|
71
72
|
`\nEvery step is visible in the transcript; Esc interrupts.`);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/redteam`: report, enter, leave, and declare the engagement scope
|
|
3
|
+
* (red-team-security-mode 4.8 / D-18).
|
|
4
|
+
*
|
|
5
|
+
* ASCII ONLY: `src/commands/**` is inside `glyphs.test.ts::inScope`.
|
|
6
|
+
*
|
|
7
|
+
* FOUR SUBCOMMANDS AND ONE SHARED ENTRY. `on` / `off` go through `controller.setRedTeam()`,
|
|
8
|
+
* the same call `Ctrl+R` makes, so a turn in flight defers the arming instead of being refused
|
|
9
|
+
* and the wording is the shared toast. `status` never refuses, in any posture and any session:
|
|
10
|
+
* a security posture nobody can query is a posture the user cannot verify - and the question
|
|
11
|
+
* "am I in red team mode right now" is exactly the one a person asks while looking at a
|
|
12
|
+
* destructive command in the transcript.
|
|
13
|
+
*
|
|
14
|
+
* THE COMMAND DOES NOT OPEN THE WAIVER OVERLAY. `on` without an accepted waiver answers with
|
|
15
|
+
* the sentence that names the key instead: the overlay is App state, and a command that opened
|
|
16
|
+
* it could not settle it (accepting has to re-plan the request and push the banner).
|
|
17
|
+
*/
|
|
18
|
+
import type { CommandContext, CommandRegistry } from './registry.js';
|
|
19
|
+
/** Where the `/redteam` handler lives, so `builtins.ts` only adds one registration. */
|
|
20
|
+
export declare function runRedTeamCommand(ctx: CommandContext): void;
|
|
21
|
+
/** Registered from `builtins.ts` with one line, next to every other subsystem. */
|
|
22
|
+
export declare function registerRedTeamCommand(registry: CommandRegistry): void;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/redteam`: report, enter, leave, and declare the engagement scope
|
|
3
|
+
* (red-team-security-mode 4.8 / D-18).
|
|
4
|
+
*
|
|
5
|
+
* ASCII ONLY: `src/commands/**` is inside `glyphs.test.ts::inScope`.
|
|
6
|
+
*
|
|
7
|
+
* FOUR SUBCOMMANDS AND ONE SHARED ENTRY. `on` / `off` go through `controller.setRedTeam()`,
|
|
8
|
+
* the same call `Ctrl+R` makes, so a turn in flight defers the arming instead of being refused
|
|
9
|
+
* and the wording is the shared toast. `status` never refuses, in any posture and any session:
|
|
10
|
+
* a security posture nobody can query is a posture the user cannot verify - and the question
|
|
11
|
+
* "am I in red team mode right now" is exactly the one a person asks while looking at a
|
|
12
|
+
* destructive command in the transcript.
|
|
13
|
+
*
|
|
14
|
+
* THE COMMAND DOES NOT OPEN THE WAIVER OVERLAY. `on` without an accepted waiver answers with
|
|
15
|
+
* the sentence that names the key instead: the overlay is App state, and a command that opened
|
|
16
|
+
* it could not settle it (accepting has to re-plan the request and push the banner).
|
|
17
|
+
*/
|
|
18
|
+
import { redTeamStatusLines, REDTEAM_COMMAND, REDTEAM_TOAST, } from '@aragon-agent/tui/ui/redteam-copy';
|
|
19
|
+
import { redTeamToast, } from '@aragon-agent/tui/model/redteam/redteam-mode';
|
|
20
|
+
import { UNAVAILABLE_RED_TEAM_VIEW } from '../agent/redteam-wiring.js';
|
|
21
|
+
/** Where the `/redteam` handler lives, so `builtins.ts` only adds one registration. */
|
|
22
|
+
export function runRedTeamCommand(ctx) {
|
|
23
|
+
const args = ctx.args.trim();
|
|
24
|
+
const [verb = '', ...rest] = args.length > 0 ? args.split(/\s+/) : [];
|
|
25
|
+
switch (verb.toLowerCase()) {
|
|
26
|
+
case '':
|
|
27
|
+
case 'status':
|
|
28
|
+
reportStatus(ctx);
|
|
29
|
+
return;
|
|
30
|
+
case 'on':
|
|
31
|
+
request(ctx, { kind: 'on' });
|
|
32
|
+
return;
|
|
33
|
+
case 'off':
|
|
34
|
+
request(ctx, { kind: 'off' });
|
|
35
|
+
return;
|
|
36
|
+
case 'scope':
|
|
37
|
+
setScope(ctx, rest.join(' ').trim());
|
|
38
|
+
return;
|
|
39
|
+
default:
|
|
40
|
+
ctx.notify('warn', REDTEAM_COMMAND.usage);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** The view, or the "no chain here" shape when the controller has none (D-17). */
|
|
44
|
+
function viewOf(ctx) {
|
|
45
|
+
const port = ctx.controller;
|
|
46
|
+
return typeof port.getRedTeamView === 'function'
|
|
47
|
+
? port.getRedTeamView()
|
|
48
|
+
: UNAVAILABLE_RED_TEAM_VIEW;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The four status lines (RV-18): effective state, scope, what the confirmation gate is doing,
|
|
52
|
+
* and what this mode does NOT lift.
|
|
53
|
+
*
|
|
54
|
+
* The third line is the one the whole feature is judged on (R-13): with `confirmTools` off -
|
|
55
|
+
* the default - it must say that NOTHING about permissions changed, because that is the truth
|
|
56
|
+
* and the disclaimer's clause 2 depends on the same truth.
|
|
57
|
+
*/
|
|
58
|
+
function reportStatus(ctx) {
|
|
59
|
+
const view = viewOf(ctx);
|
|
60
|
+
const config = ctx.controller.getConfig();
|
|
61
|
+
const lines = redTeamStatusLines(view, {
|
|
62
|
+
confirmTools: config.confirmTools === true,
|
|
63
|
+
bypassConfirm: config.redteam?.bypassConfirm !== false,
|
|
64
|
+
posture: postureOf(ctx),
|
|
65
|
+
});
|
|
66
|
+
ctx.notify('info', lines.join('\n'));
|
|
67
|
+
}
|
|
68
|
+
/** The live posture, as the two axes the copy table needs to NAME it. */
|
|
69
|
+
function postureOf(ctx) {
|
|
70
|
+
const posture = typeof ctx.controller.getPosture === 'function'
|
|
71
|
+
? ctx.controller.getPosture()
|
|
72
|
+
: 'build';
|
|
73
|
+
return {
|
|
74
|
+
mode: posture === 'plan' || posture === 'plan_govern' ? 'plan' : 'build',
|
|
75
|
+
governOn: posture === 'govern' || posture === 'plan_govern',
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** `on` / `off`: one entry, one outcome, one sentence. */
|
|
79
|
+
function request(ctx, req) {
|
|
80
|
+
const port = ctx.controller;
|
|
81
|
+
if (typeof port.setRedTeam !== 'function') {
|
|
82
|
+
ctx.notify('warn', REDTEAM_TOAST.unavailable);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const outcome = port.setRedTeam(req);
|
|
86
|
+
if (!outcome.ok && outcome.refusal === 'disclaimer') {
|
|
87
|
+
// NAMES THE KEY: the only surface that can show the waiver is the terminal's overlay.
|
|
88
|
+
ctx.notify('warn', REDTEAM_COMMAND.notOn);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
reportOutcome(ctx, req, outcome);
|
|
92
|
+
}
|
|
93
|
+
function reportOutcome(ctx, req, outcome) {
|
|
94
|
+
const view = viewOf(ctx);
|
|
95
|
+
const config = ctx.controller.getConfig();
|
|
96
|
+
// "BACK ON" IS ONLY TRUE IF THEY WERE OFF (RV-1 / D-19). Both halves are needed: a session
|
|
97
|
+
// with no `--confirm` gate never had confirmations to turn on, and one with
|
|
98
|
+
// `bypassConfirm: false` never turned them off.
|
|
99
|
+
const hadBypass = config.confirmTools === true && config.redteam?.bypassConfirm !== false;
|
|
100
|
+
const toast = redTeamToast(outcome, {
|
|
101
|
+
request: req.kind,
|
|
102
|
+
scope: view.scope,
|
|
103
|
+
bypassesConfirm: view.bypassesConfirm,
|
|
104
|
+
wasBypassing: outcome.ok && outcome.wasArmed && hadBypass,
|
|
105
|
+
waiverAccepted: view.waiverAccepted,
|
|
106
|
+
});
|
|
107
|
+
if (toast)
|
|
108
|
+
ctx.notify(toast.level, toast.text);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* `/redteam scope <one line>` sets it; `/redteam scope` with no argument CLEARS it.
|
|
112
|
+
*
|
|
113
|
+
* The refusal cases are reported rather than silently truncated (4.6 step 4): a user who
|
|
114
|
+
* typed a 300-cell scope has to learn that nothing was set, not discover later that the
|
|
115
|
+
* boundary they believed in was 200 cells of something else.
|
|
116
|
+
*/
|
|
117
|
+
function setScope(ctx, line) {
|
|
118
|
+
const port = ctx.controller;
|
|
119
|
+
if (typeof port.setRedTeamScope !== 'function') {
|
|
120
|
+
ctx.notify('warn', REDTEAM_TOAST.unavailable);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const result = port.setRedTeamScope(line);
|
|
124
|
+
if (!result.ok) {
|
|
125
|
+
ctx.notify('warn', result.reason === 'too-long'
|
|
126
|
+
? REDTEAM_COMMAND.scopeTooLong
|
|
127
|
+
: REDTEAM_COMMAND.scopeMultiLine);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
ctx.notify('info', result.scope === null
|
|
131
|
+
? REDTEAM_TOAST.scopeCleared
|
|
132
|
+
: `${REDTEAM_COMMAND.scopeSetPrefix}${result.scope}`);
|
|
133
|
+
}
|
|
134
|
+
/** Registered from `builtins.ts` with one line, next to every other subsystem. */
|
|
135
|
+
export function registerRedTeamCommand(registry) {
|
|
136
|
+
registry.register({
|
|
137
|
+
name: 'redteam',
|
|
138
|
+
description: 'Red team mode: /redteam [status|on|off|scope <one line>]',
|
|
139
|
+
run: (ctx) => { runRedTeamCommand(ctx); },
|
|
140
|
+
});
|
|
141
|
+
}
|
|
@@ -15,6 +15,7 @@ import type { SessionCommandPort } from './session-command.js';
|
|
|
15
15
|
import type { BranchCommandPort } from './branch-command.js';
|
|
16
16
|
import type { PromptCommandPort } from '@aragon-agent/tui/model/prompts/types';
|
|
17
17
|
import type { MemoryCommandPort } from '@aragon-agent/tui/model/memory/types';
|
|
18
|
+
import type { GeneCommandHost } from '../gene/command.js';
|
|
18
19
|
export interface CommandContext {
|
|
19
20
|
/** App-owned shared lock and single feedback path for command and selection copies. */
|
|
20
21
|
requestCopy?: (request: CopyRequest) => Promise<CopyRequestResult>;
|
|
@@ -194,6 +195,13 @@ export interface CommandContext {
|
|
|
194
195
|
* constructed by literal in dozens of fixtures. TYPE-ONLY import: the command needs the SHAPE.
|
|
195
196
|
*/
|
|
196
197
|
memory?: MemoryCommandPort;
|
|
198
|
+
/**
|
|
199
|
+
* The Gene Bank's host (gene-bank spec 16.3): the manager over this session's library, the live
|
|
200
|
+
* status and curator switch, the two persisted switches and "open the overlay". OPTIONAL for the
|
|
201
|
+
* reason `prompts` above records - `CommandContext` is constructed by literal in dozens of
|
|
202
|
+
* fixtures. Absent means a headless or sub-agent session, and `/gene` says so.
|
|
203
|
+
*/
|
|
204
|
+
gene?: GeneCommandHost;
|
|
197
205
|
/**
|
|
198
206
|
* The task label's three capabilities (`/keys`, `/task`; tui-shortcut-drawer-and-
|
|
199
207
|
* task-summary §6.4).
|
|
@@ -174,6 +174,16 @@ export declare function getGovernanceDir(): string;
|
|
|
174
174
|
* The caller creates it (0700 on POSIX); this function only names it.
|
|
175
175
|
*/
|
|
176
176
|
export declare function getMemoryDir(): string;
|
|
177
|
+
/**
|
|
178
|
+
* `<home>/genes` - the Gene Bank (gene-bank spec 6.8).
|
|
179
|
+
*
|
|
180
|
+
* ITS OWN ROOT, for the reason `getMemoryDir` records. Derived from the same
|
|
181
|
+
* `resolution.root`, so the `ARAGON_HOME` / VITEST isolation contract at the top of this file
|
|
182
|
+
* covers it too: a test that clears `getGeneDir()` recursively would be deleting a real
|
|
183
|
+
* user's library, so tests delete directories they built themselves. The caller creates it
|
|
184
|
+
* (0700 on POSIX); this function only names it.
|
|
185
|
+
*/
|
|
186
|
+
export declare function getGeneDir(): string;
|
|
177
187
|
/** `<home>` — parent of `skills/`, and where sidecar state such as usage lives. */
|
|
178
188
|
export declare function getUserDataDir(): string;
|
|
179
189
|
export declare function getUserSkillsDir(): string;
|
package/dist/config/app-paths.js
CHANGED
|
@@ -269,6 +269,18 @@ export function getGovernanceDir() {
|
|
|
269
269
|
export function getMemoryDir() {
|
|
270
270
|
return join(resolution.root, 'memory');
|
|
271
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* `<home>/genes` - the Gene Bank (gene-bank spec 6.8).
|
|
274
|
+
*
|
|
275
|
+
* ITS OWN ROOT, for the reason `getMemoryDir` records. Derived from the same
|
|
276
|
+
* `resolution.root`, so the `ARAGON_HOME` / VITEST isolation contract at the top of this file
|
|
277
|
+
* covers it too: a test that clears `getGeneDir()` recursively would be deleting a real
|
|
278
|
+
* user's library, so tests delete directories they built themselves. The caller creates it
|
|
279
|
+
* (0700 on POSIX); this function only names it.
|
|
280
|
+
*/
|
|
281
|
+
export function getGeneDir() {
|
|
282
|
+
return join(resolution.root, 'genes');
|
|
283
|
+
}
|
|
272
284
|
/** `<home>` — parent of `skills/`, and where sidecar state such as usage lives. */
|
|
273
285
|
export function getUserDataDir() {
|
|
274
286
|
return resolution.root;
|