nexus-agents 2.71.0 → 2.72.1

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 (125) hide show
  1. package/dist/{adaptive-memory-MKSYEBST.js → adaptive-memory-UPE76IP6.js} +5 -5
  2. package/dist/{chunk-DWLATKBK.js → child-mcp-config-5HRJGLCR.js} +6 -4
  3. package/dist/child-mcp-config-5HRJGLCR.js.map +1 -0
  4. package/dist/{chunk-ZPPX2K57.js → chunk-2KB63QGE.js} +2 -2
  5. package/dist/{chunk-L2LQ3TSV.js → chunk-2MD5MWCK.js} +2 -2
  6. package/dist/{chunk-ANC3HU6F.js → chunk-345KMHWH.js} +6 -6
  7. package/dist/chunk-345KMHWH.js.map +1 -0
  8. package/dist/{chunk-NER7H3RJ.js → chunk-3FIDMWFC.js} +2 -2
  9. package/dist/{chunk-POQQ7A5E.js → chunk-53K3KEKT.js} +51 -707
  10. package/dist/chunk-53K3KEKT.js.map +1 -0
  11. package/dist/chunk-5MHIWRKB.js +691 -0
  12. package/dist/chunk-5MHIWRKB.js.map +1 -0
  13. package/dist/{chunk-VGZJIR22.js → chunk-5WQ3SRSE.js} +2 -2
  14. package/dist/{chunk-TOYPY5XA.js → chunk-A35XORXU.js} +73 -10
  15. package/dist/chunk-A35XORXU.js.map +1 -0
  16. package/dist/chunk-BVETPIOQ.js +556 -0
  17. package/dist/chunk-BVETPIOQ.js.map +1 -0
  18. package/dist/{chunk-7LHQBMBM.js → chunk-C3JGKBL2.js} +25 -12
  19. package/dist/{chunk-7LHQBMBM.js.map → chunk-C3JGKBL2.js.map} +1 -1
  20. package/dist/{chunk-OF7CYMMA.js → chunk-DA5UDQYW.js} +2 -2
  21. package/dist/{chunk-XATH462F.js → chunk-ES6GFP35.js} +186 -34
  22. package/dist/chunk-ES6GFP35.js.map +1 -0
  23. package/dist/chunk-GOT7OAL5.js +59 -0
  24. package/dist/chunk-GOT7OAL5.js.map +1 -0
  25. package/dist/{chunk-LJT65EA7.js → chunk-I7ORMAO7.js} +2 -2
  26. package/dist/{chunk-AGVLFRN7.js → chunk-J4VR2WNI.js} +2998 -7188
  27. package/dist/chunk-J4VR2WNI.js.map +1 -0
  28. package/dist/{chunk-LMRKHQG5.js → chunk-L6N2S3UB.js} +2 -2
  29. package/dist/{chunk-7OBFO4GF.js → chunk-O4KUCF5S.js} +125 -40
  30. package/dist/chunk-O4KUCF5S.js.map +1 -0
  31. package/dist/chunk-P5OFZWDW.js +303 -0
  32. package/dist/chunk-P5OFZWDW.js.map +1 -0
  33. package/dist/{chunk-MJHOSM5U.js → chunk-QECRZ3YA.js} +2 -2
  34. package/dist/{chunk-WYSHXPKK.js → chunk-QL4HCYRD.js} +4 -44
  35. package/dist/chunk-QL4HCYRD.js.map +1 -0
  36. package/dist/{chunk-E66KFRSJ.js → chunk-TF3GROMO.js} +2 -2
  37. package/dist/{chunk-U3HZQTUF.js → chunk-TQFRPFMG.js} +2 -2
  38. package/dist/{chunk-KJCSRP34.js → chunk-V7ATY4BG.js} +3 -3
  39. package/dist/{chunk-32RIOULO.js → chunk-VPC3YNFR.js} +2 -2
  40. package/dist/{chunk-3BKVYSY6.js → chunk-VTVKC4FS.js} +4 -4
  41. package/dist/{chunk-U6BK5DQU.js → chunk-YOREAPF6.js} +315 -31
  42. package/dist/chunk-YOREAPF6.js.map +1 -0
  43. package/dist/cli-circuit-breaker-GFF2RLBZ.js +14 -0
  44. package/dist/cli.d.ts +3 -1
  45. package/dist/cli.js +1038 -1581
  46. package/dist/cli.js.map +1 -1
  47. package/dist/{composite-router-AYVJPIOS.js → composite-router-33F3F74I.js} +4 -4
  48. package/dist/{consensus-vote-EXWACBMR.js → consensus-vote-5V4KVHBE.js} +12 -11
  49. package/dist/doctor-deep-AHDTNURD.js +13 -0
  50. package/dist/expert-bridge-DMDHHDEU.js +11 -0
  51. package/dist/factory-FVD7PZ6S.js +15 -0
  52. package/dist/{factory-KMBWFIX2.js → factory-VQS3HJ7V.js} +6 -6
  53. package/dist/index.d.ts +997 -3517
  54. package/dist/index.js +74 -807
  55. package/dist/index.js.map +1 -1
  56. package/dist/init-opencode-EIOIPVWL.js +158 -0
  57. package/dist/init-opencode-EIOIPVWL.js.map +1 -0
  58. package/dist/issue-triage-HJUJWGAD.js +16 -0
  59. package/dist/{learning-persistence-FILWP3IR.js → learning-persistence-N6ILD2HX.js} +3 -3
  60. package/dist/{mobimem-77W5ED4Z.js → mobimem-BOJFXQ7B.js} +4 -4
  61. package/dist/{nexus-data-dir-M6DYKIHJ.js → nexus-data-dir-77UO7N6J.js} +2 -2
  62. package/dist/{registry-command-BBLIXULQ.js → registry-command-NCWUJKAF.js} +4 -4
  63. package/dist/{repo-security-plan-7SNM7JQN.js → repo-security-plan-3J45VAD6.js} +5 -5
  64. package/dist/research-helpers-synthesize-UGQHZZJN.js +12 -0
  65. package/dist/{routing-memory-DCIZEEVC.js → routing-memory-NO7QEH7T.js} +4 -4
  66. package/dist/{session-memory-5TSAASQW.js → session-memory-DOXLEWEU.js} +5 -5
  67. package/dist/{setup-command-5VGIQETA.js → setup-command-BWUFMZ7U.js} +10 -10
  68. package/dist/setup-config-E3JZYSLR.js +11 -0
  69. package/dist/{setup-custom-api-IQX3GD2D.js → setup-custom-api-DHJ5DRH2.js} +6 -6
  70. package/dist/{weather-report-NETGWTJX.js → weather-report-FNN4OX3N.js} +4 -4
  71. package/package.json +1 -1
  72. package/dist/chunk-7OBFO4GF.js.map +0 -1
  73. package/dist/chunk-AGVLFRN7.js.map +0 -1
  74. package/dist/chunk-ANC3HU6F.js.map +0 -1
  75. package/dist/chunk-DWLATKBK.js.map +0 -1
  76. package/dist/chunk-FDNWRZNJ.js +0 -22
  77. package/dist/chunk-FDNWRZNJ.js.map +0 -1
  78. package/dist/chunk-POQQ7A5E.js.map +0 -1
  79. package/dist/chunk-TOYPY5XA.js.map +0 -1
  80. package/dist/chunk-U6BK5DQU.js.map +0 -1
  81. package/dist/chunk-WYSHXPKK.js.map +0 -1
  82. package/dist/chunk-XATH462F.js.map +0 -1
  83. package/dist/cli-circuit-breaker-2CJ6NV52.js +0 -14
  84. package/dist/doctor-deep-BJFDBGPO.js +0 -13
  85. package/dist/expert-bridge-75WNNWI4.js +0 -11
  86. package/dist/factory-H5BYL4V5.js +0 -15
  87. package/dist/issue-triage-4SEP4WID.js +0 -16
  88. package/dist/mcp-config-OCWIXE2Y.js +0 -13
  89. package/dist/research-helpers-synthesize-7CI2FJE5.js +0 -12
  90. package/dist/setup-config-EA5RDIO2.js +0 -11
  91. package/dist/weather-report-NETGWTJX.js.map +0 -1
  92. /package/dist/{adaptive-memory-MKSYEBST.js.map → adaptive-memory-UPE76IP6.js.map} +0 -0
  93. /package/dist/{chunk-ZPPX2K57.js.map → chunk-2KB63QGE.js.map} +0 -0
  94. /package/dist/{chunk-L2LQ3TSV.js.map → chunk-2MD5MWCK.js.map} +0 -0
  95. /package/dist/{chunk-NER7H3RJ.js.map → chunk-3FIDMWFC.js.map} +0 -0
  96. /package/dist/{chunk-VGZJIR22.js.map → chunk-5WQ3SRSE.js.map} +0 -0
  97. /package/dist/{chunk-OF7CYMMA.js.map → chunk-DA5UDQYW.js.map} +0 -0
  98. /package/dist/{chunk-LJT65EA7.js.map → chunk-I7ORMAO7.js.map} +0 -0
  99. /package/dist/{chunk-LMRKHQG5.js.map → chunk-L6N2S3UB.js.map} +0 -0
  100. /package/dist/{chunk-MJHOSM5U.js.map → chunk-QECRZ3YA.js.map} +0 -0
  101. /package/dist/{chunk-E66KFRSJ.js.map → chunk-TF3GROMO.js.map} +0 -0
  102. /package/dist/{chunk-U3HZQTUF.js.map → chunk-TQFRPFMG.js.map} +0 -0
  103. /package/dist/{chunk-KJCSRP34.js.map → chunk-V7ATY4BG.js.map} +0 -0
  104. /package/dist/{chunk-32RIOULO.js.map → chunk-VPC3YNFR.js.map} +0 -0
  105. /package/dist/{chunk-3BKVYSY6.js.map → chunk-VTVKC4FS.js.map} +0 -0
  106. /package/dist/{cli-circuit-breaker-2CJ6NV52.js.map → cli-circuit-breaker-GFF2RLBZ.js.map} +0 -0
  107. /package/dist/{composite-router-AYVJPIOS.js.map → composite-router-33F3F74I.js.map} +0 -0
  108. /package/dist/{consensus-vote-EXWACBMR.js.map → consensus-vote-5V4KVHBE.js.map} +0 -0
  109. /package/dist/{doctor-deep-BJFDBGPO.js.map → doctor-deep-AHDTNURD.js.map} +0 -0
  110. /package/dist/{expert-bridge-75WNNWI4.js.map → expert-bridge-DMDHHDEU.js.map} +0 -0
  111. /package/dist/{factory-H5BYL4V5.js.map → factory-FVD7PZ6S.js.map} +0 -0
  112. /package/dist/{factory-KMBWFIX2.js.map → factory-VQS3HJ7V.js.map} +0 -0
  113. /package/dist/{issue-triage-4SEP4WID.js.map → issue-triage-HJUJWGAD.js.map} +0 -0
  114. /package/dist/{learning-persistence-FILWP3IR.js.map → learning-persistence-N6ILD2HX.js.map} +0 -0
  115. /package/dist/{mcp-config-OCWIXE2Y.js.map → mobimem-BOJFXQ7B.js.map} +0 -0
  116. /package/dist/{mobimem-77W5ED4Z.js.map → nexus-data-dir-77UO7N6J.js.map} +0 -0
  117. /package/dist/{registry-command-BBLIXULQ.js.map → registry-command-NCWUJKAF.js.map} +0 -0
  118. /package/dist/{nexus-data-dir-M6DYKIHJ.js.map → repo-security-plan-3J45VAD6.js.map} +0 -0
  119. /package/dist/{repo-security-plan-7SNM7JQN.js.map → research-helpers-synthesize-UGQHZZJN.js.map} +0 -0
  120. /package/dist/{research-helpers-synthesize-7CI2FJE5.js.map → routing-memory-NO7QEH7T.js.map} +0 -0
  121. /package/dist/{routing-memory-DCIZEEVC.js.map → session-memory-DOXLEWEU.js.map} +0 -0
  122. /package/dist/{session-memory-5TSAASQW.js.map → setup-command-BWUFMZ7U.js.map} +0 -0
  123. /package/dist/{setup-command-5VGIQETA.js.map → setup-config-E3JZYSLR.js.map} +0 -0
  124. /package/dist/{setup-custom-api-IQX3GD2D.js.map → setup-custom-api-DHJ5DRH2.js.map} +0 -0
  125. /package/dist/{setup-config-EA5RDIO2.js.map → weather-report-FNN4OX3N.js.map} +0 -0
@@ -1,11 +1,18 @@
1
+ import {
2
+ AdapterModelError,
3
+ BaseAdapter,
4
+ createStream,
5
+ requireApiKey,
6
+ validateApiKeyPresence
7
+ } from "./chunk-5MHIWRKB.js";
1
8
  import {
2
9
  CUSTOM_API_BASE_URL_ENV,
3
10
  PROVIDER_ENV_KEYS,
4
11
  validateCustomApiBaseUrl
5
- } from "./chunk-VGZJIR22.js";
12
+ } from "./chunk-5WQ3SRSE.js";
6
13
  import {
7
14
  CUSTOM_API_DEFAULT_MODEL
8
- } from "./chunk-L2LQ3TSV.js";
15
+ } from "./chunk-2MD5MWCK.js";
9
16
  import {
10
17
  createCliAdapter,
11
18
  createCliDetectionCache,
@@ -13,10 +20,10 @@ import {
13
20
  getAvailableClis,
14
21
  isCliAvailable,
15
22
  withTimeout
16
- } from "./chunk-XATH462F.js";
23
+ } from "./chunk-ES6GFP35.js";
17
24
  import {
18
25
  SessionMemory
19
- } from "./chunk-ZPPX2K57.js";
26
+ } from "./chunk-2KB63QGE.js";
20
27
  import {
21
28
  AdaptiveMemoryBackend,
22
29
  HybridMemoryBackend,
@@ -25,7 +32,7 @@ import {
25
32
  getMemoryEntry,
26
33
  memoryExists,
27
34
  memoryRowToEntry
28
- } from "./chunk-MJHOSM5U.js";
35
+ } from "./chunk-QECRZ3YA.js";
29
36
  import {
30
37
  stringifyValue,
31
38
  tokenizeFiltered
@@ -34,7 +41,6 @@ import {
34
41
  AgentError,
35
42
  CACHE_TIMEOUTS,
36
43
  CLI_NAMES,
37
- ConfigError,
38
44
  DEFAULT_CLI,
39
45
  DEFAULT_MODEL_CAPABILITIES,
40
46
  DEFAULT_MODEL_PER_CLI,
@@ -43,13 +49,11 @@ import {
43
49
  MobiMem,
44
50
  ModelCapability,
45
51
  ModelError,
46
- NexusError,
47
52
  OutcomeStore,
48
53
  SecurityError,
49
54
  TASK_SPECIALIZATION_MATRIX,
50
55
  TIMEOUT_GUARD,
51
56
  TaskOutcomeSchema,
52
- TimeoutError,
53
57
  VOTE_TIMEOUTS,
54
58
  ValidationError,
55
59
  categorizeOutcomeErrorMessage,
@@ -76,14 +80,14 @@ import {
76
80
  resolveVoteTimeout,
77
81
  toRateLimitError,
78
82
  validateTimeout
79
- } from "./chunk-7OBFO4GF.js";
83
+ } from "./chunk-O4KUCF5S.js";
80
84
  import {
81
85
  ensureLearningDir,
82
86
  getOutcomesFile
83
- } from "./chunk-LJT65EA7.js";
87
+ } from "./chunk-I7ORMAO7.js";
84
88
  import {
85
89
  nexusDataPath
86
- } from "./chunk-FDNWRZNJ.js";
90
+ } from "./chunk-GOT7OAL5.js";
87
91
 
88
92
  // src/mcp/tools/consensus-vote.ts
89
93
  import { z as z19 } from "zod";
@@ -1124,51 +1128,51 @@ function composeMiddleware(middlewares) {
1124
1128
  return dispatch(0, args);
1125
1129
  };
1126
1130
  }
1127
- function addAuditMiddleware(middlewares, skip2) {
1128
- if (skip2.audit !== true) {
1131
+ function addAuditMiddleware(middlewares, skip) {
1132
+ if (skip.audit !== true) {
1129
1133
  middlewares.push(createAuditMiddleware());
1130
1134
  }
1131
1135
  }
1132
- function addRateLimitMiddleware(middlewares, config, skip2) {
1133
- if (skip2.rateLimit !== true && config.rateLimiter !== void 0) {
1136
+ function addRateLimitMiddleware(middlewares, config, skip) {
1137
+ if (skip.rateLimit !== true && config.rateLimiter !== void 0) {
1134
1138
  const limiter = config.rateLimiter instanceof RateLimiter ? config.rateLimiter : new RateLimiter(config.rateLimiter);
1135
1139
  middlewares.push(createRateLimitMiddleware(limiter));
1136
1140
  }
1137
1141
  }
1138
- function addValidationMiddleware(middlewares, config, skip2) {
1139
- if (skip2.validation !== true && config.schema !== void 0) {
1142
+ function addValidationMiddleware(middlewares, config, skip) {
1143
+ if (skip.validation !== true && config.schema !== void 0) {
1140
1144
  middlewares.push(createValidationMiddleware(config.schema));
1141
1145
  }
1142
1146
  }
1143
- function addPolicyMiddleware(middlewares, config, skip2) {
1144
- if (skip2.policy !== true && config.policyFirewall !== void 0) {
1147
+ function addPolicyMiddleware(middlewares, config, skip) {
1148
+ if (skip.policy !== true && config.policyFirewall !== void 0) {
1145
1149
  const mode = config.executionMode ?? "read-only";
1146
1150
  middlewares.push(
1147
1151
  createPolicyMiddleware(config.policyFirewall, config.toolName, mode, config.allowedPaths)
1148
1152
  );
1149
1153
  }
1150
1154
  }
1151
- function addTimeoutMiddleware(middlewares, config, skip2) {
1152
- if (skip2.timeout !== true && config.timeout !== void 0) {
1155
+ function addTimeoutMiddleware(middlewares, config, skip) {
1156
+ if (skip.timeout !== true && config.timeout !== void 0) {
1153
1157
  const guard = new TimeoutGuard(config.timeout);
1154
1158
  middlewares.push(createTimeoutMiddleware(guard, config.toolName));
1155
1159
  }
1156
1160
  }
1157
- function addAccessPolicyMiddleware(middlewares, config, skip2) {
1158
- if (skip2.accessPolicy !== true) {
1161
+ function addAccessPolicyMiddleware(middlewares, config, skip) {
1162
+ if (skip.accessPolicy !== true) {
1159
1163
  middlewares.push(createAccessPolicyChainMiddleware(config.toolName));
1160
1164
  }
1161
1165
  }
1162
1166
  function buildMiddlewareStack(config) {
1163
- const skip2 = config.skip ?? {};
1167
+ const skip = config.skip ?? {};
1164
1168
  const middlewares = [];
1165
1169
  middlewares.push(createMetricsMiddleware());
1166
- addAuditMiddleware(middlewares, skip2);
1167
- addRateLimitMiddleware(middlewares, config, skip2);
1168
- addValidationMiddleware(middlewares, config, skip2);
1169
- addPolicyMiddleware(middlewares, config, skip2);
1170
- addAccessPolicyMiddleware(middlewares, config, skip2);
1171
- addTimeoutMiddleware(middlewares, config, skip2);
1170
+ addAuditMiddleware(middlewares, skip);
1171
+ addRateLimitMiddleware(middlewares, config, skip);
1172
+ addValidationMiddleware(middlewares, config, skip);
1173
+ addPolicyMiddleware(middlewares, config, skip);
1174
+ addAccessPolicyMiddleware(middlewares, config, skip);
1175
+ addTimeoutMiddleware(middlewares, config, skip);
1172
1176
  return middlewares;
1173
1177
  }
1174
1178
  function createMiddlewareChain(config) {
@@ -1829,658 +1833,6 @@ function createCliToModelAdapter(cliAdapter, config) {
1829
1833
  // src/adapters/claude-adapter.ts
1830
1834
  import Anthropic3 from "@anthropic-ai/sdk";
1831
1835
 
1832
- // src/adapters/base-adapter.ts
1833
- var AdapterModelError = class extends ModelError {
1834
- constructor(message, options) {
1835
- super(message, options);
1836
- this.name = "ModelError";
1837
- }
1838
- };
1839
- function isApiKeyMissing(apiKey) {
1840
- return apiKey === void 0 || apiKey === "" || apiKey.trim() === "";
1841
- }
1842
- function requireApiKey(apiKey, providerName, modelId) {
1843
- if (isApiKeyMissing(apiKey)) {
1844
- throw new ConfigError(`${providerName} API key is required`, {
1845
- context: { providerId: providerName.toLowerCase(), modelId }
1846
- });
1847
- }
1848
- }
1849
- function validateApiKeyPresence(apiKey, providerId, modelId) {
1850
- if (isApiKeyMissing(apiKey)) {
1851
- return err(
1852
- new ConfigError(`${providerId} API key is required`, {
1853
- context: { providerId, modelId }
1854
- })
1855
- );
1856
- }
1857
- return ok(void 0);
1858
- }
1859
- var BaseAdapter = class {
1860
- providerId;
1861
- modelId;
1862
- capabilities;
1863
- /** Logger for request/response logging */
1864
- logger;
1865
- /** Configuration for the adapter */
1866
- config;
1867
- /**
1868
- * Creates a new BaseAdapter instance.
1869
- *
1870
- * @param config - Adapter configuration
1871
- */
1872
- constructor(config) {
1873
- this.providerId = config.providerId;
1874
- this.modelId = config.modelId;
1875
- this.capabilities = config.capabilities;
1876
- this.config = config;
1877
- this.logger = config.logger ?? createLogger({
1878
- adapter: config.providerId,
1879
- model: config.modelId
1880
- });
1881
- }
1882
- /**
1883
- * Count tokens in text using the unified TokenEstimator.
1884
- *
1885
- * This provides a reasonable estimate for most use cases.
1886
- * Concrete adapters may override this with provider-specific tokenizers.
1887
- *
1888
- * @param text - Text to count tokens for
1889
- * @returns Approximate token count
1890
- */
1891
- countTokens(text) {
1892
- return Promise.resolve(getTokenEstimator().estimateText(text));
1893
- }
1894
- /**
1895
- * Validate adapter configuration.
1896
- *
1897
- * Checks that required configuration fields are present and valid.
1898
- * Concrete adapters may override to add provider-specific validation.
1899
- *
1900
- * @returns Ok if valid, ConfigError if invalid
1901
- */
1902
- validateConfig() {
1903
- const errors = [];
1904
- if (!this.providerId || this.providerId.trim() === "") {
1905
- errors.push("Provider ID is required");
1906
- }
1907
- if (!this.modelId || this.modelId.trim() === "") {
1908
- errors.push("Model ID is required");
1909
- }
1910
- if (this.config.timeout !== void 0 && this.config.timeout <= 0) {
1911
- errors.push("Timeout must be positive");
1912
- }
1913
- if (this.config.maxRetries !== void 0 && this.config.maxRetries < 0) {
1914
- errors.push("Max retries cannot be negative");
1915
- }
1916
- if (errors.length > 0) {
1917
- return err(
1918
- new ConfigError(`Invalid adapter configuration: ${errors.join("; ")}`, {
1919
- context: {
1920
- providerId: this.providerId,
1921
- modelId: this.modelId,
1922
- errors
1923
- }
1924
- })
1925
- );
1926
- }
1927
- return ok(void 0);
1928
- }
1929
- /**
1930
- * Check if this adapter supports a specific capability.
1931
- *
1932
- * @param capability - The capability to check for
1933
- * @returns True if the capability is supported
1934
- */
1935
- hasCapability(capability) {
1936
- return this.capabilities.includes(capability);
1937
- }
1938
- /**
1939
- * Log details about an outgoing request.
1940
- * Sanitizes sensitive information before logging.
1941
- *
1942
- * @param request - The completion request to log
1943
- */
1944
- logRequest(request) {
1945
- const messageCount = request.messages.length;
1946
- const hasTools = request.tools !== void 0 && request.tools.length > 0;
1947
- const toolCount = request.tools?.length ?? 0;
1948
- this.logger.debug("Sending completion request", {
1949
- messageCount,
1950
- hasSystemPrompt: request.systemPrompt !== void 0,
1951
- temperature: request.temperature,
1952
- maxTokens: request.maxTokens,
1953
- hasTools,
1954
- toolCount,
1955
- responseFormat: request.responseFormat?.type,
1956
- stopSequences: request.stop?.length ?? 0
1957
- });
1958
- }
1959
- /**
1960
- * Log details about a received response.
1961
- *
1962
- * @param response - The completion response to log
1963
- */
1964
- logResponse(response) {
1965
- this.logger.debug("Received completion response", {
1966
- contentBlocks: response.content.length,
1967
- stopReason: response.stopReason,
1968
- inputTokens: response.usage.inputTokens,
1969
- outputTokens: response.usage.outputTokens,
1970
- totalTokens: response.usage.totalTokens,
1971
- model: response.model
1972
- });
1973
- }
1974
- /**
1975
- * Transform a provider-specific error into a standardized ModelError.
1976
- *
1977
- * Maps common error patterns to appropriate error codes:
1978
- * - Rate limiting (429, quota exceeded)
1979
- * - Timeouts (ETIMEDOUT, ESOCKETTIMEDOUT)
1980
- * - Authentication (401, 403)
1981
- * - Model unavailable (503, 502)
1982
- *
1983
- * @param error - The original error from the provider
1984
- * @returns A standardized ModelError
1985
- */
1986
- transformError(error) {
1987
- if (error instanceof ModelError) {
1988
- return error;
1989
- }
1990
- const errorMessage = getErrorMessage(error);
1991
- const errorCode = this.determineErrorCode(error);
1992
- const modelError = this.createModelError(errorMessage, errorCode, error);
1993
- this.logger.error("Model adapter error", modelError, {
1994
- errorCode,
1995
- providerId: this.providerId,
1996
- modelId: this.modelId
1997
- });
1998
- return modelError;
1999
- }
2000
- /**
2001
- * Create a ModelError with appropriate error code.
2002
- */
2003
- createModelError(message, errorCode, originalError) {
2004
- const fullMessage = `${this.providerId}/${this.modelId}: ${message}`;
2005
- const options = {
2006
- code: errorCode,
2007
- context: {
2008
- providerId: this.providerId,
2009
- modelId: this.modelId
2010
- }
2011
- };
2012
- if (originalError instanceof Error) {
2013
- options.cause = originalError;
2014
- }
2015
- return new AdapterModelError(fullMessage, options);
2016
- }
2017
- /**
2018
- * Determine the appropriate error code based on error characteristics.
2019
- */
2020
- determineErrorCode(error) {
2021
- if (!(error instanceof Error)) {
2022
- return ErrorCode.MODEL_ERROR;
2023
- }
2024
- const message = error.message.toLowerCase();
2025
- const errorObj = error;
2026
- if (isRateLimitLikeError(error)) {
2027
- return ErrorCode.MODEL_RATE_LIMITED;
2028
- }
2029
- if (this.isTimeoutError(message, errorObj)) {
2030
- return ErrorCode.MODEL_TIMEOUT;
2031
- }
2032
- if (this.isUnavailableError(message, errorObj)) {
2033
- return ErrorCode.MODEL_UNAVAILABLE;
2034
- }
2035
- return ErrorCode.MODEL_ERROR;
2036
- }
2037
- /**
2038
- * Check if error indicates a timeout.
2039
- */
2040
- isTimeoutError(message, errorObj) {
2041
- const timeoutPatterns = ["timeout", "etimedout", "esockettimedout"];
2042
- return errorObj.code === "ETIMEDOUT" || errorObj.code === "ESOCKETTIMEDOUT" || timeoutPatterns.some((pattern) => message.includes(pattern));
2043
- }
2044
- /**
2045
- * Check if error indicates model unavailability.
2046
- */
2047
- isUnavailableError(message, errorObj) {
2048
- const unavailablePatterns = ["unavailable", "service unavailable", "overloaded"];
2049
- return errorObj.status === 502 || errorObj.status === 503 || unavailablePatterns.some((pattern) => message.includes(pattern));
2050
- }
2051
- };
2052
-
2053
- // src/adapters/streaming-types.ts
2054
- var StreamError = class extends NexusError {
2055
- constructor(message, options) {
2056
- super(message, { code: ErrorCode.INTERNAL_ERROR, ...options });
2057
- this.name = "StreamError";
2058
- }
2059
- };
2060
- var StreamCancelledError = class extends NexusError {
2061
- constructor(reason) {
2062
- super(reason ?? "Stream was cancelled", { code: ErrorCode.INTERNAL_ERROR });
2063
- this.name = "StreamCancelledError";
2064
- }
2065
- };
2066
- var StreamController = class {
2067
- chunks = [];
2068
- waiters = [];
2069
- _state = "idle";
2070
- _error;
2071
- maxBufferSize;
2072
- abortHandler;
2073
- abortSignal;
2074
- /**
2075
- * Creates a new StreamController.
2076
- * @param options - Stream creation options
2077
- */
2078
- constructor(options = {}) {
2079
- this.maxBufferSize = options.maxBufferSize ?? 100;
2080
- if (options.signal) {
2081
- this.abortSignal = options.signal;
2082
- this.abortHandler = () => {
2083
- this.cancel("AbortSignal triggered");
2084
- };
2085
- options.signal.addEventListener("abort", this.abortHandler);
2086
- }
2087
- }
2088
- /**
2089
- * Current state of the stream.
2090
- */
2091
- get state() {
2092
- return this._state;
2093
- }
2094
- /**
2095
- * Whether the stream is still active (can receive chunks).
2096
- */
2097
- get isActive() {
2098
- return this._state === "idle" || this._state === "streaming" || this._state === "paused";
2099
- }
2100
- /**
2101
- * Current buffer size.
2102
- */
2103
- get bufferSize() {
2104
- return this.chunks.length;
2105
- }
2106
- /**
2107
- * Push a chunk to the stream.
2108
- * @param chunk - The chunk to push
2109
- * @returns Result indicating success or backpressure
2110
- */
2111
- push(chunk) {
2112
- if (!this.isActive) {
2113
- return err(new StreamError(`Cannot push to stream in state: ${this._state}`));
2114
- }
2115
- if (this._state === "idle") {
2116
- this._state = "streaming";
2117
- }
2118
- const waiter = this.waiters.shift();
2119
- if (waiter) {
2120
- waiter.resolve({ done: false, value: chunk });
2121
- return ok(void 0);
2122
- }
2123
- if (this.chunks.length >= this.maxBufferSize) {
2124
- this._state = "paused";
2125
- return err(
2126
- new StreamError("Buffer full - backpressure applied", {
2127
- context: { bufferSize: this.chunks.length, maxBufferSize: this.maxBufferSize }
2128
- })
2129
- );
2130
- }
2131
- this.chunks.push(chunk);
2132
- return ok(void 0);
2133
- }
2134
- /**
2135
- * Complete the stream successfully.
2136
- */
2137
- complete() {
2138
- if (!this.isActive) {
2139
- return;
2140
- }
2141
- this._state = "completed";
2142
- this.removeAbortListener();
2143
- this.resolveAllWaiters();
2144
- }
2145
- /**
2146
- * Complete the stream with an error.
2147
- * @param error - The error that occurred
2148
- */
2149
- error(error) {
2150
- if (!this.isActive) {
2151
- return;
2152
- }
2153
- this._state = "error";
2154
- this._error = error;
2155
- this.removeAbortListener();
2156
- this.rejectAllWaiters(error);
2157
- }
2158
- /**
2159
- * Cancel the stream.
2160
- * @param reason - Optional reason for cancellation
2161
- */
2162
- cancel(reason) {
2163
- if (!this.isActive) {
2164
- return;
2165
- }
2166
- this._state = "cancelled";
2167
- this._error = new StreamCancelledError(reason);
2168
- this.removeAbortListener();
2169
- this.rejectAllWaiters(this._error);
2170
- }
2171
- /**
2172
- * Get the AsyncIterable for consuming the stream.
2173
- */
2174
- getIterable() {
2175
- const nextChunk = () => this.nextChunk();
2176
- const cancel = (reason) => {
2177
- this.cancel(reason);
2178
- };
2179
- return {
2180
- [Symbol.asyncIterator]() {
2181
- return {
2182
- async next() {
2183
- return nextChunk();
2184
- },
2185
- return() {
2186
- cancel("Iterator returned");
2187
- return Promise.resolve({ done: true, value: void 0 });
2188
- }
2189
- };
2190
- }
2191
- };
2192
- }
2193
- async nextChunk() {
2194
- const chunk = this.chunks.shift();
2195
- if (chunk !== void 0) {
2196
- if (this._state === "paused" && this.chunks.length < this.maxBufferSize / 2) {
2197
- this._state = "streaming";
2198
- }
2199
- return { done: false, value: chunk };
2200
- }
2201
- if (this._state === "completed") {
2202
- return { done: true, value: void 0 };
2203
- }
2204
- if (this._state === "cancelled" || this._state === "error") {
2205
- throw this._error ?? new StreamCancelledError();
2206
- }
2207
- return new Promise((resolve, reject) => {
2208
- this.waiters.push({ resolve, reject });
2209
- });
2210
- }
2211
- removeAbortListener() {
2212
- if (this.abortSignal && this.abortHandler) {
2213
- this.abortSignal.removeEventListener("abort", this.abortHandler);
2214
- }
2215
- }
2216
- resolveAllWaiters() {
2217
- for (const waiter of this.waiters) {
2218
- waiter.resolve({ done: true, value: void 0 });
2219
- }
2220
- this.waiters.length = 0;
2221
- }
2222
- rejectAllWaiters(error) {
2223
- for (const waiter of this.waiters) {
2224
- waiter.reject(error);
2225
- }
2226
- this.waiters.length = 0;
2227
- }
2228
- };
2229
- function createStream(options = {}) {
2230
- const controller = new StreamController(options);
2231
- return [controller, controller.getIterable()];
2232
- }
2233
-
2234
- // src/adapters/stream-operators-helpers.ts
2235
- async function* take(stream, count, options = {}) {
2236
- if (count <= 0) {
2237
- return;
2238
- }
2239
- let taken = 0;
2240
- for await (const chunk of stream) {
2241
- if (options.signal?.aborted === true) {
2242
- throw new StreamCancelledError("take aborted");
2243
- }
2244
- yield chunk;
2245
- taken++;
2246
- if (taken >= count) {
2247
- return;
2248
- }
2249
- }
2250
- }
2251
- async function* skip(stream, count, options = {}) {
2252
- let skipped = 0;
2253
- for await (const chunk of stream) {
2254
- if (options.signal?.aborted === true) {
2255
- throw new StreamCancelledError("skip aborted");
2256
- }
2257
- if (skipped < count) {
2258
- skipped++;
2259
- continue;
2260
- }
2261
- yield chunk;
2262
- }
2263
- }
2264
- async function* concatStreams(streams, options = {}) {
2265
- for (const stream of streams) {
2266
- if (options.signal?.aborted === true) {
2267
- throw new StreamCancelledError("concat aborted");
2268
- }
2269
- yield* stream;
2270
- }
2271
- }
2272
- async function* fromArray(values, options = {}) {
2273
- for (const value of values) {
2274
- if (options.signal?.aborted === true) {
2275
- throw new StreamCancelledError("fromArray aborted");
2276
- }
2277
- if (options.delayMs !== void 0 && options.delayMs > 0) {
2278
- await new Promise((resolve) => setTimeout(resolve, options.delayMs));
2279
- }
2280
- yield value;
2281
- }
2282
- }
2283
- async function* tapStream(stream, fn, options = {}) {
2284
- let index = 0;
2285
- for await (const chunk of stream) {
2286
- if (options.signal?.aborted === true) {
2287
- throw new StreamCancelledError("tap aborted");
2288
- }
2289
- await fn(chunk, index);
2290
- yield chunk;
2291
- index++;
2292
- }
2293
- }
2294
- async function reduceStream(stream, reducer, initialValue, options = {}) {
2295
- let accumulator = initialValue;
2296
- let index = 0;
2297
- try {
2298
- for await (const chunk of stream) {
2299
- if (options.signal?.aborted === true) {
2300
- return err(new StreamError("Reduce aborted"));
2301
- }
2302
- accumulator = await reducer(accumulator, chunk, index);
2303
- index++;
2304
- }
2305
- return ok(accumulator);
2306
- } catch (error) {
2307
- return err(
2308
- new StreamError("Failed to reduce stream", {
2309
- cause: error instanceof Error ? error : new Error(String(error))
2310
- })
2311
- );
2312
- }
2313
- }
2314
-
2315
- // src/adapters/stream-operators.ts
2316
- async function* transformStream(stream, fn, options = {}) {
2317
- let index = 0;
2318
- for await (const chunk of stream) {
2319
- if (options.signal?.aborted === true) {
2320
- throw new StreamCancelledError("Transform aborted");
2321
- }
2322
- yield await fn(chunk, index);
2323
- index++;
2324
- }
2325
- }
2326
- async function* mergeStreams(streams, options = {}) {
2327
- if (streams.length === 0) {
2328
- return;
2329
- }
2330
- const streamOptions = {};
2331
- if (options.signal) {
2332
- streamOptions.signal = options.signal;
2333
- }
2334
- const [controller, merged] = createStream(streamOptions);
2335
- let activeCount = streams.length;
2336
- const consumers = streams.map(async (stream, streamIndex) => {
2337
- try {
2338
- for await (const chunk of stream) {
2339
- if (options.signal?.aborted === true) {
2340
- break;
2341
- }
2342
- controller.push(chunk);
2343
- }
2344
- } catch (error) {
2345
- if (error instanceof StreamCancelledError) {
2346
- controller.cancel(`Stream ${String(streamIndex)} was cancelled`);
2347
- return;
2348
- }
2349
- controller.error(error instanceof Error ? error : new Error(String(error)));
2350
- return;
2351
- } finally {
2352
- activeCount--;
2353
- if (activeCount === 0) {
2354
- controller.complete();
2355
- }
2356
- }
2357
- });
2358
- Promise.all(consumers).catch((error) => {
2359
- controller.error(error instanceof Error ? error : new StreamError(String(error)));
2360
- });
2361
- yield* merged;
2362
- }
2363
- async function* takeUntil(stream, predicate, options = {}) {
2364
- let index = 0;
2365
- for await (const chunk of stream) {
2366
- if (options.signal?.aborted === true) {
2367
- throw new StreamCancelledError("takeUntil aborted");
2368
- }
2369
- const shouldStop = await predicate(chunk, index);
2370
- if (shouldStop) {
2371
- if (options.inclusive === true) {
2372
- yield chunk;
2373
- }
2374
- return;
2375
- }
2376
- yield chunk;
2377
- index++;
2378
- }
2379
- }
2380
- async function* filterStream(stream, predicate, options = {}) {
2381
- let index = 0;
2382
- for await (const chunk of stream) {
2383
- if (options.signal?.aborted === true) {
2384
- throw new StreamCancelledError("filter aborted");
2385
- }
2386
- if (await predicate(chunk, index)) {
2387
- yield chunk;
2388
- }
2389
- index++;
2390
- }
2391
- }
2392
- async function* withTimeout2(stream, timeoutMs, options = {}) {
2393
- const iterator = stream[Symbol.asyncIterator]();
2394
- try {
2395
- let running = true;
2396
- while (running) {
2397
- if (options.signal?.aborted === true) {
2398
- throw new StreamCancelledError("withTimeout aborted");
2399
- }
2400
- let timeoutId;
2401
- try {
2402
- const result = await Promise.race([
2403
- iterator.next().then((res) => {
2404
- if (timeoutId !== void 0) {
2405
- clearTimeout(timeoutId);
2406
- }
2407
- return res;
2408
- }),
2409
- new Promise((_, reject) => {
2410
- timeoutId = setTimeout(() => {
2411
- reject(
2412
- new TimeoutError(`Stream timed out after ${String(timeoutMs)}ms`, {
2413
- context: { timeoutMs }
2414
- })
2415
- );
2416
- }, timeoutMs);
2417
- })
2418
- ]);
2419
- if (result.done === true) {
2420
- running = false;
2421
- } else {
2422
- yield result.value;
2423
- }
2424
- } finally {
2425
- if (timeoutId !== void 0) {
2426
- clearTimeout(timeoutId);
2427
- }
2428
- }
2429
- }
2430
- } finally {
2431
- if (iterator.return !== void 0) {
2432
- await iterator.return();
2433
- }
2434
- }
2435
- }
2436
- async function* bufferStream(stream, size, options = {}) {
2437
- if (size <= 0) {
2438
- throw new StreamError("Buffer size must be positive");
2439
- }
2440
- let buffer = [];
2441
- for await (const chunk of stream) {
2442
- if (options.signal?.aborted === true) {
2443
- throw new StreamCancelledError("buffer aborted");
2444
- }
2445
- buffer.push(chunk);
2446
- if (buffer.length >= size) {
2447
- yield buffer;
2448
- buffer = [];
2449
- }
2450
- }
2451
- if (buffer.length > 0) {
2452
- yield buffer;
2453
- }
2454
- }
2455
-
2456
- // src/adapters/streaming.ts
2457
- var DEFAULT_COLLECT_STREAM_MAX_CHUNKS = 1e5;
2458
- async function collectStream(stream, options = {}) {
2459
- const chunks = [];
2460
- const maxChunks = options.maxChunks ?? DEFAULT_COLLECT_STREAM_MAX_CHUNKS;
2461
- try {
2462
- for await (const chunk of stream) {
2463
- if (options.signal?.aborted === true) {
2464
- return err(new StreamError("Collection aborted"));
2465
- }
2466
- chunks.push(chunk);
2467
- if (chunks.length >= maxChunks) {
2468
- break;
2469
- }
2470
- }
2471
- return ok(chunks);
2472
- } catch (error) {
2473
- if (error instanceof StreamCancelledError) {
2474
- return err(new StreamError("Stream was cancelled during collection", { cause: error }));
2475
- }
2476
- return err(
2477
- new StreamError("Failed to collect stream", {
2478
- cause: error instanceof Error ? error : new Error(String(error))
2479
- })
2480
- );
2481
- }
2482
- }
2483
-
2484
1836
  // src/adapters/claude-adapter-types.ts
2485
1837
  var CLAUDE_MODELS = {
2486
1838
  OPUS_4: getCliModelName("claude-opus"),
@@ -4689,12 +4041,27 @@ async function executeWithRetries(opts) {
4689
4041
  logger11.debug("Retrying vote execution", { role, attempt, delayMs, isRateLimit });
4690
4042
  await delay(delayMs);
4691
4043
  }
4044
+ const attemptStart = Date.now();
4692
4045
  const result = await executeSingleVoteAttempt(role, proposal, adapter, timeoutMs);
4046
+ const attemptMs = Date.now() - attemptStart;
4693
4047
  if (result.ok) {
4048
+ logger11.info("Vote attempt timing", {
4049
+ role,
4050
+ attempt: attempt + 1,
4051
+ attemptMs,
4052
+ succeeded: true
4053
+ });
4694
4054
  return { vote: result.vote, ok: true };
4695
4055
  }
4696
4056
  lastError = result.error;
4697
4057
  const rateLimited = isRateLimitError(lastError);
4058
+ logger11.info("Vote attempt timing", {
4059
+ role,
4060
+ attempt: attempt + 1,
4061
+ attemptMs,
4062
+ succeeded: false,
4063
+ rateLimited
4064
+ });
4698
4065
  logger11.warn("Vote attempt failed", {
4699
4066
  role,
4700
4067
  attempt: attempt + 1,
@@ -12875,7 +12242,7 @@ async function processVotesWithCascade(votes, opts) {
12875
12242
  var CONTRARIAN_ESCALATION_THRESHOLD = 0.8;
12876
12243
  async function runContrarianCheck(proposal, log) {
12877
12244
  try {
12878
- const { executeExpert } = await import("./expert-bridge-75WNNWI4.js");
12245
+ const { executeExpert } = await import("./expert-bridge-DMDHHDEU.js");
12879
12246
  const prompt = [
12880
12247
  "You are a contrarian analyst. Your job is to find reasons this proposal should be REJECTED.",
12881
12248
  "Look for: YAGNI (not needed), MISALIGNED (wrong tech/architecture), SECURITY_RISK, SCOPE_CREEP.",
@@ -13111,29 +12478,6 @@ export {
13111
12478
  messagesToAnthropicFormat,
13112
12479
  extractSystemPrompt,
13113
12480
  extractRequestSystemPrompt,
13114
- AdapterModelError,
13115
- isApiKeyMissing,
13116
- requireApiKey,
13117
- validateApiKeyPresence,
13118
- BaseAdapter,
13119
- StreamError,
13120
- StreamCancelledError,
13121
- StreamController,
13122
- createStream,
13123
- take,
13124
- skip,
13125
- concatStreams,
13126
- fromArray,
13127
- tapStream,
13128
- reduceStream,
13129
- transformStream,
13130
- mergeStreams,
13131
- takeUntil,
13132
- filterStream,
13133
- withTimeout2 as withTimeout,
13134
- bufferStream,
13135
- DEFAULT_COLLECT_STREAM_MAX_CHUNKS,
13136
- collectStream,
13137
12481
  CLAUDE_MODELS,
13138
12482
  CLAUDE_MODEL_ALIASES,
13139
12483
  ClaudeAdapter,
@@ -13250,4 +12594,4 @@ export {
13250
12594
  CONSENSUS_VOTE_OUTPUT_SCHEMA,
13251
12595
  registerConsensusVoteTool
13252
12596
  };
13253
- //# sourceMappingURL=chunk-POQQ7A5E.js.map
12597
+ //# sourceMappingURL=chunk-53K3KEKT.js.map