@datalayer/agent-runtimes 0.0.5 → 0.0.8

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 (119) hide show
  1. package/README.md +150 -22
  2. package/lib/components/chat/components/AgentDetails.d.ts +15 -2
  3. package/lib/components/chat/components/AgentDetails.js +9 -93
  4. package/lib/components/chat/components/AgentIdentity.d.ts +92 -0
  5. package/lib/components/chat/components/AgentIdentity.js +318 -0
  6. package/lib/components/chat/components/Chat.d.ts +24 -1
  7. package/lib/components/chat/components/Chat.js +41 -19
  8. package/lib/components/chat/components/ChatFloating.d.ts +6 -1
  9. package/lib/components/chat/components/ChatFloating.js +12 -6
  10. package/lib/components/chat/components/ContextDistribution.d.ts +47 -0
  11. package/lib/components/chat/components/ContextDistribution.js +146 -0
  12. package/lib/components/chat/components/ContextUsage.d.ts +33 -0
  13. package/lib/components/chat/components/ContextUsage.js +127 -0
  14. package/lib/components/chat/components/base/ChatBase.d.ts +51 -1
  15. package/lib/components/chat/components/base/ChatBase.js +278 -74
  16. package/lib/components/chat/components/display/ToolCallDisplay.d.ts +16 -2
  17. package/lib/components/chat/components/display/ToolCallDisplay.js +148 -6
  18. package/lib/components/chat/components/display/index.d.ts +1 -1
  19. package/lib/components/chat/components/display/index.js +1 -1
  20. package/lib/components/chat/components/elements/ChatInputPrompt.d.ts +12 -1
  21. package/lib/components/chat/components/elements/ChatInputPrompt.js +8 -3
  22. package/lib/components/chat/components/index.d.ts +3 -0
  23. package/lib/components/chat/components/index.js +3 -0
  24. package/lib/components/chat/components/parts/ToolPart.d.ts +1 -1
  25. package/lib/components/chat/components/parts/ToolPart.js +142 -6
  26. package/lib/components/chat/index.d.ts +1 -1
  27. package/lib/components/chat/index.js +1 -1
  28. package/lib/components/chat/protocols/A2AAdapter.d.ts +9 -0
  29. package/lib/components/chat/protocols/A2AAdapter.js +13 -2
  30. package/lib/components/chat/protocols/ACPAdapter.d.ts +9 -0
  31. package/lib/components/chat/protocols/ACPAdapter.js +13 -2
  32. package/lib/components/chat/protocols/AGUIAdapter.d.ts +9 -0
  33. package/lib/components/chat/protocols/AGUIAdapter.js +19 -1
  34. package/lib/components/chat/protocols/VercelAIAdapter.d.ts +7 -0
  35. package/lib/components/chat/protocols/VercelAIAdapter.js +19 -0
  36. package/lib/components/chat/types/execution.d.ts +78 -0
  37. package/lib/components/chat/types/execution.js +64 -0
  38. package/lib/components/chat/types/index.d.ts +1 -0
  39. package/lib/components/chat/types/index.js +1 -0
  40. package/lib/components/chat/types/protocol.d.ts +9 -0
  41. package/lib/components/ui/pagination.d.ts +2 -2
  42. package/lib/components/ui/pagination.js +4 -4
  43. package/lib/components/ui/resizable.d.ts +4 -4
  44. package/lib/components/ui/resizable.js +4 -4
  45. package/lib/examples/A2UiRestaurantExample.js +2 -2
  46. package/lib/examples/AgUiAgenticExample.js +2 -2
  47. package/lib/examples/AgUiBackendToolRenderingExample.js +2 -2
  48. package/lib/examples/AgUiHaikuGenUIExample.js +2 -2
  49. package/lib/examples/AgUiHumanInTheLoopExample.js +2 -2
  50. package/lib/examples/AgUiSharedStateExample.js +2 -2
  51. package/lib/examples/AgUiToolsBasedGenUIExample.js +2 -2
  52. package/lib/examples/AgentRuntimeCustomExample.js +2 -2
  53. package/lib/examples/AgentRuntimeLexical2Example.js +2 -1
  54. package/lib/examples/AgentRuntimeLexicalExample.js +5 -2
  55. package/lib/examples/AgentRuntimeLexicalSidebarExample.js +4 -2
  56. package/lib/examples/AgentRuntimeNotebookExample.js +1 -1
  57. package/lib/examples/AgentRuntimeStandaloneExample.js +2 -2
  58. package/lib/examples/AgentSpaceFormExample.d.ts +70 -2
  59. package/lib/examples/AgentSpaceFormExample.js +204 -35
  60. package/lib/examples/CopilotKitLexicalExample.js +2 -1
  61. package/lib/examples/components/AgentConfiguration.d.ts +37 -0
  62. package/lib/examples/components/AgentConfiguration.js +239 -8
  63. package/lib/examples/components/Header.d.ts +0 -2
  64. package/lib/examples/components/Header.js +2 -16
  65. package/lib/examples/components/LexicalEditor.js +2 -1
  66. package/lib/examples/components/MockFileBrowser.js +6 -2
  67. package/lib/examples/components/index.d.ts +0 -1
  68. package/lib/examples/components/index.js +0 -1
  69. package/lib/examples/example-selector.js +0 -1
  70. package/lib/examples/index.d.ts +0 -1
  71. package/lib/examples/index.js +0 -1
  72. package/lib/examples/lexical/editorConfig.d.ts +3 -2
  73. package/lib/examples/lexical/editorConfig.js +7 -1
  74. package/lib/examples/lexical/initial-content.json +2210 -0
  75. package/lib/examples/main.js +15 -1
  76. package/lib/identity/IdentityConnect.d.ts +90 -0
  77. package/lib/identity/IdentityConnect.js +316 -0
  78. package/lib/identity/OAuthCallback.d.ts +58 -0
  79. package/lib/identity/OAuthCallback.js +223 -0
  80. package/lib/identity/dcr.d.ts +257 -0
  81. package/lib/identity/dcr.js +282 -0
  82. package/lib/identity/identityStore.d.ts +72 -0
  83. package/lib/identity/identityStore.js +529 -0
  84. package/lib/identity/index.d.ts +46 -0
  85. package/lib/identity/index.js +17 -0
  86. package/lib/identity/pkce.d.ts +30 -0
  87. package/lib/identity/pkce.js +65 -0
  88. package/lib/identity/types.d.ts +293 -0
  89. package/lib/identity/types.js +73 -0
  90. package/lib/identity/useIdentity.d.ts +108 -0
  91. package/lib/identity/useIdentity.js +323 -0
  92. package/lib/index.d.ts +2 -0
  93. package/lib/index.js +2 -0
  94. package/lib/lib/utils.js +1 -1
  95. package/lib/renderers/a2ui/lib/utils.js +1 -1
  96. package/lib/runtime/index.d.ts +35 -0
  97. package/lib/runtime/index.js +40 -0
  98. package/lib/runtime/runtimeStore.d.ts +77 -0
  99. package/lib/runtime/runtimeStore.js +184 -0
  100. package/lib/runtime/types.d.ts +84 -0
  101. package/lib/runtime/types.js +15 -0
  102. package/lib/runtime/useAgentConnection.d.ts +46 -0
  103. package/lib/runtime/useAgentConnection.js +112 -0
  104. package/lib/runtime/useAgentRuntime.d.ts +94 -0
  105. package/lib/runtime/useAgentRuntime.js +125 -0
  106. package/lib/test-setup.d.ts +1 -1
  107. package/lib/test-setup.js +1 -0
  108. package/lib/tools/adapters/agent-runtimes/AgentRuntimesToolAdapter.js +32 -1
  109. package/lib/tools/adapters/agent-runtimes/lexicalHooks.d.ts +6 -0
  110. package/lib/tools/adapters/agent-runtimes/lexicalHooks.js +16 -17
  111. package/package.json +20 -7
  112. package/patches/@datalayer+jupyter-lexical+1.0.8.patch +11628 -0
  113. package/patches/@datalayer+jupyter-react+2.0.2.patch +5338 -0
  114. package/lib/examples/AgentSpaceHomeExample.d.ts +0 -8
  115. package/lib/examples/AgentSpaceHomeExample.js +0 -171
  116. package/lib/examples/components/AgentsDataTable.d.ts +0 -13
  117. package/lib/examples/components/AgentsDataTable.js +0 -74
  118. package/lib/examples/components/Rating.d.ts +0 -14
  119. package/lib/examples/components/Rating.js +0 -12
@@ -38,6 +38,34 @@ function isRecentDuplicate(toolName, params) {
38
38
  executionCache.set(signature, Date.now());
39
39
  return false;
40
40
  }
41
+ /**
42
+ * Process parameters to handle JSON strings that should be objects
43
+ * LLMs sometimes generate JSON strings instead of objects for nested parameters
44
+ */
45
+ function processParameters(params) {
46
+ if (!params || typeof params !== 'object' || Array.isArray(params)) {
47
+ return params;
48
+ }
49
+ const processed = {};
50
+ for (const [key, value] of Object.entries(params)) {
51
+ // If value is a string that looks like JSON, try to parse it
52
+ if (typeof value === 'string' &&
53
+ (value.startsWith('{') || value.startsWith('['))) {
54
+ try {
55
+ processed[key] = JSON.parse(value);
56
+ console.log(`[agent-runtimes] 📝 Parsed JSON string for parameter '${key}'`);
57
+ }
58
+ catch {
59
+ // If parsing fails, keep the original string
60
+ processed[key] = value;
61
+ }
62
+ }
63
+ else {
64
+ processed[key] = value;
65
+ }
66
+ }
67
+ return processed;
68
+ }
41
69
  /**
42
70
  * Converts unified tool definition to agent-runtimes tool format
43
71
  *
@@ -67,8 +95,11 @@ export function createAgentRuntimesTool(definition, operation, context) {
67
95
  };
68
96
  }
69
97
  try {
98
+ // Process parameters to handle JSON strings
99
+ const processedParams = processParameters(params);
100
+ console.log(`[agent-runtimes] Processed params:`, processedParams);
70
101
  // Use OperationRunner to execute operation with TOON format
71
- const result = await runner.execute(operation, params, {
102
+ const result = await runner.execute(operation, processedParams, {
72
103
  ...context,
73
104
  format: 'toon', // Return human/LLM-readable string
74
105
  });
@@ -1,3 +1,9 @@
1
+ /**
2
+ * React hooks for agent-runtimes lexical tool registration.
3
+ * Provides: useLexicalTools hook for ChatFloating integration.
4
+ *
5
+ * @module tools/adapters/agent-runtimes/lexicalHooks
6
+ */
1
7
  import type { ToolExecutionContext } from '@datalayer/jupyter-react';
2
8
  import { type AgentRuntimesTool } from './AgentRuntimesToolAdapter';
3
9
  /**
@@ -2,13 +2,6 @@
2
2
  * Copyright (c) 2025-2026 Datalayer, Inc.
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
- /**
6
- * React hooks for agent-runtimes lexical tool registration.
7
- * Provides: useLexicalTools hook for ChatFloating integration.
8
- *
9
- * @module tools/adapters/agent-runtimes/lexicalHooks
10
- */
11
- import { useMemo } from 'react';
12
5
  import { useLexicalStore, DefaultExecutor as LexicalDefaultExecutor, lexicalToolDefinitions, lexicalToolOperations, } from '@datalayer/jupyter-lexical';
13
6
  import { createAllAgentRuntimesTools, } from './AgentRuntimesToolAdapter';
14
7
  /**
@@ -32,19 +25,25 @@ import { createAllAgentRuntimesTools, } from './AgentRuntimesToolAdapter';
32
25
  * ```
33
26
  */
34
27
  export function useLexicalTools(documentId, contextOverrides) {
35
- // Call useLexicalStore() with no selector to get state object
28
+ console.log('[useLexicalTools] 🎣 Hook called with documentId:', documentId);
29
+ // Get fresh store state every render - NO MEMOIZATION
30
+ // This ensures we always use the latest patched methods after hot reload
36
31
  const lexicalStoreState = useLexicalStore();
37
- // Create LexicalDefaultExecutor (stable reference)
38
- // Only recreate when documentId changes, not on every state update
39
- const executor = useMemo(() => new LexicalDefaultExecutor(documentId, lexicalStoreState), [documentId]);
40
- // Create stable context object with useMemo
41
- // Defaults: format='toon' for conversational AI responses
42
- const context = useMemo(() => ({
32
+ console.log('[useLexicalTools] 📦 Store state obtained:', !!lexicalStoreState);
33
+ // Create new executor every render - NO MEMOIZATION
34
+ console.log('[useLexicalTools] 🔧 Creating new executor for documentId:', documentId);
35
+ const executor = new LexicalDefaultExecutor(documentId, lexicalStoreState);
36
+ // Create new context every render - NO MEMOIZATION
37
+ console.log('[useLexicalTools] 📝 Creating context');
38
+ const context = {
43
39
  documentId,
44
40
  executor,
45
41
  format: 'toon',
46
42
  ...contextOverrides,
47
- }), [documentId, executor, contextOverrides]);
48
- // Create and return tools (stable reference)
49
- return useMemo(() => createAllAgentRuntimesTools(lexicalToolDefinitions, lexicalToolOperations, context), [context]);
43
+ };
44
+ // Create new tools array every render - NO MEMOIZATION
45
+ console.log('[useLexicalTools] 🛠️ Creating tools array');
46
+ const tools = createAllAgentRuntimesTools(lexicalToolDefinitions, lexicalToolOperations, context);
47
+ console.log('[useLexicalTools] ✅ Created', tools.length, 'tools');
48
+ return tools;
50
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/agent-runtimes",
3
- "version": "0.0.5",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "workspaces": [
6
6
  ".",
@@ -69,6 +69,7 @@
69
69
  "create:patches": "bash scripts/create-patches.sh",
70
70
  "examples": "run-p server:start examples:vite",
71
71
  "examples:fresh": "npm run clean:cache && npm run examples",
72
+ "examples:codemode-mcp": "EXAMPLE=AgentCodemodeMcpExample VITE_APP_TARGET=examples VITE_DATALAYER_RUN_URL=http://localhost:8888 vite",
72
73
  "examples:nextjs": "npm run dev --workspace=nextjs-notebook-example",
73
74
  "examples:vite": "VITE_APP_TARGET=examples VITE_DATALAYER_RUN_URL=http://localhost:8888 vite",
74
75
  "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,json,md}\" \"examples/**/*.{js,jsx,ts,tsx,css,json,md,mjs}\"",
@@ -88,7 +89,7 @@
88
89
  "preview": "vite preview",
89
90
  "rebuild:fresh": "npm run create:patches && npm install && npm run build && npm run clean:cache",
90
91
  "server": "python -m agent_runtimes",
91
- "server:start": "python -m agent_runtimes --port 8765 --reload --debug",
92
+ "server:start": "PYTHONIOENCODING=utf-8 python -m agent_runtimes --port 8765 --reload --debug",
92
93
  "showcase:vercel-ai-elements": "VITE_APP_TARGET=showcase-vercel-ai-elements vite",
93
94
  "start": "vite",
94
95
  "start:acp": "run-p server:start start:acp:vite",
@@ -122,10 +123,10 @@
122
123
  "@agentclientprotocol/sdk": "^0.8.0",
123
124
  "@ai-sdk/react": "3.0.30",
124
125
  "@anthropic-ai/sdk": "^0.52.0",
125
- "@datalayer/core": "^0.0.24",
126
+ "@datalayer/core": "^0.0.25",
126
127
  "@datalayer/icons-react": "^1.0.6",
127
- "@datalayer/jupyter-lexical": "^1.0.6",
128
- "@datalayer/jupyter-react": "^2.0.0",
128
+ "@datalayer/jupyter-lexical": "^1.0.9",
129
+ "@datalayer/jupyter-react": "^2.0.3",
129
130
  "@datalayer/primer-addons": "^1.0.4",
130
131
  "@datalayer/primer-rjsf": "^1.0.1",
131
132
  "@jupyter-widgets/base-manager": "^1.0.12",
@@ -145,7 +146,7 @@
145
146
  "@lumino/disposable": "^2.1.5",
146
147
  "@lumino/polling": "^2.1.5",
147
148
  "@lumino/signaling": "^2.1.5",
148
- "@lumino/widgets": "^2.7.2",
149
+ "@lumino/widgets": "^2.7.3",
149
150
  "@mcp-ui/client": "^5.17.1",
150
151
  "@modelcontextprotocol/ext-apps": "^0.2.2",
151
152
  "@primer/behaviors": "^1.8.4",
@@ -159,17 +160,24 @@
159
160
  "@radix-ui/react-alert-dialog": "^1.1.15",
160
161
  "@radix-ui/react-aspect-ratio": "^1.1.8",
161
162
  "@radix-ui/react-avatar": "^1.1.11",
163
+ "@radix-ui/react-checkbox": "^1.3.3",
162
164
  "@radix-ui/react-collapsible": "^1.1.12",
165
+ "@radix-ui/react-context-menu": "^2.2.16",
163
166
  "@radix-ui/react-dialog": "^1.1.15",
164
167
  "@radix-ui/react-dropdown-menu": "^2.1.16",
165
168
  "@radix-ui/react-hover-card": "^1.1.15",
169
+ "@radix-ui/react-icons": "^1.3.2",
170
+ "@radix-ui/react-label": "^2.1.8",
166
171
  "@radix-ui/react-menubar": "^1.1.16",
167
172
  "@radix-ui/react-navigation-menu": "^1.2.14",
168
173
  "@radix-ui/react-progress": "^1.1.8",
174
+ "@radix-ui/react-radio-group": "^1.3.8",
169
175
  "@radix-ui/react-scroll-area": "^1.2.10",
170
176
  "@radix-ui/react-select": "^2.2.6",
171
177
  "@radix-ui/react-separator": "^1.1.8",
178
+ "@radix-ui/react-slider": "^1.3.6",
172
179
  "@radix-ui/react-slot": "^1.2.4",
180
+ "@radix-ui/react-switch": "^1.2.6",
173
181
  "@radix-ui/react-toast": "^1.2.15",
174
182
  "@radix-ui/react-toggle-group": "^1.1.11",
175
183
  "@radix-ui/react-tooltip": "^1.2.8",
@@ -183,6 +191,7 @@
183
191
  "ansi-to-html": "^0.7.2",
184
192
  "axios": "^1.7.7",
185
193
  "boring-avatars": "^2.0.1",
194
+ "class-variance-authority": "^0.7.1",
186
195
  "cmdk": "^1.1.1",
187
196
  "date-fns": "^2.29.3",
188
197
  "deepmerge": "^4.3.1",
@@ -199,14 +208,16 @@
199
208
  "mock-socket": "^9.3.1",
200
209
  "motion": "^12.23.26",
201
210
  "nanoid": "^5.1.6",
211
+ "next-themes": "^0.4.6",
202
212
  "react": "18.3.1",
203
213
  "react-confetti": "^6.4.0",
204
214
  "react-dom": "18.3.1",
205
215
  "react-hook-form": "^7.69.0",
206
216
  "react-is": "^19.2.0",
217
+ "react-resizable-panels": "^4.4.1",
207
218
  "react-router-dom": "^6.0.0",
208
219
  "react-toastify": "^11.0.5",
209
- "recharts": "^3.6.0",
220
+ "recharts": "^3.7.0",
210
221
  "shiki": "^3.20.0",
211
222
  "sonner": "^2.0.7",
212
223
  "streamdown": "^1.6.10",
@@ -240,6 +251,8 @@
240
251
  "@storybook/builder-vite": "^9.1.1",
241
252
  "@storybook/react-vite": "^9.1.1",
242
253
  "@tailwindcss/postcss": "^4.1.16",
254
+ "@testing-library/react": "^16.3.0",
255
+ "@testing-library/jest-dom": "^6.4.8",
243
256
  "@types/node": "^20.11.0",
244
257
  "@types/react": "18.3.20",
245
258
  "@types/react-dom": "18.3.6",