@datalayer/core 1.1.66 → 1.2.12

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 (237) hide show
  1. package/README.md +43 -20
  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/authentication.js +6 -4
  21. package/lib/api/iam/connectedAgents.d.ts +29 -0
  22. package/lib/api/iam/connectedAgents.js +35 -0
  23. package/lib/api/iam/healthz.js +2 -2
  24. package/lib/api/iam/identityProviders.d.ts +76 -0
  25. package/lib/api/iam/identityProviders.js +187 -0
  26. package/lib/api/iam/index.d.ts +1 -0
  27. package/lib/api/iam/index.js +1 -0
  28. package/lib/api/iam/mcpPolicy.d.ts +102 -1
  29. package/lib/api/iam/mcpPolicy.js +38 -2
  30. package/lib/api/iam/oauth2.js +18 -12
  31. package/lib/api/iam/profile.d.ts +17 -1
  32. package/lib/api/iam/profile.js +27 -0
  33. package/lib/api/iam/scimTokens.d.ts +79 -0
  34. package/lib/api/iam/scimTokens.js +141 -0
  35. package/lib/api/iam/secrets.js +10 -23
  36. package/lib/api/iam/trials.d.ts +38 -0
  37. package/lib/api/iam/trials.js +66 -0
  38. package/lib/api/index.d.ts +4 -0
  39. package/lib/api/index.js +4 -0
  40. package/lib/api/mcp/observability.d.ts +34 -11
  41. package/lib/api/mcp/observability.js +97 -59
  42. package/lib/api/orchestration/client.d.ts +53 -0
  43. package/lib/api/orchestration/client.js +105 -0
  44. package/lib/api/orchestration/events.d.ts +88 -0
  45. package/lib/api/orchestration/events.js +245 -0
  46. package/lib/api/orchestration/generated.d.ts +693 -0
  47. package/lib/api/orchestration/generated.js +687 -0
  48. package/lib/api/orchestration/index.d.ts +30 -0
  49. package/lib/api/orchestration/index.js +34 -0
  50. package/lib/api/orchestration/lifecycle.d.ts +39 -0
  51. package/lib/api/orchestration/lifecycle.js +57 -0
  52. package/lib/api/orchestration/measures.d.ts +55 -0
  53. package/lib/api/orchestration/measures.js +99 -0
  54. package/lib/api/otel/dashboards.d.ts +56 -0
  55. package/lib/api/otel/dashboards.js +50 -0
  56. package/lib/api/otel/index.d.ts +1 -0
  57. package/lib/api/otel/index.js +1 -0
  58. package/lib/api/otel/metrics.d.ts +16 -0
  59. package/lib/api/otel/metrics.js +15 -0
  60. package/lib/api/scheduler/client.d.ts +32 -0
  61. package/lib/api/scheduler/client.js +42 -0
  62. package/lib/api/scheduler/index.d.ts +8 -0
  63. package/lib/api/scheduler/index.js +16 -0
  64. package/lib/api/scheduler/request.d.ts +28 -0
  65. package/lib/api/scheduler/request.js +50 -0
  66. package/lib/api/scheduler/types.d.ts +88 -0
  67. package/lib/api/scheduler/types.js +5 -0
  68. package/lib/api/spacer/comments.d.ts +97 -0
  69. package/lib/api/spacer/comments.js +45 -0
  70. package/lib/api/spacer/index.d.ts +9 -0
  71. package/lib/api/spacer/index.js +17 -0
  72. package/lib/api/spacer/notebooks.d.ts +33 -0
  73. package/lib/api/spacer/notebooks.js +39 -0
  74. package/lib/api/spacer/request.d.ts +25 -0
  75. package/lib/api/spacer/request.js +46 -0
  76. package/lib/api/spacer/spaces.d.ts +68 -0
  77. package/lib/api/spacer/spaces.js +45 -0
  78. package/lib/api/utils/validation.d.ts +4 -4
  79. package/lib/api/utils/validation.js +10 -7
  80. package/lib/client/auth/strategies.js +1 -1
  81. package/lib/client/constants.d.ts +1 -0
  82. package/lib/client/constants.js +1 -0
  83. package/lib/client/mixins/IAMMixin.js +2 -2
  84. package/lib/components/animation/AnimatedText.d.ts +1 -44
  85. package/lib/components/animation/AnimatedText.js +6 -122
  86. package/lib/components/anonymous/AnonymousKeyExpired.d.ts +56 -0
  87. package/lib/components/anonymous/AnonymousKeyExpired.js +96 -0
  88. package/lib/components/anonymous/AnonymousKeyTimer.d.ts +63 -0
  89. package/lib/components/anonymous/AnonymousKeyTimer.js +140 -0
  90. package/lib/components/anonymous/index.d.ts +7 -0
  91. package/lib/components/anonymous/index.js +15 -0
  92. package/lib/components/avatars/UserAvatar.d.ts +7 -1
  93. package/lib/components/avatars/UserAvatar.js +15 -1
  94. package/lib/components/billing/BillingEntitySelect.d.ts +6 -0
  95. package/lib/components/billing/BillingEntitySelect.js +49 -10
  96. package/lib/components/billing/eligibility.d.ts +22 -0
  97. package/lib/components/billing/eligibility.js +27 -0
  98. package/lib/components/billing/index.d.ts +1 -0
  99. package/lib/components/billing/index.js +1 -0
  100. package/lib/components/checkout/StripeCheckout.d.ts +1 -1
  101. package/lib/components/checkout/StripeCheckout.js +1 -1
  102. package/lib/components/collaboration/LiveEditorCollaborators.d.ts +5 -0
  103. package/lib/components/collaboration/LiveEditorCollaborators.js +3 -1
  104. package/lib/components/display/DatalayerBox.d.ts +2 -3
  105. package/lib/components/display/DatalayerBox.js +1 -1
  106. package/lib/components/display/NavLink.js +3 -2
  107. package/lib/components/display/VisuallyHidden.d.ts +1 -2
  108. package/lib/components/labels/StatusLabels.d.ts +2 -10
  109. package/lib/components/labels/StatusLabels.js +2 -26
  110. package/lib/components/principal/PrincipalAppearance.d.ts +21 -42
  111. package/lib/components/principal/PrincipalAppearance.js +232 -174
  112. package/lib/components/principal/PrincipalAvatar.d.ts +8 -1
  113. package/lib/components/principal/PrincipalAvatar.js +2 -2
  114. package/lib/components/principal/PrincipalDetailsOverlay.d.ts +8 -1
  115. package/lib/components/principal/PrincipalDetailsOverlay.js +2 -2
  116. package/lib/components/screencapture/Screencapture.js +46 -3
  117. package/lib/components/sharing/ShareAccessComponent.d.ts +45 -4
  118. package/lib/components/sharing/ShareAccessComponent.js +110 -78
  119. package/lib/components/sharing/SharingEditor.d.ts +5 -1
  120. package/lib/components/sharing/SharingEditor.js +9 -4
  121. package/lib/components/sharing/index.d.ts +1 -0
  122. package/lib/components/sharing/index.js +1 -0
  123. package/lib/components/sharing/sandboxSharing.d.ts +26 -0
  124. package/lib/components/sharing/sandboxSharing.js +47 -0
  125. package/lib/components/spaces/SpaceDetailsOverlay.d.ts +39 -0
  126. package/lib/components/spaces/SpaceDetailsOverlay.js +80 -0
  127. package/lib/components/spaces/SpaceDisplay.d.ts +38 -0
  128. package/lib/components/spaces/SpaceDisplay.js +92 -0
  129. package/lib/components/spaces/index.d.ts +4 -0
  130. package/lib/components/spaces/index.js +7 -0
  131. package/lib/components/spaces/spaceDisplayModel.d.ts +93 -0
  132. package/lib/components/spaces/spaceDisplayModel.js +170 -0
  133. package/lib/config/Configuration.d.ts +4 -4
  134. package/lib/config/Configuration.js +7 -7
  135. package/lib/config/index.d.ts +1 -0
  136. package/lib/config/index.js +1 -0
  137. package/lib/config/planes.d.ts +45 -0
  138. package/lib/config/planes.js +53 -0
  139. package/lib/hooks/cacheConverters.d.ts +0 -7
  140. package/lib/hooks/cacheConverters.js +0 -25
  141. package/lib/hooks/index.d.ts +1 -0
  142. package/lib/hooks/index.js +1 -0
  143. package/lib/hooks/useBackdrop.d.ts +4 -5
  144. package/lib/hooks/useBillingEntityStore.js +3 -0
  145. package/lib/hooks/useCache.d.ts +197 -44
  146. package/lib/hooks/useCache.js +1586 -494
  147. package/lib/hooks/useContents.d.ts +22 -1
  148. package/lib/hooks/useContents.js +90 -21
  149. package/lib/hooks/useMcp.d.ts +87 -1
  150. package/lib/hooks/useMcp.js +248 -13
  151. package/lib/hooks/useNavigate.d.ts +41 -3
  152. package/lib/hooks/useNavigate.js +116 -52
  153. package/lib/hooks/usePrincipalCacheStore.js +3 -0
  154. package/lib/hooks/usePrincipalStore.js +3 -0
  155. package/lib/hooks/useSpaceCacheStore.d.ts +50 -0
  156. package/lib/hooks/useSpaceCacheStore.js +85 -0
  157. package/lib/hooks/useWindowSize.js +1 -1
  158. package/lib/models/CreditsDTO.d.ts +6 -5
  159. package/lib/models/CreditsDTO.js +7 -5
  160. package/lib/models/IAMProvidersSpecs.d.ts +10 -5
  161. package/lib/models/IAMProvidersSpecs.js +0 -23
  162. package/lib/models/McpBinding.d.ts +6 -0
  163. package/lib/models/Organization.d.ts +69 -0
  164. package/lib/models/Organization.js +96 -0
  165. package/lib/models/Secret.d.ts +1 -2
  166. package/lib/models/Secret.js +2 -18
  167. package/lib/models/StartedBy.d.ts +34 -0
  168. package/lib/models/StartedBy.js +36 -0
  169. package/lib/models/Team.d.ts +2 -0
  170. package/lib/models/Team.js +2 -0
  171. package/lib/models/User.d.ts +4 -0
  172. package/lib/models/User.js +3 -0
  173. package/lib/models/UserSettings.d.ts +13 -0
  174. package/lib/models/UserSettings.js +9 -0
  175. package/lib/models/contents/__fixtures__/v1-contracts.json +158 -30
  176. package/lib/navigation/adapters/react-router.d.ts +1 -1
  177. package/lib/navigation/adapters/react-router.js +3 -0
  178. package/lib/navigation/components.js +2 -3
  179. package/lib/routes/publicPaths.js +4 -0
  180. package/lib/state/index.d.ts +1 -0
  181. package/lib/state/index.js +1 -0
  182. package/lib/state/sessionEnd.d.ts +55 -0
  183. package/lib/state/sessionEnd.js +162 -0
  184. package/lib/state/substates/CoreState.js +3 -16
  185. package/lib/state/substates/IAMState.d.ts +3 -3
  186. package/lib/state/substates/IAMState.js +7 -0
  187. package/lib/state/substates/LayoutState.js +12 -0
  188. package/lib/state/substates/NavigationState.d.ts +82 -0
  189. package/lib/state/substates/NavigationState.js +255 -0
  190. package/lib/state/substates/ProfileState.d.ts +1 -0
  191. package/lib/state/substates/ProfileState.js +1 -0
  192. package/lib/state/substates/index.d.ts +1 -0
  193. package/lib/state/substates/index.js +1 -0
  194. package/lib/utils/Lazy.d.ts +20 -0
  195. package/lib/utils/Lazy.js +32 -6
  196. package/lib/utils/Screencapture.d.ts +15 -0
  197. package/lib/utils/Screencapture.js +26 -20
  198. package/lib/utils/WithSuspense.d.ts +11 -1
  199. package/lib/utils/WithSuspense.js +11 -1
  200. package/lib/views/mcp/AdmittedClients.d.ts +44 -0
  201. package/lib/views/mcp/AdmittedClients.js +59 -0
  202. package/lib/views/mcp/ApprovalQueue.d.ts +66 -0
  203. package/lib/views/mcp/ApprovalQueue.js +95 -0
  204. package/lib/views/mcp/ConnectedAgents.js +38 -3
  205. package/lib/views/mcp/EnterpriseConsole.d.ts +1 -1
  206. package/lib/views/mcp/EnterpriseConsole.js +23 -1
  207. package/lib/views/mcp/IdentityProviders.d.ts +33 -0
  208. package/lib/views/mcp/IdentityProviders.js +299 -0
  209. package/lib/views/mcp/McpDashboard.js +90 -7
  210. package/lib/views/mcp/McpHome.js +1 -1
  211. package/lib/views/mcp/McpObservability.d.ts +30 -1
  212. package/lib/views/mcp/McpObservability.js +105 -19
  213. package/lib/views/mcp/NotebookRuns.d.ts +39 -0
  214. package/lib/views/mcp/NotebookRuns.js +44 -0
  215. package/lib/views/mcp/OrganizationPolicy.js +2 -1
  216. package/lib/views/mcp/PersonalPolicy.js +2 -1
  217. package/lib/views/mcp/PolicyForm.d.ts +17 -1
  218. package/lib/views/mcp/PolicyForm.js +25 -3
  219. package/lib/views/mcp/PolicyHistory.d.ts +13 -0
  220. package/lib/views/mcp/PolicyHistory.js +14 -1
  221. package/lib/views/mcp/RunDetail.d.ts +87 -0
  222. package/lib/views/mcp/RunDetail.js +186 -0
  223. package/lib/views/mcp/ScimProvisioning.d.ts +54 -0
  224. package/lib/views/mcp/ScimProvisioning.js +173 -0
  225. package/lib/views/mcp/TeamPolicies.js +66 -5
  226. package/lib/views/mcp/ToolAccess.d.ts +60 -0
  227. package/lib/views/mcp/ToolAccess.js +101 -0
  228. package/lib/views/mcp/TraceTimeline.d.ts +81 -0
  229. package/lib/views/mcp/TraceTimeline.js +132 -0
  230. package/lib/views/mcp/index.d.ts +5 -0
  231. package/lib/views/mcp/index.js +5 -0
  232. package/lib/views/otel/simpleAuthStore.js +3 -0
  233. package/lib/views/secrets/SecretEdit.js +3 -2
  234. package/lib/views/secrets/SecretNew.js +5 -1
  235. package/package.json +271 -264
  236. package/scripts/generate-mcp-types.py +16 -10
  237. package/scripts/generate-orchestration-types.py +920 -0
@@ -0,0 +1,245 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ import { operationUrl } from './client.js';
6
+ import { isTerminal } from './lifecycle.js';
7
+ /** The user channel's event for a tree that moved, and the stream's roll-up. */
8
+ export const TREE_EVENT = 'orchestration.tree';
9
+ /**
10
+ * Split what has arrived into the complete events and what is left over,
11
+ * which is the beginning of an event still arriving.
12
+ */
13
+ export const readServerSentEvents = (buffer) => {
14
+ const blocks = buffer.replace(/\r\n/g, '\n').split('\n\n');
15
+ const rest = blocks.pop() ?? '';
16
+ const events = blocks
17
+ .filter(block => block.trim() !== '')
18
+ .map(block => {
19
+ const framed = { event: 'message', data: '' };
20
+ const data = [];
21
+ for (const line of block.split('\n')) {
22
+ if (line.startsWith(':')) {
23
+ continue;
24
+ }
25
+ const colon = line.indexOf(':');
26
+ const field = colon === -1 ? line : line.slice(0, colon);
27
+ const value = colon === -1 ? '' : line.slice(colon + 1).replace(/^ /, '');
28
+ if (field === 'id') {
29
+ framed.id = value;
30
+ }
31
+ else if (field === 'event') {
32
+ framed.event = value;
33
+ }
34
+ else if (field === 'data') {
35
+ data.push(value);
36
+ }
37
+ }
38
+ framed.data = data.join('\n');
39
+ return framed;
40
+ });
41
+ return { events, rest };
42
+ };
43
+ /** The service refused the subscription; asking again would be refused again. */
44
+ export class SubscriptionRefused extends Error {
45
+ status;
46
+ detail;
47
+ constructor(status, detail) {
48
+ super(`The subscription was refused with ${status}: ${detail}`);
49
+ this.status = status;
50
+ this.detail = detail;
51
+ this.name = 'SubscriptionRefused';
52
+ }
53
+ }
54
+ const pause = (milliseconds, signal) => new Promise(resolve => {
55
+ if (milliseconds <= 0 || signal?.aborted) {
56
+ resolve();
57
+ return;
58
+ }
59
+ const timer = setTimeout(resolve, milliseconds);
60
+ signal?.addEventListener('abort', () => {
61
+ clearTimeout(timer);
62
+ resolve();
63
+ }, { once: true });
64
+ });
65
+ /**
66
+ * Subscribe to an execution — and its tree — until it is over.
67
+ *
68
+ * A dropped connection, before the service answered or in the middle of the
69
+ * stream, is resumed from the last event received. A refusal is not: it
70
+ * rejects `done` with `SubscriptionRefused`. An abort ends the subscription
71
+ * quietly, because stopping is the caller's decision rather than a failure.
72
+ */
73
+ export const subscribeToExecution = (options, executionId, subscribe) => {
74
+ let lastEventId = subscribe.lastEventId;
75
+ const fetcher = subscribe.fetch ??
76
+ ((url, init) => fetch(url, init));
77
+ const query = {
78
+ includeChildren: subscribe.includeChildren,
79
+ fromSequence: subscribe.fromSequence,
80
+ };
81
+ const address = new URL(operationUrl(options, 'executions.subscribe', { execution_id: executionId }, query));
82
+ for (const wanted of subscribe.events ?? []) {
83
+ address.searchParams.append('events', wanted);
84
+ }
85
+ const url = address.toString();
86
+ const maxReconnects = subscribe.maxReconnects ?? 5;
87
+ const run = async () => {
88
+ let dropsInARow = 0;
89
+ for (;;) {
90
+ const headers = { Accept: 'text/event-stream' };
91
+ if (options.token) {
92
+ headers.Authorization = `Bearer ${options.token}`;
93
+ }
94
+ if (lastEventId) {
95
+ headers['Last-Event-ID'] = lastEventId;
96
+ }
97
+ let response;
98
+ try {
99
+ response = await fetcher(url, {
100
+ headers,
101
+ signal: subscribe.signal,
102
+ credentials: 'include',
103
+ });
104
+ }
105
+ catch {
106
+ if (subscribe.signal?.aborted) {
107
+ return;
108
+ }
109
+ }
110
+ if (response && !response.ok) {
111
+ throw new SubscriptionRefused(response.status, await response.text());
112
+ }
113
+ let ended = false;
114
+ if (response?.body) {
115
+ const reader = response.body.getReader();
116
+ const decoder = new TextDecoder();
117
+ let buffer = '';
118
+ for (;;) {
119
+ let chunk;
120
+ try {
121
+ chunk = await reader.read();
122
+ }
123
+ catch {
124
+ if (subscribe.signal?.aborted) {
125
+ return;
126
+ }
127
+ break;
128
+ }
129
+ if (chunk.done) {
130
+ break;
131
+ }
132
+ buffer += decoder.decode(chunk.value, { stream: true });
133
+ const { events, rest } = readServerSentEvents(buffer);
134
+ buffer = rest;
135
+ for (const framed of events) {
136
+ if (framed.event === 'end') {
137
+ ended = true;
138
+ continue;
139
+ }
140
+ if (framed.id) {
141
+ lastEventId = framed.id;
142
+ }
143
+ if (framed.event === TREE_EVENT) {
144
+ subscribe.onTree?.(JSON.parse(framed.data), framed.id ?? '');
145
+ }
146
+ else {
147
+ subscribe.onEvent(JSON.parse(framed.data), framed.id ?? '');
148
+ }
149
+ dropsInARow = 0;
150
+ }
151
+ }
152
+ }
153
+ if (ended) {
154
+ subscribe.onEnd?.();
155
+ return;
156
+ }
157
+ if (subscribe.signal?.aborted) {
158
+ return;
159
+ }
160
+ dropsInARow += 1;
161
+ if (dropsInARow > maxReconnects) {
162
+ throw new Error(`The subscription to '${executionId}' dropped ${dropsInARow} times with no event in between.`);
163
+ }
164
+ await pause(subscribe.reconnectDelayMs ?? 1000, subscribe.signal);
165
+ }
166
+ };
167
+ return { done: run(), lastEventId: () => lastEventId };
168
+ };
169
+ /**
170
+ * What a tree is doing, worked out from its canonical events alone (O2-03).
171
+ *
172
+ * The same summary the subscription sends as `orchestration.tree`: each
173
+ * execution's latest state, its parent, its worker and its goal — the message
174
+ * of the event that created it — and its depth below the first execution the
175
+ * events cover. Each execution's events are read in their own sequence,
176
+ * whatever order they arrived in.
177
+ */
178
+ export const treeFromEvents = (events) => {
179
+ const nodes = new Map();
180
+ let root = '';
181
+ const ordered = [...events].sort((one, other) => one.executionId === other.executionId
182
+ ? one.sequence - other.sequence
183
+ : one.executionId < other.executionId
184
+ ? -1
185
+ : 1);
186
+ for (const event of ordered) {
187
+ root = root || event.rootExecutionId;
188
+ let node = nodes.get(event.executionId);
189
+ if (!node) {
190
+ node = {
191
+ parent: event.parentExecutionId ?? null,
192
+ goal: event.message ?? '',
193
+ agentId: '',
194
+ updatedAt: event.emittedAt,
195
+ };
196
+ nodes.set(event.executionId, node);
197
+ }
198
+ node.agentId = event.agentId ?? node.agentId;
199
+ node.protocol = event.protocol ?? node.protocol;
200
+ node.status = event.state ?? node.status;
201
+ node.updatedAt = event.emittedAt;
202
+ }
203
+ const depth = (executionId) => {
204
+ const parent = nodes.get(executionId)?.parent;
205
+ return parent && nodes.has(parent) ? depth(parent) + 1 : 0;
206
+ };
207
+ const executions = [];
208
+ for (const [executionId, node] of nodes) {
209
+ if (node.status && node.protocol) {
210
+ executions.push({
211
+ executionId,
212
+ parentExecutionId: node.parent,
213
+ depth: depth(executionId),
214
+ status: node.status,
215
+ agentId: node.agentId,
216
+ protocol: node.protocol,
217
+ goal: node.goal,
218
+ updatedAt: node.updatedAt,
219
+ });
220
+ }
221
+ }
222
+ const counts = {};
223
+ for (const one of executions) {
224
+ counts[one.status] = (counts[one.status] ?? 0) + 1;
225
+ }
226
+ return {
227
+ rootExecutionId: root,
228
+ executions,
229
+ counts,
230
+ terminal: executions.every(one => isTerminal(one.status)),
231
+ };
232
+ };
233
+ /** Whether a user-channel message is a tree announcement. */
234
+ export const isTreeAnnouncement = (message) => {
235
+ if (typeof message !== 'object' || message === null) {
236
+ return false;
237
+ }
238
+ const { event, data } = message;
239
+ return (event === TREE_EVENT &&
240
+ typeof data === 'object' &&
241
+ data !== null &&
242
+ typeof data.rootExecutionId ===
243
+ 'string' &&
244
+ Array.isArray(data.executions));
245
+ };