@deepseekdev/coder 1.0.74

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 (711) hide show
  1. package/LICENSE +21 -0
  2. package/agents/agi-code.rules.json +159 -0
  3. package/agents/general.rules.json +181 -0
  4. package/dist/bin/cliMode.d.ts +8 -0
  5. package/dist/bin/cliMode.d.ts.map +1 -0
  6. package/dist/bin/cliMode.js +20 -0
  7. package/dist/bin/cliMode.js.map +1 -0
  8. package/dist/bin/deepseek.d.ts +3 -0
  9. package/dist/bin/deepseek.d.ts.map +1 -0
  10. package/dist/bin/deepseek.js +137 -0
  11. package/dist/bin/deepseek.js.map +1 -0
  12. package/dist/bin/erosolar.d.ts +7 -0
  13. package/dist/bin/erosolar.d.ts.map +1 -0
  14. package/dist/bin/erosolar.js +7 -0
  15. package/dist/bin/erosolar.js.map +1 -0
  16. package/dist/bin/lean.d.ts +9 -0
  17. package/dist/bin/lean.d.ts.map +1 -0
  18. package/dist/bin/lean.js +333 -0
  19. package/dist/bin/lean.js.map +1 -0
  20. package/dist/bin/selfTest.d.ts +14 -0
  21. package/dist/bin/selfTest.d.ts.map +1 -0
  22. package/dist/bin/selfTest.js +298 -0
  23. package/dist/bin/selfTest.js.map +1 -0
  24. package/dist/capabilities/baseCapability.d.ts +72 -0
  25. package/dist/capabilities/baseCapability.d.ts.map +1 -0
  26. package/dist/capabilities/baseCapability.js +183 -0
  27. package/dist/capabilities/baseCapability.js.map +1 -0
  28. package/dist/capabilities/bashCapability.d.ts +13 -0
  29. package/dist/capabilities/bashCapability.d.ts.map +1 -0
  30. package/dist/capabilities/bashCapability.js +24 -0
  31. package/dist/capabilities/bashCapability.js.map +1 -0
  32. package/dist/capabilities/editCapability.d.ts +17 -0
  33. package/dist/capabilities/editCapability.d.ts.map +1 -0
  34. package/dist/capabilities/editCapability.js +27 -0
  35. package/dist/capabilities/editCapability.js.map +1 -0
  36. package/dist/capabilities/enhancedGitCapability.d.ts +7 -0
  37. package/dist/capabilities/enhancedGitCapability.d.ts.map +1 -0
  38. package/dist/capabilities/enhancedGitCapability.js +220 -0
  39. package/dist/capabilities/enhancedGitCapability.js.map +1 -0
  40. package/dist/capabilities/filesystemCapability.d.ts +13 -0
  41. package/dist/capabilities/filesystemCapability.d.ts.map +1 -0
  42. package/dist/capabilities/filesystemCapability.js +24 -0
  43. package/dist/capabilities/filesystemCapability.js.map +1 -0
  44. package/dist/capabilities/gitHistoryCapability.d.ts +6 -0
  45. package/dist/capabilities/gitHistoryCapability.d.ts.map +1 -0
  46. package/dist/capabilities/gitHistoryCapability.js +160 -0
  47. package/dist/capabilities/gitHistoryCapability.js.map +1 -0
  48. package/dist/capabilities/hitlCapability.d.ts +18 -0
  49. package/dist/capabilities/hitlCapability.d.ts.map +1 -0
  50. package/dist/capabilities/hitlCapability.js +29 -0
  51. package/dist/capabilities/hitlCapability.js.map +1 -0
  52. package/dist/capabilities/index.d.ts +11 -0
  53. package/dist/capabilities/index.d.ts.map +1 -0
  54. package/dist/capabilities/index.js +13 -0
  55. package/dist/capabilities/index.js.map +1 -0
  56. package/dist/capabilities/searchCapability.d.ts +19 -0
  57. package/dist/capabilities/searchCapability.d.ts.map +1 -0
  58. package/dist/capabilities/searchCapability.js +29 -0
  59. package/dist/capabilities/searchCapability.js.map +1 -0
  60. package/dist/capabilities/toolManifest.d.ts +3 -0
  61. package/dist/capabilities/toolManifest.d.ts.map +1 -0
  62. package/dist/capabilities/toolManifest.js +163 -0
  63. package/dist/capabilities/toolManifest.js.map +1 -0
  64. package/dist/capabilities/toolRegistry.d.ts +25 -0
  65. package/dist/capabilities/toolRegistry.d.ts.map +1 -0
  66. package/dist/capabilities/toolRegistry.js +150 -0
  67. package/dist/capabilities/toolRegistry.js.map +1 -0
  68. package/dist/capabilities/unifiedCodingCapability.d.ts +48 -0
  69. package/dist/capabilities/unifiedCodingCapability.d.ts.map +1 -0
  70. package/dist/capabilities/unifiedCodingCapability.js +631 -0
  71. package/dist/capabilities/unifiedCodingCapability.js.map +1 -0
  72. package/dist/capabilities/webCapability.d.ts +23 -0
  73. package/dist/capabilities/webCapability.d.ts.map +1 -0
  74. package/dist/capabilities/webCapability.js +33 -0
  75. package/dist/capabilities/webCapability.js.map +1 -0
  76. package/dist/config.d.ts +25 -0
  77. package/dist/config.d.ts.map +1 -0
  78. package/dist/config.js +155 -0
  79. package/dist/config.js.map +1 -0
  80. package/dist/contracts/agent-profiles.schema.json +43 -0
  81. package/dist/contracts/agent-schemas.json +480 -0
  82. package/dist/contracts/models.schema.json +9 -0
  83. package/dist/contracts/module-schema.json +430 -0
  84. package/dist/contracts/schemas/agent-profile.schema.json +157 -0
  85. package/dist/contracts/schemas/agent-rules.schema.json +238 -0
  86. package/dist/contracts/schemas/agent-schemas.schema.json +528 -0
  87. package/dist/contracts/schemas/agent.schema.json +90 -0
  88. package/dist/contracts/schemas/tool-selection.schema.json +174 -0
  89. package/dist/contracts/tools.schema.json +82 -0
  90. package/dist/contracts/unified-schema.json +757 -0
  91. package/dist/contracts/v1/agent.d.ts +187 -0
  92. package/dist/contracts/v1/agent.d.ts.map +1 -0
  93. package/dist/contracts/v1/agent.js +8 -0
  94. package/dist/contracts/v1/agent.js.map +1 -0
  95. package/dist/contracts/v1/agentProfileManifest.d.ts +60 -0
  96. package/dist/contracts/v1/agentProfileManifest.d.ts.map +1 -0
  97. package/dist/contracts/v1/agentProfileManifest.js +9 -0
  98. package/dist/contracts/v1/agentProfileManifest.js.map +1 -0
  99. package/dist/contracts/v1/agentRules.d.ts +60 -0
  100. package/dist/contracts/v1/agentRules.d.ts.map +1 -0
  101. package/dist/contracts/v1/agentRules.js +10 -0
  102. package/dist/contracts/v1/agentRules.js.map +1 -0
  103. package/dist/contracts/v1/provider.d.ts +149 -0
  104. package/dist/contracts/v1/provider.d.ts.map +1 -0
  105. package/dist/contracts/v1/provider.js +7 -0
  106. package/dist/contracts/v1/provider.js.map +1 -0
  107. package/dist/contracts/v1/tool.d.ts +136 -0
  108. package/dist/contracts/v1/tool.d.ts.map +1 -0
  109. package/dist/contracts/v1/tool.js +7 -0
  110. package/dist/contracts/v1/tool.js.map +1 -0
  111. package/dist/contracts/v1/toolAccess.d.ts +43 -0
  112. package/dist/contracts/v1/toolAccess.d.ts.map +1 -0
  113. package/dist/contracts/v1/toolAccess.js +9 -0
  114. package/dist/contracts/v1/toolAccess.js.map +1 -0
  115. package/dist/core/agent.d.ts +320 -0
  116. package/dist/core/agent.d.ts.map +1 -0
  117. package/dist/core/agent.js +1627 -0
  118. package/dist/core/agent.js.map +1 -0
  119. package/dist/core/agentProfileManifest.d.ts +3 -0
  120. package/dist/core/agentProfileManifest.d.ts.map +1 -0
  121. package/dist/core/agentProfileManifest.js +188 -0
  122. package/dist/core/agentProfileManifest.js.map +1 -0
  123. package/dist/core/agentProfiles.d.ts +22 -0
  124. package/dist/core/agentProfiles.d.ts.map +1 -0
  125. package/dist/core/agentProfiles.js +35 -0
  126. package/dist/core/agentProfiles.js.map +1 -0
  127. package/dist/core/agentRulebook.d.ts +11 -0
  128. package/dist/core/agentRulebook.d.ts.map +1 -0
  129. package/dist/core/agentRulebook.js +136 -0
  130. package/dist/core/agentRulebook.js.map +1 -0
  131. package/dist/core/agentSchemaLoader.d.ts +131 -0
  132. package/dist/core/agentSchemaLoader.d.ts.map +1 -0
  133. package/dist/core/agentSchemaLoader.js +235 -0
  134. package/dist/core/agentSchemaLoader.js.map +1 -0
  135. package/dist/core/agiCore.d.ts +312 -0
  136. package/dist/core/agiCore.d.ts.map +1 -0
  137. package/dist/core/agiCore.js +1585 -0
  138. package/dist/core/agiCore.js.map +1 -0
  139. package/dist/core/aiErrorFixer.d.ts +57 -0
  140. package/dist/core/aiErrorFixer.d.ts.map +1 -0
  141. package/dist/core/aiErrorFixer.js +214 -0
  142. package/dist/core/aiErrorFixer.js.map +1 -0
  143. package/dist/core/bashCommandGuidance.d.ts +16 -0
  144. package/dist/core/bashCommandGuidance.d.ts.map +1 -0
  145. package/dist/core/bashCommandGuidance.js +40 -0
  146. package/dist/core/bashCommandGuidance.js.map +1 -0
  147. package/dist/core/constants.d.ts +31 -0
  148. package/dist/core/constants.d.ts.map +1 -0
  149. package/dist/core/constants.js +62 -0
  150. package/dist/core/constants.js.map +1 -0
  151. package/dist/core/contextManager.d.ts +271 -0
  152. package/dist/core/contextManager.d.ts.map +1 -0
  153. package/dist/core/contextManager.js +1073 -0
  154. package/dist/core/contextManager.js.map +1 -0
  155. package/dist/core/contextWindow.d.ts +42 -0
  156. package/dist/core/contextWindow.d.ts.map +1 -0
  157. package/dist/core/contextWindow.js +123 -0
  158. package/dist/core/contextWindow.js.map +1 -0
  159. package/dist/core/customCommands.d.ts +19 -0
  160. package/dist/core/customCommands.d.ts.map +1 -0
  161. package/dist/core/customCommands.js +85 -0
  162. package/dist/core/customCommands.js.map +1 -0
  163. package/dist/core/deepBugAnalyzer.d.ts +25 -0
  164. package/dist/core/deepBugAnalyzer.d.ts.map +1 -0
  165. package/dist/core/deepBugAnalyzer.js +44 -0
  166. package/dist/core/deepBugAnalyzer.js.map +1 -0
  167. package/dist/core/dynamicGuardrails.d.ts +207 -0
  168. package/dist/core/dynamicGuardrails.d.ts.map +1 -0
  169. package/dist/core/dynamicGuardrails.js +455 -0
  170. package/dist/core/dynamicGuardrails.js.map +1 -0
  171. package/dist/core/embeddingProviders.d.ts +80 -0
  172. package/dist/core/embeddingProviders.d.ts.map +1 -0
  173. package/dist/core/embeddingProviders.js +241 -0
  174. package/dist/core/embeddingProviders.js.map +1 -0
  175. package/dist/core/episodicMemory.d.ts +259 -0
  176. package/dist/core/episodicMemory.d.ts.map +1 -0
  177. package/dist/core/episodicMemory.js +834 -0
  178. package/dist/core/episodicMemory.js.map +1 -0
  179. package/dist/core/errors/apiKeyErrors.d.ts +11 -0
  180. package/dist/core/errors/apiKeyErrors.d.ts.map +1 -0
  181. package/dist/core/errors/apiKeyErrors.js +159 -0
  182. package/dist/core/errors/apiKeyErrors.js.map +1 -0
  183. package/dist/core/errors/errorTypes.d.ts +111 -0
  184. package/dist/core/errors/errorTypes.d.ts.map +1 -0
  185. package/dist/core/errors/errorTypes.js +345 -0
  186. package/dist/core/errors/errorTypes.js.map +1 -0
  187. package/dist/core/errors/index.d.ts +50 -0
  188. package/dist/core/errors/index.d.ts.map +1 -0
  189. package/dist/core/errors/index.js +156 -0
  190. package/dist/core/errors/index.js.map +1 -0
  191. package/dist/core/errors/networkErrors.d.ts +14 -0
  192. package/dist/core/errors/networkErrors.d.ts.map +1 -0
  193. package/dist/core/errors/networkErrors.js +53 -0
  194. package/dist/core/errors/networkErrors.js.map +1 -0
  195. package/dist/core/errors/safetyValidator.d.ts +109 -0
  196. package/dist/core/errors/safetyValidator.d.ts.map +1 -0
  197. package/dist/core/errors/safetyValidator.js +271 -0
  198. package/dist/core/errors/safetyValidator.js.map +1 -0
  199. package/dist/core/errors.d.ts +4 -0
  200. package/dist/core/errors.d.ts.map +1 -0
  201. package/dist/core/errors.js +33 -0
  202. package/dist/core/errors.js.map +1 -0
  203. package/dist/core/finalResponseFormatter.d.ts +10 -0
  204. package/dist/core/finalResponseFormatter.d.ts.map +1 -0
  205. package/dist/core/finalResponseFormatter.js +14 -0
  206. package/dist/core/finalResponseFormatter.js.map +1 -0
  207. package/dist/core/flowProtection.d.ts +154 -0
  208. package/dist/core/flowProtection.d.ts.map +1 -0
  209. package/dist/core/flowProtection.js +439 -0
  210. package/dist/core/flowProtection.js.map +1 -0
  211. package/dist/core/gitWorktreeManager.d.ts +126 -0
  212. package/dist/core/gitWorktreeManager.d.ts.map +1 -0
  213. package/dist/core/gitWorktreeManager.js +403 -0
  214. package/dist/core/gitWorktreeManager.js.map +1 -0
  215. package/dist/core/global-macbook-access.d.ts +59 -0
  216. package/dist/core/global-macbook-access.d.ts.map +1 -0
  217. package/dist/core/global-macbook-access.js +101 -0
  218. package/dist/core/global-macbook-access.js.map +1 -0
  219. package/dist/core/guardrails.d.ts +146 -0
  220. package/dist/core/guardrails.d.ts.map +1 -0
  221. package/dist/core/guardrails.js +361 -0
  222. package/dist/core/guardrails.js.map +1 -0
  223. package/dist/core/hallucinationGuard.d.ts +57 -0
  224. package/dist/core/hallucinationGuard.d.ts.map +1 -0
  225. package/dist/core/hallucinationGuard.js +237 -0
  226. package/dist/core/hallucinationGuard.js.map +1 -0
  227. package/dist/core/hitl.d.ts +109 -0
  228. package/dist/core/hitl.d.ts.map +1 -0
  229. package/dist/core/hitl.js +371 -0
  230. package/dist/core/hitl.js.map +1 -0
  231. package/dist/core/hooks.d.ts +113 -0
  232. package/dist/core/hooks.d.ts.map +1 -0
  233. package/dist/core/hooks.js +364 -0
  234. package/dist/core/hooks.js.map +1 -0
  235. package/dist/core/hotReload.d.ts +154 -0
  236. package/dist/core/hotReload.d.ts.map +1 -0
  237. package/dist/core/hotReload.js +451 -0
  238. package/dist/core/hotReload.js.map +1 -0
  239. package/dist/core/hypothesisEngine.d.ts +27 -0
  240. package/dist/core/hypothesisEngine.d.ts.map +1 -0
  241. package/dist/core/hypothesisEngine.js +58 -0
  242. package/dist/core/hypothesisEngine.js.map +1 -0
  243. package/dist/core/index.d.ts +18 -0
  244. package/dist/core/index.d.ts.map +1 -0
  245. package/dist/core/index.js +40 -0
  246. package/dist/core/index.js.map +1 -0
  247. package/dist/core/initialExplorer.d.ts +53 -0
  248. package/dist/core/initialExplorer.d.ts.map +1 -0
  249. package/dist/core/initialExplorer.js +423 -0
  250. package/dist/core/initialExplorer.js.map +1 -0
  251. package/dist/core/inputProtection.d.ts +122 -0
  252. package/dist/core/inputProtection.d.ts.map +1 -0
  253. package/dist/core/inputProtection.js +422 -0
  254. package/dist/core/inputProtection.js.map +1 -0
  255. package/dist/core/liveGCPVerification.d.ts +41 -0
  256. package/dist/core/liveGCPVerification.d.ts.map +1 -0
  257. package/dist/core/liveGCPVerification.js +745 -0
  258. package/dist/core/liveGCPVerification.js.map +1 -0
  259. package/dist/core/modelDiscovery.d.ts +105 -0
  260. package/dist/core/modelDiscovery.d.ts.map +1 -0
  261. package/dist/core/modelDiscovery.js +768 -0
  262. package/dist/core/modelDiscovery.js.map +1 -0
  263. package/dist/core/multilinePasteHandler.d.ts +35 -0
  264. package/dist/core/multilinePasteHandler.d.ts.map +1 -0
  265. package/dist/core/multilinePasteHandler.js +81 -0
  266. package/dist/core/multilinePasteHandler.js.map +1 -0
  267. package/dist/core/parallelExecutor.d.ts +215 -0
  268. package/dist/core/parallelExecutor.d.ts.map +1 -0
  269. package/dist/core/parallelExecutor.js +584 -0
  270. package/dist/core/parallelExecutor.js.map +1 -0
  271. package/dist/core/preferences.d.ts +71 -0
  272. package/dist/core/preferences.d.ts.map +1 -0
  273. package/dist/core/preferences.js +341 -0
  274. package/dist/core/preferences.js.map +1 -0
  275. package/dist/core/productTestHarness.d.ts +46 -0
  276. package/dist/core/productTestHarness.d.ts.map +1 -0
  277. package/dist/core/productTestHarness.js +128 -0
  278. package/dist/core/productTestHarness.js.map +1 -0
  279. package/dist/core/providerKeys.d.ts +20 -0
  280. package/dist/core/providerKeys.d.ts.map +1 -0
  281. package/dist/core/providerKeys.js +40 -0
  282. package/dist/core/providerKeys.js.map +1 -0
  283. package/dist/core/resultVerification.d.ts +47 -0
  284. package/dist/core/resultVerification.d.ts.map +1 -0
  285. package/dist/core/resultVerification.js +126 -0
  286. package/dist/core/resultVerification.js.map +1 -0
  287. package/dist/core/revenueEnvValidator.d.ts +30 -0
  288. package/dist/core/revenueEnvValidator.d.ts.map +1 -0
  289. package/dist/core/revenueEnvValidator.js +244 -0
  290. package/dist/core/revenueEnvValidator.js.map +1 -0
  291. package/dist/core/schemaValidator.d.ts +49 -0
  292. package/dist/core/schemaValidator.d.ts.map +1 -0
  293. package/dist/core/schemaValidator.js +234 -0
  294. package/dist/core/schemaValidator.js.map +1 -0
  295. package/dist/core/secretStore.d.ts +48 -0
  296. package/dist/core/secretStore.d.ts.map +1 -0
  297. package/dist/core/secretStore.js +295 -0
  298. package/dist/core/secretStore.js.map +1 -0
  299. package/dist/core/selfUpgrade.d.ts +79 -0
  300. package/dist/core/selfUpgrade.d.ts.map +1 -0
  301. package/dist/core/selfUpgrade.js +92 -0
  302. package/dist/core/selfUpgrade.js.map +1 -0
  303. package/dist/core/sessionStorage.d.ts +10 -0
  304. package/dist/core/sessionStorage.d.ts.map +1 -0
  305. package/dist/core/sessionStorage.js +46 -0
  306. package/dist/core/sessionStorage.js.map +1 -0
  307. package/dist/core/sessionStore.d.ts +35 -0
  308. package/dist/core/sessionStore.d.ts.map +1 -0
  309. package/dist/core/sessionStore.js +191 -0
  310. package/dist/core/sessionStore.js.map +1 -0
  311. package/dist/core/shutdown.d.ts +34 -0
  312. package/dist/core/shutdown.d.ts.map +1 -0
  313. package/dist/core/shutdown.js +173 -0
  314. package/dist/core/shutdown.js.map +1 -0
  315. package/dist/core/sudoPasswordManager.d.ts +52 -0
  316. package/dist/core/sudoPasswordManager.d.ts.map +1 -0
  317. package/dist/core/sudoPasswordManager.js +115 -0
  318. package/dist/core/sudoPasswordManager.js.map +1 -0
  319. package/dist/core/taskCompletionDetector.d.ts +112 -0
  320. package/dist/core/taskCompletionDetector.d.ts.map +1 -0
  321. package/dist/core/taskCompletionDetector.js +469 -0
  322. package/dist/core/taskCompletionDetector.js.map +1 -0
  323. package/dist/core/testFailureMonitor.d.ts +67 -0
  324. package/dist/core/testFailureMonitor.d.ts.map +1 -0
  325. package/dist/core/testFailureMonitor.js +262 -0
  326. package/dist/core/testFailureMonitor.js.map +1 -0
  327. package/dist/core/toolPreconditions.d.ts +34 -0
  328. package/dist/core/toolPreconditions.d.ts.map +1 -0
  329. package/dist/core/toolPreconditions.js +242 -0
  330. package/dist/core/toolPreconditions.js.map +1 -0
  331. package/dist/core/toolRuntime.d.ts +185 -0
  332. package/dist/core/toolRuntime.d.ts.map +1 -0
  333. package/dist/core/toolRuntime.js +412 -0
  334. package/dist/core/toolRuntime.js.map +1 -0
  335. package/dist/core/types/utilityTypes.d.ts +183 -0
  336. package/dist/core/types/utilityTypes.d.ts.map +1 -0
  337. package/dist/core/types/utilityTypes.js +273 -0
  338. package/dist/core/types/utilityTypes.js.map +1 -0
  339. package/dist/core/types.d.ts +334 -0
  340. package/dist/core/types.d.ts.map +1 -0
  341. package/dist/core/types.js +76 -0
  342. package/dist/core/types.js.map +1 -0
  343. package/dist/core/unifiedOrchestrator.d.ts +47 -0
  344. package/dist/core/unifiedOrchestrator.d.ts.map +1 -0
  345. package/dist/core/unifiedOrchestrator.js +103 -0
  346. package/dist/core/unifiedOrchestrator.js.map +1 -0
  347. package/dist/core/unrestricted-mode.d.ts +42 -0
  348. package/dist/core/unrestricted-mode.d.ts.map +1 -0
  349. package/dist/core/unrestricted-mode.js +88 -0
  350. package/dist/core/unrestricted-mode.js.map +1 -0
  351. package/dist/core/updateChecker.d.ts +148 -0
  352. package/dist/core/updateChecker.d.ts.map +1 -0
  353. package/dist/core/updateChecker.js +593 -0
  354. package/dist/core/updateChecker.js.map +1 -0
  355. package/dist/headless/interactiveShell.d.ts +22 -0
  356. package/dist/headless/interactiveShell.d.ts.map +1 -0
  357. package/dist/headless/interactiveShell.js +4045 -0
  358. package/dist/headless/interactiveShell.js.map +1 -0
  359. package/dist/headless/quickMode.d.ts +26 -0
  360. package/dist/headless/quickMode.d.ts.map +1 -0
  361. package/dist/headless/quickMode.js +236 -0
  362. package/dist/headless/quickMode.js.map +1 -0
  363. package/dist/leanAgent.d.ts +73 -0
  364. package/dist/leanAgent.d.ts.map +1 -0
  365. package/dist/leanAgent.js +175 -0
  366. package/dist/leanAgent.js.map +1 -0
  367. package/dist/orchestration/index.d.ts +14 -0
  368. package/dist/orchestration/index.d.ts.map +1 -0
  369. package/dist/orchestration/index.js +12 -0
  370. package/dist/orchestration/index.js.map +1 -0
  371. package/dist/plugins/index.d.ts +49 -0
  372. package/dist/plugins/index.d.ts.map +1 -0
  373. package/dist/plugins/index.js +104 -0
  374. package/dist/plugins/index.js.map +1 -0
  375. package/dist/plugins/providers/anthropic/index.d.ts +9 -0
  376. package/dist/plugins/providers/anthropic/index.d.ts.map +1 -0
  377. package/dist/plugins/providers/anthropic/index.js +48 -0
  378. package/dist/plugins/providers/anthropic/index.js.map +1 -0
  379. package/dist/plugins/providers/deepseek/index.d.ts +11 -0
  380. package/dist/plugins/providers/deepseek/index.d.ts.map +1 -0
  381. package/dist/plugins/providers/deepseek/index.js +54 -0
  382. package/dist/plugins/providers/deepseek/index.js.map +1 -0
  383. package/dist/plugins/providers/index.d.ts +2 -0
  384. package/dist/plugins/providers/index.d.ts.map +1 -0
  385. package/dist/plugins/providers/index.js +17 -0
  386. package/dist/plugins/providers/index.js.map +1 -0
  387. package/dist/plugins/providers/openai/index.d.ts +10 -0
  388. package/dist/plugins/providers/openai/index.d.ts.map +1 -0
  389. package/dist/plugins/providers/openai/index.js +47 -0
  390. package/dist/plugins/providers/openai/index.js.map +1 -0
  391. package/dist/plugins/providers/xai/index.d.ts +10 -0
  392. package/dist/plugins/providers/xai/index.d.ts.map +1 -0
  393. package/dist/plugins/providers/xai/index.js +47 -0
  394. package/dist/plugins/providers/xai/index.js.map +1 -0
  395. package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.d.ts +10 -0
  396. package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.d.ts.map +1 -0
  397. package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.js +110 -0
  398. package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.js.map +1 -0
  399. package/dist/plugins/tools/bash/localBashPlugin.d.ts +3 -0
  400. package/dist/plugins/tools/bash/localBashPlugin.d.ts.map +1 -0
  401. package/dist/plugins/tools/bash/localBashPlugin.js +14 -0
  402. package/dist/plugins/tools/bash/localBashPlugin.js.map +1 -0
  403. package/dist/plugins/tools/edit/editPlugin.d.ts +9 -0
  404. package/dist/plugins/tools/edit/editPlugin.d.ts.map +1 -0
  405. package/dist/plugins/tools/edit/editPlugin.js +15 -0
  406. package/dist/plugins/tools/edit/editPlugin.js.map +1 -0
  407. package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.d.ts +3 -0
  408. package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.d.ts.map +1 -0
  409. package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.js +9 -0
  410. package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.js.map +1 -0
  411. package/dist/plugins/tools/filesystem/localFilesystemPlugin.d.ts +3 -0
  412. package/dist/plugins/tools/filesystem/localFilesystemPlugin.d.ts.map +1 -0
  413. package/dist/plugins/tools/filesystem/localFilesystemPlugin.js +14 -0
  414. package/dist/plugins/tools/filesystem/localFilesystemPlugin.js.map +1 -0
  415. package/dist/plugins/tools/gitHistory/gitHistoryPlugin.d.ts +3 -0
  416. package/dist/plugins/tools/gitHistory/gitHistoryPlugin.d.ts.map +1 -0
  417. package/dist/plugins/tools/gitHistory/gitHistoryPlugin.js +9 -0
  418. package/dist/plugins/tools/gitHistory/gitHistoryPlugin.js.map +1 -0
  419. package/dist/plugins/tools/index.d.ts +3 -0
  420. package/dist/plugins/tools/index.d.ts.map +1 -0
  421. package/dist/plugins/tools/index.js +3 -0
  422. package/dist/plugins/tools/index.js.map +1 -0
  423. package/dist/plugins/tools/integrity/integrityPlugin.d.ts +3 -0
  424. package/dist/plugins/tools/integrity/integrityPlugin.d.ts.map +1 -0
  425. package/dist/plugins/tools/integrity/integrityPlugin.js +31 -0
  426. package/dist/plugins/tools/integrity/integrityPlugin.js.map +1 -0
  427. package/dist/plugins/tools/mcp/mcpPlugin.d.ts +3 -0
  428. package/dist/plugins/tools/mcp/mcpPlugin.d.ts.map +1 -0
  429. package/dist/plugins/tools/mcp/mcpPlugin.js +27 -0
  430. package/dist/plugins/tools/mcp/mcpPlugin.js.map +1 -0
  431. package/dist/plugins/tools/nodeDefaults.d.ts +13 -0
  432. package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -0
  433. package/dist/plugins/tools/nodeDefaults.js +31 -0
  434. package/dist/plugins/tools/nodeDefaults.js.map +1 -0
  435. package/dist/plugins/tools/orchestration/orchestrationPlugin.d.ts +3 -0
  436. package/dist/plugins/tools/orchestration/orchestrationPlugin.d.ts.map +1 -0
  437. package/dist/plugins/tools/orchestration/orchestrationPlugin.js +340 -0
  438. package/dist/plugins/tools/orchestration/orchestrationPlugin.js.map +1 -0
  439. package/dist/plugins/tools/registry.d.ts +22 -0
  440. package/dist/plugins/tools/registry.d.ts.map +1 -0
  441. package/dist/plugins/tools/registry.js +58 -0
  442. package/dist/plugins/tools/registry.js.map +1 -0
  443. package/dist/plugins/tools/search/localSearchPlugin.d.ts +3 -0
  444. package/dist/plugins/tools/search/localSearchPlugin.d.ts.map +1 -0
  445. package/dist/plugins/tools/search/localSearchPlugin.js +14 -0
  446. package/dist/plugins/tools/search/localSearchPlugin.js.map +1 -0
  447. package/dist/plugins/tools/skills/skillPlugin.d.ts +3 -0
  448. package/dist/plugins/tools/skills/skillPlugin.d.ts.map +1 -0
  449. package/dist/plugins/tools/skills/skillPlugin.js +27 -0
  450. package/dist/plugins/tools/skills/skillPlugin.js.map +1 -0
  451. package/dist/providers/baseProvider.d.ts +148 -0
  452. package/dist/providers/baseProvider.d.ts.map +1 -0
  453. package/dist/providers/baseProvider.js +284 -0
  454. package/dist/providers/baseProvider.js.map +1 -0
  455. package/dist/providers/openaiChatCompletionsProvider.d.ts +64 -0
  456. package/dist/providers/openaiChatCompletionsProvider.d.ts.map +1 -0
  457. package/dist/providers/openaiChatCompletionsProvider.js +1003 -0
  458. package/dist/providers/openaiChatCompletionsProvider.js.map +1 -0
  459. package/dist/providers/providerFactory.d.ts +22 -0
  460. package/dist/providers/providerFactory.d.ts.map +1 -0
  461. package/dist/providers/providerFactory.js +25 -0
  462. package/dist/providers/providerFactory.js.map +1 -0
  463. package/dist/providers/resilientProvider.d.ts +103 -0
  464. package/dist/providers/resilientProvider.d.ts.map +1 -0
  465. package/dist/providers/resilientProvider.js +462 -0
  466. package/dist/providers/resilientProvider.js.map +1 -0
  467. package/dist/runtime/agentController.d.ts +114 -0
  468. package/dist/runtime/agentController.d.ts.map +1 -0
  469. package/dist/runtime/agentController.js +707 -0
  470. package/dist/runtime/agentController.js.map +1 -0
  471. package/dist/runtime/agentHost.d.ts +61 -0
  472. package/dist/runtime/agentHost.d.ts.map +1 -0
  473. package/dist/runtime/agentHost.js +157 -0
  474. package/dist/runtime/agentHost.js.map +1 -0
  475. package/dist/runtime/agentSession.d.ts +45 -0
  476. package/dist/runtime/agentSession.d.ts.map +1 -0
  477. package/dist/runtime/agentSession.js +210 -0
  478. package/dist/runtime/agentSession.js.map +1 -0
  479. package/dist/runtime/agentWorkerPool.d.ts +167 -0
  480. package/dist/runtime/agentWorkerPool.d.ts.map +1 -0
  481. package/dist/runtime/agentWorkerPool.js +435 -0
  482. package/dist/runtime/agentWorkerPool.js.map +1 -0
  483. package/dist/runtime/node.d.ts +7 -0
  484. package/dist/runtime/node.d.ts.map +1 -0
  485. package/dist/runtime/node.js +25 -0
  486. package/dist/runtime/node.js.map +1 -0
  487. package/dist/runtime/universal.d.ts +18 -0
  488. package/dist/runtime/universal.d.ts.map +1 -0
  489. package/dist/runtime/universal.js +21 -0
  490. package/dist/runtime/universal.js.map +1 -0
  491. package/dist/shell/autoExecutor.d.ts +70 -0
  492. package/dist/shell/autoExecutor.d.ts.map +1 -0
  493. package/dist/shell/autoExecutor.js +320 -0
  494. package/dist/shell/autoExecutor.js.map +1 -0
  495. package/dist/shell/commandRegistry.d.ts +122 -0
  496. package/dist/shell/commandRegistry.d.ts.map +1 -0
  497. package/dist/shell/commandRegistry.js +398 -0
  498. package/dist/shell/commandRegistry.js.map +1 -0
  499. package/dist/shell/composableMessage.d.ts +178 -0
  500. package/dist/shell/composableMessage.d.ts.map +1 -0
  501. package/dist/shell/composableMessage.js +384 -0
  502. package/dist/shell/composableMessage.js.map +1 -0
  503. package/dist/shell/liveStatus.d.ts +27 -0
  504. package/dist/shell/liveStatus.d.ts.map +1 -0
  505. package/dist/shell/liveStatus.js +53 -0
  506. package/dist/shell/liveStatus.js.map +1 -0
  507. package/dist/shell/systemPrompt.d.ts +12 -0
  508. package/dist/shell/systemPrompt.d.ts.map +1 -0
  509. package/dist/shell/systemPrompt.js +16 -0
  510. package/dist/shell/systemPrompt.js.map +1 -0
  511. package/dist/shell/vimMode.d.ts +66 -0
  512. package/dist/shell/vimMode.d.ts.map +1 -0
  513. package/dist/shell/vimMode.js +435 -0
  514. package/dist/shell/vimMode.js.map +1 -0
  515. package/dist/tools/bashTools.d.ts +7 -0
  516. package/dist/tools/bashTools.d.ts.map +1 -0
  517. package/dist/tools/bashTools.js +773 -0
  518. package/dist/tools/bashTools.js.map +1 -0
  519. package/dist/tools/diffUtils.d.ts +43 -0
  520. package/dist/tools/diffUtils.d.ts.map +1 -0
  521. package/dist/tools/diffUtils.js +607 -0
  522. package/dist/tools/diffUtils.js.map +1 -0
  523. package/dist/tools/editTools.d.ts +29 -0
  524. package/dist/tools/editTools.d.ts.map +1 -0
  525. package/dist/tools/editTools.js +673 -0
  526. package/dist/tools/editTools.js.map +1 -0
  527. package/dist/tools/emailTools.d.ts +140 -0
  528. package/dist/tools/emailTools.d.ts.map +1 -0
  529. package/dist/tools/emailTools.js +793 -0
  530. package/dist/tools/emailTools.js.map +1 -0
  531. package/dist/tools/fileChangeTracker.d.ts +47 -0
  532. package/dist/tools/fileChangeTracker.d.ts.map +1 -0
  533. package/dist/tools/fileChangeTracker.js +154 -0
  534. package/dist/tools/fileChangeTracker.js.map +1 -0
  535. package/dist/tools/fileReadTracker.d.ts +69 -0
  536. package/dist/tools/fileReadTracker.d.ts.map +1 -0
  537. package/dist/tools/fileReadTracker.js +213 -0
  538. package/dist/tools/fileReadTracker.js.map +1 -0
  539. package/dist/tools/fileTools.d.ts +3 -0
  540. package/dist/tools/fileTools.d.ts.map +1 -0
  541. package/dist/tools/fileTools.js +333 -0
  542. package/dist/tools/fileTools.js.map +1 -0
  543. package/dist/tools/grepTools.d.ts +3 -0
  544. package/dist/tools/grepTools.d.ts.map +1 -0
  545. package/dist/tools/grepTools.js +128 -0
  546. package/dist/tools/grepTools.js.map +1 -0
  547. package/dist/tools/hitlTools.d.ts +7 -0
  548. package/dist/tools/hitlTools.d.ts.map +1 -0
  549. package/dist/tools/hitlTools.js +189 -0
  550. package/dist/tools/hitlTools.js.map +1 -0
  551. package/dist/tools/humanOpsTools.d.ts +3 -0
  552. package/dist/tools/humanOpsTools.d.ts.map +1 -0
  553. package/dist/tools/humanOpsTools.js +86 -0
  554. package/dist/tools/humanOpsTools.js.map +1 -0
  555. package/dist/tools/localExplore.d.ts +38 -0
  556. package/dist/tools/localExplore.d.ts.map +1 -0
  557. package/dist/tools/localExplore.js +30 -0
  558. package/dist/tools/localExplore.js.map +1 -0
  559. package/dist/tools/metaTools.d.ts +3 -0
  560. package/dist/tools/metaTools.d.ts.map +1 -0
  561. package/dist/tools/metaTools.js +148 -0
  562. package/dist/tools/metaTools.js.map +1 -0
  563. package/dist/tools/planningTools.d.ts +81 -0
  564. package/dist/tools/planningTools.d.ts.map +1 -0
  565. package/dist/tools/planningTools.js +370 -0
  566. package/dist/tools/planningTools.js.map +1 -0
  567. package/dist/tools/searchTools.d.ts +12 -0
  568. package/dist/tools/searchTools.d.ts.map +1 -0
  569. package/dist/tools/searchTools.js +363 -0
  570. package/dist/tools/searchTools.js.map +1 -0
  571. package/dist/tools/telemetryTools.d.ts +10 -0
  572. package/dist/tools/telemetryTools.d.ts.map +1 -0
  573. package/dist/tools/telemetryTools.js +9 -0
  574. package/dist/tools/telemetryTools.js.map +1 -0
  575. package/dist/tools/unifiedOps.d.ts +3 -0
  576. package/dist/tools/unifiedOps.d.ts.map +1 -0
  577. package/dist/tools/unifiedOps.js +57 -0
  578. package/dist/tools/unifiedOps.js.map +1 -0
  579. package/dist/tools/webTools.d.ts +26 -0
  580. package/dist/tools/webTools.d.ts.map +1 -0
  581. package/dist/tools/webTools.js +227 -0
  582. package/dist/tools/webTools.js.map +1 -0
  583. package/dist/ui/PromptController.d.ts +193 -0
  584. package/dist/ui/PromptController.d.ts.map +1 -0
  585. package/dist/ui/PromptController.js +394 -0
  586. package/dist/ui/PromptController.js.map +1 -0
  587. package/dist/ui/UnifiedUIRenderer.d.ts +843 -0
  588. package/dist/ui/UnifiedUIRenderer.d.ts.map +1 -0
  589. package/dist/ui/UnifiedUIRenderer.js +5711 -0
  590. package/dist/ui/UnifiedUIRenderer.js.map +1 -0
  591. package/dist/ui/animatedStatus.d.ts +140 -0
  592. package/dist/ui/animatedStatus.d.ts.map +1 -0
  593. package/dist/ui/animatedStatus.js +480 -0
  594. package/dist/ui/animatedStatus.js.map +1 -0
  595. package/dist/ui/animation/AnimationScheduler.d.ts +197 -0
  596. package/dist/ui/animation/AnimationScheduler.d.ts.map +1 -0
  597. package/dist/ui/animation/AnimationScheduler.js +440 -0
  598. package/dist/ui/animation/AnimationScheduler.js.map +1 -0
  599. package/dist/ui/codeHighlighter.d.ts +6 -0
  600. package/dist/ui/codeHighlighter.d.ts.map +1 -0
  601. package/dist/ui/codeHighlighter.js +855 -0
  602. package/dist/ui/codeHighlighter.js.map +1 -0
  603. package/dist/ui/designSystem.d.ts +26 -0
  604. package/dist/ui/designSystem.d.ts.map +1 -0
  605. package/dist/ui/designSystem.js +114 -0
  606. package/dist/ui/designSystem.js.map +1 -0
  607. package/dist/ui/errorFormatter.d.ts +64 -0
  608. package/dist/ui/errorFormatter.d.ts.map +1 -0
  609. package/dist/ui/errorFormatter.js +316 -0
  610. package/dist/ui/errorFormatter.js.map +1 -0
  611. package/dist/ui/globalWriteLock.d.ts +63 -0
  612. package/dist/ui/globalWriteLock.d.ts.map +1 -0
  613. package/dist/ui/globalWriteLock.js +173 -0
  614. package/dist/ui/globalWriteLock.js.map +1 -0
  615. package/dist/ui/index.d.ts +32 -0
  616. package/dist/ui/index.d.ts.map +1 -0
  617. package/dist/ui/index.js +54 -0
  618. package/dist/ui/index.js.map +1 -0
  619. package/dist/ui/interrupts/InterruptManager.d.ts +157 -0
  620. package/dist/ui/interrupts/InterruptManager.d.ts.map +1 -0
  621. package/dist/ui/interrupts/InterruptManager.js +501 -0
  622. package/dist/ui/interrupts/InterruptManager.js.map +1 -0
  623. package/dist/ui/layout.d.ts +27 -0
  624. package/dist/ui/layout.d.ts.map +1 -0
  625. package/dist/ui/layout.js +184 -0
  626. package/dist/ui/layout.js.map +1 -0
  627. package/dist/ui/outputMode.d.ts +44 -0
  628. package/dist/ui/outputMode.d.ts.map +1 -0
  629. package/dist/ui/outputMode.js +123 -0
  630. package/dist/ui/outputMode.js.map +1 -0
  631. package/dist/ui/overlay/OverlayManager.d.ts +105 -0
  632. package/dist/ui/overlay/OverlayManager.d.ts.map +1 -0
  633. package/dist/ui/overlay/OverlayManager.js +304 -0
  634. package/dist/ui/overlay/OverlayManager.js.map +1 -0
  635. package/dist/ui/premiumComponents.d.ts +54 -0
  636. package/dist/ui/premiumComponents.d.ts.map +1 -0
  637. package/dist/ui/premiumComponents.js +241 -0
  638. package/dist/ui/premiumComponents.js.map +1 -0
  639. package/dist/ui/richText.d.ts +13 -0
  640. package/dist/ui/richText.d.ts.map +1 -0
  641. package/dist/ui/richText.js +444 -0
  642. package/dist/ui/richText.js.map +1 -0
  643. package/dist/ui/telemetry/ResponseTracker.d.ts +22 -0
  644. package/dist/ui/telemetry/ResponseTracker.d.ts.map +1 -0
  645. package/dist/ui/telemetry/ResponseTracker.js +60 -0
  646. package/dist/ui/telemetry/ResponseTracker.js.map +1 -0
  647. package/dist/ui/telemetry/UITelemetry.d.ts +181 -0
  648. package/dist/ui/telemetry/UITelemetry.d.ts.map +1 -0
  649. package/dist/ui/telemetry/UITelemetry.js +446 -0
  650. package/dist/ui/telemetry/UITelemetry.js.map +1 -0
  651. package/dist/ui/textHighlighter.d.ts +83 -0
  652. package/dist/ui/textHighlighter.d.ts.map +1 -0
  653. package/dist/ui/textHighlighter.js +267 -0
  654. package/dist/ui/textHighlighter.js.map +1 -0
  655. package/dist/ui/theme.d.ts +364 -0
  656. package/dist/ui/theme.d.ts.map +1 -0
  657. package/dist/ui/theme.js +471 -0
  658. package/dist/ui/theme.js.map +1 -0
  659. package/dist/ui/toolDisplay.d.ts +221 -0
  660. package/dist/ui/toolDisplay.d.ts.map +1 -0
  661. package/dist/ui/toolDisplay.js +1654 -0
  662. package/dist/ui/toolDisplay.js.map +1 -0
  663. package/dist/ui/uiConstants.d.ts +288 -0
  664. package/dist/ui/uiConstants.d.ts.map +1 -0
  665. package/dist/ui/uiConstants.js +472 -0
  666. package/dist/ui/uiConstants.js.map +1 -0
  667. package/dist/utils/askUserPrompt.d.ts +21 -0
  668. package/dist/utils/askUserPrompt.d.ts.map +1 -0
  669. package/dist/utils/askUserPrompt.js +87 -0
  670. package/dist/utils/askUserPrompt.js.map +1 -0
  671. package/dist/utils/asyncUtils.d.ts +95 -0
  672. package/dist/utils/asyncUtils.d.ts.map +1 -0
  673. package/dist/utils/asyncUtils.js +286 -0
  674. package/dist/utils/asyncUtils.js.map +1 -0
  675. package/dist/utils/debugLogger.d.ts +6 -0
  676. package/dist/utils/debugLogger.d.ts.map +1 -0
  677. package/dist/utils/debugLogger.js +39 -0
  678. package/dist/utils/debugLogger.js.map +1 -0
  679. package/dist/utils/errorUtils.d.ts +12 -0
  680. package/dist/utils/errorUtils.d.ts.map +1 -0
  681. package/dist/utils/errorUtils.js +83 -0
  682. package/dist/utils/errorUtils.js.map +1 -0
  683. package/dist/utils/frontmatter.d.ts +10 -0
  684. package/dist/utils/frontmatter.d.ts.map +1 -0
  685. package/dist/utils/frontmatter.js +78 -0
  686. package/dist/utils/frontmatter.js.map +1 -0
  687. package/dist/utils/packageInfo.d.ts +14 -0
  688. package/dist/utils/packageInfo.d.ts.map +1 -0
  689. package/dist/utils/packageInfo.js +45 -0
  690. package/dist/utils/packageInfo.js.map +1 -0
  691. package/dist/utils/planFormatter.d.ts +34 -0
  692. package/dist/utils/planFormatter.d.ts.map +1 -0
  693. package/dist/utils/planFormatter.js +141 -0
  694. package/dist/utils/planFormatter.js.map +1 -0
  695. package/dist/utils/securityUtils.d.ts +132 -0
  696. package/dist/utils/securityUtils.d.ts.map +1 -0
  697. package/dist/utils/securityUtils.js +324 -0
  698. package/dist/utils/securityUtils.js.map +1 -0
  699. package/dist/utils/statusReporter.d.ts +6 -0
  700. package/dist/utils/statusReporter.d.ts.map +1 -0
  701. package/dist/utils/statusReporter.js +26 -0
  702. package/dist/utils/statusReporter.js.map +1 -0
  703. package/dist/workspace.d.ts +8 -0
  704. package/dist/workspace.d.ts.map +1 -0
  705. package/dist/workspace.js +135 -0
  706. package/dist/workspace.js.map +1 -0
  707. package/dist/workspace.validator.d.ts +49 -0
  708. package/dist/workspace.validator.d.ts.map +1 -0
  709. package/dist/workspace.validator.js +215 -0
  710. package/dist/workspace.validator.js.map +1 -0
  711. package/package.json +121 -0
@@ -0,0 +1,707 @@
1
+ import { createNodeRuntime } from './node.js';
2
+ import { AGENT_CONTRACT_VERSION } from '../contracts/v1/agent.js';
3
+ import { logDebug } from '../utils/debugLogger.js';
4
+ import { isFallbackEligibleError, getFallbackReason } from '../providers/resilientProvider.js';
5
+ import { getConfiguredProviders, getLatestModelForProvider } from '../core/modelDiscovery.js';
6
+ class EventStream {
7
+ queue = [];
8
+ pending = null;
9
+ closed = false;
10
+ failure = null;
11
+ push(value) {
12
+ if (this.closed || this.failure) {
13
+ return;
14
+ }
15
+ if (this.pending) {
16
+ this.pending.resolve({ value, done: false });
17
+ this.pending = null;
18
+ return;
19
+ }
20
+ this.queue.push(value);
21
+ }
22
+ close() {
23
+ if (this.closed || this.failure) {
24
+ return;
25
+ }
26
+ this.closed = true;
27
+ if (this.pending) {
28
+ this.pending.resolve({ value: undefined, done: true });
29
+ this.pending = null;
30
+ }
31
+ }
32
+ fail(error) {
33
+ if (this.closed || this.failure) {
34
+ return;
35
+ }
36
+ this.failure = error;
37
+ this.closed = true; // Mark as closed to prevent new pending promises
38
+ if (this.pending) {
39
+ this.pending.reject(error);
40
+ this.pending = null;
41
+ }
42
+ }
43
+ next() {
44
+ if (this.queue.length) {
45
+ const value = this.queue.shift();
46
+ return Promise.resolve({ value, done: false });
47
+ }
48
+ if (this.failure) {
49
+ const error = this.failure;
50
+ this.failure = null;
51
+ return Promise.reject(error);
52
+ }
53
+ if (this.closed) {
54
+ return Promise.resolve({ value: undefined, done: true });
55
+ }
56
+ return new Promise((resolve, reject) => {
57
+ this.pending = { resolve, reject };
58
+ });
59
+ }
60
+ return() {
61
+ this.close();
62
+ return Promise.resolve({ value: undefined, done: true });
63
+ }
64
+ throw(error) {
65
+ const err = error instanceof Error ? error : new Error(String(error));
66
+ this.fail(err);
67
+ return Promise.reject(err);
68
+ }
69
+ [Symbol.asyncIterator]() {
70
+ return this;
71
+ }
72
+ }
73
+ function mergeToolObservers(primary, secondary) {
74
+ if (!secondary) {
75
+ return primary;
76
+ }
77
+ return {
78
+ onToolStart(call) {
79
+ primary.onToolStart?.(call);
80
+ secondary.onToolStart?.(call);
81
+ },
82
+ onToolResult(call, output) {
83
+ primary.onToolResult?.(call, output);
84
+ secondary.onToolResult?.(call, output);
85
+ },
86
+ onToolProgress(call, progress) {
87
+ primary.onToolProgress?.(call, progress);
88
+ secondary.onToolProgress?.(call, progress);
89
+ },
90
+ onToolError(call, error) {
91
+ primary.onToolError?.(call, error);
92
+ secondary.onToolError?.(call, error);
93
+ },
94
+ onCacheHit(call) {
95
+ primary.onCacheHit?.(call);
96
+ secondary.onCacheHit?.(call);
97
+ },
98
+ onToolWarning(call, warning) {
99
+ primary.onToolWarning?.(call, warning);
100
+ secondary.onToolWarning?.(call, warning);
101
+ },
102
+ };
103
+ }
104
+ function createControllerToolObserver(ref) {
105
+ const emit = (event) => {
106
+ ref.current?.push(event);
107
+ };
108
+ const timestamp = () => Date.now();
109
+ return {
110
+ onToolStart(call) {
111
+ emit({
112
+ type: 'tool.start',
113
+ timestamp: timestamp(),
114
+ toolName: call.name,
115
+ toolCallId: call.id,
116
+ parameters: { ...call.arguments },
117
+ });
118
+ },
119
+ onToolResult(call, output) {
120
+ emit({
121
+ type: 'tool.complete',
122
+ timestamp: timestamp(),
123
+ toolName: call.name,
124
+ toolCallId: call.id,
125
+ result: output,
126
+ });
127
+ },
128
+ onToolProgress(call, progress) {
129
+ // Only emit progress for bash tools (live terminal output)
130
+ if (call.name === 'execute_bash' || call.name === 'Bash') {
131
+ emit({
132
+ type: 'tool.progress',
133
+ timestamp: timestamp(),
134
+ toolName: call.name,
135
+ toolCallId: call.id,
136
+ line: progress.message ?? '',
137
+ lineNumber: progress.current,
138
+ isStderr: progress.message?.startsWith('stderr:') ?? false,
139
+ });
140
+ }
141
+ },
142
+ onToolError(call, error) {
143
+ emit({
144
+ type: 'tool.error',
145
+ timestamp: timestamp(),
146
+ toolName: call.name,
147
+ toolCallId: call.id,
148
+ error,
149
+ });
150
+ },
151
+ };
152
+ }
153
+ export async function createAgentController(options, additionalObserver) {
154
+ const sinkRef = { current: null };
155
+ const observer = createControllerToolObserver(sinkRef);
156
+ const runtime = await createNodeRuntime({
157
+ profile: options.profile,
158
+ workspaceContext: options.workspaceContext,
159
+ workingDir: options.workingDir,
160
+ env: options.env,
161
+ toolObserver: mergeToolObservers(observer, additionalObserver),
162
+ additionalModules: options.modules,
163
+ });
164
+ return new AgentController({ runtime, sinkRef, externalCallbacks: options.callbacks });
165
+ }
166
+ export class AgentController {
167
+ session;
168
+ sinkRef;
169
+ externalCallbacks;
170
+ activeSink = null;
171
+ agent = null;
172
+ cachedHistory = [];
173
+ selection;
174
+ /** Set of providers that have failed with non-retryable errors in this session */
175
+ failedProviders = new Set();
176
+ /** Maximum fallback attempts per send() call */
177
+ static MAX_FALLBACK_ATTEMPTS = 3;
178
+ activeTimeout = null;
179
+ inflightReject = null;
180
+ constructor(dependencies) {
181
+ this.session = dependencies.runtime.session;
182
+ this.sinkRef = dependencies.sinkRef;
183
+ this.externalCallbacks = dependencies.externalCallbacks;
184
+ this.selection = this.buildInitialSelection();
185
+ }
186
+ buildInitialSelection() {
187
+ const config = this.session.profileConfig;
188
+ return {
189
+ provider: config.provider,
190
+ model: config.model,
191
+ temperature: config.temperature,
192
+ maxTokens: config.maxTokens,
193
+ systemPrompt: config.systemPrompt,
194
+ };
195
+ }
196
+ ensureAgent() {
197
+ if (this.agent) {
198
+ return this.agent;
199
+ }
200
+ const agent = this.session.createAgent(this.selection, this.createAgentCallbacks(), undefined, {
201
+ explainEdits: true,
202
+ });
203
+ if (this.cachedHistory.length) {
204
+ agent.loadHistory(this.cachedHistory);
205
+ }
206
+ this.agent = agent;
207
+ return agent;
208
+ }
209
+ createAgentCallbacks() {
210
+ return {
211
+ onRequestReceived: (requestPreview) => {
212
+ // Signal to UI that request was received - let model handle natural acknowledgment
213
+ // Don't emit verbatim echo - it's redundant and the model's response should acknowledge contextually
214
+ this.externalCallbacks?.onRequestReceived?.(requestPreview);
215
+ },
216
+ onAssistantMessage: (content, metadata) => {
217
+ this.handleAssistantMessage(content, metadata);
218
+ this.externalCallbacks?.onAssistantMessage?.(content, metadata);
219
+ },
220
+ onStreamChunk: (chunk, type) => {
221
+ if (type === 'content') {
222
+ // Content chunks go to message.delta for streaming display
223
+ this.emitDelta(chunk, false);
224
+ }
225
+ else if (type === 'reasoning') {
226
+ // Reasoning chunks go to reasoning event for thought display
227
+ this.emitReasoning(chunk);
228
+ }
229
+ // Pass all chunks to external callbacks
230
+ this.externalCallbacks?.onStreamChunk?.(chunk, type);
231
+ },
232
+ onUsage: (usage) => {
233
+ this.emitUsage(usage);
234
+ this.externalCallbacks?.onUsage?.(usage);
235
+ },
236
+ onContextPruned: (removedCount, stats) => {
237
+ this.externalCallbacks?.onContextPruned?.(removedCount, stats);
238
+ },
239
+ onContextSquishing: (message) => {
240
+ this.externalCallbacks?.onContextSquishing?.(message);
241
+ },
242
+ onContextRecovery: (attempt, maxAttempts, message) => {
243
+ this.externalCallbacks?.onContextRecovery?.(attempt, maxAttempts, message);
244
+ },
245
+ onContinueAfterRecovery: () => {
246
+ this.externalCallbacks?.onContinueAfterRecovery?.();
247
+ },
248
+ onMultilinePaste: (summary, metadata) => {
249
+ this.externalCallbacks?.onMultilinePaste?.(summary, metadata);
250
+ },
251
+ onEditExplanation: (payload) => {
252
+ this.handleEditExplanation(payload);
253
+ this.externalCallbacks?.onEditExplanation?.(payload);
254
+ },
255
+ onRetrying: (attempt, maxAttempts, error) => {
256
+ // Emit delta event to show retry status
257
+ this.emitDelta(`[Retrying ${attempt}/${maxAttempts}: ${error.message}]`, false);
258
+ this.externalCallbacks?.onRetrying?.(attempt, maxAttempts, error);
259
+ },
260
+ // onBeforeFirstToolCall not needed - model's reasoning is now emitted as thought events
261
+ };
262
+ }
263
+ /**
264
+ * Check if content looks like garbage/leaked reasoning fragments.
265
+ * Returns true if the content should be filtered out.
266
+ * NOTE: Keep this minimal to avoid suppressing legitimate short responses.
267
+ */
268
+ isGarbageContent(content) {
269
+ const trimmed = content.trim();
270
+ if (!trimmed)
271
+ return true;
272
+ // Only filter pure punctuation/markdown artifacts
273
+ if (/^[)\]}>*`'".:,!?|│┃─━═\s]+$/.test(trimmed))
274
+ return true;
275
+ // Just newlines or whitespace
276
+ if (/^[\s\n\r]+$/.test(trimmed))
277
+ return true;
278
+ // Removed aggressive short fragment filtering - was suppressing legitimate content
279
+ return false;
280
+ }
281
+ emitDelta(content, isFinal) {
282
+ if (!content?.trim()) {
283
+ return;
284
+ }
285
+ // Filter out garbage/leaked reasoning fragments
286
+ if (this.isGarbageContent(content)) {
287
+ return;
288
+ }
289
+ this.activeSink?.push({
290
+ type: 'message.delta',
291
+ timestamp: Date.now(),
292
+ content,
293
+ isFinal,
294
+ });
295
+ }
296
+ emitError(message) {
297
+ this.activeSink?.push({
298
+ type: 'error',
299
+ timestamp: Date.now(),
300
+ error: message,
301
+ });
302
+ }
303
+ emitReasoning(content) {
304
+ if (!content?.trim()) {
305
+ return;
306
+ }
307
+ // Filter out garbage/leaked formatting fragments in reasoning too
308
+ if (this.isGarbageContent(content)) {
309
+ return;
310
+ }
311
+ this.activeSink?.push({
312
+ type: 'reasoning',
313
+ timestamp: Date.now(),
314
+ content,
315
+ });
316
+ }
317
+ emitUsage(usage) {
318
+ if (!usage) {
319
+ return;
320
+ }
321
+ this.activeSink?.push({
322
+ type: 'usage',
323
+ timestamp: Date.now(),
324
+ inputTokens: usage.inputTokens,
325
+ outputTokens: usage.outputTokens,
326
+ totalTokens: usage.totalTokens,
327
+ });
328
+ }
329
+ handleEditExplanation(payload) {
330
+ if (!this.activeSink) {
331
+ return;
332
+ }
333
+ if (!payload.explanation?.trim()) {
334
+ return;
335
+ }
336
+ this.activeSink.push({
337
+ type: 'edit.explanation',
338
+ timestamp: Date.now(),
339
+ content: payload.explanation,
340
+ files: payload.files,
341
+ toolName: payload.toolName,
342
+ toolCallId: payload.toolCallId,
343
+ });
344
+ }
345
+ handleAssistantMessage(content, metadata) {
346
+ if (!this.activeSink) {
347
+ return;
348
+ }
349
+ if (!content.trim()) {
350
+ return;
351
+ }
352
+ if (metadata.suppressDisplay) {
353
+ return;
354
+ }
355
+ if (!metadata.isFinal) {
356
+ this.emitDelta(content, false);
357
+ return;
358
+ }
359
+ const elapsedMs = metadata.elapsedMs ?? 0;
360
+ this.activeSink.push({
361
+ type: 'message.complete',
362
+ timestamp: Date.now(),
363
+ content,
364
+ elapsedMs,
365
+ });
366
+ this.emitUsage(metadata.usage ?? null);
367
+ }
368
+ updateCachedHistory() {
369
+ if (this.agent) {
370
+ this.cachedHistory = this.agent.getHistory();
371
+ }
372
+ }
373
+ cancel(reason) {
374
+ if (!this.activeSink) {
375
+ return;
376
+ }
377
+ const error = new Error(reason ?? 'Run cancelled');
378
+ try {
379
+ this.agent?.cancel?.(reason);
380
+ }
381
+ catch {
382
+ // ignore cancellation errors
383
+ }
384
+ this.rejectInflight(error);
385
+ this.activeSink.fail(error);
386
+ this.activeSink = null;
387
+ this.sinkRef.current = null;
388
+ this.clearActiveTimeout();
389
+ }
390
+ clearActiveTimeout() {
391
+ if (this.activeTimeout) {
392
+ clearTimeout(this.activeTimeout);
393
+ this.activeTimeout = null;
394
+ }
395
+ }
396
+ rejectInflight(error) {
397
+ if (this.inflightReject) {
398
+ this.inflightReject(error);
399
+ this.inflightReject = null;
400
+ }
401
+ }
402
+ async *send(message) {
403
+ if (this.activeSink) {
404
+ throw new Error('Agent runtime is already processing a message. Please wait for the current run to finish.');
405
+ }
406
+ // Reset failed providers at the start of each new message
407
+ // (providers might have recovered, quotas might have reset, etc.)
408
+ this.failedProviders.clear();
409
+ let fallbackAttempts = 0;
410
+ // Retry loop for fallback handling
411
+ while (fallbackAttempts < AgentController.MAX_FALLBACK_ATTEMPTS) {
412
+ const agent = this.ensureAgent();
413
+ const sink = new EventStream();
414
+ this.activeSink = sink;
415
+ this.sinkRef.current = sink;
416
+ sink.push({ type: 'message.start', timestamp: Date.now() });
417
+ const timeoutMsRaw = process.env['AGI_AGENT_RUN_TIMEOUT_MS'];
418
+ const timeoutMs = timeoutMsRaw ? Number(timeoutMsRaw) : NaN;
419
+ if (!Number.isNaN(timeoutMs) && timeoutMs > 0 && timeoutMs < 24 * 60 * 60 * 1000) {
420
+ // Only set timeout if less than 24 hours (practically infinite)
421
+ this.activeTimeout = setTimeout(() => {
422
+ const err = new Error(`Run timed out after ${timeoutMs}ms`);
423
+ this.rejectInflight(err);
424
+ sink.fail(err);
425
+ try {
426
+ this.agent?.cancel?.('timeout');
427
+ }
428
+ catch {
429
+ // ignore
430
+ }
431
+ }, timeoutMs);
432
+ }
433
+ else {
434
+ // Set a very large timeout (24 hours) as fallback
435
+ this.activeTimeout = setTimeout(() => {
436
+ const err = new Error(`Run timed out after 24h`);
437
+ this.rejectInflight(err);
438
+ sink.fail(err);
439
+ try {
440
+ this.agent?.cancel?.('timeout');
441
+ }
442
+ catch {
443
+ // ignore
444
+ }
445
+ }, 24 * 60 * 60 * 1000);
446
+ }
447
+ let caughtError = null;
448
+ let fallbackSucceeded = false;
449
+ let cancelRun = null;
450
+ const cancelPromise = new Promise((_, reject) => {
451
+ cancelRun = reject;
452
+ });
453
+ this.inflightReject = (error) => {
454
+ cancelRun?.(error);
455
+ };
456
+ const run = Promise.race([
457
+ agent.send(message, true),
458
+ cancelPromise,
459
+ ])
460
+ .then(() => {
461
+ this.updateCachedHistory();
462
+ this.clearActiveTimeout();
463
+ sink.close();
464
+ })
465
+ .catch(async (error) => {
466
+ const errorObj = error instanceof Error ? error : new Error(String(error));
467
+ caughtError = errorObj;
468
+ this.clearActiveTimeout();
469
+ const cancelled = /cancel/i.test(errorObj.message);
470
+ const timedOut = /timed out/i.test(errorObj.message);
471
+ if (cancelled || timedOut) {
472
+ this.emitError(errorObj.message);
473
+ sink.fail(errorObj);
474
+ return;
475
+ }
476
+ // Check if this error is eligible for fallback
477
+ if (isFallbackEligibleError(error) && fallbackAttempts < AgentController.MAX_FALLBACK_ATTEMPTS - 1) {
478
+ logDebug(`[AgentController] Fallback-eligible error detected: ${errorObj.message}`);
479
+ fallbackSucceeded = await this.attemptFallback(errorObj);
480
+ if (fallbackSucceeded) {
481
+ // Close this sink without error - we'll retry with new provider
482
+ sink.close();
483
+ return;
484
+ }
485
+ }
486
+ // Not fallback-eligible or no fallback available - emit error and fail
487
+ this.emitError(errorObj.message);
488
+ sink.fail(errorObj);
489
+ })
490
+ .finally(() => {
491
+ this.clearActiveTimeout();
492
+ this.inflightReject = null;
493
+ if (this.activeSink === sink) {
494
+ this.activeSink = null;
495
+ this.sinkRef.current = null;
496
+ }
497
+ });
498
+ try {
499
+ for await (const event of sink) {
500
+ yield event;
501
+ }
502
+ }
503
+ finally {
504
+ await run;
505
+ }
506
+ // If we successfully fell back, increment counter and continue loop
507
+ if (fallbackSucceeded && caughtError) {
508
+ fallbackAttempts++;
509
+ logDebug(`[AgentController] Retrying with fallback provider (attempt ${fallbackAttempts}/${AgentController.MAX_FALLBACK_ATTEMPTS})`);
510
+ continue;
511
+ }
512
+ // No fallback happened or it failed - exit loop
513
+ break;
514
+ }
515
+ }
516
+ async switchModel(config) {
517
+ this.updateCachedHistory();
518
+ this.agent = null;
519
+ this.selection = {
520
+ provider: config.provider,
521
+ model: config.model,
522
+ temperature: config.temperature,
523
+ maxTokens: config.maxTokens,
524
+ systemPrompt: this.selection.systemPrompt,
525
+ };
526
+ this.session.updateToolContext(this.selection);
527
+ }
528
+ getCapabilities() {
529
+ const tools = this.session.toolRuntime.listProviderTools();
530
+ const manifestTools = tools.map((tool) => ({
531
+ name: tool.name,
532
+ description: tool.description,
533
+ category: 'general',
534
+ }));
535
+ return {
536
+ contractVersion: AGENT_CONTRACT_VERSION,
537
+ profile: this.session.profile,
538
+ model: this.toModelConfig(this.selection),
539
+ tools: manifestTools,
540
+ features: ['streaming', 'tool-calls'],
541
+ };
542
+ }
543
+ registerToolSuite(suiteId, suite) {
544
+ this.session.toolRuntime.registerSuite({ ...suite, id: suiteId });
545
+ }
546
+ unregisterToolSuite(suiteId) {
547
+ this.session.toolRuntime.unregisterSuite(suiteId);
548
+ }
549
+ getHistory() {
550
+ if (this.agent) {
551
+ return this.agent.getHistory();
552
+ }
553
+ return [...this.cachedHistory];
554
+ }
555
+ clearHistory() {
556
+ this.cachedHistory = [];
557
+ this.agent?.clearHistory();
558
+ }
559
+ /**
560
+ * Check if the controller is currently processing a message.
561
+ */
562
+ isProcessing() {
563
+ return this.activeSink !== null;
564
+ }
565
+ /**
566
+ * Force-clear any lingering active state. Use this before starting a new
567
+ * operation (like attack tournament) to ensure clean state.
568
+ * This will close any active sink without waiting for completion.
569
+ */
570
+ forceReset() {
571
+ if (this.activeSink) {
572
+ try {
573
+ this.activeSink.close();
574
+ }
575
+ catch {
576
+ // Ignore errors - sink may already be closed
577
+ }
578
+ this.activeSink = null;
579
+ this.sinkRef.current = null;
580
+ }
581
+ }
582
+ /**
583
+ * Sanitize history by fixing orphaned tool calls (tool_calls without corresponding tool results).
584
+ * This can happen when a run is interrupted mid-tool-execution.
585
+ * We add placeholder error results for any orphaned tool calls to keep history valid.
586
+ */
587
+ sanitizeHistory() {
588
+ const history = this.getHistory();
589
+ if (history.length === 0)
590
+ return;
591
+ const sanitized = [];
592
+ for (let i = 0; i < history.length; i++) {
593
+ const msg = history[i];
594
+ sanitized.push(msg);
595
+ // Check if this is an assistant message with tool_calls
596
+ if (msg.role === 'assistant' && msg.toolCalls?.length) {
597
+ // Look ahead for tool results
598
+ const toolCallIds = new Set(msg.toolCalls.map(tc => tc.id));
599
+ let nextIdx = i + 1;
600
+ // Consume any following tool messages
601
+ while (nextIdx < history.length && history[nextIdx].role === 'tool') {
602
+ const toolMsg = history[nextIdx];
603
+ if (toolMsg.toolCallId) {
604
+ toolCallIds.delete(toolMsg.toolCallId);
605
+ }
606
+ sanitized.push(history[nextIdx]);
607
+ nextIdx++;
608
+ }
609
+ // Add placeholder results for any orphaned tool calls
610
+ for (const orphanedId of toolCallIds) {
611
+ const orphanedCall = msg.toolCalls.find(tc => tc.id === orphanedId);
612
+ const toolName = orphanedCall?.name ?? 'unknown';
613
+ sanitized.push({
614
+ role: 'tool',
615
+ name: toolName,
616
+ toolCallId: orphanedId,
617
+ content: `[Interrupted: ${toolName} execution was cancelled]`,
618
+ });
619
+ }
620
+ // Skip the tool messages we already processed
621
+ i = nextIdx - 1;
622
+ }
623
+ }
624
+ // Update both cached history and agent history
625
+ this.cachedHistory = sanitized;
626
+ if (this.agent) {
627
+ this.agent.loadHistory(sanitized);
628
+ }
629
+ }
630
+ toModelConfig(selection) {
631
+ return {
632
+ provider: selection.provider,
633
+ model: selection.model,
634
+ temperature: selection.temperature,
635
+ maxTokens: selection.maxTokens,
636
+ };
637
+ }
638
+ /**
639
+ * Find the next available provider for fallback.
640
+ * Excludes providers that have already failed in this session.
641
+ */
642
+ findFallbackProvider() {
643
+ const configured = getConfiguredProviders();
644
+ const currentProvider = this.selection.provider;
645
+ // Provider preference order (excluding current and failed)
646
+ // deepseek-reasoner is default, grok (xai) is backup
647
+ const preferenceOrder = ['deepseek', 'xai'];
648
+ for (const providerId of preferenceOrder) {
649
+ // Skip current provider and already failed providers
650
+ if (providerId === currentProvider || this.failedProviders.has(providerId)) {
651
+ continue;
652
+ }
653
+ // Check if this provider is configured
654
+ const provider = configured.find(p => p.id === providerId);
655
+ if (provider) {
656
+ const model = getLatestModelForProvider(providerId);
657
+ if (model) {
658
+ return { provider: providerId, model };
659
+ }
660
+ }
661
+ }
662
+ return null;
663
+ }
664
+ /**
665
+ * Emit a provider fallback event
666
+ */
667
+ emitFallbackEvent(fromProvider, fromModel, toProvider, toModel, reason, error) {
668
+ this.activeSink?.push({
669
+ type: 'provider.fallback',
670
+ timestamp: Date.now(),
671
+ fromProvider,
672
+ fromModel,
673
+ toProvider,
674
+ toModel,
675
+ reason,
676
+ error,
677
+ });
678
+ }
679
+ /**
680
+ * Attempt to switch to a fallback provider
681
+ */
682
+ async attemptFallback(error) {
683
+ const fallback = this.findFallbackProvider();
684
+ if (!fallback) {
685
+ logDebug('[AgentController] No fallback provider available');
686
+ return false;
687
+ }
688
+ const reason = getFallbackReason(error);
689
+ const fromProvider = this.selection.provider;
690
+ const fromModel = this.selection.model;
691
+ // Mark current provider as failed
692
+ this.failedProviders.add(fromProvider);
693
+ // Emit fallback event
694
+ this.emitFallbackEvent(fromProvider, fromModel, fallback.provider, fallback.model, reason, error.message);
695
+ logDebug(`[AgentController] Falling back from ${fromProvider}/${fromModel} to ${fallback.provider}/${fallback.model}: ${reason}`);
696
+ // Switch to fallback provider
697
+ await this.switchModel({
698
+ provider: fallback.provider,
699
+ model: fallback.model,
700
+ });
701
+ return true;
702
+ }
703
+ getToolSuites() {
704
+ return this.session.toolSuites;
705
+ }
706
+ }
707
+ //# sourceMappingURL=agentController.js.map