@datalayer/agent-runtimes 1.0.1 → 1.0.2

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 (31) hide show
  1. package/lib/components/McpServerManager.d.ts +1 -1
  2. package/lib/components/McpServerManager.js +1 -1
  3. package/lib/components/chat/components/Chat.d.ts +1 -1
  4. package/lib/components/chat/components/base/ChatBase.d.ts +1 -1
  5. package/lib/components/chat/components/base/ChatBase.js +4 -2
  6. package/lib/components/chat/store/conversationStore.d.ts +1 -1
  7. package/lib/components/chat/store/conversationStore.js +2 -2
  8. package/lib/hooks/index.d.ts +8 -0
  9. package/lib/hooks/index.js +8 -0
  10. package/lib/hooks/useAgentRuntimes.d.ts +350 -0
  11. package/lib/hooks/useAgentRuntimes.js +78 -0
  12. package/lib/hooks/useAgentStore.d.ts +30 -0
  13. package/lib/hooks/useAgentStore.js +22 -0
  14. package/lib/specs/agents/codeai/agents.d.ts +1 -1
  15. package/lib/specs/agents/codeai/agents.js +28 -0
  16. package/lib/specs/agents/codemode-paper/agents.d.ts +1 -1
  17. package/lib/specs/agents/codemode-paper/agents.js +71 -1
  18. package/lib/specs/agents/datalayer-ai/agents.d.ts +1 -1
  19. package/lib/specs/agents/datalayer-ai/agents.js +70 -0
  20. package/lib/specs/agents/index.js +2 -0
  21. package/lib/specs/agents/mocks/agents.d.ts +43 -0
  22. package/lib/specs/agents/mocks/agents.js +2293 -0
  23. package/lib/specs/agents/mocks/index.d.ts +1 -0
  24. package/lib/specs/agents/mocks/index.js +5 -0
  25. package/lib/specs/mcpServers.d.ts +1 -0
  26. package/lib/specs/mcpServers.js +16 -0
  27. package/lib/specs/models.d.ts +2 -2
  28. package/lib/specs/models.js +5 -5
  29. package/lib/types/Types.d.ts +29 -1
  30. package/package.json +1 -1
  31. package/scripts/codegen/generate_agents.py +95 -2
@@ -17,7 +17,7 @@ export interface McpServerManagerProps {
17
17
  disabled?: boolean;
18
18
  }
19
19
  /**
20
- * McpServerManager - Manage MCP servers for agent spaces
20
+ * McpServerManager - Manage MCP servers for agent runtimes
21
21
  *
22
22
  * Features:
23
23
  * - View MCP Catalog servers (predefined, can be enabled on-demand)
@@ -9,7 +9,7 @@ import { ToolsIcon, PlusIcon, TrashIcon, SyncIcon, ServerIcon, CheckIcon, Search
9
9
  import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
10
10
  import { Box } from '@datalayer/primer-addons';
11
11
  /**
12
- * McpServerManager - Manage MCP servers for agent spaces
12
+ * McpServerManager - Manage MCP servers for agent runtimes
13
13
  *
14
14
  * Features:
15
15
  * - View MCP Catalog servers (predefined, can be enabled on-demand)
@@ -99,7 +99,7 @@ export interface ChatProps {
99
99
  /**
100
100
  * Runtime ID for conversation persistence.
101
101
  * When provided, messages are fetched from the server API on page reload
102
- * and prevents message mixing between different agent spaces.
102
+ * and prevents message mixing between different agent runtimes.
103
103
  */
104
104
  runtimeId?: string;
105
105
  /**
@@ -427,7 +427,7 @@ export interface ChatBaseProps {
427
427
  /**
428
428
  * Runtime ID for conversation persistence.
429
429
  * When provided, messages are fetched from the server API on page reload
430
- * and prevents message mixing between different agent spaces.
430
+ * and prevents message mixing between different agent runtimes.
431
431
  */
432
432
  runtimeId?: string;
433
433
  /**
@@ -714,7 +714,7 @@ pendingPrompt, }) {
714
714
  // Track previous runtimeId to detect changes
715
715
  const prevRuntimeIdRef = useRef(undefined);
716
716
  // Clear displayItems and load messages when runtimeId changes
717
- // This ensures each agent space has isolated conversation history
717
+ // This ensures each agent runtime has isolated conversation history
718
718
  useEffect(() => {
719
719
  // If runtimeId changed, clear displayItems first
720
720
  if (runtimeId !== prevRuntimeIdRef.current) {
@@ -1795,7 +1795,9 @@ pendingPrompt, }) {
1795
1795
  }, children: [emptyState?.icon || brandIcon || _jsx(AiAgentIcon, { colored: true, size: 48 }), _jsx(Text, { sx: { fontSize: 2 }, children: emptyState?.title || 'Start a conversation' }), (emptyState?.subtitle || description) && (_jsx(Text, { sx: { fontSize: 1 }, children: emptyState?.subtitle || description })), suggestions && suggestions.length > 0 && (_jsx(LabelGroup, { sx: { mt: 2, justifyContent: 'center' }, children: suggestions.map((suggestion, index) => (_jsx(Label, { variant: "accent", sx: {
1796
1796
  cursor: 'pointer',
1797
1797
  '&:hover': {
1798
- bg: 'accent.muted',
1798
+ bg: 'accent.emphasis',
1799
+ color: 'var(--button-primary-fgColor-rest)',
1800
+ borderColor: 'accent.emphasis',
1799
1801
  },
1800
1802
  }, onClick: () => handleSuggestionClick(suggestion), children: suggestion.title }, index))) }))] }));
1801
1803
  };
@@ -3,7 +3,7 @@ import type { ChatMessage } from '../types/message';
3
3
  * Conversation data for a single runtime
4
4
  */
5
5
  export interface ConversationData {
6
- /** Runtime/agent space ID */
6
+ /** Agent runtime ID */
7
7
  runtimeId: string;
8
8
  /** Messages in this conversation */
9
9
  messages: ChatMessage[];
@@ -3,11 +3,11 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
  /**
6
- * Zustand store for conversation history per runtime/agent space.
6
+ * Zustand store for conversation history per agent runtime.
7
7
  * Stores messages per runtime ID in memory during the session.
8
8
  *
9
9
  * Key features:
10
- * - Messages are stored per runtime ID (agent space) in memory
10
+ * - Messages are stored per runtime ID in memory
11
11
  * - On page reload, messages are fetched from the server API
12
12
  * - No browser storage persistence - server is the source of truth
13
13
  *
@@ -65,4 +65,12 @@ export { useVercelChat } from './useVercelChat';
65
65
  * Datalayer AI Agents REST API hook.
66
66
  */
67
67
  export * from './useAgents';
68
+ /**
69
+ * Agent runtimes service hooks for managing agent runtime instances.
70
+ */
71
+ export * from './useAgentRuntimes';
72
+ /**
73
+ * Centralized agent catalog store for available agent specs and running agents.
74
+ */
75
+ export * from './useAgentStore';
68
76
  export * from './useNotebookAIAgent';
@@ -78,4 +78,12 @@ export { useVercelChat } from './useVercelChat';
78
78
  * Datalayer AI Agents REST API hook.
79
79
  */
80
80
  export * from './useAgents';
81
+ /**
82
+ * Agent runtimes service hooks for managing agent runtime instances.
83
+ */
84
+ export * from './useAgentRuntimes';
85
+ /**
86
+ * Centralized agent catalog store for available agent specs and running agents.
87
+ */
88
+ export * from './useAgentStore';
81
89
  export * from './useNotebookAIAgent';
@@ -0,0 +1,350 @@
1
+ import type { AgentSpec } from '../types';
2
+ /**
3
+ * Agent Runtime data type (mapped from runtimes service).
4
+ *
5
+ * Backend RuntimePod fields: pod_name, environment_name, environment_title, uid,
6
+ * type, given_name, token, ingress, reservation_id, started_at, expired_at, burning_rate.
7
+ *
8
+ * We map 'ingress' to 'url' for consistency with the UI.
9
+ */
10
+ export type AgentRuntimeData = {
11
+ pod_name: string;
12
+ id: string;
13
+ name: string;
14
+ environment_name: string;
15
+ environment_title?: string;
16
+ given_name: string;
17
+ phase?: string;
18
+ type: string;
19
+ started_at?: string;
20
+ expired_at?: string;
21
+ burning_rate?: number;
22
+ status: 'starting' | 'running' | 'paused' | 'terminated' | 'archived';
23
+ messageCount: number;
24
+ ingress?: string;
25
+ url?: string;
26
+ token?: string;
27
+ agentSpec?: AgentSpec;
28
+ agent_spec_id?: string;
29
+ };
30
+ /**
31
+ * Hook to access all agent runtime operations from the centralized cache.
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * const {
36
+ * useAgentRuntime,
37
+ * useAgentRuntimes,
38
+ * useCreateAgentRuntime,
39
+ * useDeleteAgentRuntime,
40
+ * useRefreshAgentRuntimes,
41
+ * } = useAgentRuntimesCache();
42
+ * ```
43
+ */
44
+ export declare function useAgentRuntimesCache(): {
45
+ useAgentRuntime: (podName: string | undefined) => import("@tanstack/react-query").UseQueryResult<{
46
+ status: "running" | "paused" | "starting" | "terminated" | "archived";
47
+ name: string;
48
+ id: string;
49
+ url: string | undefined;
50
+ messageCount: number;
51
+ agent_spec_id: string | undefined;
52
+ pod_name: string;
53
+ environment_name: string;
54
+ environment_title?: string;
55
+ given_name: string;
56
+ phase?: string;
57
+ type: string;
58
+ started_at?: string;
59
+ expired_at?: string;
60
+ burning_rate?: number;
61
+ ingress?: string;
62
+ token?: string;
63
+ agentSpec?: any;
64
+ }, Error>;
65
+ useAgentRuntimes: () => import("@tanstack/react-query").UseQueryResult<{
66
+ status: "running" | "paused" | "starting" | "terminated" | "archived";
67
+ name: string;
68
+ id: string;
69
+ url: string | undefined;
70
+ messageCount: number;
71
+ agent_spec_id: string | undefined;
72
+ pod_name: string;
73
+ environment_name: string;
74
+ environment_title?: string;
75
+ given_name: string;
76
+ phase?: string;
77
+ type: string;
78
+ started_at?: string;
79
+ expired_at?: string;
80
+ burning_rate?: number;
81
+ ingress?: string;
82
+ token?: string;
83
+ agentSpec?: any;
84
+ }[], Error>;
85
+ useCreateAgentRuntime: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
86
+ environmentName?: string;
87
+ givenName?: string;
88
+ creditsLimit?: number;
89
+ type?: string;
90
+ editorVariant?: string;
91
+ enableCodemode?: boolean;
92
+ agentSpecId?: string;
93
+ }, unknown>;
94
+ useDeleteAgentRuntime: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
95
+ useRefreshAgentRuntimes: () => () => void;
96
+ queryKeys: {
97
+ readonly auth: {
98
+ readonly me: () => readonly ["auth", "me"];
99
+ readonly whoami: () => readonly ["auth", "whoami"];
100
+ };
101
+ readonly users: {
102
+ readonly all: () => readonly ["users"];
103
+ readonly lists: () => readonly ["users", "list"];
104
+ readonly list: (filters?: string) => readonly ["users", "list", {
105
+ readonly filters: string | undefined;
106
+ }];
107
+ readonly details: () => readonly ["users", "detail"];
108
+ readonly detail: (id: string) => readonly ["users", "detail", string];
109
+ readonly byHandle: (handle: string) => readonly ["users", "handle", string];
110
+ readonly search: (pattern: string) => readonly ["users", "search", string];
111
+ readonly settings: (userId: string) => readonly ["users", "detail", string, "settings"];
112
+ readonly onboarding: (userId: string) => readonly ["users", "detail", string, "onboarding"];
113
+ readonly surveys: (userId: string) => readonly ["users", "detail", string, "surveys"];
114
+ readonly credits: (userId: string) => readonly ["users", "detail", string, "credits"];
115
+ };
116
+ readonly organizations: {
117
+ readonly all: () => readonly ["organizations"];
118
+ readonly lists: () => readonly ["organizations", "list"];
119
+ readonly details: () => readonly ["organizations", "detail"];
120
+ readonly detail: (id: string) => readonly ["organizations", "detail", string];
121
+ readonly byHandle: (handle: string) => readonly ["organizations", "handle", string];
122
+ readonly userOrgs: () => readonly ["organizations", "user"];
123
+ readonly members: (orgId: string) => readonly ["organizations", "detail", string, "members"];
124
+ };
125
+ readonly teams: {
126
+ readonly all: () => readonly ["teams"];
127
+ readonly details: () => readonly ["teams", "detail"];
128
+ readonly detail: (id: string) => readonly ["teams", "detail", string];
129
+ readonly byHandle: (handle: string) => readonly ["teams", "handle", string];
130
+ readonly byOrganization: (orgId: string) => readonly ["teams", "organization", string];
131
+ readonly members: (teamId: string) => readonly ["teams", "detail", string, "members"];
132
+ };
133
+ readonly spaces: {
134
+ readonly all: () => readonly ["spaces"];
135
+ readonly details: () => readonly ["spaces", "detail"];
136
+ readonly detail: (id: string) => readonly ["spaces", "detail", string];
137
+ readonly byHandle: (handle: string) => readonly ["spaces", "handle", string];
138
+ readonly byOrganization: (orgId: string) => readonly ["spaces", "organization", string];
139
+ readonly orgSpaceByHandle: (orgId: string, handle: string) => readonly ["spaces", "organization", string, "handle", string];
140
+ readonly byOrganizationAndHandle: (orgHandle: string, spaceHandle: string) => readonly ["spaces", "organization", string, "space", string];
141
+ readonly userSpaces: () => readonly ["spaces", "user"];
142
+ readonly items: (spaceId: string) => readonly ["spaces", "detail", string, "items"];
143
+ readonly members: (spaceId: string) => readonly ["spaces", "detail", string, "members"];
144
+ };
145
+ readonly notebooks: {
146
+ readonly all: () => readonly ["notebooks"];
147
+ readonly details: () => readonly ["notebooks", "detail"];
148
+ readonly detail: (id: string) => readonly ["notebooks", "detail", string];
149
+ readonly bySpace: (spaceId: string) => readonly ["notebooks", "space", string];
150
+ readonly model: (notebookId: string) => readonly ["notebooks", "detail", string, "model"];
151
+ };
152
+ readonly documents: {
153
+ readonly all: () => readonly ["documents"];
154
+ readonly details: () => readonly ["documents", "detail"];
155
+ readonly detail: (id: string) => readonly ["documents", "detail", string];
156
+ readonly bySpace: (spaceId: string) => readonly ["documents", "space", string];
157
+ readonly model: (documentId: string) => readonly ["documents", "detail", string, "model"];
158
+ };
159
+ readonly cells: {
160
+ readonly all: () => readonly ["cells"];
161
+ readonly details: () => readonly ["cells", "detail"];
162
+ readonly detail: (id: string) => readonly ["cells", "detail", string];
163
+ readonly bySpace: (spaceId: string) => readonly ["cells", "space", string];
164
+ };
165
+ readonly datasets: {
166
+ readonly all: () => readonly ["datasets"];
167
+ readonly details: () => readonly ["datasets", "detail"];
168
+ readonly detail: (id: string) => readonly ["datasets", "detail", string];
169
+ readonly bySpace: (spaceId: string) => readonly ["datasets", "space", string];
170
+ };
171
+ readonly lessons: {
172
+ readonly all: () => readonly ["lessons"];
173
+ readonly details: () => readonly ["lessons", "detail"];
174
+ readonly detail: (id: string) => readonly ["lessons", "detail", string];
175
+ readonly bySpace: (spaceId: string) => readonly ["lessons", "space", string];
176
+ };
177
+ readonly exercises: {
178
+ readonly all: () => readonly ["exercises"];
179
+ readonly details: () => readonly ["exercises", "detail"];
180
+ readonly detail: (id: string) => readonly ["exercises", "detail", string];
181
+ readonly bySpace: (spaceId: string) => readonly ["exercises", "space", string];
182
+ };
183
+ readonly assignments: {
184
+ readonly all: () => readonly ["assignments"];
185
+ readonly details: () => readonly ["assignments", "detail"];
186
+ readonly detail: (id: string) => readonly ["assignments", "detail", string];
187
+ readonly bySpace: (spaceId: string) => readonly ["assignments", "space", string];
188
+ readonly forStudent: (assignmentId: string, courseId: string, studentId: string) => readonly ["assignments", "detail", string, "course", string, "student", string];
189
+ readonly studentVersion: (assignmentId: string) => readonly ["assignments", "detail", string, "studentVersion"];
190
+ };
191
+ readonly environments: {
192
+ readonly all: () => readonly ["environments"];
193
+ readonly details: () => readonly ["environments", "detail"];
194
+ readonly detail: (id: string) => readonly ["environments", "detail", string];
195
+ readonly bySpace: (spaceId: string) => readonly ["environments", "space", string];
196
+ };
197
+ readonly pages: {
198
+ readonly all: () => readonly ["pages"];
199
+ readonly details: () => readonly ["pages", "detail"];
200
+ readonly detail: (id: string) => readonly ["pages", "detail", string];
201
+ };
202
+ readonly datasources: {
203
+ readonly all: () => readonly ["datasources"];
204
+ readonly details: () => readonly ["datasources", "detail"];
205
+ readonly detail: (id: string) => readonly ["datasources", "detail", string];
206
+ };
207
+ readonly secrets: {
208
+ readonly all: () => readonly ["secrets"];
209
+ readonly details: () => readonly ["secrets", "detail"];
210
+ readonly detail: (id: string) => readonly ["secrets", "detail", string];
211
+ };
212
+ readonly tokens: {
213
+ readonly all: () => readonly ["tokens"];
214
+ readonly details: () => readonly ["tokens", "detail"];
215
+ readonly detail: (id: string) => readonly ["tokens", "detail", string];
216
+ };
217
+ readonly contacts: {
218
+ readonly all: () => readonly ["contacts"];
219
+ readonly lists: () => readonly ["contacts", "list"];
220
+ readonly details: () => readonly ["contacts", "detail"];
221
+ readonly detail: (id: string) => readonly ["contacts", "detail", string];
222
+ readonly byHandle: (handle: string) => readonly ["contacts", "handle", string];
223
+ readonly search: (query: string) => readonly ["contacts", "search", string];
224
+ };
225
+ readonly invites: {
226
+ readonly all: () => readonly ["invites"];
227
+ readonly byToken: (token: string) => readonly ["invites", "token", string];
228
+ readonly byAccount: (accountId: string) => readonly ["invites", "account", string];
229
+ };
230
+ readonly courses: {
231
+ readonly all: () => readonly ["courses"];
232
+ readonly details: () => readonly ["courses", "detail"];
233
+ readonly detail: (id: string) => readonly ["courses", "detail", string];
234
+ readonly public: () => readonly ["courses", "public"];
235
+ readonly instructor: (instructorId: string) => readonly ["courses", "instructor", string];
236
+ readonly enrollments: () => readonly ["courses", "enrollments", "me"];
237
+ readonly students: (courseId: string) => readonly ["courses", "detail", string, "students"];
238
+ readonly student: (courseId: string, studentId: string) => readonly ["courses", "detail", string, "student", string];
239
+ };
240
+ readonly schools: {
241
+ readonly all: () => readonly ["schools"];
242
+ };
243
+ readonly inbounds: {
244
+ readonly all: () => readonly ["inbounds"];
245
+ readonly detail: (id: string) => readonly ["inbounds", string];
246
+ readonly byHandle: (handle: string) => readonly ["inbounds", "handle", string];
247
+ };
248
+ readonly outbounds: {
249
+ readonly all: () => readonly ["outbounds"];
250
+ readonly detail: (id: string) => readonly ["outbounds", string];
251
+ };
252
+ readonly items: {
253
+ readonly all: () => readonly ["items"];
254
+ readonly public: () => readonly ["items", "public"];
255
+ readonly bySpace: (spaceId: string) => readonly ["items", "space", string];
256
+ readonly search: (opts: import("@datalayer/core").ISearchOpts) => readonly ["items", "search", import("@datalayer/core").ISearchOpts];
257
+ };
258
+ readonly agentRuntimes: {
259
+ readonly all: () => readonly ["agentRuntimes"];
260
+ readonly lists: () => readonly ["agentRuntimes", "list"];
261
+ readonly details: () => readonly ["agentRuntimes", "detail"];
262
+ readonly detail: (podName: string) => readonly ["agentRuntimes", "detail", string];
263
+ };
264
+ readonly layout: {
265
+ readonly byAccount: (accountHandle: string, spaceHandle?: string) => readonly ["layout", string, string] | readonly ["layout", string];
266
+ };
267
+ readonly usages: {
268
+ readonly user: () => readonly ["usages", "user"];
269
+ readonly userById: (userId: string) => readonly ["usages", "user", string];
270
+ readonly platform: () => readonly ["usages", "platform"];
271
+ };
272
+ readonly prices: {
273
+ readonly stripe: () => readonly ["prices", "stripe"];
274
+ };
275
+ readonly growth: {
276
+ readonly kpi: () => readonly ["growth", "kpi"];
277
+ };
278
+ readonly oauth2: {
279
+ readonly authorizationUrl: (queryArgs: Record<string, string>) => readonly ["oauth2", "authz", "url", Record<string, string>];
280
+ readonly authorizationLinkUrl: (queryArgs: Record<string, string>) => readonly ["oauth2", "authz", "url", "link", Record<string, string>];
281
+ };
282
+ };
283
+ };
284
+ /**
285
+ * Hook to fetch user's agent runtimes (running agent instances).
286
+ * Used by the sidebar to show running/paused/terminated agents.
287
+ */
288
+ export declare function useAgentRuntimes(): import("@tanstack/react-query").UseQueryResult<{
289
+ status: "running" | "paused" | "starting" | "terminated" | "archived";
290
+ name: string;
291
+ id: string;
292
+ url: string | undefined;
293
+ messageCount: number;
294
+ agent_spec_id: string | undefined;
295
+ pod_name: string;
296
+ environment_name: string;
297
+ environment_title?: string;
298
+ given_name: string;
299
+ phase?: string;
300
+ type: string;
301
+ started_at?: string;
302
+ expired_at?: string;
303
+ burning_rate?: number;
304
+ ingress?: string;
305
+ token?: string;
306
+ agentSpec?: any;
307
+ }[], Error>;
308
+ /**
309
+ * Hook to fetch a single agent runtime by pod name.
310
+ */
311
+ export declare function useAgentRuntimeByPodName(podName: string | undefined): import("@tanstack/react-query").UseQueryResult<{
312
+ status: "running" | "paused" | "starting" | "terminated" | "archived";
313
+ name: string;
314
+ id: string;
315
+ url: string | undefined;
316
+ messageCount: number;
317
+ agent_spec_id: string | undefined;
318
+ pod_name: string;
319
+ environment_name: string;
320
+ environment_title?: string;
321
+ given_name: string;
322
+ phase?: string;
323
+ type: string;
324
+ started_at?: string;
325
+ expired_at?: string;
326
+ burning_rate?: number;
327
+ ingress?: string;
328
+ token?: string;
329
+ agentSpec?: any;
330
+ }, Error>;
331
+ /**
332
+ * Hook to create a new agent runtime.
333
+ */
334
+ export declare function useCreateAgentRuntime(): import("@tanstack/react-query").UseMutationResult<any, Error, {
335
+ environmentName?: string;
336
+ givenName?: string;
337
+ creditsLimit?: number;
338
+ type?: string;
339
+ editorVariant?: string;
340
+ enableCodemode?: boolean;
341
+ agentSpecId?: string;
342
+ }, unknown>;
343
+ /**
344
+ * Hook to delete an agent runtime.
345
+ */
346
+ export declare function useDeleteAgentRuntime(): import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
347
+ /**
348
+ * Hook to refresh agent runtimes list.
349
+ */
350
+ export declare function useRefreshAgentRuntimes(): () => void;
@@ -0,0 +1,78 @@
1
+ /*
2
+ * Copyright (c) 2025-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * Hooks for managing Agent Runtimes (running agent instances).
7
+ *
8
+ * Agent Runtimes are backed by the datalayer-runtimes service (K8s pods).
9
+ * A project (space with variant="project") can have an agent runtime attached
10
+ * via its `attachedAgentPodName` field.
11
+ *
12
+ * @module hooks/useAgentRuntimes
13
+ */
14
+ import { useCache } from '@datalayer/core/lib/hooks';
15
+ /**
16
+ * Hook to access all agent runtime operations from the centralized cache.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * const {
21
+ * useAgentRuntime,
22
+ * useAgentRuntimes,
23
+ * useCreateAgentRuntime,
24
+ * useDeleteAgentRuntime,
25
+ * useRefreshAgentRuntimes,
26
+ * } = useAgentRuntimesCache();
27
+ * ```
28
+ */
29
+ export function useAgentRuntimesCache() {
30
+ const cache = useCache();
31
+ return {
32
+ useAgentRuntime: cache.useAgentRuntime,
33
+ useAgentRuntimes: cache.useAgentRuntimes,
34
+ useCreateAgentRuntime: cache.useCreateAgentRuntime,
35
+ useDeleteAgentRuntime: cache.useDeleteAgentRuntime,
36
+ useRefreshAgentRuntimes: cache.useRefreshAgentRuntimes,
37
+ queryKeys: cache.queryKeys,
38
+ };
39
+ }
40
+ // ============================================================================
41
+ // Agent Runtimes Hooks (from datalayer-runtimes service)
42
+ // ============================================================================
43
+ /**
44
+ * Hook to fetch user's agent runtimes (running agent instances).
45
+ * Used by the sidebar to show running/paused/terminated agents.
46
+ */
47
+ export function useAgentRuntimes() {
48
+ const { useAgentRuntimes: hook } = useCache();
49
+ return hook();
50
+ }
51
+ /**
52
+ * Hook to fetch a single agent runtime by pod name.
53
+ */
54
+ export function useAgentRuntimeByPodName(podName) {
55
+ const { useAgentRuntime: hook } = useCache();
56
+ return hook(podName);
57
+ }
58
+ /**
59
+ * Hook to create a new agent runtime.
60
+ */
61
+ export function useCreateAgentRuntime() {
62
+ const { useCreateAgentRuntime: hook } = useCache();
63
+ return hook();
64
+ }
65
+ /**
66
+ * Hook to delete an agent runtime.
67
+ */
68
+ export function useDeleteAgentRuntime() {
69
+ const { useDeleteAgentRuntime: hook } = useCache();
70
+ return hook();
71
+ }
72
+ /**
73
+ * Hook to refresh agent runtimes list.
74
+ */
75
+ export function useRefreshAgentRuntimes() {
76
+ const { useRefreshAgentRuntimes: hook } = useCache();
77
+ return hook();
78
+ }
@@ -0,0 +1,30 @@
1
+ import type { AgentSpec } from '../types';
2
+ import type { AgentRuntimeData } from './useAgentRuntimes';
3
+ /**
4
+ * Centralised Zustand store for agents.
5
+ *
6
+ * Two collections are maintained:
7
+ *
8
+ * 1. **agentSpecs** – the static catalogue of available agent blueprints
9
+ * (from `@datalayer/agent-runtimes/lib/specs`).
10
+ * Populated once at import time; call `refreshSpecs()` to re-read.
11
+ *
12
+ * 2. **runningAgents** – live agent runtimes fetched from the runtimes
13
+ * service. Updated via `setRunningAgents()` whenever the TanStack
14
+ * query refreshes.
15
+ *
16
+ * The store is consumed by `AgentAssignMenu` to show two action groups:
17
+ * • **Running Agents** – already-running runtimes that can be re-attached
18
+ * • **New Agents** – agent specs that can be instantiated
19
+ */
20
+ export type AgentStoreState = {
21
+ /** Static catalogue of agent blueprints. */
22
+ agentSpecs: AgentSpec[];
23
+ /** Live agent runtimes (running / starting). */
24
+ runningAgents: AgentRuntimeData[];
25
+ /** Re-read agent specs from the config. */
26
+ refreshSpecs: () => void;
27
+ /** Replace the running agents list (call from TanStack query effect). */
28
+ setRunningAgents: (agents: AgentRuntimeData[]) => void;
29
+ };
30
+ export declare const useAgentCatalogStore: import("zustand").UseBoundStore<import("zustand").StoreApi<AgentStoreState>>;
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Copyright (c) 2025-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ import { create } from 'zustand';
6
+ import { listAgentSpecs } from '../specs';
7
+ // ── Store ──────────────────────────────────────────────────────────────────
8
+ export const useAgentCatalogStore = create()(set => ({
9
+ agentSpecs: listAgentSpecs('datalayer-ai/'),
10
+ runningAgents: [],
11
+ refreshSpecs: () => set({ agentSpecs: listAgentSpecs('datalayer-ai/') }),
12
+ setRunningAgents: agents => set(state => ({
13
+ runningAgents: agents.map(agent => {
14
+ if (agent.agentSpec)
15
+ return agent;
16
+ if (!agent.agent_spec_id)
17
+ return agent;
18
+ const spec = state.agentSpecs.find(s => s.id === agent.agent_spec_id);
19
+ return spec ? { ...agent, agentSpec: spec } : agent;
20
+ }),
21
+ })),
22
+ }));
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Agent Library.
3
3
  *
4
- * Predefined agent specifications that can be instantiated as AgentSpaces.
4
+ * Predefined agent specifications that can be instantiated as Agent Runtimes.
5
5
  * THIS FILE IS AUTO-GENERATED. DO NOT EDIT MANUALLY.
6
6
  * Generated from YAML specifications in specs/agents/
7
7
  */
@@ -79,6 +79,20 @@ export const DATA_ACQUISITION_AGENT_SPEC = {
79
79
  ## Recommended Workflow 1. **Discover**: Use list_servers and search_tools to find relevant tools 2. **Understand**: Use get_tool_details to check parameters 3. **Execute**: Use execute_code to perform multi-step tasks, calling tools as needed
80
80
  ## Token Efficiency When possible, chain multiple tool calls in a single execute_code block. This reduces output tokens by processing intermediate results in code rather than returning them. If you want to examine results, print subsets, preview (maximum 20 first characters) and/or counts instead of full data, this is really important.
81
81
  `,
82
+ goal: undefined,
83
+ protocol: undefined,
84
+ uiExtension: undefined,
85
+ trigger: undefined,
86
+ modelConfig: undefined,
87
+ mcpServerTools: undefined,
88
+ guardrails: undefined,
89
+ evals: undefined,
90
+ codemode: undefined,
91
+ output: undefined,
92
+ advanced: undefined,
93
+ authorizationPolicy: undefined,
94
+ notifications: undefined,
95
+ team: undefined,
82
96
  };
83
97
  export const SIMPLE_AGENT_SPEC = {
84
98
  id: 'codeai/simple',
@@ -103,6 +117,20 @@ export const SIMPLE_AGENT_SPEC = {
103
117
  systemPrompt: `You are a helpful, friendly AI assistant. You do not have access to any external tools, MCP servers, or skills. Answer questions using your training knowledge, be concise, and let the user know if a question is outside your knowledge.
104
118
  `,
105
119
  systemPromptCodemodeAddons: undefined,
120
+ goal: undefined,
121
+ protocol: undefined,
122
+ uiExtension: undefined,
123
+ trigger: undefined,
124
+ modelConfig: undefined,
125
+ mcpServerTools: undefined,
126
+ guardrails: undefined,
127
+ evals: undefined,
128
+ codemode: undefined,
129
+ output: undefined,
130
+ advanced: undefined,
131
+ authorizationPolicy: undefined,
132
+ notifications: undefined,
133
+ team: undefined,
106
134
  };
107
135
  // ============================================================================
108
136
  // Agent Specs Registry
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Agent Library.
3
3
  *
4
- * Predefined agent specifications that can be instantiated as AgentSpaces.
4
+ * Predefined agent specifications that can be instantiated as Agent Runtimes.
5
5
  * THIS FILE IS AUTO-GENERATED. DO NOT EDIT MANUALLY.
6
6
  * Generated from YAML specifications in specs/agents/
7
7
  */