@wrongstack/core 0.9.7 → 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 (67) hide show
  1. package/dist/{agent-bridge-DMVOX0cF.d.ts → agent-bridge-Dti3KXGk.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-DaF_EgRG.d.ts → agent-subagent-runner-U-rs7kk7.d.ts} +3 -4
  3. package/dist/compactor-D7X96RLZ.d.ts +41 -0
  4. package/dist/{config-SkMIDN9L.d.ts → config-CLXMDOSs.d.ts} +5 -1
  5. package/dist/{context-BRNbHmRM.d.ts → context-zkZeILpr.d.ts} +46 -0
  6. package/dist/coordination/index.d.ts +14 -13
  7. package/dist/coordination/index.js +1263 -123
  8. package/dist/coordination/index.js.map +1 -1
  9. package/dist/defaults/index.d.ts +22 -21
  10. package/dist/defaults/index.js +1477 -152
  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 +42 -30
  14. package/dist/execution/index.js +359 -112
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/extension/index.d.ts +7 -6
  17. package/dist/extension/index.js.map +1 -1
  18. package/dist/{index-CP8638Wm.d.ts → index-BIHJ4uII.d.ts} +12 -8
  19. package/dist/{index-Bsha5K4D.d.ts → index-CFO9QmJo.d.ts} +9 -8
  20. package/dist/index.d.ts +319 -37
  21. package/dist/index.js +2571 -324
  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 +10 -9
  27. package/dist/kernel/index.js.map +1 -1
  28. package/dist/{mcp-servers-BouUWYW6.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-DTXF2aAl.d.ts → multi-agent-coordinator-CAhsegPz.d.ts} +20 -2
  34. package/dist/{null-fleet-bus-Chrc_3Pp.d.ts → null-fleet-bus-Dnl19vmf.d.ts} +496 -15
  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/{secret-scrubber-DttNiGYA.d.ts → permission-H35s9Evv.d.ts} +2 -7
  38. package/dist/{permission-policy-BpCGYBud.d.ts → permission-policy-CT-nRmTn.d.ts} +9 -2
  39. package/dist/{plan-templates-envSmNlZ.d.ts → plan-templates-Bs8iRwi6.d.ts} +28 -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 +10 -10
  43. package/dist/sdd/index.js +225 -68
  44. package/dist/sdd/index.js.map +1 -1
  45. package/dist/secret-scrubber-3MHDDAtm.d.ts +6 -0
  46. package/dist/{secret-scrubber-QSeI0ADi.d.ts → secret-scrubber-7rSC_emZ.d.ts} +1 -1
  47. package/dist/security/index.d.ts +5 -4
  48. package/dist/security/index.js +37 -6
  49. package/dist/security/index.js.map +1 -1
  50. package/dist/{selector-pox8abg0.d.ts → selector-CFTh3Z6p.d.ts} +1 -1
  51. package/dist/{session-reader-CSWcb5Ga.d.ts → session-reader-C7JJlxOw.d.ts} +2 -2
  52. package/dist/skills/index.d.ts +1 -1
  53. package/dist/skills/index.js +1 -1
  54. package/dist/skills/index.js.map +1 -1
  55. package/dist/storage/index.d.ts +391 -6
  56. package/dist/storage/index.js +760 -40
  57. package/dist/storage/index.js.map +1 -1
  58. package/dist/{system-prompt-Bs-Wliab.d.ts → system-prompt-CneIxVip.d.ts} +1 -1
  59. package/dist/{tool-executor-CsktM3h9.d.ts → tool-executor-flTuxsqO.d.ts} +9 -4
  60. package/dist/types/index.d.ts +16 -15
  61. package/dist/types/index.js +60 -0
  62. package/dist/types/index.js.map +1 -1
  63. package/dist/utils/index.d.ts +25 -2
  64. package/dist/utils/index.js +90 -1
  65. package/dist/utils/index.js.map +1 -1
  66. package/package.json +1 -1
  67. 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,22 +1,23 @@
1
- export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-CsktM3h9.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-SkMIDN9L.js';
8
- import { c as Agent, R as RunResult, w as SystemPromptContributor } from '../index-CP8638Wm.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-DaF_EgRG.js';
12
- import { f as DispatchClassifier, d as DefaultMultiAgentCoordinator } from '../multi-agent-coordinator-DTXF2aAl.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
- import '../secret-scrubber-DttNiGYA.js';
19
+ import '../secret-scrubber-3MHDDAtm.js';
20
+ import '../permission-H35s9Evv.js';
20
21
  import 'node:events';
21
22
 
22
23
  interface SkillLoaderOptions {
@@ -91,6 +92,11 @@ declare class IntelligentCompactor implements Compactor {
91
92
  compact(ctx: Context, opts?: {
92
93
  aggressive?: boolean;
93
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;
94
100
  private summarizeAncientTurns;
95
101
  private findSafeBoundary;
96
102
  private findExchangeStart;
@@ -153,6 +159,11 @@ declare class SelectiveCompactor implements Compactor {
153
159
  compact(ctx: Context, opts?: {
154
160
  aggressive?: boolean;
155
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;
156
167
  private repairProtocolAdjacency;
157
168
  /**
158
169
  * Run the LLM selector to decide what to keep vs collapse.
@@ -189,11 +200,16 @@ interface AutoCompactionOptions {
189
200
  * Pipeline middleware that monitors context token load and automatically
190
201
  * triggers compaction when the warn/soft/hard thresholds are crossed.
191
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.
192
207
  */
193
208
  declare class AutoCompactionMiddleware {
194
209
  readonly name = "AutoCompaction";
195
210
  private readonly compactor;
196
- private readonly estimator;
211
+ /** Deprecated. Kept for backward compat with tests that pass simpleEstimator. */
212
+ private readonly _estimator?;
197
213
  private readonly warnThreshold;
198
214
  private readonly softThreshold;
199
215
  private readonly hardThreshold;
@@ -203,19 +219,6 @@ declare class AutoCompactionMiddleware {
203
219
  private readonly events?;
204
220
  private readonly failureMode;
205
221
  private readonly policyProvider?;
206
- /**
207
- * Calibration factor applied to the estimator output. The estimator is now
208
- * expected to already include messages + system prompt + tool definitions
209
- * (see `estimateRequestTokens.total`), so no overhead boost is needed. Kept
210
- * as a constant so a future calibration against real provider tokenization
211
- * (BPE vs the chars/3.5 rough estimator) can dial this without touching the
212
- * threshold-check math.
213
- *
214
- * Historical note: was 1.3 when the estimator only counted messages — that
215
- * double-counted system+tools once the estimator was upgraded, firing
216
- * compaction ~30% earlier than intended (e.g. real 56% load showed as 73%).
217
- */
218
- private static readonly OVERHEAD_FACTOR;
219
222
  /**
220
223
  * Once a compaction attempt reduces nothing (preserveK protects everything,
221
224
  * no oversized tool_results remain to elide), retrying on every iteration
@@ -228,8 +231,11 @@ declare class AutoCompactionMiddleware {
228
231
  private lastNoopAttempt;
229
232
  /**
230
233
  * @param compactor Compactor to use for compaction.
231
- * @param maxContext Provider's max context window in tokens.
232
- * @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).
233
239
  * @param thresholds Threshold fractions (0-1) of maxContext.
234
240
  * @param opts Optional behavior. By default, failures at the
235
241
  * hard threshold throw AGENT_CONTEXT_OVERFLOW so
@@ -237,7 +243,7 @@ declare class AutoCompactionMiddleware {
237
243
  * provider context overflow. Warn/soft failures
238
244
  * still emit compaction.failed and continue.
239
245
  */
240
- constructor(compactor: Compactor, maxContext: number, estimator: (ctx: Context) => number, thresholds: {
246
+ constructor(compactor: Compactor, maxContext: number, _estimator: (ctx: Context) => number, thresholds: {
241
247
  warn: number;
242
248
  soft: number;
243
249
  hard: number;
@@ -562,6 +568,12 @@ interface ParallelEternalOptions {
562
568
  agent: Agent;
563
569
  /** Project root (used for goal.json path). */
564
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;
565
577
  /**
566
578
  * Number of parallel subagent slots per tick.
567
579
  * Default: 4. Range 1–16; values >8 are for high-throughput machines.