@mcoda/mswarm 0.1.135-codali.4 → 0.1.135-codali.40

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 (340) hide show
  1. package/README.md +5 -0
  2. package/dist/codali-executor.d.ts +19 -0
  3. package/dist/codali-executor.d.ts.map +1 -1
  4. package/dist/codali-executor.js +54 -2
  5. package/dist/codali-executor.js.map +1 -1
  6. package/dist/runtime.d.ts +3 -0
  7. package/dist/runtime.d.ts.map +1 -1
  8. package/dist/runtime.js +36 -7
  9. package/dist/runtime.js.map +1 -1
  10. package/dist/vendor/codali/cli/TerminalArtifacts.d.ts +5 -0
  11. package/dist/vendor/codali/cli/TerminalArtifacts.d.ts.map +1 -0
  12. package/dist/vendor/codali/cli/TerminalArtifacts.js +26 -0
  13. package/dist/vendor/codali/cli/TerminalCommand.d.ts +2 -1
  14. package/dist/vendor/codali/cli/TerminalCommand.d.ts.map +1 -1
  15. package/dist/vendor/codali/cli/TerminalCommand.js +436 -100
  16. package/dist/vendor/codali/cli/TerminalInput.d.ts +13 -0
  17. package/dist/vendor/codali/cli/TerminalInput.d.ts.map +1 -1
  18. package/dist/vendor/codali/cli/TerminalInput.js +55 -7
  19. package/dist/vendor/codali/cli/TerminalModels.d.ts +6 -0
  20. package/dist/vendor/codali/cli/TerminalModels.d.ts.map +1 -0
  21. package/dist/vendor/codali/cli/TerminalModels.js +45 -0
  22. package/dist/vendor/codali/cli/TerminalPlan.d.ts +40 -0
  23. package/dist/vendor/codali/cli/TerminalPlan.d.ts.map +1 -0
  24. package/dist/vendor/codali/cli/TerminalPlan.js +37 -0
  25. package/dist/vendor/codali/cli/ToolsCommand.d.ts.map +1 -1
  26. package/dist/vendor/codali/cli/ToolsCommand.js +8 -1
  27. package/dist/vendor/codali/cli/tui/TerminalCells.d.ts +6 -0
  28. package/dist/vendor/codali/cli/tui/TerminalCells.d.ts.map +1 -0
  29. package/dist/vendor/codali/cli/tui/TerminalCells.js +47 -0
  30. package/dist/vendor/codali/cli/tui/TerminalEditor.d.ts +22 -0
  31. package/dist/vendor/codali/cli/tui/TerminalEditor.d.ts.map +1 -0
  32. package/dist/vendor/codali/cli/tui/TerminalEditor.js +88 -0
  33. package/dist/vendor/codali/cli/tui/TerminalLogo.d.ts +6 -0
  34. package/dist/vendor/codali/cli/tui/TerminalLogo.d.ts.map +1 -0
  35. package/dist/vendor/codali/cli/tui/TerminalLogo.js +26 -0
  36. package/dist/vendor/codali/cli/tui/TerminalMarkdown.d.ts +5 -0
  37. package/dist/vendor/codali/cli/tui/TerminalMarkdown.d.ts.map +1 -0
  38. package/dist/vendor/codali/cli/tui/TerminalMarkdown.js +118 -0
  39. package/dist/vendor/codali/cli/tui/TerminalPresentation.d.ts +6 -0
  40. package/dist/vendor/codali/cli/tui/TerminalPresentation.d.ts.map +1 -0
  41. package/dist/vendor/codali/cli/tui/TerminalPresentation.js +152 -0
  42. package/dist/vendor/codali/cli/tui/TerminalScreen.d.ts +50 -0
  43. package/dist/vendor/codali/cli/tui/TerminalScreen.d.ts.map +1 -0
  44. package/dist/vendor/codali/cli/tui/TerminalScreen.js +137 -0
  45. package/dist/vendor/codali/cli/tui/TerminalSelection.d.ts +15 -0
  46. package/dist/vendor/codali/cli/tui/TerminalSelection.d.ts.map +1 -0
  47. package/dist/vendor/codali/cli/tui/TerminalSelection.js +38 -0
  48. package/dist/vendor/codali/cli/tui/TerminalTui.d.ts +82 -0
  49. package/dist/vendor/codali/cli/tui/TerminalTui.d.ts.map +1 -0
  50. package/dist/vendor/codali/cli/tui/TerminalTui.js +564 -0
  51. package/dist/vendor/codali/cli.d.ts.map +1 -1
  52. package/dist/vendor/codali/cli.js +5 -3
  53. package/dist/vendor/codali/config/OrchestrationConfig.d.ts +40 -0
  54. package/dist/vendor/codali/config/OrchestrationConfig.d.ts.map +1 -1
  55. package/dist/vendor/codali/config/OrchestrationConfig.js +74 -3
  56. package/dist/vendor/codali/connectors/media/MediaJobStore.d.ts +2 -1
  57. package/dist/vendor/codali/connectors/media/MediaJobStore.d.ts.map +1 -1
  58. package/dist/vendor/codali/connectors/media/MediaJobStore.js +11 -3
  59. package/dist/vendor/codali/docdex/DocdexCatalog.d.ts +12 -0
  60. package/dist/vendor/codali/docdex/DocdexCatalog.d.ts.map +1 -0
  61. package/dist/vendor/codali/docdex/DocdexCatalog.js +30 -0
  62. package/dist/vendor/codali/docdex/DocdexClient.d.ts +15 -2
  63. package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -1
  64. package/dist/vendor/codali/docdex/DocdexClient.js +119 -12
  65. package/dist/vendor/codali/docdex/ManagedDocdex.d.ts +4 -0
  66. package/dist/vendor/codali/docdex/ManagedDocdex.d.ts.map +1 -1
  67. package/dist/vendor/codali/docdex/ManagedDocdex.js +42 -5
  68. package/dist/vendor/codali/eval/EvaluationProcess.d.ts.map +1 -1
  69. package/dist/vendor/codali/eval/EvaluationProcess.js +4 -0
  70. package/dist/vendor/codali/eval/TerminalWorkflowCorpus.d.ts +1 -1
  71. package/dist/vendor/codali/eval/TerminalWorkflowCorpus.d.ts.map +1 -1
  72. package/dist/vendor/codali/eval/TerminalWorkflowCorpus.js +9 -6
  73. package/dist/vendor/codali/eval/TrustBenchmark.d.ts +94 -0
  74. package/dist/vendor/codali/eval/TrustBenchmark.d.ts.map +1 -0
  75. package/dist/vendor/codali/eval/TrustBenchmark.js +199 -0
  76. package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.d.ts +4 -0
  77. package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.d.ts.map +1 -0
  78. package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.js +10 -0
  79. package/dist/vendor/codali/eval/fixtures/MixedMediaRecoveryJourney.d.ts +6 -0
  80. package/dist/vendor/codali/eval/fixtures/MixedMediaRecoveryJourney.d.ts.map +1 -0
  81. package/dist/vendor/codali/eval/fixtures/MixedMediaRecoveryJourney.js +145 -0
  82. package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.d.ts.map +1 -1
  83. package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.js +14 -1
  84. package/dist/vendor/codali/gateway/GroundingMode.d.ts.map +1 -1
  85. package/dist/vendor/codali/gateway/GroundingMode.js +23 -3
  86. package/dist/vendor/codali/index.d.ts +1 -0
  87. package/dist/vendor/codali/index.d.ts.map +1 -1
  88. package/dist/vendor/codali/index.js +1 -0
  89. package/dist/vendor/codali/permissions/PermissionGate.d.ts +4 -1
  90. package/dist/vendor/codali/permissions/PermissionGate.d.ts.map +1 -1
  91. package/dist/vendor/codali/permissions/PermissionGate.js +50 -5
  92. package/dist/vendor/codali/permissions/WorkspacePermissions.d.ts +11 -0
  93. package/dist/vendor/codali/permissions/WorkspacePermissions.d.ts.map +1 -0
  94. package/dist/vendor/codali/permissions/WorkspacePermissions.js +42 -0
  95. package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts +1 -0
  96. package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts.map +1 -1
  97. package/dist/vendor/codali/providers/ConfiguredModelScope.js +19 -2
  98. package/dist/vendor/codali/providers/ConfiguredProvider.d.ts +10 -1
  99. package/dist/vendor/codali/providers/ConfiguredProvider.d.ts.map +1 -1
  100. package/dist/vendor/codali/providers/ConfiguredProvider.js +104 -37
  101. package/dist/vendor/codali/providers/ModelCapacityWait.d.ts +21 -0
  102. package/dist/vendor/codali/providers/ModelCapacityWait.d.ts.map +1 -0
  103. package/dist/vendor/codali/providers/ModelCapacityWait.js +40 -0
  104. package/dist/vendor/codali/providers/ModelServiceError.d.ts +16 -2
  105. package/dist/vendor/codali/providers/ModelServiceError.d.ts.map +1 -1
  106. package/dist/vendor/codali/providers/ModelServiceError.js +37 -5
  107. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts +8 -0
  108. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
  109. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +38 -3
  110. package/dist/vendor/codali/providers/ProviderTypes.d.ts +9 -0
  111. package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -1
  112. package/dist/vendor/codali/providers/RequestSize.d.ts +5 -0
  113. package/dist/vendor/codali/providers/RequestSize.d.ts.map +1 -0
  114. package/dist/vendor/codali/providers/RequestSize.js +10 -0
  115. package/dist/vendor/codali/providers/RequestUsage.d.ts +11 -0
  116. package/dist/vendor/codali/providers/RequestUsage.d.ts.map +1 -0
  117. package/dist/vendor/codali/providers/RequestUsage.js +33 -0
  118. package/dist/vendor/codali/runtime/AnswerVerification.d.ts +17 -0
  119. package/dist/vendor/codali/runtime/AnswerVerification.d.ts.map +1 -0
  120. package/dist/vendor/codali/runtime/AnswerVerification.js +39 -0
  121. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +1 -0
  122. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -1
  123. package/dist/vendor/codali/runtime/CodaliRuntime.js +1 -0
  124. package/dist/vendor/codali/runtime/CompletionReport.d.ts +8 -0
  125. package/dist/vendor/codali/runtime/CompletionReport.d.ts.map +1 -1
  126. package/dist/vendor/codali/runtime/CompletionReport.js +25 -0
  127. package/dist/vendor/codali/runtime/ComputedAnswer.d.ts +13 -0
  128. package/dist/vendor/codali/runtime/ComputedAnswer.d.ts.map +1 -0
  129. package/dist/vendor/codali/runtime/ComputedAnswer.js +75 -0
  130. package/dist/vendor/codali/runtime/ContextCompression.d.ts +41 -0
  131. package/dist/vendor/codali/runtime/ContextCompression.d.ts.map +1 -0
  132. package/dist/vendor/codali/runtime/ContextCompression.js +292 -0
  133. package/dist/vendor/codali/runtime/GatewayRequest.d.ts +5 -0
  134. package/dist/vendor/codali/runtime/GatewayRequest.d.ts.map +1 -0
  135. package/dist/vendor/codali/runtime/GatewayRequest.js +19 -0
  136. package/dist/vendor/codali/runtime/InspectionBudget.d.ts +11 -0
  137. package/dist/vendor/codali/runtime/InspectionBudget.d.ts.map +1 -0
  138. package/dist/vendor/codali/runtime/InspectionBudget.js +23 -0
  139. package/dist/vendor/codali/runtime/InspectionConvergence.d.ts +24 -0
  140. package/dist/vendor/codali/runtime/InspectionConvergence.d.ts.map +1 -0
  141. package/dist/vendor/codali/runtime/InspectionConvergence.js +67 -0
  142. package/dist/vendor/codali/runtime/InteractionContract.d.ts +44 -0
  143. package/dist/vendor/codali/runtime/InteractionContract.d.ts.map +1 -0
  144. package/dist/vendor/codali/runtime/InteractionContract.js +64 -0
  145. package/dist/vendor/codali/runtime/InteractionRouter.d.ts +73 -0
  146. package/dist/vendor/codali/runtime/InteractionRouter.d.ts.map +1 -0
  147. package/dist/vendor/codali/runtime/InteractionRouter.js +139 -0
  148. package/dist/vendor/codali/runtime/OutageWait.d.ts +14 -0
  149. package/dist/vendor/codali/runtime/OutageWait.d.ts.map +1 -0
  150. package/dist/vendor/codali/runtime/OutageWait.js +33 -0
  151. package/dist/vendor/codali/runtime/PlanCoverage.d.ts +9 -0
  152. package/dist/vendor/codali/runtime/PlanCoverage.d.ts.map +1 -0
  153. package/dist/vendor/codali/runtime/PlanCoverage.js +12 -0
  154. package/dist/vendor/codali/runtime/PreparedDocdex.d.ts +4 -0
  155. package/dist/vendor/codali/runtime/PreparedDocdex.d.ts.map +1 -0
  156. package/dist/vendor/codali/runtime/PreparedDocdex.js +55 -0
  157. package/dist/vendor/codali/runtime/PreparedMemory.d.ts +3 -0
  158. package/dist/vendor/codali/runtime/PreparedMemory.d.ts.map +1 -0
  159. package/dist/vendor/codali/runtime/PreparedMemory.js +30 -0
  160. package/dist/vendor/codali/runtime/ProgressTracker.d.ts +1 -0
  161. package/dist/vendor/codali/runtime/ProgressTracker.d.ts.map +1 -1
  162. package/dist/vendor/codali/runtime/ProgressTracker.js +25 -5
  163. package/dist/vendor/codali/runtime/ResearchEvidence.d.ts +19 -0
  164. package/dist/vendor/codali/runtime/ResearchEvidence.d.ts.map +1 -0
  165. package/dist/vendor/codali/runtime/ResearchEvidence.js +55 -0
  166. package/dist/vendor/codali/runtime/ReviewContract.d.ts +35 -0
  167. package/dist/vendor/codali/runtime/ReviewContract.d.ts.map +1 -0
  168. package/dist/vendor/codali/runtime/ReviewContract.js +132 -0
  169. package/dist/vendor/codali/runtime/ReviewCoordinator.d.ts +43 -0
  170. package/dist/vendor/codali/runtime/ReviewCoordinator.d.ts.map +1 -0
  171. package/dist/vendor/codali/runtime/ReviewCoordinator.js +134 -0
  172. package/dist/vendor/codali/runtime/ReviewSource.d.ts +3 -0
  173. package/dist/vendor/codali/runtime/ReviewSource.d.ts.map +1 -1
  174. package/dist/vendor/codali/runtime/ReviewSource.js +17 -1
  175. package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -1
  176. package/dist/vendor/codali/runtime/Runner.js +6 -1
  177. package/dist/vendor/codali/runtime/SessionController.d.ts +142 -6
  178. package/dist/vendor/codali/runtime/SessionController.d.ts.map +1 -1
  179. package/dist/vendor/codali/runtime/SessionController.js +2296 -228
  180. package/dist/vendor/codali/runtime/SpecialistTools.d.ts +8 -0
  181. package/dist/vendor/codali/runtime/SpecialistTools.d.ts.map +1 -0
  182. package/dist/vendor/codali/runtime/SpecialistTools.js +85 -0
  183. package/dist/vendor/codali/runtime/StructuralEvidence.d.ts +4 -2
  184. package/dist/vendor/codali/runtime/StructuralEvidence.d.ts.map +1 -1
  185. package/dist/vendor/codali/runtime/StructuralEvidence.js +22 -5
  186. package/dist/vendor/codali/runtime/TaskReview.d.ts +25 -0
  187. package/dist/vendor/codali/runtime/TaskReview.d.ts.map +1 -0
  188. package/dist/vendor/codali/runtime/TaskReview.js +109 -0
  189. package/dist/vendor/codali/runtime/TaskReviewContext.d.ts +37 -0
  190. package/dist/vendor/codali/runtime/TaskReviewContext.d.ts.map +1 -1
  191. package/dist/vendor/codali/runtime/TaskReviewContext.js +18 -2
  192. package/dist/vendor/codali/runtime/UsageReconciliation.d.ts +28 -0
  193. package/dist/vendor/codali/runtime/UsageReconciliation.d.ts.map +1 -0
  194. package/dist/vendor/codali/runtime/UsageReconciliation.js +68 -0
  195. package/dist/vendor/codali/runtime/VerificationReceiptSelection.d.ts +15 -0
  196. package/dist/vendor/codali/runtime/VerificationReceiptSelection.d.ts.map +1 -0
  197. package/dist/vendor/codali/runtime/VerificationReceiptSelection.js +30 -0
  198. package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts +2 -0
  199. package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts.map +1 -1
  200. package/dist/vendor/codali/runtime/WorkspaceLedger.js +44 -20
  201. package/dist/vendor/codali/runtime/WorkspaceLock.d.ts.map +1 -1
  202. package/dist/vendor/codali/runtime/WorkspaceLock.js +9 -1
  203. package/dist/vendor/codali/runtime/WorkspaceSnapshot.d.ts.map +1 -1
  204. package/dist/vendor/codali/runtime/WorkspaceSnapshot.js +3 -2
  205. package/dist/vendor/codali/runtime/WriteSyntaxCheck.d.ts +10 -0
  206. package/dist/vendor/codali/runtime/WriteSyntaxCheck.d.ts.map +1 -0
  207. package/dist/vendor/codali/runtime/WriteSyntaxCheck.js +34 -0
  208. package/dist/vendor/codali/session/InstructionLoader.d.ts +5 -1
  209. package/dist/vendor/codali/session/InstructionLoader.d.ts.map +1 -1
  210. package/dist/vendor/codali/session/InstructionLoader.js +65 -19
  211. package/dist/vendor/codali/session/SessionStoragePath.d.ts.map +1 -1
  212. package/dist/vendor/codali/session/SessionStoragePath.js +34 -17
  213. package/dist/vendor/codali/session/SessionStore.d.ts +6 -1
  214. package/dist/vendor/codali/session/SessionStore.d.ts.map +1 -1
  215. package/dist/vendor/codali/session/SessionStore.js +108 -43
  216. package/dist/vendor/codali/session/SkillCatalog.d.ts +33 -0
  217. package/dist/vendor/codali/session/SkillCatalog.d.ts.map +1 -0
  218. package/dist/vendor/codali/session/SkillCatalog.js +197 -0
  219. package/dist/vendor/codali/session/WorkState.d.ts +16 -2
  220. package/dist/vendor/codali/session/WorkState.d.ts.map +1 -1
  221. package/dist/vendor/codali/session/WorkState.js +55 -5
  222. package/dist/vendor/codali/session/WorkTypes.d.ts +8 -0
  223. package/dist/vendor/codali/session/WorkTypes.d.ts.map +1 -1
  224. package/dist/vendor/codali/session/WorkspaceScope.d.ts +3 -0
  225. package/dist/vendor/codali/session/WorkspaceScope.d.ts.map +1 -0
  226. package/dist/vendor/codali/session/WorkspaceScope.js +19 -0
  227. package/dist/vendor/codali/tools/SemanticToolRetrieval.d.ts +19 -0
  228. package/dist/vendor/codali/tools/SemanticToolRetrieval.d.ts.map +1 -0
  229. package/dist/vendor/codali/tools/SemanticToolRetrieval.js +52 -0
  230. package/dist/vendor/codali/tools/ToolRetrieval.d.ts +7 -0
  231. package/dist/vendor/codali/tools/ToolRetrieval.d.ts.map +1 -0
  232. package/dist/vendor/codali/tools/ToolRetrieval.js +25 -0
  233. package/dist/vendor/codali/tools/ToolTypes.d.ts +5 -0
  234. package/dist/vendor/codali/tools/ToolTypes.d.ts.map +1 -1
  235. package/dist/vendor/codali/tools/browser/BrowserSessionTool.d.ts +16 -0
  236. package/dist/vendor/codali/tools/browser/BrowserSessionTool.d.ts.map +1 -0
  237. package/dist/vendor/codali/tools/browser/BrowserSessionTool.js +326 -0
  238. package/dist/vendor/codali/tools/browser/BrowserTool.d.ts +17 -0
  239. package/dist/vendor/codali/tools/browser/BrowserTool.d.ts.map +1 -0
  240. package/dist/vendor/codali/tools/browser/BrowserTool.js +291 -0
  241. package/dist/vendor/codali/tools/browser/BrowserWorker.d.ts +2 -0
  242. package/dist/vendor/codali/tools/browser/BrowserWorker.d.ts.map +1 -0
  243. package/dist/vendor/codali/tools/browser/BrowserWorker.js +121 -0
  244. package/dist/vendor/codali/tools/calculation/CalculatorTool.d.ts +5 -0
  245. package/dist/vendor/codali/tools/calculation/CalculatorTool.d.ts.map +1 -0
  246. package/dist/vendor/codali/tools/calculation/CalculatorTool.js +191 -0
  247. package/dist/vendor/codali/tools/deterministic/DeterministicRuntime.d.ts +39 -0
  248. package/dist/vendor/codali/tools/deterministic/DeterministicRuntime.d.ts.map +1 -0
  249. package/dist/vendor/codali/tools/deterministic/DeterministicRuntime.js +98 -0
  250. package/dist/vendor/codali/tools/deterministic/DeterministicTools.d.ts +8 -0
  251. package/dist/vendor/codali/tools/deterministic/DeterministicTools.d.ts.map +1 -0
  252. package/dist/vendor/codali/tools/deterministic/DeterministicTools.js +100 -0
  253. package/dist/vendor/codali/tools/deterministic/node-worker.cjs +38 -0
  254. package/dist/vendor/codali/tools/deterministic/python-worker.py +237 -0
  255. package/dist/vendor/codali/tools/docdex/DocdexCatalogTools.d.ts +4 -0
  256. package/dist/vendor/codali/tools/docdex/DocdexCatalogTools.d.ts.map +1 -0
  257. package/dist/vendor/codali/tools/docdex/DocdexCatalogTools.js +59 -0
  258. package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts +2 -0
  259. package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts.map +1 -1
  260. package/dist/vendor/codali/tools/docdex/DocdexTools.js +81 -106
  261. package/dist/vendor/codali/tools/documents/DocumentRuntime.d.ts +12 -0
  262. package/dist/vendor/codali/tools/documents/DocumentRuntime.d.ts.map +1 -0
  263. package/dist/vendor/codali/tools/documents/DocumentRuntime.js +59 -0
  264. package/dist/vendor/codali/tools/documents/DocumentTools.d.ts +19 -0
  265. package/dist/vendor/codali/tools/documents/DocumentTools.d.ts.map +1 -0
  266. package/dist/vendor/codali/tools/documents/DocumentTools.js +150 -0
  267. package/dist/vendor/codali/tools/documents/worker.py +267 -0
  268. package/dist/vendor/codali/tools/entities/AdesTool.d.ts +7 -0
  269. package/dist/vendor/codali/tools/entities/AdesTool.d.ts.map +1 -0
  270. package/dist/vendor/codali/tools/entities/AdesTool.js +59 -0
  271. package/dist/vendor/codali/tools/filesystem/FileTools.d.ts.map +1 -1
  272. package/dist/vendor/codali/tools/filesystem/FileTools.js +62 -11
  273. package/dist/vendor/codali/tools/research/TnlTool.d.ts +22 -0
  274. package/dist/vendor/codali/tools/research/TnlTool.d.ts.map +1 -0
  275. package/dist/vendor/codali/tools/research/TnlTool.js +246 -0
  276. package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts +4 -0
  277. package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts.map +1 -1
  278. package/dist/vendor/codali/tools/shell/AsyncProcess.js +9 -3
  279. package/dist/vendor/codali/tools/shell/HostToolchain.d.ts +7 -0
  280. package/dist/vendor/codali/tools/shell/HostToolchain.d.ts.map +1 -1
  281. package/dist/vendor/codali/tools/shell/HostToolchain.js +65 -4
  282. package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts +5 -2
  283. package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts.map +1 -1
  284. package/dist/vendor/codali/tools/shell/IsolatedExecutor.js +148 -29
  285. package/dist/vendor/codali/tools/shell/ShellTool.d.ts +2 -0
  286. package/dist/vendor/codali/tools/shell/ShellTool.d.ts.map +1 -1
  287. package/dist/vendor/codali/tools/shell/ShellTool.js +19 -4
  288. package/dist/vendor/codali/tools/system/CalendarTool.d.ts +15 -0
  289. package/dist/vendor/codali/tools/system/CalendarTool.d.ts.map +1 -0
  290. package/dist/vendor/codali/tools/system/CalendarTool.js +44 -0
  291. package/dist/vendor/codali/tools/system/TextTool.d.ts +4 -0
  292. package/dist/vendor/codali/tools/system/TextTool.d.ts.map +1 -0
  293. package/dist/vendor/codali/tools/system/TextTool.js +39 -0
  294. package/dist/vendor/codali/tools/system/TimeTool.d.ts +4 -0
  295. package/dist/vendor/codali/tools/system/TimeTool.d.ts.map +1 -0
  296. package/dist/vendor/codali/tools/system/TimeTool.js +22 -0
  297. package/dist/vendor/codali/tools/verification/JavaScriptVerificationTool.d.ts +47 -0
  298. package/dist/vendor/codali/tools/verification/JavaScriptVerificationTool.d.ts.map +1 -0
  299. package/dist/vendor/codali/tools/verification/JavaScriptVerificationTool.js +71 -0
  300. package/dist/vendor/codali/tools/verification/JavaScriptVerificationWorker.d.ts +2 -0
  301. package/dist/vendor/codali/tools/verification/JavaScriptVerificationWorker.d.ts.map +1 -0
  302. package/dist/vendor/codali/tools/verification/JavaScriptVerificationWorker.js +91 -0
  303. package/dist/vendor/codali/tools/verification/VitestTool.d.ts +6 -0
  304. package/dist/vendor/codali/tools/verification/VitestTool.d.ts.map +1 -0
  305. package/dist/vendor/codali/tools/verification/VitestTool.js +184 -0
  306. package/dist/vendor/config/AGENTS.md +17 -0
  307. package/dist/vendor/config/deterministic/install-python.mjs +16 -0
  308. package/dist/vendor/config/deterministic/node-worker.mjs +77 -0
  309. package/dist/vendor/config/deterministic/python-worker.py +237 -0
  310. package/dist/vendor/config/deterministic/requirements.txt +6 -0
  311. package/dist/vendor/config/docdex-runtime.json +21 -0
  312. package/dist/vendor/config/docdex-tools-0.2.99.json +3977 -0
  313. package/dist/vendor/config/documents/install-python.mjs +16 -0
  314. package/dist/vendor/config/documents/requirements.txt +10 -0
  315. package/dist/vendor/config/documents/worker.py +267 -0
  316. package/dist/vendor/config/skills/architecture-design/SKILL.md +14 -0
  317. package/dist/vendor/config/skills/browser-session/SKILL.md +16 -0
  318. package/dist/vendor/config/skills/browser-use/SKILL.md +14 -0
  319. package/dist/vendor/config/skills/code-implementation/SKILL.md +18 -0
  320. package/dist/vendor/config/skills/code-review/SKILL.md +14 -0
  321. package/dist/vendor/config/skills/docdex-research/SKILL.md +18 -0
  322. package/dist/vendor/config/skills/docdex-research/references/catalog.md +111 -0
  323. package/dist/vendor/config/skills/docdex-research/references/memory.md +22 -0
  324. package/dist/vendor/config/skills/docdex-research/references/operations.md +19 -0
  325. package/dist/vendor/config/skills/docdex-research/references/retrieval.md +13 -0
  326. package/dist/vendor/config/skills/planning/SKILL.md +14 -0
  327. package/dist/vendor/config/skills/system-diagnostics/SKILL.md +14 -0
  328. package/dist/vendor/config/skills/system-services/SKILL.md +17 -0
  329. package/dist/vendor/config/skills/system-services/references/docker.md +11 -0
  330. package/dist/vendor/config/skills/system-services/references/linux.md +9 -0
  331. package/dist/vendor/config/skills/system-services/references/macos.md +9 -0
  332. package/dist/vendor/config/skills/systematic-debugging/SKILL.md +14 -0
  333. package/dist/vendor/config/skills/testing-and-verification/SKILL.md +16 -0
  334. package/dist/vendor/config/skills/tool-selection/SKILL.md +16 -0
  335. package/dist/vendor/config/skills/ui-ux-design/SKILL.md +16 -0
  336. package/dist/vendor/config/skills/ui-ux-design/references/validation.md +13 -0
  337. package/dist/vendor/config/skills/webapp-testing/SKILL.md +12 -0
  338. package/package.json +15 -5
  339. package/scripts/media_gpu_lock.py +2 -2
  340. package/scripts/native_load_guard.py +257 -0
@@ -0,0 +1,3 @@
1
+ export declare const isWithinScope: (file: string, scopes: readonly string[]) => boolean;
2
+ export declare const scopesOverlap: (a: string, b: string) => boolean;
3
+ //# sourceMappingURL=WorkspaceScope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkspaceScope.d.ts","sourceRoot":"","sources":["../../src/session/WorkspaceScope.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,EAAE,QAAQ,SAAS,MAAM,EAAE,KAAG,OAOvE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,OAAyD,CAAC"}
@@ -0,0 +1,19 @@
1
+ import path from "node:path";
2
+ /** POSIX workspace-relative scopes. Normalize harmless directory notation only;
3
+ * never normalize away traversal or interpret an empty scope as the root. */
4
+ const canonical = (value) => {
5
+ if (!value || value.includes("\0") || value.includes("\\") || path.posix.isAbsolute(value)
6
+ || /^[A-Za-z]:/.test(value) || value.split("/").includes(".."))
7
+ return;
8
+ return path.posix.normalize(value).replace(/\/$/, "");
9
+ };
10
+ export const isWithinScope = (file, scopes) => {
11
+ const target = canonical(file);
12
+ if (target === undefined)
13
+ return false;
14
+ return scopes.some(value => {
15
+ const scope = canonical(value);
16
+ return scope !== undefined && (scope === "." || target === scope || target.startsWith(`${scope}/`));
17
+ });
18
+ };
19
+ export const scopesOverlap = (a, b) => isWithinScope(a, [b]) || isWithinScope(b, [a]);
@@ -0,0 +1,19 @@
1
+ import type { ConfiguredEmbeddings } from "../providers/ConfiguredEmbeddings.js";
2
+ import type { ToolDefinition } from "./ToolTypes.js";
3
+ export interface ToolRetrievalEvidence {
4
+ method: "semantic-metadata-v1";
5
+ catalogHash: string;
6
+ spaceId: string;
7
+ cacheHit: boolean;
8
+ documents: number;
9
+ elapsedMs: number;
10
+ }
11
+ /** Cache only public tool metadata vectors, keyed by pinned model and content. */
12
+ export declare function retrieveSemanticTools(query: string, tools: readonly ToolDefinition[], embeddings: ConfiguredEmbeddings, cacheRoot: string, signal?: AbortSignal, limit?: number): Promise<{
13
+ ranked: Array<{
14
+ tool: ToolDefinition;
15
+ score: number;
16
+ }>;
17
+ evidence: ToolRetrievalEvidence;
18
+ }>;
19
+ //# sourceMappingURL=SemanticToolRetrieval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SemanticToolRetrieval.d.ts","sourceRoot":"","sources":["../../src/tools/SemanticToolRetrieval.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,MAAM,WAAW,qBAAqB;IAAG,MAAM,EAAE,sBAAsB,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;CAAE;AAOzK,kFAAkF;AAClF,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,cAAc,EAAE,EAAE,UAAU,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,EAC9I,MAAM,CAAC,EAAE,WAAW,EAAE,KAAK,SAAI,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,cAAc,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,QAAQ,EAAE,qBAAqB,CAAA;CAAE,CAAC,CA2BvI"}
@@ -0,0 +1,52 @@
1
+ import { promises as fs } from "node:fs";
2
+ import { createHash } from "node:crypto";
3
+ import path from "node:path";
4
+ import { atomicWriteJson, withStateLock } from "../session/AtomicState.js";
5
+ import { retrieveTools } from "./ToolRetrieval.js";
6
+ const cosine = (a, b) => {
7
+ let dot = 0, aa = 0, bb = 0;
8
+ for (let i = 0; i < a.length; i++) {
9
+ dot += a[i] * b[i];
10
+ aa += a[i] * a[i];
11
+ bb += b[i] * b[i];
12
+ }
13
+ return aa && bb ? dot / Math.sqrt(aa * bb) : 0;
14
+ };
15
+ /** Cache only public tool metadata vectors, keyed by pinned model and content. */
16
+ export async function retrieveSemanticTools(query, tools, embeddings, cacheRoot, signal, limit = 3) {
17
+ const started = Date.now();
18
+ const ordered = [...tools].sort((a, b) => a.name.localeCompare(b.name));
19
+ const documents = ordered.map(tool => `${tool.name.replace(/_/g, " ")}: ${tool.description.slice(0, 700)}`);
20
+ const catalogHash = createHash("sha256").update(JSON.stringify(documents)).digest("hex");
21
+ const file = path.join(cacheRoot, embeddings.space.id, `${catalogHash}.json`);
22
+ const valid = (value) => Array.isArray(value) && value.length === tools.length
23
+ && value.every(row => Array.isArray(row) && row.length === embeddings.space.dimensions && row.every(v => typeof v === "number" && Number.isFinite(v)));
24
+ let cacheHit = false;
25
+ const vectors = await withStateLock(file, async () => {
26
+ try {
27
+ const cached = JSON.parse(await fs.readFile(file, "utf8"));
28
+ if (cached.catalogHash === catalogHash && cached.spaceId === embeddings.space.id && valid(cached.vectors)) {
29
+ cacheHit = true;
30
+ return cached.vectors;
31
+ }
32
+ }
33
+ catch (error) {
34
+ if (error.code !== "ENOENT" && !(error instanceof SyntaxError))
35
+ throw error;
36
+ }
37
+ const result = [];
38
+ // Small batches fit the service's bounded input contract; every call is metered.
39
+ for (let start = 0; start < documents.length; start += 64)
40
+ result.push(...await embeddings.embed(documents.slice(start, start + 64), "document", signal));
41
+ if (!valid(result))
42
+ throw Error("Invalid tool metadata embeddings");
43
+ await atomicWriteJson(file, { schemaVersion: 1, catalogHash, spaceId: embeddings.space.id, createdAt: new Date().toISOString(), names: ordered.map(tool => tool.name), vectors: result });
44
+ return result;
45
+ });
46
+ const [wanted] = await embeddings.embed([query.slice(0, 4000)], "query", signal);
47
+ const lexical = new Map(retrieveTools(query, tools, 8).map(item => [item.tool.name, item.score]));
48
+ const maxLexical = Math.max(1, ...lexical.values());
49
+ const ranked = ordered.map((tool, i) => ({ tool, score: cosine(wanted, vectors[i]) + .03 * (lexical.get(tool.name) ?? 0) / maxLexical }))
50
+ .sort((a, b) => b.score - a.score || a.tool.name.localeCompare(b.tool.name)).slice(0, Math.max(1, Math.min(8, limit)));
51
+ return { ranked, evidence: { method: "semantic-metadata-v1", catalogHash, spaceId: embeddings.space.id, cacheHit, documents: tools.length, elapsedMs: Date.now() - started } };
52
+ }
@@ -0,0 +1,7 @@
1
+ import type { ToolDefinition } from "./ToolTypes.js";
2
+ /** Generic lexical retrieval over tool metadata, not a request-type router. */
3
+ export declare const retrieveTools: (query: string, tools: readonly ToolDefinition[], limit?: number) => Array<{
4
+ tool: ToolDefinition;
5
+ score: number;
6
+ }>;
7
+ //# sourceMappingURL=ToolRetrieval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolRetrieval.d.ts","sourceRoot":"","sources":["../../src/tools/ToolRetrieval.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMrD,+EAA+E;AAC/E,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,OAAO,SAAS,cAAc,EAAE,EAAE,cAAS,KAAG,KAAK,CAAC;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAgBvI,CAAC"}
@@ -0,0 +1,25 @@
1
+ const stop = new Set("a an and are as at be by can do for from how i in is it me of on or please that the this to use what with you your".split(" "));
2
+ const terms = (value) => (value.normalize("NFKC").replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? [])
3
+ .filter(term => term.length > 1 && !stop.has(term)).map(term => term.length > 5 ? term.replace(/(?:ing|ed|s)$/, "") : term);
4
+ /** Generic lexical retrieval over tool metadata, not a request-type router. */
5
+ export const retrieveTools = (query, tools, limit = 3) => {
6
+ const wanted = [...new Set(terms(query))];
7
+ if (!wanted.length)
8
+ return [];
9
+ const documents = tools.map(tool => {
10
+ const counts = new Map();
11
+ for (const word of terms(`${tool.name.replace(/_/g, " ")} ${tool.name.replace(/_/g, " ")} ${tool.description} ${Object.keys(tool.inputSchema?.properties ?? {}).join(" ")}`))
12
+ counts.set(word, (counts.get(word) ?? 0) + 1);
13
+ return { tool, counts, length: [...counts.values()].reduce((a, b) => a + b, 0) };
14
+ });
15
+ const average = documents.reduce((n, doc) => n + doc.length, 0) / Math.max(1, documents.length);
16
+ const frequencies = new Map(wanted.map(term => [term, documents.filter(doc => doc.counts.has(term)).length]));
17
+ return documents.map(doc => ({ tool: doc.tool, score: wanted.reduce((score, term) => {
18
+ const tf = doc.counts.get(term) ?? 0;
19
+ if (!tf)
20
+ return score;
21
+ const df = frequencies.get(term);
22
+ const idf = Math.log(1 + (documents.length - df + .5) / (df + .5));
23
+ return score + idf * tf * 2.2 / (tf + 1.2 * (.25 + .75 * doc.length / Math.max(1, average)));
24
+ }, 0) })).filter(item => item.score > 0).sort((a, b) => b.score - a.score || a.tool.name.localeCompare(b.tool.name)).slice(0, Math.max(0, Math.min(8, limit)));
25
+ };
@@ -16,8 +16,13 @@ export interface ToolContext {
16
16
  allowOutsideWorkspace?: boolean;
17
17
  allowedReadPaths?: string[];
18
18
  allowedWritePaths?: string[];
19
+ /** Trusted workspace input paths, read-only even within a writable parent. */
20
+ protectedPaths?: string[];
19
21
  allowShell?: boolean;
20
22
  allowDestructiveOperations?: boolean;
23
+ /** Set by a host whose shell executor confines writes to scratch and the
24
+ * declared write paths, so a delete cannot reach anything else. */
25
+ shellIsolated?: boolean;
21
26
  shellAllowlist?: string[];
22
27
  }
23
28
  export type ToolSchemaPrimitiveType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
@@ -1 +1 @@
1
- {"version":3,"file":"ToolTypes.d.ts","sourceRoot":"","sources":["../../src/tools/ToolTypes.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChG,SAAS,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,oFAAoF;IACpF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,8EAA8E;IAC9E,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACtG,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,qBAAqB,CAAC,EA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,OAAO,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,cAAc,CAAC;CAC5B;AAED,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAEjD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,MAAM,MAAM,KAAG,cAapD,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type ToolDefinition } from '../ToolTypes.js';
2
+ export declare const browserSessionName: (workspace: string) => string;
3
+ export interface DesktopStatus {
4
+ running: boolean;
5
+ name: string;
6
+ url?: string;
7
+ previewUrl?: string;
8
+ browserPreviewUrl?: string;
9
+ cdpUrl?: string;
10
+ sshForward?: string;
11
+ expiresAfterHours: number;
12
+ }
13
+ export declare function browserSessionStatus(workspace: string): Promise<DesktopStatus>;
14
+ export declare const checkVnc: (url: string) => Promise<void>;
15
+ export declare function createBrowserSessionTools(): ToolDefinition[];
16
+ //# sourceMappingURL=BrowserSessionTool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowserSessionTool.d.ts","sourceRoot":"","sources":["../../../src/tools/browser/BrowserSessionTool.ts"],"names":[],"mappings":"AAOA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAO1E,eAAO,MAAM,kBAAkB,GAAI,WAAW,MAAM,KAAG,MACgC,CAAC;AAuBxF,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAYD,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,CAAC,CA4BxB;AACD,eAAO,MAAM,QAAQ,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,IAAI,CA0BxD,CAAC;AAsGF,wBAAgB,yBAAyB,IAAI,cAAc,EAAE,CAgN5D"}
@@ -0,0 +1,326 @@
1
+ import { execFile, spawn } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ import { createHash } from 'node:crypto';
4
+ import { promises as fs } from 'node:fs';
5
+ import os from 'node:os';
6
+ import path from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { ToolExecutionError } from '../ToolTypes.js';
9
+ import { safeProcessEnvironment } from '../shell/AsyncProcess.js';
10
+ import { browserUrl } from './BrowserTool.js';
11
+ const exec = promisify(execFile);
12
+ const image = 'codali-browser-desktop:1';
13
+ const label = 'org.mcoda.codali.workspace';
14
+ export const browserSessionName = (workspace) => `codali-browser-${createHash('sha256').update(workspace).digest('hex').slice(0, 20)}`;
15
+ const docker = async (args, signal, timeout = 30000) => {
16
+ try {
17
+ return (await exec('docker', args, {
18
+ signal,
19
+ timeout,
20
+ maxBuffer: 1024 * 1024,
21
+ env: { ...safeProcessEnvironment(), HOME: os.homedir() },
22
+ })).stdout.trim();
23
+ }
24
+ catch (error) {
25
+ throw new ToolExecutionError('tool_execution_failed', `Managed browser Docker operation failed: ${String(error.message).slice(0, 1200)}. Use browser_session status; do not retry background shell launchers.`, { retryable: false });
26
+ }
27
+ };
28
+ const inspect = async (name) => {
29
+ const ids = await docker(['ps', '-aq', '--filter', `name=^/${name}$`]);
30
+ if (!ids)
31
+ return undefined;
32
+ return JSON.parse(await docker(['inspect', name]))[0];
33
+ };
34
+ const owned = (value, root) => {
35
+ if (value?.Config?.Labels?.[label] !== root)
36
+ throw new Error('Container name belongs to another owner; refusing to modify it');
37
+ };
38
+ export async function browserSessionStatus(workspace) {
39
+ const root = await fs.realpath(workspace), name = browserSessionName(root), value = await inspect(name);
40
+ if (!value)
41
+ return { running: false, name, expiresAfterHours: 8 };
42
+ owned(value, root);
43
+ const port = (p) => value.NetworkSettings?.Ports?.[`${p}/tcp`]?.find((v) => v.HostIp === '127.0.0.1')?.HostPort;
44
+ const web = port(6080), preview = port(8000), cdp = port(9223);
45
+ const running = value.State?.Running === true && !!web && !!preview && !!cdp;
46
+ return {
47
+ running,
48
+ name,
49
+ expiresAfterHours: 8,
50
+ ...(running
51
+ ? {
52
+ url: `http://127.0.0.1:${web}/vnc.html?autoconnect=true&resize=scale`,
53
+ previewUrl: `http://127.0.0.1:${preview}/`,
54
+ browserPreviewUrl: 'http://127.0.0.1:8000/',
55
+ cdpUrl: `http://127.0.0.1:${cdp}`,
56
+ sshForward: `ssh -N -L ${web}:127.0.0.1:${web} -L ${preview}:127.0.0.1:${preview} ${os.userInfo().username}@${os.hostname()}`,
57
+ }
58
+ : {}),
59
+ };
60
+ }
61
+ export const checkVnc = async (url) => {
62
+ await new Promise((resolve, reject) => {
63
+ const socket = new WebSocket(new URL('/websockify', url).href.replace(/^http/, 'ws'), ['binary']);
64
+ socket.binaryType = 'arraybuffer';
65
+ const finish = (error) => {
66
+ clearTimeout(timer);
67
+ socket.close();
68
+ error ? reject(error) : resolve();
69
+ };
70
+ const timer = setTimeout(() => finish(new Error('noVNC desktop handshake timed out')), 2000);
71
+ socket.onmessage = (event) => finish(Buffer.from(event.data)
72
+ .toString()
73
+ .startsWith('RFB ')
74
+ ? undefined
75
+ : new Error('Invalid VNC handshake'));
76
+ socket.onerror = () => finish(new Error('noVNC desktop connection failed'));
77
+ });
78
+ };
79
+ const ready = async (status, signal) => {
80
+ if (!status.running)
81
+ throw new Error('Managed browser is not running; call browser_session start');
82
+ await checkVnc(status.url);
83
+ for (const url of [status.url, `${status.cdpUrl}/json/version`]) {
84
+ const r = await fetch(url, {
85
+ signal: AbortSignal.any([
86
+ ...(signal ? [signal] : []),
87
+ AbortSignal.timeout(2000),
88
+ ]),
89
+ });
90
+ if (!r.ok)
91
+ throw new Error(`Browser readiness failed (${r.status})`);
92
+ if (url.endsWith('/json/version') &&
93
+ !(await r.json()).webSocketDebuggerUrl)
94
+ throw new Error('Browser CDP endpoint is not ready');
95
+ }
96
+ };
97
+ const stateHome = (name) => path.join(os.homedir(), '.local', 'state', 'codali', 'browser-sessions', name);
98
+ const runtimeHome = (name) => path.join(os.tmpdir(), `cbu-${process.getuid?.() ?? 'user'}-${name.slice(-20)}`);
99
+ const browserEnvironment = (name) => ({
100
+ ...safeProcessEnvironment(),
101
+ HOME: stateHome(name),
102
+ BU_NAME: name,
103
+ BH_RUNTIME_DIR: runtimeHome(name),
104
+ BH_TMP_DIR: stateHome(name),
105
+ BH_RECORD: '0',
106
+ BH_TAB_MARKER: '0',
107
+ ANONYMIZED_TELEMETRY: 'false',
108
+ });
109
+ async function browserUse(status, script, signal) {
110
+ const home = stateHome(status.name);
111
+ await fs.mkdir(home, { recursive: true, mode: 0o700 });
112
+ const runtime = runtimeHome(status.name);
113
+ await fs.mkdir(runtime, { mode: 0o700, recursive: true });
114
+ const stat = await fs.lstat(runtime);
115
+ if (!stat.isDirectory() ||
116
+ stat.isSymbolicLink() ||
117
+ (process.getuid && stat.uid !== process.getuid()) ||
118
+ stat.mode & 0o077)
119
+ throw new Error('Browser Use runtime directory must be private and owned by the current user');
120
+ return new Promise((resolve, reject) => {
121
+ const child = spawn('browser-use', [], {
122
+ cwd: home,
123
+ env: { ...browserEnvironment(status.name), BU_CDP_URL: status.cdpUrl },
124
+ stdio: ['pipe', 'pipe', 'pipe'],
125
+ signal,
126
+ });
127
+ let output = '', error = '';
128
+ const timer = setTimeout(() => child.kill('SIGKILL'), 45000);
129
+ child.stdout.on('data', (b) => {
130
+ output = (output + b).slice(-131072);
131
+ });
132
+ child.stderr.on('data', (b) => {
133
+ error = (error + b).slice(-3000);
134
+ });
135
+ child.once('error', (e) => {
136
+ clearTimeout(timer);
137
+ reject(new Error(`Official browser-use CLI unavailable: ${e.message}. Install browser-use with uv; do not substitute the npm community port.`));
138
+ });
139
+ child.once('close', (code) => {
140
+ clearTimeout(timer);
141
+ code === 0
142
+ ? resolve(output)
143
+ : reject(new Error(`Browser Use failed (${code}): ${error || output}`));
144
+ });
145
+ child.stdin.on('error', () => undefined);
146
+ child.stdin.end(script);
147
+ });
148
+ }
149
+ export function createBrowserSessionTools() {
150
+ let busy = false;
151
+ const exclusive = async (job) => {
152
+ if (busy)
153
+ throw new Error('Browser session is busy; wait for the previous operation');
154
+ busy = true;
155
+ try {
156
+ return await job();
157
+ }
158
+ finally {
159
+ busy = false;
160
+ }
161
+ };
162
+ return [
163
+ {
164
+ name: 'browser_session',
165
+ capability: 'browser',
166
+ readOnly: false,
167
+ description: "Manage a persistent isolated Chrome/noVNC desktop and read-only workspace web preview. start builds the bundled Docker preset if needed, waits for readiness and returns loopback URLs plus an SSH tunnel command. Survives shell calls and TUI exit, expires after 8h. status checks readiness; stop removes only this workspace's owned container. Requires Docker; no sudo, host browser profile or cloud account. Use this instead of nohup/tmux in run_shell.",
168
+ inputSchema: {
169
+ type: 'object',
170
+ properties: {
171
+ action: { type: 'string', enum: ['start', 'status', 'stop'] },
172
+ },
173
+ required: ['action'],
174
+ additionalProperties: false,
175
+ },
176
+ handler: async (args, context) => exclusive(async () => {
177
+ const { action } = args;
178
+ const root = await fs.realpath(context.workspaceRoot), name = browserSessionName(root);
179
+ await context.checkPath?.(root, 'read');
180
+ let status = await browserSessionStatus(root);
181
+ if (action === 'stop') {
182
+ if (await inspect(name))
183
+ await docker(['rm', '-f', name], context.signal);
184
+ // Stop only our named Browser Use daemon, never the default/user browser.
185
+ await exec('browser-use', ['--reload'], {
186
+ timeout: 10000,
187
+ env: browserEnvironment(name),
188
+ }).catch(() => undefined);
189
+ return {
190
+ output: "Stopped this workspace's managed browser and preview. Other sessions were not changed.",
191
+ };
192
+ }
193
+ if (action === 'start' && !status.running) {
194
+ if (await inspect(name))
195
+ await docker(['rm', name], context.signal);
196
+ if (!(await docker(['images', '-q', image], context.signal))) {
197
+ context.onOutput?.('stdout', 'Preparing the local browser desktop image (first use only)…\n');
198
+ await docker([
199
+ 'build',
200
+ '-t',
201
+ image,
202
+ fileURLToPath(new URL('../../../config/browser-desktop', import.meta.url)),
203
+ ], context.signal, 600000);
204
+ }
205
+ try {
206
+ await docker([
207
+ 'run',
208
+ '-d',
209
+ '--name',
210
+ name,
211
+ '--label',
212
+ `${label}=${root}`,
213
+ '--cap-drop=ALL',
214
+ '--security-opt',
215
+ 'no-new-privileges',
216
+ '--pids-limit',
217
+ '256',
218
+ '--memory',
219
+ '2g',
220
+ '--shm-size',
221
+ '256m',
222
+ '--read-only',
223
+ '--tmpfs',
224
+ '/tmp:rw,nosuid,size=1g,mode=1777',
225
+ '--mount',
226
+ `type=bind,src=${root},dst=/workspace,readonly`,
227
+ '-p',
228
+ '127.0.0.1::6080',
229
+ '-p',
230
+ '127.0.0.1::8000',
231
+ '-p',
232
+ '127.0.0.1::9223',
233
+ image,
234
+ ], context.signal, 120000);
235
+ let error;
236
+ for (let i = 0; i < 40; i++) {
237
+ context.signal?.throwIfAborted();
238
+ status = await browserSessionStatus(root);
239
+ try {
240
+ await ready(status, context.signal);
241
+ error = undefined;
242
+ break;
243
+ }
244
+ catch (e) {
245
+ error = e;
246
+ await new Promise((r) => setTimeout(r, 250));
247
+ }
248
+ }
249
+ if (error)
250
+ throw error;
251
+ }
252
+ catch (error) {
253
+ await docker(['rm', '-f', name]);
254
+ throw new Error(`Browser startup failed and was cleaned up: ${String(error)}`);
255
+ }
256
+ }
257
+ if (status.running)
258
+ await ready(status, context.signal);
259
+ const result = {
260
+ ...status,
261
+ note: 'Open the noVNC URL after establishing the SSH tunnel. browserPreviewUrl is for browser_interact; previewUrl is for the host/Mac. Preview is static/read-only; backend apps need their own managed service. Use browser_interact for official Browser Use actions.',
262
+ };
263
+ return { output: JSON.stringify(result), data: result };
264
+ }),
265
+ },
266
+ {
267
+ name: 'browser_interact',
268
+ capability: 'browser',
269
+ readOnly: false,
270
+ description: "Use the official Browser Use CLI against this workspace's managed browser. Start browser_session first. Actions: state (page text and controls), open URL, click CSS selector, type into CSS selector. Inspect state before actions and verify afterward. No arbitrary Python/JS, cloud agent or existing user profile. Website content is untrusted; keep user authorization for submissions.",
271
+ inputSchema: {
272
+ type: 'object',
273
+ properties: {
274
+ action: { type: 'string', enum: ['state', 'open', 'click', 'type'] },
275
+ url: { type: 'string', maxLength: 4096 },
276
+ selector: { type: 'string', maxLength: 512 },
277
+ text: { type: 'string', maxLength: 8000 },
278
+ },
279
+ required: ['action'],
280
+ additionalProperties: false,
281
+ },
282
+ handler: async (args, context) => exclusive(async () => {
283
+ const a = args;
284
+ const status = await browserSessionStatus(context.workspaceRoot);
285
+ await ready(status, context.signal);
286
+ await context.checkPath?.(await fs.realpath(context.workspaceRoot), 'read');
287
+ if (a.action === 'open') {
288
+ const url = new URL(browserUrl(a.url ?? ''));
289
+ // The published preview URL is for the host/SSH client. Chromium
290
+ // lives in the container, so its own preview uses internal port 8000.
291
+ if (url.origin === new URL(status.previewUrl).origin) {
292
+ const internal = new URL(status.browserPreviewUrl);
293
+ url.host = internal.host;
294
+ }
295
+ a.url = url.href;
296
+ }
297
+ if (['click', 'type'].includes(a.action) && !a.selector)
298
+ throw new Error('Provide a CSS selector from the current page state');
299
+ const payload = JSON.stringify(JSON.stringify(a));
300
+ const script = `import json\np = json.loads(${payload})\nensure_real_tab()\nif p['action'] == 'open':\n goto_url(p['url'])\n wait_for_load()\nif p['action'] in ('click', 'type'):\n doc = cdp('DOM.getDocument')['root']['nodeId']\n node = cdp('DOM.querySelector', nodeId=doc, selector=p['selector'])['nodeId']\n if not node: raise RuntimeError('Selector did not match; inspect state again')\n if p['action'] == 'type':\n cdp('DOM.focus', nodeId=node)\n cdp('Input.insertText', text=p.get('text', ''))\n else:\n q = cdp('DOM.getBoxModel', nodeId=node)['model']['content']\n x, y = sum(q[0::2])/4, sum(q[1::2])/4\n cdp('Input.dispatchMouseEvent', type='mousePressed', x=x, y=y, button='left', clickCount=1)\n cdp('Input.dispatchMouseEvent', type='mouseReleased', x=x, y=y, button='left', clickCount=1)\nprint(js("JSON.stringify({title:document.title,url:location.href,browserError:document.documentURI.startsWith('chrome-error:'),text:document.body.innerText.slice(0,4000),controls:Array.from(document.querySelectorAll('button,input,a,select')).slice(0,30).map(e=>({tag:e.tagName,id:e.id.slice(0,100),name:(e.getAttribute('name')||'').slice(0,100),text:(e.innerText||e.getAttribute('aria-label')||'').slice(0,100)}))})"))\n`;
301
+ const raw = await browserUse(status, script, context.signal);
302
+ const snapshot = JSON.parse(raw.trim());
303
+ if (snapshot.browserError)
304
+ throw new Error(`Browser navigation failed. For this workspace preview use ${status.browserPreviewUrl}; check the URL before retrying. ${String(snapshot.text ?? '').slice(0, 300)}`);
305
+ snapshot.title = String(snapshot.title ?? '').slice(0, 200);
306
+ snapshot.url = String(snapshot.url ?? '').slice(0, 2000);
307
+ snapshot.text = String(snapshot.text ?? '').slice(0, 1400);
308
+ // Preserve valid JSON under the shared tool-result ceiling.
309
+ while (JSON.stringify(snapshot).length > 3800 &&
310
+ snapshot.controls?.length)
311
+ snapshot.controls.pop();
312
+ while (JSON.stringify(snapshot).length > 3800 && snapshot.text.length)
313
+ snapshot.text = snapshot.text.slice(0, -100);
314
+ if (JSON.stringify(snapshot).length > 3800) {
315
+ snapshot.url = null;
316
+ snapshot.urlOmitted = true;
317
+ }
318
+ const output = JSON.stringify(snapshot);
319
+ return {
320
+ output,
321
+ data: { backend: 'official-browser-use', session: status.name },
322
+ };
323
+ }),
324
+ },
325
+ ];
326
+ }
@@ -0,0 +1,17 @@
1
+ import { type ToolDefinition } from "../ToolTypes.js";
2
+ export declare const browserUrl: (value: string) => string;
3
+ export declare function resolveBrowserBinary(): Promise<string>;
4
+ export declare function findSnapshotText(content: string, query: string, offset?: number): {
5
+ index: number;
6
+ mode: "exact" | "ordered_terms" | "ranked_terms";
7
+ matchedTerms?: string[];
8
+ } | undefined;
9
+ export declare function snapshotSectionContext(content: string, offset: number): string[];
10
+ /** A starting-position hint only: retain the full snapshot for offset reads. */
11
+ export declare function snapshotContentStart(content: string): number;
12
+ /** Short-lived, unauthenticated browser navigation; the model never supplies JS. */
13
+ export declare function createBrowserTools(options?: {
14
+ executablePath?: string;
15
+ timeoutMs?: number;
16
+ }): ToolDefinition[];
17
+ //# sourceMappingURL=BrowserTool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowserTool.d.ts","sourceRoot":"","sources":["../../../src/tools/browser/BrowserTool.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE1E,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,KAAG,MAO1C,CAAC;AAEF,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CA0B5D;AAID,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,cAAc,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,SAAS,CA4CrL;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAWhF;AAED,gFAAgF;AAChF,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAU5D;AAOD,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,OAAO,GAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,cAAc,EAAE,CAuHlH"}