@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.
- package/README.md +5 -0
- package/dist/codali-executor.d.ts +19 -0
- package/dist/codali-executor.d.ts.map +1 -1
- package/dist/codali-executor.js +54 -2
- package/dist/codali-executor.js.map +1 -1
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +13 -5
- package/dist/runtime.js.map +1 -1
- package/dist/vendor/codali/cli/TerminalArtifacts.d.ts +5 -0
- package/dist/vendor/codali/cli/TerminalArtifacts.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalArtifacts.js +26 -0
- package/dist/vendor/codali/cli/TerminalCommand.d.ts +2 -1
- package/dist/vendor/codali/cli/TerminalCommand.d.ts.map +1 -1
- package/dist/vendor/codali/cli/TerminalCommand.js +436 -100
- package/dist/vendor/codali/cli/TerminalCredentials.js +2 -2
- package/dist/vendor/codali/cli/TerminalInput.d.ts +13 -0
- package/dist/vendor/codali/cli/TerminalInput.d.ts.map +1 -1
- package/dist/vendor/codali/cli/TerminalInput.js +55 -7
- package/dist/vendor/codali/cli/TerminalModels.d.ts +6 -0
- package/dist/vendor/codali/cli/TerminalModels.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalModels.js +45 -0
- package/dist/vendor/codali/cli/TerminalPlan.d.ts +40 -0
- package/dist/vendor/codali/cli/TerminalPlan.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalPlan.js +37 -0
- package/dist/vendor/codali/cli/ToolsCommand.d.ts.map +1 -1
- package/dist/vendor/codali/cli/ToolsCommand.js +8 -1
- package/dist/vendor/codali/cli/tui/TerminalCells.d.ts +6 -0
- package/dist/vendor/codali/cli/tui/TerminalCells.d.ts.map +1 -0
- package/dist/vendor/codali/cli/tui/TerminalCells.js +47 -0
- package/dist/vendor/codali/cli/tui/TerminalEditor.d.ts +22 -0
- package/dist/vendor/codali/cli/tui/TerminalEditor.d.ts.map +1 -0
- package/dist/vendor/codali/cli/tui/TerminalEditor.js +88 -0
- package/dist/vendor/codali/cli/tui/TerminalLogo.d.ts +6 -0
- package/dist/vendor/codali/cli/tui/TerminalLogo.d.ts.map +1 -0
- package/dist/vendor/codali/cli/tui/TerminalLogo.js +26 -0
- package/dist/vendor/codali/cli/tui/TerminalMarkdown.d.ts +5 -0
- package/dist/vendor/codali/cli/tui/TerminalMarkdown.d.ts.map +1 -0
- package/dist/vendor/codali/cli/tui/TerminalMarkdown.js +118 -0
- package/dist/vendor/codali/cli/tui/TerminalPresentation.d.ts +6 -0
- package/dist/vendor/codali/cli/tui/TerminalPresentation.d.ts.map +1 -0
- package/dist/vendor/codali/cli/tui/TerminalPresentation.js +152 -0
- package/dist/vendor/codali/cli/tui/TerminalScreen.d.ts +50 -0
- package/dist/vendor/codali/cli/tui/TerminalScreen.d.ts.map +1 -0
- package/dist/vendor/codali/cli/tui/TerminalScreen.js +137 -0
- package/dist/vendor/codali/cli/tui/TerminalSelection.d.ts +15 -0
- package/dist/vendor/codali/cli/tui/TerminalSelection.d.ts.map +1 -0
- package/dist/vendor/codali/cli/tui/TerminalSelection.js +38 -0
- package/dist/vendor/codali/cli/tui/TerminalTui.d.ts +82 -0
- package/dist/vendor/codali/cli/tui/TerminalTui.d.ts.map +1 -0
- package/dist/vendor/codali/cli/tui/TerminalTui.js +564 -0
- package/dist/vendor/codali/cli.d.ts.map +1 -1
- package/dist/vendor/codali/cli.js +5 -3
- package/dist/vendor/codali/config/OrchestrationConfig.d.ts +40 -0
- package/dist/vendor/codali/config/OrchestrationConfig.d.ts.map +1 -1
- package/dist/vendor/codali/config/OrchestrationConfig.js +74 -3
- package/dist/vendor/codali/connectors/media/MediaJobStore.d.ts +2 -1
- package/dist/vendor/codali/connectors/media/MediaJobStore.d.ts.map +1 -1
- package/dist/vendor/codali/connectors/media/MediaJobStore.js +11 -3
- package/dist/vendor/codali/docdex/DocdexCatalog.d.ts +12 -0
- package/dist/vendor/codali/docdex/DocdexCatalog.d.ts.map +1 -0
- package/dist/vendor/codali/docdex/DocdexCatalog.js +30 -0
- package/dist/vendor/codali/docdex/DocdexClient.d.ts +9 -2
- package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -1
- package/dist/vendor/codali/docdex/DocdexClient.js +86 -11
- package/dist/vendor/codali/docdex/ManagedDocdex.d.ts +4 -0
- package/dist/vendor/codali/docdex/ManagedDocdex.d.ts.map +1 -1
- package/dist/vendor/codali/docdex/ManagedDocdex.js +42 -5
- package/dist/vendor/codali/eval/TerminalWorkflowCorpus.d.ts +1 -1
- package/dist/vendor/codali/eval/TerminalWorkflowCorpus.d.ts.map +1 -1
- package/dist/vendor/codali/eval/TerminalWorkflowCorpus.js +9 -6
- package/dist/vendor/codali/eval/TrustBenchmark.d.ts +94 -0
- package/dist/vendor/codali/eval/TrustBenchmark.d.ts.map +1 -0
- package/dist/vendor/codali/eval/TrustBenchmark.js +199 -0
- package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.d.ts +4 -0
- package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.d.ts.map +1 -0
- package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.js +10 -0
- package/dist/vendor/codali/eval/fixtures/MixedMediaRecoveryJourney.d.ts +6 -0
- package/dist/vendor/codali/eval/fixtures/MixedMediaRecoveryJourney.d.ts.map +1 -0
- package/dist/vendor/codali/eval/fixtures/MixedMediaRecoveryJourney.js +145 -0
- package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.d.ts.map +1 -1
- package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.js +14 -1
- package/dist/vendor/codali/gateway/GroundingMode.d.ts.map +1 -1
- package/dist/vendor/codali/gateway/GroundingMode.js +23 -3
- package/dist/vendor/codali/index.d.ts +1 -0
- package/dist/vendor/codali/index.d.ts.map +1 -1
- package/dist/vendor/codali/index.js +1 -0
- package/dist/vendor/codali/permissions/PermissionGate.d.ts +1 -1
- package/dist/vendor/codali/permissions/PermissionGate.d.ts.map +1 -1
- package/dist/vendor/codali/permissions/PermissionGate.js +45 -5
- package/dist/vendor/codali/permissions/WorkspacePermissions.d.ts +11 -0
- package/dist/vendor/codali/permissions/WorkspacePermissions.d.ts.map +1 -0
- package/dist/vendor/codali/permissions/WorkspacePermissions.js +42 -0
- package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts +1 -0
- package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts.map +1 -1
- package/dist/vendor/codali/providers/ConfiguredModelScope.js +19 -2
- package/dist/vendor/codali/providers/ConfiguredProvider.d.ts +6 -0
- package/dist/vendor/codali/providers/ConfiguredProvider.d.ts.map +1 -1
- package/dist/vendor/codali/providers/ConfiguredProvider.js +88 -34
- package/dist/vendor/codali/providers/ModelCapacityWait.d.ts +21 -0
- package/dist/vendor/codali/providers/ModelCapacityWait.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ModelCapacityWait.js +40 -0
- package/dist/vendor/codali/providers/ModelServiceError.d.ts +16 -2
- package/dist/vendor/codali/providers/ModelServiceError.d.ts.map +1 -1
- package/dist/vendor/codali/providers/ModelServiceError.js +37 -5
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +26 -3
- package/dist/vendor/codali/providers/ProviderTypes.d.ts +6 -0
- package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -1
- package/dist/vendor/codali/providers/RequestSize.d.ts +5 -0
- package/dist/vendor/codali/providers/RequestSize.d.ts.map +1 -0
- package/dist/vendor/codali/providers/RequestSize.js +10 -0
- package/dist/vendor/codali/providers/RequestUsage.d.ts +11 -0
- package/dist/vendor/codali/providers/RequestUsage.d.ts.map +1 -0
- package/dist/vendor/codali/providers/RequestUsage.js +33 -0
- package/dist/vendor/codali/runtime/AnswerVerification.d.ts +17 -0
- package/dist/vendor/codali/runtime/AnswerVerification.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/AnswerVerification.js +39 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +1 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/CodaliRuntime.js +1 -0
- package/dist/vendor/codali/runtime/CompletionReport.d.ts +2 -0
- package/dist/vendor/codali/runtime/CompletionReport.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/CompletionReport.js +17 -0
- package/dist/vendor/codali/runtime/ComputedAnswer.d.ts +13 -0
- package/dist/vendor/codali/runtime/ComputedAnswer.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ComputedAnswer.js +75 -0
- package/dist/vendor/codali/runtime/ContextCompression.d.ts +38 -0
- package/dist/vendor/codali/runtime/ContextCompression.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ContextCompression.js +263 -0
- package/dist/vendor/codali/runtime/GatewayRequest.d.ts +5 -0
- package/dist/vendor/codali/runtime/GatewayRequest.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/GatewayRequest.js +19 -0
- package/dist/vendor/codali/runtime/InspectionBudget.d.ts +11 -0
- package/dist/vendor/codali/runtime/InspectionBudget.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/InspectionBudget.js +23 -0
- package/dist/vendor/codali/runtime/InspectionConvergence.d.ts +24 -0
- package/dist/vendor/codali/runtime/InspectionConvergence.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/InspectionConvergence.js +67 -0
- package/dist/vendor/codali/runtime/InteractionContract.d.ts +44 -0
- package/dist/vendor/codali/runtime/InteractionContract.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/InteractionContract.js +64 -0
- package/dist/vendor/codali/runtime/InteractionRouter.d.ts +73 -0
- package/dist/vendor/codali/runtime/InteractionRouter.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/InteractionRouter.js +138 -0
- package/dist/vendor/codali/runtime/PlanCoverage.d.ts +9 -0
- package/dist/vendor/codali/runtime/PlanCoverage.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/PlanCoverage.js +12 -0
- package/dist/vendor/codali/runtime/PreparedDocdex.d.ts +4 -0
- package/dist/vendor/codali/runtime/PreparedDocdex.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/PreparedDocdex.js +55 -0
- package/dist/vendor/codali/runtime/PreparedMemory.d.ts +3 -0
- package/dist/vendor/codali/runtime/PreparedMemory.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/PreparedMemory.js +30 -0
- package/dist/vendor/codali/runtime/ProgressTracker.d.ts +1 -0
- package/dist/vendor/codali/runtime/ProgressTracker.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/ProgressTracker.js +25 -5
- package/dist/vendor/codali/runtime/ResearchEvidence.d.ts +19 -0
- package/dist/vendor/codali/runtime/ResearchEvidence.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ResearchEvidence.js +55 -0
- package/dist/vendor/codali/runtime/ReviewContract.d.ts +35 -0
- package/dist/vendor/codali/runtime/ReviewContract.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ReviewContract.js +132 -0
- package/dist/vendor/codali/runtime/ReviewCoordinator.d.ts +43 -0
- package/dist/vendor/codali/runtime/ReviewCoordinator.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ReviewCoordinator.js +134 -0
- package/dist/vendor/codali/runtime/ReviewSource.d.ts +3 -0
- package/dist/vendor/codali/runtime/ReviewSource.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/ReviewSource.js +17 -1
- package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/Runner.js +6 -1
- package/dist/vendor/codali/runtime/SessionController.d.ts +71 -5
- package/dist/vendor/codali/runtime/SessionController.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/SessionController.js +1913 -223
- package/dist/vendor/codali/runtime/SpecialistTools.d.ts +6 -0
- package/dist/vendor/codali/runtime/SpecialistTools.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/SpecialistTools.js +69 -0
- package/dist/vendor/codali/runtime/StructuralEvidence.d.ts +4 -2
- package/dist/vendor/codali/runtime/StructuralEvidence.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/StructuralEvidence.js +22 -5
- package/dist/vendor/codali/runtime/TaskReview.d.ts +25 -0
- package/dist/vendor/codali/runtime/TaskReview.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/TaskReview.js +109 -0
- package/dist/vendor/codali/runtime/TaskReviewContext.d.ts +37 -0
- package/dist/vendor/codali/runtime/TaskReviewContext.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/TaskReviewContext.js +18 -2
- package/dist/vendor/codali/runtime/UsageReconciliation.d.ts +28 -0
- package/dist/vendor/codali/runtime/UsageReconciliation.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/UsageReconciliation.js +68 -0
- package/dist/vendor/codali/runtime/VerificationCommand.d.ts +2 -0
- package/dist/vendor/codali/runtime/VerificationCommand.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/VerificationCommand.js +28 -0
- package/dist/vendor/codali/runtime/VerificationReceiptSelection.d.ts +15 -0
- package/dist/vendor/codali/runtime/VerificationReceiptSelection.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/VerificationReceiptSelection.js +30 -0
- package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts +2 -0
- package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/WorkspaceLedger.js +44 -20
- package/dist/vendor/codali/runtime/WorkspaceLock.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/WorkspaceLock.js +9 -1
- package/dist/vendor/codali/runtime/WorkspaceSnapshot.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/WorkspaceSnapshot.js +3 -2
- package/dist/vendor/codali/runtime/WriteSyntaxCheck.d.ts +10 -0
- package/dist/vendor/codali/runtime/WriteSyntaxCheck.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/WriteSyntaxCheck.js +34 -0
- package/dist/vendor/codali/session/AtomicState.d.ts.map +1 -1
- package/dist/vendor/codali/session/AtomicState.js +15 -1
- package/dist/vendor/codali/session/InstructionLoader.d.ts +5 -1
- package/dist/vendor/codali/session/InstructionLoader.d.ts.map +1 -1
- package/dist/vendor/codali/session/InstructionLoader.js +65 -19
- package/dist/vendor/codali/session/SessionStoragePath.d.ts.map +1 -1
- package/dist/vendor/codali/session/SessionStoragePath.js +34 -17
- package/dist/vendor/codali/session/SessionStore.d.ts +5 -1
- package/dist/vendor/codali/session/SessionStore.d.ts.map +1 -1
- package/dist/vendor/codali/session/SessionStore.js +11 -2
- package/dist/vendor/codali/session/SkillCatalog.d.ts +33 -0
- package/dist/vendor/codali/session/SkillCatalog.d.ts.map +1 -0
- package/dist/vendor/codali/session/SkillCatalog.js +197 -0
- package/dist/vendor/codali/session/WorkState.d.ts +11 -0
- package/dist/vendor/codali/session/WorkState.d.ts.map +1 -1
- package/dist/vendor/codali/session/WorkState.js +46 -2
- package/dist/vendor/codali/session/WorkTypes.d.ts +8 -0
- package/dist/vendor/codali/session/WorkTypes.d.ts.map +1 -1
- package/dist/vendor/codali/session/WorkspaceScope.d.ts +3 -0
- package/dist/vendor/codali/session/WorkspaceScope.d.ts.map +1 -0
- package/dist/vendor/codali/session/WorkspaceScope.js +19 -0
- package/dist/vendor/codali/tools/SemanticToolRetrieval.d.ts +19 -0
- package/dist/vendor/codali/tools/SemanticToolRetrieval.d.ts.map +1 -0
- package/dist/vendor/codali/tools/SemanticToolRetrieval.js +52 -0
- package/dist/vendor/codali/tools/ToolRetrieval.d.ts +7 -0
- package/dist/vendor/codali/tools/ToolRetrieval.d.ts.map +1 -0
- package/dist/vendor/codali/tools/ToolRetrieval.js +25 -0
- package/dist/vendor/codali/tools/ToolTypes.d.ts +2 -0
- package/dist/vendor/codali/tools/ToolTypes.d.ts.map +1 -1
- package/dist/vendor/codali/tools/browser/BrowserSessionTool.d.ts +16 -0
- package/dist/vendor/codali/tools/browser/BrowserSessionTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/browser/BrowserSessionTool.js +326 -0
- package/dist/vendor/codali/tools/browser/BrowserTool.d.ts +17 -0
- package/dist/vendor/codali/tools/browser/BrowserTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/browser/BrowserTool.js +291 -0
- package/dist/vendor/codali/tools/browser/BrowserWorker.d.ts +2 -0
- package/dist/vendor/codali/tools/browser/BrowserWorker.d.ts.map +1 -0
- package/dist/vendor/codali/tools/browser/BrowserWorker.js +121 -0
- package/dist/vendor/codali/tools/calculation/CalculatorTool.d.ts +5 -0
- package/dist/vendor/codali/tools/calculation/CalculatorTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/calculation/CalculatorTool.js +163 -0
- package/dist/vendor/codali/tools/deterministic/DeterministicRuntime.d.ts +39 -0
- package/dist/vendor/codali/tools/deterministic/DeterministicRuntime.d.ts.map +1 -0
- package/dist/vendor/codali/tools/deterministic/DeterministicRuntime.js +98 -0
- package/dist/vendor/codali/tools/deterministic/DeterministicTools.d.ts +8 -0
- package/dist/vendor/codali/tools/deterministic/DeterministicTools.d.ts.map +1 -0
- package/dist/vendor/codali/tools/deterministic/DeterministicTools.js +100 -0
- package/dist/vendor/codali/tools/deterministic/node-worker.cjs +38 -0
- package/dist/vendor/codali/tools/deterministic/python-worker.py +237 -0
- package/dist/vendor/codali/tools/docdex/DocdexCatalogTools.d.ts +4 -0
- package/dist/vendor/codali/tools/docdex/DocdexCatalogTools.d.ts.map +1 -0
- package/dist/vendor/codali/tools/docdex/DocdexCatalogTools.js +59 -0
- package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts +2 -0
- package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts.map +1 -1
- package/dist/vendor/codali/tools/docdex/DocdexTools.js +81 -106
- package/dist/vendor/codali/tools/documents/DocumentRuntime.d.ts +12 -0
- package/dist/vendor/codali/tools/documents/DocumentRuntime.d.ts.map +1 -0
- package/dist/vendor/codali/tools/documents/DocumentRuntime.js +59 -0
- package/dist/vendor/codali/tools/documents/DocumentTools.d.ts +19 -0
- package/dist/vendor/codali/tools/documents/DocumentTools.d.ts.map +1 -0
- package/dist/vendor/codali/tools/documents/DocumentTools.js +150 -0
- package/dist/vendor/codali/tools/documents/worker.py +267 -0
- package/dist/vendor/codali/tools/entities/AdesTool.d.ts +7 -0
- package/dist/vendor/codali/tools/entities/AdesTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/entities/AdesTool.js +59 -0
- package/dist/vendor/codali/tools/filesystem/FileTools.d.ts.map +1 -1
- package/dist/vendor/codali/tools/filesystem/FileTools.js +58 -11
- package/dist/vendor/codali/tools/research/TnlTool.d.ts +22 -0
- package/dist/vendor/codali/tools/research/TnlTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/research/TnlTool.js +246 -0
- package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts +7 -0
- package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts.map +1 -1
- package/dist/vendor/codali/tools/shell/AsyncProcess.js +9 -3
- package/dist/vendor/codali/tools/shell/HostToolchain.d.ts.map +1 -1
- package/dist/vendor/codali/tools/shell/HostToolchain.js +37 -5
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts +4 -2
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts.map +1 -1
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.js +126 -27
- package/dist/vendor/codali/tools/shell/ShellTool.d.ts +2 -0
- package/dist/vendor/codali/tools/shell/ShellTool.d.ts.map +1 -1
- package/dist/vendor/codali/tools/shell/ShellTool.js +18 -4
- package/dist/vendor/codali/tools/system/CalendarTool.d.ts +15 -0
- package/dist/vendor/codali/tools/system/CalendarTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/system/CalendarTool.js +44 -0
- package/dist/vendor/codali/tools/system/TextTool.d.ts +4 -0
- package/dist/vendor/codali/tools/system/TextTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/system/TextTool.js +39 -0
- package/dist/vendor/codali/tools/system/TimeTool.d.ts +4 -0
- package/dist/vendor/codali/tools/system/TimeTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/system/TimeTool.js +22 -0
- package/dist/vendor/codali/tools/verification/JavaScriptVerificationTool.d.ts +47 -0
- package/dist/vendor/codali/tools/verification/JavaScriptVerificationTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/verification/JavaScriptVerificationTool.js +71 -0
- package/dist/vendor/codali/tools/verification/JavaScriptVerificationWorker.d.ts +2 -0
- package/dist/vendor/codali/tools/verification/JavaScriptVerificationWorker.d.ts.map +1 -0
- package/dist/vendor/codali/tools/verification/JavaScriptVerificationWorker.js +91 -0
- package/dist/vendor/codali/tools/verification/VitestTool.d.ts +6 -0
- package/dist/vendor/codali/tools/verification/VitestTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/verification/VitestTool.js +184 -0
- package/dist/vendor/config/AGENTS.md +17 -0
- package/dist/vendor/config/deterministic/install-python.mjs +16 -0
- package/dist/vendor/config/deterministic/node-worker.mjs +77 -0
- package/dist/vendor/config/deterministic/python-worker.py +237 -0
- package/dist/vendor/config/deterministic/requirements.txt +6 -0
- package/dist/vendor/config/docdex-runtime.json +21 -0
- package/dist/vendor/config/docdex-tools-0.2.99.json +3977 -0
- package/dist/vendor/config/documents/install-python.mjs +16 -0
- package/dist/vendor/config/documents/requirements.txt +10 -0
- package/dist/vendor/config/documents/worker.py +267 -0
- package/dist/vendor/config/skills/architecture-design/SKILL.md +14 -0
- package/dist/vendor/config/skills/browser-session/SKILL.md +16 -0
- package/dist/vendor/config/skills/browser-use/SKILL.md +14 -0
- package/dist/vendor/config/skills/code-implementation/SKILL.md +18 -0
- package/dist/vendor/config/skills/code-review/SKILL.md +14 -0
- package/dist/vendor/config/skills/docdex-research/SKILL.md +18 -0
- package/dist/vendor/config/skills/docdex-research/references/catalog.md +111 -0
- package/dist/vendor/config/skills/docdex-research/references/memory.md +22 -0
- package/dist/vendor/config/skills/docdex-research/references/operations.md +19 -0
- package/dist/vendor/config/skills/docdex-research/references/retrieval.md +13 -0
- package/dist/vendor/config/skills/planning/SKILL.md +14 -0
- package/dist/vendor/config/skills/system-diagnostics/SKILL.md +14 -0
- package/dist/vendor/config/skills/system-services/SKILL.md +17 -0
- package/dist/vendor/config/skills/system-services/references/docker.md +11 -0
- package/dist/vendor/config/skills/system-services/references/linux.md +9 -0
- package/dist/vendor/config/skills/system-services/references/macos.md +9 -0
- package/dist/vendor/config/skills/systematic-debugging/SKILL.md +14 -0
- package/dist/vendor/config/skills/testing-and-verification/SKILL.md +16 -0
- package/dist/vendor/config/skills/tool-selection/SKILL.md +16 -0
- package/dist/vendor/config/skills/ui-ux-design/SKILL.md +16 -0
- package/dist/vendor/config/skills/ui-ux-design/references/validation.md +13 -0
- package/dist/vendor/config/skills/webapp-testing/SKILL.md +12 -0
- package/package.json +15 -5
- package/scripts/media_gpu_lock.py +2 -2
- package/scripts/native_load_guard.py +257 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { chromium } from "playwright-core";
|
|
2
|
+
// This process runs in a private empty directory with an explicit environment.
|
|
3
|
+
// browser-use reads .env at import time, so never import it in the CLI process.
|
|
4
|
+
process.once("message", async (input) => {
|
|
5
|
+
let browser;
|
|
6
|
+
let session;
|
|
7
|
+
let reply;
|
|
8
|
+
try {
|
|
9
|
+
browser = await chromium.connect(input.endpoint, { timeout: 10000 });
|
|
10
|
+
const context = await browser.newContext({ acceptDownloads: false, serviceWorkers: "block", permissions: [] });
|
|
11
|
+
context.setDefaultTimeout(5000);
|
|
12
|
+
await context.route("**/*", route => {
|
|
13
|
+
const request = route.request();
|
|
14
|
+
let url;
|
|
15
|
+
try {
|
|
16
|
+
url = new URL(request.url());
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return route.abort("blockedbyclient");
|
|
20
|
+
}
|
|
21
|
+
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || !["GET", "HEAD"].includes(request.method()))
|
|
22
|
+
return route.abort("blockedbyclient");
|
|
23
|
+
return route.continue();
|
|
24
|
+
});
|
|
25
|
+
await context.routeWebSocket("**/*", socket => socket.close());
|
|
26
|
+
const tab = await context.newPage();
|
|
27
|
+
let httpStatus = null;
|
|
28
|
+
let contentType = null;
|
|
29
|
+
tab.on("response", response => {
|
|
30
|
+
if (response.request().isNavigationRequest() && response.frame() === tab.mainFrame()) {
|
|
31
|
+
httpStatus = response.status();
|
|
32
|
+
contentType = response.headers()["content-type"] ?? null;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
context.on("page", popup => { if (popup !== tab)
|
|
36
|
+
void popup.close().catch(() => undefined); });
|
|
37
|
+
tab.on("dialog", dialog => { void dialog.dismiss().catch(() => undefined); });
|
|
38
|
+
const { BrowserSession } = await import("browser-use/dist/browser/session.js");
|
|
39
|
+
session = new BrowserSession({ browser, browser_context: context, page: tab,
|
|
40
|
+
profile: { accept_downloads: false, enable_default_extensions: false, captcha_solver: false,
|
|
41
|
+
keep_alive: false, permissions: [], minimum_wait_page_load_time: 0,
|
|
42
|
+
wait_for_network_idle_page_load_time: 0.1, maximum_wait_page_load_time: 1 } });
|
|
43
|
+
// A network-interface change aborts navigation immediately and says nothing
|
|
44
|
+
// about the page itself, so a single retry is cheap and cannot mask a 404.
|
|
45
|
+
for (let attempt = 0;; attempt++) {
|
|
46
|
+
try {
|
|
47
|
+
await session.navigate_to(input.url, { wait_until: "domcontentloaded", timeout_ms: 25000 });
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (attempt >= 1 || !String(error).includes("ERR_NETWORK_CHANGED"))
|
|
52
|
+
throw error;
|
|
53
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Accessibility snapshots otherwise flatten deleted/struck-through text
|
|
57
|
+
// into apparently current prose. Mark revisions in this disposable DOM;
|
|
58
|
+
// no page action, form submission or remote mutation is performed.
|
|
59
|
+
await tab.locator('del, s, strike, [style*="line-through"]').evaluateAll(elements => {
|
|
60
|
+
for (const element of elements.slice(0, 100)) {
|
|
61
|
+
if (element.parentElement?.closest('del, s, strike, [style*="line-through"]'))
|
|
62
|
+
continue;
|
|
63
|
+
element.prepend(document.createTextNode("[DELETED/STRUCK-THROUGH TEXT — not current guidance: "));
|
|
64
|
+
element.append(document.createTextNode("]"));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const main = tab.getByRole("main");
|
|
68
|
+
const useMain = input.scope !== "page" && await main.count() > 0;
|
|
69
|
+
const root = useMain ? main.first() : tab.locator("body");
|
|
70
|
+
let content;
|
|
71
|
+
let format = "accessibility";
|
|
72
|
+
if (input.scope !== "page") {
|
|
73
|
+
// Inline links/emphasis split ordinary prose into many ARIA records. Read
|
|
74
|
+
// rendered text for research, retaining heading scopes and revision marks.
|
|
75
|
+
// The disposable page is never submitted or persisted remotely.
|
|
76
|
+
const links = await root.locator("a[href]").evaluateAll(elements => elements.slice(0, 128).flatMap(element => {
|
|
77
|
+
const link = element;
|
|
78
|
+
if (link.closest('nav,[role="navigation"]') || !link.getClientRects().length)
|
|
79
|
+
return [];
|
|
80
|
+
try {
|
|
81
|
+
const url = new URL(link.href);
|
|
82
|
+
return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password
|
|
83
|
+
? [`- link ${JSON.stringify((link.innerText || link.textContent || "").trim().slice(0, 160))}\n - /url: ${url.href.slice(0, 1000)}`] : [];
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
}));
|
|
89
|
+
await root.locator('h1,h2,h3,h4,h5,h6,[role="heading"]').evaluateAll(elements => {
|
|
90
|
+
for (const element of elements) {
|
|
91
|
+
const heading = element;
|
|
92
|
+
const level = Number(heading.getAttribute("aria-level") || heading.tagName.slice(1)) || 2;
|
|
93
|
+
const label = heading.innerText?.trim();
|
|
94
|
+
if (label)
|
|
95
|
+
heading.textContent = `- heading ${JSON.stringify(label)} [level=${Math.min(6, Math.max(1, level))}]`;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
content = await root.innerText({ timeout: 5000 });
|
|
99
|
+
if (content.trim()) {
|
|
100
|
+
format = "rendered_text";
|
|
101
|
+
if (links.length)
|
|
102
|
+
content += `\n\nSource links (first 128, bounded; not additional retrieved evidence):\n${links.join("\n").slice(0, 16000)}`;
|
|
103
|
+
}
|
|
104
|
+
else
|
|
105
|
+
content = await root.ariaSnapshot({ timeout: 5000 });
|
|
106
|
+
}
|
|
107
|
+
else
|
|
108
|
+
content = await tab.ariaSnapshot({ mode: "default", depth: 20, timeout: 5000 });
|
|
109
|
+
reply = { ok: true, value: { url: tab.url(), httpStatus, contentType, title: (await tab.title()).slice(0, 1000), scope: useMain ? "main" : "page",
|
|
110
|
+
format, content: content.slice(0, 1000000), truncated: content.length > 1000000 } };
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
reply = { ok: false, message: error instanceof Error ? error.message : String(error) };
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
await session?.stop().catch(() => undefined);
|
|
117
|
+
await browser?.close().catch(() => undefined);
|
|
118
|
+
}
|
|
119
|
+
if (process.connected)
|
|
120
|
+
process.send?.(reply, () => process.disconnect());
|
|
121
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ToolDefinition } from "../ToolTypes.js";
|
|
2
|
+
/** Bounded Pratt parser; exponentiation is right associative and binds more tightly than unary minus. */
|
|
3
|
+
export declare const evaluateCalculation: (expression: string) => number;
|
|
4
|
+
export declare const createCalculatorTool: () => ToolDefinition;
|
|
5
|
+
//# sourceMappingURL=CalculatorTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalculatorTool.d.ts","sourceRoot":"","sources":["../../../src/tools/calculation/CalculatorTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA8C1E,yGAAyG;AACzG,eAAO,MAAM,mBAAmB,GAAI,YAAY,MAAM,KAAG,MA0DxD,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAO,cA0BtC,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { ToolExecutionError } from "../ToolTypes.js";
|
|
2
|
+
const finite = (value) => {
|
|
3
|
+
if (!Number.isFinite(value))
|
|
4
|
+
throw new Error("Calculation is undefined or exceeds finite numeric range");
|
|
5
|
+
if (Number.isInteger(value) && !Number.isSafeInteger(value))
|
|
6
|
+
throw new Error("Integer exceeds exact supported range");
|
|
7
|
+
return value;
|
|
8
|
+
};
|
|
9
|
+
/** A numeric grammar, not JavaScript: every character is consumed, and nothing is evaluated as code. */
|
|
10
|
+
const tokenize = (expression) => {
|
|
11
|
+
if (typeof expression !== "string" || !expression.trim() || expression.length > 4096)
|
|
12
|
+
throw new Error("Expected an expression of 1 to 4096 characters");
|
|
13
|
+
const pattern = /\s+|(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?|Math\.[A-Za-z_][A-Za-z_0-9]*|[A-Za-z_][A-Za-z_0-9]*|\*\*|[+*/%^(),-]/y;
|
|
14
|
+
const tokens = [];
|
|
15
|
+
let offset = 0;
|
|
16
|
+
while (offset < expression.length) {
|
|
17
|
+
pattern.lastIndex = offset;
|
|
18
|
+
const match = pattern.exec(expression);
|
|
19
|
+
if (!match)
|
|
20
|
+
throw new Error(`Unsupported character at position ${offset + 1}`);
|
|
21
|
+
offset = pattern.lastIndex;
|
|
22
|
+
// Literal aliases enter the same bounded grammar; no object lookup or code execution.
|
|
23
|
+
const token = match[0].startsWith("Math.") ? match[0].slice(5) : match[0];
|
|
24
|
+
if (token.trim())
|
|
25
|
+
tokens.push(token === "PI" ? "pi" : token === "E" ? "e" : token);
|
|
26
|
+
if (tokens.length > 1024)
|
|
27
|
+
throw new Error("Expression exceeds 1024 tokens");
|
|
28
|
+
}
|
|
29
|
+
return tokens;
|
|
30
|
+
};
|
|
31
|
+
const functions = new Map([
|
|
32
|
+
["abs", { min: 1, max: 1, run: Math.abs }],
|
|
33
|
+
["sqrt", { min: 1, max: 1, run: Math.sqrt }],
|
|
34
|
+
["exp", { min: 1, max: 1, run: Math.exp }],
|
|
35
|
+
["ln", { min: 1, max: 1, run: Math.log }],
|
|
36
|
+
["log", { min: 1, max: 1, run: Math.log }],
|
|
37
|
+
["log10", { min: 1, max: 1, run: Math.log10 }],
|
|
38
|
+
["sin", { min: 1, max: 1, run: Math.sin }],
|
|
39
|
+
["cos", { min: 1, max: 1, run: Math.cos }],
|
|
40
|
+
["tan", { min: 1, max: 1, run: Math.tan }],
|
|
41
|
+
["pow", { min: 2, max: 2, run: Math.pow }],
|
|
42
|
+
["floor", { min: 1, max: 1, run: Math.floor }],
|
|
43
|
+
["ceil", { min: 1, max: 1, run: Math.ceil }],
|
|
44
|
+
["round", { min: 1, max: 1, run: Math.round }],
|
|
45
|
+
["min", { min: 1, max: 128, run: Math.min }],
|
|
46
|
+
["max", { min: 1, max: 128, run: Math.max }],
|
|
47
|
+
["sum", { min: 1, max: 128, run: (...args) => args.reduce((total, value) => finite(total + value), 0) }],
|
|
48
|
+
]);
|
|
49
|
+
/** Bounded Pratt parser; exponentiation is right associative and binds more tightly than unary minus. */
|
|
50
|
+
export const evaluateCalculation = (expression) => {
|
|
51
|
+
const tokens = tokenize(expression);
|
|
52
|
+
let position = 0;
|
|
53
|
+
const expect = (token) => {
|
|
54
|
+
if (tokens[position++] !== token)
|
|
55
|
+
throw new Error(`Expected ${token}`);
|
|
56
|
+
};
|
|
57
|
+
const parse = (precedence = 0, depth = 0) => {
|
|
58
|
+
if (depth > 32)
|
|
59
|
+
throw new Error("Expression nesting exceeds 32 levels");
|
|
60
|
+
const token = tokens[position++];
|
|
61
|
+
let value;
|
|
62
|
+
if (token === "+" || token === "-") {
|
|
63
|
+
const operand = parse(25, depth + 1);
|
|
64
|
+
value = token === "-" ? -operand : operand;
|
|
65
|
+
}
|
|
66
|
+
else if (token === "(") {
|
|
67
|
+
value = parse(0, depth + 1);
|
|
68
|
+
expect(")");
|
|
69
|
+
}
|
|
70
|
+
else if (token && /^(?:\d|\.)/.test(token))
|
|
71
|
+
value = finite(Number(token));
|
|
72
|
+
else if (token === "pi")
|
|
73
|
+
value = Math.PI;
|
|
74
|
+
else if (token === "e")
|
|
75
|
+
value = Math.E;
|
|
76
|
+
else {
|
|
77
|
+
const fn = functions.get(token);
|
|
78
|
+
if (!fn)
|
|
79
|
+
throw new Error(`Expected a number or supported function, received ${token ?? "end of expression"}`);
|
|
80
|
+
expect("(");
|
|
81
|
+
const args = [];
|
|
82
|
+
if (tokens[position] !== ")") {
|
|
83
|
+
do {
|
|
84
|
+
if (args.length >= fn.max)
|
|
85
|
+
throw new Error(`${token} accepts at most ${fn.max} arguments`);
|
|
86
|
+
args.push(parse(0, depth + 1));
|
|
87
|
+
if (tokens[position] !== ",")
|
|
88
|
+
break;
|
|
89
|
+
position++;
|
|
90
|
+
} while (true);
|
|
91
|
+
}
|
|
92
|
+
expect(")");
|
|
93
|
+
if (args.length < fn.min)
|
|
94
|
+
throw new Error(`${token} requires at least ${fn.min} argument`);
|
|
95
|
+
value = finite(fn.run(...args));
|
|
96
|
+
}
|
|
97
|
+
while (position < tokens.length) {
|
|
98
|
+
const operator = tokens[position];
|
|
99
|
+
const power = operator === "^" || operator === "**";
|
|
100
|
+
const binding = power ? 30 : ["*", "/", "%"].includes(operator) ? 20 : ["+", "-"].includes(operator) ? 10 : 0;
|
|
101
|
+
if (binding === 0 || binding <= precedence)
|
|
102
|
+
break;
|
|
103
|
+
position++;
|
|
104
|
+
const right = parse(power ? binding - 1 : binding, depth + 1);
|
|
105
|
+
switch (operator) {
|
|
106
|
+
case "+":
|
|
107
|
+
value += right;
|
|
108
|
+
break;
|
|
109
|
+
case "-":
|
|
110
|
+
value -= right;
|
|
111
|
+
break;
|
|
112
|
+
case "*":
|
|
113
|
+
value *= right;
|
|
114
|
+
break;
|
|
115
|
+
case "/":
|
|
116
|
+
value /= right;
|
|
117
|
+
break;
|
|
118
|
+
case "%":
|
|
119
|
+
value %= right;
|
|
120
|
+
break;
|
|
121
|
+
default: value **= right;
|
|
122
|
+
}
|
|
123
|
+
value = finite(value);
|
|
124
|
+
}
|
|
125
|
+
return finite(value);
|
|
126
|
+
};
|
|
127
|
+
const result = parse();
|
|
128
|
+
if (position !== tokens.length)
|
|
129
|
+
throw new Error(`Unexpected token ${tokens[position]}`);
|
|
130
|
+
// JSON has a single zero representation; keep the exported numeric API consistent.
|
|
131
|
+
return result === 0 ? 0 : result;
|
|
132
|
+
};
|
|
133
|
+
export const createCalculatorTool = () => ({
|
|
134
|
+
name: "calculate", capability: "calculation", readOnly: true,
|
|
135
|
+
description: "Calculate {expression:'formula'} OR {expressions:{label:'formula'}} (up to16). Supports exp,ln/log(natural),log10,pow,sin/cos/tan(radians),abs,sqrt,floor,ceil,round,min,max,sum; + - * / %, ^ **, pi,e. Math.function aliases accepted only for this allowlist. No variables, assignments or code. IEEE-754 approximate; exact decimals use decimal_calculate. Tool success checks arithmetic, not whether your formula models the request.",
|
|
136
|
+
inputSchema: { type: "object", properties: { expression: { type: "string", description: "One numeric formula, e.g. exp(-2)*3. Supply this OR expressions.", minLength: 1, maxLength: 4096 },
|
|
137
|
+
expressions: { type: "object", description: "Map labels to complete formula STRINGS, e.g. {total:'2*3+4',check:'10'}. Each formula is independent; labels are not variables. Supply this OR expression.", minProperties: 1, maxProperties: 16, propertyNames: { pattern: "^[A-Za-z][A-Za-z0-9_]{0,63}$" }, additionalProperties: true },
|
|
138
|
+
}, oneOf: [{ required: ["expression"] }, { required: ["expressions"] }], additionalProperties: false },
|
|
139
|
+
handler: async (args, context) => {
|
|
140
|
+
context.signal?.throwIfAborted();
|
|
141
|
+
try {
|
|
142
|
+
const input = args;
|
|
143
|
+
if (!input || typeof input !== "object" || Array.isArray(input) || input.expression === undefined && input.expressions === undefined)
|
|
144
|
+
throw new Error('Use {"expression":"2+3"} or {"expressions":{"total":"2+3"}}; formulas must be strings');
|
|
145
|
+
if (input.expressions !== undefined) {
|
|
146
|
+
if (input.expression !== undefined || !input.expressions || Array.isArray(input.expressions) || Object.keys(input.expressions).length < 1 || Object.keys(input.expressions).length > 16)
|
|
147
|
+
throw new Error("Supply expression or up to16 named expressions, not both");
|
|
148
|
+
const results = Object.fromEntries(Object.entries(input.expressions).map(([label, expression]) => {
|
|
149
|
+
if (!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(label))
|
|
150
|
+
throw new Error("Invalid calculation label");
|
|
151
|
+
return [label, evaluateCalculation(expression)];
|
|
152
|
+
}));
|
|
153
|
+
return { output: JSON.stringify({ results, arithmetic: "IEEE-754 double; not exact decimal arithmetic" }) };
|
|
154
|
+
}
|
|
155
|
+
const result = evaluateCalculation(input.expression);
|
|
156
|
+
return { output: JSON.stringify({ result, arithmetic: "IEEE-754 double; not exact decimal arithmetic" }) };
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
160
|
+
throw new ToolExecutionError("tool_invalid_args", `${message}. Correct the arguments before retrying; use tools_describe for the schema. No assignments or arbitrary code; supported functions include exp(x), ln(x), log10(x), pow(x,y).`, { retryable: false });
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type DeterministicToolOptions } from "./DeterministicTools.js";
|
|
2
|
+
/** Installation metadata only; functional qualification uses the checks below. */
|
|
3
|
+
export declare function inspectDeterministicRuntime(options?: DeterministicToolOptions): Promise<{
|
|
4
|
+
pythonRoot: string;
|
|
5
|
+
nodeWorker: {
|
|
6
|
+
installed: boolean;
|
|
7
|
+
sha256: string;
|
|
8
|
+
} | {
|
|
9
|
+
installed: boolean;
|
|
10
|
+
sha256?: undefined;
|
|
11
|
+
};
|
|
12
|
+
pythonWorker: {
|
|
13
|
+
installed: boolean;
|
|
14
|
+
sha256: string;
|
|
15
|
+
} | {
|
|
16
|
+
installed: boolean;
|
|
17
|
+
sha256?: undefined;
|
|
18
|
+
};
|
|
19
|
+
pythonEnvironment: {
|
|
20
|
+
installed: boolean;
|
|
21
|
+
};
|
|
22
|
+
isolation: import("../shell/IsolatedExecutor.js").ExecutorStatus;
|
|
23
|
+
checkCommand: string;
|
|
24
|
+
installCommand: string;
|
|
25
|
+
note: string;
|
|
26
|
+
}>;
|
|
27
|
+
export interface DeterministicRuntimeCheck {
|
|
28
|
+
name: string;
|
|
29
|
+
passed: boolean;
|
|
30
|
+
library?: string;
|
|
31
|
+
version?: string;
|
|
32
|
+
elapsedMs: number;
|
|
33
|
+
error?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Exercise the real pinned offline workers against fixed independent values. */
|
|
36
|
+
export declare function checkDeterministicRuntime(options?: DeterministicToolOptions, signal?: AbortSignal): Promise<DeterministicRuntimeCheck[]>;
|
|
37
|
+
/** Host CLI only: models cannot select this script or inject installation args. */
|
|
38
|
+
export declare function runDeterministicRuntimeCommand(argv: string[], write: (line: string) => void): Promise<number>;
|
|
39
|
+
//# sourceMappingURL=DeterministicRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeterministicRuntime.d.ts","sourceRoot":"","sources":["../../../src/tools/deterministic/DeterministicRuntime.ts"],"names":[],"mappings":"AAOA,OAAO,EAAmD,KAAK,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAKzH,kFAAkF;AAClF,wBAAsB,2BAA2B,CAAC,OAAO,GAAE,wBAA6B;;;;;;;;;;;;;;;;;;;;;;;GAWvF;AAED,MAAM,WAAW,yBAAyB;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CAAE;AAWpJ,iFAAiF;AACjF,wBAAsB,yBAAyB,CAAC,OAAO,GAAE,wBAA6B,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAmBlJ;AAED,mFAAmF;AACnF,wBAAsB,8BAA8B,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBnH"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { execFile } from "node:child_process";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { promisify } from "node:util";
|
|
8
|
+
import { createDeterministicTools, defaultPythonToolRoot } from "./DeterministicTools.js";
|
|
9
|
+
import { executorStatus } from "../shell/IsolatedExecutor.js";
|
|
10
|
+
import { ToolRegistry } from "../ToolRegistry.js";
|
|
11
|
+
import { checkDocumentRuntime } from "../documents/DocumentRuntime.js";
|
|
12
|
+
/** Installation metadata only; functional qualification uses the checks below. */
|
|
13
|
+
export async function inspectDeterministicRuntime(options = {}) {
|
|
14
|
+
const pythonRoot = path.resolve(options.pythonRoot ?? defaultPythonToolRoot());
|
|
15
|
+
const worker = async (url) => {
|
|
16
|
+
try {
|
|
17
|
+
return { installed: true, sha256: createHash("sha256").update(await fs.readFile(url)).digest("hex") };
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return { installed: false };
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
let installed = false;
|
|
24
|
+
try {
|
|
25
|
+
await fs.access(path.join(pythonRoot, "pyvenv.cfg"));
|
|
26
|
+
await fs.access(path.join(pythonRoot, "bin", "python"));
|
|
27
|
+
installed = true;
|
|
28
|
+
}
|
|
29
|
+
catch { /* Optional runtime. */ }
|
|
30
|
+
return { pythonRoot, nodeWorker: await worker(new URL("./node-worker.cjs", import.meta.url)),
|
|
31
|
+
pythonWorker: await worker(new URL("./python-worker.py", import.meta.url)), pythonEnvironment: { installed }, isolation: executorStatus(),
|
|
32
|
+
checkCommand: "codali tools check", installCommand: "codali tools install", note: "Installed files do not prove functionality; run the checks." };
|
|
33
|
+
}
|
|
34
|
+
const probes = [
|
|
35
|
+
{ name: "decimal_calculate", args: { operation: "add", values: ["0.1", "0.2"] }, accepts: value => value.result === "0.3" },
|
|
36
|
+
{ name: "numerical_calculate", args: { operation: "det", args: [[[1, 2], [3, 4]]] }, accepts: value => value.result === -2 },
|
|
37
|
+
{ name: "validate_json", args: { schema: { type: "integer" }, data: "not an integer" }, accepts: value => value.valid === false },
|
|
38
|
+
{ name: "symbolic_math", args: { operation: "differentiate", expression: "x**2+2*x+1", symbols: ["x"], variable: "x" }, accepts: value => value.result === "2*x + 2" },
|
|
39
|
+
{ name: "solve_constraints", args: { variables: { x: "Int" }, constraints: ["x>2", "x<1"] }, accepts: value => value.status === "unsat" },
|
|
40
|
+
{ name: "query_data", args: { sql: "SELECT 9007199254740993::BIGINT", tables: [] }, accepts: value => JSON.stringify(value.rows) === '[["9007199254740993"]]' },
|
|
41
|
+
{ name: "transform_data", args: { rows: [{ a: 1 }, { a: 2 }], steps: [{ operation: "head", count: 1 }] }, accepts: value => JSON.stringify(value.rows) === '[{"a":1}]' },
|
|
42
|
+
];
|
|
43
|
+
/** Exercise the real pinned offline workers against fixed independent values. */
|
|
44
|
+
export async function checkDeterministicRuntime(options = {}, signal) {
|
|
45
|
+
const registry = new ToolRegistry();
|
|
46
|
+
for (const tool of createDeterministicTools(options))
|
|
47
|
+
registry.register(tool);
|
|
48
|
+
const checks = [];
|
|
49
|
+
for (const probe of probes) {
|
|
50
|
+
signal?.throwIfAborted();
|
|
51
|
+
const started = Date.now();
|
|
52
|
+
try {
|
|
53
|
+
const result = await registry.execute(probe.name, probe.args, { workspaceRoot: os.tmpdir(), signal });
|
|
54
|
+
if (!result.ok)
|
|
55
|
+
throw new Error(result.error?.message ?? "Tool check failed");
|
|
56
|
+
const value = JSON.parse(result.output);
|
|
57
|
+
const passed = probe.accepts(value);
|
|
58
|
+
checks.push({ name: probe.name, passed, library: String(value.library), version: String(value.version), elapsedMs: Date.now() - started,
|
|
59
|
+
...(passed ? {} : { error: "Observed result differs from the independent check value" }) });
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
signal?.throwIfAborted();
|
|
63
|
+
checks.push({ name: probe.name, passed: false, elapsedMs: Date.now() - started, error: error instanceof Error ? error.message : String(error) });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return checks;
|
|
67
|
+
}
|
|
68
|
+
/** Host CLI only: models cannot select this script or inject installation args. */
|
|
69
|
+
export async function runDeterministicRuntimeCommand(argv, write) {
|
|
70
|
+
const [command, ...flags] = argv;
|
|
71
|
+
if (!["install", "check"].includes(command) || flags.some(flag => !["--json", "--documents"].includes(flag)) || new Set(flags).size !== flags.length)
|
|
72
|
+
throw new Error("Use codali tools install|check [--documents] [--json]; these are host runtime commands.");
|
|
73
|
+
const json = flags.includes("--json");
|
|
74
|
+
const documents = flags.includes("--documents");
|
|
75
|
+
const abort = new AbortController();
|
|
76
|
+
const cancel = () => abort.abort(new Error("Tool runtime operation cancelled"));
|
|
77
|
+
process.once("SIGINT", cancel);
|
|
78
|
+
try {
|
|
79
|
+
if (command === "install") {
|
|
80
|
+
if (!json)
|
|
81
|
+
write(`Installing the pinned ${documents ? "document" : "deterministic"} Python runtime…`);
|
|
82
|
+
await promisify(execFile)(process.execPath, [fileURLToPath(new URL(`../../../config/${documents ? "documents" : "deterministic"}/install-python.mjs`, import.meta.url))], { timeout: 300000, maxBuffer: 2000000, signal: abort.signal });
|
|
83
|
+
}
|
|
84
|
+
const checks = documents ? await checkDocumentRuntime({}, abort.signal) : await checkDeterministicRuntime({}, abort.signal);
|
|
85
|
+
const passed = checks.every(check => check.passed);
|
|
86
|
+
if (json)
|
|
87
|
+
write(JSON.stringify({ passed, checks }, null, 2));
|
|
88
|
+
else {
|
|
89
|
+
for (const check of checks)
|
|
90
|
+
write(`${check.passed ? "PASS" : "FAIL"} ${check.name.padEnd(22)} ${check.passed ? `${check.library} ${check.version}` : check.error}`);
|
|
91
|
+
write(passed ? `All ${checks.length} ${documents ? "document" : "deterministic"} tool checks passed.` : "Some tools are unavailable. Run codali doctor for installation and isolation details.");
|
|
92
|
+
}
|
|
93
|
+
return passed ? 0 : 1;
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
process.removeListener("SIGINT", cancel);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ToolDefinition } from "../ToolTypes.js";
|
|
2
|
+
/** Deployment-owned configuration; runtime paths can never be supplied by a model. */
|
|
3
|
+
export interface DeterministicToolOptions {
|
|
4
|
+
pythonRoot?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const defaultPythonToolRoot: () => string;
|
|
7
|
+
export declare const createDeterministicTools: (options?: DeterministicToolOptions) => ToolDefinition[];
|
|
8
|
+
//# sourceMappingURL=DeterministicTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeterministicTools.d.ts","sourceRoot":"","sources":["../../../src/tools/deterministic/DeterministicTools.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwC,KAAK,cAAc,EAAmD,MAAM,iBAAiB,CAAC;AAqC7I,sFAAsF;AACtF,MAAM,WAAW,wBAAwB;IAAG,UAAU,CAAC,EAAE,MAAM,CAAC;CAAE;AAClE,eAAO,MAAM,qBAAqB,QAAO,MAAmI,CAAC;AA6C7K,eAAO,MAAM,wBAAwB,GAAI,UAAS,wBAA6B,KAAG,cAAc,EAG7F,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
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 { createIsolatedExecutor } from "../shell/IsolatedExecutor.js";
|
|
6
|
+
import { ToolExecutionError } from "../ToolTypes.js";
|
|
7
|
+
const string = (maxLength = 4000) => ({ type: "string", minLength: 1, maxLength });
|
|
8
|
+
const choices = (...values) => ({ type: "string", enum: values });
|
|
9
|
+
const array = (items, maxItems, minItems = 0) => ({ type: "array", items, minItems, maxItems });
|
|
10
|
+
const object = (properties, required) => ({ type: "object", properties, required, additionalProperties: false });
|
|
11
|
+
const jsonValue = { additionalProperties: true };
|
|
12
|
+
const identifier = { ...string(64), pattern: "^[A-Za-z][A-Za-z0-9_]*$" };
|
|
13
|
+
const scalar = { type: ["string", "number", "boolean", "null"] };
|
|
14
|
+
const schemas = {
|
|
15
|
+
decimal_calculate: object({ operation: choices("add", "subtract", "multiply", "divide", "pow", "sqrt", "abs", "round"),
|
|
16
|
+
values: array(string(512), 64, 1), precision: { type: "integer", minimum: 1, maximum: 200 }, places: { type: "integer", minimum: 0, maximum: 200 } }, ["operation", "values"]),
|
|
17
|
+
numerical_calculate: object({ operation: choices("det", "inv", "multiply", "transpose", "lusolve", "mean", "median", "std", "sum", "dot", "cross"), args: array(jsonValue, 2, 1) }, ["operation", "args"]),
|
|
18
|
+
validate_json: object({ schema: jsonValue, data: jsonValue }, ["schema", "data"]),
|
|
19
|
+
symbolic_math: object({ operation: choices("simplify", "factor", "expand", "differentiate", "integrate", "solve"), expression: string(), symbols: array(identifier, 16), variable: identifier }, ["operation", "expression", "symbols"]),
|
|
20
|
+
solve_constraints: object({ variables: { type: "object", additionalProperties: true }, constraints: array(string(), 64, 1) }, ["variables", "constraints"]),
|
|
21
|
+
query_data: object({ sql: string(8000), tables: array(object({ name: identifier, columns: { type: "object", additionalProperties: true },
|
|
22
|
+
columnOrder: array(identifier, 32, 1), rows: array({ type: ["array", "object"], items: scalar, minItems: 1, maxItems: 32, additionalProperties: true }, 2000) }, ["name", "columns", "rows"]), 8),
|
|
23
|
+
expectedRows: array(array(scalar, 32), 1000), rowOrder: choices("ordered", "unordered") }, ["sql", "tables"]),
|
|
24
|
+
transform_data: object({ rows: array({ type: "object", additionalProperties: true }, 2000), steps: array(object({
|
|
25
|
+
operation: choices("select", "sort", "head", "filter", "aggregate"), columns: array(string(128), 32, 1), descending: { type: "boolean" },
|
|
26
|
+
count: { type: "integer", minimum: 0, maximum: 1000 }, column: string(128), comparison: choices("eq", "ne", "gt", "ge", "lt", "le"), value: scalar,
|
|
27
|
+
by: array(string(128), 32), aggregations: array(object({ column: string(128), function: choices("sum", "mean", "min", "max", "count", "n_unique", "median", "std"), alias: identifier }, ["column", "function", "alias"]), 16, 1),
|
|
28
|
+
}, ["operation"]), 16) }, ["rows", "steps"]),
|
|
29
|
+
};
|
|
30
|
+
const descriptions = {
|
|
31
|
+
decimal_calculate: "Decimal.js arithmetic on decimal STRING operands, default 50 significant digits, half-even rounding. Exact decimal representation with reported precision; use for money and decimal calculations.",
|
|
32
|
+
numerical_calculate: "math.js numerical vectors/matrices: determinant, inverse, multiply, transpose, linear solve, statistics, dot/cross. args is the function argument list; IEEE-754 approximations, not exact symbolic math.",
|
|
33
|
+
validate_json: "Ajv validates data against JSON Schema draft-07, without mutation/coercion, remote refs or format checks. Returns valid/errors. Offline and bounded.",
|
|
34
|
+
symbolic_math: "SymPy exact symbolic algebra/calculus. Declare symbols; expression uses + - * / ** and sin/cos/tan/exp/log/sqrt/Abs, pi/E. solve treats expression as zero; variable required for solve/differentiate/integrate.",
|
|
35
|
+
solve_constraints: "Z3 satisfiability. variables maps names to Int/Real/Bool. constraints use arithmetic, comparisons, and/or/not, And/Or/Not/If/Implies/Distinct. Returns sat/model with checks, unsat, or unknown; no claims of optimum.",
|
|
36
|
+
query_data: "Execute DuckDB SQL SELECT on in-memory tables. Use named row objects, or arrays with explicit columnOrder matching their value order (required for multiple columns). columns maps names to BIGINT/DOUBLE/VARCHAR/BOOLEAN/DECIMAL(p,s). Decimal/large integers use strings. expectedRows checks typed results; rowOrder ordered(default) or unordered preserves duplicates. Examples do not prove general correctness. No files/network/extensions; max1000 output rows.",
|
|
37
|
+
transform_data: "Polars transforms supplied JSON rows through select/sort/head/filter/aggregate steps. aggregate uses by columns and {column,function,alias}; filter uses column/comparison/value. No files or code execution; max 1000 output rows.",
|
|
38
|
+
};
|
|
39
|
+
const pythonPackages = { symbolic_math: ["sympy", "1.14.0"], solve_constraints: ["z3-solver", "5.3.3.0"], query_data: ["duckdb", "2.0.0"], transform_data: ["polars", "2.1.0"] };
|
|
40
|
+
const nodePackages = { decimal_calculate: ["decimal.js", "10.6.0"], numerical_calculate: ["mathjs", "15.2.0"], validate_json: ["ajv", "8.20.0"] };
|
|
41
|
+
export const defaultPythonToolRoot = () => process.env.CODALI_TOOL_PYTHON_ROOT ?? path.join(os.homedir(), ".local", "state", "codali", "tool-runtimes", "python-v1");
|
|
42
|
+
async function execute(name, args, context, options) {
|
|
43
|
+
context.signal?.throwIfAborted();
|
|
44
|
+
const payload = JSON.stringify({ tool: name, args });
|
|
45
|
+
if (Buffer.byteLength(payload) > 256000)
|
|
46
|
+
throw new ToolExecutionError("tool_invalid_args", "Deterministic input exceeds 256000 bytes");
|
|
47
|
+
const root = await fs.mkdtemp(path.join(os.tmpdir(), "codali-deterministic-"));
|
|
48
|
+
const python = Object.prototype.hasOwnProperty.call(pythonPackages, name);
|
|
49
|
+
const runtime = path.resolve(options.pythonRoot ?? defaultPythonToolRoot());
|
|
50
|
+
const worker = new URL(python ? "./python-worker.py" : "./node-worker.cjs", import.meta.url);
|
|
51
|
+
const started = Date.now();
|
|
52
|
+
try {
|
|
53
|
+
await fs.chmod(root, 0o700);
|
|
54
|
+
if (python) {
|
|
55
|
+
try {
|
|
56
|
+
await fs.access(path.join(runtime, "pyvenv.cfg"));
|
|
57
|
+
await fs.access(path.join(runtime, "bin", "python"));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
throw new ToolExecutionError("tool_execution_failed", "Python tool runtime is missing. Run the packaged config/deterministic/install-python.mjs setup script, or configure CODALI_TOOL_PYTHON_ROOT.", { retryable: false });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const source = await fs.readFile(worker);
|
|
64
|
+
const script = path.join(root, python ? "worker.py" : "worker.cjs");
|
|
65
|
+
await fs.writeFile(script, source, { mode: 0o600 });
|
|
66
|
+
await fs.writeFile(path.join(root, "input.json"), payload, { mode: 0o600 });
|
|
67
|
+
const result = await createIsolatedExecutor({ network: false, readOnlyRuntimeRoots: python ? [runtime] : [] })(python ? path.join(runtime, "bin", "python") : process.execPath, python ? ["-I", "-B", script] : ["--max-old-space-size=128", script], { workspaceRoot: root, signal: context.signal, allowedWritePaths: [], shellTimeoutMs: python ? 15000 : 7000, shellMaxOutputBytes: 128000 });
|
|
68
|
+
const observation = result.data;
|
|
69
|
+
if (observation.truncated)
|
|
70
|
+
throw new ToolExecutionError("tool_execution_failed", "Deterministic output exceeded the limit");
|
|
71
|
+
const data = JSON.parse(observation.stdout);
|
|
72
|
+
if (data.error)
|
|
73
|
+
throw new ToolExecutionError("tool_invalid_args", String(data.error));
|
|
74
|
+
const [library, version] = (python ? pythonPackages : nodePackages)[name];
|
|
75
|
+
if (data.library !== library || data.version !== version)
|
|
76
|
+
throw new ToolExecutionError("tool_execution_failed", "Tool runtime version does not match the pinned contract");
|
|
77
|
+
const input = args;
|
|
78
|
+
if (name === "query_data" && input.expectedRows !== undefined) {
|
|
79
|
+
if (!Array.isArray(data.rows))
|
|
80
|
+
throw new ToolExecutionError("tool_execution_failed", "Query runtime did not return rows for validation");
|
|
81
|
+
const actual = data.rows.map(row => JSON.stringify(row)), expected = input.expectedRows.map(row => JSON.stringify(row));
|
|
82
|
+
if (input.rowOrder === "unordered") {
|
|
83
|
+
actual.sort();
|
|
84
|
+
expected.sort();
|
|
85
|
+
}
|
|
86
|
+
data.validation = { passed: JSON.stringify(actual) === JSON.stringify(expected), comparison: input.rowOrder ?? "ordered",
|
|
87
|
+
expectedCount: expected.length, actualCount: actual.length, scope: "provided examples only; no type coercion" };
|
|
88
|
+
}
|
|
89
|
+
const receipt = { inputSha256: createHash("sha256").update(payload).digest("hex"), workerSha256: createHash("sha256").update(source).digest("hex"), elapsedMs: Date.now() - started,
|
|
90
|
+
isolation: "offline, ephemeral input only", ...data };
|
|
91
|
+
return { output: JSON.stringify(receipt), data: receipt };
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export const createDeterministicTools = (options = {}) => Object.keys(schemas).map(name => ({
|
|
98
|
+
name, description: descriptions[name], readOnly: true, capability: "deterministic", inputSchema: schemas[name],
|
|
99
|
+
handler: (args, context) => execute(name, args, context, options),
|
|
100
|
+
}));
|