@forwardimpact/libeval 0.1.63 → 0.1.65
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 +21 -201
- package/bin/fit-trace.js +166 -31
- package/package.json +1 -1
- package/src/benchmark/judge.js +16 -1
- package/src/benchmark/result.js +12 -0
- package/src/benchmark/runner.js +44 -25
- package/src/commands/callback.js +11 -5
- package/src/commands/trace.js +333 -53
- package/src/cost.js +79 -0
- package/src/index.js +2 -0
- package/src/redaction.js +65 -6
- package/src/trace-collector.js +58 -2
- package/src/trace-github.js +175 -3
- package/src/trace-multi.js +101 -0
- package/src/trace-query.js +294 -45
- package/src/trace-render.js +211 -0
- package/src/trace-usage.js +249 -0
package/LICENSE
CHANGED
|
@@ -1,201 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright 2026 Dick Olsson
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Zachary Rice
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/bin/fit-trace.js
CHANGED
|
@@ -9,6 +9,7 @@ import { createLogger } from "@forwardimpact/libtelemetry";
|
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
11
|
runRunsCommand,
|
|
12
|
+
runFindCommand,
|
|
12
13
|
runDownloadCommand,
|
|
13
14
|
runOverviewCommand,
|
|
14
15
|
runCountCommand,
|
|
@@ -22,14 +23,30 @@ import {
|
|
|
22
23
|
runReasoningCommand,
|
|
23
24
|
runTimelineCommand,
|
|
24
25
|
runStatsCommand,
|
|
26
|
+
runCostCommand,
|
|
25
27
|
runInitCommand,
|
|
26
28
|
runTurnCommand,
|
|
27
29
|
runFilterCommand,
|
|
28
30
|
runSplitCommand,
|
|
31
|
+
runToolCallsCommand,
|
|
32
|
+
runCommandsCommand,
|
|
33
|
+
runPathsCommand,
|
|
34
|
+
runCompareCommand,
|
|
29
35
|
} from "../src/commands/trace.js";
|
|
30
36
|
import { runAssertCommand } from "../src/commands/assert.js";
|
|
31
37
|
import { runByDiscussionCommand } from "../src/commands/by-discussion.js";
|
|
32
38
|
|
|
39
|
+
// Cross-trace verbs take one or more trace files via repeated `--file`
|
|
40
|
+
// (libcli's named-slot `dispatch()` has no variadic positional). A value with
|
|
41
|
+
// glob metacharacters is expanded by the handler via `runtime.fsSync.globSync`.
|
|
42
|
+
const fileOption = () => ({
|
|
43
|
+
file: {
|
|
44
|
+
type: "string",
|
|
45
|
+
multiple: true,
|
|
46
|
+
description: "Trace file (repeat or pass a quoted glob for several)",
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
33
50
|
const definition = {
|
|
34
51
|
name: "fit-trace",
|
|
35
52
|
description:
|
|
@@ -47,6 +64,30 @@ const definition = {
|
|
|
47
64
|
type: "string",
|
|
48
65
|
description: "How far back to search (default: 7d)",
|
|
49
66
|
},
|
|
67
|
+
participant: {
|
|
68
|
+
type: "string",
|
|
69
|
+
description:
|
|
70
|
+
"Filter to runs carrying this participant's trace lane; in-progress candidates are labeled, not dropped",
|
|
71
|
+
},
|
|
72
|
+
repo: {
|
|
73
|
+
type: "string",
|
|
74
|
+
description:
|
|
75
|
+
"GitHub repo override (default: $GITHUB_REPOSITORY or 'origin' git remote)",
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "find",
|
|
81
|
+
args: ["run-id", "participant"],
|
|
82
|
+
argsUsage: "<run-id> <participant>",
|
|
83
|
+
handler: runFindCommand,
|
|
84
|
+
description:
|
|
85
|
+
"Resolve a participant's lane trace for a known run id in one keyed lookup (no run enumeration, no content inspection)",
|
|
86
|
+
options: {
|
|
87
|
+
dir: {
|
|
88
|
+
type: "string",
|
|
89
|
+
description: "Output directory for a downloaded dispatch artifact",
|
|
90
|
+
},
|
|
50
91
|
repo: {
|
|
51
92
|
type: "string",
|
|
52
93
|
description:
|
|
@@ -73,17 +114,17 @@ const definition = {
|
|
|
73
114
|
},
|
|
74
115
|
{
|
|
75
116
|
name: "overview",
|
|
76
|
-
args: [
|
|
77
|
-
argsUsage: "<file>",
|
|
117
|
+
args: [],
|
|
78
118
|
handler: runOverviewCommand,
|
|
79
119
|
description: "Metadata, summary, turn count, tool frequency",
|
|
120
|
+
options: fileOption(),
|
|
80
121
|
},
|
|
81
122
|
{
|
|
82
123
|
name: "count",
|
|
83
|
-
args: [
|
|
84
|
-
argsUsage: "<file>",
|
|
124
|
+
args: [],
|
|
85
125
|
handler: runCountCommand,
|
|
86
126
|
description: "Number of turns",
|
|
127
|
+
options: fileOption(),
|
|
87
128
|
},
|
|
88
129
|
{
|
|
89
130
|
name: "batch",
|
|
@@ -94,17 +135,23 @@ const definition = {
|
|
|
94
135
|
},
|
|
95
136
|
{
|
|
96
137
|
name: "head",
|
|
97
|
-
args: [
|
|
98
|
-
argsUsage: "<file> [N]",
|
|
138
|
+
args: [],
|
|
99
139
|
handler: runHeadCommand,
|
|
100
|
-
description: "First N turns (default 10)",
|
|
140
|
+
description: "First N turns (default 10; set with --lines)",
|
|
141
|
+
options: {
|
|
142
|
+
...fileOption(),
|
|
143
|
+
lines: { type: "string", description: "Number of turns (default: 10)" },
|
|
144
|
+
},
|
|
101
145
|
},
|
|
102
146
|
{
|
|
103
147
|
name: "tail",
|
|
104
|
-
args: [
|
|
105
|
-
argsUsage: "<file> [N]",
|
|
148
|
+
args: [],
|
|
106
149
|
handler: runTailCommand,
|
|
107
|
-
description: "Last N turns (default 10)",
|
|
150
|
+
description: "Last N turns (default 10; set with --lines)",
|
|
151
|
+
options: {
|
|
152
|
+
...fileOption(),
|
|
153
|
+
lines: { type: "string", description: "Number of turns (default: 10)" },
|
|
154
|
+
},
|
|
108
155
|
},
|
|
109
156
|
{
|
|
110
157
|
name: "search",
|
|
@@ -129,56 +176,127 @@ const definition = {
|
|
|
129
176
|
},
|
|
130
177
|
{
|
|
131
178
|
name: "tools",
|
|
132
|
-
args: [
|
|
133
|
-
argsUsage: "<file>",
|
|
179
|
+
args: [],
|
|
134
180
|
handler: runToolsCommand,
|
|
135
|
-
description:
|
|
181
|
+
description:
|
|
182
|
+
"Tool usage frequency (descending). See also `tool` (turns for one tool) and `tool-calls` (paired use+result records)",
|
|
183
|
+
options: fileOption(),
|
|
136
184
|
},
|
|
137
185
|
{
|
|
138
186
|
name: "tool",
|
|
139
187
|
args: ["file", "name"],
|
|
140
188
|
argsUsage: "<file> <name>",
|
|
141
189
|
handler: runToolCommand,
|
|
142
|
-
description:
|
|
190
|
+
description:
|
|
191
|
+
"All turns involving a specific tool. See also `tools` (frequency) and `tool-calls` (paired use+result records)",
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: "tool-calls",
|
|
195
|
+
args: [],
|
|
196
|
+
handler: runToolCallsCommand,
|
|
197
|
+
description:
|
|
198
|
+
"One record per tool_use block, each paired with its tool_result by toolUseId (orphans emit result:null). See also `tool` and `tools`",
|
|
199
|
+
options: fileOption(),
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: "commands",
|
|
203
|
+
args: [],
|
|
204
|
+
handler: runCommandsCommand,
|
|
205
|
+
description:
|
|
206
|
+
"One record per Bash tool_use block, carrying the command text",
|
|
207
|
+
options: {
|
|
208
|
+
...fileOption(),
|
|
209
|
+
match: {
|
|
210
|
+
type: "string",
|
|
211
|
+
description: "Filter to commands whose text matches this regex",
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
name: "paths",
|
|
217
|
+
args: [],
|
|
218
|
+
handler: runPathsCommand,
|
|
219
|
+
description:
|
|
220
|
+
"Distinct Read/Edit/Write file_path arguments, frequency-sorted",
|
|
221
|
+
options: {
|
|
222
|
+
...fileOption(),
|
|
223
|
+
prefix: {
|
|
224
|
+
type: "string",
|
|
225
|
+
description: "Filter to paths beginning with this prefix",
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: "compare",
|
|
231
|
+
args: ["file-a", "file-b"],
|
|
232
|
+
argsUsage: "<file-a> <file-b>",
|
|
233
|
+
handler: runCompareCommand,
|
|
234
|
+
description:
|
|
235
|
+
"Side-by-side comparison of two traces: turns, tools, paths, cost, and per-tool delta",
|
|
143
236
|
},
|
|
144
237
|
{
|
|
145
238
|
name: "errors",
|
|
146
|
-
args: [
|
|
147
|
-
argsUsage: "<file>",
|
|
239
|
+
args: [],
|
|
148
240
|
handler: runErrorsCommand,
|
|
149
241
|
description: "Tool results with isError=true",
|
|
242
|
+
options: fileOption(),
|
|
150
243
|
},
|
|
151
244
|
{
|
|
152
245
|
name: "reasoning",
|
|
153
|
-
args: [
|
|
154
|
-
argsUsage: "<file>",
|
|
246
|
+
args: [],
|
|
155
247
|
handler: runReasoningCommand,
|
|
156
248
|
description: "Agent reasoning text only",
|
|
157
249
|
options: {
|
|
250
|
+
...fileOption(),
|
|
158
251
|
from: { type: "string", description: "Start at turn index" },
|
|
159
252
|
to: { type: "string", description: "Stop before turn index" },
|
|
160
253
|
},
|
|
161
254
|
},
|
|
162
255
|
{
|
|
163
256
|
name: "timeline",
|
|
164
|
-
args: [
|
|
165
|
-
argsUsage: "<file>",
|
|
257
|
+
args: [],
|
|
166
258
|
handler: runTimelineCommand,
|
|
167
259
|
description: "Compact one-line-per-turn overview",
|
|
260
|
+
options: fileOption(),
|
|
168
261
|
},
|
|
169
262
|
{
|
|
170
263
|
name: "stats",
|
|
171
|
-
args: [
|
|
172
|
-
argsUsage: "<file>",
|
|
264
|
+
args: [],
|
|
173
265
|
handler: runStatsCommand,
|
|
174
266
|
description: "Token usage and cost breakdown",
|
|
267
|
+
options: {
|
|
268
|
+
...fileOption(),
|
|
269
|
+
"by-tool": {
|
|
270
|
+
type: "boolean",
|
|
271
|
+
description: "Per-tool token attribution and cost share",
|
|
272
|
+
},
|
|
273
|
+
summary: {
|
|
274
|
+
type: "boolean",
|
|
275
|
+
description: "Totals only (suppress the per-turn array)",
|
|
276
|
+
},
|
|
277
|
+
},
|
|
175
278
|
},
|
|
176
279
|
{
|
|
177
|
-
name: "
|
|
280
|
+
name: "cost",
|
|
178
281
|
args: ["file"],
|
|
179
282
|
argsUsage: "<file>",
|
|
283
|
+
handler: runCostCommand,
|
|
284
|
+
description:
|
|
285
|
+
"Total run cost across every participant (agent, supervisor, judge, named profiles), with a per-source breakdown",
|
|
286
|
+
options: {
|
|
287
|
+
markdown: {
|
|
288
|
+
type: "boolean",
|
|
289
|
+
description:
|
|
290
|
+
"Emit a GitHub-flavored markdown block (redirect into $GITHUB_STEP_SUMMARY)",
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
name: "init",
|
|
296
|
+
args: [],
|
|
180
297
|
handler: runInitCommand,
|
|
181
298
|
description: "Full system/init event",
|
|
299
|
+
options: fileOption(),
|
|
182
300
|
},
|
|
183
301
|
{
|
|
184
302
|
name: "turn",
|
|
@@ -203,11 +321,11 @@ const definition = {
|
|
|
203
321
|
},
|
|
204
322
|
{
|
|
205
323
|
name: "filter",
|
|
206
|
-
args: [
|
|
207
|
-
argsUsage: "<file>",
|
|
324
|
+
args: [],
|
|
208
325
|
handler: runFilterCommand,
|
|
209
326
|
description: "Filter turns by role, tool, or error status",
|
|
210
327
|
options: {
|
|
328
|
+
...fileOption(),
|
|
211
329
|
role: {
|
|
212
330
|
type: "string",
|
|
213
331
|
description: "Turn role (system, user, assistant, tool_result)",
|
|
@@ -286,7 +404,15 @@ const definition = {
|
|
|
286
404
|
globalOptions: {
|
|
287
405
|
help: { type: "boolean", short: "h", description: "Show this help" },
|
|
288
406
|
version: { type: "boolean", description: "Show version" },
|
|
289
|
-
json: {
|
|
407
|
+
json: {
|
|
408
|
+
type: "boolean",
|
|
409
|
+
description: "Output help as JSON (use --format json for command output)",
|
|
410
|
+
},
|
|
411
|
+
format: {
|
|
412
|
+
type: "string",
|
|
413
|
+
default: "text",
|
|
414
|
+
description: "Command output format: text (default) or json",
|
|
415
|
+
},
|
|
290
416
|
signatures: {
|
|
291
417
|
type: "boolean",
|
|
292
418
|
description: "Include thinking.signature blobs in output",
|
|
@@ -294,14 +420,23 @@ const definition = {
|
|
|
294
420
|
},
|
|
295
421
|
examples: [
|
|
296
422
|
"fit-trace runs --lookback 7d",
|
|
423
|
+
"fit-trace runs --participant release-engineer",
|
|
424
|
+
"fit-trace find 27401632821 release-engineer",
|
|
297
425
|
"fit-trace download 24497273755",
|
|
298
426
|
"fit-trace split structured.json --mode=facilitate",
|
|
299
|
-
"fit-trace overview structured.json",
|
|
300
|
-
"fit-trace
|
|
301
|
-
"fit-trace
|
|
427
|
+
"fit-trace overview --file structured.json",
|
|
428
|
+
"fit-trace overview --file structured.json --format json",
|
|
429
|
+
"fit-trace timeline --file structured.json",
|
|
430
|
+
"fit-trace stats --file structured.json --by-tool",
|
|
431
|
+
"fit-trace cost trace.ndjson",
|
|
432
|
+
"fit-trace cost trace.ndjson --markdown",
|
|
302
433
|
"fit-trace tool structured.json Conclude",
|
|
434
|
+
"fit-trace tool-calls --file structured.json",
|
|
435
|
+
"fit-trace commands --file structured.json --match '^git'",
|
|
436
|
+
"fit-trace paths --file 'traces/*.ndjson' --prefix /app",
|
|
437
|
+
"fit-trace compare trace-a.ndjson trace-b.ndjson",
|
|
303
438
|
"fit-trace search structured.json 'error|fail' --context 1",
|
|
304
|
-
"fit-trace filter structured.json --tool Bash --error",
|
|
439
|
+
"fit-trace filter --file structured.json --tool Bash --error",
|
|
305
440
|
"fit-trace turn structured.json 3",
|
|
306
441
|
"fit-trace assert has-heading --grep '^## Problem' spec.md",
|
|
307
442
|
"fit-trace assert no-leak --not --grep 'password' output.log",
|
|
@@ -336,7 +471,7 @@ const logger = createLogger("trace", runtime);
|
|
|
336
471
|
|
|
337
472
|
// Commands that talk to the GitHub API need a config-backed token resolver;
|
|
338
473
|
// the rest only read local trace files through the runtime.
|
|
339
|
-
const NEEDS_CONFIG = new Set(["runs", "download"]);
|
|
474
|
+
const NEEDS_CONFIG = new Set(["runs", "find", "download"]);
|
|
340
475
|
|
|
341
476
|
async function main() {
|
|
342
477
|
const cli = createCli(definition, {
|
package/package.json
CHANGED
package/src/benchmark/judge.js
CHANGED
|
@@ -23,11 +23,13 @@
|
|
|
23
23
|
|
|
24
24
|
import { createJudge } from "../judge.js";
|
|
25
25
|
import { createRedactor } from "../redaction.js";
|
|
26
|
+
import { sumTraceCost } from "../cost.js";
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* @typedef {object} JudgeVerdict
|
|
29
30
|
* @property {"pass" | "fail"} verdict
|
|
30
31
|
* @property {string} summary
|
|
32
|
+
* @property {number} costUsd - Cost of the judge's own SDK session.
|
|
31
33
|
*/
|
|
32
34
|
|
|
33
35
|
/**
|
|
@@ -81,12 +83,25 @@ export async function runJudge(task, workdir, invariants, deps, context) {
|
|
|
81
83
|
await new Promise((r) => output.end(r));
|
|
82
84
|
}
|
|
83
85
|
|
|
86
|
+
// The judge is its own SDK session; its spend lands in the judge trace we
|
|
87
|
+
// just wrote, not in the supervisor's combined trace. Read it back so the
|
|
88
|
+
// benchmark record's cost includes the judge.
|
|
89
|
+
const judgeTrace = await fs
|
|
90
|
+
.readFile(workdir.judgeTracePath, "utf8")
|
|
91
|
+
.catch(() => "");
|
|
92
|
+
const { totalCostUsd } = sumTraceCost(judgeTrace.split("\n"));
|
|
93
|
+
|
|
84
94
|
if (outcome.verdict === null) {
|
|
85
|
-
return {
|
|
95
|
+
return {
|
|
96
|
+
verdict: "fail",
|
|
97
|
+
summary: "judge did not conclude",
|
|
98
|
+
costUsd: totalCostUsd,
|
|
99
|
+
};
|
|
86
100
|
}
|
|
87
101
|
return {
|
|
88
102
|
verdict: outcome.verdict === "success" ? "pass" : "fail",
|
|
89
103
|
summary: outcome.summary ?? "",
|
|
104
|
+
costUsd: totalCostUsd,
|
|
90
105
|
};
|
|
91
106
|
}
|
|
92
107
|
|
package/src/benchmark/result.js
CHANGED
|
@@ -27,6 +27,17 @@ const JUDGE_VERDICT_SHAPE = z.object({
|
|
|
27
27
|
summary: z.string(),
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Per-participant cost attribution. `costUsd` is the sum of these; the
|
|
32
|
+
* breakdown lets reports show where the spend went. The judge runs as its
|
|
33
|
+
* own SDK session, so its cost is tracked separately from agent/supervisor.
|
|
34
|
+
*/
|
|
35
|
+
const COST_BREAKDOWN_SHAPE = z.object({
|
|
36
|
+
agent: z.number(),
|
|
37
|
+
supervisor: z.number(),
|
|
38
|
+
judge: z.number(),
|
|
39
|
+
});
|
|
40
|
+
|
|
30
41
|
const PROFILES_SHAPE = z.object({
|
|
31
42
|
agent: z.union([z.string(), z.null()]),
|
|
32
43
|
supervisor: z.union([z.string(), z.null()]),
|
|
@@ -44,6 +55,7 @@ const COMMON_FIELDS = {
|
|
|
44
55
|
runIndex: z.number().int().min(0),
|
|
45
56
|
verdict: VERDICT_ENUM,
|
|
46
57
|
costUsd: z.number(),
|
|
58
|
+
costBreakdown: COST_BREAKDOWN_SHAPE.optional(),
|
|
47
59
|
turns: z.number().int().min(0),
|
|
48
60
|
profiles: PROFILES_SHAPE,
|
|
49
61
|
model: z.object({
|