@mcoda/mswarm 0.1.135-codali.4 → 0.1.135-codali.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +36 -7
- 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/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 +15 -2
- package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -1
- package/dist/vendor/codali/docdex/DocdexClient.js +119 -12
- 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/EvaluationProcess.d.ts.map +1 -1
- package/dist/vendor/codali/eval/EvaluationProcess.js +4 -0
- 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 +4 -1
- package/dist/vendor/codali/permissions/PermissionGate.d.ts.map +1 -1
- package/dist/vendor/codali/permissions/PermissionGate.js +50 -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 +10 -1
- package/dist/vendor/codali/providers/ConfiguredProvider.d.ts.map +1 -1
- package/dist/vendor/codali/providers/ConfiguredProvider.js +104 -37
- 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 +8 -0
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +38 -3
- package/dist/vendor/codali/providers/ProviderTypes.d.ts +9 -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 +8 -0
- package/dist/vendor/codali/runtime/CompletionReport.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/CompletionReport.js +25 -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 +41 -0
- package/dist/vendor/codali/runtime/ContextCompression.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ContextCompression.js +292 -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 +139 -0
- package/dist/vendor/codali/runtime/OutageWait.d.ts +14 -0
- package/dist/vendor/codali/runtime/OutageWait.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/OutageWait.js +33 -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 +142 -6
- package/dist/vendor/codali/runtime/SessionController.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/SessionController.js +2296 -228
- package/dist/vendor/codali/runtime/SpecialistTools.d.ts +8 -0
- package/dist/vendor/codali/runtime/SpecialistTools.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/SpecialistTools.js +85 -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/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/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 +6 -1
- package/dist/vendor/codali/session/SessionStore.d.ts.map +1 -1
- package/dist/vendor/codali/session/SessionStore.js +108 -43
- 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 +16 -2
- package/dist/vendor/codali/session/WorkState.d.ts.map +1 -1
- package/dist/vendor/codali/session/WorkState.js +55 -5
- 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 +5 -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 +191 -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 +62 -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 +4 -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 +7 -0
- package/dist/vendor/codali/tools/shell/HostToolchain.d.ts.map +1 -1
- package/dist/vendor/codali/tools/shell/HostToolchain.js +65 -4
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts +5 -2
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts.map +1 -1
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.js +148 -29
- 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 +19 -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
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { existsSync, realpathSync, mkdtempSync, rmSync, promises as fs } from "node:fs";
|
|
1
|
+
import { existsSync, realpathSync, statSync, readdirSync, mkdirSync, mkdtempSync, rmSync, promises as fs } from "node:fs";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { spawnSync } from "node:child_process";
|
|
5
5
|
import { runProcess } from "./AsyncProcess.js";
|
|
6
6
|
import { resolveShellWorkingDirectory } from "./ShellWorkingDirectory.js";
|
|
7
7
|
import { ToolExecutionError } from "../ToolTypes.js";
|
|
8
|
-
import { discoverHostToolchain, extraRuntimeMounts } from "./HostToolchain.js";
|
|
8
|
+
import { discoverHostToolchain, extraRuntimeMounts, venvInterpreter } from "./HostToolchain.js";
|
|
9
9
|
/** All paths have been canonicalized by the host, before launching the sandbox. */
|
|
10
|
-
export const darwinSandboxProfile = (root, scratch, writePaths, runtimes, network = false) => {
|
|
10
|
+
export const darwinSandboxProfile = (root, scratch, writePaths, runtimes, network = false, runtimeRoots = [], protectedPaths = [], cacheRoot, sessionScratch) => {
|
|
11
11
|
const quoted = (value) => JSON.stringify(value);
|
|
12
12
|
const ancestors = new Set();
|
|
13
|
-
for (const target of [root, scratch, ...extraRuntimeMounts(runtimes).map(runtime => runtime.readOnlyRoot)]) {
|
|
13
|
+
for (const target of [root, scratch, ...(cacheRoot ? [cacheRoot] : []), ...(sessionScratch ? [sessionScratch] : []), ...runtimeRoots, ...extraRuntimeMounts(runtimes).map(runtime => runtime.readOnlyRoot)]) {
|
|
14
14
|
for (let parent = path.dirname(target); parent !== path.dirname(parent); parent = path.dirname(parent))
|
|
15
15
|
ancestors.add(parent);
|
|
16
16
|
}
|
|
@@ -19,6 +19,9 @@ export const darwinSandboxProfile = (root, scratch, writePaths, runtimes, networ
|
|
|
19
19
|
// dyld opens the root directory when locating its shared cache. This literal
|
|
20
20
|
// permits the directory itself, never a recursive read of the filesystem.
|
|
21
21
|
'(allow file-read* (literal "/"))',
|
|
22
|
+
// macOS exposes these system aliases before resolving /private/... paths.
|
|
23
|
+
// Metadata on the aliases permits traversal, never reading their siblings.
|
|
24
|
+
'(allow file-read-metadata (literal "/var") (literal "/tmp") (literal "/etc"))',
|
|
22
25
|
// realpath/lstat needs ancestor metadata, not directory contents or sibling files.
|
|
23
26
|
...[...ancestors].map(parent => `(allow file-read-metadata (literal ${quoted(parent)}))`),
|
|
24
27
|
'(allow file-read* (subpath "/usr") (subpath "/bin") (subpath "/sbin") (subpath "/System") (subpath "/Library") (subpath "/private/etc") (subpath "/dev"))',
|
|
@@ -29,10 +32,14 @@ export const darwinSandboxProfile = (root, scratch, writePaths, runtimes, networ
|
|
|
29
32
|
'(allow file-read* (literal "/private/var/select/sh") (literal "/var/select/sh"))',
|
|
30
33
|
'(allow file-read-metadata (literal "/private/var/select") (literal "/var/select"))',
|
|
31
34
|
`(allow file-read* (subpath ${quoted(root)}))`,
|
|
35
|
+
...runtimeRoots.map(runtime => `(allow file-read* (subpath ${quoted(runtime)}))`),
|
|
32
36
|
...extraRuntimeMounts(runtimes).map(runtime => `(allow file-read* (${runtime.directory ? "subpath" : "literal"} ${quoted(runtime.readOnlyRoot)}))`),
|
|
33
37
|
`(allow file-read* file-write* (subpath ${quoted(scratch)}))`,
|
|
38
|
+
...(cacheRoot ? [`(allow file-read* file-write* (subpath ${quoted(cacheRoot)}))`, `(deny file-write-unlink (literal ${quoted(cacheRoot)}))`] : []),
|
|
39
|
+
...(sessionScratch ? [`(allow file-read* file-write* (subpath ${quoted(sessionScratch)}))`, `(deny file-write-unlink (literal ${quoted(sessionScratch)}))`] : []),
|
|
34
40
|
...writePaths.map(file => `(allow file-write* (subpath ${quoted(file)}))`),
|
|
35
41
|
...[".git", ".mcoda"].map(dir => `(deny file-write* (subpath ${quoted(path.join(root, dir))}))`),
|
|
42
|
+
...protectedPaths.map(file => `(deny file-write* (subpath ${quoted(file)}))`),
|
|
36
43
|
network ? "(allow network*)" : "(deny network*)",
|
|
37
44
|
].join("\n");
|
|
38
45
|
};
|
|
@@ -41,6 +48,33 @@ const bubblewrapRoot = () => {
|
|
|
41
48
|
for (const dir of ["/bin", "/sbin", "/lib", "/lib64"])
|
|
42
49
|
if (existsSync(dir))
|
|
43
50
|
args.push("--ro-bind", realpathSync(dir), dir);
|
|
51
|
+
// Debian/Ubuntu BLAS and LAPACK sonames pass through /etc/alternatives.
|
|
52
|
+
// Expose only library targets already inside system library roots, not /etc
|
|
53
|
+
// or the other configured alternatives. ffprobe needs these on Ubuntu 22.04.
|
|
54
|
+
if (existsSync("/etc/ld.so.cache"))
|
|
55
|
+
args.push("--ro-bind", "/etc/ld.so.cache", "/etc/ld.so.cache");
|
|
56
|
+
// Toolchain installers inspect this public distribution descriptor. Do not
|
|
57
|
+
// expose all of /etc merely to identify the operating system.
|
|
58
|
+
if (existsSync("/etc/os-release"))
|
|
59
|
+
args.push("--ro-bind", realpathSync("/etc/os-release"), "/etc/os-release");
|
|
60
|
+
// Public system font selection is needed for reproducible browser rendering.
|
|
61
|
+
// User font settings/profiles and the rest of /etc remain inaccessible.
|
|
62
|
+
if (existsSync("/etc/fonts"))
|
|
63
|
+
args.push("--ro-bind", realpathSync("/etc/fonts"), "/etc/fonts");
|
|
64
|
+
if (existsSync("/etc/alternatives"))
|
|
65
|
+
for (const name of readdirSync("/etc/alternatives")) {
|
|
66
|
+
// Commands such as awk are aliases through /etc/alternatives to a binary
|
|
67
|
+
// under /usr/bin that is already visible; without the alias the command
|
|
68
|
+
// is "not found" inside the sandbox.
|
|
69
|
+
const library = /^lib[^/]+\.so(?:\..+)?$/.test(name);
|
|
70
|
+
try {
|
|
71
|
+
const alias = path.join("/etc/alternatives", name), target = realpathSync(alias);
|
|
72
|
+
if (!(library ? ["/usr/lib/", "/usr/lib64/", "/lib/", "/lib64/"] : ["/usr/bin/", "/bin/"]).some(prefix => target.startsWith(prefix)) || !statSync(target).isFile())
|
|
73
|
+
continue;
|
|
74
|
+
args.push("--ro-bind", target, alias);
|
|
75
|
+
}
|
|
76
|
+
catch { /* A broken optional system-library alternative is not mounted. */ }
|
|
77
|
+
}
|
|
44
78
|
return args;
|
|
45
79
|
};
|
|
46
80
|
export const executorStatus = () => {
|
|
@@ -63,6 +97,26 @@ export const executorStatus = () => {
|
|
|
63
97
|
}
|
|
64
98
|
return { available: false, backend: "unavailable", reason: "No supported isolation backend on this platform" };
|
|
65
99
|
};
|
|
100
|
+
const packageCacheEnvironment = (root) => ({
|
|
101
|
+
NPM_CONFIG_CACHE: path.join(root, "npm"), GRADLE_USER_HOME: path.join(root, "gradle"),
|
|
102
|
+
PIP_CACHE_DIR: path.join(root, "pip"), UV_CACHE_DIR: path.join(root, "uv"),
|
|
103
|
+
CARGO_HOME: path.join(root, "cargo"), XDG_CACHE_HOME: path.join(root, "xdg"),
|
|
104
|
+
});
|
|
105
|
+
/** Disposable, workspace-specific cache. Never mount an existing host package cache or credentials. */
|
|
106
|
+
const preparePackageCache = async (requested, workspace, label = "Package cache") => {
|
|
107
|
+
const absolute = path.resolve(requested);
|
|
108
|
+
const unsafe = (value) => value === path.parse(value).root || value === realpathSync(os.homedir())
|
|
109
|
+
|| value === workspace || workspace.startsWith(`${value}${path.sep}`) || value.startsWith(`${workspace}${path.sep}`);
|
|
110
|
+
if (unsafe(absolute))
|
|
111
|
+
throw new ToolExecutionError("tool_permission_denied", `${label} must be a private dedicated directory outside the workspace`);
|
|
112
|
+
await fs.mkdir(absolute, { recursive: true, mode: 0o700 });
|
|
113
|
+
const stat = await fs.lstat(absolute), real = await fs.realpath(absolute);
|
|
114
|
+
if (stat.isSymbolicLink() || !stat.isDirectory() || unsafe(real)
|
|
115
|
+
|| (process.getuid && stat.uid !== process.getuid()) || (stat.mode & 0o077) !== 0) {
|
|
116
|
+
throw new ToolExecutionError("tool_permission_denied", `${label} must be an owned private directory, not a symlink`);
|
|
117
|
+
}
|
|
118
|
+
return real;
|
|
119
|
+
};
|
|
66
120
|
export const createIsolatedExecutor = (options = {}) => {
|
|
67
121
|
const status = options.status ?? executorStatus();
|
|
68
122
|
return async (command, args, context) => {
|
|
@@ -72,45 +126,109 @@ export const createIsolatedExecutor = (options = {}) => {
|
|
|
72
126
|
const cwd = resolveShellWorkingDirectory(root, context.shellWorkingDirectory);
|
|
73
127
|
if (root === path.parse(root).root)
|
|
74
128
|
throw new ToolExecutionError("tool_permission_denied", "Filesystem root cannot be an isolated workspace");
|
|
129
|
+
const cacheRoot = options.cacheRoot ? await preparePackageCache(options.cacheRoot, root) : undefined;
|
|
130
|
+
const sessionScratch = options.scratchRoot ? await preparePackageCache(options.scratchRoot, root, "Shell scratch") : undefined;
|
|
75
131
|
const runtimes = discoverHostToolchain(root);
|
|
132
|
+
const protectedPaths = [...new Set((context.protectedPaths ?? []).flatMap(file => {
|
|
133
|
+
const requested = path.resolve(root, file);
|
|
134
|
+
if (requested === root || !requested.startsWith(`${root}${path.sep}`))
|
|
135
|
+
throw new ToolExecutionError("tool_permission_denied", "Protected input must be inside the workspace");
|
|
136
|
+
if (!existsSync(requested))
|
|
137
|
+
return [];
|
|
138
|
+
const real = realpathSync(requested);
|
|
139
|
+
if (!real.startsWith(`${root}${path.sep}`))
|
|
140
|
+
throw new ToolExecutionError("tool_permission_denied", "Protected input resolves outside the workspace");
|
|
141
|
+
return [requested, real];
|
|
142
|
+
}))];
|
|
143
|
+
const runtimeRoots = [...new Set((options.readOnlyRuntimeRoots ?? []).map(requested => {
|
|
144
|
+
const real = realpathSync(requested);
|
|
145
|
+
if (!statSync(real).isDirectory() || [path.parse(real).root, os.homedir(), context.workspaceRoot].some(forbidden => real === realpathSync(forbidden))
|
|
146
|
+
|| root.startsWith(`${real}${path.sep}`))
|
|
147
|
+
throw new ToolExecutionError("tool_permission_denied", "Runtime mount must be a dedicated installed library directory");
|
|
148
|
+
return real;
|
|
149
|
+
}))];
|
|
150
|
+
for (const [index, venv] of runtimeRoots.entries()) {
|
|
151
|
+
const interpreter = venvInterpreter(venv, root);
|
|
152
|
+
if (interpreter && !runtimes.some(runtime => runtime.executable === interpreter.executable))
|
|
153
|
+
runtimes.push({ ...interpreter, name: `python-runtime-${index}` });
|
|
154
|
+
}
|
|
76
155
|
const writePaths = (context.allowedWritePaths ?? ["."]).map(file => {
|
|
77
156
|
const requested = path.resolve(root, file);
|
|
78
157
|
if (requested !== root && !requested.startsWith(`${root}${path.sep}`))
|
|
79
158
|
throw new ToolExecutionError("tool_permission_denied", "Shell write scope escapes workspace");
|
|
159
|
+
// A declared output directory that does not exist yet (dist/, data/) is
|
|
160
|
+
// created rather than refused; a missing file still has to be written first.
|
|
161
|
+
if (!existsSync(requested) && (/[\\/]$/.test(file) || !path.extname(requested)))
|
|
162
|
+
mkdirSync(requested, { recursive: true });
|
|
80
163
|
if (!existsSync(requested))
|
|
81
|
-
throw new ToolExecutionError("tool_permission_denied", "Create the scoped directory
|
|
164
|
+
throw new ToolExecutionError("tool_permission_denied", "Create the scoped directory with create_directory (or file with write_file) before shell execution");
|
|
82
165
|
const real = realpathSync(requested);
|
|
83
166
|
if (real !== root && !real.startsWith(`${root}${path.sep}`))
|
|
84
167
|
throw new ToolExecutionError("tool_permission_denied", "Shell write scope resolves outside workspace");
|
|
85
168
|
if ([".git", ".mcoda"].some(dir => real === path.join(root, dir) || real.startsWith(`${root}/${dir}/`)))
|
|
86
169
|
throw new ToolExecutionError("tool_permission_denied", "Repository control metadata cannot be a write scope");
|
|
170
|
+
if (protectedPaths.some(input => real === input || real.startsWith(`${input}${path.sep}`)))
|
|
171
|
+
throw new ToolExecutionError("tool_permission_denied", "Authoritative input cannot be a write scope");
|
|
87
172
|
return real;
|
|
88
173
|
});
|
|
89
174
|
if (status.backend === "bubblewrap") {
|
|
90
175
|
const launch = bubblewrapRoot();
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
176
|
+
let resolverRoot;
|
|
177
|
+
try {
|
|
178
|
+
if (!options.network) {
|
|
179
|
+
resolverRoot = await fs.mkdtemp(path.join(os.tmpdir(), "codali-resolver-"));
|
|
180
|
+
const hosts = path.join(resolverRoot, "hosts");
|
|
181
|
+
await fs.writeFile(hosts, "127.0.0.1 localhost\n::1 localhost\n", { mode: 0o600 });
|
|
182
|
+
launch.push("--ro-bind", hosts, "/etc/hosts");
|
|
183
|
+
}
|
|
184
|
+
if (options.network) {
|
|
185
|
+
launch.push("--share-net");
|
|
186
|
+
for (const file of ["/etc/resolv.conf", "/etc/hosts", "/etc/nsswitch.conf", "/etc/ssl/certs"])
|
|
187
|
+
if (existsSync(file))
|
|
188
|
+
launch.push("--ro-bind", realpathSync(file), file);
|
|
189
|
+
}
|
|
190
|
+
launch.push("--dir", path.dirname(root), "--ro-bind", root, root);
|
|
191
|
+
for (const runtime of extraRuntimeMounts(runtimes))
|
|
192
|
+
launch.push("--dir", path.dirname(runtime.readOnlyRoot), ...(runtime.linkTo ? ["--symlink", runtime.linkTo, runtime.readOnlyRoot] : ["--ro-bind", runtime.readOnlyRoot, runtime.readOnlyRoot]));
|
|
193
|
+
for (const runtime of runtimeRoots)
|
|
194
|
+
launch.push("--dir", path.dirname(runtime), "--ro-bind", runtime, runtime);
|
|
195
|
+
launch.push("--dir", "/tmp/codali-bin");
|
|
196
|
+
for (const runtime of runtimes)
|
|
197
|
+
launch.push("--symlink", runtime.executable, `/tmp/codali-bin/${runtime.name}`);
|
|
198
|
+
for (const file of writePaths)
|
|
199
|
+
launch.push("--bind", file, file);
|
|
200
|
+
if (cacheRoot)
|
|
201
|
+
launch.push("--bind", cacheRoot, "/tmp/codali-cache");
|
|
202
|
+
// The rest of /tmp stays per-call; only $TMPDIR survives between calls.
|
|
203
|
+
if (sessionScratch)
|
|
204
|
+
launch.push("--bind", sessionScratch, "/tmp/scratch");
|
|
205
|
+
launch.push("--chdir", cwd, "--dir", "/tmp/home", "--setenv", "HOME", "/tmp/home", "--setenv", "TMPDIR", sessionScratch ? "/tmp/scratch" : "/tmp", "--setenv", "PATH", "/tmp/codali-bin:/usr/local/bin:/usr/bin:/bin");
|
|
206
|
+
for (const [key, value] of Object.entries({ CARGO_HOME: "/tmp/home/cargo", XDG_CACHE_HOME: "/tmp/home/cache", PYTHONPYCACHEPREFIX: "/tmp/home/pycache", PYTHONUSERBASE: "/tmp/home/python", GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null", GIT_ATTR_NOSYSTEM: "1" }))
|
|
207
|
+
launch.push("--setenv", key, value);
|
|
208
|
+
if (cacheRoot)
|
|
209
|
+
for (const [key, value] of Object.entries(packageCacheEnvironment("/tmp/codali-cache")))
|
|
210
|
+
launch.push("--setenv", key, value);
|
|
211
|
+
// A relocated Python (a CI tool cache, a copied installation) records the
|
|
212
|
+
// library directory it was built for, not the one it lives in, and fails
|
|
213
|
+
// with "libpython not found". Point the loader at the interpreter
|
|
214
|
+
// libraries already mounted from the same installation, and nothing else.
|
|
215
|
+
const interpreterLibraries = [...new Set(runtimes.flatMap(runtime => (runtime.support ?? [])
|
|
216
|
+
.filter(mount => !mount.directory && /^libpython3\./.test(path.basename(mount.readOnlyRoot))).map(mount => path.dirname(mount.readOnlyRoot))))];
|
|
217
|
+
if (interpreterLibraries.length)
|
|
218
|
+
launch.push("--setenv", "LD_LIBRARY_PATH", interpreterLibraries.join(":"));
|
|
219
|
+
// Git hooks/config and private session state are not part of executable workspace access.
|
|
220
|
+
for (const dir of [".git", ".mcoda"])
|
|
221
|
+
if (existsSync(path.join(root, dir)))
|
|
222
|
+
launch.push("--ro-bind", path.join(root, dir), path.join(root, dir));
|
|
223
|
+
for (const file of protectedPaths)
|
|
224
|
+
launch.push("--ro-bind", realpathSync(file), file);
|
|
225
|
+
launch.push("--", command, ...args);
|
|
226
|
+
return await runProcess("/usr/bin/bwrap", launch, context);
|
|
227
|
+
}
|
|
228
|
+
finally {
|
|
229
|
+
if (resolverRoot)
|
|
230
|
+
await fs.rm(resolverRoot, { recursive: true, force: true });
|
|
96
231
|
}
|
|
97
|
-
launch.push("--dir", path.dirname(root), "--ro-bind", root, root);
|
|
98
|
-
for (const runtime of extraRuntimeMounts(runtimes))
|
|
99
|
-
launch.push("--dir", path.dirname(runtime.readOnlyRoot), "--ro-bind", runtime.readOnlyRoot, runtime.readOnlyRoot);
|
|
100
|
-
launch.push("--dir", "/tmp/codali-bin");
|
|
101
|
-
for (const runtime of runtimes)
|
|
102
|
-
launch.push("--symlink", runtime.executable, `/tmp/codali-bin/${runtime.name}`);
|
|
103
|
-
for (const file of writePaths)
|
|
104
|
-
launch.push("--bind", file, file);
|
|
105
|
-
launch.push("--chdir", cwd, "--dir", "/tmp/home", "--setenv", "HOME", "/tmp/home", "--setenv", "TMPDIR", "/tmp", "--setenv", "PATH", "/tmp/codali-bin:/usr/local/bin:/usr/bin:/bin");
|
|
106
|
-
for (const [key, value] of Object.entries({ CARGO_HOME: "/tmp/home/cargo", XDG_CACHE_HOME: "/tmp/home/cache", PYTHONPYCACHEPREFIX: "/tmp/home/pycache", PYTHONUSERBASE: "/tmp/home/python", GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null", GIT_ATTR_NOSYSTEM: "1" }))
|
|
107
|
-
launch.push("--setenv", key, value);
|
|
108
|
-
// Git hooks/config and private session state are not part of executable workspace access.
|
|
109
|
-
for (const dir of [".git", ".mcoda"])
|
|
110
|
-
if (existsSync(path.join(root, dir)))
|
|
111
|
-
launch.push("--ro-bind", path.join(root, dir), path.join(root, dir));
|
|
112
|
-
launch.push("--", command, ...args);
|
|
113
|
-
return runProcess("/usr/bin/bwrap", launch, context);
|
|
114
232
|
}
|
|
115
233
|
const scratch = realpathSync(await fs.mkdtemp(path.join(os.tmpdir(), "codali-shell-")));
|
|
116
234
|
try {
|
|
@@ -121,11 +239,12 @@ export const createIsolatedExecutor = (options = {}) => {
|
|
|
121
239
|
await fs.mkdir(privateBin, { mode: 0o700 });
|
|
122
240
|
for (const runtime of runtimes)
|
|
123
241
|
await fs.symlink(runtime.executable, path.join(privateBin, runtime.name));
|
|
124
|
-
const profile = darwinSandboxProfile(root, scratch, writePaths, runtimes, options.network);
|
|
242
|
+
const profile = darwinSandboxProfile(root, scratch, writePaths, runtimes, options.network, runtimeRoots, protectedPaths, cacheRoot, sessionScratch);
|
|
125
243
|
return await runProcess("/usr/bin/sandbox-exec", ["-p", profile, runtimes.find(runtime => runtime.name === command)?.executable ?? command, ...args], context, {
|
|
126
244
|
...runtimes.find(runtime => runtime.name === "cc")?.environment,
|
|
127
|
-
HOME: privateHome, TMPDIR: scratch, PATH: `${privateBin}:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin`,
|
|
245
|
+
HOME: privateHome, TMPDIR: sessionScratch ?? scratch, PATH: `${privateBin}:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin`,
|
|
128
246
|
CARGO_HOME: path.join(privateHome, "cargo"), XDG_CACHE_HOME: path.join(privateHome, "cache"),
|
|
247
|
+
...(cacheRoot ? packageCacheEnvironment(cacheRoot) : {}),
|
|
129
248
|
PYTHONPYCACHEPREFIX: path.join(privateHome, "pycache"), PYTHONUSERBASE: path.join(privateHome, "python"),
|
|
130
249
|
// Host Git settings can invoke external helpers or read private paths.
|
|
131
250
|
GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null", GIT_ATTR_NOSYSTEM: "1",
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { type ToolDefinition } from "../ToolTypes.js";
|
|
2
|
+
/** Shared by terminal execution and tool-enabled benchmark baselines. */
|
|
3
|
+
export declare const DEVELOPMENT_COMMANDS: string[];
|
|
2
4
|
export declare const createShellTool: () => ToolDefinition;
|
|
3
5
|
//# sourceMappingURL=ShellTool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShellTool.d.ts","sourceRoot":"","sources":["../../../src/tools/shell/ShellTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAwC,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"ShellTool.d.ts","sourceRoot":"","sources":["../../../src/tools/shell/ShellTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAwC,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAI5F,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,UAA4iB,CAAC;AA6C9kB,eAAO,MAAM,eAAe,QAAO,cA8DjC,CAAC"}
|
|
@@ -2,6 +2,8 @@ import path from "node:path";
|
|
|
2
2
|
import { ToolExecutionError } from "../ToolTypes.js";
|
|
3
3
|
import { runProcess } from "./AsyncProcess.js";
|
|
4
4
|
import { resolveShellWorkingDirectory } from "./ShellWorkingDirectory.js";
|
|
5
|
+
/** Shared by terminal execution and tool-enabled benchmark baselines. */
|
|
6
|
+
export const DEVELOPMENT_COMMANDS = ["git", "rg", "grep", "node", "npm", "pnpm", "npx", "python3", "pytest", "cargo", "rustc", "go", "make", "cmake", "tsc", "sh", "bash", "ls", "cat", "pwd", "expr", "printf", "head", "tail", "sed", "awk", "uname", "which", "env", "find", "wc", "sort", "uniq", "cut", "diff", "file", "stat", "du", "df", "mkdir", "touch", "cp", "mv", "rm", "curl", "wget", "tar", "unzip", "zip", "cc", "gcc", "g++", "clang", "clang++", "ar", "swift", "swiftc", "java", "javac", "xcrun", "xcodebuild", "google-chrome", "google-chrome-stable", "chromium", "chromium-browser"];
|
|
5
7
|
const resolveAllowlist = (context) => {
|
|
6
8
|
return context.shellAllowlist ?? [];
|
|
7
9
|
};
|
|
@@ -27,7 +29,9 @@ const DESTRUCTIVE_PATTERNS = [
|
|
|
27
29
|
/\bshred\b/,
|
|
28
30
|
/\bmkfs\b/,
|
|
29
31
|
/\bdd\b/,
|
|
30
|
-
|
|
32
|
+
// Swift's named argument and formatting methods are source syntax, not the
|
|
33
|
+
// disk-format command. Direct executable names are checked separately.
|
|
34
|
+
/(?<!\.)\bformat\b(?!\s*:)/,
|
|
31
35
|
/\bfs\.rm(?:sync)?\s*\(/,
|
|
32
36
|
/\bunlink(?:sync)?\s*\(/,
|
|
33
37
|
];
|
|
@@ -41,7 +45,7 @@ const isDestructiveShellAction = (command, args) => {
|
|
|
41
45
|
};
|
|
42
46
|
export const createShellTool = () => ({
|
|
43
47
|
name: "run_shell",
|
|
44
|
-
description: 'Run an allowlisted executable. Default cwd is the workspace root; set cwd for a module-local command, e.g. {"command":"npm","args":["test"],"cwd":"packages/app"}. In terminal mode the workspace is read-only unless writePaths names root-relative paths inside the claimed task. Existing source files in those paths require current reads and structural analysis.',
|
|
48
|
+
description: 'Run an allowlisted executable. Use $TMPDIR for scratch space: files written under $TMPDIR stay available to later calls in this session, while exports, cwd changes and other /tmp paths do not persist between calls. Save required project outputs in claimed workspace writePaths; create missing scoped files/directories with write_file/create_directory first. Package-manager cache environment variables point to persistent workspace-private caches; do not hardcode their paths. Deleting files works only inside $TMPDIR and the writePaths of the call. Each call is isolated and kills its background processes on return; nohup, setsid and tmux cannot keep a server alive. Use browser_session for persistent noVNC/static previews and browser_interact for official Browser Use. Default cwd is the workspace root; set cwd for a module-local command, e.g. {"command":"npm","args":["test"],"cwd":"packages/app"}. In terminal mode the workspace is read-only unless writePaths names root-relative paths inside the claimed task. Existing source files in those paths require current reads and structural analysis.',
|
|
45
49
|
readOnly: false,
|
|
46
50
|
capability: "shell",
|
|
47
51
|
inputSchema: {
|
|
@@ -62,6 +66,7 @@ export const createShellTool = () => ({
|
|
|
62
66
|
}
|
|
63
67
|
const { command, args: commandArgs = [], cwd } = args;
|
|
64
68
|
if (!context.allowDestructiveOperations
|
|
69
|
+
&& !context.shellIsolated
|
|
65
70
|
&& isDestructiveShellAction(command, commandArgs)) {
|
|
66
71
|
throw new ToolExecutionError("tool_permission_denied", "Destructive operation blocked by policy", {
|
|
67
72
|
retryable: false,
|
|
@@ -75,12 +80,22 @@ export const createShellTool = () => ({
|
|
|
75
80
|
}
|
|
76
81
|
const allowlist = resolveAllowlist(context);
|
|
77
82
|
if (!allowlist.length || !allowlist.includes(command)) {
|
|
78
|
-
throw new ToolExecutionError("tool_permission_denied", `Command not allowed: ${command}`, {
|
|
83
|
+
throw new ToolExecutionError("tool_permission_denied", `Command not allowed: ${command.slice(0, 160)}. Available executables: ${allowlist.slice(0, 12).join(", ").slice(0, 700)}${allowlist.length > 12 ? " (first 12 shown)" : ""}`, {
|
|
79
84
|
retryable: false,
|
|
80
85
|
details: { command },
|
|
81
86
|
});
|
|
82
87
|
}
|
|
83
88
|
const shellWorkingDirectory = resolveShellWorkingDirectory(context.workspaceRoot, cwd);
|
|
84
|
-
|
|
89
|
+
const effectiveArgs = [...commandArgs];
|
|
90
|
+
if (command === "bash") {
|
|
91
|
+
// Bash requires long options before short options. Preserve caller flags
|
|
92
|
+
// and script parameters; only make failed pipeline stages observable.
|
|
93
|
+
let at = 0;
|
|
94
|
+
while (effectiveArgs[at]?.startsWith("--") && effectiveArgs[at] !== "--") {
|
|
95
|
+
at += ["--rcfile", "--init-file"].includes(effectiveArgs[at]) ? 2 : 1;
|
|
96
|
+
}
|
|
97
|
+
effectiveArgs.splice(at, 0, "-o", "pipefail");
|
|
98
|
+
}
|
|
99
|
+
return (context.shellExecutor ?? runProcess)(command, effectiveArgs, { ...context, shellWorkingDirectory });
|
|
85
100
|
},
|
|
86
101
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ToolDefinition } from "../ToolTypes.js";
|
|
2
|
+
interface CalendarInput {
|
|
3
|
+
operation: "add_days" | "difference_days";
|
|
4
|
+
date: string;
|
|
5
|
+
days?: number;
|
|
6
|
+
otherDate?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const calendarCalculate: (input: CalendarInput) => {
|
|
9
|
+
date: string;
|
|
10
|
+
} | {
|
|
11
|
+
days: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const createCalendarTool: () => ToolDefinition;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=CalendarTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalendarTool.d.ts","sourceRoot":"","sources":["../../../src/tools/system/CalendarTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE1E,UAAU,aAAa;IAAG,SAAS,EAAE,UAAU,GAAG,iBAAiB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAAE;AASvH,eAAO,MAAM,iBAAiB,GAAI,OAAO,aAAa,KAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAazF,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,cAYpC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ToolExecutionError } from "../ToolTypes.js";
|
|
2
|
+
const DAY = 86400000;
|
|
3
|
+
const epochDay = (date) => {
|
|
4
|
+
if (typeof date !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(date) || date.startsWith("0000"))
|
|
5
|
+
throw new Error("Expected a Gregorian date YYYY-MM-DD in years 0001–9999");
|
|
6
|
+
const time = Date.parse(`${date}T00:00:00.000Z`);
|
|
7
|
+
if (!Number.isFinite(time) || new Date(time).toISOString().slice(0, 10) !== date)
|
|
8
|
+
throw new Error("Invalid calendar date");
|
|
9
|
+
return time / DAY;
|
|
10
|
+
};
|
|
11
|
+
export const calendarCalculate = (input) => {
|
|
12
|
+
const start = epochDay(input.date);
|
|
13
|
+
if (input.operation === "add_days") {
|
|
14
|
+
if (!Number.isInteger(input.days) || Math.abs(input.days) > 3652058 || input.otherDate !== undefined)
|
|
15
|
+
throw new Error("add_days requires integer days and no otherDate");
|
|
16
|
+
const date = new Date((start + input.days) * DAY).toISOString().slice(0, 10);
|
|
17
|
+
epochDay(date); // Reject results beyond the supported Gregorian year range.
|
|
18
|
+
return { date };
|
|
19
|
+
}
|
|
20
|
+
if (input.operation === "difference_days") {
|
|
21
|
+
if (input.days !== undefined || input.otherDate === undefined)
|
|
22
|
+
throw new Error("difference_days requires otherDate and no days");
|
|
23
|
+
return { days: epochDay(input.otherDate) - start };
|
|
24
|
+
}
|
|
25
|
+
throw new Error("Unknown calendar operation");
|
|
26
|
+
};
|
|
27
|
+
export const createCalendarTool = () => ({
|
|
28
|
+
name: "calendar_calculate", capability: "calculation", readOnly: true,
|
|
29
|
+
description: "Exact Gregorian calendar dates: add signed days or count otherDate minus date. ISO YYYY-MM-DD, UTC; no business-day, locale or timezone guessing.",
|
|
30
|
+
inputSchema: { type: "object", required: ["operation", "date"], additionalProperties: false, properties: {
|
|
31
|
+
operation: { type: "string", enum: ["add_days", "difference_days"] }, date: { type: "string", minLength: 10, maxLength: 10 },
|
|
32
|
+
days: { type: "integer", minimum: -3652058, maximum: 3652058 }, otherDate: { type: "string", minLength: 10, maxLength: 10 },
|
|
33
|
+
} },
|
|
34
|
+
handler: async (args, context) => {
|
|
35
|
+
context.signal?.throwIfAborted();
|
|
36
|
+
try {
|
|
37
|
+
const data = { ...calendarCalculate(args), calendar: "proleptic Gregorian UTC" };
|
|
38
|
+
return { output: JSON.stringify(data), data };
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
throw new ToolExecutionError("tool_invalid_args", error instanceof Error ? error.message : String(error), { retryable: false });
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextTool.d.ts","sourceRoot":"","sources":["../../../src/tools/system/TextTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE1E,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAO9D;AAED,eAAO,MAAM,cAAc,QAAO,cAsBhC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ToolExecutionError } from "../ToolTypes.js";
|
|
2
|
+
export function compareCodePoints(a, b) {
|
|
3
|
+
const left = Array.from(a, ch => ch.codePointAt(0));
|
|
4
|
+
const right = Array.from(b, ch => ch.codePointAt(0));
|
|
5
|
+
for (let i = 0; i < Math.min(left.length, right.length); i++) {
|
|
6
|
+
if (left[i] !== right[i])
|
|
7
|
+
return left[i] - right[i];
|
|
8
|
+
}
|
|
9
|
+
return left.length - right.length;
|
|
10
|
+
}
|
|
11
|
+
export const createTextTool = () => ({
|
|
12
|
+
name: "transform_text", capability: "deterministic", readOnly: true,
|
|
13
|
+
description: "Exact string-list operations: sort lexicographically by Unicode code points, deduplicate in source order, or normalize Unicode. No locale collation. Sorting does not normalize text.",
|
|
14
|
+
inputSchema: { type: "object", required: ["operation", "values"], additionalProperties: false, properties: {
|
|
15
|
+
operation: { type: "string", enum: ["sort_codepoints", "unique", "normalize"] },
|
|
16
|
+
values: { type: "array", maxItems: 1000, items: { type: "string", maxLength: 4096 } },
|
|
17
|
+
form: { type: "string", enum: ["NFC", "NFD", "NFKC", "NFKD"] },
|
|
18
|
+
} },
|
|
19
|
+
handler: async (args, context) => {
|
|
20
|
+
context.signal?.throwIfAborted();
|
|
21
|
+
const { operation, values, form } = args;
|
|
22
|
+
if (!Array.isArray(values) || values.length > 1000 || values.some(v => typeof v !== "string" || v.length > 4096)
|
|
23
|
+
|| values.reduce((n, v) => n + v.length, 0) > 32000)
|
|
24
|
+
throw new ToolExecutionError("tool_invalid_args", "Expected at most 1000 strings and 32000 total characters");
|
|
25
|
+
if (form !== undefined && operation !== "normalize")
|
|
26
|
+
throw new ToolExecutionError("tool_invalid_args", "Normalization form applies only to normalize; sorting preserves exact text");
|
|
27
|
+
let result;
|
|
28
|
+
if (operation === "sort_codepoints")
|
|
29
|
+
result = [...values].sort(compareCodePoints);
|
|
30
|
+
else if (operation === "unique")
|
|
31
|
+
result = [...new Set(values)];
|
|
32
|
+
else if (operation === "normalize" && ["NFC", "NFD", "NFKC", "NFKD"].includes(form ?? ""))
|
|
33
|
+
result = values.map(v => v.normalize(form));
|
|
34
|
+
else
|
|
35
|
+
throw new ToolExecutionError("tool_invalid_args", "Choose sort_codepoints, unique, or normalize with an explicit Unicode form");
|
|
36
|
+
const data = { values: result };
|
|
37
|
+
return { output: JSON.stringify(data), data };
|
|
38
|
+
},
|
|
39
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeTool.d.ts","sourceRoot":"","sources":["../../../src/tools/system/TimeTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE1E,kFAAkF;AAClF,eAAO,MAAM,cAAc,GAAI,MAAK,MAAM,MAAiB,KAAG,cAe5D,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ToolExecutionError } from "../ToolTypes.js";
|
|
2
|
+
/** The execution host's clock; never an inferred date or a model-server clock. */
|
|
3
|
+
export const createTimeTool = (now = Date.now) => ({
|
|
4
|
+
name: "server_time", capability: "clock", readOnly: true,
|
|
5
|
+
description: "Read the current clock of the computer running Codali. Returns UTC, Unix milliseconds and an optional IANA timezone representation. Use for today's date, current time and resolving relative dates; this is not the remote model server's clock.",
|
|
6
|
+
inputSchema: { type: "object", properties: { timezone: { type: "string", minLength: 1, maxLength: 128 } }, additionalProperties: false },
|
|
7
|
+
handler: async (args, context) => {
|
|
8
|
+
context.signal?.throwIfAborted();
|
|
9
|
+
const timezone = args.timezone ?? "UTC";
|
|
10
|
+
let formatter;
|
|
11
|
+
try {
|
|
12
|
+
formatter = new Intl.DateTimeFormat("en-CA", { timeZone: timezone, year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit", hourCycle: "h23", timeZoneName: "longOffset" });
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new ToolExecutionError("tool_invalid_args", "Use an IANA timezone such as UTC, Europe/London or Asia/Tokyo", { retryable: false });
|
|
16
|
+
}
|
|
17
|
+
const unixMilliseconds = now();
|
|
18
|
+
const data = { source: "Codali execution host clock", utc: new Date(unixMilliseconds).toISOString(), unixMilliseconds,
|
|
19
|
+
timezone: formatter.resolvedOptions().timeZone, local: formatter.format(new Date(unixMilliseconds)) };
|
|
20
|
+
return { output: JSON.stringify(data), data };
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type ToolDefinition } from "../ToolTypes.js";
|
|
2
|
+
export interface JavaScriptChecks {
|
|
3
|
+
entry: string;
|
|
4
|
+
cases: Array<{
|
|
5
|
+
args: unknown[];
|
|
6
|
+
expected: unknown;
|
|
7
|
+
}>;
|
|
8
|
+
preserveInput?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const javaScriptChecksSchema: {
|
|
11
|
+
type: "object";
|
|
12
|
+
properties: {
|
|
13
|
+
entry: {
|
|
14
|
+
type: "string";
|
|
15
|
+
minLength: number;
|
|
16
|
+
maxLength: number;
|
|
17
|
+
};
|
|
18
|
+
cases: {
|
|
19
|
+
type: "array";
|
|
20
|
+
minItems: number;
|
|
21
|
+
maxItems: number;
|
|
22
|
+
items: {
|
|
23
|
+
type: "object";
|
|
24
|
+
properties: {
|
|
25
|
+
args: {
|
|
26
|
+
type: "array";
|
|
27
|
+
maxItems: number;
|
|
28
|
+
};
|
|
29
|
+
expected: {
|
|
30
|
+
additionalProperties: boolean;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
required: string[];
|
|
34
|
+
additionalProperties: boolean;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
preserveInput: {
|
|
38
|
+
type: "boolean";
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
required: string[];
|
|
42
|
+
additionalProperties: boolean;
|
|
43
|
+
};
|
|
44
|
+
/** Extract only a complete module, never a different source from the one shown. */
|
|
45
|
+
export declare const javaScriptAnswerSource: (answer: string) => string;
|
|
46
|
+
export declare const createJavaScriptVerificationTool: () => ToolDefinition;
|
|
47
|
+
//# sourceMappingURL=JavaScriptVerificationTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JavaScriptVerificationTool.d.ts","sourceRoot":"","sources":["../../../src/tools/verification/JavaScriptVerificationTool.ts"],"names":[],"mappings":"AAMA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE1E,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACrD,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAUlC,CAAC;AAEF,mFAAmF;AACnF,eAAO,MAAM,sBAAsB,GAAI,QAAQ,MAAM,KAAG,MAKvD,CAAC;AAEF,eAAO,MAAM,gCAAgC,QAAO,cAuClD,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { isDeepStrictEqual } from "node:util";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { createIsolatedExecutor } from "../shell/IsolatedExecutor.js";
|
|
7
|
+
import { ToolExecutionError } from "../ToolTypes.js";
|
|
8
|
+
export const javaScriptChecksSchema = {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
entry: { type: "string", minLength: 1, maxLength: 100 },
|
|
12
|
+
cases: { type: "array", minItems: 1, maxItems: 16, items: { type: "object",
|
|
13
|
+
properties: { args: { type: "array", maxItems: 16 }, expected: { additionalProperties: true } },
|
|
14
|
+
required: ["args", "expected"], additionalProperties: false } },
|
|
15
|
+
preserveInput: { type: "boolean" },
|
|
16
|
+
},
|
|
17
|
+
required: ["entry", "cases"], additionalProperties: false,
|
|
18
|
+
};
|
|
19
|
+
/** Extract only a complete module, never a different source from the one shown. */
|
|
20
|
+
export const javaScriptAnswerSource = (answer) => {
|
|
21
|
+
const fences = [...answer.matchAll(/```([^\n]*)\n([\s\S]*?)```/g)];
|
|
22
|
+
if (!fences.length && !answer.includes("```"))
|
|
23
|
+
return answer.trim();
|
|
24
|
+
if (fences.length !== 1 || !/^(?:js|javascript|mjs)?\s*$/i.test(fences[0][1]))
|
|
25
|
+
throw new ToolExecutionError("tool_invalid_args", "Verification requires one complete JavaScript module in a code fence, or raw module text");
|
|
26
|
+
return fences[0][2].trim();
|
|
27
|
+
};
|
|
28
|
+
export const createJavaScriptVerificationTool = () => ({
|
|
29
|
+
name: "verify_javascript", capability: "verification", readOnly: true,
|
|
30
|
+
description: "Run a self-contained synchronous JavaScript ES module against explicit JSON cases. Named export entry receives each args array. Compares actual JSON with expected; optional preserveInput checks mutation. No imports, workspace, credentials or network. Passing supplied cases is limited evidence, not proof of general correctness.",
|
|
31
|
+
inputSchema: { type: "object", properties: { source: { type: "string", minLength: 1, maxLength: 24000 }, ...javaScriptChecksSchema.properties },
|
|
32
|
+
required: ["source", ...javaScriptChecksSchema.required], additionalProperties: false },
|
|
33
|
+
handler: async (raw, context) => {
|
|
34
|
+
context.signal?.throwIfAborted();
|
|
35
|
+
const args = raw;
|
|
36
|
+
if (typeof args.source !== "string" || !args.source.trim() || args.source.length > 24000 || !/^[A-Za-z_$][\w$]{0,99}$/.test(args.entry)
|
|
37
|
+
|| !Array.isArray(args.cases) || args.cases.length < 1 || args.cases.length > 16
|
|
38
|
+
|| args.cases.some(test => !test || !Array.isArray(test.args) || test.args.length > 16 || !Object.prototype.hasOwnProperty.call(test, "expected"))) {
|
|
39
|
+
throw new ToolExecutionError("tool_invalid_args", "Expected bounded source, a named export, and 1-16 JSON test cases");
|
|
40
|
+
}
|
|
41
|
+
const payload = JSON.stringify({ source: args.source, entry: args.entry, inputs: args.cases.map(test => test.args) });
|
|
42
|
+
if (payload.length > 64000 || JSON.stringify(args.cases).length > 64000)
|
|
43
|
+
throw new ToolExecutionError("tool_invalid_args", "Verification input exceeds 64000 characters");
|
|
44
|
+
const root = await fs.mkdtemp(path.join(os.tmpdir(), "codali-verify-"));
|
|
45
|
+
try {
|
|
46
|
+
await fs.chmod(root, 0o700);
|
|
47
|
+
await fs.writeFile(path.join(root, "input.json"), payload, { mode: 0o600 });
|
|
48
|
+
await fs.copyFile(new URL("./JavaScriptVerificationWorker.js", import.meta.url), path.join(root, "observe.mjs"));
|
|
49
|
+
const run = await createIsolatedExecutor({ network: false })(process.execPath, ["--experimental-vm-modules", "--no-warnings", "--max-old-space-size=64", path.join(root, "observe.mjs")], { workspaceRoot: root, signal: context.signal, allowedWritePaths: [], shellTimeoutMs: 5000, shellMaxOutputBytes: 128 * 1024 });
|
|
50
|
+
const data = run.data;
|
|
51
|
+
if (data.truncated)
|
|
52
|
+
throw new ToolExecutionError("tool_execution_failed", "Verification observations exceeded the output limit");
|
|
53
|
+
const observed = JSON.parse(data.stdout);
|
|
54
|
+
if (!Array.isArray(observed.observations) || observed.observations.length !== args.cases.length)
|
|
55
|
+
throw new ToolExecutionError("tool_execution_failed", "Incomplete verification observations");
|
|
56
|
+
const checks = args.cases.map((test, index) => {
|
|
57
|
+
const observation = observed.observations[index];
|
|
58
|
+
const passed = !observation.error && Object.prototype.hasOwnProperty.call(observation, "actual") && isDeepStrictEqual(observation.actual, test.expected)
|
|
59
|
+
&& (!args.preserveInput || observation.inputPreserved === true);
|
|
60
|
+
return { index, passed, ...(!passed ? { reason: observation.error ?? (args.preserveInput && !observation.inputPreserved ? "Input was mutated" : "Actual result differs"),
|
|
61
|
+
actual: JSON.stringify(observation.actual)?.slice(0, 200), expected: JSON.stringify(test.expected).slice(0, 200) } : {}) };
|
|
62
|
+
});
|
|
63
|
+
const result = { passed: checks.every(check => check.passed), checks, sourceSha256: createHash("sha256").update(args.source).digest("hex"),
|
|
64
|
+
scope: "Only the supplied cases; synchronous JSON values, fresh module per case, no imports" };
|
|
65
|
+
return { output: JSON.stringify(result), data: result };
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JavaScriptVerificationWorker.d.ts","sourceRoot":"","sources":["../../../src/tools/verification/JavaScriptVerificationWorker.ts"],"names":[],"mappings":""}
|