@datalayer/agent-runtimes 1.0.3 → 1.0.5
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.
- package/README.md +35 -119
- package/lib/App.js +1 -1
- package/lib/agents/AgentDetails.d.ts +22 -1
- package/lib/agents/AgentDetails.js +34 -47
- package/lib/api/index.d.ts +0 -1
- package/lib/api/index.js +4 -2
- package/lib/chat/Chat.d.ts +5 -104
- package/lib/chat/Chat.js +4 -4
- package/lib/chat/ChatFloating.d.ts +7 -140
- package/lib/chat/ChatFloating.js +2 -2
- package/lib/chat/ChatPopupStandalone.d.ts +8 -47
- package/lib/chat/ChatPopupStandalone.js +3 -3
- package/lib/chat/ChatSidebar.d.ts +4 -69
- package/lib/chat/ChatSidebar.js +2 -2
- package/lib/chat/ChatStandalone.d.ts +4 -54
- package/lib/chat/ChatStandalone.js +3 -3
- package/lib/chat/base/ChatBase.js +1118 -141
- package/lib/chat/header/ChatHeaderBase.d.ts +11 -6
- package/lib/chat/header/ChatHeaderBase.js +18 -16
- package/lib/chat/indicators/McpStatusIndicator.d.ts +7 -4
- package/lib/chat/indicators/McpStatusIndicator.js +7 -32
- package/lib/chat/indicators/SandboxStatusIndicator.d.ts +4 -1
- package/lib/chat/indicators/SandboxStatusIndicator.js +9 -9
- package/lib/chat/indicators/SkillsStatusIndicator.d.ts +7 -0
- package/lib/chat/indicators/SkillsStatusIndicator.js +88 -0
- package/lib/chat/indicators/index.d.ts +1 -0
- package/lib/chat/indicators/index.js +1 -0
- package/lib/chat/messages/ChatMessageList.d.ts +1 -1
- package/lib/chat/messages/ChatMessageList.js +110 -102
- package/lib/chat/prompt/InputFooter.d.ts +19 -6
- package/lib/chat/prompt/InputFooter.js +71 -18
- package/lib/chat/prompt/InputPrompt.d.ts +3 -1
- package/lib/chat/prompt/InputPrompt.js +4 -4
- package/lib/chat/prompt/InputPromptFooter.js +1 -1
- package/lib/chat/prompt/InputPromptLexical.d.ts +3 -1
- package/lib/chat/prompt/InputPromptLexical.js +12 -5
- package/lib/chat/prompt/InputPromptText.d.ts +3 -1
- package/lib/chat/prompt/InputPromptText.js +2 -2
- package/lib/chat/tools/ToolApprovalBanner.js +1 -1
- package/lib/chat/tools/ToolCallDisplay.d.ts +3 -1
- package/lib/chat/tools/ToolCallDisplay.js +2 -2
- package/lib/chat/usage/TokenUsageBar.js +20 -2
- package/lib/client/AgentRuntimesClientContext.d.ts +53 -0
- package/lib/client/AgentRuntimesClientContext.js +55 -0
- package/lib/client/AgentsMixin.d.ts +48 -19
- package/lib/client/AgentsMixin.js +115 -30
- package/lib/client/IAgentRuntimesClient.d.ts +215 -0
- package/lib/client/IAgentRuntimesClient.js +5 -0
- package/lib/client/SdkAgentRuntimesClient.d.ts +151 -0
- package/lib/client/SdkAgentRuntimesClient.js +134 -0
- package/lib/client/index.d.ts +4 -1
- package/lib/client/index.js +3 -1
- package/lib/components/NotificationEventCard.js +55 -26
- package/lib/components/OutputCard.js +21 -7
- package/lib/components/ToolApprovalCard.js +20 -2
- package/lib/config/AgentConfiguration.js +3 -3
- package/lib/context/ContextDistribution.d.ts +3 -1
- package/lib/context/ContextDistribution.js +8 -27
- package/lib/context/ContextInspector.d.ts +3 -1
- package/lib/context/ContextInspector.js +19 -67
- package/lib/context/ContextPanel.d.ts +3 -1
- package/lib/context/ContextPanel.js +104 -64
- package/lib/context/ContextUsage.d.ts +3 -1
- package/lib/context/ContextUsage.js +3 -3
- package/lib/context/CostTracker.d.ts +9 -3
- package/lib/context/CostTracker.js +26 -47
- package/lib/context/CostUsageChart.d.ts +12 -0
- package/lib/context/CostUsageChart.js +378 -0
- package/lib/context/GraphFlowChart.d.ts +16 -0
- package/lib/context/GraphFlowChart.js +182 -0
- package/lib/context/TokenUsageChart.d.ts +8 -1
- package/lib/context/TokenUsageChart.js +349 -211
- package/lib/context/TurnGraphChart.d.ts +39 -0
- package/lib/context/TurnGraphChart.js +538 -0
- package/lib/context/otelWsPool.d.ts +20 -0
- package/lib/context/otelWsPool.js +69 -0
- package/lib/examples/A2UiComponentGalleryExample.d.ts +0 -17
- package/lib/examples/A2UiComponentGalleryExample.js +315 -522
- package/lib/examples/A2UiContactCardExample.d.ts +0 -18
- package/lib/examples/A2UiContactCardExample.js +154 -411
- package/lib/examples/A2UiRestaurantExample.d.ts +0 -30
- package/lib/examples/A2UiRestaurantExample.js +114 -212
- package/lib/examples/A2UiViewerExample.d.ts +0 -18
- package/lib/examples/A2UiViewerExample.js +283 -532
- package/lib/examples/AgUiBackendToolRenderingExample.js +1 -1
- package/lib/examples/AgUiHaikuGenUiExample.d.ts +1 -1
- package/lib/examples/AgUiHaikuGenUiExample.js +1 -1
- package/lib/examples/AgentCheckpointsExample.js +14 -34
- package/lib/examples/AgentCodemodeExample.d.ts +4 -6
- package/lib/examples/AgentCodemodeExample.js +591 -175
- package/lib/examples/AgentEvalsExample.js +13 -23
- package/lib/examples/AgentGuardrailsExample.js +371 -71
- package/lib/examples/AgentHooksExample.d.ts +3 -0
- package/lib/examples/AgentHooksExample.js +104 -0
- package/lib/examples/AgentMCPExample.d.ts +3 -0
- package/lib/examples/AgentMCPExample.js +480 -0
- package/lib/examples/AgentMemoryExample.js +14 -24
- package/lib/examples/AgentMonitoringExample.js +261 -206
- package/lib/examples/AgentNotificationsExample.js +50 -24
- package/lib/examples/AgentOtelExample.js +2 -3
- package/lib/examples/AgentOutputsExample.d.ts +11 -6
- package/lib/examples/AgentOutputsExample.js +383 -88
- package/lib/examples/AgentParametersExample.d.ts +3 -0
- package/lib/examples/AgentParametersExample.js +246 -0
- package/lib/examples/AgentSandboxExample.d.ts +2 -2
- package/lib/examples/AgentSandboxExample.js +69 -47
- package/lib/examples/AgentSkillsExample.js +92 -106
- package/lib/examples/{AgentspecExample.js → AgentSpecsExample.js} +10 -21
- package/lib/examples/AgentSubagentsExample.d.ts +14 -0
- package/lib/examples/AgentSubagentsExample.js +228 -0
- package/lib/examples/AgentToolApprovalsExample.js +30 -493
- package/lib/examples/AgentTriggersExample.js +1067 -246
- package/lib/examples/ChatCustomExample.js +11 -24
- package/lib/examples/ChatExample.js +9 -34
- package/lib/examples/CopilotKitLexicalExample.js +2 -1
- package/lib/examples/CopilotKitNotebookExample.js +2 -1
- package/lib/examples/HomeExample.d.ts +15 -0
- package/lib/examples/HomeExample.js +77 -0
- package/lib/examples/Lexical2Example.js +4 -2
- package/lib/examples/{LexicalExample.d.ts → LexicalAgentExample.d.ts} +4 -4
- package/lib/examples/{LexicalExample.js → LexicalAgentExample.js} +65 -16
- package/lib/examples/{LexicalSidebarExample.d.ts → LexicalAgentSidebarExample.d.ts} +5 -5
- package/lib/examples/LexicalAgentSidebarExample.js +261 -0
- package/lib/examples/NotebookAgentExample.d.ts +9 -0
- package/lib/examples/NotebookAgentExample.js +192 -0
- package/lib/examples/{NotebookSidebarExample.d.ts → NotebookAgentSidebarExample.d.ts} +2 -2
- package/lib/examples/NotebookAgentSidebarExample.js +221 -0
- package/lib/examples/{DatalayerNotebookExample.d.ts → NotebookCollaborationExample.d.ts} +4 -4
- package/lib/examples/{DatalayerNotebookExample.js → NotebookCollaborationExample.js} +3 -3
- package/lib/examples/NotebookExample.d.ts +4 -7
- package/lib/examples/NotebookExample.js +14 -146
- package/lib/examples/components/AuthRequiredView.d.ts +6 -0
- package/lib/examples/components/AuthRequiredView.js +33 -0
- package/lib/examples/components/ErrorView.d.ts +14 -0
- package/lib/examples/components/ErrorView.js +20 -0
- package/lib/examples/components/ExampleWrapper.d.ts +7 -0
- package/lib/examples/components/ExampleWrapper.js +25 -6
- package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.js +1 -1
- package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.js +1 -1
- package/lib/examples/{ag-ui → components}/haiku/index.d.ts +1 -1
- package/lib/examples/{ag-ui → components}/haiku/index.js +1 -1
- package/lib/examples/components/index.d.ts +5 -0
- package/lib/examples/components/index.js +5 -0
- package/lib/examples/{ag-ui → components}/weather/index.d.ts +1 -1
- package/lib/examples/{ag-ui → components}/weather/index.js +1 -1
- package/lib/examples/example-selector.d.ts +17 -4
- package/lib/examples/example-selector.js +107 -41
- package/lib/examples/index.d.ts +9 -6
- package/lib/examples/index.js +9 -6
- package/lib/examples/main.d.ts +1 -0
- package/lib/examples/main.js +218 -27
- package/lib/examples/utils/a2ui.d.ts +18 -0
- package/lib/examples/utils/a2ui.js +69 -0
- package/lib/examples/utils/a2uiMarkdownProvider.d.ts +7 -0
- package/lib/examples/utils/a2uiMarkdownProvider.js +9 -0
- package/lib/examples/utils/agentId.d.ts +18 -0
- package/lib/examples/utils/agentId.js +54 -0
- package/lib/examples/utils/agents/earthquake-detector.json +11 -11
- package/lib/examples/utils/agents/sales-forecaster.json +11 -11
- package/lib/examples/utils/agents/social-post-generator.json +11 -11
- package/lib/examples/utils/agents/stock-market.json +11 -11
- package/lib/examples/utils/examplesStore.js +82 -27
- package/lib/hooks/index.d.ts +8 -8
- package/lib/hooks/index.js +7 -7
- package/lib/hooks/useA2A.d.ts +2 -3
- package/lib/hooks/useAIAgentsWebSocket.d.ts +43 -4
- package/lib/hooks/useAIAgentsWebSocket.js +118 -12
- package/lib/hooks/useAcp.d.ts +1 -2
- package/lib/hooks/useAgUi.d.ts +1 -1
- package/lib/hooks/{useAgents.d.ts → useAgentRuntimes.d.ts} +39 -2
- package/lib/hooks/{useAgents.js → useAgentRuntimes.js} +125 -15
- package/lib/hooks/useAgentsCatalog.js +1 -1
- package/lib/hooks/useAgentsService.d.ts +2 -2
- package/lib/hooks/useAgentsService.js +7 -7
- package/lib/hooks/useCheckpoints.js +1 -1
- package/lib/hooks/useConfig.d.ts +4 -1
- package/lib/hooks/useConfig.js +10 -3
- package/lib/hooks/useContextSnapshot.d.ts +9 -4
- package/lib/hooks/useContextSnapshot.js +9 -37
- package/lib/hooks/useMonitoring.js +3 -0
- package/lib/hooks/useSandbox.d.ts +20 -8
- package/lib/hooks/useSandbox.js +105 -40
- package/lib/hooks/useSkills.d.ts +23 -5
- package/lib/hooks/useSkills.js +94 -39
- package/lib/hooks/useToolApprovals.d.ts +60 -36
- package/lib/hooks/useToolApprovals.js +318 -69
- package/lib/hooks/useVercelAI.d.ts +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -0
- package/lib/inference/index.d.ts +0 -1
- package/lib/middleware/index.d.ts +0 -1
- package/lib/protocols/AGUIAdapter.js +6 -0
- package/lib/protocols/VercelAIAdapter.d.ts +9 -0
- package/lib/protocols/VercelAIAdapter.js +144 -26
- package/lib/shims/json5.d.ts +4 -0
- package/lib/shims/json5.js +8 -0
- package/lib/specs/agents/agents.d.ts +10 -0
- package/lib/specs/agents/agents.js +752 -24
- package/lib/specs/envvars.d.ts +1 -0
- package/lib/specs/envvars.js +11 -0
- package/lib/specs/events.d.ts +1 -0
- package/lib/specs/events.js +1 -0
- package/lib/specs/index.d.ts +1 -0
- package/lib/specs/index.js +1 -0
- package/lib/specs/personas.d.ts +41 -0
- package/lib/specs/personas.js +168 -0
- package/lib/specs/skills.d.ts +2 -1
- package/lib/specs/skills.js +23 -5
- package/lib/specs/tools.js +3 -0
- package/lib/stores/agentRuntimeStore.d.ts +204 -0
- package/lib/stores/agentRuntimeStore.js +636 -0
- package/lib/stores/index.d.ts +1 -1
- package/lib/stores/index.js +1 -1
- package/lib/tools/adapters/copilotkit/lexicalHooks.d.ts +1 -2
- package/lib/tools/adapters/copilotkit/lexicalHooks.js +1 -3
- package/lib/tools/adapters/copilotkit/notebookHooks.d.ts +1 -2
- package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -3
- package/lib/tools/index.d.ts +0 -2
- package/lib/tools/index.js +0 -1
- package/lib/types/agentspecs.d.ts +50 -1
- package/lib/types/chat.d.ts +309 -8
- package/lib/types/context.d.ts +27 -0
- package/lib/types/cost.d.ts +2 -2
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +2 -0
- package/lib/types/mcp.d.ts +8 -0
- package/lib/types/models.d.ts +2 -2
- package/lib/types/personas.d.ts +25 -0
- package/lib/types/personas.js +5 -0
- package/lib/types/skills.d.ts +43 -1
- package/lib/types/stream.d.ts +110 -0
- package/lib/types/stream.js +36 -0
- package/lib/types/tools.d.ts +2 -0
- package/lib/utils/utils.d.ts +9 -5
- package/lib/utils/utils.js +9 -5
- package/package.json +13 -9
- package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_events.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
- package/scripts/codegen/generate_agents.py +106 -7
- package/scripts/codegen/generate_events.py +47 -17
- package/scripts/codegen/generate_personas.py +319 -0
- package/scripts/codegen/generate_skills.py +9 -9
- package/scripts/codegen/generate_tools.py +20 -0
- package/scripts/sync-jupyter.sh +26 -7
- package/style/primer-primitives.css +1 -6
- package/lib/api/tool-approvals.d.ts +0 -62
- package/lib/api/tool-approvals.js +0 -145
- package/lib/examples/LexicalSidebarExample.js +0 -163
- package/lib/examples/NotebookSidebarExample.js +0 -119
- package/lib/examples/NotebookSimpleExample.d.ts +0 -6
- package/lib/examples/NotebookSimpleExample.js +0 -22
- package/lib/examples/ag-ui/index.d.ts +0 -10
- package/lib/examples/ag-ui/index.js +0 -16
- package/lib/hooks/useAgentsRegistry.d.ts +0 -10
- package/lib/hooks/useAgentsRegistry.js +0 -20
- package/lib/stores/agentsStore.d.ts +0 -123
- package/lib/stores/agentsStore.js +0 -270
- package/scripts/codegen/__pycache__/generate_envvars.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_evals.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_guardrails.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_mcp_servers.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_memory.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_models.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_notifications.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_outputs.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_skills.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_teams.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_tools.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_triggers.cpython-313.pyc +0 -0
- /package/lib/examples/{AgentspecExample.d.ts → AgentSpecsExample.d.ts} +0 -0
- /package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.js +0 -0
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export * from './chat';
|
|
2
|
+
export * from './client';
|
|
2
3
|
export * from './components';
|
|
3
4
|
export * from './mcp';
|
|
4
5
|
export * from './stores';
|
|
5
6
|
export * from './identity';
|
|
6
7
|
export * from './config';
|
|
7
8
|
export * from './specs';
|
|
8
|
-
export type { AgentRuntimeData, AgentSpec, TeamSpec, GuardrailSpec, EvalSpec, TriggerSpec, OutputSpec, NotificationChannelSpec, MCPServer, SkillSpec, EnvvarSpec, } from './types';
|
|
9
|
+
export type { AgentRuntimeData, AgentSpec, ChatCommonProps, TeamSpec, GuardrailSpec, EvalSpec, TriggerSpec, OutputSpec, NotificationChannelSpec, MCPServer, SkillSpec, SkillInfo, SkillStatus, EnvvarSpec, ToolCallStartContext, ToolCallCompleteContext, } from './types';
|
package/lib/index.js
CHANGED
package/lib/inference/index.d.ts
CHANGED
|
@@ -6,4 +6,3 @@
|
|
|
6
6
|
export { BaseInferenceProvider } from './BaseInferenceProvider';
|
|
7
7
|
export { DatalayerInferenceProvider, type DatalayerInferenceConfig, } from './DatalayerInferenceProvider';
|
|
8
8
|
export { SelfHostedInferenceProvider, type SelfHostedInferenceConfig, } from './SelfHostedInferenceProvider';
|
|
9
|
-
export type { InferenceProvider, InferenceProviderConfig, InferenceProviderFactory, InferenceProviderType, InferenceRequestOptions, InferenceResponse, StreamEvent, StreamEventType, StreamEventHandler, } from '../types/inference';
|
|
@@ -168,6 +168,12 @@ export class AGUIAdapter extends BaseProtocolAdapter {
|
|
|
168
168
|
messages: aguiMessages,
|
|
169
169
|
state: null,
|
|
170
170
|
tools: options?.tools || [],
|
|
171
|
+
...(options?.builtinTools !== undefined && {
|
|
172
|
+
builtinTools: options.builtinTools,
|
|
173
|
+
}),
|
|
174
|
+
...(options?.skills !== undefined && {
|
|
175
|
+
skills: options.skills,
|
|
176
|
+
}),
|
|
171
177
|
context: [],
|
|
172
178
|
forwardedProps: null,
|
|
173
179
|
// Include model for per-request model override
|
|
@@ -42,10 +42,19 @@ export declare class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
42
42
|
private messageHistory;
|
|
43
43
|
private lastAssistantText;
|
|
44
44
|
private lastTools;
|
|
45
|
+
private lastFrontendToolNames;
|
|
45
46
|
private isContinuation;
|
|
47
|
+
private deferredToolMeta;
|
|
46
48
|
private _streamParsingDepth;
|
|
47
49
|
private _streamDonePromise;
|
|
48
50
|
private _streamDoneResolve;
|
|
51
|
+
/**
|
|
52
|
+
* Return the toolCallId for the first deferred tool whose name matches
|
|
53
|
+
* toolName, or the first deferred tool if toolName is empty/unmatched.
|
|
54
|
+
* Used by external callers (e.g. approval handlers) that need to send a
|
|
55
|
+
* continuation without access to the original tool-call-id.
|
|
56
|
+
*/
|
|
57
|
+
getDeferredToolCallId(toolName: string): string | undefined;
|
|
49
58
|
constructor(config: VercelAIAdapterConfig);
|
|
50
59
|
/**
|
|
51
60
|
* Connect to Vercel AI endpoint (SSE doesn't require persistent connection)
|
|
@@ -22,11 +22,37 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
22
22
|
messageHistory = [];
|
|
23
23
|
lastAssistantText = '';
|
|
24
24
|
lastTools = [];
|
|
25
|
+
lastFrontendToolNames = new Set();
|
|
25
26
|
isContinuation = false;
|
|
27
|
+
// Metadata for ALL deferred tool calls (frontend + approval), keyed by toolCallId.
|
|
28
|
+
// Unlike pendingToolCalls (which only tracks frontend tools for batching),
|
|
29
|
+
// this preserves tool name/args for approval tools so sendToolResult can
|
|
30
|
+
// build a correct continuation message.
|
|
31
|
+
deferredToolMeta = new Map();
|
|
26
32
|
// Stream parsing depth — prevents premature continuations
|
|
27
33
|
_streamParsingDepth = 0;
|
|
28
34
|
_streamDonePromise = null;
|
|
29
35
|
_streamDoneResolve = null;
|
|
36
|
+
/**
|
|
37
|
+
* Return the toolCallId for the first deferred tool whose name matches
|
|
38
|
+
* toolName, or the first deferred tool if toolName is empty/unmatched.
|
|
39
|
+
* Used by external callers (e.g. approval handlers) that need to send a
|
|
40
|
+
* continuation without access to the original tool-call-id.
|
|
41
|
+
*/
|
|
42
|
+
getDeferredToolCallId(toolName) {
|
|
43
|
+
if (!toolName) {
|
|
44
|
+
return this.deferredToolMeta.keys().next().value;
|
|
45
|
+
}
|
|
46
|
+
for (const [id, meta] of this.deferredToolMeta) {
|
|
47
|
+
if (meta.toolName === toolName ||
|
|
48
|
+
meta.toolName === toolName.replace(/-/g, '_') ||
|
|
49
|
+
meta.toolName === toolName.replace(/_/g, '-')) {
|
|
50
|
+
return id;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Fall back to first entry if name didn't match (handles name normalisation edge cases)
|
|
54
|
+
return this.deferredToolMeta.keys().next().value;
|
|
55
|
+
}
|
|
30
56
|
constructor(config) {
|
|
31
57
|
super(config);
|
|
32
58
|
this.vercelConfig = config;
|
|
@@ -97,10 +123,17 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
97
123
|
// Store tools for potential continuation
|
|
98
124
|
if (options?.tools) {
|
|
99
125
|
this.lastTools = options.tools;
|
|
126
|
+
this.lastFrontendToolNames = new Set(options.tools
|
|
127
|
+
.map(t => t?.name)
|
|
128
|
+
.filter((name) => Boolean(name)));
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
this.lastFrontendToolNames = new Set();
|
|
100
132
|
}
|
|
101
133
|
// Reset assistant content tracking for fresh (non-continuation) messages
|
|
102
134
|
if (!this.isContinuation) {
|
|
103
135
|
this.lastAssistantText = '';
|
|
136
|
+
this.deferredToolMeta.clear();
|
|
104
137
|
}
|
|
105
138
|
try {
|
|
106
139
|
let vercelMessages;
|
|
@@ -156,15 +189,16 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
156
189
|
const requestBody = {
|
|
157
190
|
id: requestId,
|
|
158
191
|
messages: vercelMessages,
|
|
192
|
+
// Required for pydantic-ai deferred tool approval continuations.
|
|
193
|
+
// sdkVersion 6 enables parsing approval-responded tool parts.
|
|
194
|
+
sdkVersion: 6,
|
|
159
195
|
trigger: 'submit-message',
|
|
160
196
|
...(options?.tools && { tools: options.tools }),
|
|
161
197
|
...(options?.model && { model: options.model }),
|
|
162
|
-
...(options?.builtinTools &&
|
|
163
|
-
options.builtinTools.length > 0 && {
|
|
198
|
+
...(options?.builtinTools !== undefined && {
|
|
164
199
|
builtinTools: options.builtinTools,
|
|
165
200
|
}),
|
|
166
|
-
...(options?.skills &&
|
|
167
|
-
options.skills.length > 0 && {
|
|
201
|
+
...(options?.skills !== undefined && {
|
|
168
202
|
skills: options.skills,
|
|
169
203
|
}),
|
|
170
204
|
...(options?.identities &&
|
|
@@ -237,6 +271,7 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
237
271
|
let currentMessageId = generateMessageId();
|
|
238
272
|
let accumulatedText = '';
|
|
239
273
|
const pendingToolInputs = new Map();
|
|
274
|
+
const pendingApprovalIds = new Map();
|
|
240
275
|
let doneEmitted = false;
|
|
241
276
|
// Consume the continuation flag — set by sendToolResult for this call only
|
|
242
277
|
this.isContinuation = false;
|
|
@@ -383,6 +418,7 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
383
418
|
// not frontend tools that will be handled by sendToolResult)
|
|
384
419
|
for (const [toolCallId] of pendingToolInputs.entries()) {
|
|
385
420
|
if (!this.pendingToolCalls.has(toolCallId)) {
|
|
421
|
+
const approvalId = pendingApprovalIds.get(toolCallId);
|
|
386
422
|
this.emit({
|
|
387
423
|
type: 'tool-result',
|
|
388
424
|
toolResult: {
|
|
@@ -390,6 +426,7 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
390
426
|
success: true,
|
|
391
427
|
result: {
|
|
392
428
|
pending_approval: true,
|
|
429
|
+
approval_id: approvalId,
|
|
393
430
|
message: 'Awaiting user approval',
|
|
394
431
|
},
|
|
395
432
|
},
|
|
@@ -439,12 +476,9 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
439
476
|
event.tool?.name;
|
|
440
477
|
const args = normalizeToolArgs(event.input || event.args || event.arguments, pending?.inputText || '');
|
|
441
478
|
if (toolName) {
|
|
442
|
-
//
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
toolName,
|
|
446
|
-
args,
|
|
447
|
-
});
|
|
479
|
+
// Emit tool-call for all tools so UI can render a tool entry.
|
|
480
|
+
// Only client-declared frontend tools should participate in
|
|
481
|
+
// frontend continuation batching via pendingToolCalls.
|
|
448
482
|
this.emit({
|
|
449
483
|
type: 'tool-call',
|
|
450
484
|
toolCall: {
|
|
@@ -454,6 +488,20 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
454
488
|
},
|
|
455
489
|
timestamp: new Date(),
|
|
456
490
|
});
|
|
491
|
+
// Track metadata for ALL deferred tools so sendToolResult
|
|
492
|
+
// can build proper continuation messages (tool name + args).
|
|
493
|
+
this.deferredToolMeta.set(toolCallId, {
|
|
494
|
+
toolCallId,
|
|
495
|
+
toolName,
|
|
496
|
+
args,
|
|
497
|
+
});
|
|
498
|
+
if (this.lastFrontendToolNames.has(toolName)) {
|
|
499
|
+
this.pendingToolCalls.set(toolCallId, {
|
|
500
|
+
toolCallId,
|
|
501
|
+
toolName,
|
|
502
|
+
args,
|
|
503
|
+
});
|
|
504
|
+
}
|
|
457
505
|
}
|
|
458
506
|
}
|
|
459
507
|
else if (event.type === 'tool-output-available') {
|
|
@@ -472,9 +520,11 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
472
520
|
timestamp: new Date(),
|
|
473
521
|
});
|
|
474
522
|
pendingToolInputs.delete(toolCallId);
|
|
523
|
+
pendingApprovalIds.delete(toolCallId);
|
|
475
524
|
// Server already executed this tool — remove from pending
|
|
476
525
|
// frontend tool calls so emitDoneOnce is not blocked.
|
|
477
526
|
this.pendingToolCalls.delete(toolCallId);
|
|
527
|
+
this.deferredToolMeta.delete(toolCallId);
|
|
478
528
|
}
|
|
479
529
|
else if (event.type === 'tool-output-error' ||
|
|
480
530
|
event.type === 'tool-error') {
|
|
@@ -489,6 +539,7 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
489
539
|
// Server handled the error — clear from pending frontend
|
|
490
540
|
// tool calls so emitDoneOnce is not blocked.
|
|
491
541
|
this.pendingToolCalls.delete(toolCallId);
|
|
542
|
+
this.deferredToolMeta.delete(toolCallId);
|
|
492
543
|
this.emit({
|
|
493
544
|
type: 'tool-result',
|
|
494
545
|
toolResult: {
|
|
@@ -500,6 +551,7 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
500
551
|
timestamp: new Date(),
|
|
501
552
|
});
|
|
502
553
|
pendingToolInputs.delete(toolCallId);
|
|
554
|
+
pendingApprovalIds.delete(toolCallId);
|
|
503
555
|
}
|
|
504
556
|
else if (event.type === 'error') {
|
|
505
557
|
const errorMessage = event.error ||
|
|
@@ -514,9 +566,18 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
514
566
|
timestamp: new Date(),
|
|
515
567
|
});
|
|
516
568
|
}
|
|
569
|
+
else if (event.type === 'tool-approval-request') {
|
|
570
|
+
const toolCallId = event.toolCallId ||
|
|
571
|
+
event.tool_call_id ||
|
|
572
|
+
event.id ||
|
|
573
|
+
generateMessageId();
|
|
574
|
+
const approvalId = event.approvalId || event.approval_id;
|
|
575
|
+
if (typeof approvalId === 'string' && approvalId.length > 0) {
|
|
576
|
+
pendingApprovalIds.set(toolCallId, approvalId);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
517
579
|
else if (event.type === 'tool-call' ||
|
|
518
|
-
event.type === 'tool-call-start'
|
|
519
|
-
event.type === 'tool-approval-request') {
|
|
580
|
+
event.type === 'tool-call-start') {
|
|
520
581
|
const toolName = event.toolName ||
|
|
521
582
|
event.tool_name ||
|
|
522
583
|
event.name ||
|
|
@@ -569,14 +630,26 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
569
630
|
* ONE continuation request once ALL pending tool calls have been resolved.
|
|
570
631
|
*/
|
|
571
632
|
async sendToolResult(toolCallId, result) {
|
|
633
|
+
console.info('[VercelAIAdapter] sendToolResult called', {
|
|
634
|
+
toolCallId,
|
|
635
|
+
success: result?.success,
|
|
636
|
+
hasApprovalDecision: !!result?.result &&
|
|
637
|
+
typeof result.result === 'object' &&
|
|
638
|
+
typeof result.result.approved ===
|
|
639
|
+
'boolean',
|
|
640
|
+
knownDeferredToolCallIds: Array.from(this.deferredToolMeta.keys()),
|
|
641
|
+
pendingToolCallIds: Array.from(this.pendingToolCalls.keys()),
|
|
642
|
+
});
|
|
572
643
|
// 1. Emit local event for UI updates
|
|
573
644
|
this.emit({
|
|
574
645
|
type: 'tool-result',
|
|
575
646
|
toolResult: result,
|
|
576
647
|
timestamp: new Date(),
|
|
577
648
|
});
|
|
578
|
-
// 2. Retrieve tool metadata from pending map
|
|
579
|
-
|
|
649
|
+
// 2. Retrieve tool metadata from pending map (frontend tools) or
|
|
650
|
+
// deferred tool meta (approval / all deferred tools).
|
|
651
|
+
const pendingToolCall = this.pendingToolCalls.get(toolCallId) ??
|
|
652
|
+
this.deferredToolMeta.get(toolCallId);
|
|
580
653
|
if (!pendingToolCall) {
|
|
581
654
|
console.warn('[VercelAIAdapter] No pending tool call found for ID:', toolCallId);
|
|
582
655
|
}
|
|
@@ -613,18 +686,55 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
613
686
|
state: 'done',
|
|
614
687
|
});
|
|
615
688
|
}
|
|
616
|
-
// Add each tool call with its result as a
|
|
689
|
+
// Add each tool call with its result as a dynamic-tool part.
|
|
690
|
+
// pydantic-ai parses DynamicTool* parts with output-available / output-error
|
|
691
|
+
// and approval-responded states for deferred approval continuations.
|
|
617
692
|
for (const tr of this.collectedToolResults.values()) {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
693
|
+
const resultObj = tr.result.result && typeof tr.result.result === 'object'
|
|
694
|
+
? tr.result.result
|
|
695
|
+
: undefined;
|
|
696
|
+
const isApprovalDecision = !!resultObj && typeof resultObj.approved === 'boolean';
|
|
697
|
+
if (isApprovalDecision) {
|
|
698
|
+
const approvalId = typeof resultObj?.approvalId === 'string'
|
|
699
|
+
? resultObj.approvalId
|
|
700
|
+
: tr.toolCallId;
|
|
701
|
+
const approved = Boolean(resultObj?.approved);
|
|
702
|
+
const reason = typeof resultObj?.message === 'string'
|
|
703
|
+
? resultObj.message
|
|
704
|
+
: undefined;
|
|
705
|
+
assistantParts.push({
|
|
706
|
+
type: 'dynamic-tool',
|
|
707
|
+
toolName: tr.toolName,
|
|
708
|
+
toolCallId: tr.toolCallId,
|
|
709
|
+
state: 'approval-responded',
|
|
710
|
+
input: tr.args,
|
|
711
|
+
approval: {
|
|
712
|
+
id: approvalId,
|
|
713
|
+
approved,
|
|
714
|
+
...(reason ? { reason } : {}),
|
|
715
|
+
},
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
else if (tr.result.success) {
|
|
719
|
+
assistantParts.push({
|
|
720
|
+
type: 'dynamic-tool',
|
|
721
|
+
toolName: tr.toolName,
|
|
722
|
+
toolCallId: tr.toolCallId,
|
|
723
|
+
state: 'output-available',
|
|
724
|
+
input: tr.args,
|
|
725
|
+
output: tr.result.result,
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
assistantParts.push({
|
|
730
|
+
type: 'dynamic-tool',
|
|
731
|
+
toolName: tr.toolName,
|
|
732
|
+
toolCallId: tr.toolCallId,
|
|
733
|
+
state: 'output-error',
|
|
734
|
+
input: tr.args,
|
|
735
|
+
errorText: tr.result.error ?? 'Tool execution failed',
|
|
736
|
+
});
|
|
737
|
+
}
|
|
628
738
|
}
|
|
629
739
|
const assistantMessage = {
|
|
630
740
|
id: generateMessageId(),
|
|
@@ -636,9 +746,9 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
636
746
|
// 7. Clear batching state BEFORE the async sendMessage call
|
|
637
747
|
this.pendingToolCalls.clear();
|
|
638
748
|
this.collectedToolResults.clear();
|
|
749
|
+
this.deferredToolMeta.clear();
|
|
639
750
|
// 8. Update stored message history
|
|
640
751
|
this.messageHistory = continuationMessages;
|
|
641
|
-
console.log('[VercelAIAdapter] === CONTINUATION MESSAGES ===', continuationMessages.map((m, i) => `[${i}] role=${m.role} parts=${m.parts.length}`));
|
|
642
752
|
// 9. Mark as continuation
|
|
643
753
|
this.isContinuation = true;
|
|
644
754
|
// 10. Send ONE continuation request with all tool results
|
|
@@ -648,6 +758,14 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
648
758
|
content: '',
|
|
649
759
|
createdAt: new Date(),
|
|
650
760
|
};
|
|
761
|
+
console.info('[VercelAIAdapter] Sending continuation request', {
|
|
762
|
+
messageCount: continuationMessages.length,
|
|
763
|
+
assistantParts: assistantParts.map(p => ({
|
|
764
|
+
type: p.type,
|
|
765
|
+
state: p.state,
|
|
766
|
+
toolName: p.toolName,
|
|
767
|
+
})),
|
|
768
|
+
});
|
|
651
769
|
await this.sendMessage(dummyMessage, {
|
|
652
770
|
_vercelMessages: continuationMessages,
|
|
653
771
|
tools: this.lastTools,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import JSON5 from 'json5/dist/index.mjs';
|
|
6
|
+
export const parse = JSON5.parse.bind(JSON5);
|
|
7
|
+
export const stringify = JSON5.stringify.bind(JSON5);
|
|
8
|
+
export default JSON5;
|
|
@@ -14,10 +14,20 @@ export declare const CLASSIFY_ROUTE_EMAILS_AGENT_SPEC_0_0_1: AgentSpec;
|
|
|
14
14
|
export declare const COMPREHENSIVE_SALES_ANALYTICS_AGENT_SPEC_0_0_1: AgentSpec;
|
|
15
15
|
export declare const CRAWLER_AGENT_SPEC_0_0_1: AgentSpec;
|
|
16
16
|
export declare const DATA_ACQUISITION_AGENT_SPEC_0_0_1: AgentSpec;
|
|
17
|
+
export declare const DATALAYER_AGENT_SPEC_0_0_1: AgentSpec;
|
|
17
18
|
export declare const DEMO_FULL_AGENT_SPEC_0_0_1: AgentSpec;
|
|
19
|
+
export declare const DEMO_GUARDRAILS_AGENT_SPEC_0_0_1: AgentSpec;
|
|
20
|
+
export declare const DEMO_HOOKS_AGENT_SPEC_0_0_1: AgentSpec;
|
|
21
|
+
export declare const DEMO_MCP_AGENT_SPEC_0_0_1: AgentSpec;
|
|
22
|
+
export declare const DEMO_MONITORING_AGENT_SPEC_0_0_1: AgentSpec;
|
|
18
23
|
export declare const DEMO_ONE_TRIGGER_APPROVAL_AGENT_SPEC_0_0_1: AgentSpec;
|
|
19
24
|
export declare const DEMO_ONE_TRIGGER_AGENT_SPEC_0_0_1: AgentSpec;
|
|
25
|
+
export declare const DEMO_OUTPUTS_AGENT_SPEC_0_0_1: AgentSpec;
|
|
26
|
+
export declare const DEMO_PARAMETERS_AGENT_SPEC_0_0_1: AgentSpec;
|
|
20
27
|
export declare const DEMO_SIMPLE_AGENT_SPEC_0_0_1: AgentSpec;
|
|
28
|
+
export declare const DEMO_SUBAGENTS_AGENT_SPEC_0_0_1: AgentSpec;
|
|
29
|
+
export declare const DEMO_TAVILY_CODEMODE_AGENT_SPEC_0_0_1: AgentSpec;
|
|
30
|
+
export declare const DEMO_TAVILY_NO_CODEMODE_AGENT_SPEC_0_0_1: AgentSpec;
|
|
21
31
|
export declare const END_OF_MONTH_SALES_PERFORMANCE_AGENT_SPEC_0_0_1: AgentSpec;
|
|
22
32
|
export declare const EXTRACT_DATA_FROM_FILES_AGENT_SPEC_0_0_1: AgentSpec;
|
|
23
33
|
export declare const FINANCIAL_VIZ_AGENT_SPEC_0_0_1: AgentSpec;
|