@escapeaihq/client-core 0.12.0 → 0.42.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 (239) hide show
  1. package/README.md +31 -6
  2. package/dist/adapters/capabilities.d.ts +10 -0
  3. package/dist/adapters/capabilities.d.ts.map +1 -0
  4. package/dist/adapters/capabilities.js +2 -0
  5. package/dist/adapters/capabilities.js.map +1 -0
  6. package/dist/adapters/chatAdapter.d.ts +38 -0
  7. package/dist/adapters/chatAdapter.d.ts.map +1 -0
  8. package/dist/adapters/chatAdapter.js +88 -0
  9. package/dist/adapters/chatAdapter.js.map +1 -0
  10. package/dist/adapters/directorAdapter.d.ts +62 -0
  11. package/dist/adapters/directorAdapter.d.ts.map +1 -0
  12. package/dist/adapters/directorAdapter.js +71 -0
  13. package/dist/adapters/directorAdapter.js.map +1 -0
  14. package/dist/adapters/imageAdapter.d.ts +44 -0
  15. package/dist/adapters/imageAdapter.d.ts.map +1 -0
  16. package/dist/adapters/imageAdapter.js +73 -0
  17. package/dist/adapters/imageAdapter.js.map +1 -0
  18. package/dist/adapters/index.d.ts +47 -0
  19. package/dist/adapters/index.d.ts.map +1 -0
  20. package/dist/adapters/index.js +41 -0
  21. package/dist/adapters/index.js.map +1 -0
  22. package/dist/adapters/registry.d.ts +98 -0
  23. package/dist/adapters/registry.d.ts.map +1 -0
  24. package/dist/adapters/registry.js +106 -0
  25. package/dist/adapters/registry.js.map +1 -0
  26. package/dist/adapters/worldAdapter.d.ts +142 -0
  27. package/dist/adapters/worldAdapter.d.ts.map +1 -0
  28. package/dist/adapters/worldAdapter.js +164 -0
  29. package/dist/adapters/worldAdapter.js.map +1 -0
  30. package/dist/admin.d.ts +200 -0
  31. package/dist/admin.d.ts.map +1 -0
  32. package/dist/admin.js +124 -0
  33. package/dist/admin.js.map +1 -0
  34. package/dist/api.d.ts +1185 -3
  35. package/dist/api.d.ts.map +1 -1
  36. package/dist/api.js +624 -51
  37. package/dist/api.js.map +1 -1
  38. package/dist/audio.d.ts +33 -1
  39. package/dist/audio.d.ts.map +1 -1
  40. package/dist/audio.js +4 -1
  41. package/dist/audio.js.map +1 -1
  42. package/dist/castProjection.d.ts +35 -0
  43. package/dist/castProjection.d.ts.map +1 -0
  44. package/dist/castProjection.js +80 -0
  45. package/dist/castProjection.js.map +1 -0
  46. package/dist/conversation/binding.d.ts +62 -0
  47. package/dist/conversation/binding.d.ts.map +1 -0
  48. package/dist/conversation/binding.js +51 -0
  49. package/dist/conversation/binding.js.map +1 -0
  50. package/dist/conversation/controller.d.ts +209 -0
  51. package/dist/conversation/controller.d.ts.map +1 -0
  52. package/dist/conversation/controller.js +342 -0
  53. package/dist/conversation/controller.js.map +1 -0
  54. package/dist/conversation/effectiveModel.d.ts +62 -0
  55. package/dist/conversation/effectiveModel.d.ts.map +1 -0
  56. package/dist/conversation/effectiveModel.js +73 -0
  57. package/dist/conversation/effectiveModel.js.map +1 -0
  58. package/dist/conversation/index.d.ts +27 -0
  59. package/dist/conversation/index.d.ts.map +1 -0
  60. package/dist/conversation/index.js +27 -0
  61. package/dist/conversation/index.js.map +1 -0
  62. package/dist/conversation/participant.d.ts +66 -0
  63. package/dist/conversation/participant.d.ts.map +1 -0
  64. package/dist/conversation/participant.js +36 -0
  65. package/dist/conversation/participant.js.map +1 -0
  66. package/dist/conversation/presence.d.ts +56 -0
  67. package/dist/conversation/presence.d.ts.map +1 -0
  68. package/dist/conversation/presence.js +34 -0
  69. package/dist/conversation/presence.js.map +1 -0
  70. package/dist/conversation/presenceBus.d.ts +42 -0
  71. package/dist/conversation/presenceBus.d.ts.map +1 -0
  72. package/dist/conversation/presenceBus.js +81 -0
  73. package/dist/conversation/presenceBus.js.map +1 -0
  74. package/dist/conversation/presenceRegistry.d.ts +49 -0
  75. package/dist/conversation/presenceRegistry.d.ts.map +1 -0
  76. package/dist/conversation/presenceRegistry.js +59 -0
  77. package/dist/conversation/presenceRegistry.js.map +1 -0
  78. package/dist/conversation/roster.d.ts +72 -0
  79. package/dist/conversation/roster.d.ts.map +1 -0
  80. package/dist/conversation/roster.js +69 -0
  81. package/dist/conversation/roster.js.map +1 -0
  82. package/dist/conversation/rosterProjection.d.ts +52 -0
  83. package/dist/conversation/rosterProjection.d.ts.map +1 -0
  84. package/dist/conversation/rosterProjection.js +74 -0
  85. package/dist/conversation/rosterProjection.js.map +1 -0
  86. package/dist/conversation/router.d.ts +74 -0
  87. package/dist/conversation/router.d.ts.map +1 -0
  88. package/dist/conversation/router.js +58 -0
  89. package/dist/conversation/router.js.map +1 -0
  90. package/dist/conversation/runtime.d.ts +64 -0
  91. package/dist/conversation/runtime.d.ts.map +1 -0
  92. package/dist/conversation/runtime.js +172 -0
  93. package/dist/conversation/runtime.js.map +1 -0
  94. package/dist/conversation/types.d.ts +99 -0
  95. package/dist/conversation/types.d.ts.map +1 -0
  96. package/dist/conversation/types.js +13 -0
  97. package/dist/conversation/types.js.map +1 -0
  98. package/dist/conversation/voice.d.ts +185 -0
  99. package/dist/conversation/voice.d.ts.map +1 -0
  100. package/dist/conversation/voice.js +307 -0
  101. package/dist/conversation/voice.js.map +1 -0
  102. package/dist/graphSchema.d.ts +201 -13
  103. package/dist/graphSchema.d.ts.map +1 -1
  104. package/dist/graphSchema.js +258 -9
  105. package/dist/graphSchema.js.map +1 -1
  106. package/dist/http.d.ts +20 -0
  107. package/dist/http.d.ts.map +1 -0
  108. package/dist/http.js +57 -0
  109. package/dist/http.js.map +1 -0
  110. package/dist/index.d.ts +6 -0
  111. package/dist/index.d.ts.map +1 -1
  112. package/dist/index.js +9 -0
  113. package/dist/index.js.map +1 -1
  114. package/dist/platformAssistant.d.ts +155 -0
  115. package/dist/platformAssistant.d.ts.map +1 -0
  116. package/dist/platformAssistant.js +256 -0
  117. package/dist/platformAssistant.js.map +1 -0
  118. package/dist/reactor/chunkDistribution.d.ts +43 -0
  119. package/dist/reactor/chunkDistribution.d.ts.map +1 -0
  120. package/dist/reactor/chunkDistribution.js +85 -0
  121. package/dist/reactor/chunkDistribution.js.map +1 -0
  122. package/dist/reactor/index.d.ts +2 -0
  123. package/dist/reactor/index.d.ts.map +1 -1
  124. package/dist/reactor/index.js +5 -0
  125. package/dist/reactor/index.js.map +1 -1
  126. package/dist/reactor/longLiveCommandDispatcher.d.ts +103 -0
  127. package/dist/reactor/longLiveCommandDispatcher.d.ts.map +1 -0
  128. package/dist/reactor/longLiveCommandDispatcher.js +87 -0
  129. package/dist/reactor/longLiveCommandDispatcher.js.map +1 -0
  130. package/dist/reactor/scenesFromEnrichment.d.ts.map +1 -1
  131. package/dist/reactor/scenesFromEnrichment.js +2 -66
  132. package/dist/reactor/scenesFromEnrichment.js.map +1 -1
  133. package/dist/reactor/seedImageOrchestrator.d.ts +6 -9
  134. package/dist/reactor/seedImageOrchestrator.d.ts.map +1 -1
  135. package/dist/reactor/seedImageOrchestrator.js +12 -13
  136. package/dist/reactor/seedImageOrchestrator.js.map +1 -1
  137. package/dist/reactor/storyTimeline.d.ts +44 -0
  138. package/dist/reactor/storyTimeline.d.ts.map +1 -0
  139. package/dist/reactor/storyTimeline.js +95 -0
  140. package/dist/reactor/storyTimeline.js.map +1 -0
  141. package/dist/storyGraph.d.ts +70 -0
  142. package/dist/storyGraph.d.ts.map +1 -0
  143. package/dist/storyGraph.js +178 -0
  144. package/dist/storyGraph.js.map +1 -0
  145. package/dist/vision/VisionSourceController.d.ts +127 -0
  146. package/dist/vision/VisionSourceController.d.ts.map +1 -0
  147. package/dist/vision/VisionSourceController.js +284 -0
  148. package/dist/vision/VisionSourceController.js.map +1 -0
  149. package/dist/vision/index.d.ts +4 -0
  150. package/dist/vision/index.d.ts.map +1 -1
  151. package/dist/vision/index.js +2 -0
  152. package/dist/vision/index.js.map +1 -1
  153. package/dist/vision/sourceKinds.d.ts +65 -0
  154. package/dist/vision/sourceKinds.d.ts.map +1 -0
  155. package/dist/vision/sourceKinds.js +26 -0
  156. package/dist/vision/sourceKinds.js.map +1 -0
  157. package/dist/websocket.d.ts +73 -0
  158. package/dist/websocket.d.ts.map +1 -1
  159. package/dist/websocket.js.map +1 -1
  160. package/package.json +1 -1
  161. package/src/__tests__/adapters-capabilities.test.ts +46 -0
  162. package/src/__tests__/adapters-chat.test.ts +172 -0
  163. package/src/__tests__/adapters-director.test.ts +95 -0
  164. package/src/__tests__/adapters-image.test.ts +133 -0
  165. package/src/__tests__/adapters-platform.test.ts +95 -0
  166. package/src/__tests__/adapters-registry.test.ts +189 -0
  167. package/src/__tests__/adapters-world.test.ts +296 -0
  168. package/src/__tests__/admin.test.ts +312 -0
  169. package/src/__tests__/adventures-party.test.ts +219 -0
  170. package/src/__tests__/adventures.test.ts +282 -0
  171. package/src/__tests__/api-pollers.test.ts +4 -0
  172. package/src/__tests__/api.clip-lookup.test.ts +64 -0
  173. package/src/__tests__/api.list-images-filters.test.ts +103 -0
  174. package/src/__tests__/api.test.ts +470 -0
  175. package/src/__tests__/audio.test.ts +65 -0
  176. package/src/__tests__/cast.test.ts +95 -0
  177. package/src/__tests__/castProjection.test.ts +167 -0
  178. package/src/__tests__/conversation/controller.test.ts +697 -0
  179. package/src/__tests__/conversation/effectiveModel.test.ts +169 -0
  180. package/src/__tests__/conversation/headlessRenderer.ts +46 -0
  181. package/src/__tests__/conversation/presenceBus.test.ts +236 -0
  182. package/src/__tests__/conversation/presenceRegistry.test.ts +73 -0
  183. package/src/__tests__/conversation/roster.test.ts +100 -0
  184. package/src/__tests__/conversation/rosterProjection.test.ts +142 -0
  185. package/src/__tests__/conversation/router.test.ts +81 -0
  186. package/src/__tests__/conversation/runtime.test.ts +206 -0
  187. package/src/__tests__/conversation/voice.test.ts +440 -0
  188. package/src/__tests__/documents.test.ts +360 -0
  189. package/src/__tests__/graphSchema.test.ts +218 -9
  190. package/src/__tests__/longLiveCommandDispatcher.test.ts +185 -0
  191. package/src/__tests__/platformAssistant.test.ts +484 -0
  192. package/src/__tests__/reactor/storyTimeline.test.ts +186 -0
  193. package/src/__tests__/regeneration.test.ts +486 -0
  194. package/src/__tests__/stories.test.ts +171 -0
  195. package/src/__tests__/storyGraph.test.ts +134 -0
  196. package/src/__tests__/tools-wrappers.test.ts +272 -0
  197. package/src/__tests__/videoGraph.test.ts +94 -0
  198. package/src/__tests__/websocket.test.ts +213 -0
  199. package/src/adapters/capabilities.ts +24 -0
  200. package/src/adapters/chatAdapter.ts +114 -0
  201. package/src/adapters/directorAdapter.ts +126 -0
  202. package/src/adapters/imageAdapter.ts +100 -0
  203. package/src/adapters/index.ts +67 -0
  204. package/src/adapters/registry.ts +159 -0
  205. package/src/adapters/worldAdapter.ts +272 -0
  206. package/src/admin.ts +310 -0
  207. package/src/api.ts +1731 -116
  208. package/src/audio.ts +35 -0
  209. package/src/castProjection.ts +95 -0
  210. package/src/conversation/binding.ts +81 -0
  211. package/src/conversation/controller.ts +439 -0
  212. package/src/conversation/effectiveModel.ts +111 -0
  213. package/src/conversation/index.ts +27 -0
  214. package/src/conversation/participant.ts +71 -0
  215. package/src/conversation/presence.ts +60 -0
  216. package/src/conversation/presenceBus.ts +109 -0
  217. package/src/conversation/presenceRegistry.ts +83 -0
  218. package/src/conversation/roster.ts +111 -0
  219. package/src/conversation/rosterProjection.ts +98 -0
  220. package/src/conversation/router.ts +96 -0
  221. package/src/conversation/runtime.ts +188 -0
  222. package/src/conversation/types.ts +100 -0
  223. package/src/conversation/voice.ts +402 -0
  224. package/src/graphSchema.ts +396 -13
  225. package/src/http.ts +72 -0
  226. package/src/index.ts +9 -0
  227. package/src/platformAssistant.ts +347 -0
  228. package/src/reactor/chunkDistribution.ts +98 -0
  229. package/src/reactor/index.ts +5 -0
  230. package/src/reactor/longLiveCommandDispatcher.ts +156 -0
  231. package/src/reactor/scenesFromEnrichment.ts +11 -76
  232. package/src/reactor/seedImageOrchestrator.ts +12 -13
  233. package/src/reactor/storyTimeline.ts +127 -0
  234. package/src/storyGraph.ts +298 -0
  235. package/src/vision/VisionSourceController.ts +354 -0
  236. package/src/vision/__tests__/VisionSourceController.test.ts +719 -0
  237. package/src/vision/index.ts +13 -0
  238. package/src/vision/sourceKinds.ts +75 -0
  239. package/src/websocket.ts +75 -3
package/src/admin.ts ADDED
@@ -0,0 +1,310 @@
1
+ /**
2
+ * Admin control-plane client (GitHub #215 Phase 2): the prompt-defaults editor.
3
+ *
4
+ * Additive surface — a new `AdminClient` class plus its `PromptDefault*` types.
5
+ * It does NOT touch `ApiClient`'s public API (the `^0.x`-pinned external
6
+ * consumer must keep working). The admin endpoints live on the CHAT API base
7
+ * (the router is mounted in `api/chat/app.py`), so `AdminClient` is constructed
8
+ * with the chat base URL + session token, mirroring how `ApiClient` routes
9
+ * persona/chat calls through `chatRequest`.
10
+ */
11
+
12
+ import { requestJson } from './http';
13
+
14
+ /** Where a prompt's effective value comes from. Mirrors the backend enum. */
15
+ export type PromptDefaultSource = 'db' | 'code';
16
+
17
+ /** One row in the editor list: identity + source + audit metadata (no body). */
18
+ export interface PromptDefaultSummary {
19
+ promptKey: string;
20
+ label: string;
21
+ group: string;
22
+ source: PromptDefaultSource;
23
+ updatedAt: string | null;
24
+ updatedBy: string | null;
25
+ editable: boolean;
26
+ }
27
+
28
+ /** Response for `GET /api/v1/admin/prompts`. */
29
+ export interface PromptDefaultsListResponse {
30
+ prompts: PromptDefaultSummary[];
31
+ traceId: string;
32
+ }
33
+
34
+ /** Single-key detail: effective value + in-code default (for diff) + metadata. */
35
+ export interface PromptDefaultDetail {
36
+ promptKey: string;
37
+ label: string;
38
+ group: string;
39
+ source: PromptDefaultSource;
40
+ value: string;
41
+ codeDefault: string;
42
+ previousValue: string | null;
43
+ updatedAt: string | null;
44
+ updatedBy: string | null;
45
+ editable: boolean;
46
+ traceId: string;
47
+ }
48
+
49
+ /** Body for `PUT /api/v1/admin/prompts/{key}`. */
50
+ export interface UpdatePromptDefaultRequest {
51
+ value: string;
52
+ }
53
+
54
+ /**
55
+ * One read-only regeneration base prompt from `GET /api/v1/admin/regen-prompts`
56
+ * (R6d). Mirrors the backend `RegenBasePrompt` (`api/admin/schemas.py`) EXACTLY.
57
+ * These prompts are eval-gated (tuned via observability/eval promotion,
58
+ * tech-debt #336) — `editable` is always `false` and the API exposes NO write
59
+ * path for them.
60
+ */
61
+ export interface RegenBasePrompt {
62
+ promptKey: string;
63
+ label: string;
64
+ group: string;
65
+ /** Regeneration scope kind: 'acts' | 'characters' | 'scene' | 'arc'. */
66
+ scopeKind: string;
67
+ /** The in-code base prompt text, verbatim. */
68
+ prompt: string;
69
+ editable: boolean;
70
+ }
71
+
72
+ /** Response for `GET /api/v1/admin/regen-prompts` (read-only list). */
73
+ export interface RegenBasePromptsResponse {
74
+ prompts: RegenBasePrompt[];
75
+ traceId: string;
76
+ }
77
+
78
+ /**
79
+ * One scored synthetic-eval run from `GET /api/v1/admin/eval-runs` (M12 S4/S5).
80
+ *
81
+ * Mirrors the backend `EvalRunSummary` (`api/admin/schemas.py`) EXACTLY —
82
+ * same camelCase field names + nullability. The internal PK/SK/gsi1pk/gsi1sk
83
+ * storage keys are dropped server-side, so they never appear here. `metrics`
84
+ * and the optional provenance fields are always sent by the endpoint (the
85
+ * Python model merely defaults them).
86
+ */
87
+ export interface EvalRunSummary {
88
+ evalRunId: string;
89
+ benchmarkId: string;
90
+ scenarioId: string;
91
+ status: string;
92
+ createdAt: string;
93
+ metrics: Record<string, number>;
94
+ scenarioSetId: string | null;
95
+ scenarioType: string | null;
96
+ promptVersion: string | null;
97
+ pipelineVersion: string | null;
98
+ modelId: string | null;
99
+ routeName: string | null;
100
+ costTier: string | null;
101
+ latencyMs: number | null;
102
+ estimatedCostUsd: number | null;
103
+ }
104
+
105
+ /** One cursor-paginated page from `GET /api/v1/admin/eval-runs`. */
106
+ export interface EvalRunsListResponse {
107
+ runs: EvalRunSummary[];
108
+ nextCursor: string | null;
109
+ traceId: string;
110
+ }
111
+
112
+ /**
113
+ * Query params for `listEvalRuns`.
114
+ *
115
+ * The server enforces an XOR contract: provide EXACTLY ONE of `benchmarkId`
116
+ * (base-table access path) or `promptVersion` (GSI1 access path) — neither or
117
+ * both yields a 422. The client does not pre-validate; it forwards whatever is
118
+ * given.
119
+ */
120
+ export interface ListEvalRunsParams {
121
+ benchmarkId?: string;
122
+ promptVersion?: string;
123
+ limit?: number;
124
+ cursor?: string;
125
+ }
126
+
127
+ /**
128
+ * Result of `listAllEvalRuns`: the accumulated runs plus whether the page cap
129
+ * was hit. `truncated` is `true` when {@link MAX_EVAL_RUN_PAGES} was reached
130
+ * with more pages still pending — `runs` is then a newest-first PREFIX, NOT the
131
+ * full series, so the caller must warn rather than present it as complete.
132
+ */
133
+ export interface AllEvalRunsResult {
134
+ runs: EvalRunSummary[];
135
+ truncated: boolean;
136
+ }
137
+
138
+ const ADMIN_PROMPTS_PATH = '/api/v1/admin/prompts';
139
+ const ADMIN_EVAL_RUNS_PATH = '/api/v1/admin/eval-runs';
140
+ const ADMIN_REGEN_PROMPTS_PATH = '/api/v1/admin/regen-prompts';
141
+
142
+ /**
143
+ * Safety cap on `listAllEvalRuns` pagination. A misbehaving server that always
144
+ * returns a non-null `nextCursor` would otherwise loop forever; 50 pages at the
145
+ * default page limit is plenty for an admin trend view, so we stop (not throw)
146
+ * at the cap and the page renders what it has.
147
+ */
148
+ export const MAX_EVAL_RUN_PAGES = 50;
149
+
150
+ /**
151
+ * Client for the admin prompt-defaults CRUD surface.
152
+ *
153
+ * The auth gate is the allow-all `get_user_id` floor today (any authenticated
154
+ * user); the per-user/admin gate is deferred to the future RBAC milestone. The
155
+ * server enforces the editable-key carve-out (extraction-template keys are not
156
+ * editable) regardless — a non-editable key yields a 404, surfaced here as a
157
+ * thrown `Error`.
158
+ */
159
+ export class AdminClient {
160
+ private chatBaseUrl: string;
161
+ private sessionToken?: string;
162
+
163
+ constructor(chatBaseUrl: string, sessionToken?: string) {
164
+ this.chatBaseUrl = chatBaseUrl;
165
+ this.sessionToken = sessionToken;
166
+ }
167
+
168
+ /** Update the bearer token (e.g. after a Descope session refresh). */
169
+ setSessionToken(token: string | undefined): void {
170
+ this.sessionToken = token;
171
+ }
172
+
173
+ /** List every editable prompt key with its source (db|code) + audit metadata. */
174
+ async listPromptDefaults(
175
+ options: { signal?: AbortSignal } = {},
176
+ ): Promise<PromptDefaultsListResponse> {
177
+ return requestJson<PromptDefaultsListResponse>(
178
+ this.chatBaseUrl,
179
+ ADMIN_PROMPTS_PATH,
180
+ this.sessionToken,
181
+ { signal: options.signal },
182
+ );
183
+ }
184
+
185
+ /** Get one key's effective value, in-code default (for diff), and metadata. */
186
+ async getPromptDefault(
187
+ promptKey: string,
188
+ options: { signal?: AbortSignal } = {},
189
+ ): Promise<PromptDefaultDetail> {
190
+ return requestJson<PromptDefaultDetail>(
191
+ this.chatBaseUrl,
192
+ `${ADMIN_PROMPTS_PATH}/${encodeURIComponent(promptKey)}`,
193
+ this.sessionToken,
194
+ { signal: options.signal },
195
+ );
196
+ }
197
+
198
+ /** Create or update an override (201 on create, 200 on update server-side). */
199
+ async updatePromptDefault(
200
+ promptKey: string,
201
+ body: UpdatePromptDefaultRequest,
202
+ options: { signal?: AbortSignal } = {},
203
+ ): Promise<PromptDefaultDetail> {
204
+ return requestJson<PromptDefaultDetail>(
205
+ this.chatBaseUrl,
206
+ `${ADMIN_PROMPTS_PATH}/${encodeURIComponent(promptKey)}`,
207
+ this.sessionToken,
208
+ { method: 'PUT', body: JSON.stringify(body), signal: options.signal },
209
+ );
210
+ }
211
+
212
+ /** One-step revert: restores the previous value, else the in-code default. */
213
+ async revertPromptDefault(
214
+ promptKey: string,
215
+ options: { signal?: AbortSignal } = {},
216
+ ): Promise<PromptDefaultDetail> {
217
+ return requestJson<PromptDefaultDetail>(
218
+ this.chatBaseUrl,
219
+ `${ADMIN_PROMPTS_PATH}/${encodeURIComponent(promptKey)}/revert`,
220
+ this.sessionToken,
221
+ { method: 'POST', signal: options.signal },
222
+ );
223
+ }
224
+
225
+ /**
226
+ * List the AI-tuned regeneration base prompts (acts/characters/scene/arc),
227
+ * READ-ONLY (R6d). There is no corresponding write method — the backend
228
+ * exposes no PUT/POST for these prompts; they are tuned via the eval-gated
229
+ * promotion (tech-debt #336), never the admin editor.
230
+ */
231
+ async listRegenBasePrompts(
232
+ options: { signal?: AbortSignal } = {},
233
+ ): Promise<RegenBasePromptsResponse> {
234
+ return requestJson<RegenBasePromptsResponse>(
235
+ this.chatBaseUrl,
236
+ ADMIN_REGEN_PROMPTS_PATH,
237
+ this.sessionToken,
238
+ { signal: options.signal },
239
+ );
240
+ }
241
+
242
+ /**
243
+ * Fetch one cursor-paginated page of scored synthetic-eval runs (M12 S5).
244
+ *
245
+ * The server enforces the XOR contract — EXACTLY ONE of `benchmarkId` or
246
+ * `promptVersion` (neither/both → 422). This client does NOT pre-validate; it
247
+ * forwards the params as given and lets `requestJson` surface a 422 as a
248
+ * thrown `Error`. Only defined params are appended to the query string.
249
+ */
250
+ async listEvalRuns(
251
+ params: ListEvalRunsParams,
252
+ options: { signal?: AbortSignal } = {},
253
+ ): Promise<EvalRunsListResponse> {
254
+ const search = new URLSearchParams();
255
+ if (params.benchmarkId !== undefined) {
256
+ search.set('benchmarkId', params.benchmarkId);
257
+ }
258
+ if (params.promptVersion !== undefined) {
259
+ search.set('promptVersion', params.promptVersion);
260
+ }
261
+ if (params.limit !== undefined) {
262
+ search.set('limit', String(params.limit));
263
+ }
264
+ if (params.cursor !== undefined) {
265
+ search.set('cursor', params.cursor);
266
+ }
267
+ const qs = search.toString();
268
+ const path = qs ? `${ADMIN_EVAL_RUNS_PATH}?${qs}` : ADMIN_EVAL_RUNS_PATH;
269
+ return requestJson<EvalRunsListResponse>(
270
+ this.chatBaseUrl,
271
+ path,
272
+ this.sessionToken,
273
+ { signal: options.signal },
274
+ );
275
+ }
276
+
277
+ /**
278
+ * Page through ALL eval runs for the given selector, newest-first.
279
+ *
280
+ * Follows `nextCursor` until it is `null`, accumulating runs. Stops (does NOT
281
+ * throw) at {@link MAX_EVAL_RUN_PAGES} so a misbehaving server — or simply a
282
+ * benchmark with more history than the cap covers — cannot spin forever. When
283
+ * the cap is hit with pages still pending, the returned `runs` is a
284
+ * newest-first PREFIX and `truncated` is `true`, so the caller can warn rather
285
+ * than present a partial series as complete (the `/observability` page does).
286
+ * The caller's `params` are never mutated (the cursor lives in a local). Any
287
+ * `params.cursor` is IGNORED — "list ALL" always starts from the newest page,
288
+ * so a stray cursor can't silently begin mid-series. Honors `options.signal`
289
+ * on every page request.
290
+ */
291
+ async listAllEvalRuns(
292
+ params: ListEvalRunsParams,
293
+ options: { signal?: AbortSignal } = {},
294
+ ): Promise<AllEvalRunsResult> {
295
+ const runs: EvalRunSummary[] = [];
296
+ // Start at the newest page regardless of any caller-supplied params.cursor —
297
+ // mid-series start would silently return a truncated history.
298
+ let cursor: string | undefined = undefined;
299
+ for (let page = 0; page < MAX_EVAL_RUN_PAGES; page += 1) {
300
+ const response = await this.listEvalRuns({ ...params, cursor }, options);
301
+ runs.push(...response.runs);
302
+ if (response.nextCursor === null) {
303
+ return { runs, truncated: false };
304
+ }
305
+ cursor = response.nextCursor;
306
+ }
307
+ // Exhausted the page cap with a non-null cursor still pending — partial.
308
+ return { runs, truncated: true };
309
+ }
310
+ }