@wix/pathgrade 1.0.31 → 1.0.33

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.
Files changed (114) hide show
  1. package/dist/adapters/jest/invocation-adapter.d.ts +2 -2
  2. package/dist/adapters/jest/invocation-adapter.js +1 -1
  3. package/dist/adapters/jest/lifecycle.d.ts +3 -3
  4. package/dist/adapters/jest/lifecycle.js +1 -1
  5. package/dist/adapters/jest/metadata.d.ts +0 -1
  6. package/dist/adapters/jest/metadata.js +1 -1
  7. package/dist/adapters/jest/results.d.ts +3 -2
  8. package/dist/affected/format.d.ts +0 -23
  9. package/dist/affected/format.js +1 -1
  10. package/dist/affected/sidecar.d.ts +0 -1
  11. package/dist/affected/sidecar.js +1 -1
  12. package/dist/affected/types.d.ts +2 -17
  13. package/dist/agents/claude/ask-user-answer-store.d.ts +2 -1
  14. package/dist/agents/claude/tool-results.d.ts +1 -1
  15. package/dist/agents/claude/tool-results.js +1 -1
  16. package/dist/agents/claude.d.ts +2 -1
  17. package/dist/agents/codex-app-server/agent.js +24 -8
  18. package/dist/agents/codex-app-server/protocol/ClientRequest.d.ts +3 -2
  19. package/dist/agents/codex-app-server/protocol/DynamicToolCallParams.d.ts +2 -1
  20. package/dist/agents/codex-app-server/protocol/GetAccountTokenUsageParams.d.ts +3 -0
  21. package/dist/agents/codex-app-server/protocol/GetAccountTokenUsageParams.js +4 -0
  22. package/dist/agents/codex-app-server/protocol/GetAccountTokenUsageResponse.d.ts +6 -0
  23. package/dist/agents/codex-app-server/protocol/GetAccountTokenUsageResponse.js +4 -0
  24. package/dist/agents/codex-app-server/protocol/GrantedPermissionProfile.d.ts +3 -2
  25. package/dist/agents/codex-app-server/protocol/McpElicitationRequestParams.d.ts +3 -2
  26. package/dist/agents/codex-app-server/protocol/PermissionsRequestApprovalParams.d.ts +3 -2
  27. package/dist/agents/codex-app-server/protocol/ThreadStartParams.d.ts +7 -6
  28. package/dist/agents/codex-app-server/protocol/ThreadTokenUsage.d.ts +6 -0
  29. package/dist/agents/codex-app-server/protocol/ThreadTokenUsage.js +4 -0
  30. package/dist/agents/codex-app-server/protocol/ThreadTokenUsageUpdatedNotification.d.ts +6 -0
  31. package/dist/agents/codex-app-server/protocol/ThreadTokenUsageUpdatedNotification.js +4 -0
  32. package/dist/agents/codex-app-server/protocol/ThreadUsage.d.ts +7 -0
  33. package/dist/agents/codex-app-server/protocol/ThreadUsage.js +4 -0
  34. package/dist/agents/codex-app-server/protocol/ThreadUsageBreakdownGroup.d.ts +11 -0
  35. package/dist/agents/codex-app-server/protocol/ThreadUsageBreakdownGroup.js +4 -0
  36. package/dist/agents/codex-app-server/protocol/TokenUsageBreakdown.d.ts +8 -0
  37. package/dist/agents/codex-app-server/protocol/TokenUsageBreakdown.js +4 -0
  38. package/dist/agents/codex-app-server/protocol/TurnCompletedNotification.d.ts +2 -1
  39. package/dist/agents/codex-app-server/protocol/index.d.ts +7 -0
  40. package/dist/agents/codex-app-server/transport.d.ts +2 -2
  41. package/dist/agents/codex-app-server/turn-notifications.js +4 -0
  42. package/dist/agents/codex-app-server/turn-state.d.ts +3 -0
  43. package/dist/agents/codex-app-server/usage-accounting.d.ts +18 -0
  44. package/dist/agents/codex-app-server/usage-accounting.js +121 -0
  45. package/dist/commands/analyze.d.ts +0 -13
  46. package/dist/commands/report.d.ts +0 -7
  47. package/dist/commands/report.js +1 -1
  48. package/dist/core/generated-mcp-protocol.d.ts +0 -2
  49. package/dist/core/generated-mcp-protocol.js +2 -2
  50. package/dist/evals/discovery.d.ts +0 -1
  51. package/dist/evals/discovery.js +1 -1
  52. package/dist/internal/direct-mcp-v2/acp-client.d.ts +0 -8
  53. package/dist/internal/direct-mcp-v2/acp-direct-mcp.d.ts +2 -1
  54. package/dist/internal/direct-mcp-v2/claude-direct-mcp.d.ts +1 -1
  55. package/dist/internal/direct-mcp-v2/claude-profile.d.ts +0 -10
  56. package/dist/internal/direct-mcp-v2/claude-profile.js +3 -3
  57. package/dist/internal/direct-mcp-v2/codex-direct-mcp.d.ts +2 -1
  58. package/dist/internal/direct-mcp-v2/compiler.d.ts +0 -1
  59. package/dist/internal/direct-mcp-v2/compiler.js +1 -1
  60. package/dist/internal/direct-mcp-v2/json.d.ts +0 -2
  61. package/dist/internal/direct-mcp-v2/json.js +2 -2
  62. package/dist/internal/direct-mcp-v2/runtime-lock.d.ts +2 -1
  63. package/dist/internal/direct-mcp-v2/runtime-profile.d.ts +0 -1
  64. package/dist/internal/direct-mcp-v2/runtime-profile.js +1 -1
  65. package/dist/internal/direct-mcp-v2/types.d.ts +5 -4
  66. package/dist/openai-oauth/chatgpt-oauth-llm.js +12 -1
  67. package/dist/providers/mcp-config.d.ts +0 -2
  68. package/dist/providers/mcp-config.js +2 -2
  69. package/dist/providers/mcp-runtime-mounting.d.ts +1 -9
  70. package/dist/providers/sandbox-lifecycle.d.ts +0 -2
  71. package/dist/providers/sandbox-lifecycle.js +2 -2
  72. package/dist/providers/scripted-mcp-mock-host.d.ts +1 -1
  73. package/dist/providers/workspace.d.ts +0 -1
  74. package/dist/reporters/github-comment.d.ts +0 -11
  75. package/dist/reporters/github-comment.js +1 -1
  76. package/dist/reporters/verbose-emitter.d.ts +7 -19
  77. package/dist/reporters/verbose-emitter.js +5 -5
  78. package/dist/reporting/types.d.ts +2 -1
  79. package/dist/runners/adapter-loader.d.ts +0 -3
  80. package/dist/runners/model-validation.d.ts +2 -1
  81. package/dist/runners/repeated-attempts.d.ts +0 -5
  82. package/dist/runners/repeated-attempts.js +1 -1
  83. package/dist/runners/vitest-invocation.d.ts +2 -2
  84. package/dist/runners/vitest-invocation.js +1 -1
  85. package/dist/runners/vitest-lifecycle.d.ts +0 -2
  86. package/dist/runners/vitest-lifecycle.js +1 -1
  87. package/dist/sdk/agent.js +1 -3
  88. package/dist/sdk/ask-bus/handler.d.ts +3 -2
  89. package/dist/sdk/diagnostics.d.ts +4 -3
  90. package/dist/sdk/evaluate.js +3 -2
  91. package/dist/sdk/judge-tool-runner.d.ts +1 -2
  92. package/dist/sdk/lifecycle.js +4 -0
  93. package/dist/sdk/mcp-mock-approvals.d.ts +3 -2
  94. package/dist/sdk/reaction-loader.d.ts +1 -2
  95. package/dist/sdk/reaction-preview.d.ts +1 -4
  96. package/dist/sdk/reaction-preview.js +3 -3
  97. package/dist/sdk/run-scorer.d.ts +1 -4
  98. package/dist/sdk/run-scorer.js +3 -3
  99. package/dist/sdk/runtime-policy.d.ts +0 -1
  100. package/dist/sdk/runtime-policy.js +1 -1
  101. package/dist/tool-events.d.ts +0 -1
  102. package/dist/tool-events.js +1 -1
  103. package/dist/types.d.ts +10 -32
  104. package/dist/types.js +1 -1
  105. package/dist/utils/cli.d.ts +0 -15
  106. package/dist/utils/cli.js +4 -4
  107. package/dist/utils/llm-mocks.d.ts +3 -2
  108. package/dist/utils/llm-mocks.js +5 -0
  109. package/dist/utils/llm-providers/cli.d.ts +0 -1
  110. package/dist/utils/llm-providers/cli.js +1 -1
  111. package/dist/utils/llm-types.d.ts +7 -4
  112. package/dist/utils/llm.d.ts +2 -2
  113. package/dist/utils/llm.js +6 -1
  114. package/package.json +2 -2
@@ -10,18 +10,18 @@
10
10
  */
11
11
  import { fmt } from '../utils/cli.js';
12
12
  /** Maximum characters retained in a prompt/reply preview before truncation. */
13
- export const PREVIEW_MAX_CHARS = 80;
13
+ const PREVIEW_MAX_CHARS = 80;
14
14
  /** Maximum characters retained in a retry error message before truncation. */
15
- export const RETRY_ERROR_MAX_CHARS = 120;
15
+ const RETRY_ERROR_MAX_CHARS = 120;
16
16
  /** Ellipsis appended to truncated strings. */
17
- export const TRUNCATION_SUFFIX = '…';
17
+ const TRUNCATION_SUFFIX = '…';
18
18
  /** Newline replacement in single-line previews. */
19
- export const NEWLINE_REPLACEMENT = '⏎';
19
+ const NEWLINE_REPLACEMENT = '⏎';
20
20
  /**
21
21
  * Build a preview string: strip newlines, truncate to a max length.
22
22
  * `null` / `undefined` becomes an empty string so formatting never throws.
23
23
  */
24
- export function preview(text, max = PREVIEW_MAX_CHARS) {
24
+ function preview(text, max = PREVIEW_MAX_CHARS) {
25
25
  const normalized = (text ?? '').replace(/\r?\n/g, NEWLINE_REPLACEMENT);
26
26
  if (normalized.length <= max)
27
27
  return normalized;
@@ -75,9 +75,10 @@ export interface ReportSummaryGroup {
75
75
  trial_count: number;
76
76
  diagnostics: ReportSummaryDiagnostics[];
77
77
  }
78
- export interface ReportSummaryDiagnostics {
78
+ interface ReportSummaryDiagnostics {
79
79
  caseName: string;
80
80
  state: ReportCaseState;
81
81
  resultKind?: EvaluationResultKind;
82
82
  report: DiagnosticsReport;
83
83
  }
84
+ export {};
@@ -2,9 +2,6 @@ import type { ResolvedPathgradeConfig } from '../config/pathgrade.js';
2
2
  import { type SpawnVitest } from './vitest-invocation.js';
3
3
  import type { RunnerAdapter } from './adapter.js';
4
4
  import type { RunnerInvocationAdapter } from './invocation.js';
5
- export interface ExternalAdapterFactoryInput {
6
- config: ResolvedPathgradeConfig;
7
- }
8
5
  export declare function loadRunnerAdapter(input: {
9
6
  adapterName?: string;
10
7
  cwd?: string;
@@ -3,10 +3,11 @@ export interface NormalizedRunValidationResult {
3
3
  ok: boolean;
4
4
  errors: NormalizedRunValidationError[];
5
5
  }
6
- export interface NormalizedRunValidationError {
6
+ interface NormalizedRunValidationError {
7
7
  path: string;
8
8
  message: string;
9
9
  }
10
10
  export declare function validateNormalizedRunSnapshot(snapshot: NormalizedRunSnapshot, options: {
11
11
  completeness: SnapshotCompleteness;
12
12
  }): NormalizedRunValidationResult;
13
+ export {};
@@ -1,7 +1,2 @@
1
1
  import type { NormalizedRunSnapshot } from './model.js';
2
- export type RepeatAggregationFailure = 'incomplete_attempts' | 'case_identity_mismatch';
3
- export declare class RepeatAggregationError extends Error {
4
- readonly reason: RepeatAggregationFailure;
5
- constructor(reason: RepeatAggregationFailure, message: string);
6
- }
7
2
  export declare function mergeRepeatedRunSnapshots(snapshots: readonly NormalizedRunSnapshot[]): NormalizedRunSnapshot;
@@ -1,6 +1,6 @@
1
1
  import { createHash, randomUUID } from 'node:crypto';
2
2
  import { validateNormalizedRunSnapshot } from './model-validation.js';
3
- export class RepeatAggregationError extends Error {
3
+ class RepeatAggregationError extends Error {
4
4
  reason;
5
5
  constructor(reason, message) {
6
6
  super(message);
@@ -1,5 +1,5 @@
1
1
  import type { RunnerInvocationAdapter } from './invocation.js';
2
- export interface SpawnVitestRequest {
2
+ interface SpawnVitestRequest {
3
3
  argv: string[];
4
4
  env: NodeJS.ProcessEnv;
5
5
  cwd: string;
@@ -8,4 +8,4 @@ export type SpawnVitest = (req: SpawnVitestRequest) => Promise<number> | number;
8
8
  export declare function createVitestInvocationAdapter(input?: {
9
9
  spawnVitest?: SpawnVitest;
10
10
  }): RunnerInvocationAdapter;
11
- export declare function resolveVitestCli(cwd: string): string;
11
+ export {};
@@ -47,7 +47,7 @@ async function defaultSpawnVitest(req) {
47
47
  child.on('close', code => resolve(code ?? 0));
48
48
  });
49
49
  }
50
- export function resolveVitestCli(cwd) {
50
+ function resolveVitestCli(cwd) {
51
51
  const requireFromCwd = createRequire(path.join(cwd, 'package.json'));
52
52
  const packageJsonPath = requireFromCwd.resolve('vitest/package.json');
53
53
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
@@ -1,7 +1,6 @@
1
1
  import type { Agent, PathgradeTestMeta } from '../sdk/types.js';
2
2
  import { type ResultObserverHandle } from '../sdk/result-capture.js';
3
3
  import { type CaseContextProviderHandle } from '../sdk/case-context.js';
4
- import { type LifecycleAgentOwner } from '../sdk/lifecycle.js';
5
4
  import type { AdapterLifecycleHooks, EvalResultEvent } from './adapter.js';
6
5
  export type VitestAfterEachFn = (fn: (ctx: {
7
6
  task: {
@@ -31,7 +30,6 @@ export interface VitestLifecycleInstallHandle {
31
30
  }
32
31
  export declare function createVitestLifecycleHooks(): AdapterLifecycleHooks;
33
32
  export declare function installVitestLifecycle(input: VitestLifecycleInstallInput): VitestLifecycleInstallHandle;
34
- export declare function currentVitestAgentOwner(resultCaptureActive: boolean): LifecycleAgentOwner | null;
35
33
  export declare function trackVitestAgent(agent: Agent, resultCaptureActive: boolean): void;
36
34
  export declare function untrackVitestAgent(agent: Agent): void;
37
35
  export declare function releaseVitestAgent(agent: Agent): void;
@@ -43,7 +43,7 @@ export function installVitestLifecycle(input) {
43
43
  fileContextHandle.restore();
44
44
  }
45
45
  }
46
- export function currentVitestAgentOwner(resultCaptureActive) {
46
+ function currentVitestAgentOwner(resultCaptureActive) {
47
47
  const current = getCurrentCaseContext();
48
48
  if (current.status === 'active') {
49
49
  return current.context.scope === 'runner-case'
package/dist/sdk/agent.js CHANGED
@@ -261,9 +261,7 @@ class AgentImpl {
261
261
  const sendTurn = async (message) => {
262
262
  const turnResult = await ms.executeTurn(message);
263
263
  turnNumber++;
264
- // Accumulate agent turn tokens (from CLI stream-json) on the shared tracker.
265
- // Cost is populated by Claude SDK (from `total_cost_usd`); Codex/Cursor leave
266
- // it undefined, in which case this is a no-op.
264
+ // Accumulate provider-reported agent turn tokens and cost on the shared tracker.
267
265
  this.accumulateTurnUsage(turnResult);
268
266
  for (const toolEvent of turnResult.toolEvents) {
269
267
  this._log.push(buildToolEventLogEntry(toolEvent, new Date().toISOString()));
@@ -1,12 +1,12 @@
1
1
  import type { AskHandler } from './types.js';
2
2
  import type { AskUserReactionPreviewEntry, Reaction } from '../types.js';
3
- export type UnmatchedAskUserDisposition = 'error' | 'first-option' | 'decline';
3
+ type UnmatchedAskUserDisposition = 'error' | 'first-option' | 'decline';
4
4
  export interface AskUserHandlerContext {
5
5
  reactions: readonly Reaction[];
6
6
  onUnmatchedAskUser: UnmatchedAskUserDisposition;
7
7
  firedOnce: Set<number>;
8
8
  }
9
- export interface AskUserUnmatchedSignal {
9
+ interface AskUserUnmatchedSignal {
10
10
  batchId: string;
11
11
  turnNumber: number;
12
12
  /**
@@ -29,3 +29,4 @@ export interface AskUserHandlerApi {
29
29
  getUnmatchedError(): AskUserUnmatchedSignal | null;
30
30
  }
31
31
  export declare function createAskUserHandler(ctx: AskUserHandlerContext): AskUserHandlerApi;
32
+ export {};
@@ -1,7 +1,7 @@
1
1
  import type { LogEntry } from '../types.js';
2
2
  import type { ReactionFiredEntry, TurnDetail } from './types.js';
3
3
  import { type RuntimePolicyAuditEntry } from './runtime-policy.js';
4
- export interface DiagnosticsScorer {
4
+ interface DiagnosticsScorer {
5
5
  name: string;
6
6
  type: string;
7
7
  score: number;
@@ -9,10 +9,10 @@ export interface DiagnosticsScorer {
9
9
  details?: string;
10
10
  status?: 'ok' | 'error' | 'skipped';
11
11
  }
12
- export interface DiagnosticsTurnDetail extends TurnDetail {
12
+ interface DiagnosticsTurnDetail extends TurnDetail {
13
13
  apiRetries: number;
14
14
  }
15
- export type DiagnosticsRuntimePolicyEntry = RuntimePolicyAuditEntry;
15
+ type DiagnosticsRuntimePolicyEntry = RuntimePolicyAuditEntry;
16
16
  export interface DiagnosticsReport {
17
17
  turns: number;
18
18
  totalDurationMs: number;
@@ -39,3 +39,4 @@ export interface BuildDiagnosticsReportInput {
39
39
  log: LogEntry[];
40
40
  }
41
41
  export declare function buildDiagnosticsReport(input: BuildDiagnosticsReportInput): DiagnosticsReport;
42
+ export {};
@@ -68,8 +68,9 @@ function makeEvaluateAgent() {
68
68
  : undefined;
69
69
  // Agent usage is independent of the optional scorer LLM. Same
70
70
  // first-eval attribution rule for cost; omit it when unavailable.
71
- // no conversation cost was captured (Codex / Cursor today).
72
- const conversationCost = isFirstEval && beforeCostUsd > 0
71
+ // Preserve an authoritative zero while retaining compatibility with
72
+ // older/custom ports whose positive total is the only presence signal.
73
+ const conversationCost = isFirstEval && (agent.llm.costObserved === true || beforeCostUsd > 0)
73
74
  ? { conversation_cost_usd: beforeCostUsd }
74
75
  : undefined;
75
76
  if (isFirstEval)
@@ -1,7 +1,6 @@
1
1
  import type { ToolCapableLLMPort } from '../utils/llm-types.js';
2
2
  import type { JudgeScorer, ScorerContext, ScorerResultEntry, TokenUsage } from './types.js';
3
- import { type JudgeErrorCode, type JudgeToolCallRecord, type ToolExecutor } from './judge-tool-session.js';
4
- export type { JudgeErrorCode, JudgeToolCallRecord };
3
+ import { type JudgeToolCallRecord, type ToolExecutor } from './judge-tool-session.js';
5
4
  export interface RunJudgeWithToolsResult {
6
5
  entry: ScorerResultEntry;
7
6
  rounds: number;
@@ -140,6 +140,7 @@ function synthesizeTrialFromAgent(agent) {
140
140
  return null;
141
141
  const nCommands = countShellCommandsFromLog(agent.log);
142
142
  const tokenUsage = agent.llm.tokenUsage;
143
+ const conversationCostUsd = agent.llm.costUsd ?? 0;
143
144
  const conversationEnd = [...agent.log].reverse().find((entry) => entry.type === 'conversation_end');
144
145
  const completionReason = conversationEnd?.completion_reason ?? (agent.log.some((entry) => entry.type === 'agent_result') ? 'completed' : undefined);
145
146
  return {
@@ -160,6 +161,9 @@ function synthesizeTrialFromAgent(agent) {
160
161
  conversation_output_tokens: tokenUsage.outputTokens,
161
162
  }
162
163
  : {}),
164
+ ...(agent.llm.costObserved === true || conversationCostUsd > 0
165
+ ? { conversation_cost_usd: conversationCostUsd }
166
+ : {}),
163
167
  session_log: [...agent.log],
164
168
  },
165
169
  diagnostics: buildDiagnosticsReport({
@@ -9,7 +9,7 @@ export interface McpMockApprovalRule {
9
9
  decision: 'approve' | 'deny';
10
10
  label?: string;
11
11
  }
12
- export interface CompiledMcpTool {
12
+ interface CompiledMcpTool {
13
13
  name: string;
14
14
  description?: string;
15
15
  inputSchema: Record<string, unknown>;
@@ -19,7 +19,7 @@ export interface CompiledMcpTool {
19
19
  response: McpMockJsonValue;
20
20
  }>[];
21
21
  }
22
- export interface CompiledMcpServer {
22
+ interface CompiledMcpServer {
23
23
  name: string;
24
24
  instructions?: string;
25
25
  tools: ReadonlyMap<string, CompiledMcpTool>;
@@ -38,3 +38,4 @@ export declare function matchesMcpApprovalArguments(actual: Record<string, McpMo
38
38
  export declare function canonicalizeMcpArguments(value: McpMockJsonValue): string;
39
39
  export declare function createMcpArgumentDigest(key: Buffer, value: McpMockJsonValue): string;
40
40
  export declare function createMcpReceiptKey(): Buffer;
41
+ export {};
@@ -1,4 +1,3 @@
1
- import type { AskUserOption, AskUserQuestion, AskUserReaction, Message, Reaction, TextReaction } from './types.js';
1
+ import type { Message, Reaction } from './types.js';
2
2
  export declare function loadReactionSnapshotMessages(snapshotPath: string): Promise<Message[]>;
3
3
  export declare function loadReactionsFromFile(filePath: string): Promise<Reaction[]>;
4
- export type { AskUserOption, AskUserQuestion, AskUserReaction, TextReaction };
@@ -1,6 +1,3 @@
1
- import type { AskUserReaction, Message, Reaction, ReactionPreviewEntry, ReactionPreviewResult, TextReaction } from './types.js';
2
- export declare function isAskUserReaction(reaction: Reaction): reaction is AskUserReaction;
3
- export declare function isTextReaction(reaction: Reaction): reaction is TextReaction;
1
+ import type { Message, Reaction, ReactionPreviewEntry, ReactionPreviewResult } from './types.js';
4
2
  export declare function inspectReactions(agentMessage: string, reactions: Reaction[], firedOnce: Set<number>): ReactionPreviewEntry[];
5
- export declare function pickReactionReply(agentMessage: string, reactions: Reaction[], firedOnce: Set<number>): string | null;
6
3
  export declare function previewReactions(messages: Message[], reactions: Reaction[]): ReactionPreviewResult;
@@ -20,10 +20,10 @@ function testUnless(pattern, input) {
20
20
  return false;
21
21
  }
22
22
  }
23
- export function isAskUserReaction(reaction) {
23
+ function isAskUserReaction(reaction) {
24
24
  return 'whenAsked' in reaction;
25
25
  }
26
- export function isTextReaction(reaction) {
26
+ function isTextReaction(reaction) {
27
27
  return 'when' in reaction;
28
28
  }
29
29
  export function inspectReactions(agentMessage, reactions, firedOnce) {
@@ -71,7 +71,7 @@ export function inspectReactions(agentMessage, reactions, firedOnce) {
71
71
  };
72
72
  });
73
73
  }
74
- export function pickReactionReply(agentMessage, reactions, firedOnce) {
74
+ function pickReactionReply(agentMessage, reactions, firedOnce) {
75
75
  const evaluations = inspectReactions(agentMessage, reactions, firedOnce);
76
76
  const match = evaluations.find((evaluation) => evaluation.fired && evaluation.kind === 'text');
77
77
  return match && match.kind === 'text' ? match.reply ?? null : null;
@@ -1,10 +1,7 @@
1
1
  import type { LLMPort } from '../utils/llm-types.js';
2
- import type { CheckScorer, Scorer, ScoreScorer, ScorerContext, ScorerResultEntry, ToolUsageScorer } from './types.js';
2
+ import type { Scorer, ScorerContext, ScorerResultEntry } from './types.js';
3
3
  export interface RunScorerOptions {
4
4
  /** Required for `judge` scorers; ignored for other types. */
5
5
  llm?: LLMPort;
6
6
  }
7
7
  export declare function runScorer(scorer: Scorer, ctx: ScorerContext, opts?: RunScorerOptions): Promise<ScorerResultEntry>;
8
- export declare function runCheckScorer(scorer: CheckScorer, ctx: ScorerContext): Promise<ScorerResultEntry>;
9
- export declare function runScoreScorer(scorer: ScoreScorer, ctx: ScorerContext): Promise<ScorerResultEntry>;
10
- export declare function runToolUsageScorer(scorer: ToolUsageScorer, ctx: ScorerContext): Promise<ScorerResultEntry>;
@@ -43,7 +43,7 @@ function buildEntryFromOutcome(scorer, outcome) {
43
43
  errorCode: outcome.code,
44
44
  };
45
45
  }
46
- export async function runCheckScorer(scorer, ctx) {
46
+ async function runCheckScorer(scorer, ctx) {
47
47
  try {
48
48
  const passed = await scorer.fn(ctx);
49
49
  return {
@@ -59,7 +59,7 @@ export async function runCheckScorer(scorer, ctx) {
59
59
  return makeErroredResult('check', scorer.name, scorer.weight, error);
60
60
  }
61
61
  }
62
- export async function runScoreScorer(scorer, ctx) {
62
+ async function runScoreScorer(scorer, ctx) {
63
63
  try {
64
64
  const raw = await scorer.fn(ctx);
65
65
  if (typeof raw === 'number') {
@@ -84,7 +84,7 @@ export async function runScoreScorer(scorer, ctx) {
84
84
  return makeErroredResult('score', scorer.name, scorer.weight, error);
85
85
  }
86
86
  }
87
- export async function runToolUsageScorer(scorer, ctx) {
87
+ async function runToolUsageScorer(scorer, ctx) {
88
88
  try {
89
89
  const toolEvents = ctx.toolEvents;
90
90
  if (toolEvents.length === 0) {
@@ -15,7 +15,6 @@ export interface RuntimePolicyAuditEntry {
15
15
  export declare const NONINTERACTIVE_RUNTIME_POLICY: RuntimePolicyDescriptor;
16
16
  export declare function planRuntimePolicies(agent: AgentName, transport?: AgentTransport): RuntimePolicyDescriptor[];
17
17
  export declare function renderRuntimePolicy(policy: RuntimePolicyDescriptor, context: RuntimePolicyRenderContext): string;
18
- export declare function renderRuntimePolicies(policies: RuntimePolicyDescriptor[], context: RuntimePolicyRenderContext): string;
19
18
  export declare function prependRuntimePolicies(instruction: string, policies: RuntimePolicyDescriptor[], context: RuntimePolicyRenderContext): string;
20
19
  export declare function getRuntimePolicyLogMetadata(turnResult: AgentTurnResult): Record<string, unknown>;
21
20
  export declare function extractRuntimePolicyAuditEntries(log: LogEntry[]): RuntimePolicyAuditEntry[];
@@ -32,7 +32,7 @@ export function renderRuntimePolicy(policy, context) {
32
32
  'Ask only the earliest outstanding approval checkpoint.',
33
33
  ].join('\n');
34
34
  }
35
- export function renderRuntimePolicies(policies, context) {
35
+ function renderRuntimePolicies(policies, context) {
36
36
  return policies
37
37
  .map((policy) => renderRuntimePolicy(policy, context))
38
38
  .filter((policy) => policy.length > 0)
@@ -44,7 +44,6 @@ export interface ToolEventResult {
44
44
  exitCode?: number;
45
45
  truncated?: boolean;
46
46
  }
47
- export declare function summarizeToolEvents(events: ToolEvent[]): string;
48
47
  /**
49
48
  * Map from provider-specific tool names to normalized Pathgrade actions.
50
49
  * Conservative: only map names we're confident about.
@@ -1,4 +1,4 @@
1
- export function summarizeToolEvents(events) {
1
+ function summarizeToolEvents(events) {
2
2
  return events.map((event) => `${event.action}:${event.providerToolName}`).join(', ');
3
3
  }
4
4
  /**
package/dist/types.d.ts CHANGED
@@ -8,10 +8,10 @@ export interface CommandResult {
8
8
  timedOut?: boolean;
9
9
  killed?: boolean;
10
10
  }
11
- export interface TurnCommand extends CommandResult {
11
+ interface TurnCommand extends CommandResult {
12
12
  command: string;
13
13
  }
14
- export type ConversationReplySource = 'opener' | 'reaction' | 'persona_llm';
14
+ type ConversationReplySource = 'opener' | 'reaction' | 'persona_llm';
15
15
  export interface ConversationTurn {
16
16
  turn_number: number;
17
17
  user_message: string;
@@ -24,7 +24,7 @@ export interface ConversationTurn {
24
24
  step_scorer_results?: ScorerResult[];
25
25
  tool_events?: import('./tool-events.js').ToolEvent[];
26
26
  }
27
- export type ConversationCompletionReason = 'max_turns' | 'signal' | 'done_phrase' | 'done_when' | 'timeout' | 'no_replies' | 'error';
27
+ type ConversationCompletionReason = 'max_turns' | 'signal' | 'done_phrase' | 'done_when' | 'timeout' | 'no_replies' | 'error';
28
28
  export interface ScorerResult {
29
29
  scorer_type: string;
30
30
  score: number;
@@ -32,25 +32,7 @@ export interface ScorerResult {
32
32
  details: string;
33
33
  status?: import('./sdk/types.js').ScorerStatus;
34
34
  }
35
- /**
36
- * JSON contract for deterministic scorer stdout.
37
- * The scorer script must print a JSON object matching this shape to stdout.
38
- */
39
- export interface ScorerOutput {
40
- /** Score between 0.0 and 1.0 (required). Clamped by pathgrade. */
41
- score: number;
42
- /** Human-readable summary (optional). */
43
- details?: string;
44
- /** Per-check breakdown, rendered as checkmarks in reports (optional). */
45
- checks?: ScorerCheck[];
46
- }
47
- /** Individual check result within a ScorerOutput. */
48
- export interface ScorerCheck {
49
- name: string;
50
- passed: boolean;
51
- message?: string;
52
- }
53
- export interface JudgeToolCallLogData {
35
+ interface JudgeToolCallLogData {
54
36
  /** Tool name (readFile | listDir | grep | getToolEvents). */
55
37
  name: string;
56
38
  /** Arguments the LLM passed to the tool. */
@@ -103,8 +85,7 @@ export interface LogEntry {
103
85
  blocked_prompt_tool_use_id?: string;
104
86
  runtime_policies_applied?: RuntimePolicyDescriptor[];
105
87
  /**
106
- * Per-turn agent cost in USD when the upstream provider reports it (the
107
- * Claude Agent SDK populates `total_cost_usd` on result messages).
88
+ * Per-turn agent cost in USD when the executing agent reports or estimates it.
108
89
  * Written by `buildModelAgentResultLogEntry` only when the turn result
109
90
  * carries a `costUsd` value; absent for agents that do not expose cost.
110
91
  */
@@ -300,7 +281,7 @@ export interface PathgradeReport {
300
281
  selection?: PathgradeSelectionReport;
301
282
  }
302
283
  export type PassAtKUnavailableReason = 'non_binary_reward' | 'incomplete_attempts' | 'case_identity_mismatch';
303
- export interface TrialPaths {
284
+ interface TrialPaths {
304
285
  root: string;
305
286
  workspace: string;
306
287
  home: string;
@@ -317,11 +298,11 @@ export interface TrialRuntime {
317
298
  }
318
299
  export type EnvironmentHandle = string | TrialRuntime;
319
300
  export type AgentCommandRunner = (cmd: string) => Promise<CommandResult>;
320
- export interface AgentTurnInput {
301
+ interface AgentTurnInput {
321
302
  message: string;
322
303
  continueSession?: boolean;
323
304
  }
324
- export type VisibleAssistantMessageSource = 'assistant_message';
305
+ type VisibleAssistantMessageSource = 'assistant_message';
325
306
  export interface AgentTurnResult {
326
307
  rawOutput: string;
327
308
  assistantMessage: string;
@@ -350,10 +331,7 @@ export interface AgentTurnResult {
350
331
  */
351
332
  cacheReadInputTokens?: number;
352
333
  /**
353
- * Optional turn cost in USD reported by providers that expose exact
354
- * pricing. The Claude Agent SDK populates this from the result
355
- * message's `total_cost_usd`. Other drivers (Codex, Cursor) leave it
356
- * undefined until their providers expose comparable metadata.
334
+ * Optional turn cost in USD reported or estimated by the executing agent.
357
335
  */
358
336
  costUsd?: number;
359
337
  /**
@@ -395,7 +373,6 @@ export interface AgentSession {
395
373
  dispose?(): Promise<void>;
396
374
  }
397
375
  export declare function getWorkspacePath(handle: EnvironmentHandle): string;
398
- export declare function getRuntimeHandle(handle: EnvironmentHandle): string;
399
376
  export declare function getRuntimeEnv(handle: EnvironmentHandle): Record<string, string>;
400
377
  export type McpConfigOrigin = 'generated_mock' | 'caller_config';
401
378
  export interface AgentSessionOptions {
@@ -449,3 +426,4 @@ export declare abstract class BaseAgent {
449
426
  run(_instruction: string, _workspacePath: string, _runCommand: AgentCommandRunner): Promise<string>;
450
427
  }
451
428
  export declare function createAgentSession(agent: BaseAgent, runtime: EnvironmentHandle, runCommand: AgentCommandRunner, options?: AgentSessionOptions): Promise<AgentSession>;
429
+ export {};
package/dist/types.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export function getWorkspacePath(handle) {
2
2
  return typeof handle === 'string' ? handle : handle.workspacePath;
3
3
  }
4
- export function getRuntimeHandle(handle) {
4
+ function getRuntimeHandle(handle) {
5
5
  return typeof handle === 'string' ? handle : handle.handle;
6
6
  }
7
7
  export function getRuntimeEnv(handle) {
@@ -15,21 +15,6 @@ export declare const fmt: {
15
15
  };
16
16
  /** Print a section header with a rule line */
17
17
  export declare function header(title: string, width?: number): void;
18
- /** Print a labeled key-value pair */
19
- export declare function kv(label: string, value: string, indent?: number): void;
20
- /** Print a trial result row */
21
- export declare function trialRow(trialId: number, total: number, reward: number, duration: string, commands: number, scorers: {
22
- type: string;
23
- score: number;
24
- }[]): void;
25
- /** Print the results summary block */
26
- export declare function resultsSummary(passRate: number, passAtK: number, passPowK: number, trials: number, preset?: string): void;
27
- /** Print a validation result */
28
- export declare function validationResult(passed: boolean, reward: number, scorers: {
29
- type: string;
30
- score: number;
31
- details: string;
32
- }[]): void;
33
18
  /**
34
19
  * In-place spinner that shows current phase + elapsed time on one line.
35
20
  *
package/dist/utils/cli.js CHANGED
@@ -27,13 +27,13 @@ export function header(title, width = 60) {
27
27
  console.log(`\n${fmt.bold(`── ${title} `)}${fmt.dim(rule)}`);
28
28
  }
29
29
  /** Print a labeled key-value pair */
30
- export function kv(label, value, indent = 2) {
30
+ function kv(label, value, indent = 2) {
31
31
  const pad = ' '.repeat(indent);
32
32
  const labelPad = label.padEnd(12);
33
33
  console.log(`${pad}${fmt.dim(labelPad)}${value}`);
34
34
  }
35
35
  /** Print a trial result row */
36
- export function trialRow(trialId, total, reward, duration, commands, scorers) {
36
+ function trialRow(trialId, total, reward, duration, commands, scorers) {
37
37
  const pad = ' ';
38
38
  const status = reward >= 0.5 ? fmt.pass('PASS') : fmt.fail('FAIL');
39
39
  const rewardStr = reward.toFixed(2);
@@ -47,7 +47,7 @@ export function trialRow(trialId, total, reward, duration, commands, scorers) {
47
47
  console.log(`${pad} ${fmt.dim(trialLabel)} ${status} ${fmt.bold(rewardStr)} ${fmt.dim(duration.padEnd(7))} ${fmt.dim(commands + ' cmds')} ${scorerStr}`);
48
48
  }
49
49
  /** Print the results summary block */
50
- export function resultsSummary(passRate, passAtK, passPowK, trials, preset) {
50
+ function resultsSummary(passRate, passAtK, passPowK, trials, preset) {
51
51
  const presetLabel = preset === 'smoke' ? ' (smoke test)'
52
52
  : preset === 'reliable' ? ' (reliable)'
53
53
  : preset === 'regression' ? ' (regression)'
@@ -61,7 +61,7 @@ export function resultsSummary(passRate, passAtK, passPowK, trials, preset) {
61
61
  console.log();
62
62
  }
63
63
  /** Print a validation result */
64
- export function validationResult(passed, reward, scorers) {
64
+ function validationResult(passed, reward, scorers) {
65
65
  for (const g of scorers) {
66
66
  const scoreStr = g.score.toFixed(2);
67
67
  const color = g.score >= 0.5 ? fmt.green(scoreStr) : fmt.red(scoreStr);
@@ -26,11 +26,11 @@ export interface CreateMockLLMOptions {
26
26
  /** When set, replaces the queue for `.call()`. Useful for dynamic / side-effecting tests. */
27
27
  respond?: (prompt: string, opts?: LLMCallOptions) => MockResponse | Promise<MockResponse>;
28
28
  }
29
- export interface MockCallRecord {
29
+ interface MockCallRecord {
30
30
  prompt: string;
31
31
  opts?: LLMCallOptions;
32
32
  }
33
- export interface MockToolCallRecord {
33
+ interface MockToolCallRecord {
34
34
  messages: ToolUseMessage[];
35
35
  opts: CallWithToolsOptions;
36
36
  }
@@ -41,3 +41,4 @@ export interface MockLLM extends LLMPort {
41
41
  readonly toolCalls: readonly MockToolCallRecord[];
42
42
  }
43
43
  export declare function createMockLLM(opts?: CreateMockLLMOptions): MockLLM;
44
+ export {};
@@ -12,6 +12,7 @@ export function createMockLLM(opts = {}) {
12
12
  let inputTokens = 0;
13
13
  let outputTokens = 0;
14
14
  let costUsd = 0;
15
+ let costObserved = false;
15
16
  let callCount = 0;
16
17
  const take = () => {
17
18
  callCount++;
@@ -29,6 +30,9 @@ export function createMockLLM(opts = {}) {
29
30
  get costUsd() {
30
31
  return costUsd;
31
32
  },
33
+ get costObserved() {
34
+ return costObserved;
35
+ },
32
36
  get supportsToolUse() {
33
37
  return true;
34
38
  },
@@ -43,6 +47,7 @@ export function createMockLLM(opts = {}) {
43
47
  if (!Number.isFinite(usd) || usd < 0)
44
48
  return;
45
49
  costUsd += usd;
50
+ costObserved = true;
46
51
  },
47
52
  async measure(fn) {
48
53
  const inBefore = inputTokens;
@@ -3,7 +3,6 @@ import type { LLMProvider } from '../llm-types.js';
3
3
  export declare function resetCliCache(): void;
4
4
  /** Check if claude CLI is installed and authenticated. */
5
5
  export declare function isClaudeCliAvailable(): Promise<boolean>;
6
- export declare function isCodexCliAvailable(): Promise<boolean>;
7
6
  interface CliEnvelope {
8
7
  result?: string;
9
8
  structured_output?: unknown;
@@ -27,7 +27,7 @@ export function resetCliCache() {
27
27
  export async function isClaudeCliAvailable() {
28
28
  return getCliAvailability('claude', ['auth', 'status'], 5);
29
29
  }
30
- export async function isCodexCliAvailable() {
30
+ async function isCodexCliAvailable() {
31
31
  return getCliAvailability('codex', ['login', 'status'], 5);
32
32
  }
33
33
  export function parseCliEnvelope(raw) {
@@ -32,9 +32,11 @@ export interface LLMPort {
32
32
  * comparable metadata.
33
33
  */
34
34
  readonly costUsd?: number;
35
+ /** True after any valid cost observation, including an observed zero. */
36
+ readonly costObserved?: boolean;
35
37
  /** Add externally-observed tokens (e.g. from agent CLI turns). */
36
38
  addTokens?(input: number, output: number): void;
37
- /** Add externally-observed cost (e.g. from Claude SDK `total_cost_usd`). */
39
+ /** Add externally-observed agent cost. */
38
40
  addCost?(usd: number): void;
39
41
  /** Run `fn` and return its token + cost delta. */
40
42
  measure?<T>(fn: () => Promise<T>): Promise<{
@@ -73,12 +75,12 @@ export interface ToolResultBlock {
73
75
  content: string;
74
76
  is_error?: boolean;
75
77
  }
76
- export interface TextBlock {
78
+ interface TextBlock {
77
79
  type: 'text';
78
80
  text: string;
79
81
  }
80
- export type AssistantContentBlock = TextBlock | ToolUseBlock;
81
- export type UserContentBlock = TextBlock | ToolResultBlock;
82
+ type AssistantContentBlock = TextBlock | ToolUseBlock;
83
+ type UserContentBlock = TextBlock | ToolResultBlock;
82
84
  export interface ToolUseMessage {
83
85
  role: 'user' | 'assistant';
84
86
  content: string | Array<AssistantContentBlock | UserContentBlock>;
@@ -105,3 +107,4 @@ export interface LLMProviderAdapter {
105
107
  }
106
108
  /** @deprecated Use `LLMProviderAdapter`. Alias retained only during the RFC 010a migration. */
107
109
  export type LLMProvider = LLMProviderAdapter;
110
+ export {};