@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.
@@ -1,5 +1,5 @@
1
1
  export { B as BrainArbiter, a as BrainDecision, b as BrainDecisionOption, c as BrainDecisionQueue, d as BrainDecisionRequest, e as BrainDecisionSource, f as BrainFallback, g as BrainRisk, D as DefaultBrainArbiter, h as DefaultBrainArbiterOptions, H as HumanEscalatingBrainArbiter, O as ObservableBrainArbiter, l as formatHumanPrompt } from '../events-CIplI98R.js';
2
- export { A as ACP_AGENTS, 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, h as BugFinding, C as CollabBudgetConfig, i as CollabBudgetOverrides, j as CollabBudgetWarningPayload, k as CollabDebugReport, l as CollabSession, m as CollabSessionOptions, n as CreateDelegateToolOptions, o as CriticConcern, p as CriticEvaluation, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, t as DirectorAlert, u as DirectorAlertLevel, v as DirectorCancelCollabPayload, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, E as FLEET_ROSTER_WITHACP, G as FleetCostCapError, H as FleetManager, I as FleetManagerOptions, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, N as LargeAnswerStore, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, P as RefactorPhase, Q as RefactorPlan, S as SECURITY_SCANNER_AGENT, T as SharedFileEntry, U as SharedFileSnapshot, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a0 as makeAskResultTool, 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, ae as makeWorkCompleteTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-VApKRxcp.js';
2
+ export { A as ACP_AGENTS, 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, h as BugFinding, C as CollabBudgetConfig, i as CollabBudgetOverrides, j as CollabBudgetWarningPayload, k as CollabDebugReport, l as CollabSession, m as CollabSessionOptions, n as CreateDelegateToolOptions, o as CriticConcern, p as CriticEvaluation, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, t as DirectorAlert, u as DirectorAlertLevel, v as DirectorCancelCollabPayload, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, E as FLEET_ROSTER_WITHACP, G as FleetCostCapError, H as FleetManager, I as FleetManagerOptions, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, N as LargeAnswerStore, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, P as RefactorPhase, Q as RefactorPlan, S as SECURITY_SCANNER_AGENT, T as SharedFileEntry, U as SharedFileSnapshot, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a0 as makeAskResultTool, 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, ae as makeWorkCompleteTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-CuN0ObJr.js';
3
3
  import { b as AgentDefinition } from '../multi-agent-coordinator-CWnH-CiX.js';
4
4
  export { T as AGENT_TOOL_PRESETS, A as AgentBudgetTier, a as AgentCapability, 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, H as HEAVY_BUDGET, L as LIGHT_BUDGET, M as MEDIUM_BUDGET, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-CWnH-CiX.js';
5
5
  export { c as AgentFactory, d as AgentFactoryResult, e as AgentRunnerOptions, g as BudgetExceededError, h as BudgetKind, i as BudgetLimits, j as BudgetNegotiationMode, k as BudgetThresholdDecision, l as BudgetThresholdHandler, m as BudgetThresholdSignal, 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';
@@ -4284,116 +4284,6 @@ function resolveModelMatrix(matrix, role) {
4284
4284
  return void 0;
4285
4285
  }
4286
4286
 
4287
- // src/types/errors.ts
4288
- var ERROR_CODES = {
4289
- // Provider
4290
- PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED",
4291
- PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED",
4292
- PROVIDER_OVERLOADED: "PROVIDER_OVERLOADED",
4293
- PROVIDER_INVALID_REQUEST: "PROVIDER_INVALID_REQUEST",
4294
- PROVIDER_SERVER_ERROR: "PROVIDER_SERVER_ERROR",
4295
- PROVIDER_NETWORK_ERROR: "PROVIDER_NETWORK_ERROR"};
4296
- var WrongStackError = class extends Error {
4297
- code;
4298
- subsystem;
4299
- severity;
4300
- recoverable;
4301
- context;
4302
- constructor(opts) {
4303
- super(opts.message, { cause: opts.cause });
4304
- this.name = "WrongStackError";
4305
- this.code = opts.code;
4306
- this.subsystem = opts.subsystem;
4307
- this.severity = opts.severity ?? "error";
4308
- this.recoverable = opts.recoverable ?? false;
4309
- this.context = opts.context;
4310
- }
4311
- /**
4312
- * Render a one-line user-facing description.
4313
- * Subclasses should override for domain-specific formatting.
4314
- */
4315
- describe() {
4316
- const ctx = this.context ? ` ${formatContext(this.context)}` : "";
4317
- return `${this.code}: ${this.message}${ctx}`;
4318
- }
4319
- };
4320
- function formatContext(ctx) {
4321
- const parts = Object.entries(ctx).filter(([, v]) => v !== void 0).slice(0, 3).map(([k, v]) => `${k}=${String(v)}`);
4322
- return parts.length > 0 ? `[${parts.join(" ")}]` : "";
4323
- }
4324
-
4325
- // src/types/provider.ts
4326
- var ProviderError = class extends WrongStackError {
4327
- status;
4328
- retryable;
4329
- providerId;
4330
- body;
4331
- constructor(message, status, retryable, providerId, opts = {}) {
4332
- super({
4333
- message,
4334
- code: providerStatusToCode(status, opts.body?.type),
4335
- subsystem: "provider",
4336
- severity: status >= 500 ? "error" : "warning",
4337
- recoverable: retryable,
4338
- context: { providerId, status },
4339
- cause: opts.cause
4340
- });
4341
- this.name = "ProviderError";
4342
- this.status = status;
4343
- this.retryable = retryable;
4344
- this.providerId = providerId;
4345
- this.body = opts.body;
4346
- }
4347
- /**
4348
- * Render a one-line, user-facing description. Designed for the CLI/TUI
4349
- * status line and the agent's retry warning. Avoids dumping raw JSON
4350
- * (which is what users see today when a 529 lands and the log message
4351
- * includes the full `{"type":"error",...}` body).
4352
- *
4353
- * Examples:
4354
- * "minimax-coding-plan overloaded (529): High traffic detected. Upgrade for highspeed model. [req 06534785201de9c0…]"
4355
- * "openai rate limited (429): Retry after 12s"
4356
- * "anthropic invalid request (400): messages.0.role must be one of 'user'|'assistant'"
4357
- * "groq HTTP 500 (server error)"
4358
- */
4359
- describe() {
4360
- const kind = describeStatus(this.status, this.body?.type);
4361
- const head = `${this.providerId} ${kind}`;
4362
- const detail = this.body?.message?.trim();
4363
- const reqId = this.body?.requestId ? ` [req ${this.body.requestId.slice(0, 16)}${this.body.requestId.length > 16 ? "\u2026" : ""}]` : "";
4364
- if (detail && detail.length > 0) {
4365
- return `${head}: ${truncate(detail, 240)}${reqId}`;
4366
- }
4367
- return `${head}${reqId}`;
4368
- }
4369
- };
4370
- function describeStatus(status, type) {
4371
- if (status === 0) return "network error";
4372
- if (type === "overloaded_error" || status === 529) return `overloaded (${status})`;
4373
- if (type === "rate_limit_error" || status === 429) return `rate limited (${status})`;
4374
- if (type === "authentication_error" || status === 401) return `auth failed (${status})`;
4375
- if (type === "permission_error" || status === 403) return `forbidden (${status})`;
4376
- if (type === "not_found_error" || status === 404) return `not found (${status})`;
4377
- if (type === "invalid_request_error" || status === 400) return `invalid request (${status})`;
4378
- if (status === 408) return `timeout (${status})`;
4379
- if (status >= 500 && status < 600) return `HTTP ${status} (server error)`;
4380
- if (type) return `${type} (${status})`;
4381
- return `HTTP ${status}`;
4382
- }
4383
- function truncate(s, n) {
4384
- return s.length <= n ? s : `${s.slice(0, n - 1)}\u2026`;
4385
- }
4386
- function providerStatusToCode(status, type) {
4387
- if (status === 0) return ERROR_CODES.PROVIDER_NETWORK_ERROR;
4388
- if (type === "rate_limit_error" || status === 429) return ERROR_CODES.PROVIDER_RATE_LIMITED;
4389
- if (type === "authentication_error" || status === 401) return ERROR_CODES.PROVIDER_AUTH_FAILED;
4390
- if (type === "overloaded_error" || status === 529) return ERROR_CODES.PROVIDER_OVERLOADED;
4391
- if (type === "invalid_request_error" || status === 400) return ERROR_CODES.PROVIDER_INVALID_REQUEST;
4392
- if (status === 408) return ERROR_CODES.PROVIDER_NETWORK_ERROR;
4393
- if (status >= 500) return ERROR_CODES.PROVIDER_SERVER_ERROR;
4394
- return ERROR_CODES.PROVIDER_INVALID_REQUEST;
4395
- }
4396
-
4397
4287
  // src/coordination/subagent-budget.ts
4398
4288
  var BudgetExceededError = class extends Error {
4399
4289
  kind;
@@ -4733,6 +4623,181 @@ var SubagentBudget = class _SubagentBudget {
4733
4623
  }
4734
4624
  };
4735
4625
 
4626
+ // src/types/errors.ts
4627
+ var ERROR_CODES = {
4628
+ // Provider
4629
+ PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED",
4630
+ PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED",
4631
+ PROVIDER_OVERLOADED: "PROVIDER_OVERLOADED",
4632
+ PROVIDER_INVALID_REQUEST: "PROVIDER_INVALID_REQUEST",
4633
+ PROVIDER_SERVER_ERROR: "PROVIDER_SERVER_ERROR",
4634
+ PROVIDER_NETWORK_ERROR: "PROVIDER_NETWORK_ERROR"};
4635
+ var WrongStackError = class extends Error {
4636
+ code;
4637
+ subsystem;
4638
+ severity;
4639
+ recoverable;
4640
+ context;
4641
+ constructor(opts) {
4642
+ super(opts.message, { cause: opts.cause });
4643
+ this.name = "WrongStackError";
4644
+ this.code = opts.code;
4645
+ this.subsystem = opts.subsystem;
4646
+ this.severity = opts.severity ?? "error";
4647
+ this.recoverable = opts.recoverable ?? false;
4648
+ this.context = opts.context;
4649
+ }
4650
+ /**
4651
+ * Render a one-line user-facing description.
4652
+ * Subclasses should override for domain-specific formatting.
4653
+ */
4654
+ describe() {
4655
+ const ctx = this.context ? ` ${formatContext(this.context)}` : "";
4656
+ return `${this.code}: ${this.message}${ctx}`;
4657
+ }
4658
+ };
4659
+ function formatContext(ctx) {
4660
+ const parts = Object.entries(ctx).filter(([, v]) => v !== void 0).slice(0, 3).map(([k, v]) => `${k}=${String(v)}`);
4661
+ return parts.length > 0 ? `[${parts.join(" ")}]` : "";
4662
+ }
4663
+
4664
+ // src/types/provider.ts
4665
+ var ProviderError = class extends WrongStackError {
4666
+ status;
4667
+ retryable;
4668
+ providerId;
4669
+ body;
4670
+ constructor(message, status, retryable, providerId, opts = {}) {
4671
+ super({
4672
+ message,
4673
+ code: providerStatusToCode(status, opts.body?.type),
4674
+ subsystem: "provider",
4675
+ severity: status >= 500 ? "error" : "warning",
4676
+ recoverable: retryable,
4677
+ context: { providerId, status },
4678
+ cause: opts.cause
4679
+ });
4680
+ this.name = "ProviderError";
4681
+ this.status = status;
4682
+ this.retryable = retryable;
4683
+ this.providerId = providerId;
4684
+ this.body = opts.body;
4685
+ }
4686
+ /**
4687
+ * Render a one-line, user-facing description. Designed for the CLI/TUI
4688
+ * status line and the agent's retry warning. Avoids dumping raw JSON
4689
+ * (which is what users see today when a 529 lands and the log message
4690
+ * includes the full `{"type":"error",...}` body).
4691
+ *
4692
+ * Examples:
4693
+ * "minimax-coding-plan overloaded (529): High traffic detected. Upgrade for highspeed model. [req 06534785201de9c0…]"
4694
+ * "openai rate limited (429): Retry after 12s"
4695
+ * "anthropic invalid request (400): messages.0.role must be one of 'user'|'assistant'"
4696
+ * "groq HTTP 500 (server error)"
4697
+ */
4698
+ describe() {
4699
+ const kind = describeStatus(this.status, this.body?.type);
4700
+ const head = `${this.providerId} ${kind}`;
4701
+ const detail = this.body?.message?.trim();
4702
+ const reqId = this.body?.requestId ? ` [req ${this.body.requestId.slice(0, 16)}${this.body.requestId.length > 16 ? "\u2026" : ""}]` : "";
4703
+ if (detail && detail.length > 0) {
4704
+ return `${head}: ${truncate(detail, 240)}${reqId}`;
4705
+ }
4706
+ return `${head}${reqId}`;
4707
+ }
4708
+ };
4709
+ function describeStatus(status, type) {
4710
+ if (status === 0) return "network error";
4711
+ if (type === "overloaded_error" || status === 529) return `overloaded (${status})`;
4712
+ if (type === "rate_limit_error" || status === 429) return `rate limited (${status})`;
4713
+ if (type === "authentication_error" || status === 401) return `auth failed (${status})`;
4714
+ if (type === "permission_error" || status === 403) return `forbidden (${status})`;
4715
+ if (type === "not_found_error" || status === 404) return `not found (${status})`;
4716
+ if (type === "invalid_request_error" || status === 400) return `invalid request (${status})`;
4717
+ if (status === 408) return `timeout (${status})`;
4718
+ if (status >= 500 && status < 600) return `HTTP ${status} (server error)`;
4719
+ if (type) return `${type} (${status})`;
4720
+ return `HTTP ${status}`;
4721
+ }
4722
+ function truncate(s, n) {
4723
+ return s.length <= n ? s : `${s.slice(0, n - 1)}\u2026`;
4724
+ }
4725
+ function providerStatusToCode(status, type) {
4726
+ if (status === 0) return ERROR_CODES.PROVIDER_NETWORK_ERROR;
4727
+ if (type === "rate_limit_error" || status === 429) return ERROR_CODES.PROVIDER_RATE_LIMITED;
4728
+ if (type === "authentication_error" || status === 401) return ERROR_CODES.PROVIDER_AUTH_FAILED;
4729
+ if (type === "overloaded_error" || status === 529) return ERROR_CODES.PROVIDER_OVERLOADED;
4730
+ if (type === "invalid_request_error" || status === 400) return ERROR_CODES.PROVIDER_INVALID_REQUEST;
4731
+ if (status === 408) return ERROR_CODES.PROVIDER_NETWORK_ERROR;
4732
+ if (status >= 500) return ERROR_CODES.PROVIDER_SERVER_ERROR;
4733
+ return ERROR_CODES.PROVIDER_INVALID_REQUEST;
4734
+ }
4735
+
4736
+ // src/coordination/coordinator/error-classifier.ts
4737
+ function classifySubagentError(err, hints = {}) {
4738
+ const cause = err instanceof Error ? { name: err.name, message: err.message, stack: err.stack } : void 0;
4739
+ if (err instanceof ProviderError) {
4740
+ const baseMessage2 = err.describe();
4741
+ return providerErrorToSubagentError(err, baseMessage2, cause);
4742
+ }
4743
+ const baseMessage = err instanceof Error ? err.message : String(err);
4744
+ if (err instanceof BudgetExceededError) {
4745
+ const map = {
4746
+ iterations: "budget_iterations",
4747
+ tool_calls: "budget_tool_calls",
4748
+ tokens: "budget_tokens",
4749
+ cost: "budget_cost",
4750
+ timeout: "budget_timeout",
4751
+ idle_timeout: "budget_timeout"
4752
+ };
4753
+ return {
4754
+ kind: map[err.kind],
4755
+ message: baseMessage,
4756
+ retryable: false,
4757
+ cause
4758
+ };
4759
+ }
4760
+ if (hints.parentAborted) {
4761
+ return { kind: "aborted_by_parent", message: baseMessage, retryable: false, cause };
4762
+ }
4763
+ const lower = baseMessage.toLowerCase();
4764
+ if (/agent aborted$/i.test(baseMessage)) {
4765
+ return { kind: "aborted_by_parent", message: baseMessage, retryable: false, cause };
4766
+ }
4767
+ if (/agent exhausted iteration limit$/i.test(baseMessage)) {
4768
+ return { kind: "budget_iterations", message: baseMessage, retryable: false, cause };
4769
+ }
4770
+ if (/empty response$/i.test(baseMessage)) {
4771
+ return { kind: "empty_response", message: baseMessage, retryable: false, cause };
4772
+ }
4773
+ if (/^tool failed: /i.test(baseMessage)) {
4774
+ return { kind: "tool_failed", message: baseMessage, retryable: false, cause };
4775
+ }
4776
+ if (lower.includes("bridge transport") || /bridge.*(closed|disconnect)/i.test(baseMessage)) {
4777
+ return { kind: "bridge_failed", message: baseMessage, retryable: false, cause };
4778
+ }
4779
+ if (/context length|max.*tokens?.*exceeded|prompt is too long/i.test(baseMessage)) {
4780
+ return { kind: "context_overflow", message: baseMessage, retryable: false, cause };
4781
+ }
4782
+ return { kind: "unknown", message: baseMessage, retryable: false, cause };
4783
+ }
4784
+ function providerErrorToSubagentError(err, message, cause) {
4785
+ const status = err.status;
4786
+ if (status === 429 || err.body?.type === "rate_limit_error") {
4787
+ return { kind: "provider_rate_limit", message, retryable: true, backoffMs: 5e3, cause };
4788
+ }
4789
+ if (status === 401 || status === 403 || err.body?.type === "authentication_error") {
4790
+ return { kind: "provider_auth", message, retryable: false, cause };
4791
+ }
4792
+ if (status === 408 || status === 0) {
4793
+ return { kind: "provider_timeout", message, retryable: true, cause };
4794
+ }
4795
+ if (status >= 500 && status < 600) {
4796
+ return { kind: "provider_5xx", message, retryable: true, backoffMs: 3e3, cause };
4797
+ }
4798
+ return { kind: "unknown", message, retryable: err.retryable, cause };
4799
+ }
4800
+
4736
4801
  // src/coordination/fleet.ts
4737
4802
  var AUDIT_LOG_AGENT = {
4738
4803
  id: "audit-log",
@@ -5800,103 +5865,8 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
5800
5865
  return false;
5801
5866
  }
5802
5867
  };
5803
- function classifySubagentError(err, hints = {}) {
5804
- const cause = err instanceof Error ? { name: err.name, message: err.message, stack: err.stack } : void 0;
5805
- if (err instanceof ProviderError) {
5806
- const baseMessage2 = err.describe();
5807
- return providerErrorToSubagentError(err, baseMessage2, cause);
5808
- }
5809
- const baseMessage = err instanceof Error ? err.message : String(err);
5810
- if (err instanceof BudgetExceededError) {
5811
- const map = {
5812
- iterations: "budget_iterations",
5813
- tool_calls: "budget_tool_calls",
5814
- tokens: "budget_tokens",
5815
- cost: "budget_cost",
5816
- timeout: "budget_timeout",
5817
- idle_timeout: "budget_timeout"
5818
- };
5819
- return {
5820
- kind: map[err.kind],
5821
- message: baseMessage,
5822
- // Budgets are user-configured ceilings, not transient failures —
5823
- // retrying with the same budget will hit the same ceiling. The
5824
- // orchestrator must raise the budget or narrow the task first.
5825
- retryable: false,
5826
- cause
5827
- };
5828
- }
5829
- if (hints.parentAborted) {
5830
- return {
5831
- kind: "aborted_by_parent",
5832
- message: baseMessage,
5833
- retryable: false,
5834
- cause
5835
- };
5836
- }
5837
- const lower = baseMessage.toLowerCase();
5838
- if (/agent aborted$/i.test(baseMessage)) {
5839
- return {
5840
- kind: "aborted_by_parent",
5841
- message: baseMessage,
5842
- retryable: false,
5843
- cause
5844
- };
5845
- }
5846
- if (/agent exhausted iteration limit$/i.test(baseMessage)) {
5847
- return { kind: "budget_iterations", message: baseMessage, retryable: false, cause };
5848
- }
5849
- if (/empty response$/i.test(baseMessage)) {
5850
- return { kind: "empty_response", message: baseMessage, retryable: false, cause };
5851
- }
5852
- if (/^tool failed: /i.test(baseMessage)) {
5853
- return { kind: "tool_failed", message: baseMessage, retryable: false, cause };
5854
- }
5855
- if (lower.includes("bridge transport") || /bridge.*(closed|disconnect)/i.test(baseMessage)) {
5856
- return { kind: "bridge_failed", message: baseMessage, retryable: false, cause };
5857
- }
5858
- if (/context length|max.*tokens?.*exceeded|prompt is too long/i.test(baseMessage)) {
5859
- return { kind: "context_overflow", message: baseMessage, retryable: false, cause };
5860
- }
5861
- return {
5862
- kind: "unknown",
5863
- message: baseMessage,
5864
- retryable: false,
5865
- cause
5866
- };
5867
- }
5868
- function providerErrorToSubagentError(err, message, cause) {
5869
- const status = err.status;
5870
- if (status === 429 || err.body?.type === "rate_limit_error") {
5871
- return {
5872
- kind: "provider_rate_limit",
5873
- message,
5874
- retryable: true,
5875
- // Conservative default: 5s. Provider-specific code can override
5876
- // by emitting an error whose body carries an explicit hint.
5877
- backoffMs: 5e3,
5878
- cause
5879
- };
5880
- }
5881
- if (status === 401 || status === 403 || err.body?.type === "authentication_error") {
5882
- return { kind: "provider_auth", message, retryable: false, cause };
5883
- }
5884
- if (status === 408 || status === 0) {
5885
- return { kind: "provider_timeout", message, retryable: true, cause };
5886
- }
5887
- if (status >= 500 && status < 600) {
5888
- return {
5889
- kind: "provider_5xx",
5890
- message,
5891
- retryable: true,
5892
- backoffMs: 3e3,
5893
- cause
5894
- };
5895
- }
5896
- return { kind: "unknown", message, retryable: err.retryable, cause };
5897
- }
5898
5868
 
5899
- // src/coordination/director.ts
5869
+ // src/coordination/director/director-errors.ts
5900
5870
  var FleetSpawnBudgetError = class extends Error {
5901
5871
  kind;
5902
5872
  limit;
@@ -5938,6 +5908,8 @@ var FleetContextOverflowError = class extends Error {
5938
5908
  this.observed = observed;
5939
5909
  }
5940
5910
  };
5911
+
5912
+ // src/coordination/director.ts
5941
5913
  var Director = class _Director {
5942
5914
  /** Alias for the ICoordinator contract. `id` is retained for backward compatibility. */
5943
5915
  get coordinatorId() {