@wix/pathgrade 0.29.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.
Files changed (238) hide show
  1. package/bin/pathgrade.js +2 -0
  2. package/dist/affected/anchor.d.ts +18 -0
  3. package/dist/affected/anchor.js +42 -0
  4. package/dist/affected/config.d.ts +25 -0
  5. package/dist/affected/config.js +98 -0
  6. package/dist/affected/format.d.ts +45 -0
  7. package/dist/affected/format.js +87 -0
  8. package/dist/affected/git.d.ts +33 -0
  9. package/dist/affected/git.js +68 -0
  10. package/dist/affected/glob.d.ts +17 -0
  11. package/dist/affected/glob.js +25 -0
  12. package/dist/affected/meta.d.ts +26 -0
  13. package/dist/affected/meta.js +158 -0
  14. package/dist/affected/select.d.ts +30 -0
  15. package/dist/affected/select.js +101 -0
  16. package/dist/affected/sidecar.d.ts +32 -0
  17. package/dist/affected/sidecar.js +86 -0
  18. package/dist/affected/types.d.ts +43 -0
  19. package/dist/affected/types.js +7 -0
  20. package/dist/agents/claude/ask-user-answer-store.d.ts +28 -0
  21. package/dist/agents/claude/ask-user-answer-store.js +29 -0
  22. package/dist/agents/claude/ask-user-bridge.d.ts +56 -0
  23. package/dist/agents/claude/ask-user-bridge.js +162 -0
  24. package/dist/agents/claude/sdk-message-projector.d.ts +43 -0
  25. package/dist/agents/claude/sdk-message-projector.js +208 -0
  26. package/dist/agents/claude/sdk-options.d.ts +52 -0
  27. package/dist/agents/claude/sdk-options.js +79 -0
  28. package/dist/agents/claude.d.ts +56 -0
  29. package/dist/agents/claude.js +143 -0
  30. package/dist/agents/codex-app-server/agent.d.ts +35 -0
  31. package/dist/agents/codex-app-server/agent.js +388 -0
  32. package/dist/agents/codex-app-server/fixtures/app-server-client.d.ts +19 -0
  33. package/dist/agents/codex-app-server/fixtures/app-server-client.js +104 -0
  34. package/dist/agents/codex-app-server/fixtures/run-gate.d.ts +25 -0
  35. package/dist/agents/codex-app-server/fixtures/run-gate.js +48 -0
  36. package/dist/agents/codex-app-server/protocol/ClientRequest.d.ts +27 -0
  37. package/dist/agents/codex-app-server/protocol/ClientRequest.js +7 -0
  38. package/dist/agents/codex-app-server/protocol/DynamicToolCallParams.d.ts +9 -0
  39. package/dist/agents/codex-app-server/protocol/DynamicToolCallParams.js +4 -0
  40. package/dist/agents/codex-app-server/protocol/GrantedPermissionProfile.d.ts +6 -0
  41. package/dist/agents/codex-app-server/protocol/GrantedPermissionProfile.js +7 -0
  42. package/dist/agents/codex-app-server/protocol/McpElicitationRequestParams.d.ts +23 -0
  43. package/dist/agents/codex-app-server/protocol/McpElicitationRequestParams.js +8 -0
  44. package/dist/agents/codex-app-server/protocol/Op.d.ts +11 -0
  45. package/dist/agents/codex-app-server/protocol/Op.js +5 -0
  46. package/dist/agents/codex-app-server/protocol/PermissionsRequestApprovalParams.d.ts +10 -0
  47. package/dist/agents/codex-app-server/protocol/PermissionsRequestApprovalParams.js +6 -0
  48. package/dist/agents/codex-app-server/protocol/PermissionsRequestApprovalResponse.d.ts +15 -0
  49. package/dist/agents/codex-app-server/protocol/PermissionsRequestApprovalResponse.js +4 -0
  50. package/dist/agents/codex-app-server/protocol/SandboxMode.d.ts +1 -0
  51. package/dist/agents/codex-app-server/protocol/SandboxMode.js +4 -0
  52. package/dist/agents/codex-app-server/protocol/ServerRequest.d.ts +42 -0
  53. package/dist/agents/codex-app-server/protocol/ServerRequest.js +7 -0
  54. package/dist/agents/codex-app-server/protocol/ThreadStartParams.d.ts +45 -0
  55. package/dist/agents/codex-app-server/protocol/ThreadStartParams.js +10 -0
  56. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputAnswer.d.ts +6 -0
  57. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputAnswer.js +4 -0
  58. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputOption.d.ts +7 -0
  59. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputOption.js +4 -0
  60. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputParams.d.ts +10 -0
  61. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputParams.js +4 -0
  62. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputQuestion.d.ts +12 -0
  63. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputQuestion.js +4 -0
  64. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputResponse.d.ts +9 -0
  65. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputResponse.js +4 -0
  66. package/dist/agents/codex-app-server/protocol/TurnCompletedNotification.d.ts +5 -0
  67. package/dist/agents/codex-app-server/protocol/TurnCompletedNotification.js +4 -0
  68. package/dist/agents/codex-app-server/protocol/index.d.ts +16 -0
  69. package/dist/agents/codex-app-server/protocol/index.js +11 -0
  70. package/dist/agents/codex-app-server/transport.d.ts +84 -0
  71. package/dist/agents/codex-app-server/transport.js +246 -0
  72. package/dist/agents/codex-app-server/wire-translators.d.ts +19 -0
  73. package/dist/agents/codex-app-server/wire-translators.js +52 -0
  74. package/dist/agents/codex.d.ts +7 -0
  75. package/dist/agents/codex.js +164 -0
  76. package/dist/agents/cursor.d.ts +39 -0
  77. package/dist/agents/cursor.js +233 -0
  78. package/dist/agents/registry.d.ts +17 -0
  79. package/dist/agents/registry.js +27 -0
  80. package/dist/agents/transcript-agent.d.ts +14 -0
  81. package/dist/agents/transcript-agent.js +59 -0
  82. package/dist/analytics/engine.d.ts +18 -0
  83. package/dist/analytics/engine.js +66 -0
  84. package/dist/commands/affected.d.ts +31 -0
  85. package/dist/commands/affected.js +150 -0
  86. package/dist/commands/analyze.d.ts +21 -0
  87. package/dist/commands/analyze.js +167 -0
  88. package/dist/commands/init.d.ts +3 -0
  89. package/dist/commands/init.js +242 -0
  90. package/dist/commands/preview-reactions.d.ts +10 -0
  91. package/dist/commands/preview-reactions.js +88 -0
  92. package/dist/commands/preview.d.ts +5 -0
  93. package/dist/commands/preview.js +17 -0
  94. package/dist/commands/report.d.ts +39 -0
  95. package/dist/commands/report.js +108 -0
  96. package/dist/commands/run-args.d.ts +22 -0
  97. package/dist/commands/run-args.js +69 -0
  98. package/dist/commands/run-changed.d.ts +26 -0
  99. package/dist/commands/run-changed.js +138 -0
  100. package/dist/commands/validate.d.ts +13 -0
  101. package/dist/commands/validate.js +233 -0
  102. package/dist/core/mcp-mock.d.ts +3 -0
  103. package/dist/core/mcp-mock.js +23 -0
  104. package/dist/core/mcp-mock.types.d.ts +15 -0
  105. package/dist/core/mcp-mock.types.js +1 -0
  106. package/dist/core/skills.d.ts +15 -0
  107. package/dist/core/skills.js +76 -0
  108. package/dist/evals/discovery.d.ts +7 -0
  109. package/dist/evals/discovery.js +69 -0
  110. package/dist/mcp-mock-server.d.ts +1 -0
  111. package/dist/mcp-mock-server.js +116 -0
  112. package/dist/pathgrade.d.ts +10 -0
  113. package/dist/pathgrade.js +243 -0
  114. package/dist/plugin/index.d.ts +9 -0
  115. package/dist/plugin/index.js +81 -0
  116. package/dist/plugin/lifecycle.d.ts +45 -0
  117. package/dist/plugin/lifecycle.js +146 -0
  118. package/dist/plugin/reporter.d.ts +36 -0
  119. package/dist/plugin/reporter.js +275 -0
  120. package/dist/plugin/setup.d.ts +1 -0
  121. package/dist/plugin/setup.js +3 -0
  122. package/dist/providers/copy-filter.d.ts +18 -0
  123. package/dist/providers/copy-filter.js +66 -0
  124. package/dist/providers/credentials.d.ts +36 -0
  125. package/dist/providers/credentials.js +202 -0
  126. package/dist/providers/mcp-config.d.ts +34 -0
  127. package/dist/providers/mcp-config.js +55 -0
  128. package/dist/providers/sandbox-exec.d.ts +8 -0
  129. package/dist/providers/sandbox-exec.js +82 -0
  130. package/dist/providers/sandbox.d.ts +22 -0
  131. package/dist/providers/sandbox.js +158 -0
  132. package/dist/providers/sandboxed-claude-spawn.d.ts +24 -0
  133. package/dist/providers/sandboxed-claude-spawn.js +57 -0
  134. package/dist/providers/workspace.d.ts +15 -0
  135. package/dist/providers/workspace.js +73 -0
  136. package/dist/reporters/browser.d.ts +2 -0
  137. package/dist/reporters/browser.js +85 -0
  138. package/dist/reporters/cli.d.ts +2 -0
  139. package/dist/reporters/cli.js +131 -0
  140. package/dist/reporters/diagnostics.d.ts +46 -0
  141. package/dist/reporters/diagnostics.js +147 -0
  142. package/dist/reporters/github-comment.d.ts +67 -0
  143. package/dist/reporters/github-comment.js +252 -0
  144. package/dist/reporters/loader.d.ts +8 -0
  145. package/dist/reporters/loader.js +36 -0
  146. package/dist/reporters/results-path.d.ts +2 -0
  147. package/dist/reporters/results-path.js +10 -0
  148. package/dist/reporters/verbose-emitter.d.ts +69 -0
  149. package/dist/reporters/verbose-emitter.js +103 -0
  150. package/dist/sdk/agent-crash.d.ts +19 -0
  151. package/dist/sdk/agent-crash.js +20 -0
  152. package/dist/sdk/agent-resolution.d.ts +12 -0
  153. package/dist/sdk/agent-resolution.js +21 -0
  154. package/dist/sdk/agent-result-log.d.ts +19 -0
  155. package/dist/sdk/agent-result-log.js +45 -0
  156. package/dist/sdk/agent.d.ts +4 -0
  157. package/dist/sdk/agent.js +354 -0
  158. package/dist/sdk/ask-bus/bus.d.ts +21 -0
  159. package/dist/sdk/ask-bus/bus.js +129 -0
  160. package/dist/sdk/ask-bus/handler.d.ts +31 -0
  161. package/dist/sdk/ask-bus/handler.js +244 -0
  162. package/dist/sdk/ask-bus/parsers.d.ts +9 -0
  163. package/dist/sdk/ask-bus/parsers.js +30 -0
  164. package/dist/sdk/ask-bus/projection.d.ts +26 -0
  165. package/dist/sdk/ask-bus/projection.js +45 -0
  166. package/dist/sdk/ask-bus/types.d.ts +69 -0
  167. package/dist/sdk/ask-bus/types.js +1 -0
  168. package/dist/sdk/chat.d.ts +29 -0
  169. package/dist/sdk/chat.js +93 -0
  170. package/dist/sdk/conversation-window.d.ts +14 -0
  171. package/dist/sdk/conversation-window.js +38 -0
  172. package/dist/sdk/converse.d.ts +42 -0
  173. package/dist/sdk/converse.js +329 -0
  174. package/dist/sdk/eval-runtime.d.ts +10 -0
  175. package/dist/sdk/eval-runtime.js +17 -0
  176. package/dist/sdk/evaluate.d.ts +13 -0
  177. package/dist/sdk/evaluate.js +325 -0
  178. package/dist/sdk/index.d.ts +31 -0
  179. package/dist/sdk/index.js +20 -0
  180. package/dist/sdk/judge-pipeline.d.ts +7 -0
  181. package/dist/sdk/judge-pipeline.js +178 -0
  182. package/dist/sdk/judge-prompt-builder.d.ts +7 -0
  183. package/dist/sdk/judge-prompt-builder.js +76 -0
  184. package/dist/sdk/judge-tool-runner.d.ts +19 -0
  185. package/dist/sdk/judge-tool-runner.js +51 -0
  186. package/dist/sdk/judge-tool-session.d.ts +47 -0
  187. package/dist/sdk/judge-tool-session.js +213 -0
  188. package/dist/sdk/judge-tools.d.ts +29 -0
  189. package/dist/sdk/judge-tools.js +283 -0
  190. package/dist/sdk/managed-session.d.ts +50 -0
  191. package/dist/sdk/managed-session.js +110 -0
  192. package/dist/sdk/persona.d.ts +5 -0
  193. package/dist/sdk/persona.js +33 -0
  194. package/dist/sdk/reaction-loader.d.ts +4 -0
  195. package/dist/sdk/reaction-loader.js +119 -0
  196. package/dist/sdk/reaction-preview.d.ts +6 -0
  197. package/dist/sdk/reaction-preview.js +94 -0
  198. package/dist/sdk/run-scorer.d.ts +10 -0
  199. package/dist/sdk/run-scorer.js +124 -0
  200. package/dist/sdk/runtime-policy.d.ts +21 -0
  201. package/dist/sdk/runtime-policy.js +89 -0
  202. package/dist/sdk/scorer-utils.d.ts +6 -0
  203. package/dist/sdk/scorer-utils.js +39 -0
  204. package/dist/sdk/scorers.d.ts +64 -0
  205. package/dist/sdk/scorers.js +80 -0
  206. package/dist/sdk/snapshots.d.ts +41 -0
  207. package/dist/sdk/snapshots.js +148 -0
  208. package/dist/sdk/types.d.ts +416 -0
  209. package/dist/sdk/types.js +17 -0
  210. package/dist/sdk/visible-turn.d.ts +4 -0
  211. package/dist/sdk/visible-turn.js +23 -0
  212. package/dist/tool-events.d.ts +45 -0
  213. package/dist/tool-events.js +167 -0
  214. package/dist/types.d.ts +372 -0
  215. package/dist/types.js +37 -0
  216. package/dist/utils/cli.d.ts +55 -0
  217. package/dist/utils/cli.js +131 -0
  218. package/dist/utils/env.d.ts +8 -0
  219. package/dist/utils/env.js +26 -0
  220. package/dist/utils/llm-mocks.d.ts +43 -0
  221. package/dist/utils/llm-mocks.js +108 -0
  222. package/dist/utils/llm-providers/anthropic.d.ts +2 -0
  223. package/dist/utils/llm-providers/anthropic.js +132 -0
  224. package/dist/utils/llm-providers/cli.d.ts +20 -0
  225. package/dist/utils/llm-providers/cli.js +162 -0
  226. package/dist/utils/llm-providers/openai.d.ts +2 -0
  227. package/dist/utils/llm-providers/openai.js +56 -0
  228. package/dist/utils/llm-types.d.ts +107 -0
  229. package/dist/utils/llm-types.js +1 -0
  230. package/dist/utils/llm.d.ts +36 -0
  231. package/dist/utils/llm.js +209 -0
  232. package/dist/utils/shutdown.d.ts +15 -0
  233. package/dist/utils/shutdown.js +41 -0
  234. package/dist/utils/timeout.d.ts +8 -0
  235. package/dist/utils/timeout.js +32 -0
  236. package/dist/viewer.html +1178 -0
  237. package/package.json +88 -0
  238. package/templates/eval.ts.template +28 -0
@@ -0,0 +1,36 @@
1
+ import fs from 'fs-extra';
2
+ import * as path from 'path';
3
+ async function hydrateTraces(report, traceFile, resolved) {
4
+ const tracePath = path.resolve(resolved, traceFile);
5
+ if (!await fs.pathExists(tracePath))
6
+ return;
7
+ const traceTrials = await fs.readJSON(tracePath);
8
+ if (!Array.isArray(traceTrials) || !Array.isArray(report.trials))
9
+ return;
10
+ report.trials = report.trials.map((t, i) => ({ ...t, ...traceTrials[i] }));
11
+ }
12
+ export async function loadReports(resultsDir, opts) {
13
+ const resolved = path.resolve(resultsDir);
14
+ const files = (await fs.readdir(resolved))
15
+ .filter(f => f.endsWith('.json'))
16
+ .reverse();
17
+ const results = [];
18
+ for (const file of files) {
19
+ try {
20
+ const raw = await fs.readJSON(path.join(resolved, file));
21
+ if (!raw.version || !Array.isArray(raw.groups)) {
22
+ results.push({ file, ...raw });
23
+ continue;
24
+ }
25
+ for (const group of raw.groups) {
26
+ const report = { file, timestamp: raw.timestamp, ...group };
27
+ if (!opts?.skipTraces && group.trace_file) {
28
+ await hydrateTraces(report, group.trace_file, resolved);
29
+ }
30
+ results.push(report);
31
+ }
32
+ }
33
+ catch { /* skip malformed */ }
34
+ }
35
+ return results;
36
+ }
@@ -0,0 +1,2 @@
1
+ export declare function getPathgradeDir(projectDir: string): string;
2
+ export declare function getResultsDir(projectDir: string, baseDir?: string): string;
@@ -0,0 +1,10 @@
1
+ import * as path from 'path';
2
+ export function getPathgradeDir(projectDir) {
3
+ return path.join(projectDir, '.pathgrade');
4
+ }
5
+ export function getResultsDir(projectDir, baseDir) {
6
+ if (baseDir) {
7
+ return path.join(baseDir, path.basename(projectDir), 'results');
8
+ }
9
+ return getPathgradeDir(projectDir);
10
+ }
@@ -0,0 +1,69 @@
1
+ /** Maximum characters retained in a prompt/reply preview before truncation. */
2
+ export declare const PREVIEW_MAX_CHARS = 80;
3
+ /** Maximum characters retained in a retry error message before truncation. */
4
+ export declare const RETRY_ERROR_MAX_CHARS = 120;
5
+ /** Ellipsis appended to truncated strings. */
6
+ export declare const TRUNCATION_SUFFIX = "\u2026";
7
+ /** Newline replacement in single-line previews. */
8
+ export declare const NEWLINE_REPLACEMENT = "\u23CE";
9
+ export interface VerboseSink {
10
+ write(line: string): void;
11
+ }
12
+ export interface VerboseEmitterOptions {
13
+ enabled: boolean;
14
+ /** Output sink. Defaults to a stderr-backed sink. */
15
+ sink?: VerboseSink;
16
+ /**
17
+ * Optional test-name header printed once before the first real event.
18
+ * Helps the reader locate the beginning of each test block.
19
+ */
20
+ testName?: string;
21
+ }
22
+ export interface TurnStartArgs {
23
+ turn: number;
24
+ kind: 'agent_start' | 'user_reply';
25
+ message: string;
26
+ }
27
+ export interface ToolEventArgs {
28
+ action: string;
29
+ summary: string;
30
+ }
31
+ export interface TurnEndArgs {
32
+ turn: number;
33
+ durationMs: number;
34
+ outputLines: number;
35
+ messagePreview: string;
36
+ }
37
+ export interface RetryArgs {
38
+ attempt: number;
39
+ maxAttempts: number;
40
+ errorMessage: string;
41
+ }
42
+ export interface ReactionFiredArgs {
43
+ turn: number;
44
+ reactionIndex: number;
45
+ pattern: string;
46
+ reply: string;
47
+ }
48
+ export interface ConversationEndArgs {
49
+ reason: string;
50
+ turns: number;
51
+ durationMs: number;
52
+ /** Present when `reason === 'error'` / `'timeout'` / `'agent_crashed'`. */
53
+ detail?: string;
54
+ }
55
+ export interface VerboseEmitter {
56
+ readonly enabled: boolean;
57
+ turnStart(args: TurnStartArgs): void;
58
+ toolEvent(args: ToolEventArgs): void;
59
+ turnEnd(args: TurnEndArgs): void;
60
+ retry(args: RetryArgs): void;
61
+ reactionFired(args: ReactionFiredArgs): void;
62
+ conversationEnd(args: ConversationEndArgs): void;
63
+ }
64
+ /**
65
+ * Build a preview string: strip newlines, truncate to a max length.
66
+ * `null` / `undefined` becomes an empty string so formatting never throws.
67
+ */
68
+ export declare function preview(text: string | null | undefined, max?: number): string;
69
+ export declare function createVerboseEmitter(opts: VerboseEmitterOptions): VerboseEmitter;
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Verbose live-streaming emitter.
3
+ *
4
+ * Formats per-turn agent events into one-line human-readable output and
5
+ * writes them to a sink (default: `process.stderr`). The emitter is
6
+ * orthogonal to `--diagnostics`: it streams while the agent runs, rather
7
+ * than summarizing after the fact.
8
+ *
9
+ * See `docs/prds/PRD_VERBOSE_LIVE_STREAMING.md` for the full design.
10
+ */
11
+ import { fmt } from '../utils/cli.js';
12
+ /** Maximum characters retained in a prompt/reply preview before truncation. */
13
+ export const PREVIEW_MAX_CHARS = 80;
14
+ /** Maximum characters retained in a retry error message before truncation. */
15
+ export const RETRY_ERROR_MAX_CHARS = 120;
16
+ /** Ellipsis appended to truncated strings. */
17
+ export const TRUNCATION_SUFFIX = '…';
18
+ /** Newline replacement in single-line previews. */
19
+ export const NEWLINE_REPLACEMENT = '⏎';
20
+ /**
21
+ * Build a preview string: strip newlines, truncate to a max length.
22
+ * `null` / `undefined` becomes an empty string so formatting never throws.
23
+ */
24
+ export function preview(text, max = PREVIEW_MAX_CHARS) {
25
+ const normalized = (text ?? '').replace(/\r?\n/g, NEWLINE_REPLACEMENT);
26
+ if (normalized.length <= max)
27
+ return normalized;
28
+ return normalized.slice(0, max) + TRUNCATION_SUFFIX;
29
+ }
30
+ function stderrSink() {
31
+ return {
32
+ write(line) {
33
+ // Bypass vitest's stdout capture: vitest's default reporter
34
+ // does not hijack stderr, so writes here reach the user's
35
+ // terminal while a test is still running.
36
+ process.stderr.write(line + '\n');
37
+ },
38
+ };
39
+ }
40
+ function formatDurationSeconds(ms) {
41
+ return `${(ms / 1000).toFixed(1)}s`;
42
+ }
43
+ function disabledEmitter() {
44
+ return {
45
+ enabled: false,
46
+ turnStart() { },
47
+ toolEvent() { },
48
+ turnEnd() { },
49
+ retry() { },
50
+ reactionFired() { },
51
+ conversationEnd() { },
52
+ };
53
+ }
54
+ export function createVerboseEmitter(opts) {
55
+ if (!opts.enabled) {
56
+ return disabledEmitter();
57
+ }
58
+ const sink = opts.sink ?? stderrSink();
59
+ const testName = opts.testName;
60
+ let headerPrinted = false;
61
+ const emitHeaderOnce = () => {
62
+ if (headerPrinted)
63
+ return;
64
+ headerPrinted = true;
65
+ if (testName) {
66
+ sink.write(fmt.bold(`▶ ${testName}`));
67
+ }
68
+ };
69
+ const writeLine = (line) => {
70
+ emitHeaderOnce();
71
+ sink.write(line);
72
+ };
73
+ return {
74
+ enabled: true,
75
+ turnStart({ turn, kind, message }) {
76
+ const p = preview(message, PREVIEW_MAX_CHARS);
77
+ writeLine(`${fmt.cyan('→')} Turn ${fmt.bold(String(turn))} ${fmt.dim(`[${kind}]`)} "${p}"`);
78
+ },
79
+ toolEvent({ action, summary }) {
80
+ writeLine(` ${fmt.dim('·')} ${fmt.cyan(action)} ${summary}`);
81
+ },
82
+ turnEnd({ turn, durationMs, outputLines, messagePreview }) {
83
+ const p = preview(messagePreview, PREVIEW_MAX_CHARS);
84
+ const duration = formatDurationSeconds(durationMs);
85
+ writeLine(`${fmt.green('←')} Turn ${fmt.bold(String(turn))} ${fmt.dim(duration)} ${fmt.dim(`${outputLines}l`)} "${p}"`);
86
+ },
87
+ retry({ attempt, maxAttempts, errorMessage }) {
88
+ const msg = preview(errorMessage, RETRY_ERROR_MAX_CHARS);
89
+ writeLine(` ${fmt.red('⟲')} retry ${attempt}/${maxAttempts}: ${msg}`);
90
+ },
91
+ reactionFired({ reactionIndex, pattern, reply }) {
92
+ const p = preview(reply, PREVIEW_MAX_CHARS);
93
+ writeLine(` ${fmt.cyan('⚡')} reaction ${fmt.bold(`#${reactionIndex}`)} ${fmt.dim(pattern)} → "${p}"`);
94
+ },
95
+ conversationEnd({ reason, turns, durationMs, detail }) {
96
+ const duration = formatDurationSeconds(durationMs);
97
+ const detailSuffix = detail
98
+ ? ` ${fmt.red('detail=')}${preview(detail, RETRY_ERROR_MAX_CHARS)}`
99
+ : '';
100
+ writeLine(`${fmt.bold('■')} end ${fmt.dim('reason=')}${reason} ${fmt.dim('turns=')}${turns} ${fmt.dim(duration)}${detailSuffix}`);
101
+ },
102
+ };
103
+ }
@@ -0,0 +1,19 @@
1
+ import type { ToolEvent } from '../tool-events.js';
2
+ /**
3
+ * Error thrown by an agent driver when the subprocess dies mid-turn under a
4
+ * stateful transport (e.g. Codex `app-server`). Carries enough diagnostic
5
+ * information for `runConversation` to build `ConversationResult.crashDiagnostic`.
6
+ */
7
+ export declare class AgentCrashError extends Error {
8
+ readonly pid?: number;
9
+ readonly signal?: NodeJS.Signals | null;
10
+ readonly exitCode?: number | null;
11
+ /** Non-ask-user tool events captured before the crash, if available. */
12
+ partialToolEvents?: ToolEvent[];
13
+ constructor(message: string, info: {
14
+ pid?: number;
15
+ signal?: NodeJS.Signals | string | null;
16
+ exitCode?: number | null;
17
+ partialToolEvents?: ToolEvent[];
18
+ });
19
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Error thrown by an agent driver when the subprocess dies mid-turn under a
3
+ * stateful transport (e.g. Codex `app-server`). Carries enough diagnostic
4
+ * information for `runConversation` to build `ConversationResult.crashDiagnostic`.
5
+ */
6
+ export class AgentCrashError extends Error {
7
+ pid;
8
+ signal;
9
+ exitCode;
10
+ /** Non-ask-user tool events captured before the crash, if available. */
11
+ partialToolEvents;
12
+ constructor(message, info) {
13
+ super(message);
14
+ this.name = 'AgentCrashError';
15
+ this.pid = info.pid;
16
+ this.signal = info.signal;
17
+ this.exitCode = info.exitCode ?? null;
18
+ this.partialToolEvents = info.partialToolEvents;
19
+ }
20
+ }
@@ -0,0 +1,12 @@
1
+ import type { AgentName, AgentTransport, AgentOptions } from './types.js';
2
+ export declare class InvalidTransportEnvError extends Error {
3
+ constructor(value: string);
4
+ }
5
+ export declare function resolveAgentName(opts: Pick<AgentOptions, 'agent'>, env: {
6
+ PATHGRADE_AGENT?: string;
7
+ }): AgentName;
8
+ export declare function resolveCodexTransport(opts: {
9
+ transport?: AgentTransport;
10
+ }, env: {
11
+ PATHGRADE_CODEX_TRANSPORT?: string;
12
+ }): AgentTransport;
@@ -0,0 +1,21 @@
1
+ export class InvalidTransportEnvError extends Error {
2
+ constructor(value) {
3
+ super(`Invalid PATHGRADE_CODEX_TRANSPORT value: '${value}'. Valid options: 'exec', 'app-server'.`);
4
+ this.name = 'InvalidTransportEnvError';
5
+ }
6
+ }
7
+ export function resolveAgentName(opts, env) {
8
+ return (opts.agent || env.PATHGRADE_AGENT || 'claude');
9
+ }
10
+ export function resolveCodexTransport(opts, env) {
11
+ if (opts.transport)
12
+ return opts.transport;
13
+ const envValue = env.PATHGRADE_CODEX_TRANSPORT;
14
+ if (envValue) {
15
+ if (envValue !== 'exec' && envValue !== 'app-server') {
16
+ throw new InvalidTransportEnvError(envValue);
17
+ }
18
+ return envValue;
19
+ }
20
+ return 'app-server';
21
+ }
@@ -0,0 +1,19 @@
1
+ import type { AgentTurnResult, LogEntry } from '../types.js';
2
+ import type { AskBus } from './ask-bus/types.js';
3
+ export declare function buildModelAgentResultLogEntry(params: {
4
+ timestamp: string;
5
+ turnNumber?: number;
6
+ durationMs?: number;
7
+ turnResult: AgentTurnResult;
8
+ assistantMessage?: string;
9
+ }): LogEntry;
10
+ /**
11
+ * Build one `ask_batch` LogEntry per AskBus batch emitted in the given turn.
12
+ * Callers push these to the session log before the `agent_result` entry for
13
+ * that turn.
14
+ */
15
+ export declare function buildAskBatchLogEntries(params: {
16
+ askBus: AskBus;
17
+ turnNumber: number;
18
+ timestamp: string;
19
+ }): LogEntry[];
@@ -0,0 +1,45 @@
1
+ import { getTurnResultLogMetadata, getVisibleAssistantMessage } from './visible-turn.js';
2
+ function getOutputMetrics(message) {
3
+ return {
4
+ output_lines: message.split('\n').length,
5
+ output_chars: message.length,
6
+ };
7
+ }
8
+ export function buildModelAgentResultLogEntry(params) {
9
+ const assistantMessage = params.assistantMessage ?? getVisibleAssistantMessage(params.turnResult);
10
+ return {
11
+ type: 'agent_result',
12
+ timestamp: params.timestamp,
13
+ ...(params.turnNumber === undefined ? {} : { turn_number: params.turnNumber }),
14
+ output: params.turnResult.rawOutput,
15
+ assistant_message: assistantMessage,
16
+ ...getTurnResultLogMetadata(params.turnResult),
17
+ ...(params.durationMs === undefined ? {} : { duration_ms: params.durationMs }),
18
+ // Per-turn cost when the upstream provider reports it.
19
+ // Conditionally spread so agents without cost data
20
+ // never produce a zero-valued field that could be mistaken for
21
+ // a free turn.
22
+ ...(params.turnResult.costUsd !== undefined ? { cost_usd: params.turnResult.costUsd } : {}),
23
+ ...getOutputMetrics(assistantMessage),
24
+ };
25
+ }
26
+ /**
27
+ * Build one `ask_batch` LogEntry per AskBus batch emitted in the given turn.
28
+ * Callers push these to the session log before the `agent_result` entry for
29
+ * that turn.
30
+ */
31
+ export function buildAskBatchLogEntries(params) {
32
+ const batches = params.askBus.snapshot(params.turnNumber);
33
+ return batches.map((batch) => ({
34
+ type: 'ask_batch',
35
+ timestamp: params.timestamp,
36
+ turn_number: batch.turnNumber,
37
+ batch_id: batch.batchId,
38
+ source: batch.source,
39
+ lifecycle: batch.lifecycle,
40
+ source_tool: batch.sourceTool,
41
+ ...(batch.toolUseId ? { tool_use_id: batch.toolUseId } : {}),
42
+ question_count: batch.questions.length,
43
+ ...(batch.lifecycle === 'live' ? { resolved: batch.resolution !== null } : {}),
44
+ }));
45
+ }
@@ -0,0 +1,4 @@
1
+ import type { Agent, AgentOptions } from './types.js';
2
+ import { type VerboseSink } from '../reporters/verbose-emitter.js';
3
+ export declare function __setVerboseSinkForTesting(sink: VerboseSink | null): void;
4
+ export declare function createAgent(opts: AgentOptions): Promise<Agent>;