@wrongstack/core 0.6.0 → 0.6.1
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-BKNiE1VH.d.ts → agent-bridge-DaCvA_uK.d.ts} +1 -1
- package/dist/coordination/index.d.ts +5 -5
- package/dist/coordination/index.js +178 -54
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +10 -10
- package/dist/defaults/index.js +534 -75
- package/dist/defaults/index.js.map +1 -1
- package/dist/{events-DPQKFX7W.d.ts → events-CzkeaVVl.d.ts} +8 -2
- package/dist/execution/index.d.ts +149 -6
- package/dist/execution/index.js +345 -16
- package/dist/execution/index.js.map +1 -1
- package/dist/extension/index.d.ts +2 -2
- package/dist/{goal-store-BQ3YX1h1.d.ts → goal-store-DVCfj7Ff.d.ts} +20 -0
- package/dist/{index-B0qTujQW.d.ts → index-BkKLQjea.d.ts} +1 -1
- package/dist/{index-DkdRz6yK.d.ts → index-i9rPR53g.d.ts} +11 -4
- package/dist/index.d.ts +50 -16
- package/dist/index.js +769 -86
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +2 -2
- package/dist/kernel/index.d.ts +2 -2
- package/dist/kernel/index.js.map +1 -1
- package/dist/{multi-agent-Cpp7FXUl.d.ts → multi-agent-MfI6dmv-.d.ts} +30 -5
- package/dist/observability/index.d.ts +1 -1
- package/dist/{path-resolver--g_hKJ7V.d.ts → path-resolver-CWINz5XR.d.ts} +1 -1
- package/dist/{plan-templates-CKJs_sYh.d.ts → plan-templates-Bne1pB4d.d.ts} +1 -1
- package/dist/{provider-runner-hl4Il3xS.d.ts → provider-runner-CZYIzeBp.d.ts} +1 -1
- package/dist/sdd/index.d.ts +2 -2
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.js +3 -0
- package/dist/storage/index.js.map +1 -1
- package/dist/{tool-executor-B03CRwu-.d.ts → tool-executor-40Q6shR-.d.ts} +1 -1
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.js +16 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +5 -1
|
@@ -57,6 +57,7 @@ interface EventMap {
|
|
|
57
57
|
'provider.tool_use_stop': {
|
|
58
58
|
ctx: Context;
|
|
59
59
|
id: string;
|
|
60
|
+
name: string;
|
|
60
61
|
};
|
|
61
62
|
/**
|
|
62
63
|
* Fired before each retry of a failed provider call. `attempt` is 1-based
|
|
@@ -175,15 +176,20 @@ interface EventMap {
|
|
|
175
176
|
* runner/budget classes.
|
|
176
177
|
*/
|
|
177
178
|
'budget.threshold_reached': {
|
|
178
|
-
kind: 'iterations' | 'tool_calls' | 'tokens' | 'cost';
|
|
179
|
+
kind: 'iterations' | 'tool_calls' | 'tokens' | 'cost' | 'timeout';
|
|
179
180
|
used: number;
|
|
180
181
|
limit: number;
|
|
181
|
-
/**
|
|
182
|
+
/**
|
|
183
|
+
* Call to grant more of the same budget type. `timeoutMs` extends the
|
|
184
|
+
* wall-clock budget; the coordinator's watchdog observes the patched
|
|
185
|
+
* limit and re-arms its timer for the new remainder.
|
|
186
|
+
*/
|
|
182
187
|
extend: (extra: Partial<{
|
|
183
188
|
maxIterations: number;
|
|
184
189
|
maxToolCalls: number;
|
|
185
190
|
maxTokens: number;
|
|
186
191
|
maxCostUsd: number;
|
|
192
|
+
timeoutMs: number;
|
|
187
193
|
}>) => void;
|
|
188
194
|
/** Call to deny the extension — subagent will stop. */
|
|
189
195
|
deny: () => void;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-
|
|
1
|
+
export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-40Q6shR-.js';
|
|
2
2
|
import { g as Provider, a2 as Context } from '../context-CDRyrkKQ.js';
|
|
3
3
|
import { a as Compactor, C as CompactReport } from '../compactor-RIPuTtWK.js';
|
|
4
4
|
import { M as MessageSelector } from '../selector-C7HqnZJU.js';
|
|
5
|
-
import { E as EventBus } from '../events-
|
|
5
|
+
import { E as EventBus } from '../events-CzkeaVVl.js';
|
|
6
6
|
import { c as MiddlewareHandler } from '../system-prompt-Dl2QY1_B.js';
|
|
7
7
|
import { e as ContextWindowAggressiveOn, i as ContextWindowPolicy } from '../config-BGGuP_Ar.js';
|
|
8
|
-
import { r as Agent, R as RunResult } from '../index-
|
|
9
|
-
import { D as DoneCondition } from '../multi-agent-
|
|
10
|
-
import { J as JournalEntry } from '../goal-store-
|
|
8
|
+
import { r as Agent, R as RunResult, j as SystemPromptContributor } from '../index-BkKLQjea.js';
|
|
9
|
+
import { D as DoneCondition } from '../multi-agent-MfI6dmv-.js';
|
|
10
|
+
import { J as JournalEntry } from '../goal-store-DVCfj7Ff.js';
|
|
11
11
|
import { a as SkillLoader, b as SkillManifest, S as SkillEntry } from '../skill-CxuWrsKK.js';
|
|
12
12
|
import { W as WstackPaths } from '../wstack-paths-86YPFktR.js';
|
|
13
13
|
import '../retry-policy-LKS8MHsB.js';
|
|
@@ -296,6 +296,13 @@ interface EternalAutonomyOptions {
|
|
|
296
296
|
* provider call should not freeze the whole eternal loop.
|
|
297
297
|
*/
|
|
298
298
|
iterationTimeoutMs?: number;
|
|
299
|
+
/**
|
|
300
|
+
* Maximum number of internal agent.run iterations the engine grants per
|
|
301
|
+
* eternal-loop tick. The engine sets `autonomousContinue: true` so the
|
|
302
|
+
* agent can run multi-step tasks end-to-end within one tick instead of
|
|
303
|
+
* bouncing back to the engine after every single tool call. Default 50.
|
|
304
|
+
*/
|
|
305
|
+
iterationMaxAgentSteps?: number;
|
|
299
306
|
/**
|
|
300
307
|
* Minimum sleep between iterations. Defaults to 1 s — enough for
|
|
301
308
|
* SIGINT handlers to fire mid-loop without pegging a core when the
|
|
@@ -307,6 +314,22 @@ interface EternalAutonomyOptions {
|
|
|
307
314
|
* brainstorm cycle. Default 3. Acts as a soft-recovery, not a stop.
|
|
308
315
|
*/
|
|
309
316
|
failureBudget?: number;
|
|
317
|
+
/**
|
|
318
|
+
* Per-todo failed-attempt ceiling. When the engine picks the same todo
|
|
319
|
+
* and the iteration fails this many times in total, the todo is taken
|
|
320
|
+
* out of rotation (engine prefers other sources) until it changes
|
|
321
|
+
* status. Default 3. Prevents the loop from spinning forever on one
|
|
322
|
+
* stuck task.
|
|
323
|
+
*/
|
|
324
|
+
todoMaxAttempts?: number;
|
|
325
|
+
/**
|
|
326
|
+
* Consecutive brainstorm-DONE responses required to consider the goal
|
|
327
|
+
* complete and stop the engine. When the LLM's brainstorm step keeps
|
|
328
|
+
* answering `DONE`, the engine treats that as "no more work" and, after
|
|
329
|
+
* this many in a row, marks the goal as completed instead of sleeping
|
|
330
|
+
* forever. Default 3.
|
|
331
|
+
*/
|
|
332
|
+
brainstormDoneStopThreshold?: number;
|
|
310
333
|
/** Side-channel notifications (logging, UI updates). */
|
|
311
334
|
onIteration?: (entry: JournalEntry) => void;
|
|
312
335
|
onError?: (err: Error, iteration: number) => void;
|
|
@@ -342,6 +365,20 @@ interface EternalAutonomyOptions {
|
|
|
342
365
|
* checks (iteration cadence still applies).
|
|
343
366
|
*/
|
|
344
367
|
maxContextTokens?: number;
|
|
368
|
+
/**
|
|
369
|
+
* Base delay (ms) for the first transient-error backoff. Subsequent
|
|
370
|
+
* transient failures double this, capped at `transientBackoffMaxMs`.
|
|
371
|
+
* Default 2_000.
|
|
372
|
+
*
|
|
373
|
+
* "Transient" means the underlying error is recoverable per
|
|
374
|
+
* `WrongStackError.recoverable` (ProviderError sets this for 429/529/5xx
|
|
375
|
+
* /network errors). Permanent errors (auth/invalid request) skip the
|
|
376
|
+
* backoff and count toward `failureBudget` like before — backing off
|
|
377
|
+
* on a permanent failure is wasted time.
|
|
378
|
+
*/
|
|
379
|
+
transientBackoffBaseMs?: number;
|
|
380
|
+
/** Ceiling for the exponential backoff. Default 60_000 (60 s). */
|
|
381
|
+
transientBackoffMaxMs?: number;
|
|
345
382
|
}
|
|
346
383
|
type EternalEngineState = 'idle' | 'running' | 'stopped';
|
|
347
384
|
declare class EternalAutonomyEngine {
|
|
@@ -349,6 +386,14 @@ declare class EternalAutonomyEngine {
|
|
|
349
386
|
private state;
|
|
350
387
|
private stopRequested;
|
|
351
388
|
private consecutiveFailures;
|
|
389
|
+
private consecutiveBrainstormDone;
|
|
390
|
+
/**
|
|
391
|
+
* Count of consecutive transient (recoverable) provider failures. Drives
|
|
392
|
+
* the exponential backoff between iterations. Reset on the first
|
|
393
|
+
* successful iteration so a single bad afternoon doesn't permanently
|
|
394
|
+
* slow the loop down.
|
|
395
|
+
*/
|
|
396
|
+
private consecutiveTransientRetries;
|
|
352
397
|
private currentCtrl;
|
|
353
398
|
private iterationsSinceCompact;
|
|
354
399
|
private readonly goalPath;
|
|
@@ -401,9 +446,107 @@ declare class EternalAutonomyEngine {
|
|
|
401
446
|
private readGitStatus;
|
|
402
447
|
private brainstormTask;
|
|
403
448
|
private buildDirective;
|
|
449
|
+
/**
|
|
450
|
+
* Exponential backoff for transient provider errors. `2^N * base`
|
|
451
|
+
* capped at `transientBackoffMaxMs`. Zero base disables backoff.
|
|
452
|
+
* Public-private to keep `runOneIteration` readable; the value is
|
|
453
|
+
* recomputed each call from the current retry count, so callers
|
|
454
|
+
* don't have to track state.
|
|
455
|
+
*/
|
|
456
|
+
private computeTransientBackoffMs;
|
|
457
|
+
/**
|
|
458
|
+
* Sleep that wakes early if `stopRequested` flips. Polls every 250 ms
|
|
459
|
+
* so SIGINT / `/autonomy stop` can land in the middle of a long
|
|
460
|
+
* backoff instead of waiting up to a minute for the timer.
|
|
461
|
+
*/
|
|
462
|
+
private sleepInterruptible;
|
|
404
463
|
private appendIterationEntry;
|
|
464
|
+
/**
|
|
465
|
+
* Persistent per-todo failure counter. Skipped silently when the goal
|
|
466
|
+
* file has been removed (graceful clear). Each non-success iteration
|
|
467
|
+
* against a todo source bumps the counter by 1; `pickPendingTodo` reads
|
|
468
|
+
* the counter to rotate past stuck todos once they cross `todoMaxAttempts`.
|
|
469
|
+
*/
|
|
470
|
+
private bumpTodoAttempt;
|
|
471
|
+
/**
|
|
472
|
+
* Flip the mission to `completed` and journal it. Called from two
|
|
473
|
+
* paths: (a) `[GOAL_COMPLETE]` marker in a successful iteration's
|
|
474
|
+
* finalText, (b) `brainstorm` returning DONE consecutively past the
|
|
475
|
+
* configured threshold. Idempotent — re-entry is a no-op once the
|
|
476
|
+
* goal is already `completed`.
|
|
477
|
+
*/
|
|
478
|
+
private markGoalCompleted;
|
|
405
479
|
private appendFailure;
|
|
406
480
|
private persistEngineState;
|
|
407
481
|
}
|
|
408
482
|
|
|
409
|
-
|
|
483
|
+
/**
|
|
484
|
+
* System-prompt contributor that surfaces eternal-autonomy state to the
|
|
485
|
+
* model on every turn.
|
|
486
|
+
*
|
|
487
|
+
* Why this exists: when the engine drives a long-running loop, the
|
|
488
|
+
* per-iteration directive carries the rules. But the directive is a USER
|
|
489
|
+
* message — it scrolls out of working memory after a few compactions and
|
|
490
|
+
* the model forgets it's in autonomy mode (forgets `[GOAL_COMPLETE]`,
|
|
491
|
+
* forgets the todo-state protocol, forgets the no-confirmation rule).
|
|
492
|
+
* Injecting the same anchor as a CACHED system-prompt block solves that
|
|
493
|
+
* — the rules sit next to the identity layer and survive compactions.
|
|
494
|
+
*
|
|
495
|
+
* Block is tagged `ephemeral` so its content (journal tail, iteration
|
|
496
|
+
* counter) changes each turn without invalidating the upstream prefix
|
|
497
|
+
* cache.
|
|
498
|
+
*/
|
|
499
|
+
|
|
500
|
+
interface AutonomyPromptContributorOptions {
|
|
501
|
+
/** Absolute path to the project's `goal.json`. */
|
|
502
|
+
goalPath: string;
|
|
503
|
+
/**
|
|
504
|
+
* Gating function. The contributor consults this on every build and
|
|
505
|
+
* returns an empty array when `false` — without this, the block would
|
|
506
|
+
* leak into interactive runs that happen to have a goal on disk and
|
|
507
|
+
* teach the model loop-control markers it shouldn't emit.
|
|
508
|
+
*
|
|
509
|
+
* Typical wiring: `() => autonomyMode === 'eternal'`.
|
|
510
|
+
*/
|
|
511
|
+
enabled: () => boolean;
|
|
512
|
+
/** Number of journal entries to include in the recent-tail block. Default 5. */
|
|
513
|
+
journalTailSize?: number;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Build a contributor that renders the autonomy-state system block.
|
|
517
|
+
* Returns `[]` when disabled, no goal exists, or the goal has been
|
|
518
|
+
* completed/abandoned — all silent fast-paths.
|
|
519
|
+
*/
|
|
520
|
+
declare function makeAutonomyPromptContributor(opts: AutonomyPromptContributorOptions): SystemPromptContributor;
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* `/goal <description>` preamble — the "no force can stop this" mode.
|
|
524
|
+
*
|
|
525
|
+
* Unlike STEERING (which redirects mid-flight), GOAL is a contract:
|
|
526
|
+
* the user hands over a problem, the agent commits to verifiably
|
|
527
|
+
* finishing it, and every iteration re-reads this preamble from the
|
|
528
|
+
* conversation history. The hardening is entirely prompt-level —
|
|
529
|
+
* the system has already removed implicit budget caps, so this
|
|
530
|
+
* preamble's job is to remove the MODEL's tendency to hedge, ask
|
|
531
|
+
* permission, or declare premature success.
|
|
532
|
+
*
|
|
533
|
+
* The four sections are intentional:
|
|
534
|
+
* 1. AUTHORITY — explicit grant of unbounded fan-out + model
|
|
535
|
+
* switching. Without this the model self-throttles ("I shouldn't
|
|
536
|
+
* spawn too many…") even when budgets are unlimited.
|
|
537
|
+
* 2. DONE — concrete bar for completion. Forces a verifiable
|
|
538
|
+
* artifact (test passing, file written, bug re-run clean).
|
|
539
|
+
* Without this the model returns "I believe it's fixed" and
|
|
540
|
+
* counts that as done.
|
|
541
|
+
* 3. NOT DONE — explicit anti-patterns. Each item is something we
|
|
542
|
+
* saw real agents do as a "completion" that wasn't.
|
|
543
|
+
* 4. PERSISTENCE — three-angle rule for blockers. Stops the model
|
|
544
|
+
* from giving up on the first tool failure.
|
|
545
|
+
*
|
|
546
|
+
* Located in @wrongstack/core (rather than @wrongstack/tui) so headless
|
|
547
|
+
* callers and the WebUI can issue `/goal set` without dragging the TUI
|
|
548
|
+
* package in. The tui re-exports this for backward compatibility.
|
|
549
|
+
*/
|
|
550
|
+
declare function buildGoalPreamble(goal: string): string;
|
|
551
|
+
|
|
552
|
+
export { AutoCompactionMiddleware, AutonomousRunner, type AutonomousRunnerOptions, type AutonomyPromptContributorOptions, DefaultSkillLoader, type DoneCheckResult, DoneConditionChecker, EternalAutonomyEngine, type EternalAutonomyOptions, type EternalEngineState, IntelligentCompactor, type IntelligentCompactorOptions, SelectiveCompactor, type SelectiveCompactorOptions, type SkillLoaderOptions, buildGoalPreamble, makeAutonomyPromptContributor };
|