@opensearch-project/agent-health 0.5.2 → 0.7.0
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 +1 -0
- package/cli/dist/index.js +2325 -961
- package/dist/assets/index-D-Np_l_T.js +246 -0
- package/dist/assets/index-vZt9QZKf.css +1 -0
- package/dist/index.html +2 -2
- package/docs/CLI.md +183 -3
- package/docs/CONFIGURATION.md +1 -1
- package/docs/CONNECTORS.md +1 -1
- package/docs/INSTRUMENT_WITH_OTEL.md +7 -0
- package/docs/SDK.md +178 -5
- package/docs/STORAGE_INDEX_FIELD_LIMITS.md +216 -0
- package/docs/skills/AGENT_HEALTH.md +55 -1
- package/docs/skills/add-connector/SKILL.md +5 -1
- package/examples/eval-files/demo.eval.js +1 -1
- package/examples/eval-files/ops-rca-classification.eval.js +71 -0
- package/examples/eval-files/ops-rca-evaluator.json +15 -0
- package/examples/eval-files/sdk-demo.eval.js +72 -0
- package/examples/eval-files/sdk-describe-demo.eval.js +50 -0
- package/examples/eval-files/sdk-hooks-demo.eval.js +1 -1
- package/lib/dist/lib/agentTrends.d.ts +210 -0
- package/lib/dist/lib/agentTrends.d.ts.map +1 -0
- package/lib/dist/lib/agentTrends.js +360 -0
- package/lib/dist/lib/agentTrends.js.map +1 -0
- package/lib/dist/lib/bedrockCompat.d.ts +27 -0
- package/lib/dist/lib/bedrockCompat.d.ts.map +1 -0
- package/lib/dist/lib/bedrockCompat.js +83 -0
- package/lib/dist/lib/bedrockCompat.js.map +1 -0
- package/lib/dist/lib/benchmarkCaseReview.d.ts +114 -0
- package/lib/dist/lib/benchmarkCaseReview.d.ts.map +1 -0
- package/lib/dist/lib/benchmarkCaseReview.js +177 -0
- package/lib/dist/lib/benchmarkCaseReview.js.map +1 -0
- package/lib/dist/lib/benchmarkImage.d.ts +52 -0
- package/lib/dist/lib/benchmarkImage.d.ts.map +1 -0
- package/lib/dist/lib/benchmarkImage.js +113 -0
- package/lib/dist/lib/benchmarkImage.js.map +1 -0
- package/lib/dist/lib/benchmarkRunsTable.d.ts +109 -0
- package/lib/dist/lib/benchmarkRunsTable.d.ts.map +1 -0
- package/lib/dist/lib/benchmarkRunsTable.js +212 -0
- package/lib/dist/lib/benchmarkRunsTable.js.map +1 -0
- package/lib/dist/lib/benchmarkVersionUtils.d.ts +13 -0
- package/lib/dist/lib/benchmarkVersionUtils.d.ts.map +1 -1
- package/lib/dist/lib/benchmarkVersionUtils.js +21 -0
- package/lib/dist/lib/benchmarkVersionUtils.js.map +1 -1
- package/lib/dist/lib/chunkedFetch.d.ts +18 -0
- package/lib/dist/lib/chunkedFetch.d.ts.map +1 -0
- package/lib/dist/lib/chunkedFetch.js +40 -0
- package/lib/dist/lib/chunkedFetch.js.map +1 -0
- package/lib/dist/lib/comparisonInsights.d.ts +151 -0
- package/lib/dist/lib/comparisonInsights.d.ts.map +1 -0
- package/lib/dist/lib/comparisonInsights.js +270 -0
- package/lib/dist/lib/comparisonInsights.js.map +1 -0
- package/lib/dist/lib/config/loader.d.ts.map +1 -1
- package/lib/dist/lib/config/loader.js +16 -1
- package/lib/dist/lib/config/loader.js.map +1 -1
- package/lib/dist/lib/config/types.d.ts +14 -0
- package/lib/dist/lib/config/types.d.ts.map +1 -1
- package/lib/dist/lib/constants.d.ts +11 -0
- package/lib/dist/lib/constants.d.ts.map +1 -1
- package/lib/dist/lib/constants.js +10 -1
- package/lib/dist/lib/constants.js.map +1 -1
- package/lib/dist/lib/contextFormat.d.ts +26 -0
- package/lib/dist/lib/contextFormat.d.ts.map +1 -0
- package/lib/dist/lib/contextFormat.js +28 -0
- package/lib/dist/lib/contextFormat.js.map +1 -0
- package/lib/dist/lib/dashboardMetrics.d.ts +11 -2
- package/lib/dist/lib/dashboardMetrics.d.ts.map +1 -1
- package/lib/dist/lib/dashboardMetrics.js +38 -3
- package/lib/dist/lib/dashboardMetrics.js.map +1 -1
- package/lib/dist/lib/envCompat.d.ts.map +1 -1
- package/lib/dist/lib/envCompat.js +14 -5
- package/lib/dist/lib/envCompat.js.map +1 -1
- package/lib/dist/lib/evaluationRerun.d.ts +102 -0
- package/lib/dist/lib/evaluationRerun.d.ts.map +1 -0
- package/lib/dist/lib/evaluationRerun.js +134 -0
- package/lib/dist/lib/evaluationRerun.js.map +1 -0
- package/lib/dist/lib/judgeFailureSummary.d.ts +66 -0
- package/lib/dist/lib/judgeFailureSummary.d.ts.map +1 -0
- package/lib/dist/lib/judgeFailureSummary.js +68 -0
- package/lib/dist/lib/judgeFailureSummary.js.map +1 -0
- package/lib/dist/lib/judgeStrategies.d.ts +108 -0
- package/lib/dist/lib/judgeStrategies.d.ts.map +1 -0
- package/lib/dist/lib/judgeStrategies.js +135 -0
- package/lib/dist/lib/judgeStrategies.js.map +1 -0
- package/lib/dist/lib/matchers/expect.d.ts +21 -1
- package/lib/dist/lib/matchers/expect.d.ts.map +1 -1
- package/lib/dist/lib/matchers/expect.js +51 -0
- package/lib/dist/lib/matchers/expect.js.map +1 -1
- package/lib/dist/lib/matchers/judgeAccessor.d.ts +4 -0
- package/lib/dist/lib/matchers/judgeAccessor.d.ts.map +1 -1
- package/lib/dist/lib/matchers/judgeAccessor.js +13 -2
- package/lib/dist/lib/matchers/judgeAccessor.js.map +1 -1
- package/lib/dist/lib/matchers/judgeReasoningParse.d.ts +49 -0
- package/lib/dist/lib/matchers/judgeReasoningParse.d.ts.map +1 -0
- package/lib/dist/lib/matchers/judgeReasoningParse.js +128 -0
- package/lib/dist/lib/matchers/judgeReasoningParse.js.map +1 -0
- package/lib/dist/lib/matchers/traces.d.ts +17 -2
- package/lib/dist/lib/matchers/traces.d.ts.map +1 -1
- package/lib/dist/lib/matchers/traces.js +136 -16
- package/lib/dist/lib/matchers/traces.js.map +1 -1
- package/lib/dist/lib/matchers/tracesPricing.d.ts +38 -0
- package/lib/dist/lib/matchers/tracesPricing.d.ts.map +1 -0
- package/lib/dist/lib/matchers/tracesPricing.js +64 -0
- package/lib/dist/lib/matchers/tracesPricing.js.map +1 -0
- package/lib/dist/lib/matchers/types.d.ts +25 -0
- package/lib/dist/lib/matchers/types.d.ts.map +1 -1
- package/lib/dist/lib/resolveCanonicalRun.d.ts +23 -0
- package/lib/dist/lib/resolveCanonicalRun.d.ts.map +1 -0
- package/lib/dist/lib/resolveCanonicalRun.js +26 -0
- package/lib/dist/lib/resolveCanonicalRun.js.map +1 -0
- package/lib/dist/lib/runActions.d.ts +120 -0
- package/lib/dist/lib/runActions.d.ts.map +1 -0
- package/lib/dist/lib/runActions.js +130 -0
- package/lib/dist/lib/runActions.js.map +1 -0
- package/lib/dist/lib/runInsights.d.ts +86 -0
- package/lib/dist/lib/runInsights.d.ts.map +1 -0
- package/lib/dist/lib/runInsights.js +185 -0
- package/lib/dist/lib/runInsights.js.map +1 -0
- package/lib/dist/lib/runName.d.ts +29 -0
- package/lib/dist/lib/runName.d.ts.map +1 -0
- package/lib/dist/lib/runName.js +38 -0
- package/lib/dist/lib/runName.js.map +1 -0
- package/lib/dist/lib/runReportPath.d.ts +16 -0
- package/lib/dist/lib/runReportPath.d.ts.map +1 -0
- package/lib/dist/lib/runReportPath.js +22 -0
- package/lib/dist/lib/runReportPath.js.map +1 -0
- package/lib/dist/lib/runSort.d.ts +27 -0
- package/lib/dist/lib/runSort.d.ts.map +1 -0
- package/lib/dist/lib/runSort.js +31 -0
- package/lib/dist/lib/runSort.js.map +1 -0
- package/lib/dist/lib/runStats.d.ts +109 -5
- package/lib/dist/lib/runStats.d.ts.map +1 -1
- package/lib/dist/lib/runStats.js +193 -10
- package/lib/dist/lib/runStats.js.map +1 -1
- package/lib/dist/lib/testCases/define.d.ts.map +1 -1
- package/lib/dist/lib/testCases/define.js +93 -46
- package/lib/dist/lib/testCases/define.js.map +1 -1
- package/lib/dist/lib/testCases/judge.d.ts.map +1 -1
- package/lib/dist/lib/testCases/judge.js +22 -4
- package/lib/dist/lib/testCases/judge.js.map +1 -1
- package/lib/dist/lib/testCases/loader.d.ts +35 -1
- package/lib/dist/lib/testCases/loader.d.ts.map +1 -1
- package/lib/dist/lib/testCases/loader.js +278 -31
- package/lib/dist/lib/testCases/loader.js.map +1 -1
- package/lib/dist/lib/trajectoryStepDisplay.d.ts +25 -0
- package/lib/dist/lib/trajectoryStepDisplay.d.ts.map +1 -0
- package/lib/dist/lib/trajectoryStepDisplay.js +42 -0
- package/lib/dist/lib/trajectoryStepDisplay.js.map +1 -0
- package/lib/dist/lib/utils.d.ts +34 -0
- package/lib/dist/lib/utils.d.ts.map +1 -1
- package/lib/dist/lib/utils.js +49 -0
- package/lib/dist/lib/utils.js.map +1 -1
- package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.d.ts +68 -22
- package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.d.ts.map +1 -1
- package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.js +148 -111
- package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.js.map +1 -1
- package/lib/dist/services/connectors/kiro/KiroConnector.d.ts +21 -13
- package/lib/dist/services/connectors/kiro/KiroConnector.d.ts.map +1 -1
- package/lib/dist/services/connectors/kiro/KiroConnector.js +22 -25
- package/lib/dist/services/connectors/kiro/KiroConnector.js.map +1 -1
- package/lib/dist/services/connectors/pi/PiConnector.d.ts +49 -10
- package/lib/dist/services/connectors/pi/PiConnector.d.ts.map +1 -1
- package/lib/dist/services/connectors/pi/PiConnector.js +102 -86
- package/lib/dist/services/connectors/pi/PiConnector.js.map +1 -1
- package/lib/dist/services/connectors/subprocess/SubprocessConnector.d.ts +59 -14
- package/lib/dist/services/connectors/subprocess/SubprocessConnector.d.ts.map +1 -1
- package/lib/dist/services/connectors/subprocess/SubprocessConnector.js +95 -61
- package/lib/dist/services/connectors/subprocess/SubprocessConnector.js.map +1 -1
- package/lib/dist/services/evaluation/bedrockJudge.d.ts +18 -0
- package/lib/dist/services/evaluation/bedrockJudge.d.ts.map +1 -1
- package/lib/dist/services/evaluation/bedrockJudge.js +4 -0
- package/lib/dist/services/evaluation/bedrockJudge.js.map +1 -1
- package/lib/dist/services/evaluation/index.d.ts +18 -1
- package/lib/dist/services/evaluation/index.d.ts.map +1 -1
- package/lib/dist/services/evaluation/index.js +156 -19
- package/lib/dist/services/evaluation/index.js.map +1 -1
- package/lib/dist/services/metrics.d.ts +55 -0
- package/lib/dist/services/metrics.d.ts.map +1 -0
- package/lib/dist/services/metrics.js +89 -0
- package/lib/dist/services/metrics.js.map +1 -0
- package/lib/dist/services/storage/asyncBenchmarkStorage.d.ts +1 -1
- package/lib/dist/services/storage/asyncBenchmarkStorage.d.ts.map +1 -1
- package/lib/dist/services/storage/asyncBenchmarkStorage.js +30 -3
- package/lib/dist/services/storage/asyncBenchmarkStorage.js.map +1 -1
- package/lib/dist/services/storage/asyncRunStorage.d.ts +20 -1
- package/lib/dist/services/storage/asyncRunStorage.d.ts.map +1 -1
- package/lib/dist/services/storage/asyncRunStorage.js +125 -2
- package/lib/dist/services/storage/asyncRunStorage.js.map +1 -1
- package/lib/dist/services/storage/asyncTestCaseStorage.d.ts +18 -4
- package/lib/dist/services/storage/asyncTestCaseStorage.d.ts.map +1 -1
- package/lib/dist/services/storage/asyncTestCaseStorage.js +21 -4
- package/lib/dist/services/storage/asyncTestCaseStorage.js.map +1 -1
- package/lib/dist/services/storage/opensearchClient.d.ts +47 -12
- package/lib/dist/services/storage/opensearchClient.d.ts.map +1 -1
- package/lib/dist/services/storage/opensearchClient.js +12 -5
- package/lib/dist/services/storage/opensearchClient.js.map +1 -1
- package/lib/dist/services/traces/browserRecovery.d.ts +12 -1
- package/lib/dist/services/traces/browserRecovery.d.ts.map +1 -1
- package/lib/dist/services/traces/browserRecovery.js +35 -5
- package/lib/dist/services/traces/browserRecovery.js.map +1 -1
- package/lib/dist/services/traces/index.d.ts +8 -1
- package/lib/dist/services/traces/index.d.ts.map +1 -1
- package/lib/dist/services/traces/index.js +33 -12
- package/lib/dist/services/traces/index.js.map +1 -1
- package/lib/dist/services/traces/judgeAgentsHints.d.ts +98 -3
- package/lib/dist/services/traces/judgeAgentsHints.d.ts.map +1 -1
- package/lib/dist/services/traces/judgeAgentsHints.js +144 -3
- package/lib/dist/services/traces/judgeAgentsHints.js.map +1 -1
- package/lib/dist/services/traces/messageExtraction.d.ts.map +1 -1
- package/lib/dist/services/traces/messageExtraction.js +95 -33
- package/lib/dist/services/traces/messageExtraction.js.map +1 -1
- package/lib/dist/services/traces/spansToTrajectory.d.ts.map +1 -1
- package/lib/dist/services/traces/spansToTrajectory.js +51 -13
- package/lib/dist/services/traces/spansToTrajectory.js.map +1 -1
- package/lib/dist/services/traces/tracePoller.d.ts +27 -3
- package/lib/dist/services/traces/tracePoller.d.ts.map +1 -1
- package/lib/dist/services/traces/tracePoller.js +196 -33
- package/lib/dist/services/traces/tracePoller.js.map +1 -1
- package/lib/dist/services/traces/trajectoryMerge.d.ts +79 -0
- package/lib/dist/services/traces/trajectoryMerge.d.ts.map +1 -0
- package/lib/dist/services/traces/trajectoryMerge.js +109 -0
- package/lib/dist/services/traces/trajectoryMerge.js.map +1 -0
- package/lib/dist/types/index.d.ts +250 -3
- package/lib/dist/types/index.d.ts.map +1 -1
- package/lib/dist/types/index.js +24 -0
- package/lib/dist/types/index.js.map +1 -1
- package/package.json +8 -5
- package/server/dist/app.js +5490 -1557
- package/server/dist/index.js +5490 -1557
- package/dist/assets/index-CCQRDlO0.js +0 -243
- package/dist/assets/index-CNHQVbcj.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAmB,MAAM,MAAM,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,UAAU,EAAE,CAAC,GAAG,MAAoB;IACxC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AA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B,GAAG,CAAC,IAAwE,EAAU,EAAE;IACrH,MAAM,MAAM,GAAG;QACb,OAAO,EAAE,kCAAkC;QAC3C,OAAO,EAAE,oCAAoC;QAC7C,KAAK,EAAE,gCAAgC;QACvC,OAAO,EAAE,oCAAoC;QAC7C,IAAI,EAAE,sCAAsC;QAC5C,SAAS,EAAE,kCAAkC;KAC9C,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC,CAAC;AAEF,2DAA2D;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,MAAc,EAAU,EAAE;IAC/D,IAAI,IAAI,CAAC,MAAM,IAAI,MAAM;QAAE,OAAO,IAAI,CAAC;IACvC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC;AAClD,CAAC,CAAC;AAEF,2EAA2E;AAE3E;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACrC,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9E,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -3,8 +3,45 @@
|
|
|
3
3
|
* Specialized subprocess connector for Claude Code CLI
|
|
4
4
|
*/
|
|
5
5
|
import type { TrajectoryStep } from '../../../types/index.js';
|
|
6
|
-
import { SubprocessConnector } from '../../../services/connectors/subprocess/SubprocessConnector.js';
|
|
6
|
+
import { SubprocessConnector, type SubprocessExecutionState } from '../../../services/connectors/subprocess/SubprocessConnector.js';
|
|
7
7
|
import type { ConnectorAuth, ConnectorRequest, ConnectorProgressCallback, SubprocessConfig } from '../../../services/connectors/types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Upper bound on the tool output text persisted per `tool_result` step
|
|
10
|
+
* (`content` + `toolOutput`). Larger outputs are cut here with an explicit
|
|
11
|
+
* truncation marker carrying the original length, so the judge knows it saw
|
|
12
|
+
* a prefix. The full stream stays in `report.rawEvents`. Sized to cover the
|
|
13
|
+
* largest single results observed live (~28 KB) without doubling every
|
|
14
|
+
* report; the judge's own per-step cap (`AH_JUDGE_TOOL_OUTPUT_CAP`, default
|
|
15
|
+
* 100 KB) is the outer bound.
|
|
16
|
+
*/
|
|
17
|
+
export declare const CLAUDE_CODE_MAX_TOOL_OUTPUT_CHARS: number;
|
|
18
|
+
/**
|
|
19
|
+
* Per-invocation parse state for one Claude Code subprocess. See
|
|
20
|
+
* {@link SubprocessExecutionState} for why none of this may live on the
|
|
21
|
+
* (singleton) connector instance.
|
|
22
|
+
*/
|
|
23
|
+
interface ClaudeCodeExecutionState extends SubprocessExecutionState {
|
|
24
|
+
/** Partial trailing NDJSON line carried between stdout chunks. */
|
|
25
|
+
outputBuffer: string;
|
|
26
|
+
thinkingBuffer: string;
|
|
27
|
+
textBuffer: string;
|
|
28
|
+
/**
|
|
29
|
+
* Claude Code's `session_id` (present on every stream-json event). Captured
|
|
30
|
+
* for Strategy D trace correlation — it equals the `session.id` attribute
|
|
31
|
+
* Claude Code stamps on its OTel spans. Surfaced to the report via
|
|
32
|
+
* {@link extraResultMetadata} → `report.sessionId`.
|
|
33
|
+
*/
|
|
34
|
+
sessionId?: string;
|
|
35
|
+
/**
|
|
36
|
+
* `tool_use` blocks seen so far, keyed by their id, so the matching
|
|
37
|
+
* `tool_result` block (which only carries `tool_use_id`) can be attributed
|
|
38
|
+
* to a tool name. Entries are consumed on pairing.
|
|
39
|
+
*/
|
|
40
|
+
pendingToolUses: Map<string, {
|
|
41
|
+
name: string;
|
|
42
|
+
input: unknown;
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
8
45
|
/**
|
|
9
46
|
* MCP server definition for Claude Code --mcp-config flag
|
|
10
47
|
*/
|
|
@@ -34,39 +71,31 @@ export interface ClaudeCodeConnectorConfig {
|
|
|
34
71
|
timeout?: number;
|
|
35
72
|
additionalArgs?: string[];
|
|
36
73
|
}
|
|
74
|
+
/** Cut `text` at `max` chars with an explicit marker carrying the full length. */
|
|
75
|
+
export declare function boundToolOutput(text: string, max?: number): string;
|
|
37
76
|
/**
|
|
38
77
|
* Claude Code CLI Connector
|
|
39
78
|
* Invokes Claude Code as a subprocess for agent evaluation
|
|
40
79
|
*/
|
|
41
|
-
export declare class ClaudeCodeConnector extends SubprocessConnector {
|
|
80
|
+
export declare class ClaudeCodeConnector extends SubprocessConnector<ClaudeCodeExecutionState> {
|
|
42
81
|
readonly type: "claude-code";
|
|
43
82
|
readonly name = "Claude Code CLI";
|
|
44
83
|
traceContext: {
|
|
45
84
|
propagateEnv: boolean;
|
|
46
85
|
serviceName: string;
|
|
47
86
|
};
|
|
48
|
-
private outputBuffer;
|
|
49
|
-
private thinkingBuffer;
|
|
50
|
-
private textBuffer;
|
|
51
|
-
private isInThinking;
|
|
52
|
-
/**
|
|
53
|
-
* Claude Code's `session_id` (present on every stream-json event). Captured
|
|
54
|
-
* for Strategy D trace correlation — it equals the `session.id` attribute
|
|
55
|
-
* Claude Code stamps on its OTel spans. Surfaced to the report via
|
|
56
|
-
* {@link extraResultMetadata}.
|
|
57
|
-
*/
|
|
58
|
-
private sessionId?;
|
|
59
87
|
constructor(config?: Partial<SubprocessConfig>);
|
|
60
88
|
/**
|
|
61
89
|
* Build prompt for Claude Code
|
|
62
90
|
* Structures the input to get the best RCA results
|
|
63
91
|
*/
|
|
64
92
|
buildPayload(request: ConnectorRequest): string;
|
|
93
|
+
protected createExecutionState(): ClaudeCodeExecutionState;
|
|
65
94
|
/**
|
|
66
95
|
* Parse Claude Code streaming output (stream-json format)
|
|
67
96
|
* Each line is a JSON object with type and content
|
|
68
97
|
*/
|
|
69
|
-
protected parseStreamingOutput(chunk: string, trajectory: TrajectoryStep[], onProgress
|
|
98
|
+
protected parseStreamingOutput(chunk: string, trajectory: TrajectoryStep[], onProgress: ConnectorProgressCallback | undefined, state: ClaudeCodeExecutionState): void;
|
|
70
99
|
/**
|
|
71
100
|
* Parse a single JSON event from stream-json output
|
|
72
101
|
*/
|
|
@@ -79,20 +108,34 @@ export declare class ClaudeCodeConnector extends SubprocessConnector {
|
|
|
79
108
|
stderr: string;
|
|
80
109
|
exitCode: number;
|
|
81
110
|
}): TrajectoryStep[];
|
|
82
|
-
/**
|
|
83
|
-
* Reset state for new execution
|
|
84
|
-
*/
|
|
85
|
-
private resetState;
|
|
86
111
|
/**
|
|
87
112
|
* Flush remaining buffers when the subprocess stream ends.
|
|
88
113
|
*/
|
|
89
|
-
protected onBeforeStreamEnd(trajectory: TrajectoryStep[], onProgress
|
|
114
|
+
protected onBeforeStreamEnd(trajectory: TrajectoryStep[], onProgress: ConnectorProgressCallback | undefined, state: ClaudeCodeExecutionState): void;
|
|
90
115
|
/**
|
|
91
116
|
* Build CLI args from ClaudeCodeConnectorConfig
|
|
92
117
|
*/
|
|
93
118
|
private buildConfigArgs;
|
|
94
119
|
/**
|
|
95
|
-
*
|
|
120
|
+
* Translate `ClaudeCodeConnectorConfig` (the agent's `connectorConfig`) into
|
|
121
|
+
* the effective per-execution subprocess config. Pure: builds a fresh
|
|
122
|
+
* snapshot from the constructor defaults — `this.config` is never written,
|
|
123
|
+
* so concurrent executions on the shared singleton cannot compound each
|
|
124
|
+
* other's flags (spawns were once observed with --append-system-prompt /
|
|
125
|
+
* --allowed-tools duplicated up to 5× at concurrency 3) or swap env /
|
|
126
|
+
* timeout / cwd.
|
|
127
|
+
*/
|
|
128
|
+
protected resolveExecutionConfig(request: ConnectorRequest): {
|
|
129
|
+
inputMode: import("../../../services/connectors/types.js").SubprocessInputMode;
|
|
130
|
+
env: Record<string, string>;
|
|
131
|
+
args: string[];
|
|
132
|
+
command: string;
|
|
133
|
+
outputParser: import("../../../services/connectors/types.js").SubprocessOutputParser;
|
|
134
|
+
timeout?: number;
|
|
135
|
+
workingDir?: string;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Override execute for debug logging around the base implementation.
|
|
96
139
|
*/
|
|
97
140
|
execute(endpoint: string, request: ConnectorRequest, auth: ConnectorAuth, onProgress?: ConnectorProgressCallback, onRawEvent?: (event: any) => void): Promise<import('../types.js').ConnectorResponse>;
|
|
98
141
|
/**
|
|
@@ -101,9 +144,11 @@ export declare class ClaudeCodeConnector extends SubprocessConnector {
|
|
|
101
144
|
healthCheck(endpoint: string, auth: ConnectorAuth): Promise<boolean>;
|
|
102
145
|
/**
|
|
103
146
|
* Surface the captured Claude Code `session_id` so the runner can persist it
|
|
104
|
-
* as `report.sessionId` for Strategy D trace correlation.
|
|
147
|
+
* as `report.sessionId` for Strategy D trace correlation. Read from the
|
|
148
|
+
* per-invocation state — never from the instance — so concurrent runs on
|
|
149
|
+
* the shared singleton can't swap session ids.
|
|
105
150
|
*/
|
|
106
|
-
protected extraResultMetadata(): Record<string, any>;
|
|
151
|
+
protected extraResultMetadata(state: ClaudeCodeExecutionState): Record<string, any>;
|
|
107
152
|
}
|
|
108
153
|
/**
|
|
109
154
|
* Create a Claude Code connector with specific Bedrock configuration
|
|
@@ -113,4 +158,5 @@ export declare function createBedrockClaudeCodeConnector(): ClaudeCodeConnector;
|
|
|
113
158
|
* Default instance for convenience
|
|
114
159
|
*/
|
|
115
160
|
export declare const claudeCodeConnector: ClaudeCodeConnector;
|
|
161
|
+
export {};
|
|
116
162
|
//# sourceMappingURL=ClaudeCodeConnector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClaudeCodeConnector.d.ts","sourceRoot":"","sources":["../../../../../services/connectors/claude-code/ClaudeCodeConnector.ts"],"names":[],"mappings":"AAKA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,
|
|
1
|
+
{"version":3,"file":"ClaudeCodeConnector.d.ts","sourceRoot":"","sources":["../../../../../services/connectors/claude-code/ClaudeCodeConnector.ts"],"names":[],"mappings":"AAKA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,EAC9B,MAAM,sDAAsD,CAAC;AAC9D,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC;;;;;;;;GAQG;AACH,eAAO,MAAM,iCAAiC,QAAY,CAAC;AAE3D;;;;GAIG;AACH,UAAU,wBAAyB,SAAQ,wBAAwB;IACjE,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAChE;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,C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KAAK,EAAE,wBAAwB,GAC9B,IAAI;IAmCP;;OAEG;IACH,OAAO,CAAC,eAAe;IAsCvB;;;;;;;;OAQG;cACgB,sBAAsB,CAAC,OAAO,EAAE,gBAAgB;;;;;;;;;IAoCnE;;OAEG;IACY,OAAO,CACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,aAAa,EACnB,UAAU,CAAC,EAAE,yBAAyB,EACtC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GAChC,OAAO,CAAC,OAAO,UAAU,EAAE,iBAAiB,CAAC;IAWhD;;OAEG;IACY,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAInF;;;;;OAKG;cACgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAM7F;AAED;;GAEG;AACH,wBAAgB,gCAAgC,IAAI,mBAAmB,CA6BtE;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,qBAA4B,CAAC"}
|
|
@@ -3,7 +3,17 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { ToolCallStatus } from '../../../types/index.js';
|
|
6
|
-
import { SubprocessConnector } from '../../../services/connectors/subprocess/SubprocessConnector.js';
|
|
6
|
+
import { SubprocessConnector, } from '../../../services/connectors/subprocess/SubprocessConnector.js';
|
|
7
|
+
/**
|
|
8
|
+
* Upper bound on the tool output text persisted per `tool_result` step
|
|
9
|
+
* (`content` + `toolOutput`). Larger outputs are cut here with an explicit
|
|
10
|
+
* truncation marker carrying the original length, so the judge knows it saw
|
|
11
|
+
* a prefix. The full stream stays in `report.rawEvents`. Sized to cover the
|
|
12
|
+
* largest single results observed live (~28 KB) without doubling every
|
|
13
|
+
* report; the judge's own per-step cap (`AH_JUDGE_TOOL_OUTPUT_CAP`, default
|
|
14
|
+
* 100 KB) is the outer bound.
|
|
15
|
+
*/
|
|
16
|
+
export const CLAUDE_CODE_MAX_TOOL_OUTPUT_CHARS = 32 * 1024;
|
|
7
17
|
/**
|
|
8
18
|
* Default Claude Code configuration
|
|
9
19
|
*
|
|
@@ -24,6 +34,37 @@ const CLAUDE_CODE_DEFAULT_CONFIG = {
|
|
|
24
34
|
outputParser: 'streaming',
|
|
25
35
|
timeout: 600000, // 10 minutes for Claude Code
|
|
26
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Flatten a stream-json `tool_result` block into the text the model saw.
|
|
39
|
+
* Claude Code emits either a plain string or an array of content blocks
|
|
40
|
+
* (`{type:'text', text}` for MCP/Bash/Read results, `tool_reference` for
|
|
41
|
+
* ToolSearch, …). Text blocks are joined verbatim; anything else is
|
|
42
|
+
* JSON-encoded so no evidence is dropped. Falls back to the event-level
|
|
43
|
+
* `tool_use_result` (a structured mirror of the same result) when the block
|
|
44
|
+
* carries no content at all.
|
|
45
|
+
*/
|
|
46
|
+
function toolResultText(block, event) {
|
|
47
|
+
const c = block?.content;
|
|
48
|
+
if (typeof c === 'string')
|
|
49
|
+
return c;
|
|
50
|
+
if (Array.isArray(c)) {
|
|
51
|
+
return c
|
|
52
|
+
.map((part) => part && part.type === 'text' && typeof part.text === 'string' ? part.text : JSON.stringify(part))
|
|
53
|
+
.join('\n');
|
|
54
|
+
}
|
|
55
|
+
if (c != null)
|
|
56
|
+
return JSON.stringify(c);
|
|
57
|
+
const mirror = event?.tool_use_result;
|
|
58
|
+
if (mirror === undefined || mirror === null)
|
|
59
|
+
return '';
|
|
60
|
+
return typeof mirror === 'string' ? mirror : JSON.stringify(mirror);
|
|
61
|
+
}
|
|
62
|
+
/** Cut `text` at `max` chars with an explicit marker carrying the full length. */
|
|
63
|
+
export function boundToolOutput(text, max = CLAUDE_CODE_MAX_TOOL_OUTPUT_CHARS) {
|
|
64
|
+
if (text.length <= max)
|
|
65
|
+
return text;
|
|
66
|
+
return `${text.slice(0, max)}\n… [tool output truncated: showing ${max} of ${text.length} chars]`;
|
|
67
|
+
}
|
|
27
68
|
/**
|
|
28
69
|
* Claude Code CLI Connector
|
|
29
70
|
* Invokes Claude Code as a subprocess for agent evaluation
|
|
@@ -34,10 +75,6 @@ export class ClaudeCodeConnector extends SubprocessConnector {
|
|
|
34
75
|
this.type = 'claude-code';
|
|
35
76
|
this.name = 'Claude Code CLI';
|
|
36
77
|
this.traceContext = { propagateEnv: true, serviceName: 'claude-code-agent' };
|
|
37
|
-
this.outputBuffer = '';
|
|
38
|
-
this.thinkingBuffer = '';
|
|
39
|
-
this.textBuffer = '';
|
|
40
|
-
this.isInThinking = false;
|
|
41
78
|
}
|
|
42
79
|
/**
|
|
43
80
|
* Build prompt for Claude Code
|
|
@@ -59,22 +96,31 @@ export class ClaudeCodeConnector extends SubprocessConnector {
|
|
|
59
96
|
parts.push(request.testCase.initialPrompt);
|
|
60
97
|
return parts.join('\n');
|
|
61
98
|
}
|
|
99
|
+
createExecutionState() {
|
|
100
|
+
return {
|
|
101
|
+
...super.createExecutionState(),
|
|
102
|
+
outputBuffer: '',
|
|
103
|
+
thinkingBuffer: '',
|
|
104
|
+
textBuffer: '',
|
|
105
|
+
pendingToolUses: new Map(),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
62
108
|
/**
|
|
63
109
|
* Parse Claude Code streaming output (stream-json format)
|
|
64
110
|
* Each line is a JSON object with type and content
|
|
65
111
|
*/
|
|
66
|
-
parseStreamingOutput(chunk, trajectory, onProgress) {
|
|
67
|
-
|
|
112
|
+
parseStreamingOutput(chunk, trajectory, onProgress, state) {
|
|
113
|
+
state.outputBuffer += chunk;
|
|
68
114
|
// Parse complete JSON lines (NDJSON format)
|
|
69
|
-
const lines =
|
|
70
|
-
|
|
115
|
+
const lines = state.outputBuffer.split('\n');
|
|
116
|
+
state.outputBuffer = lines.pop() || ''; // Keep incomplete line
|
|
71
117
|
for (const line of lines) {
|
|
72
118
|
const trimmed = line.trim();
|
|
73
119
|
if (!trimmed)
|
|
74
120
|
continue;
|
|
75
121
|
try {
|
|
76
122
|
const event = JSON.parse(trimmed);
|
|
77
|
-
const steps = this.parseJsonEvent(event);
|
|
123
|
+
const steps = this.parseJsonEvent(event, state);
|
|
78
124
|
for (const step of steps) {
|
|
79
125
|
trajectory.push(step);
|
|
80
126
|
onProgress?.(step);
|
|
@@ -93,12 +139,12 @@ export class ClaudeCodeConnector extends SubprocessConnector {
|
|
|
93
139
|
/**
|
|
94
140
|
* Parse a single JSON event from stream-json output
|
|
95
141
|
*/
|
|
96
|
-
parseJsonEvent(event) {
|
|
142
|
+
parseJsonEvent(event, state) {
|
|
97
143
|
const steps = [];
|
|
98
144
|
// Capture the session id (present on system/init, assistant, user, result
|
|
99
145
|
// events). Used for Strategy D trace correlation (attributes.session.id).
|
|
100
146
|
if (typeof event.session_id === 'string' && event.session_id) {
|
|
101
|
-
|
|
147
|
+
state.sessionId = event.session_id;
|
|
102
148
|
}
|
|
103
149
|
// Handle different event types from Claude Code stream-json
|
|
104
150
|
if (event.type === 'assistant' && event.message?.content) {
|
|
@@ -110,6 +156,9 @@ export class ClaudeCodeConnector extends SubprocessConnector {
|
|
|
110
156
|
steps.push(this.createStep('assistant', block.text));
|
|
111
157
|
}
|
|
112
158
|
else if (block.type === 'tool_use') {
|
|
159
|
+
if (typeof block.id === 'string' && block.id) {
|
|
160
|
+
state.pendingToolUses.set(block.id, { name: block.name, input: block.input });
|
|
161
|
+
}
|
|
113
162
|
steps.push(this.createStep('action', JSON.stringify(block.input || {}), {
|
|
114
163
|
toolName: block.name,
|
|
115
164
|
toolArgs: block.input,
|
|
@@ -122,13 +171,23 @@ export class ClaudeCodeConnector extends SubprocessConnector {
|
|
|
122
171
|
// content blocks (referenced back to the assistant's tool_use_id).
|
|
123
172
|
// Without this branch, tool outputs are silently dropped — the trajectory
|
|
124
173
|
// shows the tool calls but not their results.
|
|
174
|
+
//
|
|
175
|
+
// Each result is paired with its `tool_use` by id so the step carries
|
|
176
|
+
// the tool name, and the (bounded) output text is stored on BOTH
|
|
177
|
+
// `content` and `toolOutput`. `toolOutput` is what the judge and the
|
|
178
|
+
// trajectory-merge policy (services/traces/trajectoryMerge.ts) treat as
|
|
179
|
+
// evidence; without it a span-derived "tool succeeded" stub could
|
|
180
|
+
// replace a 28 KB retrieval result.
|
|
125
181
|
for (const block of event.message.content) {
|
|
126
182
|
if (block.type === 'tool_result') {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
183
|
+
const paired = typeof block.tool_use_id === 'string' ? state.pendingToolUses.get(block.tool_use_id) : undefined;
|
|
184
|
+
if (paired && typeof block.tool_use_id === 'string')
|
|
185
|
+
state.pendingToolUses.delete(block.tool_use_id);
|
|
186
|
+
const output = boundToolOutput(toolResultText(block, event));
|
|
187
|
+
steps.push(this.createStep('tool_result', output, {
|
|
131
188
|
status: block.is_error ? ToolCallStatus.FAILURE : ToolCallStatus.SUCCESS,
|
|
189
|
+
...(paired?.name ? { toolName: paired.name } : {}),
|
|
190
|
+
...(output ? { toolOutput: output } : {}),
|
|
132
191
|
}));
|
|
133
192
|
}
|
|
134
193
|
else if (block.type === 'text' && block.text) {
|
|
@@ -140,23 +199,23 @@ export class ClaudeCodeConnector extends SubprocessConnector {
|
|
|
140
199
|
else if (event.type === 'content_block_delta') {
|
|
141
200
|
// Streaming delta updates — accumulate into buffers
|
|
142
201
|
if (event.delta?.type === 'thinking_delta' && event.delta.thinking) {
|
|
143
|
-
|
|
202
|
+
state.thinkingBuffer += event.delta.thinking;
|
|
144
203
|
}
|
|
145
204
|
else if (event.delta?.type === 'text_delta' && event.delta.text) {
|
|
146
205
|
// Accumulate text deltas; the 'result' event will emit the final response
|
|
147
|
-
|
|
206
|
+
state.textBuffer += event.delta.text;
|
|
148
207
|
}
|
|
149
208
|
}
|
|
150
209
|
else if (event.type === 'content_block_stop') {
|
|
151
210
|
// Flush thinking buffer when block ends
|
|
152
|
-
if (
|
|
153
|
-
steps.push(this.createStep('thinking',
|
|
154
|
-
|
|
211
|
+
if (state.thinkingBuffer) {
|
|
212
|
+
steps.push(this.createStep('thinking', state.thinkingBuffer));
|
|
213
|
+
state.thinkingBuffer = '';
|
|
155
214
|
}
|
|
156
215
|
// Flush text buffer when block ends (consolidated assistant step)
|
|
157
|
-
if (
|
|
158
|
-
steps.push(this.createStep('assistant',
|
|
159
|
-
|
|
216
|
+
if (state.textBuffer) {
|
|
217
|
+
steps.push(this.createStep('assistant', state.textBuffer));
|
|
218
|
+
state.textBuffer = '';
|
|
160
219
|
}
|
|
161
220
|
}
|
|
162
221
|
else if (event.type === 'result' && event.result) {
|
|
@@ -193,49 +252,40 @@ export class ClaudeCodeConnector extends SubprocessConnector {
|
|
|
193
252
|
}
|
|
194
253
|
return steps;
|
|
195
254
|
}
|
|
196
|
-
/**
|
|
197
|
-
* Reset state for new execution
|
|
198
|
-
*/
|
|
199
|
-
resetState() {
|
|
200
|
-
this.outputBuffer = '';
|
|
201
|
-
this.thinkingBuffer = '';
|
|
202
|
-
this.textBuffer = '';
|
|
203
|
-
this.isInThinking = false;
|
|
204
|
-
}
|
|
205
255
|
/**
|
|
206
256
|
* Flush remaining buffers when the subprocess stream ends.
|
|
207
257
|
*/
|
|
208
|
-
onBeforeStreamEnd(trajectory, onProgress) {
|
|
258
|
+
onBeforeStreamEnd(trajectory, onProgress, state) {
|
|
209
259
|
// Flush outputBuffer (incomplete NDJSON line)
|
|
210
|
-
if (
|
|
260
|
+
if (state.outputBuffer.trim()) {
|
|
211
261
|
try {
|
|
212
|
-
const event = JSON.parse(
|
|
213
|
-
const steps = this.parseJsonEvent(event);
|
|
262
|
+
const event = JSON.parse(state.outputBuffer.trim());
|
|
263
|
+
const steps = this.parseJsonEvent(event, state);
|
|
214
264
|
for (const step of steps) {
|
|
215
265
|
trajectory.push(step);
|
|
216
266
|
onProgress?.(step);
|
|
217
267
|
}
|
|
218
268
|
}
|
|
219
269
|
catch {
|
|
220
|
-
const step = this.createStep('assistant',
|
|
270
|
+
const step = this.createStep('assistant', state.outputBuffer.trim());
|
|
221
271
|
trajectory.push(step);
|
|
222
272
|
onProgress?.(step);
|
|
223
273
|
}
|
|
224
|
-
|
|
274
|
+
state.outputBuffer = '';
|
|
225
275
|
}
|
|
226
276
|
// Flush thinkingBuffer
|
|
227
|
-
if (
|
|
228
|
-
const step = this.createStep('thinking',
|
|
277
|
+
if (state.thinkingBuffer) {
|
|
278
|
+
const step = this.createStep('thinking', state.thinkingBuffer);
|
|
229
279
|
trajectory.push(step);
|
|
230
280
|
onProgress?.(step);
|
|
231
|
-
|
|
281
|
+
state.thinkingBuffer = '';
|
|
232
282
|
}
|
|
233
283
|
// Flush textBuffer (text deltas received without a result event)
|
|
234
|
-
if (
|
|
235
|
-
const step = this.createStep('response',
|
|
284
|
+
if (state.textBuffer) {
|
|
285
|
+
const step = this.createStep('response', state.textBuffer);
|
|
236
286
|
trajectory.push(step);
|
|
237
287
|
onProgress?.(step);
|
|
238
|
-
|
|
288
|
+
state.textBuffer = '';
|
|
239
289
|
}
|
|
240
290
|
}
|
|
241
291
|
/**
|
|
@@ -273,79 +323,61 @@ export class ClaudeCodeConnector extends SubprocessConnector {
|
|
|
273
323
|
return args;
|
|
274
324
|
}
|
|
275
325
|
/**
|
|
276
|
-
*
|
|
326
|
+
* Translate `ClaudeCodeConnectorConfig` (the agent's `connectorConfig`) into
|
|
327
|
+
* the effective per-execution subprocess config. Pure: builds a fresh
|
|
328
|
+
* snapshot from the constructor defaults — `this.config` is never written,
|
|
329
|
+
* so concurrent executions on the shared singleton cannot compound each
|
|
330
|
+
* other's flags (spawns were once observed with --append-system-prompt /
|
|
331
|
+
* --allowed-tools duplicated up to 5× at concurrency 3) or swap env /
|
|
332
|
+
* timeout / cwd.
|
|
277
333
|
*/
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (ccConfig) {
|
|
295
|
-
this.debug('Applying connectorConfig:', Object.keys(ccConfig));
|
|
296
|
-
// Merge environment variables
|
|
297
|
-
if (ccConfig.env) {
|
|
298
|
-
this.config.env = { ...this.config.env, ...ccConfig.env };
|
|
299
|
-
}
|
|
300
|
-
// Switch input mode if requested
|
|
301
|
-
if (ccConfig.usePromptArg) {
|
|
302
|
-
this.config.inputMode = 'arg';
|
|
303
|
-
}
|
|
304
|
-
// Override timeout if specified
|
|
305
|
-
if (ccConfig.timeout !== undefined) {
|
|
306
|
-
this.config.timeout = ccConfig.timeout;
|
|
307
|
-
}
|
|
308
|
-
// Override working directory if specified
|
|
309
|
-
if (ccConfig.workingDir) {
|
|
310
|
-
this.config.workingDir = ccConfig.workingDir;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
334
|
+
resolveExecutionConfig(request) {
|
|
335
|
+
const ccConfig = (request.connectorConfig || {});
|
|
336
|
+
const base = super.resolveExecutionConfig({
|
|
337
|
+
...request,
|
|
338
|
+
// Only `env` / `timeout` / `workingDir` are base-shaped on the Claude
|
|
339
|
+
// Code config; everything else is translated to CLI flags below.
|
|
340
|
+
connectorConfig: {
|
|
341
|
+
...(ccConfig.env ? { env: ccConfig.env } : {}),
|
|
342
|
+
...(ccConfig.timeout !== undefined ? { timeout: ccConfig.timeout } : {}),
|
|
343
|
+
...(ccConfig.workingDir ? { workingDir: ccConfig.workingDir } : {}),
|
|
344
|
+
},
|
|
345
|
+
});
|
|
346
|
+
const configArgs = this.buildConfigArgs(ccConfig);
|
|
347
|
+
if (configArgs.length > 0)
|
|
348
|
+
this.debug('Config args added:', configArgs);
|
|
349
|
+
let env = base.env || {};
|
|
313
350
|
// When using Bedrock, clear any Anthropic API key to prevent
|
|
314
351
|
// login-managed key from taking precedence and triggering a credit
|
|
315
352
|
// balance check instead of routing through Bedrock.
|
|
316
|
-
if (
|
|
317
|
-
|
|
353
|
+
if (env.CLAUDE_CODE_USE_BEDROCK === '1') {
|
|
354
|
+
env = { ...env, ANTHROPIC_API_KEY: '' };
|
|
318
355
|
this.debug('Bedrock mode: cleared ANTHROPIC_API_KEY to bypass credit check');
|
|
319
356
|
}
|
|
320
357
|
// The agent's model is owned by its agent-health.config.ts connector
|
|
321
358
|
// config (env.ANTHROPIC_MODEL, or a `--model` flag in connectorConfig.args)
|
|
322
359
|
// — there is no run-level / user-selected agent model. We intentionally do
|
|
323
360
|
// NOT inject a model from the run here.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
this.config.args = originalArgs;
|
|
345
|
-
this.config.inputMode = originalInputMode;
|
|
346
|
-
this.config.timeout = originalTimeout;
|
|
347
|
-
this.config.workingDir = originalWorkingDir;
|
|
348
|
-
}
|
|
361
|
+
return {
|
|
362
|
+
...base,
|
|
363
|
+
env,
|
|
364
|
+
args: [...(this.config.args || []), ...configArgs],
|
|
365
|
+
...(ccConfig.usePromptArg ? { inputMode: 'arg' } : {}),
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Override execute for debug logging around the base implementation.
|
|
370
|
+
*/
|
|
371
|
+
async execute(endpoint, request, auth, onProgress, onRawEvent) {
|
|
372
|
+
this.debug('========== execute() STARTED ==========');
|
|
373
|
+
this.debug('Endpoint:', endpoint);
|
|
374
|
+
this.debug('Test case:', request.testCase.name);
|
|
375
|
+
if (request.connectorConfig)
|
|
376
|
+
this.debug('Applying connectorConfig:', Object.keys(request.connectorConfig));
|
|
377
|
+
const result = await super.execute(endpoint, request, auth, onProgress, onRawEvent);
|
|
378
|
+
this.debug('super.execute() returned with', result.trajectory.length, 'steps');
|
|
379
|
+
this.debug('========== execute() COMPLETED ==========');
|
|
380
|
+
return result;
|
|
349
381
|
}
|
|
350
382
|
/**
|
|
351
383
|
* Health check - verify claude command exists
|
|
@@ -355,10 +387,15 @@ export class ClaudeCodeConnector extends SubprocessConnector {
|
|
|
355
387
|
}
|
|
356
388
|
/**
|
|
357
389
|
* Surface the captured Claude Code `session_id` so the runner can persist it
|
|
358
|
-
* as `report.sessionId` for Strategy D trace correlation.
|
|
390
|
+
* as `report.sessionId` for Strategy D trace correlation. Read from the
|
|
391
|
+
* per-invocation state — never from the instance — so concurrent runs on
|
|
392
|
+
* the shared singleton can't swap session ids.
|
|
359
393
|
*/
|
|
360
|
-
extraResultMetadata() {
|
|
361
|
-
return
|
|
394
|
+
extraResultMetadata(state) {
|
|
395
|
+
return {
|
|
396
|
+
...super.extraResultMetadata(state),
|
|
397
|
+
...(state.sessionId ? { sessionId: state.sessionId } : {}),
|
|
398
|
+
};
|
|
362
399
|
}
|
|
363
400
|
}
|
|
364
401
|
/**
|