@wrongstack/core 0.9.19 → 0.9.20

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.
Files changed (63) hide show
  1. package/dist/{agent-bridge-DMVOX0cF.d.ts → agent-bridge-Dti3KXGk.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-C4qt9e5Y.d.ts → agent-subagent-runner-U-rs7kk7.d.ts} +3 -4
  3. package/dist/compactor-D7X96RLZ.d.ts +41 -0
  4. package/dist/{config-CWva0qoL.d.ts → config-CLXMDOSs.d.ts} +1 -1
  5. package/dist/{context-BRNbHmRM.d.ts → context-zkZeILpr.d.ts} +46 -0
  6. package/dist/coordination/index.d.ts +13 -13
  7. package/dist/coordination/index.js +660 -146
  8. package/dist/coordination/index.js.map +1 -1
  9. package/dist/defaults/index.d.ts +20 -20
  10. package/dist/defaults/index.js +918 -350
  11. package/dist/defaults/index.js.map +1 -1
  12. package/dist/{events-CiG9qUM_.d.ts → events-DH-9r-_C.d.ts} +42 -1
  13. package/dist/execution/index.d.ts +41 -30
  14. package/dist/execution/index.js +358 -112
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/extension/index.d.ts +6 -6
  17. package/dist/extension/index.js.map +1 -1
  18. package/dist/{index-aizK8olO.d.ts → index-BIHJ4uII.d.ts} +11 -8
  19. package/dist/{index-p95HQ22A.d.ts → index-CFO9QmJo.d.ts} +8 -8
  20. package/dist/index.d.ts +311 -35
  21. package/dist/index.js +1933 -512
  22. package/dist/index.js.map +1 -1
  23. package/dist/infrastructure/index.d.ts +6 -6
  24. package/dist/infrastructure/index.js +36 -0
  25. package/dist/infrastructure/index.js.map +1 -1
  26. package/dist/kernel/index.d.ts +9 -9
  27. package/dist/kernel/index.js.map +1 -1
  28. package/dist/{mcp-servers-BkVEqkRe.d.ts → mcp-servers-DkESgh0G.d.ts} +25 -3
  29. package/dist/models/index.d.ts +2 -2
  30. package/dist/models/index.js +1 -1
  31. package/dist/models/index.js.map +1 -1
  32. package/dist/{multi-agent-3ZnTB1aT.d.ts → multi-agent-DNp6lAzg.d.ts} +35 -23
  33. package/dist/{multi-agent-coordinator-bRaI_aD1.d.ts → multi-agent-coordinator-CAhsegPz.d.ts} +20 -2
  34. package/dist/{null-fleet-bus-DKM3Iy9d.d.ts → null-fleet-bus-Dnl19vmf.d.ts} +411 -110
  35. package/dist/observability/index.d.ts +2 -2
  36. package/dist/{path-resolver-TcJfc29Y.d.ts → path-resolver-CHiBL0DD.d.ts} +2 -2
  37. package/dist/{permission-bPuzAy4x.d.ts → permission-H35s9Evv.d.ts} +1 -1
  38. package/dist/{permission-policy-BUQSutpl.d.ts → permission-policy-CT-nRmTn.d.ts} +2 -2
  39. package/dist/{plan-templates-fkQTyz3U.d.ts → plan-templates-Bs8iRwi6.d.ts} +4 -4
  40. package/dist/{provider-runner-BEpikbbN.d.ts → provider-runner-BZdDrWrS.d.ts} +3 -3
  41. package/dist/{retry-policy-BYkq0ugs.d.ts → retry-policy-J9N_PM40.d.ts} +1 -1
  42. package/dist/sdd/index.d.ts +9 -10
  43. package/dist/sdd/index.js +224 -68
  44. package/dist/sdd/index.js.map +1 -1
  45. package/dist/security/index.d.ts +3 -3
  46. package/dist/{selector-pox8abg0.d.ts → selector-CFTh3Z6p.d.ts} +1 -1
  47. package/dist/{session-reader-CSWcb5Ga.d.ts → session-reader-C7JJlxOw.d.ts} +2 -2
  48. package/dist/skills/index.d.ts +1 -1
  49. package/dist/skills/index.js +1 -1
  50. package/dist/skills/index.js.map +1 -1
  51. package/dist/storage/index.d.ts +390 -6
  52. package/dist/storage/index.js +672 -35
  53. package/dist/storage/index.js.map +1 -1
  54. package/dist/{system-prompt-Bs-Wliab.d.ts → system-prompt-CneIxVip.d.ts} +1 -1
  55. package/dist/{tool-executor-Boo3dekH.d.ts → tool-executor-flTuxsqO.d.ts} +9 -4
  56. package/dist/types/index.d.ts +14 -14
  57. package/dist/types/index.js +60 -0
  58. package/dist/types/index.js.map +1 -1
  59. package/dist/utils/index.d.ts +18 -6
  60. package/dist/utils/index.js +61 -56
  61. package/dist/utils/index.js.map +1 -1
  62. package/package.json +1 -1
  63. package/dist/compactor-DVTKL7XD.d.ts +0 -23
@@ -1,4 +1,4 @@
1
- import { $ as Usage, d as Context, X as ToolProgressEvent, Q as Tool } from './context-BRNbHmRM.js';
1
+ import { $ as Usage, d as Context, X as ToolProgressEvent, Q as Tool } from './context-zkZeILpr.js';
2
2
 
3
3
  /**
4
4
  * EventBus — observe-only typed event bus.
@@ -160,6 +160,20 @@ interface EventMap {
160
160
  * for tools without a meaningful line count. */
161
161
  outputLines?: number;
162
162
  };
163
+ /**
164
+ * Fired on every `iteration.completed`. UIs subscribe to render a live
165
+ * context-window fill bar per agent (e.g. "67% ████████░░"). The
166
+ * `load` fraction matches the threshold levels: 0–0.6 green, 0.6–0.75
167
+ * yellow, 0.75+ red.
168
+ */
169
+ 'ctx.pct': {
170
+ /** Fraction of maxContext currently in use (0–1+. Can exceed 1 when over budget). */
171
+ load: number;
172
+ /** Estimated total tokens (system + tools + messages). */
173
+ tokens: number;
174
+ /** Provider's max context window. */
175
+ maxContext: number;
176
+ };
163
177
  'token.threshold': {
164
178
  used: number;
165
179
  limit: number;
@@ -365,6 +379,18 @@ interface EventMap {
365
379
  summary: string;
366
380
  ok: boolean;
367
381
  };
382
+ /**
383
+ * Fired by MultiAgentHost when a subagent's context window load changes.
384
+ * The leader agent's ctx.pct is emitted directly on the host EventBus;
385
+ * subagent ctx.pct events are forwarded here with subagentId attribution.
386
+ * TUI uses this to render live context fill bars per agent.
387
+ */
388
+ 'subagent.ctx_pct': {
389
+ subagentId: string;
390
+ load: number;
391
+ tokens: number;
392
+ maxContext: number;
393
+ };
368
394
  'mcp.server.connected': {
369
395
  name: string;
370
396
  toolCount: number;
@@ -387,6 +413,21 @@ interface EventMap {
387
413
  ts: string;
388
414
  fileCount: number;
389
415
  };
416
+ /**
417
+ * Fired by SessionWriter.writeInFlightMarker() — the agent loop has
418
+ * started a long-running operation. Pairs with `in_flight.ended`
419
+ * on clean shutdown. A marker with no end indicates a crash.
420
+ * (Idea #1 from IDEAS.md — Stateful Session Recovery.)
421
+ */
422
+ 'in_flight.started': {
423
+ context: string;
424
+ ts: string;
425
+ };
426
+ /** Fired by SessionWriter.clearInFlightMarker() — operation completed cleanly. */
427
+ 'in_flight.ended': {
428
+ reason: 'clean' | 'aborted' | 'recovered';
429
+ ts: string;
430
+ };
390
431
  /**
391
432
  * Fired after a session rewind completes: files are reverted and the session
392
433
  * history is truncated. The TUI listens to this to update its checkpoint
@@ -1,23 +1,23 @@
1
- export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-Boo3dekH.js';
2
- import { m as Provider, d as Context } from '../context-BRNbHmRM.js';
3
- import { a as Compactor, C as CompactReport } from '../compactor-DVTKL7XD.js';
4
- import { M as MessageSelector } from '../selector-pox8abg0.js';
5
- import { E as EventBus } from '../events-CiG9qUM_.js';
6
- import { b as MiddlewareHandler } from '../system-prompt-Bs-Wliab.js';
7
- import { e as ContextWindowAggressiveOn, i as ContextWindowPolicy } from '../config-CWva0qoL.js';
8
- import { c as Agent, R as RunResult, w as SystemPromptContributor } from '../index-aizK8olO.js';
9
- import { D as DoneCondition } from '../multi-agent-3ZnTB1aT.js';
1
+ export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-flTuxsqO.js';
2
+ import { m as Provider, d as Context } from '../context-zkZeILpr.js';
3
+ import { a as Compactor, C as CompactReport } from '../compactor-D7X96RLZ.js';
4
+ import { M as MessageSelector } from '../selector-CFTh3Z6p.js';
5
+ import { E as EventBus } from '../events-DH-9r-_C.js';
6
+ import { b as MiddlewareHandler } from '../system-prompt-CneIxVip.js';
7
+ import { e as ContextWindowAggressiveOn, i as ContextWindowPolicy } from '../config-CLXMDOSs.js';
8
+ import { c as Agent, R as RunResult, w as SystemPromptContributor } from '../index-BIHJ4uII.js';
9
+ import { D as DoneCondition } from '../multi-agent-DNp6lAzg.js';
10
10
  import { J as JournalEntry } from '../goal-store-C7jcumEh.js';
11
- import { A as AgentFactory } from '../agent-subagent-runner-C4qt9e5Y.js';
12
- import { f as DispatchClassifier, d as DefaultMultiAgentCoordinator } from '../multi-agent-coordinator-bRaI_aD1.js';
11
+ import { A as AgentFactory } from '../agent-subagent-runner-U-rs7kk7.js';
12
+ import { f as DispatchClassifier, d as DefaultMultiAgentCoordinator } from '../multi-agent-coordinator-CAhsegPz.js';
13
13
  import { a as SkillLoader, b as SkillManifest, S as SkillEntry } from '../skill-CxuWrsKK.js';
14
14
  import { a as WstackPaths } from '../wstack-paths-BCgmTNlG.js';
15
- import '../retry-policy-BYkq0ugs.js';
15
+ import '../retry-policy-J9N_PM40.js';
16
16
  import '../models-registry-BcYJDKLm.js';
17
17
  import '../logger-DDd5C--Z.js';
18
18
  import '../observability-BhnVLBLS.js';
19
19
  import '../secret-scrubber-3MHDDAtm.js';
20
- import '../permission-bPuzAy4x.js';
20
+ import '../permission-H35s9Evv.js';
21
21
  import 'node:events';
22
22
 
23
23
  interface SkillLoaderOptions {
@@ -92,6 +92,11 @@ declare class IntelligentCompactor implements Compactor {
92
92
  compact(ctx: Context, opts?: {
93
93
  aggressive?: boolean;
94
94
  }): Promise<CompactReport>;
95
+ /**
96
+ * Estimate the full API request token count: messages + systemPrompt + toolDefs.
97
+ * This is the accurate figure for context-window pressure monitoring.
98
+ */
99
+ private estimateFullRequest;
95
100
  private summarizeAncientTurns;
96
101
  private findSafeBoundary;
97
102
  private findExchangeStart;
@@ -154,6 +159,11 @@ declare class SelectiveCompactor implements Compactor {
154
159
  compact(ctx: Context, opts?: {
155
160
  aggressive?: boolean;
156
161
  }): Promise<CompactReport>;
162
+ /**
163
+ * Estimate the full API request token count: messages + systemPrompt + toolDefs.
164
+ * This is the accurate figure for context-window pressure monitoring.
165
+ */
166
+ private estimateFullRequest;
157
167
  private repairProtocolAdjacency;
158
168
  /**
159
169
  * Run the LLM selector to decide what to keep vs collapse.
@@ -190,11 +200,16 @@ interface AutoCompactionOptions {
190
200
  * Pipeline middleware that monitors context token load and automatically
191
201
  * triggers compaction when the warn/soft/hard thresholds are crossed.
192
202
  * Runs before the next agent iteration.
203
+ *
204
+ * Uses `estimateRequestTokens` for accurate full-request token counting:
205
+ * messages + systemPrompt + toolDefs. This replaces the previous pattern
206
+ * of applying an OVERHEAD_FACTOR to a messages-only estimate.
193
207
  */
194
208
  declare class AutoCompactionMiddleware {
195
209
  readonly name = "AutoCompaction";
196
210
  private readonly compactor;
197
- private readonly estimator;
211
+ /** Deprecated. Kept for backward compat with tests that pass simpleEstimator. */
212
+ private readonly _estimator?;
198
213
  private readonly warnThreshold;
199
214
  private readonly softThreshold;
200
215
  private readonly hardThreshold;
@@ -204,19 +219,6 @@ declare class AutoCompactionMiddleware {
204
219
  private readonly events?;
205
220
  private readonly failureMode;
206
221
  private readonly policyProvider?;
207
- /**
208
- * Calibration factor applied to the estimator output. The estimator is now
209
- * expected to already include messages + system prompt + tool definitions
210
- * (see `estimateRequestTokens.total`), so no overhead boost is needed. Kept
211
- * as a constant so a future calibration against real provider tokenization
212
- * (BPE vs the chars/3.5 rough estimator) can dial this without touching the
213
- * threshold-check math.
214
- *
215
- * Historical note: was 1.3 when the estimator only counted messages — that
216
- * double-counted system+tools once the estimator was upgraded, firing
217
- * compaction ~30% earlier than intended (e.g. real 56% load showed as 73%).
218
- */
219
- private static readonly OVERHEAD_FACTOR;
220
222
  /**
221
223
  * Once a compaction attempt reduces nothing (preserveK protects everything,
222
224
  * no oversized tool_results remain to elide), retrying on every iteration
@@ -229,8 +231,11 @@ declare class AutoCompactionMiddleware {
229
231
  private lastNoopAttempt;
230
232
  /**
231
233
  * @param compactor Compactor to use for compaction.
232
- * @param maxContext Provider's max context window in tokens.
233
- * @param estimator Token estimation function.
234
+ * @param maxContext Provider's max context window in tokens.
235
+ * @param _estimator Deprecated parameter kept for backward compatibility.
236
+ * The middleware now uses `estimateRequestTokens` internally
237
+ * for accurate full-request token counting (messages +
238
+ * systemPrompt + toolDefs).
234
239
  * @param thresholds Threshold fractions (0-1) of maxContext.
235
240
  * @param opts Optional behavior. By default, failures at the
236
241
  * hard threshold throw AGENT_CONTEXT_OVERFLOW so
@@ -238,7 +243,7 @@ declare class AutoCompactionMiddleware {
238
243
  * provider context overflow. Warn/soft failures
239
244
  * still emit compaction.failed and continue.
240
245
  */
241
- constructor(compactor: Compactor, maxContext: number, estimator: (ctx: Context) => number, thresholds: {
246
+ constructor(compactor: Compactor, maxContext: number, _estimator: (ctx: Context) => number, thresholds: {
242
247
  warn: number;
243
248
  soft: number;
244
249
  hard: number;
@@ -563,6 +568,12 @@ interface ParallelEternalOptions {
563
568
  agent: Agent;
564
569
  /** Project root (used for goal.json path). */
565
570
  projectRoot: string;
571
+ /**
572
+ * Override the resolved goal.json path. Defaults to
573
+ * `goalFilePath(projectRoot)` (a hashed location under the home dir).
574
+ * Primarily for tests that want an isolated goal file under a temp dir.
575
+ */
576
+ goalPath?: string;
566
577
  /**
567
578
  * Number of parallel subagent slots per tick.
568
579
  * Default: 4. Range 1–16; values >8 are for high-throughput machines.