@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.
@@ -5560,6 +5560,71 @@ function providerStatusToCode(status, type) {
5560
5560
  if (status >= 500) return ERROR_CODES.PROVIDER_SERVER_ERROR;
5561
5561
  return ERROR_CODES.PROVIDER_INVALID_REQUEST;
5562
5562
  }
5563
+
5564
+ // src/coordination/coordinator/error-classifier.ts
5565
+ function classifySubagentError(err, hints = {}) {
5566
+ const cause = err instanceof Error ? { name: err.name, message: err.message, stack: err.stack } : void 0;
5567
+ if (err instanceof ProviderError) {
5568
+ const baseMessage2 = err.describe();
5569
+ return providerErrorToSubagentError(err, baseMessage2, cause);
5570
+ }
5571
+ const baseMessage = err instanceof Error ? err.message : String(err);
5572
+ if (err instanceof BudgetExceededError) {
5573
+ const map = {
5574
+ iterations: "budget_iterations",
5575
+ tool_calls: "budget_tool_calls",
5576
+ tokens: "budget_tokens",
5577
+ cost: "budget_cost",
5578
+ timeout: "budget_timeout",
5579
+ idle_timeout: "budget_timeout"
5580
+ };
5581
+ return {
5582
+ kind: map[err.kind],
5583
+ message: baseMessage,
5584
+ retryable: false,
5585
+ cause
5586
+ };
5587
+ }
5588
+ if (hints.parentAborted) {
5589
+ return { kind: "aborted_by_parent", message: baseMessage, retryable: false, cause };
5590
+ }
5591
+ const lower = baseMessage.toLowerCase();
5592
+ if (/agent aborted$/i.test(baseMessage)) {
5593
+ return { kind: "aborted_by_parent", message: baseMessage, retryable: false, cause };
5594
+ }
5595
+ if (/agent exhausted iteration limit$/i.test(baseMessage)) {
5596
+ return { kind: "budget_iterations", message: baseMessage, retryable: false, cause };
5597
+ }
5598
+ if (/empty response$/i.test(baseMessage)) {
5599
+ return { kind: "empty_response", message: baseMessage, retryable: false, cause };
5600
+ }
5601
+ if (/^tool failed: /i.test(baseMessage)) {
5602
+ return { kind: "tool_failed", message: baseMessage, retryable: false, cause };
5603
+ }
5604
+ if (lower.includes("bridge transport") || /bridge.*(closed|disconnect)/i.test(baseMessage)) {
5605
+ return { kind: "bridge_failed", message: baseMessage, retryable: false, cause };
5606
+ }
5607
+ if (/context length|max.*tokens?.*exceeded|prompt is too long/i.test(baseMessage)) {
5608
+ return { kind: "context_overflow", message: baseMessage, retryable: false, cause };
5609
+ }
5610
+ return { kind: "unknown", message: baseMessage, retryable: false, cause };
5611
+ }
5612
+ function providerErrorToSubagentError(err, message, cause) {
5613
+ const status = err.status;
5614
+ if (status === 429 || err.body?.type === "rate_limit_error") {
5615
+ return { kind: "provider_rate_limit", message, retryable: true, backoffMs: 5e3, cause };
5616
+ }
5617
+ if (status === 401 || status === 403 || err.body?.type === "authentication_error") {
5618
+ return { kind: "provider_auth", message, retryable: false, cause };
5619
+ }
5620
+ if (status === 408 || status === 0) {
5621
+ return { kind: "provider_timeout", message, retryable: true, cause };
5622
+ }
5623
+ if (status >= 500 && status < 600) {
5624
+ return { kind: "provider_5xx", message, retryable: true, backoffMs: 3e3, cause };
5625
+ }
5626
+ return { kind: "unknown", message, retryable: err.retryable, cause };
5627
+ }
5563
5628
  ({
5564
5629
  ...Object.fromEntries(
5565
5630
  ALL_AGENT_DEFINITIONS.map((d) => [d.config.role, d.config])
@@ -6413,101 +6478,6 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
6413
6478
  return false;
6414
6479
  }
6415
6480
  };
6416
- function classifySubagentError(err, hints = {}) {
6417
- const cause = err instanceof Error ? { name: err.name, message: err.message, stack: err.stack } : void 0;
6418
- if (err instanceof ProviderError) {
6419
- const baseMessage2 = err.describe();
6420
- return providerErrorToSubagentError(err, baseMessage2, cause);
6421
- }
6422
- const baseMessage = err instanceof Error ? err.message : String(err);
6423
- if (err instanceof BudgetExceededError) {
6424
- const map = {
6425
- iterations: "budget_iterations",
6426
- tool_calls: "budget_tool_calls",
6427
- tokens: "budget_tokens",
6428
- cost: "budget_cost",
6429
- timeout: "budget_timeout",
6430
- idle_timeout: "budget_timeout"
6431
- };
6432
- return {
6433
- kind: map[err.kind],
6434
- message: baseMessage,
6435
- // Budgets are user-configured ceilings, not transient failures —
6436
- // retrying with the same budget will hit the same ceiling. The
6437
- // orchestrator must raise the budget or narrow the task first.
6438
- retryable: false,
6439
- cause
6440
- };
6441
- }
6442
- if (hints.parentAborted) {
6443
- return {
6444
- kind: "aborted_by_parent",
6445
- message: baseMessage,
6446
- retryable: false,
6447
- cause
6448
- };
6449
- }
6450
- const lower = baseMessage.toLowerCase();
6451
- if (/agent aborted$/i.test(baseMessage)) {
6452
- return {
6453
- kind: "aborted_by_parent",
6454
- message: baseMessage,
6455
- retryable: false,
6456
- cause
6457
- };
6458
- }
6459
- if (/agent exhausted iteration limit$/i.test(baseMessage)) {
6460
- return { kind: "budget_iterations", message: baseMessage, retryable: false, cause };
6461
- }
6462
- if (/empty response$/i.test(baseMessage)) {
6463
- return { kind: "empty_response", message: baseMessage, retryable: false, cause };
6464
- }
6465
- if (/^tool failed: /i.test(baseMessage)) {
6466
- return { kind: "tool_failed", message: baseMessage, retryable: false, cause };
6467
- }
6468
- if (lower.includes("bridge transport") || /bridge.*(closed|disconnect)/i.test(baseMessage)) {
6469
- return { kind: "bridge_failed", message: baseMessage, retryable: false, cause };
6470
- }
6471
- if (/context length|max.*tokens?.*exceeded|prompt is too long/i.test(baseMessage)) {
6472
- return { kind: "context_overflow", message: baseMessage, retryable: false, cause };
6473
- }
6474
- return {
6475
- kind: "unknown",
6476
- message: baseMessage,
6477
- retryable: false,
6478
- cause
6479
- };
6480
- }
6481
- function providerErrorToSubagentError(err, message, cause) {
6482
- const status = err.status;
6483
- if (status === 429 || err.body?.type === "rate_limit_error") {
6484
- return {
6485
- kind: "provider_rate_limit",
6486
- message,
6487
- retryable: true,
6488
- // Conservative default: 5s. Provider-specific code can override
6489
- // by emitting an error whose body carries an explicit hint.
6490
- backoffMs: 5e3,
6491
- cause
6492
- };
6493
- }
6494
- if (status === 401 || status === 403 || err.body?.type === "authentication_error") {
6495
- return { kind: "provider_auth", message, retryable: false, cause };
6496
- }
6497
- if (status === 408 || status === 0) {
6498
- return { kind: "provider_timeout", message, retryable: true, cause };
6499
- }
6500
- if (status >= 500 && status < 600) {
6501
- return {
6502
- kind: "provider_5xx",
6503
- message,
6504
- retryable: true,
6505
- backoffMs: 3e3,
6506
- cause
6507
- };
6508
- }
6509
- return { kind: "unknown", message, retryable: err.retryable, cause };
6510
- }
6511
6481
 
6512
6482
  // src/execution/parallel-eternal-engine.ts
6513
6483
  function sleep2(ms) {