@cursor/july 0.1.16 → 0.1.18

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 (273) hide show
  1. package/README.md +9 -4
  2. package/dist/bin/agent-serve.js +60 -2
  3. package/dist/channels/slack/api.d.ts.map +1 -1
  4. package/dist/channels/slack/api.js +13 -3
  5. package/dist/channels/slack/auth.d.ts +7 -1
  6. package/dist/channels/slack/auth.d.ts.map +1 -1
  7. package/dist/channels/slack/auth.js +14 -0
  8. package/dist/channels/slack/blocks.d.ts +61 -0
  9. package/dist/channels/slack/blocks.d.ts.map +1 -0
  10. package/dist/channels/slack/blocks.js +90 -0
  11. package/dist/channels/slack/cursor-account.d.ts.map +1 -1
  12. package/dist/channels/slack/cursor-account.js +1 -1
  13. package/dist/channels/slack/defaults.d.ts +2 -0
  14. package/dist/channels/slack/defaults.d.ts.map +1 -1
  15. package/dist/channels/slack/defaults.js +29 -3
  16. package/dist/channels/slack/dispatch.d.ts +3 -17
  17. package/dist/channels/slack/dispatch.d.ts.map +1 -1
  18. package/dist/channels/slack/dispatch.js +4 -1
  19. package/dist/channels/slack/inbound.d.ts.map +1 -1
  20. package/dist/channels/slack/inbound.js +6 -1
  21. package/dist/channels/slack/index.d.ts +2 -0
  22. package/dist/channels/slack/index.d.ts.map +1 -1
  23. package/dist/channels/slack/index.js +2 -0
  24. package/dist/channels/slack/init.d.ts.map +1 -1
  25. package/dist/channels/slack/init.js +4 -1
  26. package/dist/channels/slack/interactive.d.ts +39 -3
  27. package/dist/channels/slack/interactive.d.ts.map +1 -1
  28. package/dist/channels/slack/interactive.js +153 -7
  29. package/dist/channels/slack/manifest.d.ts +13 -0
  30. package/dist/channels/slack/manifest.d.ts.map +1 -1
  31. package/dist/channels/slack/manifest.js +36 -14
  32. package/dist/channels/slack/message-body.d.ts +13 -0
  33. package/dist/channels/slack/message-body.d.ts.map +1 -0
  34. package/dist/channels/slack/message-body.js +82 -0
  35. package/dist/channels/slack/setup.d.ts +4 -1
  36. package/dist/channels/slack/setup.d.ts.map +1 -1
  37. package/dist/channels/slack/setup.js +16 -2
  38. package/dist/channels/slack/slack-channel.d.ts.map +1 -1
  39. package/dist/channels/slack/slack-channel.js +24 -3
  40. package/dist/channels/slack/thread-context.d.ts +0 -2
  41. package/dist/channels/slack/thread-context.d.ts.map +1 -1
  42. package/dist/channels/slack/thread-context.js +1 -65
  43. package/dist/channels/slack/types.d.ts +93 -1
  44. package/dist/channels/slack/types.d.ts.map +1 -1
  45. package/dist/connections.d.ts +4 -1
  46. package/dist/connections.d.ts.map +1 -1
  47. package/dist/connections.js +4 -1
  48. package/dist/docs/404.html +2 -2
  49. package/dist/docs/ab.html +3 -3
  50. package/dist/docs/assets/{app.DjHC-Ggf.js → app.BR5EdVSq.js} +1 -1
  51. package/dist/docs/assets/chunks/@localSearchIndexroot.BOzkeUi8.js +1 -0
  52. package/dist/docs/assets/chunks/{VPLocalSearchBox.DwviwmIq.js → VPLocalSearchBox.CNCzfUKC.js} +1 -1
  53. package/dist/docs/assets/chunks/{theme.BIpeYSon.js → theme.CwKvMSWv.js} +2 -2
  54. package/dist/docs/assets/{example-agents_security-reviewer.md.BZSNycMf.js → example-agents_security-reviewer.md.Dhj_m7_B.js} +1 -1
  55. package/dist/docs/assets/{guides_mcp-oauth.md.DqmEOQY1.js → guides_mcp-oauth.md.Dd8EgSem.js} +3 -2
  56. package/dist/docs/assets/{guides_mcp-oauth.md.DqmEOQY1.lean.js → guides_mcp-oauth.md.Dd8EgSem.lean.js} +1 -1
  57. package/dist/docs/assets/{guides_slack.md.FWale6Ip.js → guides_slack.md.D_xFKlnF.js} +1 -1
  58. package/dist/docs/assets/{reference_connections.md.CsSr3rDz.js → reference_connections.md.B9Q3TOve.js} +12 -5
  59. package/dist/docs/assets/{reference_connections.md.CsSr3rDz.lean.js → reference_connections.md.B9Q3TOve.lean.js} +1 -1
  60. package/dist/docs/building-with-agents.html +3 -3
  61. package/dist/docs/concepts.html +3 -3
  62. package/dist/docs/deployment.html +3 -3
  63. package/dist/docs/evals.html +3 -3
  64. package/dist/docs/example-agents/approval-buddy.html +3 -3
  65. package/dist/docs/example-agents/benny.html +3 -3
  66. package/dist/docs/example-agents/bugbot.html +3 -3
  67. package/dist/docs/example-agents/codebase-wiki.html +3 -3
  68. package/dist/docs/example-agents/codeowners-review.html +3 -3
  69. package/dist/docs/example-agents/concierge.html +3 -3
  70. package/dist/docs/example-agents/fsd.html +3 -3
  71. package/dist/docs/example-agents/index.html +3 -3
  72. package/dist/docs/example-agents/knowledge-base.html +3 -3
  73. package/dist/docs/example-agents/oncall.html +3 -3
  74. package/dist/docs/example-agents/security-reviewer.html +5 -5
  75. package/dist/docs/example-agents/slack-agent.html +3 -3
  76. package/dist/docs/example-agents/weather-agent.html +3 -3
  77. package/dist/docs/guides/agent-to-agent.html +3 -3
  78. package/dist/docs/guides/cloud-runtime.html +3 -3
  79. package/dist/docs/guides/github.html +3 -3
  80. package/dist/docs/guides/human-in-the-loop.html +3 -3
  81. package/dist/docs/guides/mcp-oauth.html +6 -5
  82. package/dist/docs/guides/slack.html +5 -5
  83. package/dist/docs/guides/webhooks.html +3 -3
  84. package/dist/docs/hashmap.json +1 -1
  85. package/dist/docs/hillclimbing.html +3 -3
  86. package/dist/docs/index.html +3 -3
  87. package/dist/docs/quickstart.html +3 -3
  88. package/dist/docs/reference/agent-config.html +3 -3
  89. package/dist/docs/reference/channels.html +3 -3
  90. package/dist/docs/reference/cli.html +3 -3
  91. package/dist/docs/reference/connections.html +14 -7
  92. package/dist/docs/reference/hooks.html +3 -3
  93. package/dist/docs/reference/http-api.html +3 -3
  94. package/dist/docs/reference/instructions.html +3 -3
  95. package/dist/docs/reference/playground.html +3 -3
  96. package/dist/docs/reference/project-layout.html +3 -3
  97. package/dist/docs/reference/prompt.html +3 -3
  98. package/dist/docs/reference/schedules.html +3 -3
  99. package/dist/docs/reference/sessions.html +3 -3
  100. package/dist/docs/reference/skills.html +3 -3
  101. package/dist/docs/reference/subagents.html +3 -3
  102. package/dist/docs/reference/tools.html +3 -3
  103. package/dist/docs/scaffolding-agents.html +3 -3
  104. package/dist/docs/storage.html +3 -3
  105. package/dist/docs/troubleshooting.html +3 -3
  106. package/dist/evals/assertions.d.ts +190 -0
  107. package/dist/evals/assertions.d.ts.map +1 -0
  108. package/dist/evals/assertions.js +461 -0
  109. package/dist/evals/expect.d.ts +95 -0
  110. package/dist/evals/expect.d.ts.map +1 -0
  111. package/dist/evals/expect.js +194 -0
  112. package/dist/evals/judge.d.ts +133 -0
  113. package/dist/evals/judge.d.ts.map +1 -0
  114. package/dist/evals/judge.js +228 -0
  115. package/dist/evals/loaders.d.ts +51 -0
  116. package/dist/evals/loaders.d.ts.map +1 -0
  117. package/dist/evals/loaders.js +124 -0
  118. package/dist/evals/matchers.d.ts +95 -0
  119. package/dist/evals/matchers.d.ts.map +1 -0
  120. package/dist/evals/matchers.js +145 -0
  121. package/dist/evals/reporters.d.ts +70 -0
  122. package/dist/evals/reporters.d.ts.map +1 -0
  123. package/dist/evals/reporters.js +221 -0
  124. package/dist/evals/results.d.ts +103 -0
  125. package/dist/evals/results.d.ts.map +1 -0
  126. package/dist/evals/results.js +28 -0
  127. package/dist/evals/run-facts.d.ts +77 -0
  128. package/dist/evals/run-facts.d.ts.map +1 -0
  129. package/dist/evals/run-facts.js +187 -0
  130. package/dist/evals.d.ts +118 -31
  131. package/dist/evals.d.ts.map +1 -1
  132. package/dist/evals.js +46 -12
  133. package/dist/index.d.ts +1 -1
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +1 -1
  136. package/dist/internal/builtin-tools/index.d.ts +10 -0
  137. package/dist/internal/builtin-tools/index.d.ts.map +1 -0
  138. package/dist/internal/builtin-tools/index.js +27 -0
  139. package/dist/internal/builtin-tools/reminders.d.ts +9 -0
  140. package/dist/internal/builtin-tools/reminders.d.ts.map +1 -0
  141. package/dist/internal/builtin-tools/reminders.js +138 -0
  142. package/dist/internal/cli-ax.d.ts +27 -0
  143. package/dist/internal/cli-ax.d.ts.map +1 -1
  144. package/dist/internal/cli-ax.js +90 -12
  145. package/dist/internal/cli-mcp.d.ts +8 -0
  146. package/dist/internal/cli-mcp.d.ts.map +1 -1
  147. package/dist/internal/cli-mcp.js +98 -0
  148. package/dist/internal/cli-slack.d.ts +29 -1
  149. package/dist/internal/cli-slack.d.ts.map +1 -1
  150. package/dist/internal/cli-slack.js +799 -13
  151. package/dist/internal/cursor-event-relay.d.ts +30 -0
  152. package/dist/internal/cursor-event-relay.d.ts.map +1 -1
  153. package/dist/internal/cursor-event-relay.js +37 -0
  154. package/dist/internal/deploy-client.d.ts +7 -0
  155. package/dist/internal/deploy-client.d.ts.map +1 -1
  156. package/dist/internal/deploy-client.js +9 -0
  157. package/dist/internal/discovery.d.ts.map +1 -1
  158. package/dist/internal/discovery.js +70 -9
  159. package/dist/internal/distribution.d.ts.map +1 -1
  160. package/dist/internal/distribution.js +2 -0
  161. package/dist/internal/eval-judge-model.d.ts +59 -0
  162. package/dist/internal/eval-judge-model.d.ts.map +1 -0
  163. package/dist/internal/eval-judge-model.js +131 -0
  164. package/dist/internal/eval-run-store.d.ts.map +1 -1
  165. package/dist/internal/eval-run-store.js +12 -20
  166. package/dist/internal/eval-runner.d.ts +31 -25
  167. package/dist/internal/eval-runner.d.ts.map +1 -1
  168. package/dist/internal/eval-runner.js +329 -126
  169. package/dist/internal/evals-client.d.ts.map +1 -1
  170. package/dist/internal/evals-client.js +4 -1
  171. package/dist/internal/local-env.d.ts +8 -0
  172. package/dist/internal/local-env.d.ts.map +1 -0
  173. package/dist/internal/local-env.js +47 -0
  174. package/dist/internal/playground/static.d.ts +3 -0
  175. package/dist/internal/playground/static.d.ts.map +1 -1
  176. package/dist/internal/playground/static.js +3 -0
  177. package/dist/internal/reminder-runner.d.ts +7 -0
  178. package/dist/internal/reminder-runner.d.ts.map +1 -1
  179. package/dist/internal/reminder-runner.js +21 -0
  180. package/dist/internal/run-client.d.ts +15 -0
  181. package/dist/internal/run-client.d.ts.map +1 -1
  182. package/dist/internal/run-client.js +3 -2
  183. package/dist/internal/sdk-runner.d.ts +51 -1
  184. package/dist/internal/sdk-runner.d.ts.map +1 -1
  185. package/dist/internal/sdk-runner.js +176 -36
  186. package/dist/internal/server.d.ts.map +1 -1
  187. package/dist/internal/server.js +11 -1
  188. package/dist/internal/session-engine.d.ts +18 -5
  189. package/dist/internal/session-engine.d.ts.map +1 -1
  190. package/dist/internal/session-engine.js +81 -19
  191. package/dist/internal/slack-provision-client.d.ts +133 -0
  192. package/dist/internal/slack-provision-client.d.ts.map +1 -0
  193. package/dist/internal/slack-provision-client.js +286 -0
  194. package/dist/playground/assets/cursor-icons-16-f_W_ogc-.woff2 +0 -0
  195. package/dist/playground/assets/index-DRjS5klQ.js +85 -0
  196. package/dist/playground/assets/index-TCDs-UhZ.css +1 -0
  197. package/dist/playground/index.html +2 -2
  198. package/dist/types.d.ts +98 -4
  199. package/dist/types.d.ts.map +1 -1
  200. package/dist/types.js +26 -0
  201. package/docs/example-agents/security-reviewer.md +1 -1
  202. package/docs/guides/mcp-oauth.md +10 -5
  203. package/docs/guides/slack.md +3 -2
  204. package/docs/reference/connections.md +28 -18
  205. package/package.json +20 -2
  206. package/skills/create-agent/SKILL.md +15 -7
  207. package/skills/debug/SKILL.md +3 -1
  208. package/skills/mcp-auth/SKILL.md +1 -1
  209. package/skills/setup-slack/SKILL.md +177 -11
  210. package/src/bin/agent-serve.ts +63 -2
  211. package/src/channels/slack/api.ts +16 -3
  212. package/src/channels/slack/auth.ts +16 -1
  213. package/src/channels/slack/blocks.ts +139 -0
  214. package/src/channels/slack/cursor-account.ts +1 -0
  215. package/src/channels/slack/defaults.ts +32 -4
  216. package/src/channels/slack/dispatch.ts +6 -19
  217. package/src/channels/slack/inbound.ts +6 -1
  218. package/src/channels/slack/index.ts +2 -0
  219. package/src/channels/slack/init.ts +3 -0
  220. package/src/channels/slack/interactive.ts +184 -19
  221. package/src/channels/slack/manifest.ts +37 -6
  222. package/src/channels/slack/message-body.ts +90 -0
  223. package/src/channels/slack/setup.ts +16 -2
  224. package/src/channels/slack/slack-channel.ts +37 -6
  225. package/src/channels/slack/thread-context.ts +1 -69
  226. package/src/channels/slack/types.ts +105 -1
  227. package/src/connections.ts +4 -1
  228. package/src/evals/assertions.ts +704 -0
  229. package/src/evals/expect.ts +272 -0
  230. package/src/evals/judge.ts +346 -0
  231. package/src/evals/loaders.ts +113 -0
  232. package/src/evals/matchers.ts +246 -0
  233. package/src/evals/reporters.ts +274 -0
  234. package/src/evals/results.ts +132 -0
  235. package/src/evals/run-facts.ts +274 -0
  236. package/src/evals.ts +205 -42
  237. package/src/index.ts +2 -0
  238. package/src/internal/builtin-tools/index.ts +40 -0
  239. package/src/internal/builtin-tools/reminders.ts +158 -0
  240. package/src/internal/cli-ax.ts +134 -15
  241. package/src/internal/cli-mcp.ts +118 -5
  242. package/src/internal/cli-slack.ts +1017 -15
  243. package/src/internal/cursor-event-relay.ts +67 -0
  244. package/src/internal/deploy-client.ts +10 -0
  245. package/src/internal/discovery.ts +83 -5
  246. package/src/internal/distribution.ts +2 -0
  247. package/src/internal/eval-judge-model.ts +148 -0
  248. package/src/internal/eval-run-store.ts +10 -14
  249. package/src/internal/eval-runner.ts +460 -214
  250. package/src/internal/evals-client.ts +5 -0
  251. package/src/internal/local-env.ts +53 -0
  252. package/src/internal/playground/static.ts +3 -0
  253. package/src/internal/reminder-runner.ts +30 -0
  254. package/src/internal/run-client.ts +17 -1
  255. package/src/internal/sdk-runner.ts +234 -35
  256. package/src/internal/server.ts +12 -0
  257. package/src/internal/session-engine.ts +103 -21
  258. package/src/internal/slack-provision-client.ts +442 -0
  259. package/src/types.ts +125 -4
  260. package/dist/channels/slack/post-update-delivery.d.ts +0 -85
  261. package/dist/channels/slack/post-update-delivery.d.ts.map +0 -1
  262. package/dist/docs/assets/chunks/@localSearchIndexroot.DZtu0ZIc.js +0 -1
  263. package/dist/internal/json-dir-store.d.ts +0 -32
  264. package/dist/internal/json-dir-store.d.ts.map +0 -1
  265. package/dist/internal/persistence-coordinator.d.ts +0 -127
  266. package/dist/internal/persistence-coordinator.d.ts.map +0 -1
  267. package/dist/persistence.d.ts +0 -184
  268. package/dist/persistence.d.ts.map +0 -1
  269. package/dist/playground/assets/cursor-icons-16-CQ50JpfO.woff2 +0 -0
  270. package/dist/playground/assets/index-Bwl4Onx4.js +0 -85
  271. package/dist/playground/assets/index-ByV4nfch.css +0 -1
  272. /package/dist/docs/assets/{example-agents_security-reviewer.md.BZSNycMf.lean.js → example-agents_security-reviewer.md.Dhj_m7_B.lean.js} +0 -0
  273. /package/dist/docs/assets/{guides_slack.md.FWale6Ip.lean.js → guides_slack.md.D_xFKlnF.lean.js} +0 -0
@@ -13,13 +13,44 @@ import { readdir } from "node:fs/promises";
13
13
  import { join, relative, resolve } from "node:path";
14
14
  import { pathToFileURL } from "node:url";
15
15
  import type {
16
- EvalAssertionResult,
16
+ EvalAssertionHandle,
17
+ EvalAssertions,
18
+ } from "../evals/assertions.js";
19
+ import {
20
+ computeVerdict,
21
+ createAssertions,
22
+ EvalAssertionRecorder,
23
+ EvalRequireFailure,
24
+ EvalSkipSignal,
25
+ } from "../evals/assertions.js";
26
+ import { evaluateExpectation } from "../evals/expect.js";
27
+ import type {
28
+ EvalJudge,
29
+ EvalJudgeCaller,
30
+ EvalJudgeCallOptions,
31
+ EvalJudgeConfig,
32
+ EvalJudgeGrader,
33
+ } from "../evals/judge.js";
34
+ import {
35
+ EVAL_JUDGE_GRADERS,
36
+ EvalJudgeUnavailableError,
37
+ renderSubmission,
38
+ } from "../evals/judge.js";
39
+ import { EVAL_ROOT_ENV } from "../evals/loaders.js";
40
+ import { combineReporters } from "../evals/reporters.js";
41
+ import { summarizeEvalResults } from "../evals/results.js";
42
+ import type {
17
43
  EvalCaseDefinition,
18
44
  EvalConfigFile,
19
45
  EvalDefinition,
46
+ EvalReporter,
47
+ EvalReporterTarget,
48
+ EvalRunResult,
49
+ EvalRunSummary,
20
50
  EvalSendOptions,
21
51
  EvalTestContext,
22
52
  EvalTurnResult,
53
+ EvalVerdict,
23
54
  Expectation,
24
55
  } from "../evals.js";
25
56
  import {
@@ -30,8 +61,13 @@ import {
30
61
  matchesEvalIdFilter,
31
62
  normalizeEvalMaxConcurrency,
32
63
  } from "../evals.js";
33
- import type { SessionEvent } from "../types.js";
64
+ import type { ModelSetting, SessionEvent } from "../types.js";
34
65
  import { isDefinitionOfKind } from "./brand.js";
66
+ import {
67
+ callJudgeModel,
68
+ EVAL_JUDGE_MODEL_ENV,
69
+ resolveJudgeModel,
70
+ } from "./eval-judge-model.js";
35
71
  import { mapPool } from "./map-pool.js";
36
72
  import { RunSessionTimeoutError, runSession } from "./run-client.js";
37
73
  import { buildTrajectory } from "./trajectory.js";
@@ -45,30 +81,7 @@ export interface DiscoveredEval {
45
81
  definition: EvalCaseDefinition;
46
82
  }
47
83
 
48
- export interface EvalRunResult {
49
- id: string;
50
- path: string;
51
- description?: string;
52
- ok: boolean;
53
- assertions: EvalAssertionResult[];
54
- sessionId?: string;
55
- /** Messages passed to `t.send` (eval inputs). */
56
- inputs: string[];
57
- finalText?: string;
58
- tools?: string[];
59
- /** Tool calls with args/results from the trajectory. */
60
- toolCalls?: Array<{
61
- toolName: string;
62
- args?: unknown;
63
- output?: unknown;
64
- isError: boolean;
65
- }>;
66
- error?: string;
67
- logs: string[];
68
- /** Structured scores from {@link import("../evals.js").EvalTestContext.metric}. */
69
- metrics: Record<string, string | number>;
70
- durationMs: number;
71
- }
84
+ export type { EvalRunResult } from "../evals.js";
72
85
 
73
86
  export interface EvalSelectionOptions {
74
87
  filterIds?: string[];
@@ -79,6 +92,21 @@ export interface RunEvalsOptions extends EvalSelectionOptions {
79
92
  projectRoot: string;
80
93
  baseUrl: string;
81
94
  timeoutMs?: number;
95
+ /** Override `evals.config.ts` `maxConcurrency` (CLI `--max-concurrency`). */
96
+ maxConcurrency?: number;
97
+ /**
98
+ * Reporters attached by the caller (CLI `--junit` / `--artifacts`), in
99
+ * addition to the ones declared in `evals.config.ts` and on each eval.
100
+ */
101
+ reporters?: readonly EvalReporter[];
102
+ /** Ignore reporters declared in config and eval files (`--skip-report`). */
103
+ skipReport?: boolean;
104
+ /** Reported to reporters so a destination can label the run. */
105
+ target?: EvalReporterTarget;
106
+ /** Treat soft threshold misses as failures when summarizing. */
107
+ strict?: boolean;
108
+ /** Injected judge model call; defaults to the Cursor SDK caller. */
109
+ judgeCaller?: EvalJudgeCaller;
82
110
  bearerToken?: string;
83
111
  /** Extra request headers (e.g. hosted engineAccess). */
84
112
  headers?: Record<string, string>;
@@ -155,6 +183,11 @@ export async function discoverEvals(
155
183
  const evals: DiscoveredEval[] = [];
156
184
  let config: Partial<EvalConfigFile> = {};
157
185
 
186
+ // Fixture loaders resolve relative paths against the app root, so a dataset
187
+ // path reads the same however deep the eval file sits and whatever cwd the
188
+ // CLI ran from.
189
+ process.env[EVAL_ROOT_ENV] = root;
190
+
158
191
  for (const abs of files) {
159
192
  const rel = relative(evalsDir, abs).replace(/\\/g, "/");
160
193
  if (rel === "evals.config.ts" || rel === "evals.config.js") {
@@ -168,16 +201,9 @@ export async function discoverEvals(
168
201
  continue;
169
202
  }
170
203
  const mod = await importModule(abs);
171
- const def = mod.default;
172
- if (!isDefinitionOfKind(def, "eval")) {
173
- throw new Error(`${rel}: default export must be defineEval({ ... })`);
174
- }
175
204
  const fileId = rel.replace(/\.eval\.(ts|js)$/, "").replace(/\/index$/, "");
176
205
  try {
177
- for (const expanded of expandEvalDefinition(
178
- fileId,
179
- def as EvalDefinition
180
- )) {
206
+ for (const expanded of expandEvalModule(fileId, mod.default)) {
181
207
  evals.push({
182
208
  id: expanded.id,
183
209
  fileId,
@@ -194,6 +220,45 @@ export async function discoverEvals(
194
220
  return { evals, config };
195
221
  }
196
222
 
223
+ /**
224
+ * Expand one eval module's default export into runnable datapoints.
225
+ *
226
+ * A file normally exports a single `defineEval(...)`. It may instead export an
227
+ * **array** of them to fan out over a dataset, in which case ids come from the
228
+ * file name plus a zero-padded index in array order (`sql/0000`, `sql/0001`, …).
229
+ * Prefer `cases` when the datapoints are hand-written and deserve stable names;
230
+ * the array form is for generated datasets where the index *is* the name.
231
+ */
232
+ export function expandEvalModule(
233
+ fileId: string,
234
+ defaultExport: unknown
235
+ ): Array<{ id: string; definition: EvalCaseDefinition }> {
236
+ if (Array.isArray(defaultExport)) {
237
+ if (defaultExport.length === 0) {
238
+ throw new Error(
239
+ "default export array is empty; export at least one defineEval({ ... })"
240
+ );
241
+ }
242
+ return defaultExport.flatMap((entry, index) => {
243
+ if (!isDefinitionOfKind(entry, "eval")) {
244
+ throw new Error(
245
+ `default export array entry ${index} must be defineEval({ ... })`
246
+ );
247
+ }
248
+ return expandEvalDefinition(
249
+ `${fileId}/${String(index).padStart(4, "0")}`,
250
+ entry as EvalDefinition
251
+ );
252
+ });
253
+ }
254
+ if (!isDefinitionOfKind(defaultExport, "eval")) {
255
+ throw new Error(
256
+ "default export must be defineEval({ ... }) or an array of them"
257
+ );
258
+ }
259
+ return expandEvalDefinition(fileId, defaultExport as EvalDefinition);
260
+ }
261
+
197
262
  /** Apply id/tag filters used by CLI, playground, and `runDiscoveredEvals`. */
198
263
  export function filterDiscoveredEvals(
199
264
  evals: readonly DiscoveredEval[],
@@ -239,8 +304,18 @@ export async function runDiscoveredEvals(
239
304
  return [];
240
305
  }
241
306
 
242
- const maxConcurrency = resolveEvalMaxConcurrency(config);
307
+ const maxConcurrency =
308
+ options.maxConcurrency === undefined
309
+ ? resolveEvalMaxConcurrency(config)
310
+ : normalizeEvalMaxConcurrency(options.maxConcurrency);
243
311
  const defaultTimeoutMs = options.timeoutMs ?? config.timeoutMs ?? 180_000;
312
+ const reporter = buildReporterHub(options, config, selected);
313
+ const startedAt = new Date().toISOString();
314
+
315
+ await reporter?.runStart(
316
+ selected,
317
+ options.target ?? { baseUrl: options.baseUrl, mode: "local" }
318
+ );
244
319
 
245
320
  // Iterations of the same authored datapoint share one concurrency slot and
246
321
  // run sequentially. maxConcurrency is therefore the max number of distinct
@@ -266,19 +341,103 @@ export async function runDiscoveredEvals(
266
341
  headers: options.headers,
267
342
  verbose: Boolean(options.verbose),
268
343
  signal: options.signal,
344
+ judge: {
345
+ configModel: config.judge?.model,
346
+ caller: options.judgeCaller ?? callJudgeModel,
347
+ },
269
348
  onEvent: (event) => {
270
349
  options.onCaseEvent?.(discovered.id, event);
271
350
  options.onEvent?.(event);
272
351
  },
273
352
  });
274
353
  options.onCaseDone?.(result);
354
+ await reporter?.caseComplete(discovered, result);
275
355
  results.push(result);
276
356
  }
277
357
  return results;
278
358
  },
279
359
  { signal: options.signal }
280
360
  );
281
- return nested.flat();
361
+ const results = nested.flat();
362
+
363
+ await reporter?.runComplete(
364
+ summarizeEvalResults(results, {
365
+ strict: options.strict === true,
366
+ startedAt,
367
+ finishedAt: new Date().toISOString(),
368
+ })
369
+ );
370
+ return results;
371
+ }
372
+
373
+ interface ReporterHub {
374
+ runStart(
375
+ evals: readonly DiscoveredEval[],
376
+ target: EvalReporterTarget
377
+ ): Promise<void>;
378
+ caseComplete(
379
+ discovered: DiscoveredEval,
380
+ result: EvalRunResult
381
+ ): Promise<void>;
382
+ runComplete(summary: EvalRunSummary): Promise<void>;
383
+ }
384
+
385
+ /**
386
+ * Fan results out to the reporters that observe them.
387
+ *
388
+ * Run-wide reporters (CLI flags plus `evals.config.ts`) see every case; an
389
+ * eval's own `reporters` only see that eval. The run lifecycle hooks fire on
390
+ * every reporter in the run, so a per-eval destination still gets its
391
+ * `onRunStart` / `onRunComplete` pair.
392
+ */
393
+ function buildReporterHub(
394
+ options: RunEvalsOptions,
395
+ config: Partial<EvalConfigFile>,
396
+ selected: readonly DiscoveredEval[]
397
+ ): ReporterHub | undefined {
398
+ const skip = options.skipReport === true;
399
+ const runWide = [
400
+ ...(options.reporters ?? []),
401
+ ...(skip ? [] : (config.reporters ?? [])),
402
+ ];
403
+ const perEval = skip
404
+ ? []
405
+ : selected.flatMap((e) => e.definition.reporters ?? []);
406
+ const everyReporter = [...new Set([...runWide, ...perEval])];
407
+ if (everyReporter.length === 0) {
408
+ return undefined;
409
+ }
410
+ const onError = (error: unknown): void => {
411
+ // A broken destination must not fail the eval run itself.
412
+ const detail = error instanceof Error ? error.message : String(error);
413
+ process.stderr.write(`eval reporter error: ${detail}\n`);
414
+ };
415
+ const all = combineReporters(everyReporter, onError);
416
+ return {
417
+ async runStart(evals, target) {
418
+ await all.onRunStart?.(
419
+ evals.map((e) => ({
420
+ id: e.id,
421
+ fileId: e.fileId,
422
+ description: e.definition.description,
423
+ tags: e.definition.tags,
424
+ })),
425
+ target
426
+ );
427
+ },
428
+ async caseComplete(discovered, result) {
429
+ const observers = [
430
+ ...new Set([
431
+ ...runWide,
432
+ ...(skip ? [] : (discovered.definition.reporters ?? [])),
433
+ ]),
434
+ ];
435
+ await combineReporters(observers, onError).onEvalComplete?.(result);
436
+ },
437
+ async runComplete(summary) {
438
+ await all.onRunComplete?.(summary);
439
+ },
440
+ };
282
441
  }
283
442
 
284
443
  /**
@@ -336,6 +495,12 @@ function resolveEvalMaxConcurrency(config: Partial<EvalConfigFile>): number {
336
495
  return normalizeEvalMaxConcurrency(config.maxConcurrency);
337
496
  }
338
497
 
498
+ interface RunOneEvalJudgeOptions {
499
+ /** Judge model from `evals.config.ts`. */
500
+ configModel?: ModelSetting;
501
+ caller: EvalJudgeCaller;
502
+ }
503
+
339
504
  async function runOneEval(
340
505
  discovered: DiscoveredEval,
341
506
  opts: {
@@ -344,50 +509,29 @@ async function runOneEval(
344
509
  bearerToken?: string;
345
510
  headers?: Record<string, string>;
346
511
  verbose: boolean;
512
+ judge: RunOneEvalJudgeOptions;
347
513
  onEvent?: (event: SessionEvent) => void;
348
514
  signal?: AbortSignal;
349
515
  }
350
516
  ): Promise<EvalRunResult> {
351
517
  const logs: string[] = [];
352
518
  const metrics: Record<string, string | number> = {};
353
- const assertions: EvalAssertionResult[] = [];
519
+ const recorder = new EvalAssertionRecorder();
354
520
  const def = discovered.definition;
355
521
  const timeoutMs = def.timeoutMs ?? opts.defaultTimeoutMs;
356
522
  const startedAt = Date.now();
357
523
 
358
524
  let sessionId: string | undefined;
359
525
  let continuationToken: string | undefined;
526
+ // The session stream replays from an index and the client stops at the first
527
+ // terminal event, so each send must resume after the previous turn's last
528
+ // event or it would re-read that turn instead of the new one.
529
+ let nextEventIndex = 0;
360
530
  const allEvents: SessionEvent[] = [];
361
531
  const inputs: string[] = [];
532
+ const turns: EvalTurnResult[] = [];
362
533
  let reply: string | null = null;
363
534
 
364
- if (opts.signal?.aborted) {
365
- return {
366
- id: discovered.id,
367
- path: discovered.path,
368
- ...(def.description === undefined
369
- ? {}
370
- : { description: def.description }),
371
- ok: false,
372
- assertions,
373
- error: "cancelled",
374
- logs,
375
- metrics,
376
- inputs,
377
- toolCalls: [],
378
- tools: [],
379
- durationMs: Date.now() - startedAt,
380
- };
381
- }
382
-
383
- const record = (name: string, passed: boolean, detail?: string): void => {
384
- assertions.push({
385
- name,
386
- passed,
387
- ...(detail === undefined ? {} : { detail }),
388
- });
389
- };
390
-
391
535
  const toolsUsed = (): string[] =>
392
536
  buildTrajectory(allEvents).turns.flatMap((t) =>
393
537
  t.toolCalls.map((c) => c.toolName)
@@ -403,7 +547,69 @@ async function runOneEval(
403
547
  }))
404
548
  );
405
549
 
550
+ const finish = (extra: {
551
+ verdict: EvalVerdict;
552
+ ok: boolean;
553
+ error?: string;
554
+ skipReason?: string;
555
+ finalText?: string;
556
+ }): EvalRunResult => ({
557
+ id: discovered.id,
558
+ path: discovered.path,
559
+ ...(def.description === undefined ? {} : { description: def.description }),
560
+ ok: extra.ok,
561
+ verdict: extra.verdict,
562
+ skipReason: extra.skipReason,
563
+ assertions: recorder.results(),
564
+ error: extra.error,
565
+ logs,
566
+ metrics,
567
+ metadata: def.metadata,
568
+ tags: def.tags,
569
+ inputs,
570
+ toolCalls: toolCallIo(),
571
+ ...(sessionId === undefined ? {} : { sessionId }),
572
+ finalText: extra.finalText,
573
+ tools: toolsUsed(),
574
+ durationMs: Date.now() - startedAt,
575
+ });
576
+
577
+ if (opts.signal?.aborted) {
578
+ return finish({ verdict: "failed", ok: false, error: "cancelled" });
579
+ }
580
+
581
+ // A judge that cannot reach a model must not look like a quality regression:
582
+ // the case is skipped visibly instead.
583
+ let judgeUnavailable: string | undefined;
584
+ const timeout = new AbortController();
585
+ const timer = setTimeout(() => timeout.abort(), clampTimerDelay(timeoutMs));
586
+ // A pending case timer must not hold the process open on its own.
587
+ timer.unref?.();
588
+
589
+ const runAssertions: EvalAssertions = createAssertions({
590
+ recorder,
591
+ events: () => allEvents,
592
+ });
593
+
594
+ const judge = createJudgeSurface({
595
+ recorder,
596
+ grader: (name) => EVAL_JUDGE_GRADERS[name],
597
+ resolveModel: (callModel) =>
598
+ resolveJudgeModel({
599
+ call: callModel,
600
+ evalLevel: def.judge?.model,
601
+ config: opts.judge.configModel,
602
+ env: process.env[EVAL_JUDGE_MODEL_ENV],
603
+ }),
604
+ caller: opts.judge.caller,
605
+ defaultValue: () => reply,
606
+ onUnavailable: (message) => {
607
+ judgeUnavailable = judgeUnavailable ?? message;
608
+ },
609
+ });
610
+
406
611
  const t: EvalTestContext = {
612
+ ...runAssertions,
407
613
  get reply() {
408
614
  return reply;
409
615
  },
@@ -413,12 +619,19 @@ async function runOneEval(
413
619
  get events() {
414
620
  return allEvents;
415
621
  },
622
+ get turns() {
623
+ return turns;
624
+ },
416
625
  get iteration() {
417
626
  return def.iteration ?? 1;
418
627
  },
419
628
  get iterations() {
420
629
  return def.iterations ?? 1;
421
630
  },
631
+ get signal() {
632
+ return timeout.signal;
633
+ },
634
+ judge,
422
635
  async send(
423
636
  message: string,
424
637
  options: EvalSendOptions = {}
@@ -429,6 +642,7 @@ async function runOneEval(
429
642
  messages: [message],
430
643
  sessionId,
431
644
  continuationToken,
645
+ startIndex: nextEventIndex,
432
646
  // Keep defineEval traffic out of live defineAB enrollment/metrics.
433
647
  purpose: "eval",
434
648
  bearerToken: opts.bearerToken,
@@ -442,57 +656,57 @@ async function runOneEval(
442
656
  });
443
657
  sessionId = result.sessionId;
444
658
  continuationToken = result.continuationToken;
659
+ nextEventIndex = result.nextEventIndex ?? nextEventIndex;
445
660
  allEvents.push(...result.events);
446
661
  if (result.trajectory.finalText !== "") {
447
662
  reply = result.trajectory.finalText;
448
663
  }
449
- return {
664
+ const index = turns.length + 1;
665
+ // The turn is immutable, so its assertions read a frozen event slice
666
+ // even after later turns append to the run.
667
+ const turnEvents = [...result.events];
668
+ const turn: EvalTurnResult = {
669
+ ...createAssertions({
670
+ recorder,
671
+ events: () => turnEvents,
672
+ scope: `turn[${index}]`,
673
+ }),
450
674
  message: result.trajectory.finalText,
451
675
  sessionId: result.sessionId,
452
- events: result.events,
676
+ events: turnEvents,
453
677
  toolCalls: result.trajectory.turns.flatMap((turn) =>
454
678
  turn.toolCalls.map((c) => c.toolName)
455
679
  ),
456
680
  ok: result.ok,
681
+ index,
682
+ expectOk() {
683
+ if (!result.ok) {
684
+ throw new Error(
685
+ `turn[${index}] failed: ${result.trajectory.turns.find((x) => x.failed)?.error ?? "unknown error"}`
686
+ );
687
+ }
688
+ return turn;
689
+ },
457
690
  };
691
+ turns.push(turn);
692
+ return turn;
458
693
  },
459
- succeeded() {
460
- const traj = buildTrajectory(allEvents);
461
- record(
462
- "succeeded",
463
- traj.ok && traj.turns.length > 0,
464
- traj.ok ? undefined : "turn failed"
465
- );
466
- },
467
- calledTool(name: string) {
468
- const tools = toolsUsed();
469
- record(
470
- `calledTool(${name})`,
471
- tools.includes(name),
472
- tools.includes(name) ? undefined : `got [${tools.join(", ")}]`
473
- );
474
- },
475
- notCalledTool(name: string) {
476
- const tools = toolsUsed();
477
- record(
478
- `notCalledTool(${name})`,
479
- !tools.includes(name),
480
- tools.includes(name) ? "tool was called" : undefined
481
- );
482
- },
483
- messageIncludes(token: string | RegExp) {
484
- const text = reply ?? "";
485
- const passed =
486
- typeof token === "string" ? text.includes(token) : token.test(text);
487
- record(
488
- `messageIncludes(${String(token)})`,
489
- passed,
490
- passed ? undefined : `reply=${JSON.stringify(text.slice(0, 120))}`
491
- );
694
+ async require<T>(value: T, assertion: Expectation): Promise<T> {
695
+ const outcome = evaluateExpectation(value, assertion);
696
+ recorder.record({
697
+ name: `require(${assertion.kind})`,
698
+ passed: outcome.passed,
699
+ detail: outcome.detail,
700
+ score: outcome.score,
701
+ severity: "gate",
702
+ });
703
+ if (!outcome.passed) {
704
+ throw new EvalRequireFailure(`require(${assertion.kind})`);
705
+ }
706
+ return value;
492
707
  },
493
- check(value: unknown, assertion: Expectation) {
494
- const { passed, detail } = matchExpectation(value, assertion);
495
- record(`check(${assertion.kind})`, passed, detail);
708
+ skip(reason: string): never {
709
+ throw new EvalSkipSignal(reason);
496
710
  },
497
711
  log(message: string) {
498
712
  logs.push(message);
@@ -515,129 +729,161 @@ async function runOneEval(
515
729
  try {
516
730
  await def.test(t);
517
731
  } catch (error) {
518
- const message = error instanceof Error ? error.message : String(error);
519
- if (error instanceof RunSessionTimeoutError && sessionId === undefined) {
520
- sessionId = error.sessionId;
732
+ if (error instanceof EvalSkipSignal) {
733
+ clearTimeout(timer);
734
+ return finish({
735
+ verdict: "skipped",
736
+ ok: true,
737
+ skipReason: error.reason,
738
+ finalText: reply ?? undefined,
739
+ });
740
+ }
741
+ if (!(error instanceof EvalRequireFailure)) {
742
+ const message = error instanceof Error ? error.message : String(error);
743
+ if (error instanceof RunSessionTimeoutError && sessionId === undefined) {
744
+ sessionId = error.sessionId;
745
+ }
746
+ await recorder.waitForPending().catch(() => undefined);
747
+ clearTimeout(timer);
748
+ return finish({
749
+ verdict: "failed",
750
+ ok: false,
751
+ error: message,
752
+ finalText: reply ?? undefined,
753
+ });
521
754
  }
522
- return {
523
- id: discovered.id,
524
- path: discovered.path,
525
- ...(def.description === undefined
526
- ? {}
527
- : { description: def.description }),
528
- ok: false,
529
- assertions,
530
- error: message,
531
- logs,
532
- metrics,
533
- inputs,
534
- toolCalls: toolCallIo(),
535
- ...(sessionId === undefined ? {} : { sessionId }),
536
- ...(reply === null ? {} : { finalText: reply }),
537
- tools: toolsUsed(),
538
- durationMs: Date.now() - startedAt,
539
- };
755
+ // `require` already recorded the failing gate; fall through so the verdict
756
+ // comes from the assertions rather than a duplicate execution error.
540
757
  }
541
758
 
759
+ await recorder.waitForPending();
760
+ clearTimeout(timer);
761
+
762
+ const assertions = recorder.results();
542
763
  const traj = buildTrajectory(allEvents);
543
- const ok =
764
+ // With no assertions at all, keep the historical fallback: a case that just
765
+ // drives the agent passes when the run itself succeeded.
766
+ const verdict: EvalVerdict =
544
767
  assertions.length > 0
545
- ? assertions.every((a) => a.passed)
546
- : traj.ok && traj.turns.length > 0;
768
+ ? computeVerdict(assertions)
769
+ : traj.ok && traj.turns.length > 0
770
+ ? "passed"
771
+ : "failed";
772
+ const finalText = reply ?? traj.finalText;
547
773
 
548
- return {
549
- id: discovered.id,
550
- path: discovered.path,
551
- ...(def.description === undefined ? {} : { description: def.description }),
552
- ok,
553
- assertions,
554
- logs,
555
- metrics,
556
- inputs,
557
- toolCalls: toolCallIo(),
558
- ...(sessionId === undefined ? {} : { sessionId }),
559
- finalText: reply ?? traj.finalText,
560
- tools: toolsUsed(),
561
- durationMs: Date.now() - startedAt,
562
- };
774
+ // An unreachable judge means the *judged* signal is unknown, so the case is
775
+ // reported as skipped rather than as a quality regression. It must not also
776
+ // bury a deterministic gate that already failed: skipping a failed case would
777
+ // turn a red eval green on any machine that happens to lack credentials.
778
+ if (judgeUnavailable !== undefined && verdict !== "failed") {
779
+ logs.push(`judge skipped: ${judgeUnavailable}`);
780
+ return finish({
781
+ verdict: "skipped",
782
+ ok: true,
783
+ skipReason: judgeUnavailable,
784
+ finalText,
785
+ });
786
+ }
787
+ if (judgeUnavailable !== undefined) {
788
+ logs.push(
789
+ `judge unavailable (${judgeUnavailable}), but a gate already failed — reporting the failure`
790
+ );
791
+ }
792
+
793
+ return finish({
794
+ verdict,
795
+ ok: verdict !== "failed",
796
+ finalText,
797
+ });
563
798
  }
564
799
 
565
- function matchExpectation(
566
- value: unknown,
567
- assertion: Expectation
568
- ): { passed: boolean; detail?: string } {
569
- switch (assertion.kind) {
570
- case "includes": {
571
- const text = value === null || value === undefined ? "" : String(value);
572
- const passed =
573
- typeof assertion.value === "string"
574
- ? text.includes(assertion.value)
575
- : assertion.value.test(text);
576
- return {
577
- passed,
578
- ...(passed
579
- ? {}
580
- : {
581
- detail: `value=${JSON.stringify(text.slice(0, 120))}`,
582
- }),
583
- };
584
- }
585
- case "equals": {
586
- const passed = deepEqual(value, assertion.value);
587
- // Always attach a short detail so values like recall `40.0% (4/10)`
588
- // show up on PASS lines / playground, not only on failure.
589
- const rendered =
590
- typeof value === "string" ? value : JSON.stringify(value);
591
- return {
592
- passed,
593
- detail: passed ? rendered : `got ${rendered}`,
594
- };
800
+ /** Clamp a case timeout to a delay `setTimeout` can represent. */
801
+ function clampTimerDelay(timeoutMs: number): number {
802
+ const MAX_TIMER = 2_147_483_647;
803
+ return Math.min(Math.max(timeoutMs, 0), MAX_TIMER);
804
+ }
805
+
806
+ /**
807
+ * Build `t.judge`. Each grader records its slot immediately and resolves it
808
+ * during finalization, so several judges overlap instead of serializing.
809
+ */
810
+ function createJudgeSurface(args: {
811
+ recorder: EvalAssertionRecorder;
812
+ grader: (name: keyof typeof EVAL_JUDGE_GRADERS) => EvalJudgeGrader;
813
+ resolveModel: (call?: ModelSetting) => ModelSetting | undefined;
814
+ caller: EvalJudgeCaller;
815
+ defaultValue: () => unknown;
816
+ onUnavailable: (message: string) => void;
817
+ }): EvalJudge {
818
+ const grade = (
819
+ graderName: keyof typeof EVAL_JUDGE_GRADERS,
820
+ reference: string,
821
+ options: EvalJudgeCallOptions | undefined
822
+ ): EvalAssertionHandle => {
823
+ const grader = args.grader(graderName);
824
+ const model = args.resolveModel(options?.model);
825
+ const name = `judge.${graderName}(${truncateForName(reference)})`;
826
+ if (model === undefined) {
827
+ // A missing judge model is an authoring error, not a flaky provider.
828
+ return args.recorder.record({
829
+ name,
830
+ passed: false,
831
+ severity: "gate",
832
+ detail:
833
+ "no judge model configured; set judge.model in evals.config.ts, on the eval, or on the call",
834
+ });
595
835
  }
596
- case "satisfies": {
597
- const passed = assertion.predicate(value);
836
+ const submission = renderSubmission(
837
+ options !== undefined && "on" in options
838
+ ? options.on
839
+ : args.defaultValue()
840
+ );
841
+ const settle = (async () => {
842
+ const reply = await args.caller({
843
+ prompt: grader.buildPrompt({ submission, reference }),
844
+ model,
845
+ });
846
+ const result = grader.parse(reply);
598
847
  return {
599
- passed,
600
- ...(passed ? {} : { detail: assertion.label }),
848
+ passed: true,
849
+ score: result.score,
850
+ detail:
851
+ result.rationale === undefined
852
+ ? `${result.choice} (${result.score.toFixed(2)})`
853
+ : `${result.choice} (${result.score.toFixed(2)}) — ${result.rationale}`,
601
854
  };
602
- }
603
- }
855
+ })().catch((error: unknown) => {
856
+ if (error instanceof EvalJudgeUnavailableError) {
857
+ args.onUnavailable(error.message);
858
+ return { passed: true, detail: `skipped: ${error.message}` };
859
+ }
860
+ throw error;
861
+ });
862
+ // Soft by default: a judge is a tracked score until given a bar.
863
+ return args.recorder.recordAsync(
864
+ { name, passed: true, severity: "soft", detail: "grading…" },
865
+ settle
866
+ );
867
+ };
868
+
869
+ return {
870
+ async model(prompt, options) {
871
+ const model = args.resolveModel(options?.model);
872
+ if (model === undefined) {
873
+ throw new Error(
874
+ "t.judge.model: no judge model configured; set judge.model in evals.config.ts, on the eval, or on the call"
875
+ );
876
+ }
877
+ return args.caller({ prompt, model });
878
+ },
879
+ factuality: (expected, options) => grade("factuality", expected, options),
880
+ summarizes: (expected, options) => grade("summarizes", expected, options),
881
+ closedQA: (criteria, options) => grade("closedQA", criteria, options),
882
+ sql: (expected, options) => grade("sql", expected, options),
883
+ };
604
884
  }
605
885
 
606
- function deepEqual(a: unknown, b: unknown): boolean {
607
- if (Object.is(a, b)) {
608
- return true;
609
- }
610
- if (
611
- typeof a !== "object" ||
612
- typeof b !== "object" ||
613
- a === null ||
614
- b === null
615
- ) {
616
- return false;
617
- }
618
- if (Array.isArray(a) !== Array.isArray(b)) {
619
- return false;
620
- }
621
- if (Array.isArray(a) && Array.isArray(b)) {
622
- if (a.length !== b.length) {
623
- return false;
624
- }
625
- return a.every((item, i) => deepEqual(item, b[i]));
626
- }
627
- const aKeys = Object.keys(a as object);
628
- const bKeys = Object.keys(b as object);
629
- if (aKeys.length !== bKeys.length) {
630
- return false;
631
- }
632
- for (const key of aKeys) {
633
- if (
634
- !deepEqual(
635
- (a as Record<string, unknown>)[key],
636
- (b as Record<string, unknown>)[key]
637
- )
638
- ) {
639
- return false;
640
- }
641
- }
642
- return true;
886
+ function truncateForName(text: string): string {
887
+ const oneLine = text.replace(/\s+/g, " ").trim();
888
+ return oneLine.length > 60 ? `${oneLine.slice(0, 59)}…` : oneLine;
643
889
  }