@wrongstack/core 0.89.3 → 0.107.2
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/{agent-bridge-DbVe1dHT.d.ts → agent-bridge-mOxbpFcg.d.ts} +1 -1
- package/dist/{agent-subagent-runner-C6eqID1t.d.ts → agent-subagent-runner-DukQLUcS.d.ts} +5 -5
- package/dist/{brain-s9DyD_Vf.d.ts → brain-Dfv4Y82E.d.ts} +1 -1
- package/dist/{config-84VaZpH6.d.ts → config-BSU-6vah.d.ts} +1 -1
- package/dist/coordination/index.d.ts +9 -9
- package/dist/coordination/index.js +103 -0
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +18 -17
- package/dist/defaults/index.js +276 -12
- package/dist/defaults/index.js.map +1 -1
- package/dist/execution/index.d.ts +61 -365
- package/dist/execution/index.js +423 -8
- package/dist/execution/index.js.map +1 -1
- package/dist/extension/index.d.ts +4 -4
- package/dist/goal-preamble-CI8lxeY1.d.ts +378 -0
- package/dist/{goal-store-DvWLNu52.d.ts → goal-store-ht0VmR1A.d.ts} +63 -21
- package/dist/{index-CqrroYcU.d.ts → index-BWRN6wOb.d.ts} +5 -5
- package/dist/{index-D3Nax3YU.d.ts → index-DIKEcfgC.d.ts} +3 -3
- package/dist/index.d.ts +31 -29
- package/dist/index.js +530 -53
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +4 -4
- package/dist/kernel/index.d.ts +6 -6
- package/dist/{mcp-servers-D3E5ixAR.d.ts → mcp-servers-CXCsANdY.d.ts} +1 -1
- package/dist/{multi-agent-coordinator-DHNrjPaA.d.ts → multi-agent-coordinator-51LvnXkD.d.ts} +1 -1
- package/dist/{null-fleet-bus-BzzciAc4.d.ts → null-fleet-bus-D09hMzFQ.d.ts} +5 -5
- package/dist/observability/index.d.ts +1 -1
- package/dist/{parallel-eternal-engine-CTpcrb9O.d.ts → parallel-eternal-engine-CUtmM_0V.d.ts} +24 -5
- package/dist/{path-resolver-B7hgMAVe.d.ts → path-resolver-DDJiMAtX.d.ts} +1 -1
- package/dist/{pipeline-C1Ad9OjI.d.ts → pipeline-BqiA_UMr.d.ts} +2 -2
- package/dist/{plan-templates-CNphsz0n.d.ts → plan-templates-BdDxl9cI.d.ts} +2 -2
- package/dist/{provider-runner-cqvlB_oS.d.ts → provider-runner-BUunikwY.d.ts} +1 -1
- package/dist/sdd/index.d.ts +11 -6
- package/dist/sdd/index.js +124 -5
- package/dist/sdd/index.js.map +1 -1
- package/dist/{session-event-bridge-IVzs2GpE.d.ts → session-event-bridge-BpJ5trO9.d.ts} +1 -1
- package/dist/{skill-BJxzIyyN.d.ts → skill-Bj6Ezqb8.d.ts} +1 -1
- package/dist/skills/index.d.ts +1 -1
- package/dist/spec-TBi3Jr6T.d.ts +78 -0
- package/dist/storage/index.d.ts +21 -9
- package/dist/storage/index.js +157 -14
- package/dist/storage/index.js.map +1 -1
- package/dist/task-format-vGOIftmK.d.ts +23 -0
- package/dist/task-graph-u1q9Jkyk.d.ts +84 -0
- package/dist/types/index.d.ts +15 -14
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +110 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/tech-stack/SKILL.md +177 -0
- package/dist/task-graph-DJBqO0EY.d.ts +0 -161
|
@@ -1,387 +1,83 @@
|
|
|
1
|
-
export { C as CompactorOptions,
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { E as EventBus } from '../brain-s9DyD_Vf.js';
|
|
6
|
-
import { d as MiddlewareHandler } from '../pipeline-C1Ad9OjI.js';
|
|
7
|
-
import { a as SessionEventBridge } from '../session-event-bridge-IVzs2GpE.js';
|
|
8
|
-
import { k as ContextWindowAggressiveOn, o as ContextWindowPolicy } from '../config-84VaZpH6.js';
|
|
9
|
-
import { g as Agent, O as DoneCondition } from '../agent-subagent-runner-C6eqID1t.js';
|
|
10
|
-
import { R as RunResult, S as SystemPromptContributor } from '../index-D3Nax3YU.js';
|
|
11
|
-
import { S as SkillLoader, b as SkillManifest, a as SkillEntry } from '../skill-BJxzIyyN.js';
|
|
12
|
-
import { W as WstackPaths } from '../wstack-paths-_lqjzErq.js';
|
|
1
|
+
export { C as CompactorOptions, D as DefaultErrorHandler, a as DefaultRetryPolicy, E as EternalAutonomyEngine, b as EternalAutonomyOptions, c as EternalEngineState, H as HybridCompactor, I as IterationStage, P as ParallelEngineState, d as ParallelEternalEngine, e as ParallelEternalOptions, f as ParallelIterationStage, T as ToolExecutor } from '../parallel-eternal-engine-CUtmM_0V.js';
|
|
2
|
+
export { A as AutoCompactionMiddleware, a as AutonomousRunner, b as AutonomousRunnerOptions, c as AutonomyPromptContributorOptions, D as DefaultSkillLoader, d as DoneCheckResult, e as DoneConditionChecker, I as IntelligentCompactor, f as IntelligentCompactorOptions, S as SelectiveCompactor, g as SelectiveCompactorOptions, h as SkillLoaderOptions, i as buildGoalPreamble, m as makeAutonomyPromptContributor } from '../goal-preamble-CI8lxeY1.js';
|
|
3
|
+
import { P as Provider } from '../context-CNRYfhUv.js';
|
|
4
|
+
import { B as BrainDecision, a as BrainDecisionRequest, b as BrainArbiter } from '../brain-Dfv4Y82E.js';
|
|
13
5
|
import '../retry-policy-BcmuT_V0.js';
|
|
6
|
+
import '../compactor-DXLxLcmU.js';
|
|
14
7
|
import '../models-registry-B6_KfS65.js';
|
|
15
|
-
import '../
|
|
16
|
-
import '../multi-agent-coordinator-DHNrjPaA.js';
|
|
17
|
-
import 'node:events';
|
|
8
|
+
import '../index-DIKEcfgC.js';
|
|
18
9
|
import '../logger-B63L5bTg.js';
|
|
10
|
+
import '../pipeline-BqiA_UMr.js';
|
|
11
|
+
import '../config-BSU-6vah.js';
|
|
19
12
|
import '../observability-D-HZN_mF.js';
|
|
20
13
|
import '../permission-BDv7z0mk.js';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* 1. Project-committed: <project>/.wrongstack/skills/
|
|
30
|
-
* 2. User-global: ~/.wrongstack/skills/
|
|
31
|
-
* 3. Bundled with build: packages/core/skills/
|
|
32
|
-
*/
|
|
33
|
-
declare class DefaultSkillLoader implements SkillLoader {
|
|
34
|
-
private readonly dirs;
|
|
35
|
-
private cache?;
|
|
36
|
-
constructor(opts: SkillLoaderOptions);
|
|
37
|
-
list(): Promise<SkillManifest[]>;
|
|
38
|
-
find(name: string): Promise<SkillManifest | undefined>;
|
|
39
|
-
manifestText(): Promise<string>;
|
|
40
|
-
listEntries(): Promise<SkillEntry[]>;
|
|
41
|
-
invalidateCache(): void;
|
|
42
|
-
readBody(name: string): Promise<string>;
|
|
43
|
-
}
|
|
14
|
+
import '../agent-subagent-runner-DukQLUcS.js';
|
|
15
|
+
import '../goal-store-ht0VmR1A.js';
|
|
16
|
+
import '../multi-agent-coordinator-51LvnXkD.js';
|
|
17
|
+
import 'node:events';
|
|
18
|
+
import '../skill-Bj6Ezqb8.js';
|
|
19
|
+
import '../wstack-paths-_lqjzErq.js';
|
|
20
|
+
import '../selector-C7wcdqMA.js';
|
|
21
|
+
import '../session-event-bridge-BpJ5trO9.js';
|
|
44
22
|
|
|
45
23
|
/**
|
|
46
|
-
*
|
|
47
|
-
*/
|
|
48
|
-
interface IntelligentCompactorOptions {
|
|
49
|
-
/** Provider to use for LLM-assisted summarization. Required. */
|
|
50
|
-
provider: Provider;
|
|
51
|
-
/** Fraction of maxContext that triggers a warning (default 0.6). */
|
|
52
|
-
warnThreshold?: number | undefined;
|
|
53
|
-
/** Fraction of maxContext that triggers soft compaction (default 0.75). */
|
|
54
|
-
softThreshold?: number | undefined;
|
|
55
|
-
/** Fraction of maxContext that triggers hard compaction (default 0.9). */
|
|
56
|
-
hardThreshold?: number | undefined;
|
|
57
|
-
/** Max context window in tokens (used only for threshold fraction math). */
|
|
58
|
-
maxContext?: number | undefined;
|
|
59
|
-
/** How many recent (user+assistant) pairs to always preserve (default 4). */
|
|
60
|
-
preserveK?: number | undefined;
|
|
61
|
-
/** Token threshold below which tool results are not elided (default 500). */
|
|
62
|
-
eliseThreshold?: number | undefined;
|
|
63
|
-
/** System prompt for the summarizer sub-LLM. */
|
|
64
|
-
summarizerPrompt?: string | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* Model ID to use for summarization. When not set, the same model as the
|
|
67
|
-
* agent is used (which risks cascading failure on context overflow). Set to
|
|
68
|
-
* a fast/cheap model like `claude-3-5-haiku-20240620` for resilience.
|
|
69
|
-
*/
|
|
70
|
-
summarizerModel?: string | undefined;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* IntelligentCompactor uses an LLM to:
|
|
74
|
-
* - Analyze message importance and preserve critical context
|
|
75
|
-
* - Generate semantic summaries for old message ranges
|
|
76
|
-
* - Make intelligent decisions about what to compact
|
|
24
|
+
* AutonomyBrain — a self-driving decision layer for autonomous workflows.
|
|
77
25
|
*
|
|
78
|
-
*
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
private readonly warnThreshold;
|
|
83
|
-
private readonly softThreshold;
|
|
84
|
-
private readonly hardThreshold;
|
|
85
|
-
private readonly maxContext;
|
|
86
|
-
private readonly preserveK;
|
|
87
|
-
private readonly eliseThreshold;
|
|
88
|
-
private readonly summarizerPrompt;
|
|
89
|
-
private readonly summarizerModel?;
|
|
90
|
-
constructor(opts: IntelligentCompactorOptions);
|
|
91
|
-
compact(ctx: Context, opts?: {
|
|
92
|
-
aggressive?: boolean | undefined;
|
|
93
|
-
}): Promise<CompactReport>;
|
|
94
|
-
/**
|
|
95
|
-
* Estimate the full API request token count: messages + systemPrompt + toolDefs.
|
|
96
|
-
* This is the accurate figure for context-window pressure monitoring.
|
|
97
|
-
*/
|
|
98
|
-
private estimateFullRequest;
|
|
99
|
-
private summarizeAncientTurns;
|
|
100
|
-
private findSafeBoundary;
|
|
101
|
-
private findExchangeStart;
|
|
102
|
-
private callSummarizer;
|
|
103
|
-
private messagesToText;
|
|
104
|
-
private lightweightCompact;
|
|
105
|
-
private eliseOldToolResults;
|
|
106
|
-
private hasTextContent;
|
|
107
|
-
private estimateTokens;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Options for SelectiveCompactor — the most configurable compactor.
|
|
112
|
-
*/
|
|
113
|
-
interface SelectiveCompactorOptions {
|
|
114
|
-
/** Provider for LLM calls (selector + summarizer). Required. */
|
|
115
|
-
provider: Provider;
|
|
116
|
-
/** Selector for LLM-driven importance analysis. */
|
|
117
|
-
selector?: MessageSelector | undefined;
|
|
118
|
-
/** Fraction of maxContext that triggers a warning (default 0.6). */
|
|
119
|
-
warnThreshold?: number | undefined;
|
|
120
|
-
/** Fraction of maxContext that triggers soft compaction (default 0.75). */
|
|
121
|
-
softThreshold?: number | undefined;
|
|
122
|
-
/** Fraction of maxContext that triggers hard compaction (default 0.9). */
|
|
123
|
-
hardThreshold?: number | undefined;
|
|
124
|
-
/** Max context window in tokens (used for threshold fraction math). */
|
|
125
|
-
maxContext?: number | undefined;
|
|
126
|
-
/** How many recent (user+assistant) pairs to always preserve (default 4). */
|
|
127
|
-
preserveK?: number | undefined;
|
|
128
|
-
/** Token threshold below which tool results are not elided (default 500). */
|
|
129
|
-
eliseThreshold?: number | undefined;
|
|
130
|
-
/** Model for selector LLM calls (default: same as provider default). */
|
|
131
|
-
selectorModel?: string | undefined;
|
|
132
|
-
/** Summarizer model for collapsed ranges (default: same as selectorModel). */
|
|
133
|
-
summarizerModel?: string | undefined;
|
|
134
|
-
/** Prompt for the summarizer sub-LLM. */
|
|
135
|
-
summarizerPrompt?: string | undefined;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* SelectiveCompactor uses an LLM-driven MessageSelector to make
|
|
139
|
-
* surgical decisions about which message ranges to keep vs collapse.
|
|
26
|
+
* Unlike the standard BrainArbiter which asks the human when uncertain,
|
|
27
|
+
* AutonomyBrain makes decisions autonomously within configured risk
|
|
28
|
+
* boundaries, keeping the system running unattended. It uses the session
|
|
29
|
+
* LLM to evaluate situations and produce decisions.
|
|
140
30
|
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*/
|
|
146
|
-
declare class SelectiveCompactor implements Compactor {
|
|
147
|
-
private readonly provider;
|
|
148
|
-
private readonly selector;
|
|
149
|
-
private readonly warnThreshold;
|
|
150
|
-
private readonly softThreshold;
|
|
151
|
-
private readonly hardThreshold;
|
|
152
|
-
private readonly maxContext;
|
|
153
|
-
private readonly preserveK;
|
|
154
|
-
private readonly eliseThreshold;
|
|
155
|
-
private readonly summarizerModel;
|
|
156
|
-
private readonly summarizerPrompt;
|
|
157
|
-
constructor(opts: SelectiveCompactorOptions);
|
|
158
|
-
compact(ctx: Context, opts?: {
|
|
159
|
-
aggressive?: boolean | undefined;
|
|
160
|
-
}): Promise<CompactReport>;
|
|
161
|
-
/**
|
|
162
|
-
* Estimate the full API request token count: messages + systemPrompt + toolDefs.
|
|
163
|
-
* This is the accurate figure for context-window pressure monitoring.
|
|
164
|
-
*/
|
|
165
|
-
private estimateFullRequest;
|
|
166
|
-
private repairProtocolAdjacency;
|
|
167
|
-
/**
|
|
168
|
-
* Run the LLM selector to decide what to keep vs collapse.
|
|
169
|
-
* Returns the token savings achieved.
|
|
170
|
-
*/
|
|
171
|
-
private runSelector;
|
|
172
|
-
/**
|
|
173
|
-
* Execute a SelectorResult plan: collapse/remove ranges and
|
|
174
|
-
* insert summaries where the selector provided them.
|
|
175
|
-
*/
|
|
176
|
-
private executePlan;
|
|
177
|
-
private summarizeRange;
|
|
178
|
-
private messagePreview;
|
|
179
|
-
/**
|
|
180
|
-
* Fallback when selector fails: aggressively trim from the oldest end
|
|
181
|
-
* until we hit targetBudget.
|
|
182
|
-
*/
|
|
183
|
-
private aggressiveRecencyTrim;
|
|
184
|
-
private computeTargetBudget;
|
|
185
|
-
private eliseOldToolResults;
|
|
186
|
-
private hasTextContent;
|
|
187
|
-
private estimateTokens;
|
|
188
|
-
private roughTokenEstimate;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
type CompactionFailureMode = 'throw' | 'throw_on_hard' | 'continue';
|
|
192
|
-
interface AutoCompactionOptions {
|
|
193
|
-
aggressiveOn?: ContextWindowAggressiveOn | undefined;
|
|
194
|
-
events?: EventBus | undefined;
|
|
195
|
-
failureMode?: CompactionFailureMode | undefined;
|
|
196
|
-
policyProvider?: (ctx: Context) => Pick<ContextWindowPolicy, 'thresholds' | 'aggressiveOn'> | null | undefined;
|
|
197
|
-
/** Optional bridge for writing compaction events into the persistent session log. */
|
|
198
|
-
sessionBridge?: SessionEventBridge | undefined;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Pipeline middleware that monitors context token load and automatically
|
|
202
|
-
* triggers compaction when the warn/soft/hard thresholds are crossed.
|
|
203
|
-
* Runs before the next agent iteration.
|
|
31
|
+
* ## Identity
|
|
32
|
+
* The AutonomyBrain is NOT the main agent. It is a dedicated decision
|
|
33
|
+
* engine with a single purpose: evaluate blocked/stuck situations in
|
|
34
|
+
* autonomous workflows and decide whether to continue, pivot, or stop.
|
|
204
35
|
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
|
|
209
|
-
declare class AutoCompactionMiddleware {
|
|
210
|
-
readonly name = "AutoCompaction";
|
|
211
|
-
private readonly compactor;
|
|
212
|
-
/** Deprecated. Kept for backward compat with tests that pass simpleEstimator. */
|
|
213
|
-
private readonly _estimator?;
|
|
214
|
-
private readonly warnThreshold;
|
|
215
|
-
private readonly softThreshold;
|
|
216
|
-
private readonly hardThreshold;
|
|
217
|
-
/** Writable so model-switch can update the denominator without re-registering the middleware. */
|
|
218
|
-
private _maxContext;
|
|
219
|
-
private readonly aggressiveOn;
|
|
220
|
-
private readonly events?;
|
|
221
|
-
private readonly failureMode;
|
|
222
|
-
private readonly policyProvider?;
|
|
223
|
-
private readonly sessionBridge?;
|
|
224
|
-
/**
|
|
225
|
-
* Once a compaction attempt reduces nothing (preserveK protects everything,
|
|
226
|
-
* no oversized tool_results remain to elide), retrying on every iteration
|
|
227
|
-
* just spams `compaction.fired` events without making progress. We remember
|
|
228
|
-
* the no-op and skip until either the pressure level escalates or context
|
|
229
|
-
* has grown by at least this many tokens since the failed attempt.
|
|
230
|
-
*/
|
|
231
|
-
private static readonly NOOP_RETRY_DELTA_TOKENS;
|
|
232
|
-
/** Tracks the most recent no-op attempt so we can avoid re-firing per turn. */
|
|
233
|
-
private lastNoopAttempt;
|
|
234
|
-
/**
|
|
235
|
-
* @param compactor Compactor to use for compaction.
|
|
236
|
-
* @param maxContext Provider's max context window in tokens.
|
|
237
|
-
* @param _estimator Deprecated parameter kept for backward compatibility.
|
|
238
|
-
* The middleware now uses `estimateRequestTokens` internally
|
|
239
|
-
* for accurate full-request token counting (messages +
|
|
240
|
-
* systemPrompt + toolDefs).
|
|
241
|
-
* @param thresholds Threshold fractions (0-1) of maxContext.
|
|
242
|
-
* @param opts Optional behavior. By default, failures at the
|
|
243
|
-
* hard threshold throw AGENT_CONTEXT_OVERFLOW so
|
|
244
|
-
* the agent does not continue into a likely
|
|
245
|
-
* provider context overflow. Warn/soft failures
|
|
246
|
-
* still emit compaction.failed and continue.
|
|
247
|
-
*/
|
|
248
|
-
constructor(compactor: Compactor, maxContext: number, _estimator: (ctx: Context) => number, thresholds: {
|
|
249
|
-
warn: number;
|
|
250
|
-
soft: number;
|
|
251
|
-
hard: number;
|
|
252
|
-
}, optsOrAggressiveOn?: AutoCompactionOptions | ContextWindowAggressiveOn, events?: EventBus | undefined);
|
|
253
|
-
/** Allow callers (e.g. model-switch in WebUI) to update the context window
|
|
254
|
-
* denominator when the active model changes. */
|
|
255
|
-
setMaxContext(maxContext: number): void;
|
|
256
|
-
handler(): MiddlewareHandler<Context>;
|
|
257
|
-
/**
|
|
258
|
-
* Returns true when the previous compaction at the same or higher pressure
|
|
259
|
-
* level reduced nothing and context has not grown materially since. Prevents
|
|
260
|
-
* a stuck preserveK window from spamming compaction events every iteration.
|
|
261
|
-
*/
|
|
262
|
-
private shouldSkipNoopRetry;
|
|
263
|
-
private recordAttempt;
|
|
264
|
-
private compact;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
type AutonomousResult = RunResult & {
|
|
268
|
-
toolCalls: number;
|
|
269
|
-
reason?: string | undefined;
|
|
270
|
-
};
|
|
271
|
-
interface DoneCheckResult {
|
|
272
|
-
done: boolean;
|
|
273
|
-
reason?: string | undefined;
|
|
274
|
-
iterations: number;
|
|
275
|
-
toolCalls: number;
|
|
276
|
-
}
|
|
277
|
-
declare class DoneConditionChecker {
|
|
278
|
-
private readonly condition;
|
|
279
|
-
private readonly compiledRegex;
|
|
280
|
-
constructor(condition: DoneCondition);
|
|
281
|
-
check(state: {
|
|
282
|
-
iterations: number;
|
|
283
|
-
toolCalls: number;
|
|
284
|
-
lastOutput?: string | undefined;
|
|
285
|
-
}): DoneCheckResult;
|
|
286
|
-
}
|
|
287
|
-
interface AutonomousRunnerOptions {
|
|
288
|
-
agent: Agent;
|
|
289
|
-
context: Context;
|
|
290
|
-
doneCondition: DoneCondition;
|
|
291
|
-
iterationTimeoutMs?: number | undefined;
|
|
292
|
-
onIteration?: (state: {
|
|
293
|
-
iteration: number | undefined;
|
|
294
|
-
toolCalls: number;
|
|
295
|
-
}) => void;
|
|
296
|
-
onDone?: (((result: AutonomousResult) => void)) | undefined;
|
|
297
|
-
/**
|
|
298
|
-
* When true and `doneCondition.type === 'directive'`, the runner
|
|
299
|
-
* runs the agent with `autonomousContinue: true` so the agent loop
|
|
300
|
-
* handles its own [continue]/[done] markers internally (no outer
|
|
301
|
-
* re-invocation needed). The runner still provides iteration/timeouts.
|
|
302
|
-
*/
|
|
303
|
-
enableAutonomousContinue?: boolean | undefined;
|
|
304
|
-
}
|
|
305
|
-
declare class AutonomousRunner {
|
|
306
|
-
private readonly opts;
|
|
307
|
-
private iterations;
|
|
308
|
-
private toolCalls;
|
|
309
|
-
private lastOutput?;
|
|
310
|
-
private stopped;
|
|
311
|
-
private readonly doneChecker;
|
|
312
|
-
constructor(opts: AutonomousRunnerOptions);
|
|
313
|
-
run(): Promise<AutonomousResult>;
|
|
314
|
-
private runLoop;
|
|
315
|
-
stop(): void;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* System-prompt contributor that surfaces eternal-autonomy state to the
|
|
320
|
-
* model on every turn.
|
|
36
|
+
* ## Decision Flow
|
|
37
|
+
* 1. RISK GATE — if request risk > maxAutoRisk, auto-deny
|
|
38
|
+
* 2. HEURISTIC — fast pattern-match for common situations (deadlock, retry-exhausted)
|
|
39
|
+
* 3. LLM EVALUATION — complex decisions (goal completion, conflict resolution)
|
|
321
40
|
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
* the model forgets it's in autonomy mode (forgets `[GOAL_COMPLETE]`,
|
|
326
|
-
* forgets the todo-state protocol, forgets the no-confirmation rule).
|
|
327
|
-
* Injecting the same anchor as a CACHED system-prompt block solves that
|
|
328
|
-
* — the rules sit next to the identity layer and survive compactions.
|
|
41
|
+
* ## Decision Logging
|
|
42
|
+
* Every decision is emitted via `onDecision` callback with a human-readable
|
|
43
|
+
* summary suitable for chat history and journal entries.
|
|
329
44
|
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
45
|
+
* Usage:
|
|
46
|
+
* const brain = createAutonomyBrain({
|
|
47
|
+
* provider, model, maxAutoRisk: 'high',
|
|
48
|
+
* onDecision: (summary) => journal.push(summary),
|
|
49
|
+
* });
|
|
333
50
|
*/
|
|
334
51
|
|
|
335
|
-
interface
|
|
336
|
-
/**
|
|
337
|
-
|
|
52
|
+
interface AutonomyBrainOptions {
|
|
53
|
+
/** LLM provider for decision-making. */
|
|
54
|
+
provider: Provider;
|
|
55
|
+
/** Model to use for decisions (should be fast + cheap). */
|
|
56
|
+
model: string;
|
|
57
|
+
/** Maximum risk level the brain will auto-decide. Default: 'high'.
|
|
58
|
+
* 'low' — only auto-decide low-risk questions
|
|
59
|
+
* 'medium' — auto-decide low/medium
|
|
60
|
+
* 'high' — auto-decide low/medium/high
|
|
61
|
+
* 'all' — auto-decide everything (including critical)
|
|
62
|
+
*/
|
|
63
|
+
maxAutoRisk?: 'low' | 'medium' | 'high' | 'all' | undefined;
|
|
64
|
+
/** Timeout for each decision call (ms). Default: 15_000. */
|
|
65
|
+
decisionTimeoutMs?: number | undefined;
|
|
338
66
|
/**
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
* teach the model loop-control markers it shouldn't emit.
|
|
343
|
-
*
|
|
344
|
-
* Typical wiring: enable while `eternal` or `eternal-parallel` autonomy is active.
|
|
67
|
+
* Called after every decision with a human-readable summary.
|
|
68
|
+
* Use this to log decisions into chat history, journal, or status line.
|
|
69
|
+
* Example: "🧠 Brain: skipped deadlocked tasks → continuing with phase 3/5"
|
|
345
70
|
*/
|
|
346
|
-
|
|
347
|
-
/** Number of journal entries to include in the recent-tail block. Default 5. */
|
|
348
|
-
journalTailSize?: number | undefined;
|
|
71
|
+
onDecision?: ((summary: string, decision: BrainDecision, request: BrainDecisionRequest) => void) | undefined;
|
|
349
72
|
}
|
|
350
73
|
/**
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
* completed/abandoned — all silent fast-paths.
|
|
74
|
+
* Create a self-driving brain that makes autonomous decisions.
|
|
75
|
+
* Never asks the human — within its risk boundary it answers, above it denies.
|
|
354
76
|
*/
|
|
355
|
-
declare function
|
|
356
|
-
|
|
77
|
+
declare function createAutonomyBrain(opts: AutonomyBrainOptions): BrainArbiter;
|
|
357
78
|
/**
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
* Unlike STEERING (which redirects mid-flight), GOAL is a contract:
|
|
361
|
-
* the user hands over a problem, the agent commits to verifiably
|
|
362
|
-
* finishing it, and every iteration re-reads this preamble from the
|
|
363
|
-
* conversation history. The hardening is entirely prompt-level —
|
|
364
|
-
* the system has already removed implicit budget caps, so this
|
|
365
|
-
* preamble's job is to remove the MODEL's tendency to hedge, ask
|
|
366
|
-
* permission, or declare premature success.
|
|
367
|
-
*
|
|
368
|
-
* The four sections are intentional:
|
|
369
|
-
* 1. AUTHORITY — explicit grant of unbounded fan-out + model
|
|
370
|
-
* switching. Without this the model self-throttles ("I shouldn't
|
|
371
|
-
* spawn too many…") even when budgets are unlimited.
|
|
372
|
-
* 2. DONE — concrete bar for completion. Forces a verifiable
|
|
373
|
-
* artifact (test passing, file written, bug re-run clean).
|
|
374
|
-
* Without this the model returns "I believe it's fixed" and
|
|
375
|
-
* counts that as done.
|
|
376
|
-
* 3. NOT DONE — explicit anti-patterns. Each item is something we
|
|
377
|
-
* saw real agents do as a "completion" that wasn't.
|
|
378
|
-
* 4. PERSISTENCE — three-angle rule for blockers. Stops the model
|
|
379
|
-
* from giving up on the first tool failure.
|
|
380
|
-
*
|
|
381
|
-
* Located in @wrongstack/core (rather than @wrongstack/tui) so headless
|
|
382
|
-
* callers and the WebUI can issue `/goal set` without dragging the TUI
|
|
383
|
-
* package in. The tui re-exports this for backward compatibility.
|
|
79
|
+
* Format a decision as a human-readable one-liner for chat history.
|
|
384
80
|
*/
|
|
385
|
-
declare function
|
|
81
|
+
declare function formatDecisionSummary(decision: BrainDecision, request: BrainDecisionRequest): string;
|
|
386
82
|
|
|
387
|
-
export {
|
|
83
|
+
export { type AutonomyBrainOptions, createAutonomyBrain, formatDecisionSummary };
|