@mcoda/mswarm 0.1.134 → 0.1.135-codali.11
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 +40 -0
- package/dist/codali-executor.d.ts +76 -0
- package/dist/codali-executor.d.ts.map +1 -1
- package/dist/codali-executor.js +122 -8
- package/dist/codali-executor.js.map +1 -1
- package/dist/invocation-token.d.ts.map +1 -1
- package/dist/invocation-token.js +1 -0
- package/dist/invocation-token.js.map +1 -1
- package/dist/native-reasoning.d.ts +8 -0
- package/dist/native-reasoning.d.ts.map +1 -0
- package/dist/native-reasoning.js +18 -0
- package/dist/native-reasoning.js.map +1 -0
- package/dist/runtime.d.ts +23 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +187 -17
- package/dist/runtime.js.map +1 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +58 -8
- package/dist/server.js.map +1 -1
- package/dist/vendor/codali/agents/RoleResolution.d.ts.map +1 -1
- package/dist/vendor/codali/agents/RoleResolution.js +4 -4
- package/dist/vendor/codali/api/CodaliApi.d.ts +16 -0
- package/dist/vendor/codali/api/CodaliApi.d.ts.map +1 -1
- package/dist/vendor/codali/api/CodaliApi.js +39 -10
- package/dist/vendor/codali/cli/AskCommand.d.ts +3 -0
- package/dist/vendor/codali/cli/AskCommand.d.ts.map +1 -1
- package/dist/vendor/codali/cli/AskCommand.js +76 -13
- package/dist/vendor/codali/cli/RunCommand.d.ts +4 -0
- package/dist/vendor/codali/cli/RunCommand.d.ts.map +1 -1
- package/dist/vendor/codali/cli/RunCommand.js +110 -24
- package/dist/vendor/codali/cli/TerminalCommand.d.ts +35 -0
- package/dist/vendor/codali/cli/TerminalCommand.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalCommand.js +618 -0
- package/dist/vendor/codali/cli/TerminalCredentials.d.ts +3 -0
- package/dist/vendor/codali/cli/TerminalCredentials.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalCredentials.js +89 -0
- package/dist/vendor/codali/cli/TerminalInput.d.ts +24 -0
- package/dist/vendor/codali/cli/TerminalInput.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalInput.js +98 -0
- package/dist/vendor/codali/cli/TerminalText.d.ts +10 -0
- package/dist/vendor/codali/cli/TerminalText.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalText.js +53 -0
- package/dist/vendor/codali/cli.d.ts.map +1 -1
- package/dist/vendor/codali/cli.js +33 -4
- package/dist/vendor/codali/cognitive/ConfiguredPipeline.d.ts +34 -0
- package/dist/vendor/codali/cognitive/ConfiguredPipeline.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ConfiguredPipeline.js +50 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.d.ts +4 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.d.ts.map +1 -1
- package/dist/vendor/codali/cognitive/ValidationRunner.js +18 -41
- package/dist/vendor/codali/config/NodeOrchestration.d.ts +21 -0
- package/dist/vendor/codali/config/NodeOrchestration.d.ts.map +1 -0
- package/dist/vendor/codali/config/NodeOrchestration.js +54 -0
- package/dist/vendor/codali/config/OrchestrationConfig.d.ts +100 -0
- package/dist/vendor/codali/config/OrchestrationConfig.d.ts.map +1 -0
- package/dist/vendor/codali/config/OrchestrationConfig.js +245 -0
- package/dist/vendor/codali/connectors/mcp/McpClient.d.ts +3 -1
- package/dist/vendor/codali/connectors/mcp/McpClient.d.ts.map +1 -1
- package/dist/vendor/codali/connectors/mcp/McpClient.js +3 -2
- package/dist/vendor/codali/connectors/mcp/McpServerRegistry.d.ts +2 -2
- package/dist/vendor/codali/connectors/mcp/McpServerRegistry.d.ts.map +1 -1
- package/dist/vendor/codali/connectors/mcp/McpServerRegistry.js +39 -16
- package/dist/vendor/codali/connectors/mcp/McpToolAdapter.js +2 -2
- package/dist/vendor/codali/connectors/media/ConfiguredMediaTools.d.ts +6 -0
- package/dist/vendor/codali/connectors/media/ConfiguredMediaTools.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/ConfiguredMediaTools.js +41 -0
- package/dist/vendor/codali/connectors/media/ImageGenerationTool.js +3 -3
- package/dist/vendor/codali/connectors/media/MediaArtifactReceipt.d.ts +5 -0
- package/dist/vendor/codali/connectors/media/MediaArtifactReceipt.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/MediaArtifactReceipt.js +65 -0
- package/dist/vendor/codali/connectors/media/MediaJobStore.d.ts +68 -0
- package/dist/vendor/codali/connectors/media/MediaJobStore.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/MediaJobStore.js +199 -0
- package/dist/vendor/codali/connectors/media/MediaJobWorker.d.ts +2 -0
- package/dist/vendor/codali/connectors/media/MediaJobWorker.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/MediaJobWorker.js +65 -0
- package/dist/vendor/codali/connectors/media/RemoteMediaJob.d.ts +6 -0
- package/dist/vendor/codali/connectors/media/RemoteMediaJob.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/RemoteMediaJob.js +80 -0
- package/dist/vendor/codali/docdex/DocdexClient.d.ts +18 -1
- package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -1
- package/dist/vendor/codali/docdex/DocdexClient.js +135 -19
- package/dist/vendor/codali/docdex/ManagedDocdex.d.ts +29 -0
- package/dist/vendor/codali/docdex/ManagedDocdex.d.ts.map +1 -0
- package/dist/vendor/codali/docdex/ManagedDocdex.js +215 -0
- package/dist/vendor/codali/docdex/ManagedRuntime.d.ts +28 -0
- package/dist/vendor/codali/docdex/ManagedRuntime.d.ts.map +1 -0
- package/dist/vendor/codali/docdex/ManagedRuntime.js +212 -0
- package/dist/vendor/codali/eval/EvaluationProcess.d.ts +13 -0
- package/dist/vendor/codali/eval/EvaluationProcess.d.ts.map +1 -0
- package/dist/vendor/codali/eval/EvaluationProcess.js +76 -0
- package/dist/vendor/codali/eval/LongWorkflowJourney.d.ts +34 -0
- package/dist/vendor/codali/eval/LongWorkflowJourney.d.ts.map +1 -0
- package/dist/vendor/codali/eval/LongWorkflowJourney.js +243 -0
- package/dist/vendor/codali/eval/PlanningCorpus.d.ts +45 -0
- package/dist/vendor/codali/eval/PlanningCorpus.d.ts.map +1 -0
- package/dist/vendor/codali/eval/PlanningCorpus.js +189 -0
- package/dist/vendor/codali/eval/PlanningCorpusRunner.d.ts +13 -0
- package/dist/vendor/codali/eval/PlanningCorpusRunner.d.ts.map +1 -0
- package/dist/vendor/codali/eval/PlanningCorpusRunner.js +89 -0
- package/dist/vendor/codali/eval/TerminalCorpusRunner.d.ts +36 -0
- package/dist/vendor/codali/eval/TerminalCorpusRunner.d.ts.map +1 -0
- package/dist/vendor/codali/eval/TerminalCorpusRunner.js +222 -0
- package/dist/vendor/codali/eval/TerminalTaskCorpus.d.ts +26 -0
- package/dist/vendor/codali/eval/TerminalTaskCorpus.d.ts.map +1 -0
- package/dist/vendor/codali/eval/TerminalTaskCorpus.js +105 -0
- package/dist/vendor/codali/eval/TerminalWorkflowCorpus.d.ts +11 -0
- package/dist/vendor/codali/eval/TerminalWorkflowCorpus.d.ts.map +1 -0
- package/dist/vendor/codali/eval/TerminalWorkflowCorpus.js +119 -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 +4 -0
- package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.d.ts.map +1 -0
- package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.js +136 -0
- package/dist/vendor/codali/gateway/CodaliGateway.d.ts +2 -0
- package/dist/vendor/codali/gateway/CodaliGateway.d.ts.map +1 -1
- package/dist/vendor/codali/gateway/CodaliGateway.js +11 -1
- package/dist/vendor/codali/gateway/ConfiguredGateway.d.ts +23 -0
- package/dist/vendor/codali/gateway/ConfiguredGateway.d.ts.map +1 -0
- package/dist/vendor/codali/gateway/ConfiguredGateway.js +44 -0
- package/dist/vendor/codali/gateway/GatewayTracer.d.ts +1 -1
- package/dist/vendor/codali/gateway/GatewayTracer.d.ts.map +1 -1
- package/dist/vendor/codali/gateway/GatewayTracer.js +2 -27
- package/dist/vendor/codali/index.d.ts +24 -0
- package/dist/vendor/codali/index.d.ts.map +1 -1
- package/dist/vendor/codali/index.js +13 -0
- package/dist/vendor/codali/permissions/PermissionGate.d.ts +44 -0
- package/dist/vendor/codali/permissions/PermissionGate.d.ts.map +1 -0
- package/dist/vendor/codali/permissions/PermissionGate.js +97 -0
- package/dist/vendor/codali/providers/ConfiguredEmbeddings.d.ts +43 -0
- package/dist/vendor/codali/providers/ConfiguredEmbeddings.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ConfiguredEmbeddings.js +87 -0
- package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts +70 -0
- package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ConfiguredModelScope.js +129 -0
- package/dist/vendor/codali/providers/ConfiguredProvider.d.ts +84 -0
- package/dist/vendor/codali/providers/ConfiguredProvider.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ConfiguredProvider.js +271 -0
- package/dist/vendor/codali/providers/ModelServiceError.d.ts +15 -0
- package/dist/vendor/codali/providers/ModelServiceError.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ModelServiceError.js +69 -0
- package/dist/vendor/codali/providers/MswarmWorkerProvider.d.ts.map +1 -1
- package/dist/vendor/codali/providers/MswarmWorkerProvider.js +4 -0
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +97 -50
- package/dist/vendor/codali/providers/ProviderTypes.d.ts +14 -0
- package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -1
- 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/CodaliJobRuntime.d.ts +6 -0
- package/dist/vendor/codali/runtime/CodaliJobRuntime.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/CodaliJobRuntime.js +36 -1
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +29 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/CodaliRuntime.js +70 -1
- package/dist/vendor/codali/runtime/CompletionReport.d.ts +5 -0
- package/dist/vendor/codali/runtime/CompletionReport.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/CompletionReport.js +12 -0
- package/dist/vendor/codali/runtime/ProgressTracker.d.ts +17 -0
- package/dist/vendor/codali/runtime/ProgressTracker.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ProgressTracker.js +27 -0
- package/dist/vendor/codali/runtime/RequestedTestEvidence.d.ts +12 -0
- package/dist/vendor/codali/runtime/RequestedTestEvidence.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RequestedTestEvidence.js +16 -0
- package/dist/vendor/codali/runtime/RequiredRetrieval.d.ts +13 -0
- package/dist/vendor/codali/runtime/RequiredRetrieval.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RequiredRetrieval.js +25 -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 +41 -0
- package/dist/vendor/codali/runtime/ReviewCoordinator.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ReviewCoordinator.js +126 -0
- package/dist/vendor/codali/runtime/ReviewSource.d.ts +9 -0
- package/dist/vendor/codali/runtime/ReviewSource.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ReviewSource.js +54 -0
- package/dist/vendor/codali/runtime/Runner.d.ts +7 -0
- package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/Runner.js +220 -171
- package/dist/vendor/codali/runtime/SecretRedaction.d.ts +11 -0
- package/dist/vendor/codali/runtime/SecretRedaction.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/SecretRedaction.js +85 -0
- package/dist/vendor/codali/runtime/SessionController.d.ts +150 -0
- package/dist/vendor/codali/runtime/SessionController.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/SessionController.js +1487 -0
- package/dist/vendor/codali/runtime/StructuralEvidence.d.ts +22 -0
- package/dist/vendor/codali/runtime/StructuralEvidence.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/StructuralEvidence.js +87 -0
- 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 +84 -0
- package/dist/vendor/codali/runtime/TaskReviewContext.d.ts +71 -0
- package/dist/vendor/codali/runtime/TaskReviewContext.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/TaskReviewContext.js +50 -0
- 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/ValidationOutput.d.ts +5 -0
- package/dist/vendor/codali/runtime/ValidationOutput.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ValidationOutput.js +32 -0
- package/dist/vendor/codali/runtime/VerificationCommand.d.ts +5 -0
- package/dist/vendor/codali/runtime/VerificationCommand.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/VerificationCommand.js +76 -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/WorkStatusPage.d.ts +15 -0
- package/dist/vendor/codali/runtime/WorkStatusPage.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/WorkStatusPage.js +58 -0
- package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts +13 -0
- package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/WorkspaceLedger.js +145 -0
- package/dist/vendor/codali/runtime/WorkspaceLock.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/WorkspaceLock.js +20 -17
- package/dist/vendor/codali/runtime/WorkspaceSnapshot.d.ts +13 -0
- package/dist/vendor/codali/runtime/WorkspaceSnapshot.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/WorkspaceSnapshot.js +88 -0
- package/dist/vendor/codali/session/AtomicState.d.ts +13 -0
- package/dist/vendor/codali/session/AtomicState.d.ts.map +1 -0
- package/dist/vendor/codali/session/AtomicState.js +123 -0
- package/dist/vendor/codali/session/SessionStoragePath.d.ts +15 -0
- package/dist/vendor/codali/session/SessionStoragePath.d.ts.map +1 -0
- package/dist/vendor/codali/session/SessionStoragePath.js +101 -0
- package/dist/vendor/codali/session/SessionStore.d.ts +9 -0
- package/dist/vendor/codali/session/SessionStore.d.ts.map +1 -1
- package/dist/vendor/codali/session/SessionStore.js +181 -47
- package/dist/vendor/codali/session/WorkState.d.ts +32 -0
- package/dist/vendor/codali/session/WorkState.d.ts.map +1 -0
- package/dist/vendor/codali/session/WorkState.js +399 -0
- package/dist/vendor/codali/session/WorkTypes.d.ts +102 -0
- package/dist/vendor/codali/session/WorkTypes.d.ts.map +1 -0
- package/dist/vendor/codali/session/WorkTypes.js +1 -0
- package/dist/vendor/codali/tools/ToolRegistry.d.ts +2 -0
- package/dist/vendor/codali/tools/ToolRegistry.d.ts.map +1 -1
- package/dist/vendor/codali/tools/ToolRegistry.js +12 -2
- package/dist/vendor/codali/tools/ToolTypes.d.ts +16 -0
- package/dist/vendor/codali/tools/ToolTypes.d.ts.map +1 -1
- 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 +17 -2
- package/dist/vendor/codali/tools/filesystem/FileTools.d.ts.map +1 -1
- package/dist/vendor/codali/tools/filesystem/FileTools.js +30 -10
- package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts +19 -0
- package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/AsyncProcess.js +94 -0
- package/dist/vendor/codali/tools/shell/DarwinRuntimeLibraries.d.ts +13 -0
- package/dist/vendor/codali/tools/shell/DarwinRuntimeLibraries.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/DarwinRuntimeLibraries.js +130 -0
- package/dist/vendor/codali/tools/shell/HostToolchain.d.ts +19 -0
- package/dist/vendor/codali/tools/shell/HostToolchain.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/HostToolchain.js +266 -0
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts +15 -0
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.js +138 -0
- package/dist/vendor/codali/tools/shell/ShellTool.d.ts.map +1 -1
- package/dist/vendor/codali/tools/shell/ShellTool.js +9 -29
- package/dist/vendor/codali/tools/shell/ShellWorkingDirectory.d.ts +3 -0
- package/dist/vendor/codali/tools/shell/ShellWorkingDirectory.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/ShellWorkingDirectory.js +30 -0
- package/package.json +31 -29
- package/scripts/backend-http-drain.mjs +152 -0
- package/scripts/media_gpu_lock.py +238 -0
- package/scripts/native_load_guard.py +257 -0
- package/scripts/stable-audio-3-openai-server.py +45 -14
- package/scripts/stable-diffusion-cpp-openai-server.py +34 -4
- package/scripts/stable-diffusion-cpp-webm-duration.patch +22 -0
- package/scripts/wan22-openai-server.py +97 -18
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { requiredRetrievalProvider } from "./RequiredRetrieval.js";
|
|
2
3
|
import { normalizeAgentRequest, parseAgentRequest, } from "../agents/AgentProtocol.js";
|
|
3
4
|
import { createProvider } from "../providers/ProviderRegistry.js";
|
|
4
5
|
import { OpenAiCompatibleProvider } from "../providers/OpenAiCompatibleProvider.js";
|
|
@@ -6,6 +7,8 @@ import { OllamaRemoteProvider } from "../providers/OllamaRemoteProvider.js";
|
|
|
6
7
|
import { CodexCliProvider } from "../providers/CodexCliProvider.js";
|
|
7
8
|
import { ClaudeCliProvider } from "../providers/ClaudeCliProvider.js";
|
|
8
9
|
import { MswarmWorkerProvider } from "../providers/MswarmWorkerProvider.js";
|
|
10
|
+
import { ConfiguredModelScope } from "../providers/ConfiguredModelScope.js";
|
|
11
|
+
import { validateOrchestrationConfig, orchestrationHash } from "../config/OrchestrationConfig.js";
|
|
9
12
|
import { DocdexClient, normalizeDocdexRuntimeOperation, } from "../docdex/DocdexClient.js";
|
|
10
13
|
import { AppToolGatewayDispatchError, dispatchAppToolGateway, } from "../gateway/AppToolGatewayDispatcher.js";
|
|
11
14
|
import { createDiffTool } from "../tools/diff/DiffTool.js";
|
|
@@ -74,6 +77,12 @@ const DOCDEX_TOOL_OPERATIONS = new Map([
|
|
|
74
77
|
["docdex_tree", ["tree"]],
|
|
75
78
|
["docdex_memory_save", ["memory_save"]],
|
|
76
79
|
["docdex_memory_recall", ["memory_recall"]],
|
|
80
|
+
["docdex_wakeup", ["wakeup"]],
|
|
81
|
+
["docdex_diary_read", ["diary_read"]],
|
|
82
|
+
["docdex_diary_write", ["diary_write"]],
|
|
83
|
+
["docdex_conversation_read", ["conversation_read"]],
|
|
84
|
+
["docdex_conversation_search", ["conversation_search"]],
|
|
85
|
+
["docdex_kg_query", ["kg_query"]],
|
|
77
86
|
["docdex_get_profile", ["profile_read"]],
|
|
78
87
|
["docdex_save_preference", ["profile_write"]],
|
|
79
88
|
["docdex_web_research", ["web_research"]],
|
|
@@ -969,6 +978,7 @@ const createRuntimeProvider = (input) => {
|
|
|
969
978
|
apiKey: input.apiKey,
|
|
970
979
|
baseUrl: input.baseUrl,
|
|
971
980
|
timeoutMs: input.timeoutMs,
|
|
981
|
+
retryTransient: input.retryTransient,
|
|
972
982
|
localRunner: input.localRunner,
|
|
973
983
|
runnerKind: input.runnerKind,
|
|
974
984
|
authMode: input.authMode,
|
|
@@ -1266,6 +1276,7 @@ const initializeRuntimeSession = async (input, runId, warnings) => {
|
|
|
1266
1276
|
const instructionSources = instructionBlocks.map((block) => block.sourcePath);
|
|
1267
1277
|
const metadata = await store.getOrCreateSession({
|
|
1268
1278
|
sessionId: input.session.id,
|
|
1279
|
+
parentSessionId: input.session.parentSessionId,
|
|
1269
1280
|
repoRoot: input.workspace.root,
|
|
1270
1281
|
task: input.task,
|
|
1271
1282
|
instructionSources,
|
|
@@ -1282,6 +1293,9 @@ const initializeRuntimeSession = async (input, runId, warnings) => {
|
|
|
1282
1293
|
data: {
|
|
1283
1294
|
task: input.task,
|
|
1284
1295
|
mode: input.policy.mode,
|
|
1296
|
+
gatewayRunId: input.metadata?.gatewayRunId,
|
|
1297
|
+
gatewayTaskId: input.metadata?.gatewayTaskId,
|
|
1298
|
+
parentSessionId: input.session.parentSessionId,
|
|
1285
1299
|
agent: input.agent?.slug,
|
|
1286
1300
|
model: input.provider.model,
|
|
1287
1301
|
},
|
|
@@ -1752,6 +1766,7 @@ const runProtocolLoop = async (options) => {
|
|
|
1752
1766
|
maxTokens: input.policy.maxTokens,
|
|
1753
1767
|
}, warnings);
|
|
1754
1768
|
const response = await withTimeout(provider.generate({
|
|
1769
|
+
signal: input.signal,
|
|
1755
1770
|
messages: [...messages],
|
|
1756
1771
|
maxTokens: input.policy.maxTokens,
|
|
1757
1772
|
stream: input.streaming?.enabled,
|
|
@@ -1916,6 +1931,40 @@ export const createCodaliRuntime = (input) => ({
|
|
|
1916
1931
|
run: () => runCodaliTask(input),
|
|
1917
1932
|
});
|
|
1918
1933
|
export const runCodaliTask = async (input) => {
|
|
1934
|
+
if (!input.orchestration)
|
|
1935
|
+
return runCodaliTaskWithinScope(input);
|
|
1936
|
+
const configured = input.orchestration;
|
|
1937
|
+
validateOrchestrationConfig(configured.resolved.config);
|
|
1938
|
+
if (orchestrationHash(configured.resolved.config) !== configured.resolved.hash)
|
|
1939
|
+
throw new Error("Orchestration configuration changed after resolution");
|
|
1940
|
+
if (input.providerInstance)
|
|
1941
|
+
throw new Error("Configured orchestration cannot be bypassed by a provider override");
|
|
1942
|
+
if (input.subagents?.enabled)
|
|
1943
|
+
throw new Error("Configured orchestration requires controller-managed helper bindings; legacy subagents must be disabled");
|
|
1944
|
+
const scope = configured.scope ?? new ConfiguredModelScope(configured.resolved, { effort: configured.effort, signal: input.signal, caller: configured.caller });
|
|
1945
|
+
try {
|
|
1946
|
+
if (scope.configHash !== configured.resolved.hash || (configured.effort !== undefined && scope.effort !== configured.effort))
|
|
1947
|
+
throw new Error("Parent orchestration scope does not match configuration or effort");
|
|
1948
|
+
if (configured.caller && !scope.matchesCaller(configured.caller))
|
|
1949
|
+
throw new Error("Parent orchestration scope does not match caller identity");
|
|
1950
|
+
const budget = scope.budget();
|
|
1951
|
+
const signals = [scope.signal, input.signal, input.toolContext?.signal].filter((value) => Boolean(value));
|
|
1952
|
+
return await runCodaliTaskWithinScope({ ...input, signal: AbortSignal.any(signals), policy: { ...input.policy,
|
|
1953
|
+
maxSteps: Math.min(input.policy.maxSteps, budget.maxSteps),
|
|
1954
|
+
maxToolCalls: Math.min(input.policy.maxToolCalls, budget.maxToolCalls),
|
|
1955
|
+
maxTokens: Math.min(input.policy.maxTokens ?? budget.maxOutputTokens, budget.maxOutputTokens),
|
|
1956
|
+
timeoutMs: Math.min(input.policy.timeoutMs, budget.timeoutMs),
|
|
1957
|
+
} }, scope);
|
|
1958
|
+
}
|
|
1959
|
+
finally {
|
|
1960
|
+
if (!configured.scope)
|
|
1961
|
+
scope.close();
|
|
1962
|
+
}
|
|
1963
|
+
};
|
|
1964
|
+
const runCodaliTaskWithinScope = async (input, scope) => {
|
|
1965
|
+
input.signal?.throwIfAborted();
|
|
1966
|
+
if (input.requiredRetrieval && input.policy.mode !== "protocol_loop")
|
|
1967
|
+
throw new Error("Required retrieval needs protocol_loop mode");
|
|
1919
1968
|
const runId = input.metadata?.requestId ?? randomUUID();
|
|
1920
1969
|
const touchedFiles = new Set();
|
|
1921
1970
|
const warnings = [];
|
|
@@ -1927,16 +1976,31 @@ export const runCodaliTask = async (input) => {
|
|
|
1927
1976
|
events.push(event);
|
|
1928
1977
|
emitRuntimeEvent(event, input.onEvent, warnings);
|
|
1929
1978
|
};
|
|
1930
|
-
const
|
|
1979
|
+
const routes = [];
|
|
1980
|
+
const selected = input.requiredRetrieval ? requiredRetrievalProvider(input.requiredRetrieval, `${runId}:required-tools`)
|
|
1981
|
+
: scope ? scope.provider(input.orchestration?.binding ?? "lead") : input.providerInstance ?? createRuntimeProvider(input.provider);
|
|
1982
|
+
const provider = scope ? { ...selected, generate: async (request) => {
|
|
1983
|
+
const response = await selected.generate(request);
|
|
1984
|
+
if (response.route)
|
|
1985
|
+
routes.push(response.route);
|
|
1986
|
+
return response;
|
|
1987
|
+
} } : selected;
|
|
1988
|
+
const orchestration = () => scope ? { configHash: scope.configHash, routes, cumulativeUsage: scope.snapshot(), cumulativeToolCalls: scope.toolsUsed } : undefined;
|
|
1931
1989
|
const registry = buildRuntimeToolRegistry(input, dynamicToolState, warnings);
|
|
1932
1990
|
const originalRecordTouchedFile = input.toolContext?.recordTouchedFile;
|
|
1933
1991
|
const toolContext = {
|
|
1934
1992
|
...input.toolContext,
|
|
1993
|
+
signal: input.signal ?? input.toolContext?.signal,
|
|
1935
1994
|
workspaceRoot: input.workspace.root,
|
|
1936
1995
|
runId: input.toolContext?.runId ?? runId,
|
|
1937
1996
|
allowOutsideWorkspace: input.policy.allowOutsideWorkspace,
|
|
1938
1997
|
allowShell: input.policy.allowShell,
|
|
1939
1998
|
allowDestructiveOperations: input.policy.allowDestructiveOperations,
|
|
1999
|
+
beforeTool: scope ? async (...args) => {
|
|
2000
|
+
scope.reserveTool();
|
|
2001
|
+
await input.toolContext?.beforeTool?.(...args);
|
|
2002
|
+
input.signal?.throwIfAborted();
|
|
2003
|
+
} : input.toolContext?.beforeTool,
|
|
1940
2004
|
recordTouchedFile: (filePath) => {
|
|
1941
2005
|
touchedFiles.add(filePath);
|
|
1942
2006
|
originalRecordTouchedFile?.(filePath);
|
|
@@ -1976,6 +2040,7 @@ export const runCodaliTask = async (input) => {
|
|
|
1976
2040
|
await appendSessionEvent(session, runId, "final", { content: result.finalMessage.content }, warnings);
|
|
1977
2041
|
const finalSession = await compactRuntimeSession(session, "completed", warnings);
|
|
1978
2042
|
return {
|
|
2043
|
+
orchestration: orchestration(),
|
|
1979
2044
|
finalMessage: result.finalMessage.content,
|
|
1980
2045
|
messages: result.messages,
|
|
1981
2046
|
toolCallsExecuted: result.toolCallsExecuted,
|
|
@@ -2008,6 +2073,9 @@ export const runCodaliTask = async (input) => {
|
|
|
2008
2073
|
}
|
|
2009
2074
|
}
|
|
2010
2075
|
const runner = new Runner({
|
|
2076
|
+
signal: input.signal,
|
|
2077
|
+
continueAfterFinal: input.continueAfterFinal,
|
|
2078
|
+
onMessages: input.onMessages,
|
|
2011
2079
|
provider,
|
|
2012
2080
|
tools: registry,
|
|
2013
2081
|
context: toolContext,
|
|
@@ -2037,6 +2105,7 @@ export const runCodaliTask = async (input) => {
|
|
|
2037
2105
|
await appendSessionEvent(session, runId, "final", { content: result.finalMessage.content }, warnings);
|
|
2038
2106
|
const finalSession = await compactRuntimeSession(session, "completed", warnings);
|
|
2039
2107
|
return {
|
|
2108
|
+
orchestration: orchestration(),
|
|
2040
2109
|
finalMessage: result.finalMessage.content,
|
|
2041
2110
|
messages: result.messages,
|
|
2042
2111
|
toolCallsExecuted: result.toolCallsExecuted,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WorkState } from "../session/WorkTypes.js";
|
|
2
|
+
/** Delivery repeats accepted evidence instead of asking the model to introduce
|
|
3
|
+
* new factual claims after the goal has already passed review. */
|
|
4
|
+
export declare function completionReport(state: WorkState, budgetExhausted?: boolean): string;
|
|
5
|
+
//# sourceMappingURL=CompletionReport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompletionReport.d.ts","sourceRoot":"","sources":["../../src/runtime/CompletionReport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD;kEACkE;AAClE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,eAAe,UAAQ,GAAG,MAAM,CASlF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Delivery repeats accepted evidence instead of asking the model to introduce
|
|
2
|
+
* new factual claims after the goal has already passed review. */
|
|
3
|
+
export function completionReport(state, budgetExhausted = false) {
|
|
4
|
+
const accepted = new Set(state.tasks.filter(task => task.status === "verified").flatMap(task => task.evidenceIds));
|
|
5
|
+
const summaries = [...new Set(state.evidence.filter(item => accepted.has(item.id) && item.kind === "review" && item.ok)
|
|
6
|
+
.map(item => item.summary.trim()).filter(Boolean))];
|
|
7
|
+
const heading = state.projectTask ? "Execution verified and submitted for mcoda review." : "Required work completed with recorded verification evidence.";
|
|
8
|
+
const selected = summaries.slice(-5).map(summary => summary.length <= 2000 ? summary : summary.slice(0, 2000) + "\n[Summary shortened; full evidence is retained in the session.]");
|
|
9
|
+
const more = summaries.length > selected.length ? `\n\n${summaries.length - selected.length} additional accepted task summaries are retained in the session.` : "";
|
|
10
|
+
return heading + (selected.length ? "\n\n" + selected.join("\n\n") : "") + more
|
|
11
|
+
+ (budgetExhausted ? "\n\nThe model budget was exhausted; this report uses the recorded verification evidence." : "");
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Counts unchanged local operations, not wall-clock-dependent tool diagnostics.
|
|
2
|
+
* A changed input or task attempt gets its own counter. Controls/remote polling
|
|
3
|
+
* are excluded: repetition alone does not prove those operations stalled. */
|
|
4
|
+
export declare class ProgressTracker {
|
|
5
|
+
private counts;
|
|
6
|
+
clear(): void;
|
|
7
|
+
observe(input: {
|
|
8
|
+
tool: string;
|
|
9
|
+
args: unknown;
|
|
10
|
+
ok: boolean;
|
|
11
|
+
hashes: Record<string, string>;
|
|
12
|
+
task?: unknown;
|
|
13
|
+
output: string;
|
|
14
|
+
errorCode?: string;
|
|
15
|
+
}): number;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ProgressTracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressTracker.d.ts","sourceRoot":"","sources":["../../src/runtime/ProgressTracker.ts"],"names":[],"mappings":"AAKA;;6EAE6E;AAC7E,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAA6B;IAC3C,KAAK,IAAI,IAAI;IACb,OAAO,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;CAYzJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
const canonical = (value) => Array.isArray(value) ? value.map(canonical)
|
|
3
|
+
: value && typeof value === "object" ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, entry]) => [key, canonical(entry)])) : value;
|
|
4
|
+
/** Counts unchanged local operations, not wall-clock-dependent tool diagnostics.
|
|
5
|
+
* A changed input or task attempt gets its own counter. Controls/remote polling
|
|
6
|
+
* are excluded: repetition alone does not prove those operations stalled. */
|
|
7
|
+
export class ProgressTracker {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.counts = new Map();
|
|
10
|
+
}
|
|
11
|
+
clear() { this.counts.clear(); }
|
|
12
|
+
observe(input) {
|
|
13
|
+
if (!["read_file", "list_files", "run_shell"].includes(input.tool) || input.ok && input.tool === "run_shell")
|
|
14
|
+
return 0;
|
|
15
|
+
const signature = createHash("sha256").update(JSON.stringify(canonical({
|
|
16
|
+
tool: input.tool, args: input.args, ok: input.ok, hashes: input.hashes, task: input.task,
|
|
17
|
+
// File/list results can change without a prior snapshot, e.g. a user edit.
|
|
18
|
+
observed: input.ok ? createHash("sha256").update(input.output).digest("hex") : input.errorCode,
|
|
19
|
+
}))).digest("hex");
|
|
20
|
+
const count = (this.counts.get(signature) ?? 0) + 1;
|
|
21
|
+
this.counts.delete(signature);
|
|
22
|
+
this.counts.set(signature, count);
|
|
23
|
+
if (this.counts.size > 512)
|
|
24
|
+
this.counts.delete(this.counts.keys().next().value);
|
|
25
|
+
return count;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Recognize only direct requests to add/extend tests. This is a conservative
|
|
2
|
+
* extra evidence check, not a natural-language requirement parser. The full
|
|
3
|
+
* request still goes to independent review. Existing-test execution alone is
|
|
4
|
+
* not evidence that the agent added requested regression coverage. */
|
|
5
|
+
export declare const requestsAddedTests: (requirements: readonly {
|
|
6
|
+
description: string;
|
|
7
|
+
}[]) => boolean;
|
|
8
|
+
export declare const isTestSourcePath: (file: string) => boolean;
|
|
9
|
+
export declare const assertRequestedTestEvidence: (requirements: readonly {
|
|
10
|
+
description: string;
|
|
11
|
+
}[], changedPaths: readonly string[], currentHashes: Record<string, string>, codeChanged: boolean) => void;
|
|
12
|
+
//# sourceMappingURL=RequestedTestEvidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequestedTestEvidence.d.ts","sourceRoot":"","sources":["../../src/runtime/RequestedTestEvidence.ts"],"names":[],"mappings":"AAAA;;;sEAGsE;AACtE,eAAO,MAAM,kBAAkB,GAAI,cAAc,SAAS;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,EAAE,KAAG,OAC4M,CAAC;AAEnS,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,OAI/C,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,cAAc,SAAS;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,EAAE,EAAE,cAAc,SAAS,MAAM,EAAE,EAAE,eAAe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,OAAO,KAAG,IAI5L,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Recognize only direct requests to add/extend tests. This is a conservative
|
|
2
|
+
* extra evidence check, not a natural-language requirement parser. The full
|
|
3
|
+
* request still goes to independent review. Existing-test execution alone is
|
|
4
|
+
* not evidence that the agent added requested regression coverage. */
|
|
5
|
+
export const requestsAddedTests = (requirements) => requirements.some(({ description }) => /(?:^\s*(?:[-*+]\s+|\d+[.)]\s+)?|[.!?;:,]\s*|\band\s+)(?:please\s+)?(?:add|write|create|extend|expand)\s+(?:(?:a|the|some|new|more|additional|meaningful|public|focused|unit|integration|regression|automated|end-to-end|e2e)\s+)*(?:tests?\b|test\s+(?:cases|coverage)\b)/im.test(description));
|
|
6
|
+
export const isTestSourcePath = (file) => {
|
|
7
|
+
const normalized = file.replace(/\\/g, '/');
|
|
8
|
+
if (!/\.(?:[cm]?[jt]sx?|py|rs|go|java|kt|rb|php|swift|cs|c|cpp|sh)$/.test(normalized))
|
|
9
|
+
return false;
|
|
10
|
+
return /(?:^|\/)(?:__tests__|tests?|specs?)(?:\/|$)|\.(?:test|spec)\.[^/]+$|(?:^|\/)test_[^/]+\.py$|_test\.(?:go|py|rs)$|(?:Test|Tests|Spec)\.(?:java|kt|cs|php|swift)$/.test(normalized);
|
|
11
|
+
};
|
|
12
|
+
export const assertRequestedTestEvidence = (requirements, changedPaths, currentHashes, codeChanged) => {
|
|
13
|
+
if (codeChanged && requestsAddedTests(requirements) && !changedPaths.some(file => isTestSourcePath(file) && /^[a-f0-9]{64}$/.test(currentHashes[file] ?? ''))) {
|
|
14
|
+
throw new Error('This task explicitly requires added or extended tests, but no test source has changed from the workspace baseline. Running an existing test does not satisfy that requirement. Add meaningful coverage, rerun the checks, then request verification again.');
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Provider } from "../providers/ProviderTypes.js";
|
|
2
|
+
export type RequiredRetrievalNeed = {
|
|
3
|
+
type: "docdex.search";
|
|
4
|
+
query: string;
|
|
5
|
+
limit: number;
|
|
6
|
+
} | {
|
|
7
|
+
type: "docdex.web";
|
|
8
|
+
query: string;
|
|
9
|
+
force_web: true;
|
|
10
|
+
};
|
|
11
|
+
/** Deterministic retrieval through the ordinary authorized tool loop; makes no model call. */
|
|
12
|
+
export declare function requiredRetrievalProvider(needs: readonly RequiredRetrievalNeed[], requestId: string): Provider;
|
|
13
|
+
//# sourceMappingURL=RequiredRetrieval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequiredRetrieval.d.ts","sourceRoot":"","sources":["../../src/runtime/RequiredRetrieval.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAE9D,MAAM,MAAM,qBAAqB,GAC7B;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC;AAE3D,8FAA8F;AAC9F,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,SAAS,qBAAqB,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,QAAQ,CAoB9G"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Deterministic retrieval through the ordinary authorized tool loop; makes no model call. */
|
|
2
|
+
export function requiredRetrievalProvider(needs, requestId) {
|
|
3
|
+
if (!Array.isArray(needs) || !needs.length || needs.length > 32)
|
|
4
|
+
throw new Error("Required retrieval needs must contain 1–32 entries");
|
|
5
|
+
for (const need of needs) {
|
|
6
|
+
if (!need || typeof need.query !== "string" || !need.query.trim() || need.query.length > 16000
|
|
7
|
+
|| (need.type !== "docdex.search" && need.type !== "docdex.web")
|
|
8
|
+
|| (need.type === "docdex.search" && (!Number.isSafeInteger(need.limit) || need.limit < 1 || need.limit > 100))
|
|
9
|
+
|| (need.type === "docdex.web" && need.force_web !== true))
|
|
10
|
+
throw new Error("Invalid required retrieval need");
|
|
11
|
+
}
|
|
12
|
+
const pinned = structuredClone(needs);
|
|
13
|
+
let requested = false;
|
|
14
|
+
return { name: "required-retrieval", async generate(request) {
|
|
15
|
+
request.signal?.throwIfAborted();
|
|
16
|
+
if (!requested) {
|
|
17
|
+
requested = true;
|
|
18
|
+
return { message: { role: "assistant", content: JSON.stringify({ version: "v1", role: "rag_worker", request_id: requestId, needs: pinned }) } };
|
|
19
|
+
}
|
|
20
|
+
const response = [...request.messages].reverse().find(message => message.role === "user" && message.content.startsWith("CODALI_RESPONSE v1"));
|
|
21
|
+
if (!response)
|
|
22
|
+
throw new Error("Required retrieval response missing");
|
|
23
|
+
return { message: { role: "assistant", content: response.content.replace(/^CODALI_RESPONSE v1\s*/, "") } };
|
|
24
|
+
} };
|
|
25
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Provider } from "../providers/ProviderTypes.js";
|
|
2
|
+
export interface ReviewContractSource {
|
|
3
|
+
id: string;
|
|
4
|
+
text: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ReviewContractCheck {
|
|
7
|
+
sourceId: string;
|
|
8
|
+
contractQuote: string;
|
|
9
|
+
expectedBehavior: string;
|
|
10
|
+
}
|
|
11
|
+
export type ReviewContractResult = {
|
|
12
|
+
checks: ReviewContractCheck[];
|
|
13
|
+
} | {
|
|
14
|
+
findings: string[];
|
|
15
|
+
};
|
|
16
|
+
export declare function reviewContractSources(context: {
|
|
17
|
+
goal?: string;
|
|
18
|
+
requirements: readonly {
|
|
19
|
+
id: string;
|
|
20
|
+
description: string;
|
|
21
|
+
}[];
|
|
22
|
+
constraints: readonly string[];
|
|
23
|
+
nonGoals: readonly string[];
|
|
24
|
+
}): ReviewContractSource[];
|
|
25
|
+
/** Bounded specification-only batches and one format repair per batch, through
|
|
26
|
+
* the same accounted provider as review. Every call retains all authoritative
|
|
27
|
+
* sources; implementation, test expectations and tools are never sent. */
|
|
28
|
+
export declare function prepareReviewContract(options: {
|
|
29
|
+
provider: Provider;
|
|
30
|
+
sources: readonly ReviewContractSource[];
|
|
31
|
+
maxInputChars: number;
|
|
32
|
+
maxOutputTokens?: number;
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
}): Promise<ReviewContractResult>;
|
|
35
|
+
//# sourceMappingURL=ReviewContract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReviewContract.d.ts","sourceRoot":"","sources":["../../src/runtime/ReviewContract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,+BAA+B,CAAC;AAE/E,MAAM,WAAW,oBAAoB;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AAClE,MAAM,WAAW,mBAAmB;IAAG,QAAQ,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE;AAC1G,MAAM,MAAM,oBAAoB,GAAG;IAAE,MAAM,EAAE,mBAAmB,EAAE,CAAA;CAAE,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE9F,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,SAAS;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC7D,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B,GAAG,oBAAoB,EAAE,CAWzB;AAuDD;;0EAE0E;AAC1E,wBAAsB,qBAAqB,CAAC,OAAO,EAAE;IACnD,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA2ChC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
export function reviewContractSources(context) {
|
|
2
|
+
const separateGoal = context.goal && !context.requirements.some(value => value.description === context.goal);
|
|
3
|
+
return [
|
|
4
|
+
...(separateGoal ? [{ id: "goal", text: context.goal }] : []),
|
|
5
|
+
// The current goal may contain the original objective and later steering
|
|
6
|
+
// verbatim. Keep those bytes once; the review still receives every criterion.
|
|
7
|
+
...context.requirements.filter(value => !separateGoal || !context.goal.includes(value.description))
|
|
8
|
+
.map(value => ({ id: `requirement:${value.id}`, text: value.description })),
|
|
9
|
+
...context.constraints.map((text, index) => ({ id: `constraint:${index}`, text })),
|
|
10
|
+
...context.nonGoals.map((text, index) => ({ id: `nonGoal:${index}`, text })),
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
const instruction = 'Prepare independent contract checks before seeing implementation, tests, diffs or claimed results. Use only the supplied authoritative sources. This is verification after authorized task execution; distinguish obligations that apply only during earlier planning. Preserve explicit error types, exact messages, schema fields, defaults, boundaries, side-effect rules and temporal/conditional qualifications. Do not invent behavior or relax quoted literals into substring matches. Reply exactly JSON {"checks":[{"sourceId":string,"quoteIndex":integer,"expectedBehavior":string}]}. Each source contains an excerpts array of {quoteIndex,text} objects: concatenating text in order reconstructs its complete original text without changes. Read them together; excerpt boundaries do not separate or qualify obligations. quoteIndex is the explicit numeric label on the supporting excerpt in that identified source. Copy that label; do not count excerpts or infer an index from another source. Select the index instead of copying or rewriting the quotation; the controller supplies the exact source bytes. When targetSourceIds is supplied, generate checks only for those sources; all supplied sources remain authoritative context for interpreting conditions and qualifications. Include at least one check for every targeted source (every source when no targets are given), and enough checks to cover its distinct obligations. Multiple checks may cite the same excerpt. Keep each expectedBehavior concise; avoid repeating the same obligation. expectedBehavior states a concrete observable check, not an approval. These checks are an aid, never a replacement for the complete original contract. No tools.';
|
|
14
|
+
/** Lossless source slices; preserve whitespace and never split a surrogate pair. */
|
|
15
|
+
function sourceExcerpts(text) {
|
|
16
|
+
const excerpts = [];
|
|
17
|
+
for (let offset = 0; offset < text.length;) {
|
|
18
|
+
let end = Math.min(offset + 512, text.length);
|
|
19
|
+
if (end < text.length) {
|
|
20
|
+
const boundary = Math.max(text.lastIndexOf("\n", end - 1), text.lastIndexOf(" ", end - 1), text.lastIndexOf("\t", end - 1));
|
|
21
|
+
if (boundary >= offset + 256)
|
|
22
|
+
end = boundary + 1;
|
|
23
|
+
const last = text.charCodeAt(end - 1);
|
|
24
|
+
if (last >= 0xD800 && last <= 0xDBFF)
|
|
25
|
+
end--;
|
|
26
|
+
}
|
|
27
|
+
excerpts.push(text.slice(offset, end));
|
|
28
|
+
offset = end;
|
|
29
|
+
}
|
|
30
|
+
return excerpts;
|
|
31
|
+
}
|
|
32
|
+
function validate(value, sources) {
|
|
33
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
34
|
+
throw new Error("Expected a checklist object");
|
|
35
|
+
const checks = value.checks;
|
|
36
|
+
if (!Array.isArray(checks) || !checks.length || checks.length > 256)
|
|
37
|
+
throw new Error("Expected one to 256 checks");
|
|
38
|
+
const seen = new Set();
|
|
39
|
+
const normalized = [];
|
|
40
|
+
for (const [index, check] of checks.entries()) {
|
|
41
|
+
if (!check || typeof check !== "object" || Array.isArray(check))
|
|
42
|
+
throw new Error("Invalid check object");
|
|
43
|
+
const source = sources.find(item => item.id === check.sourceId);
|
|
44
|
+
if (!source)
|
|
45
|
+
throw new Error("Check " + index + " does not identify a targeted authoritative source");
|
|
46
|
+
let quote = check.contractQuote;
|
|
47
|
+
if (Object.prototype.hasOwnProperty.call(check, "quoteIndex")) {
|
|
48
|
+
const excerpts = sourceExcerpts(source.text);
|
|
49
|
+
if (!Number.isInteger(check.quoteIndex) || check.quoteIndex < 0 || check.quoteIndex >= excerpts.length) {
|
|
50
|
+
throw new Error("Check " + index + " has an invalid excerpt index");
|
|
51
|
+
}
|
|
52
|
+
quote = excerpts[check.quoteIndex];
|
|
53
|
+
if (Object.prototype.hasOwnProperty.call(check, "contractQuote") && check.contractQuote !== quote) {
|
|
54
|
+
throw new Error("Check " + index + " conflicts with its selected source excerpt");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Older provider fixtures/responses remain accepted only with exact quotes.
|
|
58
|
+
if (typeof quote !== "string" || !quote.trim() || quote.length > 2048 || !source.text.includes(quote)) {
|
|
59
|
+
throw new Error("Each check needs an exact quote from its identified source");
|
|
60
|
+
}
|
|
61
|
+
if (typeof check.expectedBehavior !== "string" || !check.expectedBehavior.trim() || check.expectedBehavior.length > 4000) {
|
|
62
|
+
throw new Error("Each check needs a bounded expected behavior");
|
|
63
|
+
}
|
|
64
|
+
seen.add(source.id);
|
|
65
|
+
normalized.push({ sourceId: source.id, contractQuote: quote, expectedBehavior: check.expectedBehavior });
|
|
66
|
+
}
|
|
67
|
+
if (sources.some(source => !seen.has(source.id)))
|
|
68
|
+
throw new Error("The checklist omitted an authoritative source");
|
|
69
|
+
return normalized;
|
|
70
|
+
}
|
|
71
|
+
/** Bounded specification-only batches and one format repair per batch, through
|
|
72
|
+
* the same accounted provider as review. Every call retains all authoritative
|
|
73
|
+
* sources; implementation, test expectations and tools are never sent. */
|
|
74
|
+
export async function prepareReviewContract(options) {
|
|
75
|
+
const reject = (message) => ({ findings: [message] });
|
|
76
|
+
if (!options.sources.length || options.sources.length > 256 || new Set(options.sources.map(source => source.id)).size !== options.sources.length
|
|
77
|
+
|| options.sources.some(source => !source.id.trim() || !source.text.trim())) {
|
|
78
|
+
return reject("Contract review requires distinct, nonempty authoritative sources; acceptance is not established.");
|
|
79
|
+
}
|
|
80
|
+
const batches = [];
|
|
81
|
+
let batch = [];
|
|
82
|
+
let chars = 0;
|
|
83
|
+
const targetChars = Math.max(1024, Math.floor((options.maxOutputTokens ?? 4096) / 2));
|
|
84
|
+
for (const source of options.sources) {
|
|
85
|
+
if (batch.length && chars + source.text.length > targetChars) {
|
|
86
|
+
batches.push(batch);
|
|
87
|
+
batch = [];
|
|
88
|
+
chars = 0;
|
|
89
|
+
}
|
|
90
|
+
batch.push(source);
|
|
91
|
+
chars += source.text.length;
|
|
92
|
+
}
|
|
93
|
+
if (batch.length)
|
|
94
|
+
batches.push(batch);
|
|
95
|
+
if (batches.length > 16)
|
|
96
|
+
return reject("Contract preparation requires too many bounded batches. Split the task or select a larger compatible reviewer; acceptance is not established.");
|
|
97
|
+
const contractSources = options.sources.map(source => ({ id: source.id,
|
|
98
|
+
excerpts: sourceExcerpts(source.text).map((text, quoteIndex) => ({ quoteIndex, text })) }));
|
|
99
|
+
const checks = [];
|
|
100
|
+
for (const targets of batches) {
|
|
101
|
+
const messages = [
|
|
102
|
+
{ role: "system", content: instruction },
|
|
103
|
+
{ role: "user", content: JSON.stringify({ contractSources,
|
|
104
|
+
...(batches.length > 1 ? { targetSourceIds: targets.map(source => source.id) } : {}) }) },
|
|
105
|
+
];
|
|
106
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
107
|
+
options.signal?.throwIfAborted();
|
|
108
|
+
if (JSON.stringify(messages).length > options.maxInputChars) {
|
|
109
|
+
return reject("Required contract checks exceed the configured review context. Split the task or select a larger compatible reviewer; acceptance is not established.");
|
|
110
|
+
}
|
|
111
|
+
// Parse locally so malformed output and usage reach the accounted caller.
|
|
112
|
+
const response = await options.provider.generate({ messages, signal: options.signal, maxTokens: options.maxOutputTokens ?? 4096 });
|
|
113
|
+
options.signal?.throwIfAborted();
|
|
114
|
+
if (response.toolCalls?.length || response.message.toolCalls?.length)
|
|
115
|
+
return reject("Contract preparation returned an unsupported tool call; acceptance is not established.");
|
|
116
|
+
try {
|
|
117
|
+
checks.push(...validate(JSON.parse(response.message.content), targets));
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
const detail = error instanceof SyntaxError ? "Response is not valid JSON" : error instanceof Error ? error.message : "Invalid checklist";
|
|
122
|
+
if (attempt === 1)
|
|
123
|
+
return reject(`Contract preparation failed validation: ${detail}. Acceptance is not established.`);
|
|
124
|
+
messages.push({ role: "assistant", content: response.message.content });
|
|
125
|
+
messages.push({ role: "user", content: `Return a corrected complete checklist for the same targets using the original sources. Validation failure: ${detail}. Preserve every original obligation; do not return an acceptance verdict.` });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (checks.length > 256)
|
|
129
|
+
return reject("Contract preparation exceeded the bounded checklist size; acceptance is not established.");
|
|
130
|
+
}
|
|
131
|
+
return { checks };
|
|
132
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Provider } from "../providers/ProviderTypes.js";
|
|
2
|
+
import type { WorkTask } from "../session/WorkTypes.js";
|
|
3
|
+
import { type taskReviewContext } from "./TaskReviewContext.js";
|
|
4
|
+
import { type ReviewSourcePage, type TaskReviewResult } from "./TaskReview.js";
|
|
5
|
+
export interface TaskReviewAssessment {
|
|
6
|
+
taskId: string;
|
|
7
|
+
criterionIds: string[];
|
|
8
|
+
sourcePaths: string[];
|
|
9
|
+
workspaceSnapshotHash: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function reviewWorkspaceHash(hashes: Readonly<Record<string, string>>): string;
|
|
12
|
+
/** Review one scope without loading every sibling's source into the prompt.
|
|
13
|
+
* Assessments are created only by the controller after separate successful
|
|
14
|
+
* reviews; the caller must fence the complete snapshot before accepting them. */
|
|
15
|
+
export declare function reviewTaskScope(options: {
|
|
16
|
+
provider: Provider;
|
|
17
|
+
scope: ReturnType<typeof taskReviewContext>;
|
|
18
|
+
task: WorkTask;
|
|
19
|
+
hashes: Record<string, string>;
|
|
20
|
+
receipts: readonly {
|
|
21
|
+
id: string;
|
|
22
|
+
tool: string;
|
|
23
|
+
args: unknown;
|
|
24
|
+
status: string;
|
|
25
|
+
output?: string;
|
|
26
|
+
taskId?: string;
|
|
27
|
+
}[];
|
|
28
|
+
preExistingDirtyPaths?: string[];
|
|
29
|
+
summary: string;
|
|
30
|
+
assessments?: readonly TaskReviewAssessment[];
|
|
31
|
+
readSource: (file: string, maxChars: number) => Promise<{
|
|
32
|
+
content: string;
|
|
33
|
+
truncated: boolean;
|
|
34
|
+
}>;
|
|
35
|
+
readSourcePage: (file: string, offset: number) => Promise<ReviewSourcePage>;
|
|
36
|
+
diff: (files: string[]) => Promise<string>;
|
|
37
|
+
maxInputChars: number;
|
|
38
|
+
maxOutputTokens: number;
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
}): Promise<TaskReviewResult>;
|
|
41
|
+
//# sourceMappingURL=ReviewCoordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReviewCoordinator.d.ts","sourceRoot":"","sources":["../../src/runtime/ReviewCoordinator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,+BAA+B,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAuB,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAiB,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAG9F,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAGpF;AAWD;;iFAEiF;AACjF,wBAAsB,eAAe,CAAC,OAAO,EAAE;IAC7C,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC5C,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,QAAQ,EAAE,SAAS;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACnH,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC9C,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACjG,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC5E,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAsF5B"}
|