@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
|
@@ -36,6 +36,32 @@ export interface SystemPromptParams {
|
|
|
36
36
|
* pre-memory prompt BYTE FOR BYTE (`memory.enabled: false`, `-p`, and every subagent).
|
|
37
37
|
*/
|
|
38
38
|
memoryBlock?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The stable `<gene_library>` rules block, or `''` / absent (gene-bank spec 9.2, I-2, I-20).
|
|
41
|
+
*
|
|
42
|
+
* POSITION IS THE SEMANTICS: immediately AFTER `memoryBlock` and before the skills catalog.
|
|
43
|
+
* Both are stable prefix text (every sentence of this block is independent of the current
|
|
44
|
+
* task), so they sit together in front of the blocks that change with the mode. The text is a
|
|
45
|
+
* SOURCE CONSTANT built by `buildGeneRulesBlock`; nothing a gene says can reach it.
|
|
46
|
+
*
|
|
47
|
+
* Spliced conditionally exactly as `memoryBlock` is: `gene.enabled: false`, `--no-gene`,
|
|
48
|
+
* `ARAGON_GENE=0`, a session without the gene tools and every caller that passes nothing
|
|
49
|
+
* produce the pre-feature prompt BYTE FOR BYTE for a fixed tool array.
|
|
50
|
+
*/
|
|
51
|
+
geneRulesBlock?: string;
|
|
52
|
+
/**
|
|
53
|
+
* The `<gene_context>` zone of one-line previews, or `''` / absent (gene-bank spec 9.2, RV-2).
|
|
54
|
+
*
|
|
55
|
+
* THE ONE BLOCK THAT CHANGES PER TASK, so it goes AFTER every stable subsystem block (their
|
|
56
|
+
* prefix cache stays warm) and BEFORE `<structured_result>`, `Operating guidance:` and the
|
|
57
|
+
* caller's `## Additional instructions`. It must NEVER move after `appendSystemPrompt`: that
|
|
58
|
+
* section is last so "no CLI-generated content can be read as a correction of the caller's
|
|
59
|
+
* instructions", and `project-guidance-prompt.test.ts` pins the `endsWith` that says so. This
|
|
60
|
+
* zone is automatically generated and the lowest-trust text in the prompt.
|
|
61
|
+
*
|
|
62
|
+
* Empty splices NOTHING (not even a blank line), which keeps the closed state byte-identical.
|
|
63
|
+
*/
|
|
64
|
+
geneContextBlock?: string;
|
|
39
65
|
/**
|
|
40
66
|
* The session's current mode. Absent or `'build'` produces a BYTE-IDENTICAL
|
|
41
67
|
* prompt to the pre-plan-mode output for a fixed `tools` array (I-P1) — the
|
|
@@ -205,6 +231,19 @@ export interface SystemPromptParams {
|
|
|
205
231
|
* Only read when `agentMode` is `'plan'`; absent leaves the plan block unchanged.
|
|
206
232
|
*/
|
|
207
233
|
governAddendum?: string;
|
|
234
|
+
/**
|
|
235
|
+
* The rendered `<redteam_mode>` block, or '' (red-team-security-mode 4.6 / D-7).
|
|
236
|
+
*
|
|
237
|
+
* SPLICED IMMEDIATELY AFTER `buildProjectGuidanceBlock()` AND BEFORE `memoryBlock`, and that
|
|
238
|
+
* position is the argument: this block declares who authorized this session and where the
|
|
239
|
+
* boundary is, so it is the frame that explains the scale of every capability block after
|
|
240
|
+
* it. It also has to come after the base prompt's environment and tool list, because a
|
|
241
|
+
* scope sits on top of a real working directory and a real toolset.
|
|
242
|
+
*
|
|
243
|
+
* CONDITIONAL LIKE EVERY BLOCK ABOVE, which is what makes I-1 true: with the mode off the
|
|
244
|
+
* prompt is byte-identical to the pre-feature text for a fixed tool array.
|
|
245
|
+
*/
|
|
246
|
+
redteamBlock?: string;
|
|
208
247
|
}
|
|
209
248
|
/** Describe the active shell so the model does not emit incompatible syntax. */
|
|
210
249
|
export declare function describeShell(): {
|
|
@@ -33,6 +33,8 @@ export function buildSystemPrompt(params) {
|
|
|
33
33
|
const skillsBlock = params.skillsBlock ?? '';
|
|
34
34
|
const hasSkills = skillsBlock.length > 0;
|
|
35
35
|
const memoryBlock = params.memoryBlock ?? '';
|
|
36
|
+
const geneRulesBlock = params.geneRulesBlock ?? '';
|
|
37
|
+
const geneContextBlock = params.geneContextBlock ?? '';
|
|
36
38
|
const planBlock = params.agentMode === 'plan'
|
|
37
39
|
? buildPlanModeBlock({
|
|
38
40
|
interactive: params.planInteractive !== false,
|
|
@@ -53,6 +55,7 @@ export function buildSystemPrompt(params) {
|
|
|
53
55
|
const jobsBlock = params.jobsBlock ?? '';
|
|
54
56
|
const imageInputBlock = params.imageInputBlock ?? '';
|
|
55
57
|
const structuredResultBlock = params.structuredResultBlock ?? '';
|
|
58
|
+
const redteamBlock = params.redteamBlock ?? '';
|
|
56
59
|
const appended = (params.appendSystemPrompt ?? '').trim();
|
|
57
60
|
return [
|
|
58
61
|
'You are AragonAgent, an autonomous coding assistant operating inside a terminal (TUI).',
|
|
@@ -68,8 +71,18 @@ export function buildSystemPrompt(params) {
|
|
|
68
71
|
// Base-prompt upgrade; optional blocks still preserve empty/absent equivalence.
|
|
69
72
|
'',
|
|
70
73
|
buildProjectGuidanceBlock(),
|
|
74
|
+
// IMMEDIATELY AFTER THE PROJECT GUIDANCE AND BEFORE THE SKILLS CATALOG
|
|
75
|
+
// (red-team-security-mode D-7). This block says WHO authorized this session and WHERE the
|
|
76
|
+
// boundary is; a model that reads "you may do X" first and "the boundary is Y" afterwards
|
|
77
|
+
// has been given the capability before the constraint, which is not how a professional
|
|
78
|
+
// reads an engagement letter. Conditional, so `''` splices nothing (I-1).
|
|
79
|
+
...(redteamBlock ? ['', redteamBlock] : []),
|
|
71
80
|
// AFTER the project guidance and BEFORE the skills catalog (agent-memory D-5).
|
|
72
81
|
...(memoryBlock ? ['', memoryBlock] : []),
|
|
82
|
+
// IMMEDIATELY AFTER the memory block, before the skills catalog (gene-bank 9.2): the second
|
|
83
|
+
// piece of stable, task-independent text. A source constant, so it can carry the authority
|
|
84
|
+
// claim the dynamic zone below relies on.
|
|
85
|
+
...(geneRulesBlock ? ['', geneRulesBlock] : []),
|
|
73
86
|
...(hasSkills ? ['', skillsBlock] : []),
|
|
74
87
|
// AFTER <available_skills> (it refers to it as "above") and BEFORE <plan_mode>
|
|
75
88
|
// (whose step 1 defers to it). Conditional like every other optional block.
|
|
@@ -89,6 +102,11 @@ export function buildSystemPrompt(params) {
|
|
|
89
102
|
...(backgroundBlock ? ['', backgroundBlock] : []),
|
|
90
103
|
...(jobsBlock ? ['', jobsBlock] : []),
|
|
91
104
|
...(imageInputBlock ? ['', imageInputBlock] : []),
|
|
105
|
+
// AFTER every stable subsystem block and the image block, BEFORE the answer-shape block and the
|
|
106
|
+
// operating guidance (gene-bank RV-2). Changing text goes last among the cacheable blocks so a
|
|
107
|
+
// refresh costs the prefix cache only what follows it; it is NOT after the caller's own
|
|
108
|
+
// instructions, which stay the final word.
|
|
109
|
+
...(geneContextBlock ? ['', geneContextBlock] : []),
|
|
92
110
|
// AFTER every subsystem block, BEFORE the caller's own instructions: it describes
|
|
93
111
|
// the shape of the answer, which is the last thing to know before answering, while
|
|
94
112
|
// `## Additional instructions` still has the final word (section 2.3.8).
|
package/dist/app/App.d.ts
CHANGED
|
@@ -112,6 +112,15 @@ export interface AppProps {
|
|
|
112
112
|
* affordance, and a notice on every launch trains users to ignore notices.
|
|
113
113
|
*/
|
|
114
114
|
sessionNotice?: string;
|
|
115
|
+
/**
|
|
116
|
+
* What the red team reconciliation produced when this session was resumed
|
|
117
|
+
* (red-team-security-mode 4.10 / I-12).
|
|
118
|
+
*
|
|
119
|
+
* PRESENT ONLY WHEN A RESUME ACTUALLY SAID SOMETHING: the mode came back armed (and the user
|
|
120
|
+
* has to know the posture they are in before the first message), or it did not because the
|
|
121
|
+
* waiver moved. Absent on an ordinary launch, which is what keeps its first frame identical.
|
|
122
|
+
*/
|
|
123
|
+
redTeamNotice?: string;
|
|
115
124
|
}
|
|
116
125
|
/**
|
|
117
126
|
* `App`'s and `cli.tsx`'s small two-way surface for the session, shaped exactly
|
|
@@ -163,4 +172,4 @@ export interface TerminalBridge {
|
|
|
163
172
|
writeForeign?: (text: string) => void;
|
|
164
173
|
selection?: SelectionBridge;
|
|
165
174
|
}
|
|
166
|
-
export declare function App({ controller, version, initialOverlay, initialPrompt, confirmBridge, humanInputBridge, mouseSource, vtInputWarning, updateBridge, pasteBridge, terminal, scrollMode, scrollback, initialEntries, session, sessionBridge, sessionNotice, }: AppProps): React.ReactElement;
|
|
175
|
+
export declare function App({ controller, version, initialOverlay, initialPrompt, confirmBridge, humanInputBridge, mouseSource, vtInputWarning, updateBridge, pasteBridge, terminal, scrollMode, scrollback, initialEntries, session, sessionBridge, sessionNotice, redTeamNotice, }: AppProps): React.ReactElement;
|
package/dist/app/App.js
CHANGED
|
@@ -8,6 +8,7 @@ import { selectTranscriptEntries, mergePendingEntries } from '@aragon-agent/tui/
|
|
|
8
8
|
* input / toast stack / status bar / overlays.
|
|
9
9
|
*/
|
|
10
10
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from 'react';
|
|
11
|
+
import process from 'node:process';
|
|
11
12
|
import { Text, useApp, useInput, useStdout } from 'ink';
|
|
12
13
|
import { advanceInterruptGesture, INTERRUPT_CONFIRM_MS, cancelInterruptConfirmation, } from '@aragon-agent/tui/input/interrupt-gesture';
|
|
13
14
|
import { initialViewState, viewReducer, } from '@aragon-agent/tui/model/agent/reducer';
|
|
@@ -61,6 +62,10 @@ import { advanceBudget, decideFollowThrough, emptyBudget, } from '@aragon-agent/
|
|
|
61
62
|
// no policy. Imported beside the todo decision it shares one timer with.
|
|
62
63
|
import { buildDispatchNudge, decideForcedDispatch, FORCED_NUDGE_NOTICE } from '../team/dispatch-gate.js';
|
|
63
64
|
import { teamToastTtlMs, useTeamMode } from './use-team-mode.js';
|
|
65
|
+
// THE RED TEAM SWITCH (red-team-security-mode 4.3 / 4.8): Ctrl+R, the waiver flow, the
|
|
66
|
+
// deferred arming and the banner. Same adapter shape as `use-team-mode` above.
|
|
67
|
+
import { redTeamToastTtlMs, useRedTeamMode, } from './use-redteam-mode.js';
|
|
68
|
+
import { RedTeamDisclaimerOverlay } from '@aragon-agent/tui/ui/overlays/RedTeamDisclaimerOverlay';
|
|
64
69
|
import { teamStatusFromView } from '@aragon-agent/tui/model/team/team-mode';
|
|
65
70
|
import { FORCED_NUDGE_GRACE_MS } from '@aragon-agent/tui/model/team/limits';
|
|
66
71
|
import { useTerminalSize } from '@aragon-agent/tui/ui/layout/useTerminalSize';
|
|
@@ -89,6 +94,14 @@ import { INITIAL_MEMORY_STATE, memoryReducer } from '@aragon-agent/tui/ui/overla
|
|
|
89
94
|
import { memoryChipFacts } from '@aragon-agent/tui/ui/layout/memory-chip';
|
|
90
95
|
import { memoryRepairCopy } from '@aragon-agent/tui/model/memory/copy';
|
|
91
96
|
import { takeMemoryRepairNotice } from '../memory/store.js';
|
|
97
|
+
// Gene Bank (gene-bank spec 12): the manager, its state machine (OWNED HERE, RV-11) and the
|
|
98
|
+
// status chip. The overlay is a pure function of the state and a `GeneManagerPort`.
|
|
99
|
+
import { GeneOverlay } from '@aragon-agent/tui/ui/overlays/GeneOverlay';
|
|
100
|
+
import { INITIAL_GENE_STATE, geneReducer, } from '@aragon-agent/tui/ui/overlays/gene-state';
|
|
101
|
+
import { geneKeyLetter, isGeneToggleKey } from '@aragon-agent/tui/ui/overlays/gene-keys';
|
|
102
|
+
import { chipFacts as geneChipFactsOf } from '@aragon-agent/tui/model/gene/activity';
|
|
103
|
+
import { geneHintCopy } from '@aragon-agent/tui/model/gene/copy';
|
|
104
|
+
import { explainAvailableFor } from '../gene/explain.js';
|
|
92
105
|
import { draftToInput } from '@aragon-agent/tui/ui/overlays/prompt-library-state';
|
|
93
106
|
import { createPrompt, deletePrompt, flushPromptStats, loadPromptLibrary, movePrompt, recordPromptUse, setPromptFavorite, takePromptRepairNotice, updatePrompt, } from '../prompts/store.js';
|
|
94
107
|
import { resolvePromptRef } from '../prompts/resolve.js';
|
|
@@ -251,7 +264,7 @@ function lastUserText(entries) {
|
|
|
251
264
|
}
|
|
252
265
|
return '';
|
|
253
266
|
}
|
|
254
|
-
export function App({ controller, version, initialOverlay, initialPrompt, confirmBridge, humanInputBridge, mouseSource, vtInputWarning, updateBridge, pasteBridge, terminal, scrollMode = 'app', scrollback, initialEntries, session, sessionBridge, sessionNotice, }) {
|
|
267
|
+
export function App({ controller, version, initialOverlay, initialPrompt, confirmBridge, humanInputBridge, mouseSource, vtInputWarning, updateBridge, pasteBridge, terminal, scrollMode = 'app', scrollback, initialEntries, session, sessionBridge, sessionNotice, redTeamNotice, }) {
|
|
255
268
|
const native = scrollMode === 'native' && scrollback !== undefined;
|
|
256
269
|
/** Set when the native writer swallowed repeated tall frames; cleared by a resize. */
|
|
257
270
|
const [guardTripped, setGuardTripped] = useState(false);
|
|
@@ -284,6 +297,13 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
284
297
|
const [memoryState, memoryDispatch] = useReducer(memoryReducer, INITIAL_MEMORY_STATE);
|
|
285
298
|
const [memoryIntent, setMemoryIntent] = useState(null);
|
|
286
299
|
const memoryIntentNonce = useRef(0);
|
|
300
|
+
// --- Gene Bank (gene-bank spec 12.2) -----------------------------------------------------
|
|
301
|
+
// THE SAME RULE AS MEMORY ABOVE (RV-11): the page stack and the editor draft live HERE, so an
|
|
302
|
+
// approval the agent asks for while the manager is open (`suspendedOverlay`) cannot destroy a
|
|
303
|
+
// half-written gene.
|
|
304
|
+
const [geneState, geneDispatch] = useReducer(geneReducer, INITIAL_GENE_STATE);
|
|
305
|
+
const [geneIntent, setGeneIntent] = useState(null);
|
|
306
|
+
const geneIntentNonce = useRef(0);
|
|
287
307
|
/** The composer's draft text, kept current by `PromptInput`; read on ONE keypress. */
|
|
288
308
|
const draftTextRef = useRef('');
|
|
289
309
|
/** What the manager was opened with: the draft and the last reply, for `c` and `l`. */
|
|
@@ -648,6 +668,59 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
648
668
|
});
|
|
649
669
|
const teamKeysRef = useRef(teamKeys);
|
|
650
670
|
teamKeysRef.current = teamKeys;
|
|
671
|
+
// THE RED TEAM SWITCH (red-team-security-mode): Ctrl+R, the waiver flow and the deferred
|
|
672
|
+
// arming at `agent_end`. Same shape as `teamKeys` above, same reason: the controller owns the
|
|
673
|
+
// state, this hook is the adapter, and `App` only routes keys and props.
|
|
674
|
+
const redTeam = useRedTeamMode({
|
|
675
|
+
controller,
|
|
676
|
+
pushToast: (level, text) => dispatch({
|
|
677
|
+
type: 'pushToast', level, text, ttlMs: redTeamToastTtlMs(level),
|
|
678
|
+
}),
|
|
679
|
+
pushNotice: (level, text) => dispatch({ type: 'notice', level, text }),
|
|
680
|
+
openDisclaimer: () => dispatch({ type: 'setOverlay', overlay: 'redteam-disclaimer' }),
|
|
681
|
+
canAct: () => !stateRef.current.overlay,
|
|
682
|
+
});
|
|
683
|
+
const redTeamRef = useRef(redTeam);
|
|
684
|
+
redTeamRef.current = redTeam;
|
|
685
|
+
/**
|
|
686
|
+
* DECISIONS THAT ARRIVED WHILE THE WAIVER WAS OPEN (4.3 / D-21).
|
|
687
|
+
*
|
|
688
|
+
* `overlay` is a single field, so a `confirm` / `question` / `plan` request would REPLACE the
|
|
689
|
+
* waiver - and a disclaimer read halfway through is a blind signature. These are queued here
|
|
690
|
+
* and replayed once it settles. The queue is a ref because it must not re-render the
|
|
691
|
+
* transcript, and it is drained in `settleDisclaimer` below.
|
|
692
|
+
*/
|
|
693
|
+
const queuedDecisions = useRef([]);
|
|
694
|
+
const queueWhileWaiverOpen = useCallback((show) => {
|
|
695
|
+
if (stateRef.current.overlay !== 'redteam-disclaimer')
|
|
696
|
+
return false;
|
|
697
|
+
queuedDecisions.current.push(show);
|
|
698
|
+
return true;
|
|
699
|
+
}, []);
|
|
700
|
+
const drainQueuedDecisions = useCallback(() => {
|
|
701
|
+
const queued = queuedDecisions.current;
|
|
702
|
+
queuedDecisions.current = [];
|
|
703
|
+
for (const show of queued)
|
|
704
|
+
show();
|
|
705
|
+
}, []);
|
|
706
|
+
/**
|
|
707
|
+
* THE WAIVER SETTLED (4.3). `overlay` closes FIRST, then the record is written, then the
|
|
708
|
+
* queued decisions are replayed - in that order, so a `confirm` that arrived during the
|
|
709
|
+
* disclaimer can own the screen the moment it is free.
|
|
710
|
+
*
|
|
711
|
+
* Accepting re-issues the request that opened the overlay (`toggle` stays a toggle), which is
|
|
712
|
+
* the hook's job; this function only owns the ORDER of the App-side effects.
|
|
713
|
+
*/
|
|
714
|
+
const acceptRedTeamWaiver = useCallback(() => {
|
|
715
|
+
dispatch({ type: 'setOverlay', overlay: null });
|
|
716
|
+
redTeamRef.current.acceptDisclaimer();
|
|
717
|
+
drainQueuedDecisions();
|
|
718
|
+
}, [drainQueuedDecisions]);
|
|
719
|
+
const declineRedTeamWaiver = useCallback(() => {
|
|
720
|
+
dispatch({ type: 'setOverlay', overlay: null });
|
|
721
|
+
redTeamRef.current.declineDisclaimer();
|
|
722
|
+
drainQueuedDecisions();
|
|
723
|
+
}, [drainQueuedDecisions]);
|
|
651
724
|
/**
|
|
652
725
|
* Disarm an armed continuation. Idempotent; NEVER touches the budget — a
|
|
653
726
|
* cancelled continuation was never issued, so it must not be charged (AC-18).
|
|
@@ -891,6 +964,10 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
891
964
|
// read its basis (I-9). The posture lands next: a pending GOVERN entry that
|
|
892
965
|
// arrives with it is reported by the same toast channel, not silently swallowed.
|
|
893
966
|
teamKeysRef.current.onTurnEnd();
|
|
967
|
+
// The same for red team mode: an arming asked for during the turn lands NOW, and the
|
|
968
|
+
// banner is printed here so the user learns the posture before the next message
|
|
969
|
+
// (red-team-security-mode D-12 / 4.6).
|
|
970
|
+
redTeamRef.current.onTurnEnd();
|
|
894
971
|
// A deferred `plan -> build` (or any posture change that waited for a governed
|
|
895
972
|
// stage, governance-mode D-23) becomes real here and nowhere else (§3.2).
|
|
896
973
|
const applied = controller.applyPendingPosture();
|
|
@@ -1206,8 +1283,16 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
1206
1283
|
if (!confirmBridge)
|
|
1207
1284
|
return;
|
|
1208
1285
|
confirmBridge.handler = (req) => new Promise((resolve) => {
|
|
1209
|
-
|
|
1210
|
-
|
|
1286
|
+
const show = () => {
|
|
1287
|
+
setConfirmState({ summary: req.summary, resolve });
|
|
1288
|
+
dispatch({ type: 'setOverlay', overlay: 'confirm' });
|
|
1289
|
+
};
|
|
1290
|
+
// THE WAIVER IS NOT INTERRUPTED (D-21 / RV-10): a confirm arriving while the disclaimer
|
|
1291
|
+
// is open is QUEUED, not shown, and replayed once it settles. Reading half a liability
|
|
1292
|
+
// waiver and then signing it is the one failure this overlay cannot have.
|
|
1293
|
+
if (queueWhileWaiverOpen(show))
|
|
1294
|
+
return;
|
|
1295
|
+
show();
|
|
1211
1296
|
});
|
|
1212
1297
|
return () => {
|
|
1213
1298
|
// The skill ApprovalGate reads `handler !== null` LIVE on every call, so
|
|
@@ -1230,11 +1315,18 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
1230
1315
|
// Without this listener both ceilings are gone at once and the process
|
|
1231
1316
|
// wedges behind an overlay nobody is going to answer (P0-2).
|
|
1232
1317
|
signal?.addEventListener('abort', () => settleHuman(entry, null), { once: true });
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1318
|
+
const show = () => {
|
|
1319
|
+
setHumanRequest(req);
|
|
1320
|
+
dispatch({
|
|
1321
|
+
type: 'setOverlay',
|
|
1322
|
+
overlay: req.kind === 'plan' ? 'plan' : 'question',
|
|
1323
|
+
});
|
|
1324
|
+
};
|
|
1325
|
+
// QUEUED BEHIND THE WAIVER, exactly like the confirm bridge above (D-21). The request
|
|
1326
|
+
// itself is already registered, so its own abort listener still fires while it waits.
|
|
1327
|
+
if (queueWhileWaiverOpen(show))
|
|
1328
|
+
return;
|
|
1329
|
+
show();
|
|
1238
1330
|
});
|
|
1239
1331
|
bridge.cancelPending = cancelPendingHuman;
|
|
1240
1332
|
return () => {
|
|
@@ -1244,7 +1336,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
1244
1336
|
cancelPendingHuman();
|
|
1245
1337
|
bridge.handler = null;
|
|
1246
1338
|
};
|
|
1247
|
-
}, [humanInputBridge, settleHuman, cancelPendingHuman]);
|
|
1339
|
+
}, [humanInputBridge, settleHuman, cancelPendingHuman, queueWhileWaiverOpen]);
|
|
1248
1340
|
// --- Seed the mode mirror from its owner, once, on mount. --------------
|
|
1249
1341
|
// `--plan` / `planModeDefault` are resolved before the App exists, so the
|
|
1250
1342
|
// reducer's `'build'` seed would render one wrong frame without this.
|
|
@@ -1331,6 +1423,41 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
1331
1423
|
memoryDispatch({ type: 'reset' });
|
|
1332
1424
|
dispatch({ type: 'setOverlay', overlay: null });
|
|
1333
1425
|
}, []);
|
|
1426
|
+
/**
|
|
1427
|
+
* Open the gene manager on a page (gene-bank spec 12.1). The nonce is bumped BEFORE the overlay
|
|
1428
|
+
* opens and the overlay consumes it at most once (two `/gene` in a row are two intents).
|
|
1429
|
+
*/
|
|
1430
|
+
const openGene = useCallback((entry) => {
|
|
1431
|
+
geneIntentNonce.current += 1;
|
|
1432
|
+
setGeneIntent({ nonce: geneIntentNonce.current, entry });
|
|
1433
|
+
dispatch({ type: 'setOverlay', overlay: 'gene' });
|
|
1434
|
+
}, []);
|
|
1435
|
+
const closeGene = useCallback(() => {
|
|
1436
|
+
geneDispatch({ type: 'reset' });
|
|
1437
|
+
dispatch({ type: 'setOverlay', overlay: null });
|
|
1438
|
+
}, []);
|
|
1439
|
+
// The overlay's whole view of the library: ONE port, shared with `/gene` and (through the host
|
|
1440
|
+
// facade) the desktop. Absent for a host without the library (off, headless, a test double),
|
|
1441
|
+
// in which case the key does nothing and `/gene` says why.
|
|
1442
|
+
const genePort = useMemo(() => (typeof controller.getGeneManager === 'function' ? controller.getGeneManager() ?? null : null), [controller]);
|
|
1443
|
+
// The unified status (I-23): the chip, the overlay header and `/gene status` all read THIS.
|
|
1444
|
+
const [geneView, setGeneView] = useState(() => (typeof controller.getGeneView === 'function' ? controller.getGeneView() : null));
|
|
1445
|
+
useEffect(() => {
|
|
1446
|
+
if (typeof controller.subscribeGene !== 'function')
|
|
1447
|
+
return undefined;
|
|
1448
|
+
return controller.subscribeGene(() => setGeneView(controller.getGeneView()));
|
|
1449
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1450
|
+
}, [controller]);
|
|
1451
|
+
// The one-time "Ctrl+Q opens the Gene Bank" hint (I3-9 U-1). The hub raises it once per library
|
|
1452
|
+
// and records that on disk, so this only has to say it when it arrives, never twice in a session.
|
|
1453
|
+
const geneHintShown = useRef(false);
|
|
1454
|
+
useEffect(() => {
|
|
1455
|
+
if (geneView?.hint === undefined || geneHintShown.current)
|
|
1456
|
+
return;
|
|
1457
|
+
geneHintShown.current = true;
|
|
1458
|
+
toast('info', geneHintCopy(geneView.hint, controller.getConfig().gene?.key ?? 'ctrl+q'));
|
|
1459
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1460
|
+
}, [geneView?.hint]);
|
|
1334
1461
|
// The overlay's whole view of the session: a port over the controller's service. Absent for a
|
|
1335
1462
|
// host without memory (a test double, a headless run), in which case the overlay never opens.
|
|
1336
1463
|
const memoryPort = useMemo(() => {
|
|
@@ -1462,6 +1589,14 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
1462
1589
|
notify('info', sessionNotice);
|
|
1463
1590
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1464
1591
|
}, []);
|
|
1592
|
+
// THE RESUMED POSTURE (red-team-security-mode 4.10 / I-12). Once, on mount, and only when a
|
|
1593
|
+
// resume had something to say: a session that comes back ARMED must tell the user what posture
|
|
1594
|
+
// they are in before their first message, and one that stayed off has to say why.
|
|
1595
|
+
useEffect(() => {
|
|
1596
|
+
if (redTeamNotice)
|
|
1597
|
+
notify('warn', redTeamNotice);
|
|
1598
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1599
|
+
}, []);
|
|
1465
1600
|
// --- Session bridge: identity write-back (D-15 / 3.12). -------------------
|
|
1466
1601
|
//
|
|
1467
1602
|
// INSTALLED AND CLEARED EXACTLY LIKE `confirmBridge.handler`: the rotation is
|
|
@@ -1912,6 +2047,29 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
1912
2047
|
openMemory(entry);
|
|
1913
2048
|
},
|
|
1914
2049
|
},
|
|
2050
|
+
// The Gene Bank's host for `/gene` (spec 16.3). OMITTED when the library is off, so the
|
|
2051
|
+
// command says so instead of acting on a manager that does not exist.
|
|
2052
|
+
...(genePort
|
|
2053
|
+
? {
|
|
2054
|
+
gene: {
|
|
2055
|
+
manager: genePort,
|
|
2056
|
+
control: {
|
|
2057
|
+
getView: () => controller.getGeneView(),
|
|
2058
|
+
curator: (action) => controller.geneCurator(action),
|
|
2059
|
+
},
|
|
2060
|
+
// Persisted AND applied to this session at once (I-18); a failed write is a toast.
|
|
2061
|
+
setUse: (value) => {
|
|
2062
|
+
controller.setGeneConfig({ use: value });
|
|
2063
|
+
persistConfig({ gene: { use: value } });
|
|
2064
|
+
},
|
|
2065
|
+
setAutoLearn: (value) => {
|
|
2066
|
+
controller.setGeneConfig({ autoLearn: value });
|
|
2067
|
+
persistConfig({ gene: { autoLearn: value } });
|
|
2068
|
+
},
|
|
2069
|
+
openManager: (page) => openGene(page && page !== 'list' ? { kind: 'page', page } : { kind: 'list' }),
|
|
2070
|
+
},
|
|
2071
|
+
}
|
|
2072
|
+
: {}),
|
|
1915
2073
|
setOverlay: (overlay) => dispatch({ type: 'setOverlay', overlay }),
|
|
1916
2074
|
// THE TASK LABEL PORT (`/keys`, `/task`; §6.4). Reads go through `stateRef` so a
|
|
1917
2075
|
// command always sees the LATEST label rather than the one from the render that
|
|
@@ -2597,6 +2755,22 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
2597
2755
|
openMemory({ kind: 'list' });
|
|
2598
2756
|
return;
|
|
2599
2757
|
}
|
|
2758
|
+
// Ctrl+Q / Alt+Q: the gene manager (gene-bank spec 12.1). Ctrl+Q is the unambiguous C0 byte
|
|
2759
|
+
// 0x11 (unlike Ctrl+M / Ctrl+I it needs no key frame), the Alt twin is ALWAYS live because
|
|
2760
|
+
// VS Code's terminal and tmux can swallow the control key, and `gene.key` is read at KEY
|
|
2761
|
+
// TIME so a settings change needs no restart. Same guards and the same position as Ctrl+M:
|
|
2762
|
+
// BEFORE the `tooSmall` return, so "the key did nothing" stays distinguishable from "the key
|
|
2763
|
+
// never arrived". The overlay closes itself on the same key (it owns the unsaved-draft check).
|
|
2764
|
+
if (isGeneToggleKey(input, key, geneKeyLetter(controller.getConfig().gene?.key ?? 'ctrl+q'))) {
|
|
2765
|
+
if (tooSmall || (stateRef.current.overlay && stateRef.current.overlay !== 'gene'))
|
|
2766
|
+
return;
|
|
2767
|
+
if (stateRef.current.overlay === 'gene')
|
|
2768
|
+
return;
|
|
2769
|
+
if (controller.getConfig().gene?.enabled !== true || !genePort)
|
|
2770
|
+
return;
|
|
2771
|
+
openGene({ kind: 'list' });
|
|
2772
|
+
return;
|
|
2773
|
+
}
|
|
2600
2774
|
// Ctrl+L: branch this session into a NEW terminal (tui-branch-terminal-
|
|
2601
2775
|
// shortcut D-1 / D-2). Guarded exactly like Ctrl+G and Ctrl+I above it: an
|
|
2602
2776
|
// overlay owns the keyboard, and on a too-small terminal the feedback has
|
|
@@ -2637,7 +2811,9 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
2637
2811
|
// nothing and the wheel falls through to the transcript behind it.
|
|
2638
2812
|
|| overlay === 'prompts' || overlay === 'prompt-pick'
|
|
2639
2813
|
// The memory manager pages through `overlayScroll` too (agent-memory V-4).
|
|
2640
|
-
|| overlay === 'memory'
|
|
2814
|
+
|| overlay === 'memory'
|
|
2815
|
+
// And so does the gene manager (gene-bank 12.2).
|
|
2816
|
+
|| overlay === 'gene';
|
|
2641
2817
|
if (key.pageUp) {
|
|
2642
2818
|
if (controlled)
|
|
2643
2819
|
setOverlayScroll((n) => Math.max(0, n - overlayPage));
|
|
@@ -2686,18 +2862,23 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
2686
2862
|
// both keys so a draft's history and a popup's highlight never also move (I-6).
|
|
2687
2863
|
if (teamKeys.handleKey(input, key))
|
|
2688
2864
|
return;
|
|
2689
|
-
//
|
|
2865
|
+
// Ctrl+R IS THE RED TEAM SWITCH (red-team-security-mode D-1), and the repaint moved to
|
|
2866
|
+
// Alt+R for the reason Ctrl+T moved to Alt+T: legacy encodings deliver the same byte for
|
|
2867
|
+
// Ctrl+R and Ctrl+Shift+R, so a Shift binding would exist only behind keyboard enhancement.
|
|
2690
2868
|
//
|
|
2691
|
-
//
|
|
2692
|
-
//
|
|
2693
|
-
//
|
|
2694
|
-
//
|
|
2869
|
+
// THE REBINDING IS UNCONDITIONAL (RV-11 / I-9): it does not depend on `redteam.enabled`,
|
|
2870
|
+
// `--no-redteam` or `ARAGON_REDTEAM=0`. Whether Ctrl+R repaints must not depend on a config
|
|
2871
|
+
// key; in a session with the chain unregistered the hook simply answers `unavailable` with
|
|
2872
|
+
// one toast per press, and Alt+R below still repaints.
|
|
2695
2873
|
//
|
|
2696
|
-
//
|
|
2697
|
-
//
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2874
|
+
// The overlay guard is the pre-existing one: with an overlay open, this key belongs to
|
|
2875
|
+
// whoever owns the screen (the settings page's own Ctrl+R is "Test connection").
|
|
2876
|
+
if (redTeamRef.current.handleKey(input, key))
|
|
2877
|
+
return;
|
|
2878
|
+
// Alt+R = repaint. TWO BYTE FORMS, exactly like the Alt+T branch below: the `meta` flag Ink
|
|
2879
|
+
// sets after stripping the ESC, AND the raw `ESC r` that some stacks deliver whole. Handling
|
|
2880
|
+
// only the first would make the recovery key dead on exactly those stacks.
|
|
2881
|
+
if ((key.meta && !key.ctrl && input.toLowerCase() === 'r') || input === '\x1br') {
|
|
2701
2882
|
if (stateRef.current.overlay)
|
|
2702
2883
|
return;
|
|
2703
2884
|
setRedrawNonce((n) => n + 1);
|
|
@@ -2806,6 +2987,16 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
2806
2987
|
// and nothing else could close it.
|
|
2807
2988
|
if (overlay === 'memory' && memoryPort)
|
|
2808
2989
|
return;
|
|
2990
|
+
// THE GENE MANAGER OWNS ITS Esc for the same reason: the editor's first Esc only arms the discard.
|
|
2991
|
+
if (overlay === 'gene' && genePort)
|
|
2992
|
+
return;
|
|
2993
|
+
// THE WAIVER'S `Esc` (4.3). App owns the key for the plan overlays and for this one, so
|
|
2994
|
+
// declining and draining the queue happen in ONE place - the overlay registers no Escape
|
|
2995
|
+
// handler of its own, and a second one would decline twice.
|
|
2996
|
+
if (overlay === 'redteam-disclaimer') {
|
|
2997
|
+
declineRedTeamWaiver();
|
|
2998
|
+
return;
|
|
2999
|
+
}
|
|
2809
3000
|
if (overlay) {
|
|
2810
3001
|
cancelConfirmation();
|
|
2811
3002
|
if (overlay === 'confirm' && confirmRef.current) {
|
|
@@ -2922,6 +3113,9 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
2922
3113
|
.filter((kit) => kit.id !== activeKit.id).map((kit) => kit.name),
|
|
2923
3114
|
};
|
|
2924
3115
|
const memoryChip = memoryChipFacts(memoryView) ?? undefined;
|
|
3116
|
+
// THE GENE CHIP (gene-bank 12.3): `show` is false for an empty, idle library, which keeps the
|
|
3117
|
+
// row byte-identical to the build without the feature for everyone who has no genes.
|
|
3118
|
+
const geneChip = geneView && geneView.available ? geneChipFactsOf(geneView) : null;
|
|
2925
3119
|
const empty = state.entries.length === 0;
|
|
2926
3120
|
// RENDER SCOPE, so the chip and the composer hint agree with what the Ctrl+C
|
|
2927
3121
|
// handler will do on the very next keystroke.
|
|
@@ -3139,7 +3333,7 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3139
3333
|
// user cannot even OPEN reads as a broken key.
|
|
3140
3334
|
busy: controller.isModelSettingsBusy(), maxRows: overlayMaxRows, cols: viewCols, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, theme: theme, caps: caps, onChoose: handleKitChoose, onClose: () => dispatch({ type: 'setOverlay', overlay: null }) })) : overlay === 'prompts' ? (_jsx(PromptLibraryOverlay, { isActive: !tooSmall, library: promptLibrary, ...(promptIntent ? { intent: promptIntent } : {}), cols: viewCols, maxRows: overlayMaxRows, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, theme: theme, caps: caps, onMutate: handlePromptMutate, onNotice: notify, onClose: () => dispatch({ type: 'setOverlay', overlay: null }) })) : overlay === 'prompt-pick' ? (_jsx(PromptPicker, { isActive: !tooSmall, library: promptLibrary, cols: viewCols, maxRows: overlayMaxRows, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, theme: theme, caps: caps, onFill: handlePromptFill, onManage: (entry) => openPromptLibrary(entry), onClose: closePromptPicker })) : overlay === 'memory' && memoryPort ? (_jsx(MemoryOverlay, { isActive: !tooSmall, state: memoryState, dispatch: memoryDispatch, port: memoryPort, ...(memoryIntent ? { intent: memoryIntent } : {}), context: memoryContext.current, cols: viewCols, maxRows: overlayMaxRows, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, theme: theme, caps: caps, reducedMotion: cfg.reducedMotion ?? false, ...(terminal?.enhancedKeys === undefined ? {} : { enhancedKeys: terminal.enhancedKeys }),
|
|
3141
3335
|
// Outcomes are toasts (they expire); the editor's own error row is what stays on screen.
|
|
3142
|
-
onNotice: (level, text) => toast(level === 'info' ? 'success' : level, text), onClose: closeMemory })) : overlay === 'settings' ? (_jsx(SettingsScreen, { isActive: !tooSmall, initial: {
|
|
3336
|
+
onNotice: (level, text) => toast(level === 'info' ? 'success' : level, text), onClose: closeMemory })) : overlay === 'gene' && genePort && geneView ? (_jsx(GeneOverlay, { isActive: !tooSmall, state: geneState, dispatch: geneDispatch, port: genePort, view: geneView, ...(geneIntent ? { intent: geneIntent } : {}), cols: viewCols, maxRows: overlayMaxRows, scrollOffset: overlayScroll, onScrollClamp: setOverlayScroll, theme: theme, caps: caps, reducedMotion: cfg.reducedMotion ?? false, configuredKey: cfg.gene?.key ?? 'ctrl+q', explainAvailable: explainAvailableFor(cfg.gene?.explainLanguage ?? 'auto', process.env.LC_ALL ?? process.env.LANG ?? '', controller.getFastStatus().tier.ok), onNotice: (level, text) => toast(level === 'info' ? 'success' : level, text), onClose: closeGene })) : overlay === 'settings' ? (_jsx(SettingsScreen, { isActive: !tooSmall, initial: {
|
|
3143
3337
|
provider: cfg.provider,
|
|
3144
3338
|
model: cfg.model,
|
|
3145
3339
|
baseUrl: cfg.baseUrl ?? '',
|
|
@@ -3192,7 +3386,11 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3192
3386
|
// already disabled the transcript underneath.
|
|
3193
3387
|
_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
3388
|
// 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 === '
|
|
3389
|
+
_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' ? (
|
|
3390
|
+
// THE WAIVER (red-team-security-mode 4.3). Rendered from the reducer's overlay field like
|
|
3391
|
+
// every other surface, so it cannot be open at the same time as a decision dialog - the
|
|
3392
|
+
// requests that would have replaced it are queued in `queuedDecisions` instead (D-21).
|
|
3393
|
+
_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
3394
|
const density = cfg.density;
|
|
3197
3395
|
const transcriptWindow = cfg.transcriptWindow ?? DEFAULT_TRANSCRIPT_WINDOW;
|
|
3198
3396
|
// The fixed status bar remains visible underneath every overlay and toast.
|
|
@@ -3319,6 +3517,12 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3319
3517
|
// needs the second status row was decided once, above, by `acceptanceChip`.
|
|
3320
3518
|
...(acceptanceActive ? { acceptanceActive } : {}),
|
|
3321
3519
|
fastActive: state.fast?.live ? { inFlight: state.fast.inFlight } : undefined,
|
|
3520
|
+
// THE DETAILS-ROW LINE (4.7 c): `Red team armed; confirmations off` or
|
|
3521
|
+
// `Red team paused (...)`. Read from the same view the chip reads, so the two surfaces
|
|
3522
|
+
// cannot describe one posture differently (I-10).
|
|
3523
|
+
...(redTeam.view.available && redTeam.view.armed
|
|
3524
|
+
? { redteam: { armed: redTeam.view.armed, paused: redTeam.view.paused } }
|
|
3525
|
+
: {}),
|
|
3322
3526
|
...feedbackProjection,
|
|
3323
3527
|
};
|
|
3324
3528
|
const details = planStatusDetail({ status: statusInput, model: cfg.model, provider: cfg.provider,
|
|
@@ -3330,7 +3534,10 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3330
3534
|
...(state.governance?.pauseRequested === true ? { govPausePending: true } : {}),
|
|
3331
3535
|
interruptPhase: interruptGesture.current.phase,
|
|
3332
3536
|
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,
|
|
3537
|
+
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,
|
|
3538
|
+
// ARMED AND IN EFFECT, never `armed` alone: a paused session keeps its plan / govern
|
|
3539
|
+
// colour, because `paused` has one definition and this prop does not re-derive it (4.7 b).
|
|
3540
|
+
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
3541
|
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
3542
|
// --- Native panel band (release-gate-and-native-panels §6.3/§6.4) -------------
|
|
3336
3543
|
//
|
|
@@ -3356,7 +3563,9 @@ export function App({ controller, version, initialOverlay, initialPrompt, confir
|
|
|
3356
3563
|
const rail = fullscreenRailVisible && state.todos ? (_jsx(TodoPanel, { snapshot: state.todos, width: railWidth, rows: railRows, running: running, reducedMotion: viewReducedMotion, theme: theme, caps: caps })) : null;
|
|
3357
3564
|
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
3565
|
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 } : {}),
|
|
3566
|
+
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 } : {}), ...(geneChip && geneChip.show ? { gene: geneChip } : {}), ...(redTeam.view.available && redTeam.view.armed
|
|
3567
|
+
? { redteam: { armed: redTeam.view.armed, paused: redTeam.view.paused } }
|
|
3568
|
+
: {}), waitingForConfirmation: !!humanRequest || !!confirmState, stopping: interruptGesture.current.phase === 'stopping', interruptHint: interruptGesture.current.phase === 'stopping'
|
|
3360
3569
|
? 'Esc force-stop' : 'Esc x2 interrupt', model: cfg.model, provider: cfg.provider, usageTotal: state.usageTotal,
|
|
3361
3570
|
// ONE OBJECT INSTEAD OF FOUR PARALLEL PROPS (§4.3). The four were a
|
|
3362
3571
|
// 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;
|