@wrongstack/core 0.31.1 → 0.41.0

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 (34) hide show
  1. package/dist/{agent-subagent-runner-DpZTLdBe.d.ts → agent-subagent-runner-C66vi4Gq.d.ts} +1 -1
  2. package/dist/{config-BUEGM4JP.d.ts → config-ZRCf7sTu.d.ts} +21 -1
  3. package/dist/coordination/index.d.ts +7 -7
  4. package/dist/coordination/index.js +3051 -2947
  5. package/dist/coordination/index.js.map +1 -1
  6. package/dist/defaults/index.d.ts +8 -8
  7. package/dist/defaults/index.js +1435 -1321
  8. package/dist/defaults/index.js.map +1 -1
  9. package/dist/execution/index.d.ts +5 -5
  10. package/dist/extension/index.d.ts +2 -2
  11. package/dist/{index-ysfO_DlX.d.ts → index-6_csX32J.d.ts} +1 -1
  12. package/dist/{index-pXJdVLe0.d.ts → index-DkVgH3wC.d.ts} +31 -1
  13. package/dist/index.d.ts +135 -15
  14. package/dist/index.js +1236 -931
  15. package/dist/index.js.map +1 -1
  16. package/dist/infrastructure/index.d.ts +2 -2
  17. package/dist/infrastructure/index.js +17 -3
  18. package/dist/infrastructure/index.js.map +1 -1
  19. package/dist/kernel/index.d.ts +2 -2
  20. package/dist/{mcp-servers-BzB3r7_c.d.ts → mcp-servers-DONdo-XM.d.ts} +1 -1
  21. package/dist/{multi-agent-coordinator-DOXSgtom.d.ts → multi-agent-coordinator-BUsjiRWl.d.ts} +1 -1
  22. package/dist/{null-fleet-bus-CAQDGsKc.d.ts → null-fleet-bus-FvgHnZah.d.ts} +169 -131
  23. package/dist/{plan-templates-BZMi-VpU.d.ts → plan-templates-DYCeRCDN.d.ts} +1 -1
  24. package/dist/sdd/index.d.ts +3 -3
  25. package/dist/storage/index.d.ts +2 -2
  26. package/dist/{tool-executor-BAi4WI2d.d.ts → tool-executor-BpK-SWtJ.d.ts} +1 -1
  27. package/dist/types/index.d.ts +3 -3
  28. package/dist/types/index.js +17 -3
  29. package/dist/types/index.js.map +1 -1
  30. package/dist/utils/index.d.ts +107 -1
  31. package/dist/utils/index.js +53 -2
  32. package/dist/utils/index.js.map +1 -1
  33. package/package.json +1 -1
  34. package/skills/multi-agent/SKILL.md +57 -1
@@ -1,9 +1,10 @@
1
- import { c as AgentPhase, b as AgentDefinition, d as DefaultMultiAgentCoordinator, f as DispatchClassifier } from './multi-agent-coordinator-DOXSgtom.js';
1
+ import { c as AgentPhase, b as AgentDefinition, d as DefaultMultiAgentCoordinator, f as DispatchClassifier } from './multi-agent-coordinator-BUsjiRWl.js';
2
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';
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-C66vi4Gq.js';
5
5
  import { EventEmitter } from 'node:events';
6
6
  import { a as DirectorStateSnapshot } from './director-state-BmYi3DGA.js';
7
+ import { k as ModelMatrixEntry } from './config-ZRCf7sTu.js';
7
8
  import { I as InMemoryAgentBridge } from './agent-bridge-D_XcS2HL.js';
8
9
  import { E as EventBus } from './events-BrQiweXN.js';
9
10
 
@@ -194,6 +195,20 @@ interface CollabSessionOptions {
194
195
  prebuiltSnapshot?: SharedFileSnapshot;
195
196
  /** Max time to wait for the session to resolve (ms). Default: 10 min. */
196
197
  timeoutMs?: number;
198
+ /**
199
+ * Maximum number of files to include in the snapshot.
200
+ * - If set explicitly: use this value (hard override).
201
+ * - If `contextWindow` is set: calculate dynamically from estimated token budget.
202
+ * - If neither: use `DEFAULT_MAX_TARGET_FILES` (30).
203
+ */
204
+ maxTargetFiles?: number;
205
+ /**
206
+ * Context window size (in tokens) of the model running the subagents.
207
+ * When provided and `maxTargetFiles` is not set, the limit is computed
208
+ * dynamically: `floor((contextWindow * 0.4) / AVG_TOKENS_PER_FILE)`.
209
+ * If not provided, `DEFAULT_MAX_TARGET_FILES` is used as the fallback.
210
+ */
211
+ contextWindow?: number;
197
212
  /**
198
213
  * Budget overrides per role. When provided, these override the hard-coded
199
214
  * defaults so the Director can enforce fleet-wide budget policy.
@@ -240,6 +255,11 @@ declare class CollabSession extends EventEmitter {
240
255
  * all three collab agents.
241
256
  */
242
257
  getSubagentIds(): ReadonlyMap<string, string>;
258
+ /**
259
+ * Returns the effective file limit for this session.
260
+ * Priority: explicit `maxTargetFiles` > dynamic from `contextWindow` > `DEFAULT_MAX_TARGET_FILES`.
261
+ */
262
+ effectiveFileLimit(): number;
243
263
  buildSnapshot(): Promise<SharedFileSnapshot>;
244
264
  /**
245
265
  * Cancel the session. Emits director.cancel_collab on the FleetBus so all
@@ -262,135 +282,6 @@ declare class CollabSession extends EventEmitter {
262
282
  private cleanup;
263
283
  }
264
284
 
265
- declare class LargeAnswerStore {
266
- /**
267
- * Responses above this size (in characters) are stored out-of-context.
268
- * Below this, the full answer is returned inline (no overhead).
269
- * Default: 2000 chars ≈ 400-600 tokens.
270
- */
271
- readonly sizeThreshold: number;
272
- private readonly store;
273
- constructor(sizeThreshold?: number);
274
- /**
275
- * Store a value, returning a summary + key for inline use.
276
- * If the value is below sizeThreshold, returns it as-is (no store entry).
277
- */
278
- storeAnswer(value: unknown): {
279
- key?: string;
280
- summary: string;
281
- inline: boolean;
282
- };
283
- /**
284
- * Retrieve a previously stored answer by its key.
285
- * Returns undefined if the key is unknown or the store was cleared.
286
- */
287
- retrieveAnswer(key: string): unknown | undefined;
288
- /**
289
- * Check if a key exists in the store.
290
- */
291
- hasAnswer(key: string): boolean;
292
- /** Number of stored entries. */
293
- get size(): number;
294
- /** Total characters stored. */
295
- get totalChars(): number;
296
- /** Clear all stored entries. Call at the end of a director run. */
297
- clear(): void;
298
- }
299
-
300
- /**
301
- * Interface for a fleet coordinator. Implemented by both `Director`
302
- * (full LLM-driven orchestration with fleet policy) and
303
- * `DefaultMultiAgentCoordinator` (direct API-driven, no fleet policy).
304
- *
305
- * External callers — CLI slash commands, tests, the delegate tool —
306
- * use this to stay agnostic to the orchestration mode.
307
- *
308
- * The interface captures the **orchestration contract**: spawn, assign,
309
- * terminate, await, and query. Fleet-level policy (cost caps, manifest
310
- * writing, checkpointing) lives behind this surface and is optional
311
- * from the caller's perspective.
312
- *
313
- * @example
314
- * ```typescript
315
- * let coordinator: ICoordinator = isDirectorMode
316
- * ? new Director({ config, ... })
317
- * : new DefaultMultiAgentCoordinator(config);
318
- * const id = await coordinator.spawn({ name: 'worker', role: 'researcher' });
319
- * await coordinator.assign({ id: 't-1', description: 'research X', subagentId: id });
320
- * const results = await coordinator.awaitTasks(['t-1']);
321
- * ```
322
- */
323
- interface ICoordinator {
324
- /** Stable identifier for this coordinator instance. */
325
- readonly coordinatorId: string;
326
- /**
327
- * Spawn a new subagent and return its id. In director mode this
328
- * enforces fleet-wide spawn caps and cost limits; in raw coordinator
329
- * mode it is a direct pass-through.
330
- */
331
- spawn(config: SubagentConfig): Promise<string>;
332
- /**
333
- * Assign a task to a subagent (or to the fleet for auto-routing).
334
- * Returns the assigned task id.
335
- */
336
- assign(task: {
337
- id: string;
338
- description: string;
339
- subagentId?: string;
340
- }): Promise<string>;
341
- /**
342
- * Synchronously ask a subagent something via the in-memory bridge.
343
- * The subagent must have been spawned and must handle `bridge.subscribe()`
344
- * in its task loop. Returns the reply payload or throws on timeout.
345
- *
346
- * Only available in director mode — raw coordinator has no bridge.
347
- */
348
- ask<T = unknown>(subagentId: string, payload: unknown, timeoutMs?: number): Promise<T>;
349
- /**
350
- * Wait for one or more tasks to complete and return their results.
351
- * If a task is already done when called, returns immediately.
352
- * Resolves to an array in the same order as `taskIds`.
353
- */
354
- awaitTasks(taskIds: string[]): Promise<TaskResult[]>;
355
- /**
356
- * Gracefully stop a single subagent. The subagent finishes its current
357
- * in-flight work and exits cleanly — it does not hard-kill.
358
- */
359
- terminate(subagentId: string): Promise<void>;
360
- /**
361
- * Stop all subagents. In-flight tasks are allowed to complete;
362
- * no new tasks are dispatched.
363
- */
364
- terminateAll(): Promise<void>;
365
- /**
366
- * Stop a subagent and remove it from the coordinator. Releases all
367
- * associated resources (AbortController, budget state). The subagent
368
- * entry is deleted so the id can be reused in a future spawn.
369
- */
370
- remove(subagentId: string): Promise<void>;
371
- /**
372
- * Live coordinator status — subagent list, pending task count,
373
- * completed task count, iteration totals.
374
- */
375
- status(): CoordinatorStatus;
376
- /**
377
- * Snapshot of completed task results. In director mode this returns
378
- * every `TaskResult` from the fleet; in raw coordinator mode this
379
- * may return an empty array if the coordinator doesn't cache results.
380
- */
381
- completedResults(): TaskResult[];
382
- /**
383
- * Subscribe to coordinator lifecycle events. Currently supports
384
- * `task.completed` — the payload carries the task spec and result.
385
- *
386
- * Returns a disposer function; call it to unsubscribe.
387
- */
388
- on(event: 'task.completed', handler: (payload: {
389
- task: TaskSpec;
390
- result: TaskResult;
391
- }) => void): () => void;
392
- }
393
-
394
285
  /**
395
286
  * Interface for fleet-level lifecycle and policy. Covers:
396
287
  * - Spawn lifecycle hooks (canSpawn check, recordSpawn after-effects)
@@ -755,6 +646,135 @@ declare class FleetManager implements IFleetManager {
755
646
  dispose(): void;
756
647
  }
757
648
 
649
+ /**
650
+ * Interface for a fleet coordinator. Implemented by both `Director`
651
+ * (full LLM-driven orchestration with fleet policy) and
652
+ * `DefaultMultiAgentCoordinator` (direct API-driven, no fleet policy).
653
+ *
654
+ * External callers — CLI slash commands, tests, the delegate tool —
655
+ * use this to stay agnostic to the orchestration mode.
656
+ *
657
+ * The interface captures the **orchestration contract**: spawn, assign,
658
+ * terminate, await, and query. Fleet-level policy (cost caps, manifest
659
+ * writing, checkpointing) lives behind this surface and is optional
660
+ * from the caller's perspective.
661
+ *
662
+ * @example
663
+ * ```typescript
664
+ * let coordinator: ICoordinator = isDirectorMode
665
+ * ? new Director({ config, ... })
666
+ * : new DefaultMultiAgentCoordinator(config);
667
+ * const id = await coordinator.spawn({ name: 'worker', role: 'researcher' });
668
+ * await coordinator.assign({ id: 't-1', description: 'research X', subagentId: id });
669
+ * const results = await coordinator.awaitTasks(['t-1']);
670
+ * ```
671
+ */
672
+ interface ICoordinator {
673
+ /** Stable identifier for this coordinator instance. */
674
+ readonly coordinatorId: string;
675
+ /**
676
+ * Spawn a new subagent and return its id. In director mode this
677
+ * enforces fleet-wide spawn caps and cost limits; in raw coordinator
678
+ * mode it is a direct pass-through.
679
+ */
680
+ spawn(config: SubagentConfig): Promise<string>;
681
+ /**
682
+ * Assign a task to a subagent (or to the fleet for auto-routing).
683
+ * Returns the assigned task id.
684
+ */
685
+ assign(task: {
686
+ id: string;
687
+ description: string;
688
+ subagentId?: string;
689
+ }): Promise<string>;
690
+ /**
691
+ * Synchronously ask a subagent something via the in-memory bridge.
692
+ * The subagent must have been spawned and must handle `bridge.subscribe()`
693
+ * in its task loop. Returns the reply payload or throws on timeout.
694
+ *
695
+ * Only available in director mode — raw coordinator has no bridge.
696
+ */
697
+ ask<T = unknown>(subagentId: string, payload: unknown, timeoutMs?: number): Promise<T>;
698
+ /**
699
+ * Wait for one or more tasks to complete and return their results.
700
+ * If a task is already done when called, returns immediately.
701
+ * Resolves to an array in the same order as `taskIds`.
702
+ */
703
+ awaitTasks(taskIds: string[]): Promise<TaskResult[]>;
704
+ /**
705
+ * Gracefully stop a single subagent. The subagent finishes its current
706
+ * in-flight work and exits cleanly — it does not hard-kill.
707
+ */
708
+ terminate(subagentId: string): Promise<void>;
709
+ /**
710
+ * Stop all subagents. In-flight tasks are allowed to complete;
711
+ * no new tasks are dispatched.
712
+ */
713
+ terminateAll(): Promise<void>;
714
+ /**
715
+ * Stop a subagent and remove it from the coordinator. Releases all
716
+ * associated resources (AbortController, budget state). The subagent
717
+ * entry is deleted so the id can be reused in a future spawn.
718
+ */
719
+ remove(subagentId: string): Promise<void>;
720
+ /**
721
+ * Live coordinator status — subagent list, pending task count,
722
+ * completed task count, iteration totals.
723
+ */
724
+ status(): CoordinatorStatus;
725
+ /**
726
+ * Snapshot of completed task results. In director mode this returns
727
+ * every `TaskResult` from the fleet; in raw coordinator mode this
728
+ * may return an empty array if the coordinator doesn't cache results.
729
+ */
730
+ completedResults(): TaskResult[];
731
+ /**
732
+ * Subscribe to coordinator lifecycle events. Currently supports
733
+ * `task.completed` — the payload carries the task spec and result.
734
+ *
735
+ * Returns a disposer function; call it to unsubscribe.
736
+ */
737
+ on(event: 'task.completed', handler: (payload: {
738
+ task: TaskSpec;
739
+ result: TaskResult;
740
+ }) => void): () => void;
741
+ }
742
+
743
+ declare class LargeAnswerStore {
744
+ /**
745
+ * Responses above this size (in characters) are stored out-of-context.
746
+ * Below this, the full answer is returned inline (no overhead).
747
+ * Default: 2000 chars ≈ 400-600 tokens.
748
+ */
749
+ readonly sizeThreshold: number;
750
+ private readonly store;
751
+ constructor(sizeThreshold?: number);
752
+ /**
753
+ * Store a value, returning a summary + key for inline use.
754
+ * If the value is below sizeThreshold, returns it as-is (no store entry).
755
+ */
756
+ storeAnswer(value: unknown): {
757
+ key?: string;
758
+ summary: string;
759
+ inline: boolean;
760
+ };
761
+ /**
762
+ * Retrieve a previously stored answer by its key.
763
+ * Returns undefined if the key is unknown or the store was cleared.
764
+ */
765
+ retrieveAnswer(key: string): unknown | undefined;
766
+ /**
767
+ * Check if a key exists in the store.
768
+ */
769
+ hasAnswer(key: string): boolean;
770
+ /** Number of stored entries. */
771
+ get size(): number;
772
+ /** Total characters stored. */
773
+ get totalChars(): number;
774
+ /** Clear all stored entries. Call at the end of a director run. */
775
+ clear(): void;
776
+ }
777
+
758
778
  /**
759
779
  * Director — high-level orchestrator that owns a `MultiAgentCoordinator`,
760
780
  * a `FleetBus`, and a `FleetUsageAggregator`. Exposes a small imperative
@@ -940,7 +960,22 @@ interface DirectorOptions {
940
960
  * Only used when no `fleetManager` is provided (inline mode).
941
961
  */
942
962
  maxContext?: number;
963
+ /**
964
+ * Per-task model matrix (Config.modelMatrix). When set, a spawn whose
965
+ * config has no explicit `model` is resolved against this matrix by role
966
+ * (→ phase → `*`) before the subagent is built — so the spawned event,
967
+ * manifest, and the agent itself all run the matched model. Explicit
968
+ * per-spawn `model` overrides always win.
969
+ *
970
+ * Pass a **function** (not a snapshot) when the matrix can change at
971
+ * runtime (the CLI passes `() => configStore.get().modelMatrix`) so a
972
+ * mid-session `/setmodel` takes effect on the next spawn. A static record
973
+ * is also accepted for tests and one-shot runs.
974
+ */
975
+ modelMatrix?: ModelMatrixSource;
943
976
  }
977
+ /** Either a static matrix or a live getter (re-read on every spawn). */
978
+ type ModelMatrixSource = Record<string, ModelMatrixEntry> | (() => Record<string, ModelMatrixEntry> | undefined);
944
979
  /**
945
980
  * Thrown by `Director.spawn()` when a configured spawn cap (`maxSpawns`,
946
981
  * `maxSpawnDepth`) is hit. Distinct error class so callers — including
@@ -1086,6 +1121,9 @@ declare class Director implements ICoordinator {
1086
1121
  private readonly maxLeaderContextLoad;
1087
1122
  /** Provider's max context window in tokens. */
1088
1123
  private readonly maxContext;
1124
+ /** Per-task model matrix (static record or live getter); resolved
1125
+ * per-spawn when no explicit model is set. */
1126
+ private readonly modelMatrix?;
1089
1127
  /**
1090
1128
  * When set by `workComplete()`, the director stops dispatching new tasks
1091
1129
  * and terminates all running subagents. Used when the director's LLM decides
@@ -4,7 +4,7 @@ import { y as SessionStore, x as SessionMetadata, B as SessionWriter, r as Resum
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,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
2
  import { E as EventBus } from '../events-BrQiweXN.js';
3
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';
4
+ import { c as Agent } from '../index-6_csX32J.js';
5
+ import { A as AgentFactory } from '../agent-subagent-runner-C66vi4Gq.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,11 +1,11 @@
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-DYCeRCDN.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';
8
+ import { n as SyncCategory, o as SyncConfig } from '../config-ZRCf7sTu.js';
9
9
  import '../events-BrQiweXN.js';
10
10
  import '../secret-scrubber-3MHDDAtm.js';
11
11
  import '../memory-CEXuo7sz.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-6_csX32J.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
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';
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';
@@ -10,11 +10,11 @@ export { D as DefaultSecretScrubber, a as DefaultSecretVault, S as SecretVaultOp
10
10
  export { D as DefaultLogger, a as DefaultLoggerOptions } from '../logger-bOzkF5LL.js';
11
11
  export { D as DefaultPathResolver, a as DefaultTokenCounter } from '../path-resolver-DumKAi0n.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-BpK-SWtJ.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-6_csX32J.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
20
  export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-D_XcS2HL.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
  }