@adonis-agora/agent 0.30.2 → 0.33.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 (240) hide show
  1. package/CHANGELOG.md +866 -0
  2. package/dist/assets/spa/assets/{index-Cfi3g3b2.js → index-3Q2m5_Ax.js} +1 -1
  3. package/dist/assets/spa/index.html +1 -1
  4. package/dist/providers/agent_provider.d.ts.map +1 -1
  5. package/dist/providers/agent_provider.js +157 -9
  6. package/dist/providers/agent_provider.js.map +1 -1
  7. package/dist/src/agent-deps-factory.d.ts +16 -2
  8. package/dist/src/agent-deps-factory.d.ts.map +1 -1
  9. package/dist/src/agent-deps-factory.js +8 -0
  10. package/dist/src/agent-deps-factory.js.map +1 -1
  11. package/dist/src/agent-deps.d.ts +21 -1
  12. package/dist/src/agent-deps.d.ts.map +1 -1
  13. package/dist/src/agent-deps.js.map +1 -1
  14. package/dist/src/agent-loop.d.ts +226 -9
  15. package/dist/src/agent-loop.d.ts.map +1 -1
  16. package/dist/src/agent-loop.js +1311 -208
  17. package/dist/src/agent-loop.js.map +1 -1
  18. package/dist/src/agent-service.d.ts +27 -0
  19. package/dist/src/agent-service.d.ts.map +1 -1
  20. package/dist/src/agent-service.js +29 -0
  21. package/dist/src/agent-service.js.map +1 -1
  22. package/dist/src/ai-sdk/ai-sdk-model.d.ts.map +1 -1
  23. package/dist/src/ai-sdk/ai-sdk-model.js +21 -1
  24. package/dist/src/ai-sdk/ai-sdk-model.js.map +1 -1
  25. package/dist/src/client/sse.d.ts +32 -2
  26. package/dist/src/client/sse.d.ts.map +1 -1
  27. package/dist/src/client/sse.js +45 -2
  28. package/dist/src/client/sse.js.map +1 -1
  29. package/dist/src/define_config.d.ts +41 -7
  30. package/dist/src/define_config.d.ts.map +1 -1
  31. package/dist/src/define_config.js.map +1 -1
  32. package/dist/src/durable/agent-run-workflow.d.ts +10 -11
  33. package/dist/src/durable/agent-run-workflow.d.ts.map +1 -1
  34. package/dist/src/durable/agent-run-workflow.js +49 -21
  35. package/dist/src/durable/agent-run-workflow.js.map +1 -1
  36. package/dist/src/durable/durable-agent-runner.d.ts +3 -2
  37. package/dist/src/durable/durable-agent-runner.d.ts.map +1 -1
  38. package/dist/src/durable/durable-agent-runner.js +2 -2
  39. package/dist/src/durable/durable-agent-runner.js.map +1 -1
  40. package/dist/src/elicitation.d.ts +207 -0
  41. package/dist/src/elicitation.d.ts.map +1 -0
  42. package/dist/src/elicitation.js +315 -0
  43. package/dist/src/elicitation.js.map +1 -0
  44. package/dist/src/evals/approval-prior.d.ts +58 -0
  45. package/dist/src/evals/approval-prior.d.ts.map +1 -0
  46. package/dist/src/evals/approval-prior.js +82 -0
  47. package/dist/src/evals/approval-prior.js.map +1 -0
  48. package/dist/src/evals/evaluate.d.ts +51 -0
  49. package/dist/src/evals/evaluate.d.ts.map +1 -0
  50. package/dist/src/evals/evaluate.js +76 -0
  51. package/dist/src/evals/evaluate.js.map +1 -0
  52. package/dist/src/evals/governance-sample-source.d.ts +23 -0
  53. package/dist/src/evals/governance-sample-source.d.ts.map +1 -0
  54. package/dist/src/evals/governance-sample-source.js +93 -0
  55. package/dist/src/evals/governance-sample-source.js.map +1 -0
  56. package/dist/src/evals/in-memory-score-store.d.ts +16 -0
  57. package/dist/src/evals/in-memory-score-store.d.ts.map +1 -0
  58. package/dist/src/evals/in-memory-score-store.js +57 -0
  59. package/dist/src/evals/in-memory-score-store.js.map +1 -0
  60. package/dist/src/evals/index.d.ts +15 -0
  61. package/dist/src/evals/index.d.ts.map +1 -0
  62. package/dist/src/evals/index.js +14 -0
  63. package/dist/src/evals/index.js.map +1 -0
  64. package/dist/src/evals/judge.d.ts +30 -0
  65. package/dist/src/evals/judge.d.ts.map +1 -0
  66. package/dist/src/evals/judge.js +53 -0
  67. package/dist/src/evals/judge.js.map +1 -0
  68. package/dist/src/evals/live-scoring.d.ts +42 -0
  69. package/dist/src/evals/live-scoring.d.ts.map +1 -0
  70. package/dist/src/evals/live-scoring.js +103 -0
  71. package/dist/src/evals/live-scoring.js.map +1 -0
  72. package/dist/src/evals/sample-source.d.ts +40 -0
  73. package/dist/src/evals/sample-source.d.ts.map +1 -0
  74. package/dist/src/evals/sample-source.js +33 -0
  75. package/dist/src/evals/sample-source.js.map +1 -0
  76. package/dist/src/evals/score-store.d.ts +54 -0
  77. package/dist/src/evals/score-store.d.ts.map +1 -0
  78. package/dist/src/evals/score-store.js +2 -0
  79. package/dist/src/evals/score-store.js.map +1 -0
  80. package/dist/src/evals/scorers/answer-relevancy.scorer.d.ts +28 -0
  81. package/dist/src/evals/scorers/answer-relevancy.scorer.d.ts.map +1 -0
  82. package/dist/src/evals/scorers/answer-relevancy.scorer.js +42 -0
  83. package/dist/src/evals/scorers/answer-relevancy.scorer.js.map +1 -0
  84. package/dist/src/evals/scorers/approval-outcome.scorer.d.ts +22 -0
  85. package/dist/src/evals/scorers/approval-outcome.scorer.d.ts.map +1 -0
  86. package/dist/src/evals/scorers/approval-outcome.scorer.js +60 -0
  87. package/dist/src/evals/scorers/approval-outcome.scorer.js.map +1 -0
  88. package/dist/src/evals/scorers/approval-risk.scorer.d.ts +28 -0
  89. package/dist/src/evals/scorers/approval-risk.scorer.d.ts.map +1 -0
  90. package/dist/src/evals/scorers/approval-risk.scorer.js +54 -0
  91. package/dist/src/evals/scorers/approval-risk.scorer.js.map +1 -0
  92. package/dist/src/evals/scorers/run-completion.scorer.d.ts +18 -0
  93. package/dist/src/evals/scorers/run-completion.scorer.d.ts.map +1 -0
  94. package/dist/src/evals/scorers/run-completion.scorer.js +55 -0
  95. package/dist/src/evals/scorers/run-completion.scorer.js.map +1 -0
  96. package/dist/src/evals/summarize.d.ts +44 -0
  97. package/dist/src/evals/summarize.d.ts.map +1 -0
  98. package/dist/src/evals/summarize.js +87 -0
  99. package/dist/src/evals/summarize.js.map +1 -0
  100. package/dist/src/evals/types.d.ts +81 -0
  101. package/dist/src/evals/types.d.ts.map +1 -0
  102. package/dist/src/evals/types.js +15 -0
  103. package/dist/src/evals/types.js.map +1 -0
  104. package/dist/src/history-window.d.ts +50 -11
  105. package/dist/src/history-window.d.ts.map +1 -1
  106. package/dist/src/history-window.js +84 -12
  107. package/dist/src/history-window.js.map +1 -1
  108. package/dist/src/index.d.ts +11 -3
  109. package/dist/src/index.d.ts.map +1 -1
  110. package/dist/src/index.js +10 -3
  111. package/dist/src/index.js.map +1 -1
  112. package/dist/src/mcp/server.d.ts +8 -0
  113. package/dist/src/mcp/server.d.ts.map +1 -1
  114. package/dist/src/mcp/server.js +27 -1
  115. package/dist/src/mcp/server.js.map +1 -1
  116. package/dist/src/mcp-client/importer.d.ts +75 -0
  117. package/dist/src/mcp-client/importer.d.ts.map +1 -0
  118. package/dist/src/mcp-client/importer.js +161 -0
  119. package/dist/src/mcp-client/importer.js.map +1 -0
  120. package/dist/src/mcp-client/index.d.ts +9 -0
  121. package/dist/src/mcp-client/index.d.ts.map +1 -0
  122. package/dist/src/mcp-client/index.js +8 -0
  123. package/dist/src/mcp-client/index.js.map +1 -0
  124. package/dist/src/mcp-client/options.d.ts +99 -0
  125. package/dist/src/mcp-client/options.d.ts.map +1 -0
  126. package/dist/src/mcp-client/options.js +2 -0
  127. package/dist/src/mcp-client/options.js.map +1 -0
  128. package/dist/src/mcp-client/tool-input.d.ts +39 -0
  129. package/dist/src/mcp-client/tool-input.d.ts.map +1 -0
  130. package/dist/src/mcp-client/tool-input.js +61 -0
  131. package/dist/src/mcp-client/tool-input.js.map +1 -0
  132. package/dist/src/mcp-client/tool-kind.d.ts +37 -0
  133. package/dist/src/mcp-client/tool-kind.d.ts.map +1 -0
  134. package/dist/src/mcp-client/tool-kind.js +20 -0
  135. package/dist/src/mcp-client/tool-kind.js.map +1 -0
  136. package/dist/src/mcp-client/tool-name.d.ts +22 -0
  137. package/dist/src/mcp-client/tool-name.d.ts.map +1 -0
  138. package/dist/src/mcp-client/tool-name.js +35 -0
  139. package/dist/src/mcp-client/tool-name.js.map +1 -0
  140. package/dist/src/mcp-client/tool-source.d.ts +75 -0
  141. package/dist/src/mcp-client/tool-source.d.ts.map +1 -0
  142. package/dist/src/mcp-client/tool-source.js +244 -0
  143. package/dist/src/mcp-client/tool-source.js.map +1 -0
  144. package/dist/src/mcp-client/transient.d.ts +28 -0
  145. package/dist/src/mcp-client/transient.d.ts.map +1 -0
  146. package/dist/src/mcp-client/transient.js +126 -0
  147. package/dist/src/mcp-client/transient.js.map +1 -0
  148. package/dist/src/mcp-client/unsafe-regex.d.ts +23 -0
  149. package/dist/src/mcp-client/unsafe-regex.d.ts.map +1 -0
  150. package/dist/src/mcp-client/unsafe-regex.js +194 -0
  151. package/dist/src/mcp-client/unsafe-regex.js.map +1 -0
  152. package/dist/src/memory.d.ts +448 -0
  153. package/dist/src/memory.d.ts.map +1 -0
  154. package/dist/src/memory.js +330 -0
  155. package/dist/src/memory.js.map +1 -0
  156. package/dist/src/pagination.d.ts +63 -0
  157. package/dist/src/pagination.d.ts.map +1 -0
  158. package/dist/src/pagination.js +16 -0
  159. package/dist/src/pagination.js.map +1 -0
  160. package/dist/src/processors.d.ts +134 -0
  161. package/dist/src/processors.d.ts.map +1 -0
  162. package/dist/src/processors.js +215 -0
  163. package/dist/src/processors.js.map +1 -0
  164. package/dist/src/rag/qdrant-store.d.ts +48 -6
  165. package/dist/src/rag/qdrant-store.d.ts.map +1 -1
  166. package/dist/src/rag/qdrant-store.js +77 -24
  167. package/dist/src/rag/qdrant-store.js.map +1 -1
  168. package/dist/src/replay-integrity.d.ts +17 -0
  169. package/dist/src/replay-integrity.d.ts.map +1 -0
  170. package/dist/src/replay-integrity.js +19 -0
  171. package/dist/src/replay-integrity.js.map +1 -0
  172. package/dist/src/runners/inline-agent-runner.d.ts +33 -7
  173. package/dist/src/runners/inline-agent-runner.d.ts.map +1 -1
  174. package/dist/src/runners/inline-agent-runner.js +113 -27
  175. package/dist/src/runners/inline-agent-runner.js.map +1 -1
  176. package/dist/src/skills.d.ts +291 -0
  177. package/dist/src/skills.d.ts.map +1 -0
  178. package/dist/src/skills.js +0 -0
  179. package/dist/src/skills.js.map +1 -0
  180. package/dist/src/spi/agent-runner.d.ts +20 -6
  181. package/dist/src/spi/agent-runner.d.ts.map +1 -1
  182. package/dist/src/spi/agent-store.d.ts +53 -0
  183. package/dist/src/spi/agent-store.d.ts.map +1 -1
  184. package/dist/src/spi/governance-queries.d.ts +33 -13
  185. package/dist/src/spi/governance-queries.d.ts.map +1 -1
  186. package/dist/src/spi/history-window.d.ts +64 -10
  187. package/dist/src/spi/history-window.d.ts.map +1 -1
  188. package/dist/src/spi/model-provider.d.ts +18 -0
  189. package/dist/src/spi/model-provider.d.ts.map +1 -1
  190. package/dist/src/spi/processors.d.ts +161 -0
  191. package/dist/src/spi/processors.d.ts.map +1 -0
  192. package/dist/src/spi/processors.js +57 -0
  193. package/dist/src/spi/processors.js.map +1 -0
  194. package/dist/src/spi/token-stream-sink.d.ts +43 -0
  195. package/dist/src/spi/token-stream-sink.d.ts.map +1 -1
  196. package/dist/src/spi/token-stream-sink.js +17 -1
  197. package/dist/src/spi/token-stream-sink.js.map +1 -1
  198. package/dist/src/sse.d.ts +5 -2
  199. package/dist/src/sse.d.ts.map +1 -1
  200. package/dist/src/sse.js +11 -2
  201. package/dist/src/sse.js.map +1 -1
  202. package/dist/src/stores/lucid-governance-queries.d.ts +5 -2
  203. package/dist/src/stores/lucid-governance-queries.d.ts.map +1 -1
  204. package/dist/src/stores/lucid-governance-queries.js +14 -5
  205. package/dist/src/stores/lucid-governance-queries.js.map +1 -1
  206. package/dist/src/stores/lucid-schema.d.ts.map +1 -1
  207. package/dist/src/stores/lucid-schema.js +15 -0
  208. package/dist/src/stores/lucid-schema.js.map +1 -1
  209. package/dist/src/stores/lucid.d.ts +11 -3
  210. package/dist/src/stores/lucid.d.ts.map +1 -1
  211. package/dist/src/stores/lucid.js +65 -0
  212. package/dist/src/stores/lucid.js.map +1 -1
  213. package/dist/src/structured-output.d.ts +57 -0
  214. package/dist/src/structured-output.d.ts.map +1 -0
  215. package/dist/src/structured-output.js +80 -0
  216. package/dist/src/structured-output.js.map +1 -0
  217. package/dist/src/telescope/agent-governance-providers.js +2 -2
  218. package/dist/src/telescope/agent-governance-providers.js.map +1 -1
  219. package/dist/src/testing/fake-model-provider.d.ts +8 -4
  220. package/dist/src/testing/fake-model-provider.d.ts.map +1 -1
  221. package/dist/src/testing/fake-model-provider.js +6 -9
  222. package/dist/src/testing/fake-model-provider.js.map +1 -1
  223. package/dist/src/testing/in-memory-governance-queries.d.ts.map +1 -1
  224. package/dist/src/testing/in-memory-governance-queries.js +8 -3
  225. package/dist/src/testing/in-memory-governance-queries.js.map +1 -1
  226. package/dist/src/testing/in-memory-store.d.ts +4 -3
  227. package/dist/src/testing/in-memory-store.d.ts.map +1 -1
  228. package/dist/src/testing/in-memory-store.js +13 -7
  229. package/dist/src/testing/in-memory-store.js.map +1 -1
  230. package/dist/src/testing/index.d.ts +1 -1
  231. package/dist/src/testing/index.d.ts.map +1 -1
  232. package/dist/src/testing/index.js.map +1 -1
  233. package/dist/src/tool-registry.d.ts +9 -0
  234. package/dist/src/tool-registry.d.ts.map +1 -1
  235. package/dist/src/tool-registry.js +11 -0
  236. package/dist/src/tool-registry.js.map +1 -1
  237. package/dist/src/types.d.ts +55 -2
  238. package/dist/src/types.d.ts.map +1 -1
  239. package/package.json +20 -10
  240. package/skills/agent-personas-agents/SKILL.md +16 -12
@@ -0,0 +1,93 @@
1
+ /**
2
+ * A {@link RunSampleSource} over what the agent already persisted, read through
3
+ * {@link AgentGovernanceQueries} alone. Works against any adapter that implements it (Lucid, the
4
+ * in-memory one) — this module adds no tables of its own on the read side.
5
+ *
6
+ * The prompt and the answer come off `runDetail`, whose messages are the ones stamped with this
7
+ * run's own `run_id`. There is no transcript join and no time-window heuristic: a run that wrote no
8
+ * message has empty text, and no other run's answer can ever be handed to it.
9
+ *
10
+ * One seam remains, and it is the read-model's rather than this class's: a run whose messages were
11
+ * written before message-level run stamping reads as empty text. A rule-based scorer over tool
12
+ * outcomes still works on it; a judge over the answer has nothing to read.
13
+ */
14
+ export class GovernanceRunSampleSource {
15
+ queries;
16
+ constructor(queries) {
17
+ this.queries = queries;
18
+ }
19
+ async listRuns(query) {
20
+ const filter = {
21
+ ...(query.actorRef !== undefined ? { actor: query.actorRef } : {}),
22
+ ...(query.agentName !== undefined ? { agent: query.agentName } : {}),
23
+ ...(query.status !== undefined ? { status: query.status } : {}),
24
+ ...(query.fromDay !== undefined ? { from: query.fromDay } : {}),
25
+ ...(query.toDay !== undefined ? { to: query.toDay } : {}),
26
+ };
27
+ // The read-model clamps a page to 200, so a batch bigger than that has to walk the cursor rather
28
+ // than ask for the whole thing and quietly get a fifth of it.
29
+ const runs = [];
30
+ let cursor = null;
31
+ while (runs.length < query.limit) {
32
+ const page = await this.queries.listRuns({
33
+ ...filter,
34
+ first: query.limit - runs.length,
35
+ ...(cursor !== null ? { after: cursor } : {}),
36
+ });
37
+ for (const row of page.items) {
38
+ const detail = await this.queries.runDetail(row.runId);
39
+ if (detail !== null) {
40
+ runs.push(toScorableRun(detail));
41
+ }
42
+ }
43
+ cursor = page.nextCursor;
44
+ if (cursor === null || page.items.length === 0) {
45
+ break;
46
+ }
47
+ }
48
+ return runs;
49
+ }
50
+ async getRun(runId) {
51
+ const detail = await this.queries.runDetail(runId);
52
+ return detail === null ? null : toScorableRun(detail);
53
+ }
54
+ }
55
+ /**
56
+ * Flatten a run's trace into the unit a scorer judges. A turn can persist several assistant messages
57
+ * (one per model step); the LAST is the answer and the earlier ones are the steps that called tools,
58
+ * so both sides reduce by taking the last of their role.
59
+ */
60
+ function toScorableRun(detail) {
61
+ const { run } = detail;
62
+ let input = '';
63
+ let output = '';
64
+ for (const message of detail.messages) {
65
+ if (message.role === 'user') {
66
+ input = message.content;
67
+ }
68
+ else if (message.role === 'assistant') {
69
+ output = message.content;
70
+ }
71
+ }
72
+ return {
73
+ runId: run.runId,
74
+ threadId: run.threadId,
75
+ actorRef: run.actorRef,
76
+ agentName: run.agentName,
77
+ status: run.status,
78
+ input,
79
+ output,
80
+ toolCalls: detail.toolCalls.map((call) => ({
81
+ toolCallId: call.toolCallId,
82
+ toolName: call.toolName,
83
+ toolType: call.toolType,
84
+ status: call.status,
85
+ executionMs: call.executionMs,
86
+ error: call.error,
87
+ })),
88
+ durationMs: run.durationMs,
89
+ error: run.error,
90
+ startedAt: run.startedAt,
91
+ };
92
+ }
93
+ //# sourceMappingURL=governance-sample-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governance-sample-source.js","sourceRoot":"","sources":["../../../src/evals/governance-sample-source.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,yBAAyB;IACP,OAAO;IAApC,YAA6B,OAA+B;uBAA/B,OAAO;IAA2B,CAAC;IAEhE,KAAK,CAAC,QAAQ,CAAC,KAAqB;QAClC,MAAM,MAAM,GAAmB;YAC7B,GAAG,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAClE,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACpE,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/D,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/D,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC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it tests and the offline demo.
4
+ *
5
+ * Append-only: `recordScores` never replaces a previous verdict, so re-scoring the same run after a
6
+ * scorer changed leaves both rows and the history stays auditable. Callers that want one row per
7
+ * `(runId, scorer)` skip the already-scored runs via {@link InMemoryScoreStore.scoredRunIds}, which
8
+ * is what `runEvaluation` does by default.
9
+ */
10
+ export declare class InMemoryScoreStore implements ScoreStore {
11
+ private readonly scores;
12
+ recordScores(scores: RunScore[]): Promise<void>;
13
+ scoredRunIds(scorer: string, runIds: string[]): Promise<string[]>;
14
+ listScores(where?: ScoreWhere): Promise<RunScore[]>;
15
+ }
16
+ //# sourceMappingURL=in-memory-score-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-score-store.d.ts","sourceRoot":"","sources":["../../../src/evals/in-memory-score-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAqBzE;;;;;;;GAOG;AACH,qBAAa,kBAAmB,YAAW,UAAU;IACnD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IAEnC,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAIpD;IAEK,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAStE;IAEK,UAAU,CAAC,KAAK,GAAE,UAAe,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAc5D;CACF"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Whether a `YYYY-MM-DD` day falls within an inclusive range whose bounds are each optional — an
3
+ * absent bound imposes no constraint on that side. Lexicographic comparison is valid because the
4
+ * days are zero-padded ISO dates.
5
+ */
6
+ function dayWithinBounds(day, fromDay, toDay) {
7
+ if (fromDay !== undefined && day < fromDay) {
8
+ return false;
9
+ }
10
+ if (toDay !== undefined && day > toDay) {
11
+ return false;
12
+ }
13
+ return true;
14
+ }
15
+ /**
16
+ * A fully in-memory {@link ScoreStore} for unit tests and the offline demo.
17
+ *
18
+ * Append-only: `recordScores` never replaces a previous verdict, so re-scoring the same run after a
19
+ * scorer changed leaves both rows and the history stays auditable. Callers that want one row per
20
+ * `(runId, scorer)` skip the already-scored runs via {@link InMemoryScoreStore.scoredRunIds}, which
21
+ * is what `runEvaluation` does by default.
22
+ */
23
+ export class InMemoryScoreStore {
24
+ scores = [];
25
+ async recordScores(scores) {
26
+ for (const score of scores) {
27
+ this.scores.push({ ...score });
28
+ }
29
+ }
30
+ async scoredRunIds(scorer, runIds) {
31
+ const wanted = new Set(runIds);
32
+ const seen = new Set();
33
+ for (const row of this.scores) {
34
+ if (row.scorer === scorer && wanted.has(row.runId)) {
35
+ seen.add(row.runId);
36
+ }
37
+ }
38
+ return [...seen];
39
+ }
40
+ async listScores(where = {}) {
41
+ return this.scores
42
+ .filter((row) => {
43
+ if (where.scorer !== undefined && row.scorer !== where.scorer)
44
+ return false;
45
+ if (where.agentName !== undefined && row.agentName !== where.agentName)
46
+ return false;
47
+ if (where.threadId !== undefined && row.threadId !== where.threadId)
48
+ return false;
49
+ if (where.runId !== undefined && row.runId !== where.runId)
50
+ return false;
51
+ return dayWithinBounds(row.day, where.fromDay, where.toDay);
52
+ })
53
+ .sort((left, right) => right.scoredAt.localeCompare(left.scoredAt) || right.runId.localeCompare(left.runId))
54
+ .map((row) => ({ ...row }));
55
+ }
56
+ }
57
+ //# sourceMappingURL=in-memory-score-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-score-store.js","sourceRoot":"","sources":["../../../src/evals/in-memory-score-store.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,SAAS,eAAe,CACtB,GAAW,EACX,OAA2B,EAC3B,KAAyB;IAEzB,IAAI,OAAO,KAAK,SAAS,IAAI,GAAG,GAAG,OAAO,EAAE,CAAC;QAC3C,OAAO,KAAK,CAAC;IACf,CAAC;I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,QAAQ,KAAK,SAAS,IAAI,GAAG,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ;gBAAE,OAAO,KAAK,CAAC;YAClF,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK;gBAAE,OAAO,KAAK,CAAC;YACzE,OAAO,eAAe,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9D,CAAC,CAAC;aACD,IAAI,CACH,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACd,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CACvF;aACA,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ export { type ApprovalPriorQuery, approvalPosterior, buildApprovalPrior, loadApprovalPrior, priorFromRuns, type ToolApprovalCounts, type ToolApprovalDecision, type ToolApprovalPrior, } from './approval-prior.js';
2
+ export { type EvaluationOptions, type EvaluationSummary, runEvaluation, type ScorerFailure, toRunScore, } from './evaluate.js';
3
+ export { GovernanceRunSampleSource } from './governance-sample-source.js';
4
+ export { InMemoryScoreStore } from './in-memory-score-store.js';
5
+ export { discardingSink, JudgeVerdictError, MAX_JUDGE_SCORE, parseJudgeVerdict, } from './judge.js';
6
+ export { attachLiveScoring, type LiveScoring, type LiveScoringOptions } from './live-scoring.js';
7
+ export { type RunSampleQuery, type RunSampleSource, StaticRunSampleSource, } from './sample-source.js';
8
+ export type { RunScore, ScoreStore, ScoreWhere } from './score-store.js';
9
+ export { ANSWER_RELEVANCY_SCORER, type AnswerRelevancyOptions, AnswerRelevancyScorer, } from './scorers/answer-relevancy.scorer.js';
10
+ export { APPROVAL_OUTCOME_SCORER, ApprovalOutcomeScorer, } from './scorers/approval-outcome.scorer.js';
11
+ export { APPROVAL_RISK_SCORER, ApprovalRiskScorer } from './scorers/approval-risk.scorer.js';
12
+ export { RUN_COMPLETION_SCORER, RunCompletionScorer } from './scorers/run-completion.scorer.js';
13
+ export { type AgentScoreRow, bucketScoreTrend, type ScorerSummaryRow, type ScoreTrendPoint, summarizeByAgent, summarizeByScorer, worstScoredRuns, } from './summarize.js';
14
+ export { clampScore, type ScorableRun, type ScorableToolCall, type ScoreResult, type Scorer, type ScorerKind, } from './types.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/evals/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,aAAa,EACb,KAAK,aAAa,EAClB,UAAU,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACL,uBAAuB,EACvB,KAAK,sBAAsB,EAC3B,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,EACL,KAAK,aAAa,EAClB,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,14 @@
1
+ export { approvalPosterior, buildApprovalPrior, loadApprovalPrior, priorFromRuns, } from './approval-prior.js';
2
+ export { runEvaluation, toRunScore, } from './evaluate.js';
3
+ export { GovernanceRunSampleSource } from './governance-sample-source.js';
4
+ export { InMemoryScoreStore } from './in-memory-score-store.js';
5
+ export { discardingSink, JudgeVerdictError, MAX_JUDGE_SCORE, parseJudgeVerdict, } from './judge.js';
6
+ export { attachLiveScoring } from './live-scoring.js';
7
+ export { StaticRunSampleSource, } from './sample-source.js';
8
+ export { ANSWER_RELEVANCY_SCORER, AnswerRelevancyScorer, } from './scorers/answer-relevancy.scorer.js';
9
+ export { APPROVAL_OUTCOME_SCORER, ApprovalOutcomeScorer, } from './scorers/approval-outcome.scorer.js';
10
+ export { APPROVAL_RISK_SCORER, ApprovalRiskScorer } from './scorers/approval-risk.scorer.js';
11
+ export { RUN_COMPLETION_SCORER, RunCompletionScorer } from './scorers/run-completion.scorer.js';
12
+ export { bucketScoreTrend, summarizeByAgent, summarizeByScorer, worstScoredRuns, } from './summarize.js';
13
+ export { clampScore, } from './types.js';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/evals/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,GAId,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,aAAa,EAEb,UAAU,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAA6C,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAGL,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,uBAAuB,EAEvB,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAEL,gBAAgB,EAGhB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,UAAU,GAMX,MAAM,YAAY,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { SinkWriter } from '../spi/token-stream-sink.js';
2
+ import type { ScoreResult } from './types.js';
3
+ /** The toolkit a model-graded (LLM-as-judge) scorer needs: a sink to nowhere and a verdict parser. */
4
+ /**
5
+ * A {@link SinkWriter} that drops every token.
6
+ *
7
+ * {@link import('../spi/model-provider.js').ModelProvider.runTurn} streams deltas as it generates,
8
+ * but a judge's verdict is read from the assembled `text` it returns and nobody is watching it
9
+ * arrive — a judge call has no run, so there is no live stream to join.
10
+ */
11
+ export declare function discardingSink(): SinkWriter;
12
+ /**
13
+ * The upper end of the scale a judge is asked for. A 0–5 integer band is easier for a model to hold
14
+ * consistently than a raw 0–1 float, so the prompt asks for that and the parser normalizes.
15
+ */
16
+ export declare const MAX_JUDGE_SCORE = 5;
17
+ /** A judge reply that could not be read as a verdict. */
18
+ export declare class JudgeVerdictError extends Error {
19
+ constructor(message: string);
20
+ }
21
+ /**
22
+ * Read a `SCORE: n` / `REASON: …` reply into a {@link ScoreResult}, normalizing the score to `0..1`.
23
+ *
24
+ * A missing or out-of-band score THROWS rather than scoring 0: a judge that did not answer is a
25
+ * broken evaluation, and recording it as a bad run would put the blame on the agent. The batch
26
+ * runner catches it as a per-run scorer failure. A missing reason is tolerated — the number is the
27
+ * verdict, the sentence is the courtesy.
28
+ */
29
+ export declare function parseJudgeVerdict(text: string): ScoreResult;
30
+ //# sourceMappingURL=judge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"judge.d.ts","sourceRoot":"","sources":["../../../src/evals/judge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,sGAAsG;AAEtG;;;;;;GAMG;AACH,wBAAgB,cAAc,IAAI,UAAU,CAK3C;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,yDAAyD;AACzD,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAKD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAiB3D"}
@@ -0,0 +1,53 @@
1
+ /** The toolkit a model-graded (LLM-as-judge) scorer needs: a sink to nowhere and a verdict parser. */
2
+ /**
3
+ * A {@link SinkWriter} that drops every token.
4
+ *
5
+ * {@link import('../spi/model-provider.js').ModelProvider.runTurn} streams deltas as it generates,
6
+ * but a judge's verdict is read from the assembled `text` it returns and nobody is watching it
7
+ * arrive — a judge call has no run, so there is no live stream to join.
8
+ */
9
+ export function discardingSink() {
10
+ return {
11
+ write: () => { },
12
+ end: () => { },
13
+ };
14
+ }
15
+ /**
16
+ * The upper end of the scale a judge is asked for. A 0–5 integer band is easier for a model to hold
17
+ * consistently than a raw 0–1 float, so the prompt asks for that and the parser normalizes.
18
+ */
19
+ export const MAX_JUDGE_SCORE = 5;
20
+ /** A judge reply that could not be read as a verdict. */
21
+ export class JudgeVerdictError extends Error {
22
+ constructor(message) {
23
+ super(message);
24
+ this.name = 'JudgeVerdictError';
25
+ }
26
+ }
27
+ const SCORE_PATTERN = /SCORE:\s*(\d+(?:\.\d+)?)/i;
28
+ const REASON_PATTERN = /REASON:\s*([\s\S]+)/i;
29
+ /**
30
+ * Read a `SCORE: n` / `REASON: …` reply into a {@link ScoreResult}, normalizing the score to `0..1`.
31
+ *
32
+ * A missing or out-of-band score THROWS rather than scoring 0: a judge that did not answer is a
33
+ * broken evaluation, and recording it as a bad run would put the blame on the agent. The batch
34
+ * runner catches it as a per-run scorer failure. A missing reason is tolerated — the number is the
35
+ * verdict, the sentence is the courtesy.
36
+ */
37
+ export function parseJudgeVerdict(text) {
38
+ const scoreMatch = SCORE_PATTERN.exec(text);
39
+ const raw = scoreMatch?.[1];
40
+ if (raw === undefined) {
41
+ throw new JudgeVerdictError(`judge reply carried no "SCORE:" line: ${text.slice(0, 200)}`);
42
+ }
43
+ const rawScore = Number(raw);
44
+ if (!Number.isFinite(rawScore) || rawScore > MAX_JUDGE_SCORE) {
45
+ throw new JudgeVerdictError(`judge scored ${raw}, outside the 0-${MAX_JUDGE_SCORE} scale it was asked for`);
46
+ }
47
+ return {
48
+ score: rawScore / MAX_JUDGE_SCORE,
49
+ reason: REASON_PATTERN.exec(text)?.[1]?.trim() ?? 'the judge gave no reason',
50
+ metadata: { rawScore, maxScore: MAX_JUDGE_SCORE },
51
+ };
52
+ }
53
+ //# sourceMappingURL=judge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"judge.js","sourceRoot":"","sources":["../../../src/evals/judge.ts"],"names":[],"mappings":"AAGA,sGAAsG;AAEtG;;;;;;GAMG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO;QACL,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;QACf,GAAG,EAAE,GAAG,EAAE,GAAE,CAAC;KACd,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AAEjC,yDAAyD;AACzD,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAClD,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,iBAAiB,CAAC,yCAAyC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IAC7F,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,eAAe,EAAE,CAAC;QAC7D,MAAM,IAAI,iBAAiB,CACzB,gBAAgB,GAAG,mBAAmB,eAAe,yBAAyB,CAC/E,CAAC;IACJ,CAAC;IACD,OAAO;QACL,KAAK,EAAE,QAAQ,GAAG,eAAe;QACjC,MAAM,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,0BAA0B;QAC5E,QAAQ,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE;KAClD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { RunSampleSource } from './sample-source.js';
2
+ import type { ScoreStore } from './score-store.js';
3
+ import type { Scorer } from './types.js';
4
+ export interface LiveScoringOptions {
5
+ source: RunSampleSource;
6
+ scorers: Scorer[];
7
+ store: ScoreStore;
8
+ /**
9
+ * Fraction of finished runs to score, `0..1`. Default `1`. Turn it down for a scorer that costs
10
+ * money per run — a trend needs a representative sample, not every row.
11
+ */
12
+ sampleRate?: number;
13
+ /** Sampler; injectable so a test can pin the decision. */
14
+ random?: () => number;
15
+ now?: () => Date;
16
+ /** Told about anything that went wrong. Default: swallowed — a score is never worth a log storm. */
17
+ onError?: (error: unknown) => void;
18
+ }
19
+ /** The handle {@link attachLiveScoring} returns. */
20
+ export interface LiveScoring {
21
+ /** Detach the subscription. In-flight scoring already started still settles. */
22
+ dispose(): void;
23
+ /** Resolves once every scoring started so far has settled — what a test awaits. */
24
+ settled(): Promise<void>;
25
+ }
26
+ /**
27
+ * Score runs as they finish, by listening to `agora:agent:run.finished`.
28
+ *
29
+ * Opt-in: nothing calls this for you. And deliberately NOT inline in the turn — a scorer wired into
30
+ * the agent loop would add its latency to every message a user sends, and a model-graded one would
31
+ * double the cost of the product. This runs AFTER the run has already finished and reported so, on a
32
+ * diagnostics subscriber, in a detached promise. There is no code path from a scorer back into the
33
+ * turn: the run has settled and its stream has closed before the first scorer is called, and every
34
+ * failure below is caught and handed to `onError`. A scorer cannot fail a turn because by the time
35
+ * it runs there is no turn left to fail.
36
+ *
37
+ * It still costs real work per run, so the offline {@link import('./evaluate.js').runEvaluation}
38
+ * batch remains the default path — reach for this when you want a dashboard that moves within the
39
+ * hour, and prefer the `rule`/`statistical` scorers here.
40
+ */
41
+ export declare function attachLiveScoring(options: LiveScoringOptions): LiveScoring;
42
+ //# sourceMappingURL=live-scoring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-scoring.d.ts","sourceRoot":"","sources":["../../../src/evals/live-scoring.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAY,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AA4BzC,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,UAAU,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,oGAAoG;IACpG,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC;AAED,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,gFAAgF;IAChF,OAAO,IAAI,IAAI,CAAC;IAChB,mFAAmF;IACnF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CA8B1E"}
@@ -0,0 +1,103 @@
1
+ import diagnostics_channel from 'node:diagnostics_channel';
2
+ import { toRunScore } from './evaluate.js';
3
+ /**
4
+ * The channel the agent loop publishes a settled run on. Subscribed over Node's builtin
5
+ * `node:diagnostics_channel`, exactly as the media-ingestion bridge does — but the loop only PUBLISHES
6
+ * when `@adonis-agora/diagnostics` is installed to fill the emit slot, so live scoring is silently
7
+ * inert without it. The offline batch has no such dependency.
8
+ */
9
+ const RUN_FINISHED_CHANNEL = 'agora:agent:run.finished';
10
+ /** Pull `.payload` off a diagnostics-channel message without an unguarded cast. */
11
+ function envelopePayload(message) {
12
+ if (typeof message === 'object' && message !== null && 'payload' in message) {
13
+ return message.payload;
14
+ }
15
+ return undefined;
16
+ }
17
+ /** The `runId` a `run.finished` envelope carries, or `undefined` for anything else. */
18
+ function finishedRunId(message) {
19
+ const payload = envelopePayload(message);
20
+ if (typeof payload !== 'object' || payload === null || !('runId' in payload)) {
21
+ return undefined;
22
+ }
23
+ const runId = payload.runId;
24
+ return typeof runId === 'string' ? runId : undefined;
25
+ }
26
+ /**
27
+ * Score runs as they finish, by listening to `agora:agent:run.finished`.
28
+ *
29
+ * Opt-in: nothing calls this for you. And deliberately NOT inline in the turn — a scorer wired into
30
+ * the agent loop would add its latency to every message a user sends, and a model-graded one would
31
+ * double the cost of the product. This runs AFTER the run has already finished and reported so, on a
32
+ * diagnostics subscriber, in a detached promise. There is no code path from a scorer back into the
33
+ * turn: the run has settled and its stream has closed before the first scorer is called, and every
34
+ * failure below is caught and handed to `onError`. A scorer cannot fail a turn because by the time
35
+ * it runs there is no turn left to fail.
36
+ *
37
+ * It still costs real work per run, so the offline {@link import('./evaluate.js').runEvaluation}
38
+ * batch remains the default path — reach for this when you want a dashboard that moves within the
39
+ * hour, and prefer the `rule`/`statistical` scorers here.
40
+ */
41
+ export function attachLiveScoring(options) {
42
+ const now = options.now ?? (() => new Date());
43
+ const random = options.random ?? Math.random;
44
+ const sampleRate = options.sampleRate ?? 1;
45
+ const channel = diagnostics_channel.channel(RUN_FINISHED_CHANNEL);
46
+ const inFlight = new Set();
47
+ const onMessage = (message) => {
48
+ // The whole handler is guarded: this runs on the publisher's stack, so anything that escapes
49
+ // here surfaces inside whoever emitted the event.
50
+ try {
51
+ const runId = finishedRunId(message);
52
+ if (runId === undefined || (sampleRate < 1 && random() >= sampleRate)) {
53
+ return;
54
+ }
55
+ const task = scoreFinishedRun({ runId, options, now }).catch(options.onError ?? (() => { }));
56
+ inFlight.add(task);
57
+ void task.finally(() => inFlight.delete(task));
58
+ }
59
+ catch (error) {
60
+ options.onError?.(error);
61
+ }
62
+ };
63
+ channel.subscribe(onMessage);
64
+ return {
65
+ dispose: () => channel.unsubscribe(onMessage),
66
+ settled: async () => {
67
+ await Promise.all([...inFlight]);
68
+ },
69
+ };
70
+ }
71
+ /** Load the finished run and persist whatever the scorers had to say about it. */
72
+ async function scoreFinishedRun(args) {
73
+ const { runId, options, now } = args;
74
+ const run = await options.source.getRun(runId);
75
+ if (run === null) {
76
+ return;
77
+ }
78
+ const scores = [];
79
+ for (const scorer of options.scorers) {
80
+ try {
81
+ const result = await scorer.score(run);
82
+ if (result !== null) {
83
+ scores.push(toRunScore({ run, scorer, result, scoredAt: now() }));
84
+ }
85
+ }
86
+ catch (error) {
87
+ options.onError?.(error);
88
+ }
89
+ }
90
+ if (scores.length > 0) {
91
+ await recordQuietly({ store: options.store, scores, onError: options.onError });
92
+ }
93
+ }
94
+ /** A store that rejects must not take the whole subscriber down with it. */
95
+ async function recordQuietly(args) {
96
+ try {
97
+ await args.store.recordScores(args.scores);
98
+ }
99
+ catch (error) {
100
+ args.onError?.(error);
101
+ }
102
+ }
103
+ //# sourceMappingURL=live-scoring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-scoring.js","sourceRoot":"","sources":["../../../src/evals/live-scoring.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AAExD,mFAAmF;AACnF,SAAS,eAAe,CAAC,OAAgB;IACvC,IAAI,OAAO,OA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AC,CAAC;YACvC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBACpB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,aAAa,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAClF,CAAC;AACH,CAAC;AAED,4EAA4E;AAC5E,KAAK,UAAU,aAAa,CAAC,IAI5B;IACC,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;AACH,CAAC"}
@@ -0,0 +1,40 @@
1
+ import type { RunStatus } from '../spi/governance-queries.js';
2
+ import type { ScorableRun } from './types.js';
3
+ /**
4
+ * Which stored runs to score. `limit` caps the batch; every other field is an optional filter, and
5
+ * each one maps to a filter the governance read-model actually has
6
+ * ({@link import('../spi/governance-queries.js').ListRunsFilter}) — a filter this package applied
7
+ * after the page was already clamped would return fewer runs than `limit` asked for and look like a
8
+ * quiet corpus.
9
+ */
10
+ export interface RunSampleQuery {
11
+ /** Max runs returned, newest first. */
12
+ limit: number;
13
+ /** Inclusive UTC day bounds on the run's start, `YYYY-MM-DD`. */
14
+ fromDay?: string;
15
+ toDay?: string;
16
+ agentName?: string;
17
+ status?: RunStatus;
18
+ /** Exact `actorRef` — score one person's runs, or one tenant's service account. */
19
+ actorRef?: string;
20
+ }
21
+ /**
22
+ * Where {@link ScorableRun}s come from. The evaluation runner reads through this and nothing else,
23
+ * so a host can point it at the live agent tables, at a frozen regression set checked into a repo,
24
+ * or at a hand-written fixture in a test — the scorers never learn which.
25
+ */
26
+ export interface RunSampleSource {
27
+ listRuns(query: RunSampleQuery): Promise<ScorableRun[]>;
28
+ getRun(runId: string): Promise<ScorableRun | null>;
29
+ }
30
+ /**
31
+ * A {@link RunSampleSource} over a fixed list of runs — the regression-set / fixture source. Also
32
+ * what a test uses instead of standing up a store.
33
+ */
34
+ export declare class StaticRunSampleSource implements RunSampleSource {
35
+ private readonly runs;
36
+ constructor(runs: ScorableRun[]);
37
+ listRuns(query: RunSampleQuery): Promise<ScorableRun[]>;
38
+ getRun(runId: string): Promise<ScorableRun | null>;
39
+ }
40
+ //# sourceMappingURL=sample-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample-source.d.ts","sourceRoot":"","sources":["../../../src/evals/sample-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,mFAAmF;IACnF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACxD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;CACpD;AAED;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,eAAe;IAC/C,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAjC,YAA6B,IAAI,EAAE,WAAW,EAAE,EAAI;IAE9C,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAgB5D;IAEK,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAEvD;CACF"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * A {@link RunSampleSource} over a fixed list of runs — the regression-set / fixture source. Also
3
+ * what a test uses instead of standing up a store.
4
+ */
5
+ export class StaticRunSampleSource {
6
+ runs;
7
+ constructor(runs) {
8
+ this.runs = runs;
9
+ }
10
+ async listRuns(query) {
11
+ return this.runs
12
+ .filter((run) => {
13
+ if (query.agentName !== undefined && run.agentName !== query.agentName)
14
+ return false;
15
+ if (query.status !== undefined && run.status !== query.status)
16
+ return false;
17
+ if (query.actorRef !== undefined && run.actorRef !== query.actorRef)
18
+ return false;
19
+ const day = run.startedAt.slice(0, 10);
20
+ if (query.fromDay !== undefined && day < query.fromDay)
21
+ return false;
22
+ if (query.toDay !== undefined && day > query.toDay)
23
+ return false;
24
+ return true;
25
+ })
26
+ .sort((left, right) => right.startedAt.localeCompare(left.startedAt) || right.runId.localeCompare(left.runId))
27
+ .slice(0, query.limit);
28
+ }
29
+ async getRun(runId) {
30
+ return this.runs.find((run) => run.runId === runId) ?? null;
31
+ }
32
+ }
33
+ //# sourceMappingURL=sample-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample-source.js","sourceRoot":"","sources":["../../../src/evals/sample-source.ts"],"names":[],"mappings":"AAgCA;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACH,IAAI;IAAjC,YAA6B,IAAmB;oBAAnB,IAAI;IAAkB,CAAC;IAEpD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C;CACF"}
@@ -0,0 +1,54 @@
1
+ import type { ScorerKind } from './types.js';
2
+ /**
3
+ * Persistence for scores, separate from {@link import('../spi/agent-store.js').AgentStore} the same
4
+ * way the governance read-model is: the agent's own tables are the INPUT to scoring and must not
5
+ * grow a column every time someone writes a scorer. A host binds whichever adapter it likes;
6
+ * {@link import('./in-memory-score-store.js').InMemoryScoreStore} covers tests and the offline demo.
7
+ */
8
+ /** One scorer's verdict on one run, as persisted. */
9
+ export interface RunScore {
10
+ runId: string;
11
+ threadId: string;
12
+ agentName: string | null;
13
+ /** {@link import('./types.js').Scorer.name}. */
14
+ scorer: string;
15
+ kind: ScorerKind;
16
+ /** `0..1`, 1 is good. */
17
+ score: number;
18
+ reason: string;
19
+ metadata?: Record<string, unknown>;
20
+ /**
21
+ * The `YYYY-MM-DD` UTC day the SCORED RUN started — not the day the batch ran. A trend must move
22
+ * when the agent's quality moves, not when someone re-ran a backfill over last month.
23
+ */
24
+ day: string;
25
+ /** ISO timestamp the score was produced. */
26
+ scoredAt: string;
27
+ }
28
+ /** Filters for {@link ScoreStore.listScores}; an absent field imposes no constraint. */
29
+ export interface ScoreWhere {
30
+ scorer?: string;
31
+ agentName?: string;
32
+ threadId?: string;
33
+ runId?: string;
34
+ /** Inclusive UTC day bounds on {@link RunScore.day}, `YYYY-MM-DD`. */
35
+ fromDay?: string;
36
+ toDay?: string;
37
+ }
38
+ export interface ScoreStore {
39
+ /**
40
+ * Append scores. Idempotency is the caller's job via {@link ScoreStore.scoredRunIds} — an adapter
41
+ * that upserts on `(runId, scorer)` and one that appends both satisfy this SPI, so a consumer must
42
+ * not read "the score" of a run without deciding which it wants.
43
+ */
44
+ recordScores(scores: RunScore[]): Promise<void>;
45
+ /**
46
+ * Which of `runIds` already carry a score from `scorer`. The resume seam: a backfill interrupted
47
+ * halfway is restarted by skipping these, so re-running it costs nothing and — for a model-graded
48
+ * scorer — bills nothing.
49
+ */
50
+ scoredRunIds(scorer: string, runIds: string[]): Promise<string[]>;
51
+ /** Every score matching `where`, newest-scored first. The feed the summaries aggregate. */
52
+ listScores(where: ScoreWhere): Promise<RunScore[]>;
53
+ }
54
+ //# sourceMappingURL=score-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"score-store.d.ts","sourceRoot":"","sources":["../../../src/evals/score-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;GAKG;AAEH,qDAAqD;AACrD,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,CAAC;IACjB,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wFAAwF;AACxF,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD;;;;OAIG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAClE,2FAA2F;IAC3F,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;CACpD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=score-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"score-store.js","sourceRoot":"","sources":["../../../src/evals/score-store.ts"],"names":[],"mappings":""}