@mcoda/mswarm 0.1.135-codali.2 → 0.1.135-codali.32

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 (339) 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 +13 -5
  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/TerminalCredentials.js +2 -2
  17. package/dist/vendor/codali/cli/TerminalInput.d.ts +13 -0
  18. package/dist/vendor/codali/cli/TerminalInput.d.ts.map +1 -1
  19. package/dist/vendor/codali/cli/TerminalInput.js +55 -7
  20. package/dist/vendor/codali/cli/TerminalModels.d.ts +6 -0
  21. package/dist/vendor/codali/cli/TerminalModels.d.ts.map +1 -0
  22. package/dist/vendor/codali/cli/TerminalModels.js +45 -0
  23. package/dist/vendor/codali/cli/TerminalPlan.d.ts +40 -0
  24. package/dist/vendor/codali/cli/TerminalPlan.d.ts.map +1 -0
  25. package/dist/vendor/codali/cli/TerminalPlan.js +37 -0
  26. package/dist/vendor/codali/cli/ToolsCommand.d.ts.map +1 -1
  27. package/dist/vendor/codali/cli/ToolsCommand.js +8 -1
  28. package/dist/vendor/codali/cli/tui/TerminalCells.d.ts +6 -0
  29. package/dist/vendor/codali/cli/tui/TerminalCells.d.ts.map +1 -0
  30. package/dist/vendor/codali/cli/tui/TerminalCells.js +47 -0
  31. package/dist/vendor/codali/cli/tui/TerminalEditor.d.ts +22 -0
  32. package/dist/vendor/codali/cli/tui/TerminalEditor.d.ts.map +1 -0
  33. package/dist/vendor/codali/cli/tui/TerminalEditor.js +88 -0
  34. package/dist/vendor/codali/cli/tui/TerminalLogo.d.ts +6 -0
  35. package/dist/vendor/codali/cli/tui/TerminalLogo.d.ts.map +1 -0
  36. package/dist/vendor/codali/cli/tui/TerminalLogo.js +26 -0
  37. package/dist/vendor/codali/cli/tui/TerminalMarkdown.d.ts +5 -0
  38. package/dist/vendor/codali/cli/tui/TerminalMarkdown.d.ts.map +1 -0
  39. package/dist/vendor/codali/cli/tui/TerminalMarkdown.js +118 -0
  40. package/dist/vendor/codali/cli/tui/TerminalPresentation.d.ts +6 -0
  41. package/dist/vendor/codali/cli/tui/TerminalPresentation.d.ts.map +1 -0
  42. package/dist/vendor/codali/cli/tui/TerminalPresentation.js +152 -0
  43. package/dist/vendor/codali/cli/tui/TerminalScreen.d.ts +50 -0
  44. package/dist/vendor/codali/cli/tui/TerminalScreen.d.ts.map +1 -0
  45. package/dist/vendor/codali/cli/tui/TerminalScreen.js +137 -0
  46. package/dist/vendor/codali/cli/tui/TerminalSelection.d.ts +15 -0
  47. package/dist/vendor/codali/cli/tui/TerminalSelection.d.ts.map +1 -0
  48. package/dist/vendor/codali/cli/tui/TerminalSelection.js +38 -0
  49. package/dist/vendor/codali/cli/tui/TerminalTui.d.ts +82 -0
  50. package/dist/vendor/codali/cli/tui/TerminalTui.d.ts.map +1 -0
  51. package/dist/vendor/codali/cli/tui/TerminalTui.js +564 -0
  52. package/dist/vendor/codali/cli.d.ts.map +1 -1
  53. package/dist/vendor/codali/cli.js +5 -3
  54. package/dist/vendor/codali/config/OrchestrationConfig.d.ts +40 -0
  55. package/dist/vendor/codali/config/OrchestrationConfig.d.ts.map +1 -1
  56. package/dist/vendor/codali/config/OrchestrationConfig.js +74 -3
  57. package/dist/vendor/codali/connectors/media/MediaJobStore.d.ts +2 -1
  58. package/dist/vendor/codali/connectors/media/MediaJobStore.d.ts.map +1 -1
  59. package/dist/vendor/codali/connectors/media/MediaJobStore.js +11 -3
  60. package/dist/vendor/codali/docdex/DocdexCatalog.d.ts +12 -0
  61. package/dist/vendor/codali/docdex/DocdexCatalog.d.ts.map +1 -0
  62. package/dist/vendor/codali/docdex/DocdexCatalog.js +30 -0
  63. package/dist/vendor/codali/docdex/DocdexClient.d.ts +9 -2
  64. package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -1
  65. package/dist/vendor/codali/docdex/DocdexClient.js +86 -11
  66. package/dist/vendor/codali/docdex/ManagedDocdex.d.ts +4 -0
  67. package/dist/vendor/codali/docdex/ManagedDocdex.d.ts.map +1 -1
  68. package/dist/vendor/codali/docdex/ManagedDocdex.js +42 -5
  69. package/dist/vendor/codali/eval/TerminalWorkflowCorpus.d.ts +1 -1
  70. package/dist/vendor/codali/eval/TerminalWorkflowCorpus.d.ts.map +1 -1
  71. package/dist/vendor/codali/eval/TerminalWorkflowCorpus.js +9 -6
  72. package/dist/vendor/codali/eval/TrustBenchmark.d.ts +94 -0
  73. package/dist/vendor/codali/eval/TrustBenchmark.d.ts.map +1 -0
  74. package/dist/vendor/codali/eval/TrustBenchmark.js +199 -0
  75. package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.d.ts +4 -0
  76. package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.d.ts.map +1 -0
  77. package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.js +10 -0
  78. package/dist/vendor/codali/eval/fixtures/MixedMediaRecoveryJourney.d.ts +6 -0
  79. package/dist/vendor/codali/eval/fixtures/MixedMediaRecoveryJourney.d.ts.map +1 -0
  80. package/dist/vendor/codali/eval/fixtures/MixedMediaRecoveryJourney.js +145 -0
  81. package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.d.ts.map +1 -1
  82. package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.js +14 -1
  83. package/dist/vendor/codali/gateway/GroundingMode.d.ts.map +1 -1
  84. package/dist/vendor/codali/gateway/GroundingMode.js +23 -3
  85. package/dist/vendor/codali/index.d.ts +1 -0
  86. package/dist/vendor/codali/index.d.ts.map +1 -1
  87. package/dist/vendor/codali/index.js +1 -0
  88. package/dist/vendor/codali/permissions/PermissionGate.d.ts +1 -1
  89. package/dist/vendor/codali/permissions/PermissionGate.d.ts.map +1 -1
  90. package/dist/vendor/codali/permissions/PermissionGate.js +45 -5
  91. package/dist/vendor/codali/permissions/WorkspacePermissions.d.ts +11 -0
  92. package/dist/vendor/codali/permissions/WorkspacePermissions.d.ts.map +1 -0
  93. package/dist/vendor/codali/permissions/WorkspacePermissions.js +42 -0
  94. package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts +1 -0
  95. package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts.map +1 -1
  96. package/dist/vendor/codali/providers/ConfiguredModelScope.js +19 -2
  97. package/dist/vendor/codali/providers/ConfiguredProvider.d.ts +6 -0
  98. package/dist/vendor/codali/providers/ConfiguredProvider.d.ts.map +1 -1
  99. package/dist/vendor/codali/providers/ConfiguredProvider.js +88 -34
  100. package/dist/vendor/codali/providers/ModelCapacityWait.d.ts +21 -0
  101. package/dist/vendor/codali/providers/ModelCapacityWait.d.ts.map +1 -0
  102. package/dist/vendor/codali/providers/ModelCapacityWait.js +40 -0
  103. package/dist/vendor/codali/providers/ModelServiceError.d.ts +16 -2
  104. package/dist/vendor/codali/providers/ModelServiceError.d.ts.map +1 -1
  105. package/dist/vendor/codali/providers/ModelServiceError.js +37 -5
  106. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
  107. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +26 -3
  108. package/dist/vendor/codali/providers/ProviderTypes.d.ts +6 -0
  109. package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -1
  110. package/dist/vendor/codali/providers/RequestSize.d.ts +5 -0
  111. package/dist/vendor/codali/providers/RequestSize.d.ts.map +1 -0
  112. package/dist/vendor/codali/providers/RequestSize.js +10 -0
  113. package/dist/vendor/codali/providers/RequestUsage.d.ts +11 -0
  114. package/dist/vendor/codali/providers/RequestUsage.d.ts.map +1 -0
  115. package/dist/vendor/codali/providers/RequestUsage.js +33 -0
  116. package/dist/vendor/codali/runtime/AnswerVerification.d.ts +17 -0
  117. package/dist/vendor/codali/runtime/AnswerVerification.d.ts.map +1 -0
  118. package/dist/vendor/codali/runtime/AnswerVerification.js +39 -0
  119. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +1 -0
  120. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -1
  121. package/dist/vendor/codali/runtime/CodaliRuntime.js +1 -0
  122. package/dist/vendor/codali/runtime/CompletionReport.d.ts +2 -0
  123. package/dist/vendor/codali/runtime/CompletionReport.d.ts.map +1 -1
  124. package/dist/vendor/codali/runtime/CompletionReport.js +17 -0
  125. package/dist/vendor/codali/runtime/ComputedAnswer.d.ts +13 -0
  126. package/dist/vendor/codali/runtime/ComputedAnswer.d.ts.map +1 -0
  127. package/dist/vendor/codali/runtime/ComputedAnswer.js +75 -0
  128. package/dist/vendor/codali/runtime/ContextCompression.d.ts +38 -0
  129. package/dist/vendor/codali/runtime/ContextCompression.d.ts.map +1 -0
  130. package/dist/vendor/codali/runtime/ContextCompression.js +263 -0
  131. package/dist/vendor/codali/runtime/GatewayRequest.d.ts +5 -0
  132. package/dist/vendor/codali/runtime/GatewayRequest.d.ts.map +1 -0
  133. package/dist/vendor/codali/runtime/GatewayRequest.js +19 -0
  134. package/dist/vendor/codali/runtime/InspectionBudget.d.ts +11 -0
  135. package/dist/vendor/codali/runtime/InspectionBudget.d.ts.map +1 -0
  136. package/dist/vendor/codali/runtime/InspectionBudget.js +23 -0
  137. package/dist/vendor/codali/runtime/InspectionConvergence.d.ts +24 -0
  138. package/dist/vendor/codali/runtime/InspectionConvergence.d.ts.map +1 -0
  139. package/dist/vendor/codali/runtime/InspectionConvergence.js +67 -0
  140. package/dist/vendor/codali/runtime/InteractionContract.d.ts +44 -0
  141. package/dist/vendor/codali/runtime/InteractionContract.d.ts.map +1 -0
  142. package/dist/vendor/codali/runtime/InteractionContract.js +64 -0
  143. package/dist/vendor/codali/runtime/InteractionRouter.d.ts +73 -0
  144. package/dist/vendor/codali/runtime/InteractionRouter.d.ts.map +1 -0
  145. package/dist/vendor/codali/runtime/InteractionRouter.js +138 -0
  146. package/dist/vendor/codali/runtime/PlanCoverage.d.ts +9 -0
  147. package/dist/vendor/codali/runtime/PlanCoverage.d.ts.map +1 -0
  148. package/dist/vendor/codali/runtime/PlanCoverage.js +12 -0
  149. package/dist/vendor/codali/runtime/PreparedDocdex.d.ts +4 -0
  150. package/dist/vendor/codali/runtime/PreparedDocdex.d.ts.map +1 -0
  151. package/dist/vendor/codali/runtime/PreparedDocdex.js +55 -0
  152. package/dist/vendor/codali/runtime/PreparedMemory.d.ts +3 -0
  153. package/dist/vendor/codali/runtime/PreparedMemory.d.ts.map +1 -0
  154. package/dist/vendor/codali/runtime/PreparedMemory.js +30 -0
  155. package/dist/vendor/codali/runtime/ProgressTracker.d.ts +1 -0
  156. package/dist/vendor/codali/runtime/ProgressTracker.d.ts.map +1 -1
  157. package/dist/vendor/codali/runtime/ProgressTracker.js +25 -5
  158. package/dist/vendor/codali/runtime/ResearchEvidence.d.ts +19 -0
  159. package/dist/vendor/codali/runtime/ResearchEvidence.d.ts.map +1 -0
  160. package/dist/vendor/codali/runtime/ResearchEvidence.js +55 -0
  161. package/dist/vendor/codali/runtime/ReviewContract.d.ts +35 -0
  162. package/dist/vendor/codali/runtime/ReviewContract.d.ts.map +1 -0
  163. package/dist/vendor/codali/runtime/ReviewContract.js +132 -0
  164. package/dist/vendor/codali/runtime/ReviewCoordinator.d.ts +43 -0
  165. package/dist/vendor/codali/runtime/ReviewCoordinator.d.ts.map +1 -0
  166. package/dist/vendor/codali/runtime/ReviewCoordinator.js +134 -0
  167. package/dist/vendor/codali/runtime/ReviewSource.d.ts +3 -0
  168. package/dist/vendor/codali/runtime/ReviewSource.d.ts.map +1 -1
  169. package/dist/vendor/codali/runtime/ReviewSource.js +17 -1
  170. package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -1
  171. package/dist/vendor/codali/runtime/Runner.js +6 -1
  172. package/dist/vendor/codali/runtime/SessionController.d.ts +71 -5
  173. package/dist/vendor/codali/runtime/SessionController.d.ts.map +1 -1
  174. package/dist/vendor/codali/runtime/SessionController.js +1913 -223
  175. package/dist/vendor/codali/runtime/SpecialistTools.d.ts +6 -0
  176. package/dist/vendor/codali/runtime/SpecialistTools.d.ts.map +1 -0
  177. package/dist/vendor/codali/runtime/SpecialistTools.js +69 -0
  178. package/dist/vendor/codali/runtime/StructuralEvidence.d.ts +4 -2
  179. package/dist/vendor/codali/runtime/StructuralEvidence.d.ts.map +1 -1
  180. package/dist/vendor/codali/runtime/StructuralEvidence.js +22 -5
  181. package/dist/vendor/codali/runtime/TaskReview.d.ts +25 -0
  182. package/dist/vendor/codali/runtime/TaskReview.d.ts.map +1 -0
  183. package/dist/vendor/codali/runtime/TaskReview.js +109 -0
  184. package/dist/vendor/codali/runtime/TaskReviewContext.d.ts +37 -0
  185. package/dist/vendor/codali/runtime/TaskReviewContext.d.ts.map +1 -1
  186. package/dist/vendor/codali/runtime/TaskReviewContext.js +18 -2
  187. package/dist/vendor/codali/runtime/UsageReconciliation.d.ts +28 -0
  188. package/dist/vendor/codali/runtime/UsageReconciliation.d.ts.map +1 -0
  189. package/dist/vendor/codali/runtime/UsageReconciliation.js +68 -0
  190. package/dist/vendor/codali/runtime/VerificationCommand.d.ts +2 -0
  191. package/dist/vendor/codali/runtime/VerificationCommand.d.ts.map +1 -1
  192. package/dist/vendor/codali/runtime/VerificationCommand.js +28 -0
  193. package/dist/vendor/codali/runtime/VerificationReceiptSelection.d.ts +15 -0
  194. package/dist/vendor/codali/runtime/VerificationReceiptSelection.d.ts.map +1 -0
  195. package/dist/vendor/codali/runtime/VerificationReceiptSelection.js +30 -0
  196. package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts +2 -0
  197. package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts.map +1 -1
  198. package/dist/vendor/codali/runtime/WorkspaceLedger.js +44 -20
  199. package/dist/vendor/codali/runtime/WorkspaceLock.d.ts.map +1 -1
  200. package/dist/vendor/codali/runtime/WorkspaceLock.js +9 -1
  201. package/dist/vendor/codali/runtime/WorkspaceSnapshot.d.ts.map +1 -1
  202. package/dist/vendor/codali/runtime/WorkspaceSnapshot.js +3 -2
  203. package/dist/vendor/codali/runtime/WriteSyntaxCheck.d.ts +10 -0
  204. package/dist/vendor/codali/runtime/WriteSyntaxCheck.d.ts.map +1 -0
  205. package/dist/vendor/codali/runtime/WriteSyntaxCheck.js +34 -0
  206. package/dist/vendor/codali/session/AtomicState.d.ts.map +1 -1
  207. package/dist/vendor/codali/session/AtomicState.js +15 -1
  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 +5 -1
  214. package/dist/vendor/codali/session/SessionStore.d.ts.map +1 -1
  215. package/dist/vendor/codali/session/SessionStore.js +11 -2
  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 +11 -0
  220. package/dist/vendor/codali/session/WorkState.d.ts.map +1 -1
  221. package/dist/vendor/codali/session/WorkState.js +46 -2
  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 +2 -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 +163 -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 +58 -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 +7 -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.map +1 -1
  280. package/dist/vendor/codali/tools/shell/HostToolchain.js +37 -5
  281. package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts +4 -2
  282. package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts.map +1 -1
  283. package/dist/vendor/codali/tools/shell/IsolatedExecutor.js +126 -27
  284. package/dist/vendor/codali/tools/shell/ShellTool.d.ts +2 -0
  285. package/dist/vendor/codali/tools/shell/ShellTool.d.ts.map +1 -1
  286. package/dist/vendor/codali/tools/shell/ShellTool.js +18 -4
  287. package/dist/vendor/codali/tools/system/CalendarTool.d.ts +15 -0
  288. package/dist/vendor/codali/tools/system/CalendarTool.d.ts.map +1 -0
  289. package/dist/vendor/codali/tools/system/CalendarTool.js +44 -0
  290. package/dist/vendor/codali/tools/system/TextTool.d.ts +4 -0
  291. package/dist/vendor/codali/tools/system/TextTool.d.ts.map +1 -0
  292. package/dist/vendor/codali/tools/system/TextTool.js +39 -0
  293. package/dist/vendor/codali/tools/system/TimeTool.d.ts +4 -0
  294. package/dist/vendor/codali/tools/system/TimeTool.d.ts.map +1 -0
  295. package/dist/vendor/codali/tools/system/TimeTool.js +22 -0
  296. package/dist/vendor/codali/tools/verification/JavaScriptVerificationTool.d.ts +47 -0
  297. package/dist/vendor/codali/tools/verification/JavaScriptVerificationTool.d.ts.map +1 -0
  298. package/dist/vendor/codali/tools/verification/JavaScriptVerificationTool.js +71 -0
  299. package/dist/vendor/codali/tools/verification/JavaScriptVerificationWorker.d.ts +2 -0
  300. package/dist/vendor/codali/tools/verification/JavaScriptVerificationWorker.d.ts.map +1 -0
  301. package/dist/vendor/codali/tools/verification/JavaScriptVerificationWorker.js +91 -0
  302. package/dist/vendor/codali/tools/verification/VitestTool.d.ts +6 -0
  303. package/dist/vendor/codali/tools/verification/VitestTool.d.ts.map +1 -0
  304. package/dist/vendor/codali/tools/verification/VitestTool.js +184 -0
  305. package/dist/vendor/config/AGENTS.md +17 -0
  306. package/dist/vendor/config/deterministic/install-python.mjs +16 -0
  307. package/dist/vendor/config/deterministic/node-worker.mjs +77 -0
  308. package/dist/vendor/config/deterministic/python-worker.py +237 -0
  309. package/dist/vendor/config/deterministic/requirements.txt +6 -0
  310. package/dist/vendor/config/docdex-runtime.json +21 -0
  311. package/dist/vendor/config/docdex-tools-0.2.99.json +3977 -0
  312. package/dist/vendor/config/documents/install-python.mjs +16 -0
  313. package/dist/vendor/config/documents/requirements.txt +10 -0
  314. package/dist/vendor/config/documents/worker.py +267 -0
  315. package/dist/vendor/config/skills/architecture-design/SKILL.md +14 -0
  316. package/dist/vendor/config/skills/browser-session/SKILL.md +16 -0
  317. package/dist/vendor/config/skills/browser-use/SKILL.md +14 -0
  318. package/dist/vendor/config/skills/code-implementation/SKILL.md +18 -0
  319. package/dist/vendor/config/skills/code-review/SKILL.md +14 -0
  320. package/dist/vendor/config/skills/docdex-research/SKILL.md +18 -0
  321. package/dist/vendor/config/skills/docdex-research/references/catalog.md +111 -0
  322. package/dist/vendor/config/skills/docdex-research/references/memory.md +22 -0
  323. package/dist/vendor/config/skills/docdex-research/references/operations.md +19 -0
  324. package/dist/vendor/config/skills/docdex-research/references/retrieval.md +13 -0
  325. package/dist/vendor/config/skills/planning/SKILL.md +14 -0
  326. package/dist/vendor/config/skills/system-diagnostics/SKILL.md +14 -0
  327. package/dist/vendor/config/skills/system-services/SKILL.md +17 -0
  328. package/dist/vendor/config/skills/system-services/references/docker.md +11 -0
  329. package/dist/vendor/config/skills/system-services/references/linux.md +9 -0
  330. package/dist/vendor/config/skills/system-services/references/macos.md +9 -0
  331. package/dist/vendor/config/skills/systematic-debugging/SKILL.md +14 -0
  332. package/dist/vendor/config/skills/testing-and-verification/SKILL.md +16 -0
  333. package/dist/vendor/config/skills/tool-selection/SKILL.md +16 -0
  334. package/dist/vendor/config/skills/ui-ux-design/SKILL.md +16 -0
  335. package/dist/vendor/config/skills/ui-ux-design/references/validation.md +13 -0
  336. package/dist/vendor/config/skills/webapp-testing/SKILL.md +12 -0
  337. package/package.json +15 -5
  338. package/scripts/media_gpu_lock.py +2 -2
  339. package/scripts/native_load_guard.py +257 -0
@@ -0,0 +1,59 @@
1
+ import { promises as fs } from "node:fs";
2
+ import { createHash } from "node:crypto";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { createDocumentTools, defaultDocumentPythonRoot } from "./DocumentTools.js";
6
+ import { ToolRegistry } from "../ToolRegistry.js";
7
+ export async function inspectDocumentRuntime(options = {}) {
8
+ const pythonRoot = path.resolve(options.pythonRoot ?? defaultDocumentPythonRoot());
9
+ let installed = false, workerSha256;
10
+ try {
11
+ await fs.access(path.join(pythonRoot, "pyvenv.cfg"));
12
+ await fs.access(path.join(pythonRoot, "bin/python"));
13
+ installed = true;
14
+ }
15
+ catch { /* Host setup required. */ }
16
+ try {
17
+ workerSha256 = createHash("sha256").update(await fs.readFile(new URL("./worker.py", import.meta.url))).digest("hex");
18
+ }
19
+ catch { /* Build/package incomplete. */ }
20
+ return { pythonRoot, installed, workerSha256, checkCommand: "codali tools check --documents", installCommand: "codali tools install --documents",
21
+ note: "Metadata only. Check real file creation/extraction before relying on the runtime." };
22
+ }
23
+ export async function checkDocumentRuntime(options = {}, signal) {
24
+ const registry = new ToolRegistry();
25
+ for (const tool of createDocumentTools(options))
26
+ registry.register(tool);
27
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), "codali-document-check-"));
28
+ const checks = [];
29
+ try {
30
+ await fs.chmod(root, 0o700);
31
+ for (const format of ["md", "pdf", "docx", "xlsx"]) {
32
+ signal?.throwIfAborted();
33
+ const started = Date.now();
34
+ try {
35
+ const args = format === "xlsx" ? { sheets: [{ name: "Values", rows: [["Label", "Value"], ["Checked", 42], ["Literal", "=1+1"]] }] }
36
+ : { title: "Runtime check", blocks: [{ type: "paragraph", text: "Checked value: 42." }] };
37
+ const created = await registry.execute("document_create", { path: `probe.${format}`, format, ...args }, { workspaceRoot: root, signal });
38
+ if (!created.ok)
39
+ throw new Error(created.error?.message ?? "Document creation failed");
40
+ const read = await registry.execute("document_read", { path: `probe.${format}` }, { workspaceRoot: root, signal });
41
+ if (!read.ok)
42
+ throw new Error(read.error?.message ?? "Document extraction failed");
43
+ const data = read.data;
44
+ const serialized = JSON.stringify(data);
45
+ const passed = format === "xlsx" ? serialized.includes('["Checked",42]') && serialized.includes('"formulas":[]') && serialized.includes('"=1+1"') : serialized.includes("Checked value: 42.");
46
+ checks.push({ name: `document_${format}`, passed, library: "local document runtime", version: "v1", elapsedMs: Date.now() - started,
47
+ ...(passed ? {} : { error: "Created file did not preserve the independent check value" }) });
48
+ }
49
+ catch (error) {
50
+ signal?.throwIfAborted();
51
+ checks.push({ name: `document_${format}`, passed: false, elapsedMs: Date.now() - started, error: error instanceof Error ? error.message : String(error) });
52
+ }
53
+ }
54
+ return checks;
55
+ }
56
+ finally {
57
+ await fs.rm(root, { recursive: true, force: true });
58
+ }
59
+ }
@@ -0,0 +1,19 @@
1
+ import { type ToolDefinition } from "../ToolTypes.js";
2
+ export interface DocumentToolOptions {
3
+ pythonRoot?: string;
4
+ }
5
+ export declare const defaultDocumentPythonRoot: () => string;
6
+ export declare const documentVersions: {
7
+ "python-docx": string;
8
+ openpyxl: string;
9
+ pypdf: string;
10
+ reportlab: string;
11
+ defusedxml: string;
12
+ "charset-normalizer": string;
13
+ et_xmlfile: string;
14
+ lxml: string;
15
+ pillow: string;
16
+ typing_extensions: string;
17
+ };
18
+ export declare const createDocumentTools: (options?: DocumentToolOptions) => ToolDefinition[];
19
+ //# sourceMappingURL=DocumentTools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentTools.d.ts","sourceRoot":"","sources":["../../../src/tools/documents/DocumentTools.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwC,KAAK,cAAc,EAA6B,MAAM,iBAAiB,CAAC;AAEvH,MAAM,WAAW,mBAAmB;IAAG,UAAU,CAAC,EAAE,MAAM,CAAC;CAAE;AAC7D,eAAO,MAAM,yBAAyB,cAA6H,CAAC;AACpK,eAAO,MAAM,gBAAgB;;;;;;;;;;;CAA4N,CAAC;AAiG1P,eAAO,MAAM,mBAAmB,GAAI,UAAS,mBAAwB,KAAG,cAAc,EAarF,CAAC"}
@@ -0,0 +1,150 @@
1
+ import { constants, promises as fs } from "node:fs";
2
+ import { createHash, randomUUID } from "node:crypto";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { createIsolatedExecutor } from "../shell/IsolatedExecutor.js";
6
+ import { ToolExecutionError } from "../ToolTypes.js";
7
+ export const defaultDocumentPythonRoot = () => process.env.CODALI_DOCUMENT_PYTHON_ROOT ?? path.join(os.homedir(), ".local/state/codali/tool-runtimes/documents-v1");
8
+ export const documentVersions = { "python-docx": "1.2.0", openpyxl: "3.1.5", pypdf: "6.21.4", reportlab: "5.1.0", defusedxml: "0.7.1", "charset-normalizer": "3.5.2", et_xmlfile: "2.0.0", lxml: "6.1.3", pillow: "13.0.0", typing_extensions: "4.16.0" };
9
+ const maxBytes = 8 * 1024 * 1024;
10
+ const sha = (data) => createHash("sha256").update(data).digest("hex");
11
+ const text = (maxLength) => ({ type: "string", maxLength });
12
+ const scalar = { type: ["string", "number", "boolean", "null"], maxLength: 4000 };
13
+ const array = (items, maxItems, minItems = 0) => ({ type: "array", items, maxItems, minItems });
14
+ const format = { type: "string", enum: ["md", "pdf", "docx", "xlsx"] };
15
+ const rows = array(array(scalar, 32), 500);
16
+ const object = (properties, required) => ({ type: "object", properties, required, additionalProperties: false });
17
+ function within(root, candidate) {
18
+ const relative = path.relative(root, candidate);
19
+ return relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
20
+ }
21
+ /** All input bytes are copied into a private worker directory; no workspace mount. */
22
+ async function documentPath(context, target, action) {
23
+ const root = await fs.realpath(context.workspaceRoot);
24
+ const requested = path.resolve(context.workspaceRoot, target);
25
+ if (!within(path.resolve(context.workspaceRoot), requested))
26
+ throw new Error("Document path is outside the workspace");
27
+ const parent = await fs.realpath(path.dirname(requested)); // Existing directory required; no implicit broad write scope.
28
+ const actual = path.join(parent, path.basename(requested));
29
+ if (!within(root, actual))
30
+ throw new Error("Document path resolves outside the workspace");
31
+ const relative = path.relative(root, actual);
32
+ if (relative.split(path.sep).some(part => [".git", ".mcoda"].includes(part)))
33
+ throw new Error("Document paths cannot address control metadata");
34
+ const scopes = action === "read" ? context.allowedReadPaths : context.allowedWritePaths;
35
+ if (scopes && !scopes.some(scope => within(path.resolve(root, scope), actual) && within(root, path.resolve(root, scope))))
36
+ throw new Error(`Document is outside allowed ${action} scopes`);
37
+ await context.checkPath?.(actual, action);
38
+ return { actual, relative, parent };
39
+ }
40
+ async function readBounded(file) {
41
+ const handle = await fs.open(file, constants.O_RDONLY | constants.O_NOFOLLOW);
42
+ try {
43
+ const stat = await handle.stat();
44
+ if (!stat.isFile() || stat.size > maxBytes)
45
+ throw new Error("Document must be a regular file of at most 8 MiB");
46
+ const buffer = Buffer.alloc(Math.min(maxBytes + 1, stat.size + 1));
47
+ let size = 0;
48
+ while (size < buffer.length) {
49
+ const result = await handle.read(buffer, size, buffer.length - size, null);
50
+ if (!result.bytesRead)
51
+ break;
52
+ size += result.bytesRead;
53
+ }
54
+ if (size !== stat.size)
55
+ throw new Error("Document changed size while being read");
56
+ return buffer.subarray(0, size);
57
+ }
58
+ finally {
59
+ await handle.close();
60
+ }
61
+ }
62
+ async function execute(operation, input, context, options) {
63
+ context.signal?.throwIfAborted();
64
+ const { path: target, ...args } = input;
65
+ const selectedFormat = args.format ?? path.extname(target).slice(1).toLowerCase();
66
+ if (!["md", "pdf", "docx", "xlsx"].includes(selectedFormat) || path.extname(target).slice(1).toLowerCase() !== selectedFormat)
67
+ throw new Error("Document format must match a .md, .pdf, .docx or .xlsx path");
68
+ const destination = await documentPath(context, target, operation === "read" ? "read" : "write");
69
+ if (operation === "create") {
70
+ try {
71
+ await fs.lstat(destination.actual);
72
+ throw new Error("Document creation never overwrites an existing file; choose a new path");
73
+ }
74
+ catch (error) {
75
+ if (error.code !== "ENOENT")
76
+ throw error;
77
+ }
78
+ }
79
+ const source = operation === "read" ? await readBounded(destination.actual) : undefined;
80
+ const payload = JSON.stringify({ operation, args: { ...args, format: selectedFormat } });
81
+ if (Buffer.byteLength(payload) > 256000)
82
+ throw new Error("Document arguments exceed 256000 bytes");
83
+ const runtime = path.resolve(options.pythonRoot ?? defaultDocumentPythonRoot());
84
+ try {
85
+ await fs.access(path.join(runtime, "pyvenv.cfg"));
86
+ await fs.access(path.join(runtime, "bin/python"));
87
+ }
88
+ catch {
89
+ throw new ToolExecutionError("tool_execution_failed", "Document runtime is missing. Run codali tools install --documents.", { retryable: false });
90
+ }
91
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), "codali-document-"));
92
+ const started = Date.now();
93
+ try {
94
+ await fs.chmod(root, 0o700);
95
+ const worker = await fs.readFile(new URL("./worker.py", import.meta.url));
96
+ await fs.writeFile(path.join(root, "worker.py"), worker, { mode: 0o600 });
97
+ await fs.writeFile(path.join(root, "input.json"), payload, { mode: 0o600 });
98
+ if (source)
99
+ await fs.writeFile(path.join(root, "source"), source, { mode: 0o600 });
100
+ await fs.mkdir(path.join(root, "output"), { mode: 0o700 });
101
+ const observed = await createIsolatedExecutor({ network: false, readOnlyRuntimeRoots: [runtime] })(path.join(runtime, "bin/python"), ["-I", "-B", path.join(root, "worker.py")], { workspaceRoot: root, signal: context.signal, allowedWritePaths: operation === "create" ? ["output"] : [], shellTimeoutMs: 15000, shellMaxOutputBytes: 128000 });
102
+ const observation = observed.data;
103
+ if (observation.truncated)
104
+ throw new Error("Document observation exceeds its output limit");
105
+ const data = JSON.parse(observation.stdout);
106
+ if (data.error)
107
+ throw new Error(String(data.error));
108
+ const versions = data.versions;
109
+ if (Object.entries(documentVersions).some(([name, version]) => versions?.[name] !== version))
110
+ throw new Error("Document runtime versions differ from the pinned contract");
111
+ if (operation === "create") {
112
+ const bytes = await readBounded(path.join(root, "output/artifact"));
113
+ if (data.bytes !== bytes.length || data.sha256 !== sha(bytes))
114
+ throw new Error("Generated document failed its byte/checksum receipt");
115
+ const checked = await documentPath(context, target, "write");
116
+ if (checked.actual !== destination.actual)
117
+ throw new Error("Document destination changed during generation");
118
+ const temporary = path.join(checked.parent, `.codali-document-${randomUUID()}.tmp`);
119
+ try {
120
+ await fs.writeFile(temporary, bytes, { flag: "wx", mode: 0o600 });
121
+ context.signal?.throwIfAborted();
122
+ await fs.link(temporary, checked.actual); // Atomic no-replace publication, including existing symlinks.
123
+ context.recordTouchedFile?.(checked.relative);
124
+ }
125
+ finally {
126
+ await fs.rm(temporary, { force: true });
127
+ }
128
+ }
129
+ const receipt = { ...data, path: destination.relative, inputSha256: sha(source ?? payload), argumentsSha256: sha(payload),
130
+ workerSha256: sha(worker), elapsedMs: Date.now() - started, isolation: "offline worker with copied input only" };
131
+ return { output: JSON.stringify(receipt), data: receipt };
132
+ }
133
+ finally {
134
+ await fs.rm(root, { recursive: true, force: true });
135
+ }
136
+ }
137
+ export const createDocumentTools = (options = {}) => [
138
+ { name: "document_read", capability: "workspace", readOnly: true,
139
+ description: "Read a local PDF, DOCX, XLSX or UTF-8 Markdown file with bounded text/tables and checksum provenance. Reports truncation, uncalculated spreadsheet formulas and PDF pages needing OCR. No OCR, macros, network or formula evaluation.",
140
+ inputSchema: { type: "object", additionalProperties: false, required: ["path"], properties: { path: text(1000),
141
+ maxChars: { type: "integer", minimum: 100, maximum: 24000 }, maxPages: { type: "integer", minimum: 1, maximum: 20 },
142
+ maxRows: { type: "integer", minimum: 1, maximum: 200 }, maxSheets: { type: "integer", minimum: 1, maximum: 8 } } },
143
+ handler: (args, context) => execute("read", args, context, options) },
144
+ { name: "document_create", capability: "workspace", readOnly: false,
145
+ description: "Create a new PDF/DOCX/Markdown from typed text blocks, or XLSX from literal typed sheet rows. Use an existing parent directory and new path. Returns a real file checksum and bounded read-back. Text/tables only; no images or formula calculation. PDF font supports a limited character set and fails rather than dropping unsupported characters.",
146
+ inputSchema: { type: "object", additionalProperties: false, required: ["path", "format"], properties: { path: text(1000), format, title: text(300),
147
+ blocks: array(object({ type: { type: "string", enum: ["heading", "paragraph", "bullet", "table"] }, text: text(8000), level: { type: "integer", minimum: 1, maximum: 6 }, headers: array(text(300), 16, 1), rows }, ["type"]), 100, 1),
148
+ sheets: array(object({ name: { ...text(31), minLength: 1, pattern: "^[^\\\\/*?:\\[\\]]+$" }, rows, header: { type: "boolean" } }, ["name", "rows"]), 8, 1) } },
149
+ handler: (args, context) => execute("create", args, context, options) },
150
+ ];
@@ -0,0 +1,267 @@
1
+ """Offline, bounded document operations. Input/output paths are fixed by the host."""
2
+ import hashlib
3
+ import importlib.metadata
4
+ import io
5
+ import json
6
+ import math
7
+ import resource
8
+ import sys
9
+ import zipfile
10
+ from pathlib import Path
11
+ from xml.sax.saxutils import escape
12
+
13
+ def lower_limit(kind, maximum):
14
+ inherited = resource.getrlimit(kind)
15
+ bound = min([maximum] + [value for value in inherited if value != resource.RLIM_INFINITY])
16
+ resource.setrlimit(kind, (bound, bound))
17
+ return bound
18
+
19
+
20
+ # Darwin exposes RLIMIT_AS but does not provide Linux's address-space limit.
21
+ # Keep the supported CPU/file caps and disclose the missing memory cap.
22
+ LIMITS = {
23
+ "addressSpaceBytes": lower_limit(resource.RLIMIT_AS, 768 * 1024 * 1024) if sys.platform == "linux" else None,
24
+ "cpuSeconds": lower_limit(resource.RLIMIT_CPU, 10),
25
+ "fileBytes": lower_limit(resource.RLIMIT_FSIZE, 16 * 1024 * 1024),
26
+ }
27
+ VERSIONS = {name: importlib.metadata.version(name) for name in ["python-docx", "openpyxl", "pypdf", "reportlab", "defusedxml", "charset-normalizer", "et_xmlfile", "lxml", "pillow", "typing_extensions"]}
28
+ MIME = {"md": "text/markdown", "pdf": "application/pdf", "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}
29
+
30
+
31
+ def bounded_zip(data):
32
+ with zipfile.ZipFile(io.BytesIO(data)) as archive:
33
+ entries = archive.infolist()
34
+ if len(entries) > 4096 or sum(entry.file_size for entry in entries) > 32 * 1024 * 1024:
35
+ raise ValueError("Document archive expands beyond the extraction limit")
36
+ if any(entry.file_size > 8 * 1024 * 1024 or entry.flag_bits & 1 for entry in entries):
37
+ raise ValueError("Oversized or encrypted archive member")
38
+ names = [entry.filename for entry in entries]
39
+ if len(set(names)) != len(names) or any(name.startswith("/") or ".." in name.split("/") for name in names):
40
+ raise ValueError("Unsafe or ambiguous document archive")
41
+
42
+
43
+ def scalar(value):
44
+ if value is None or isinstance(value, (str, bool, int)):
45
+ return value
46
+ if isinstance(value, float) and math.isfinite(value):
47
+ return value
48
+ if hasattr(value, "isoformat"):
49
+ return value.isoformat()
50
+ return str(value)
51
+
52
+
53
+ def read_document(data, fmt, args):
54
+ chars = args.get("maxChars", 16000)
55
+ max_pages = args.get("maxPages", 10)
56
+ max_rows = args.get("maxRows", 100)
57
+ max_sheets = args.get("maxSheets", 4)
58
+ result = {"format": fmt, "truncated": False, "warnings": []}
59
+ remaining = chars
60
+
61
+ def text(value):
62
+ nonlocal remaining
63
+ value = str(value)
64
+ result["truncated"] |= len(value) > remaining
65
+ selected = value[:remaining]
66
+ remaining -= len(selected)
67
+ return selected
68
+
69
+ if fmt == "md":
70
+ result["text"] = text(data.decode("utf-8", errors="strict"))
71
+ elif fmt == "pdf":
72
+ from pypdf import PdfReader
73
+ reader = PdfReader(io.BytesIO(data), strict=True)
74
+ if reader.is_encrypted:
75
+ raise ValueError("Encrypted PDF requires an independently decrypted local copy")
76
+ result["pageCount"] = len(reader.pages)
77
+ result["pages"] = []
78
+ result["truncated"] |= len(reader.pages) > max_pages
79
+ for number, page in enumerate(reader.pages[:max_pages], 1):
80
+ stream = page.get_contents()
81
+ if stream is not None and len(stream.get_data()) > 8 * 1024 * 1024:
82
+ raise ValueError("PDF page content exceeds the extraction limit")
83
+ value = page.extract_text() or ""
84
+ result["pages"].append({"page": number, "text": text(value), "status": "text_extracted" if value.strip() else "no_extractable_text"})
85
+ if not value.strip():
86
+ result["warnings"].append(f"Page {number} has no extractable text; OCR or visual inspection may be needed. No OCR was performed.")
87
+ result["warnings"].append("PDF text order and table layout are heuristic; verify the source page for ambiguous content.")
88
+ elif fmt == "docx":
89
+ from docx import Document
90
+ from docx.table import Table
91
+ bounded_zip(data)
92
+ document = Document(io.BytesIO(data))
93
+ result["blocks"] = []
94
+ for index, block in enumerate(document.iter_inner_content()):
95
+ if index >= 200 or remaining <= 0:
96
+ result["truncated"] = True
97
+ break
98
+ if isinstance(block, Table):
99
+ rows = [[text(cell.text) for cell in row.cells[:32]] for row in block.rows[:max_rows]]
100
+ result["truncated"] |= len(block.rows) > max_rows or any(len(row.cells) > 32 for row in block.rows[:max_rows])
101
+ result["blocks"].append({"type": "table", "rows": rows})
102
+ else:
103
+ result["blocks"].append({"type": "paragraph", "text": text(block.text)})
104
+ result["warnings"].append("Main-body paragraphs/tables only; images, headers, footnotes and tracked changes are not a complete visual interpretation.")
105
+ elif fmt == "xlsx":
106
+ from openpyxl import load_workbook
107
+ bounded_zip(data)
108
+ workbook = load_workbook(io.BytesIO(data), read_only=True, data_only=False, keep_links=False)
109
+ try:
110
+ result["sheetCount"] = len(workbook.worksheets)
111
+ result["sheets"] = []
112
+ result["truncated"] |= len(workbook.worksheets) > max_sheets
113
+ for sheet in workbook.worksheets[:max_sheets]:
114
+ rows, formulas = [], []
115
+ for row in sheet.iter_rows(max_row=min(sheet.max_row or max_rows, max_rows), max_col=min(sheet.max_column or 32, 32)):
116
+ if remaining <= 0:
117
+ result["truncated"] = True
118
+ break
119
+ values = []
120
+ for cell in row:
121
+ value = scalar(cell.value)
122
+ if isinstance(value, str):
123
+ value = text(value)
124
+ if cell.data_type == "f":
125
+ formulas.append({"cell": cell.coordinate, "expression": value})
126
+ values.append(value)
127
+ rows.append(values)
128
+ result["truncated"] |= (sheet.max_row or 0) > max_rows or (sheet.max_column or 0) > 32
129
+ result["sheets"].append({"name": sheet.title, "rows": rows, "formulas": formulas, "formulaValuesVerified": False})
130
+ result["warnings"].append("Formula expressions are source text, never evaluated values. Macros and external links are not executed.")
131
+ finally:
132
+ workbook.close()
133
+ else:
134
+ raise ValueError("Unsupported document format")
135
+ return result
136
+
137
+
138
+ def create_document(fmt, args):
139
+ blocks = args.get("blocks", [])
140
+ sheets = args.get("sheets", [])
141
+ title = args.get("title", "")
142
+ if fmt == "xlsx":
143
+ if blocks or not sheets:
144
+ raise ValueError("XLSX requires sheets and cannot consume text blocks")
145
+ from openpyxl import Workbook
146
+ from openpyxl.styles import Font, PatternFill, Alignment
147
+ workbook = Workbook()
148
+ workbook.remove(workbook.active)
149
+ seen = set()
150
+ for data in sheets:
151
+ name = data["name"]
152
+ if name.lower() in seen:
153
+ raise ValueError("Worksheet names must be unique ignoring case")
154
+ seen.add(name.lower())
155
+ sheet = workbook.create_sheet(name)
156
+ for row in data["rows"]:
157
+ sheet.append(row)
158
+ for cell in sheet[sheet.max_row]:
159
+ if isinstance(cell.value, str):
160
+ cell.data_type = "s" # Literal input never becomes a formula or DDE expression.
161
+ cell.alignment = Alignment(vertical="top", wrap_text=True)
162
+ if data.get("header", True) and data["rows"]:
163
+ for cell in sheet[1]:
164
+ cell.font = Font(color="FFFFFF", bold=True)
165
+ cell.fill = PatternFill("solid", fgColor="234364")
166
+ sheet.freeze_panes = "A2"
167
+ for column in sheet.columns:
168
+ sheet.column_dimensions[column[0].column_letter].width = min(48, max(12, max(len(str(cell.value or "")) for cell in column) + 2))
169
+ output = io.BytesIO()
170
+ workbook.save(output)
171
+ workbook.close()
172
+ return output.getvalue()
173
+ if sheets or not blocks:
174
+ raise ValueError("Text documents require blocks and cannot consume sheets")
175
+ if fmt == "md":
176
+ lines = ["# " + title, ""] if title else []
177
+ safe_cell = lambda value: str(value).replace("|", "\\|").replace("\n", "<br>")
178
+ for block in blocks:
179
+ kind = block["type"]
180
+ if kind == "table":
181
+ headers = block["headers"]
182
+ lines += ["| " + " | ".join(map(safe_cell, headers)) + " |", "| " + " | ".join(["---"] * len(headers)) + " |"]
183
+ lines += ["| " + " | ".join(map(safe_cell, row)) + " |" for row in block["rows"]]
184
+ else:
185
+ prefix = "#" * block.get("level", 2) + " " if kind == "heading" else "- " if kind == "bullet" else ""
186
+ lines.append(prefix + block["text"])
187
+ lines.append("")
188
+ return ("\n".join(lines) + "\n").encode("utf-8")
189
+ if fmt == "docx":
190
+ from docx import Document
191
+ document = Document()
192
+ if title:
193
+ document.add_heading(title, 0)
194
+ for block in blocks:
195
+ if block["type"] == "table":
196
+ table = document.add_table(rows=1, cols=len(block["headers"]))
197
+ table.style = "Light Shading Accent 1"
198
+ for cell, value in zip(table.rows[0].cells, block["headers"]):
199
+ cell.text = str(value)
200
+ for row in block["rows"]:
201
+ for cell, value in zip(table.add_row().cells, row):
202
+ cell.text = str(value)
203
+ elif block["type"] == "heading":
204
+ document.add_heading(block["text"], block.get("level", 2))
205
+ else:
206
+ document.add_paragraph(block["text"], "List Bullet" if block["type"] == "bullet" else None)
207
+ output = io.BytesIO()
208
+ document.save(output)
209
+ return output.getvalue()
210
+ if fmt == "pdf":
211
+ import reportlab
212
+ from reportlab.pdfbase import pdfmetrics
213
+ from reportlab.pdfbase.ttfonts import TTFont
214
+ from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle
215
+ from reportlab.lib.styles import getSampleStyleSheet
216
+ from reportlab.lib.colors import HexColor
217
+ font = TTFont("CodaliVera", str(Path(reportlab.__file__).parent / "fonts" / "Vera.ttf"))
218
+ pdfmetrics.registerFont(font)
219
+ content = title + "".join(block.get("text", "") + "".join(map(str, block.get("headers", []))) + "".join(str(value) for row in block.get("rows", []) for value in row) for block in blocks)
220
+ if any(ord(char) not in font.face.charToGlyph and char not in "\n\r\t" for char in content):
221
+ raise ValueError("Bundled PDF font cannot represent some characters; choose DOCX/Markdown instead of losing text")
222
+ styles = getSampleStyleSheet()
223
+ for style in styles.byName.values():
224
+ style.fontName = "CodaliVera"
225
+ def paragraph(value, style="BodyText"):
226
+ return Paragraph(escape(str(value)).replace("\n", "<br/>"), styles[style])
227
+ elements = [paragraph(title, "Title"), Spacer(1, 12)] if title else []
228
+ for block in blocks:
229
+ if block["type"] == "table":
230
+ rows = [[paragraph(cell) for cell in row] for row in [block["headers"], *block["rows"]]]
231
+ table = Table(rows, colWidths=[450 / len(block["headers"])] * len(block["headers"]), repeatRows=1)
232
+ table.setStyle(TableStyle([("BACKGROUND", (0, 0), (-1, 0), HexColor("#e8eef5")), ("GRID", (0, 0), (-1, -1), .5, HexColor("#9aaabb")), ("VALIGN", (0, 0), (-1, -1), "TOP"), ("BOTTOMPADDING", (0, 0), (-1, -1), 7)]))
233
+ elements.append(table)
234
+ else:
235
+ value = ("• " if block["type"] == "bullet" else "") + block["text"]
236
+ elements.append(paragraph(value, "Heading" + str(min(block.get("level", 2), 3)) if block["type"] == "heading" else "BodyText"))
237
+ elements.append(Spacer(1, 8))
238
+ output = io.BytesIO()
239
+ SimpleDocTemplate(output, title=title, author="", invariant=1).build(elements)
240
+ return output.getvalue()
241
+ raise ValueError("Unsupported document format")
242
+
243
+
244
+ try:
245
+ request = json.loads(Path("input.json").read_text())
246
+ args = request["args"]
247
+ fmt = args["format"]
248
+ if request["operation"] == "read":
249
+ data = Path("source").read_bytes()
250
+ result = read_document(data, fmt, args)
251
+ elif request["operation"] == "create":
252
+ for block in args.get("blocks", []):
253
+ if block["type"] == "table":
254
+ if not block.get("headers") or any(len(row) != len(block["headers"]) for row in block.get("rows", [])):
255
+ raise ValueError("Every table row must match its nonempty header")
256
+ elif "text" not in block:
257
+ raise ValueError("Non-table blocks require text")
258
+ data = create_document(fmt, args)
259
+ if not data or len(data) > 8 * 1024 * 1024:
260
+ raise ValueError("Generated document is empty or oversized")
261
+ Path("output/artifact").write_bytes(data)
262
+ result = {"format": fmt, "mimeType": MIME[fmt], "bytes": len(data), "sha256": hashlib.sha256(data).hexdigest(), "verifiedStructure": read_document(data, fmt, {"maxChars": 1000, "maxRows": 5, "maxSheets": 2, "maxPages": 2})}
263
+ else:
264
+ raise ValueError("Unknown operation")
265
+ print(json.dumps({"versions": VERSIONS, "resourceLimits": LIMITS, **result}, ensure_ascii=False, allow_nan=False))
266
+ except Exception as error:
267
+ print(json.dumps({"error": str(error)[:1200], "versions": VERSIONS}))
@@ -0,0 +1,7 @@
1
+ import { type ToolDefinition } from "../ToolTypes.js";
2
+ export interface AdesToolOptions {
3
+ baseUrl?: string;
4
+ timeoutMs?: number;
5
+ }
6
+ export declare const createAdesTool: (options?: AdesToolOptions) => ToolDefinition;
7
+ //# sourceMappingURL=AdesTool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdesTool.d.ts","sourceRoot":"","sources":["../../../src/tools/entities/AdesTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE1E,MAAM,WAAW,eAAe;IAAG,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAAE;AAC1E,eAAO,MAAM,cAAc,GAAI,UAAS,eAAoB,KAAG,cAmC7D,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { createHash } from "node:crypto";
2
+ import { ToolExecutionError } from "../ToolTypes.js";
3
+ export const createAdesTool = (options = {}) => ({
4
+ name: "extract_entities", capability: "entity_hints", readOnly: true,
5
+ description: "Local ADES deterministic entity/alias extraction. Returns confidence, canonical IDs and provenance as optional retrieval hints, not facts. Preserve the original query; empty results do not establish absence. No LLM refinement or graph expansion.",
6
+ inputSchema: { type: "object", properties: { text: { type: "string", minLength: 1, maxLength: 8000 }, pack: { type: "string", pattern: "^[a-z][a-z0-9-]{0,79}$", maxLength: 80 } }, required: ["text"], additionalProperties: false },
7
+ handler: async (raw, context) => {
8
+ const args = raw;
9
+ if (typeof args.text !== "string" || !args.text.length || args.text.length > 8000 || (args.pack !== undefined && !/^[a-z][a-z0-9-]{0,79}$/.test(args.pack)))
10
+ throw new ToolExecutionError("tool_invalid_args", "Provide bounded text and a valid pack name");
11
+ const base = new URL(options.baseUrl ?? process.env.CODALI_ADES_URL ?? "http://127.0.0.1:8734");
12
+ if (!["http:", "https:"].includes(base.protocol) || !["127.0.0.1", "[::1]", "localhost"].includes(base.hostname) || base.username || base.password)
13
+ throw new ToolExecutionError("tool_permission_denied", "The built-in entity tool accepts only a local ADES service");
14
+ const signal = AbortSignal.any([...(context.signal ? [context.signal] : []), AbortSignal.timeout(options.timeoutMs ?? 2500)]);
15
+ signal.throwIfAborted();
16
+ const started = Date.now();
17
+ const request = { text: args.text, pack: args.pack ?? "general-en", content_type: "text/plain", options: {
18
+ hybrid: false, include_related_entities: false, include_graph_support: false, refine_links: false, include_impact_paths: false,
19
+ } };
20
+ const response = await fetch(new URL("/v0/tag", base), { method: "POST", redirect: "error", signal, headers: { "content-type": "application/json" }, body: JSON.stringify(request) });
21
+ if (!response.ok) {
22
+ await response.body?.cancel();
23
+ throw new ToolExecutionError("tool_execution_failed", `Local ADES returned HTTP ${response.status}`, { retryable: false });
24
+ }
25
+ if (!response.body)
26
+ throw new ToolExecutionError("tool_execution_failed", "Empty ADES response");
27
+ const reader = response.body.getReader();
28
+ const chunks = [];
29
+ let size = 0;
30
+ try {
31
+ for (;;) {
32
+ const next = await reader.read();
33
+ if (next.done)
34
+ break;
35
+ size += next.value.length;
36
+ if (size > 256000)
37
+ throw new ToolExecutionError("tool_execution_failed", "ADES response exceeds the limit");
38
+ chunks.push(next.value);
39
+ }
40
+ }
41
+ finally {
42
+ await reader.cancel();
43
+ }
44
+ const result = JSON.parse(Buffer.concat(chunks).toString("utf8"));
45
+ if (!Array.isArray(result.entities) || result.refinement_applied === true)
46
+ throw new ToolExecutionError("tool_execution_failed", "ADES did not return a deterministic extraction result");
47
+ const bounded = (value, max = 160) => typeof value === "string" ? value.slice(0, max) : undefined;
48
+ const entities = result.entities.slice(0, 64).map((entity) => ({
49
+ text: bounded(entity.text), label: bounded(entity.label, 80), confidence: typeof entity.confidence === "number" && Number.isFinite(entity.confidence) ? entity.confidence : null,
50
+ start: Number.isSafeInteger(entity.start) ? entity.start : null, end: Number.isSafeInteger(entity.end) ? entity.end : null,
51
+ canonical: bounded(entity.link?.canonical_text), id: bounded(entity.link?.entity_id), aliases: Array.isArray(entity.aliases) ? entity.aliases.slice(0, 8).map((alias) => bounded(alias)) : [],
52
+ provenance: { lane: bounded(entity.provenance?.lane), pack: bounded(entity.provenance?.source_pack), weakAlias: entity.provenance?.weak_alias ?? null, match: bounded(entity.provenance?.match_kind) },
53
+ }));
54
+ const data = { library: "adestool", version: bounded(result.version), pack: bounded(result.pack), packVersion: bounded(result.pack_version),
55
+ inputSha256: createHash("sha256").update(JSON.stringify(request)).digest("hex"), elapsedMs: Date.now() - started, entities,
56
+ truncated: result.entities.length > 64, scope: "Optional entity hints; ambiguous or missed matches are possible. Keep the original query and verify facts with Docdex/source evidence." };
57
+ return { output: JSON.stringify(data), data };
58
+ },
59
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"FileTools.d.ts","sourceRoot":"","sources":["../../../src/tools/filesystem/FileTools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA8EnE,eAAO,MAAM,eAAe,QAAO,cAAc,EAkGhD,CAAC"}
1
+ {"version":3,"file":"FileTools.d.ts","sourceRoot":"","sources":["../../../src/tools/filesystem/FileTools.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA2FnE,eAAO,MAAM,eAAe,QAAO,cAAc,EA8HhD,CAAC"}