@mcoda/mswarm 0.1.56 → 0.1.60
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 +20 -1
- package/dist/codali-executor.d.ts +266 -0
- package/dist/codali-executor.d.ts.map +1 -0
- package/dist/codali-executor.js +227 -0
- package/dist/codali-executor.js.map +1 -0
- package/dist/runtime.d.ts +47 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +248 -30
- package/dist/runtime.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +83 -3
- 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 +113 -0
- package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -0
- package/dist/vendor/codali/docdex/DocdexClient.js +524 -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 +183 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.js +1363 -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 +263 -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 +32 -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 +453 -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,25 @@
|
|
|
1
|
+
export type PatchAction = {
|
|
2
|
+
action: "replace";
|
|
3
|
+
file: string;
|
|
4
|
+
search_block: string;
|
|
5
|
+
replace_block: string;
|
|
6
|
+
} | {
|
|
7
|
+
action: "create";
|
|
8
|
+
file: string;
|
|
9
|
+
content: string;
|
|
10
|
+
} | {
|
|
11
|
+
action: "delete";
|
|
12
|
+
file: string;
|
|
13
|
+
};
|
|
14
|
+
export type PatchFormat = "search_replace" | "file_writes";
|
|
15
|
+
export interface PatchPayload {
|
|
16
|
+
patches: PatchAction[];
|
|
17
|
+
}
|
|
18
|
+
export declare const PATCHES_ARRAY_MISSING_ERROR = "Patch payload is missing required 'patches' array";
|
|
19
|
+
export declare const PATCHES_ARRAY_TYPE_ERROR = "Patch payload field 'patches' must be an array";
|
|
20
|
+
export declare const PATCHES_ARRAY_EMPTY_ERROR = "Patch payload includes empty patches array";
|
|
21
|
+
export declare const FILES_ARRAY_MISSING_ERROR = "Patch payload is missing required 'files' array";
|
|
22
|
+
export declare const FILES_ARRAY_TYPE_ERROR = "Patch payload field 'files' must be an array";
|
|
23
|
+
export declare const FILES_ARRAY_EMPTY_ERROR = "Patch payload includes empty files array";
|
|
24
|
+
export declare const parsePatchOutput: (content: string, format?: PatchFormat) => PatchPayload;
|
|
25
|
+
//# sourceMappingURL=BuilderOutputParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuilderOutputParser.d.ts","sourceRoot":"","sources":["../../src/cognitive/BuilderOutputParser.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GACnB;IACE,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB,GACD;IACE,MAAM,EAAE,QAAQ,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,GACD;IACE,MAAM,EAAE,QAAQ,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEN,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAE3D,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,2BAA2B,sDAAsD,CAAC;AAC/F,eAAO,MAAM,wBAAwB,mDAAmD,CAAC;AACzF,eAAO,MAAM,yBAAyB,+CAA+C,CAAC;AACtF,eAAO,MAAM,yBAAyB,oDAAoD,CAAC;AAC3F,eAAO,MAAM,sBAAsB,iDAAiD,CAAC;AACrF,eAAO,MAAM,uBAAuB,6CAA6C,CAAC;AA2IlF,eAAO,MAAM,gBAAgB,GAC3B,SAAS,MAAM,EACf,SAAQ,WAA8B,KACrC,YAkBF,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
export const PATCHES_ARRAY_MISSING_ERROR = "Patch payload is missing required 'patches' array";
|
|
2
|
+
export const PATCHES_ARRAY_TYPE_ERROR = "Patch payload field 'patches' must be an array";
|
|
3
|
+
export const PATCHES_ARRAY_EMPTY_ERROR = "Patch payload includes empty patches array";
|
|
4
|
+
export const FILES_ARRAY_MISSING_ERROR = "Patch payload is missing required 'files' array";
|
|
5
|
+
export const FILES_ARRAY_TYPE_ERROR = "Patch payload field 'files' must be an array";
|
|
6
|
+
export const FILES_ARRAY_EMPTY_ERROR = "Patch payload includes empty files array";
|
|
7
|
+
const extractJsonCandidate = (raw) => {
|
|
8
|
+
const trimmed = raw.trim();
|
|
9
|
+
if (!trimmed)
|
|
10
|
+
return undefined;
|
|
11
|
+
const fenceMatch = trimmed.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
12
|
+
if (fenceMatch?.[1]) {
|
|
13
|
+
return fenceMatch[1].trim();
|
|
14
|
+
}
|
|
15
|
+
const startIndex = trimmed.search(/[\[{]/);
|
|
16
|
+
if (startIndex === -1)
|
|
17
|
+
return undefined;
|
|
18
|
+
const stack = [];
|
|
19
|
+
let inString = false;
|
|
20
|
+
let escape = false;
|
|
21
|
+
for (let i = startIndex; i < trimmed.length; i += 1) {
|
|
22
|
+
const ch = trimmed[i];
|
|
23
|
+
if (inString) {
|
|
24
|
+
if (escape) {
|
|
25
|
+
escape = false;
|
|
26
|
+
}
|
|
27
|
+
else if (ch === "\\\\") {
|
|
28
|
+
escape = true;
|
|
29
|
+
}
|
|
30
|
+
else if (ch === "\"") {
|
|
31
|
+
inString = false;
|
|
32
|
+
}
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (ch === "\"") {
|
|
36
|
+
inString = true;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (ch === "{" || ch === "[") {
|
|
40
|
+
stack.push(ch);
|
|
41
|
+
}
|
|
42
|
+
else if (ch === "}" || ch === "]") {
|
|
43
|
+
if (!stack.length)
|
|
44
|
+
continue;
|
|
45
|
+
stack.pop();
|
|
46
|
+
if (stack.length === 0) {
|
|
47
|
+
return trimmed.slice(startIndex, i + 1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
};
|
|
53
|
+
const assertString = (value, field) => {
|
|
54
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
55
|
+
throw new Error(`Patch field '${field}' must be a non-empty string`);
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
};
|
|
59
|
+
const parsePatchAction = (raw) => {
|
|
60
|
+
const action = raw.action;
|
|
61
|
+
if (action !== "replace" && action !== "create" && action !== "delete") {
|
|
62
|
+
throw new Error("Patch action must be replace, create, or delete");
|
|
63
|
+
}
|
|
64
|
+
const file = assertString(raw.file, "file");
|
|
65
|
+
if (action === "replace") {
|
|
66
|
+
return {
|
|
67
|
+
action,
|
|
68
|
+
file,
|
|
69
|
+
search_block: assertString(raw.search_block, "search_block"),
|
|
70
|
+
replace_block: assertString(raw.replace_block, "replace_block"),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (action === "create") {
|
|
74
|
+
return {
|
|
75
|
+
action,
|
|
76
|
+
file,
|
|
77
|
+
content: assertString(raw.content, "content"),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return { action, file };
|
|
81
|
+
};
|
|
82
|
+
const parseSearchReplacePayload = (payload) => {
|
|
83
|
+
if (Array.isArray(payload)) {
|
|
84
|
+
return parseSearchReplacePayload({ patches: payload });
|
|
85
|
+
}
|
|
86
|
+
if (!payload || typeof payload !== "object") {
|
|
87
|
+
throw new Error("Patch payload must be an object");
|
|
88
|
+
}
|
|
89
|
+
const patchesRaw = payload.patches;
|
|
90
|
+
if (patchesRaw === undefined) {
|
|
91
|
+
throw new Error(PATCHES_ARRAY_MISSING_ERROR);
|
|
92
|
+
}
|
|
93
|
+
if (!Array.isArray(patchesRaw)) {
|
|
94
|
+
throw new Error(PATCHES_ARRAY_TYPE_ERROR);
|
|
95
|
+
}
|
|
96
|
+
if (patchesRaw.length === 0) {
|
|
97
|
+
throw new Error(PATCHES_ARRAY_EMPTY_ERROR);
|
|
98
|
+
}
|
|
99
|
+
const parsed = patchesRaw.map((entry) => {
|
|
100
|
+
if (!entry || typeof entry !== "object") {
|
|
101
|
+
throw new Error("Patch entry must be an object");
|
|
102
|
+
}
|
|
103
|
+
return parsePatchAction(entry);
|
|
104
|
+
});
|
|
105
|
+
return { patches: parsed };
|
|
106
|
+
};
|
|
107
|
+
const parseFileWritesPayload = (payload) => {
|
|
108
|
+
if (!payload || typeof payload !== "object") {
|
|
109
|
+
throw new Error("Patch payload must be an object");
|
|
110
|
+
}
|
|
111
|
+
const record = payload;
|
|
112
|
+
if (Array.isArray(record.patches) && record.patches.length > 0) {
|
|
113
|
+
return parseSearchReplacePayload(payload);
|
|
114
|
+
}
|
|
115
|
+
if (Array.isArray(record.patches) && record.patches.length === 0 && record.files === undefined) {
|
|
116
|
+
throw new Error(PATCHES_ARRAY_EMPTY_ERROR);
|
|
117
|
+
}
|
|
118
|
+
const filesRaw = record.files;
|
|
119
|
+
if (filesRaw === undefined) {
|
|
120
|
+
throw new Error(FILES_ARRAY_MISSING_ERROR);
|
|
121
|
+
}
|
|
122
|
+
if (!Array.isArray(filesRaw)) {
|
|
123
|
+
throw new Error(FILES_ARRAY_TYPE_ERROR);
|
|
124
|
+
}
|
|
125
|
+
if (filesRaw.length === 0) {
|
|
126
|
+
throw new Error(FILES_ARRAY_EMPTY_ERROR);
|
|
127
|
+
}
|
|
128
|
+
const patches = filesRaw.map((entry) => {
|
|
129
|
+
if (!entry || typeof entry !== "object") {
|
|
130
|
+
throw new Error("Patch file entry must be an object");
|
|
131
|
+
}
|
|
132
|
+
const file = assertString(entry.path, "path");
|
|
133
|
+
const content = assertString(entry.content, "content");
|
|
134
|
+
return { action: "create", file, content };
|
|
135
|
+
});
|
|
136
|
+
const deletes = record.delete;
|
|
137
|
+
if (Array.isArray(deletes)) {
|
|
138
|
+
for (const entry of deletes) {
|
|
139
|
+
const file = assertString(entry, "delete");
|
|
140
|
+
patches.push({ action: "delete", file });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return { patches };
|
|
144
|
+
};
|
|
145
|
+
export const parsePatchOutput = (content, format = "search_replace") => {
|
|
146
|
+
if (!content.trim()) {
|
|
147
|
+
throw new Error("Patch output is empty");
|
|
148
|
+
}
|
|
149
|
+
let payload;
|
|
150
|
+
const candidate = extractJsonCandidate(content);
|
|
151
|
+
try {
|
|
152
|
+
payload = JSON.parse(candidate ?? content);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
throw new Error("Patch output is not valid JSON");
|
|
156
|
+
}
|
|
157
|
+
if (format === "search_replace" && Array.isArray(payload)) {
|
|
158
|
+
return parseSearchReplacePayload({ patches: payload });
|
|
159
|
+
}
|
|
160
|
+
if (format === "file_writes") {
|
|
161
|
+
return parseFileWritesPayload(payload);
|
|
162
|
+
}
|
|
163
|
+
return parseSearchReplacePayload(payload);
|
|
164
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { AgentEvent, Provider, ProviderResponseFormat } from "../providers/ProviderTypes.js";
|
|
2
|
+
import type { ToolContext } from "../tools/ToolTypes.js";
|
|
3
|
+
import { ToolRegistry } from "../tools/ToolRegistry.js";
|
|
4
|
+
import type { RunLogger } from "../runtime/RunLogger.js";
|
|
5
|
+
import { type RunnerResult } from "../runtime/Runner.js";
|
|
6
|
+
import type { ContextBundle, ContextRequest, PatchFailureClassification, Plan } from "./Types.js";
|
|
7
|
+
import { type PatchAction, type PatchFormat } from "./BuilderOutputParser.js";
|
|
8
|
+
import { PatchApplier } from "./PatchApplier.js";
|
|
9
|
+
import type { ContextManager } from "./ContextManager.js";
|
|
10
|
+
import type { PatchInterpreterClient } from "./PatchInterpreter.js";
|
|
11
|
+
export interface BuilderRunResult extends RunnerResult {
|
|
12
|
+
contextRequest?: ContextRequest;
|
|
13
|
+
touchedFiles?: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface PatchApplyFailure {
|
|
16
|
+
source: string;
|
|
17
|
+
error: string;
|
|
18
|
+
reasonCode?: string;
|
|
19
|
+
diagnostics?: Record<string, unknown>;
|
|
20
|
+
classification?: PatchFailureClassification;
|
|
21
|
+
attemptHistory?: string[];
|
|
22
|
+
patches: PatchAction[];
|
|
23
|
+
rollback: {
|
|
24
|
+
attempted: boolean;
|
|
25
|
+
ok: boolean;
|
|
26
|
+
error?: string;
|
|
27
|
+
};
|
|
28
|
+
rawOutput: string;
|
|
29
|
+
}
|
|
30
|
+
export declare class PatchApplyError extends Error {
|
|
31
|
+
readonly details: PatchApplyFailure;
|
|
32
|
+
constructor(details: PatchApplyFailure);
|
|
33
|
+
}
|
|
34
|
+
export interface BuilderRunnerOptions {
|
|
35
|
+
provider: Provider;
|
|
36
|
+
tools: ToolRegistry;
|
|
37
|
+
context: ToolContext;
|
|
38
|
+
maxSteps: number;
|
|
39
|
+
maxToolCalls: number;
|
|
40
|
+
maxTokens?: number;
|
|
41
|
+
timeoutMs?: number;
|
|
42
|
+
temperature?: number;
|
|
43
|
+
responseFormat?: ProviderResponseFormat;
|
|
44
|
+
logger?: RunLogger;
|
|
45
|
+
mode?: "tool_calls" | "patch_json" | "freeform";
|
|
46
|
+
patchFormat?: PatchFormat;
|
|
47
|
+
patchApplier?: PatchApplier;
|
|
48
|
+
interpreter?: PatchInterpreterClient;
|
|
49
|
+
fallbackToInterpreter?: boolean;
|
|
50
|
+
allowDestructiveOperations?: boolean;
|
|
51
|
+
contextManager?: ContextManager;
|
|
52
|
+
laneId?: string;
|
|
53
|
+
model?: string;
|
|
54
|
+
stream?: boolean;
|
|
55
|
+
onEvent?: (event: AgentEvent) => void;
|
|
56
|
+
onToken?: (token: string) => void;
|
|
57
|
+
streamFlushMs?: number;
|
|
58
|
+
}
|
|
59
|
+
export declare class BuilderRunner {
|
|
60
|
+
private options;
|
|
61
|
+
constructor(options: BuilderRunnerOptions);
|
|
62
|
+
setProvider(provider: Provider, options?: {
|
|
63
|
+
model?: string;
|
|
64
|
+
temperature?: number;
|
|
65
|
+
responseFormat?: ProviderResponseFormat;
|
|
66
|
+
mode?: "tool_calls" | "patch_json" | "freeform";
|
|
67
|
+
}): void;
|
|
68
|
+
private isToolSupportError;
|
|
69
|
+
run(plan: Plan, contextBundle: ContextBundle, options?: {
|
|
70
|
+
contextManager?: ContextManager;
|
|
71
|
+
laneId?: string;
|
|
72
|
+
model?: string;
|
|
73
|
+
note?: string;
|
|
74
|
+
}): Promise<BuilderRunResult>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=BuilderRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuilderRunner.d.ts","sourceRoot":"","sources":["../../src/cognitive/BuilderRunner.ts"],"names":[],"mappings":"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"}
|