@agentv/core 4.15.1 → 4.15.2-next.1

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/dist/index.cjs CHANGED
@@ -1878,6 +1878,7 @@ __export(index_exports, {
1878
1878
  getWorkspacePath: () => getWorkspacePath,
1879
1879
  getWorkspacePoolRoot: () => getWorkspacePoolRoot,
1880
1880
  getWorkspacesRoot: () => getWorkspacesRoot,
1881
+ groupTranscriptJsonLines: () => groupTranscriptJsonLines,
1881
1882
  initializeBaseline: () => initializeBaseline,
1882
1883
  isAgentSkillsFormat: () => isAgentSkillsFormat,
1883
1884
  isContent: () => isContent,
@@ -1953,7 +1954,7 @@ __export(index_exports, {
1953
1954
  syncResultsRepo: () => syncResultsRepo,
1954
1955
  toCamelCaseDeep: () => toCamelCaseDeep,
1955
1956
  toSnakeCaseDeep: () => toSnakeCaseDeep,
1956
- toTranscriptJsonLine: () => toTranscriptJsonLine,
1957
+ toTranscriptJsonLines: () => toTranscriptJsonLines,
1957
1958
  tokensPerTool: () => tokensPerTool,
1958
1959
  touchBenchmark: () => touchBenchmark,
1959
1960
  transpileEvalYaml: () => transpileEvalYaml,
@@ -6077,7 +6078,21 @@ async function resolveWorkspaceConfig(raw, evalFileDir) {
6077
6078
  );
6078
6079
  }
6079
6080
  const workspaceFileDir = import_node_path9.default.dirname(workspaceFilePath);
6080
- return parseWorkspaceConfig(parsed, workspaceFileDir);
6081
+ const resolvedWorkspace = parseWorkspaceConfig(parsed, workspaceFileDir);
6082
+ if (resolvedWorkspace) {
6083
+ return resolvedWorkspace;
6084
+ }
6085
+ const parsedObject = parsed;
6086
+ if ("workspace" in parsedObject && isJsonObject(parsedObject.workspace)) {
6087
+ throw new Error(
6088
+ [
6089
+ `Invalid workspace file format: ${workspaceFilePath}`,
6090
+ "External workspace files must contain the workspace config object directly.",
6091
+ 'Remove the top-level "workspace:" wrapper.'
6092
+ ].join(" ")
6093
+ );
6094
+ }
6095
+ return void 0;
6081
6096
  }
6082
6097
  return parseWorkspaceConfig(raw, evalFileDir);
6083
6098
  }
@@ -25245,30 +25260,91 @@ init_cjs_shims();
25245
25260
  // src/import/types.ts
25246
25261
  init_cjs_shims();
25247
25262
  var import_promises43 = require("fs/promises");
25248
- function toTranscriptJsonLine(entry) {
25249
- const firstUserMessage = entry.messages.find((m) => m.role === "user");
25250
- const input = typeof firstUserMessage?.content === "string" ? firstUserMessage.content : "";
25263
+ function toTranscriptJsonLines(entry, options) {
25264
+ const source = {
25265
+ provider: entry.source.provider,
25266
+ session_id: entry.source.sessionId,
25267
+ model: entry.source.model,
25268
+ timestamp: entry.source.startedAt,
25269
+ git_branch: entry.source.gitBranch,
25270
+ cwd: entry.source.cwd ?? entry.source.projectPath,
25271
+ version: entry.source.version
25272
+ };
25273
+ const transcriptTokenUsage = entry.tokenUsage ? {
25274
+ input: entry.tokenUsage.input,
25275
+ output: entry.tokenUsage.output,
25276
+ cached: entry.tokenUsage.cached,
25277
+ reasoning: entry.tokenUsage.reasoning
25278
+ } : void 0;
25279
+ const testId = options?.testId ?? entry.source.sessionId;
25280
+ const target = options?.target ?? entry.source.provider;
25281
+ return entry.messages.map((message, index) => ({
25282
+ test_id: testId,
25283
+ target,
25284
+ message_index: index,
25285
+ ...toSnakeCaseDeep(message),
25286
+ transcript_token_usage: transcriptTokenUsage,
25287
+ transcript_duration_ms: entry.durationMs,
25288
+ transcript_cost_usd: entry.costUsd,
25289
+ source
25290
+ }));
25291
+ }
25292
+ function buildReplayMessage(line) {
25293
+ const camelCased = toCamelCaseDeep(line);
25251
25294
  return {
25252
- input,
25253
- output: entry.messages,
25254
- token_usage: entry.tokenUsage ? {
25255
- input: entry.tokenUsage.input,
25256
- output: entry.tokenUsage.output,
25257
- cached: entry.tokenUsage.cached
25258
- } : void 0,
25259
- duration_ms: entry.durationMs,
25260
- cost_usd: entry.costUsd,
25261
- source: {
25262
- provider: entry.source.provider,
25263
- session_id: entry.source.sessionId,
25264
- model: entry.source.model,
25265
- timestamp: entry.source.startedAt,
25266
- git_branch: entry.source.gitBranch,
25267
- cwd: entry.source.cwd ?? entry.source.projectPath,
25268
- version: entry.source.version
25269
- }
25295
+ role: camelCased.role,
25296
+ name: camelCased.name,
25297
+ content: camelCased.content,
25298
+ toolCalls: camelCased.toolCalls,
25299
+ startTime: camelCased.startTime,
25300
+ endTime: camelCased.endTime,
25301
+ durationMs: camelCased.durationMs,
25302
+ metadata: camelCased.metadata,
25303
+ tokenUsage: camelCased.tokenUsage
25270
25304
  };
25271
25305
  }
25306
+ function groupTranscriptJsonLines(lines) {
25307
+ const grouped = /* @__PURE__ */ new Map();
25308
+ for (const line of lines) {
25309
+ const existing = grouped.get(line.test_id);
25310
+ const source = {
25311
+ provider: line.source.provider,
25312
+ sessionId: line.source.session_id,
25313
+ startedAt: line.source.timestamp,
25314
+ model: line.source.model,
25315
+ gitBranch: line.source.git_branch,
25316
+ cwd: line.source.cwd,
25317
+ version: line.source.version
25318
+ };
25319
+ const transcriptTokenUsage = line.transcript_token_usage ? {
25320
+ input: line.transcript_token_usage.input,
25321
+ output: line.transcript_token_usage.output,
25322
+ cached: line.transcript_token_usage.cached,
25323
+ reasoning: line.transcript_token_usage.reasoning
25324
+ } : void 0;
25325
+ if (existing) {
25326
+ existing.messages.push({ index: line.message_index, message: buildReplayMessage(line) });
25327
+ continue;
25328
+ }
25329
+ grouped.set(line.test_id, {
25330
+ target: line.target,
25331
+ tokenUsage: transcriptTokenUsage,
25332
+ durationMs: line.transcript_duration_ms,
25333
+ costUsd: line.transcript_cost_usd,
25334
+ source,
25335
+ messages: [{ index: line.message_index, message: buildReplayMessage(line) }]
25336
+ });
25337
+ }
25338
+ return [...grouped.entries()].map(([testId, entry]) => ({
25339
+ testId,
25340
+ target: entry.target,
25341
+ tokenUsage: entry.tokenUsage,
25342
+ durationMs: entry.durationMs,
25343
+ costUsd: entry.costUsd,
25344
+ source: entry.source,
25345
+ messages: entry.messages.sort((first, second) => first.index - second.index).map((item) => item.message)
25346
+ }));
25347
+ }
25272
25348
  async function readTranscriptJsonl(filePath) {
25273
25349
  const text = await (0, import_promises43.readFile)(filePath, "utf8");
25274
25350
  return text.split("\n").filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
@@ -25282,12 +25358,12 @@ var TranscriptProvider = class _TranscriptProvider {
25282
25358
  id;
25283
25359
  kind = "transcript";
25284
25360
  targetName;
25285
- lines;
25361
+ entries;
25286
25362
  cursor = 0;
25287
- constructor(targetName, lines) {
25363
+ constructor(targetName, entries) {
25288
25364
  this.targetName = targetName;
25289
25365
  this.id = `transcript:${targetName}`;
25290
- this.lines = lines;
25366
+ this.entries = entries;
25291
25367
  }
25292
25368
  /**
25293
25369
  * Create a TranscriptProvider from a JSONL file path.
@@ -25297,29 +25373,31 @@ var TranscriptProvider = class _TranscriptProvider {
25297
25373
  if (lines.length === 0) {
25298
25374
  throw new Error(`Transcript file is empty: ${filePath}`);
25299
25375
  }
25300
- const providerName = lines[0].source.provider ?? "transcript";
25301
- return new _TranscriptProvider(providerName, lines);
25376
+ const entries = groupTranscriptJsonLines(lines);
25377
+ const providerName = entries[0]?.source.provider ?? "transcript";
25378
+ return new _TranscriptProvider(providerName, entries);
25302
25379
  }
25303
25380
  get lineCount() {
25304
- return this.lines.length;
25381
+ return this.entries.length;
25305
25382
  }
25306
25383
  async invoke(_request) {
25307
- if (this.cursor >= this.lines.length) {
25384
+ if (this.cursor >= this.entries.length) {
25308
25385
  throw new Error(
25309
- `Transcript exhausted: ${this.lines.length} line(s) available but ${this.cursor + 1} invocations attempted. Each transcript line maps to one test case.`
25386
+ `Transcript exhausted: ${this.entries.length} entr${this.entries.length === 1 ? "y" : "ies"} available but ${this.cursor + 1} invocations attempted. Each transcript entry maps to one test case.`
25310
25387
  );
25311
25388
  }
25312
- const line = this.lines[this.cursor++];
25389
+ const entry = this.entries[this.cursor++];
25313
25390
  return {
25314
- output: line.output,
25315
- tokenUsage: line.token_usage ? {
25316
- input: line.token_usage.input,
25317
- output: line.token_usage.output,
25318
- cached: line.token_usage.cached
25391
+ output: entry.messages,
25392
+ tokenUsage: entry.tokenUsage ? {
25393
+ input: entry.tokenUsage.input,
25394
+ output: entry.tokenUsage.output,
25395
+ cached: entry.tokenUsage.cached,
25396
+ reasoning: entry.tokenUsage.reasoning
25319
25397
  } : void 0,
25320
- durationMs: line.duration_ms,
25321
- costUsd: line.cost_usd ?? void 0,
25322
- startTime: line.source.timestamp
25398
+ durationMs: entry.durationMs,
25399
+ costUsd: entry.costUsd ?? void 0,
25400
+ startTime: entry.source.startedAt
25323
25401
  };
25324
25402
  }
25325
25403
  };
@@ -25441,6 +25519,7 @@ function createAgentKernel() {
25441
25519
  getWorkspacePath,
25442
25520
  getWorkspacePoolRoot,
25443
25521
  getWorkspacesRoot,
25522
+ groupTranscriptJsonLines,
25444
25523
  initializeBaseline,
25445
25524
  isAgentSkillsFormat,
25446
25525
  isContent,
@@ -25516,7 +25595,7 @@ function createAgentKernel() {
25516
25595
  syncResultsRepo,
25517
25596
  toCamelCaseDeep,
25518
25597
  toSnakeCaseDeep,
25519
- toTranscriptJsonLine,
25598
+ toTranscriptJsonLines,
25520
25599
  tokensPerTool,
25521
25600
  touchBenchmark,
25522
25601
  transpileEvalYaml,