@wrongstack/core 0.66.13 → 0.68.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.
@@ -9,7 +9,7 @@ export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolic
9
9
  export { AutoCompactionMiddleware, AutonomousRunner, AutonomousRunnerOptions, AutonomyPromptContributorOptions, DefaultSkillLoader, DoneCheckResult, DoneConditionChecker, IntelligentCompactor, IntelligentCompactorOptions, SelectiveCompactor, SelectiveCompactorOptions, SkillLoaderOptions, buildGoalPreamble, makeAutonomyPromptContributor } from '../execution/index.js';
10
10
  import { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-mXvXGSIw.js';
11
11
  import { q as Response } from '../context-y87Jc5ei.js';
12
- export { a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, n as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a1 as makeAskTool, a2 as makeAssignTool, a3 as makeAwaitTasksTool, a4 as makeCollabDebugTool, a5 as makeDirectorSessionFactory, a6 as makeFleetEmitTool, a7 as makeFleetHealthTool, a8 as makeFleetSessionTool, a9 as makeFleetStatusTool, aa as makeFleetUsageTool, ab as makeRollUpTool, ac as makeSpawnTool, ad as makeTerminateTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-VApKRxcp.js';
12
+ export { a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, n as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a1 as makeAskTool, a2 as makeAssignTool, a3 as makeAwaitTasksTool, a4 as makeCollabDebugTool, a5 as makeDirectorSessionFactory, a6 as makeFleetEmitTool, a7 as makeFleetHealthTool, a8 as makeFleetSessionTool, a9 as makeFleetStatusTool, aa as makeFleetUsageTool, ab as makeRollUpTool, ac as makeSpawnTool, ad as makeTerminateTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-CuN0ObJr.js';
13
13
  export { A as AgentBudgetTier, a as AgentCapability, b as AgentDefinition, c as AgentPhase, D as DEFAULT_DISPATCH_ROLE, d as DefaultMultiAgentCoordinator, e as DispatchCandidate, f as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-CWnH-CiX.js';
14
14
  export { c as AgentFactory, d as AgentFactoryResult, e as AgentRunnerOptions, g as BudgetExceededError, h as BudgetKind, i as BudgetLimits, n as BudgetUsage, F as FleetBus, p as FleetEvent, q as FleetHandler, r as FleetUsage, s as FleetUsageAggregator, K as SubagentBudget, V as SubagentUsageSnapshot, _ as makeAgentSubagentRunner } from '../agent-subagent-runner-DRZ9-NnR.js';
15
15
  export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-D-j6OOBT.js';
@@ -9737,6 +9737,71 @@ Do not add prose, markdown, or code fences.`;
9737
9737
  };
9738
9738
  }
9739
9739
 
9740
+ // src/coordination/coordinator/error-classifier.ts
9741
+ function classifySubagentError(err, hints = {}) {
9742
+ const cause = err instanceof Error ? { name: err.name, message: err.message, stack: err.stack } : void 0;
9743
+ if (err instanceof ProviderError) {
9744
+ const baseMessage2 = err.describe();
9745
+ return providerErrorToSubagentError(err, baseMessage2, cause);
9746
+ }
9747
+ const baseMessage = err instanceof Error ? err.message : String(err);
9748
+ if (err instanceof BudgetExceededError) {
9749
+ const map = {
9750
+ iterations: "budget_iterations",
9751
+ tool_calls: "budget_tool_calls",
9752
+ tokens: "budget_tokens",
9753
+ cost: "budget_cost",
9754
+ timeout: "budget_timeout",
9755
+ idle_timeout: "budget_timeout"
9756
+ };
9757
+ return {
9758
+ kind: map[err.kind],
9759
+ message: baseMessage,
9760
+ retryable: false,
9761
+ cause
9762
+ };
9763
+ }
9764
+ if (hints.parentAborted) {
9765
+ return { kind: "aborted_by_parent", message: baseMessage, retryable: false, cause };
9766
+ }
9767
+ const lower = baseMessage.toLowerCase();
9768
+ if (/agent aborted$/i.test(baseMessage)) {
9769
+ return { kind: "aborted_by_parent", message: baseMessage, retryable: false, cause };
9770
+ }
9771
+ if (/agent exhausted iteration limit$/i.test(baseMessage)) {
9772
+ return { kind: "budget_iterations", message: baseMessage, retryable: false, cause };
9773
+ }
9774
+ if (/empty response$/i.test(baseMessage)) {
9775
+ return { kind: "empty_response", message: baseMessage, retryable: false, cause };
9776
+ }
9777
+ if (/^tool failed: /i.test(baseMessage)) {
9778
+ return { kind: "tool_failed", message: baseMessage, retryable: false, cause };
9779
+ }
9780
+ if (lower.includes("bridge transport") || /bridge.*(closed|disconnect)/i.test(baseMessage)) {
9781
+ return { kind: "bridge_failed", message: baseMessage, retryable: false, cause };
9782
+ }
9783
+ if (/context length|max.*tokens?.*exceeded|prompt is too long/i.test(baseMessage)) {
9784
+ return { kind: "context_overflow", message: baseMessage, retryable: false, cause };
9785
+ }
9786
+ return { kind: "unknown", message: baseMessage, retryable: false, cause };
9787
+ }
9788
+ function providerErrorToSubagentError(err, message, cause) {
9789
+ const status = err.status;
9790
+ if (status === 429 || err.body?.type === "rate_limit_error") {
9791
+ return { kind: "provider_rate_limit", message, retryable: true, backoffMs: 5e3, cause };
9792
+ }
9793
+ if (status === 401 || status === 403 || err.body?.type === "authentication_error") {
9794
+ return { kind: "provider_auth", message, retryable: false, cause };
9795
+ }
9796
+ if (status === 408 || status === 0) {
9797
+ return { kind: "provider_timeout", message, retryable: true, cause };
9798
+ }
9799
+ if (status >= 500 && status < 600) {
9800
+ return { kind: "provider_5xx", message, retryable: true, backoffMs: 3e3, cause };
9801
+ }
9802
+ return { kind: "unknown", message, retryable: err.retryable, cause };
9803
+ }
9804
+
9740
9805
  // src/coordination/fleet.ts
9741
9806
  var AUDIT_LOG_AGENT = {
9742
9807
  id: "audit-log",
@@ -10804,101 +10869,6 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
10804
10869
  return false;
10805
10870
  }
10806
10871
  };
10807
- function classifySubagentError(err, hints = {}) {
10808
- const cause = err instanceof Error ? { name: err.name, message: err.message, stack: err.stack } : void 0;
10809
- if (err instanceof ProviderError) {
10810
- const baseMessage2 = err.describe();
10811
- return providerErrorToSubagentError(err, baseMessage2, cause);
10812
- }
10813
- const baseMessage = err instanceof Error ? err.message : String(err);
10814
- if (err instanceof BudgetExceededError) {
10815
- const map = {
10816
- iterations: "budget_iterations",
10817
- tool_calls: "budget_tool_calls",
10818
- tokens: "budget_tokens",
10819
- cost: "budget_cost",
10820
- timeout: "budget_timeout",
10821
- idle_timeout: "budget_timeout"
10822
- };
10823
- return {
10824
- kind: map[err.kind],
10825
- message: baseMessage,
10826
- // Budgets are user-configured ceilings, not transient failures —
10827
- // retrying with the same budget will hit the same ceiling. The
10828
- // orchestrator must raise the budget or narrow the task first.
10829
- retryable: false,
10830
- cause
10831
- };
10832
- }
10833
- if (hints.parentAborted) {
10834
- return {
10835
- kind: "aborted_by_parent",
10836
- message: baseMessage,
10837
- retryable: false,
10838
- cause
10839
- };
10840
- }
10841
- const lower = baseMessage.toLowerCase();
10842
- if (/agent aborted$/i.test(baseMessage)) {
10843
- return {
10844
- kind: "aborted_by_parent",
10845
- message: baseMessage,
10846
- retryable: false,
10847
- cause
10848
- };
10849
- }
10850
- if (/agent exhausted iteration limit$/i.test(baseMessage)) {
10851
- return { kind: "budget_iterations", message: baseMessage, retryable: false, cause };
10852
- }
10853
- if (/empty response$/i.test(baseMessage)) {
10854
- return { kind: "empty_response", message: baseMessage, retryable: false, cause };
10855
- }
10856
- if (/^tool failed: /i.test(baseMessage)) {
10857
- return { kind: "tool_failed", message: baseMessage, retryable: false, cause };
10858
- }
10859
- if (lower.includes("bridge transport") || /bridge.*(closed|disconnect)/i.test(baseMessage)) {
10860
- return { kind: "bridge_failed", message: baseMessage, retryable: false, cause };
10861
- }
10862
- if (/context length|max.*tokens?.*exceeded|prompt is too long/i.test(baseMessage)) {
10863
- return { kind: "context_overflow", message: baseMessage, retryable: false, cause };
10864
- }
10865
- return {
10866
- kind: "unknown",
10867
- message: baseMessage,
10868
- retryable: false,
10869
- cause
10870
- };
10871
- }
10872
- function providerErrorToSubagentError(err, message, cause) {
10873
- const status = err.status;
10874
- if (status === 429 || err.body?.type === "rate_limit_error") {
10875
- return {
10876
- kind: "provider_rate_limit",
10877
- message,
10878
- retryable: true,
10879
- // Conservative default: 5s. Provider-specific code can override
10880
- // by emitting an error whose body carries an explicit hint.
10881
- backoffMs: 5e3,
10882
- cause
10883
- };
10884
- }
10885
- if (status === 401 || status === 403 || err.body?.type === "authentication_error") {
10886
- return { kind: "provider_auth", message, retryable: false, cause };
10887
- }
10888
- if (status === 408 || status === 0) {
10889
- return { kind: "provider_timeout", message, retryable: true, cause };
10890
- }
10891
- if (status >= 500 && status < 600) {
10892
- return {
10893
- kind: "provider_5xx",
10894
- message,
10895
- retryable: true,
10896
- backoffMs: 3e3,
10897
- cause
10898
- };
10899
- }
10900
- return { kind: "unknown", message, retryable: err.retryable, cause };
10901
- }
10902
10872
 
10903
10873
  // src/execution/parallel-eternal-engine.ts
10904
10874
  function sleep2(ms) {
@@ -13033,7 +13003,7 @@ function resolveModelMatrix(matrix, role) {
13033
13003
  return void 0;
13034
13004
  }
13035
13005
 
13036
- // src/coordination/director.ts
13006
+ // src/coordination/director/director-errors.ts
13037
13007
  var FleetSpawnBudgetError = class extends Error {
13038
13008
  kind;
13039
13009
  limit;
@@ -13075,6 +13045,8 @@ var FleetContextOverflowError = class extends Error {
13075
13045
  this.observed = observed;
13076
13046
  }
13077
13047
  };
13048
+
13049
+ // src/coordination/director.ts
13078
13050
  var Director = class _Director {
13079
13051
  /** Alias for the ICoordinator contract. `id` is retained for backward compatibility. */
13080
13052
  get coordinatorId() {