@aragon-agent/cli 0.6.54 → 0.6.55
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 +26 -0
- package/README.md +4111 -4042
- package/dist/agent/controller.d.ts +72 -0
- package/dist/agent/controller.js +212 -0
- 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 +13 -0
- package/dist/agent/system-prompt.js +7 -0
- package/dist/app/App.d.ts +10 -1
- package/dist/app/App.js +133 -22
- package/dist/app/use-redteam-mode.d.ts +56 -0
- package/dist/app/use-redteam-mode.js +121 -0
- package/dist/cli.js +53 -3
- package/dist/commands/builtins.js +39 -1
- package/dist/commands/catalog.js +4 -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/config/env.d.ts +2 -1
- package/dist/config/env.js +12 -1
- package/dist/config/load.d.ts +12 -0
- package/dist/config/load.js +10 -1
- package/dist/config/redteam-launch.d.ts +77 -0
- package/dist/config/redteam-launch.js +58 -0
- package/dist/config/store.js +11 -1
- package/dist/config/ui-state.d.ts +44 -0
- package/dist/config/ui-state.js +38 -0
- package/dist/host/controller-factory.d.ts +8 -0
- package/dist/host/controller-factory.js +7 -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 +11 -0
- package/dist/team/runtime.js +6 -0
- package/dist/team/subagent.d.ts +21 -0
- package/dist/team/subagent.js +7 -0
- package/dist/tools/index.d.ts +24 -0
- package/dist/tools/index.js +20 -3
- 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
package/dist/app/App.js
CHANGED
|
@@ -61,6 +61,10 @@ import { advanceBudget, decideFollowThrough, emptyBudget, } from '@aragon-agent/
|
|
|
61
61
|
// no policy. Imported beside the todo decision it shares one timer with.
|
|
62
62
|
import { buildDispatchNudge, decideForcedDispatch, FORCED_NUDGE_NOTICE } from '../team/dispatch-gate.js';
|
|
63
63
|
import { teamToastTtlMs, useTeamMode } from './use-team-mode.js';
|
|
64
|
+
// THE RED TEAM SWITCH (red-team-security-mode 4.3 / 4.8): Ctrl+R, the waiver flow, the
|
|
65
|
+
// deferred arming and the banner. Same adapter shape as `use-team-mode` above.
|
|
66
|
+
import { redTeamToastTtlMs, useRedTeamMode, } from './use-redteam-mode.js';
|
|
67
|
+
import { RedTeamDisclaimerOverlay } from '@aragon-agent/tui/ui/overlays/RedTeamDisclaimerOverlay';
|
|
64
68
|
import { teamStatusFromView } from '@aragon-agent/tui/model/team/team-mode';
|
|
65
69
|
import { FORCED_NUDGE_GRACE_MS } from '@aragon-agent/tui/model/team/limits';
|
|
66
70
|
import { useTerminalSize } from '@aragon-agent/tui/ui/layout/useTerminalSize';
|
|
@@ -251,7 +255,7 @@ function lastUserText(entries) {
|
|
|
251
255
|
}
|
|
252
256
|
return '';
|
|
253
257
|
}
|
|
254
|
-
export function App({ controller, version, initialOverlay, initialPrompt, confirmBridge, humanInputBridge, mouseSource, vtInputWarning, updateBridge, pasteBridge, terminal, scrollMode = 'app', scrollback, initialEntries, session, sessionBridge, sessionNotice, }) {
|
|
258
|
+
export function App({ controller, version, initialOverlay, initialPrompt, confirmBridge, humanInputBridge, mouseSource, vtInputWarning, updateBridge, pasteBridge, terminal, scrollMode = 'app', scrollback, initialEntries, session, sessionBridge, sessionNotice, redTeamNotice, }) {
|
|
255
259
|
const native = scrollMode === 'native' && scrollback !== undefined;
|
|
256
260
|
/** Set when the native writer swallowed repeated tall frames; cleared by a resize. */
|
|
257
261
|
const [guardTripped, setGuardTripped] = useState(false);
|
|
@@ -648,6 +652,59 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
648
652
|
});
|
|
649
653
|
const teamKeysRef = useRef(teamKeys);
|
|
650
654
|
teamKeysRef.current = teamKeys;
|
|
655
|
+
// THE RED TEAM SWITCH (red-team-security-mode): Ctrl+R, the waiver flow and the deferred
|
|
656
|
+
// arming at `agent_end`. Same shape as `teamKeys` above, same reason: the controller owns the
|
|
657
|
+
// state, this hook is the adapter, and `App` only routes keys and props.
|
|
658
|
+
const redTeam = useRedTeamMode({
|
|
659
|
+
controller,
|
|
660
|
+
pushToast: (level, text) => dispatch({
|
|
661
|
+
type: 'pushToast', level, text, ttlMs: redTeamToastTtlMs(level),
|
|
662
|
+
}),
|
|
663
|
+
pushNotice: (level, text) => dispatch({ type: 'notice', level, text }),
|
|
664
|
+
openDisclaimer: () => dispatch({ type: 'setOverlay', overlay: 'redteam-disclaimer' }),
|
|
665
|
+
canAct: () => !stateRef.current.overlay,
|
|
666
|
+
});
|
|
667
|
+
const redTeamRef = useRef(redTeam);
|
|
668
|
+
redTeamRef.current = redTeam;
|
|
669
|
+
/**
|
|
670
|
+
* DECISIONS THAT ARRIVED WHILE THE WAIVER WAS OPEN (4.3 / D-21).
|
|
671
|
+
*
|
|
672
|
+
* `overlay` is a single field, so a `confirm` / `question` / `plan` request would REPLACE the
|
|
673
|
+
* waiver - and a disclaimer read halfway through is a blind signature. These are queued here
|
|
674
|
+
* and replayed once it settles. The queue is a ref because it must not re-render the
|
|
675
|
+
* transcript, and it is drained in `settleDisclaimer` below.
|
|
676
|
+
*/
|
|
677
|
+
const queuedDecisions = useRef([]);
|
|
678
|
+
const queueWhileWaiverOpen = useCallback((show) => {
|
|
679
|
+
if (stateRef.current.overlay !== 'redteam-disclaimer')
|
|
680
|
+
return false;
|
|
681
|
+
queuedDecisions.current.push(show);
|
|
682
|
+
return true;
|
|
683
|
+
}, []);
|
|
684
|
+
const drainQueuedDecisions = useCallback(() => {
|
|
685
|
+
const queued = queuedDecisions.current;
|
|
686
|
+
queuedDecisions.current = [];
|
|
687
|
+
for (const show of queued)
|
|
688
|
+
show();
|
|
689
|
+
}, []);
|
|
690
|
+
/**
|
|
691
|
+
* THE WAIVER SETTLED (4.3). `overlay` closes FIRST, then the record is written, then the
|
|
692
|
+
* queued decisions are replayed - in that order, so a `confirm` that arrived during the
|
|
693
|
+
* disclaimer can own the screen the moment it is free.
|
|
694
|
+
*
|
|
695
|
+
* Accepting re-issues the request that opened the overlay (`toggle` stays a toggle), which is
|
|
696
|
+
* the hook's job; this function only owns the ORDER of the App-side effects.
|
|
697
|
+
*/
|
|
698
|
+
const acceptRedTeamWaiver = useCallback(() => {
|
|
699
|
+
dispatch({ type: 'setOverlay', overlay: null });
|
|
700
|
+
redTeamRef.current.acceptDisclaimer();
|
|
701
|
+
drainQueuedDecisions();
|
|
702
|
+
}, [drainQueuedDecisions]);
|
|
703
|
+
const declineRedTeamWaiver = useCallback(() => {
|
|
704
|
+
dispatch({ type: 'setOverlay', overlay: null });
|
|
705
|
+
redTeamRef.current.declineDisclaimer();
|
|
706
|
+
drainQueuedDecisions();
|
|
707
|
+
}, [drainQueuedDecisions]);
|
|
651
708
|
/**
|
|
652
709
|
* Disarm an armed continuation. Idempotent; NEVER touches the budget — a
|
|
653
710
|
* cancelled continuation was never issued, so it must not be charged (AC-18).
|
|
@@ -891,6 +948,10 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
891
948
|
// read its basis (I-9). The posture lands next: a pending GOVERN entry that
|
|
892
949
|
// arrives with it is reported by the same toast channel, not silently swallowed.
|
|
893
950
|
teamKeysRef.current.onTurnEnd();
|
|
951
|
+
// The same for red team mode: an arming asked for during the turn lands NOW, and the
|
|
952
|
+
// banner is printed here so the user learns the posture before the next message
|
|
953
|
+
// (red-team-security-mode D-12 / 4.6).
|
|
954
|
+
redTeamRef.current.onTurnEnd();
|
|
894
955
|
// A deferred `plan -> build` (or any posture change that waited for a governed
|
|
895
956
|
// stage, governance-mode D-23) becomes real here and nowhere else (§3.2).
|
|
896
957
|
const applied = controller.applyPendingPosture();
|
|
@@ -1206,8 +1267,16 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
1206
1267
|
if (!confirmBridge)
|
|
1207
1268
|
return;
|
|
1208
1269
|
confirmBridge.handler = (req) => new Promise((resolve) => {
|
|
1209
|
-
|
|
1210
|
-
|
|
1270
|
+
const show = () => {
|
|
1271
|
+
setConfirmState({ summary: req.summary, resolve });
|
|
1272
|
+
dispatch({ type: 'setOverlay', overlay: 'confirm' });
|
|
1273
|
+
};
|
|
1274
|
+
// THE WAIVER IS NOT INTERRUPTED (D-21 / RV-10): a confirm arriving while the disclaimer
|
|
1275
|
+
// is open is QUEUED, not shown, and replayed once it settles. Reading half a liability
|
|
1276
|
+
// waiver and then signing it is the one failure this overlay cannot have.
|
|
1277
|
+
if (queueWhileWaiverOpen(show))
|
|
1278
|
+
return;
|
|
1279
|
+
show();
|
|
1211
1280
|
});
|
|
1212
1281
|
return () => {
|
|
1213
1282
|
// The skill ApprovalGate reads `handler !== null` LIVE on every call, so
|
|
@@ -1230,11 +1299,18 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
1230
1299
|
// Without this listener both ceilings are gone at once and the process
|
|
1231
1300
|
// wedges behind an overlay nobody is going to answer (P0-2).
|
|
1232
1301
|
signal?.addEventListener('abort', () => settleHuman(entry, null), { once: true });
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1302
|
+
const show = () => {
|
|
1303
|
+
setHumanRequest(req);
|
|
1304
|
+
dispatch({
|
|
1305
|
+
type: 'setOverlay',
|
|
1306
|
+
overlay: req.kind === 'plan' ? 'plan' : 'question',
|
|
1307
|
+
});
|
|
1308
|
+
};
|
|
1309
|
+
// QUEUED BEHIND THE WAIVER, exactly like the confirm bridge above (D-21). The request
|
|
1310
|
+
// itself is already registered, so its own abort listener still fires while it waits.
|
|
1311
|
+
if (queueWhileWaiverOpen(show))
|
|
1312
|
+
return;
|
|
1313
|
+
show();
|
|
1238
1314
|
});
|
|
1239
1315
|
bridge.cancelPending = cancelPendingHuman;
|
|
1240
1316
|
return () => {
|
|
@@ -1244,7 +1320,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
1244
1320
|
cancelPendingHuman();
|
|
1245
1321
|
bridge.handler = null;
|
|
1246
1322
|
};
|
|
1247
|
-
}, [humanInputBridge, settleHuman, cancelPendingHuman]);
|
|
1323
|
+
}, [humanInputBridge, settleHuman, cancelPendingHuman, queueWhileWaiverOpen]);
|
|
1248
1324
|
// --- Seed the mode mirror from its owner, once, on mount. --------------
|
|
1249
1325
|
// `--plan` / `planModeDefault` are resolved before the App exists, so the
|
|
1250
1326
|
// reducer's `'build'` seed would render one wrong frame without this.
|
|
@@ -1462,6 +1538,14 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
1462
1538
|
notify('info', sessionNotice);
|
|
1463
1539
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1464
1540
|
}, []);
|
|
1541
|
+
// THE RESUMED POSTURE (red-team-security-mode 4.10 / I-12). Once, on mount, and only when a
|
|
1542
|
+
// resume had something to say: a session that comes back ARMED must tell the user what posture
|
|
1543
|
+
// they are in before their first message, and one that stayed off has to say why.
|
|
1544
|
+
useEffect(() => {
|
|
1545
|
+
if (redTeamNotice)
|
|
1546
|
+
notify('warn', redTeamNotice);
|
|
1547
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1548
|
+
}, []);
|
|
1465
1549
|
// --- Session bridge: identity write-back (D-15 / 3.12). -------------------
|
|
1466
1550
|
//
|
|
1467
1551
|
// INSTALLED AND CLEARED EXACTLY LIKE `confirmBridge.handler`: the rotation is
|
|
@@ -2686,18 +2770,23 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
2686
2770
|
// both keys so a draft's history and a popup's highlight never also move (I-6).
|
|
2687
2771
|
if (teamKeys.handleKey(input, key))
|
|
2688
2772
|
return;
|
|
2689
|
-
//
|
|
2773
|
+
// Ctrl+R IS THE RED TEAM SWITCH (red-team-security-mode D-1), and the repaint moved to
|
|
2774
|
+
// Alt+R for the reason Ctrl+T moved to Alt+T: legacy encodings deliver the same byte for
|
|
2775
|
+
// Ctrl+R and Ctrl+Shift+R, so a Shift binding would exist only behind keyboard enhancement.
|
|
2690
2776
|
//
|
|
2691
|
-
//
|
|
2692
|
-
//
|
|
2693
|
-
//
|
|
2694
|
-
//
|
|
2777
|
+
// THE REBINDING IS UNCONDITIONAL (RV-11 / I-9): it does not depend on `redteam.enabled`,
|
|
2778
|
+
// `--no-redteam` or `ARAGON_REDTEAM=0`. Whether Ctrl+R repaints must not depend on a config
|
|
2779
|
+
// key; in a session with the chain unregistered the hook simply answers `unavailable` with
|
|
2780
|
+
// one toast per press, and Alt+R below still repaints.
|
|
2695
2781
|
//
|
|
2696
|
-
//
|
|
2697
|
-
//
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2782
|
+
// The overlay guard is the pre-existing one: with an overlay open, this key belongs to
|
|
2783
|
+
// whoever owns the screen (the settings page's own Ctrl+R is "Test connection").
|
|
2784
|
+
if (redTeamRef.current.handleKey(input, key))
|
|
2785
|
+
return;
|
|
2786
|
+
// Alt+R = repaint. TWO BYTE FORMS, exactly like the Alt+T branch below: the `meta` flag Ink
|
|
2787
|
+
// sets after stripping the ESC, AND the raw `ESC r` that some stacks deliver whole. Handling
|
|
2788
|
+
// only the first would make the recovery key dead on exactly those stacks.
|
|
2789
|
+
if ((key.meta && !key.ctrl && input.toLowerCase() === 'r') || input === '\x1br') {
|
|
2701
2790
|
if (stateRef.current.overlay)
|
|
2702
2791
|
return;
|
|
2703
2792
|
setRedrawNonce((n) => n + 1);
|
|
@@ -2806,6 +2895,13 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
2806
2895
|
// and nothing else could close it.
|
|
2807
2896
|
if (overlay === 'memory' && memoryPort)
|
|
2808
2897
|
return;
|
|
2898
|
+
// THE WAIVER'S `Esc` (4.3). App owns the key for the plan overlays and for this one, so
|
|
2899
|
+
// declining and draining the queue happen in ONE place - the overlay registers no Escape
|
|
2900
|
+
// handler of its own, and a second one would decline twice.
|
|
2901
|
+
if (overlay === 'redteam-disclaimer') {
|
|
2902
|
+
declineRedTeamWaiver();
|
|
2903
|
+
return;
|
|
2904
|
+
}
|
|
2809
2905
|
if (overlay) {
|
|
2810
2906
|
cancelConfirmation();
|
|
2811
2907
|
if (overlay === 'confirm' && confirmRef.current) {
|
|
@@ -3192,7 +3288,11 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3192
3288
|
// already disabled the transcript underneath.
|
|
3193
3289
|
_jsx(AgentsBoardOverlay, { voice: voice, team: state.team, entries: state.entries, cols: viewCols, maxRows: overlayMaxRows, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, isActive: !tooSmall, native: native, theme: theme, caps: caps })) : overlay === 'governance' ? (
|
|
3194
3290
|
// THE BRANCH AND THE `Overlay` MEMBER SHIP TOGETHER (R-11), like `agents` above.
|
|
3195
|
-
_jsx(GovernanceBoardOverlay, { voice: voice, data: governanceBoardData(controller, state.governance), cols: viewCols, maxRows: overlayMaxRows, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, isActive: !tooSmall, theme: theme, caps: caps, onCopyPath: (path) => { void copyCoordinator.requestCopy({ text: path, lines: 1 }); }, onNotice: toast })) : overlay === '
|
|
3291
|
+
_jsx(GovernanceBoardOverlay, { voice: voice, data: governanceBoardData(controller, state.governance), cols: viewCols, maxRows: overlayMaxRows, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, isActive: !tooSmall, theme: theme, caps: caps, onCopyPath: (path) => { void copyCoordinator.requestCopy({ text: path, lines: 1 }); }, onNotice: toast })) : overlay === 'redteam-disclaimer' ? (
|
|
3292
|
+
// THE WAIVER (red-team-security-mode 4.3). Rendered from the reducer's overlay field like
|
|
3293
|
+
// every other surface, so it cannot be open at the same time as a decision dialog - the
|
|
3294
|
+
// requests that would have replaced it are queued in `queuedDecisions` instead (D-21).
|
|
3295
|
+
_jsx(RedTeamDisclaimerOverlay, { isActive: !tooSmall, cols: viewCols, maxRows: overlayMaxRows, theme: theme, caps: caps, onAccept: acceptRedTeamWaiver, onDecline: declineRedTeamWaiver })) : overlay === 'confirm' && confirmState ? (_jsx(ConfirmDialog, { isActive: !tooSmall, state: confirmState, maxRows: overlayMaxRows, cols: viewCols, theme: theme, caps: caps, onClose: closeConfirm })) : overlay === 'question' && humanRequest?.kind === 'questions' ? (_jsx(QuestionOverlay, { isActive: !tooSmall, questions: humanRequest.questions, maxRows: overlayMaxRows, cols: viewCols, theme: theme, caps: caps, onSubmit: (answers) => resolveHuman({ kind: 'answers', answers, cancelled: false }), ...interviewProps })) : overlay === 'plan' && humanRequest?.kind === 'plan' ? (_jsx(PlanReviewOverlay, { isActive: !tooSmall, plan: humanRequest.plan, maxRows: overlayMaxRows, cols: viewCols, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, theme: theme, caps: caps, onVerdict: handlePlanVerdict })) : null;
|
|
3196
3296
|
const density = cfg.density;
|
|
3197
3297
|
const transcriptWindow = cfg.transcriptWindow ?? DEFAULT_TRANSCRIPT_WINDOW;
|
|
3198
3298
|
// The fixed status bar remains visible underneath every overlay and toast.
|
|
@@ -3319,6 +3419,12 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3319
3419
|
// needs the second status row was decided once, above, by `acceptanceChip`.
|
|
3320
3420
|
...(acceptanceActive ? { acceptanceActive } : {}),
|
|
3321
3421
|
fastActive: state.fast?.live ? { inFlight: state.fast.inFlight } : undefined,
|
|
3422
|
+
// THE DETAILS-ROW LINE (4.7 c): `Red team armed; confirmations off` or
|
|
3423
|
+
// `Red team paused (...)`. Read from the same view the chip reads, so the two surfaces
|
|
3424
|
+
// cannot describe one posture differently (I-10).
|
|
3425
|
+
...(redTeam.view.available && redTeam.view.armed
|
|
3426
|
+
? { redteam: { armed: redTeam.view.armed, paused: redTeam.view.paused } }
|
|
3427
|
+
: {}),
|
|
3322
3428
|
...feedbackProjection,
|
|
3323
3429
|
};
|
|
3324
3430
|
const details = planStatusDetail({ status: statusInput, model: cfg.model, provider: cfg.provider,
|
|
@@ -3330,7 +3436,10 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3330
3436
|
...(state.governance?.pauseRequested === true ? { govPausePending: true } : {}),
|
|
3331
3437
|
interruptPhase: interruptGesture.current.phase,
|
|
3332
3438
|
updateAvailable: !!updateSnapshot && shouldRenderUpdateLine(updateSnapshot) } });
|
|
3333
|
-
const composer = (_jsx(Composer, { deleteDisambiguated: terminal?.deleteDisambiguated ?? false, onCompletionContextChange: setCompletion, cols: frameBudget.composerCols, terminalRows: rows, statusExpanded: statusExpanded, onInteraction: returnToComposer, reducedMotion: cfg.reducedMotion ?? false, onEscape: handleComposerEscape, onEscapeDismiss: cancelConfirmation, isActive: overlay === null && !tooSmall, running: state.status === 'running', history: promptHistory, commands: commandOptions, cwd: controller.getCwd(), showHint: false, submitCount: cfg.submitCount, hintsEnabled: cfg.hints, agentMode: state.agentMode, posture: state.posture,
|
|
3439
|
+
const composer = (_jsx(Composer, { deleteDisambiguated: terminal?.deleteDisambiguated ?? false, onCompletionContextChange: setCompletion, cols: frameBudget.composerCols, terminalRows: rows, statusExpanded: statusExpanded, onInteraction: returnToComposer, reducedMotion: cfg.reducedMotion ?? false, onEscape: handleComposerEscape, onEscapeDismiss: cancelConfirmation, isActive: overlay === null && !tooSmall, running: state.status === 'running', history: promptHistory, commands: commandOptions, cwd: controller.getCwd(), showHint: false, submitCount: cfg.submitCount, hintsEnabled: cfg.hints, agentMode: state.agentMode, posture: state.posture,
|
|
3440
|
+
// ARMED AND IN EFFECT, never `armed` alone: a paused session keeps its plan / govern
|
|
3441
|
+
// colour, because `paused` has one definition and this prop does not re-derive it (4.7 b).
|
|
3442
|
+
redTeamActive: redTeam.view.effective === 'armed', services: liveServices, modeToggleKey: modeToggleKey, popupMaxRows: popupMaxRows, popupMaxHeight: frameBudget.popupMaxHeight, onPopupRowsChange: onPopupRowsChange, onDraftRows: onDraftRows, onDraftPresence: onDraftPresence, draftClearNonce: draftClearNonce, draftTextRef: draftTextRef, ...(draftFill ? { draftFill } : {}), insertMode: cfg.prompts?.insertMode ?? 'insert', onNotice: notify, theme: theme, caps: caps, onSubmit: handleSubmit, onHelp: () => dispatch({ type: 'setOverlay', overlay: 'help' }) }));
|
|
3334
3443
|
const team = governanceLayout ? (_jsx(GovernancePanel, { layout: governanceLayout, theme: theme, caps: caps })) : state.team ? (_jsx(TeamPanel, { snapshot: state.team, layout: teamLayout, rows: rows, cols: contentCols, reducedMotion: viewReducedMotion, voice: teamVoice, theme: theme, caps: caps })) : null;
|
|
3335
3444
|
// --- Native panel band (release-gate-and-native-panels §6.3/§6.4) -------------
|
|
3336
3445
|
//
|
|
@@ -3356,7 +3465,9 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3356
3465
|
const rail = fullscreenRailVisible && state.todos ? (_jsx(TodoPanel, { snapshot: state.todos, width: railWidth, rows: railRows, running: running, reducedMotion: viewReducedMotion, theme: theme, caps: caps })) : null;
|
|
3357
3466
|
const viewport = (_jsxs(ScrollViewport, { active: overlay === null && !tooSmall, overlay: overlayNode, footer: _jsxs(_Fragment, { children: [team, _jsx(QueuePanel, { layout: queueLayout, theme: theme })] }), rail: rail, scrollbar: terminal?.scrollbar, resetKey: scrollResetKey, intent: scrollIntent, pinToBottomNonce: pinToBottomNonce, onScrolledLinesChange: setScrolledLines, onViewportShiftChange: onViewportShiftChange, onGeometryChange: onGeometryChange, geometryKey: `${rows}:${cols}:${viewportBudget}:${frameBudget.composerSlotRows}:${frameBudget.statusRows}:${contentCols}:${overlay}:${tooSmall}`, tailRowsRef: tailSink, hold: selectionHold, resumeMs: cfg.scrollResumeMs, showScrollIndicator: true, cols: contentCols, theme: theme, caps: caps, children: [opener, _jsx(TranscriptList, { entries: transcriptEntries, expandedToolIds: state.expandedToolIds, thinkingVisible: state.thinkingVisible, reducedMotion: viewReducedMotion, voice: voice, density: density, nowSec: nowSec, theme: theme, caps: caps, windowSize: transcriptWindow, cols: contentCols, heights: heights, mountedSink: mountedCount, tailSink: tailSink })] }));
|
|
3358
3467
|
const detailsNode = _jsx(BottomStatusRow, { plan: details, columns: viewCols, theme: theme });
|
|
3359
|
-
const statusNode = (_jsx(StatusBar, { columns: viewCols, speedKnown: speedKnown, ...feedbackProjection, interruptPhase: interruptGesture.current.phase, pendingSteering: state.pendingSteering, runPhase: state.runPhase, activeTool: state.activeTool, ...(wait ? { wait } : {}), runOutcome: state.runOutcome, reducedMotion: reducedMotion, ...(sessionId ? { sessionId } : {}), developerMode: state.developerMode, ...(kitChip ? { kit: kitChip } : {}), ...(memoryChip ? { memory: memoryChip } : {}),
|
|
3468
|
+
const statusNode = (_jsx(StatusBar, { columns: viewCols, speedKnown: speedKnown, ...feedbackProjection, interruptPhase: interruptGesture.current.phase, pendingSteering: state.pendingSteering, runPhase: state.runPhase, activeTool: state.activeTool, ...(wait ? { wait } : {}), runOutcome: state.runOutcome, reducedMotion: reducedMotion, ...(sessionId ? { sessionId } : {}), developerMode: state.developerMode, ...(kitChip ? { kit: kitChip } : {}), ...(memoryChip ? { memory: memoryChip } : {}), ...(redTeam.view.available && redTeam.view.armed
|
|
3469
|
+
? { redteam: { armed: redTeam.view.armed, paused: redTeam.view.paused } }
|
|
3470
|
+
: {}), waitingForConfirmation: !!humanRequest || !!confirmState, stopping: interruptGesture.current.phase === 'stopping', interruptHint: interruptGesture.current.phase === 'stopping'
|
|
3360
3471
|
? 'Esc force-stop' : 'Esc x2 interrupt', model: cfg.model, provider: cfg.provider, usageTotal: state.usageTotal,
|
|
3361
3472
|
// ONE OBJECT INSTEAD OF FOUR PARALLEL PROPS (§4.3). The four were a
|
|
3362
3473
|
// projection of "many sources of truth" into the props layer, and a
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { type RedTeamRequest } from '@aragon-agent/tui/model/redteam/redteam-mode';
|
|
18
|
+
import type { RedTeamView } from '@aragon-agent/tui/model/redteam/types';
|
|
19
|
+
import type { AgentController } from '../agent/controller.js';
|
|
20
|
+
/** The slice of Ink's `Key` this hook reads; structural so tests need not import Ink. */
|
|
21
|
+
export interface RedTeamKeyLike {
|
|
22
|
+
ctrl: boolean;
|
|
23
|
+
meta: boolean;
|
|
24
|
+
shift: boolean;
|
|
25
|
+
}
|
|
26
|
+
export type RedTeamToastLevel = 'info' | 'warn';
|
|
27
|
+
export type RedTeamControllerPort = Partial<Pick<AgentController, 'getRedTeamView' | 'setRedTeam' | 'applyPendingRedTeam' | 'subscribeRedTeam' | 'acceptRedTeamWaiver' | 'getRedTeamBanner' | 'getRedTeamScope' | 'getConfig'>>;
|
|
28
|
+
export interface UseRedTeamModeArgs {
|
|
29
|
+
controller: RedTeamControllerPort;
|
|
30
|
+
/** App supplies the toast with the right ttl for the level. */
|
|
31
|
+
pushToast(level: RedTeamToastLevel, text: string): void;
|
|
32
|
+
/** A full-width transcript line: the banner and the resume notice go here, not into a toast. */
|
|
33
|
+
pushNotice?(level: RedTeamToastLevel, text: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Open the waiver overlay. App owns `overlay`, and a `refusal: 'disclaimer'` is exactly the
|
|
36
|
+
* outcome that must NOT be answered with a toast alone (4.3).
|
|
37
|
+
*/
|
|
38
|
+
openDisclaimer(): void;
|
|
39
|
+
/** A decision overlay is open, so a key must not fight it (I-7 / D-21). */
|
|
40
|
+
canAct(): boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface UseRedTeamMode {
|
|
43
|
+
view: RedTeamView;
|
|
44
|
+
request(req: RedTeamRequest): void;
|
|
45
|
+
/** True when the key was Ctrl+R and has been consumed. */
|
|
46
|
+
handleKey(input: string, key: RedTeamKeyLike): boolean;
|
|
47
|
+
/** Call at `agent_end`: lands an arming asked for during the turn, and pushes the banner. */
|
|
48
|
+
onTurnEnd(): void;
|
|
49
|
+
/** The waiver was accepted: record it and re-issue the arming. */
|
|
50
|
+
acceptDisclaimer(): void;
|
|
51
|
+
/** The waiver was declined: nothing is recorded, nothing is armed. */
|
|
52
|
+
declineDisclaimer(): void;
|
|
53
|
+
}
|
|
54
|
+
/** How long each level stays on screen. Refusals are longer: they have to be read. */
|
|
55
|
+
export declare function redTeamToastTtlMs(level: RedTeamToastLevel): number;
|
|
56
|
+
export declare function useRedTeamMode(args: UseRedTeamModeArgs): UseRedTeamMode;
|
|
@@ -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,6 +13,8 @@ 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 { checkRedTeamCommandLine } from './config/redteam-launch.js';
|
|
17
|
+
import { getRedTeamWaiverVersion, isRedTeamEnvOff } from './config/ui-state.js';
|
|
16
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, 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';
|
|
@@ -216,6 +218,12 @@ function toFlags(opts) {
|
|
|
216
218
|
// defaults `opts.memory` to `true` when it is absent, so only an explicit `false` is
|
|
217
219
|
// forwarded and silence can never read as an override.
|
|
218
220
|
memory: opts.memory === false ? false : undefined,
|
|
221
|
+
// Site three of three for the red team pair. BOTH are forwarded, and both are tri-state:
|
|
222
|
+
// `--redteam` absent is `undefined` (no arming), `--no-redteam` absent is `undefined` (no
|
|
223
|
+
// kill switch). Forwarding silence as `false` here would unregister the chain for every run
|
|
224
|
+
// that passed no flag at all.
|
|
225
|
+
redteam: opts.redteam === true ? true : undefined,
|
|
226
|
+
noRedteam: opts.redteam === false ? true : undefined,
|
|
219
227
|
// Site three of three for `--resume` / `--save` -- ELEVEN features, one trap
|
|
220
228
|
// (`mouse` P1-2, `team` P1-4, `todo` C-9, render L4, retry, fast, update,
|
|
221
229
|
// compaction, now session identity). A flag needs the `.option()`
|
|
@@ -394,11 +402,17 @@ async function runInteractive(flags, extras = {}) {
|
|
|
394
402
|
// MUTABLE BECAUSE `/resume` ROTATES IT (D-15). The chip follows through the
|
|
395
403
|
// App's `onIdentity`, and the writer reads `parentId` from here on every write.
|
|
396
404
|
let identity = startup.identity;
|
|
397
|
-
const { controller, confirmBridge, humanInputBridge } = makeController(flags
|
|
405
|
+
const { controller, confirmBridge, humanInputBridge } = makeController(flags, {
|
|
406
|
+
interactive: true,
|
|
407
|
+
// THE ONE LAUNCH PATH THAT MAY START ARMED (4.8). `flags.redteam` is already tri-state and
|
|
408
|
+
// the `preAction` hook has already refused the two impossible combinations, so this is a
|
|
409
|
+
// plain boolean by here - and it is absent for `-p` / `exec` / every subcommand (I-1).
|
|
410
|
+
...(flags.redteam === true ? { redTeamArmed: true } : {}),
|
|
411
|
+
});
|
|
398
412
|
// THE RESTORE HAPPENS BEFORE THE FIRST FRAME. `initialEntries` seeds the
|
|
399
413
|
// reducer, so a resumed transcript is complete on frame one instead of filling
|
|
400
414
|
// in behind the user's eyes.
|
|
401
|
-
startup.apply(controller);
|
|
415
|
+
const redTeamResumeNotice = startup.apply(controller);
|
|
402
416
|
void controller.refreshModelMetadata();
|
|
403
417
|
const config = controller.getConfig();
|
|
404
418
|
const caps = resolveTuiCapabilities({}, config.color);
|
|
@@ -1128,7 +1142,7 @@ async function runInteractive(flags, extras = {}) {
|
|
|
1128
1142
|
vtInputWarning: vtInputSupported ? undefined : { nodeVersion: process.versions.node }, updateBridge: updateEligible ? updateBridge : undefined,
|
|
1129
1143
|
// Absent when nothing can refuse a paste, so a `--no-paste` tree is
|
|
1130
1144
|
// 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 } : {}) }),
|
|
1145
|
+
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
1146
|
// Full-screen owns console.* itself (I-4): Ink's patchConsole writes
|
|
1133
1147
|
// straight to stdout and permanently shifts the fixed frame's accounting.
|
|
1134
1148
|
{
|
|
@@ -2097,6 +2111,16 @@ function buildProgram() {
|
|
|
2097
2111
|
// Negative-only for the reason `--no-governance` records: it can only ever switch the
|
|
2098
2112
|
// feature off for this launch, and `toFlags` forwards it only when explicitly given.
|
|
2099
2113
|
.option('--no-memory', 'Disable agent memory for this launch (no memory tools or prompt block; not persisted)')
|
|
2114
|
+
// RED TEAM / SECURITY MODE (red-team-security-mode 4.8). The pair is declared POSITIVE FIRST
|
|
2115
|
+
// for the tri-state reason recorded five times above: `redteam.enabled` is persisted and
|
|
2116
|
+
// defaults to `true`, so a negative-only declaration would let commander synthesize `true`
|
|
2117
|
+
// and overwrite a stored `false` on every run that passed no flag at all.
|
|
2118
|
+
//
|
|
2119
|
+
// `--redteam` additionally means "start this session ARMED", which `validateRedTeamLaunch`
|
|
2120
|
+
// refuses in headless mode and before the waiver is accepted - both are cases where nobody
|
|
2121
|
+
// could accept it, and an armed session nobody can leave is worse than no armed session.
|
|
2122
|
+
.option('--redteam', 'Start this session in red team / security mode (needs the waiver accepted)')
|
|
2123
|
+
.option('--no-redteam', 'Disable red team mode for this launch (no chip, no key; not persisted)')
|
|
2100
2124
|
.option('--no-skills', 'Disable the skill system entirely (no catalog, no skill tools)')
|
|
2101
2125
|
.option('--skill <name>', 'Force-load a skill at Level 2 for this run (repeatable)', (value, previous = []) => [...previous, value])
|
|
2102
2126
|
.option('--skills-yes', 'Approve skill installs for this run (CI / headless)')
|
|
@@ -2176,6 +2200,32 @@ function buildProgram() {
|
|
|
2176
2200
|
process.stderr.write(`${check.message}\n`);
|
|
2177
2201
|
process.exit(2);
|
|
2178
2202
|
});
|
|
2203
|
+
/**
|
|
2204
|
+
* The red team flag rules (red-team-security-mode 4.8), in a `preAction` of their own for the
|
|
2205
|
+
* reason the governance hook above records: root-level options, one place, and it covers
|
|
2206
|
+
* `aragon -p` and `aragon exec` too - which is exactly where `--redteam` must be REFUSED.
|
|
2207
|
+
*
|
|
2208
|
+
* The waiver version is read here rather than in `loadConfig` because it lives in `state.json`
|
|
2209
|
+
* (a machine fact, not a preference) and this is the only code path that may open a terminal.
|
|
2210
|
+
*/
|
|
2211
|
+
program.hook('preAction', (root, action) => {
|
|
2212
|
+
const raw = root.opts();
|
|
2213
|
+
const check = checkRedTeamCommandLine({ ...(raw.redteam === true ? { redteam: true } : {}),
|
|
2214
|
+
...(raw.redteam === false ? { noRedteamFlag: false } : {}) }, {
|
|
2215
|
+
commandName: action.name(),
|
|
2216
|
+
isRootAction: action === root,
|
|
2217
|
+
stdinIsTty: !!process.stdin.isTTY,
|
|
2218
|
+
stdoutIsTty: !!process.stdout.isTTY,
|
|
2219
|
+
}, getRedTeamWaiverVersion(),
|
|
2220
|
+
// READ THE VARIABLE DIRECTLY rather than through `readEnvConfig()`: that function also
|
|
2221
|
+
// registers secrets, and a `preAction` hook must not have that side effect for a question
|
|
2222
|
+
// this small. Only the values the other kill switches accept count, and only "off" is one.
|
|
2223
|
+
raw.redteam === false || isRedTeamEnvOff());
|
|
2224
|
+
if (check.ok)
|
|
2225
|
+
return;
|
|
2226
|
+
process.stderr.write(`${check.message}\n`);
|
|
2227
|
+
process.exit(2);
|
|
2228
|
+
});
|
|
2179
2229
|
// aragon config [set <key> <value> | path]
|
|
2180
2230
|
const configCmd = program
|
|
2181
2231
|
.command('config')
|
|
@@ -33,6 +33,9 @@ import { registerSubagentCommand } from './subagent-command.js';
|
|
|
33
33
|
// and this pair of lines is the whole registration; the `team` entry that used to
|
|
34
34
|
// live in `COMMANDS` above was a CONFIG command and now lives in `Settings > Team`.
|
|
35
35
|
import { registerTeamCommand } from './team-command.js';
|
|
36
|
+
// `/redteam` (red-team-security-mode 4.8): the body is `commands/redteam-command.ts` and this
|
|
37
|
+
// import is the whole registration, the `/team` shape.
|
|
38
|
+
import { registerRedTeamCommand } from './redteam-command.js';
|
|
36
39
|
// THE DRAWER AND THE HEADER LABEL (tui-shortcut-drawer-and-task-summary §4.7):
|
|
37
40
|
// two single-purpose commands in their own modules, registered from here. Both are
|
|
38
41
|
// UNCONDITIONAL, even with `taskSummary.enabled=false`, because they are the only
|
|
@@ -246,6 +249,27 @@ function formatFastStatus(controller) {
|
|
|
246
249
|
`${formatTokens(snapshot.usage.outputTokens)}, cost ${cost}.`);
|
|
247
250
|
return lines.join('\n');
|
|
248
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* The two session-file fields red team mode contributes to a `/save` (4.10).
|
|
254
|
+
*
|
|
255
|
+
* A HELPER RATHER THAN FOUR INLINE LINES because the answer is "the whole object, or nothing":
|
|
256
|
+
* an unarmed session must write NO key, so a `/save` from a session that never used the mode is
|
|
257
|
+
* byte-identical to one written before the feature. `getRedTeamSessionState` is optional on the
|
|
258
|
+
* port (D-17), so a host without the chain simply contributes nothing.
|
|
259
|
+
*/
|
|
260
|
+
function redTeamSaveFields(port) {
|
|
261
|
+
const state = typeof port.getRedTeamSessionState === 'function'
|
|
262
|
+
? port.getRedTeamSessionState()
|
|
263
|
+
: undefined;
|
|
264
|
+
if (state?.armed !== true)
|
|
265
|
+
return {};
|
|
266
|
+
return {
|
|
267
|
+
redTeam: true,
|
|
268
|
+
...(typeof state.waiverVersion === 'number'
|
|
269
|
+
? { redTeamWaiverVersion: state.waiverVersion }
|
|
270
|
+
: {}),
|
|
271
|
+
};
|
|
272
|
+
}
|
|
249
273
|
const COMMANDS = [
|
|
250
274
|
{
|
|
251
275
|
name: 'help',
|
|
@@ -983,6 +1007,9 @@ const COMMANDS = [
|
|
|
983
1007
|
// "not started" that the user had already watched being verified. Read
|
|
984
1008
|
// from the STORE, so a save taken while the capability is off keeps them.
|
|
985
1009
|
acceptance: ctx.controller.getAcceptanceItems(),
|
|
1010
|
+
// The red team posture, so `/save` and the live checkpoint agree about it (4.10). A
|
|
1011
|
+
// disarmed session contributes no key at all, which keeps this file byte-identical.
|
|
1012
|
+
...redTeamSaveFields(ctx.controller),
|
|
986
1013
|
});
|
|
987
1014
|
ctx.notify('info', `Saved session to ${path}`);
|
|
988
1015
|
}
|
|
@@ -1017,7 +1044,11 @@ const COMMANDS = [
|
|
|
1017
1044
|
// live TUI and a no-op at startup, and the second is a VIEW action with
|
|
1018
1045
|
// no controller to hang it on.
|
|
1019
1046
|
ctx.controller.clearAllQueues();
|
|
1020
|
-
|
|
1047
|
+
// The notice is the red team reconciliation (4.10): a session that comes back
|
|
1048
|
+
// DISARMED because the waiver moved has to say so, or the user assumes the mode stuck.
|
|
1049
|
+
const notice = applyRestoredSession(ctx.controller, session);
|
|
1050
|
+
if (notice)
|
|
1051
|
+
ctx.notify('warn', notice);
|
|
1021
1052
|
ctx.dispatch({ type: 'restoreEntries', entries: session.entries });
|
|
1022
1053
|
// A NEW ID, AND A ZEROED COUNTER, IN THAT ORDER (D-15 / D-10 / R-9).
|
|
1023
1054
|
// Without the rotation the next checkpoint would write THIS conversation
|
|
@@ -1374,6 +1405,10 @@ export function registerBuiltinCommands(registry) {
|
|
|
1374
1405
|
// `/gov` (governance-mode 11.3). Unconditional, like `/team` and for the same reason: the
|
|
1375
1406
|
// session where governance cannot run is exactly where a user asks the command why.
|
|
1376
1407
|
registerGovernanceCommand(registry);
|
|
1408
|
+
// `/redteam` (red-team-security-mode 4.8). UNCONDITIONAL, like `/team` and `/gov`: the session
|
|
1409
|
+
// where the mode cannot run (`--no-redteam`) is exactly the session where a user types
|
|
1410
|
+
// `/redteam status` to find out why, so registering it may not read the config or the waiver.
|
|
1411
|
+
registerRedTeamCommand(registry);
|
|
1377
1412
|
// The keyboard drawer (`Ctrl+G` / `/keys`) and the task label (`/task`). Two
|
|
1378
1413
|
// registrations, no new mechanism: `/keys` sets the panel's pre-filter and opens
|
|
1379
1414
|
// the same overlay `Ctrl+G` opens, and `/task` reports what the header cell says.
|
|
@@ -1393,6 +1428,9 @@ export const BUILTIN_COMMAND_NAMES = ['queue', 'prompts', 'agents', 'subagent',
|
|
|
1393
1428
|
// `commands/team-command.ts`), and this array is the documentation/tests surface
|
|
1394
1429
|
// for every built-in name - the `flatMap` below only sees `COMMANDS`.
|
|
1395
1430
|
'team',
|
|
1431
|
+
// `redteam` joins the list for the reason `team` above records: its body lives in
|
|
1432
|
+
// `commands/redteam-command.ts`, so only this array can document it to the tests.
|
|
1433
|
+
'redteam',
|
|
1396
1434
|
'keys', 'task',
|
|
1397
1435
|
...COMMANDS.flatMap((c) => [
|
|
1398
1436
|
c.name,
|