@burtson-labs/stealth-core-runtime 1.4.7

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 (415) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +46 -0
  3. package/dist/banditEngineProvider.d.ts +48 -0
  4. package/dist/banditEngineProvider.d.ts.map +1 -0
  5. package/dist/banditEngineProvider.js +1021 -0
  6. package/dist/banditEngineProvider.js.map +1 -0
  7. package/dist/embeddingCache.d.ts +23 -0
  8. package/dist/embeddingCache.d.ts.map +1 -0
  9. package/dist/embeddingCache.js +196 -0
  10. package/dist/embeddingCache.js.map +1 -0
  11. package/dist/embeddingClient.d.ts +35 -0
  12. package/dist/embeddingClient.d.ts.map +1 -0
  13. package/dist/embeddingClient.js +162 -0
  14. package/dist/embeddingClient.js.map +1 -0
  15. package/dist/executorAgent.d.ts +7 -0
  16. package/dist/executorAgent.d.ts.map +1 -0
  17. package/dist/executorAgent.js +95 -0
  18. package/dist/executorAgent.js.map +1 -0
  19. package/dist/extensionSystemPrompt.d.ts +80 -0
  20. package/dist/extensionSystemPrompt.d.ts.map +1 -0
  21. package/dist/extensionSystemPrompt.js +208 -0
  22. package/dist/extensionSystemPrompt.js.map +1 -0
  23. package/dist/gatewaySearchAdapter.d.ts +69 -0
  24. package/dist/gatewaySearchAdapter.d.ts.map +1 -0
  25. package/dist/gatewaySearchAdapter.js +131 -0
  26. package/dist/gatewaySearchAdapter.js.map +1 -0
  27. package/dist/goalInference.d.ts +26 -0
  28. package/dist/goalInference.d.ts.map +1 -0
  29. package/dist/goalInference.js +605 -0
  30. package/dist/goalInference.js.map +1 -0
  31. package/dist/hostTypes.d.ts +86 -0
  32. package/dist/hostTypes.d.ts.map +1 -0
  33. package/dist/hostTypes.js +3 -0
  34. package/dist/hostTypes.js.map +1 -0
  35. package/dist/index.d.ts +37 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +83 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/internalTypes.d.ts +16 -0
  40. package/dist/internalTypes.d.ts.map +1 -0
  41. package/dist/internalTypes.js +20 -0
  42. package/dist/internalTypes.js.map +1 -0
  43. package/dist/ollamaEmbeddingClient.d.ts +45 -0
  44. package/dist/ollamaEmbeddingClient.d.ts.map +1 -0
  45. package/dist/ollamaEmbeddingClient.js +143 -0
  46. package/dist/ollamaEmbeddingClient.js.map +1 -0
  47. package/dist/pdfjsShim.d.ts +2 -0
  48. package/dist/pdfjsShim.d.ts.map +1 -0
  49. package/dist/pdfjsShim.js +80 -0
  50. package/dist/pdfjsShim.js.map +1 -0
  51. package/dist/runtime/actionRuntime.d.ts +13 -0
  52. package/dist/runtime/actionRuntime.d.ts.map +1 -0
  53. package/dist/runtime/actionRuntime.js +15 -0
  54. package/dist/runtime/actionRuntime.js.map +1 -0
  55. package/dist/runtime/actionServices.d.ts +72 -0
  56. package/dist/runtime/actionServices.d.ts.map +1 -0
  57. package/dist/runtime/actionServices.js +53 -0
  58. package/dist/runtime/actionServices.js.map +1 -0
  59. package/dist/runtime/adapters/connectorBus.d.ts +9 -0
  60. package/dist/runtime/adapters/connectorBus.d.ts.map +1 -0
  61. package/dist/runtime/adapters/connectorBus.js +20 -0
  62. package/dist/runtime/adapters/connectorBus.js.map +1 -0
  63. package/dist/runtime/adapters/fsAdapter.d.ts +6 -0
  64. package/dist/runtime/adapters/fsAdapter.d.ts.map +1 -0
  65. package/dist/runtime/adapters/fsAdapter.js +144 -0
  66. package/dist/runtime/adapters/fsAdapter.js.map +1 -0
  67. package/dist/runtime/adapters/llmAdapter.d.ts +4 -0
  68. package/dist/runtime/adapters/llmAdapter.d.ts.map +1 -0
  69. package/dist/runtime/adapters/llmAdapter.js +12 -0
  70. package/dist/runtime/adapters/llmAdapter.js.map +1 -0
  71. package/dist/runtime/adapters/shellAdapter.d.ts +6 -0
  72. package/dist/runtime/adapters/shellAdapter.d.ts.map +1 -0
  73. package/dist/runtime/adapters/shellAdapter.js +118 -0
  74. package/dist/runtime/adapters/shellAdapter.js.map +1 -0
  75. package/dist/runtime/additionalWrites.d.ts +22 -0
  76. package/dist/runtime/additionalWrites.d.ts.map +1 -0
  77. package/dist/runtime/additionalWrites.js +148 -0
  78. package/dist/runtime/additionalWrites.js.map +1 -0
  79. package/dist/runtime/artifactManager.d.ts +32 -0
  80. package/dist/runtime/artifactManager.d.ts.map +1 -0
  81. package/dist/runtime/artifactManager.js +154 -0
  82. package/dist/runtime/artifactManager.js.map +1 -0
  83. package/dist/runtime/autoHealer.d.ts +27 -0
  84. package/dist/runtime/autoHealer.d.ts.map +1 -0
  85. package/dist/runtime/autoHealer.js +583 -0
  86. package/dist/runtime/autoHealer.js.map +1 -0
  87. package/dist/runtime/changeTracker.d.ts +20 -0
  88. package/dist/runtime/changeTracker.d.ts.map +1 -0
  89. package/dist/runtime/changeTracker.js +147 -0
  90. package/dist/runtime/changeTracker.js.map +1 -0
  91. package/dist/runtime/contextBuilder.d.ts +85 -0
  92. package/dist/runtime/contextBuilder.d.ts.map +1 -0
  93. package/dist/runtime/contextBuilder.js +159 -0
  94. package/dist/runtime/contextBuilder.js.map +1 -0
  95. package/dist/runtime/coreRuntime.d.ts +7 -0
  96. package/dist/runtime/coreRuntime.d.ts.map +1 -0
  97. package/dist/runtime/coreRuntime.js +173 -0
  98. package/dist/runtime/coreRuntime.js.map +1 -0
  99. package/dist/runtime/createStealthRuntime.d.ts +4 -0
  100. package/dist/runtime/createStealthRuntime.d.ts.map +1 -0
  101. package/dist/runtime/createStealthRuntime.js +514 -0
  102. package/dist/runtime/createStealthRuntime.js.map +1 -0
  103. package/dist/runtime/diagnostics.d.ts +53 -0
  104. package/dist/runtime/diagnostics.d.ts.map +1 -0
  105. package/dist/runtime/diagnostics.js +396 -0
  106. package/dist/runtime/diagnostics.js.map +1 -0
  107. package/dist/runtime/diagnosticsServices.d.ts +51 -0
  108. package/dist/runtime/diagnosticsServices.d.ts.map +1 -0
  109. package/dist/runtime/diagnosticsServices.js +46 -0
  110. package/dist/runtime/diagnosticsServices.js.map +1 -0
  111. package/dist/runtime/diffManager.d.ts +20 -0
  112. package/dist/runtime/diffManager.d.ts.map +1 -0
  113. package/dist/runtime/diffManager.js +172 -0
  114. package/dist/runtime/diffManager.js.map +1 -0
  115. package/dist/runtime/diffPresenter.d.ts +8 -0
  116. package/dist/runtime/diffPresenter.d.ts.map +1 -0
  117. package/dist/runtime/diffPresenter.js +57 -0
  118. package/dist/runtime/diffPresenter.js.map +1 -0
  119. package/dist/runtime/embeddingClientResolver.d.ts +14 -0
  120. package/dist/runtime/embeddingClientResolver.d.ts.map +1 -0
  121. package/dist/runtime/embeddingClientResolver.js +54 -0
  122. package/dist/runtime/embeddingClientResolver.js.map +1 -0
  123. package/dist/runtime/embeddingManager.d.ts +22 -0
  124. package/dist/runtime/embeddingManager.d.ts.map +1 -0
  125. package/dist/runtime/embeddingManager.js +224 -0
  126. package/dist/runtime/embeddingManager.js.map +1 -0
  127. package/dist/runtime/eventBus.d.ts +7 -0
  128. package/dist/runtime/eventBus.d.ts.map +1 -0
  129. package/dist/runtime/eventBus.js +28 -0
  130. package/dist/runtime/eventBus.js.map +1 -0
  131. package/dist/runtime/executorServices.d.ts +46 -0
  132. package/dist/runtime/executorServices.d.ts.map +1 -0
  133. package/dist/runtime/executorServices.js +47 -0
  134. package/dist/runtime/executorServices.js.map +1 -0
  135. package/dist/runtime/extractionService.d.ts +11 -0
  136. package/dist/runtime/extractionService.d.ts.map +1 -0
  137. package/dist/runtime/extractionService.js +282 -0
  138. package/dist/runtime/extractionService.js.map +1 -0
  139. package/dist/runtime/feedbackService.d.ts +12 -0
  140. package/dist/runtime/feedbackService.d.ts.map +1 -0
  141. package/dist/runtime/feedbackService.js +111 -0
  142. package/dist/runtime/feedbackService.js.map +1 -0
  143. package/dist/runtime/goalEngine.d.ts +10 -0
  144. package/dist/runtime/goalEngine.d.ts.map +1 -0
  145. package/dist/runtime/goalEngine.js +429 -0
  146. package/dist/runtime/goalEngine.js.map +1 -0
  147. package/dist/runtime/goalFlowServices.d.ts +49 -0
  148. package/dist/runtime/goalFlowServices.d.ts.map +1 -0
  149. package/dist/runtime/goalFlowServices.js +45 -0
  150. package/dist/runtime/goalFlowServices.js.map +1 -0
  151. package/dist/runtime/goalReplay.d.ts +33 -0
  152. package/dist/runtime/goalReplay.d.ts.map +1 -0
  153. package/dist/runtime/goalReplay.js +58 -0
  154. package/dist/runtime/goalReplay.js.map +1 -0
  155. package/dist/runtime/goalRunner.d.ts +35 -0
  156. package/dist/runtime/goalRunner.d.ts.map +1 -0
  157. package/dist/runtime/goalRunner.js +42 -0
  158. package/dist/runtime/goalRunner.js.map +1 -0
  159. package/dist/runtime/healingEngine.d.ts +72 -0
  160. package/dist/runtime/healingEngine.d.ts.map +1 -0
  161. package/dist/runtime/healingEngine.js +969 -0
  162. package/dist/runtime/healingEngine.js.map +1 -0
  163. package/dist/runtime/healingServices.d.ts +62 -0
  164. package/dist/runtime/healingServices.d.ts.map +1 -0
  165. package/dist/runtime/healingServices.js +45 -0
  166. package/dist/runtime/healingServices.js.map +1 -0
  167. package/dist/runtime/helpers.d.ts +22 -0
  168. package/dist/runtime/helpers.d.ts.map +1 -0
  169. package/dist/runtime/helpers.js +694 -0
  170. package/dist/runtime/helpers.js.map +1 -0
  171. package/dist/runtime/hosts/actionHost.d.ts +82 -0
  172. package/dist/runtime/hosts/actionHost.d.ts.map +1 -0
  173. package/dist/runtime/hosts/actionHost.js +61 -0
  174. package/dist/runtime/hosts/actionHost.js.map +1 -0
  175. package/dist/runtime/hosts/baseServices.d.ts +51 -0
  176. package/dist/runtime/hosts/baseServices.d.ts.map +1 -0
  177. package/dist/runtime/hosts/baseServices.js +73 -0
  178. package/dist/runtime/hosts/baseServices.js.map +1 -0
  179. package/dist/runtime/hosts/embeddingServices.d.ts +25 -0
  180. package/dist/runtime/hosts/embeddingServices.d.ts.map +1 -0
  181. package/dist/runtime/hosts/embeddingServices.js +34 -0
  182. package/dist/runtime/hosts/embeddingServices.js.map +1 -0
  183. package/dist/runtime/hosts/goalFlowHost.d.ts +34 -0
  184. package/dist/runtime/hosts/goalFlowHost.d.ts.map +1 -0
  185. package/dist/runtime/hosts/goalFlowHost.js +35 -0
  186. package/dist/runtime/hosts/goalFlowHost.js.map +1 -0
  187. package/dist/runtime/hosts/goalFlowRuntime.d.ts +41 -0
  188. package/dist/runtime/hosts/goalFlowRuntime.d.ts.map +1 -0
  189. package/dist/runtime/hosts/goalFlowRuntime.js +31 -0
  190. package/dist/runtime/hosts/goalFlowRuntime.js.map +1 -0
  191. package/dist/runtime/hosts/providerHost.d.ts +19 -0
  192. package/dist/runtime/hosts/providerHost.d.ts.map +1 -0
  193. package/dist/runtime/hosts/providerHost.js +18 -0
  194. package/dist/runtime/hosts/providerHost.js.map +1 -0
  195. package/dist/runtime/hosts/rewriteHost.d.ts +84 -0
  196. package/dist/runtime/hosts/rewriteHost.d.ts.map +1 -0
  197. package/dist/runtime/hosts/rewriteHost.js +64 -0
  198. package/dist/runtime/hosts/rewriteHost.js.map +1 -0
  199. package/dist/runtime/hosts/workspaceHost.d.ts +113 -0
  200. package/dist/runtime/hosts/workspaceHost.d.ts.map +1 -0
  201. package/dist/runtime/hosts/workspaceHost.js +76 -0
  202. package/dist/runtime/hosts/workspaceHost.js.map +1 -0
  203. package/dist/runtime/index.d.ts +78 -0
  204. package/dist/runtime/index.d.ts.map +1 -0
  205. package/dist/runtime/index.js +95 -0
  206. package/dist/runtime/index.js.map +1 -0
  207. package/dist/runtime/insight.d.ts +16 -0
  208. package/dist/runtime/insight.d.ts.map +1 -0
  209. package/dist/runtime/insight.js +11 -0
  210. package/dist/runtime/insight.js.map +1 -0
  211. package/dist/runtime/internalActions.d.ts +16 -0
  212. package/dist/runtime/internalActions.d.ts.map +1 -0
  213. package/dist/runtime/internalActions.js +302 -0
  214. package/dist/runtime/internalActions.js.map +1 -0
  215. package/dist/runtime/modelBehavior.d.ts +69 -0
  216. package/dist/runtime/modelBehavior.d.ts.map +1 -0
  217. package/dist/runtime/modelBehavior.js +514 -0
  218. package/dist/runtime/modelBehavior.js.map +1 -0
  219. package/dist/runtime/modelCapabilities.d.ts +139 -0
  220. package/dist/runtime/modelCapabilities.d.ts.map +1 -0
  221. package/dist/runtime/modelCapabilities.js +458 -0
  222. package/dist/runtime/modelCapabilities.js.map +1 -0
  223. package/dist/runtime/modelsDevCatalog.d.ts +34 -0
  224. package/dist/runtime/modelsDevCatalog.d.ts.map +1 -0
  225. package/dist/runtime/modelsDevCatalog.js +263 -0
  226. package/dist/runtime/modelsDevCatalog.js.map +1 -0
  227. package/dist/runtime/pendingInference.d.ts +18 -0
  228. package/dist/runtime/pendingInference.d.ts.map +1 -0
  229. package/dist/runtime/pendingInference.js +121 -0
  230. package/dist/runtime/pendingInference.js.map +1 -0
  231. package/dist/runtime/persistence.d.ts +21 -0
  232. package/dist/runtime/persistence.d.ts.map +1 -0
  233. package/dist/runtime/persistence.js +73 -0
  234. package/dist/runtime/persistence.js.map +1 -0
  235. package/dist/runtime/planContext.d.ts +42 -0
  236. package/dist/runtime/planContext.d.ts.map +1 -0
  237. package/dist/runtime/planContext.js +246 -0
  238. package/dist/runtime/planContext.js.map +1 -0
  239. package/dist/runtime/planGenerator.d.ts +21 -0
  240. package/dist/runtime/planGenerator.d.ts.map +1 -0
  241. package/dist/runtime/planGenerator.js +89 -0
  242. package/dist/runtime/planGenerator.js.map +1 -0
  243. package/dist/runtime/planPreparation.d.ts +64 -0
  244. package/dist/runtime/planPreparation.d.ts.map +1 -0
  245. package/dist/runtime/planPreparation.js +173 -0
  246. package/dist/runtime/planPreparation.js.map +1 -0
  247. package/dist/runtime/projectSummary.d.ts +3 -0
  248. package/dist/runtime/projectSummary.d.ts.map +1 -0
  249. package/dist/runtime/projectSummary.js +42 -0
  250. package/dist/runtime/projectSummary.js.map +1 -0
  251. package/dist/runtime/providerSettings.d.ts +28 -0
  252. package/dist/runtime/providerSettings.d.ts.map +1 -0
  253. package/dist/runtime/providerSettings.js +93 -0
  254. package/dist/runtime/providerSettings.js.map +1 -0
  255. package/dist/runtime/pythonActions.d.ts +78 -0
  256. package/dist/runtime/pythonActions.d.ts.map +1 -0
  257. package/dist/runtime/pythonActions.js +392 -0
  258. package/dist/runtime/pythonActions.js.map +1 -0
  259. package/dist/runtime/pythonBridge.d.ts +13 -0
  260. package/dist/runtime/pythonBridge.d.ts.map +1 -0
  261. package/dist/runtime/pythonBridge.js +117 -0
  262. package/dist/runtime/pythonBridge.js.map +1 -0
  263. package/dist/runtime/rewriteEngine.d.ts +46 -0
  264. package/dist/runtime/rewriteEngine.d.ts.map +1 -0
  265. package/dist/runtime/rewriteEngine.js +259 -0
  266. package/dist/runtime/rewriteEngine.js.map +1 -0
  267. package/dist/runtime/rewriteGenerator.d.ts +29 -0
  268. package/dist/runtime/rewriteGenerator.d.ts.map +1 -0
  269. package/dist/runtime/rewriteGenerator.js +1527 -0
  270. package/dist/runtime/rewriteGenerator.js.map +1 -0
  271. package/dist/runtime/rewriteHydration.d.ts +22 -0
  272. package/dist/runtime/rewriteHydration.d.ts.map +1 -0
  273. package/dist/runtime/rewriteHydration.js +265 -0
  274. package/dist/runtime/rewriteHydration.js.map +1 -0
  275. package/dist/runtime/rewriteOrchestration.d.ts +105 -0
  276. package/dist/runtime/rewriteOrchestration.d.ts.map +1 -0
  277. package/dist/runtime/rewriteOrchestration.js +130 -0
  278. package/dist/runtime/rewriteOrchestration.js.map +1 -0
  279. package/dist/runtime/rewritePayload.d.ts +18 -0
  280. package/dist/runtime/rewritePayload.d.ts.map +1 -0
  281. package/dist/runtime/rewritePayload.js +166 -0
  282. package/dist/runtime/rewritePayload.js.map +1 -0
  283. package/dist/runtime/rewriteRuntime.d.ts +13 -0
  284. package/dist/runtime/rewriteRuntime.d.ts.map +1 -0
  285. package/dist/runtime/rewriteRuntime.js +21 -0
  286. package/dist/runtime/rewriteRuntime.js.map +1 -0
  287. package/dist/runtime/rewriteServices.d.ts +70 -0
  288. package/dist/runtime/rewriteServices.d.ts.map +1 -0
  289. package/dist/runtime/rewriteServices.js +50 -0
  290. package/dist/runtime/rewriteServices.js.map +1 -0
  291. package/dist/runtime/runtimeHelpers.d.ts +9 -0
  292. package/dist/runtime/runtimeHelpers.d.ts.map +1 -0
  293. package/dist/runtime/runtimeHelpers.js +86 -0
  294. package/dist/runtime/runtimeHelpers.js.map +1 -0
  295. package/dist/runtime/sessionData.d.ts +4 -0
  296. package/dist/runtime/sessionData.d.ts.map +1 -0
  297. package/dist/runtime/sessionData.js +45 -0
  298. package/dist/runtime/sessionData.js.map +1 -0
  299. package/dist/runtime/sessionRuntime.d.ts +47 -0
  300. package/dist/runtime/sessionRuntime.d.ts.map +1 -0
  301. package/dist/runtime/sessionRuntime.js +128 -0
  302. package/dist/runtime/sessionRuntime.js.map +1 -0
  303. package/dist/runtime/stealthRuntimeTypes.d.ts +12 -0
  304. package/dist/runtime/stealthRuntimeTypes.d.ts.map +1 -0
  305. package/dist/runtime/stealthRuntimeTypes.js +3 -0
  306. package/dist/runtime/stealthRuntimeTypes.js.map +1 -0
  307. package/dist/runtime/stepExecutor.d.ts +22 -0
  308. package/dist/runtime/stepExecutor.d.ts.map +1 -0
  309. package/dist/runtime/stepExecutor.js +83 -0
  310. package/dist/runtime/stepExecutor.js.map +1 -0
  311. package/dist/runtime/stepLifecycle.d.ts +29 -0
  312. package/dist/runtime/stepLifecycle.d.ts.map +1 -0
  313. package/dist/runtime/stepLifecycle.js +122 -0
  314. package/dist/runtime/stepLifecycle.js.map +1 -0
  315. package/dist/runtime/stepMetadata.d.ts +6 -0
  316. package/dist/runtime/stepMetadata.d.ts.map +1 -0
  317. package/dist/runtime/stepMetadata.js +87 -0
  318. package/dist/runtime/stepMetadata.js.map +1 -0
  319. package/dist/runtime/taskQueue.d.ts +16 -0
  320. package/dist/runtime/taskQueue.d.ts.map +1 -0
  321. package/dist/runtime/taskQueue.js +103 -0
  322. package/dist/runtime/taskQueue.js.map +1 -0
  323. package/dist/runtime/telemetry.d.ts +6 -0
  324. package/dist/runtime/telemetry.d.ts.map +1 -0
  325. package/dist/runtime/telemetry.js +42 -0
  326. package/dist/runtime/telemetry.js.map +1 -0
  327. package/dist/runtime/telemetryHub.d.ts +61 -0
  328. package/dist/runtime/telemetryHub.d.ts.map +1 -0
  329. package/dist/runtime/telemetryHub.js +190 -0
  330. package/dist/runtime/telemetryHub.js.map +1 -0
  331. package/dist/runtime/textSanitizer.d.ts +4 -0
  332. package/dist/runtime/textSanitizer.d.ts.map +1 -0
  333. package/dist/runtime/textSanitizer.js +86 -0
  334. package/dist/runtime/textSanitizer.js.map +1 -0
  335. package/dist/runtime/typeCheckRunner.d.ts +33 -0
  336. package/dist/runtime/typeCheckRunner.d.ts.map +1 -0
  337. package/dist/runtime/typeCheckRunner.js +357 -0
  338. package/dist/runtime/typeCheckRunner.js.map +1 -0
  339. package/dist/runtime/types.d.ts +334 -0
  340. package/dist/runtime/types.d.ts.map +1 -0
  341. package/dist/runtime/types.js +3 -0
  342. package/dist/runtime/types.js.map +1 -0
  343. package/dist/runtime/typescriptValidator.d.ts +18 -0
  344. package/dist/runtime/typescriptValidator.d.ts.map +1 -0
  345. package/dist/runtime/typescriptValidator.js +363 -0
  346. package/dist/runtime/typescriptValidator.js.map +1 -0
  347. package/dist/runtime/undoManager.d.ts +7 -0
  348. package/dist/runtime/undoManager.d.ts.map +1 -0
  349. package/dist/runtime/undoManager.js +56 -0
  350. package/dist/runtime/undoManager.js.map +1 -0
  351. package/dist/runtime/validationController.d.ts +11 -0
  352. package/dist/runtime/validationController.d.ts.map +1 -0
  353. package/dist/runtime/validationController.js +29 -0
  354. package/dist/runtime/validationController.js.map +1 -0
  355. package/dist/runtime/validationUtils.d.ts +17 -0
  356. package/dist/runtime/validationUtils.d.ts.map +1 -0
  357. package/dist/runtime/validationUtils.js +121 -0
  358. package/dist/runtime/validationUtils.js.map +1 -0
  359. package/dist/runtime/workspaceAssertions.d.ts +21 -0
  360. package/dist/runtime/workspaceAssertions.d.ts.map +1 -0
  361. package/dist/runtime/workspaceAssertions.js +183 -0
  362. package/dist/runtime/workspaceAssertions.js.map +1 -0
  363. package/dist/runtime/workspaceIndexService.d.ts +24 -0
  364. package/dist/runtime/workspaceIndexService.d.ts.map +1 -0
  365. package/dist/runtime/workspaceIndexService.js +133 -0
  366. package/dist/runtime/workspaceIndexService.js.map +1 -0
  367. package/dist/runtime/workspaceIndexer.d.ts +21 -0
  368. package/dist/runtime/workspaceIndexer.d.ts.map +1 -0
  369. package/dist/runtime/workspaceIndexer.js +95 -0
  370. package/dist/runtime/workspaceIndexer.js.map +1 -0
  371. package/dist/runtime/workspacePackages.d.ts +22 -0
  372. package/dist/runtime/workspacePackages.d.ts.map +1 -0
  373. package/dist/runtime/workspacePackages.js +198 -0
  374. package/dist/runtime/workspacePackages.js.map +1 -0
  375. package/dist/runtime/workspaceRuntime.d.ts +58 -0
  376. package/dist/runtime/workspaceRuntime.d.ts.map +1 -0
  377. package/dist/runtime/workspaceRuntime.js +86 -0
  378. package/dist/runtime/workspaceRuntime.js.map +1 -0
  379. package/dist/runtime/workspaceService.d.ts +14 -0
  380. package/dist/runtime/workspaceService.d.ts.map +1 -0
  381. package/dist/runtime/workspaceService.js +88 -0
  382. package/dist/runtime/workspaceService.js.map +1 -0
  383. package/dist/runtime/workspaceServices.d.ts +114 -0
  384. package/dist/runtime/workspaceServices.d.ts.map +1 -0
  385. package/dist/runtime/workspaceServices.js +114 -0
  386. package/dist/runtime/workspaceServices.js.map +1 -0
  387. package/dist/runtime/writeServices.d.ts +34 -0
  388. package/dist/runtime/writeServices.d.ts.map +1 -0
  389. package/dist/runtime/writeServices.js +32 -0
  390. package/dist/runtime/writeServices.js.map +1 -0
  391. package/dist/sharedPromptSections.d.ts +58 -0
  392. package/dist/sharedPromptSections.d.ts.map +1 -0
  393. package/dist/sharedPromptSections.js +94 -0
  394. package/dist/sharedPromptSections.js.map +1 -0
  395. package/dist/statusTypes.d.ts +13 -0
  396. package/dist/statusTypes.d.ts.map +1 -0
  397. package/dist/statusTypes.js +3 -0
  398. package/dist/statusTypes.js.map +1 -0
  399. package/dist/streamIdleTimeout.d.ts +38 -0
  400. package/dist/streamIdleTimeout.d.ts.map +1 -0
  401. package/dist/streamIdleTimeout.js +44 -0
  402. package/dist/streamIdleTimeout.js.map +1 -0
  403. package/dist/types/bandit.d.ts +113 -0
  404. package/dist/types/bandit.d.ts.map +1 -0
  405. package/dist/types/bandit.js +3 -0
  406. package/dist/types/bandit.js.map +1 -0
  407. package/dist/types.d.ts +152 -0
  408. package/dist/types.d.ts.map +1 -0
  409. package/dist/types.js +3 -0
  410. package/dist/types.js.map +1 -0
  411. package/dist/workspaceIndex.d.ts +44 -0
  412. package/dist/workspaceIndex.d.ts.map +1 -0
  413. package/dist/workspaceIndex.js +258 -0
  414. package/dist/workspaceIndex.js.map +1 -0
  415. package/package.json +36 -0
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.describeScanResponse = describeScanResponse;
4
+ exports.buildProjectSummary = buildProjectSummary;
5
+ function describeScanResponse(data) {
6
+ if (!data) {
7
+ return undefined;
8
+ }
9
+ const fileCount = Array.isArray(data.files) ? data.files.length : undefined;
10
+ const scripts = data.scripts && typeof data.scripts === 'object'
11
+ ? Object.keys(data.scripts).join(', ')
12
+ : '';
13
+ const parts = [];
14
+ if (typeof fileCount === 'number') {
15
+ parts.push(`${fileCount} files`);
16
+ }
17
+ if (scripts) {
18
+ parts.push(`scripts: ${scripts}`);
19
+ }
20
+ return parts.length > 0 ? parts.join('; ') : undefined;
21
+ }
22
+ function buildProjectSummary(data) {
23
+ if (!data) {
24
+ return 'Project metadata unavailable.';
25
+ }
26
+ const files = Array.isArray(data.files) ? data.files.slice(0, 10) : [];
27
+ const scripts = data.scripts && typeof data.scripts === 'object'
28
+ ? Object.keys(data.scripts)
29
+ : [];
30
+ const pkg = data.packageJson && typeof data.packageJson === 'object'
31
+ ? data.packageJson
32
+ : undefined;
33
+ const deps = pkg && typeof pkg.dependencies === 'object'
34
+ ? Object.keys(pkg.dependencies)
35
+ : [];
36
+ return [
37
+ files.length > 0 ? `Notable files: ${files.join(', ')}` : 'No files captured.',
38
+ scripts.length > 0 ? `Scripts: ${scripts.join(', ')}` : 'No npm scripts found.',
39
+ deps.length > 0 ? `Dependencies: ${deps.slice(0, 8).join(', ')}` : 'Dependencies not detected.'
40
+ ].join(' | ');
41
+ }
42
+ //# sourceMappingURL=projectSummary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projectSummary.js","sourceRoot":"","sources":["../../src/runtime/projectSummary.ts"],"names":[],"mappings":";;AAAA,oDAiBC;AAED,kDAsBC;AAzCD,SAAgB,oBAAoB,CAAC,IAAyC;IAC5E,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,MAAM,OAAO,GACX,IAAI,CAAC,OAAO,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ;QAC9C,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAkC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACjE,CAAC,CAAC,EAAE,CAAC;IACT,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,QAAQ,CAAC,CAAC;IACnC,CAAC;IACD,IAAI,OAAO,EAAE,CAAC;QACZ,KAAK,CAAC,IAAI,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAA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CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,4BAA4B;KAChG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAChB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { ProviderKind, ProviderSettings } from '../internalTypes';
2
+ export declare const DEFAULT_OLLAMA_MODEL = "gemma3:12b";
3
+ export declare const DEFAULT_OLLAMA_URL = "http://localhost:11434";
4
+ export interface ProviderConfiguration {
5
+ get<T>(section: string, defaultValue: T): T;
6
+ }
7
+ export declare function getProviderKind(configuration: ProviderConfiguration): ProviderKind;
8
+ export declare function getProviderModel(configuration: ProviderConfiguration, providerKind: ProviderKind): string;
9
+ /**
10
+ * Returns the model ID to use for agent rewrite/coding tasks.
11
+ * When `banditStealth.agentOllamaModel` is set (Ollama provider only), that model
12
+ * is used instead of `ollamaModel`, allowing a separate coding model (e.g.
13
+ * `qwen2.5-coder:32b`) while keeping a different chat model (`bandit-core:27b-it-qat`).
14
+ * Falls back to `getProviderModel` when no agent-specific model is configured.
15
+ */
16
+ export declare function getAgentProviderModel(configuration: ProviderConfiguration, providerKind: ProviderKind): string;
17
+ export declare function buildProviderSettings(configuration: ProviderConfiguration, apiKey: string): ProviderSettings;
18
+ /**
19
+ * Resolves the actual Ollama URL + headers the chat engine will use, mirroring
20
+ * the resolution in {@link ../banditEngineProvider.ts}. Shared so the model
21
+ * picker and other UI never show a different endpoint than chat actually hits.
22
+ */
23
+ export declare function resolveOllamaEndpoint(configuration: ProviderConfiguration): {
24
+ url: string;
25
+ headers: Record<string, string>;
26
+ isNodeOverride: boolean;
27
+ };
28
+ //# sourceMappingURL=providerSettings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providerSettings.d.ts","sourceRoot":"","sources":["../../src/runtime/providerSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEvE,eAAO,MAAM,oBAAoB,eAAe,CAAC;AACjD,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAE3D,MAAM,WAAW,qBAAqB;IACpC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC;CAC7C;AAED,wBAAgB,eAAe,CAAC,aAAa,EAAE,qBAAqB,GAAG,YAAY,CAIlF;AAED,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,qBAAqB,EACpC,YAAY,EAAE,YAAY,GACzB,MAAM,CAKR;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,qBAAqB,EACpC,YAAY,EAAE,YAAY,GACzB,MAAM,CAQR;AAED,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,qBAAqB,EACpC,MAAM,EAAE,MAAM,GACb,gBAAgB,CAsBlB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,qBAAqB,GAAG;IAC3E,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,cAAc,EAAE,OAAO,CAAC;CACzB,CAaA"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_OLLAMA_URL = exports.DEFAULT_OLLAMA_MODEL = void 0;
4
+ exports.getProviderKind = getProviderKind;
5
+ exports.getProviderModel = getProviderModel;
6
+ exports.getAgentProviderModel = getAgentProviderModel;
7
+ exports.buildProviderSettings = buildProviderSettings;
8
+ exports.resolveOllamaEndpoint = resolveOllamaEndpoint;
9
+ exports.DEFAULT_OLLAMA_MODEL = 'gemma3:12b';
10
+ exports.DEFAULT_OLLAMA_URL = 'http://localhost:11434';
11
+ function getProviderKind(configuration) {
12
+ const rawProvider = configuration.get('provider', 'ollama');
13
+ const normalized = typeof rawProvider === 'string' ? rawProvider.trim().toLowerCase() : 'ollama';
14
+ return normalized === 'ollama' ? 'ollama' : 'bandit';
15
+ }
16
+ function getProviderModel(configuration, providerKind) {
17
+ if (providerKind === 'ollama') {
18
+ return configuration.get('ollamaModel', exports.DEFAULT_OLLAMA_MODEL) || exports.DEFAULT_OLLAMA_MODEL;
19
+ }
20
+ return configuration.get('model', 'bandit-core-1') || 'bandit-core-1';
21
+ }
22
+ /**
23
+ * Returns the model ID to use for agent rewrite/coding tasks.
24
+ * When `banditStealth.agentOllamaModel` is set (Ollama provider only), that model
25
+ * is used instead of `ollamaModel`, allowing a separate coding model (e.g.
26
+ * `qwen2.5-coder:32b`) while keeping a different chat model (`bandit-core:27b-it-qat`).
27
+ * Falls back to `getProviderModel` when no agent-specific model is configured.
28
+ */
29
+ function getAgentProviderModel(configuration, providerKind) {
30
+ if (providerKind === 'ollama') {
31
+ const agentModel = configuration.get('agentOllamaModel', '');
32
+ if (agentModel)
33
+ return agentModel;
34
+ const codingModel = configuration.get('ollamaCodingModel', '');
35
+ if (codingModel)
36
+ return codingModel;
37
+ }
38
+ return getProviderModel(configuration, providerKind);
39
+ }
40
+ function buildProviderSettings(configuration, apiKey) {
41
+ const rawHeaders = configuration.get('ollamaHeaders', {}) || {};
42
+ const ollamaHeaders = sanitizeOllamaHeaders(rawHeaders);
43
+ return {
44
+ kind: getProviderKind(configuration),
45
+ apiKey,
46
+ apiUrl: configuration.get('apiUrl', 'https://api.burtson.ai/completions'),
47
+ // ollamaUrl: primary local endpoint (Mac localhost or LAN). Never RunPod.
48
+ // Accepts both ollamaUrl (legacy) and ollamaBaseUrl (new setting name).
49
+ ollamaUrl: configuration.get('ollamaBaseUrl', '') ||
50
+ configuration.get('ollamaUrl', exports.DEFAULT_OLLAMA_URL) ||
51
+ exports.DEFAULT_OLLAMA_URL,
52
+ // ollamaNodeUrl: optional secondary endpoint for external node (e.g. RTX 5090).
53
+ // When set, Ollama requests are routed here instead of ollamaUrl.
54
+ ollamaNodeUrl: configuration.get('ollamaNodeUrl', '') || undefined,
55
+ ollamaModel: configuration.get('ollamaModel', exports.DEFAULT_OLLAMA_MODEL) || exports.DEFAULT_OLLAMA_MODEL,
56
+ // ollamaHeaders: extra HTTP headers (Bearer token, Cloudflare Access, etc.).
57
+ // Undefined when empty so banditEngineProvider can skip the merge fast-path.
58
+ ollamaHeaders: Object.keys(ollamaHeaders).length > 0 ? ollamaHeaders : undefined
59
+ };
60
+ }
61
+ /**
62
+ * Resolves the actual Ollama URL + headers the chat engine will use, mirroring
63
+ * the resolution in {@link ../banditEngineProvider.ts}. Shared so the model
64
+ * picker and other UI never show a different endpoint than chat actually hits.
65
+ */
66
+ function resolveOllamaEndpoint(configuration) {
67
+ const base = configuration.get('ollamaBaseUrl', '') ||
68
+ configuration.get('ollamaUrl', exports.DEFAULT_OLLAMA_URL) ||
69
+ exports.DEFAULT_OLLAMA_URL;
70
+ const nodeRaw = configuration.get('ollamaNodeUrl', '') ?? '';
71
+ const node = typeof nodeRaw === 'string' ? nodeRaw.trim() : '';
72
+ const rawUrl = node.length > 0 ? node : base;
73
+ const url = (rawUrl || exports.DEFAULT_OLLAMA_URL).replace(/\/+$/, '');
74
+ const headers = sanitizeOllamaHeaders(configuration.get('ollamaHeaders', {}) || {});
75
+ return { url, headers, isNodeOverride: node.length > 0 };
76
+ }
77
+ function sanitizeOllamaHeaders(raw) {
78
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
79
+ return {};
80
+ }
81
+ const out = {};
82
+ for (const [key, value] of Object.entries(raw)) {
83
+ if (!key || typeof key !== 'string')
84
+ continue;
85
+ if (key.toLowerCase() === 'content-type')
86
+ continue; // always forced to JSON
87
+ if (typeof value === 'string' && value.length > 0) {
88
+ out[key] = value;
89
+ }
90
+ }
91
+ return out;
92
+ }
93
+ //# sourceMappingURL=providerSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providerSettings.js","sourceRoot":"","sources":["../../src/runtime/providerSettings.ts"],"names":[],"mappings":";;;AASA,0CAIC;AAED,4CAQC;AASD,sDAW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AAM,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7C,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,0BAAkB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/D,MAAM,OAAO,GAAG,qBAAqB,CACnC,aAAa,CAAC,GAAG,CAAyB,eAAe,EAAE,EAAE,CAAC,IAAI,EAAE,CACrE,CAAC;IACF,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;AAC3D,CAAC;AAED,SAAS,qBAAqB,CAAC,GAAY;IACzC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1D,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAA8B,CAAC,EAAE,CAAC;QAC1E,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,SAAS;QAC9C,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,cAAc;YAAE,SAAS,CAAC,wBAAwB;QAC5E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClD,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,78 @@
1
+ import type { PlanStep, PythonScanProjectAction, PythonReadFileAction, PythonWriteFileAction, PythonRunCommandAction } from '../internalTypes';
2
+ import type { HelperStepMetadata, AdditionalWrite, StepOutcome, StatusPayload, LogPayload, PythonResponse, IUndoManager } from '../internalTypes';
3
+ export type PythonAction = PythonScanProjectAction | PythonReadFileAction | PythonWriteFileAction | PythonRunCommandAction;
4
+ export interface PythonActionDeps {
5
+ ensureSession(): {
6
+ workspaceRoot: string;
7
+ };
8
+ getContextValue<T>(key: string): T | undefined;
9
+ setContextValue(key: string, value: unknown): void;
10
+ normalizeRelativePath(value: string): string | undefined;
11
+ getHelperStepMetadata(step: PlanStep | undefined): HelperStepMetadata | undefined;
12
+ resolveRootParam(ref?: string): string;
13
+ isDryRunEnabled(): boolean;
14
+ isPreviewOnly(): boolean;
15
+ telemetry: {
16
+ status(payload: StatusPayload): Promise<void>;
17
+ log(payload: LogPayload): Promise<void>;
18
+ };
19
+ embeddingCache: {
20
+ indexFiles(workspaceRoot: string, files: string[]): Promise<{
21
+ reused: number;
22
+ computed: number;
23
+ }>;
24
+ };
25
+ embeddingManager: {
26
+ scheduleEmbeddingUpsert(path: string, content: string): void;
27
+ };
28
+ postEmbeddingStatus(stats: {
29
+ reused: number;
30
+ computed: number;
31
+ }, total: number): Promise<void>;
32
+ captureExtractionSection(content: string): void;
33
+ buildProjectSummary(data: Record<string, unknown> | undefined): string;
34
+ describeScanResponse(data: Record<string, unknown> | undefined): string | undefined;
35
+ buildContentSample(content: string, maxLines?: number, maxLength?: number): string;
36
+ applyIncrementalEdits(original: string, content: string, relativePath: string): {
37
+ content: string;
38
+ replaced: number;
39
+ total: number;
40
+ confidence: number;
41
+ };
42
+ helperManager: {
43
+ applyImportHints(meta: HelperStepMetadata | undefined, content: string): string;
44
+ };
45
+ diffManager: {
46
+ registerPendingDiff(path: string, original: string, updated: string, confidence?: number): Promise<{
47
+ diff?: string;
48
+ summary?: {
49
+ added: number;
50
+ removed: number;
51
+ };
52
+ changed?: boolean;
53
+ confidence?: number;
54
+ }>;
55
+ };
56
+ additionalWriteManager: {
57
+ applyAdditionalWrites(config: {
58
+ workspaceRoot: string;
59
+ writes: AdditionalWrite[];
60
+ encoding: BufferEncoding;
61
+ dryRun: boolean;
62
+ stepId?: string;
63
+ }): Promise<Array<Record<string, unknown>>>;
64
+ };
65
+ undoManager: Pick<IUndoManager, 'createBackup' | 'capturePreWriteState' | 'recordSnapshot'>;
66
+ recordWriteContext(paths: (string | undefined)[], helperStep: boolean): void;
67
+ clearPendingWriteContext(): void;
68
+ pendingInferenceTracker: {
69
+ flagMissingFiles(relativePath: string, writes: AdditionalWrite[]): Promise<void>;
70
+ };
71
+ filterAdditionalWrites(raw: unknown, normalize: (value: string) => string | undefined): AdditionalWrite[];
72
+ resolveAdditionalWritesRef(action: PythonWriteFileAction): string | undefined;
73
+ runPython(action: string, payload: unknown): Promise<PythonResponse>;
74
+ }
75
+ export declare function createPythonActionExecutor(deps: PythonActionDeps): {
76
+ execute: (action: PythonAction, stepId?: string, step?: PlanStep) => Promise<StepOutcome>;
77
+ };
78
+ //# sourceMappingURL=pythonActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pythonActions.d.ts","sourceRoot":"","sources":["../../src/runtime/pythonActions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,aAAa,EACb,UAAU,EACV,cAAc,EAEd,YAAY,EACb,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,YAAY,GACpB,uBAAuB,GACvB,oBAAoB,GACpB,qBAAqB,GACrB,sBAAsB,CAAC;AAE3B,MAAM,WAAW,gBAAgB;IAC/B,aAAa,IAAI;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAC/C,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,I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,kBAAkB,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7E,wBAAwB,IAAI,IAAI,CAAC;IACjC,uBAAuB,EAAE;QACvB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAClF,CAAC;IACF,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAAG,eAAe,EAAE,CAAC;IAC1G,0BAA0B,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,GAAG,SAAS,CAAC;IAC9E,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACtE;AAoCD,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,gBAAgB;sBAChC,YAAY,WAAW,MAAM,SAAS,QAAQ,KAAG,OAAO,CAAC,WAAW,CAAC;EAuWrG"}
@@ -0,0 +1,392 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createPythonActionExecutor = createPythonActionExecutor;
37
+ const path = __importStar(require("path"));
38
+ const coerceNumber = (value) => typeof value === 'number' && Number.isFinite(value) ? value : undefined;
39
+ const coerceRewriteGuard = (value) => {
40
+ if (!value || typeof value !== 'object') {
41
+ return undefined;
42
+ }
43
+ const record = value;
44
+ const maxRemovedLineRatio = coerceNumber(record.maxRemovedLineRatio);
45
+ const maxChangedLineRatio = coerceNumber(record.maxChangedLineRatio);
46
+ const minOriginalLineCount = coerceNumber(record.minOriginalLineCount);
47
+ const reason = typeof record.reason === 'string' ? record.reason : undefined;
48
+ if (maxRemovedLineRatio === undefined && maxChangedLineRatio === undefined) {
49
+ return undefined;
50
+ }
51
+ return {
52
+ maxRemovedLineRatio,
53
+ maxChangedLineRatio,
54
+ minOriginalLineCount,
55
+ reason
56
+ };
57
+ };
58
+ const countLines = (value) => value.split(/\r\n|\r|\n/).length;
59
+ const formatPercent = (ratio) => `${(ratio * 100).toFixed(1)}%`;
60
+ function createPythonActionExecutor(deps) {
61
+ async function execute(action, stepId, step) {
62
+ const session = deps.ensureSession();
63
+ const helperMeta = deps.getHelperStepMetadata(step);
64
+ if (action.name === 'scanProject') {
65
+ const payload = {
66
+ root: deps.resolveRootParam(action.params?.rootRef),
67
+ maxDepth: action.params?.maxDepth ?? 5,
68
+ maxFiles: action.params?.maxFiles ?? 400,
69
+ includeExtensions: action.params?.includeExtensions ?? []
70
+ };
71
+ await deps.telemetry.status({
72
+ text: 'Scanning project files…',
73
+ phase: 'progress',
74
+ detail: `Root ${path.basename(payload.root)} (max ${payload.maxFiles} files)`,
75
+ stepId,
76
+ icon: 'search'
77
+ });
78
+ await deps.telemetry.log({
79
+ message: `Scanning project at ${payload.root} (depth ${payload.maxDepth}, max ${payload.maxFiles} files)…`,
80
+ stepId,
81
+ level: 'info'
82
+ });
83
+ const response = await deps.runPython('scanProject', payload);
84
+ if (response.status === 'SUCCESS' && action.storeKey) {
85
+ const storedData = {
86
+ ...(response.data ?? {}),
87
+ root: payload.root
88
+ };
89
+ deps.setContextValue(action.storeKey, storedData);
90
+ deps.setContextValue('project.root', payload.root);
91
+ deps.setContextValue('project.summary', deps.buildProjectSummary(response.data));
92
+ }
93
+ const files = Array.isArray(response.data?.files) ? response.data?.files : [];
94
+ if (files.length > 0) {
95
+ const indexedPaths = files.filter((file) => typeof file === 'string');
96
+ if (indexedPaths.length > 0) {
97
+ const stats = await deps.embeddingCache.indexFiles(session.workspaceRoot, indexedPaths);
98
+ deps.setContextValue('project.embeddingStats', { ...stats, total: indexedPaths.length, refreshedAt: Date.now() });
99
+ await deps.telemetry.log({
100
+ message: `Embedding cache hydrated — reused ${stats.reused}, computed ${stats.computed}.`,
101
+ stepId,
102
+ level: 'info'
103
+ });
104
+ await deps.postEmbeddingStatus(stats, indexedPaths.length).catch(() => undefined);
105
+ }
106
+ }
107
+ await deps.telemetry.log({
108
+ message: response.status === 'SUCCESS'
109
+ ? `Project scan complete — indexed ${files.length} file${files.length === 1 ? '' : 's'}.`
110
+ : `Project scan failed${response.error ? `: ${response.error}` : ''}`,
111
+ stepId,
112
+ level: response.status === 'SUCCESS' ? 'info' : 'error'
113
+ });
114
+ return {
115
+ ok: response.status === 'SUCCESS',
116
+ output: response.output ?? deps.describeScanResponse(response.data),
117
+ error: response.status === 'FAILED' ? response.error?.toString() : undefined,
118
+ data: response.data ? { storedKey: action.storeKey, ...response.data } : undefined
119
+ };
120
+ }
121
+ if (action.name === 'readFile') {
122
+ const relativePath = deps.getContextValue(action.pathRef);
123
+ if (!relativePath) {
124
+ return { ok: false, error: `Missing path for ${action.pathRef}` };
125
+ }
126
+ const payload = {
127
+ root: session.workspaceRoot,
128
+ path: relativePath,
129
+ encoding: action.encoding ?? 'utf-8'
130
+ };
131
+ const response = await deps.runPython('readFile', payload);
132
+ if (response.status === 'SUCCESS' && action.storeKey) {
133
+ deps.setContextValue(action.storeKey, response.data?.content ?? response.output ?? '');
134
+ }
135
+ const contentText = typeof response.data?.content === 'string' ? response.data.content : undefined;
136
+ const fetchedContent = contentText ?? (typeof response.output === 'string' ? response.output : '');
137
+ if (response.status === 'SUCCESS' && contentText) {
138
+ deps.embeddingManager.scheduleEmbeddingUpsert(relativePath, contentText);
139
+ }
140
+ if (response.status === 'SUCCESS' && action.storeKey === 'focus.primary.content') {
141
+ deps.captureExtractionSection(fetchedContent);
142
+ deps.setContextValue('focus.extract.sourcePath', relativePath);
143
+ }
144
+ return {
145
+ ok: response.status === 'SUCCESS',
146
+ output: response.status === 'SUCCESS' ? `Read ${relativePath}` : undefined,
147
+ error: response.status === 'FAILED' ? response.error?.toString() : undefined,
148
+ data: response.data
149
+ ? {
150
+ storedKey: action.storeKey,
151
+ path: response.data.path,
152
+ bytes: contentText?.length ?? 0,
153
+ sample: contentText ? deps.buildContentSample(contentText) : undefined
154
+ }
155
+ : undefined
156
+ };
157
+ }
158
+ if (action.name === 'writeFile') {
159
+ const contextualPath = action.pathRef ? deps.getContextValue(action.pathRef) : undefined;
160
+ const helperPath = helperMeta?.helperPath;
161
+ const relativePath = helperPath ?? contextualPath;
162
+ const content = deps.getContextValue(action.contentRef);
163
+ const original = action.originalContentRef ? deps.getContextValue(action.originalContentRef) : undefined;
164
+ if (!relativePath || typeof content !== 'string') {
165
+ return { ok: false, error: 'Missing path or content for writeFile action.' };
166
+ }
167
+ const additionalWritesRef = deps.resolveAdditionalWritesRef(action);
168
+ const additionalWritesRaw = additionalWritesRef ? deps.getContextValue(additionalWritesRef) : undefined;
169
+ const additionalWrites = deps.filterAdditionalWrites(additionalWritesRaw, (value) => deps.normalizeRelativePath(value));
170
+ if (helperPath && additionalWrites.length > 0) {
171
+ additionalWrites[0] = { ...additionalWrites[0], path: helperPath };
172
+ }
173
+ const requiredFileEntries = Array.isArray(step?.metadata?.requiredFileEntries)
174
+ ? step?.metadata?.requiredFileEntries
175
+ : [];
176
+ if (requiredFileEntries.length > 0) {
177
+ const normalizedPrimary = (deps.normalizeRelativePath(relativePath) ?? relativePath).toLowerCase();
178
+ const requiredNormalized = requiredFileEntries
179
+ .map((entry) => deps.normalizeRelativePath(entry) ?? entry)
180
+ .filter((entry) => Boolean(entry))
181
+ .map((entry) => entry.toLowerCase())
182
+ .filter((entry) => entry !== normalizedPrimary);
183
+ if (requiredNormalized.length > 0) {
184
+ const actualAdditional = new Map();
185
+ for (const entry of additionalWrites) {
186
+ const normalizedEntry = deps.normalizeRelativePath(entry.path) ?? entry.path;
187
+ if (!normalizedEntry) {
188
+ continue;
189
+ }
190
+ const contentValue = typeof entry.content === 'string' ? entry.content : '';
191
+ actualAdditional.set(normalizedEntry.toLowerCase(), contentValue);
192
+ }
193
+ const missing = requiredNormalized.filter((entry) => {
194
+ const contentValue = actualAdditional.get(entry);
195
+ if (contentValue === undefined) {
196
+ return true;
197
+ }
198
+ return contentValue.trim().length === 0;
199
+ });
200
+ if (missing.length > 0) {
201
+ return {
202
+ ok: false,
203
+ error: `Missing required additional file writes or content: ${missing.join(', ')}.`
204
+ };
205
+ }
206
+ }
207
+ }
208
+ const dryRun = deps.isPreviewOnly() || deps.isDryRunEnabled();
209
+ const encoding = action.encoding ?? 'utf-8';
210
+ const incremental = typeof original === 'string'
211
+ ? deps.applyIncrementalEdits(original, content, relativePath)
212
+ : { content, replaced: 0, total: 0, confidence: 0.9 };
213
+ let finalContent = incremental.content;
214
+ finalContent = deps.helperManager.applyImportHints(helperMeta, finalContent);
215
+ const baselineOriginal = typeof original === 'string' ? original : '';
216
+ const pendingDiff = await deps.diffManager.registerPendingDiff(relativePath, baselineOriginal, finalContent, incremental.confidence);
217
+ const shouldWritePrimary = pendingDiff.changed !== false;
218
+ let backupPath;
219
+ let preWriteState;
220
+ if (shouldWritePrimary && !dryRun && typeof original === 'string') {
221
+ try {
222
+ backupPath = await deps.undoManager.createBackup(session.workspaceRoot, relativePath, original);
223
+ }
224
+ catch (error) {
225
+ const message = error instanceof Error ? error.message : String(error);
226
+ await deps.telemetry.log({
227
+ message: `Backup failed for ${relativePath}: ${message}`,
228
+ level: 'warn'
229
+ });
230
+ }
231
+ }
232
+ const diffText = pendingDiff.diff;
233
+ let diffSummary = pendingDiff.summary;
234
+ if (diffText === undefined) {
235
+ return { ok: false, error: `Unable to compute diff for ${relativePath}. Aborting write.` };
236
+ }
237
+ const summaryForLog = diffSummary ?? { added: 0, removed: 0 };
238
+ diffSummary = summaryForLog;
239
+ await deps.telemetry.log({
240
+ message: `Diff summary for ${relativePath}: +${summaryForLog.added} / -${summaryForLog.removed}${pendingDiff.confidence ? ` (confidence ${(100 * pendingDiff.confidence).toFixed(1)}%)` : ''}`,
241
+ level: 'info'
242
+ });
243
+ if (action.diffStoreKey) {
244
+ deps.setContextValue(action.diffStoreKey, diffText);
245
+ }
246
+ const rewriteGuard = coerceRewriteGuard(step?.metadata?.rewriteGuard);
247
+ if (rewriteGuard && shouldWritePrimary && typeof original === 'string') {
248
+ const originalLineCount = countLines(original);
249
+ if (!rewriteGuard.minOriginalLineCount || originalLineCount >= rewriteGuard.minOriginalLineCount) {
250
+ const baselineLines = Math.max(1, originalLineCount);
251
+ const removedRatio = summaryForLog.removed / baselineLines;
252
+ const changedRatio = (summaryForLog.added + summaryForLog.removed) / baselineLines;
253
+ const violations = [];
254
+ if (rewriteGuard.maxRemovedLineRatio !== undefined
255
+ && removedRatio > rewriteGuard.maxRemovedLineRatio) {
256
+ violations.push(`removed ${formatPercent(removedRatio)} of lines (max ${formatPercent(rewriteGuard.maxRemovedLineRatio)})`);
257
+ }
258
+ if (rewriteGuard.maxChangedLineRatio !== undefined
259
+ && changedRatio > rewriteGuard.maxChangedLineRatio) {
260
+ violations.push(`changed ${formatPercent(changedRatio)} of lines (max ${formatPercent(rewriteGuard.maxChangedLineRatio)})`);
261
+ }
262
+ if (violations.length > 0) {
263
+ const reason = rewriteGuard.reason ? ` (${rewriteGuard.reason})` : '';
264
+ return {
265
+ ok: false,
266
+ error: `Rewrite guard blocked update for ${relativePath}${reason}: ${violations.join('; ')}.`
267
+ };
268
+ }
269
+ }
270
+ }
271
+ if (!shouldWritePrimary) {
272
+ await deps.telemetry.status({
273
+ text: `No changes detected for ${relativePath}`,
274
+ phase: 'progress',
275
+ detail: 'Skipping disk write because the file is unchanged.',
276
+ stepId,
277
+ icon: 'code'
278
+ });
279
+ }
280
+ if (!dryRun && shouldWritePrimary) {
281
+ preWriteState = await deps.undoManager.capturePreWriteState(session.workspaceRoot, relativePath, encoding, original);
282
+ }
283
+ let response = { status: 'SUCCESS', data: { path: relativePath } };
284
+ if (dryRun) {
285
+ await deps.telemetry.status({
286
+ text: `Dry run prepared for ${relativePath}`,
287
+ phase: 'progress',
288
+ detail: 'Changes staged for review without writing to disk.',
289
+ stepId,
290
+ icon: 'code'
291
+ });
292
+ }
293
+ else if (shouldWritePrimary) {
294
+ const payload = {
295
+ root: session.workspaceRoot,
296
+ path: relativePath,
297
+ content: finalContent,
298
+ encoding
299
+ };
300
+ response = await deps.runPython('writeFile', payload);
301
+ }
302
+ const ok = response.status === 'SUCCESS';
303
+ if (!dryRun && ok && preWriteState) {
304
+ deps.undoManager.recordSnapshot({
305
+ path: relativePath,
306
+ absolutePath: preWriteState.absolutePath,
307
+ before: preWriteState.before,
308
+ after: finalContent,
309
+ encoding,
310
+ timestamp: Date.now(),
311
+ existedBefore: preWriteState.existedBefore
312
+ });
313
+ }
314
+ if (ok && !dryRun && shouldWritePrimary) {
315
+ deps.embeddingManager.scheduleEmbeddingUpsert(relativePath, finalContent);
316
+ }
317
+ const bytesWritten = shouldWritePrimary ? Buffer.byteLength(finalContent, encoding) : 0;
318
+ let additionalWriteDetails = [];
319
+ if (additionalWrites.length > 0) {
320
+ additionalWriteDetails = await deps.additionalWriteManager.applyAdditionalWrites({
321
+ workspaceRoot: session.workspaceRoot,
322
+ writes: additionalWrites,
323
+ encoding,
324
+ dryRun,
325
+ stepId
326
+ });
327
+ if (additionalWritesRef) {
328
+ deps.setContextValue(additionalWritesRef, []);
329
+ }
330
+ }
331
+ if (!dryRun) {
332
+ if (ok) {
333
+ const extraPaths = additionalWriteDetails
334
+ .map((entry) => (typeof entry.path === 'string' ? entry.path : undefined))
335
+ .filter((value) => Boolean(value));
336
+ deps.recordWriteContext([relativePath, ...extraPaths], Boolean(helperMeta));
337
+ }
338
+ else {
339
+ deps.clearPendingWriteContext();
340
+ }
341
+ }
342
+ else {
343
+ deps.clearPendingWriteContext();
344
+ }
345
+ if (!dryRun) {
346
+ await deps.pendingInferenceTracker.flagMissingFiles(relativePath, additionalWrites);
347
+ }
348
+ return {
349
+ ok,
350
+ output: ok ? (dryRun ? `Prepared dry run for ${relativePath}` : `Wrote ${relativePath}`) : undefined,
351
+ error: ok ? undefined : response.error?.toString(),
352
+ data: {
353
+ ...(response.data ?? {}),
354
+ diff: diffText,
355
+ diffSummary,
356
+ backupPath,
357
+ backupContent: typeof original === 'string' ? original : undefined,
358
+ path: relativePath,
359
+ dryRun,
360
+ astEdits: {
361
+ replaced: incremental.replaced,
362
+ total: incremental.total,
363
+ confidence: incremental.confidence
364
+ },
365
+ bytesWritten,
366
+ additionalWrites: additionalWriteDetails
367
+ }
368
+ };
369
+ }
370
+ if (action.name === 'runCommand') {
371
+ const payload = {
372
+ command: action.command,
373
+ cwd: deps.resolveRootParam(action.cwdRef),
374
+ root: session.workspaceRoot
375
+ };
376
+ const response = await deps.runPython('runCommand', payload);
377
+ const ok = response.status === 'SUCCESS' || Boolean(action.allowFailure);
378
+ return {
379
+ ok,
380
+ output: response.output,
381
+ error: response.status === 'FAILED' ? response.error?.toString() : undefined,
382
+ data: {
383
+ code: response.code,
384
+ status: response.status
385
+ }
386
+ };
387
+ }
388
+ return { ok: false, error: 'Unsupported python action.' };
389
+ }
390
+ return { execute };
391
+ }
392
+ //# sourceMappingURL=pythonActions.js.map