@wrongstack/core 0.299.0 → 0.301.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/chronicle/index.d.ts +2 -0
- package/dist/chronicle/index.js +297 -10
- package/dist/chronicle/project-server.js +253 -15
- package/dist/chronicle/sqlite-compaction.d.ts +20 -0
- package/dist/chronicle/sqlite-journal.d.ts +57 -0
- package/dist/coordination/agents/capability-manifest.d.ts +7 -0
- package/dist/coordination/agents/index.d.ts +3 -2
- package/dist/coordination/agents/index.js +818 -570
- package/dist/coordination/agents/project-agent-identity.d.ts +6 -6
- package/dist/coordination/agents/role-skills.d.ts +1 -1
- package/dist/coordination/agents/types.d.ts +6 -0
- package/dist/coordination/director.d.ts +10 -2
- package/dist/coordination/fleet-manager.d.ts +48 -3
- package/dist/coordination/ifleet-manager.d.ts +2 -0
- package/dist/coordination/index.js +6880 -6440
- package/dist/coordination/mail-tools.d.ts +3 -3
- package/dist/coordination/mailbox-project-server.js +3 -4
- package/dist/coordination/mailbox-types.d.ts +6 -0
- package/dist/coordination/multi-agent-coordinator.d.ts +1 -0
- package/dist/core/agent-response.d.ts +5 -1
- package/dist/core/agent-tools.d.ts +3 -0
- package/dist/core/context.d.ts +20 -0
- package/dist/core/fallback-model.d.ts +48 -0
- package/dist/core/index.d.ts +11 -9
- package/dist/core/index.js +1119 -310
- package/dist/core/instruction-template.d.ts +83 -0
- package/dist/core/next-steps-slot.d.ts +88 -0
- package/dist/core/system-prompt-blocks.d.ts +10 -1
- package/dist/core/system-prompt-builder.d.ts +40 -4
- package/dist/core/system-prompt-memory-skills.d.ts +1 -0
- package/dist/core/system-prompt-skill-bodies.d.ts +3 -3
- package/dist/defaults/index.js +9805 -8767
- package/dist/design/index.js +11 -3
- package/dist/execution/auto-compaction-middleware.d.ts +17 -0
- package/dist/execution/autonomy-brain.d.ts +15 -2
- package/dist/execution/brain-runtime.d.ts +3 -1
- package/dist/execution/compaction-core.d.ts +41 -2
- package/dist/execution/council-brain.d.ts +47 -1
- package/dist/execution/council-orchestrator.d.ts +25 -6
- package/dist/execution/council-prompts.d.ts +12 -1
- package/dist/execution/index.d.ts +11 -10
- package/dist/execution/index.js +10507 -9189
- package/dist/execution/tool-executor.d.ts +4 -1
- package/dist/execution/topic-shift-advisor.d.ts +53 -0
- package/dist/extension/index.js +8 -2
- package/dist/extension/registry.d.ts +8 -1
- package/dist/fleet-notifier.d.ts +9 -2
- package/dist/goal/index.js +11 -3
- package/dist/hooks/index.js +50 -13
- package/dist/hooks/runner.d.ts +12 -1
- package/dist/hq/index.js +59 -21
- package/dist/hq/protocol/fleet.d.ts +20 -0
- package/dist/hq/protocol.js +10 -0
- package/dist/hq/publisher.d.ts +21 -3
- package/dist/index.d.ts +22 -20
- package/dist/index.js +12211 -8572
- package/dist/infrastructure/index.js +108 -21
- package/dist/kernel/events/brain-events.d.ts +9 -0
- package/dist/kernel/events/provider-events.d.ts +42 -1
- package/dist/kernel/events/session-events.d.ts +13 -0
- package/dist/kernel/events/tool-events.d.ts +3 -3
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.js +18 -1
- package/dist/models/provider-credentials.d.ts +54 -0
- package/dist/plugin/api.d.ts +6 -0
- package/dist/plugin/config.d.ts +55 -0
- package/dist/plugin/index.d.ts +2 -1
- package/dist/plugin/index.js +2179 -544
- package/dist/plugins/auto-review-plugin.d.ts +3 -0
- package/dist/plugins/cloud-config-sync-plugin.d.ts +22 -0
- package/dist/plugins/review-claim-registry.d.ts +23 -8
- package/dist/plugins/review-types.d.ts +2 -0
- package/dist/registry/index.js +109 -74
- package/dist/registry/tool-registry.d.ts +15 -0
- package/dist/security/capabilities.d.ts +2 -0
- package/dist/security/index.d.ts +2 -2
- package/dist/security/index.js +166 -44
- package/dist/security/permission-helpers.d.ts +23 -6
- package/dist/security/permission-policy.d.ts +16 -0
- package/dist/security/readonly-permission-policy.d.ts +20 -0
- package/dist/security/totp.d.ts +14 -0
- package/dist/session-registry-atomic-file.d.ts +32 -5
- package/dist/skills/frontmatter.d.ts +6 -0
- package/dist/skills/index.js +22 -5
- package/dist/storage/cloud-config-sync/sanitize.d.ts +54 -0
- package/dist/storage/cloud-config-sync.d.ts +87 -0
- package/dist/storage/director-state.d.ts +7 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.js +887 -74
- package/dist/tools/fallback-system-config-view-tool.d.ts +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +898 -335
- package/dist/tools/one-shot-llm-tool.d.ts +1 -0
- package/dist/tools/plugin-manager.d.ts +27 -0
- package/dist/types/config/mcp-features.d.ts +18 -11
- package/dist/types/config/root.d.ts +8 -1
- package/dist/types/config/runtime.d.ts +20 -6
- package/dist/types/config/skills-fleet-brain.d.ts +12 -4
- package/dist/types/config/tools.d.ts +16 -0
- package/dist/types/context-window.d.ts +1 -0
- package/dist/types/council.d.ts +11 -0
- package/dist/types/hooks.d.ts +14 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +1 -0
- package/dist/types/multi-agent.d.ts +12 -0
- package/dist/types/one-shot-llm.d.ts +25 -0
- package/dist/types/plugin.d.ts +28 -0
- package/dist/types/provider.d.ts +16 -0
- package/dist/types/runtime-capability-manifest.d.ts +168 -0
- package/dist/types/skill.d.ts +5 -0
- package/dist/types/system-prompt.d.ts +3 -1
- package/dist/types/tool-executor.d.ts +8 -1
- package/dist/utils/context-breakdown.d.ts +8 -2
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +141 -31
- package/dist/utils/regex-guard.d.ts +16 -2
- package/dist/utils/sage-output-block.d.ts +7 -10
- package/dist/utils/wstack-paths.d.ts +11 -3
- package/dist/worktree/index.js +4 -4
- package/instructions/agents/browser.md +1 -4
- package/instructions/agents/e2e.md +17 -15
- package/instructions/agents/ios.md +3 -3
- package/instructions/agents/search.md +1 -1
- package/instructions/autonomy/goal-preamble.md +4 -4
- package/instructions/coordination/director-preamble.md +2 -3
- package/instructions/coordination/subagent-baseline.md +3 -1
- package/instructions/leader-after-task.md +12 -0
- package/instructions/llm/chimera-review.md +1 -1
- package/instructions/modes/audit-lite.md +1 -1
- package/instructions/sections/tool/common-patterns.md +18 -2
- package/instructions/sections/tool/mailbox-compact.md +1 -1
- package/instructions/sections/tool/mailbox-full.md +1 -1
- package/instructions/system-lite.md +91 -3
- package/instructions/system-pro.md +296 -102
- package/instructions/system.md +248 -92
- package/package.json +3 -3
- package/skills/api-design/SKILL.md +3 -0
- package/skills/audit-log/SKILL.md +2 -0
- package/skills/auto-review/SKILL.md +6 -1
- package/skills/bug-hunter/SKILL.md +4 -1
- package/skills/chimera/SKILL.md +3 -0
- package/skills/data-governance/SKILL.md +3 -0
- package/skills/design-system/SKILL.md +5 -2
- package/skills/docker-deploy/SKILL.md +2 -0
- package/skills/git-flow/SKILL.md +2 -0
- package/skills/mailbox-bridge/SKILL.md +3 -0
- package/skills/mnemosyne/SKILL.md +2 -0
- package/skills/multi-agent/SKILL.md +4 -1
- package/skills/node-modern/SKILL.md +4 -1
- package/skills/observability/SKILL.md +3 -0
- package/skills/output-standards/SKILL.md +2 -0
- package/skills/plugin-author/SKILL.md +4 -1
- package/skills/prompt-engineering/SKILL.md +3 -1
- package/skills/react-modern/SKILL.md +6 -3
- package/skills/refactor-planner/SKILL.md +2 -0
- package/skills/research-web/SKILL.md +3 -0
- package/skills/sdd/SKILL.md +3 -1
- package/skills/security-scanner/SKILL.md +3 -0
- package/skills/skill-creator/SKILL.md +2 -0
- package/skills/tech-stack/SKILL.md +3 -0
- package/skills/testing/SKILL.md +4 -1
- package/skills/typescript-strict/SKILL.md +4 -1
- package/skills/wrongstack-kanban/SKILL.md +6 -3
- package/skills/wrongstack-mailbox/SKILL.md +4 -1
- package/skills/wrongstack-mailbox-mcp/SKILL.md +10 -8
package/dist/design/index.js
CHANGED
|
@@ -66,6 +66,9 @@ function canonicalProjectRoot(absRoot) {
|
|
|
66
66
|
const commonDirFile = path.join(gitDir, "commondir");
|
|
67
67
|
if (!fs.statSync(commonDirFile).isFile()) return checkoutRoot;
|
|
68
68
|
const commonDir = path.resolve(gitDir, fs.readFileSync(commonDirFile, "utf8").trim());
|
|
69
|
+
const worktreesDir = path.dirname(gitDir);
|
|
70
|
+
if (path.basename(worktreesDir).toLowerCase() !== "worktrees") return checkoutRoot;
|
|
71
|
+
if (path.resolve(worktreesDir, "..") !== commonDir) return checkoutRoot;
|
|
69
72
|
if (path.basename(commonDir).toLowerCase() !== ".git") return checkoutRoot;
|
|
70
73
|
return path.dirname(commonDir);
|
|
71
74
|
} catch {
|
|
@@ -88,7 +91,7 @@ function safeProfileName(name) {
|
|
|
88
91
|
const safe = (name ?? "").replace(/[/\\:]/g, "_").replace(/\.\./g, "_").trim();
|
|
89
92
|
return safe || "default";
|
|
90
93
|
}
|
|
91
|
-
function
|
|
94
|
+
function bootstrapProfileName(globalRoot) {
|
|
92
95
|
try {
|
|
93
96
|
const parsed = JSON.parse(fs.readFileSync(path.join(globalRoot, "config.json"), "utf8"));
|
|
94
97
|
return safeProfileName(
|
|
@@ -106,7 +109,7 @@ function wstackGlobalRoot() {
|
|
|
106
109
|
function resolveWstackPaths(opts) {
|
|
107
110
|
const globalRoot = opts.globalRoot ?? (opts.userHome ? path.join(opts.userHome, ".wrongstack") : wstackGlobalRoot());
|
|
108
111
|
const homeDir = opts.userHome ?? os.homedir();
|
|
109
|
-
const profileName = safeProfileName(opts.profileName ??
|
|
112
|
+
const profileName = safeProfileName(opts.profileName ?? bootstrapProfileName(globalRoot));
|
|
110
113
|
const profileDir = path.join(globalRoot, "profiles", profileName);
|
|
111
114
|
const hash = projectHash(opts.projectRoot);
|
|
112
115
|
const slug = projectSlug(opts.projectRoot);
|
|
@@ -176,7 +179,12 @@ function resolveWstackPaths(opts) {
|
|
|
176
179
|
projectRequirementIntakes: path.join(projectDir, "requirement-intakes"),
|
|
177
180
|
syncConfig: path.join(profileDir, "sync.json"),
|
|
178
181
|
configHistoryDir: path.join(globalRoot, "config-history"),
|
|
179
|
-
projectStatus: (
|
|
182
|
+
projectStatus: (statusProjectSlug) => {
|
|
183
|
+
if (!/^[a-z0-9](?:[a-z0-9-]{0,39})-[a-f0-9]{6}$/.test(statusProjectSlug)) {
|
|
184
|
+
throw new Error(`Invalid project slug: ${statusProjectSlug}`);
|
|
185
|
+
}
|
|
186
|
+
return path.join(globalRoot, "projects", statusProjectSlug, "status.json");
|
|
187
|
+
}
|
|
180
188
|
};
|
|
181
189
|
}
|
|
182
190
|
|
|
@@ -138,6 +138,8 @@ export declare class AutoCompactionMiddleware {
|
|
|
138
138
|
* the caller falls back to a fresh walk.
|
|
139
139
|
*/
|
|
140
140
|
private tryStashedTokens;
|
|
141
|
+
/** Invalidate every token view derived from the pre-rewrite conversation. */
|
|
142
|
+
private invalidateTokenCaches;
|
|
141
143
|
/**
|
|
142
144
|
* Returns true when the previous compaction at the same or higher pressure
|
|
143
145
|
* level reduced nothing and context has not grown materially since. Prevents
|
|
@@ -158,6 +160,21 @@ export declare class AutoCompactionMiddleware {
|
|
|
158
160
|
private emergencyTrim;
|
|
159
161
|
/** Preserve-window size from the active policy, defaulting to 6 recent pairs. */
|
|
160
162
|
private resolvePreserveK;
|
|
163
|
+
/**
|
|
164
|
+
* Aggregate raw acknowledged tool-I/O budget from the active mode.
|
|
165
|
+
*
|
|
166
|
+
* `eliseThreshold` remains the per-result baseline. Multiplying it by the
|
|
167
|
+
* preserve window gives recent multi-tool investigations breathing room;
|
|
168
|
+
* the 12% context cap prevents deep mode or huge custom thresholds from
|
|
169
|
+
* turning that room into another unbounded prompt owner.
|
|
170
|
+
*/
|
|
171
|
+
private resolveToolResultRetention;
|
|
172
|
+
/**
|
|
173
|
+
* Number of recent completed tool exchanges kept as semantic receipts.
|
|
174
|
+
* Four receipts per preserve slot retains a useful investigation trail; the
|
|
175
|
+
* absolute bounds keep frugal mode useful and deep mode finite.
|
|
176
|
+
*/
|
|
177
|
+
private resolveToolReceiptRetention;
|
|
161
178
|
}
|
|
162
179
|
export {};
|
|
163
180
|
//# sourceMappingURL=auto-compaction-middleware.d.ts.map
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
* onDecision: (summary) => journal.push(summary),
|
|
27
27
|
* });
|
|
28
28
|
*/
|
|
29
|
-
import type { Provider, Usage } from '../types/provider.js';
|
|
30
29
|
import { type BrainArbiter, type BrainDecision, type BrainDecisionRequest } from '../coordination/brain.js';
|
|
31
30
|
import { type BrainHeuristicsConfig } from '../coordination/brain-heuristics.js';
|
|
32
|
-
import type { BrainCircuitBreaker } from './brain-circuit.js';
|
|
33
31
|
import type { EventBus } from '../kernel/events.js';
|
|
32
|
+
import type { Provider, ResponseFormat, Usage } from '../types/provider.js';
|
|
33
|
+
import type { BrainCircuitBreaker } from './brain-circuit.js';
|
|
34
34
|
/** One (provider, model) pair the Brain may call for a decision. */
|
|
35
35
|
export interface BrainLlmTarget {
|
|
36
36
|
provider: Provider;
|
|
@@ -218,6 +218,8 @@ export declare function completeBrainLlm(target: BrainLlmTarget, input: {
|
|
|
218
218
|
user: string;
|
|
219
219
|
timeoutMs: number;
|
|
220
220
|
maxTokens?: number | undefined;
|
|
221
|
+
/** External cancellation (e.g. a council's overall budget or user abort). */
|
|
222
|
+
signal?: AbortSignal | undefined;
|
|
221
223
|
}): Promise<string>;
|
|
222
224
|
/** Text plus the observable call metadata a trace/quality gate needs. */
|
|
223
225
|
interface BrainLlmCallResult {
|
|
@@ -237,12 +239,23 @@ interface BrainLlmCallResult {
|
|
|
237
239
|
* Usage was previously thrown away at this boundary, which is why the council
|
|
238
240
|
* adapter reported hardcoded zero tokens for every seat and why "what do
|
|
239
241
|
* Brain decisions cost" had no answer.
|
|
242
|
+
*
|
|
243
|
+
* The per-call timeout is composed with any caller-supplied `signal` so an
|
|
244
|
+
* external abort (the council's overall budget, a user cancel) interrupts an
|
|
245
|
+
* in-flight provider call instead of waiting out the per-call timeout.
|
|
240
246
|
*/
|
|
241
247
|
export declare function completeBrainLlmDetailed(target: BrainLlmTarget, input: {
|
|
242
248
|
system: string;
|
|
243
249
|
user: string;
|
|
244
250
|
timeoutMs: number;
|
|
245
251
|
maxTokens?: number | undefined;
|
|
252
|
+
/**
|
|
253
|
+
* Wire-level response format (e.g. json_object). Callers that parse the
|
|
254
|
+
* response as JSON (the council seats) must pass this through — prompt
|
|
255
|
+
* wording alone does not put a provider into JSON mode.
|
|
256
|
+
*/
|
|
257
|
+
responseFormat?: ResponseFormat | undefined;
|
|
258
|
+
signal?: AbortSignal | undefined;
|
|
246
259
|
}): Promise<BrainLlmCallResult>;
|
|
247
260
|
/**
|
|
248
261
|
* Output budget for a Brain decision call.
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
*/
|
|
26
26
|
import { type BrainArbiter, type BrainDecisionRequest, type BrainEscalationMode, type BrainTerminalPolicy } from '../coordination/brain.js';
|
|
27
27
|
import type { BrainHeuristicsConfig } from '../coordination/brain-heuristics.js';
|
|
28
|
-
import type { EventBus } from '../kernel/events.js';
|
|
29
28
|
import { type BrainRule } from '../coordination/brain-rules.js';
|
|
29
|
+
import type { EventBus } from '../kernel/events.js';
|
|
30
30
|
import type { BrainConfig, BrainCouncilVoterConfig, BrainModelEntry } from '../types/config.js';
|
|
31
31
|
import type { Provider } from '../types/provider.js';
|
|
32
32
|
import { type BrainAutoRisk } from './autonomy-brain.js';
|
|
@@ -55,6 +55,7 @@ export interface BrainConfigSnapshot {
|
|
|
55
55
|
perCallTimeoutMs: number | undefined;
|
|
56
56
|
maxConcurrency: number | undefined;
|
|
57
57
|
distinctness: 'none' | 'model' | 'provider';
|
|
58
|
+
voterMaxTokens: number | undefined;
|
|
58
59
|
judgeMaxTokens: number | undefined;
|
|
59
60
|
seats: Array<{
|
|
60
61
|
persona: string;
|
|
@@ -152,6 +153,7 @@ export interface BrainCouncilPatch {
|
|
|
152
153
|
perCallTimeoutMs?: number | null | undefined;
|
|
153
154
|
maxConcurrency?: number | null | undefined;
|
|
154
155
|
distinctness?: 'none' | 'model' | 'provider' | null | undefined;
|
|
156
|
+
voterMaxTokens?: number | null | undefined;
|
|
155
157
|
judgeMaxTokens?: number | null | undefined;
|
|
156
158
|
seats?: Array<{
|
|
157
159
|
persona: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Message } from '../types/messages.js';
|
|
2
1
|
import type { Logger } from '../types/logger.js';
|
|
2
|
+
import type { Message } from '../types/messages.js';
|
|
3
3
|
import { estimateMessageTokens } from '../utils/token-estimate.js';
|
|
4
|
-
export { buildSmartDigest, extractText, hasLargeToolResult, hasToolUse, scoreMessage,
|
|
4
|
+
export { buildSmartDigest, type ContentScore, extractText, hasLargeToolResult, hasToolUse, scoreMessage, } from './compaction-scoring.js';
|
|
5
5
|
/** Set the module-level compaction debug logger (called by compactor constructors). */
|
|
6
6
|
export declare function setCompactionDebugLogger(logger: Logger | undefined): void;
|
|
7
7
|
/**
|
|
@@ -42,6 +42,45 @@ export interface EliseResult {
|
|
|
42
42
|
saved: number;
|
|
43
43
|
changed: boolean;
|
|
44
44
|
}
|
|
45
|
+
export interface AcknowledgedToolResultElision extends EliseResult {
|
|
46
|
+
/** Raw tool-result blocks replaced with compact receipts. */
|
|
47
|
+
elidedResults: number;
|
|
48
|
+
/** Raw acknowledged tool I/O left verbatim after the pass. */
|
|
49
|
+
retainedTokens: number;
|
|
50
|
+
}
|
|
51
|
+
export interface AcknowledgedToolReceiptCollapse extends EliseResult {
|
|
52
|
+
/** Complete acknowledged tool exchanges folded into the bounded digest. */
|
|
53
|
+
collapsedPairs: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Bound raw tool I/O that the model has already consumed successfully.
|
|
57
|
+
*
|
|
58
|
+
* A result is acknowledged only when a later assistant message exists. The
|
|
59
|
+
* trailing tool-result batch therefore stays verbatim until it has actually
|
|
60
|
+
* reached the provider; retries and recovered sessions cannot lose the input
|
|
61
|
+
* needed for their next request. Among acknowledged pairs, the newest raw
|
|
62
|
+
* payloads share `maxRetainedTokens`; older or individually oversized pairs
|
|
63
|
+
* become semantic receipts while their exact payload remains in the session
|
|
64
|
+
* log. Tool ids and provider metadata stay intact so strict provider replay
|
|
65
|
+
* adjacency remains valid.
|
|
66
|
+
*/
|
|
67
|
+
export declare function eliseAcknowledgedToolResults(messages: readonly Message[], opts: {
|
|
68
|
+
maxRetainedTokens: number;
|
|
69
|
+
}): AcknowledgedToolResultElision;
|
|
70
|
+
/**
|
|
71
|
+
* Bound the number of acknowledged tool-protocol pairs retained in history.
|
|
72
|
+
*
|
|
73
|
+
* Raw payload elision bounds bytes, but every receipt still leaves an
|
|
74
|
+
* assistant tool_use message and a user tool_result message behind. Long
|
|
75
|
+
* autonomous sessions therefore continued to grow linearly in protocol
|
|
76
|
+
* shells. This pass keeps the newest `maxPairs`, removes both halves of older
|
|
77
|
+
* pairs, drops thinking that existed solely to authorize an omitted tool call,
|
|
78
|
+
* and folds the count into one stable system digest. Surrounding assistant or
|
|
79
|
+
* user text is preserved.
|
|
80
|
+
*/
|
|
81
|
+
export declare function collapseAcknowledgedToolReceipts(messages: readonly Message[], opts: {
|
|
82
|
+
maxPairs: number;
|
|
83
|
+
}): AcknowledgedToolReceiptCollapse;
|
|
45
84
|
/**
|
|
46
85
|
* Elide oversized tool I/O that falls before the preserve window. Pure:
|
|
47
86
|
* returns a fresh array (or the same reference when unchanged). Replaces the
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import type { BrainArbiter, BrainDecisionRequest } from '../coordination/brain.js';
|
|
22
22
|
import type { EventBus } from '../kernel/events.js';
|
|
23
|
+
import type { CouncilLLMCaller } from '../types/council.js';
|
|
23
24
|
import type { Provider } from '../types/provider.js';
|
|
25
|
+
import { type BrainLlmTarget } from './autonomy-brain.js';
|
|
24
26
|
/**
|
|
25
27
|
* Refusal option id used by the Brain adapter. Re-exported from the
|
|
26
28
|
* orchestrator so both layers share a single source of truth.
|
|
@@ -53,12 +55,25 @@ export interface CouncilBrainOptions {
|
|
|
53
55
|
quorumFraction?: number | undefined;
|
|
54
56
|
/** Winning option weight must exceed this fraction. Default 0.5. */
|
|
55
57
|
approvalFraction?: number | undefined;
|
|
56
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Per-voter completion timeout in ms. Default
|
|
60
|
+
* {@link BRAIN_COUNCIL_DEFAULT_PER_CALL_TIMEOUT_MS} (45s) — a council
|
|
61
|
+
* convenes for high-stakes decisions only, and reasoning models routinely
|
|
62
|
+
* take longer than the single-LLM tier's 15s before their first token.
|
|
63
|
+
*/
|
|
57
64
|
decisionTimeoutMs?: number | undefined;
|
|
58
65
|
/** Seats polled concurrently, 1..8. Default 3 (the orchestrator's default). */
|
|
59
66
|
maxConcurrency?: number | undefined;
|
|
60
67
|
/** Panel-diversity warning policy. Default 'none'. */
|
|
61
68
|
distinctness?: 'none' | 'model' | 'provider' | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Output budget per voter seat call. Default
|
|
71
|
+
* {@link BRAIN_COUNCIL_DEFAULT_VOTER_MAX_TOKENS}. Reasoning models spend
|
|
72
|
+
* their thinking tokens from this same budget, so the orchestrator's
|
|
73
|
+
* generic 300-token default starves them into `invalid` votes (empty or
|
|
74
|
+
* truncated JSON).
|
|
75
|
+
*/
|
|
76
|
+
voterMaxTokens?: number | undefined;
|
|
62
77
|
/** Output budget for the judge call. */
|
|
63
78
|
judgeMaxTokens?: number | undefined;
|
|
64
79
|
/** Optional digest of past decisions for context. */
|
|
@@ -75,6 +90,37 @@ export interface CouncilBrainOptions {
|
|
|
75
90
|
*/
|
|
76
91
|
traceContent?: boolean | undefined;
|
|
77
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Default output budget per Brain-council voter seat.
|
|
95
|
+
*
|
|
96
|
+
* Deliberately larger than the orchestrator's generic 300-token default
|
|
97
|
+
* (`DEFAULT_COUNCIL_VOTER_MAX_TOKENS`): a vote is still just one optionId
|
|
98
|
+
* plus a short rationale, but reasoning models (deepseek-v4, glm, kimi, …)
|
|
99
|
+
* burn their chain-of-thought from the same `maxTokens` budget before any
|
|
100
|
+
* visible text appears. 300 reliably produced empty/truncated responses →
|
|
101
|
+
* `invalid` votes; 2000 leaves room to think and answer. Override via
|
|
102
|
+
* `brain.council.voterMaxTokens`.
|
|
103
|
+
*/
|
|
104
|
+
export declare const BRAIN_COUNCIL_DEFAULT_VOTER_MAX_TOKENS = 2000;
|
|
105
|
+
/**
|
|
106
|
+
* Default per-seat completion timeout for the Brain council.
|
|
107
|
+
*
|
|
108
|
+
* Deliberately larger than the single-LLM tier's 15s: the council only
|
|
109
|
+
* convenes for high-stakes questions, and reasoning models on the panel
|
|
110
|
+
* often need more than 15s before their first visible token — at 15s they
|
|
111
|
+
* surfaced as `failed` seats on every convene. Override via
|
|
112
|
+
* `brain.council.perCallTimeoutMs` (or `brain.decisionTimeoutMs`).
|
|
113
|
+
*/
|
|
114
|
+
export declare const BRAIN_COUNCIL_DEFAULT_PER_CALL_TIMEOUT_MS = 45000;
|
|
115
|
+
/**
|
|
116
|
+
* Build the per-seat LLM caller that wraps `completeBrainLlmDetailed` for
|
|
117
|
+
* one BrainLlmTarget. Exported so tests can drive the exact production
|
|
118
|
+
* wiring: it forwards the orchestrator's `input.signal` (overall budget +
|
|
119
|
+
* caller cancellation) into the provider call so an in-flight seat is
|
|
120
|
+
* interrupted on timeout/cancel instead of running out its per-call
|
|
121
|
+
* timeout.
|
|
122
|
+
*/
|
|
123
|
+
export declare function makeSeatCallerForVoter(target: BrainLlmTarget): CouncilLLMCaller;
|
|
78
124
|
/**
|
|
79
125
|
* Create a council-of-LLMs Brain arbiter backed by CouncilOrchestrator
|
|
80
126
|
* with per-seat LLM callers — each voter's own Provider is used for its
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { FallbackProfileManager } from '../core/fallback-profile-manager.js';
|
|
2
|
+
import type { Config } from '../types/config.js';
|
|
1
3
|
import type { CouncilLLMCaller, CouncilQuestion, CouncilResult } from '../types/council.js';
|
|
2
4
|
import { type CouncilPersonaRegistry } from './council-personas.js';
|
|
3
5
|
import { type CouncilProfileRegistry } from './council-profiles.js';
|
|
4
|
-
import type { FallbackProfileManager } from '../core/fallback-profile-manager.js';
|
|
5
|
-
import type { Config } from '../types/config.js';
|
|
6
6
|
/** Synthetic ballot entry for "refuse every real option". */
|
|
7
7
|
export declare const COUNCIL_REFUSAL_OPTION_ID = "council_refuse";
|
|
8
8
|
export declare const DEFAULT_COUNCIL_MAX_CONCURRENCY = 3;
|
|
@@ -53,17 +53,36 @@ export declare class CouncilOrchestrator {
|
|
|
53
53
|
private readonly fallbackProfileManager;
|
|
54
54
|
private readonly seatCaller;
|
|
55
55
|
private readonly judgeCaller;
|
|
56
|
+
/**
|
|
57
|
+
* Normalized ad-hoc profiles keyed by the caller's config object identity.
|
|
58
|
+
* The Brain adapter reuses ONE profile object for every decision, so this
|
|
59
|
+
* avoids re-validating + re-freezing it on every ask() without caching
|
|
60
|
+
* string-keyed registry lookups (those are already O(1)).
|
|
61
|
+
*
|
|
62
|
+
* Hosts must treat ad-hoc profile configs as IMMUTABLE once passed to
|
|
63
|
+
* ask(): the cache is keyed by object identity and never invalidated, so
|
|
64
|
+
* mutating a cached profile would silently serve the first snapshot.
|
|
65
|
+
*/
|
|
66
|
+
private readonly profileCache;
|
|
56
67
|
constructor(opts: CouncilOrchestratorOptions);
|
|
68
|
+
/**
|
|
69
|
+
* Resolve the effective profile for a question. String ids and the default
|
|
70
|
+
* go through the registry (already O(1)); ad-hoc config objects are
|
|
71
|
+
* normalized once per stable object identity and cached, because hosts such
|
|
72
|
+
* as the Brain adapter pass the same profile object on every ask().
|
|
73
|
+
*/
|
|
74
|
+
private resolveProfile;
|
|
57
75
|
ask(question: CouncilQuestion): Promise<CouncilResult>;
|
|
58
76
|
private callSeat;
|
|
59
77
|
private resolveOptionQuestion;
|
|
60
78
|
private resolveOpenQuestion;
|
|
61
79
|
private callJudge;
|
|
62
80
|
/**
|
|
63
|
-
* Resolve the effective LLM caller for a call. Voter seats
|
|
64
|
-
* `seatCaller(seatIndex)` when wired
|
|
65
|
-
*
|
|
66
|
-
*
|
|
81
|
+
* Resolve the effective LLM caller for a call. Voter seats (defined
|
|
82
|
+
* seatIndex) use `seatCaller(seatIndex)` when wired, otherwise the shared
|
|
83
|
+
* `caller` — a seat never falls through to the judge caller. Judge seats
|
|
84
|
+
* (seatIndex undefined) use `judgeCaller` if set, otherwise `seatCaller(0)`
|
|
85
|
+
* if set, otherwise the shared `caller`.
|
|
67
86
|
*/
|
|
68
87
|
private resolveCaller;
|
|
69
88
|
private safeCall;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CouncilPersona, CouncilQuestion, CouncilVoteResult, ResolvedCouncilSeat } from '../types/council.js';
|
|
1
|
+
import type { CouncilOption, CouncilPersona, CouncilQuestion, CouncilVoteResult, ResolvedCouncilSeat } from '../types/council.js';
|
|
2
2
|
export declare const COUNCIL_VOTER_PROMPT_PATH = "llm/council-voter.md";
|
|
3
3
|
export declare const COUNCIL_JUDGE_PROMPT_PATH = "llm/council-judge.md";
|
|
4
4
|
/** Build the trusted system instruction for one independent seat. */
|
|
@@ -18,4 +18,15 @@ export declare function buildCouncilJudgeUserPrompt(question: CouncilQuestion, v
|
|
|
18
18
|
reason?: string | undefined;
|
|
19
19
|
refusalOptionId?: string | undefined;
|
|
20
20
|
}): string;
|
|
21
|
+
/**
|
|
22
|
+
* Validate a Council option list; returns human-readable problems (empty
|
|
23
|
+
* array = valid). Single source of the id/label/duplicate rules shared by the
|
|
24
|
+
* `council` tool validator (fixable errors returned to the caller) and the
|
|
25
|
+
* prompt builder (which throws with every problem joined).
|
|
26
|
+
*
|
|
27
|
+
* Note: empty ids are added to the `seen` set, so two empty-id options also
|
|
28
|
+
* report `Duplicate option id ""` next to the empty-id error — harmless noise
|
|
29
|
+
* that preserves the historical tool-validator behavior exactly.
|
|
30
|
+
*/
|
|
31
|
+
export declare function validateCouncilOptions(options: readonly CouncilOption[] | undefined): string[];
|
|
21
32
|
//# sourceMappingURL=council-prompts.d.ts.map
|
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
export { AutoCompactionMiddleware, type ContextWindowBudgetSnapshot, } from './auto-compaction-middleware.js';
|
|
2
|
-
export { installSubagentAutoCompaction } from './subagent-compaction.js';
|
|
3
2
|
export { AutonomousRunner, type AutonomousRunnerOptions, type DoneCheckResult, DoneConditionChecker, } from './autonomous-runner.js';
|
|
4
3
|
export { type AutonomyBrainOptions, type BrainAutoRisk, type BrainLlmTarget, buildBrainUserMessage, completeBrainLlm, createAutonomyBrain, createTieredBrainArbiter, formatDecisionSummary, parseOptionDecision, type TieredBrainArbiterOptions, } from './autonomy-brain.js';
|
|
4
|
+
export { type AutonomyPromptContributorOptions, makeAutonomyPromptContributor, } from './autonomy-prompt-contributor.js';
|
|
5
5
|
export { assembleBrainTiers, type BrainTierAssembly, type BrainTierAssemblyOptions, } from './brain-chain.js';
|
|
6
6
|
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';
|
|
7
7
|
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';
|
|
8
|
+
export { type CompactorOptions, HybridCompactor } from './compactor.js';
|
|
8
9
|
export { COUNCIL_REFUSE_OPTION_ID, type CouncilBrainOptions, type CouncilVoter, createCouncilBrainArbiter, } from './council-brain.js';
|
|
9
|
-
export {
|
|
10
|
+
export { COUNCIL_REFUSAL_OPTION_ID, CouncilOrchestrator, type CouncilOrchestratorOptions, DEFAULT_COUNCIL_MAX_CONCURRENCY, MAX_COUNCIL_CONCURRENCY, } from './council-orchestrator.js';
|
|
10
11
|
export { BUILTIN_COUNCIL_PERSONA_IDS, BUILTIN_COUNCIL_PERSONAS, CouncilPersonaRegistry, createCouncilPersonaRegistry, DEFAULT_COUNCIL_PERSONA_REGISTRY, } from './council-personas.js';
|
|
11
12
|
export { BUILTIN_COUNCIL_PROFILES, CouncilProfileRegistry, createCouncilProfileRegistry, DEFAULT_COUNCIL_APPROVAL_FRACTION, DEFAULT_COUNCIL_JUDGE_MAX_TOKENS, DEFAULT_COUNCIL_OVERALL_TIMEOUT_MS, DEFAULT_COUNCIL_PER_CALL_TIMEOUT_MS, DEFAULT_COUNCIL_PROFILE_REGISTRY, DEFAULT_COUNCIL_QUORUM_FRACTION, DEFAULT_COUNCIL_VOTER_MAX_TOKENS, normalizeCouncilProfile, resolveCouncilProfile, } from './council-profiles.js';
|
|
12
13
|
export { buildCouncilJudgeSystemPrompt, buildCouncilJudgeUserPrompt, buildCouncilQuestionPrompt, buildCouncilVoterSystemPrompt, buildCouncilVoterUserPrompt, COUNCIL_JUDGE_PROMPT_PATH, COUNCIL_VOTER_PROMPT_PATH, } from './council-prompts.js';
|
|
13
|
-
export {
|
|
14
|
-
export { type AutonomyPromptContributorOptions, makeAutonomyPromptContributor, } from './autonomy-prompt-contributor.js';
|
|
15
|
-
export { type CompactorOptions, HybridCompactor } from './compactor.js';
|
|
14
|
+
export { type CouncilResolution, type CouncilResolutionInput, type CouncilResolutionSeat, type CouncilResolutionVote, resolveCouncilVotes, } from './council-resolution.js';
|
|
16
15
|
export { activateDesign, clearActiveKit, detectFrontendFile, detectFrontendIntent, getDesignState, installDesignStudioMiddleware, makeDesignDetectToolCallMiddleware, makeDesignDetectUserInputMiddleware, makeDesignStudioRequestMiddleware, setActiveKit, } from './design-detect.js';
|
|
17
16
|
export { _resetDesignKitLoaderMemo, DefaultDesignKitLoader, type DesignKitLoaderOptions, getDesignKitLoader, resolveBundledDesignKitsDir, } from './design-kit-loader.js';
|
|
18
17
|
export { _resetDesignRulesCache, clearPersistedActiveKit, designProjectDir, loadActiveKit, loadProjectDesignRules, type PersistedActiveKit, recordKitChoice, } from './design-project-store.js';
|
|
18
|
+
export { nextEnhanceTimeout, resolveConfiguredRefinerRef, resolveEnhanceFallbackRef, } from './enhance-recovery.js';
|
|
19
19
|
export { buildRecoveryStrategies, DEFAULT_RECOVERY_STRATEGIES, DefaultErrorHandler, type RecoveryStrategy, } from './error-handler.js';
|
|
20
20
|
export { EternalAutonomyEngine, type EternalAutonomyOptions, type EternalEngineState, type IterationStage, } from './eternal-autonomy.js';
|
|
21
21
|
export { buildGoalPreamble } from './goal-preamble.js';
|
|
22
22
|
export { IntelligentCompactor, type IntelligentCompactorOptions } from './intelligent-compactor.js';
|
|
23
|
-
export { applyModelRuntime,
|
|
23
|
+
export { applyModelRuntime, type ModelRuntimeMiddlewareOptions, mergeModelRuntime, type ResolvedModelRuntime, resolveCacheForRequest, resolveModelRuntime, resolveReasoningForRequest, } from './model-runtime.js';
|
|
24
|
+
export { OneShotOrchestrator } from './one-shot-llm.js';
|
|
24
25
|
export { type ParallelEngineState, ParallelEternalEngine, type ParallelEternalOptions, type ParallelIterationStage, } from './parallel-eternal-engine.js';
|
|
26
|
+
export { buildRefinerContextSections, DEFAULT_REFINER_RETRY_FEEDBACK, type EnhanceFailureKind, enhanceUserPrompt, gatedEnhancerReasoning, isValidEnglishRefinement, normalizedEqual, parseBilingualEnhancement, recentTextTurns, shouldEnhance, } from './prompt-enhancer.js';
|
|
27
|
+
export { DefaultPromptLoader, type PromptLoaderOptions, renderPrompt } from './prompt-loader.js';
|
|
25
28
|
export { DefaultRetryPolicy } from './retry-policy.js';
|
|
26
29
|
export { SelectiveCompactor, type SelectiveCompactorOptions } from './selective-compactor.js';
|
|
27
30
|
export { DefaultSkillLoader, type SkillLoaderOptions } from './skill-loader.js';
|
|
28
|
-
export { DefaultPromptLoader, type PromptLoaderOptions, renderPrompt } from './prompt-loader.js';
|
|
29
31
|
export { type CompactorStrategy, createStrategyCompactor, type StrategyCompactorOptions, } from './strategy-compactor.js';
|
|
32
|
+
export { installSubagentAutoCompaction } from './subagent-compaction.js';
|
|
30
33
|
export { ToolExecutor } from './tool-executor.js';
|
|
31
|
-
export {
|
|
32
|
-
export { buildRefinerContextSections, DEFAULT_REFINER_RETRY_FEEDBACK, enhanceUserPrompt, gatedEnhancerReasoning, type EnhanceFailureKind, isValidEnglishRefinement, normalizedEqual, parseBilingualEnhancement, recentTextTurns, shouldEnhance, } from './prompt-enhancer.js';
|
|
33
|
-
export { nextEnhanceTimeout, resolveConfiguredRefinerRef, resolveEnhanceFallbackRef, } from './enhance-recovery.js';
|
|
34
|
+
export { startFreshTopicContext, type TopicShiftAdvice, TopicShiftAdvisor, type TopicShiftAdvisorInput, type TopicShiftAdvisorOptions, } from './topic-shift-advisor.js';
|
|
34
35
|
//# sourceMappingURL=index.d.ts.map
|