@wrongstack/core 0.285.0 → 0.286.0
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/dist/autophase/phase-orchestrator.d.ts.map +1 -1
- package/dist/boot.d.ts.map +1 -1
- package/dist/coordination/agent-monitor.d.ts +29 -0
- package/dist/coordination/agent-monitor.d.ts.map +1 -1
- package/dist/coordination/autonomous-brain.d.ts +0 -2
- package/dist/coordination/autonomous-brain.d.ts.map +1 -1
- package/dist/coordination/autonomous-coordinator.d.ts +4 -0
- package/dist/coordination/autonomous-coordinator.d.ts.map +1 -1
- package/dist/coordination/brain-ledger.d.ts +142 -0
- package/dist/coordination/brain-ledger.d.ts.map +1 -0
- package/dist/coordination/brain-monitor.d.ts +31 -2
- package/dist/coordination/brain-monitor.d.ts.map +1 -1
- package/dist/coordination/brain.d.ts +43 -0
- package/dist/coordination/brain.d.ts.map +1 -1
- package/dist/coordination/delegate-tool.d.ts.map +1 -1
- package/dist/coordination/director-construction.d.ts.map +1 -1
- package/dist/coordination/director.d.ts +1 -1
- package/dist/coordination/director.d.ts.map +1 -1
- package/dist/coordination/fleet.d.ts +4 -4
- package/dist/coordination/fleet.d.ts.map +1 -1
- package/dist/coordination/global-mailbox.d.ts +63 -2
- package/dist/coordination/global-mailbox.d.ts.map +1 -1
- package/dist/coordination/index.d.ts +2 -1
- package/dist/coordination/index.d.ts.map +1 -1
- package/dist/coordination/index.js +1566 -462
- package/dist/coordination/index.js.map +4 -4
- package/dist/coordination/knowledge-graph.d.ts +13 -1
- package/dist/coordination/knowledge-graph.d.ts.map +1 -1
- package/dist/coordination/mailbox-actions.d.ts +12 -13
- package/dist/coordination/mailbox-actions.d.ts.map +1 -1
- package/dist/coordination/mailbox-constants.d.ts +64 -0
- package/dist/coordination/mailbox-constants.d.ts.map +1 -0
- package/dist/coordination/mailbox-events.d.ts +32 -0
- package/dist/coordination/mailbox-events.d.ts.map +1 -0
- package/dist/coordination/mailbox-message-codec.d.ts +8 -0
- package/dist/coordination/mailbox-message-codec.d.ts.map +1 -0
- package/dist/coordination/mailbox-types.d.ts +88 -4
- package/dist/coordination/mailbox-types.d.ts.map +1 -1
- package/dist/coordination/mailbox.d.ts +21 -2
- package/dist/coordination/mailbox.d.ts.map +1 -1
- package/dist/coordination/package-author-tracker.d.ts.map +1 -1
- package/dist/coordination/subagent-result-tool.d.ts.map +1 -1
- package/dist/defaults/index.js +846 -523
- package/dist/defaults/index.js.map +4 -4
- package/dist/execution/autonomous-runner.d.ts +7 -1
- package/dist/execution/autonomous-runner.d.ts.map +1 -1
- package/dist/execution/autonomy-brain.d.ts +72 -11
- package/dist/execution/autonomy-brain.d.ts.map +1 -1
- package/dist/execution/brain-chain.d.ts +53 -0
- package/dist/execution/brain-chain.d.ts.map +1 -0
- package/dist/execution/brain-evaluation.d.ts +66 -0
- package/dist/execution/brain-evaluation.d.ts.map +1 -0
- package/dist/execution/brain-runtime.d.ts +171 -0
- package/dist/execution/brain-runtime.d.ts.map +1 -0
- package/dist/execution/council-brain.d.ts +79 -0
- package/dist/execution/council-brain.d.ts.map +1 -0
- package/dist/execution/eternal-autonomy.d.ts +12 -0
- package/dist/execution/eternal-autonomy.d.ts.map +1 -1
- package/dist/execution/index.d.ts +5 -1
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +1350 -377
- package/dist/execution/index.js.map +4 -4
- package/dist/execution/parallel-eternal-engine.d.ts +12 -0
- package/dist/execution/parallel-eternal-engine.d.ts.map +1 -1
- package/dist/execution/tool-executor.d.ts.map +1 -1
- package/dist/hq/auth-store.d.ts +21 -3
- package/dist/hq/auth-store.d.ts.map +1 -1
- package/dist/hq/factory.d.ts +3 -0
- package/dist/hq/factory.d.ts.map +1 -1
- package/dist/hq/index.js +628 -72
- package/dist/hq/index.js.map +4 -4
- package/dist/hq/protocol.d.ts +54 -2
- package/dist/hq/protocol.d.ts.map +1 -1
- package/dist/hq/publisher.d.ts +4 -0
- package/dist/hq/publisher.d.ts.map +1 -1
- package/dist/index.d.ts +12 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3482 -1495
- package/dist/index.js.map +4 -4
- package/dist/kernel/events.d.ts +22 -4
- package/dist/kernel/events.d.ts.map +1 -1
- package/dist/kernel/index.js.map +2 -2
- package/dist/mailbox-attach.d.ts.map +1 -1
- package/dist/observability/index.js +16 -15
- package/dist/observability/index.js.map +2 -2
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +253 -21
- package/dist/security/index.js.map +4 -4
- package/dist/security/permission-policy-schema.d.ts +77 -0
- package/dist/security/permission-policy-schema.d.ts.map +1 -0
- package/dist/security/permission-policy.d.ts +5 -0
- package/dist/security/permission-policy.d.ts.map +1 -1
- package/dist/security/secret-vault.d.ts +9 -0
- package/dist/security/secret-vault.d.ts.map +1 -1
- package/dist/session-registry.d.ts.map +1 -1
- package/dist/storage/config-loader.d.ts +10 -0
- package/dist/storage/config-loader.d.ts.map +1 -1
- package/dist/storage/goal-store.d.ts +1 -1
- package/dist/storage/goal-store.d.ts.map +1 -1
- package/dist/storage/index.js +147 -162
- package/dist/storage/index.js.map +2 -2
- package/dist/storage/plan-store.d.ts +1 -1
- package/dist/storage/plan-store.d.ts.map +1 -1
- package/dist/storage/queue-store.d.ts +4 -0
- package/dist/storage/queue-store.d.ts.map +1 -1
- package/dist/storage/session-store.d.ts +9 -0
- package/dist/storage/session-store.d.ts.map +1 -1
- package/dist/storage/task-store.d.ts +1 -1
- package/dist/storage/task-store.d.ts.map +1 -1
- package/dist/storage/todos-checkpoint.d.ts +2 -2
- package/dist/storage/todos-checkpoint.d.ts.map +1 -1
- package/dist/types/config.d.ts +209 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +2 -2
- package/dist/types/multi-agent.d.ts +8 -0
- package/dist/types/multi-agent.d.ts.map +1 -1
- package/dist/types/observability.d.ts +5 -0
- package/dist/types/observability.d.ts.map +1 -1
- package/dist/types/tool.d.ts +7 -0
- package/dist/types/tool.d.ts.map +1 -1
- package/dist/utils/glob-expand.d.ts.map +1 -1
- package/dist/utils/incoming-images.d.ts +39 -0
- package/dist/utils/incoming-images.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +81 -3
- package/dist/utils/index.js.map +3 -3
- package/dist/worktree/worktree-manager.d.ts +13 -4
- package/dist/worktree/worktree-manager.d.ts.map +1 -1
- package/instructions/agents/browser.md +25 -16
- package/instructions/coordination/subagent-baseline.md +16 -2
- package/instructions/leader-after-task.md +3 -1
- package/instructions/sections/tool/common-patterns.md +7 -1
- package/instructions/system.md +47 -0
- package/package.json +2 -2
- package/skills/docker-deploy/SKILL.md +1 -1
- package/skills/wrongstack-mailbox/SKILL.md +51 -12
- package/dist/plugins/git-plugin.d.ts +0 -15
- package/dist/plugins/git-plugin.d.ts.map +0 -1
- package/dist/plugins/observability-plugin.d.ts +0 -19
- package/dist/plugins/observability-plugin.d.ts.map +0 -1
- package/dist/plugins/plan-plugin.d.ts +0 -16
- package/dist/plugins/plan-plugin.d.ts.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Agent, RunResult } from '../core/agent.js';
|
|
2
2
|
import type { Context } from '../core/context.js';
|
|
3
|
+
import type { Logger } from '../types/logger.js';
|
|
3
4
|
import type { DoneCondition } from '../types/multi-agent.js';
|
|
4
5
|
type AutonomousResult = RunResult & {
|
|
5
6
|
toolCalls: number;
|
|
@@ -14,7 +15,10 @@ export interface DoneCheckResult {
|
|
|
14
15
|
export declare class DoneConditionChecker {
|
|
15
16
|
private readonly condition;
|
|
16
17
|
private readonly compiledRegex;
|
|
17
|
-
|
|
18
|
+
private readonly logger;
|
|
19
|
+
constructor(condition: DoneCondition, opts?: {
|
|
20
|
+
logger?: Logger | undefined;
|
|
21
|
+
});
|
|
18
22
|
check(state: {
|
|
19
23
|
iterations: number;
|
|
20
24
|
toolCalls: number;
|
|
@@ -38,6 +42,8 @@ export interface AutonomousRunnerOptions {
|
|
|
38
42
|
* re-invocation needed). The runner still provides iteration/timeouts.
|
|
39
43
|
*/
|
|
40
44
|
enableAutonomousContinue?: boolean | undefined;
|
|
45
|
+
/** Logger for structured warnings. Falls back to console.warn when omitted. */
|
|
46
|
+
logger?: Logger | undefined;
|
|
41
47
|
}
|
|
42
48
|
export declare class AutonomousRunner {
|
|
43
49
|
private readonly opts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autonomous-runner.d.ts","sourceRoot":"","sources":["../../src/execution/autonomous-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAI7D,KAAK,gBAAgB,GAAG,SAAS,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEvF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,oBAAoB;
|
|
1
|
+
{"version":3,"file":"autonomous-runner.d.ts","sourceRoot":"","sources":["../../src/execution/autonomous-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,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AC;IAC/C,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,qBAAa,gBAAgB;IAOf,OAAO,CAAC,QAAQ,CAAC,IAAI;IANjC,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,UAAU,CAAC,CAAqB;IACxC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuB;IAEnD,YAA6B,IAAI,EAAE,uBAAuB,EAEzD;IAEK,GAAG,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAgCrC;YAEa,OAAO;IA6GrB,IAAI,IAAI,IAAI,CAEX;CACF"}
|
|
@@ -28,11 +28,27 @@
|
|
|
28
28
|
*/
|
|
29
29
|
import type { Provider } from '../types/provider.js';
|
|
30
30
|
import type { BrainArbiter, BrainDecision, BrainDecisionRequest } from '../coordination/brain.js';
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
/** One (provider, model) pair the Brain may call for a decision. */
|
|
32
|
+
export interface BrainLlmTarget {
|
|
33
33
|
provider: Provider;
|
|
34
|
-
/** Model to use for decisions (should be fast + cheap). */
|
|
35
34
|
model: string;
|
|
35
|
+
/** Display label for logs/status (e.g. "anthropic/claude-haiku"). */
|
|
36
|
+
label?: string | undefined;
|
|
37
|
+
}
|
|
38
|
+
export interface AutonomyBrainOptions {
|
|
39
|
+
/** LLM provider for decision-making. Ignored when `targets` is non-empty. */
|
|
40
|
+
provider?: Provider | undefined;
|
|
41
|
+
/** Model to use for decisions (should be fast + cheap). Ignored when `targets` is non-empty. */
|
|
42
|
+
model?: string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Ordered LLM pool. With `strategy: 'fallback'` (default) the first target
|
|
45
|
+
* is primary and later ones are tried in order when a call fails/times
|
|
46
|
+
* out; with 'round-robin' successive decisions rotate the starting target.
|
|
47
|
+
* At least one of `targets` / (`provider` + `model`) must be provided.
|
|
48
|
+
*/
|
|
49
|
+
targets?: BrainLlmTarget[] | undefined;
|
|
50
|
+
/** Pool selection strategy. Default 'fallback'. */
|
|
51
|
+
strategy?: 'fallback' | 'round-robin' | undefined;
|
|
36
52
|
/** Maximum risk level the brain will auto-decide. Default: 'high'.
|
|
37
53
|
* 'low' — only auto-decide low-risk questions
|
|
38
54
|
* 'medium' — auto-decide low/medium
|
|
@@ -42,6 +58,12 @@ export interface AutonomyBrainOptions {
|
|
|
42
58
|
maxAutoRisk?: 'low' | 'medium' | 'high' | 'all' | undefined;
|
|
43
59
|
/** Timeout for each decision call (ms). Default: 15_000. */
|
|
44
60
|
decisionTimeoutMs?: number | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Decision-history digest for the LLM prompt (typically
|
|
63
|
+
* `BrainDecisionLedger.digestFor`): how similar past decisions went and
|
|
64
|
+
* how they turned out. Appended to the user message when non-empty.
|
|
65
|
+
*/
|
|
66
|
+
getDecisionDigest?: ((request: BrainDecisionRequest) => string | undefined) | undefined;
|
|
45
67
|
/**
|
|
46
68
|
* Called after every decision with a human-readable summary.
|
|
47
69
|
* Use this to log decisions into chat history, journal, or status line.
|
|
@@ -64,18 +86,38 @@ export interface TieredBrainArbiterOptions {
|
|
|
64
86
|
* entirely (everything the policy can't answer goes to the human).
|
|
65
87
|
*/
|
|
66
88
|
getMaxAutoRisk?: (() => BrainAutoRisk) | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Multi-LLM council (createCouncilBrainArbiter). When present, requests at
|
|
91
|
+
* or above the council risk floor are decided by the council INSTEAD of
|
|
92
|
+
* the single-LLM layer. Council answers AND denies are terminal — a panel
|
|
93
|
+
* that considered the question and refused is a real decision, not a
|
|
94
|
+
* failure. Only `ask_human` (quorum not met / judge unavailable) falls
|
|
95
|
+
* through to the escalation tier.
|
|
96
|
+
*/
|
|
97
|
+
council?: BrainArbiter | undefined;
|
|
98
|
+
/** Live council risk floor. Default 'high'. Read on every decision. */
|
|
99
|
+
getCouncilMinRisk?: (() => 'medium' | 'high' | 'critical') | undefined;
|
|
67
100
|
}
|
|
68
101
|
/**
|
|
69
|
-
* The standard Brain positioning: policy first, LLM second,
|
|
102
|
+
* The standard Brain positioning: policy first, LLM/council second,
|
|
103
|
+
* escalation last.
|
|
70
104
|
*
|
|
71
105
|
* 1. POLICY — deterministic DefaultBrainArbiter (low-risk fast path,
|
|
72
|
-
* fallback semantics).
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
106
|
+
* fallback semantics). Denies and option-backed answers pass through
|
|
107
|
+
* untouched. A fallback-produced `continue` answer (no optionId, the
|
|
108
|
+
* request declared `fallback: 'continue'`) is only PROVISIONAL: it
|
|
109
|
+
* means "nobody could decide", not "this is the right call", so the
|
|
110
|
+
* LLM tier still gets consulted within the ceiling. Historically it
|
|
111
|
+
* short-circuited here, which meant e.g. goal-completion checks never
|
|
112
|
+
* reached the LLM at all.
|
|
113
|
+
* 2. COUNCIL — requests at/above the council floor (default 'high') are
|
|
114
|
+
* decided by the multi-LLM council when one is wired.
|
|
115
|
+
* 3. LLM — everything else within the live ceiling goes to the
|
|
116
|
+
* single-LLM autonomous brain. Only a real `answer` short-circuits;
|
|
117
|
+
* denials/failures fall through.
|
|
118
|
+
* 4. ESCALATION — anything left escalates. Callers wrap this in
|
|
119
|
+
* `EscalationRoutingBrainArbiter` (interactive prompt or headless
|
|
120
|
+
* terminal policy) or the legacy `HumanEscalatingBrainArbiter`.
|
|
79
121
|
*/
|
|
80
122
|
export declare function createTieredBrainArbiter(opts: TieredBrainArbiterOptions): BrainArbiter;
|
|
81
123
|
/**
|
|
@@ -87,4 +129,23 @@ export declare function createAutonomyBrain(opts: AutonomyBrainOptions): BrainAr
|
|
|
87
129
|
* Format a decision as a human-readable one-liner for chat history.
|
|
88
130
|
*/
|
|
89
131
|
export declare function formatDecisionSummary(decision: BrainDecision, request: BrainDecisionRequest): string;
|
|
132
|
+
/**
|
|
133
|
+
* Render a decision request as the user message for a Brain LLM call.
|
|
134
|
+
* Shared by the single-LLM tier and every council voter so all of them see
|
|
135
|
+
* the same question/context/options shape.
|
|
136
|
+
*/
|
|
137
|
+
export declare function buildBrainUserMessage(request: BrainDecisionRequest): string;
|
|
138
|
+
/** Append a decision-history digest to a Brain user message (shared shape). */
|
|
139
|
+
export declare function withDecisionDigest(user: string, digest: string | undefined): string;
|
|
140
|
+
/**
|
|
141
|
+
* One Brain LLM call against a single target. Throws on transport failure,
|
|
142
|
+
* timeout, or abort — callers own the pool/fallback semantics.
|
|
143
|
+
*/
|
|
144
|
+
export declare function completeBrainLlm(target: BrainLlmTarget, input: {
|
|
145
|
+
system: string;
|
|
146
|
+
user: string;
|
|
147
|
+
timeoutMs: number;
|
|
148
|
+
maxTokens?: number | undefined;
|
|
149
|
+
}): Promise<string>;
|
|
150
|
+
export declare function parseOptionDecision(rawText: string, options: NonNullable<BrainDecisionRequest['options']>): BrainDecision | null;
|
|
90
151
|
//# sourceMappingURL=autonomy-brain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autonomy-brain.d.ts","sourceRoot":"","sources":["../../src/execution/autonomy-brain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAIlG,MAAM,WAAW,oBAAoB;IACnC,
|
|
1
|
+
{"version":3,"file":"autonomy-brain.d.ts","sourceRoot":"","sources":["../../src/execution/autonomy-brain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,o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single-LLM pool + optional multi-LLM council) that
|
|
4
|
+
* `createTieredBrainArbiter` composes. Shared by every host that wires a
|
|
5
|
+
* Brain (CLI/TUI in `wiring/brain-and-orchestration.ts`, the standalone
|
|
6
|
+
* WebUI server in `backend-services.ts`) so the config surface behaves
|
|
7
|
+
* identically everywhere.
|
|
8
|
+
*
|
|
9
|
+
* Hosts differ only in HOW a provider id becomes a `Provider` instance, so
|
|
10
|
+
* that is the one injected dependency (`resolveProvider`). Unresolvable
|
|
11
|
+
* pool/council entries are skipped — one bad ref never takes the Brain down.
|
|
12
|
+
*
|
|
13
|
+
* @module brain-chain
|
|
14
|
+
*/
|
|
15
|
+
import type { BrainArbiter, BrainDecisionRequest } from '../coordination/brain.js';
|
|
16
|
+
import type { BrainConfig } from '../types/config.js';
|
|
17
|
+
import type { Provider } from '../types/provider.js';
|
|
18
|
+
export interface BrainTierAssemblyOptions {
|
|
19
|
+
/** `config.brain` — undefined assembles the legacy session-model single tier. */
|
|
20
|
+
brainConfig: BrainConfig | undefined;
|
|
21
|
+
/** The session's provider id (`config.provider`). */
|
|
22
|
+
defaultProviderId: string;
|
|
23
|
+
/** Live session provider — read per decision so `/setmodel` switches apply. */
|
|
24
|
+
sessionProvider: () => Provider;
|
|
25
|
+
/** Live session model id — read per decision. */
|
|
26
|
+
sessionModel: () => string;
|
|
27
|
+
/**
|
|
28
|
+
* Resolve a NON-default provider id to a Provider instance. May throw or
|
|
29
|
+
* return null; the entry is then skipped.
|
|
30
|
+
*/
|
|
31
|
+
resolveProvider: (providerId: string, model: string) => Provider | null;
|
|
32
|
+
/**
|
|
33
|
+
* Decision-history digest (typically `BrainDecisionLedger.digestFor`) —
|
|
34
|
+
* injected into both the single-LLM and council prompts so the Brain
|
|
35
|
+
* learns from the outcomes of its past similar decisions.
|
|
36
|
+
*/
|
|
37
|
+
getDecisionDigest?: ((request: BrainDecisionRequest) => string | undefined) | undefined;
|
|
38
|
+
}
|
|
39
|
+
export interface BrainTierAssembly {
|
|
40
|
+
/** Single-LLM tier for `TieredBrainArbiterOptions.autonomous`. */
|
|
41
|
+
autonomous: BrainArbiter;
|
|
42
|
+
/** Council tier for `TieredBrainArbiterOptions.council` (undefined = disabled). */
|
|
43
|
+
council: BrainArbiter | undefined;
|
|
44
|
+
/** Live council risk floor for `TieredBrainArbiterOptions.getCouncilMinRisk`. */
|
|
45
|
+
getCouncilMinRisk: () => 'medium' | 'high' | 'critical';
|
|
46
|
+
/** Human-readable pool labels for status surfaces; empty = session model. */
|
|
47
|
+
poolLabels: string[];
|
|
48
|
+
/** Human-readable council seat labels; empty = council disabled. */
|
|
49
|
+
councilLabels: string[];
|
|
50
|
+
}
|
|
51
|
+
/** Assemble the LLM tiers of the Brain chain from `Config.brain`. */
|
|
52
|
+
export declare function assembleBrainTiers(opts: BrainTierAssemblyOptions): BrainTierAssembly;
|
|
53
|
+
//# sourceMappingURL=brain-chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brain-chain.d.ts","sourceRoot":"","sources":["../../src/execution/brain-chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAWrD,MAAM,WAAW,wBAAwB;IACvC,iFAAiF;IACjF,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,qDAAqD;IACrD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,eAAe,EAAE,MAAM,QAAQ,CAAC;IAChC,iDAAiD;IACjD,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B;;;OAGG;IACH,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,QAAQ,GAAG,IAAI,CAAC;IACxE;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,oBAAoB,KAAK,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;CACzF;AAED,MAAM,WAAW,iBAAiB;IAChC,kEAAkE;IAClE,UAAU,EAAE,YAAY,CAAC;IACzB,mFAAmF;IACnF,OAAO,EAAE,YAAY,GAAG,SAAS,CAAC;IAClC,iFAAiF;IACjF,iBAAiB,EAAE,MAAM,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACxD,6EAA6E;IAC7E,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,oEAAoE;IACpE,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB,CAqGpF"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { BrainArbiter, BrainDecision, BrainDecisionRequest } from '../coordination/brain.js';
|
|
2
|
+
export declare const BRAIN_EVALUATION_CASE_VERSION: 1;
|
|
3
|
+
export interface BrainEvaluationExpectations {
|
|
4
|
+
/** Restrict the accepted decision variants for this case. */
|
|
5
|
+
allowedDecisionTypes?: BrainDecision['type'][] | undefined;
|
|
6
|
+
/** Exact option ids that may be selected. Every id must exist in the request. */
|
|
7
|
+
allowedOptionIds?: string[] | undefined;
|
|
8
|
+
/** Options that represent an unsafe allowance and must fail the case. */
|
|
9
|
+
unsafeOptionIds?: string[] | undefined;
|
|
10
|
+
/** Require an answer to carry an exact option id. */
|
|
11
|
+
requireOptionId?: boolean | undefined;
|
|
12
|
+
/** Whether ask_human is acceptable rather than an unnecessary escalation. */
|
|
13
|
+
allowEscalation?: boolean | undefined;
|
|
14
|
+
}
|
|
15
|
+
/** Versioned, JSON-serializable fixture for side-effect-free Brain evaluation. */
|
|
16
|
+
export interface BrainEvaluationCaseV1 {
|
|
17
|
+
version: typeof BRAIN_EVALUATION_CASE_VERSION;
|
|
18
|
+
id: string;
|
|
19
|
+
description?: string | undefined;
|
|
20
|
+
request: BrainDecisionRequest;
|
|
21
|
+
expectations?: BrainEvaluationExpectations | undefined;
|
|
22
|
+
}
|
|
23
|
+
export type BrainEvaluationFailureCode = 'invalid_fixture' | 'arbiter_error' | 'unexpected_decision_type' | 'invalid_option_id' | 'missing_option_id' | 'disallowed_option_id' | 'unsafe_option_id' | 'unexpected_escalation';
|
|
24
|
+
export interface BrainEvaluationFailure {
|
|
25
|
+
code: BrainEvaluationFailureCode;
|
|
26
|
+
message: string;
|
|
27
|
+
}
|
|
28
|
+
export interface BrainEvaluationCaseResult {
|
|
29
|
+
caseId: string;
|
|
30
|
+
passed: boolean;
|
|
31
|
+
decision?: BrainDecision | undefined;
|
|
32
|
+
failures: BrainEvaluationFailure[];
|
|
33
|
+
latencyMs: number;
|
|
34
|
+
}
|
|
35
|
+
export interface BrainEvaluationMetrics {
|
|
36
|
+
totalCases: number;
|
|
37
|
+
passedCases: number;
|
|
38
|
+
failedCases: number;
|
|
39
|
+
optionDecisionCount: number;
|
|
40
|
+
invalidOptionCount: number;
|
|
41
|
+
validOptionRate: number;
|
|
42
|
+
unsafeAllowanceCount: number;
|
|
43
|
+
unnecessaryEscalationCount: number;
|
|
44
|
+
averageLatencyMs: number;
|
|
45
|
+
}
|
|
46
|
+
export interface BrainEvaluationReport {
|
|
47
|
+
version: typeof BRAIN_EVALUATION_CASE_VERSION;
|
|
48
|
+
results: BrainEvaluationCaseResult[];
|
|
49
|
+
metrics: BrainEvaluationMetrics;
|
|
50
|
+
}
|
|
51
|
+
export type BrainEvaluationCaseValidation = {
|
|
52
|
+
ok: true;
|
|
53
|
+
value: BrainEvaluationCaseV1;
|
|
54
|
+
} | {
|
|
55
|
+
ok: false;
|
|
56
|
+
diagnostics: string[];
|
|
57
|
+
};
|
|
58
|
+
/** Validate a fixture loaded from JSON before any arbiter is invoked. */
|
|
59
|
+
export declare function validateBrainEvaluationCase(value: unknown): BrainEvaluationCaseValidation;
|
|
60
|
+
/**
|
|
61
|
+
* Replay evaluation fixtures through a Brain arbiter without applying the
|
|
62
|
+
* returned decisions. The runner has no dispatch, terminate, permission, or
|
|
63
|
+
* tool-execution callback, so a result can only be measured and reported.
|
|
64
|
+
*/
|
|
65
|
+
export declare function runBrainEvaluation(arbiter: BrainArbiter, cases: readonly unknown[]): Promise<BrainEvaluationReport>;
|
|
66
|
+
//# sourceMappingURL=brain-evaluation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brain-evaluation.d.ts","sourceRoot":"","sources":["../../src/execution/brain-evaluation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAElG,eAAO,MAAM,6BAA6B,EAAG,CAAU,CAAC;AAExD,MAAM,WAAW,2BAA2B;IAC1C,6DAA6D;IAC7D,oBAAoB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,CAAC;IAC3D,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACxC,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACvC,qDAAqD;IACrD,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,6EAA6E;IAC7E,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACvC;AAED,kFAAkF;AAClF,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,6BAA6B,CAAC;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,YAAY,CAAC,EAAE,2BAA2B,GAAG,SAAS,CAAC;CACxD;AAED,MAAM,MAAM,0BAA0B,GAClC,iBAAiB,GACjB,eAAe,GACf,0BAA0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AC,qBAAqB,CAAC,CA0FhC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BrainRuntime — the live, rebuildable owner of `config.brain`.
|
|
3
|
+
*
|
|
4
|
+
* The Brain chain used to be assembled once at boot; every knob except the
|
|
5
|
+
* risk ceiling and escalation mode was frozen until restart. This module
|
|
6
|
+
* makes the whole `BrainConfig` surface live-editable AND persistable from
|
|
7
|
+
* any host surface (/brain subcommands, TUI Brain panel, WebUI BrainSection):
|
|
8
|
+
*
|
|
9
|
+
* - `arbiter` is a STABLE delegating handle (`decide` reads a mutable
|
|
10
|
+
* `current`), so hosts wrap it once in their EscalationRouting/Observable
|
|
11
|
+
* layers and no consumer ever needs a rebind after a settings change.
|
|
12
|
+
* - `apply(patch)` normalizes + validates the patch, commits it, rebuilds
|
|
13
|
+
* the tier chain when a structural knob changed (pool, council, timeout,
|
|
14
|
+
* ledger guard), and persists through an injected callback — core never
|
|
15
|
+
* touches config files itself.
|
|
16
|
+
* - `getSnapshot()` is the JSON-safe truth both UIs render: configured
|
|
17
|
+
* values plus derived facts (resolved pool/council labels, EFFECTIVE
|
|
18
|
+
* council enablement, session-model fallback).
|
|
19
|
+
*
|
|
20
|
+
* Persistence contract: `config.brain` is on the in-project deny list, so
|
|
21
|
+
* the injected `persist` MUST write the GLOBAL config. A persist failure
|
|
22
|
+
* never rolls back the live change; it is reported via the returned promise.
|
|
23
|
+
*
|
|
24
|
+
* @module brain-runtime
|
|
25
|
+
*/
|
|
26
|
+
import { type BrainArbiter, type BrainDecisionRequest, type BrainEscalationMode } from '../coordination/brain.js';
|
|
27
|
+
import type { BrainConfig, BrainCouncilVoterConfig, BrainModelEntry } from '../types/config.js';
|
|
28
|
+
import type { Provider } from '../types/provider.js';
|
|
29
|
+
import { type BrainAutoRisk } from './autonomy-brain.js';
|
|
30
|
+
export type BrainCouncilMinRisk = 'medium' | 'high' | 'critical';
|
|
31
|
+
export type BrainPoolStrategy = 'fallback' | 'round-robin';
|
|
32
|
+
/** JSON-safe view of the live Brain configuration + derived facts. */
|
|
33
|
+
export interface BrainConfigSnapshot {
|
|
34
|
+
mode: BrainEscalationMode;
|
|
35
|
+
maxAutoRisk: BrainAutoRisk;
|
|
36
|
+
/** Configured pool entries (normalized). Empty = session model. */
|
|
37
|
+
models: BrainModelEntry[];
|
|
38
|
+
strategy: BrainPoolStrategy;
|
|
39
|
+
decisionTimeoutMs: number | undefined;
|
|
40
|
+
humanTimeoutMs: number | undefined;
|
|
41
|
+
council: {
|
|
42
|
+
/** EFFECTIVE enablement (default rule `voters >= 2` applied). */
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
/** Raw configured value (undefined = default rule decides). */
|
|
45
|
+
configured: boolean | undefined;
|
|
46
|
+
minRisk: BrainCouncilMinRisk;
|
|
47
|
+
/** Explicitly configured voters; seats derived from the pool are visible via `councilLabels`. */
|
|
48
|
+
voters: BrainCouncilVoterConfig[];
|
|
49
|
+
quorum: number | undefined;
|
|
50
|
+
approval: number | undefined;
|
|
51
|
+
judge: BrainModelEntry | undefined;
|
|
52
|
+
};
|
|
53
|
+
ledger: {
|
|
54
|
+
enabled: boolean;
|
|
55
|
+
autoDenyAfterFailures: number | undefined;
|
|
56
|
+
path: string | undefined;
|
|
57
|
+
};
|
|
58
|
+
/** Resolved pool labels from the LAST assembly (may be fewer than `models` — unresolvable refs are skipped). */
|
|
59
|
+
poolLabels: string[];
|
|
60
|
+
/** Resolved council seat labels; empty = council effectively disabled. */
|
|
61
|
+
councilLabels: string[];
|
|
62
|
+
usingSessionModel: boolean;
|
|
63
|
+
}
|
|
64
|
+
/** Council sub-patch. Arrays REPLACE; `null` clears back to the default. */
|
|
65
|
+
export interface BrainCouncilPatch {
|
|
66
|
+
enabled?: boolean | null | undefined;
|
|
67
|
+
minRisk?: BrainCouncilMinRisk | null | undefined;
|
|
68
|
+
voters?: Array<string | BrainCouncilVoterConfig> | null | undefined;
|
|
69
|
+
quorum?: number | null | undefined;
|
|
70
|
+
approval?: number | null | undefined;
|
|
71
|
+
judge?: string | BrainModelEntry | null | undefined;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Partial update for the live Brain config. Omitted fields are untouched,
|
|
75
|
+
* `null` clears a field back to its default, arrays replace wholesale.
|
|
76
|
+
*/
|
|
77
|
+
export interface BrainConfigPatch {
|
|
78
|
+
mode?: BrainEscalationMode | undefined;
|
|
79
|
+
maxAutoRisk?: BrainAutoRisk | undefined;
|
|
80
|
+
models?: Array<string | BrainModelEntry> | null | undefined;
|
|
81
|
+
strategy?: BrainPoolStrategy | null | undefined;
|
|
82
|
+
decisionTimeoutMs?: number | null | undefined;
|
|
83
|
+
humanTimeoutMs?: number | null | undefined;
|
|
84
|
+
council?: BrainCouncilPatch | null | undefined;
|
|
85
|
+
ledger?: {
|
|
86
|
+
enabled?: boolean | undefined;
|
|
87
|
+
autoDenyAfterFailures?: number | null | undefined;
|
|
88
|
+
} | null | undefined;
|
|
89
|
+
}
|
|
90
|
+
/** Host-owned ledger controller — the runtime never touches ledger files. */
|
|
91
|
+
export interface BrainRuntimeLedgerHost {
|
|
92
|
+
getPath: () => string | undefined;
|
|
93
|
+
isEnabled: () => boolean;
|
|
94
|
+
/** Host starts/stops its BrainDecisionLedger instance. */
|
|
95
|
+
setEnabled: (enabled: boolean) => void;
|
|
96
|
+
failureStreakFor?: ((request: Pick<BrainDecisionRequest, 'source' | 'question' | 'id'>) => number) | undefined;
|
|
97
|
+
getDecisionDigest?: ((request: BrainDecisionRequest) => string | undefined) | undefined;
|
|
98
|
+
}
|
|
99
|
+
export interface BrainRuntimeOptions {
|
|
100
|
+
/** Boot-time `config.brain`. Invalid entries are dropped leniently here (apply() is strict). */
|
|
101
|
+
initialConfig: BrainConfig | undefined;
|
|
102
|
+
/** The session's provider id (`config.provider`). */
|
|
103
|
+
defaultProviderId: string;
|
|
104
|
+
/** Live session provider — read per decision so `/setmodel` switches apply. */
|
|
105
|
+
sessionProvider: () => Provider;
|
|
106
|
+
/** Live session model id — read per decision. */
|
|
107
|
+
sessionModel: () => string;
|
|
108
|
+
/** Resolve a NON-default provider id. May throw / return null → entry skipped. */
|
|
109
|
+
resolveProvider: (providerId: string, model: string) => Provider | null;
|
|
110
|
+
ledger?: BrainRuntimeLedgerHost | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Injected writer for the canonical `BrainConfig`. MUST target the global
|
|
113
|
+
* config (`config.brain` is denied in project scope). Absent = live-only.
|
|
114
|
+
*/
|
|
115
|
+
persist?: ((config: BrainConfig) => Promise<void>) | undefined;
|
|
116
|
+
/** Fired after every successful apply, with the fresh snapshot. */
|
|
117
|
+
onApplied?: ((snapshot: BrainConfigSnapshot) => void) | undefined;
|
|
118
|
+
}
|
|
119
|
+
export interface BrainApplyResult {
|
|
120
|
+
snapshot: BrainConfigSnapshot;
|
|
121
|
+
/** Resolves `{ok: true}` immediately when persistence was skipped or absent. */
|
|
122
|
+
persisted: Promise<{
|
|
123
|
+
ok: boolean;
|
|
124
|
+
error?: string | undefined;
|
|
125
|
+
}>;
|
|
126
|
+
}
|
|
127
|
+
export interface BrainRuntime {
|
|
128
|
+
/** STABLE arbiter handle — the inner tier chain swaps on `apply`. */
|
|
129
|
+
arbiter: BrainArbiter;
|
|
130
|
+
getMode(): BrainEscalationMode;
|
|
131
|
+
getMaxAutoRisk(): BrainAutoRisk;
|
|
132
|
+
getHumanTimeoutMs(): number | undefined;
|
|
133
|
+
getSnapshot(): BrainConfigSnapshot;
|
|
134
|
+
/** Canonical shape written to `config.brain` (compact string refs where lossless). */
|
|
135
|
+
getConfig(): BrainConfig;
|
|
136
|
+
/** Live-apply synchronously; persistence (default on) is async best-effort. */
|
|
137
|
+
apply(patch: BrainConfigPatch, opts?: {
|
|
138
|
+
persist?: boolean | undefined;
|
|
139
|
+
}): BrainApplyResult;
|
|
140
|
+
}
|
|
141
|
+
export interface BrainDefaultsContext {
|
|
142
|
+
/** The session's fallback chain (`config.fallbackModels`) — seeds the default pool. */
|
|
143
|
+
fallbackModels?: readonly string[] | undefined;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Product defaults for hosts that want a minimum-human Brain out of the box
|
|
147
|
+
* (CLI/TUI wiring and the standalone WebUI server both apply this before
|
|
148
|
+
* `createBrainRuntime`). Only FILLS GAPS — every explicitly configured field
|
|
149
|
+
* wins, so existing `config.brain` blocks are untouched by updates.
|
|
150
|
+
*
|
|
151
|
+
* - `models` → the user's own `fallbackModels` chain (never hardcoded
|
|
152
|
+
* model ids; every install has different providers). With ≥2 entries the
|
|
153
|
+
* council auto-derives from the pool, so multi-model users get a council
|
|
154
|
+
* by default.
|
|
155
|
+
* - `mode` → 'headless': decisions never block on a human; the terminal
|
|
156
|
+
* policy (safe default / deny) is the escalation of last resort.
|
|
157
|
+
* - `maxAutoRisk` → adaptive: 'all' when a council can convene (critical
|
|
158
|
+
* questions get a multi-model panel), otherwise 'high' (critical
|
|
159
|
+
* questions resolve via the conservative terminal policy instead of a
|
|
160
|
+
* single unchecked model).
|
|
161
|
+
* - `humanTimeoutMs` → 120s: if the user explicitly switches back to
|
|
162
|
+
* 'interactive', an unanswered prompt still auto-resolves instead of
|
|
163
|
+
* hanging an unattended run forever. Set `humanTimeoutMs: 0` to restore
|
|
164
|
+
* the legacy wait-indefinitely behavior.
|
|
165
|
+
*
|
|
166
|
+
* NOTE deliberately NOT persisted anywhere — resolved at boot, so existing
|
|
167
|
+
* users pick these up on update without any config migration/write.
|
|
168
|
+
*/
|
|
169
|
+
export declare function resolveBrainConfigDefaults(brain: BrainConfig | undefined, ctx?: BrainDefaultsContext): BrainConfig;
|
|
170
|
+
export declare function createBrainRuntime(opts: BrainRuntimeOptions): BrainRuntime;
|
|
171
|
+
//# sourceMappingURL=brain-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brain-runtime.d.ts","sourceRoot":"","sources":["../../src/execution/brain-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;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CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC,CAAC;CACjE;AAED,MAAM,WAAW,YAAY;IAC3B,qEAAqE;IACrE,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,IAAI,mBAAmB,CAAC;IAC/B,cAAc,IAAI,aAAa,CAAC;IAChC,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAAC;IACxC,WAAW,IAAI,mBAAmB,CAAC;IACnC,sFAAsF;IACtF,SAAS,IAAI,WAAW,CAAC;IACzB,+EAA+E;IAC/E,KAAK,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;KAAE,GAAG,gBAAgB,CAAC;CAC5F;AAkED,MAAM,WAAW,oBAAoB;IACnC,uFAAuF;IACvF,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,WAAW,GAAG,SAAS,EAC9B,GAAG,GAAE,oBAAyB,GAC7B,WAAW,CAWb;AA6BD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,mBAAmB,GAAG,YAAY,CAiP1E"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CouncilBrainArbiter — a multi-LLM decision panel for high-stakes questions.
|
|
3
|
+
*
|
|
4
|
+
* Instead of trusting one model's single completion, the council convenes N
|
|
5
|
+
* independent voters (ideally different models/providers), each with a
|
|
6
|
+
* distinct decision persona:
|
|
7
|
+
*
|
|
8
|
+
* - executor — biased toward forward progress; hates stalling.
|
|
9
|
+
* - skeptic — hunts for the reason the proposed action is wrong; may veto.
|
|
10
|
+
* - auditor — cost/waste/budget lens; hates throwing tokens at dead ends.
|
|
11
|
+
*
|
|
12
|
+
* Votes are cast INDEPENDENTLY (no voter sees another's rationale), then
|
|
13
|
+
* tallied with weights. Resolution ladder:
|
|
14
|
+
*
|
|
15
|
+
* 1. QUORUM — fewer than `quorumFraction` of seats returned a valid vote
|
|
16
|
+
* → the council abstains (`ask_human`), letting the escalation tier
|
|
17
|
+
* (human prompt or headless terminal policy) resolve it.
|
|
18
|
+
* 2. VETO — a veto seat explicitly refusing denies the request outright.
|
|
19
|
+
* 3. MAJORITY — the option with the highest total weight wins when it
|
|
20
|
+
* exceeds `approvalFraction` of all cast weight.
|
|
21
|
+
* 4. JUDGE — ties / weak pluralities go to a judge model that sees every
|
|
22
|
+
* vote's rationale and issues the final structured decision. No judge
|
|
23
|
+
* (or judge failure) → abstain (`ask_human`).
|
|
24
|
+
*
|
|
25
|
+
* Optionless (free-text) requests skip the tally: every voter writes an
|
|
26
|
+
* independent stance and the judge synthesizes the final answer; without a
|
|
27
|
+
* judge, the first valid stance wins.
|
|
28
|
+
*
|
|
29
|
+
* The council NEVER blocks on a human itself — its worst case is an
|
|
30
|
+
* `ask_human` abstention that the outer escalation tier resolves.
|
|
31
|
+
*
|
|
32
|
+
* @module council-brain
|
|
33
|
+
*/
|
|
34
|
+
import type { BrainArbiter, BrainDecision, BrainDecisionRequest } from '../coordination/brain.js';
|
|
35
|
+
import { type BrainLlmTarget } from './autonomy-brain.js';
|
|
36
|
+
/** One voting seat on the council. */
|
|
37
|
+
export interface CouncilVoter extends BrainLlmTarget {
|
|
38
|
+
/**
|
|
39
|
+
* Decision lens. Built-ins: 'executor', 'skeptic', 'auditor'. Any other
|
|
40
|
+
* string is injected verbatim as the persona description.
|
|
41
|
+
*/
|
|
42
|
+
persona?: string | undefined;
|
|
43
|
+
/** Vote weight in the tally. Default 1. */
|
|
44
|
+
weight?: number | undefined;
|
|
45
|
+
/** When true, this seat's explicit refusal denies the request outright. */
|
|
46
|
+
veto?: boolean | undefined;
|
|
47
|
+
}
|
|
48
|
+
export interface CouncilBrainOptions {
|
|
49
|
+
voters: CouncilVoter[];
|
|
50
|
+
/** Tie-breaker / synthesizer. Default: none (ties abstain to escalation). */
|
|
51
|
+
judge?: BrainLlmTarget | undefined;
|
|
52
|
+
/** Fraction of seats that must return a valid vote. Default 0.5. */
|
|
53
|
+
quorumFraction?: number | undefined;
|
|
54
|
+
/** Fraction of cast weight the winning option must EXCEED. Default 0.5. */
|
|
55
|
+
approvalFraction?: number | undefined;
|
|
56
|
+
/** Per-voter (and judge) completion timeout in ms. Default 15000. */
|
|
57
|
+
decisionTimeoutMs?: number | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Decision-history digest (typically `BrainDecisionLedger.digestFor`) —
|
|
60
|
+
* appended to every voter's user message so the panel sees how similar
|
|
61
|
+
* past decisions turned out.
|
|
62
|
+
*/
|
|
63
|
+
getDecisionDigest?: ((request: BrainDecisionRequest) => string | undefined) | undefined;
|
|
64
|
+
/** Called with a human-readable summary after every council decision. */
|
|
65
|
+
onDecision?: ((summary: string, decision: BrainDecision, request: BrainDecisionRequest) => void) | undefined;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Synthetic ballot entry that lets any voter refuse every real option. Kept
|
|
69
|
+
* deliberately awkward so it can never collide with a caller option id; if
|
|
70
|
+
* it somehow does, the synthetic entry is skipped for that request.
|
|
71
|
+
*/
|
|
72
|
+
export declare const COUNCIL_REFUSE_OPTION_ID = "council_refuse";
|
|
73
|
+
/**
|
|
74
|
+
* Create a council-of-LLMs Brain arbiter. See the module docs for the
|
|
75
|
+
* resolution ladder. Positioned by `createTieredBrainArbiter` above the
|
|
76
|
+
* single-LLM tier for requests at/above the council risk floor.
|
|
77
|
+
*/
|
|
78
|
+
export declare function createCouncilBrainArbiter(opts: CouncilBrainOptions): BrainArbiter;
|
|
79
|
+
//# sourceMappingURL=council-brain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"council-brain.d.ts","sourceRoot":"","sources":["../../src/execution/council-brain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;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us } from '../kernel/events.js';
|
|
3
|
+
import type { Logger } from '../types/logger.js';
|
|
3
4
|
import type { Compactor } from '../types/compactor.js';
|
|
4
5
|
import type { BrainArbiter } from '../coordination/brain.js';
|
|
5
6
|
import { type JournalEntry } from '../storage/goal-store.js';
|
|
@@ -79,6 +80,8 @@ export interface EternalAutonomyOptions {
|
|
|
79
80
|
* Optional clock — tests stub for deterministic timestamps.
|
|
80
81
|
*/
|
|
81
82
|
now?: ((() => Date)) | undefined;
|
|
83
|
+
/** Logger for structured warnings/errors. Falls back to console.error when omitted. */
|
|
84
|
+
logger?: Logger | undefined;
|
|
82
85
|
/**
|
|
83
86
|
* Optional compactor. When provided, the engine runs compaction every
|
|
84
87
|
* `compactEveryNIterations` iterations to keep the agent's message
|
|
@@ -175,8 +178,17 @@ export declare class EternalAutonomyEngine {
|
|
|
175
178
|
private iterationsSinceCompact;
|
|
176
179
|
private readonly goalPath;
|
|
177
180
|
constructor(opts: EternalAutonomyOptions);
|
|
181
|
+
/**
|
|
182
|
+
* Emit a structured error. Uses the configured Logger when available;
|
|
183
|
+
* falls back to console.error(JSON) so events are never silently dropped.
|
|
184
|
+
*/
|
|
185
|
+
private logError;
|
|
178
186
|
/** Current engine state — readable for UIs. */
|
|
179
187
|
get currentState(): EternalEngineState;
|
|
188
|
+
/**
|
|
189
|
+
* Load the goal file with structured logging for parse/schema warnings.
|
|
190
|
+
*/
|
|
191
|
+
private loadGoal;
|
|
180
192
|
/** Synchronously request stop. Resolves once the running iteration aborts. */
|
|
181
193
|
stop(): void;
|
|
182
194
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eternal-autonomy.d.ts","sourceRoot":"","sources":["../../src/execution/eternal-autonomy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,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nC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAElC,YAA6B,IAAI,EAAE,sBAAsB,EAExD;IAED;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAQhB,+CAA+C;IAC/C,IAAI,YAAY,IAAI,kBAAkB,CAErC;IAED;;OAEG;IACH,OAAO,CAAC,QAAQ;IAQhB,8EAA8E;IAC9E,IAAI,IAAI,IAAI,CAcX;IAED;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAI3B;IAED;;;OAGG;IACG,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CA6BzB;IAED;;;;;;;OAOG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAgQxC;IAED;;;;;;;OAOG;YACW,YAAY;IA0C1B;;;;;;;;OAQG;YACW,MAAM;IAsDpB,OAAO,CAAC,eAAe;YAkBT,WAAW;YAeX,aAAa;YAQb,cAAc;IAuD5B,OAAO,CAAC,cAAc;IAqDtB;;;;;;OAMG;IACH,OAAO,CAAC,yBAAyB;IAQjC;;;;OAIG;YACW,kBAAkB;YAUlB,oBAAoB;IAUlC;;;;;OAKG;YACW,eAAe;IAQ7B;;;;;;OAMG;YACW,iBAAiB;IA8B/B;;;;OAIG;YACW,iBAAiB;YAqBjB,aAAa;IAI3B;;;OAGG;YACW,mBAAmB;IA0EjC;;OAEG;YACW,cAAc;YAOd,kBAAkB;CAMjC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export { AutoCompactionMiddleware, type ContextWindowBudgetSnapshot, } from './auto-compaction-middleware.js';
|
|
2
2
|
export { AutonomousRunner, type AutonomousRunnerOptions, type DoneCheckResult, DoneConditionChecker, } from './autonomous-runner.js';
|
|
3
|
-
export { type AutonomyBrainOptions, type BrainAutoRisk, createAutonomyBrain, createTieredBrainArbiter, formatDecisionSummary, type TieredBrainArbiterOptions, } from './autonomy-brain.js';
|
|
3
|
+
export { type AutonomyBrainOptions, type BrainAutoRisk, type BrainLlmTarget, buildBrainUserMessage, completeBrainLlm, createAutonomyBrain, createTieredBrainArbiter, formatDecisionSummary, parseOptionDecision, type TieredBrainArbiterOptions, } from './autonomy-brain.js';
|
|
4
|
+
export { assembleBrainTiers, type BrainTierAssembly, type BrainTierAssemblyOptions, } from './brain-chain.js';
|
|
5
|
+
export { BRAIN_EVALUATION_CASE_VERSION, type BrainEvaluationCaseResult, type BrainEvaluationCaseV1, type BrainEvaluationCaseValidation, type BrainEvaluationExpectations, type BrainEvaluationFailure, type BrainEvaluationFailureCode, type BrainEvaluationMetrics, type BrainEvaluationReport, runBrainEvaluation, validateBrainEvaluationCase, } from './brain-evaluation.js';
|
|
6
|
+
export { type BrainApplyResult, type BrainConfigPatch, type BrainConfigSnapshot, type BrainCouncilMinRisk, type BrainCouncilPatch, type BrainDefaultsContext, type BrainPoolStrategy, type BrainRuntime, type BrainRuntimeLedgerHost, type BrainRuntimeOptions, createBrainRuntime, resolveBrainConfigDefaults, } from './brain-runtime.js';
|
|
7
|
+
export { COUNCIL_REFUSE_OPTION_ID, type CouncilBrainOptions, type CouncilVoter, createCouncilBrainArbiter, } from './council-brain.js';
|
|
4
8
|
export { type AutonomyPromptContributorOptions, makeAutonomyPromptContributor, } from './autonomy-prompt-contributor.js';
|
|
5
9
|
export { type CompactorOptions, HybridCompactor } from './compactor.js';
|
|
6
10
|
export { activateDesign, clearActiveKit, detectFrontendFile, detectFrontendIntent, getDesignState, installDesignStudioMiddleware, makeDesignDetectToolCallMiddleware, makeDesignDetectUserInputMiddleware, makeDesignStudioRequestMiddleware, setActiveKit, } from './design-detect.js';
|