@salesforce/agents 1.5.1 → 1.6.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/lib/agentEvalRunner.d.ts +26 -0
- package/lib/agentEvalRunner.js +102 -0
- package/lib/agentEvalRunner.js.map +1 -0
- package/lib/evalFormatter.d.ts +44 -0
- package/lib/evalFormatter.js +267 -0
- package/lib/evalFormatter.js.map +1 -0
- package/lib/evalNormalizer.d.ts +57 -0
- package/lib/evalNormalizer.js +442 -0
- package/lib/evalNormalizer.js.map +1 -0
- package/lib/index.d.ts +6 -2
- package/lib/index.js +25 -1
- package/lib/index.js.map +1 -1
- package/lib/utils.d.ts +21 -0
- package/lib/utils.js +55 -1
- package/lib/utils.js.map +1 -1
- package/lib/yamlSpecTranslator.d.ts +20 -0
- package/lib/yamlSpecTranslator.js +234 -0
- package/lib/yamlSpecTranslator.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026, Salesforce, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.normalizePayload = normalizePayload;
|
|
19
|
+
exports.normalizeMcpShorthand = normalizeMcpShorthand;
|
|
20
|
+
exports.autoCorrectFields = autoCorrectFields;
|
|
21
|
+
exports.normalizeCamelCase = normalizeCamelCase;
|
|
22
|
+
exports.normalizeEvaluatorFields = normalizeEvaluatorFields;
|
|
23
|
+
exports.convertShorthandRefs = convertShorthandRefs;
|
|
24
|
+
exports.injectDefaults = injectDefaults;
|
|
25
|
+
exports.stripUnrecognizedFields = stripUnrecognizedFields;
|
|
26
|
+
exports.splitIntoBatches = splitIntoBatches;
|
|
27
|
+
// --- Evaluator classification ---
|
|
28
|
+
const SCORING_EVALUATORS = new Set([
|
|
29
|
+
'evaluator.text_alignment',
|
|
30
|
+
'evaluator.hallucination_detection',
|
|
31
|
+
'evaluator.citation_recall',
|
|
32
|
+
'evaluator.answer_faithfulness',
|
|
33
|
+
]);
|
|
34
|
+
const ASSERTION_EVALUATORS = new Set(['evaluator.string_assertion', 'evaluator.json_assertion']);
|
|
35
|
+
const DEFAULT_METRIC_NAMES = {
|
|
36
|
+
'evaluator.text_alignment': 'base.cosine_similarity',
|
|
37
|
+
'evaluator.hallucination_detection': 'hallucination_detection',
|
|
38
|
+
'evaluator.citation_recall': 'citation_recall',
|
|
39
|
+
'evaluator.answer_faithfulness': 'answer_faithfulness',
|
|
40
|
+
};
|
|
41
|
+
const SCORING_VALID_FIELDS = new Set([
|
|
42
|
+
'type',
|
|
43
|
+
'id',
|
|
44
|
+
'generated_output',
|
|
45
|
+
'reference_answer',
|
|
46
|
+
'metric_name',
|
|
47
|
+
'threshold',
|
|
48
|
+
]);
|
|
49
|
+
const ASSERTION_VALID_FIELDS = new Set([
|
|
50
|
+
'type',
|
|
51
|
+
'id',
|
|
52
|
+
'actual',
|
|
53
|
+
'expected',
|
|
54
|
+
'operator',
|
|
55
|
+
'threshold',
|
|
56
|
+
'json_path',
|
|
57
|
+
'json_schema',
|
|
58
|
+
'metric_name',
|
|
59
|
+
]);
|
|
60
|
+
const VALID_AGENT_FIELDS = {
|
|
61
|
+
'agent.create_session': new Set([
|
|
62
|
+
'type',
|
|
63
|
+
'id',
|
|
64
|
+
'agent_id',
|
|
65
|
+
'agent_version_id',
|
|
66
|
+
'use_agent_api',
|
|
67
|
+
'planner_id',
|
|
68
|
+
'state',
|
|
69
|
+
'setupSessionContext',
|
|
70
|
+
'context_variables',
|
|
71
|
+
]),
|
|
72
|
+
'agent.send_message': new Set(['type', 'id', 'session_id', 'utterance']),
|
|
73
|
+
'agent.get_state': new Set(['type', 'id', 'session_id']),
|
|
74
|
+
};
|
|
75
|
+
// --- Auto-correction maps ---
|
|
76
|
+
const AGENT_CORRECTIONS = {
|
|
77
|
+
agentId: 'agent_id',
|
|
78
|
+
agentVersionId: 'agent_version_id',
|
|
79
|
+
sessionId: 'session_id',
|
|
80
|
+
text: 'utterance',
|
|
81
|
+
message: 'utterance',
|
|
82
|
+
input: 'utterance',
|
|
83
|
+
prompt: 'utterance',
|
|
84
|
+
user_message: 'utterance',
|
|
85
|
+
userMessage: 'utterance',
|
|
86
|
+
};
|
|
87
|
+
const EVALUATOR_CORRECTIONS = {
|
|
88
|
+
subject: 'actual',
|
|
89
|
+
expectedValue: 'expected',
|
|
90
|
+
expected_value: 'expected',
|
|
91
|
+
actualValue: 'actual',
|
|
92
|
+
actual_value: 'actual',
|
|
93
|
+
assertionType: 'operator',
|
|
94
|
+
assertion_type: 'operator',
|
|
95
|
+
comparator: 'operator',
|
|
96
|
+
};
|
|
97
|
+
// --- camelCase alias maps for agent.create_session ---
|
|
98
|
+
const AGENT_FIELD_ALIASES = {
|
|
99
|
+
useAgentApi: 'use_agent_api',
|
|
100
|
+
plannerId: 'planner_id',
|
|
101
|
+
plannerDefinitionId: 'planner_id',
|
|
102
|
+
planner_definition_id: 'planner_id',
|
|
103
|
+
planner_version_id: 'planner_id',
|
|
104
|
+
plannerVersionId: 'planner_id',
|
|
105
|
+
};
|
|
106
|
+
// --- Scoring evaluator field aliases ---
|
|
107
|
+
const SCORING_FIELD_ALIASES = {
|
|
108
|
+
actual: 'generated_output',
|
|
109
|
+
expected: 'reference_answer',
|
|
110
|
+
actual_value: 'generated_output',
|
|
111
|
+
expected_value: 'reference_answer',
|
|
112
|
+
actual_output: 'generated_output',
|
|
113
|
+
expected_output: 'reference_answer',
|
|
114
|
+
response: 'generated_output',
|
|
115
|
+
ground_truth: 'reference_answer',
|
|
116
|
+
};
|
|
117
|
+
// --- Assertion evaluator field aliases ---
|
|
118
|
+
const ASSERTION_FIELD_ALIASES = {
|
|
119
|
+
actual_value: 'actual',
|
|
120
|
+
expected_value: 'expected',
|
|
121
|
+
generated_output: 'actual',
|
|
122
|
+
reference_answer: 'expected',
|
|
123
|
+
actual_output: 'actual',
|
|
124
|
+
expected_output: 'expected',
|
|
125
|
+
response: 'actual',
|
|
126
|
+
ground_truth: 'expected',
|
|
127
|
+
};
|
|
128
|
+
// --- MCP shorthand field mapping ---
|
|
129
|
+
// MCP uses `field: "gs1.planner_state.topic"` — map to Eval API `actual` with correct JSONPath
|
|
130
|
+
const MCP_FIELD_MAP = {
|
|
131
|
+
'planner_state.topic': 'response.planner_response.lastExecution.topic',
|
|
132
|
+
'planner_state.invokedActions': 'response.planner_response.lastExecution.invokedActions',
|
|
133
|
+
'planner_state.actionsSequence': 'response.planner_response.lastExecution.invokedActions',
|
|
134
|
+
response: 'response',
|
|
135
|
+
'response.messages': 'response',
|
|
136
|
+
};
|
|
137
|
+
// --- Main entry point ---
|
|
138
|
+
/**
|
|
139
|
+
* Apply all normalizations to a test payload.
|
|
140
|
+
* Passes run in order: mcp-shorthand -> auto-correct -> camelCase -> evaluator fields -> shorthand refs -> defaults -> strip.
|
|
141
|
+
*/
|
|
142
|
+
function normalizePayload(payload) {
|
|
143
|
+
const normalized = {
|
|
144
|
+
tests: payload.tests.map((test) => {
|
|
145
|
+
let steps = [...test.steps];
|
|
146
|
+
steps = normalizeMcpShorthand(steps);
|
|
147
|
+
steps = autoCorrectFields(steps);
|
|
148
|
+
steps = normalizeCamelCase(steps);
|
|
149
|
+
steps = normalizeEvaluatorFields(steps);
|
|
150
|
+
steps = convertShorthandRefs(steps);
|
|
151
|
+
steps = injectDefaults(steps);
|
|
152
|
+
steps = stripUnrecognizedFields(steps);
|
|
153
|
+
return { ...test, steps };
|
|
154
|
+
}),
|
|
155
|
+
};
|
|
156
|
+
return normalized;
|
|
157
|
+
}
|
|
158
|
+
// --- Individual normalization passes ---
|
|
159
|
+
/**
|
|
160
|
+
* Convert MCP shorthand format to raw Eval API format.
|
|
161
|
+
* MCP uses type="evaluator" + evaluator_type, raw API uses type="evaluator.xxx".
|
|
162
|
+
* Also maps `field` to `actual` with proper JSONPath and auto-generates missing `id` fields.
|
|
163
|
+
*/
|
|
164
|
+
function normalizeMcpShorthand(steps) {
|
|
165
|
+
let evalCounter = 0;
|
|
166
|
+
return steps.map((step) => {
|
|
167
|
+
const evaluator_type = step.evaluator_type;
|
|
168
|
+
// Only applies to MCP shorthand: type="evaluator" with evaluator_type field
|
|
169
|
+
if (step.type !== 'evaluator' || !evaluator_type)
|
|
170
|
+
return step;
|
|
171
|
+
const normalized = { ...step };
|
|
172
|
+
// Merge type: "evaluator" + evaluator_type: "xxx" → type: "evaluator.xxx"
|
|
173
|
+
normalized.type = `evaluator.${evaluator_type}`;
|
|
174
|
+
delete normalized.evaluator_type;
|
|
175
|
+
// Convert `field` to `actual` with proper shorthand ref format
|
|
176
|
+
if ('field' in normalized) {
|
|
177
|
+
if (!('actual' in normalized)) {
|
|
178
|
+
const fieldValue = normalized.field;
|
|
179
|
+
// Parse "gs1.planner_state.topic" → stepId="gs1", fieldPath="planner_state.topic"
|
|
180
|
+
const dotIdx = fieldValue.indexOf('.');
|
|
181
|
+
if (dotIdx > 0) {
|
|
182
|
+
const stepId = fieldValue.substring(0, dotIdx);
|
|
183
|
+
const fieldPath = fieldValue.substring(dotIdx + 1);
|
|
184
|
+
const mappedPath = MCP_FIELD_MAP[fieldPath] ?? fieldPath;
|
|
185
|
+
normalized.actual = `{${stepId}.${mappedPath}}`;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
normalized.actual = fieldValue;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
delete normalized.field;
|
|
192
|
+
}
|
|
193
|
+
// Auto-generate id if missing
|
|
194
|
+
if (!normalized.id || normalized.id === '') {
|
|
195
|
+
normalized.id = `eval_${evalCounter}`;
|
|
196
|
+
evalCounter++;
|
|
197
|
+
}
|
|
198
|
+
return normalized;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Auto-correct common field name mistakes.
|
|
203
|
+
* Maps wrong field names to correct ones (agentId->agent_id, text->utterance, etc.)
|
|
204
|
+
*/
|
|
205
|
+
function autoCorrectFields(steps) {
|
|
206
|
+
return steps.map((step) => {
|
|
207
|
+
const corrected = { ...step };
|
|
208
|
+
const stepType = corrected.type ?? '';
|
|
209
|
+
if (stepType.startsWith('agent.')) {
|
|
210
|
+
for (const [wrong, correct] of Object.entries(AGENT_CORRECTIONS)) {
|
|
211
|
+
if (wrong in corrected && !(correct in corrected)) {
|
|
212
|
+
corrected[correct] = corrected[wrong];
|
|
213
|
+
delete corrected[wrong];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else if (stepType.startsWith('evaluator.')) {
|
|
218
|
+
for (const [wrong, correct] of Object.entries(EVALUATOR_CORRECTIONS)) {
|
|
219
|
+
if (wrong in corrected && !(correct in corrected)) {
|
|
220
|
+
corrected[correct] = corrected[wrong];
|
|
221
|
+
delete corrected[wrong];
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return corrected;
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Normalize camelCase agent field names to snake_case.
|
|
230
|
+
* useAgentApi->use_agent_api, plannerDefinitionId->planner_id, etc.
|
|
231
|
+
*/
|
|
232
|
+
function normalizeCamelCase(steps) {
|
|
233
|
+
return steps.map((step) => {
|
|
234
|
+
if (step.type !== 'agent.create_session')
|
|
235
|
+
return step;
|
|
236
|
+
const normalized = { ...step };
|
|
237
|
+
for (const [alias, canonical] of Object.entries(AGENT_FIELD_ALIASES)) {
|
|
238
|
+
if (alias in normalized) {
|
|
239
|
+
if (!(canonical in normalized)) {
|
|
240
|
+
normalized[canonical] = normalized[alias];
|
|
241
|
+
}
|
|
242
|
+
delete normalized[alias];
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return normalized;
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Apply field aliases: remap alias keys to canonical keys, removing duplicates.
|
|
250
|
+
*/
|
|
251
|
+
function applyFieldAliases(step, aliases) {
|
|
252
|
+
for (const [alias, canonical] of Object.entries(aliases)) {
|
|
253
|
+
if (alias in step && !(canonical in step)) {
|
|
254
|
+
step[canonical] = step[alias];
|
|
255
|
+
delete step[alias];
|
|
256
|
+
}
|
|
257
|
+
else if (alias in step && canonical in step) {
|
|
258
|
+
delete step[alias];
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Normalize a scoring evaluator step (field aliases + metric_name injection).
|
|
264
|
+
*/
|
|
265
|
+
function normalizeScoringEvaluator(normalized, evalType) {
|
|
266
|
+
applyFieldAliases(normalized, SCORING_FIELD_ALIASES);
|
|
267
|
+
// Auto-inject or correct metric_name
|
|
268
|
+
if (!('metric_name' in normalized)) {
|
|
269
|
+
const defaultMetric = DEFAULT_METRIC_NAMES[evalType];
|
|
270
|
+
if (defaultMetric) {
|
|
271
|
+
normalized.metric_name = defaultMetric;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
else if (normalized.metric_name === evalType.split('.')[1]) {
|
|
275
|
+
const defaultMetric = DEFAULT_METRIC_NAMES[evalType];
|
|
276
|
+
if (defaultMetric) {
|
|
277
|
+
normalized.metric_name = defaultMetric;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Normalize an assertion evaluator step (field aliases + operator lowercase + metric_name).
|
|
283
|
+
*/
|
|
284
|
+
function normalizeAssertionEvaluator(normalized, evalType) {
|
|
285
|
+
applyFieldAliases(normalized, ASSERTION_FIELD_ALIASES);
|
|
286
|
+
// Auto-lowercase operator
|
|
287
|
+
if ('operator' in normalized && typeof normalized.operator === 'string') {
|
|
288
|
+
normalized.operator = normalized.operator.toLowerCase();
|
|
289
|
+
}
|
|
290
|
+
// Auto-inject metric_name for assertion evaluators
|
|
291
|
+
if (!('metric_name' in normalized)) {
|
|
292
|
+
normalized.metric_name = evalType.split('.')[1];
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Normalize evaluator field names based on evaluator category.
|
|
297
|
+
* Maps actual/expected <-> generated_output/reference_answer.
|
|
298
|
+
* Also auto-lowercases operator values and auto-injects metric_name.
|
|
299
|
+
*/
|
|
300
|
+
function normalizeEvaluatorFields(steps) {
|
|
301
|
+
return steps.map((step) => {
|
|
302
|
+
const evalType = step.type ?? '';
|
|
303
|
+
if (!evalType.startsWith('evaluator.'))
|
|
304
|
+
return step;
|
|
305
|
+
const normalized = { ...step };
|
|
306
|
+
if (SCORING_EVALUATORS.has(evalType)) {
|
|
307
|
+
normalizeScoringEvaluator(normalized, evalType);
|
|
308
|
+
}
|
|
309
|
+
else if (ASSERTION_EVALUATORS.has(evalType)) {
|
|
310
|
+
normalizeAssertionEvaluator(normalized, evalType);
|
|
311
|
+
}
|
|
312
|
+
// Don't inject metric_name for unknown evaluator types to avoid API validation errors
|
|
313
|
+
// Unknown evaluators like bot_response_rating and planner_topic_assertion don't use metric_name
|
|
314
|
+
return normalized;
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Convert {step_id.field} shorthand references to JSONPath $.outputs[N].field.
|
|
319
|
+
* Builds step_id->index mapping from non-evaluator steps.
|
|
320
|
+
*/
|
|
321
|
+
function convertShorthandRefs(steps) {
|
|
322
|
+
// Build step_id -> output-array index mapping
|
|
323
|
+
const stepIdToIdx = {};
|
|
324
|
+
let outputIdx = 0;
|
|
325
|
+
for (const step of steps) {
|
|
326
|
+
const sid = step.id;
|
|
327
|
+
const stype = step.type ?? '';
|
|
328
|
+
if (sid && !stype.startsWith('evaluator.')) {
|
|
329
|
+
stepIdToIdx[sid] = outputIdx;
|
|
330
|
+
outputIdx += 1;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
const refPattern = /\{([^}]+)\}/g;
|
|
334
|
+
function replaceValue(value) {
|
|
335
|
+
if (typeof value !== 'string')
|
|
336
|
+
return value;
|
|
337
|
+
return value.replace(refPattern, (match, ref) => {
|
|
338
|
+
const dotIdx = ref.indexOf('.');
|
|
339
|
+
if (dotIdx < 0)
|
|
340
|
+
return match;
|
|
341
|
+
const sid = ref.substring(0, dotIdx);
|
|
342
|
+
let field = ref.substring(dotIdx + 1);
|
|
343
|
+
if (!(sid in stepIdToIdx))
|
|
344
|
+
return match;
|
|
345
|
+
const idx = stepIdToIdx[sid];
|
|
346
|
+
// Normalize legacy nested-response path to flat response
|
|
347
|
+
if (field.startsWith('response.messages')) {
|
|
348
|
+
field = 'response';
|
|
349
|
+
}
|
|
350
|
+
return `$.outputs[${idx}].${field}`;
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
return steps.map((step) => {
|
|
354
|
+
const newStep = {};
|
|
355
|
+
for (const [key, val] of Object.entries(step)) {
|
|
356
|
+
if (typeof val === 'string') {
|
|
357
|
+
newStep[key] = replaceValue(val);
|
|
358
|
+
}
|
|
359
|
+
else if (val !== null && typeof val === 'object' && !Array.isArray(val)) {
|
|
360
|
+
const newObj = {};
|
|
361
|
+
for (const [k, v] of Object.entries(val)) {
|
|
362
|
+
newObj[k] = typeof v === 'string' ? replaceValue(v) : v;
|
|
363
|
+
}
|
|
364
|
+
newStep[key] = newObj;
|
|
365
|
+
}
|
|
366
|
+
else if (Array.isArray(val)) {
|
|
367
|
+
newStep[key] = val.map((item) => typeof item === 'string' ? replaceValue(item) : item);
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
newStep[key] = val;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return newStep;
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Inject default values:
|
|
378
|
+
* - use_agent_api=true on agent.create_session if neither use_agent_api nor planner_id present
|
|
379
|
+
*/
|
|
380
|
+
function injectDefaults(steps) {
|
|
381
|
+
return steps.map((step) => {
|
|
382
|
+
if (step.type === 'agent.create_session') {
|
|
383
|
+
if (!('use_agent_api' in step) && !('planner_id' in step)) {
|
|
384
|
+
return { ...step, use_agent_api: true };
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return step;
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Strip unrecognized fields from steps based on type-specific whitelists.
|
|
392
|
+
*/
|
|
393
|
+
function stripUnrecognizedFields(steps) {
|
|
394
|
+
return steps.map((step) => {
|
|
395
|
+
const stepType = step.type ?? '';
|
|
396
|
+
// Agent steps
|
|
397
|
+
if (stepType in VALID_AGENT_FIELDS) {
|
|
398
|
+
const validFields = VALID_AGENT_FIELDS[stepType];
|
|
399
|
+
const stripped = {};
|
|
400
|
+
for (const [key, val] of Object.entries(step)) {
|
|
401
|
+
if (validFields.has(key)) {
|
|
402
|
+
stripped[key] = val;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return stripped;
|
|
406
|
+
}
|
|
407
|
+
// Scoring evaluators
|
|
408
|
+
if (SCORING_EVALUATORS.has(stepType)) {
|
|
409
|
+
const stripped = {};
|
|
410
|
+
for (const [key, val] of Object.entries(step)) {
|
|
411
|
+
if (SCORING_VALID_FIELDS.has(key)) {
|
|
412
|
+
stripped[key] = val;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return stripped;
|
|
416
|
+
}
|
|
417
|
+
// Assertion evaluators
|
|
418
|
+
if (ASSERTION_EVALUATORS.has(stepType)) {
|
|
419
|
+
const stripped = {};
|
|
420
|
+
for (const [key, val] of Object.entries(step)) {
|
|
421
|
+
if (ASSERTION_VALID_FIELDS.has(key)) {
|
|
422
|
+
stripped[key] = val;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
return stripped;
|
|
426
|
+
}
|
|
427
|
+
// Unknown types: don't strip (to avoid breaking future evaluator types)
|
|
428
|
+
return step;
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
// --- Batch splitting ---
|
|
432
|
+
/**
|
|
433
|
+
* Split tests array into chunks of batchSize.
|
|
434
|
+
*/
|
|
435
|
+
function splitIntoBatches(tests, batchSize) {
|
|
436
|
+
const batches = [];
|
|
437
|
+
for (let i = 0; i < tests.length; i += batchSize) {
|
|
438
|
+
batches.push(tests.slice(i, i + batchSize));
|
|
439
|
+
}
|
|
440
|
+
return batches;
|
|
441
|
+
}
|
|
442
|
+
//# sourceMappingURL=evalNormalizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evalNormalizer.js","sourceRoot":"","sources":["../src/evalNormalizer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AA2JH,4CAeC;AASD,sDA0CC;AAMD,8CAuBC;AAMD,gDAeC;AA0DD,4DAiBC;AAMD,oDA2DC;AAMD,wCASC;AAKD,0DAyCC;AAOD,4CAMC;AAhdD,mCAAmC;AAEnC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,0BAA0B;IAC1B,mCAAmC;IACnC,2BAA2B;IAC3B,+BAA+B;CAChC,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,4BAA4B,EAAE,0BAA0B,CAAC,CAAC,CAAC;AAEjG,MAAM,oBAAoB,GAA2B;IACnD,0BAA0B,EAAE,wBAAwB;IACpD,mCAAmC,EAAE,yBAAyB;IAC9D,2BAA2B,EAAE,iBAAiB;IAC9C,+BAA+B,EAAE,qBAAqB;CACvD,CAA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YACvC,MAAM,QAAQ,GAA4B,EAAE,CAAC;YAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC9C,IAAI,sBAAsB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBACpC,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;gBACtB,CAAC;YACH,CAAC;YACD,OAAO,QAAoB,CAAC;QAC9B,CAAC;QAED,wEAAwE;QACxE,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED,0BAA0B;AAE1B;;GAEG;AACH,SAAgB,gBAAgB,CAAC,KAAiB,EAAE,SAAiB;IACnE,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC;QACjD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { type BaseAgentConfig, type AgentPreviewStartResponse, type AgentPreviewSendResponse, type AgentPreviewEndResponse, type EndReason, type ApiStatus, type AgentJson, type AgentCompilationSuccess, type AgentScriptContent, type AgentCreateConfig, type AgentCreateResponse, type AgentJobSpec, type AgentJobSpecCreateConfig, type AgentOptions, type AgentTone, type AgentType, type BotMetadata, type BotVersionMetadata, type PreviewableAgent, type CompilationError, type DraftAgentTopics, type DraftAgentTopicsBody, type DraftAgentTopicsResponse, type AvailableDefinition, type AgentPreviewMessageLinks, type AgentPreviewMessage, type AgentPreviewError, AgentSource, type ScriptAgentType, type ProductionAgentType, type AgentTestResultsResponse, type AgentTestStartResponse, type AgentTestStatusResponse, type TestCaseResult, type TestStatus, type AgentTestConfig, type TestCase, type TestSpec, type MetadataMetric, type MetadataExpectation, type MetadataCustomEvaluation, type AiEvaluationDefinition, type AgentforceStudioTestStartResponse, type AgentforceStudioTestStatusResponse, type AgentforceStudioTestResultsResponse, type TestScorerResult, type AgentforceStudioTestCaseResult, type AgentTraceResponse, type AgentTraceStep, type UserInputStep, type LLMExecutionStep, type UpdateTopicStep, type EventStep, type ReasoningStep, type PlannerResponseStep, COMPILATION_API_EXIT_CODES, } from './types';
|
|
2
|
-
export { metric, findAuthoringBundle, readTranscriptEntries, determineTestRunner, detectTestRunnerFromId, type TestRunnerType, createPreviewSessionCache, validatePreviewSession, removePreviewSessionCache, getCachedPreviewSessionIds, getCurrentPreviewSessionId, listCachedPreviewSessions, type SessionType, type PreviewSessionMeta, type CachedPreviewSessionInfo, type CachedPreviewSessionEntry, } from './utils';
|
|
1
|
+
export { type BaseAgentConfig, type AgentPreviewStartResponse, type AgentPreviewSendResponse, type AgentPreviewEndResponse, type EndReason, type ApiStatus, type AgentJson, type AgentCompilationSuccess, type AgentScriptContent, type AgentCreateConfig, type AgentCreateResponse, type AgentJobSpec, type AgentJobSpecCreateConfig, type AgentOptions, type AgentTone, type AgentType, type BotMetadata, type BotVersionMetadata, type PreviewableAgent, type CompilationError, type DraftAgentTopics, type DraftAgentTopicsBody, type DraftAgentTopicsResponse, type AvailableDefinition, type AgentPreviewMessageLinks, type AgentPreviewMessage, type AgentPreviewError, AgentSource, type ScriptAgentType, type ProductionAgentType, type AgentTestResultsResponse, type AgentTestStartResponse, type AgentTestStatusResponse, type TestCaseResult, type TestStatus, type AgentTestConfig, type TestCase, type TestSpec, type MetadataMetric, type MetadataExpectation, type MetadataCustomEvaluation, type AiEvaluationDefinition, type AgentforceStudioTestStartResponse, type AgentforceStudioTestStatusResponse, type AgentforceStudioTestResultsResponse, type TestScorerResult, type AgentforceStudioTestCaseResult, type AgentTraceResponse, type AgentTraceStep, type PlannerResponse, type PlanStep, type UserInputStep, type LLMExecutionStep, type UpdateTopicStep, type EventStep, type FunctionStep, type ReasoningStep, type PlannerResponseStep, COMPILATION_API_EXIT_CODES, } from './types';
|
|
2
|
+
export { metric, findAuthoringBundle, readTranscriptEntries, determineTestRunner, detectTestRunnerFromId, type TestRunnerType, createPreviewSessionCache, validatePreviewSession, removePreviewSessionCache, getCachedPreviewSessionIds, getCurrentPreviewSessionId, listCachedPreviewSessions, listSessionTraces, readSessionTrace, readTurnIndex, type TraceFileInfo, type TurnIndex, type TurnIndexEntry, type SessionType, type PreviewSessionMeta, type CachedPreviewSessionInfo, type CachedPreviewSessionEntry, } from './utils';
|
|
3
3
|
export { Agent, AgentCreateLifecycleStages, type AgentInstance } from './agent';
|
|
4
4
|
export { AgentTester } from './agentTester';
|
|
5
5
|
export { AgentforceStudioTester, normalizeAgentforceStudioResults } from './agentforceStudioTester';
|
|
@@ -11,3 +11,7 @@ export { AgentBase } from './agents/agentBase';
|
|
|
11
11
|
export { convertTestResultsToFormat, humanFriendlyName } from './agentTestResults';
|
|
12
12
|
export { writeDebugLog } from './apexUtils';
|
|
13
13
|
export { applyStringReplacements, applyStringReplacementsToAgent, type ReplacementConfig, type ReplacementResult, } from './stringReplacements';
|
|
14
|
+
export { normalizePayload, normalizeMcpShorthand, autoCorrectFields, normalizeCamelCase, normalizeEvaluatorFields, convertShorthandRefs, injectDefaults, stripUnrecognizedFields, splitIntoBatches, type EvalPayload, type EvalTest, type EvalStep, } from './evalNormalizer';
|
|
15
|
+
export { formatResults, type EvalApiResponse, type EvalOutput, type EvalResult, type TestError, type TestResult, type ResultFormat, } from './evalFormatter';
|
|
16
|
+
export { isYamlTestSpec, parseTestSpec, translateTestSpec, translateTestCase, } from './yamlSpecTranslator';
|
|
17
|
+
export { resolveAgent, executeBatches, buildResultSummary, type AgentEvalRunResult, } from './agentEvalRunner';
|
package/lib/index.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.applyStringReplacementsToAgent = exports.applyStringReplacements = exports.writeDebugLog = exports.humanFriendlyName = exports.convertTestResultsToFormat = exports.AgentBase = exports.ScriptAgent = exports.ProductionAgent = exports.AgentTestCreateLifecycleStages = exports.AgentTest = exports.createAgentTester = exports.normalizeAgentforceStudioResults = exports.AgentforceStudioTester = exports.AgentTester = exports.AgentCreateLifecycleStages = exports.Agent = exports.listCachedPreviewSessions = exports.getCurrentPreviewSessionId = exports.getCachedPreviewSessionIds = exports.removePreviewSessionCache = exports.validatePreviewSession = exports.createPreviewSessionCache = exports.detectTestRunnerFromId = exports.determineTestRunner = exports.readTranscriptEntries = exports.findAuthoringBundle = exports.metric = exports.COMPILATION_API_EXIT_CODES = exports.AgentSource = void 0;
|
|
18
|
+
exports.buildResultSummary = exports.executeBatches = exports.resolveAgent = exports.translateTestCase = exports.translateTestSpec = exports.parseTestSpec = exports.isYamlTestSpec = exports.formatResults = exports.splitIntoBatches = exports.stripUnrecognizedFields = exports.injectDefaults = exports.convertShorthandRefs = exports.normalizeEvaluatorFields = exports.normalizeCamelCase = exports.autoCorrectFields = exports.normalizeMcpShorthand = exports.normalizePayload = exports.applyStringReplacementsToAgent = exports.applyStringReplacements = exports.writeDebugLog = exports.humanFriendlyName = exports.convertTestResultsToFormat = exports.AgentBase = exports.ScriptAgent = exports.ProductionAgent = exports.AgentTestCreateLifecycleStages = exports.AgentTest = exports.createAgentTester = exports.normalizeAgentforceStudioResults = exports.AgentforceStudioTester = exports.AgentTester = exports.AgentCreateLifecycleStages = exports.Agent = exports.readTurnIndex = exports.readSessionTrace = exports.listSessionTraces = exports.listCachedPreviewSessions = exports.getCurrentPreviewSessionId = exports.getCachedPreviewSessionIds = exports.removePreviewSessionCache = exports.validatePreviewSession = exports.createPreviewSessionCache = exports.detectTestRunnerFromId = exports.determineTestRunner = exports.readTranscriptEntries = exports.findAuthoringBundle = exports.metric = exports.COMPILATION_API_EXIT_CODES = exports.AgentSource = void 0;
|
|
19
19
|
var types_1 = require("./types");
|
|
20
20
|
Object.defineProperty(exports, "AgentSource", { enumerable: true, get: function () { return types_1.AgentSource; } });
|
|
21
21
|
// Compilation API exit codes (CLI contract)
|
|
@@ -32,6 +32,9 @@ Object.defineProperty(exports, "removePreviewSessionCache", { enumerable: true,
|
|
|
32
32
|
Object.defineProperty(exports, "getCachedPreviewSessionIds", { enumerable: true, get: function () { return utils_1.getCachedPreviewSessionIds; } });
|
|
33
33
|
Object.defineProperty(exports, "getCurrentPreviewSessionId", { enumerable: true, get: function () { return utils_1.getCurrentPreviewSessionId; } });
|
|
34
34
|
Object.defineProperty(exports, "listCachedPreviewSessions", { enumerable: true, get: function () { return utils_1.listCachedPreviewSessions; } });
|
|
35
|
+
Object.defineProperty(exports, "listSessionTraces", { enumerable: true, get: function () { return utils_1.listSessionTraces; } });
|
|
36
|
+
Object.defineProperty(exports, "readSessionTrace", { enumerable: true, get: function () { return utils_1.readSessionTrace; } });
|
|
37
|
+
Object.defineProperty(exports, "readTurnIndex", { enumerable: true, get: function () { return utils_1.readTurnIndex; } });
|
|
35
38
|
var agent_1 = require("./agent");
|
|
36
39
|
Object.defineProperty(exports, "Agent", { enumerable: true, get: function () { return agent_1.Agent; } });
|
|
37
40
|
Object.defineProperty(exports, "AgentCreateLifecycleStages", { enumerable: true, get: function () { return agent_1.AgentCreateLifecycleStages; } });
|
|
@@ -59,4 +62,25 @@ Object.defineProperty(exports, "writeDebugLog", { enumerable: true, get: functio
|
|
|
59
62
|
var stringReplacements_1 = require("./stringReplacements");
|
|
60
63
|
Object.defineProperty(exports, "applyStringReplacements", { enumerable: true, get: function () { return stringReplacements_1.applyStringReplacements; } });
|
|
61
64
|
Object.defineProperty(exports, "applyStringReplacementsToAgent", { enumerable: true, get: function () { return stringReplacements_1.applyStringReplacementsToAgent; } });
|
|
65
|
+
var evalNormalizer_1 = require("./evalNormalizer");
|
|
66
|
+
Object.defineProperty(exports, "normalizePayload", { enumerable: true, get: function () { return evalNormalizer_1.normalizePayload; } });
|
|
67
|
+
Object.defineProperty(exports, "normalizeMcpShorthand", { enumerable: true, get: function () { return evalNormalizer_1.normalizeMcpShorthand; } });
|
|
68
|
+
Object.defineProperty(exports, "autoCorrectFields", { enumerable: true, get: function () { return evalNormalizer_1.autoCorrectFields; } });
|
|
69
|
+
Object.defineProperty(exports, "normalizeCamelCase", { enumerable: true, get: function () { return evalNormalizer_1.normalizeCamelCase; } });
|
|
70
|
+
Object.defineProperty(exports, "normalizeEvaluatorFields", { enumerable: true, get: function () { return evalNormalizer_1.normalizeEvaluatorFields; } });
|
|
71
|
+
Object.defineProperty(exports, "convertShorthandRefs", { enumerable: true, get: function () { return evalNormalizer_1.convertShorthandRefs; } });
|
|
72
|
+
Object.defineProperty(exports, "injectDefaults", { enumerable: true, get: function () { return evalNormalizer_1.injectDefaults; } });
|
|
73
|
+
Object.defineProperty(exports, "stripUnrecognizedFields", { enumerable: true, get: function () { return evalNormalizer_1.stripUnrecognizedFields; } });
|
|
74
|
+
Object.defineProperty(exports, "splitIntoBatches", { enumerable: true, get: function () { return evalNormalizer_1.splitIntoBatches; } });
|
|
75
|
+
var evalFormatter_1 = require("./evalFormatter");
|
|
76
|
+
Object.defineProperty(exports, "formatResults", { enumerable: true, get: function () { return evalFormatter_1.formatResults; } });
|
|
77
|
+
var yamlSpecTranslator_1 = require("./yamlSpecTranslator");
|
|
78
|
+
Object.defineProperty(exports, "isYamlTestSpec", { enumerable: true, get: function () { return yamlSpecTranslator_1.isYamlTestSpec; } });
|
|
79
|
+
Object.defineProperty(exports, "parseTestSpec", { enumerable: true, get: function () { return yamlSpecTranslator_1.parseTestSpec; } });
|
|
80
|
+
Object.defineProperty(exports, "translateTestSpec", { enumerable: true, get: function () { return yamlSpecTranslator_1.translateTestSpec; } });
|
|
81
|
+
Object.defineProperty(exports, "translateTestCase", { enumerable: true, get: function () { return yamlSpecTranslator_1.translateTestCase; } });
|
|
82
|
+
var agentEvalRunner_1 = require("./agentEvalRunner");
|
|
83
|
+
Object.defineProperty(exports, "resolveAgent", { enumerable: true, get: function () { return agentEvalRunner_1.resolveAgent; } });
|
|
84
|
+
Object.defineProperty(exports, "executeBatches", { enumerable: true, get: function () { return agentEvalRunner_1.executeBatches; } });
|
|
85
|
+
Object.defineProperty(exports, "buildResultSummary", { enumerable: true, get: function () { return agentEvalRunner_1.buildResultSummary; } });
|
|
62
86
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iCAyEiB;AAxCf,oGAAA,WAAW,OAAA;AAsCX,4CAA4C;AAC5C,mHAAA,0BAA0B,OAAA;AAG5B,iCAuBiB;AAtBf,+FAAA,MAAM,OAAA;AACN,4GAAA,mBAAmB,OAAA;AACnB,8GAAA,qBAAqB,OAAA;AACrB,4GAAA,mBAAmB,OAAA;AACnB,+GAAA,sBAAsB,OAAA;AAEtB,kHAAA,yBAAyB,OAAA;AACzB,+GAAA,sBAAsB,OAAA;AACtB,kHAAA,yBAAyB,OAAA;AACzB,mHAAA,0BAA0B,OAAA;AAC1B,mHAAA,0BAA0B,OAAA;AAC1B,kHAAA,yBAAyB,OAAA;AACzB,0GAAA,iBAAiB,OAAA;AACjB,yGAAA,gBAAgB,OAAA;AAChB,sGAAA,aAAa,OAAA;AASf,iCAAgF;AAAvE,8FAAA,KAAK,OAAA;AAAE,mHAAA,0BAA0B,OAAA;AAC1C,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,mEAAoG;AAA3F,gIAAA,sBAAsB,OAAA;AAAE,0IAAA,gCAAgC,OAAA;AACjE,2DAAsH;AAA7G,uHAAA,iBAAiB,OAAA;AAC1B,yCAAwE;AAA/D,sGAAA,SAAS,OAAA;AAAE,2HAAA,8BAA8B,OAAA;AAClD,4DAA2D;AAAlD,kHAAA,eAAe,OAAA;AACxB,oDAAmD;AAA1C,0GAAA,WAAW,OAAA;AACpB,gDAA+C;AAAtC,sGAAA,SAAS,OAAA;AAClB,uDAAmF;AAA1E,8HAAA,0BAA0B,OAAA;AAAE,qHAAA,iBAAiB,OAAA;AACtD,yCAA4C;AAAnC,0GAAA,aAAa,OAAA;AACtB,2DAK8B;AAJ5B,6HAAA,uBAAuB,OAAA;AACvB,oIAAA,8BAA8B,OAAA;AAIhC,mDAa0B;AAZxB,kHAAA,gBAAgB,OAAA;AAChB,uHAAA,qBAAqB,OAAA;AACrB,mHAAA,iBAAiB,OAAA;AACjB,oHAAA,kBAAkB,OAAA;AAClB,0HAAA,wBAAwB,OAAA;AACxB,sHAAA,oBAAoB,OAAA;AACpB,gHAAA,cAAc,OAAA;AACd,yHAAA,uBAAuB,OAAA;AACvB,kHAAA,gBAAgB,OAAA;AAKlB,iDAQyB;AAPvB,8GAAA,aAAa,OAAA;AAQf,2DAK8B;AAJ5B,oHAAA,cAAc,OAAA;AACd,mHAAA,aAAa,OAAA;AACb,uHAAA,iBAAiB,OAAA;AACjB,uHAAA,iBAAiB,OAAA;AAEnB,qDAK2B;AAJzB,+GAAA,YAAY,OAAA;AACZ,iHAAA,cAAc,OAAA;AACd,qHAAA,kBAAkB,OAAA"}
|
package/lib/utils.d.ts
CHANGED
|
@@ -115,6 +115,27 @@ export declare const appendTranscriptToHistory: (entry: TranscriptEntry, session
|
|
|
115
115
|
* @returns {Promise<void>}
|
|
116
116
|
*/
|
|
117
117
|
export declare const writeTraceToHistory: (planId: string, trace: PlannerResponse | undefined, historyDir: string) => Promise<void>;
|
|
118
|
+
export type TraceFileInfo = {
|
|
119
|
+
planId: string;
|
|
120
|
+
path: string;
|
|
121
|
+
size: number;
|
|
122
|
+
mtime: Date;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* List trace files for a given agent session.
|
|
126
|
+
*
|
|
127
|
+
* Returns one entry per .json file in the session's traces/ directory.
|
|
128
|
+
* File path is absolute. Returns an empty array if the traces directory does not exist.
|
|
129
|
+
*/
|
|
130
|
+
export declare const listSessionTraces: (agentId: string, sessionId: string) => Promise<TraceFileInfo[]>;
|
|
131
|
+
/**
|
|
132
|
+
* Read a single trace file by planId. Returns null if the file does not exist or cannot be parsed.
|
|
133
|
+
*/
|
|
134
|
+
export declare const readSessionTrace: (agentId: string, sessionId: string, planId: string) => Promise<PlannerResponse | null>;
|
|
135
|
+
/**
|
|
136
|
+
* Read the turn-index.json for a session. Returns null if not found.
|
|
137
|
+
*/
|
|
138
|
+
export declare const readTurnIndex: (agentId: string, sessionId: string) => Promise<TurnIndex | null>;
|
|
118
139
|
/**
|
|
119
140
|
* Write or append a session line to .sfdx/agents/<agentId>/index.md.
|
|
120
141
|
* If the file does not exist, creates it with a header and the session line.
|
package/lib/utils.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.readTranscriptEntries = exports.getAllHistory = exports.recordTraceForTurn = exports.logTurnToHistory = exports.SessionHistoryBuffer = exports.logSessionToIndex = exports.writeTraceToHistory = exports.appendTranscriptToHistory = exports.getAgentIndexDir = exports.getHistoryDir = exports.useNamedUserJwt = exports.findLocalAgents = exports.findAuthoringBundle = exports.decodeHtmlEntities = exports.sanitizeFilename = exports.metric = void 0;
|
|
36
|
+
exports.readTranscriptEntries = exports.getAllHistory = exports.recordTraceForTurn = exports.logTurnToHistory = exports.SessionHistoryBuffer = exports.logSessionToIndex = exports.readTurnIndex = exports.readSessionTrace = exports.listSessionTraces = exports.writeTraceToHistory = exports.appendTranscriptToHistory = exports.getAgentIndexDir = exports.getHistoryDir = exports.useNamedUserJwt = exports.findLocalAgents = exports.findAuthoringBundle = exports.decodeHtmlEntities = exports.sanitizeFilename = exports.metric = void 0;
|
|
37
37
|
exports.getHttpStatusCode = getHttpStatusCode;
|
|
38
38
|
exports.requestWithEndpointFallback = requestWithEndpointFallback;
|
|
39
39
|
exports.detectTestRunnerFromId = detectTestRunnerFromId;
|
|
@@ -381,6 +381,60 @@ const writeTraceToHistory = async (planId, trace, historyDir) => {
|
|
|
381
381
|
await (0, promises_1.writeFile)(tracePath, JSON.stringify(trace ?? {}, null, 2), 'utf-8');
|
|
382
382
|
};
|
|
383
383
|
exports.writeTraceToHistory = writeTraceToHistory;
|
|
384
|
+
/**
|
|
385
|
+
* List trace files for a given agent session.
|
|
386
|
+
*
|
|
387
|
+
* Returns one entry per .json file in the session's traces/ directory.
|
|
388
|
+
* File path is absolute. Returns an empty array if the traces directory does not exist.
|
|
389
|
+
*/
|
|
390
|
+
const listSessionTraces = async (agentId, sessionId) => {
|
|
391
|
+
const historyDir = await (0, exports.getHistoryDir)(agentId, sessionId);
|
|
392
|
+
const tracesDir = path.join(historyDir, 'traces');
|
|
393
|
+
try {
|
|
394
|
+
const files = await (0, promises_1.readdir)(tracesDir);
|
|
395
|
+
return await Promise.all(files
|
|
396
|
+
.filter((f) => f.endsWith('.json'))
|
|
397
|
+
.map(async (f) => {
|
|
398
|
+
const filePath = path.join(tracesDir, f);
|
|
399
|
+
const s = await (0, promises_1.stat)(filePath);
|
|
400
|
+
return { planId: path.basename(f, '.json'), path: filePath, size: s.size, mtime: s.mtime };
|
|
401
|
+
}));
|
|
402
|
+
}
|
|
403
|
+
catch {
|
|
404
|
+
return [];
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
exports.listSessionTraces = listSessionTraces;
|
|
408
|
+
/**
|
|
409
|
+
* Read a single trace file by planId. Returns null if the file does not exist or cannot be parsed.
|
|
410
|
+
*/
|
|
411
|
+
const readSessionTrace = async (agentId, sessionId, planId) => {
|
|
412
|
+
const historyDir = await (0, exports.getHistoryDir)(agentId, sessionId);
|
|
413
|
+
const tracePath = path.join(historyDir, 'traces', `${planId}.json`);
|
|
414
|
+
try {
|
|
415
|
+
const raw = await (0, promises_1.readFile)(tracePath, 'utf-8');
|
|
416
|
+
return JSON.parse(raw);
|
|
417
|
+
}
|
|
418
|
+
catch {
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
exports.readSessionTrace = readSessionTrace;
|
|
423
|
+
/**
|
|
424
|
+
* Read the turn-index.json for a session. Returns null if not found.
|
|
425
|
+
*/
|
|
426
|
+
const readTurnIndex = async (agentId, sessionId) => {
|
|
427
|
+
const historyDir = await (0, exports.getHistoryDir)(agentId, sessionId);
|
|
428
|
+
const turnIndexPath = path.join(historyDir, 'turn-index.json');
|
|
429
|
+
try {
|
|
430
|
+
const raw = await (0, promises_1.readFile)(turnIndexPath, 'utf-8');
|
|
431
|
+
return JSON.parse(raw);
|
|
432
|
+
}
|
|
433
|
+
catch {
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
exports.readTurnIndex = readTurnIndex;
|
|
384
438
|
/**
|
|
385
439
|
* Write or append a session line to .sfdx/agents/<agentId>/index.md.
|
|
386
440
|
* If the file does not exist, creates it with a header and the session line.
|