@mcoda/mswarm 0.1.133 → 0.1.135-codali.10
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 +44 -0
- package/dist/codali-executor.d.ts +79 -1
- package/dist/codali-executor.d.ts.map +1 -1
- package/dist/codali-executor.js +115 -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 +25 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +226 -22
- 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 +16 -4
- 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/gateway/LocalGatewayTaskRunner.d.ts.map +1 -1
- package/dist/vendor/codali/gateway/LocalGatewayTaskRunner.js +13 -1
- 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 +117 -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 +14 -0
- package/dist/vendor/codali/providers/ModelServiceError.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ModelServiceError.js +67 -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 +140 -52
- package/dist/vendor/codali/providers/ProviderTypes.d.ts +16 -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 +31 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/CodaliRuntime.js +72 -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 +131 -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 +81 -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 +13 -0
- package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/Runner.js +225 -158
- 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
|
@@ -14,6 +14,7 @@ const DOCDEX_WRITE_TOOLS = new Set([
|
|
|
14
14
|
"docdex_memory_save",
|
|
15
15
|
"docdex_save_preference",
|
|
16
16
|
"docdex_delegate",
|
|
17
|
+
"docdex_diary_write",
|
|
17
18
|
]);
|
|
18
19
|
/**
|
|
19
20
|
* Docdex is one capability from the orchestrator's point of view, except web
|
|
@@ -313,7 +314,21 @@ const withDocdexMetadata = (tools) => tools.map((tool) => ({
|
|
|
313
314
|
readOnly: tool.readOnly ?? !DOCDEX_WRITE_TOOLS.has(tool.name),
|
|
314
315
|
capability: tool.capability ?? docdexCapabilityFor(tool.name),
|
|
315
316
|
}));
|
|
316
|
-
export const createDocdexTools = (client, options = {}) => withDocdexMetadata(docdexToolDefinitions(client, options));
|
|
317
|
+
export const createDocdexTools = (client, options = {}) => withDocdexMetadata([...docdexToolDefinitions(client, options), ...continuityTools(client)]);
|
|
318
|
+
const continuityTools = (client) => {
|
|
319
|
+
const single = (name, description, key, call) => ({
|
|
320
|
+
name, description, inputSchema: { type: "object", properties: { [key]: { type: "string", minLength: 1, maxLength: 12000 } }, required: [key], additionalProperties: false },
|
|
321
|
+
handler: async (args) => toOutput(await call(args[key])),
|
|
322
|
+
});
|
|
323
|
+
return [
|
|
324
|
+
single("docdex_wakeup", "Read bounded continuity context for this repository and agent. Canonical goal and authorization remain authoritative.", "query", query => client.wakeup(query)),
|
|
325
|
+
single("docdex_conversation_search", "Find source-linked prior conversation records in this repository.", "query", query => client.conversationSearch(query)),
|
|
326
|
+
single("docdex_conversation_read", "Read a prior repository conversation by its returned session ID.", "sessionId", id => client.conversationRead(id)),
|
|
327
|
+
single("docdex_kg_query", "Inspect temporal knowledge-graph facts and provenance for this repository.", "query", query => client.knowledgeQuery(query)),
|
|
328
|
+
single("docdex_diary_write", "Save a concise durable handoff with the current goal, observed outcome and next action. Requires memory-write permission.", "content", content => client.diaryWrite(content)),
|
|
329
|
+
{ name: "docdex_diary_read", description: "Read the agent's recent durable repository handoffs.", inputSchema: { type: "object", properties: {}, additionalProperties: false }, handler: async () => toOutput(await client.diaryRead()) },
|
|
330
|
+
];
|
|
331
|
+
};
|
|
317
332
|
const docdexToolDefinitions = (client, options) => [
|
|
318
333
|
{
|
|
319
334
|
name: "docdex_health",
|
|
@@ -377,7 +392,7 @@ const docdexToolDefinitions = (client, options) => [
|
|
|
377
392
|
}
|
|
378
393
|
}
|
|
379
394
|
const webQuery = normalizeWebQuery(query);
|
|
380
|
-
if (!localAnswers && webQuery && !webResearchBlocked()) {
|
|
395
|
+
if (options.allowSearchWebFallback !== false && !localAnswers && webQuery && !webResearchBlocked()) {
|
|
381
396
|
try {
|
|
382
397
|
const web = await client.search(webQuery, { limit, forceWeb: true });
|
|
383
398
|
if (hasWebFindings(web)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileTools.d.ts","sourceRoot":"","sources":["../../../src/tools/filesystem/FileTools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"FileTools.d.ts","sourceRoot":"","sources":["../../../src/tools/filesystem/FileTools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA8EnE,eAAO,MAAM,eAAe,QAAO,cAAc,EAkGhD,CAAC"}
|
|
@@ -1,18 +1,36 @@
|
|
|
1
|
-
import { promises as fs } from "node:fs";
|
|
1
|
+
import { promises as fs, realpathSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
const resolveWorkspacePath = (context, targetPath) => {
|
|
3
|
+
const resolveWorkspacePath = async (context, targetPath) => {
|
|
4
4
|
const resolved = path.resolve(context.workspaceRoot, targetPath);
|
|
5
5
|
if (context.allowOutsideWorkspace) {
|
|
6
6
|
return resolved;
|
|
7
7
|
}
|
|
8
8
|
const relative = path.relative(context.workspaceRoot, resolved);
|
|
9
|
-
if (relative.startsWith(
|
|
9
|
+
if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
|
10
10
|
throw new Error("Path is outside the workspace root");
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
const root = await fs.realpath(context.workspaceRoot);
|
|
13
|
+
let existing = resolved;
|
|
14
|
+
const suffix = [];
|
|
15
|
+
while (true) {
|
|
16
|
+
try {
|
|
17
|
+
const real = await fs.realpath(existing);
|
|
18
|
+
const actual = path.join(real, ...suffix.reverse());
|
|
19
|
+
const rel = path.relative(root, actual);
|
|
20
|
+
if (rel === ".." || rel.startsWith(`..${path.sep}`) || path.isAbsolute(rel))
|
|
21
|
+
throw new Error("Symlink path is outside the workspace root");
|
|
22
|
+
return actual;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (error.code !== "ENOENT" || existing === path.dirname(existing))
|
|
26
|
+
throw error;
|
|
27
|
+
suffix.push(path.basename(existing));
|
|
28
|
+
existing = path.dirname(existing);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
13
31
|
};
|
|
14
32
|
const toRelative = (context, targetPath) => {
|
|
15
|
-
return path.relative(context.workspaceRoot, targetPath) || ".";
|
|
33
|
+
return path.relative(realpathSync.native(context.workspaceRoot), targetPath) || ".";
|
|
16
34
|
};
|
|
17
35
|
const normalizeScope = (value) => {
|
|
18
36
|
const normalized = path.posix.normalize(value.replace(/\\/g, "/")).replace(/^\/+/, "");
|
|
@@ -66,10 +84,11 @@ export const createFileTools = () => {
|
|
|
66
84
|
},
|
|
67
85
|
handler: async (args, context) => {
|
|
68
86
|
const { path: target } = args;
|
|
69
|
-
const resolved = resolveWorkspacePath(context, target);
|
|
87
|
+
const resolved = await resolveWorkspacePath(context, target);
|
|
70
88
|
assertPathScope(context, resolved, context.allowedReadPaths, "read");
|
|
89
|
+
await context.checkPath?.(resolved, "read");
|
|
71
90
|
const content = await fs.readFile(resolved, "utf8");
|
|
72
|
-
return { output: content };
|
|
91
|
+
return { output: content, data: { path: toRelative(context, resolved) } };
|
|
73
92
|
},
|
|
74
93
|
},
|
|
75
94
|
{
|
|
@@ -87,8 +106,9 @@ export const createFileTools = () => {
|
|
|
87
106
|
},
|
|
88
107
|
handler: async (args, context) => {
|
|
89
108
|
const { path: target, content } = args;
|
|
90
|
-
const resolved = resolveWorkspacePath(context, target);
|
|
109
|
+
const resolved = await resolveWorkspacePath(context, target);
|
|
91
110
|
assertPathScope(context, resolved, context.allowedWritePaths, "write");
|
|
111
|
+
await context.checkPath?.(resolved, "write");
|
|
92
112
|
await fs.mkdir(path.dirname(resolved), { recursive: true });
|
|
93
113
|
await fs.writeFile(resolved, content, "utf8");
|
|
94
114
|
if (context.recordTouchedFile) {
|
|
@@ -111,7 +131,7 @@ export const createFileTools = () => {
|
|
|
111
131
|
},
|
|
112
132
|
handler: async (args, context) => {
|
|
113
133
|
const { path: target = ".", maxDepth = 2 } = args ?? {};
|
|
114
|
-
const resolved = resolveWorkspacePath(context, target);
|
|
134
|
+
const resolved = await resolveWorkspacePath(context, target);
|
|
115
135
|
assertPathScope(context, resolved, context.allowedReadPaths, "read");
|
|
116
136
|
const entries = await listFilesRecursive(resolved, maxDepth);
|
|
117
137
|
const relativeEntries = entries.map((entry) => toRelative(context, entry));
|
|
@@ -132,7 +152,7 @@ export const createFileTools = () => {
|
|
|
132
152
|
},
|
|
133
153
|
handler: async (args, context) => {
|
|
134
154
|
const { path: target } = args;
|
|
135
|
-
const resolved = resolveWorkspacePath(context, target);
|
|
155
|
+
const resolved = await resolveWorkspacePath(context, target);
|
|
136
156
|
assertPathScope(context, resolved, context.allowedReadPaths, "read");
|
|
137
157
|
const stats = await fs.stat(resolved);
|
|
138
158
|
const info = {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ToolContext, type ToolHandlerResult } from "../ToolTypes.js";
|
|
2
|
+
export declare const safeProcessEnvironment: () => NodeJS.ProcessEnv;
|
|
3
|
+
/** Host executor settings, never populated from model-supplied tool arguments. */
|
|
4
|
+
export interface ProcessEnvironment {
|
|
5
|
+
HOME?: string;
|
|
6
|
+
TMPDIR?: string;
|
|
7
|
+
PATH?: string;
|
|
8
|
+
CARGO_HOME?: string;
|
|
9
|
+
XDG_CACHE_HOME?: string;
|
|
10
|
+
PYTHONPYCACHEPREFIX?: string;
|
|
11
|
+
PYTHONUSERBASE?: string;
|
|
12
|
+
SDKROOT?: string;
|
|
13
|
+
DEVELOPER_DIR?: string;
|
|
14
|
+
GIT_CONFIG_NOSYSTEM?: string;
|
|
15
|
+
GIT_CONFIG_GLOBAL?: string;
|
|
16
|
+
GIT_ATTR_NOSYSTEM?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const runProcess: (command: string, args: string[], context: ToolContext, environment?: ProcessEnvironment) => Promise<ToolHandlerResult>;
|
|
19
|
+
//# sourceMappingURL=AsyncProcess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncProcess.d.ts","sourceRoot":"","sources":["../../../src/tools/shell/AsyncProcess.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAG/F,eAAO,MAAM,sBAAsB,QAAO,MAAM,CAAC,UAGhD,CAAC;AAEF,kFAAkF;AAClF,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACpG,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IACzC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACtF;AAED,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,MAAM,MAAM,EAAE,EAAE,SAAS,WAAW,EAAE,cAAa,kBAAuB,KAAG,OAAO,CAAC,iBAAiB,CAgDjJ,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { StringDecoder } from "node:string_decoder";
|
|
3
|
+
import { ToolExecutionError } from "../ToolTypes.js";
|
|
4
|
+
import { resolveShellWorkingDirectory } from "./ShellWorkingDirectory.js";
|
|
5
|
+
export const safeProcessEnvironment = () => Object.fromEntries(["PATH", "LANG", "LC_ALL", "LC_CTYPE", "TERM", "TZ", "TMPDIR", "SYSTEMROOT", "WINDIR", "COMSPEC", "PATHEXT"]
|
|
6
|
+
.filter(key => process.env[key] !== undefined).map(key => [key, process.env[key]]));
|
|
7
|
+
export const runProcess = (command, args, context, environment = {}) => {
|
|
8
|
+
context.signal?.throwIfAborted();
|
|
9
|
+
const timeoutMs = context.shellTimeoutMs ?? 120000;
|
|
10
|
+
const maxBytes = context.shellMaxOutputBytes ?? 1048576;
|
|
11
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0 || !Number.isSafeInteger(maxBytes) || maxBytes <= 0)
|
|
12
|
+
throw new Error("Invalid process limits");
|
|
13
|
+
const cwd = resolveShellWorkingDirectory(context.workspaceRoot, context.shellWorkingDirectory);
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
const group = process.platform !== "win32";
|
|
16
|
+
const env = safeProcessEnvironment();
|
|
17
|
+
for (const key of ["HOME", "TMPDIR", "PATH", "CARGO_HOME", "XDG_CACHE_HOME", "PYTHONPYCACHEPREFIX", "PYTHONUSERBASE", "SDKROOT", "DEVELOPER_DIR", "GIT_CONFIG_NOSYSTEM", "GIT_CONFIG_GLOBAL", "GIT_ATTR_NOSYSTEM"])
|
|
18
|
+
if (typeof environment[key] === "string")
|
|
19
|
+
env[key] = environment[key];
|
|
20
|
+
const child = spawn(command, args, { cwd, env, detached: group, stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
|
|
21
|
+
let stdout = "";
|
|
22
|
+
let stderr = "";
|
|
23
|
+
let captured = 0;
|
|
24
|
+
let truncated = false;
|
|
25
|
+
let timedOut = false;
|
|
26
|
+
const decoders = { stdout: new StringDecoder("utf8"), stderr: new StringDecoder("utf8") };
|
|
27
|
+
let escalation;
|
|
28
|
+
const kill = (signal) => {
|
|
29
|
+
if (!child.pid)
|
|
30
|
+
return;
|
|
31
|
+
try {
|
|
32
|
+
if (group)
|
|
33
|
+
process.kill(-child.pid, signal);
|
|
34
|
+
else
|
|
35
|
+
child.kill(signal);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error.code !== "ESRCH")
|
|
39
|
+
child.kill(signal);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const stop = () => { kill("SIGTERM"); escalation ?? (escalation = setTimeout(() => kill("SIGKILL"), 1000)); escalation.unref(); };
|
|
43
|
+
const timeout = setTimeout(() => { timedOut = true; stop(); }, timeoutMs);
|
|
44
|
+
const append = (stream, text) => {
|
|
45
|
+
if (stream === "stdout")
|
|
46
|
+
stdout += text;
|
|
47
|
+
else
|
|
48
|
+
stderr += text;
|
|
49
|
+
if (text) {
|
|
50
|
+
try {
|
|
51
|
+
context.onOutput?.(stream, text);
|
|
52
|
+
}
|
|
53
|
+
catch { /* Rendering cannot abandon process cleanup. */ }
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const collect = (stream, chunk) => {
|
|
57
|
+
const remaining = Math.max(0, maxBytes - captured);
|
|
58
|
+
if (chunk.length > remaining)
|
|
59
|
+
truncated = true;
|
|
60
|
+
const text = decoders[stream].write(chunk.subarray(0, remaining));
|
|
61
|
+
captured += Math.min(chunk.length, remaining);
|
|
62
|
+
append(stream, text);
|
|
63
|
+
};
|
|
64
|
+
child.stdout.on("data", (chunk) => collect("stdout", chunk));
|
|
65
|
+
child.stderr.on("data", (chunk) => collect("stderr", chunk));
|
|
66
|
+
context.signal?.addEventListener("abort", stop, { once: true });
|
|
67
|
+
if (context.signal?.aborted)
|
|
68
|
+
stop();
|
|
69
|
+
const cleanup = () => { clearTimeout(timeout); if (escalation)
|
|
70
|
+
clearTimeout(escalation); context.signal?.removeEventListener("abort", stop); };
|
|
71
|
+
child.once("error", error => { cleanup(); reject(error); });
|
|
72
|
+
child.once("close", (exitCode, signal) => {
|
|
73
|
+
cleanup();
|
|
74
|
+
append("stdout", decoders.stdout.end());
|
|
75
|
+
append("stderr", decoders.stderr.end());
|
|
76
|
+
if (group)
|
|
77
|
+
kill("SIGKILL");
|
|
78
|
+
const details = { command, args, cwd, exitCode, signal, stdout, stderr, truncated, timedOut };
|
|
79
|
+
if (context.signal?.aborted) {
|
|
80
|
+
reject(context.signal.reason ?? new Error("Process cancelled"));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (timedOut) {
|
|
84
|
+
reject(new ToolExecutionError("tool_timeout", "Process deadline exceeded", { retryable: false, details }));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (exitCode !== 0 || signal) {
|
|
88
|
+
reject(new ToolExecutionError("tool_execution_failed", stderr || stdout || `Process terminated (${signal ?? exitCode})`, { retryable: false, details }));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
resolve({ output: (stdout || stderr) + (truncated ? "\n[output truncated]" : ""), data: details });
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HostRuntimeMount } from "./HostToolchain.js";
|
|
2
|
+
interface LoadCommands {
|
|
3
|
+
libraries: string[];
|
|
4
|
+
rpaths: string[];
|
|
5
|
+
}
|
|
6
|
+
/** Inspect installed binaries, never execute a runtime or import repository code. */
|
|
7
|
+
export declare const inspectMachOLibraries: (files: string[]) => Map<string, LoadCommands>;
|
|
8
|
+
export declare const parseMachOLoadCommands: (output: string, files: string[]) => Map<string, LoadCommands>;
|
|
9
|
+
/** Admit only concrete native dependencies, including symlink spellings used by
|
|
10
|
+
* dyld. Never grant a package-manager prefix, home, or arbitrary library folder. */
|
|
11
|
+
export declare const discoverDarwinRuntimeLibraries: (executable: string, extensionFiles: string[], workspace: string, home: string, inspect?: (files: string[]) => Map<string, LoadCommands>) => HostRuntimeMount[];
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=DarwinRuntimeLibraries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DarwinRuntimeLibraries.d.ts","sourceRoot":"","sources":["../../../src/tools/shell/DarwinRuntimeLibraries.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,UAAU,YAAY;IAAG,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAC;CAAE;AAIjE,qFAAqF;AACrF,eAAO,MAAM,qBAAqB,GAAI,OAAO,MAAM,EAAE,KAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAM/E,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM,EAAE,KAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAoBhG,CAAC;AAUF;oFACoF;AACpF,eAAO,MAAM,8BAA8B,GACzC,YAAY,MAAM,EAAE,gBAAgB,MAAM,EAAE,EAAE,WAAW,MAAM,EAAE,MAAM,MAAM,EAC7E,UAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,CAAC,MAAM,EAAE,YAAY,CAAyB,KAC9E,gBAAgB,EAiDlB,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { closeSync, openSync, readSync, realpathSync, statSync } from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
const within = (file, root) => file === root || file.startsWith(`${root}${path.sep}`);
|
|
6
|
+
const systemLibrary = (file) => within(file, "/usr/lib") || within(file, "/System");
|
|
7
|
+
/** Inspect installed binaries, never execute a runtime or import repository code. */
|
|
8
|
+
export const inspectMachOLibraries = (files) => {
|
|
9
|
+
const result = spawnSync("/usr/bin/otool", ["-l", ...files], {
|
|
10
|
+
cwd: os.tmpdir(), env: { PATH: "/usr/bin:/bin" }, timeout: 3000, maxBuffer: 4 * 1024 * 1024, encoding: "utf8",
|
|
11
|
+
});
|
|
12
|
+
if (result.status !== 0)
|
|
13
|
+
throw new Error("Cannot inspect installed runtime libraries");
|
|
14
|
+
return parseMachOLoadCommands(result.stdout, files);
|
|
15
|
+
};
|
|
16
|
+
export const parseMachOLoadCommands = (output, files) => {
|
|
17
|
+
const allowed = new Set(files);
|
|
18
|
+
const result = new Map();
|
|
19
|
+
let current;
|
|
20
|
+
let command = "";
|
|
21
|
+
for (const line of output.split("\n")) {
|
|
22
|
+
if (!/^\s/.test(line) && line.endsWith(":")) {
|
|
23
|
+
const file = line.slice(0, -1).replace(/ \(architecture [^)]+\)$/, "");
|
|
24
|
+
current = allowed.has(file) ? result.get(file) ?? { libraries: [], rpaths: [] } : undefined;
|
|
25
|
+
if (current)
|
|
26
|
+
result.set(file, current);
|
|
27
|
+
command = "";
|
|
28
|
+
}
|
|
29
|
+
else if (/^Load command \d+$/.test(line))
|
|
30
|
+
command = "";
|
|
31
|
+
else if (current) {
|
|
32
|
+
const kind = line.match(/^\s+cmd (LC_[A-Z_]+)\s*$/);
|
|
33
|
+
if (kind)
|
|
34
|
+
command = kind[1];
|
|
35
|
+
const value = line.match(/^\s+(?:name|path) (.+) \(offset \d+\)\s*$/)?.[1];
|
|
36
|
+
if (value && command === "LC_RPATH")
|
|
37
|
+
current.rpaths.push(value);
|
|
38
|
+
else if (value && ["LC_LOAD_DYLIB", "LC_LOAD_WEAK_DYLIB", "LC_REEXPORT_DYLIB", "LC_LOAD_UPWARD_DYLIB"].includes(command))
|
|
39
|
+
current.libraries.push(value);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (files.some(file => !result.has(file)))
|
|
43
|
+
throw new Error("Incomplete runtime library inspection");
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
const nativeFile = (file) => {
|
|
47
|
+
if (!statSync(file).isFile())
|
|
48
|
+
return false;
|
|
49
|
+
const fd = openSync(file, "r");
|
|
50
|
+
const header = Buffer.alloc(4);
|
|
51
|
+
try {
|
|
52
|
+
if (readSync(fd, header, 0, 4, 0) !== 4)
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
closeSync(fd);
|
|
57
|
+
}
|
|
58
|
+
return ["feedface", "feedfacf", "cefaedfe", "cffaedfe", "cafebabe", "bebafeca", "cafebabf", "bfbafeca"].includes(header.toString("hex"));
|
|
59
|
+
};
|
|
60
|
+
/** Admit only concrete native dependencies, including symlink spellings used by
|
|
61
|
+
* dyld. Never grant a package-manager prefix, home, or arbitrary library folder. */
|
|
62
|
+
export const discoverDarwinRuntimeLibraries = (executable, extensionFiles, workspace, home, inspect = inspectMachOLibraries) => {
|
|
63
|
+
const mounts = new Map();
|
|
64
|
+
const visited = new Set();
|
|
65
|
+
const initial = [...new Set([executable, ...extensionFiles])];
|
|
66
|
+
const safe = (file) => {
|
|
67
|
+
if (!path.isAbsolute(file) || /[\r\n\0]/.test(file))
|
|
68
|
+
throw new Error("Invalid runtime library path");
|
|
69
|
+
const resolved = realpathSync(file);
|
|
70
|
+
if (within(file, workspace) || within(resolved, workspace) || resolved === home || !nativeFile(resolved)) {
|
|
71
|
+
throw new Error("Runtime library is not an installed native file");
|
|
72
|
+
}
|
|
73
|
+
return resolved;
|
|
74
|
+
};
|
|
75
|
+
let pending = initial.map(file => ({ file: safe(file), inherited: [] }));
|
|
76
|
+
let executableRpaths = [];
|
|
77
|
+
const expand = (value, loader) => {
|
|
78
|
+
if (value === "@loader_path")
|
|
79
|
+
return path.dirname(loader);
|
|
80
|
+
if (value === "@executable_path")
|
|
81
|
+
return path.dirname(executable);
|
|
82
|
+
if (value.startsWith("@loader_path/"))
|
|
83
|
+
return path.resolve(path.dirname(loader), value.slice(13));
|
|
84
|
+
if (value.startsWith("@executable_path/"))
|
|
85
|
+
return path.resolve(path.dirname(executable), value.slice(17));
|
|
86
|
+
return path.isAbsolute(value) ? path.normalize(value) : undefined;
|
|
87
|
+
};
|
|
88
|
+
for (let depth = 0; pending.length; depth++) {
|
|
89
|
+
if (depth >= 12 || visited.size + pending.length > 256)
|
|
90
|
+
throw new Error("Runtime library graph exceeds discovery limit");
|
|
91
|
+
const files = [...new Set(pending.map(item => item.file))];
|
|
92
|
+
const inspected = inspect(files);
|
|
93
|
+
const next = [];
|
|
94
|
+
for (const { file, inherited } of pending) {
|
|
95
|
+
if (visited.has(file))
|
|
96
|
+
continue;
|
|
97
|
+
visited.add(file);
|
|
98
|
+
const info = inspected.get(file);
|
|
99
|
+
if (!info)
|
|
100
|
+
throw new Error("Missing runtime library metadata");
|
|
101
|
+
const rpaths = info.rpaths.map(value => expand(value, file)).filter((value) => value !== undefined);
|
|
102
|
+
if (file === executable)
|
|
103
|
+
executableRpaths = rpaths;
|
|
104
|
+
const searchRoots = [...rpaths, ...inherited, ...executableRpaths];
|
|
105
|
+
for (const library of info.libraries) {
|
|
106
|
+
const candidates = library.startsWith("@rpath/") ? searchRoots.map(root => path.resolve(root, library.slice(7))) : [expand(library, file)];
|
|
107
|
+
for (const candidate of candidates) {
|
|
108
|
+
if (!candidate)
|
|
109
|
+
continue;
|
|
110
|
+
if (systemLibrary(candidate))
|
|
111
|
+
break; // May exist only in the system dyld cache.
|
|
112
|
+
let resolved;
|
|
113
|
+
try {
|
|
114
|
+
resolved = safe(candidate);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
continue;
|
|
118
|
+
} // Missing optional libraries stay inaccessible.
|
|
119
|
+
for (const alias of [candidate, resolved])
|
|
120
|
+
mounts.set(alias, { readOnlyRoot: alias, directory: false });
|
|
121
|
+
if (!visited.has(resolved) && !next.some(item => item.file === resolved))
|
|
122
|
+
next.push({ file: resolved, inherited: searchRoots });
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
pending = next;
|
|
128
|
+
}
|
|
129
|
+
return [...mounts.values()];
|
|
130
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface HostRuntimeMount {
|
|
2
|
+
readOnlyRoot: string;
|
|
3
|
+
directory: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface HostRuntime extends HostRuntimeMount {
|
|
6
|
+
name: string;
|
|
7
|
+
executable: string;
|
|
8
|
+
support?: HostRuntimeMount[];
|
|
9
|
+
environment?: {
|
|
10
|
+
SDKROOT: string;
|
|
11
|
+
DEVELOPER_DIR: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** Discover known user-installed language tools. The workspace can neither
|
|
15
|
+
* supply this PATH nor turn its own package.json into a trusted runtime mount.
|
|
16
|
+
* Mounts are single binaries or matching package roots, never the user's home. */
|
|
17
|
+
export declare const discoverHostToolchain: (workspaceRoot: string, searchPath?: string) => HostRuntime[];
|
|
18
|
+
export declare const extraRuntimeMounts: (runtimes: HostRuntime[]) => HostRuntimeMount[];
|
|
19
|
+
//# sourceMappingURL=HostToolchain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HostToolchain.d.ts","sourceRoot":"","sources":["../../../src/tools/shell/HostToolchain.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,gBAAgB;IAAG,YAAY,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;CAAE;AAC/E,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACnD,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC/D,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1D;AAkID;;kFAEkF;AAClF,eAAO,MAAM,qBAAqB,GAAI,eAAe,MAAM,EAAE,mBAAmC,KAAG,WAAW,EA0D7G,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,UAAU,WAAW,EAAE,KAAG,gBAAgB,EAM5E,CAAC"}
|