@wrongstack/core 0.32.0 → 0.51.3

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 (45) hide show
  1. package/dist/{agent-bridge-D_XcS2HL.d.ts → agent-bridge-CjbD-i7-.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-DpZTLdBe.d.ts → agent-subagent-runner-DfvlBx5N.d.ts} +3 -3
  3. package/dist/{config-BUEGM4JP.d.ts → config-ZRCf7sTu.d.ts} +21 -1
  4. package/dist/coordination/index.d.ts +10 -10
  5. package/dist/coordination/index.js +3310 -3056
  6. package/dist/coordination/index.js.map +1 -1
  7. package/dist/defaults/index.d.ts +13 -13
  8. package/dist/defaults/index.js +1544 -1390
  9. package/dist/defaults/index.js.map +1 -1
  10. package/dist/{events-BrQiweXN.d.ts → events-Bt44ikPN.d.ts} +135 -1
  11. package/dist/execution/index.d.ts +35 -9
  12. package/dist/execution/index.js +61 -28
  13. package/dist/execution/index.js.map +1 -1
  14. package/dist/extension/index.d.ts +3 -3
  15. package/dist/{index-pXJdVLe0.d.ts → index-OzA1XjHL.d.ts} +35 -3
  16. package/dist/{index-ysfO_DlX.d.ts → index-mAWBdLyJ.d.ts} +2 -2
  17. package/dist/index.d.ts +221 -25
  18. package/dist/index.js +1670 -1017
  19. package/dist/index.js.map +1 -1
  20. package/dist/infrastructure/index.d.ts +4 -4
  21. package/dist/infrastructure/index.js +17 -3
  22. package/dist/infrastructure/index.js.map +1 -1
  23. package/dist/kernel/index.d.ts +4 -4
  24. package/dist/kernel/index.js +3 -1
  25. package/dist/kernel/index.js.map +1 -1
  26. package/dist/{mcp-servers-BzB3r7_c.d.ts → mcp-servers-DONdo-XM.d.ts} +1 -1
  27. package/dist/models/index.js +5 -2
  28. package/dist/models/index.js.map +1 -1
  29. package/dist/{multi-agent-C8Z1i__e.d.ts → multi-agent-Ba9Ni2hC.d.ts} +1 -1
  30. package/dist/{multi-agent-coordinator-DOXSgtom.d.ts → multi-agent-coordinator-BuKq0q89.d.ts} +2 -2
  31. package/dist/{null-fleet-bus-DLsUjOyB.d.ts → null-fleet-bus-C0xd73YP.d.ts} +169 -138
  32. package/dist/observability/index.d.ts +1 -1
  33. package/dist/{path-resolver-DumKAi0n.d.ts → path-resolver-nkmdiFgi.d.ts} +1 -1
  34. package/dist/{plan-templates-BZMi-VpU.d.ts → plan-templates-BmDdJ7UL.d.ts} +2 -2
  35. package/dist/{provider-runner-Dlv8Fvw9.d.ts → provider-runner-BGro2qQB.d.ts} +1 -1
  36. package/dist/sdd/index.d.ts +5 -5
  37. package/dist/storage/index.d.ts +3 -3
  38. package/dist/{tool-executor-BAi4WI2d.d.ts → tool-executor-p4tP9tGF.d.ts} +1 -1
  39. package/dist/types/index.d.ts +8 -8
  40. package/dist/types/index.js +22 -5
  41. package/dist/types/index.js.map +1 -1
  42. package/dist/utils/index.d.ts +107 -1
  43. package/dist/utils/index.js +53 -2
  44. package/dist/utils/index.js.map +1 -1
  45. package/package.json +1 -1
@@ -1,11 +1,12 @@
1
- import { c as AgentPhase, b as AgentDefinition, d as DefaultMultiAgentCoordinator, f as DispatchClassifier } from './multi-agent-coordinator-DOXSgtom.js';
2
- import { n as SubagentConfig, u as TaskResult, k as CoordinatorStatus, v as TaskSpec, M as MultiAgentConfig, t as SubagentRunner } from './multi-agent-C8Z1i__e.js';
1
+ import { c as AgentPhase, b as AgentDefinition, d as DefaultMultiAgentCoordinator, f as DispatchClassifier } from './multi-agent-coordinator-BuKq0q89.js';
2
+ import { n as SubagentConfig, u as TaskResult, k as CoordinatorStatus, v as TaskSpec, M as MultiAgentConfig, t as SubagentRunner } from './multi-agent-Ba9Ni2hC.js';
3
3
  import { B as SessionWriter, Q as Tool, y as SessionStore } from './context-7u93AcGD.js';
4
- import { F as FleetBus, e as FleetUsage, f as FleetUsageAggregator } from './agent-subagent-runner-DpZTLdBe.js';
4
+ import { F as FleetBus, e as FleetUsage, f as FleetUsageAggregator } from './agent-subagent-runner-DfvlBx5N.js';
5
5
  import { EventEmitter } from 'node:events';
6
+ import { B as BrainArbiter, E as EventBus } from './events-Bt44ikPN.js';
6
7
  import { a as DirectorStateSnapshot } from './director-state-BmYi3DGA.js';
7
- import { I as InMemoryAgentBridge } from './agent-bridge-D_XcS2HL.js';
8
- import { E as EventBus } from './events-BrQiweXN.js';
8
+ import { k as ModelMatrixEntry } from './config-ZRCf7sTu.js';
9
+ import { I as InMemoryAgentBridge } from './agent-bridge-CjbD-i7-.js';
9
10
 
10
11
  /**
11
12
  * Agent catalog aggregator.
@@ -281,135 +282,6 @@ declare class CollabSession extends EventEmitter {
281
282
  private cleanup;
282
283
  }
283
284
 
284
- declare class LargeAnswerStore {
285
- /**
286
- * Responses above this size (in characters) are stored out-of-context.
287
- * Below this, the full answer is returned inline (no overhead).
288
- * Default: 2000 chars ≈ 400-600 tokens.
289
- */
290
- readonly sizeThreshold: number;
291
- private readonly store;
292
- constructor(sizeThreshold?: number);
293
- /**
294
- * Store a value, returning a summary + key for inline use.
295
- * If the value is below sizeThreshold, returns it as-is (no store entry).
296
- */
297
- storeAnswer(value: unknown): {
298
- key?: string;
299
- summary: string;
300
- inline: boolean;
301
- };
302
- /**
303
- * Retrieve a previously stored answer by its key.
304
- * Returns undefined if the key is unknown or the store was cleared.
305
- */
306
- retrieveAnswer(key: string): unknown | undefined;
307
- /**
308
- * Check if a key exists in the store.
309
- */
310
- hasAnswer(key: string): boolean;
311
- /** Number of stored entries. */
312
- get size(): number;
313
- /** Total characters stored. */
314
- get totalChars(): number;
315
- /** Clear all stored entries. Call at the end of a director run. */
316
- clear(): void;
317
- }
318
-
319
- /**
320
- * Interface for a fleet coordinator. Implemented by both `Director`
321
- * (full LLM-driven orchestration with fleet policy) and
322
- * `DefaultMultiAgentCoordinator` (direct API-driven, no fleet policy).
323
- *
324
- * External callers — CLI slash commands, tests, the delegate tool —
325
- * use this to stay agnostic to the orchestration mode.
326
- *
327
- * The interface captures the **orchestration contract**: spawn, assign,
328
- * terminate, await, and query. Fleet-level policy (cost caps, manifest
329
- * writing, checkpointing) lives behind this surface and is optional
330
- * from the caller's perspective.
331
- *
332
- * @example
333
- * ```typescript
334
- * let coordinator: ICoordinator = isDirectorMode
335
- * ? new Director({ config, ... })
336
- * : new DefaultMultiAgentCoordinator(config);
337
- * const id = await coordinator.spawn({ name: 'worker', role: 'researcher' });
338
- * await coordinator.assign({ id: 't-1', description: 'research X', subagentId: id });
339
- * const results = await coordinator.awaitTasks(['t-1']);
340
- * ```
341
- */
342
- interface ICoordinator {
343
- /** Stable identifier for this coordinator instance. */
344
- readonly coordinatorId: string;
345
- /**
346
- * Spawn a new subagent and return its id. In director mode this
347
- * enforces fleet-wide spawn caps and cost limits; in raw coordinator
348
- * mode it is a direct pass-through.
349
- */
350
- spawn(config: SubagentConfig): Promise<string>;
351
- /**
352
- * Assign a task to a subagent (or to the fleet for auto-routing).
353
- * Returns the assigned task id.
354
- */
355
- assign(task: {
356
- id: string;
357
- description: string;
358
- subagentId?: string;
359
- }): Promise<string>;
360
- /**
361
- * Synchronously ask a subagent something via the in-memory bridge.
362
- * The subagent must have been spawned and must handle `bridge.subscribe()`
363
- * in its task loop. Returns the reply payload or throws on timeout.
364
- *
365
- * Only available in director mode — raw coordinator has no bridge.
366
- */
367
- ask<T = unknown>(subagentId: string, payload: unknown, timeoutMs?: number): Promise<T>;
368
- /**
369
- * Wait for one or more tasks to complete and return their results.
370
- * If a task is already done when called, returns immediately.
371
- * Resolves to an array in the same order as `taskIds`.
372
- */
373
- awaitTasks(taskIds: string[]): Promise<TaskResult[]>;
374
- /**
375
- * Gracefully stop a single subagent. The subagent finishes its current
376
- * in-flight work and exits cleanly — it does not hard-kill.
377
- */
378
- terminate(subagentId: string): Promise<void>;
379
- /**
380
- * Stop all subagents. In-flight tasks are allowed to complete;
381
- * no new tasks are dispatched.
382
- */
383
- terminateAll(): Promise<void>;
384
- /**
385
- * Stop a subagent and remove it from the coordinator. Releases all
386
- * associated resources (AbortController, budget state). The subagent
387
- * entry is deleted so the id can be reused in a future spawn.
388
- */
389
- remove(subagentId: string): Promise<void>;
390
- /**
391
- * Live coordinator status — subagent list, pending task count,
392
- * completed task count, iteration totals.
393
- */
394
- status(): CoordinatorStatus;
395
- /**
396
- * Snapshot of completed task results. In director mode this returns
397
- * every `TaskResult` from the fleet; in raw coordinator mode this
398
- * may return an empty array if the coordinator doesn't cache results.
399
- */
400
- completedResults(): TaskResult[];
401
- /**
402
- * Subscribe to coordinator lifecycle events. Currently supports
403
- * `task.completed` — the payload carries the task spec and result.
404
- *
405
- * Returns a disposer function; call it to unsubscribe.
406
- */
407
- on(event: 'task.completed', handler: (payload: {
408
- task: TaskSpec;
409
- result: TaskResult;
410
- }) => void): () => void;
411
- }
412
-
413
285
  /**
414
286
  * Interface for fleet-level lifecycle and policy. Covers:
415
287
  * - Spawn lifecycle hooks (canSpawn check, recordSpawn after-effects)
@@ -596,8 +468,11 @@ interface FleetManagerOptions {
596
468
  /**
597
469
  * Provider's max context window in tokens. Used with `maxLeaderContextLoad`
598
470
  * to compute the absolute token threshold. Default: 128_000.
471
+ *
472
+ * A function may be supplied when the leader can switch models at runtime;
473
+ * canSpawn() reads it lazily so the spawn threshold follows the active model.
599
474
  */
600
- maxContext?: number;
475
+ maxContext?: number | (() => number | undefined);
601
476
  }
602
477
  /**
603
478
  * Fleet-level policy container extracted from `Director`. Owns:
@@ -655,7 +530,7 @@ declare class FleetManager implements IFleetManager {
655
530
  private leaderContextPressure;
656
531
  /** Maximum context load fraction before spawn is refused. */
657
532
  private readonly maxLeaderContextLoad;
658
- /** Provider's max context window in tokens. */
533
+ /** Provider's max context window in tokens, or a live resolver for runtime model switches. */
659
534
  private readonly maxContext;
660
535
  constructor(opts?: FleetManagerOptions);
661
536
  get fleetBus(): FleetBus;
@@ -682,6 +557,7 @@ declare class FleetManager implements IFleetManager {
682
557
  observed: number;
683
558
  } | null;
684
559
  setLeaderContextPressure(tokens: number): void;
560
+ private resolveMaxContext;
685
561
  /**
686
562
  * Assign a memorable nickname (e.g. "Einstein (Bug Hunter)") to the config,
687
563
  * record it so the same name is never reused, then record the spawn.
@@ -774,6 +650,135 @@ declare class FleetManager implements IFleetManager {
774
650
  dispose(): void;
775
651
  }
776
652
 
653
+ /**
654
+ * Interface for a fleet coordinator. Implemented by both `Director`
655
+ * (full LLM-driven orchestration with fleet policy) and
656
+ * `DefaultMultiAgentCoordinator` (direct API-driven, no fleet policy).
657
+ *
658
+ * External callers — CLI slash commands, tests, the delegate tool —
659
+ * use this to stay agnostic to the orchestration mode.
660
+ *
661
+ * The interface captures the **orchestration contract**: spawn, assign,
662
+ * terminate, await, and query. Fleet-level policy (cost caps, manifest
663
+ * writing, checkpointing) lives behind this surface and is optional
664
+ * from the caller's perspective.
665
+ *
666
+ * @example
667
+ * ```typescript
668
+ * let coordinator: ICoordinator = isDirectorMode
669
+ * ? new Director({ config, ... })
670
+ * : new DefaultMultiAgentCoordinator(config);
671
+ * const id = await coordinator.spawn({ name: 'worker', role: 'researcher' });
672
+ * await coordinator.assign({ id: 't-1', description: 'research X', subagentId: id });
673
+ * const results = await coordinator.awaitTasks(['t-1']);
674
+ * ```
675
+ */
676
+ interface ICoordinator {
677
+ /** Stable identifier for this coordinator instance. */
678
+ readonly coordinatorId: string;
679
+ /**
680
+ * Spawn a new subagent and return its id. In director mode this
681
+ * enforces fleet-wide spawn caps and cost limits; in raw coordinator
682
+ * mode it is a direct pass-through.
683
+ */
684
+ spawn(config: SubagentConfig): Promise<string>;
685
+ /**
686
+ * Assign a task to a subagent (or to the fleet for auto-routing).
687
+ * Returns the assigned task id.
688
+ */
689
+ assign(task: {
690
+ id: string;
691
+ description: string;
692
+ subagentId?: string;
693
+ }): Promise<string>;
694
+ /**
695
+ * Synchronously ask a subagent something via the in-memory bridge.
696
+ * The subagent must have been spawned and must handle `bridge.subscribe()`
697
+ * in its task loop. Returns the reply payload or throws on timeout.
698
+ *
699
+ * Only available in director mode — raw coordinator has no bridge.
700
+ */
701
+ ask<T = unknown>(subagentId: string, payload: unknown, timeoutMs?: number): Promise<T>;
702
+ /**
703
+ * Wait for one or more tasks to complete and return their results.
704
+ * If a task is already done when called, returns immediately.
705
+ * Resolves to an array in the same order as `taskIds`.
706
+ */
707
+ awaitTasks(taskIds: string[]): Promise<TaskResult[]>;
708
+ /**
709
+ * Gracefully stop a single subagent. The subagent finishes its current
710
+ * in-flight work and exits cleanly — it does not hard-kill.
711
+ */
712
+ terminate(subagentId: string): Promise<void>;
713
+ /**
714
+ * Stop all subagents. In-flight tasks are allowed to complete;
715
+ * no new tasks are dispatched.
716
+ */
717
+ terminateAll(): Promise<void>;
718
+ /**
719
+ * Stop a subagent and remove it from the coordinator. Releases all
720
+ * associated resources (AbortController, budget state). The subagent
721
+ * entry is deleted so the id can be reused in a future spawn.
722
+ */
723
+ remove(subagentId: string): Promise<void>;
724
+ /**
725
+ * Live coordinator status — subagent list, pending task count,
726
+ * completed task count, iteration totals.
727
+ */
728
+ status(): CoordinatorStatus;
729
+ /**
730
+ * Snapshot of completed task results. In director mode this returns
731
+ * every `TaskResult` from the fleet; in raw coordinator mode this
732
+ * may return an empty array if the coordinator doesn't cache results.
733
+ */
734
+ completedResults(): TaskResult[];
735
+ /**
736
+ * Subscribe to coordinator lifecycle events. Currently supports
737
+ * `task.completed` — the payload carries the task spec and result.
738
+ *
739
+ * Returns a disposer function; call it to unsubscribe.
740
+ */
741
+ on(event: 'task.completed', handler: (payload: {
742
+ task: TaskSpec;
743
+ result: TaskResult;
744
+ }) => void): () => void;
745
+ }
746
+
747
+ declare class LargeAnswerStore {
748
+ /**
749
+ * Responses above this size (in characters) are stored out-of-context.
750
+ * Below this, the full answer is returned inline (no overhead).
751
+ * Default: 2000 chars ≈ 400-600 tokens.
752
+ */
753
+ readonly sizeThreshold: number;
754
+ private readonly store;
755
+ constructor(sizeThreshold?: number);
756
+ /**
757
+ * Store a value, returning a summary + key for inline use.
758
+ * If the value is below sizeThreshold, returns it as-is (no store entry).
759
+ */
760
+ storeAnswer(value: unknown): {
761
+ key?: string;
762
+ summary: string;
763
+ inline: boolean;
764
+ };
765
+ /**
766
+ * Retrieve a previously stored answer by its key.
767
+ * Returns undefined if the key is unknown or the store was cleared.
768
+ */
769
+ retrieveAnswer(key: string): unknown | undefined;
770
+ /**
771
+ * Check if a key exists in the store.
772
+ */
773
+ hasAnswer(key: string): boolean;
774
+ /** Number of stored entries. */
775
+ get size(): number;
776
+ /** Total characters stored. */
777
+ get totalChars(): number;
778
+ /** Clear all stored entries. Call at the end of a director run. */
779
+ clear(): void;
780
+ }
781
+
777
782
  /**
778
783
  * Director — high-level orchestrator that owns a `MultiAgentCoordinator`,
779
784
  * a `FleetBus`, and a `FleetUsageAggregator`. Exposes a small imperative
@@ -790,6 +795,8 @@ declare class FleetManager implements IFleetManager {
790
795
  interface DirectorOptions {
791
796
  config: MultiAgentConfig;
792
797
  runner?: SubagentRunner;
798
+ /** Optional Brain arbiter above the director for policy/decision escalation. */
799
+ brain?: BrainArbiter;
793
800
  /**
794
801
  * When set, the director writes a `fleet.json` manifest to this path
795
802
  * recording every spawned subagent (id, provider, model, role, task
@@ -957,9 +964,27 @@ interface DirectorOptions {
957
964
  * Provider's max context window in tokens. Used with `maxLeaderContextLoad`
958
965
  * to compute the absolute token threshold. Default: 128_000.
959
966
  * Only used when no `fleetManager` is provided (inline mode).
967
+ *
968
+ * A function may be supplied when the leader can switch models at runtime;
969
+ * spawn() reads it lazily so the threshold follows the active model.
970
+ */
971
+ maxContext?: number | (() => number | undefined);
972
+ /**
973
+ * Per-task model matrix (Config.modelMatrix). When set, a spawn whose
974
+ * config has no explicit `model` is resolved against this matrix by role
975
+ * (→ phase → `*`) before the subagent is built — so the spawned event,
976
+ * manifest, and the agent itself all run the matched model. Explicit
977
+ * per-spawn `model` overrides always win.
978
+ *
979
+ * Pass a **function** (not a snapshot) when the matrix can change at
980
+ * runtime (the CLI passes `() => configStore.get().modelMatrix`) so a
981
+ * mid-session `/setmodel` takes effect on the next spawn. A static record
982
+ * is also accepted for tests and one-shot runs.
960
983
  */
961
- maxContext?: number;
984
+ modelMatrix?: ModelMatrixSource;
962
985
  }
986
+ /** Either a static matrix or a live getter (re-read on every spawn). */
987
+ type ModelMatrixSource = Record<string, ModelMatrixEntry> | (() => Record<string, ModelMatrixEntry> | undefined);
963
988
  /**
964
989
  * Thrown by `Director.spawn()` when a configured spawn cap (`maxSpawns`,
965
990
  * `maxSpawnDepth`) is hit. Distinct error class so callers — including
@@ -1012,6 +1037,9 @@ declare class Director implements ICoordinator {
1012
1037
  * Read the leader agent's current context pressure.
1013
1038
  */
1014
1039
  getLeaderContextPressure(): number;
1040
+ private resolveMaxContext;
1041
+ /** Optional Brain arbiter for director-level policy decisions. */
1042
+ private readonly brain?;
1015
1043
  /**
1016
1044
  * Optional fleet-level policy container. When provided the Director
1017
1045
  * delegates spawn budgeting, manifest entries, and checkpointing to it
@@ -1103,8 +1131,11 @@ declare class Director implements ICoordinator {
1103
1131
  private leaderContextPressure;
1104
1132
  /** Maximum context load fraction before spawn is refused. */
1105
1133
  private readonly maxLeaderContextLoad;
1106
- /** Provider's max context window in tokens. */
1134
+ /** Provider's max context window in tokens, or a live resolver for runtime model switches. */
1107
1135
  private readonly maxContext;
1136
+ /** Per-task model matrix (static record or live getter); resolved
1137
+ * per-spawn when no explicit model is set. */
1138
+ private readonly modelMatrix?;
1108
1139
  /**
1109
1140
  * When set by `workComplete()`, the director stops dispatching new tasks
1110
1141
  * and terminates all running subagents. Used when the director's LLM decides
@@ -1,5 +1,5 @@
1
1
  import { e as MetricsSink, M as MetricLabels, f as MetricsSnapshot, b as HealthRegistry, H as HealthCheck, A as AggregateHealth, T as Tracer, S as Span } from '../observability-BhnVLBLS.js';
2
- import { E as EventBus } from '../events-BrQiweXN.js';
2
+ import { E as EventBus } from '../events-Bt44ikPN.js';
3
3
  import '../context-7u93AcGD.js';
4
4
 
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { E as EventBus } from './events-BrQiweXN.js';
1
+ import { E as EventBus } from './events-Bt44ikPN.js';
2
2
  import { b as ModelsRegistry, R as ResolvedModel } from './models-registry-BcYJDKLm.js';
3
3
  import { O as TokenCounter, $ as Usage, C as CacheStats } from './context-7u93AcGD.js';
4
4
  import { P as PathResolver } from './path-resolver-CPRj4bFY.js';
@@ -1,10 +1,10 @@
1
- import { E as EventBus } from './events-BrQiweXN.js';
1
+ import { E as EventBus } from './events-Bt44ikPN.js';
2
2
  import { S as SecretScrubber } from './secret-scrubber-3MHDDAtm.js';
3
3
  import { y as SessionStore, x as SessionMetadata, B as SessionWriter, r as ResumedSession, S as SessionData, z as SessionSummary, c as ContentBlock, w as SessionEvent, N as TodoItem, f as ConversationState } from './context-7u93AcGD.js';
4
4
  import { e as AttachmentStore, A as AddAttachmentInput, d as AttachmentRef, a as Attachment } from './session-reader-bfgsy2a0.js';
5
5
  import { b as MemoryStore, a as MemoryScope } from './memory-CEXuo7sz.js';
6
6
  import { a as WstackPaths } from './wstack-paths-eMXnY1_X.js';
7
- import { c as ConfigStore, a as Config, b as ConfigLoader, n as SyncConfig } from './config-BUEGM4JP.js';
7
+ import { c as ConfigStore, a as Config, b as ConfigLoader, o as SyncConfig } from './config-ZRCf7sTu.js';
8
8
  import { S as SecretVault } from './secret-vault-DoISxaKO.js';
9
9
 
10
10
  interface SessionStoreOptions {
@@ -1,4 +1,4 @@
1
- import { E as EventBus } from './events-BrQiweXN.js';
1
+ import { E as EventBus } from './events-Bt44ikPN.js';
2
2
  import { a as Logger } from './logger-DDd5C--Z.js';
3
3
  import { T as Tracer } from './observability-BhnVLBLS.js';
4
4
  import { m as Provider, p as Request, d as Context, q as Response } from './context-7u93AcGD.js';
@@ -1,15 +1,15 @@
1
1
  import { h as Specification, S as SpecAnalysis, g as SpecValidationResult, l as TaskGraph, m as TaskNode, k as TaskFilter, p as TaskSort, o as TaskProgress, r as TaskType, n as TaskPriority, e as SpecStatus, f as SpecTemplate, b as SpecRequirement } from '../task-graph-D1YQbpxF.js';
2
- import { E as EventBus } from '../events-BrQiweXN.js';
3
- import { D as DoneCondition, u as TaskResult } from '../multi-agent-C8Z1i__e.js';
4
- import { c as Agent } from '../index-ysfO_DlX.js';
5
- import { A as AgentFactory } from '../agent-subagent-runner-DpZTLdBe.js';
2
+ import { E as EventBus } from '../events-Bt44ikPN.js';
3
+ import { D as DoneCondition, u as TaskResult } from '../multi-agent-Ba9Ni2hC.js';
4
+ import { c as Agent } from '../index-mAWBdLyJ.js';
5
+ import { A as AgentFactory } from '../agent-subagent-runner-DfvlBx5N.js';
6
6
  import '../context-7u93AcGD.js';
7
7
  import '../logger-DDd5C--Z.js';
8
8
  import '../system-prompt-CM6zOhd2.js';
9
9
  import '../observability-BhnVLBLS.js';
10
10
  import '../secret-scrubber-3MHDDAtm.js';
11
11
  import '../permission-B6sldrSp.js';
12
- import '../config-BUEGM4JP.js';
12
+ import '../config-ZRCf7sTu.js';
13
13
  import '../models-registry-BcYJDKLm.js';
14
14
 
15
15
  declare class SpecParser {
@@ -1,12 +1,12 @@
1
- export { A as AbandonedSession, a as AttachmentStoreOptions, C as ConfigLoaderOptions, b as ConfigMigration, c as ConfigMigrationError, d as ConfigSource, D as DEFAULT_CONFIG_MIGRATIONS, e as DefaultAttachmentStore, f as DefaultConfigLoader, g as DefaultConfigStore, h as DefaultMemoryStore, i as DefaultSessionStore, M as MemoryStoreOptions, j as MigrationContext, k as MigrationResult, P as PersistedQueueItem, l as PlanFile, m as PlanItem, n as PlanTemplate, Q as QueueStore, R as RecoveryLock, o as RecoveryLockOptions, S as SessionAnalyzer, p as SessionStoreOptions, T as TodosCheckpointFile, q as addPlanItem, r as attachPlanCheckpoint, s as attachTodosCheckpoint, t as clearPlan, u as deriveTodosFromPlanItem, v as emptyPlan, w as formatPlan, x as formatPlanTemplates, y as getPlanTemplate, z as listPlanTemplates, B as loadPlan, E as loadTodosCheckpoint, F as removePlanItem, G as runConfigMigrations, H as savePlan, I as saveTodosCheckpoint, J as setPlanItemStatus } from '../plan-templates-BZMi-VpU.js';
1
+ export { A as AbandonedSession, a as AttachmentStoreOptions, C as ConfigLoaderOptions, b as ConfigMigration, c as ConfigMigrationError, d as ConfigSource, D as DEFAULT_CONFIG_MIGRATIONS, e as DefaultAttachmentStore, f as DefaultConfigLoader, g as DefaultConfigStore, h as DefaultMemoryStore, i as DefaultSessionStore, M as MemoryStoreOptions, j as MigrationContext, k as MigrationResult, P as PersistedQueueItem, l as PlanFile, m as PlanItem, n as PlanTemplate, Q as QueueStore, R as RecoveryLock, o as RecoveryLockOptions, S as SessionAnalyzer, p as SessionStoreOptions, T as TodosCheckpointFile, q as addPlanItem, r as attachPlanCheckpoint, s as attachTodosCheckpoint, t as clearPlan, u as deriveTodosFromPlanItem, v as emptyPlan, w as formatPlan, x as formatPlanTemplates, y as getPlanTemplate, z as listPlanTemplates, B as loadPlan, E as loadTodosCheckpoint, F as removePlanItem, G as runConfigMigrations, H as savePlan, I as saveTodosCheckpoint, J as setPlanItemStatus } from '../plan-templates-BmDdJ7UL.js';
2
2
  export { D as DefaultSessionReader, f as DefaultSessionReaderOptions, S as SessionReader } from '../session-reader-bfgsy2a0.js';
3
3
  import { p as Request, q as Response, w as SessionEvent } from '../context-7u93AcGD.js';
4
4
  import { S as SessionRewinder, C as CheckpointInfo, a as RewindResultExtended } from '../session-rewinder-C9HnMkhP.js';
5
5
  export { D as DirectorStateCheckpoint, a as DirectorStateSnapshot, b as DirectorSubagentState, c as DirectorTaskState, l as loadDirectorState } from '../director-state-BmYi3DGA.js';
6
6
  export { A as AuditLevel, C as CORE_RECONSTRUCT_EVENTS, G as GoalFile, J as JournalEntry, M as MAX_JOURNAL_ENTRIES, S as STANDARD_AUDIT_EVENTS, a as SessionEventBridge, b as SessionEventBridgeOptions, c as SessionSamplingOptions, T as ToolProgressSamplingOptions, d as appendJournal, e as createSessionEventBridge, f as emptyGoal, g as formatGoal, h as goalFilePath, l as loadGoal, r as resolveAuditLevel, i as resolveSessionLoggingConfig, s as saveGoal, j as summarizeUsage } from '../goal-store-BeRsj7YX.js';
7
7
  import { a as WstackPaths } from '../wstack-paths-eMXnY1_X.js';
8
- import { m as SyncCategory, n as SyncConfig } from '../config-BUEGM4JP.js';
9
- import '../events-BrQiweXN.js';
8
+ import { n as SyncCategory, o as SyncConfig } from '../config-ZRCf7sTu.js';
9
+ import '../events-Bt44ikPN.js';
10
10
  import '../secret-scrubber-3MHDDAtm.js';
11
11
  import '../memory-CEXuo7sz.js';
12
12
  import '../secret-vault-DoISxaKO.js';
@@ -2,7 +2,7 @@ import { d as Context, n as ProviderError, Q as Tool, _ as ToolUseBlock, Y as To
2
2
  import { a as Compactor, C as CompactReport } from './compactor-D1RHFRmF.js';
3
3
  import { R as RecoveryDecision, E as ErrorHandler, a as RetryPolicy } from './retry-policy-KF18W4dg.js';
4
4
  import { b as ModelsRegistry } from './models-registry-BcYJDKLm.js';
5
- import { y as ToolExecutorOptions, z as ToolExecutorStrategy, T as ToolBatchResult } from './index-ysfO_DlX.js';
5
+ import { y as ToolExecutorOptions, z as ToolExecutorStrategy, T as ToolBatchResult } from './index-mAWBdLyJ.js';
6
6
 
7
7
  interface CompactorOptions {
8
8
  preserveK?: number;
@@ -1,6 +1,6 @@
1
1
  export { A as AgentError, a as Capabilities, b as ConfigError, c as ContentBlock, E as ERROR_CODES, g as ErrorCode, h as ErrorSeverity, i as ErrorSubsystem, F as FileSnapshot, j as FsError, I as ImageBlock, J as JSONSchema, M as Message, k as MessageRole, P as Permission, l as PluginError, m as Provider, n as ProviderError, o as ProviderErrorBody, p as Request, q as Response, r as ResumedSession, s as RiskTier, S as SessionData, v as SessionError, w as SessionEvent, x as SessionMetadata, y as SessionStore, z as SessionSummary, B as SessionWriter, H as StopReason, K as StreamEvent, T as TextBlock, L as ThinkingBlock, Q as Tool, U as ToolCallContext, V as ToolError, W as ToolFinalEvent, X as ToolProgressEvent, Y as ToolResultBlock, Z as ToolStreamEvent, _ as ToolUseBlock, $ as Usage, a0 as WrongStackError, a1 as asBlocks, a2 as asText, a4 as isAgentError, a5 as isConfigError, a6 as isFsError, a7 as isImageBlock, a8 as isPluginError, a9 as isSessionError, aa as isTextBlock, ab as isThinkingBlock, ac as isToolError, ad as isToolResultBlock, ae as isToolUseBlock, af as isWrongStackError, ag as toWrongStackError } from '../context-7u93AcGD.js';
2
- export { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-Dlv8Fvw9.js';
3
- export { A as AutonomyConfig, C as CONTEXT_WINDOW_MODES, a as Config, b as ConfigLoader, c as ConfigStore, d as ContextConfig, e as ContextWindowAggressiveOn, f as ContextWindowConfigLike, g as ContextWindowMode, h as ContextWindowModeId, i as ContextWindowPolicy, j as ContextWindowThresholds, D as DEFAULT_CONTEXT_WINDOW_MODE_ID, F as FeaturesConfig, L as LogConfig, M as MCPServerConfig, P as PluginConfig, k as ProviderApiKey, l as ProviderConfig, S as SessionLoggingConfig, m as SyncCategory, n as SyncConfig, T as ToolsConfig, o as formatContextWindowModeList, p as getContextWindowMode, q as isContextWindowModeId, r as listContextWindowModes, s as resolveContextWindowPolicy } from '../config-BUEGM4JP.js';
2
+ export { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-BGro2qQB.js';
3
+ export { A as AutonomyConfig, C as CONTEXT_WINDOW_MODES, a as Config, b as ConfigLoader, c as ConfigStore, d as ContextConfig, e as ContextWindowAggressiveOn, f as ContextWindowConfigLike, g as ContextWindowMode, h as ContextWindowModeId, i as ContextWindowPolicy, j as ContextWindowThresholds, D as DEFAULT_CONTEXT_WINDOW_MODE_ID, F as FeaturesConfig, L as LogConfig, M as MCPServerConfig, k as ModelMatrixEntry, P as PluginConfig, l as ProviderApiKey, m as ProviderConfig, S as SessionLoggingConfig, n as SyncCategory, o as SyncConfig, T as ToolsConfig, p as formatContextWindowModeList, q as getContextWindowMode, r as isContextWindowModeId, s as listContextWindowModes, t as resolveContextWindowPolicy } from '../config-ZRCf7sTu.js';
4
4
  export { C as CompactReport, a as Compactor } from '../compactor-D1RHFRmF.js';
5
5
  export { P as PermissionDecision, a as PermissionPolicy, T as TrustPolicy } from '../permission-B6sldrSp.js';
6
6
  export { C as CheckpointInfo, R as RewindResult, a as RewindResultExtended, S as SessionRewinder } from '../session-rewinder-C9HnMkhP.js';
@@ -8,20 +8,20 @@ export { A as AddAttachmentInput, a as Attachment, b as AttachmentKind, c as Att
8
8
  export { D as DEFAULT_AUTONOMY_CONFIG, a as DEFAULT_CONTEXT_CONFIG, b as DEFAULT_SESSION_LOGGING_CONFIG, c as DEFAULT_TOOLS_CONFIG } from '../default-config-DEXI4jsl.js';
9
9
  export { D as DefaultSecretScrubber, a as DefaultSecretVault, S as SecretVaultOptions, d as decryptConfigSecrets, e as encryptConfigSecrets, m as migratePlaintextSecrets, r as rewriteConfigEncrypted } from '../secret-scrubber-7rSC_emZ.js';
10
10
  export { D as DefaultLogger, a as DefaultLoggerOptions } from '../logger-bOzkF5LL.js';
11
- export { D as DefaultPathResolver, a as DefaultTokenCounter } from '../path-resolver-DumKAi0n.js';
11
+ export { D as DefaultPathResolver, a as DefaultTokenCounter } from '../path-resolver-nkmdiFgi.js';
12
12
  export { M as MemoryEntry, a as MemoryScope, b as MemoryStore } from '../memory-CEXuo7sz.js';
13
- export { C as CompactorOptions, D as DEFAULT_RECOVERY_STRATEGIES, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, R as RecoveryStrategy, T as ToolExecutor, c as buildRecoveryStrategies } from '../tool-executor-BAi4WI2d.js';
13
+ export { C as CompactorOptions, D as DEFAULT_RECOVERY_STRATEGIES, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, R as RecoveryStrategy, T as ToolExecutor, c as buildRecoveryStrategies } from '../tool-executor-p4tP9tGF.js';
14
14
  export { S as SkillEntry, a as SkillLoader, b as SkillManifest } from '../skill-CxuWrsKK.js';
15
15
  export { a as BuildContext, c as ModelCapabilities, e as Renderer, S as SystemPromptBuilder } from '../system-prompt-CM6zOhd2.js';
16
16
  export { I as InputReader, P as PromptOption } from '../input-reader-E-ffP2ee.js';
17
- export { M as MCPRegistryView, j as MetricsSinkView, P as Plugin, k as PluginAPI, l as PluginCapabilities, m as PluginDependency, n as PluginPipelines, o as ProviderFactory, r as ProviderRegistryView, S as SessionWriterView, u as SlashCommand, v as SlashCommandRegistryView, w as SystemPromptContributor, F as ToolRegistryView } from '../index-ysfO_DlX.js';
17
+ export { M as MCPRegistryView, j as MetricsSinkView, P as Plugin, k as PluginAPI, l as PluginCapabilities, m as PluginDependency, n as PluginPipelines, o as ProviderFactory, r as ProviderRegistryView, S as SessionWriterView, u as SlashCommand, v as SlashCommandRegistryView, w as SystemPromptContributor, F as ToolRegistryView } from '../index-mAWBdLyJ.js';
18
18
  export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from '../models-registry-gwMAo6E3.js';
19
19
  export { D as DEFAULT_MODES, M as Mode, a as ModeConfig, b as ModeManifest, c as ModeStore } from '../mode-CV077NjV.js';
20
- export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-D_XcS2HL.js';
21
- export { C as CoordinatorEvents, k as CoordinatorStatus, D as DoneCondition, M as MultiAgentConfig, l as MultiAgentCoordinator, S as SpawnResult, n as SubagentConfig, o as SubagentContext, p as SubagentError, q as SubagentErrorKind, r as SubagentRunContext, s as SubagentRunOutcome, t as SubagentRunner, T as TaskDelegation, u as TaskResult, v as TaskSpec } from '../multi-agent-C8Z1i__e.js';
20
+ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-CjbD-i7-.js';
21
+ export { C as CoordinatorEvents, k as CoordinatorStatus, D as DoneCondition, M as MultiAgentConfig, l as MultiAgentCoordinator, S as SpawnResult, n as SubagentConfig, o as SubagentContext, p as SubagentError, q as SubagentErrorKind, r as SubagentRunContext, s as SubagentRunOutcome, t as SubagentRunner, T as TaskDelegation, u as TaskResult, v as TaskSpec } from '../multi-agent-Ba9Ni2hC.js';
22
22
  export { C as CriticalPathResult, D as DEFAULT_SPEC_TEMPLATE, S as SpecAnalysis, a as SpecApiEndpoint, b as SpecRequirement, c as SpecSection, d as SpecSectionType, e as SpecStatus, f as SpecTemplate, g as SpecValidationResult, h as Specification, T as TaskAssignment, i as TaskDependency, j as TaskEdge, k as TaskFilter, l as TaskGraph, m as TaskNode, n as TaskPriority, o as TaskProgress, p as TaskSort, q as TaskStatus, r as TaskType, s as computeTaskProgress, t as findCriticalPath, u as topologicalSort } from '../task-graph-D1YQbpxF.js';
23
23
  export { A as AggregateHealth, H as HealthCheck, a as HealthCheckResult, b as HealthRegistry, c as HealthStatus, M as MetricLabels, d as MetricSeries, e as MetricsSink, f as MetricsSnapshot, S as Span, T as Tracer } from '../observability-BhnVLBLS.js';
24
- import '../events-BrQiweXN.js';
24
+ import '../events-Bt44ikPN.js';
25
25
  import '../logger-DDd5C--Z.js';
26
26
  import '../retry-policy-KF18W4dg.js';
27
27
  import '../models-registry-BcYJDKLm.js';
@@ -598,11 +598,25 @@ function deepMerge(a, b) {
598
598
  return out;
599
599
  }
600
600
 
601
+ // src/utils/term.ts
602
+ var hasStdout = () => typeof process !== "undefined" && !!process.stdout;
603
+ function isStdoutTTY() {
604
+ return hasStdout() && Boolean(process.stdout.isTTY);
605
+ }
606
+ function writeTo(s, stream) {
607
+ if (!stream || typeof stream.write !== "function") return false;
608
+ stream.write(s);
609
+ return true;
610
+ }
611
+ function writeErr(s, stream = process.stderr) {
612
+ return writeTo(s, stream);
613
+ }
614
+
601
615
  // src/utils/color.ts
602
616
  var isColorTty = () => {
603
617
  if (process.env.NO_COLOR) return false;
604
618
  if (process.env.FORCE_COLOR) return true;
605
- return Boolean(process.stdout?.isTTY);
619
+ return isStdoutTTY();
606
620
  };
607
621
  var COLOR = isColorTty();
608
622
  var wrap = (open2, close) => (s) => COLOR ? `\x1B[${open2}m${s}\x1B[${close}m` : s;
@@ -699,10 +713,10 @@ var DefaultLogger = class _DefaultLogger {
699
713
  if (r <= LEVEL_RANK.warn || this.level === "debug" || this.level === "trace") {
700
714
  const head = `${color.dim(ts)} ${COLORS[level](level.toUpperCase().padEnd(5))} ${msg}`;
701
715
  if (ctx !== void 0) {
702
- process.stderr.write(`${head} ${formatCtx(ctx)}
716
+ writeErr(`${head} ${formatCtx(ctx)}
703
717
  `);
704
718
  } else {
705
- process.stderr.write(`${head}
719
+ writeErr(`${head}
706
720
  `);
707
721
  }
708
722
  }
@@ -1682,12 +1696,12 @@ var DefaultModelsRegistry = class {
1682
1696
  */
1683
1697
  async loadOverlay(opts = {}) {
1684
1698
  if (this.overlayPayload && !opts.force) return this.overlayPayload;
1685
- if (this.overlay) {
1699
+ if (hasEntries(this.overlay)) {
1686
1700
  this.overlayPayload = this.overlay;
1687
1701
  return this.overlayPayload;
1688
1702
  }
1689
1703
  const fetched = await this.loadOverlayFromUrl(opts);
1690
- if (fetched) {
1704
+ if (hasEntries(fetched)) {
1691
1705
  this.overlayPayload = fetched;
1692
1706
  return fetched;
1693
1707
  }
@@ -1814,6 +1828,9 @@ var DefaultModelsRegistry = class {
1814
1828
  return path4.resolve(this.cacheFile);
1815
1829
  }
1816
1830
  };
1831
+ function hasEntries(payload) {
1832
+ return payload !== void 0 && Object.keys(payload).length > 0;
1833
+ }
1817
1834
 
1818
1835
  // src/types/mode.ts
1819
1836
  var DEFAULT_MODES = [