@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,71 @@
|
|
|
1
|
+
import type { PhaseArtifactError, PhaseArtifactV1, VerificationReport } from "../cognitive/Types.js";
|
|
2
|
+
import { type PhaseTelemetryInput, type RunSummaryInput, type SafetyTelemetryEventData } from "./RunTelemetryTypes.js";
|
|
3
|
+
export type { SafetyTelemetryEventData, RunSummaryEventData, RunFinalDisposition, RunFailureClass, RunDisposition, RunQualityDimensions, RunArtifactReference, TelemetryReasonCode, SafetyTelemetryCategory, SafetyTelemetryDisposition, RunTelemetryValidationError, PhaseTelemetryRecord, PhaseTelemetryInput, PhaseUsageTelemetry, PhaseCostTelemetry, } from "./RunTelemetryTypes.js";
|
|
4
|
+
export interface RunLogEvent {
|
|
5
|
+
type: string;
|
|
6
|
+
timestamp: string;
|
|
7
|
+
data: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export type InvestigationGateStatus = "not_checked" | "pass" | "fail";
|
|
10
|
+
export interface InvestigationGateSummary {
|
|
11
|
+
status: InvestigationGateStatus;
|
|
12
|
+
reason?: string;
|
|
13
|
+
missing?: string[];
|
|
14
|
+
required?: Record<string, number>;
|
|
15
|
+
observed?: Record<string, number>;
|
|
16
|
+
score?: number;
|
|
17
|
+
threshold?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface InvestigationTelemetry extends Record<string, unknown> {
|
|
20
|
+
phase: "research";
|
|
21
|
+
status: "skipped" | "completed";
|
|
22
|
+
duration_ms: number;
|
|
23
|
+
tool_usage: Record<string, {
|
|
24
|
+
ok: number;
|
|
25
|
+
failed: number;
|
|
26
|
+
skipped: number;
|
|
27
|
+
total: number;
|
|
28
|
+
}>;
|
|
29
|
+
tool_usage_totals: {
|
|
30
|
+
ok: number;
|
|
31
|
+
failed: number;
|
|
32
|
+
skipped: number;
|
|
33
|
+
total: number;
|
|
34
|
+
};
|
|
35
|
+
evidence_gate: InvestigationGateSummary;
|
|
36
|
+
quota: InvestigationGateSummary;
|
|
37
|
+
budget: InvestigationGateSummary & {
|
|
38
|
+
required_cycles?: number;
|
|
39
|
+
cycles?: number;
|
|
40
|
+
required_ms?: number;
|
|
41
|
+
elapsed_ms?: number;
|
|
42
|
+
};
|
|
43
|
+
warnings?: string[];
|
|
44
|
+
summary?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface InvestigationTelemetryEvent extends RunLogEvent {
|
|
47
|
+
type: "investigation_telemetry";
|
|
48
|
+
data: InvestigationTelemetry;
|
|
49
|
+
}
|
|
50
|
+
export declare const buildPhaseArtifact: (params: {
|
|
51
|
+
runId: string;
|
|
52
|
+
phase: string;
|
|
53
|
+
kind: string;
|
|
54
|
+
payload: unknown;
|
|
55
|
+
startedAtMs?: number;
|
|
56
|
+
endedAtMs?: number;
|
|
57
|
+
error?: PhaseArtifactError;
|
|
58
|
+
}) => PhaseArtifactV1;
|
|
59
|
+
export declare class RunLogger {
|
|
60
|
+
readonly logPath: string;
|
|
61
|
+
readonly logDir: string;
|
|
62
|
+
readonly runId: string;
|
|
63
|
+
constructor(workspaceRoot: string, logDir: string, runId: string);
|
|
64
|
+
log(type: string, data: Record<string, unknown>): Promise<void>;
|
|
65
|
+
logSafetyEvent(data: Omit<SafetyTelemetryEventData, "schema_version" | "run_id">): Promise<void>;
|
|
66
|
+
logPhaseTelemetry(data: PhaseTelemetryInput): Promise<void>;
|
|
67
|
+
logRunSummary(data: RunSummaryInput): Promise<void>;
|
|
68
|
+
logVerificationReport(report: VerificationReport): Promise<void>;
|
|
69
|
+
writePhaseArtifact(phase: string, kind: string, payload: unknown): Promise<string>;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=RunLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunLogger.d.ts","sourceRoot":"","sources":["../../src/runtime/RunLogger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACrG,OAAO,EAKL,KAAK,mBAAmB,EAExB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC9B,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,EACvB,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,MAAM,uBAAuB,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;AAEtE,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,uBAAuB,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,C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AC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC5B,KAAG,eAaF,CAAC;AAEH,qBAAa,SAAS;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAO1D,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAW/D,cAAc,CAClB,IAAI,EAAE,IAAI,CAAC,wBAAwB,EAAE,gBAAgB,GAAG,QAAQ,CAAC,GAChE,OAAO,CAAC,IAAI,CAAC;IAQV,iBAAiB,CACrB,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,IAAI,CAAC;IAWV,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAOnD,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOhE,kBAAkB,CACtB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC;CA4BnB"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { normalizePhaseTelemetryRecord, normalizeRunEventPayload, normalizeRunSummaryData, stableSortValue, } from "./RunTelemetryTypes.js";
|
|
4
|
+
const summarizePayload = (payload) => {
|
|
5
|
+
if (!payload || typeof payload !== "object")
|
|
6
|
+
return { type: typeof payload };
|
|
7
|
+
const objectPayload = payload;
|
|
8
|
+
const summary = {};
|
|
9
|
+
for (const key of ["status", "phase", "reason", "code"]) {
|
|
10
|
+
if (key in objectPayload)
|
|
11
|
+
summary[key] = objectPayload[key];
|
|
12
|
+
}
|
|
13
|
+
if (typeof objectPayload.error === "string")
|
|
14
|
+
summary.error = objectPayload.error;
|
|
15
|
+
if (Array.isArray(objectPayload.warnings))
|
|
16
|
+
summary.warning_count = objectPayload.warnings.length;
|
|
17
|
+
return summary;
|
|
18
|
+
};
|
|
19
|
+
export const buildPhaseArtifact = (params) => ({
|
|
20
|
+
schema_version: 1,
|
|
21
|
+
phase: params.phase,
|
|
22
|
+
kind: params.kind,
|
|
23
|
+
run_id: params.runId,
|
|
24
|
+
started_at_ms: params.startedAtMs,
|
|
25
|
+
ended_at_ms: params.endedAtMs,
|
|
26
|
+
duration_ms: params.startedAtMs !== undefined && params.endedAtMs !== undefined
|
|
27
|
+
? params.endedAtMs - params.startedAtMs
|
|
28
|
+
: undefined,
|
|
29
|
+
error: params.error,
|
|
30
|
+
payload: params.payload,
|
|
31
|
+
});
|
|
32
|
+
export class RunLogger {
|
|
33
|
+
constructor(workspaceRoot, logDir, runId) {
|
|
34
|
+
const resolvedDir = path.resolve(workspaceRoot, logDir);
|
|
35
|
+
this.logDir = resolvedDir;
|
|
36
|
+
this.runId = runId;
|
|
37
|
+
this.logPath = path.join(resolvedDir, `${runId}.jsonl`);
|
|
38
|
+
}
|
|
39
|
+
async log(type, data) {
|
|
40
|
+
await fs.mkdir(path.dirname(this.logPath), { recursive: true });
|
|
41
|
+
const normalizedData = normalizeRunEventPayload(type, data, this.runId);
|
|
42
|
+
const event = {
|
|
43
|
+
type,
|
|
44
|
+
timestamp: new Date().toISOString(),
|
|
45
|
+
data: stableSortValue(normalizedData),
|
|
46
|
+
};
|
|
47
|
+
await fs.appendFile(this.logPath, `${JSON.stringify(event)}\n`, "utf8");
|
|
48
|
+
}
|
|
49
|
+
async logSafetyEvent(data) {
|
|
50
|
+
await this.log("safety_event", {
|
|
51
|
+
schema_version: 1,
|
|
52
|
+
run_id: this.runId,
|
|
53
|
+
...data,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async logPhaseTelemetry(data) {
|
|
57
|
+
const normalized = normalizePhaseTelemetryRecord({
|
|
58
|
+
...data,
|
|
59
|
+
run_id: data.run_id ?? this.runId,
|
|
60
|
+
});
|
|
61
|
+
await this.log("phase_telemetry", { ...normalized });
|
|
62
|
+
}
|
|
63
|
+
async logRunSummary(data) {
|
|
64
|
+
await this.log("run_summary", normalizeRunSummaryData({ ...data, run_id: data.run_id ?? this.runId }, this.runId));
|
|
65
|
+
}
|
|
66
|
+
async logVerificationReport(report) {
|
|
67
|
+
await this.log("verification_report", {
|
|
68
|
+
run_id: this.runId,
|
|
69
|
+
report,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
async writePhaseArtifact(phase, kind, payload) {
|
|
73
|
+
const endedAt = Date.now();
|
|
74
|
+
const artifact = buildPhaseArtifact({
|
|
75
|
+
runId: this.runId,
|
|
76
|
+
phase,
|
|
77
|
+
kind,
|
|
78
|
+
payload,
|
|
79
|
+
endedAtMs: endedAt,
|
|
80
|
+
});
|
|
81
|
+
const phaseDir = path.join(this.logDir, "phase");
|
|
82
|
+
await fs.mkdir(phaseDir, { recursive: true });
|
|
83
|
+
const safePhase = phase.replace(/[^a-z0-9_-]/gi, "_");
|
|
84
|
+
const safeKind = kind.replace(/[^a-z0-9_-]/gi, "_");
|
|
85
|
+
const ext = "json";
|
|
86
|
+
const timestamp = Date.now();
|
|
87
|
+
const filename = `${this.runId}-${safePhase}-${safeKind}-${timestamp}.${ext}`;
|
|
88
|
+
const filePath = path.join(phaseDir, filename);
|
|
89
|
+
const content = JSON.stringify(artifact, null, 2);
|
|
90
|
+
await fs.writeFile(filePath, content, "utf8");
|
|
91
|
+
await this.log("phase_artifact", {
|
|
92
|
+
phase,
|
|
93
|
+
kind,
|
|
94
|
+
path: filePath,
|
|
95
|
+
schema_version: artifact.schema_version,
|
|
96
|
+
payload_summary: summarizePayload(payload),
|
|
97
|
+
});
|
|
98
|
+
return filePath;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export declare const RUN_TELEMETRY_SCHEMA_VERSION: 1;
|
|
2
|
+
export type RunTelemetrySchemaVersion = typeof RUN_TELEMETRY_SCHEMA_VERSION;
|
|
3
|
+
export type RunDisposition = "pass" | "fail" | "degraded";
|
|
4
|
+
export type RunFailureClass = "execution_failure" | "verification_failure" | "policy_failure" | "safety_failure" | "patch_failure" | "provider_failure" | "unknown_failure";
|
|
5
|
+
export type QualityDimensionStatus = "available" | "missing" | "degraded";
|
|
6
|
+
export type TelemetrySource = "actual_usage" | "estimated_usage" | "unknown";
|
|
7
|
+
export type TelemetryReasonCode = "usage_missing" | "cost_missing" | "provider_usage_not_exposed" | "pricing_unavailable" | "phase_not_model_invoking" | "not_applicable" | "unknown";
|
|
8
|
+
export type SafetyTelemetryCategory = "tool" | "patch" | "critic" | "policy";
|
|
9
|
+
export type SafetyTelemetryDisposition = "retryable" | "non_retryable";
|
|
10
|
+
export interface SafetyTelemetryEventData {
|
|
11
|
+
schema_version: RunTelemetrySchemaVersion;
|
|
12
|
+
run_id: string;
|
|
13
|
+
phase: string;
|
|
14
|
+
category: SafetyTelemetryCategory;
|
|
15
|
+
code: string;
|
|
16
|
+
disposition: SafetyTelemetryDisposition;
|
|
17
|
+
message: string;
|
|
18
|
+
source?: string;
|
|
19
|
+
tool?: string;
|
|
20
|
+
failure_class?: RunFailureClass;
|
|
21
|
+
reason_codes?: string[];
|
|
22
|
+
details?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export interface RunArtifactReference {
|
|
25
|
+
phase: string;
|
|
26
|
+
kind: string;
|
|
27
|
+
path?: string | null;
|
|
28
|
+
status: "present" | "missing";
|
|
29
|
+
reason_code?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface PhaseUsageTelemetry {
|
|
32
|
+
input_tokens?: number;
|
|
33
|
+
output_tokens?: number;
|
|
34
|
+
total_tokens?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface PhaseCostTelemetry {
|
|
37
|
+
usd?: number;
|
|
38
|
+
source: TelemetrySource;
|
|
39
|
+
pricing_source?: string;
|
|
40
|
+
reason_code?: TelemetryReasonCode;
|
|
41
|
+
}
|
|
42
|
+
export interface PhaseTelemetryRecord {
|
|
43
|
+
schema_version: RunTelemetrySchemaVersion;
|
|
44
|
+
run_id: string;
|
|
45
|
+
phase: string;
|
|
46
|
+
provider?: string;
|
|
47
|
+
model?: string;
|
|
48
|
+
duration_ms?: number;
|
|
49
|
+
usage?: PhaseUsageTelemetry;
|
|
50
|
+
cost?: PhaseCostTelemetry;
|
|
51
|
+
missing_usage_reason?: TelemetryReasonCode;
|
|
52
|
+
missing_cost_reason?: TelemetryReasonCode;
|
|
53
|
+
metadata?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
export interface PhaseTelemetryInput {
|
|
56
|
+
run_id?: string;
|
|
57
|
+
phase?: string;
|
|
58
|
+
provider?: string;
|
|
59
|
+
model?: string;
|
|
60
|
+
duration_ms?: number;
|
|
61
|
+
usage?: PhaseUsageTelemetry;
|
|
62
|
+
cost?: PhaseCostTelemetry;
|
|
63
|
+
missing_usage_reason?: TelemetryReasonCode;
|
|
64
|
+
missing_cost_reason?: TelemetryReasonCode;
|
|
65
|
+
metadata?: Record<string, unknown>;
|
|
66
|
+
}
|
|
67
|
+
export interface RunQualityDimensions {
|
|
68
|
+
plan: QualityDimensionStatus;
|
|
69
|
+
retrieval: QualityDimensionStatus;
|
|
70
|
+
patch: QualityDimensionStatus;
|
|
71
|
+
verification: QualityDimensionStatus;
|
|
72
|
+
final_disposition: QualityDimensionStatus;
|
|
73
|
+
}
|
|
74
|
+
export interface RunFinalDisposition {
|
|
75
|
+
status: RunDisposition;
|
|
76
|
+
failure_class?: RunFailureClass;
|
|
77
|
+
reason_codes: string[];
|
|
78
|
+
stage?: string;
|
|
79
|
+
retryable?: boolean | null;
|
|
80
|
+
}
|
|
81
|
+
export interface RunSummaryEventData extends Record<string, unknown> {
|
|
82
|
+
schema_version: RunTelemetrySchemaVersion;
|
|
83
|
+
run_id: string;
|
|
84
|
+
runId: string;
|
|
85
|
+
durationMs: number;
|
|
86
|
+
touchedFiles: string[];
|
|
87
|
+
quality_dimensions: RunQualityDimensions;
|
|
88
|
+
final_disposition: RunFinalDisposition;
|
|
89
|
+
artifact_references: RunArtifactReference[];
|
|
90
|
+
phase_telemetry: PhaseTelemetryRecord[];
|
|
91
|
+
missing_artifacts: string[];
|
|
92
|
+
}
|
|
93
|
+
export interface RunSummaryInput extends Record<string, unknown> {
|
|
94
|
+
schema_version?: number;
|
|
95
|
+
run_id?: string;
|
|
96
|
+
runId?: string;
|
|
97
|
+
durationMs?: number;
|
|
98
|
+
touchedFiles?: string[];
|
|
99
|
+
quality_dimensions?: Partial<RunQualityDimensions>;
|
|
100
|
+
final_disposition?: Partial<RunFinalDisposition>;
|
|
101
|
+
artifact_references?: RunArtifactReference[];
|
|
102
|
+
phase_telemetry?: PhaseTelemetryInput[];
|
|
103
|
+
missing_artifacts?: string[];
|
|
104
|
+
}
|
|
105
|
+
export declare class RunTelemetryValidationError extends Error {
|
|
106
|
+
readonly code: string;
|
|
107
|
+
constructor(code: string, message: string);
|
|
108
|
+
}
|
|
109
|
+
export declare const stableSortValue: (value: unknown) => unknown;
|
|
110
|
+
export declare const normalizeFailureClass: (value: unknown) => RunFailureClass | undefined;
|
|
111
|
+
export declare const normalizePhaseTelemetryRecord: (input: PhaseTelemetryInput) => PhaseTelemetryRecord;
|
|
112
|
+
export declare const normalizeRunSummaryData: (input: RunSummaryInput, fallbackRunId?: string) => RunSummaryEventData;
|
|
113
|
+
export declare const normalizeSafetyTelemetryEventData: (input: Omit<SafetyTelemetryEventData, "schema_version"> & {
|
|
114
|
+
schema_version?: number;
|
|
115
|
+
}, fallbackRunId?: string) => SafetyTelemetryEventData;
|
|
116
|
+
export declare const normalizeRunEventPayload: (type: string, data: Record<string, unknown>, fallbackRunId?: string) => Record<string, unknown>;
|
|
117
|
+
//# sourceMappingURL=RunTelemetryTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunTelemetryTypes.d.ts","sourceRoot":"","sources":["../../src/runtime/RunTelemetryTypes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,EAAG,CAAU,CAAC;AAEvD,MAAM,MAAM,yBAAyB,GAAG,OAAO,4BAA4B,CAAC;AAE5E,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;AAE1D,MAAM,MAAM,eAAe,GACvB,mBAAmB,GACnB,sBAAsB,GACtB,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,kBAAkB,GAClB,iBAAiB,CAAC;AAEtB,MAAM,MAAM,sBAAsB,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;AAE1E,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,iBAAiB,GAAG,SAAS,CAAC;AAE7E,MAAM,MAAM,mBAAmB,GAC3B,eAAe,GACf,cAAc,GACd,4BAA4B,GAC5B,qBAAqB,GACrB,0BAA0B,GAC1B,gBAAgB,GAChB,SAAS,CAAC;AAEd,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE7E,MAAM,MAAM,0BAA0B,GAAG,WAAW,GAAG,eAAe,CAAC;AAEvE,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,yBAAyB,CAAC;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,uBAAuB,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,0BAA0B,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aA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|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
export const RUN_TELEMETRY_SCHEMA_VERSION = 1;
|
|
2
|
+
export class RunTelemetryValidationError extends Error {
|
|
3
|
+
constructor(code, message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "RunTelemetryValidationError";
|
|
6
|
+
this.code = code;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
const asRecord = (value) => {
|
|
10
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
11
|
+
return undefined;
|
|
12
|
+
return value;
|
|
13
|
+
};
|
|
14
|
+
const normalizeNonEmptyString = (value, code, message) => {
|
|
15
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
16
|
+
throw new RunTelemetryValidationError(code, message);
|
|
17
|
+
}
|
|
18
|
+
return value.trim();
|
|
19
|
+
};
|
|
20
|
+
const normalizeFiniteNumber = (value) => {
|
|
21
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
22
|
+
return undefined;
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
const uniqueSortedStrings = (values) => {
|
|
26
|
+
if (!Array.isArray(values))
|
|
27
|
+
return [];
|
|
28
|
+
return Array.from(new Set(values
|
|
29
|
+
.filter((entry) => typeof entry === "string")
|
|
30
|
+
.map((entry) => entry.trim())
|
|
31
|
+
.filter((entry) => entry.length > 0))).sort((left, right) => left.localeCompare(right));
|
|
32
|
+
};
|
|
33
|
+
export const stableSortValue = (value) => {
|
|
34
|
+
if (Array.isArray(value)) {
|
|
35
|
+
return value.map((entry) => stableSortValue(entry));
|
|
36
|
+
}
|
|
37
|
+
if (!value || typeof value !== "object")
|
|
38
|
+
return value;
|
|
39
|
+
const source = value;
|
|
40
|
+
const ordered = Object.keys(source)
|
|
41
|
+
.sort((left, right) => left.localeCompare(right))
|
|
42
|
+
.map((key) => [key, stableSortValue(source[key])]);
|
|
43
|
+
return Object.fromEntries(ordered);
|
|
44
|
+
};
|
|
45
|
+
const QUALITY_DEFAULTS = {
|
|
46
|
+
plan: "missing",
|
|
47
|
+
retrieval: "missing",
|
|
48
|
+
patch: "missing",
|
|
49
|
+
verification: "missing",
|
|
50
|
+
final_disposition: "available",
|
|
51
|
+
};
|
|
52
|
+
const DISPOSITION_STATUSES = ["pass", "fail", "degraded"];
|
|
53
|
+
const FAILURE_CLASSES = [
|
|
54
|
+
"execution_failure",
|
|
55
|
+
"verification_failure",
|
|
56
|
+
"policy_failure",
|
|
57
|
+
"safety_failure",
|
|
58
|
+
"patch_failure",
|
|
59
|
+
"provider_failure",
|
|
60
|
+
"unknown_failure",
|
|
61
|
+
];
|
|
62
|
+
const TELEMETRY_REASON_CODES = [
|
|
63
|
+
"usage_missing",
|
|
64
|
+
"cost_missing",
|
|
65
|
+
"provider_usage_not_exposed",
|
|
66
|
+
"pricing_unavailable",
|
|
67
|
+
"phase_not_model_invoking",
|
|
68
|
+
"not_applicable",
|
|
69
|
+
"unknown",
|
|
70
|
+
];
|
|
71
|
+
const normalizeQualityDimension = (value) => {
|
|
72
|
+
if (value === "available" || value === "missing" || value === "degraded")
|
|
73
|
+
return value;
|
|
74
|
+
return "missing";
|
|
75
|
+
};
|
|
76
|
+
export const normalizeFailureClass = (value) => {
|
|
77
|
+
if (typeof value !== "string")
|
|
78
|
+
return undefined;
|
|
79
|
+
const normalized = value.trim().toLowerCase();
|
|
80
|
+
if (FAILURE_CLASSES.includes(normalized)) {
|
|
81
|
+
return normalized;
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
};
|
|
85
|
+
const normalizeReasonCode = (value) => {
|
|
86
|
+
if (typeof value !== "string")
|
|
87
|
+
return undefined;
|
|
88
|
+
const normalized = value.trim().toLowerCase();
|
|
89
|
+
if (TELEMETRY_REASON_CODES.includes(normalized)) {
|
|
90
|
+
return normalized;
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
};
|
|
94
|
+
const normalizeArtifactReference = (value) => {
|
|
95
|
+
const record = asRecord(value);
|
|
96
|
+
if (!record)
|
|
97
|
+
return undefined;
|
|
98
|
+
const phase = typeof record.phase === "string" ? record.phase.trim() : "";
|
|
99
|
+
const kind = typeof record.kind === "string" ? record.kind.trim() : "";
|
|
100
|
+
if (!phase || !kind)
|
|
101
|
+
return undefined;
|
|
102
|
+
const status = record.status === "present" || record.status === "missing" ? record.status : "present";
|
|
103
|
+
const pathValue = typeof record.path === "string"
|
|
104
|
+
? record.path
|
|
105
|
+
: record.path === null
|
|
106
|
+
? null
|
|
107
|
+
: undefined;
|
|
108
|
+
const reasonCode = typeof record.reason_code === "string" && record.reason_code.trim().length > 0
|
|
109
|
+
? record.reason_code.trim()
|
|
110
|
+
: undefined;
|
|
111
|
+
return {
|
|
112
|
+
phase,
|
|
113
|
+
kind,
|
|
114
|
+
status,
|
|
115
|
+
path: pathValue,
|
|
116
|
+
reason_code: reasonCode,
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
const normalizeTelemetrySource = (value) => {
|
|
120
|
+
if (value === "actual_usage" || value === "estimated_usage" || value === "unknown") {
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
return "unknown";
|
|
124
|
+
};
|
|
125
|
+
export const normalizePhaseTelemetryRecord = (input) => {
|
|
126
|
+
const runId = normalizeNonEmptyString(input.run_id, "phase_telemetry_missing_run_id", "phase telemetry requires run_id");
|
|
127
|
+
const phase = normalizeNonEmptyString(input.phase, "phase_telemetry_missing_phase", "phase telemetry requires phase");
|
|
128
|
+
const usageRecord = asRecord(input.usage);
|
|
129
|
+
const inputTokens = normalizeFiniteNumber(usageRecord?.input_tokens);
|
|
130
|
+
const outputTokens = normalizeFiniteNumber(usageRecord?.output_tokens);
|
|
131
|
+
const totalTokens = normalizeFiniteNumber(usageRecord?.total_tokens);
|
|
132
|
+
const hasUsage = inputTokens !== undefined || outputTokens !== undefined || totalTokens !== undefined;
|
|
133
|
+
const costRecord = asRecord(input.cost);
|
|
134
|
+
const costUsd = normalizeFiniteNumber(costRecord?.usd);
|
|
135
|
+
const costSource = normalizeTelemetrySource(costRecord?.source);
|
|
136
|
+
const costPricingSource = typeof costRecord?.pricing_source === "string" ? costRecord.pricing_source : undefined;
|
|
137
|
+
const costReasonCode = normalizeReasonCode(costRecord?.reason_code);
|
|
138
|
+
const hasCost = costUsd !== undefined || costSource !== "unknown" || costReasonCode !== undefined;
|
|
139
|
+
const missingUsageReason = normalizeReasonCode(input.missing_usage_reason);
|
|
140
|
+
const missingCostReason = normalizeReasonCode(input.missing_cost_reason);
|
|
141
|
+
if (!hasUsage && !missingUsageReason) {
|
|
142
|
+
throw new RunTelemetryValidationError("phase_telemetry_missing_usage_reason", "phase telemetry without usage requires missing_usage_reason");
|
|
143
|
+
}
|
|
144
|
+
if (!hasCost && !missingCostReason) {
|
|
145
|
+
throw new RunTelemetryValidationError("phase_telemetry_missing_cost_reason", "phase telemetry without cost requires missing_cost_reason");
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
schema_version: RUN_TELEMETRY_SCHEMA_VERSION,
|
|
149
|
+
run_id: runId,
|
|
150
|
+
phase,
|
|
151
|
+
provider: typeof input.provider === "string" ? input.provider : undefined,
|
|
152
|
+
model: typeof input.model === "string" ? input.model : undefined,
|
|
153
|
+
duration_ms: normalizeFiniteNumber(input.duration_ms),
|
|
154
|
+
usage: hasUsage
|
|
155
|
+
? {
|
|
156
|
+
input_tokens: inputTokens,
|
|
157
|
+
output_tokens: outputTokens,
|
|
158
|
+
total_tokens: totalTokens,
|
|
159
|
+
}
|
|
160
|
+
: undefined,
|
|
161
|
+
cost: hasCost
|
|
162
|
+
? {
|
|
163
|
+
usd: costUsd,
|
|
164
|
+
source: costSource,
|
|
165
|
+
pricing_source: costPricingSource,
|
|
166
|
+
reason_code: costReasonCode,
|
|
167
|
+
}
|
|
168
|
+
: undefined,
|
|
169
|
+
missing_usage_reason: missingUsageReason,
|
|
170
|
+
missing_cost_reason: missingCostReason,
|
|
171
|
+
metadata: asRecord(input.metadata),
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
const normalizeDisposition = (value) => {
|
|
175
|
+
if (typeof value === "string" && DISPOSITION_STATUSES.includes(value)) {
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
return "pass";
|
|
179
|
+
};
|
|
180
|
+
const normalizeFinalDisposition = (value) => {
|
|
181
|
+
const record = asRecord(value);
|
|
182
|
+
const status = normalizeDisposition(record?.status);
|
|
183
|
+
const reasonCodes = uniqueSortedStrings(record?.reason_codes);
|
|
184
|
+
const failureClass = normalizeFailureClass(record?.failure_class);
|
|
185
|
+
const retryable = typeof record?.retryable === "boolean" || record?.retryable === null
|
|
186
|
+
? record.retryable
|
|
187
|
+
: undefined;
|
|
188
|
+
return {
|
|
189
|
+
status,
|
|
190
|
+
failure_class: status === "pass" ? undefined : failureClass ?? "unknown_failure",
|
|
191
|
+
reason_codes: reasonCodes,
|
|
192
|
+
stage: typeof record?.stage === "string" ? record.stage : undefined,
|
|
193
|
+
retryable,
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
export const normalizeRunSummaryData = (input, fallbackRunId) => {
|
|
197
|
+
const resolvedRunIdCandidate = (typeof input.run_id === "string" ? input.run_id : undefined)
|
|
198
|
+
?? (typeof input.runId === "string" ? input.runId : undefined)
|
|
199
|
+
?? fallbackRunId;
|
|
200
|
+
const runId = normalizeNonEmptyString(resolvedRunIdCandidate, "run_summary_missing_run_id", "run summary requires run_id or runId");
|
|
201
|
+
const durationMs = normalizeFiniteNumber(input.durationMs) ?? 0;
|
|
202
|
+
const touchedFiles = uniqueSortedStrings(input.touchedFiles);
|
|
203
|
+
const qualityInput = asRecord(input.quality_dimensions);
|
|
204
|
+
const qualityDimensions = {
|
|
205
|
+
plan: normalizeQualityDimension(qualityInput?.plan ?? QUALITY_DEFAULTS.plan),
|
|
206
|
+
retrieval: normalizeQualityDimension(qualityInput?.retrieval ?? QUALITY_DEFAULTS.retrieval),
|
|
207
|
+
patch: normalizeQualityDimension(qualityInput?.patch ?? QUALITY_DEFAULTS.patch),
|
|
208
|
+
verification: normalizeQualityDimension(qualityInput?.verification ?? QUALITY_DEFAULTS.verification),
|
|
209
|
+
final_disposition: normalizeQualityDimension(qualityInput?.final_disposition ?? QUALITY_DEFAULTS.final_disposition),
|
|
210
|
+
};
|
|
211
|
+
const finalDisposition = normalizeFinalDisposition(input.final_disposition);
|
|
212
|
+
const artifactReferencesRaw = Array.isArray(input.artifact_references)
|
|
213
|
+
? input.artifact_references
|
|
214
|
+
: [];
|
|
215
|
+
const artifactReferences = artifactReferencesRaw
|
|
216
|
+
.map((entry) => normalizeArtifactReference(entry))
|
|
217
|
+
.filter((entry) => Boolean(entry))
|
|
218
|
+
.sort((left, right) => `${left.phase}:${left.kind}:${left.path ?? ""}`.localeCompare(`${right.phase}:${right.kind}:${right.path ?? ""}`));
|
|
219
|
+
const missingArtifacts = uniqueSortedStrings(input.missing_artifacts
|
|
220
|
+
?? artifactReferences
|
|
221
|
+
.filter((entry) => entry.status === "missing")
|
|
222
|
+
.map((entry) => `${entry.phase}:${entry.kind}`));
|
|
223
|
+
const phaseTelemetryRaw = Array.isArray(input.phase_telemetry) ? input.phase_telemetry : [];
|
|
224
|
+
const phaseTelemetry = phaseTelemetryRaw
|
|
225
|
+
.map((entry) => normalizePhaseTelemetryRecord({ ...entry, run_id: runId }))
|
|
226
|
+
.sort((left, right) => left.phase.localeCompare(right.phase));
|
|
227
|
+
const knownKeys = new Set([
|
|
228
|
+
"schema_version",
|
|
229
|
+
"run_id",
|
|
230
|
+
"runId",
|
|
231
|
+
"durationMs",
|
|
232
|
+
"touchedFiles",
|
|
233
|
+
"quality_dimensions",
|
|
234
|
+
"final_disposition",
|
|
235
|
+
"artifact_references",
|
|
236
|
+
"phase_telemetry",
|
|
237
|
+
"missing_artifacts",
|
|
238
|
+
]);
|
|
239
|
+
const passthrough = {};
|
|
240
|
+
for (const [key, value] of Object.entries(input)) {
|
|
241
|
+
if (knownKeys.has(key))
|
|
242
|
+
continue;
|
|
243
|
+
passthrough[key] = value;
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
...passthrough,
|
|
247
|
+
schema_version: RUN_TELEMETRY_SCHEMA_VERSION,
|
|
248
|
+
run_id: runId,
|
|
249
|
+
runId,
|
|
250
|
+
durationMs,
|
|
251
|
+
touchedFiles,
|
|
252
|
+
quality_dimensions: qualityDimensions,
|
|
253
|
+
final_disposition: finalDisposition,
|
|
254
|
+
artifact_references: artifactReferences,
|
|
255
|
+
phase_telemetry: phaseTelemetry,
|
|
256
|
+
missing_artifacts: missingArtifacts,
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
export const normalizeSafetyTelemetryEventData = (input, fallbackRunId) => {
|
|
260
|
+
const runId = normalizeNonEmptyString(input.run_id ?? fallbackRunId, "safety_event_missing_run_id", "safety telemetry requires run_id");
|
|
261
|
+
const phase = normalizeNonEmptyString(input.phase, "safety_event_missing_phase", "safety telemetry requires phase");
|
|
262
|
+
const code = normalizeNonEmptyString(input.code, "safety_event_missing_code", "safety telemetry requires code");
|
|
263
|
+
const message = normalizeNonEmptyString(input.message, "safety_event_missing_message", "safety telemetry requires message");
|
|
264
|
+
if (!input.category) {
|
|
265
|
+
throw new RunTelemetryValidationError("safety_event_missing_category", "safety telemetry requires category");
|
|
266
|
+
}
|
|
267
|
+
if (!input.disposition) {
|
|
268
|
+
throw new RunTelemetryValidationError("safety_event_missing_disposition", "safety telemetry requires disposition");
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
schema_version: RUN_TELEMETRY_SCHEMA_VERSION,
|
|
272
|
+
run_id: runId,
|
|
273
|
+
phase,
|
|
274
|
+
category: input.category,
|
|
275
|
+
code,
|
|
276
|
+
disposition: input.disposition,
|
|
277
|
+
message,
|
|
278
|
+
source: typeof input.source === "string" ? input.source : undefined,
|
|
279
|
+
tool: typeof input.tool === "string" ? input.tool : undefined,
|
|
280
|
+
failure_class: normalizeFailureClass(input.failure_class),
|
|
281
|
+
reason_codes: uniqueSortedStrings(input.reason_codes),
|
|
282
|
+
details: asRecord(input.details),
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
export const normalizeRunEventPayload = (type, data, fallbackRunId) => {
|
|
286
|
+
if (type === "run_summary") {
|
|
287
|
+
return stableSortValue(normalizeRunSummaryData(data, fallbackRunId));
|
|
288
|
+
}
|
|
289
|
+
if (type === "phase_telemetry") {
|
|
290
|
+
return stableSortValue(normalizePhaseTelemetryRecord({
|
|
291
|
+
...data,
|
|
292
|
+
run_id: typeof data.run_id === "string" ? data.run_id : fallbackRunId,
|
|
293
|
+
}));
|
|
294
|
+
}
|
|
295
|
+
if (type === "safety_event") {
|
|
296
|
+
return stableSortValue(normalizeSafetyTelemetryEventData(data, fallbackRunId));
|
|
297
|
+
}
|
|
298
|
+
return stableSortValue(data);
|
|
299
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { AgentEvent, Provider, ProviderMessage, ProviderRequest, ProviderResponseFormat, ProviderUsage } from "../providers/ProviderTypes.js";
|
|
2
|
+
import { ToolRegistry } from "../tools/ToolRegistry.js";
|
|
3
|
+
import type { ToolContext } from "../tools/ToolTypes.js";
|
|
4
|
+
import type { RunLogger } from "./RunLogger.js";
|
|
5
|
+
export interface RunnerOptions {
|
|
6
|
+
provider: Provider;
|
|
7
|
+
tools: ToolRegistry;
|
|
8
|
+
context: ToolContext;
|
|
9
|
+
maxSteps: number;
|
|
10
|
+
maxToolCalls: number;
|
|
11
|
+
maxTokens?: number;
|
|
12
|
+
temperature?: number;
|
|
13
|
+
responseFormat?: ProviderResponseFormat;
|
|
14
|
+
toolChoice?: ProviderRequest["toolChoice"];
|
|
15
|
+
stream?: boolean;
|
|
16
|
+
onEvent?: (event: AgentEvent) => void;
|
|
17
|
+
onToken?: (token: string) => void;
|
|
18
|
+
streamFlushMs?: number;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
logger?: RunLogger;
|
|
21
|
+
}
|
|
22
|
+
export interface RunnerResult {
|
|
23
|
+
finalMessage: ProviderMessage;
|
|
24
|
+
messages: ProviderMessage[];
|
|
25
|
+
toolCallsExecuted: number;
|
|
26
|
+
usage?: ProviderUsage;
|
|
27
|
+
}
|
|
28
|
+
export type RunnerBudgetReasonCode = "runner_timeout_exceeded" | "runner_tool_call_limit_exceeded" | "runner_step_limit_exceeded";
|
|
29
|
+
export declare class RunnerBudgetError extends Error {
|
|
30
|
+
readonly code: RunnerBudgetReasonCode;
|
|
31
|
+
readonly metadata: {
|
|
32
|
+
reason_code: RunnerBudgetReasonCode;
|
|
33
|
+
step: number;
|
|
34
|
+
tool_calls_executed: number;
|
|
35
|
+
max_steps: number;
|
|
36
|
+
max_tool_calls: number;
|
|
37
|
+
timeout_ms?: number;
|
|
38
|
+
};
|
|
39
|
+
constructor(code: RunnerBudgetReasonCode, metadata: {
|
|
40
|
+
step: number;
|
|
41
|
+
tool_calls_executed: number;
|
|
42
|
+
max_steps: number;
|
|
43
|
+
max_tool_calls: number;
|
|
44
|
+
timeout_ms?: number;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export declare class Runner {
|
|
48
|
+
private provider;
|
|
49
|
+
private tools;
|
|
50
|
+
private context;
|
|
51
|
+
private maxSteps;
|
|
52
|
+
private maxToolCalls;
|
|
53
|
+
private maxTokens?;
|
|
54
|
+
private temperature?;
|
|
55
|
+
private responseFormat?;
|
|
56
|
+
private toolChoice?;
|
|
57
|
+
private stream?;
|
|
58
|
+
private onEvent?;
|
|
59
|
+
private onToken?;
|
|
60
|
+
private streamFlushMs?;
|
|
61
|
+
private timeoutMs?;
|
|
62
|
+
private logger?;
|
|
63
|
+
constructor(options: RunnerOptions);
|
|
64
|
+
run(initialMessages: ProviderMessage[]): Promise<RunnerResult>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=Runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Runner.d.ts","sourceRoot":"","sources":["../../src/runtime/Runner.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