@mcoda/mswarm 0.1.57 → 0.1.61
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 +19 -0
- package/dist/codali-executor.d.ts +278 -0
- package/dist/codali-executor.d.ts.map +1 -0
- package/dist/codali-executor.js +243 -0
- package/dist/codali-executor.js.map +1 -0
- package/dist/runtime.d.ts +46 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +298 -30
- package/dist/runtime.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +66 -1
- package/dist/server.js.map +1 -1
- package/dist/vendor/codali/agents/AgentProtocol.d.ts +287 -0
- package/dist/vendor/codali/agents/AgentProtocol.d.ts.map +1 -0
- package/dist/vendor/codali/agents/AgentProtocol.js +365 -0
- package/dist/vendor/codali/agents/AgentResolver.d.ts +23 -0
- package/dist/vendor/codali/agents/AgentResolver.d.ts.map +1 -0
- package/dist/vendor/codali/agents/AgentResolver.js +77 -0
- package/dist/vendor/codali/agents/PhaseAgentSelector.d.ts +23 -0
- package/dist/vendor/codali/agents/PhaseAgentSelector.d.ts.map +1 -0
- package/dist/vendor/codali/agents/PhaseAgentSelector.js +287 -0
- package/dist/vendor/codali/cli/EvalCommand.d.ts +37 -0
- package/dist/vendor/codali/cli/EvalCommand.d.ts.map +1 -0
- package/dist/vendor/codali/cli/EvalCommand.js +333 -0
- package/dist/vendor/codali/cli/FeedbackCommand.d.ts +22 -0
- package/dist/vendor/codali/cli/FeedbackCommand.d.ts.map +1 -0
- package/dist/vendor/codali/cli/FeedbackCommand.js +163 -0
- package/dist/vendor/codali/cli/RunCommand.d.ts +78 -0
- package/dist/vendor/codali/cli/RunCommand.d.ts.map +1 -0
- package/dist/vendor/codali/cli/RunCommand.js +2261 -0
- package/dist/vendor/codali/cli.d.ts +3 -0
- package/dist/vendor/codali/cli.d.ts.map +1 -0
- package/dist/vendor/codali/cli.js +109 -0
- package/dist/vendor/codali/cognitive/ArchitectPlanner.d.ts +107 -0
- package/dist/vendor/codali/cognitive/ArchitectPlanner.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ArchitectPlanner.js +1726 -0
- package/dist/vendor/codali/cognitive/BuilderOutputParser.d.ts +25 -0
- package/dist/vendor/codali/cognitive/BuilderOutputParser.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/BuilderOutputParser.js +164 -0
- package/dist/vendor/codali/cognitive/BuilderRunner.d.ts +76 -0
- package/dist/vendor/codali/cognitive/BuilderRunner.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/BuilderRunner.js +1159 -0
- package/dist/vendor/codali/cognitive/ContextAssembler.d.ts +91 -0
- package/dist/vendor/codali/cognitive/ContextAssembler.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextAssembler.js +4547 -0
- package/dist/vendor/codali/cognitive/ContextBudget.d.ts +19 -0
- package/dist/vendor/codali/cognitive/ContextBudget.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextBudget.js +35 -0
- package/dist/vendor/codali/cognitive/ContextFileLoader.d.ts +30 -0
- package/dist/vendor/codali/cognitive/ContextFileLoader.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextFileLoader.js +307 -0
- package/dist/vendor/codali/cognitive/ContextManager.d.ts +47 -0
- package/dist/vendor/codali/cognitive/ContextManager.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextManager.js +272 -0
- package/dist/vendor/codali/cognitive/ContextRedactor.d.ts +18 -0
- package/dist/vendor/codali/cognitive/ContextRedactor.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextRedactor.js +53 -0
- package/dist/vendor/codali/cognitive/ContextSelector.d.ts +22 -0
- package/dist/vendor/codali/cognitive/ContextSelector.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextSelector.js +431 -0
- package/dist/vendor/codali/cognitive/ContextSerializer.d.ts +8 -0
- package/dist/vendor/codali/cognitive/ContextSerializer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextSerializer.js +882 -0
- package/dist/vendor/codali/cognitive/ContextStore.d.ts +27 -0
- package/dist/vendor/codali/cognitive/ContextStore.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextStore.js +79 -0
- package/dist/vendor/codali/cognitive/ContextSummarizer.d.ts +16 -0
- package/dist/vendor/codali/cognitive/ContextSummarizer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextSummarizer.js +45 -0
- package/dist/vendor/codali/cognitive/CostEstimator.d.ts +31 -0
- package/dist/vendor/codali/cognitive/CostEstimator.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/CostEstimator.js +66 -0
- package/dist/vendor/codali/cognitive/CriticEvaluator.d.ts +32 -0
- package/dist/vendor/codali/cognitive/CriticEvaluator.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/CriticEvaluator.js +297 -0
- package/dist/vendor/codali/cognitive/EvidenceGate.d.ts +9 -0
- package/dist/vendor/codali/cognitive/EvidenceGate.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/EvidenceGate.js +75 -0
- package/dist/vendor/codali/cognitive/GoldenExampleIndexer.d.ts +12 -0
- package/dist/vendor/codali/cognitive/GoldenExampleIndexer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/GoldenExampleIndexer.js +34 -0
- package/dist/vendor/codali/cognitive/GoldenSetStore.d.ts +33 -0
- package/dist/vendor/codali/cognitive/GoldenSetStore.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/GoldenSetStore.js +159 -0
- package/dist/vendor/codali/cognitive/IntentSignals.d.ts +7 -0
- package/dist/vendor/codali/cognitive/IntentSignals.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/IntentSignals.js +285 -0
- package/dist/vendor/codali/cognitive/LearningGovernance.d.ts +100 -0
- package/dist/vendor/codali/cognitive/LearningGovernance.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/LearningGovernance.js +276 -0
- package/dist/vendor/codali/cognitive/MemoryWriteback.d.ts +64 -0
- package/dist/vendor/codali/cognitive/MemoryWriteback.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/MemoryWriteback.js +287 -0
- package/dist/vendor/codali/cognitive/PatchApplier.d.ts +49 -0
- package/dist/vendor/codali/cognitive/PatchApplier.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PatchApplier.js +199 -0
- package/dist/vendor/codali/cognitive/PatchInterpreter.d.ts +35 -0
- package/dist/vendor/codali/cognitive/PatchInterpreter.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PatchInterpreter.js +100 -0
- package/dist/vendor/codali/cognitive/PatchOutputNormalizer.d.ts +7 -0
- package/dist/vendor/codali/cognitive/PatchOutputNormalizer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PatchOutputNormalizer.js +59 -0
- package/dist/vendor/codali/cognitive/PostMortemAnalyzer.d.ts +17 -0
- package/dist/vendor/codali/cognitive/PostMortemAnalyzer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PostMortemAnalyzer.js +131 -0
- package/dist/vendor/codali/cognitive/PreferenceExtraction.d.ts +3 -0
- package/dist/vendor/codali/cognitive/PreferenceExtraction.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PreferenceExtraction.js +85 -0
- package/dist/vendor/codali/cognitive/Prompts.d.ts +15 -0
- package/dist/vendor/codali/cognitive/Prompts.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/Prompts.js +326 -0
- package/dist/vendor/codali/cognitive/ProviderRouting.d.ts +16 -0
- package/dist/vendor/codali/cognitive/ProviderRouting.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ProviderRouting.js +24 -0
- package/dist/vendor/codali/cognitive/QueryExtraction.d.ts +12 -0
- package/dist/vendor/codali/cognitive/QueryExtraction.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/QueryExtraction.js +262 -0
- package/dist/vendor/codali/cognitive/RunHistoryIndexer.d.ts +13 -0
- package/dist/vendor/codali/cognitive/RunHistoryIndexer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/RunHistoryIndexer.js +125 -0
- package/dist/vendor/codali/cognitive/SmartPipeline.d.ts +92 -0
- package/dist/vendor/codali/cognitive/SmartPipeline.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/SmartPipeline.js +4804 -0
- package/dist/vendor/codali/cognitive/Types.d.ts +474 -0
- package/dist/vendor/codali/cognitive/Types.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/Types.js +7 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.d.ts +57 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.js +515 -0
- package/dist/vendor/codali/config/Config.d.ts +249 -0
- package/dist/vendor/codali/config/Config.d.ts.map +1 -0
- package/dist/vendor/codali/config/Config.js +200 -0
- package/dist/vendor/codali/config/ConfigLoader.d.ts +56 -0
- package/dist/vendor/codali/config/ConfigLoader.d.ts.map +1 -0
- package/dist/vendor/codali/config/ConfigLoader.js +1246 -0
- package/dist/vendor/codali/docdex/DocdexClient.d.ts +158 -0
- package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -0
- package/dist/vendor/codali/docdex/DocdexClient.js +785 -0
- package/dist/vendor/codali/eval/EvalRunner.d.ts +35 -0
- package/dist/vendor/codali/eval/EvalRunner.d.ts.map +1 -0
- package/dist/vendor/codali/eval/EvalRunner.js +38 -0
- package/dist/vendor/codali/eval/EvalTaskExecutor.d.ts +81 -0
- package/dist/vendor/codali/eval/EvalTaskExecutor.d.ts.map +1 -0
- package/dist/vendor/codali/eval/EvalTaskExecutor.js +371 -0
- package/dist/vendor/codali/eval/GateEvaluator.d.ts +31 -0
- package/dist/vendor/codali/eval/GateEvaluator.d.ts.map +1 -0
- package/dist/vendor/codali/eval/GateEvaluator.js +134 -0
- package/dist/vendor/codali/eval/MetricTypes.d.ts +28 -0
- package/dist/vendor/codali/eval/MetricTypes.d.ts.map +1 -0
- package/dist/vendor/codali/eval/MetricTypes.js +1 -0
- package/dist/vendor/codali/eval/MetricsAggregator.d.ts +4 -0
- package/dist/vendor/codali/eval/MetricsAggregator.d.ts.map +1 -0
- package/dist/vendor/codali/eval/MetricsAggregator.js +97 -0
- package/dist/vendor/codali/eval/RegressionComparator.d.ts +29 -0
- package/dist/vendor/codali/eval/RegressionComparator.d.ts.map +1 -0
- package/dist/vendor/codali/eval/RegressionComparator.js +155 -0
- package/dist/vendor/codali/eval/ReportInputAdapter.d.ts +52 -0
- package/dist/vendor/codali/eval/ReportInputAdapter.d.ts.map +1 -0
- package/dist/vendor/codali/eval/ReportInputAdapter.js +229 -0
- package/dist/vendor/codali/eval/ReportSerializer.d.ts +32 -0
- package/dist/vendor/codali/eval/ReportSerializer.d.ts.map +1 -0
- package/dist/vendor/codali/eval/ReportSerializer.js +33 -0
- package/dist/vendor/codali/eval/ReportStore.d.ts +18 -0
- package/dist/vendor/codali/eval/ReportStore.d.ts.map +1 -0
- package/dist/vendor/codali/eval/ReportStore.js +96 -0
- package/dist/vendor/codali/eval/SuiteLoader.d.ts +12 -0
- package/dist/vendor/codali/eval/SuiteLoader.d.ts.map +1 -0
- package/dist/vendor/codali/eval/SuiteLoader.js +51 -0
- package/dist/vendor/codali/eval/SuiteSchema.d.ts +56 -0
- package/dist/vendor/codali/eval/SuiteSchema.d.ts.map +1 -0
- package/dist/vendor/codali/eval/SuiteSchema.js +357 -0
- package/dist/vendor/codali/index.d.ts +11 -0
- package/dist/vendor/codali/index.d.ts.map +1 -0
- package/dist/vendor/codali/index.js +5 -0
- package/dist/vendor/codali/providers/CodexCliProvider.d.ts +8 -0
- package/dist/vendor/codali/providers/CodexCliProvider.d.ts.map +1 -0
- package/dist/vendor/codali/providers/CodexCliProvider.js +282 -0
- package/dist/vendor/codali/providers/OllamaRemoteProvider.d.ts +8 -0
- package/dist/vendor/codali/providers/OllamaRemoteProvider.d.ts.map +1 -0
- package/dist/vendor/codali/providers/OllamaRemoteProvider.js +300 -0
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts +8 -0
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -0
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +192 -0
- package/dist/vendor/codali/providers/ProviderRegistry.d.ts +12 -0
- package/dist/vendor/codali/providers/ProviderRegistry.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ProviderRegistry.js +28 -0
- package/dist/vendor/codali/providers/ProviderTypes.d.ts +81 -0
- package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ProviderTypes.js +1 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +189 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.js +1435 -0
- package/dist/vendor/codali/runtime/DeepInvestigationErrors.d.ts +39 -0
- package/dist/vendor/codali/runtime/DeepInvestigationErrors.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/DeepInvestigationErrors.js +57 -0
- package/dist/vendor/codali/runtime/RunContext.d.ts +27 -0
- package/dist/vendor/codali/runtime/RunContext.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunContext.js +51 -0
- package/dist/vendor/codali/runtime/RunLogQuery.d.ts +48 -0
- package/dist/vendor/codali/runtime/RunLogQuery.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunLogQuery.js +36 -0
- package/dist/vendor/codali/runtime/RunLogReader.d.ts +19 -0
- package/dist/vendor/codali/runtime/RunLogReader.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunLogReader.js +361 -0
- package/dist/vendor/codali/runtime/RunLogger.d.ts +71 -0
- package/dist/vendor/codali/runtime/RunLogger.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunLogger.js +100 -0
- package/dist/vendor/codali/runtime/RunTelemetryTypes.d.ts +117 -0
- package/dist/vendor/codali/runtime/RunTelemetryTypes.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunTelemetryTypes.js +299 -0
- package/dist/vendor/codali/runtime/Runner.d.ts +66 -0
- package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/Runner.js +215 -0
- package/dist/vendor/codali/runtime/StoragePaths.d.ts +3 -0
- package/dist/vendor/codali/runtime/StoragePaths.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/StoragePaths.js +19 -0
- package/dist/vendor/codali/runtime/WorkspaceLock.d.ts +30 -0
- package/dist/vendor/codali/runtime/WorkspaceLock.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/WorkspaceLock.js +141 -0
- package/dist/vendor/codali/session/InstructionLoader.d.ts +14 -0
- package/dist/vendor/codali/session/InstructionLoader.d.ts.map +1 -0
- package/dist/vendor/codali/session/InstructionLoader.js +107 -0
- package/dist/vendor/codali/session/SessionStore.d.ts +81 -0
- package/dist/vendor/codali/session/SessionStore.d.ts.map +1 -0
- package/dist/vendor/codali/session/SessionStore.js +244 -0
- package/dist/vendor/codali/subagents/SubagentOrchestrator.d.ts +68 -0
- package/dist/vendor/codali/subagents/SubagentOrchestrator.d.ts.map +1 -0
- package/dist/vendor/codali/subagents/SubagentOrchestrator.js +150 -0
- package/dist/vendor/codali/tools/ToolRegistry.d.ts +9 -0
- package/dist/vendor/codali/tools/ToolRegistry.d.ts.map +1 -0
- package/dist/vendor/codali/tools/ToolRegistry.js +293 -0
- package/dist/vendor/codali/tools/ToolTypes.d.ts +66 -0
- package/dist/vendor/codali/tools/ToolTypes.d.ts.map +1 -0
- package/dist/vendor/codali/tools/ToolTypes.js +40 -0
- package/dist/vendor/codali/tools/diff/DiffTool.d.ts +3 -0
- package/dist/vendor/codali/tools/diff/DiffTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/diff/DiffTool.js +34 -0
- package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts +4 -0
- package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts.map +1 -0
- package/dist/vendor/codali/tools/docdex/DocdexTools.js +490 -0
- package/dist/vendor/codali/tools/filesystem/FileTools.d.ts +3 -0
- package/dist/vendor/codali/tools/filesystem/FileTools.d.ts.map +1 -0
- package/dist/vendor/codali/tools/filesystem/FileTools.js +141 -0
- package/dist/vendor/codali/tools/search/SearchTool.d.ts +3 -0
- package/dist/vendor/codali/tools/search/SearchTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/search/SearchTool.js +46 -0
- package/dist/vendor/codali/tools/shell/ShellTool.d.ts +3 -0
- package/dist/vendor/codali/tools/shell/ShellTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/ShellTool.js +104 -0
- package/package.json +5 -3
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { ToolExecutionError, toolErrorCategoryForCode, } from "./ToolTypes.js";
|
|
2
|
+
const isObject = (value) => {
|
|
3
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
|
+
};
|
|
5
|
+
const TOOL_SCHEMA_TYPES = new Set([
|
|
6
|
+
"string",
|
|
7
|
+
"number",
|
|
8
|
+
"integer",
|
|
9
|
+
"boolean",
|
|
10
|
+
"object",
|
|
11
|
+
"array",
|
|
12
|
+
"null",
|
|
13
|
+
]);
|
|
14
|
+
const buildToolError = (code, message, options = {}) => ({
|
|
15
|
+
code,
|
|
16
|
+
category: toolErrorCategoryForCode(code),
|
|
17
|
+
message,
|
|
18
|
+
retryable: options.retryable ?? code === "tool_timeout",
|
|
19
|
+
details: options.details,
|
|
20
|
+
});
|
|
21
|
+
const readSchemaTypes = (schema) => {
|
|
22
|
+
if (schema.type === undefined)
|
|
23
|
+
return undefined;
|
|
24
|
+
if (Array.isArray(schema.type))
|
|
25
|
+
return schema.type;
|
|
26
|
+
return [schema.type];
|
|
27
|
+
};
|
|
28
|
+
const schemaValidationError = (message, path, details = {}) => {
|
|
29
|
+
return buildToolError("tool_schema_invalid", message, {
|
|
30
|
+
retryable: false,
|
|
31
|
+
details: { path, ...details },
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const validateSchema = (schema, path = "$") => {
|
|
35
|
+
if (!schema)
|
|
36
|
+
return undefined;
|
|
37
|
+
const types = readSchemaTypes(schema);
|
|
38
|
+
if (types && types.length === 0) {
|
|
39
|
+
return schemaValidationError("Invalid schema: empty type list", path);
|
|
40
|
+
}
|
|
41
|
+
if (types && types.some((type) => !TOOL_SCHEMA_TYPES.has(type))) {
|
|
42
|
+
return schemaValidationError("Invalid schema: unsupported type", path, { types });
|
|
43
|
+
}
|
|
44
|
+
if (schema.required && (!Array.isArray(schema.required) || schema.required.some((key) => typeof key !== "string"))) {
|
|
45
|
+
return schemaValidationError("Invalid schema: required must be a string array", path);
|
|
46
|
+
}
|
|
47
|
+
if (schema.properties !== undefined) {
|
|
48
|
+
if (!isObject(schema.properties)) {
|
|
49
|
+
return schemaValidationError("Invalid schema: properties must be an object", path);
|
|
50
|
+
}
|
|
51
|
+
for (const [key, child] of Object.entries(schema.properties)) {
|
|
52
|
+
const childError = validateSchema(child, `${path}.properties.${key}`);
|
|
53
|
+
if (childError)
|
|
54
|
+
return childError;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (schema.items !== undefined) {
|
|
58
|
+
const childError = validateSchema(schema.items, `${path}.items`);
|
|
59
|
+
if (childError)
|
|
60
|
+
return childError;
|
|
61
|
+
}
|
|
62
|
+
if (schema.additionalProperties !== undefined && typeof schema.additionalProperties !== "boolean") {
|
|
63
|
+
return schemaValidationError("Invalid schema: additionalProperties must be boolean", path);
|
|
64
|
+
}
|
|
65
|
+
if (schema.enum !== undefined && !Array.isArray(schema.enum)) {
|
|
66
|
+
return schemaValidationError("Invalid schema: enum must be an array", path);
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
};
|
|
70
|
+
const runtimeTypeOf = (value) => {
|
|
71
|
+
if (value === null)
|
|
72
|
+
return "null";
|
|
73
|
+
if (Array.isArray(value))
|
|
74
|
+
return "array";
|
|
75
|
+
if (typeof value === "string")
|
|
76
|
+
return "string";
|
|
77
|
+
if (typeof value === "number")
|
|
78
|
+
return Number.isInteger(value) ? "integer" : "number";
|
|
79
|
+
if (typeof value === "boolean")
|
|
80
|
+
return "boolean";
|
|
81
|
+
if (isObject(value))
|
|
82
|
+
return "object";
|
|
83
|
+
return "unknown";
|
|
84
|
+
};
|
|
85
|
+
const matchesType = (value, type) => {
|
|
86
|
+
if (type === "string")
|
|
87
|
+
return typeof value === "string";
|
|
88
|
+
if (type === "number")
|
|
89
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
90
|
+
if (type === "integer")
|
|
91
|
+
return typeof value === "number" && Number.isInteger(value);
|
|
92
|
+
if (type === "boolean")
|
|
93
|
+
return typeof value === "boolean";
|
|
94
|
+
if (type === "object")
|
|
95
|
+
return isObject(value);
|
|
96
|
+
if (type === "array")
|
|
97
|
+
return Array.isArray(value);
|
|
98
|
+
return value === null;
|
|
99
|
+
};
|
|
100
|
+
const argumentValidationError = (message, path, details = {}) => {
|
|
101
|
+
return buildToolError("tool_invalid_args", message, {
|
|
102
|
+
retryable: false,
|
|
103
|
+
details: { path, ...details },
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const validateValue = (value, schema, path = "$") => {
|
|
107
|
+
const schemaTypes = readSchemaTypes(schema);
|
|
108
|
+
if (schemaTypes && schemaTypes.length > 0) {
|
|
109
|
+
const matched = schemaTypes.some((type) => matchesType(value, type));
|
|
110
|
+
if (!matched) {
|
|
111
|
+
return argumentValidationError("Invalid argument type", path, {
|
|
112
|
+
expected: schemaTypes,
|
|
113
|
+
actual: runtimeTypeOf(value),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (schema.enum && !schema.enum.some((entry) => Object.is(entry, value))) {
|
|
118
|
+
return argumentValidationError("Invalid argument value", path, {
|
|
119
|
+
expected: schema.enum,
|
|
120
|
+
actual: value,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (typeof value === "number") {
|
|
124
|
+
if (schema.minimum !== undefined && value < schema.minimum) {
|
|
125
|
+
return argumentValidationError("Argument is below minimum", path, {
|
|
126
|
+
minimum: schema.minimum,
|
|
127
|
+
actual: value,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (schema.maximum !== undefined && value > schema.maximum) {
|
|
131
|
+
return argumentValidationError("Argument is above maximum", path, {
|
|
132
|
+
maximum: schema.maximum,
|
|
133
|
+
actual: value,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (typeof value === "string") {
|
|
138
|
+
if (schema.minLength !== undefined && value.length < schema.minLength) {
|
|
139
|
+
return argumentValidationError("String argument is shorter than minimum length", path, {
|
|
140
|
+
minLength: schema.minLength,
|
|
141
|
+
actualLength: value.length,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
if (schema.maxLength !== undefined && value.length > schema.maxLength) {
|
|
145
|
+
return argumentValidationError("String argument is longer than maximum length", path, {
|
|
146
|
+
maxLength: schema.maxLength,
|
|
147
|
+
actualLength: value.length,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (Array.isArray(value) && schema.items) {
|
|
152
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
153
|
+
const childError = validateValue(value[index], schema.items, `${path}[${index}]`);
|
|
154
|
+
if (childError)
|
|
155
|
+
return childError;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (isObject(value)) {
|
|
159
|
+
const properties = schema.properties ?? {};
|
|
160
|
+
const required = schema.required ?? [];
|
|
161
|
+
for (const key of required) {
|
|
162
|
+
if (!(key in value)) {
|
|
163
|
+
return argumentValidationError("Missing required argument", `${path}.${key}`, {
|
|
164
|
+
required: key,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const allowUnknown = schema.additionalProperties === true;
|
|
169
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
170
|
+
const propertySchema = properties[key];
|
|
171
|
+
if (propertySchema) {
|
|
172
|
+
const childError = validateValue(entry, propertySchema, `${path}.${key}`);
|
|
173
|
+
if (childError)
|
|
174
|
+
return childError;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (!allowUnknown) {
|
|
178
|
+
return argumentValidationError("Unknown argument", `${path}.${key}`, {
|
|
179
|
+
unknown: key,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return undefined;
|
|
185
|
+
};
|
|
186
|
+
const PERMISSION_DENIED_PATTERNS = [
|
|
187
|
+
"outside the workspace",
|
|
188
|
+
"outside allowed",
|
|
189
|
+
"not allowed",
|
|
190
|
+
"disallowed",
|
|
191
|
+
"permission",
|
|
192
|
+
"read-only",
|
|
193
|
+
"disabled",
|
|
194
|
+
"eacces",
|
|
195
|
+
"eperm",
|
|
196
|
+
];
|
|
197
|
+
const PRESERVED_ERROR_CODES = new Set([
|
|
198
|
+
"tool_unknown",
|
|
199
|
+
"tool_schema_invalid",
|
|
200
|
+
"tool_invalid_args",
|
|
201
|
+
"tool_permission_denied",
|
|
202
|
+
"tool_timeout",
|
|
203
|
+
"tool_execution_failed",
|
|
204
|
+
"docdex_context_missing",
|
|
205
|
+
"docdex_api_key_missing",
|
|
206
|
+
"docdex_operation_not_allowed",
|
|
207
|
+
"docdex_auth_failed",
|
|
208
|
+
"docdex_repo_access_denied",
|
|
209
|
+
"docdex_unavailable",
|
|
210
|
+
]);
|
|
211
|
+
const preservedErrorCode = (error) => {
|
|
212
|
+
if (!isObject(error))
|
|
213
|
+
return undefined;
|
|
214
|
+
const code = error.code;
|
|
215
|
+
return typeof code === "string" && PRESERVED_ERROR_CODES.has(code)
|
|
216
|
+
? code
|
|
217
|
+
: undefined;
|
|
218
|
+
};
|
|
219
|
+
const normalizeExecutionError = (error) => {
|
|
220
|
+
if (error instanceof ToolExecutionError) {
|
|
221
|
+
return error.toToolError();
|
|
222
|
+
}
|
|
223
|
+
const explicitCode = preservedErrorCode(error);
|
|
224
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
225
|
+
if (explicitCode) {
|
|
226
|
+
const retryable = isObject(error) && typeof error.retryable === "boolean"
|
|
227
|
+
? error.retryable
|
|
228
|
+
: explicitCode === "tool_timeout" || explicitCode === "docdex_unavailable";
|
|
229
|
+
const details = isObject(error) && isObject(error.details) ? error.details : undefined;
|
|
230
|
+
return buildToolError(explicitCode, message, { retryable, details });
|
|
231
|
+
}
|
|
232
|
+
const normalized = message.toLowerCase();
|
|
233
|
+
if (normalized.includes("timeout") || normalized.includes("timed out") || normalized.includes("etimedout")) {
|
|
234
|
+
return buildToolError("tool_timeout", message, { retryable: true });
|
|
235
|
+
}
|
|
236
|
+
if (PERMISSION_DENIED_PATTERNS.some((pattern) => normalized.includes(pattern))) {
|
|
237
|
+
return buildToolError("tool_permission_denied", message, { retryable: false });
|
|
238
|
+
}
|
|
239
|
+
return buildToolError("tool_execution_failed", message, { retryable: true });
|
|
240
|
+
};
|
|
241
|
+
export class ToolRegistry {
|
|
242
|
+
constructor() {
|
|
243
|
+
this.tools = new Map();
|
|
244
|
+
}
|
|
245
|
+
register(tool) {
|
|
246
|
+
if (this.tools.has(tool.name)) {
|
|
247
|
+
throw new Error(`Tool already registered: ${tool.name}`);
|
|
248
|
+
}
|
|
249
|
+
this.tools.set(tool.name, tool);
|
|
250
|
+
}
|
|
251
|
+
list() {
|
|
252
|
+
return Array.from(this.tools.values());
|
|
253
|
+
}
|
|
254
|
+
describe() {
|
|
255
|
+
return this.list().map((tool) => ({
|
|
256
|
+
name: tool.name,
|
|
257
|
+
description: tool.description,
|
|
258
|
+
inputSchema: tool.inputSchema,
|
|
259
|
+
}));
|
|
260
|
+
}
|
|
261
|
+
async execute(name, args, context) {
|
|
262
|
+
const tool = this.tools.get(name);
|
|
263
|
+
if (!tool) {
|
|
264
|
+
return {
|
|
265
|
+
ok: false,
|
|
266
|
+
output: "",
|
|
267
|
+
error: buildToolError("tool_unknown", `Unknown tool: ${name}`, {
|
|
268
|
+
retryable: false,
|
|
269
|
+
details: { tool: name },
|
|
270
|
+
}),
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
const schemaError = validateSchema(tool.inputSchema);
|
|
274
|
+
if (schemaError) {
|
|
275
|
+
return { ok: false, output: "", error: schemaError };
|
|
276
|
+
}
|
|
277
|
+
const validationError = tool.inputSchema ? validateValue(args, tool.inputSchema) : undefined;
|
|
278
|
+
if (validationError) {
|
|
279
|
+
return { ok: false, output: "", error: validationError };
|
|
280
|
+
}
|
|
281
|
+
try {
|
|
282
|
+
const result = await tool.handler(args, context);
|
|
283
|
+
return { ok: true, output: result.output, data: result.data };
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
return {
|
|
287
|
+
ok: false,
|
|
288
|
+
output: "",
|
|
289
|
+
error: normalizeExecutionError(error),
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export interface ToolContext {
|
|
2
|
+
workspaceRoot: string;
|
|
3
|
+
runId?: string;
|
|
4
|
+
recordTouchedFile?: (path: string) => void;
|
|
5
|
+
allowOutsideWorkspace?: boolean;
|
|
6
|
+
allowedReadPaths?: string[];
|
|
7
|
+
allowedWritePaths?: string[];
|
|
8
|
+
allowShell?: boolean;
|
|
9
|
+
allowDestructiveOperations?: boolean;
|
|
10
|
+
shellAllowlist?: string[];
|
|
11
|
+
}
|
|
12
|
+
export type ToolSchemaPrimitiveType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
|
|
13
|
+
export interface ToolSchemaDefinition extends Record<string, unknown> {
|
|
14
|
+
type?: ToolSchemaPrimitiveType | ToolSchemaPrimitiveType[];
|
|
15
|
+
properties?: Record<string, ToolSchemaDefinition>;
|
|
16
|
+
required?: string[];
|
|
17
|
+
items?: ToolSchemaDefinition;
|
|
18
|
+
additionalProperties?: boolean;
|
|
19
|
+
enum?: unknown[];
|
|
20
|
+
minimum?: number;
|
|
21
|
+
maximum?: number;
|
|
22
|
+
minLength?: number;
|
|
23
|
+
maxLength?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface ToolInputSchema extends ToolSchemaDefinition {
|
|
26
|
+
type: "object";
|
|
27
|
+
properties?: Record<string, ToolSchemaDefinition>;
|
|
28
|
+
required?: string[];
|
|
29
|
+
}
|
|
30
|
+
export type ToolErrorCode = "tool_unknown" | "tool_schema_invalid" | "tool_invalid_args" | "tool_permission_denied" | "tool_timeout" | "tool_execution_failed" | "docdex_context_missing" | "docdex_api_key_missing" | "docdex_operation_not_allowed" | "docdex_auth_failed" | "docdex_repo_access_denied" | "docdex_unavailable";
|
|
31
|
+
export type ToolErrorCategory = "lookup" | "schema" | "validation" | "permission" | "timeout" | "execution";
|
|
32
|
+
export interface ToolError {
|
|
33
|
+
code: ToolErrorCode;
|
|
34
|
+
category: ToolErrorCategory;
|
|
35
|
+
message: string;
|
|
36
|
+
retryable: boolean;
|
|
37
|
+
details?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
export declare class ToolExecutionError extends Error {
|
|
40
|
+
readonly code: ToolErrorCode;
|
|
41
|
+
readonly category: ToolErrorCategory;
|
|
42
|
+
readonly retryable: boolean;
|
|
43
|
+
readonly details?: Record<string, unknown>;
|
|
44
|
+
constructor(code: ToolErrorCode, message: string, options?: {
|
|
45
|
+
retryable?: boolean;
|
|
46
|
+
details?: Record<string, unknown>;
|
|
47
|
+
});
|
|
48
|
+
toToolError(): ToolError;
|
|
49
|
+
}
|
|
50
|
+
export declare const toolErrorCategoryForCode: (code: ToolErrorCode) => ToolErrorCategory;
|
|
51
|
+
export interface ToolHandlerResult {
|
|
52
|
+
output: string;
|
|
53
|
+
data?: unknown;
|
|
54
|
+
}
|
|
55
|
+
export interface ToolExecutionResult extends ToolHandlerResult {
|
|
56
|
+
ok: boolean;
|
|
57
|
+
error?: ToolError;
|
|
58
|
+
}
|
|
59
|
+
export type ToolHandler = (args: unknown, context: ToolContext) => Promise<ToolHandlerResult>;
|
|
60
|
+
export interface ToolDefinition {
|
|
61
|
+
name: string;
|
|
62
|
+
description: string;
|
|
63
|
+
inputSchema?: ToolInputSchema;
|
|
64
|
+
handler: ToolHandler;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=ToolTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolTypes.d.ts","sourceRoot":"","sources":["../../src/tools/ToolTypes.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export class ToolExecutionError extends Error {
|
|
2
|
+
constructor(code, message, options = {}) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = "ToolExecutionError";
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.category = toolErrorCategoryForCode(code);
|
|
7
|
+
this.retryable = options.retryable ?? code === "tool_timeout";
|
|
8
|
+
this.details = options.details;
|
|
9
|
+
}
|
|
10
|
+
toToolError() {
|
|
11
|
+
return {
|
|
12
|
+
code: this.code,
|
|
13
|
+
category: this.category,
|
|
14
|
+
message: this.message,
|
|
15
|
+
retryable: this.retryable,
|
|
16
|
+
details: this.details,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export const toolErrorCategoryForCode = (code) => {
|
|
21
|
+
if (code === "tool_unknown")
|
|
22
|
+
return "lookup";
|
|
23
|
+
if (code === "tool_schema_invalid")
|
|
24
|
+
return "schema";
|
|
25
|
+
if (code === "tool_invalid_args")
|
|
26
|
+
return "validation";
|
|
27
|
+
if (code === "tool_permission_denied")
|
|
28
|
+
return "permission";
|
|
29
|
+
if (code === "tool_timeout")
|
|
30
|
+
return "timeout";
|
|
31
|
+
if (code === "docdex_context_missing")
|
|
32
|
+
return "validation";
|
|
33
|
+
if (code === "docdex_api_key_missing" ||
|
|
34
|
+
code === "docdex_operation_not_allowed" ||
|
|
35
|
+
code === "docdex_auth_failed" ||
|
|
36
|
+
code === "docdex_repo_access_denied") {
|
|
37
|
+
return "permission";
|
|
38
|
+
}
|
|
39
|
+
return "execution";
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DiffTool.d.ts","sourceRoot":"","sources":["../../../src/tools/diff/DiffTool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAanE,eAAO,MAAM,cAAc,QAAO,cAsBhC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
const runGitStatus = (cwd) => {
|
|
3
|
+
const result = spawnSync("git", ["status", "--porcelain"], { cwd, encoding: "utf8" });
|
|
4
|
+
if (result.error) {
|
|
5
|
+
return { ok: false, output: "", error: result.error.message };
|
|
6
|
+
}
|
|
7
|
+
if (result.status !== 0) {
|
|
8
|
+
return { ok: false, output: result.stdout ?? "", error: result.stderr ?? "git status failed" };
|
|
9
|
+
}
|
|
10
|
+
return { ok: true, output: result.stdout ?? "" };
|
|
11
|
+
};
|
|
12
|
+
export const createDiffTool = () => ({
|
|
13
|
+
name: "diff_summary",
|
|
14
|
+
description: "Show a git status summary of workspace changes.",
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
maxLines: { type: "number" },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
handler: async (args, context) => {
|
|
22
|
+
const { maxLines = 200 } = args ?? {};
|
|
23
|
+
const result = runGitStatus(context.workspaceRoot);
|
|
24
|
+
if (!result.ok) {
|
|
25
|
+
throw new Error(result.error ?? "git status failed");
|
|
26
|
+
}
|
|
27
|
+
const lines = result.output.split("\n").filter(Boolean);
|
|
28
|
+
const clipped = lines.slice(0, maxLines);
|
|
29
|
+
return {
|
|
30
|
+
output: clipped.join("\n"),
|
|
31
|
+
data: { count: clipped.length, total: lines.length },
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocdexTools.d.ts","sourceRoot":"","sources":["../../../src/tools/docdex/DocdexTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAOjE,eAAO,MAAM,iBAAiB,GAAI,QAAQ,YAAY,KAAG,cAAc,EA8iBtE,CAAC"}
|