@datalayer/core 1.1.66 → 1.2.10

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 (210) hide show
  1. package/README.md +41 -18
  2. package/lib/api/constants.d.ts +1 -1
  3. package/lib/api/constants.js +1 -1
  4. package/lib/api/contents/attachments.js +3 -7
  5. package/lib/api/contents/datasets.d.ts +48 -0
  6. package/lib/api/contents/datasets.js +44 -7
  7. package/lib/api/contents/runtimeMounts.js +1 -1
  8. package/lib/api/contents/sandboxUid.d.ts +13 -45
  9. package/lib/api/contents/sandboxUid.js +14 -65
  10. package/lib/api/evals/client.d.ts +402 -0
  11. package/lib/api/evals/client.js +359 -0
  12. package/lib/api/evals/index.d.ts +10 -0
  13. package/lib/api/evals/index.js +18 -0
  14. package/lib/api/evals/request.d.ts +43 -0
  15. package/lib/api/evals/request.js +67 -0
  16. package/lib/api/evals/status.d.ts +27 -0
  17. package/lib/api/evals/status.js +122 -0
  18. package/lib/api/evals/types.d.ts +1335 -0
  19. package/lib/api/evals/types.js +5 -0
  20. package/lib/api/iam/connectedAgents.d.ts +29 -0
  21. package/lib/api/iam/connectedAgents.js +35 -0
  22. package/lib/api/iam/identityProviders.d.ts +76 -0
  23. package/lib/api/iam/identityProviders.js +187 -0
  24. package/lib/api/iam/index.d.ts +1 -0
  25. package/lib/api/iam/index.js +1 -0
  26. package/lib/api/iam/mcpPolicy.d.ts +102 -1
  27. package/lib/api/iam/mcpPolicy.js +38 -2
  28. package/lib/api/iam/profile.d.ts +17 -1
  29. package/lib/api/iam/profile.js +27 -0
  30. package/lib/api/iam/scimTokens.d.ts +79 -0
  31. package/lib/api/iam/scimTokens.js +141 -0
  32. package/lib/api/iam/secrets.js +9 -21
  33. package/lib/api/iam/trials.d.ts +38 -0
  34. package/lib/api/iam/trials.js +66 -0
  35. package/lib/api/index.d.ts +4 -0
  36. package/lib/api/index.js +4 -0
  37. package/lib/api/mcp/observability.d.ts +25 -9
  38. package/lib/api/mcp/observability.js +63 -50
  39. package/lib/api/orchestration/client.d.ts +53 -0
  40. package/lib/api/orchestration/client.js +105 -0
  41. package/lib/api/orchestration/events.d.ts +88 -0
  42. package/lib/api/orchestration/events.js +245 -0
  43. package/lib/api/orchestration/generated.d.ts +693 -0
  44. package/lib/api/orchestration/generated.js +687 -0
  45. package/lib/api/orchestration/index.d.ts +30 -0
  46. package/lib/api/orchestration/index.js +34 -0
  47. package/lib/api/orchestration/lifecycle.d.ts +39 -0
  48. package/lib/api/orchestration/lifecycle.js +57 -0
  49. package/lib/api/orchestration/measures.d.ts +55 -0
  50. package/lib/api/orchestration/measures.js +99 -0
  51. package/lib/api/otel/dashboards.d.ts +56 -0
  52. package/lib/api/otel/dashboards.js +50 -0
  53. package/lib/api/otel/index.d.ts +1 -0
  54. package/lib/api/otel/index.js +1 -0
  55. package/lib/api/otel/metrics.d.ts +16 -0
  56. package/lib/api/otel/metrics.js +15 -0
  57. package/lib/api/scheduler/client.d.ts +32 -0
  58. package/lib/api/scheduler/client.js +42 -0
  59. package/lib/api/scheduler/index.d.ts +8 -0
  60. package/lib/api/scheduler/index.js +16 -0
  61. package/lib/api/scheduler/request.d.ts +28 -0
  62. package/lib/api/scheduler/request.js +50 -0
  63. package/lib/api/scheduler/types.d.ts +88 -0
  64. package/lib/api/scheduler/types.js +5 -0
  65. package/lib/api/spacer/comments.d.ts +97 -0
  66. package/lib/api/spacer/comments.js +45 -0
  67. package/lib/api/spacer/index.d.ts +9 -0
  68. package/lib/api/spacer/index.js +17 -0
  69. package/lib/api/spacer/notebooks.d.ts +33 -0
  70. package/lib/api/spacer/notebooks.js +39 -0
  71. package/lib/api/spacer/request.d.ts +25 -0
  72. package/lib/api/spacer/request.js +46 -0
  73. package/lib/api/spacer/spaces.d.ts +68 -0
  74. package/lib/api/spacer/spaces.js +45 -0
  75. package/lib/api/utils/validation.d.ts +4 -4
  76. package/lib/api/utils/validation.js +10 -7
  77. package/lib/client/constants.d.ts +1 -0
  78. package/lib/client/constants.js +1 -0
  79. package/lib/components/animation/AnimatedText.d.ts +1 -44
  80. package/lib/components/animation/AnimatedText.js +6 -122
  81. package/lib/components/anonymous/AnonymousKeyExpired.d.ts +56 -0
  82. package/lib/components/anonymous/AnonymousKeyExpired.js +96 -0
  83. package/lib/components/anonymous/AnonymousKeyTimer.d.ts +63 -0
  84. package/lib/components/anonymous/AnonymousKeyTimer.js +140 -0
  85. package/lib/components/anonymous/index.d.ts +7 -0
  86. package/lib/components/anonymous/index.js +15 -0
  87. package/lib/components/avatars/UserAvatar.d.ts +7 -1
  88. package/lib/components/avatars/UserAvatar.js +15 -1
  89. package/lib/components/billing/BillingEntitySelect.d.ts +6 -0
  90. package/lib/components/billing/BillingEntitySelect.js +49 -10
  91. package/lib/components/billing/eligibility.d.ts +22 -0
  92. package/lib/components/billing/eligibility.js +27 -0
  93. package/lib/components/billing/index.d.ts +1 -0
  94. package/lib/components/billing/index.js +1 -0
  95. package/lib/components/collaboration/LiveEditorCollaborators.d.ts +5 -0
  96. package/lib/components/collaboration/LiveEditorCollaborators.js +3 -1
  97. package/lib/components/display/DatalayerBox.d.ts +2 -3
  98. package/lib/components/display/DatalayerBox.js +1 -1
  99. package/lib/components/display/NavLink.js +3 -2
  100. package/lib/components/labels/StatusLabels.d.ts +2 -10
  101. package/lib/components/labels/StatusLabels.js +2 -26
  102. package/lib/components/principal/PrincipalAppearance.d.ts +21 -42
  103. package/lib/components/principal/PrincipalAppearance.js +232 -174
  104. package/lib/components/principal/PrincipalAvatar.d.ts +8 -1
  105. package/lib/components/principal/PrincipalAvatar.js +2 -2
  106. package/lib/components/principal/PrincipalDetailsOverlay.d.ts +8 -1
  107. package/lib/components/principal/PrincipalDetailsOverlay.js +2 -2
  108. package/lib/components/screencapture/Screencapture.js +46 -3
  109. package/lib/components/sharing/ShareAccessComponent.d.ts +45 -4
  110. package/lib/components/sharing/ShareAccessComponent.js +110 -78
  111. package/lib/components/sharing/SharingEditor.d.ts +5 -1
  112. package/lib/components/sharing/SharingEditor.js +9 -4
  113. package/lib/components/sharing/index.d.ts +1 -0
  114. package/lib/components/sharing/index.js +1 -0
  115. package/lib/components/sharing/sandboxSharing.d.ts +26 -0
  116. package/lib/components/sharing/sandboxSharing.js +41 -0
  117. package/lib/components/spaces/SpaceDetailsOverlay.d.ts +39 -0
  118. package/lib/components/spaces/SpaceDetailsOverlay.js +80 -0
  119. package/lib/components/spaces/SpaceDisplay.d.ts +38 -0
  120. package/lib/components/spaces/SpaceDisplay.js +92 -0
  121. package/lib/components/spaces/index.d.ts +4 -0
  122. package/lib/components/spaces/index.js +7 -0
  123. package/lib/components/spaces/spaceDisplayModel.d.ts +93 -0
  124. package/lib/components/spaces/spaceDisplayModel.js +170 -0
  125. package/lib/hooks/cacheConverters.d.ts +0 -7
  126. package/lib/hooks/cacheConverters.js +0 -25
  127. package/lib/hooks/index.d.ts +1 -0
  128. package/lib/hooks/index.js +1 -0
  129. package/lib/hooks/useBillingEntityStore.js +3 -0
  130. package/lib/hooks/useCache.d.ts +168 -25
  131. package/lib/hooks/useCache.js +1424 -307
  132. package/lib/hooks/useContents.d.ts +22 -1
  133. package/lib/hooks/useContents.js +90 -21
  134. package/lib/hooks/useMcp.d.ts +87 -1
  135. package/lib/hooks/useMcp.js +247 -12
  136. package/lib/hooks/useNavigate.d.ts +41 -3
  137. package/lib/hooks/useNavigate.js +106 -52
  138. package/lib/hooks/usePrincipalCacheStore.js +3 -0
  139. package/lib/hooks/usePrincipalStore.js +3 -0
  140. package/lib/hooks/useSpaceCacheStore.d.ts +50 -0
  141. package/lib/hooks/useSpaceCacheStore.js +85 -0
  142. package/lib/models/CreditsDTO.d.ts +6 -5
  143. package/lib/models/CreditsDTO.js +7 -5
  144. package/lib/models/McpBinding.d.ts +6 -0
  145. package/lib/models/Organization.d.ts +69 -0
  146. package/lib/models/Organization.js +96 -0
  147. package/lib/models/Secret.d.ts +1 -2
  148. package/lib/models/Secret.js +2 -18
  149. package/lib/models/StartedBy.d.ts +34 -0
  150. package/lib/models/StartedBy.js +36 -0
  151. package/lib/models/Team.d.ts +2 -0
  152. package/lib/models/Team.js +2 -0
  153. package/lib/models/User.d.ts +4 -0
  154. package/lib/models/User.js +3 -0
  155. package/lib/models/UserSettings.d.ts +13 -0
  156. package/lib/models/UserSettings.js +9 -0
  157. package/lib/models/contents/__fixtures__/v1-contracts.json +158 -30
  158. package/lib/navigation/components.js +2 -3
  159. package/lib/routes/publicPaths.js +4 -0
  160. package/lib/state/index.d.ts +1 -0
  161. package/lib/state/index.js +1 -0
  162. package/lib/state/sessionEnd.d.ts +55 -0
  163. package/lib/state/sessionEnd.js +162 -0
  164. package/lib/state/substates/CoreState.js +3 -3
  165. package/lib/state/substates/IAMState.js +7 -0
  166. package/lib/state/substates/LayoutState.js +12 -0
  167. package/lib/state/substates/ProfileState.d.ts +1 -0
  168. package/lib/state/substates/ProfileState.js +1 -0
  169. package/lib/utils/Lazy.d.ts +20 -0
  170. package/lib/utils/Lazy.js +32 -6
  171. package/lib/utils/Screencapture.js +3 -0
  172. package/lib/utils/WithSuspense.d.ts +11 -1
  173. package/lib/utils/WithSuspense.js +11 -1
  174. package/lib/views/mcp/AdmittedClients.d.ts +44 -0
  175. package/lib/views/mcp/AdmittedClients.js +59 -0
  176. package/lib/views/mcp/ApprovalQueue.d.ts +66 -0
  177. package/lib/views/mcp/ApprovalQueue.js +95 -0
  178. package/lib/views/mcp/ConnectedAgents.js +38 -3
  179. package/lib/views/mcp/EnterpriseConsole.d.ts +1 -1
  180. package/lib/views/mcp/EnterpriseConsole.js +23 -1
  181. package/lib/views/mcp/IdentityProviders.d.ts +33 -0
  182. package/lib/views/mcp/IdentityProviders.js +299 -0
  183. package/lib/views/mcp/McpDashboard.js +90 -7
  184. package/lib/views/mcp/McpObservability.d.ts +30 -1
  185. package/lib/views/mcp/McpObservability.js +105 -19
  186. package/lib/views/mcp/NotebookRuns.d.ts +39 -0
  187. package/lib/views/mcp/NotebookRuns.js +44 -0
  188. package/lib/views/mcp/OrganizationPolicy.js +2 -1
  189. package/lib/views/mcp/PersonalPolicy.js +2 -1
  190. package/lib/views/mcp/PolicyForm.d.ts +17 -1
  191. package/lib/views/mcp/PolicyForm.js +25 -3
  192. package/lib/views/mcp/PolicyHistory.d.ts +13 -0
  193. package/lib/views/mcp/PolicyHistory.js +14 -1
  194. package/lib/views/mcp/RunDetail.d.ts +87 -0
  195. package/lib/views/mcp/RunDetail.js +186 -0
  196. package/lib/views/mcp/ScimProvisioning.d.ts +54 -0
  197. package/lib/views/mcp/ScimProvisioning.js +173 -0
  198. package/lib/views/mcp/TeamPolicies.js +66 -5
  199. package/lib/views/mcp/ToolAccess.d.ts +60 -0
  200. package/lib/views/mcp/ToolAccess.js +101 -0
  201. package/lib/views/mcp/TraceTimeline.d.ts +81 -0
  202. package/lib/views/mcp/TraceTimeline.js +132 -0
  203. package/lib/views/mcp/index.d.ts +5 -0
  204. package/lib/views/mcp/index.js +5 -0
  205. package/lib/views/otel/simpleAuthStore.js +3 -0
  206. package/lib/views/secrets/SecretEdit.js +3 -2
  207. package/lib/views/secrets/SecretNew.js +5 -1
  208. package/package.json +269 -264
  209. package/scripts/generate-mcp-types.py +1 -1
  210. package/scripts/generate-orchestration-types.py +920 -0
@@ -0,0 +1,359 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /*
6
+ * Copyright (c) 2023-2026 Datalayer, Inc.
7
+ * Distributed under the terms of the Modified BSD License.
8
+ */
9
+ /**
10
+ * The evals API, one function per endpoint.
11
+ *
12
+ * Paths mirror `tests/test_evals_api_contract.py` in the AI Agents service
13
+ * and `evalsApiContract.spec.ts` in the landings UI. Downloads (export and
14
+ * report) are URLs rather than requests: the browser opens them and the
15
+ * service answers with an attachment.
16
+ *
17
+ * @module api/evals/client
18
+ */
19
+ import { evalsRequest, evalsUrl, segment, } from './request.js';
20
+ export const listEvalsets = (options, query = {}) => evalsRequest(options, '/evalsets', { query });
21
+ export const getEvalset = (options, evalsetId) => evalsRequest(options, `/evalsets/${segment(evalsetId)}`);
22
+ export const createEvalset = (options, body) => evalsRequest(options, '/evalsets', { method: 'POST', body });
23
+ export const updateEvalset = (options, evalsetId, body) => evalsRequest(options, `/evalsets/${segment(evalsetId)}`, {
24
+ method: 'PATCH',
25
+ body,
26
+ });
27
+ export const setEvalsetPublic = (options, evalsetId, isPublic) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/public`, {
28
+ method: 'PATCH',
29
+ body: { is_public: isPublic },
30
+ });
31
+ /**
32
+ * Take a benchmark into the account the options name (B5-03): a private copy
33
+ * of its definition that says what it was taken from. A published benchmark
34
+ * is anybody's to take; an unpublished one, a Viewer's. `derivation` says why:
35
+ * `fork` to change it, `compare` to run it against one's own agent (B5-05).
36
+ */
37
+ export const cloneEvalset = (options, evalsetId, body = {}) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/clone`, {
38
+ method: 'POST',
39
+ body,
40
+ });
41
+ /**
42
+ * Propose the next version of a benchmark's definition, from an investigation
43
+ * (B5-07): a task added or corrected, a corrected evaluator, a threshold
44
+ * moved. The version records the investigation that asked for it.
45
+ */
46
+ export const reviseEvalset = (options, evalsetId, body) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/revisions`, {
47
+ method: 'POST',
48
+ body,
49
+ });
50
+ /**
51
+ * What publishing this benchmark would put in the library (B5-02): the
52
+ * contents of the package, the enumeration the publication review shows, what
53
+ * is left out and why, and everything that would refuse it — before anybody
54
+ * presses the button, because a publication cannot be taken back from whoever
55
+ * already read it.
56
+ */
57
+ export const previewEvalsetPublication = (options, evalsetId, query = {}) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/publication/preview`, { query });
58
+ /**
59
+ * Publish the package: the immutable snapshot of the definition, the data, the
60
+ * subjects, the environment, the results, the report, the evidence and the
61
+ * evaluators (section 14.3). Refused with `detail.problems` where section 14.5
62
+ * says it cannot be published.
63
+ */
64
+ export const publishEvalsetPackage = (options, evalsetId, body = {}) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/publications`, {
65
+ method: 'POST',
66
+ body,
67
+ });
68
+ /** Every package published of this benchmark, withdrawn ones included. */
69
+ export const listEvalsetPublications = (options, evalsetId, query = {}) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/publications`, { query });
70
+ /**
71
+ * Take a package out of the library. What it holds stays as it was written:
72
+ * withdrawing a snapshot does not make it editable.
73
+ */
74
+ export const withdrawEvalsetPublication = (options, evalsetId, publicationId) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/publications/${segment(publicationId)}`, { method: 'DELETE' });
75
+ /** The package a published benchmark stands for, to anybody (B5-02). */
76
+ export const getPublicEvalsetPublication = (options, evalsetId) => evalsRequest(options, `/public/evalsets/${segment(evalsetId)}/publication`);
77
+ /**
78
+ * Launches of one benchmark side by side (B5-08): what each scored, what each
79
+ * subject scored in each, and which tasks went from passing to failing or
80
+ * back. Launch ids are compared in the order given, oldest first; the two
81
+ * newest launches where none is named.
82
+ */
83
+ export const compareEvalsetLaunches = (options, evalsetId, query = {}) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/comparison`, { query });
84
+ /**
85
+ * The subjects that ran a published benchmark, best first. Only runs a package
86
+ * published are counted (B5-02), and each row names the package its best run
87
+ * came from.
88
+ */
89
+ export const getPublicEvalsetLeaderboard = (options, evalsetId) => evalsRequest(options, `/public/evalsets/${segment(evalsetId)}/leaderboard`);
90
+ /**
91
+ * What an agent or a model has actually run (B5-12): the benchmarks that ran
92
+ * it, what its runs scored, what they cost, how long they took, and the
93
+ * launches still going. Empty where it has never been run.
94
+ *
95
+ * The ref keeps its slashes — an agentspec id has one — so each segment is
96
+ * encoded rather than the whole string.
97
+ */
98
+ export const getSubjectUsage = (options, subjectRef) => evalsRequest(options, `/subjects/${subjectRef.split('/').map(encodeURIComponent).join('/')}/usage`);
99
+ /**
100
+ * Whether anything will run the account's benchmarks (B5-12, section 15.2):
101
+ * the executor, whether a worker polls the benchmark queue, and the account's
102
+ * own queued and running launches.
103
+ */
104
+ export const getBenchmarkCompute = (options) => evalsRequest(options, '/compute/operations');
105
+ /**
106
+ * What benchmark work a sandbox is doing (B5-12, section 15.4).
107
+ *
108
+ * The ref is a pool slot's name (`benchmark-<run>-slot-<n>`) or the snapshot
109
+ * a sandbox was restored from. A sandbox of nobody's benchmark answers
110
+ * `found: false`, so a page asks without knowing in advance.
111
+ */
112
+ export const getSandboxProvenance = (options, sandboxRef) => evalsRequest(options, `/sandboxes/${sandboxRef.split('/').map(encodeURIComponent).join('/')}/provenance`);
113
+ /**
114
+ * Find things across the caller's benchmarks (B5-11, section 19): benchmarks,
115
+ * launches, tasks, reports and investigations, each row keeping its kind and
116
+ * what it belongs to.
117
+ *
118
+ * Nobody types a field name, so the service reads the words first: a status
119
+ * word becomes a status, `run 128` becomes a launch number, and what is left
120
+ * is the text. An empty query finds nothing rather than everything.
121
+ */
122
+ export const searchEvals = (options, query = {}) => evalsRequest(options, '/search', { query });
123
+ export const renameEvalset = (options, evalsetId, name) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/rename`, {
124
+ method: 'PATCH',
125
+ body: { name },
126
+ });
127
+ export const deleteEvalset = (options, evalsetId) => evalsRequest(options, `/evalsets/${segment(evalsetId)}`, {
128
+ method: 'DELETE',
129
+ });
130
+ // --- Cases ------------------------------------------------------------------
131
+ export const listCases = (options, evalsetId) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/cases`);
132
+ export const createCase = (options, evalsetId, body) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/cases`, {
133
+ method: 'POST',
134
+ body,
135
+ });
136
+ export const updateCase = (options, evalsetId, caseId, body) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/cases/${segment(caseId)}`, {
137
+ method: 'PATCH',
138
+ body,
139
+ });
140
+ export const deleteCase = (options, evalsetId, caseId) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/cases/${segment(caseId)}`, {
141
+ method: 'DELETE',
142
+ });
143
+ /** The URL the browser opens to download an evalset definition. */
144
+ export const evalsetExportUrl = (options, evalsetId, format = 'json') => evalsUrl(options, `/evalsets/${segment(evalsetId)}/export`, { format });
145
+ /** The URL the browser opens to download a generated report. */
146
+ export const evalsetReportUrl = (options, evalsetId, format = 'markdown', runLimit) => evalsUrl(options, `/evalsets/${segment(evalsetId)}/report`, {
147
+ format,
148
+ run_limit: runLimit,
149
+ });
150
+ // --- Public reads -----------------------------------------------------------
151
+ export const getPublicEvalset = (options, evalsetId) => evalsRequest(options, `/public/evalsets/${segment(evalsetId)}`);
152
+ export const getPublicEvalsetDetails = (options, evalsetId, runsLimit) => evalsRequest(options, `/public/evalsets/${segment(evalsetId)}/details`, {
153
+ query: { runs_limit: runsLimit },
154
+ });
155
+ export const listPublicRuns = (options, evalsetId, experimentId, query = {}) => evalsRequest(options, `/public/evalsets/${segment(evalsetId)}/experiments/${segment(experimentId)}/runs`, { query });
156
+ export const createExperiment = (options, body) => evalsRequest(options, '/experiments', {
157
+ method: 'POST',
158
+ body,
159
+ });
160
+ export const listExperiments = (options, query = {}) => evalsRequest(options, '/experiments', { query });
161
+ export const getExperiment = (options, experimentId) => evalsRequest(options, `/experiments/${segment(experimentId)}`);
162
+ export const updateExperiment = (options, experimentId, body) => evalsRequest(options, `/experiments/${segment(experimentId)}`, {
163
+ method: 'PATCH',
164
+ body,
165
+ });
166
+ export const deleteExperiment = (options, experimentId) => evalsRequest(options, `/experiments/${segment(experimentId)}`, {
167
+ method: 'DELETE',
168
+ });
169
+ // --- Runs -------------------------------------------------------------------
170
+ export const createRun = (options, experimentId, body) => evalsRequest(options, `/experiments/${segment(experimentId)}/runs`, {
171
+ method: 'POST',
172
+ body,
173
+ });
174
+ export const listRuns = (options, experimentId, query = {}) => evalsRequest(options, `/experiments/${segment(experimentId)}/runs`, { query });
175
+ export const getRun = (options, runId) => evalsRequest(options, `/runs/${segment(runId)}`);
176
+ export const deleteRun = (options, runId) => evalsRequest(options, `/runs/${segment(runId)}`, {
177
+ method: 'DELETE',
178
+ });
179
+ export const compareRuns = (options, runIds) => evalsRequest(options, '/runs/compare', {
180
+ method: 'POST',
181
+ body: { run_ids: runIds },
182
+ });
183
+ export const createLiveEvent = (options, body) => evalsRequest(options, '/live/events', {
184
+ method: 'POST',
185
+ body,
186
+ });
187
+ export const listLiveTargets = (options, query = {}) => evalsRequest(options, '/live/targets', { query });
188
+ export const listLiveEvents = (options, query) => evalsRequest(options, '/live/events', { query });
189
+ /** The alerts the rolling windows raised: failure spikes and drifts (B2-13). */
190
+ export const listLiveAlerts = (options, query = {}) => evalsRequest(options, '/live/alerts', { query });
191
+ export const deleteLiveTarget = (options, targetId, targetType = 'agent') => evalsRequest(options, '/live/targets', {
192
+ method: 'DELETE',
193
+ query: { target_id: targetId, target_type: targetType },
194
+ });
195
+ export const listRunsAcross = (options, query = {}) => evalsRequest(options, '/runs', { query });
196
+ export const cancelRun = (options, runId) => evalsRequest(options, `/runs/${segment(runId)}/cancel`, {
197
+ method: 'POST',
198
+ });
199
+ /** The task grid of a run, filtered and paged by the service. */
200
+ export const listCaseResults = (options, runId, query = {}) => evalsRequest(options, `/runs/${segment(runId)}/cases`, { query });
201
+ export const getCaseResult = (options, runId, caseId) => evalsRequest(options, `/runs/${segment(runId)}/cases/${segment(caseId)}`);
202
+ /**
203
+ * The run as the network of agents that worked on it. `budget` is how many
204
+ * tasks' messages to answer: every task that did not pass, then passed ones
205
+ * while there is room.
206
+ */
207
+ export const getRunNetwork = (options, runId, query = {}) => evalsRequest(options, `/runs/${segment(runId)}/network`, {
208
+ query,
209
+ });
210
+ /**
211
+ * One message of a run's network, in full. The id is the service's own and
212
+ * holds colons, which the route reads as a path: each segment is encoded, the
213
+ * separators are kept.
214
+ */
215
+ export const getRunNetworkMessage = (options, runId, messageId) => evalsRequest(options, `/runs/${segment(runId)}/network/messages/${messageId.split('/').map(segment).join('/')}`);
216
+ /** A launch's runs, each as one line of its own network. */
217
+ export const getLaunchNetwork = (options, launchId) => evalsRequest(options, `/launches/${segment(launchId)}/network`);
218
+ export const reviewCaseResult = (options, runId, caseId, body) => evalsRequest(options, `/runs/${segment(runId)}/cases/${segment(caseId)}/review`, {
219
+ method: 'PATCH',
220
+ body,
221
+ });
222
+ /**
223
+ * Give an anonymous trial's work to the person who just signed in (B2-14):
224
+ * the benchmark, the launch, its runs and everything under them, moved
225
+ * rather than copied so a link the visitor kept still opens.
226
+ *
227
+ * Takes two credentials: the person's, in the client's options, and the
228
+ * trial's own key, which travels in its header.
229
+ */
230
+ export const claimTrial = (options, trialUid, trialToken) => evalsRequest(options, '/trials/claim', {
231
+ method: 'POST',
232
+ body: { trial_uid: trialUid },
233
+ headers: { 'X-Datalayer-Trial-Token': trialToken },
234
+ });
235
+ /** The subjects an experiment can have, and the models offered (B2-11). */
236
+ export const listSubjects = (options) => evalsRequest(options, '/subjects');
237
+ /**
238
+ * Count one of those.
239
+ *
240
+ * Nothing is stored, and the answer says only that it was counted. Never worth
241
+ * failing a page for: a measure that breaks what somebody was doing is worse
242
+ * than a measure nobody has.
243
+ */
244
+ export const recordProductEvent = (options, event) => evalsRequest(options, '/measures', {
245
+ method: 'POST',
246
+ body: { event },
247
+ });
248
+ /**
249
+ * The plan of a launch before it is made (B2-07): estimated duration and
250
+ * cost, the compute, and the problems that would stop it. Same body as the
251
+ * launch; nothing is created.
252
+ */
253
+ export const validateLaunch = (options, evalsetId, body) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/launches/validate`, {
254
+ method: 'POST',
255
+ body,
256
+ });
257
+ /** One submission of a benchmark across its experiments. */
258
+ export const createLaunch = (options, evalsetId, body) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/launches`, {
259
+ method: 'POST',
260
+ body,
261
+ });
262
+ export const listLaunches = (options, query = {}) => evalsRequest(options, '/launches', { query });
263
+ export const getLaunch = (options, launchId) => evalsRequest(options, `/launches/${segment(launchId)}`);
264
+ export const cancelLaunch = (options, launchId) => evalsRequest(options, `/launches/${segment(launchId)}/cancel`, { method: 'POST' });
265
+ export const archiveLaunch = (options, launchId) => evalsRequest(options, `/launches/${segment(launchId)}/archive`, { method: 'POST' });
266
+ // --- Spec import and definition versions (B2-08, B2-09) --------------------
267
+ /** An evalset from a spec file, the same body the CLI and the action send. */
268
+ export const importEvalset = (options, body) => evalsRequest(options, '/evalsets/import', {
269
+ method: 'POST',
270
+ body,
271
+ });
272
+ export const listEvalsetVersions = (options, evalsetId, query = {}) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/versions`, { query });
273
+ export const getEvalsetVersion = (options, evalsetId, version) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/versions/${segment(String(version))}`);
274
+ // --- Reports of a launch and a run, and the report document (B3-03) --------
275
+ /** The benchmark's whole report (every launch) as a serialized Lexical editor state. */
276
+ export const getEvalsetReportDocument = (options, evalsetId, query = {}) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/report`, { query: { ...query, format: 'lexical' } });
277
+ /** The launch's report as a serialized Lexical editor state. */
278
+ export const getLaunchReportDocument = (options, launchId, query = {}) => evalsRequest(options, `/launches/${segment(launchId)}/report`, { query: { ...query, format: 'lexical' } });
279
+ /** Where a launch's Markdown or CSV report is downloaded from. */
280
+ export const launchReportUrl = (options, launchId, format) => evalsUrl(options, `/launches/${segment(launchId)}/report`, { format });
281
+ /** One run's report as a serialized Lexical editor state, with its task documents. */
282
+ export const getRunReportDocument = (options, runId) => evalsRequest(options, `/runs/${segment(runId)}/report`, { query: { format: 'lexical' } });
283
+ export const runReportUrl = (options, runId, format) => evalsUrl(options, `/runs/${segment(runId)}/report`, { format });
284
+ /** Write the launch's report into the account's benchmarks space. */
285
+ export const writeLaunchReportDocument = (options, launchId, body = {}) => evalsRequest(options, `/launches/${segment(launchId)}/report-document`, { method: 'POST', body });
286
+ // --- Investigations and the task sandbox (B3-02, B3-05) --------------------
287
+ /** Open the investigation of one task, or get the one already open. */
288
+ export const openTaskInvestigation = (options, runId, caseId) => evalsRequest(options, `/runs/${segment(runId)}/tasks/${segment(caseId)}/investigation`, { method: 'POST' });
289
+ export const openLaunchInvestigation = (options, launchId) => evalsRequest(options, `/launches/${segment(launchId)}/investigation`, { method: 'POST' });
290
+ export const listInvestigations = (options, query = {}) => evalsRequest(options, '/investigations', {
291
+ query,
292
+ });
293
+ export const getInvestigation = (options, investigationId) => evalsRequest(options, `/investigations/${segment(investigationId)}`);
294
+ export const updateInvestigation = (options, investigationId, body) => evalsRequest(options, `/investigations/${segment(investigationId)}`, { method: 'PATCH', body });
295
+ /**
296
+ * Publish an investigation to the library, or take it back: its owner's alone.
297
+ * The document and the notebooks it is written in go public and private with
298
+ * it.
299
+ */
300
+ export const setInvestigationPublic = (options, investigationId, isPublic) => evalsRequest(options, `/investigations/${segment(investigationId)}/public`, { method: 'PATCH', body: { is_public: isPublic } });
301
+ /**
302
+ * Keep the investigation's page as it is shown, under a name everybody on
303
+ * the investigation sees; a view of that name is replaced (B4-11).
304
+ */
305
+ export const saveInvestigationView = (options, investigationId, body) => evalsRequest(options, `/investigations/${segment(investigationId)}/views`, { method: 'POST', body });
306
+ /** Forget a saved view of the investigation's page. */
307
+ export const forgetInvestigationView = (options, investigationId, name) => evalsRequest(options, `/investigations/${segment(investigationId)}/views`, { method: 'DELETE', query: { name } });
308
+ /** Bring the task's sandbox back from its snapshot, bound to its investigation. */
309
+ export const resumeTaskSandbox = (options, runId, caseId, body = {}) => evalsRequest(options, `/runs/${segment(runId)}/tasks/${segment(caseId)}/sandbox/resume`, { method: 'POST', body });
310
+ // --- Sharing and permissions (B4-05) ----------------------------------------
311
+ /** Who a benchmark, one of its runs or an investigation is shared with; its owner's to read. */
312
+ export const getEvalsSharing = (options, record, uid) => evalsRequest(options, `/${record}/${segment(uid)}/sharing`);
313
+ /** Replace the grants at the levels named; the others are kept. Its owner's to do. */
314
+ export const updateEvalsSharing = (options, record, uid, access) => evalsRequest(options, `/${record}/${segment(uid)}/sharing`, { method: 'PUT', body: { access } });
315
+ /** The caller's role on the record, and what it allows. */
316
+ export const getEvalsPermissions = (options, record, uid) => evalsRequest(options, `/${record}/${segment(uid)}/permissions`);
317
+ // --- Reports (B4-04) ----------------------------------------------------------
318
+ /** A report over runs of a benchmark, written as a draft. */
319
+ export const createReport = (options, body) => evalsRequest(options, '/reports', { method: 'POST', body });
320
+ export const listReports = (options, query = {}) => evalsRequest(options, '/reports', { query });
321
+ export const getReport = (options, reportId) => evalsRequest(options, `/reports/${segment(reportId)}`);
322
+ /** Send a report for review, send it back, approve it or publish it. */
323
+ export const moveReport = (options, reportId, body) => evalsRequest(options, `/reports/${segment(reportId)}/state`, {
324
+ method: 'POST',
325
+ body,
326
+ });
327
+ /** A new version over newer runs, or the same ones; the old report is superseded by it. */
328
+ export const regenerateReport = (options, reportId, launchIds) => evalsRequest(options, `/reports/${segment(reportId)}/regenerate`, {
329
+ method: 'POST',
330
+ body: launchIds?.length ? { launch_ids: launchIds } : {},
331
+ });
332
+ // --- Review decisions (B4-03) -------------------------------------------------
333
+ /** What a reviewer decided about part of a result, recorded on a report or in an investigation. */
334
+ export const recordDecision = (options, subject, uid, body) => evalsRequest(options, `/${subject}/${segment(uid)}/decisions`, { method: 'POST', body });
335
+ /** The decisions made on a report or in an investigation, in the order they were made. */
336
+ export const listDecisions = (options, subject, uid) => evalsRequest(options, `/${subject}/${segment(uid)}/decisions`);
337
+ /**
338
+ * What was decided about a benchmark, or about one of its launches (B6-04).
339
+ *
340
+ * `listDecisions` answers what was decided *in* one report or investigation;
341
+ * this answers what was decided about the benchmark, which is what something
342
+ * outside the product has to ask — CI knows the benchmark it ran and nothing
343
+ * else. Naming neither answers nothing rather than everything.
344
+ */
345
+ export const listDecisionsAbout = (options, query = {}) => evalsRequest(options, '/decisions', { query });
346
+ /** Where a report is downloaded as it was written, with its decisions (B4-08). */
347
+ export const reportExportUrl = (options, reportId, format = 'markdown') => evalsUrl(options, `/reports/${segment(reportId)}/export`, { format });
348
+ // --- Shared with the caller (B4-07) -------------------------------------------
349
+ /** The reports and investigations other people shared with the caller. */
350
+ export const listSharedWithMe = (options) => evalsRequest(options, '/shared');
351
+ // --- CI reports imported as snapshots (B4-09) ---------------------------------
352
+ /** Keep a report file CI produced on its benchmark, as its text. */
353
+ export const importReport = (options, evalsetId, body) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/reports/import`, { method: 'POST', body });
354
+ /** The reports imported on a benchmark, newest first, without their text. */
355
+ export const listReportImports = (options, evalsetId) => evalsRequest(options, `/evalsets/${segment(evalsetId)}/reports/imports`);
356
+ /** One imported report, with its text as it was. */
357
+ export const getReportImport = (options, importId) => evalsRequest(options, `/report-imports/${segment(importId)}`);
358
+ /** Continue investigation: a live report and an investigation over its runs. */
359
+ export const continueReportImport = (options, importId) => evalsRequest(options, `/report-imports/${segment(importId)}/continue`, { method: 'POST' });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The evals API of the AI Agents service: evalsets (benchmarks), their
3
+ * cases, experiments, runs, comparisons and live targets.
4
+ *
5
+ * @module api/evals
6
+ */
7
+ export * from './types';
8
+ export * from './request';
9
+ export * from './client';
10
+ export * from './status';
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /*
6
+ * Copyright (c) 2023-2026 Datalayer, Inc.
7
+ * Distributed under the terms of the Modified BSD License.
8
+ */
9
+ /**
10
+ * The evals API of the AI Agents service: evalsets (benchmarks), their
11
+ * cases, experiments, runs, comparisons and live targets.
12
+ *
13
+ * @module api/evals
14
+ */
15
+ export * from './types.js';
16
+ export * from './request.js';
17
+ export * from './client.js';
18
+ export * from './status.js';
@@ -0,0 +1,43 @@
1
+ /** What every evals call needs to know. */
2
+ export interface EvalsClientOptions {
3
+ /** The AI Agents service origin, e.g. `https://prod1.datalayer.run`. */
4
+ baseUrl?: string;
5
+ /** The caller's IAM token; a public read may go without one. */
6
+ token?: string;
7
+ /** An organization or team uid to act for; the caller's own when absent. */
8
+ accountUid?: string;
9
+ }
10
+ export type EvalsQuery = Record<string, string | number | boolean | undefined | null>;
11
+ export type EvalsMethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
12
+ /** The AI Agents origin, with no trailing slash. */
13
+ export declare const aiAgentsOrigin: (baseUrl?: string) => string;
14
+ /**
15
+ * A full URL under `/api/ai-agents/v1`, with the account scope and any
16
+ * query merged in. Empty, null and undefined values are left out.
17
+ */
18
+ export declare const aiAgentsUrl: (options: EvalsClientOptions, path: string, query?: EvalsQuery) => string;
19
+ /** A URL under `/api/ai-agents/v1/evals`. */
20
+ export declare const evalsUrl: (options: EvalsClientOptions, suffix: string, query?: EvalsQuery) => string;
21
+ export interface AiAgentsRequestInit {
22
+ method?: EvalsMethod;
23
+ body?: unknown;
24
+ query?: EvalsQuery;
25
+ signal?: AbortSignal;
26
+ /**
27
+ * Headers beyond the caller's own credential. One call needs this: a
28
+ * trial's claim carries the trial's key beside the person's (B2-14).
29
+ */
30
+ headers?: Record<string, string>;
31
+ }
32
+ /**
33
+ * One request to the AI Agents service, `path` relative to `/api/ai-agents/v1`.
34
+ *
35
+ * The typed functions in `client.ts` are built on this; a view that needs a
36
+ * path the client does not name yet may call it directly, and the contract
37
+ * spec still sees the path.
38
+ */
39
+ export declare const aiAgentsRequest: <T>(options: EvalsClientOptions, path: string, init?: AiAgentsRequestInit) => Promise<T>;
40
+ /** One request under `/evals`. */
41
+ export declare const evalsRequest: <T>(options: EvalsClientOptions, suffix: string, init?: AiAgentsRequestInit) => Promise<T>;
42
+ /** A path segment, encoded once. */
43
+ export declare const segment: (value: string) => string;
@@ -0,0 +1,67 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /*
6
+ * Copyright (c) 2023-2026 Datalayer, Inc.
7
+ * Distributed under the terms of the Modified BSD License.
8
+ */
9
+ /**
10
+ * How the evals API is reached.
11
+ *
12
+ * One place builds the AI Agents origin, the `/api/ai-agents/v1` prefix and
13
+ * the account scope. The landings UI used to assemble those in three views;
14
+ * a service origin that moves then broke three places, silently. Here it
15
+ * is one, and the contract tests on both sides read this module's paths.
16
+ *
17
+ * Account scope: the service answers for the caller unless `account_uid`
18
+ * names an organization or a team the caller belongs to, in which case the
19
+ * evalsets are that account's. The option rides on every request.
20
+ *
21
+ * @module api/evals/request
22
+ */
23
+ import { requestDatalayerAPI } from '../DatalayerApi.js';
24
+ import { API_BASE_PATHS, DEFAULT_SERVICE_URLS } from '../constants.js';
25
+ /** The AI Agents origin, with no trailing slash. */
26
+ export const aiAgentsOrigin = (baseUrl) => String(baseUrl || DEFAULT_SERVICE_URLS.AI_AGENTS)
27
+ .trim()
28
+ .replace(/\/+$/, '');
29
+ /**
30
+ * A full URL under `/api/ai-agents/v1`, with the account scope and any
31
+ * query merged in. Empty, null and undefined values are left out.
32
+ */
33
+ export const aiAgentsUrl = (options, path, query = {}) => {
34
+ const [pathname, inlineSearch = ''] = path.split('?');
35
+ const parameters = new URLSearchParams(inlineSearch);
36
+ for (const [key, value] of Object.entries(query)) {
37
+ if (value !== undefined && value !== null && value !== '') {
38
+ parameters.set(key, String(value));
39
+ }
40
+ }
41
+ if (options.accountUid && !parameters.has('account_uid')) {
42
+ parameters.set('account_uid', options.accountUid);
43
+ }
44
+ const search = parameters.toString();
45
+ return `${aiAgentsOrigin(options.baseUrl)}${API_BASE_PATHS.AI_AGENTS}${pathname}${search ? `?${search}` : ''}`;
46
+ };
47
+ /** A URL under `/api/ai-agents/v1/evals`. */
48
+ export const evalsUrl = (options, suffix, query = {}) => aiAgentsUrl(options, `/evals${suffix}`, query);
49
+ /**
50
+ * One request to the AI Agents service, `path` relative to `/api/ai-agents/v1`.
51
+ *
52
+ * The typed functions in `client.ts` are built on this; a view that needs a
53
+ * path the client does not name yet may call it directly, and the contract
54
+ * spec still sees the path.
55
+ */
56
+ export const aiAgentsRequest = (options, path, init = {}) => requestDatalayerAPI({
57
+ url: aiAgentsUrl(options, path, init.query),
58
+ method: init.method ?? 'GET',
59
+ body: init.body,
60
+ token: options.token,
61
+ signal: init.signal,
62
+ ...(init.headers ? { headers: init.headers } : {}),
63
+ });
64
+ /** One request under `/evals`. */
65
+ export const evalsRequest = (options, suffix, init = {}) => aiAgentsRequest(options, `/evals${suffix}`, init);
66
+ /** A path segment, encoded once. */
67
+ export const segment = (value) => encodeURIComponent(String(value ?? '').trim());
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The one vocabulary for what a run and a case are doing.
3
+ *
4
+ * The service stores `status` as free text and its writers disagreed over
5
+ * time (`queued`, `init`, `pending`, `running`, `completed`, `failed`,
6
+ * `error`, `success`, `done`, …). This is the same mapping as
7
+ * `agent_runtimes.evals.status` in Python: every word a writer has used maps
8
+ * onto the product vocabulary of BENCHMARK.md section 11.4, and "finished" is
9
+ * answered once. A word nobody has used maps to itself, lower-cased, so it is
10
+ * visible rather than misread.
11
+ *
12
+ * @module api/evals/status
13
+ */
14
+ export declare const RUN_STATUSES: readonly ["queued", "provisioning", "running", "scoring", "completed", "failed", "review", "blocked", "cancelled"];
15
+ export type RunStatus = (typeof RUN_STATUSES)[number];
16
+ export declare const CASE_STATUSES: readonly ["waiting", "provisioning", "running", "scoring", "passed", "failed", "review", "blocked", "cancelled"];
17
+ export type CaseStatus = (typeof CASE_STATUSES)[number];
18
+ export declare const TERMINAL_RUN_STATUSES: ReadonlySet<string>;
19
+ export declare const TERMINAL_CASE_STATUSES: ReadonlySet<string>;
20
+ /** The section 11.4 word for a run status, whatever a writer wrote. */
21
+ export declare const normalizeRunStatus: (value: unknown) => RunStatus | string;
22
+ /** The section 11.4 word for a case status. */
23
+ export declare const normalizeCaseStatus: (value: unknown) => CaseStatus | string;
24
+ /** Whether a run with this status is over. */
25
+ export declare const isTerminalRunStatus: (value: unknown) => boolean;
26
+ /** Whether a case with this status is over. */
27
+ export declare const isTerminalCaseStatus: (value: unknown) => boolean;
@@ -0,0 +1,122 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /*
6
+ * Copyright (c) 2023-2026 Datalayer, Inc.
7
+ * Distributed under the terms of the Modified BSD License.
8
+ */
9
+ /**
10
+ * The one vocabulary for what a run and a case are doing.
11
+ *
12
+ * The service stores `status` as free text and its writers disagreed over
13
+ * time (`queued`, `init`, `pending`, `running`, `completed`, `failed`,
14
+ * `error`, `success`, `done`, …). This is the same mapping as
15
+ * `agent_runtimes.evals.status` in Python: every word a writer has used maps
16
+ * onto the product vocabulary of BENCHMARK.md section 11.4, and "finished" is
17
+ * answered once. A word nobody has used maps to itself, lower-cased, so it is
18
+ * visible rather than misread.
19
+ *
20
+ * @module api/evals/status
21
+ */
22
+ export const RUN_STATUSES = [
23
+ 'queued',
24
+ 'provisioning',
25
+ 'running',
26
+ 'scoring',
27
+ 'completed',
28
+ 'failed',
29
+ 'review',
30
+ 'blocked',
31
+ 'cancelled',
32
+ ];
33
+ export const CASE_STATUSES = [
34
+ 'waiting',
35
+ 'provisioning',
36
+ 'running',
37
+ 'scoring',
38
+ 'passed',
39
+ 'failed',
40
+ 'review',
41
+ 'blocked',
42
+ 'cancelled',
43
+ ];
44
+ export const TERMINAL_RUN_STATUSES = new Set([
45
+ 'completed',
46
+ 'failed',
47
+ 'cancelled',
48
+ ]);
49
+ export const TERMINAL_CASE_STATUSES = new Set([
50
+ 'passed',
51
+ 'failed',
52
+ 'cancelled',
53
+ ]);
54
+ const LEGACY_RUN_STATUS = {
55
+ '': 'queued',
56
+ init: 'queued',
57
+ pending: 'queued',
58
+ queued: 'queued',
59
+ provisioning: 'provisioning',
60
+ starting: 'provisioning',
61
+ running: 'running',
62
+ in_progress: 'running',
63
+ scoring: 'scoring',
64
+ evaluating: 'scoring',
65
+ completed: 'completed',
66
+ complete: 'completed',
67
+ success: 'completed',
68
+ succeeded: 'completed',
69
+ passed: 'completed',
70
+ done: 'completed',
71
+ finished: 'completed',
72
+ failed: 'failed',
73
+ failure: 'failed',
74
+ error: 'failed',
75
+ errored: 'failed',
76
+ review: 'review',
77
+ needs_review: 'review',
78
+ blocked: 'blocked',
79
+ cancelled: 'cancelled',
80
+ canceled: 'cancelled',
81
+ aborted: 'cancelled',
82
+ };
83
+ const LEGACY_CASE_STATUS = {
84
+ '': 'waiting',
85
+ waiting: 'waiting',
86
+ queued: 'waiting',
87
+ pending: 'waiting',
88
+ provisioning: 'provisioning',
89
+ running: 'running',
90
+ scoring: 'scoring',
91
+ passed: 'passed',
92
+ pass: 'passed',
93
+ success: 'passed',
94
+ completed: 'passed',
95
+ failed: 'failed',
96
+ fail: 'failed',
97
+ error: 'failed',
98
+ review: 'review',
99
+ needs_review: 'review',
100
+ blocked: 'blocked',
101
+ cancelled: 'cancelled',
102
+ canceled: 'cancelled',
103
+ skipped: 'cancelled',
104
+ };
105
+ const word = (value) => String(value ?? '')
106
+ .trim()
107
+ .toLowerCase()
108
+ .replace(/[-\s]/g, '_');
109
+ /** The section 11.4 word for a run status, whatever a writer wrote. */
110
+ export const normalizeRunStatus = (value) => {
111
+ const key = word(value);
112
+ return LEGACY_RUN_STATUS[key] ?? key;
113
+ };
114
+ /** The section 11.4 word for a case status. */
115
+ export const normalizeCaseStatus = (value) => {
116
+ const key = word(value);
117
+ return LEGACY_CASE_STATUS[key] ?? key;
118
+ };
119
+ /** Whether a run with this status is over. */
120
+ export const isTerminalRunStatus = (value) => TERMINAL_RUN_STATUSES.has(normalizeRunStatus(value));
121
+ /** Whether a case with this status is over. */
122
+ export const isTerminalCaseStatus = (value) => TERMINAL_CASE_STATUSES.has(normalizeCaseStatus(value));