@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
package/dist/agent/controller.js
CHANGED
|
@@ -10,7 +10,7 @@ import { countAllImages, countHistoryImages, makeImageProjection, projectImagesF
|
|
|
10
10
|
import { buildImageInputBlock } from './image-input-prompt.js';
|
|
11
11
|
import { isImageCapabilityRefusal } from '@aragon-agent/tui/model/agent/image-refusal';
|
|
12
12
|
import { Agent, IMAGE_TOKEN_ESTIMATE, initProviders, ModelRegistry, } from '@aragon-agent/core';
|
|
13
|
-
import { clampCompactionConfig, clampFastConfig, clampRetryConfig, clampMemoryConfig, clampTeamConfig, clampTodoConfig, isAdapterProvider, toRetryPolicy, } from '@aragon-agent/tui/model/config/schema';
|
|
13
|
+
import { clampCompactionConfig, clampFastConfig, clampRetryConfig, clampGeneConfig, clampMemoryConfig, clampTeamConfig, clampTodoConfig, isAdapterProvider, toRetryPolicy, } from '@aragon-agent/tui/model/config/schema';
|
|
14
14
|
import { resolveModelProfileState } from '@aragon-agent/tui/model/config/model-profile-resolution';
|
|
15
15
|
import { makeGetApiKey } from '../config/load.js';
|
|
16
16
|
import { updatePersistedConfig } from '../config/store.js';
|
|
@@ -30,8 +30,17 @@ import { buildTeamBlock } from '../team/prompt.js';
|
|
|
30
30
|
import { buildForcedTeamBlock } from '../team/forced-prompt.js';
|
|
31
31
|
import { DEFAULT_FORCED_COUNT } from '../team/forced-mode.js';
|
|
32
32
|
import { TeamModeWiring, effectiveForced } from './team-mode-wiring.js';
|
|
33
|
+
// RED TEAM / SECURITY MODE (red-team-security-mode 4.4). The state, the waiver and the ONE
|
|
34
|
+
// permission predicate live in the wiring; this class forwards and composes the prompt.
|
|
35
|
+
import { RedTeamWiring, bannerConfirmations, readWaiverVersionPort, writeWaiverVersionPort } from './redteam-wiring.js';
|
|
36
|
+
import { buildRedTeamBanner } from './redteam-prompt.js';
|
|
37
|
+
import { acceptRedTeamWaiver, getRedTeamWaiverVersion, } from '../config/ui-state.js';
|
|
33
38
|
import { MemoryService, UNAVAILABLE_VIEW } from '../memory/service.js';
|
|
34
39
|
import { createMemoryTools } from '../memory/tools.js';
|
|
40
|
+
import { createGeneWiring } from '../gene/wiring.js';
|
|
41
|
+
import { skillPortOf } from '../gene/import-skill-port.js';
|
|
42
|
+
import { createToolAccess, geneRunTimeoutOverride } from '../gene/tools.js';
|
|
43
|
+
import { emptyGeneSessionView } from '@aragon-agent/tui/model/gene/activity';
|
|
35
44
|
import { buildFastBlock } from '../fast/prompt.js';
|
|
36
45
|
import { ProcSupervisor } from '../proc/supervisor.js';
|
|
37
46
|
import { buildBackgroundJobsBlock, buildBackgroundServicesBlock } from '../proc/prompt.js';
|
|
@@ -69,7 +78,7 @@ import { createNodeSkillHost } from '../skills/node-host.js';
|
|
|
69
78
|
import { SkillService } from '../skills/service.js';
|
|
70
79
|
import { createSkillTools } from '../skills/tools.js';
|
|
71
80
|
import { SKILL_TRIAGE_LIMITS } from '../skills/triage.js';
|
|
72
|
-
import { buildSystemPrompt } from './system-prompt.js';
|
|
81
|
+
import { buildSystemPrompt, describeShell } from './system-prompt.js';
|
|
73
82
|
import { buildSkillTriageBlock } from './skill-triage-prompt.js';
|
|
74
83
|
import { resetConversationWith, } from './conversation-reset.js';
|
|
75
84
|
import { archiveClearedConversation, } from '../session/clear-archive.js';
|
|
@@ -226,6 +235,19 @@ export class AgentController {
|
|
|
226
235
|
// -----------------------------------------------------------------------
|
|
227
236
|
teamMode;
|
|
228
237
|
// -----------------------------------------------------------------------
|
|
238
|
+
// Red team / security mode (red-team-security-mode 4.4)
|
|
239
|
+
//
|
|
240
|
+
// SESSION STATE, NEVER PERSISTED (D-4): `armed` is the wiring's own field, `config.json`
|
|
241
|
+
// has no key that can express it, and a saved session records it as an OPTIONAL BOOLEAN so
|
|
242
|
+
// `/resume` can restore it honestly (4.10). The scope lives here too and is never written
|
|
243
|
+
// anywhere - a target name can itself be the sensitive part of an engagement (D-9).
|
|
244
|
+
//
|
|
245
|
+
// THE WAIVER IS NOT STATE THIS CLASS OWNS: it is `state.json`, read through two functions
|
|
246
|
+
// from `config/ui-state.ts`, so no code path can arm the mode by writing a config field
|
|
247
|
+
// (I-3 / I-4).
|
|
248
|
+
// -----------------------------------------------------------------------
|
|
249
|
+
redTeam;
|
|
250
|
+
// -----------------------------------------------------------------------
|
|
229
251
|
// Agent memory (agent-memory spec 8.4)
|
|
230
252
|
// -----------------------------------------------------------------------
|
|
231
253
|
// `undefined` when memory is off, the host is headless, or this is a subagent - which is
|
|
@@ -234,6 +256,15 @@ export class AgentController {
|
|
|
234
256
|
// unregistered, so `memory.enabled` turned off mid-session makes the block disappear and
|
|
235
257
|
// the tools refuse, but a fully clean session needs a restart.
|
|
236
258
|
memory;
|
|
259
|
+
/**
|
|
260
|
+
* The Gene Bank composition root (gene-bank spec 4), or `undefined` when the feature is off
|
|
261
|
+
* (`gene.enabled`, after the `ARAGON_GENE` kill switch and `--no-gene`). `undefined` is what
|
|
262
|
+
* leaves the tool array, the system prompt and the status row byte-identical to the build
|
|
263
|
+
* before the feature existed (I-20). Fixed at construction, like `memory`: tools cannot be
|
|
264
|
+
* unregistered, so `enabled` turned off mid-session makes the blocks vanish and the tools
|
|
265
|
+
* refuse (`use`), but a fully clean session needs a restart.
|
|
266
|
+
*/
|
|
267
|
+
gene;
|
|
237
268
|
// -----------------------------------------------------------------------
|
|
238
269
|
// Todo planning (todo-plan-execution §3.6a) — THE SAME TWO FLAGS, FOR THE
|
|
239
270
|
// SAME REASON.
|
|
@@ -535,9 +566,70 @@ export class AgentController {
|
|
|
535
566
|
rebuildPrompt: () => this.rebuildSystemPrompt(),
|
|
536
567
|
defaultCount: DEFAULT_FORCED_COUNT,
|
|
537
568
|
});
|
|
569
|
+
// AFTER the governance wiring and the launch posture, for the same reason `teamMode` is:
|
|
570
|
+
// `paused` is derived from `getPosture()`, which reads both. BEFORE `createBuiltinTools`,
|
|
571
|
+
// because the confirm-bypass closure below is handed to it (the `fileChanges` rule).
|
|
572
|
+
this.redTeam = new RedTeamWiring({
|
|
573
|
+
getConfig: () => this.config,
|
|
574
|
+
// ONE PREDICATE, not three flags: `--no-redteam` and `ARAGON_REDTEAM=0` are already
|
|
575
|
+
// folded into `redteam.enabled` by the config layer (4.8's table).
|
|
576
|
+
isAvailable: () => this.config.redteam?.enabled !== false,
|
|
577
|
+
readWaiverVersion: () => readWaiverVersionPort(getRedTeamWaiverVersion),
|
|
578
|
+
saveWaiverVersion: (version) => writeWaiverVersionPort(acceptRedTeamWaiver, version),
|
|
579
|
+
getPosture: () => {
|
|
580
|
+
const posture = this.getPosture();
|
|
581
|
+
return { mode: posture === 'plan' || posture === 'plan_govern' ? 'plan' : 'build',
|
|
582
|
+
governOn: posture === 'govern' || posture === 'plan_govern' };
|
|
583
|
+
},
|
|
584
|
+
isRunning: () => this.isRunning() || this.isCompactionBusy(),
|
|
585
|
+
rebuildPrompt: () => this.rebuildSystemPrompt(),
|
|
586
|
+
log: (event) => this.logRedTeam(event),
|
|
587
|
+
});
|
|
588
|
+
// `--redteam`: the launch check already refused the two cases that cannot work (headless,
|
|
589
|
+
// and no accepted waiver), so this is the ONE place a session may start armed without a
|
|
590
|
+
// keystroke. It still goes through the wiring, so the log and the view agree.
|
|
591
|
+
if (deps.redTeamArmed === true)
|
|
592
|
+
this.redTeam.armForLaunch();
|
|
593
|
+
// THE GENE BANK (gene-bank spec 4), ABOVE `createBuiltinTools` because its tools and hint
|
|
594
|
+
// engine are passed in. Every closure below is read LATER (tools / agent / fast do not exist
|
|
595
|
+
// yet), which is why none of them is evaluated here.
|
|
596
|
+
this.gene = createGeneWiring({
|
|
597
|
+
getConfig: () => this.config,
|
|
598
|
+
getCwd: () => this.cwd,
|
|
599
|
+
sessionId: this.jobSessionTag,
|
|
600
|
+
kind: deps.gene?.kind ?? 'tui',
|
|
601
|
+
headless: !this.planInteractive,
|
|
602
|
+
learnFlag: deps.gene?.learnFlag === true,
|
|
603
|
+
printMode: deps.gene?.printMode === true,
|
|
604
|
+
registeredToolNames: () => [...this.tools, ...this.callerTools].map((tool) => tool.name),
|
|
605
|
+
windowTokens: () => this.getModelInfo().contextWindow,
|
|
606
|
+
knownSecrets: () => this.memoryKnownSecrets(),
|
|
607
|
+
rebuildPrompt: () => this.rebuildSystemPrompt(),
|
|
608
|
+
notify: (level, text) => deps.notify?.(level, text),
|
|
609
|
+
mode: () => {
|
|
610
|
+
const posture = this.getPosture();
|
|
611
|
+
if (posture === 'govern' || posture === 'plan_govern')
|
|
612
|
+
return 'govern';
|
|
613
|
+
if (posture === 'plan')
|
|
614
|
+
return 'plan';
|
|
615
|
+
return this.teamRegistered ? 'team' : 'build';
|
|
616
|
+
},
|
|
617
|
+
redTeamArmed: () => this.redTeam?.isArmed() === true,
|
|
618
|
+
fastTier: () => this.fast?.getTier() ?? { ok: false, reason: 'disabled' },
|
|
619
|
+
mainModel: () => ({
|
|
620
|
+
providerId: this.config.provider,
|
|
621
|
+
modelId: this.config.model,
|
|
622
|
+
...(this.config.baseUrl ? { baseUrl: this.config.baseUrl } : {}),
|
|
623
|
+
}),
|
|
624
|
+
getApiKey: (providerId, role) => this.resolveKey(providerId, role ?? 'main'),
|
|
625
|
+
skills: () => (this.skillsEnabled ? skillPortOf(this.skills) : null),
|
|
626
|
+
...(deps.gene?.root === undefined ? {} : { root: deps.gene.root }),
|
|
627
|
+
});
|
|
538
628
|
this.teamRuntime = this.teamRegistered
|
|
539
629
|
? new TeamRuntime({
|
|
540
630
|
getConfig: () => this.config,
|
|
631
|
+
// Sub-agents share the process-wide library (no copy); absent when the library is off.
|
|
632
|
+
...(this.gene ? { geneTools: this.gene.subagentTools() } : {}),
|
|
541
633
|
// Read LIVE: the closure is only ever called from inside a dispatch,
|
|
542
634
|
// and `childFactory()` re-reads `compaction.subagents` on every call
|
|
543
635
|
// so a settings-screen edit reaches the next dispatch.
|
|
@@ -605,6 +697,26 @@ export class AgentController {
|
|
|
605
697
|
// mid-dispatch and abort it at `idleTimeoutMs`. The queue pauses the
|
|
606
698
|
// CHILD's watchdog instead, which is the one that needs it (P0-4).
|
|
607
699
|
...(confirm ? { humanQueue: new TeamHumanQueue(confirm) } : {}),
|
|
700
|
+
// THE CHILD INHERITS THE LEAD'S RED TEAM PHRASE (4.5 point 6 / D-16 / RV-2).
|
|
701
|
+
// `buildSubagentTools` builds its OWN confirm closure (`humanQueue.request`), so
|
|
702
|
+
// "the same closure is inherited" is FALSE - the same PREDICATE has to be passed
|
|
703
|
+
// down explicitly, or one `task` call walks around the arm state. Spread so a
|
|
704
|
+
// session without the chain builds `SubagentDeps` exactly as before.
|
|
705
|
+
...(this.redTeam.available()
|
|
706
|
+
? {
|
|
707
|
+
confirmBypass: () => this.redTeam.bypassesConfirmation(),
|
|
708
|
+
// The audit sink has to travel WITH the predicate: a child that skips a dialog
|
|
709
|
+
// silently is the one case R-12 exists for.
|
|
710
|
+
onConfirmBypass: (tool) => this.logRedTeam({
|
|
711
|
+
type: 'redteam.confirm_bypass', tool,
|
|
712
|
+
}),
|
|
713
|
+
}
|
|
714
|
+
: {}),
|
|
715
|
+
// THE CHILD'S PROMPT HALF OF THE SAME INHERITANCE: a trimmed `<redteam_mode>` block
|
|
716
|
+
// that tells the child it is bound by the lead's engagement rules.
|
|
717
|
+
...(this.redTeam.available()
|
|
718
|
+
? { redteamBlock: () => this.redTeam.childBlock() }
|
|
719
|
+
: {}),
|
|
608
720
|
// SITE ONE OF TWO FOR THE CHILD GATE (headless-host-bridge 2.3.7). The
|
|
609
721
|
// second is `runtime.ts::subDeps`; declaring it here and forgetting that
|
|
610
722
|
// one type-checks and forwards nothing, and every child would then run
|
|
@@ -762,6 +874,21 @@ export class AgentController {
|
|
|
762
874
|
}
|
|
763
875
|
: {}),
|
|
764
876
|
confirmTools: config.confirmTools,
|
|
877
|
+
// THE ONE PERMISSION EFFECT OF RED TEAM MODE (4.5 / I-5). Spread only when the chain
|
|
878
|
+
// exists, so a `--no-redteam` session's options bag is the object it always was. A
|
|
879
|
+
// FUNCTION, not a boolean: `armed` changes mid-session while the tool array cannot, and a
|
|
880
|
+
// boolean here would make this feature "active from the next launch".
|
|
881
|
+
//
|
|
882
|
+
// It is read by `withConfirmation` and by NOTHING ELSE. Plan mode's gate and the
|
|
883
|
+
// governance gate are wrapped OUTSIDE it, so an armed + PLAN turn never reaches the code
|
|
884
|
+
// that would consult this (I-6, structurally).
|
|
885
|
+
...(this.redTeam.available()
|
|
886
|
+
? {
|
|
887
|
+
confirmBypass: () => this.redTeam.bypassesConfirmation(),
|
|
888
|
+
// One `redteam.confirm_bypass` record per skipped dialog, tool name only (R-12).
|
|
889
|
+
onConfirmBypass: (tool) => this.logRedTeam({ type: 'redteam.confirm_bypass', tool }),
|
|
890
|
+
}
|
|
891
|
+
: {}),
|
|
765
892
|
// Routed through the same watchdog pause as the plan tools. This is a
|
|
766
893
|
// pre-existing bug being fixed in passing: a `--confirm` user who took
|
|
767
894
|
// longer than `idleTimeoutMs` over `Proceed? (y/N)` had their run killed
|
|
@@ -864,6 +991,17 @@ export class AgentController {
|
|
|
864
991
|
}),
|
|
865
992
|
}
|
|
866
993
|
: {}),
|
|
994
|
+
// THE FOUR GENE TOOLS AND THE HINT ENGINE (gene-bank 9.1 / 9.4), THROUGH THE FACTORY for the
|
|
995
|
+
// reason `memoryTools` records - and for one more: `gene_run` must sit INSIDE the plan gate,
|
|
996
|
+
// the skill ceiling and the approval wrappers applied there, exactly like `bash`. The access
|
|
997
|
+
// object reads `this.tools` LAZILY, so the `bash` it delegates to is the fully wrapped one
|
|
998
|
+
// (I-15). Absent when the library is off, which leaves the array provably untouched.
|
|
999
|
+
...(this.gene
|
|
1000
|
+
? {
|
|
1001
|
+
geneTools: this.gene.tools(createToolAccess(() => this.tools), true, () => describeShell().shell),
|
|
1002
|
+
geneHints: this.gene.hints,
|
|
1003
|
+
}
|
|
1004
|
+
: {}),
|
|
867
1005
|
// SPREAD, NEVER `resultTool: deps.resultTool` (the D-12 lesson, and the shape
|
|
868
1006
|
// every optional dep in this bag follows). With no schema the options bag has no
|
|
869
1007
|
// such key, so `createBuiltinTools` adds nothing and the tool array is the one it
|
|
@@ -964,6 +1102,13 @@ export class AgentController {
|
|
|
964
1102
|
}
|
|
965
1103
|
: {}),
|
|
966
1104
|
});
|
|
1105
|
+
// `gene_run` FOLLOWS `bash` (9.6): with the shell denied or absent the tool could only be
|
|
1106
|
+
// refused, and advertising it would burn a turn. In place, because `tools` is `readonly`.
|
|
1107
|
+
if (this.gene && !this.tools.some((tool) => tool.name === 'bash')) {
|
|
1108
|
+
const orphan = this.tools.findIndex((tool) => tool.name === 'gene_run');
|
|
1109
|
+
if (orphan >= 0)
|
|
1110
|
+
this.tools.splice(orphan, 1);
|
|
1111
|
+
}
|
|
967
1112
|
const model = {
|
|
968
1113
|
providerId: config.provider,
|
|
969
1114
|
modelId: config.model,
|
|
@@ -1083,6 +1228,11 @@ export class AgentController {
|
|
|
1083
1228
|
// outlived a mid-session `Settings > Team` switch to the supervisor
|
|
1084
1229
|
// and killed the dispatch the supervisor was meant to look after.
|
|
1085
1230
|
...(this.teamRegistered ? { task: 0 } : {}),
|
|
1231
|
+
// `gene_run` delegates to `bash`, which may wait on a human approval: the executor arms
|
|
1232
|
+
// its timer when `gene_run` starts, so the wait must not be charged to the gene's command.
|
|
1233
|
+
...(this.gene
|
|
1234
|
+
? geneRunTimeoutOverride(config.toolTimeoutMs, deps.decisionBudgetMs ?? 0)
|
|
1235
|
+
: {}),
|
|
1086
1236
|
// THE EXECUTOR'S OWN CLOCK FOR A LONG WAIT (extended-job-wait I-2 / I-4').
|
|
1087
1237
|
// Without it `job_wait` falls onto `toolTimeoutMs` (180 s) and a 20-minute
|
|
1088
1238
|
// wait dies at three; with `0` the wait would have no independent backstop
|
|
@@ -1150,6 +1300,9 @@ export class AgentController {
|
|
|
1150
1300
|
// its own agent. A receipt is where a user steer stops being pending;
|
|
1151
1301
|
// `agent_start` is where a requested abort stops being in force.
|
|
1152
1302
|
this.agent.subscribe((event) => {
|
|
1303
|
+
// The Gene Bank's feed (learner ledger, usage, evaluation). Never throws.
|
|
1304
|
+
// `abortRequested` is still in force here: it is cleared at the NEXT `agent_start`.
|
|
1305
|
+
this.gene?.onAgentEvent(event, this.abortRequested);
|
|
1153
1306
|
if (event.type === 'agent_start')
|
|
1154
1307
|
this.abortRequested = false;
|
|
1155
1308
|
if (event.type === 'message_update' && event.streamEvent.type === 'error') {
|
|
@@ -1195,6 +1348,9 @@ export class AgentController {
|
|
|
1195
1348
|
// stop saying "applies after this turn". The prompt itself is rebuilt at the START of
|
|
1196
1349
|
// the next turn, which is also where outside edits are picked up.
|
|
1197
1350
|
this.memory?.onTurnEnd();
|
|
1351
|
+
// A red team change asked for DURING the turn lands here (D-12): tightening already
|
|
1352
|
+
// took effect immediately, this is the loosening half.
|
|
1353
|
+
this.redTeam.applyPending();
|
|
1198
1354
|
// The same reconciliation at the other end of a run. Both ends are
|
|
1199
1355
|
// required: `turn_start` covers the next turn of the same run, and this
|
|
1200
1356
|
// covers a run that ended with a notice stranded in the queue.
|
|
@@ -1206,9 +1362,15 @@ export class AgentController {
|
|
|
1206
1362
|
});
|
|
1207
1363
|
// The switch's baseline view, taken once everything it reads exists (team-mode-toggle-keys).
|
|
1208
1364
|
this.teamMode.prime();
|
|
1365
|
+
// The same for red team mode: taken AFTER the launch arming above, so an `--redteam`
|
|
1366
|
+
// session's first render already says `RT armed` rather than repainting one frame later.
|
|
1367
|
+
this.redTeam.prime();
|
|
1209
1368
|
if (this.fast) {
|
|
1210
1369
|
this.rebuildSystemPrompt();
|
|
1211
1370
|
}
|
|
1371
|
+
// The library opens LAST: it needs the Agent (events), the tools (registered names) and the fast
|
|
1372
|
+
// wiring. `start()` never rejects; its failures are a degraded view, not an exception.
|
|
1373
|
+
void this.gene?.start();
|
|
1212
1374
|
// ONE LINE FOR THE TWO CONFIGURATION MISTAKES THAT ARE OTHERWISE INVISIBLE
|
|
1213
1375
|
// (§3.3): the tier is on but unnamed, or named against a provider with no
|
|
1214
1376
|
// key. Nothing else in the session would ever mention either.
|
|
@@ -1284,6 +1446,11 @@ export class AgentController {
|
|
|
1284
1446
|
// pre-builds the INCOMING model's prompt, and budgets sized for the outgoing window
|
|
1285
1447
|
// would overrun a smaller one. `''` when memory is off, which splices nothing.
|
|
1286
1448
|
memoryBlock: this.memory?.renderBlock(config) ?? '',
|
|
1449
|
+
// Gene Bank (9.2). The rules block is a source constant; the context block is the last
|
|
1450
|
+
// zone `planForTurn` computed and is spliced BEFORE `Operating guidance`, never after the
|
|
1451
|
+
// caller's appended instructions (RV-2). Both '' when off: nothing is spliced.
|
|
1452
|
+
geneRulesBlock: this.gene?.rulesBlock(this.tools.map((tool) => tool.name), config) ?? '',
|
|
1453
|
+
geneContextBlock: this.gene?.contextBlock() ?? '',
|
|
1287
1454
|
// Immediately after the catalog it refers to, before the plan block whose
|
|
1288
1455
|
// first step defers to it (§4.2.4).
|
|
1289
1456
|
skillTriageBlock: triageBlock,
|
|
@@ -1359,6 +1526,18 @@ export class AgentController {
|
|
|
1359
1526
|
model: `${config.provider}/${config.model}`,
|
|
1360
1527
|
})
|
|
1361
1528
|
: '',
|
|
1529
|
+
// THE RED TEAM BLOCK (4.6 / D-7). '' unless the mode is armed for THIS config, which is
|
|
1530
|
+
// what makes the closed state byte-identical (I-1). Read through the wiring so the block,
|
|
1531
|
+
// the chip and the gate can never disagree about whether the mode is on (I-10).
|
|
1532
|
+
//
|
|
1533
|
+
// NO `config` ARGUMENT, unlike `team` / `memory` above: the two keys that could differ in
|
|
1534
|
+
// a previewed settings snapshot (`enabled`, `bypassConfirm`) change the GATE, not the
|
|
1535
|
+
// block's text, and the block's presence depends on `armed`, which no config can express.
|
|
1536
|
+
// OPTIONAL-CHAINED BECAUSE `skills.discover()` CAN REACH THIS COMPOSER BEFORE THE WIRING
|
|
1537
|
+
// EXISTS: it runs in the constructor, and its `onChange` rebuilds the prompt. A missing
|
|
1538
|
+
// wiring means this session has no red team mode, which is `''` - the same answer the
|
|
1539
|
+
// block gives when the mode is off.
|
|
1540
|
+
redteamBlock: this.redTeam?.block() ?? '',
|
|
1362
1541
|
// FROM THE FIELD, so the block survives every rebuild for the reason the field's
|
|
1363
1542
|
// own comment records. Empty everywhere but `aragon exec --result-schema`, and
|
|
1364
1543
|
// `buildSystemPrompt` splices it conditionally - so every existing prompt is
|
|
@@ -1394,6 +1573,11 @@ export class AgentController {
|
|
|
1394
1573
|
// LAST: every change to what the switch shows passes through here, so one notification
|
|
1395
1574
|
// point replaces "each call site remembers to notify" (D-7).
|
|
1396
1575
|
this.teamMode.emitIfChanged();
|
|
1576
|
+
// The same funnel for red team mode: every way its view can change (arm, disarm, scope,
|
|
1577
|
+
// posture, waiver) ends up here or in `emitIfChanged`, so no surface needs "did every call
|
|
1578
|
+
// site remember to notify". Optional-chained for the constructor-order reason the prompt
|
|
1579
|
+
// composer records.
|
|
1580
|
+
this.redTeam?.emitIfChanged();
|
|
1397
1581
|
this.memory?.emitIfChanged();
|
|
1398
1582
|
}
|
|
1399
1583
|
currentImageKey() {
|
|
@@ -1563,6 +1747,16 @@ export class AgentController {
|
|
|
1563
1747
|
}
|
|
1564
1748
|
/** Prepare before clearing the plan, then enter the engine without yielding. */
|
|
1565
1749
|
async startPrompt(text, options, request) {
|
|
1750
|
+
// THE GENE ZONE IS PLANNED BEFORE THE PROMPT IS BUILT (9.3), because the loop captures the
|
|
1751
|
+
// system prompt by value on its way in. Bounded (~100 ms) and never rejects; a cancellation
|
|
1752
|
+
// that arrived while it ran is honoured before anything is prepared.
|
|
1753
|
+
if (this.gene) {
|
|
1754
|
+
this.gene.beginRun();
|
|
1755
|
+
await this.gene.planForTurn(text, 'user_turn');
|
|
1756
|
+
if (request !== this.startupSequence) {
|
|
1757
|
+
return { status: 'not-started', reason: 'cancelled' };
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1566
1760
|
this.prepareUserTurn(text, { steering: false });
|
|
1567
1761
|
if (request !== this.startupSequence) {
|
|
1568
1762
|
return { status: 'not-started', reason: 'cancelled' };
|
|
@@ -1611,6 +1805,7 @@ export class AgentController {
|
|
|
1611
1805
|
* thoughtless option.
|
|
1612
1806
|
*/
|
|
1613
1807
|
prepareUserTurn(text, options) {
|
|
1808
|
+
this.gene?.onUserMessage(text, { steering: options.steering });
|
|
1614
1809
|
if (this.skillsEnabled)
|
|
1615
1810
|
this.skills.beginUserTurn();
|
|
1616
1811
|
if (!options.steering) {
|
|
@@ -2304,6 +2499,118 @@ export class AgentController {
|
|
|
2304
2499
|
return this.config.team;
|
|
2305
2500
|
}
|
|
2306
2501
|
// -----------------------------------------------------------------------
|
|
2502
|
+
// Red team / security mode - public surface (red-team-security-mode 4.4)
|
|
2503
|
+
// -----------------------------------------------------------------------
|
|
2504
|
+
/** The mode as every surface renders it. Cached; cheap to call per render. */
|
|
2505
|
+
getRedTeamView() {
|
|
2506
|
+
return this.redTeam.getView();
|
|
2507
|
+
}
|
|
2508
|
+
/**
|
|
2509
|
+
* The ONE write entry: `Ctrl+R`, `/redteam on|off` and `--redteam` all arrive here.
|
|
2510
|
+
*
|
|
2511
|
+
* A `refusal: 'disclaimer'` is the caller's cue to open the waiver overlay - the command
|
|
2512
|
+
* handler cannot (it has no overlay access) and App can.
|
|
2513
|
+
*/
|
|
2514
|
+
setRedTeam(req) {
|
|
2515
|
+
return this.redTeam.request(req);
|
|
2516
|
+
}
|
|
2517
|
+
/** Land a deferred change at `agent_end`. `null` = nothing was pending. */
|
|
2518
|
+
applyPendingRedTeam() {
|
|
2519
|
+
return this.redTeam.applyPending();
|
|
2520
|
+
}
|
|
2521
|
+
/** Tell `listener` whenever the view changes. Returns the unsubscribe. */
|
|
2522
|
+
subscribeRedTeam(listener) {
|
|
2523
|
+
return this.redTeam.subscribe(listener);
|
|
2524
|
+
}
|
|
2525
|
+
/** The engagement scope, or `null` when the user declared none. Never persisted. */
|
|
2526
|
+
getRedTeamScope() {
|
|
2527
|
+
return this.redTeam.getScope();
|
|
2528
|
+
}
|
|
2529
|
+
/** Set or clear the scope; refuses rather than truncating (4.6 step 4). */
|
|
2530
|
+
setRedTeamScope(line) {
|
|
2531
|
+
return this.redTeam.setScope(line);
|
|
2532
|
+
}
|
|
2533
|
+
/** Record the waiver acceptance and return the version that landed on disk. */
|
|
2534
|
+
acceptRedTeamWaiver() {
|
|
2535
|
+
return this.redTeam.acceptWaiver();
|
|
2536
|
+
}
|
|
2537
|
+
/**
|
|
2538
|
+
* The three banner rows for an armed session, or `null` when the banner is off in config.
|
|
2539
|
+
*
|
|
2540
|
+
* `bannerConfirmations` decides WHICH sentence the middle row carries, because this feature's
|
|
2541
|
+
* only honest statement about permissions depends on two facts this class has: whether
|
|
2542
|
+
* `confirmTools` is on for this session, and whether `bypassConfirm` is (RV-1 / D-19).
|
|
2543
|
+
*/
|
|
2544
|
+
getRedTeamBanner() {
|
|
2545
|
+
if (this.config.redteam?.banner === false)
|
|
2546
|
+
return null;
|
|
2547
|
+
if (this.redTeam.getView().effective !== 'armed')
|
|
2548
|
+
return null;
|
|
2549
|
+
return buildRedTeamBanner(this.redTeam.getScope(), bannerConfirmations(this.config.redteam ?? {}, this.config.confirmTools));
|
|
2550
|
+
}
|
|
2551
|
+
/**
|
|
2552
|
+
* The armed/disarmed pair for the session file (4.10), plus the waiver version it was armed
|
|
2553
|
+
* under. `armed: false` with no version writes neither key, so an unarmed session's file is
|
|
2554
|
+
* byte-identical to today's.
|
|
2555
|
+
*/
|
|
2556
|
+
getRedTeamSessionState() {
|
|
2557
|
+
const armed = this.redTeam.getView().armed;
|
|
2558
|
+
return armed
|
|
2559
|
+
? { armed, waiverVersion: this.redTeam.disclaimerVersion }
|
|
2560
|
+
: { armed };
|
|
2561
|
+
}
|
|
2562
|
+
/**
|
|
2563
|
+
* Adopt the state a saved session carried (`/resume`, `--resume`, a checkpoint replay).
|
|
2564
|
+
*
|
|
2565
|
+
* TOLERANT AT THIS BOUNDARY (4.10 / RV-5): anything that is not a boolean reads as disarmed,
|
|
2566
|
+
* so a hand-edited file costs the mode and not the conversation. Returns the notice App should
|
|
2567
|
+
* print, or `null`.
|
|
2568
|
+
*/
|
|
2569
|
+
restoreRedTeam(saved) {
|
|
2570
|
+
if (!saved)
|
|
2571
|
+
return null;
|
|
2572
|
+
return this.redTeam.restoreFromSession({
|
|
2573
|
+
armed: saved.armed === true,
|
|
2574
|
+
...(typeof saved.waiverVersion === 'number' ? { waiverVersion: saved.waiverVersion } : {}),
|
|
2575
|
+
}).notice;
|
|
2576
|
+
}
|
|
2577
|
+
/** The posture changed (`Shift+Tab`, `/gov`): `paused` may have, so repaint. */
|
|
2578
|
+
noteRedTeamPosture() {
|
|
2579
|
+
this.redTeam.onPostureChange();
|
|
2580
|
+
}
|
|
2581
|
+
/**
|
|
2582
|
+
* One log record per mode event, and NONE of them carries a command, a target or a secret:
|
|
2583
|
+
* `scope_set` records a length, `confirm_bypass` records a tool name (D-9 / R-12).
|
|
2584
|
+
*/
|
|
2585
|
+
logRedTeam(event) {
|
|
2586
|
+
switch (event.type) {
|
|
2587
|
+
case 'redteam.arm':
|
|
2588
|
+
// `scopeCells` is a length: the scope itself never reaches a log file (D-9 / R-12).
|
|
2589
|
+
getLogger().info('agent', 'redteam_armed', {
|
|
2590
|
+
deferred: event.deferred, scopeCells: event.scopeCells,
|
|
2591
|
+
});
|
|
2592
|
+
return;
|
|
2593
|
+
case 'redteam.disarm':
|
|
2594
|
+
getLogger().info('agent', 'redteam_disarmed', {});
|
|
2595
|
+
return;
|
|
2596
|
+
case 'redteam.confirm_bypass':
|
|
2597
|
+
// ONE LINE PER BYPASSED CALL, with the tool name and nothing else: this is the audit
|
|
2598
|
+
// trail that answers "what did it run without asking me".
|
|
2599
|
+
getLogger().warn('agent', 'redteam_confirm_bypass', { tool: event.tool });
|
|
2600
|
+
return;
|
|
2601
|
+
case 'redteam.waiver_accepted':
|
|
2602
|
+
getLogger().info('agent', 'redteam_waiver_accepted', { version: event.version });
|
|
2603
|
+
return;
|
|
2604
|
+
case 'redteam.scope_set':
|
|
2605
|
+
getLogger().info('agent', 'redteam_scope_set', { cells: event.cells });
|
|
2606
|
+
return;
|
|
2607
|
+
case 'redteam.resume_restored':
|
|
2608
|
+
getLogger().info('agent', 'redteam_resume_restored', {
|
|
2609
|
+
armed: event.armed, reason: event.reason,
|
|
2610
|
+
});
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
// -----------------------------------------------------------------------
|
|
2307
2614
|
// Agent memory - public surface (agent-memory spec 8.4)
|
|
2308
2615
|
// -----------------------------------------------------------------------
|
|
2309
2616
|
/** The memory service, or `undefined` when memory is off / headless / a subagent. */
|
|
@@ -2342,6 +2649,56 @@ export class AgentController {
|
|
|
2342
2649
|
this.rebuildSystemPrompt();
|
|
2343
2650
|
return memory;
|
|
2344
2651
|
}
|
|
2652
|
+
// -----------------------------------------------------------------------
|
|
2653
|
+
// Gene Bank - public surface (gene-bank spec 16.8)
|
|
2654
|
+
// -----------------------------------------------------------------------
|
|
2655
|
+
/** The composition root, or `undefined` when the library is off / a subagent. */
|
|
2656
|
+
getGeneWiring() {
|
|
2657
|
+
return this.gene;
|
|
2658
|
+
}
|
|
2659
|
+
/** The per-session read facade, or `undefined` when off. */
|
|
2660
|
+
getGeneService() {
|
|
2661
|
+
return this.gene?.service;
|
|
2662
|
+
}
|
|
2663
|
+
/** The manager both user interfaces talk to, or `undefined` when off. */
|
|
2664
|
+
getGeneManager() {
|
|
2665
|
+
return this.gene?.manager;
|
|
2666
|
+
}
|
|
2667
|
+
/** The unified status; `available: false` when the library is off. */
|
|
2668
|
+
getGeneView() {
|
|
2669
|
+
return this.gene?.getView() ?? emptyGeneSessionView();
|
|
2670
|
+
}
|
|
2671
|
+
/** Subscribe to status changes; the returned function unsubscribes. */
|
|
2672
|
+
subscribeGene(listener) {
|
|
2673
|
+
return this.gene?.subscribe(listener) ?? (() => { });
|
|
2674
|
+
}
|
|
2675
|
+
/**
|
|
2676
|
+
* Adopt a new `gene` config for this session (Settings > Genes, `/gene on|off`), clamped here
|
|
2677
|
+
* as well as on the persist path. Like `setMemoryConfig` this does NOT persist. The two user
|
|
2678
|
+
* switches take effect on the NEXT call (I-18); the prompt is rebuilt so the blocks follow.
|
|
2679
|
+
*/
|
|
2680
|
+
setGeneConfig(patch) {
|
|
2681
|
+
const gene = clampGeneConfig({ ...this.config.gene, ...patch });
|
|
2682
|
+
this.advanceSettingsRevision();
|
|
2683
|
+
this.config = { ...this.config, gene };
|
|
2684
|
+
this.gene?.onConfigChanged();
|
|
2685
|
+
this.rebuildSystemPrompt();
|
|
2686
|
+
return gene;
|
|
2687
|
+
}
|
|
2688
|
+
/** A SESSION-level `use` override (the desktop's host command); `null` returns to the config. */
|
|
2689
|
+
setGeneUse(value) {
|
|
2690
|
+
this.gene?.setUseOverride(value);
|
|
2691
|
+
this.rebuildSystemPrompt();
|
|
2692
|
+
}
|
|
2693
|
+
/** A SESSION-level `autoLearn` override; `null` returns to the config. */
|
|
2694
|
+
setGeneAutoLearn(value) {
|
|
2695
|
+
this.gene?.setAutoLearnOverride(value);
|
|
2696
|
+
this.rebuildSystemPrompt();
|
|
2697
|
+
}
|
|
2698
|
+
/** Pause / resume THIS machine's curator consumption (queueing is unaffected). */
|
|
2699
|
+
geneCurator(action) {
|
|
2700
|
+
this.gene?.curatorControl(action);
|
|
2701
|
+
}
|
|
2345
2702
|
/** The window of the model `cfg` selects, or `undefined` when only a fallback is known. */
|
|
2346
2703
|
memoryWindowTokens(cfg) {
|
|
2347
2704
|
if (typeof cfg.contextWindow === 'number' && cfg.contextWindow > 0)
|
|
@@ -2408,6 +2765,8 @@ export class AgentController {
|
|
|
2408
2765
|
this.modelMetadataGeneration += 1;
|
|
2409
2766
|
this.modelMetadataAbort.abort();
|
|
2410
2767
|
this.teamRuntime?.dispose();
|
|
2768
|
+
// Flushes usage, stops the learner / curator / maintenance and releases the lease. Never rejects.
|
|
2769
|
+
void this.gene?.dispose();
|
|
2411
2770
|
this.governance.dispose();
|
|
2412
2771
|
this.fast?.dispose();
|
|
2413
2772
|
this.compaction?.dispose();
|
|
@@ -2790,6 +3149,8 @@ export class AgentController {
|
|
|
2790
3149
|
// The PROJECT scope moved with the directory: recompute which notes are visible before
|
|
2791
3150
|
// the rebuild reads them (agent-memory 5.3).
|
|
2792
3151
|
this.memory?.setCwd(cwd);
|
|
3152
|
+
// The PROJECT scope and the environment fingerprint moved with the directory (gene-bank 9.3).
|
|
3153
|
+
this.gene?.resetSession('cwd');
|
|
2793
3154
|
this.rebuildSystemPrompt();
|
|
2794
3155
|
this.onSkillsChanged?.();
|
|
2795
3156
|
}
|
|
@@ -2889,6 +3250,7 @@ export class AgentController {
|
|
|
2889
3250
|
* `docs/plans/clear-command-context-reset/spec.md`.
|
|
2890
3251
|
*/
|
|
2891
3252
|
clearMessages() {
|
|
3253
|
+
this.gene?.resetSession('clear');
|
|
2892
3254
|
this.idleCompaction?.abort();
|
|
2893
3255
|
this.restoredCompactionIdentity = undefined;
|
|
2894
3256
|
this.agent.clearMessages();
|
|
@@ -2979,6 +3341,7 @@ export class AgentController {
|
|
|
2979
3341
|
return this.agent.state.systemPrompt;
|
|
2980
3342
|
}
|
|
2981
3343
|
replaceMessages(messages, identity) {
|
|
3344
|
+
this.gene?.resetSession('resume');
|
|
2982
3345
|
this.idleCompaction?.abort();
|
|
2983
3346
|
this.restoredCompactionIdentity = identity;
|
|
2984
3347
|
this.agent.replaceMessages(messages);
|
|
@@ -36,6 +36,7 @@ import { buildRoleBlock } from '../governance/prompts/role-blocks.js';
|
|
|
36
36
|
import { readRunReport } from '../governance/report-reader.js';
|
|
37
37
|
import { ArtifactStore } from '../governance/store/artifacts.js';
|
|
38
38
|
import { RunStore } from '../governance/store/run-store.js';
|
|
39
|
+
import { withoutOrphanGeneRun } from '../gene/tools.js';
|
|
39
40
|
import { buildChildTools } from '../governance/tools/child-tools.js';
|
|
40
41
|
import { applyInspectorToolPolicy, withGovernanceReadGuard } from '../governance/tools/guard.js';
|
|
41
42
|
import { makeGovDispatchTool, makeGovRunTool } from '../governance/tools/lead-tools.js';
|
|
@@ -287,9 +288,15 @@ export class GovernanceWiring {
|
|
|
287
288
|
if (ext === undefined)
|
|
288
289
|
return tools;
|
|
289
290
|
const root = getGovernanceDir();
|
|
290
|
-
const
|
|
291
|
+
const policed = ext.role === 'INSP'
|
|
291
292
|
? applyInspectorToolPolicy(tools, { integrationCommands: ext.integrationCommands ?? [] })
|
|
292
293
|
: tools;
|
|
294
|
+
// `gene_run` FOLLOWS `bash` (gene-bank 9.6): an inspector with no registered integration
|
|
295
|
+
// command has no shell, and a library tool that runs through that shell goes with it. When the
|
|
296
|
+
// inspector DOES keep a (restricted) `bash`, `gene_run` stays and delegates to that restricted
|
|
297
|
+
// tool, because the child's gene tools resolve `bash` from its FINAL array (`createToolAccess`).
|
|
298
|
+
// The gene READ tools pass through untouched: they write nothing and need no shell.
|
|
299
|
+
const base = withoutOrphanGeneRun(policed);
|
|
293
300
|
return base.map((tool) => withGovernanceReadGuard(tool, root));
|
|
294
301
|
}
|
|
295
302
|
// -------------------------------------------------------------------------
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `<redteam_mode>` system-prompt block and the session banner
|
|
3
|
+
* (red-team-security-mode 4.6).
|
|
4
|
+
*
|
|
5
|
+
* ASCII ONLY AND ENGLISH, AND BOTH ARE HARD CONSTRAINTS: `agent/**` is inside
|
|
6
|
+
* `glyphs.test.ts::inScope` (a single non-ASCII byte turns the suite red), and the
|
|
7
|
+
* requirement is explicit that this mode's prompt is English.
|
|
8
|
+
*
|
|
9
|
+
* WHERE IT GOES AND WHY (D-7). `buildSystemPrompt` splices it immediately AFTER the project
|
|
10
|
+
* guidance and BEFORE memory / skills, because this block declares who authorized the session
|
|
11
|
+
* and where the boundary is - it is the frame that explains the scale of every capability
|
|
12
|
+
* block after it. It also has to sit after the base prompt's environment and tool list, since
|
|
13
|
+
* the scope and the target sit on top of the real working directory and the real toolset.
|
|
14
|
+
*
|
|
15
|
+
* WHAT IT DOES NOT SAY. It does not say "maximum permission". `confirmTools` is `false` by
|
|
16
|
+
* default, so for most sessions this mode changes no permission at all (RV-1); a prompt that
|
|
17
|
+
* claimed otherwise would be the same untruth as v1's disclaimer clause 2, one layer down.
|
|
18
|
+
* The `What this mode changes` section therefore states the narrow fact and names the four
|
|
19
|
+
* things that are still refused.
|
|
20
|
+
*
|
|
21
|
+
* VERSIONS: `REDTEAM_BLOCK_VERSION` for the lead, `REDTEAM_CHILD_BLOCK_VERSION` for a
|
|
22
|
+
* subagent, so a wording change is greppable from a behaviour report.
|
|
23
|
+
*/
|
|
24
|
+
import { type RedTeamConfirmations } from '@aragon-agent/tui/ui/layout/redteam-banner';
|
|
25
|
+
export interface RedTeamBlockParams {
|
|
26
|
+
/** The user's declared engagement scope; `null` = not declared (D-9). */
|
|
27
|
+
scope: string | null;
|
|
28
|
+
/** A stricter posture is holding THIS turn back (PLAN / GOVERN). */
|
|
29
|
+
paused: boolean;
|
|
30
|
+
/** The name of the posture doing it, for the note; ignored when `paused` is false. */
|
|
31
|
+
postureLabel?: string;
|
|
32
|
+
/** `lead` or `child`: a subagent gets the trimmed variant (D-8 / D-16). */
|
|
33
|
+
role: 'lead' | 'child';
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The block. TOTAL: every combination of `scope` / `paused` / `role` produces exactly one
|
|
37
|
+
* string with exactly one opening and one closing tag (T-P1 / I-8).
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildRedTeamBlock(params: RedTeamBlockParams): string;
|
|
40
|
+
/**
|
|
41
|
+
* The three-row session banner (4.6), as plain lines for the `notice` entry.
|
|
42
|
+
*
|
|
43
|
+
* THE CONFIRMATION SENTENCE IS CONDITIONAL (RV-1 / D-19): the banner is the third place a
|
|
44
|
+
* user could be told something that did not happen, so it states which of the three
|
|
45
|
+
* situations this session is actually in.
|
|
46
|
+
*/
|
|
47
|
+
export declare function buildRedTeamBanner(scope: string | null, confirmations: RedTeamConfirmations): string[];
|