@datalayer/agent-runtimes 1.0.4 → 1.0.6
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 +182 -1
- package/lib/AgentNode.d.ts +3 -0
- package/lib/AgentNode.js +676 -0
- package/lib/App.js +1 -1
- package/lib/agent-node/themeStore.d.ts +3 -0
- package/lib/agent-node/themeStore.js +156 -0
- package/lib/agent-node-main.d.ts +1 -0
- package/lib/agent-node-main.js +14 -0
- 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 -106
- package/lib/chat/Chat.js +20 -14
- package/lib/chat/ChatFloating.d.ts +7 -140
- package/lib/chat/ChatFloating.js +3 -3
- 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 +83 -51
- package/lib/chat/ChatStandalone.d.ts +4 -54
- package/lib/chat/ChatStandalone.js +3 -3
- package/lib/chat/base/ChatBase.js +1414 -174
- package/lib/chat/display/FloatingBrandButton.js +8 -1
- package/lib/chat/header/ChatHeader.d.ts +3 -1
- package/lib/chat/header/ChatHeader.js +15 -12
- package/lib/chat/header/ChatHeaderBase.d.ts +30 -5
- package/lib/chat/header/ChatHeaderBase.js +41 -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 +91 -56
- 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 +154 -114
- package/lib/chat/messages/ChatMessages.js +6 -2
- package/lib/chat/prompt/InputFooter.d.ts +21 -6
- package/lib/chat/prompt/InputFooter.js +76 -20
- package/lib/chat/prompt/InputPrompt.d.ts +5 -1
- package/lib/chat/prompt/InputPrompt.js +4 -4
- package/lib/chat/prompt/InputPromptFooter.d.ts +3 -1
- package/lib/chat/prompt/InputPromptFooter.js +3 -3
- 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 +0 -18
- package/lib/client/AgentsMixin.js +20 -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 +5 -1
- package/lib/config/AgentConfiguration.d.ts +22 -0
- package/lib/config/AgentConfiguration.js +319 -64
- 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/AgUiSharedStateExample.js +2 -1
- package/lib/examples/AgentCheckpointsExample.js +14 -28
- package/lib/examples/AgentCodemodeExample.d.ts +4 -6
- package/lib/examples/AgentCodemodeExample.js +603 -169
- package/lib/examples/AgentEvalsExample.js +339 -53
- package/lib/examples/AgentGuardrailsExample.js +383 -66
- package/lib/examples/AgentHooksExample.d.ts +3 -0
- package/lib/examples/AgentHooksExample.js +122 -0
- package/lib/examples/AgentInferenceProviderExample.d.ts +3 -0
- package/lib/examples/AgentInferenceProviderExample.js +329 -0
- package/lib/examples/AgentMCPExample.d.ts +3 -0
- package/lib/examples/AgentMCPExample.js +481 -0
- package/lib/examples/AgentMemoryExample.d.ts +1 -2
- package/lib/examples/AgentMemoryExample.js +78 -33
- package/lib/examples/AgentMonitoringExample.js +261 -200
- package/lib/examples/AgentNotificationsExample.d.ts +1 -2
- package/lib/examples/AgentNotificationsExample.js +114 -33
- package/lib/examples/AgentOtelExample.js +32 -42
- package/lib/examples/AgentOutputsExample.d.ts +11 -6
- package/lib/examples/AgentOutputsExample.js +433 -81
- package/lib/examples/AgentParametersExample.d.ts +3 -0
- package/lib/examples/AgentParametersExample.js +248 -0
- package/lib/examples/AgentSandboxExample.d.ts +3 -3
- package/lib/examples/AgentSandboxExample.js +74 -45
- package/lib/examples/AgentSkillsExample.js +95 -103
- package/lib/examples/AgentSubagentsExample.d.ts +14 -0
- package/lib/examples/AgentSubagentsExample.js +228 -0
- package/lib/examples/AgentToolApprovalsExample.js +49 -561
- package/lib/examples/AgentTriggersExample.js +823 -569
- package/lib/examples/{AgentspecExample.d.ts → AgentspecsExample.d.ts} +2 -2
- package/lib/examples/AgentspecsExample.js +1096 -0
- package/lib/examples/ChatCustomExample.js +16 -28
- package/lib/examples/ChatExample.js +13 -29
- 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} +66 -17
- 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/ExampleWrapper.d.ts +9 -3
- package/lib/examples/components/ExampleWrapper.js +45 -9
- 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 +3 -0
- package/lib/examples/components/index.js +4 -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 +108 -41
- package/lib/examples/index.d.ts +10 -6
- package/lib/examples/index.js +10 -6
- package/lib/examples/lexical/initial-content.json +6 -6
- package/lib/examples/main.js +257 -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/examples/utils/useExampleAgentRuntimesUrl.d.ts +5 -0
- package/lib/examples/utils/useExampleAgentRuntimesUrl.js +19 -0
- 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 +153 -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} +70 -4
- package/lib/hooks/{useAgents.js → useAgentRuntimes.js} +237 -32
- 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 +7 -0
- package/lib/protocols/VercelAIAdapter.js +59 -7
- package/lib/specs/agents/agents.d.ts +21 -4
- package/lib/specs/agents/agents.js +2879 -316
- package/lib/specs/agents/index.js +3 -1
- package/lib/specs/benchmarks.d.ts +20 -0
- package/lib/specs/benchmarks.js +205 -0
- package/lib/specs/envvars.js +27 -20
- package/lib/specs/evals.d.ts +10 -9
- package/lib/specs/evals.js +128 -88
- package/lib/specs/events.d.ts +3 -10
- package/lib/specs/events.js +127 -84
- package/lib/specs/frontendTools.js +2 -2
- package/lib/specs/guardrails.d.ts +0 -7
- package/lib/specs/guardrails.js +240 -159
- package/lib/specs/mcpServers.js +35 -6
- package/lib/specs/memory.d.ts +0 -2
- package/lib/specs/memory.js +4 -17
- package/lib/specs/models.d.ts +0 -2
- package/lib/specs/models.js +20 -15
- package/lib/specs/notifications.js +102 -18
- package/lib/specs/outputs.js +15 -9
- package/lib/specs/personas.d.ts +41 -0
- package/lib/specs/personas.js +168 -0
- package/lib/specs/skills.d.ts +1 -1
- package/lib/specs/skills.js +23 -23
- package/lib/specs/teams/index.js +3 -1
- package/lib/specs/teams/teams.js +468 -348
- package/lib/specs/tools.js +4 -4
- package/lib/specs/triggers.js +61 -11
- package/lib/stores/agentRuntimeStore.d.ts +208 -0
- package/lib/stores/agentRuntimeStore.js +650 -0
- package/lib/stores/conversationStore.js +2 -2
- 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/agents-lifecycle.d.ts +18 -0
- package/lib/types/agents.d.ts +6 -0
- package/lib/types/agentspecs.d.ts +54 -1
- package/lib/types/benchmarks.d.ts +43 -0
- package/lib/types/benchmarks.js +5 -0
- package/lib/types/chat.d.ts +325 -8
- package/lib/types/context.d.ts +27 -0
- package/lib/types/cost.d.ts +2 -2
- package/lib/types/evals.d.ts +26 -17
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.js +3 -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/utils/utils.d.ts +9 -5
- package/lib/utils/utils.js +9 -5
- package/package.json +19 -11
- package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_benchmarks.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_evals.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 +187 -45
- package/scripts/codegen/generate_benchmarks.py +441 -0
- package/scripts/codegen/generate_evals.py +94 -16
- package/scripts/codegen/generate_events.py +35 -14
- package/scripts/codegen/generate_personas.py +319 -0
- package/scripts/codegen/generate_skills.py +9 -9
- package/scripts/sync-jupyter.sh +26 -7
- package/lib/api/tool-approvals.d.ts +0 -62
- package/lib/api/tool-approvals.js +0 -145
- package/lib/examples/AgentspecExample.js +0 -705
- 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/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
|
@@ -8,7 +8,7 @@ import { InputPromptLexical } from './InputPromptLexical';
|
|
|
8
8
|
/**
|
|
9
9
|
* InputPrompt — Integrated chat input with header, input area, and footer.
|
|
10
10
|
*/
|
|
11
|
-
export function InputPrompt({ variant = 'text', placeholder = 'Ask anything…', isLoading = false, onSend, onStop, autoFocus = false, focusTrigger, showBorderTop = true, showBackground = true, padding = 3, disabled = false, sx, value: controlledValue, onChange: controlledOnChange, headerContent, footerContent, footerRightContent, }) {
|
|
11
|
+
export function InputPrompt({ variant = 'text', placeholder = 'Ask anything…', isLoading = false, isKernelBusy = false, onSend, onStop, autoFocus = false, focusTrigger, showBorderTop = true, showBackground = true, padding = 3, disabled = false, readOnly = false, sx, value: controlledValue, onChange: controlledOnChange, headerContent, footerContent, footerRightContent, }) {
|
|
12
12
|
// ---- Controlled / uncontrolled state -----------------------------------
|
|
13
13
|
const [internalInput, setInternalInput] = useState('');
|
|
14
14
|
const input = controlledValue !== undefined ? controlledValue : internalInput;
|
|
@@ -46,14 +46,14 @@ export function InputPrompt({ variant = 'text', placeholder = 'Ask anything…',
|
|
|
46
46
|
}, [isLoading, variant]);
|
|
47
47
|
// ---- Send / Stop handlers ----------------------------------------------
|
|
48
48
|
const handleSend = useCallback(() => {
|
|
49
|
-
if (!input.trim() || isLoading || disabled)
|
|
49
|
+
if (!input.trim() || isLoading || disabled || readOnly)
|
|
50
50
|
return;
|
|
51
51
|
const message = input.trim();
|
|
52
52
|
if (controlledValue === undefined) {
|
|
53
53
|
setInput('');
|
|
54
54
|
}
|
|
55
55
|
onSend(message);
|
|
56
|
-
}, [input, isLoading, disabled, onSend, setInput, controlledValue]);
|
|
56
|
+
}, [input, isLoading, disabled, readOnly, onSend, setInput, controlledValue]);
|
|
57
57
|
const handleStop = useCallback(() => {
|
|
58
58
|
onStop?.();
|
|
59
59
|
}, [onStop]);
|
|
@@ -78,6 +78,6 @@ export function InputPrompt({ variant = 'text', placeholder = 'Ask anything…',
|
|
|
78
78
|
borderColor: 'accent.fg',
|
|
79
79
|
boxShadow: (t) => `0 0 0 1px ${t?.colors?.accent?.fg ?? '#0969da'}`,
|
|
80
80
|
},
|
|
81
|
-
}, children: [_jsx(InputPromptHeader, { children: headerContent }), variant === 'lexical' ? (_jsx(InputPromptLexical, { value: input, onChange: setInput, placeholder: placeholder, disabled: isLoading || disabled, onSubmit: handleSend, autoFocus: autoFocus })) : (_jsx(InputPromptText, { value: input, onChange: setInput, placeholder: placeholder, disabled: isLoading || disabled, onSubmit: handleSend, inputRef: inputRef })), _jsx(InputPromptFooter, { isLoading: isLoading, sendDisabled: !input.trim() || disabled, onSend: handleSend, onStop: handleStop, rightContent: footerRightContent, children: footerContent })] }) }) }));
|
|
81
|
+
}, children: [_jsx(InputPromptHeader, { children: headerContent }), variant === 'lexical' ? (_jsx(InputPromptLexical, { value: input, onChange: setInput, placeholder: placeholder, disabled: isLoading || disabled, readOnly: readOnly, onSubmit: handleSend, autoFocus: autoFocus })) : (_jsx(InputPromptText, { value: input, onChange: setInput, placeholder: placeholder, disabled: isLoading || disabled, readOnly: readOnly, onSubmit: handleSend, inputRef: inputRef })), _jsx(InputPromptFooter, { isLoading: isLoading, isKernelBusy: isKernelBusy, sendDisabled: !input.trim() || disabled || readOnly, onSend: handleSend, onStop: handleStop, rightContent: footerRightContent, children: footerContent })] }) }) }));
|
|
82
82
|
}
|
|
83
83
|
export default InputPrompt;
|
|
@@ -16,10 +16,12 @@ export interface InputPromptFooterProps {
|
|
|
16
16
|
isLoading?: boolean;
|
|
17
17
|
/** Whether the send button should be disabled */
|
|
18
18
|
sendDisabled?: boolean;
|
|
19
|
+
/** Whether the connected kernel is currently busy */
|
|
20
|
+
isKernelBusy?: boolean;
|
|
19
21
|
/** Callback when the send button is clicked */
|
|
20
22
|
onSend: () => void;
|
|
21
23
|
/** Callback when the stop button is clicked */
|
|
22
24
|
onStop?: () => void;
|
|
23
25
|
}
|
|
24
|
-
export declare function InputPromptFooter({ children, rightContent, isLoading, sendDisabled, onSend, onStop, }: InputPromptFooterProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare function InputPromptFooter({ children, rightContent, isLoading, sendDisabled, isKernelBusy, onSend, onStop, }: InputPromptFooterProps): import("react/jsx-runtime").JSX.Element;
|
|
25
27
|
export default InputPromptFooter;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { IconButton } from '@primer/react';
|
|
3
3
|
import { Box } from '@datalayer/primer-addons';
|
|
4
|
-
import { PaperAirplaneIcon, SquareCircleIcon } from '@primer/octicons-react';
|
|
5
|
-
export function InputPromptFooter({ children, rightContent, isLoading = false, sendDisabled = false, onSend, onStop, }) {
|
|
4
|
+
import { PaperAirplaneIcon, SquareCircleIcon, PauseIcon, } from '@primer/octicons-react';
|
|
5
|
+
export function InputPromptFooter({ children, rightContent, isLoading = false, sendDisabled = false, isKernelBusy = false, onSend, onStop, }) {
|
|
6
6
|
return (_jsxs(Box, { sx: {
|
|
7
7
|
display: 'flex',
|
|
8
8
|
alignItems: 'center',
|
|
@@ -10,6 +10,6 @@ export function InputPromptFooter({ children, rightContent, isLoading = false, s
|
|
|
10
10
|
px: 2,
|
|
11
11
|
pt: 1,
|
|
12
12
|
pb: 2,
|
|
13
|
-
}, children: [_jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2, flex: 1 }, children: children }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: [rightContent, isLoading ? (_jsx(IconButton, { icon: SquareCircleIcon, "aria-label": "Stop", onClick: onStop, size: "small" })) : (_jsx(IconButton, { icon: PaperAirplaneIcon, "aria-label": "Send", onClick: onSend, disabled: sendDisabled, size: "small" }))] })] }));
|
|
13
|
+
}, children: [_jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2, flex: 1 }, children: children }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: [rightContent, isLoading ? (_jsx(IconButton, { icon: SquareCircleIcon, "aria-label": "Stop", onClick: onStop, size: "small", variant: "invisible" })) : isKernelBusy ? (_jsx(IconButton, { icon: PauseIcon, "aria-label": "Pause (kernel busy)", onClick: onStop, size: "small", variant: "invisible", disabled: !onStop })) : (_jsx(IconButton, { icon: PaperAirplaneIcon, "aria-label": "Send", onClick: onSend, disabled: sendDisabled, size: "small", variant: "invisible" }))] })] }));
|
|
14
14
|
}
|
|
15
15
|
export default InputPromptFooter;
|
|
@@ -7,10 +7,12 @@ export interface InputPromptLexicalProps {
|
|
|
7
7
|
placeholder?: string;
|
|
8
8
|
/** Whether the input is disabled */
|
|
9
9
|
disabled?: boolean;
|
|
10
|
+
/** Whether the input is read-only */
|
|
11
|
+
readOnly?: boolean;
|
|
10
12
|
/** Callback when the user presses Enter (without Shift) */
|
|
11
13
|
onSubmit?: () => void;
|
|
12
14
|
/** Auto-focus the editor on mount */
|
|
13
15
|
autoFocus?: boolean;
|
|
14
16
|
}
|
|
15
|
-
export declare function InputPromptLexical({ value, onChange, placeholder, disabled, onSubmit, autoFocus, }: InputPromptLexicalProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function InputPromptLexical({ value, onChange, placeholder, disabled, readOnly, onSubmit, autoFocus, }: InputPromptLexicalProps): import("react/jsx-runtime").JSX.Element;
|
|
16
18
|
export default InputPromptLexical;
|
|
@@ -38,17 +38,17 @@ const EDITOR_CONFIG = {
|
|
|
38
38
|
},
|
|
39
39
|
};
|
|
40
40
|
// ---- Enter-to-submit plugin ---------------------------------------------
|
|
41
|
-
function EnterSubmitPlugin({ onSubmit, disabled, }) {
|
|
41
|
+
function EnterSubmitPlugin({ onSubmit, disabled, readOnly, }) {
|
|
42
42
|
const [editor] = useLexicalComposerContext();
|
|
43
43
|
useEffect(() => {
|
|
44
44
|
return editor.registerCommand(KEY_ENTER_COMMAND, (event) => {
|
|
45
|
-
if (event?.shiftKey || disabled)
|
|
45
|
+
if (event?.shiftKey || disabled || readOnly)
|
|
46
46
|
return false;
|
|
47
47
|
event?.preventDefault();
|
|
48
48
|
onSubmit?.();
|
|
49
49
|
return true;
|
|
50
50
|
}, COMMAND_PRIORITY_HIGH);
|
|
51
|
-
}, [editor, onSubmit, disabled]);
|
|
51
|
+
}, [editor, onSubmit, disabled, readOnly]);
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
54
|
// ---- Sync plugin (controlled component bridge) --------------------------
|
|
@@ -94,7 +94,14 @@ function AutoFocusPlugin({ autoFocus }) {
|
|
|
94
94
|
}, [editor, autoFocus]);
|
|
95
95
|
return null;
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
function ReadOnlyPlugin({ readOnly }) {
|
|
98
|
+
const [editor] = useLexicalComposerContext();
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
editor.setEditable(!readOnly);
|
|
101
|
+
}, [editor, readOnly]);
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
export function InputPromptLexical({ value, onChange, placeholder = 'Ask anything…', disabled = false, readOnly = false, onSubmit, autoFocus = false, }) {
|
|
98
105
|
return (_jsx(Box, { sx: {
|
|
99
106
|
px: 2,
|
|
100
107
|
py: 1,
|
|
@@ -117,6 +124,6 @@ export function InputPromptLexical({ value, onChange, placeholder = 'Ask anythin
|
|
|
117
124
|
fontSize: 1,
|
|
118
125
|
pointerEvents: 'none',
|
|
119
126
|
userSelect: 'none',
|
|
120
|
-
}, children: placeholder }), ErrorBoundary: LexicalErrorBoundary }), _jsx(HistoryPlugin, {}), _jsx(SyncPlugin, { value: value, onChange: onChange }), _jsx(EnterSubmitPlugin, { onSubmit: onSubmit, disabled: disabled }), _jsx(AutoFocusPlugin, { autoFocus: autoFocus })] }) }));
|
|
127
|
+
}, children: placeholder }), ErrorBoundary: LexicalErrorBoundary }), _jsx(HistoryPlugin, {}), _jsx(SyncPlugin, { value: value, onChange: onChange }), _jsx(ReadOnlyPlugin, { readOnly: readOnly || disabled }), _jsx(EnterSubmitPlugin, { onSubmit: onSubmit, disabled: disabled, readOnly: readOnly }), _jsx(AutoFocusPlugin, { autoFocus: autoFocus })] }) }));
|
|
121
128
|
}
|
|
122
129
|
export default InputPromptLexical;
|
|
@@ -15,10 +15,12 @@ export interface InputPromptTextProps {
|
|
|
15
15
|
placeholder?: string;
|
|
16
16
|
/** Whether the input is disabled */
|
|
17
17
|
disabled?: boolean;
|
|
18
|
+
/** Whether the input is read-only */
|
|
19
|
+
readOnly?: boolean;
|
|
18
20
|
/** Callback when the user presses Enter (without Shift) */
|
|
19
21
|
onSubmit?: () => void;
|
|
20
22
|
/** Ref forwarded to the underlying textarea */
|
|
21
23
|
inputRef?: Ref<HTMLTextAreaElement>;
|
|
22
24
|
}
|
|
23
|
-
export declare function InputPromptText({ value, onChange, placeholder, disabled, onSubmit, inputRef, }: InputPromptTextProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare function InputPromptText({ value, onChange, placeholder, disabled, readOnly, onSubmit, inputRef, }: InputPromptTextProps): import("react/jsx-runtime").JSX.Element;
|
|
24
26
|
export default InputPromptText;
|
|
@@ -13,7 +13,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
import { useCallback, useEffect, } from 'react';
|
|
14
14
|
import { Textarea } from '@primer/react';
|
|
15
15
|
import { Box } from '@datalayer/primer-addons';
|
|
16
|
-
export function InputPromptText({ value, onChange, placeholder = 'Ask anything…', disabled = false, onSubmit, inputRef, }) {
|
|
16
|
+
export function InputPromptText({ value, onChange, placeholder = 'Ask anything…', disabled = false, readOnly = false, onSubmit, inputRef, }) {
|
|
17
17
|
// Auto-resize
|
|
18
18
|
const adjustHeight = useCallback(() => {
|
|
19
19
|
const el = inputRef && 'current' in inputRef
|
|
@@ -41,7 +41,7 @@ export function InputPromptText({ value, onChange, placeholder = 'Ask anything
|
|
|
41
41
|
onSubmit?.();
|
|
42
42
|
}
|
|
43
43
|
}, [onSubmit]);
|
|
44
|
-
return (_jsx(Box, { sx: { px: 2, py: 1 }, children: _jsx(Textarea, { ref: inputRef, value: value, onChange: e => onChange(e.target.value), onKeyDown: handleKeyDown, placeholder: placeholder, disabled: disabled, sx: {
|
|
44
|
+
return (_jsx(Box, { sx: { px: 2, py: 1 }, children: _jsx(Textarea, { ref: inputRef, value: value, onChange: e => onChange(e.target.value), onKeyDown: handleKeyDown, placeholder: placeholder, disabled: disabled, readOnly: readOnly, sx: {
|
|
45
45
|
width: '100%',
|
|
46
46
|
resize: 'none',
|
|
47
47
|
minHeight: '40px',
|
|
@@ -46,7 +46,7 @@ export function ToolApprovalBanner({ pendingApprovals, onReview, onApproveAll, o
|
|
|
46
46
|
justifyContent: 'space-between',
|
|
47
47
|
px: 3,
|
|
48
48
|
py: 2,
|
|
49
|
-
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsx(AlertIcon, { size: 16 }), _jsxs(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: [pendingApprovals.length, " tool", ' ', pendingApprovals.length === 1 ? 'approval' : 'approvals', " pending"] })] }), _jsxs(Box, { sx: { display: 'flex', gap: 1 }, children: [onApproveAll && pendingApprovals.length
|
|
49
|
+
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsx(AlertIcon, { size: 16 }), _jsxs(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: [pendingApprovals.length, " tool", ' ', pendingApprovals.length === 1 ? 'approval' : 'approvals', " pending"] })] }), _jsxs(Box, { sx: { display: 'flex', gap: 1 }, children: [onApproveAll && pendingApprovals.length >= 1 && (_jsx(Button, { size: "small", variant: "primary", leadingVisual: CheckIcon, onClick: onApproveAll, children: "Approve all" })), collapsible && (_jsx(Button, { size: "small", variant: "invisible", onClick: () => setCollapsed(true), children: "Collapse" })), onDismiss && (_jsx(Button, { size: "small", variant: "invisible", leadingVisual: XIcon, onClick: onDismiss, "aria-label": "Dismiss" }))] })] }), _jsx(Box, { sx: { px: 3, pb: 2 }, children: pendingApprovals.map(approval => (_jsxs(Box, { sx: {
|
|
50
50
|
display: 'flex',
|
|
51
51
|
alignItems: 'center',
|
|
52
52
|
justifyContent: 'space-between',
|
|
@@ -28,6 +28,8 @@ export interface ToolCallDisplayProps {
|
|
|
28
28
|
approvalRequired?: boolean;
|
|
29
29
|
/** Approval state for this tool call */
|
|
30
30
|
approvalState?: 'pending' | 'approved' | 'denied';
|
|
31
|
+
/** Where the approval decision originated */
|
|
32
|
+
approvalDecisionSource?: 'inline' | 'external';
|
|
31
33
|
/** Called when user approves this tool call */
|
|
32
34
|
onApprove?: () => void;
|
|
33
35
|
/** Called when user denies this tool call */
|
|
@@ -45,5 +47,5 @@ export interface ToolCallDisplayProps {
|
|
|
45
47
|
* - Color-coded status indicators
|
|
46
48
|
* - Rich error display distinguishing execution errors from code errors
|
|
47
49
|
*/
|
|
48
|
-
export declare function ToolCallDisplay({ toolCallId, toolName, args, result, status, error, executionResult, codeError, exitCode, executionError, approvalRequired, approvalState, onApprove, onDeny, approvalLoading, }: ToolCallDisplayProps): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export declare function ToolCallDisplay({ toolCallId, toolName, args, result, status, error, executionResult, codeError, exitCode, executionError, approvalRequired, approvalState, approvalDecisionSource, onApprove, onDeny, approvalLoading, }: ToolCallDisplayProps): import("react/jsx-runtime").JSX.Element;
|
|
49
51
|
export default ToolCallDisplay;
|
|
@@ -124,7 +124,7 @@ function getArgsSummary(args) {
|
|
|
124
124
|
* - Color-coded status indicators
|
|
125
125
|
* - Rich error display distinguishing execution errors from code errors
|
|
126
126
|
*/
|
|
127
|
-
export function ToolCallDisplay({ toolCallId, toolName, args, result, status, error, executionResult, codeError, exitCode, executionError, approvalRequired = false, approvalState, onApprove, onDeny, approvalLoading = false, }) {
|
|
127
|
+
export function ToolCallDisplay({ toolCallId, toolName, args, result, status, error, executionResult, codeError, exitCode, executionError, approvalRequired = false, approvalState, approvalDecisionSource, onApprove, onDeny, approvalLoading = false, }) {
|
|
128
128
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
129
129
|
// Determine effective exit code from props or execution result
|
|
130
130
|
const effectiveExitCode = exitCode ?? executionResult?.exit_code;
|
|
@@ -265,7 +265,7 @@ export function ToolCallDisplay({ toolCallId, toolName, args, result, status, er
|
|
|
265
265
|
wordBreak: 'break-word',
|
|
266
266
|
}, children: typeof result === 'string'
|
|
267
267
|
? result
|
|
268
|
-
: JSON.stringify(result, null, 2) }) })] })), approvalRequired && (_jsx(Box, { sx: { mt: status === 'complete' && result !== undefined ? 3 : 0 }, children: approvalState === 'approved' ? (_jsx(Text, { sx: { color: 'success.fg', fontSize: 1 }, children: "Approved. Executing tool." })) : approvalState === 'denied' ? (_jsx(Text, { sx: { color: 'danger.fg', fontSize: 1 }, children: "Denied. Tool will not run." })) : (_jsxs(_Fragment, { children: [_jsx(Text, { sx: { fontSize: 1, color: 'fg.default' }, children: "This tool requires your approval to run." }), _jsxs(Box, { sx: { mt: 2, display: 'flex', gap: 2 }, children: [_jsx(Button, { size: "small", onClick: onApprove, disabled: approvalLoading || !onApprove, children: "Approve" }), _jsx(Button, { size: "small", variant: "danger", onClick: onDeny, disabled: approvalLoading || !onDeny, children: "Deny" })] })] })) })), status === 'error' && effectiveExecutionError && (_jsxs(Box, { children: [_jsxs(Text, { sx: {
|
|
268
|
+
: JSON.stringify(result, null, 2) }) })] })), approvalRequired && (_jsx(Box, { sx: { mt: status === 'complete' && result !== undefined ? 3 : 0 }, children: approvalState === 'approved' ? (_jsxs(Box, { children: [_jsx(Text, { sx: { color: 'success.fg', fontSize: 1, display: 'block' }, children: "Approved. Executing tool." }), approvalDecisionSource === 'external' && (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 0, display: 'block' }, children: "Approved from sidebar." }))] })) : approvalState === 'denied' ? (_jsxs(Box, { children: [_jsx(Text, { sx: { color: 'danger.fg', fontSize: 1, display: 'block' }, children: "Denied. Tool will not run." }), approvalDecisionSource === 'external' && (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 0, display: 'block' }, children: "Decision came from sidebar." }))] })) : (_jsxs(_Fragment, { children: [_jsx(Text, { sx: { fontSize: 1, color: 'fg.default' }, children: "This tool requires your approval to run." }), _jsxs(Box, { sx: { mt: 2, display: 'flex', gap: 2 }, children: [_jsx(Button, { size: "small", onClick: onApprove, disabled: approvalLoading || !onApprove, children: "Approve" }), _jsx(Button, { size: "small", variant: "danger", onClick: onDeny, disabled: approvalLoading || !onDeny, children: "Deny" })] })] })) })), status === 'error' && effectiveExecutionError && (_jsxs(Box, { children: [_jsxs(Text, { sx: {
|
|
269
269
|
display: 'block',
|
|
270
270
|
fontSize: 0,
|
|
271
271
|
fontWeight: 'semibold',
|
|
@@ -29,6 +29,19 @@ export function TokenUsageBar({ agentUsage, padding }) {
|
|
|
29
29
|
const hasSession = agentUsage.sessionUsage &&
|
|
30
30
|
(agentUsage.sessionUsage.inputTokens > 0 ||
|
|
31
31
|
agentUsage.sessionUsage.outputTokens > 0);
|
|
32
|
+
const hasCostUsage = !!agentUsage.costUsage &&
|
|
33
|
+
(agentUsage.costUsage.cumulativeCostUsd > 0 ||
|
|
34
|
+
agentUsage.costUsage.lastTurnCostUsd > 0);
|
|
35
|
+
const sessionUsage = agentUsage.sessionUsage;
|
|
36
|
+
const turnUsage = agentUsage.turnUsage;
|
|
37
|
+
const costUsage = agentUsage.costUsage;
|
|
38
|
+
const formatUsd = (amount) => {
|
|
39
|
+
if (amount < 0.01)
|
|
40
|
+
return `$${amount.toFixed(4)}`;
|
|
41
|
+
if (amount < 1)
|
|
42
|
+
return `$${amount.toFixed(3)}`;
|
|
43
|
+
return `$${amount.toFixed(2)}`;
|
|
44
|
+
};
|
|
32
45
|
// Build pie chart data
|
|
33
46
|
const usedTokens = agentUsage.totalTokens;
|
|
34
47
|
const windowTokens = agentUsage.contextWindow;
|
|
@@ -180,7 +193,12 @@ export function TokenUsageBar({ agentUsage, padding }) {
|
|
|
180
193
|
color: 'fg.default',
|
|
181
194
|
display: 'block',
|
|
182
195
|
mb: 2,
|
|
183
|
-
}, children: "Context Window" }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', display: 'block', mb: 1 }, children: [_jsx(Text, { as: "span", sx: { fontWeight: 'semibold', color: 'fg.default' }, children: formatTokenCount(usedTokens) }), ' / ', formatTokenCount(windowTokens), ' tokens'] }), _jsxs(Text, { sx: {
|
|
196
|
+
}, children: "Context Window" }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', display: 'block', mb: 1 }, children: [_jsx(Text, { as: "span", sx: { fontWeight: 'semibold', color: 'fg.default' }, children: formatTokenCount(usedTokens) }), ' / ', formatTokenCount(windowTokens), ' tokens'] }), agentUsage.costUsage && (_jsxs(Text, { sx: {
|
|
197
|
+
fontSize: 0,
|
|
198
|
+
color: 'fg.muted',
|
|
199
|
+
display: 'block',
|
|
200
|
+
mb: 2,
|
|
201
|
+
}, children: ['cost ', _jsx(Text, { as: "span", sx: { fontWeight: 'semibold', color: 'fg.default' }, children: formatUsd(agentUsage.costUsage.lastTurnCostUsd) }), ' turn · ', _jsx(Text, { as: "span", sx: { fontWeight: 'semibold', color: 'fg.default' }, children: formatUsd(agentUsage.costUsage.cumulativeCostUsd) }), ' total'] })), _jsxs(Text, { sx: {
|
|
184
202
|
fontSize: 0,
|
|
185
203
|
color: pct > 90
|
|
186
204
|
? 'danger.fg'
|
|
@@ -209,5 +227,5 @@ export function TokenUsageBar({ agentUsage, padding }) {
|
|
|
209
227
|
display: 'block',
|
|
210
228
|
mt: 2,
|
|
211
229
|
fontStyle: 'italic',
|
|
212
|
-
}, children: "Quality may decline as limit nears." }))] }))] }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', flexShrink: 0 }, children: [_jsx(Text, { as: "span", sx: { fontWeight: 'semibold', color: 'fg.default', fontSize: 0 }, children: formatTokenCount(agentUsage.totalTokens) }), ' / ', formatTokenCount(agentUsage.contextWindow), ' ctx'] }), hasSession && (_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', flexShrink: 0 }, children: ['· ', formatTokenCount(
|
|
230
|
+
}, children: "Quality may decline as limit nears." }))] }))] }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', flexShrink: 0 }, children: [_jsx(Text, { as: "span", sx: { fontWeight: 'semibold', color: 'fg.default', fontSize: 0 }, children: formatTokenCount(agentUsage.totalTokens) }), ' / ', formatTokenCount(agentUsage.contextWindow), ' ctx'] }), hasCostUsage && (_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', flexShrink: 0 }, children: ['· cost ', _jsx(Text, { as: "span", sx: { fontWeight: 'semibold', color: 'fg.default', fontSize: 0 }, children: formatUsd(costUsage?.lastTurnCostUsd ?? 0) }), ' turn / ', _jsx(Text, { as: "span", sx: { fontWeight: 'semibold', color: 'fg.default', fontSize: 0 }, children: formatUsd(costUsage?.cumulativeCostUsd ?? 0) })] })), hasSession && (_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', flexShrink: 0 }, children: ['· ', formatTokenCount(sessionUsage?.inputTokens ?? 0), _jsx(Text, { as: "span", sx: { color: 'success.fg', fontSize: 0 }, children: '▲' }), ' ', formatTokenCount(sessionUsage?.outputTokens ?? 0), _jsx(Text, { as: "span", sx: { color: 'attention.fg', fontSize: 0 }, children: '▼' })] })), hasTurn && (_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', flexShrink: 0 }, children: ['· turn ', formatTokenCount(turnUsage?.inputTokens ?? 0), _jsx(Text, { as: "span", sx: { color: 'success.fg', fontSize: 0 }, children: '▲' }), ' ', formatTokenCount(turnUsage?.outputTokens ?? 0), _jsx(Text, { as: "span", sx: { color: 'attention.fg', fontSize: 0 }, children: '▼' })] }))] }));
|
|
213
231
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React context and hook for injecting an {@link IAgentRuntimesClient}
|
|
3
|
+
* implementation into the chat component tree.
|
|
4
|
+
*
|
|
5
|
+
* Consumers wrap the `<Chat>` component with `<AgentRuntimesClientProvider>`
|
|
6
|
+
* and pass the implementation of their choice — the default
|
|
7
|
+
* `SdkAgentRuntimesClient` for browser / Node, or a bridge
|
|
8
|
+
* implementation in the VSCode webview sandbox. Components and hooks inside
|
|
9
|
+
* the tree call {@link useAgentRuntimesClient} to retrieve the current client
|
|
10
|
+
* without knowing anything about how it talks to the backend.
|
|
11
|
+
*
|
|
12
|
+
* @module client/AgentRuntimesClientContext
|
|
13
|
+
*/
|
|
14
|
+
import type { ReactNode } from 'react';
|
|
15
|
+
import type { IAgentRuntimesClient } from './IAgentRuntimesClient';
|
|
16
|
+
/** Props for {@link AgentRuntimesClientProvider}. */
|
|
17
|
+
export interface AgentRuntimesClientProviderProps {
|
|
18
|
+
/** Client implementation to make available to descendants. */
|
|
19
|
+
client: IAgentRuntimesClient;
|
|
20
|
+
/** Descendants that should see the provided client. */
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Provides an {@link IAgentRuntimesClient} instance to every descendant.
|
|
25
|
+
*
|
|
26
|
+
* @param props - Provider props.
|
|
27
|
+
*
|
|
28
|
+
* @returns A React element that exposes `props.client` to descendants.
|
|
29
|
+
*/
|
|
30
|
+
export declare function AgentRuntimesClientProvider(props: AgentRuntimesClientProviderProps): JSX.Element;
|
|
31
|
+
/**
|
|
32
|
+
* Reads the active {@link IAgentRuntimesClient} from context.
|
|
33
|
+
*
|
|
34
|
+
* @returns The active client.
|
|
35
|
+
*
|
|
36
|
+
* @throws When called outside an {@link AgentRuntimesClientProvider}. Prefer a
|
|
37
|
+
* loud failure to silently falling back to a default client, because a
|
|
38
|
+
* missing provider usually indicates a wiring bug (especially in the VSCode
|
|
39
|
+
* webview where the default client would make forbidden direct HTTP calls).
|
|
40
|
+
*/
|
|
41
|
+
export declare function useAgentRuntimesClient(): IAgentRuntimesClient;
|
|
42
|
+
/**
|
|
43
|
+
* Reads the current {@link IAgentRuntimesClient} from context without
|
|
44
|
+
* throwing.
|
|
45
|
+
*
|
|
46
|
+
* Use this variant in code paths that want to fall back to some other behavior
|
|
47
|
+
* when no provider is mounted (for example, legacy hook implementations that
|
|
48
|
+
* currently still make direct network calls and are being migrated
|
|
49
|
+
* incrementally).
|
|
50
|
+
*
|
|
51
|
+
* @returns The active client, or `null` when no provider is mounted.
|
|
52
|
+
*/
|
|
53
|
+
export declare function useOptionalAgentRuntimesClient(): IAgentRuntimesClient | null;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* React context carrying the active {@link IAgentRuntimesClient}. `null` when
|
|
5
|
+
* no provider is mounted — in that case {@link useAgentRuntimesClient} throws
|
|
6
|
+
* so callers fail loudly rather than silently making no-op HTTP calls.
|
|
7
|
+
*/
|
|
8
|
+
const AgentRuntimesClientContext = createContext(null);
|
|
9
|
+
/**
|
|
10
|
+
* Provides an {@link IAgentRuntimesClient} instance to every descendant.
|
|
11
|
+
*
|
|
12
|
+
* @param props - Provider props.
|
|
13
|
+
*
|
|
14
|
+
* @returns A React element that exposes `props.client` to descendants.
|
|
15
|
+
*/
|
|
16
|
+
export function AgentRuntimesClientProvider(props) {
|
|
17
|
+
const { client, children } = props;
|
|
18
|
+
// Memoize the context value so identity only changes when the client
|
|
19
|
+
// reference itself changes.
|
|
20
|
+
const value = useMemo(() => client, [client]);
|
|
21
|
+
return (_jsx(AgentRuntimesClientContext.Provider, { value: value, children: children }));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Reads the active {@link IAgentRuntimesClient} from context.
|
|
25
|
+
*
|
|
26
|
+
* @returns The active client.
|
|
27
|
+
*
|
|
28
|
+
* @throws When called outside an {@link AgentRuntimesClientProvider}. Prefer a
|
|
29
|
+
* loud failure to silently falling back to a default client, because a
|
|
30
|
+
* missing provider usually indicates a wiring bug (especially in the VSCode
|
|
31
|
+
* webview where the default client would make forbidden direct HTTP calls).
|
|
32
|
+
*/
|
|
33
|
+
export function useAgentRuntimesClient() {
|
|
34
|
+
const client = useContext(AgentRuntimesClientContext);
|
|
35
|
+
if (client === null) {
|
|
36
|
+
throw new Error('useAgentRuntimesClient must be called inside an <AgentRuntimesClientProvider>. ' +
|
|
37
|
+
'Wrap your <Chat> component (or the subtree that uses agent-runtimes hooks) ' +
|
|
38
|
+
'with <AgentRuntimesClientProvider client={...}>.');
|
|
39
|
+
}
|
|
40
|
+
return client;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Reads the current {@link IAgentRuntimesClient} from context without
|
|
44
|
+
* throwing.
|
|
45
|
+
*
|
|
46
|
+
* Use this variant in code paths that want to fall back to some other behavior
|
|
47
|
+
* when no provider is mounted (for example, legacy hook implementations that
|
|
48
|
+
* currently still make direct network calls and are being migrated
|
|
49
|
+
* incrementally).
|
|
50
|
+
*
|
|
51
|
+
* @returns The active client, or `null` when no provider is mounted.
|
|
52
|
+
*/
|
|
53
|
+
export function useOptionalAgentRuntimesClient() {
|
|
54
|
+
return useContext(AgentRuntimesClientContext);
|
|
55
|
+
}
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
import type { Constructor } from '@datalayer/core/lib/client/utils/mixins';
|
|
14
14
|
import type { AgentEvent, CreateAgentEventRequest, GetAgentEventResponse, ListAgentEventsParams, ListAgentEventsResponse, UpdateAgentEventRequest, RunningAgent, AgentUsageSummary, ConversationCheckpoint, AgentNotification, NotificationFilters, OutputArtifact, EvalReport, RunEvalsRequest, ContextUsage, CostUsage, AgentSpec } from '../types';
|
|
15
15
|
import type { CreateAgentRuntimeRequest, CreateRuntimeApiResponse } from '../types/agents-lifecycle';
|
|
16
|
-
import type { ToolApproval, ToolApprovalFilters } from '../types/tool-approvals';
|
|
17
16
|
/** Agents mixin providing durable agent management. */
|
|
18
17
|
export declare function AgentsMixin<TBase extends Constructor>(Base: TBase): {
|
|
19
18
|
new (...args: any[]): {
|
|
@@ -53,23 +52,6 @@ export declare function AgentsMixin<TBase extends Constructor>(Base: TBase): {
|
|
|
53
52
|
* @returns Usage summary including tokens, cost, iterations
|
|
54
53
|
*/
|
|
55
54
|
getAgentUsage(podName: string, agentId?: string): Promise<AgentUsageSummary>;
|
|
56
|
-
/**
|
|
57
|
-
* List tool approval requests, optionally filtered.
|
|
58
|
-
* @param filters - Optional filters (status, agentId)
|
|
59
|
-
* @returns Array of tool approval records
|
|
60
|
-
*/
|
|
61
|
-
getToolApprovals(filters?: ToolApprovalFilters): Promise<ToolApproval[]>;
|
|
62
|
-
/**
|
|
63
|
-
* Approve a tool execution request.
|
|
64
|
-
* @param approvalId - ID of the approval to approve
|
|
65
|
-
*/
|
|
66
|
-
approveToolRequest(approvalId: string): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Reject a tool execution request.
|
|
69
|
-
* @param approvalId - ID of the approval to reject
|
|
70
|
-
* @param reason - Optional rejection reason
|
|
71
|
-
*/
|
|
72
|
-
rejectToolRequest(approvalId: string, reason?: string): Promise<void>;
|
|
73
55
|
/**
|
|
74
56
|
* List notifications, optionally filtered.
|
|
75
57
|
* @param filters - Optional filters (level, read status)
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
import * as agents from '../api/agents';
|
|
6
|
-
import * as toolApprovals from '../api/tool-approvals';
|
|
7
6
|
import * as notifications from '../api/notifications';
|
|
8
7
|
import * as events from '../api/events';
|
|
9
8
|
import * as output from '../api/output';
|
|
@@ -80,35 +79,12 @@ export function AgentsMixin(Base) {
|
|
|
80
79
|
// ========================================================================
|
|
81
80
|
// Tool Approvals
|
|
82
81
|
// ========================================================================
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const token = this.getToken();
|
|
90
|
-
const baseUrl = this.getIamRunUrl();
|
|
91
|
-
return toolApprovals.getToolApprovals(token, filters, baseUrl);
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Approve a tool execution request.
|
|
95
|
-
* @param approvalId - ID of the approval to approve
|
|
96
|
-
*/
|
|
97
|
-
async approveToolRequest(approvalId) {
|
|
98
|
-
const token = this.getToken();
|
|
99
|
-
const baseUrl = this.getIamRunUrl();
|
|
100
|
-
return toolApprovals.approveToolRequest(token, approvalId, baseUrl);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Reject a tool execution request.
|
|
104
|
-
* @param approvalId - ID of the approval to reject
|
|
105
|
-
* @param reason - Optional rejection reason
|
|
106
|
-
*/
|
|
107
|
-
async rejectToolRequest(approvalId, reason) {
|
|
108
|
-
const token = this.getToken();
|
|
109
|
-
const baseUrl = this.getIamRunUrl();
|
|
110
|
-
return toolApprovals.rejectToolRequest(token, approvalId, reason, baseUrl);
|
|
111
|
-
}
|
|
82
|
+
//
|
|
83
|
+
// Tool approval interactions have been removed from the REST mixin.
|
|
84
|
+
// All approval flows (list / approve / reject / realtime updates) now
|
|
85
|
+
// travel exclusively over the AI Agents websocket stream. Use the
|
|
86
|
+
// `useToolApprovals` React hook (or send `tool_approval_decision`
|
|
87
|
+
// messages directly on the stream) instead.
|
|
112
88
|
// ========================================================================
|
|
113
89
|
// Notifications
|
|
114
90
|
// ========================================================================
|
|
@@ -353,6 +329,11 @@ export function AgentsMixin(Base) {
|
|
|
353
329
|
async createAgentRuntime(data) {
|
|
354
330
|
const token = this.getToken();
|
|
355
331
|
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
332
|
+
const normalizedVolumeUids = Array.isArray(data.volumeUids)
|
|
333
|
+
? data.volumeUids.map(uid => String(uid || '').trim()).filter(Boolean)
|
|
334
|
+
: data.volumeUid
|
|
335
|
+
? [String(data.volumeUid).trim()]
|
|
336
|
+
: [];
|
|
356
337
|
return requestDatalayerAPI({
|
|
357
338
|
url: `${runtimesRunUrl}/api/runtimes/v1/runtimes`,
|
|
358
339
|
method: 'POST',
|
|
@@ -366,6 +347,15 @@ export function AgentsMixin(Base) {
|
|
|
366
347
|
enable_codemode: data.enableCodemode ?? false,
|
|
367
348
|
agent_spec_id: data.agentSpecId || undefined,
|
|
368
349
|
agent_spec: data.agentSpec || undefined,
|
|
350
|
+
user_account_handle: data.userAccountHandle || undefined,
|
|
351
|
+
billable_account_uid: data.billableAccountUid || undefined,
|
|
352
|
+
billable_account_type: data.billableAccountType || undefined,
|
|
353
|
+
billable_account_handle: data.billableAccountHandle || undefined,
|
|
354
|
+
billable_source_organization_uid: data.billableSourceOrganizationUid || undefined,
|
|
355
|
+
billable_source_organization_handle: data.billableSourceOrganizationHandle || undefined,
|
|
356
|
+
mount_home_folder: data.mountHomeFolder ?? false,
|
|
357
|
+
volume_uids: normalizedVolumeUids.length > 0 ? normalizedVolumeUids : undefined,
|
|
358
|
+
volume_uid: normalizedVolumeUids[0] || data.volumeUid || undefined,
|
|
369
359
|
},
|
|
370
360
|
});
|
|
371
361
|
}
|