@mongodb-js/harness-tester 3.0.0-prerelease.4 → 3.0.3
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/LICENSE +202 -0
- package/dist/harness/claude/claudeConfig.d.ts +30 -0
- package/dist/harness/claude/claudeConfig.d.ts.map +1 -0
- package/dist/harness/claude/claudeConfig.js +87 -0
- package/dist/harness/claude/claudeConfig.js.map +1 -0
- package/dist/harness/claude/claudeHarness.d.ts +30 -0
- package/dist/harness/claude/claudeHarness.d.ts.map +1 -0
- package/dist/harness/claude/claudeHarness.js +84 -0
- package/dist/harness/claude/claudeHarness.js.map +1 -0
- package/dist/harness/claude/claudeSession.d.ts +24 -0
- package/dist/harness/claude/claudeSession.d.ts.map +1 -0
- package/dist/harness/claude/claudeSession.js +49 -0
- package/dist/harness/claude/claudeSession.js.map +1 -0
- package/dist/harness/claude/parseClaudeToolCalls.d.ts +19 -0
- package/dist/harness/claude/parseClaudeToolCalls.d.ts.map +1 -0
- package/dist/harness/claude/parseClaudeToolCalls.js +84 -0
- package/dist/harness/claude/parseClaudeToolCalls.js.map +1 -0
- package/dist/harness/codex/codexConfig.d.ts +38 -0
- package/dist/harness/codex/codexConfig.d.ts.map +1 -0
- package/dist/harness/codex/codexConfig.js +162 -0
- package/dist/harness/codex/codexConfig.js.map +1 -0
- package/dist/harness/codex/codexHarness.d.ts +30 -0
- package/dist/harness/codex/codexHarness.d.ts.map +1 -0
- package/dist/harness/codex/codexHarness.js +68 -0
- package/dist/harness/codex/codexHarness.js.map +1 -0
- package/dist/harness/codex/codexParseTuiTranscript.d.ts +8 -0
- package/dist/harness/codex/codexParseTuiTranscript.d.ts.map +1 -0
- package/dist/harness/codex/codexParseTuiTranscript.js +37 -0
- package/dist/harness/codex/codexParseTuiTranscript.js.map +1 -0
- package/dist/harness/codex/codexSession.d.ts +21 -0
- package/dist/harness/codex/codexSession.d.ts.map +1 -0
- package/dist/harness/codex/codexSession.js +31 -0
- package/dist/harness/codex/codexSession.js.map +1 -0
- package/dist/harness/logger.d.ts +10 -0
- package/dist/harness/logger.d.ts.map +1 -0
- package/dist/harness/logger.js +18 -0
- package/dist/harness/logger.js.map +1 -0
- package/dist/harness/shared.d.ts +18 -0
- package/dist/harness/shared.d.ts.map +1 -0
- package/dist/harness/shared.js +46 -0
- package/dist/harness/shared.js.map +1 -0
- package/dist/harness/tuiSession.d.ts +73 -0
- package/dist/harness/tuiSession.d.ts.map +1 -0
- package/dist/harness/tuiSession.js +202 -0
- package/dist/harness/tuiSession.js.map +1 -0
- package/dist/harness/types.d.ts +91 -0
- package/dist/harness/types.d.ts.map +1 -0
- package/dist/harness/types.js +2 -0
- package/dist/harness/types.js.map +1 -0
- package/dist/harnesses.d.ts +3 -0
- package/dist/harnesses.d.ts.map +1 -0
- package/dist/harnesses.js +4 -0
- package/dist/harnesses.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/useAgent.d.ts +16 -0
- package/dist/useAgent.d.ts.map +1 -0
- package/dist/useAgent.js +47 -0
- package/dist/useAgent.js.map +1 -0
- package/package.json +6 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AgentHarnessConfig, AgentHarnessOptions } from "../types.js";
|
|
2
|
+
/** Default model: grove serves the undated id; `haiku` resolves to a dated id it lacks. */
|
|
3
|
+
export declare const DEFAULT_CLAUDE_MODEL = "claude-haiku-4-5";
|
|
4
|
+
/** Minimum reasoning effort for e2e runs (mirrors the codex harness's `"low"`). */
|
|
5
|
+
export declare const DEFAULT_CLAUDE_EFFORT_LEVEL = "low";
|
|
6
|
+
/** Grove gateway Anthropic endpoint (no trailing /v1; claude appends it). */
|
|
7
|
+
export declare const GROVE_ANTHROPIC_BASE_URL = "https://grove-gateway-prod.azure-api.net/grove-foundry-prod/anthropic";
|
|
8
|
+
export declare function resolveClaudeModel(options: AgentHarnessOptions): string;
|
|
9
|
+
/** Env for the spawned claude process; the grove key is read live from `GROVE_API_KEY`, never written to config files. */
|
|
10
|
+
export declare function buildClaudeEnv(options: AgentHarnessOptions): Record<string, string>;
|
|
11
|
+
/** {@link AgentHarnessConfig} for claude: emits the `--mcp-config` JSON registering the MCP server. */
|
|
12
|
+
export declare class ClaudeHarnessConfig implements AgentHarnessConfig {
|
|
13
|
+
readonly homeDirEnvVar = "CLAUDE_CONFIG_DIR";
|
|
14
|
+
readonly configFileName = "mcp-config.json";
|
|
15
|
+
/** Directory claude uses for its config/state on the host machine. */
|
|
16
|
+
getHostHomeDir(): string;
|
|
17
|
+
buildConfig(options: AgentHarnessOptions): string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Pre-seed the hermetic claude home to suppress onboarding/trust dialogs.
|
|
21
|
+
* Mutates nothing outside the home.
|
|
22
|
+
*
|
|
23
|
+
* @param mcpServerName MCP server name; the allow list is scoped to its tools (`mcp__<name>__*`).
|
|
24
|
+
*/
|
|
25
|
+
export declare function seedClaudeHome({ homeDir, workDir, mcpServerName, }: {
|
|
26
|
+
homeDir: string;
|
|
27
|
+
workDir: string;
|
|
28
|
+
mcpServerName?: string;
|
|
29
|
+
}): void;
|
|
30
|
+
//# sourceMappingURL=claudeConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeConfig.d.ts","sourceRoot":"","sources":["../../../src/harness/claude/claudeConfig.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE3E,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AAEvD,mFAAmF;AACnF,eAAO,MAAM,2BAA2B,QAAQ,CAAC;AAEjD,6EAA6E;AAC7E,eAAO,MAAM,wBAAwB,0EAA0E,CAAC;AAEhH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAIvE;AAED,0HAA0H;AAC1H,wBAAgB,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkBnF;AAED,uGAAuG;AACvG,qBAAa,mBAAoB,YAAW,kBAAkB;IAC1D,QAAQ,CAAC,aAAa,uBAAuB;IAC7C,QAAQ,CAAC,cAAc,qBAAqB;IAE5C,sEAAsE;IACtE,cAAc,IAAI,MAAM;IAIxB,WAAW,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM;CAYpD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC3B,OAAO,EACP,OAAO,EACP,aAAuB,GAC1B,EAAE;IACC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,IAAI,CAsBP"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { canonicalPath } from "../shared.js";
|
|
5
|
+
/** Default model: grove serves the undated id; `haiku` resolves to a dated id it lacks. */
|
|
6
|
+
export const DEFAULT_CLAUDE_MODEL = "claude-haiku-4-5";
|
|
7
|
+
/** Minimum reasoning effort for e2e runs (mirrors the codex harness's `"low"`). */
|
|
8
|
+
export const DEFAULT_CLAUDE_EFFORT_LEVEL = "low";
|
|
9
|
+
/** Grove gateway Anthropic endpoint (no trailing /v1; claude appends it). */
|
|
10
|
+
export const GROVE_ANTHROPIC_BASE_URL = "https://grove-gateway-prod.azure-api.net/grove-foundry-prod/anthropic";
|
|
11
|
+
export function resolveClaudeModel(options) {
|
|
12
|
+
// Model priority: explicit `options.model` (CI override) > env override > default.
|
|
13
|
+
return options.model || process.env.AGENT_E2E_CLAUDE_MODEL || DEFAULT_CLAUDE_MODEL;
|
|
14
|
+
}
|
|
15
|
+
/** Env for the spawned claude process; the grove key is read live from `GROVE_API_KEY`, never written to config files. */
|
|
16
|
+
export function buildClaudeEnv(options) {
|
|
17
|
+
const groveApiKey = process.env.GROVE_API_KEY ?? "";
|
|
18
|
+
return {
|
|
19
|
+
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1",
|
|
20
|
+
// Keep e2e runs cheap and deterministic: no extended thinking plus minimum
|
|
21
|
+
// reasoning effort (mirrors the codex harness's `model_reasoning_effort = "low"`).
|
|
22
|
+
// On the Anthropic API MAX_THINKING_TOKENS=0 turns thinking off; against a
|
|
23
|
+
// gateway (grove) it omits the `thinking` parameter instead. `--effort low` is
|
|
24
|
+
// also passed on the command line for top precedence.
|
|
25
|
+
MAX_THINKING_TOKENS: "0",
|
|
26
|
+
CLAUDE_CODE_EFFORT_LEVEL: DEFAULT_CLAUDE_EFFORT_LEVEL,
|
|
27
|
+
ANTHROPIC_BASE_URL: GROVE_ANTHROPIC_BASE_URL,
|
|
28
|
+
ANTHROPIC_AUTH_TOKEN: groveApiKey,
|
|
29
|
+
ANTHROPIC_CUSTOM_HEADERS: `api-key: ${groveApiKey}`,
|
|
30
|
+
// `ANTHROPIC_MODEL` and `--model` are the only model slots that win over the
|
|
31
|
+
// org default (Opus) even when the org sets override-user-selection; pin haiku.
|
|
32
|
+
ANTHROPIC_MODEL: resolveClaudeModel(options),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** {@link AgentHarnessConfig} for claude: emits the `--mcp-config` JSON registering the MCP server. */
|
|
36
|
+
export class ClaudeHarnessConfig {
|
|
37
|
+
constructor() {
|
|
38
|
+
this.homeDirEnvVar = "CLAUDE_CONFIG_DIR";
|
|
39
|
+
this.configFileName = "mcp-config.json";
|
|
40
|
+
}
|
|
41
|
+
/** Directory claude uses for its config/state on the host machine. */
|
|
42
|
+
getHostHomeDir() {
|
|
43
|
+
return process.env[this.homeDirEnvVar] ?? path.join(os.homedir(), ".claude");
|
|
44
|
+
}
|
|
45
|
+
buildConfig(options) {
|
|
46
|
+
const mcpServerName = options.mcpServerName ?? "mongo";
|
|
47
|
+
const server = options.stdioServer
|
|
48
|
+
? {
|
|
49
|
+
type: "stdio",
|
|
50
|
+
command: options.stdioServer.command,
|
|
51
|
+
args: options.stdioServer.args,
|
|
52
|
+
env: options.stdioServer.env,
|
|
53
|
+
}
|
|
54
|
+
: { type: "http", url: options.serverUrl ?? "" };
|
|
55
|
+
return JSON.stringify({ mcpServers: { [mcpServerName]: server } }, null, 2);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Pre-seed the hermetic claude home to suppress onboarding/trust dialogs.
|
|
60
|
+
* Mutates nothing outside the home.
|
|
61
|
+
*
|
|
62
|
+
* @param mcpServerName MCP server name; the allow list is scoped to its tools (`mcp__<name>__*`).
|
|
63
|
+
*/
|
|
64
|
+
export function seedClaudeHome({ homeDir, workDir, mcpServerName = "mongo", }) {
|
|
65
|
+
const canonical = canonicalPath(workDir);
|
|
66
|
+
const claudeJson = {
|
|
67
|
+
hasCompletedOnboarding: true,
|
|
68
|
+
shiftEnterKeyBindingInstalled: true,
|
|
69
|
+
theme: "dark",
|
|
70
|
+
// Mark the test workdir trusted so the trust gate never shows.
|
|
71
|
+
projects: {
|
|
72
|
+
[canonical]: { hasTrustDialogAccepted: true, allowedTools: [] },
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
// `dontAsk` auto-denies anything not in `allow`, so this list is the whole
|
|
76
|
+
// toolset (MCP tools only — no bash/file/web tools).
|
|
77
|
+
const settingsJson = {
|
|
78
|
+
permissions: {
|
|
79
|
+
defaultMode: "dontAsk",
|
|
80
|
+
allow: [`mcp__${mcpServerName}__*`],
|
|
81
|
+
},
|
|
82
|
+
skipDangerousModePermissionPrompt: true,
|
|
83
|
+
};
|
|
84
|
+
fs.writeFileSync(path.join(homeDir, ".claude.json"), JSON.stringify(claudeJson, null, 2));
|
|
85
|
+
fs.writeFileSync(path.join(homeDir, "settings.json"), JSON.stringify(settingsJson, null, 2));
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=claudeConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeConfig.js","sourceRoot":"","sources":["../../../src/harness/claude/claudeConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,2FAA2F;AAC3F,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEvD,mFAAmF;AACnF,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,CAAC;AAEjD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,wBAAwB,GAAG,uEAAuE,CAAC;AAEhH,MAAM,UAAU,kBAAkB,CAAC,OAA4B;IAC3D,mFAAmF;IAEnF,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,oBAAoB,CAAC;AACvF,CAAC;AAED,0HAA0H;AAC1H,MAAM,UAAU,cAAc,CAAC,OAA4B;IACvD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC;IACpD,OAAO;QACH,wCAAwC,EAAE,GAAG;QAC7C,2EAA2E;QAC3E,mFAAmF;QACnF,2EAA2E;QAC3E,+EAA+E;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AAG,OAAO,GAK1B;IACG,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,UAAU,GAAG;QACf,sBAAsB,EAAE,IAAI;QAC5B,6BAA6B,EAAE,IAAI;QACnC,KAAK,EAAE,MAAM;QACb,+DAA+D;QAC/D,QAAQ,EAAE;YACN,CAAC,SAAS,CAAC,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE;SAClE;KACJ,CAAC;IACF,2EAA2E;IAC3E,qDAAqD;IACrD,MAAM,YAAY,GAAG;QACjB,WAAW,EAAE;YACT,WAAW,EAAE,SAAS;YACtB,KAAK,EAAE,CAAC,QAAQ,aAAa,KAAK,CAAC;SACtC;QACD,iCAAiC,EAAE,IAAI;KAC1C,CAAC;IACF,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1F,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACjG,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Backend } from "@microsoft/tui-test";
|
|
2
|
+
import { type ClaudeState } from "./claudeSession.js";
|
|
3
|
+
import type { AgentHarness, AgentHarnessOptions, AgentSession } from "../types.js";
|
|
4
|
+
export interface ClaudeTuiHarnessOptions {
|
|
5
|
+
/** Override the claude binary path (default: "claude" on PATH). */
|
|
6
|
+
binaryPath?: string;
|
|
7
|
+
/** tui-test emulator backend (default: "alacritty", override for CI). */
|
|
8
|
+
backend?: Backend;
|
|
9
|
+
/** Terminal size in cells (default: 180x50). */
|
|
10
|
+
cols?: number;
|
|
11
|
+
rows?: number;
|
|
12
|
+
/** Per-poll state callback for tests that want to observe/live-debug the TUI. */
|
|
13
|
+
onState?: (state: ClaudeState) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare class ClaudeTuiHarness implements AgentHarness {
|
|
16
|
+
readonly name = "claude-tui";
|
|
17
|
+
private readonly binaryPath;
|
|
18
|
+
private readonly backend;
|
|
19
|
+
private readonly cols;
|
|
20
|
+
private readonly rows;
|
|
21
|
+
private readonly onState;
|
|
22
|
+
private readonly log;
|
|
23
|
+
constructor(options?: ClaudeTuiHarnessOptions);
|
|
24
|
+
getBinaryPath(): string;
|
|
25
|
+
getBackend(): Backend;
|
|
26
|
+
/** Synchronous (required by `describe.skipIf`): binary `--version` + GROVE_API_KEY set. */
|
|
27
|
+
isAvailable(): boolean;
|
|
28
|
+
start(options: AgentHarnessOptions): Promise<AgentSession>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=claudeHarness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeHarness.d.ts","sourceRoot":"","sources":["../../../src/harness/claude/claudeHarness.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAU5D,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEnF,MAAM,WAAW,uBAAuB;IACpC,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CAC1C;AAED,qBAAa,gBAAiB,YAAW,YAAY;IACjD,QAAQ,CAAC,IAAI,gBAAgB;IAE7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6C;IACrE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgC;gBAExC,OAAO,GAAE,uBAA4B;IAQjD,aAAa,IAAI,MAAM;IAIvB,UAAU,IAAI,OAAO;IAIrB,2FAA2F;IAC3F,WAAW,IAAI,OAAO;IAehB,KAAK,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC;CAiDnE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { TuiTest } from "@microsoft/tui-test";
|
|
5
|
+
import { ClaudeHarnessConfig, buildClaudeEnv, DEFAULT_CLAUDE_EFFORT_LEVEL, resolveClaudeModel, seedClaudeHome, } from "./claudeConfig.js";
|
|
6
|
+
import { resolveBackend } from "../shared.js";
|
|
7
|
+
import { HarnessLogger } from "../logger.js";
|
|
8
|
+
import { ClaudeTuiSession } from "./claudeSession.js";
|
|
9
|
+
export class ClaudeTuiHarness {
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
this.name = "claude-tui";
|
|
12
|
+
this.log = new HarnessLogger(this.name);
|
|
13
|
+
this.binaryPath = options.binaryPath;
|
|
14
|
+
this.backend = resolveBackend(options.backend);
|
|
15
|
+
this.cols = options.cols ?? 180;
|
|
16
|
+
this.rows = options.rows ?? 50;
|
|
17
|
+
this.onState = options.onState;
|
|
18
|
+
}
|
|
19
|
+
getBinaryPath() {
|
|
20
|
+
return this.binaryPath ?? process.env.AGENT_E2E_CLAUDE_BIN ?? "claude";
|
|
21
|
+
}
|
|
22
|
+
getBackend() {
|
|
23
|
+
return this.backend;
|
|
24
|
+
}
|
|
25
|
+
/** Synchronous (required by `describe.skipIf`): binary `--version` + GROVE_API_KEY set. */
|
|
26
|
+
isAvailable() {
|
|
27
|
+
const binary = this.getBinaryPath();
|
|
28
|
+
try {
|
|
29
|
+
execFileSync(binary, ["--version"], { timeout: 30000, stdio: "ignore" });
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
this.log.info(`binary '${binary}' not available; skipping claude agent e2e tests`);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (process.env.GROVE_API_KEY) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
this.log.info("no GROVE_API_KEY set; skipping claude agent e2e tests");
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
async start(options) {
|
|
42
|
+
// Per-session CLAUDE_CONFIG_DIR: developer config untouched, no state or JSONL reused.
|
|
43
|
+
const config = new ClaudeHarnessConfig();
|
|
44
|
+
const claudeHome = path.join(options.workDir, `claude-home-${Math.random().toString(36).slice(2, 8)}`);
|
|
45
|
+
await fs.mkdir(claudeHome, { recursive: true });
|
|
46
|
+
// Pre-seed onboarding/trust state + MCP config (whitelists MCP tools, so no permission flags needed).
|
|
47
|
+
const mcpServerName = options.mcpServerName ?? "mongo";
|
|
48
|
+
seedClaudeHome({ homeDir: claudeHome, workDir: options.workDir, mcpServerName });
|
|
49
|
+
const mcpConfig = config.buildConfig(options);
|
|
50
|
+
const mcpConfigPath = path.join(claudeHome, config.configFileName);
|
|
51
|
+
await fs.writeFile(mcpConfigPath, mcpConfig);
|
|
52
|
+
const terminal = new TuiTest(`claude-${process.pid}-${Math.random().toString(36).slice(2, 8)}`, {
|
|
53
|
+
backend: this.backend,
|
|
54
|
+
timeouts: { ready: 60000, text: 60000, idle: 60000 },
|
|
55
|
+
});
|
|
56
|
+
// `--model` (plus `ANTHROPIC_MODEL` in the env) pins haiku, and `--effort`
|
|
57
|
+
// (plus `CLAUDE_CODE_EFFORT_LEVEL`) pins minimum reasoning: both outrank the
|
|
58
|
+
// org default (Opus) and override-user-selection per Claude Code docs.
|
|
59
|
+
await terminal.run(this.getBinaryPath(), [
|
|
60
|
+
"--model",
|
|
61
|
+
resolveClaudeModel(options),
|
|
62
|
+
"--effort",
|
|
63
|
+
DEFAULT_CLAUDE_EFFORT_LEVEL,
|
|
64
|
+
"--mcp-config",
|
|
65
|
+
mcpConfigPath,
|
|
66
|
+
"--strict-mcp-config",
|
|
67
|
+
], {
|
|
68
|
+
cwd: options.workDir,
|
|
69
|
+
cols: this.cols,
|
|
70
|
+
rows: this.rows,
|
|
71
|
+
env: {
|
|
72
|
+
...process.env,
|
|
73
|
+
...buildClaudeEnv(options),
|
|
74
|
+
[config.homeDirEnvVar]: claudeHome,
|
|
75
|
+
TERM: "xterm-256color",
|
|
76
|
+
},
|
|
77
|
+
waitReady: false,
|
|
78
|
+
});
|
|
79
|
+
const session = new ClaudeTuiSession({ terminal, options, claudeHome, onState: this.onState });
|
|
80
|
+
await session.initialise();
|
|
81
|
+
return session;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=claudeHarness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeHarness.js","sourceRoot":"","sources":["../../../src/harness/claude/claudeHarness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAgB,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EACH,mBAAmB,EACnB,cAAc,EACd,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa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AQ,CAAC,GAAG,CACd,IAAI,CAAC,aAAa,EAAE,EACpB;YACI,SAAS;YACT,kBAAkB,CAAC,OAAO,CAAC;YAC3B,UAAU;YACV,2BAA2B;YAC3B,cAAc;YACd,aAAa;YACb,qBAAqB;SACxB,EACD;YACI,GAAG,EAAE,OAAO,CAAC,OAAO;YACpB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE;gBACD,GAAG,OAAO,CAAC,GAAG;gBACd,GAAG,cAAc,CAAC,OAAO,CAAC;gBAC1B,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,UAAU;gBAClC,IAAI,EAAE,gBAAgB;aACzB;YACD,SAAS,EAAE,KAAK;SACnB,CACJ,CAAC;QAEF,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/F,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TuiTest } from "@microsoft/tui-test";
|
|
2
|
+
import { TuiSessionBase, type TuiState } from "../tuiSession.js";
|
|
3
|
+
import type { AgentHarnessOptions, ToolCallRecord } from "../types.js";
|
|
4
|
+
export type ClaudeState = TuiState;
|
|
5
|
+
export declare class ClaudeTuiSession extends TuiSessionBase {
|
|
6
|
+
private readonly claudeHome;
|
|
7
|
+
private readonly seenCallKeys;
|
|
8
|
+
constructor({ terminal, options, claudeHome, onState, }: {
|
|
9
|
+
terminal: TuiTest;
|
|
10
|
+
options: AgentHarnessOptions;
|
|
11
|
+
claudeHome: string;
|
|
12
|
+
onState?: (state: TuiState) => void;
|
|
13
|
+
});
|
|
14
|
+
protected get label(): string;
|
|
15
|
+
protected isWorking(text: string): boolean;
|
|
16
|
+
protected isComposerIdle(text: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Claude renders the elicitation as a `→ to expand` dropdown field
|
|
19
|
+
* (Accept/Decline); expand it so the options are selectable.
|
|
20
|
+
*/
|
|
21
|
+
protected sendChoice(choice: "confirm" | "decline"): Promise<void>;
|
|
22
|
+
protected extractToolCalls(): ToolCallRecord[];
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=claudeSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeSession.d.ts","sourceRoot":"","sources":["../../../src/harness/claude/claudeSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGvE,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;AAOnC,qBAAa,gBAAiB,SAAQ,cAAc;IAChD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqB;gBAEtC,EACR,QAAQ,EACR,OAAO,EACP,UAAU,EACV,OAAO,GACV,EAAE;QACC,QAAQ,EAAE,OAAO,CAAC;QAClB,OAAO,EAAE,mBAAmB,CAAC;QAC7B,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;KACvC;IAKD,SAAS,KAAK,KAAK,IAAI,MAAM,CAE5B;IAED,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQ1C,SAAS,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAO/C;;;OAGG;cACsB,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IASjF,SAAS,CAAC,gBAAgB,IAAI,cAAc,EAAE;CAKjD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { parseClaudeTurn } from "./parseClaudeToolCalls.js";
|
|
2
|
+
import { TuiSessionBase } from "../tuiSession.js";
|
|
3
|
+
import { sleep } from "../shared.js";
|
|
4
|
+
/** Composer idle marker. */
|
|
5
|
+
const COMPOSER_IDLE_MARKER = "❯";
|
|
6
|
+
/** Footer marker present only while a turn is in progress. */
|
|
7
|
+
const WORKING_FOOTER_MARKER = "esc to interrupt";
|
|
8
|
+
export class ClaudeTuiSession extends TuiSessionBase {
|
|
9
|
+
constructor({ terminal, options, claudeHome, onState, }) {
|
|
10
|
+
super({ terminal, options, onState });
|
|
11
|
+
this.seenCallKeys = new Set();
|
|
12
|
+
this.claudeHome = claudeHome;
|
|
13
|
+
}
|
|
14
|
+
get label() {
|
|
15
|
+
return "claude";
|
|
16
|
+
}
|
|
17
|
+
isWorking(text) {
|
|
18
|
+
// The `esc to interrupt` footer is only a working signal at the bottom of the
|
|
19
|
+
// viewport; matching it anywhere could match a stale or incidental occurrence.
|
|
20
|
+
const lines = text.split("\n").filter((l) => l.trim().length > 0);
|
|
21
|
+
const footer = lines[lines.length - 1] ?? "";
|
|
22
|
+
return footer.includes(WORKING_FOOTER_MARKER);
|
|
23
|
+
}
|
|
24
|
+
isComposerIdle(text) {
|
|
25
|
+
// A bare `❯` line is the empty composer. `❯ <prompt>` (an echoed prompt) also
|
|
26
|
+
// contains `❯`, so a substring match would report idle too early — that prompt
|
|
27
|
+
// echo is exactly the case that must NOT count as composition idle.
|
|
28
|
+
return text.split("\n").some((l) => l.trim() === COMPOSER_IDLE_MARKER);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Claude renders the elicitation as a `→ to expand` dropdown field
|
|
32
|
+
* (Accept/Decline); expand it so the options are selectable.
|
|
33
|
+
*/
|
|
34
|
+
async sendChoice(choice) {
|
|
35
|
+
// Claude presents a multi-field dropdown where you first expand using Right arrow to select the option.
|
|
36
|
+
await this.terminal.keyboard.press("Right");
|
|
37
|
+
if (choice === "decline")
|
|
38
|
+
await this.terminal.keyboard.press("Down");
|
|
39
|
+
await this.terminal.keyboard.press("Enter");
|
|
40
|
+
await sleep(200);
|
|
41
|
+
await this.terminal.keyboard.press("Enter");
|
|
42
|
+
}
|
|
43
|
+
extractToolCalls() {
|
|
44
|
+
// The session JSONL is the authoritative source; the TUI scrollback only renders the
|
|
45
|
+
// server name, so tool-level calls are read from the JSONL rather than the transcript.
|
|
46
|
+
return parseClaudeTurn({ claudeHomeDir: this.claudeHome, seenCallKeys: this.seenCallKeys }).toolCalls;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=claudeSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeSession.js","sourceRoot":"","sources":["../../../src/harness/claude/claudeSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAiB,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAIrC,4BAA4B;AAC5B,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,8DAA8D;AAC9D,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAEjD,MAAM,OAAO,gBAAiB,SAAQ,cAAc;IAIhD,YAAY,EACR,QAAQ,EACR,OAAO,EACP,UAAU,EACV,OAAO,GAMV;QACG,KAAK,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAbzB,iBAAY,GAAG,IAAI,GAAG,EAAU,CAAC;QAc9C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,IAAc,KAAK;QACf,OAAO,QAAQ,CAAC;IACpB,CAAC;IAES,SAAS,CAAC,IAAY;QAC5B,8EAA8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C;CACJ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { normalizeToolName } from "../shared.js";
|
|
2
|
+
import type { ToolCallRecord } from "../types.js";
|
|
3
|
+
export { normalizeToolName };
|
|
4
|
+
export interface ClaudeTranscriptParseResult {
|
|
5
|
+
toolCalls: ToolCallRecord[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Exact tool calls from the session JSONL claude writes per session under
|
|
9
|
+
* `$CLAUDE_CONFIG_DIR/projects/<dir>/<session>.jsonl`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function collectSessionJsonlToolCalls(claudeHomeDir: string, seenCallKeys?: Set<string>): ToolCallRecord[];
|
|
12
|
+
export interface ParseClaudeTurnOptions {
|
|
13
|
+
/** Hermetic `CLAUDE_CONFIG_DIR`; exact tool calls are read from the session JSONL. */
|
|
14
|
+
claudeHomeDir?: string;
|
|
15
|
+
/** Persistent per-session dedupe set so earlier turns' calls are not re-attributed. */
|
|
16
|
+
seenCallKeys?: Set<string>;
|
|
17
|
+
}
|
|
18
|
+
export declare function parseClaudeTurn({ claudeHomeDir, seenCallKeys }: ParseClaudeTurnOptions): ClaudeTranscriptParseResult;
|
|
19
|
+
//# sourceMappingURL=parseClaudeToolCalls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseClaudeToolCalls.d.ts","sourceRoot":"","sources":["../../../src/harness/claude/parseClaudeToolCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B,MAAM,WAAW,2BAA2B;IACxC,SAAS,EAAE,cAAc,EAAE,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,cAAc,EAAE,CA+DhH;AAED,MAAM,WAAW,sBAAsB;IACnC,sFAAsF;IACtF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uFAAuF;IACvF,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC9B;AAED,wBAAgB,eAAe,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,EAAE,sBAAsB,GAAG,2BAA2B,CAOpH"}
|