@aragon-agent/cli 0.6.55 → 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 -2864
- package/README.md +160 -45
- package/dist/agent/controller.d.ts +47 -0
- package/dist/agent/controller.js +153 -2
- package/dist/agent/governance-wiring.js +8 -1
- package/dist/agent/system-prompt.d.ts +26 -0
- package/dist/agent/system-prompt.js +11 -0
- package/dist/app/App.js +101 -3
- package/dist/cli.js +29 -1
- package/dist/commands/builtins.js +4 -0
- package/dist/commands/catalog.js +1 -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 +2 -1
- package/dist/config/env.js +12 -1
- package/dist/config/load.d.ts +10 -0
- package/dist/config/load.js +13 -2
- package/dist/config/store.js +11 -1
- 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/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/team/runtime.d.ts +5 -0
- package/dist/team/runtime.js +23 -0
- package/dist/team/subagent.d.ts +34 -0
- package/dist/team/subagent.js +39 -2
- package/dist/tools/index.d.ts +36 -2
- package/dist/tools/index.js +48 -7
- package/package.json +3 -3
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The model transports the Gene Bank's background work uses (gene-bank spec 10.1, 10.3, RV-22).
|
|
3
|
+
*
|
|
4
|
+
* ASCII ONLY - the whole `gene/` tree is in `glyphs.test.ts::inScope`.
|
|
5
|
+
*
|
|
6
|
+
* ONE FAIL-FAST REGISTRY OF ITS OWN. `FastWiring` only resolves the fast tier and has no transport
|
|
7
|
+
* for `reviewerModel: 'main'` / `curatorModel: 'main'`; reusing the main agent's registry would
|
|
8
|
+
* give a background learning call the main agent's long rate-limit backoff, so under a 429 the
|
|
9
|
+
* learner would fight the foreground for the same quota and hang for minutes. The registry built
|
|
10
|
+
* here retries once, like `FastWiring`'s, and is created lazily: a session that never learns
|
|
11
|
+
* allocates nothing.
|
|
12
|
+
*
|
|
13
|
+
* WHICH KEY. `fast` resolves the key as the `fast` role, `main` as the `main` role, exactly as the
|
|
14
|
+
* rest of the CLI does (`makeGetApiKey`). A model with no key reports unavailable instead of being
|
|
15
|
+
* called, so the learner shows `no_fast_tier` and the curator pauses rather than failing.
|
|
16
|
+
*/
|
|
17
|
+
import { DEFAULT_RETRY_POLICY, initProviders, } from '@aragon-agent/core';
|
|
18
|
+
const FAIL_FAST_RETRY_POLICY = { ...DEFAULT_RETRY_POLICY, maxRetries: 1 };
|
|
19
|
+
const NO_FAST_HINT = 'Configure a fast model (/fast model <id>) or set gene.curatorModel to main.';
|
|
20
|
+
/** The model the slot selects right now, or why there is none. Pure over the ports. */
|
|
21
|
+
export function resolveGeneModel(slot, ports) {
|
|
22
|
+
if (slot === 'fast') {
|
|
23
|
+
const tier = ports.fastTier();
|
|
24
|
+
if (!tier.ok)
|
|
25
|
+
return { ok: false, reason: 'no_fast_tier', hint: NO_FAST_HINT };
|
|
26
|
+
return {
|
|
27
|
+
ok: true,
|
|
28
|
+
choice: { ref: tier.ref, getApiKey: (providerId) => ports.getApiKey(providerId, 'fast') },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const ref = ports.mainModel();
|
|
32
|
+
if (ports.getApiKey(ref.providerId, 'main') === undefined) {
|
|
33
|
+
return { ok: false, reason: 'no_fast_tier', hint: 'No API key for the main model.' };
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
ok: true,
|
|
37
|
+
choice: { ref, getApiKey: (providerId) => ports.getApiKey(providerId, 'main') },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** The process-lifetime, lazily created, fail-fast registry shared by learner and curator. */
|
|
41
|
+
export function createFailFastRegistry() {
|
|
42
|
+
let registry = null;
|
|
43
|
+
return () => {
|
|
44
|
+
registry ??= initProviders({ retryPolicy: FAIL_FAST_RETRY_POLICY });
|
|
45
|
+
return registry;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** A failure the learner can classify: `errorType` is what `runLearnCall` reads. */
|
|
49
|
+
function unavailable(message) {
|
|
50
|
+
return Object.assign(new Error(message), { errorType: 'model_unavailable' });
|
|
51
|
+
}
|
|
52
|
+
/** The learner's one-shot completion: a single bounded call, temperature 0, no tools. */
|
|
53
|
+
export function createLearnComplete(deps) {
|
|
54
|
+
return async (request) => {
|
|
55
|
+
const resolved = resolveGeneModel(deps.slot(), deps.ports);
|
|
56
|
+
if (!resolved.ok)
|
|
57
|
+
throw unavailable('the reviewer model is not available');
|
|
58
|
+
const { ref, getApiKey } = resolved.choice;
|
|
59
|
+
const apiKey = getApiKey(ref.providerId);
|
|
60
|
+
if (apiKey === undefined)
|
|
61
|
+
throw unavailable('no API key for the reviewer model');
|
|
62
|
+
const reply = await deps.registry().complete(ref.providerId, {
|
|
63
|
+
model: ref.modelId,
|
|
64
|
+
messages: [{ role: 'user', content: request.user, timestamp: Date.now() }],
|
|
65
|
+
systemPrompt: request.system,
|
|
66
|
+
apiKey,
|
|
67
|
+
...(ref.baseUrl === undefined ? {} : { baseUrl: ref.baseUrl }),
|
|
68
|
+
signal: request.signal,
|
|
69
|
+
temperature: request.temperature,
|
|
70
|
+
maxTokens: request.maxTokens,
|
|
71
|
+
});
|
|
72
|
+
const text = reply.content
|
|
73
|
+
.filter((block) => block.type === 'text')
|
|
74
|
+
.map((block) => block.text)
|
|
75
|
+
.join('');
|
|
76
|
+
const inTok = reply.usage?.inputTokens ?? 0;
|
|
77
|
+
const outTok = reply.usage?.outputTokens ?? 0;
|
|
78
|
+
deps.onSpend?.({ inTok, outTok, usd: reply.usage?.cost });
|
|
79
|
+
return { text, usage: { inTok, outTok } };
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `GeneWiring` - the controller-side composition root of the Gene Bank
|
|
3
|
+
* (gene-bank spec 4, 9.7, 9.8, 10, 12.8, 13, 15.2).
|
|
4
|
+
*
|
|
5
|
+
* ASCII ONLY - the whole `gene/` tree is in `glyphs.test.ts::inScope`.
|
|
6
|
+
*
|
|
7
|
+
* WHAT IT OWNS. The lifetime of every per-session part: the read-path `GeneService`, the usage
|
|
8
|
+
* recorder, the hint engine, the evidence-ledger learner, (in interactive processes only) the
|
|
9
|
+
* curator and the maintenance runner, the activity hub and the manager both user interfaces talk
|
|
10
|
+
* to. It owns NO decision. What to retrieve, what to learn and what to publish live in the modules
|
|
11
|
+
* it assembles; this file supplies their inputs (the session's config, cwd, tools and models) and
|
|
12
|
+
* forwards the agent's events to them.
|
|
13
|
+
*
|
|
14
|
+
* ONE LIBRARY HANDLE PER PROCESS. `getGeneLibrary` is memoised per root: the version service, the
|
|
15
|
+
* lock manager and the queue must be the SAME objects the manager commits through, because two
|
|
16
|
+
* lock managers in one process do not exclude each other (an in-process pid is "stale" to its own
|
|
17
|
+
* file lock).
|
|
18
|
+
*
|
|
19
|
+
* THE LAYERING OF SWITCHES. `gene.enabled` is fixed for the session by whether this object exists
|
|
20
|
+
* (the controller builds none when it is off, which leaves the tool array, the prompt and the
|
|
21
|
+
* status row byte-identical to a build without the feature, I-20). `use` and `autoLearn` are read
|
|
22
|
+
* at CALL time through `effective()` (I-18), and the host can lay a SESSION-level override over
|
|
23
|
+
* either one without touching the file.
|
|
24
|
+
*
|
|
25
|
+
* FAIL-OPEN (I-24). Every entry point the agent loop calls (`onAgentEvent`, `onUserMessage`,
|
|
26
|
+
* `planForTurn`, `rulesBlock`, `contextBlock`) catches. A library that cannot be read costs the
|
|
27
|
+
* turn nothing.
|
|
28
|
+
*/
|
|
29
|
+
import type { AgentEvent, AgentTool, ModelRef } from '@aragon-agent/core';
|
|
30
|
+
import type { NoticeLevel } from '@aragon-agent/tui/model/agent/reducer';
|
|
31
|
+
import type { ModelRole } from '@aragon-agent/tui/model/config/model-profiles';
|
|
32
|
+
import { type CliConfig, type GeneConfig } from '@aragon-agent/tui/model/config/schema';
|
|
33
|
+
import type { FastTier } from '@aragon-agent/tui/model/fast/types';
|
|
34
|
+
import type { GeneSessionView } from '@aragon-agent/tui/model/gene/types';
|
|
35
|
+
import type { SubagentGeneDeps } from '../team/subagent.js';
|
|
36
|
+
import { GeneHintEngine } from './hints.js';
|
|
37
|
+
import { GeneActivityHub } from './hub.js';
|
|
38
|
+
import { ProjectLearningPolicy } from './policy.js';
|
|
39
|
+
import type { SkillSourcePort } from './import-sources.js';
|
|
40
|
+
import { type GeneManager } from './manager.js';
|
|
41
|
+
import { GeneService } from './service.js';
|
|
42
|
+
import type { GeneContextReason } from './service-types.js';
|
|
43
|
+
import { type GeneToolAccess } from './tools.js';
|
|
44
|
+
import { type ModelPorts } from './wiring-models.js';
|
|
45
|
+
export interface GeneWiringDeps extends ModelPorts {
|
|
46
|
+
getConfig(): CliConfig;
|
|
47
|
+
getCwd(): string;
|
|
48
|
+
sessionId: string;
|
|
49
|
+
kind: 'tui' | 'desktop' | 'exec';
|
|
50
|
+
/** No human can be asked anything (`-p`, `exec`). */
|
|
51
|
+
headless: boolean;
|
|
52
|
+
/** `--gene-learn` was given (only meaningful in print mode). */
|
|
53
|
+
learnFlag: boolean;
|
|
54
|
+
printMode: boolean;
|
|
55
|
+
registeredToolNames(): readonly string[];
|
|
56
|
+
windowTokens(): number;
|
|
57
|
+
knownSecrets(): readonly string[];
|
|
58
|
+
/** Recompose the system prompt (after an asynchronous re-plan lands). */
|
|
59
|
+
rebuildPrompt(): void;
|
|
60
|
+
notify(level: NoticeLevel, text: string): void;
|
|
61
|
+
mode(): 'build' | 'plan' | 'govern' | 'team';
|
|
62
|
+
redTeamArmed(): boolean;
|
|
63
|
+
fastTier(): FastTier;
|
|
64
|
+
mainModel(): ModelRef;
|
|
65
|
+
getApiKey(providerId: string, role?: ModelRole): string | undefined;
|
|
66
|
+
/** The session's installed skills, for the cold-start import. Absent = no skills import. */
|
|
67
|
+
skills?(): SkillSourcePort | null;
|
|
68
|
+
/** Library root override (tests). */
|
|
69
|
+
root?: string;
|
|
70
|
+
}
|
|
71
|
+
export declare class GeneWiring {
|
|
72
|
+
private readonly deps;
|
|
73
|
+
readonly service: GeneService;
|
|
74
|
+
readonly hints: GeneHintEngine;
|
|
75
|
+
readonly hub: GeneActivityHub;
|
|
76
|
+
private readonly lib;
|
|
77
|
+
/** The per-project "do not learn here" switch (I3-5); the files on disk are the truth. */
|
|
78
|
+
readonly policy: ProjectLearningPolicy;
|
|
79
|
+
/** The one recorder of this process: the service, the learner and the hint engine share it. */
|
|
80
|
+
private readonly usage;
|
|
81
|
+
private readonly learner;
|
|
82
|
+
private readonly feed;
|
|
83
|
+
private readonly curator;
|
|
84
|
+
private readonly runner;
|
|
85
|
+
private readonly registry;
|
|
86
|
+
private managerHandle;
|
|
87
|
+
private cache;
|
|
88
|
+
private projectMemo;
|
|
89
|
+
private envMemo;
|
|
90
|
+
private useOverride;
|
|
91
|
+
private learnOverride;
|
|
92
|
+
private runCounter;
|
|
93
|
+
private runId;
|
|
94
|
+
private runStartedAt;
|
|
95
|
+
private meter;
|
|
96
|
+
/** Explanation spend since the last run began; folded into the next run's cost row. */
|
|
97
|
+
private explainCarry;
|
|
98
|
+
private lastTask;
|
|
99
|
+
private lastLearnerState;
|
|
100
|
+
private started;
|
|
101
|
+
private disposed;
|
|
102
|
+
constructor(deps: GeneWiringDeps);
|
|
103
|
+
/** The live config with the session overrides laid over `use` / `autoLearn`. */
|
|
104
|
+
effective(): GeneConfig;
|
|
105
|
+
/** Curator and maintenance run only where a person is at the keyboard (9.8). */
|
|
106
|
+
private isBackground;
|
|
107
|
+
setUseOverride(value: boolean | null): void;
|
|
108
|
+
setAutoLearnOverride(value: boolean | null): void;
|
|
109
|
+
/** A `gene` config edit landed (Settings > Genes, `/gene on|off`). */
|
|
110
|
+
onConfigChanged(): void;
|
|
111
|
+
private settingsTouched;
|
|
112
|
+
/** Pause or resume THIS machine's consumption of the queue; queueing is unaffected. */
|
|
113
|
+
curatorControl(action: 'pause' | 'resume'): void;
|
|
114
|
+
private actor;
|
|
115
|
+
private project;
|
|
116
|
+
/** The authority for this session's project: both layers, re-read if their stamp moved. */
|
|
117
|
+
private refreshProjectVerdict;
|
|
118
|
+
/** The root `session-start` recorded for a project scope; null when unreadable (I3-5). */
|
|
119
|
+
private recordedProjectRoot;
|
|
120
|
+
private env;
|
|
121
|
+
private usageSink;
|
|
122
|
+
private buildService;
|
|
123
|
+
private learnerConfig;
|
|
124
|
+
private buildLearner;
|
|
125
|
+
private recordUsage;
|
|
126
|
+
/**
|
|
127
|
+
* The reviewer-budget tier-1 list the learning call sees so it can tell "already known" from
|
|
128
|
+
* "new". Planned straight from the pure planner: going through `service.planContext` would
|
|
129
|
+
* count every line as `shown`, and the reviewer showing itself genes is not exposure.
|
|
130
|
+
*/
|
|
131
|
+
private reviewerLines;
|
|
132
|
+
private buildCurator;
|
|
133
|
+
private buildRunner;
|
|
134
|
+
private buildHub;
|
|
135
|
+
/** Every part that can change what the status chip says tells the hub. */
|
|
136
|
+
private wireNotifications;
|
|
137
|
+
/** One transcript notice when learning switches itself off, not one per status refresh. */
|
|
138
|
+
private warnWhenLearnerFails;
|
|
139
|
+
/** Open the library and start the background parts. Never rejects. */
|
|
140
|
+
start(): Promise<void>;
|
|
141
|
+
private runStartChecks;
|
|
142
|
+
/** Stop every part and flush usage. Never rejects. */
|
|
143
|
+
dispose(): Promise<void>;
|
|
144
|
+
/** A new user-initiated run begins (not a steering message). */
|
|
145
|
+
beginRun(): void;
|
|
146
|
+
onUserMessage(text: string, options: {
|
|
147
|
+
steering: boolean;
|
|
148
|
+
}): void;
|
|
149
|
+
onAgentEvent(event: AgentEvent, aborted?: boolean): void;
|
|
150
|
+
/**
|
|
151
|
+
* Plan the context zone for the turn that is about to start. Bounded: the zone is an
|
|
152
|
+
* optimisation, so a slow or cold index costs the turn at most `PLAN_WAIT_MS`.
|
|
153
|
+
*/
|
|
154
|
+
planForTurn(text: string, reason: GeneContextReason): Promise<void>;
|
|
155
|
+
/** `/cwd`, `/clear`, `/resume`: forget what depended on the old context and plan again. */
|
|
156
|
+
resetSession(reason: 'cwd' | 'clear' | 'resume'): void;
|
|
157
|
+
private replan;
|
|
158
|
+
/** The stable `<gene_library>` rules block, or '' when the caller cannot use the library. */
|
|
159
|
+
rulesBlock(toolNames: readonly string[], _config?: CliConfig): string;
|
|
160
|
+
/** The last planned `<gene_context>` block, or ''. */
|
|
161
|
+
contextBlock(): string;
|
|
162
|
+
/** The four gene tools for the main agent. `shell` is read when `gene_run` quotes arguments. */
|
|
163
|
+
tools(access: GeneToolAccess, includeRun: boolean, shell: () => string): AgentTool[];
|
|
164
|
+
/**
|
|
165
|
+
* What `TeamRuntime` needs to give each child the same library (9.7): the child's own tools
|
|
166
|
+
* (tagged with its label), a hint engine per child, the rules block and a context zone planned
|
|
167
|
+
* ONCE per dispatch from its brief. Children share the index; none gets a copy.
|
|
168
|
+
*/
|
|
169
|
+
subagentTools(): SubagentGeneDeps;
|
|
170
|
+
private hintEngineFor;
|
|
171
|
+
/**
|
|
172
|
+
* Plan each child's zone one after another (they share the service's per-role hysteresis
|
|
173
|
+
* memory, so interleaving them would let one child's plan reuse another's text), then restore
|
|
174
|
+
* the main agent's own zone so the status chip describes the main agent again.
|
|
175
|
+
*/
|
|
176
|
+
private prepareZones;
|
|
177
|
+
/** The manager both user interfaces talk to; rebuilt when the working directory moves. */
|
|
178
|
+
get manager(): GeneManager;
|
|
179
|
+
/**
|
|
180
|
+
* The model a Chinese explanation uses: the fast tier, through this session's own fail-fast
|
|
181
|
+
* registry. Its spend is carried into the NEXT run's evaluation row as the `explain` component
|
|
182
|
+
* (a click is outside any run, so it cannot belong to a run that is not happening).
|
|
183
|
+
*/
|
|
184
|
+
private explainTransport;
|
|
185
|
+
/** The unified status (one source for both interfaces). */
|
|
186
|
+
getView(): GeneSessionView;
|
|
187
|
+
subscribe(listener: () => void): () => void;
|
|
188
|
+
/** The run ended: write its evaluation row once the run's learning call has reported its cost. */
|
|
189
|
+
private onRunEnd;
|
|
190
|
+
private settleEval;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* The composition root, or `undefined` when the feature is off (byte-identical sessions, I-20).
|
|
194
|
+
*
|
|
195
|
+
* A config with NO `gene` section is OFF, not default-on: the section is optional on `CliConfig`
|
|
196
|
+
* exactly like `memory` and `redteam`, `App` reads `gene?.enabled !== true`, and every config
|
|
197
|
+
* that went through `load.ts` carries the section. Reading absence as "on" would hand a fixture,
|
|
198
|
+
* or any embedder that builds a `CliConfig` by hand, four tools and a prompt block it never asked for.
|
|
199
|
+
*/
|
|
200
|
+
export declare function createGeneWiring(deps: GeneWiringDeps): GeneWiring | undefined;
|