@datalayer/agent-runtimes 1.3.89 → 1.3.91
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/lib/Agent.js +2 -18
- package/lib/AgentDocument.js +5 -55
- package/lib/AgentNode.js +31 -208
- package/lib/AgentNotebook.js +5 -59
- package/lib/agent-node/AgentNodeGallery.js +23 -111
- package/lib/agents/AgentDetails.js +36 -274
- package/lib/agents/AgentRuntimeChat.js +1 -8
- package/lib/chat/Chat.js +7 -46
- package/lib/chat/ChatFloating.js +15 -100
- package/lib/chat/ChatInline.js +5 -47
- package/lib/chat/ChatPopupStandalone.js +5 -53
- package/lib/chat/ChatSidebar.js +4 -51
- package/lib/chat/ChatStandalone.js +4 -45
- package/lib/chat/EphemeralSurfaceControl.js +5 -25
- package/lib/chat/assistant/AssistantContextMenu.d.ts +8 -0
- package/lib/chat/assistant/AssistantContextMenu.js +17 -1
- package/lib/chat/assistant/AssistantStage.js +6 -25
- package/lib/chat/assistant/BalloonParts.js +8 -40
- package/lib/chat/assistant/BalloonVisual.js +2 -2
- package/lib/chat/assistant/ConversationBalloon.js +2 -11
- package/lib/chat/assistant/DecisionAsk.js +3 -3
- package/lib/chat/assistant/SandboxDetailsDialog.js +3 -17
- package/lib/chat/assistant/SpeechBalloon.js +14 -78
- package/lib/chat/base/ChatBase.js +37 -172
- package/lib/chat/display/EmptyState.js +7 -35
- package/lib/chat/display/FloatingBrandButton.js +4 -34
- package/lib/chat/display/PoweredByTag.js +3 -14
- package/lib/chat/document/EphemeralDocument.js +3 -18
- package/lib/chat/header/ChatHeader.js +1 -17
- package/lib/chat/header/ChatHeaderBase.js +2 -24
- package/lib/chat/header/ChatViewModeToggle.js +7 -29
- package/lib/chat/indicators/McpStatusIndicator.js +3 -12
- package/lib/chat/indicators/SandboxStatusIndicator.js +6 -34
- package/lib/chat/indicators/SkillsStatusIndicator.js +3 -12
- package/lib/chat/indicators/TypingDots.js +1 -11
- package/lib/chat/messages/ChatMessageList.js +58 -185
- package/lib/chat/messages/ChatMessages.js +15 -79
- package/lib/chat/messages/FormSubmissionMessage.js +2 -33
- package/lib/chat/messages/NotebookToolSurfaces.js +12 -41
- package/lib/chat/messages/TurnFooter.js +4 -10
- package/lib/chat/notebook/EphemeralNotebook.js +2 -10
- package/lib/chat/parts/ReasoningPart.js +2 -16
- package/lib/chat/parts/TextPart.js +2 -12
- package/lib/chat/parts/ToolPart.js +16 -90
- package/lib/chat/presence/Presence.js +5 -33
- package/lib/chat/prompt/FloatingCard.js +1 -13
- package/lib/chat/prompt/InputPrompt.js +1 -6
- package/lib/chat/prompt/InputPromptBase.js +4 -17
- package/lib/chat/prompt/InputPromptLexical.js +44 -45
- package/lib/chat/prompt/InputPromptText.js +1 -1
- package/lib/chat/prompt/footer/InPromptFooter.js +1 -8
- package/lib/chat/prompt/menus/AgentsMenu.js +1 -1
- package/lib/chat/prompt/menus/InlineAgentsMenu.js +1 -1
- package/lib/chat/prompt/menus/ModelSelector.js +1 -5
- package/lib/chat/prompt/menus/SkillsMenu.js +3 -30
- package/lib/chat/prompt/menus/SuggestionsMenu.js +1 -1
- package/lib/chat/prompt/menus/ToolsMenu.js +4 -48
- package/lib/chat/prompt/plugins/AgentMentionPlugin.js +2 -9
- package/lib/chat/prompt/plugins/CommandPlugin.js +2 -9
- package/lib/chat/prompt/plugins/MentionChip.js +1 -15
- package/lib/chat/prompt/stack.js +1 -19
- package/lib/chat/tools/A2AAgentDialog.js +9 -42
- package/lib/chat/tools/SubagentActivity.js +5 -22
- package/lib/chat/tools/ToolApprovalBanner.js +4 -34
- package/lib/chat/tools/ToolApprovalDialog.js +4 -19
- package/lib/chat/tools/ToolCallDisplay.js +12 -97
- package/lib/chat/usage/ContextPie.js +4 -45
- package/lib/chat/words.d.ts +7 -0
- package/lib/chat/words.js +12 -0
- package/lib/components/a2ui/datalayer/Chart.js +4 -10
- package/lib/components/a2ui/datalayer/Chat.js +2 -10
- package/lib/components/a2ui/datalayer/Download.js +1 -1
- package/lib/components/a2ui/datalayer/Evidence.js +1 -15
- package/lib/components/a2ui/datalayer/FileUpload.js +1 -12
- package/lib/components/a2ui/datalayer/Table.js +9 -17
- package/lib/components/a2ui/datalayer/formWidgets.js +3 -2
- package/lib/components/a2ui/datalayer/parts.js +1 -16
- package/lib/components/a2ui/styles.js +16 -5
- package/lib/components/agents/AgentSummary.js +1 -51
- package/lib/components/cards/NotificationEventCard.js +6 -72
- package/lib/components/cards/OutputCard.js +4 -48
- package/lib/components/cards/ToolApprovalCard.js +2 -35
- package/lib/components/code-sandboxes/CodeSandboxCellVariables.js +1 -1
- package/lib/components/code-sandboxes/CodeSandboxEnvironmentSelect.js +4 -14
- package/lib/components/code-sandboxes/CodeSandboxPicker.js +16 -21
- package/lib/components/code-sandboxes/CodeSandboxVariables.js +2 -2
- package/lib/components/scheduler/ScheduleMenu.js +5 -10
- package/lib/components/specs/SpecPayloadPreview.js +1 -26
- package/lib/components/teams/A2ATeamGraph.d.ts +4 -3
- package/lib/components/teams/A2ATeamGraph.js +25 -71
- package/lib/components/teams/AnswerSurfacesView.js +2 -2
- package/lib/components/teams/NotebookPreview.js +1 -10
- package/lib/components/teams/NotebookPreviewView.js +2 -3
- package/lib/components/teams/SceneTranscript.js +3 -17
- package/lib/components/teams/SceneView.js +1 -8
- package/lib/components/teams/TeamNotebook.js +5 -13
- package/lib/components/teams/TeamNotebookView.js +2 -12
- package/lib/components/teams/index.d.ts +1 -0
- package/lib/components/teams/index.js +1 -0
- package/lib/components/teams/useBalloonRoom.d.ts +39 -0
- package/lib/components/teams/useBalloonRoom.js +89 -0
- package/lib/config/AgentConfiguration.js +22 -225
- package/lib/context/ContextDistribution.js +7 -41
- package/lib/context/ContextInspector.js +9 -107
- package/lib/context/ContextPanel.js +11 -86
- package/lib/context/ContextUsage.js +6 -34
- package/lib/context/CostTracker.js +7 -42
- package/lib/context/MessageHistory.js +3 -37
- package/lib/context/TurnGraphChart.js +9 -41
- package/lib/examples/A2UiAgentExample.js +6 -108
- package/lib/examples/A2UiComponentsGalleryExample.js +1 -1
- package/lib/examples/A2UiContactCardExample.js +1 -1
- package/lib/examples/A2UiJupyterOutputExample.js +25 -125
- package/lib/examples/A2UiRestaurantExample.js +1 -1
- package/lib/examples/A2UiViewerExample.js +1 -1
- package/lib/examples/AgUiAgenticExample.js +3 -35
- package/lib/examples/AgUiBackendToolRenderingExample.js +2 -25
- package/lib/examples/AgUiHaikuGenUiExample.js +2 -32
- package/lib/examples/AgUiHumanInTheLoopExample.js +5 -59
- package/lib/examples/AgUiSharedStateExample.js +6 -56
- package/lib/examples/AgUiToolsBasedGenUiExample.js +25 -120
- package/lib/examples/AgentA2AExample.js +1 -15
- package/lib/examples/AgentA2ATeamExample.js +6 -30
- package/lib/examples/AgentCheckpointsExample.js +11 -145
- package/lib/examples/AgentCodeSandboxExample.js +5 -108
- package/lib/examples/AgentCodeSandboxesExample.js +3 -30
- package/lib/examples/AgentCodemodeExample.js +9 -85
- package/lib/examples/AgentCompactionExample.js +3 -64
- package/lib/examples/AgentDecideExample.js +1 -13
- package/lib/examples/AgentEvalsExample.js +5 -60
- package/lib/examples/AgentGuardrailsExample.js +4 -28
- package/lib/examples/AgentHooksExample.js +1 -1
- package/lib/examples/AgentInferenceProviderExample.js +5 -96
- package/lib/examples/AgentMCPExample.js +7 -105
- package/lib/examples/AgentMemoryExample.js +5 -74
- package/lib/examples/AgentMonitoringExample.js +7 -53
- package/lib/examples/AgentNotificationsExample.js +3 -61
- package/lib/examples/AgentOtelExample.js +3 -72
- package/lib/examples/AgentOutputsExample.js +6 -81
- package/lib/examples/AgentParametersExample.js +2 -37
- package/lib/examples/AgentSkillsExample.js +3 -45
- package/lib/examples/AgentSubagentsExample.js +6 -56
- package/lib/examples/AgentToolApprovalsExample.js +1 -11
- package/lib/examples/AgentTriggersExample.js +29 -239
- package/lib/examples/AgentspecsExample.js +6 -60
- package/lib/examples/AssistantExample.js +5 -5
- package/lib/examples/AssistantGalleryExample.js +8 -65
- package/lib/examples/CellExample.js +1 -6
- package/lib/examples/ChatCustomExample.js +2 -31
- package/lib/examples/ChatExample.js +1 -9
- package/lib/examples/ChatStandaloneExample.js +3 -37
- package/lib/examples/CopilotKitLexicalExample.js +1 -24
- package/lib/examples/DecksAgent.js +1 -1
- package/lib/examples/DocumentPageAgent.js +1 -1
- package/lib/examples/HomeExample.js +14 -62
- package/lib/examples/Lexical2Example.js +3 -32
- package/lib/examples/LexicalAgentExample.js +2 -34
- package/lib/examples/LexicalAgentSidebarExample.js +3 -34
- package/lib/examples/LoopAppComputerExample.js +1 -1
- package/lib/examples/LoopShellExample.js +2 -2
- package/lib/examples/LoopStrategyExample.js +15 -87
- package/lib/examples/LoopWorkspaceEmbed.js +2 -18
- package/lib/examples/LoopWorkspaceExample.js +2 -2
- package/lib/examples/NotebookAgentExample.js +2 -33
- package/lib/examples/NotebookAgentSidebarExample.js +3 -46
- package/lib/examples/NotebookCollaborationExample.js +1 -31
- package/lib/examples/NotebookExample.js +1 -18
- package/lib/examples/NotebookPageAgent.js +1 -1
- package/lib/examples/ScenesExample.js +5 -24
- package/lib/examples/VoiceChatExample.js +1 -1
- package/lib/examples/components/AuthRequiredView.js +1 -7
- package/lib/examples/components/ErrorView.js +1 -8
- package/lib/examples/components/ExampleErrorBoundary.js +1 -14
- package/lib/examples/components/FooterMetrics.js +1 -7
- package/lib/examples/components/Header.js +12 -51
- package/lib/examples/components/HeaderControls.js +1 -9
- package/lib/examples/components/LexicalEditor.js +1 -8
- package/lib/examples/components/MainContent.js +1 -13
- package/lib/examples/components/MockFileBrowser.js +4 -40
- package/lib/examples/components/SessionTabs.js +1 -1
- package/lib/examples/components/TimeTravel.js +1 -13
- package/lib/examples/main.js +13 -81
- package/lib/examples/scenes/A2UiComponentsGalleryScene.js +3 -34
- package/lib/examples/scenes/A2UiContactCardScene.js +3 -35
- package/lib/examples/scenes/A2UiRestaurantScene.js +3 -53
- package/lib/examples/scenes/A2UiViewerScene.js +3 -34
- package/lib/examples/utils/AssistantGalleryGrid.js +6 -35
- package/lib/examples2/DatalayerNotebookExample.js +3 -33
- package/lib/examples2/NativeNavigationExample.js +4 -10
- package/lib/examples2/NotebookMutationsKernel.js +2 -1
- package/lib/examples2/NotebookMutationsServiceManager.js +2 -1
- package/lib/examples2/ReactRouterExample.js +14 -42
- package/lib/hooks/useToolApprovals.d.ts +2 -34
- package/lib/hooks/useToolApprovals.js +1 -64
- package/lib/identity/AgentIdentity.js +17 -62
- package/lib/identity/IdentityConnect.js +13 -59
- package/lib/identity/OAuthCallback.js +6 -44
- package/lib/lexical/ChatInlinePlugin.js +6 -14
- package/lib/loop/apps/AppFeedback.js +12 -3
- package/lib/loop/apps/AppRenderer.d.ts +4 -3
- package/lib/loop/apps/AppRenderer.js +11 -12
- package/lib/loop/apps/appspec.js +6 -3
- package/lib/loop/apps/feedback.d.ts +3 -2
- package/lib/loop/apps/feedback.js +4 -2
- package/lib/loop/core/index.d.ts +19 -0
- package/lib/loop/core/index.js +27 -0
- package/lib/loop/embed/AppEmbed.d.ts +1 -1
- package/lib/loop/embed/AppEmbed.js +2 -1
- package/lib/loop/embed/LoopEmbed.js +1 -7
- package/lib/loop/embed/embedConfig.d.ts +3 -3
- package/lib/loop/embed/embedConfig.js +2 -3
- package/lib/loop/embed/embedTheme.d.ts +4 -4
- package/lib/loop/embed/embedTheme.js +11 -7
- package/lib/loop/plugins/a2a-sidebar/A2ASidebar.js +7 -34
- package/lib/loop/plugins/a2ui/A2uiView.js +4 -12
- package/lib/loop/plugins/a2ui-surface/InlineSurface.js +1 -16
- package/lib/loop/plugins/a2ui-surface/SurfaceToolResult.js +2 -12
- package/lib/loop/plugins/agents/AnonymousKeyBadge.js +3 -2
- package/lib/loop/plugins/agents/SandboxSelector.js +3 -7
- package/lib/loop/plugins/agents/SandboxView.js +4 -27
- package/lib/loop/plugins/agents/TeamMemberPicker.js +2 -2
- package/lib/loop/plugins/agentspecs/AgentspecPicker.js +3 -2
- package/lib/loop/plugins/app-activity/AppActivity.js +1 -1
- package/lib/loop/plugins/app-computer/AppComputer.js +32 -27
- package/lib/loop/plugins/app-elements/AppElements.js +2 -31
- package/lib/loop/plugins/app-page/AppPage.js +26 -8
- package/lib/loop/plugins/app-rules/AppRulesCard.js +4 -20
- package/lib/loop/plugins/assistant/index.js +1 -13
- package/lib/loop/plugins/chat/ChatView.js +89 -130
- package/lib/loop/plugins/checkpoints-sidebar/CheckpointsSidebar.js +2 -13
- package/lib/loop/plugins/decks/DeckSurface.js +2 -2
- package/lib/loop/plugins/document/DocumentView.js +4 -12
- package/lib/loop/plugins/document-toolbar/SandboxStatusItem.js +3 -8
- package/lib/loop/plugins/graph/GraphView.js +2 -2
- package/lib/loop/plugins/input-prompt/ComposerView.js +1 -1
- package/lib/loop/plugins/notebook/NotebookView.js +3 -11
- package/lib/loop/plugins/page-layout/SplitLayout.js +11 -34
- package/lib/loop/plugins/page-layout/TurnPanel.js +9 -35
- package/lib/loop/plugins/shell/useEditorPreviews.js +3 -2
- package/lib/loop/plugins/subagent-activity/SubagentPulse.js +1 -13
- package/lib/loop/plugins/window-frame/WindowFrame.js +10 -44
- package/lib/loop/plugins/window-frame/index.js +1 -1
- package/lib/loop/shell/LoopWorkspace.js +34 -77
- package/lib/loop/shell/PluginToggles.js +4 -15
- package/lib/loop/shell/SidebarRail.js +8 -40
- package/lib/loop/shell/ViewSwitcher.js +4 -24
- package/lib/loop-main.js +2 -3
- package/lib/mcp/McpServerManager.js +6 -37
- package/lib/portable/index.d.ts +11 -0
- package/lib/portable/index.js +20 -0
- package/lib/protocols/AGUIAdapter.js +2 -2
- package/lib/protocols/BaseProtocolAdapter.d.ts +2 -0
- package/lib/protocols/BaseProtocolAdapter.js +4 -0
- package/lib/specs/apps.js +6 -0
- package/lib/specs/appspecSchema.js +11 -4
- package/lib/stories/loop/ReferenceScreens.js +17 -91
- package/lib/stories/loop/pictures-main.js +1 -1
- package/lib/types/agentspecs.d.ts +5 -2
- package/lib/types/protocol.d.ts +2 -0
- package/lib/utils/approvals.d.ts +59 -0
- package/lib/utils/approvals.js +101 -0
- package/lib/voice/VoiceInput.js +3 -39
- package/package.json +2 -2
- package/lib/shims/primerAddonsBox.d.ts +0 -1
- package/lib/shims/primerAddonsBox.js +0 -7
|
@@ -31,27 +31,7 @@ function formatTokens(tokens) {
|
|
|
31
31
|
*/
|
|
32
32
|
function CollapsibleSection({ title, icon, count, tokens, defaultExpanded = false, children, }) {
|
|
33
33
|
const [expanded, setExpanded] = useState(defaultExpanded);
|
|
34
|
-
return (_jsxs(Box, {
|
|
35
|
-
display: 'flex',
|
|
36
|
-
alignItems: 'center',
|
|
37
|
-
gap: 2,
|
|
38
|
-
width: '100%',
|
|
39
|
-
p: 2,
|
|
40
|
-
bg: 'canvas.subtle',
|
|
41
|
-
border: '1px solid',
|
|
42
|
-
borderColor: 'border.default',
|
|
43
|
-
borderRadius: 2,
|
|
44
|
-
cursor: 'pointer',
|
|
45
|
-
'&:hover': {
|
|
46
|
-
bg: 'canvas.inset',
|
|
47
|
-
},
|
|
48
|
-
}, children: [expanded ? (_jsx(ChevronDownIcon, { size: 16 })) : (_jsx(ChevronRightIcon, { size: 16 })), React.createElement(icon, { size: 16 }), _jsx(Text, { sx: { fontWeight: 'semibold', flex: 1, textAlign: 'left' }, children: title }), count !== undefined && (_jsx(Label, { variant: "secondary", size: "small", children: count })), tokens !== undefined && tokens > 0 && (_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [formatTokens(tokens), " tokens"] }))] }), expanded && (_jsx(Box, { sx: {
|
|
49
|
-
border: '1px solid',
|
|
50
|
-
borderColor: 'border.default',
|
|
51
|
-
borderTop: 'none',
|
|
52
|
-
borderRadius: '0 0 6px 6px',
|
|
53
|
-
p: 2,
|
|
54
|
-
}, children: children }))] }));
|
|
34
|
+
return (_jsxs(Box, { mb: 2, children: [_jsxs(Box, { as: "button", onClick: () => setExpanded(!expanded), display: "flex", alignItems: "center", gap: 2, width: "100%", p: 2, bg: "canvas.subtle", border: "1px solid", borderColor: "border.default", borderRadius: 2, cursor: "pointer", hover: { bg: 'canvas.inset' }, children: [expanded ? (_jsx(ChevronDownIcon, { size: 16 })) : (_jsx(ChevronRightIcon, { size: 16 })), React.createElement(icon, { size: 16 }), _jsx(Text, { sx: { fontWeight: 'semibold', flex: 1, textAlign: 'left' }, children: title }), count !== undefined && (_jsx(Label, { variant: "secondary", size: "small", children: count })), tokens !== undefined && tokens > 0 && (_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [formatTokens(tokens), " tokens"] }))] }), expanded && (_jsx(Box, { border: "1px solid", borderColor: "border.default", borderTop: "none", borderRadius: "0 0 6px 6px", p: 2, children: children }))] }));
|
|
55
35
|
}
|
|
56
36
|
/**
|
|
57
37
|
* Tool detail view component
|
|
@@ -59,30 +39,7 @@ function CollapsibleSection({ title, icon, count, tokens, defaultExpanded = fals
|
|
|
59
39
|
function ToolDetailView({ tool }) {
|
|
60
40
|
const [showSchema, setShowSchema] = useState(false);
|
|
61
41
|
const [showSource, setShowSource] = useState(false);
|
|
62
|
-
return (_jsxs(Box, { sx: {
|
|
63
|
-
p: 2,
|
|
64
|
-
mb: 2,
|
|
65
|
-
bg: 'canvas.default',
|
|
66
|
-
border: '1px solid',
|
|
67
|
-
borderColor: 'border.muted',
|
|
68
|
-
borderRadius: 2,
|
|
69
|
-
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2, mb: 1 }, children: [_jsx(Text, { sx: { fontWeight: 'bold', fontFamily: 'mono', fontSize: 1 }, children: tool.name }), _jsx(Label, { size: "small", variant: "secondary", children: tool.sourceType }), tool.isAsync && (_jsx(Label, { size: "small", variant: "accent", children: "async" })), tool.requiresApproval && (_jsx(Label, { size: "small", variant: "attention", children: "requires approval" })), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', ml: 'auto' }, children: [formatTokens(tool.totalTokens), " tokens"] })] }), tool.description && (_jsx(Text, { sx: { fontSize: 1, color: 'fg.muted', display: 'block', mb: 2 }, children: tool.description })), _jsxs(Box, { sx: { display: 'flex', gap: 2 }, children: [_jsxs(Button, { size: "small", variant: "invisible", onClick: () => setShowSchema(!showSchema), children: [showSchema ? 'Hide' : 'Show', " Schema"] }), tool.sourceCode && (_jsxs(Button, { size: "small", variant: "invisible", onClick: () => setShowSource(!showSource), children: [showSource ? 'Hide' : 'Show', " Source"] }))] }), showSchema && (_jsx(Box, { as: "pre", sx: {
|
|
70
|
-
mt: 2,
|
|
71
|
-
p: 2,
|
|
72
|
-
bg: 'canvas.inset',
|
|
73
|
-
borderRadius: 2,
|
|
74
|
-
fontSize: 0,
|
|
75
|
-
overflow: 'auto',
|
|
76
|
-
maxHeight: 200,
|
|
77
|
-
}, children: JSON.stringify(tool.parametersSchema, null, 2) })), showSource && tool.sourceCode && (_jsx(Box, { as: "pre", sx: {
|
|
78
|
-
mt: 2,
|
|
79
|
-
p: 2,
|
|
80
|
-
bg: 'canvas.inset',
|
|
81
|
-
borderRadius: 2,
|
|
82
|
-
fontSize: 0,
|
|
83
|
-
overflow: 'auto',
|
|
84
|
-
maxHeight: 300,
|
|
85
|
-
}, children: tool.sourceCode }))] }));
|
|
42
|
+
return (_jsxs(Box, { p: 2, mb: 2, bg: "canvas.default", border: "1px solid", borderColor: "border.muted", borderRadius: 2, children: [_jsxs(Box, { display: "flex", alignItems: "center", gap: 2, mb: 1, children: [_jsx(Text, { sx: { fontWeight: 'bold', fontFamily: 'mono', fontSize: 1 }, children: tool.name }), _jsx(Label, { size: "small", variant: "secondary", children: tool.sourceType }), tool.isAsync && (_jsx(Label, { size: "small", variant: "accent", children: "async" })), tool.requiresApproval && (_jsx(Label, { size: "small", variant: "attention", children: "requires approval" })), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', ml: 'auto' }, children: [formatTokens(tool.totalTokens), " tokens"] })] }), tool.description && (_jsx(Text, { sx: { fontSize: 1, color: 'fg.muted', display: 'block', mb: 2 }, children: tool.description })), _jsxs(Box, { display: "flex", gap: 2, children: [_jsxs(Button, { size: "small", variant: "invisible", onClick: () => setShowSchema(!showSchema), children: [showSchema ? 'Hide' : 'Show', " Schema"] }), tool.sourceCode && (_jsxs(Button, { size: "small", variant: "invisible", onClick: () => setShowSource(!showSource), children: [showSource ? 'Hide' : 'Show', " Source"] }))] }), showSchema && (_jsx(Box, { as: "pre", mt: 2, p: 2, bg: "canvas.inset", borderRadius: 2, fontSize: 0, overflow: "auto", maxHeight: 200, children: JSON.stringify(tool.parametersSchema, null, 2) })), showSource && tool.sourceCode && (_jsx(Box, { as: "pre", mt: 2, p: 2, bg: "canvas.inset", borderRadius: 2, fontSize: 0, overflow: "auto", maxHeight: 300, children: tool.sourceCode }))] }));
|
|
86
43
|
}
|
|
87
44
|
/**
|
|
88
45
|
* ContextInspector component displays full detailed context snapshot.
|
|
@@ -92,84 +49,29 @@ export function ContextInspector({ agentId, apiBase, liveData, }) {
|
|
|
92
49
|
// REST polling removed — data comes exclusively via WS `agent.snapshot`.
|
|
93
50
|
const contextData = liveData;
|
|
94
51
|
if (!hasLiveData) {
|
|
95
|
-
return (_jsx(Box, { sx: {
|
|
96
|
-
p: 3,
|
|
97
|
-
display: 'flex',
|
|
98
|
-
alignItems: 'center',
|
|
99
|
-
justifyContent: 'center',
|
|
100
|
-
}, children: _jsx(Text, { sx: { color: 'fg.muted' }, children: "Waiting for context data from WebSocket stream..." }) }));
|
|
52
|
+
return (_jsx(Box, { p: 3, display: "flex", alignItems: "center", justifyContent: "center", children: _jsx(Text, { sx: { color: 'fg.muted' }, children: "Waiting for context data from WebSocket stream..." }) }));
|
|
101
53
|
}
|
|
102
54
|
if (!contextData) {
|
|
103
|
-
return (_jsx(Box, { sx: {
|
|
104
|
-
p: 3,
|
|
105
|
-
bg: 'attention.subtle',
|
|
106
|
-
borderRadius: 2,
|
|
107
|
-
border: '1px solid',
|
|
108
|
-
borderColor: 'attention.muted',
|
|
109
|
-
}, children: _jsx(Text, { sx: { color: 'attention.fg' }, children: "No context data available." }) }));
|
|
55
|
+
return (_jsx(Box, { p: 3, bg: "attention.subtle", borderRadius: 2, border: "1px solid", borderColor: "attention.muted", children: _jsx(Text, { sx: { color: 'attention.fg' }, children: "No context data available." }) }));
|
|
110
56
|
}
|
|
111
57
|
if (contextData.error) {
|
|
112
|
-
return (_jsx(Box, { sx: {
|
|
113
|
-
p: 3,
|
|
114
|
-
bg: 'attention.subtle',
|
|
115
|
-
borderRadius: 2,
|
|
116
|
-
border: '1px solid',
|
|
117
|
-
borderColor: 'attention.muted',
|
|
118
|
-
}, children: _jsx(Text, { sx: { color: 'attention.fg' }, children: contextData.error }) }));
|
|
58
|
+
return (_jsx(Box, { p: 3, bg: "attention.subtle", borderRadius: 2, border: "1px solid", borderColor: "attention.muted", children: _jsx(Text, { sx: { color: 'attention.fg' }, children: contextData.error }) }));
|
|
119
59
|
}
|
|
120
60
|
const { tokenSummary, modelConfiguration } = contextData;
|
|
121
|
-
return (_jsxs(Box, { children: [_jsxs(Box, {
|
|
61
|
+
return (_jsxs(Box, { children: [_jsxs(Box, { mb: 3, children: [_jsxs(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: ["Total usage: ", formatTokens(tokenSummary.total), " /", ' ', formatTokens(tokenSummary.contextWindow), " (", Math.round(tokenSummary.usagePercent), "%)"] }), _jsx(ProgressBar, { progress: Math.min(tokenSummary.usagePercent, 100), sx: { mt: 2, height: 8 }, bg: tokenSummary.usagePercent > 90
|
|
122
62
|
? 'danger.emphasis'
|
|
123
63
|
: tokenSummary.usagePercent > 70
|
|
124
64
|
? 'attention.emphasis'
|
|
125
|
-
: 'success.emphasis' }), _jsxs(Box, { sx: {
|
|
126
|
-
display: 'flex',
|
|
127
|
-
gap: 3,
|
|
128
|
-
mt: 2,
|
|
129
|
-
flexWrap: 'wrap',
|
|
130
|
-
fontSize: 0,
|
|
131
|
-
color: 'fg.muted',
|
|
132
|
-
}, children: [_jsxs(Text, { children: ["System: ", formatTokens(tokenSummary.systemPrompts)] }), _jsxs(Text, { children: ["Tools: ", formatTokens(tokenSummary.tools)] }), tokenSummary.memory > 0 && (_jsxs(Text, { children: ["Memory: ", formatTokens(tokenSummary.memory)] })), _jsxs(Text, { children: ["History: ", formatTokens(tokenSummary.history)] }), _jsxs(Text, { children: ["Current: ", formatTokens(tokenSummary.current)] })] })] }), _jsx(CollapsibleSection, { title: "Model Configuration", icon: AiModelIcon, defaultExpanded: false, children: _jsxs(Box, { sx: { display: 'grid', gridTemplateColumns: '1fr 2fr', gap: 2 }, children: [_jsx(Text, { sx: { fontWeight: 'semibold', fontSize: 1 }, children: "Model:" }), _jsx(Text, { sx: { fontSize: 1, fontFamily: 'mono' }, children: modelConfiguration.modelName || 'Not specified' }), _jsx(Text, { sx: { fontWeight: 'semibold', fontSize: 1 }, children: "Context Window:" }), _jsxs(Text, { sx: { fontSize: 1 }, children: [formatTokens(modelConfiguration.contextWindow), " tokens"] }), Object.keys(modelConfiguration.settings).length > 0 && (_jsxs(_Fragment, { children: [_jsx(Text, { sx: { fontWeight: 'semibold', fontSize: 1 }, children: "Settings:" }), _jsx(Box, { as: "pre", sx: {
|
|
133
|
-
fontSize: 0,
|
|
134
|
-
p: 2,
|
|
135
|
-
bg: 'canvas.inset',
|
|
136
|
-
borderRadius: 2,
|
|
137
|
-
overflow: 'auto',
|
|
138
|
-
}, children: JSON.stringify(modelConfiguration.settings, null, 2) })] }))] }) }), _jsx(CollapsibleSection, { title: "System Prompts", icon: InfoIcon, count: contextData.systemPrompts.length, tokens: contextData.systemPromptTokens, children: contextData.systemPrompts.length === 0 ? (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "No system prompts configured" })) : (contextData.systemPrompts.map((prompt, idx) => (_jsxs(Box, { sx: {
|
|
139
|
-
p: 2,
|
|
140
|
-
mb: 2,
|
|
141
|
-
bg: 'canvas.inset',
|
|
142
|
-
borderRadius: 2,
|
|
143
|
-
border: '1px solid',
|
|
144
|
-
borderColor: 'border.muted',
|
|
145
|
-
}, children: [_jsxs(Box, { sx: {
|
|
146
|
-
display: 'flex',
|
|
147
|
-
justifyContent: 'space-between',
|
|
148
|
-
mb: 1,
|
|
149
|
-
}, children: [_jsxs(Text, { sx: { fontWeight: 'semibold', fontSize: 0 }, children: ["Prompt ", idx + 1] }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [formatTokens(prompt.tokens), " tokens"] })] }), _jsx(Text, { as: "pre", sx: {
|
|
65
|
+
: 'success.emphasis' }), _jsxs(Box, { display: "flex", gap: 3, mt: 2, flexWrap: "wrap", fontSize: 0, color: "fg.muted", children: [_jsxs(Text, { children: ["System: ", formatTokens(tokenSummary.systemPrompts)] }), _jsxs(Text, { children: ["Tools: ", formatTokens(tokenSummary.tools)] }), tokenSummary.memory > 0 && (_jsxs(Text, { children: ["Memory: ", formatTokens(tokenSummary.memory)] })), _jsxs(Text, { children: ["History: ", formatTokens(tokenSummary.history)] }), _jsxs(Text, { children: ["Current: ", formatTokens(tokenSummary.current)] })] })] }), _jsx(CollapsibleSection, { title: "Model Configuration", icon: AiModelIcon, defaultExpanded: false, children: _jsxs(Box, { display: "grid", gridTemplateColumns: "1fr 2fr", gap: 2, children: [_jsx(Text, { sx: { fontWeight: 'semibold', fontSize: 1 }, children: "Model:" }), _jsx(Text, { sx: { fontSize: 1, fontFamily: 'mono' }, children: modelConfiguration.modelName || 'Not specified' }), _jsx(Text, { sx: { fontWeight: 'semibold', fontSize: 1 }, children: "Context Window:" }), _jsxs(Text, { sx: { fontSize: 1 }, children: [formatTokens(modelConfiguration.contextWindow), " tokens"] }), Object.keys(modelConfiguration.settings).length > 0 && (_jsxs(_Fragment, { children: [_jsx(Text, { sx: { fontWeight: 'semibold', fontSize: 1 }, children: "Settings:" }), _jsx(Box, { as: "pre", fontSize: 0, p: 2, bg: "canvas.inset", borderRadius: 2, overflow: "auto", children: JSON.stringify(modelConfiguration.settings, null, 2) })] }))] }) }), _jsx(CollapsibleSection, { title: "System Prompts", icon: InfoIcon, count: contextData.systemPrompts.length, tokens: contextData.systemPromptTokens, children: contextData.systemPrompts.length === 0 ? (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "No system prompts configured" })) : (contextData.systemPrompts.map((prompt, idx) => (_jsxs(Box, { p: 2, mb: 2, bg: "canvas.inset", borderRadius: 2, border: "1px solid", borderColor: "border.muted", children: [_jsxs(Box, { display: "flex", justifyContent: "space-between", mb: 1, children: [_jsxs(Text, { sx: { fontWeight: 'semibold', fontSize: 0 }, children: ["Prompt ", idx + 1] }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [formatTokens(prompt.tokens), " tokens"] })] }), _jsx(Text, { as: "pre", sx: {
|
|
150
66
|
fontSize: 0,
|
|
151
67
|
whiteSpace: 'pre-wrap',
|
|
152
68
|
wordBreak: 'break-word',
|
|
153
69
|
maxHeight: 200,
|
|
154
70
|
overflow: 'auto',
|
|
155
|
-
}, children: prompt.content })] }, idx)))) }), _jsx(CollapsibleSection, { title: "Tool Definitions", icon: TerminalIcon, count: contextData.tools.length, tokens: contextData.toolTokens, children: contextData.tools.length === 0 ? (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "No tools configured" })) : (contextData.tools.map((tool, idx) => (_jsx(ToolDetailView, { tool: tool }, idx)))) }), contextData.memoryBlocks.length > 0 && (_jsx(CollapsibleSection, { title: "Memory Blocks", icon: DatabaseIcon, count: contextData.memoryBlocks.length, tokens: contextData.memoryTokens, children: contextData.memoryBlocks.map((block, idx) => (_jsx(Box, { as: "pre", sx: {
|
|
156
|
-
p: 2,
|
|
157
|
-
mb: 2,
|
|
158
|
-
bg: 'canvas.inset',
|
|
159
|
-
borderRadius: 2,
|
|
160
|
-
fontSize: 0,
|
|
161
|
-
overflow: 'auto',
|
|
162
|
-
}, children: JSON.stringify(block, null, 2) }, idx))) })), Object.keys(contextData.toolEnvironment).length > 0 && (_jsx(CollapsibleSection, { title: "Tool Environment", icon: KeyIcon, count: Object.keys(contextData.toolEnvironment).length, children: _jsx(Box, { sx: { display: 'grid', gridTemplateColumns: '1fr 2fr', gap: 2 }, children: Object.entries(contextData.toolEnvironment).map(([key, value]) => (_jsxs(React.Fragment, { children: [_jsx(Text, { sx: {
|
|
71
|
+
}, children: prompt.content })] }, idx)))) }), _jsx(CollapsibleSection, { title: "Tool Definitions", icon: TerminalIcon, count: contextData.tools.length, tokens: contextData.toolTokens, children: contextData.tools.length === 0 ? (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "No tools configured" })) : (contextData.tools.map((tool, idx) => (_jsx(ToolDetailView, { tool: tool }, idx)))) }), contextData.memoryBlocks.length > 0 && (_jsx(CollapsibleSection, { title: "Memory Blocks", icon: DatabaseIcon, count: contextData.memoryBlocks.length, tokens: contextData.memoryTokens, children: contextData.memoryBlocks.map((block, idx) => (_jsx(Box, { as: "pre", p: 2, mb: 2, bg: "canvas.inset", borderRadius: 2, fontSize: 0, overflow: "auto", children: JSON.stringify(block, null, 2) }, idx))) })), Object.keys(contextData.toolEnvironment).length > 0 && (_jsx(CollapsibleSection, { title: "Tool Environment", icon: KeyIcon, count: Object.keys(contextData.toolEnvironment).length, children: _jsx(Box, { display: "grid", gridTemplateColumns: "1fr 2fr", gap: 2, children: Object.entries(contextData.toolEnvironment).map(([key, value]) => (_jsxs(React.Fragment, { children: [_jsx(Text, { sx: {
|
|
163
72
|
fontFamily: 'mono',
|
|
164
73
|
fontSize: 1,
|
|
165
74
|
fontWeight: 'semibold',
|
|
166
|
-
}, children: key }), _jsx(Text, { sx: { fontFamily: 'mono', fontSize: 1, color: 'fg.muted' }, children: value })] }, key))) }) })), contextData.toolRules.length > 0 && (_jsx(CollapsibleSection, { title: "Tool Rules", icon: CodeIcon, count: contextData.toolRules.length, children: contextData.toolRules.map((rule, idx) => (_jsx(Box, { as: "pre",
|
|
167
|
-
p: 2,
|
|
168
|
-
mb: 2,
|
|
169
|
-
bg: 'canvas.inset',
|
|
170
|
-
borderRadius: 2,
|
|
171
|
-
fontSize: 0,
|
|
172
|
-
overflow: 'auto',
|
|
173
|
-
}, children: JSON.stringify(rule, null, 2) }, idx))) }))] }));
|
|
75
|
+
}, children: key }), _jsx(Text, { sx: { fontFamily: 'mono', fontSize: 1, color: 'fg.muted' }, children: value })] }, key))) }) })), contextData.toolRules.length > 0 && (_jsx(CollapsibleSection, { title: "Tool Rules", icon: CodeIcon, count: contextData.toolRules.length, children: contextData.toolRules.map((rule, idx) => (_jsx(Box, { as: "pre", p: 2, mb: 2, bg: "canvas.inset", borderRadius: 2, fontSize: 0, overflow: "auto", children: JSON.stringify(rule, null, 2) }, idx))) }))] }));
|
|
174
76
|
}
|
|
175
77
|
export default ContextInspector;
|
|
@@ -303,16 +303,7 @@ export function ContextPanel({ agentId, apiBase, liveData, messageCount = 0, def
|
|
|
303
303
|
fontWeight: 'semibold',
|
|
304
304
|
mb: 2,
|
|
305
305
|
color: 'fg.muted',
|
|
306
|
-
}, children: "Context Usage" }), _jsxs(Box, { sx: {
|
|
307
|
-
p: 3,
|
|
308
|
-
bg: 'canvas.subtle',
|
|
309
|
-
borderRadius: 2,
|
|
310
|
-
border: '1px solid',
|
|
311
|
-
borderColor: 'border.default',
|
|
312
|
-
display: 'flex',
|
|
313
|
-
alignItems: 'center',
|
|
314
|
-
gap: 2,
|
|
315
|
-
}, children: [_jsx(Spinner, { size: "small" }), _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Loading context details..." })] })] }));
|
|
306
|
+
}, children: "Context Usage" }), _jsxs(Box, { p: 3, bg: "canvas.subtle", borderRadius: 2, border: "1px solid", borderColor: "border.default", display: "flex", alignItems: "center", gap: 2, children: [_jsx(Spinner, { size: "small" }), _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Loading context details..." })] })] }));
|
|
316
307
|
}
|
|
317
308
|
if (hasError || !snapshotData) {
|
|
318
309
|
return (_jsxs(Box, { children: [_jsx(Heading, { as: "h4", sx: {
|
|
@@ -320,86 +311,31 @@ export function ContextPanel({ agentId, apiBase, liveData, messageCount = 0, def
|
|
|
320
311
|
fontWeight: 'semibold',
|
|
321
312
|
mb: 2,
|
|
322
313
|
color: 'fg.muted',
|
|
323
|
-
}, children: "Context Usage" }), _jsx(Box, { sx: {
|
|
324
|
-
p: 3,
|
|
325
|
-
bg: 'attention.subtle',
|
|
326
|
-
borderRadius: 2,
|
|
327
|
-
border: '1px solid',
|
|
328
|
-
borderColor: 'attention.muted',
|
|
329
|
-
}, children: _jsx(Text, { sx: { fontSize: 1, color: 'attention.fg' }, children: "Waiting for context data from WebSocket stream..." }) })] }));
|
|
314
|
+
}, children: "Context Usage" }), _jsx(Box, { p: 3, bg: "attention.subtle", borderRadius: 2, border: "1px solid", borderColor: "attention.muted", children: _jsx(Text, { sx: { fontSize: 1, color: 'attention.fg' }, children: "Waiting for context data from WebSocket stream..." }) })] }));
|
|
330
315
|
}
|
|
331
316
|
const { totalTokens, contextWindow, sessionUsage, turnUsage, distribution } = snapshotData;
|
|
332
317
|
const sentMessageCount = messageCount > 0
|
|
333
318
|
? messageCount
|
|
334
319
|
: Math.max(sessionUsage?.turns ?? 0, snapshotData.perRequestUsage?.length > 0 ? 1 : 0);
|
|
335
320
|
const hasDistributionData = distribution?.children && distribution.children.length > 0;
|
|
336
|
-
return (_jsxs(Box, { children: [_jsxs(Box, { sx: {
|
|
337
|
-
display: 'flex',
|
|
338
|
-
justifyContent: 'space-between',
|
|
339
|
-
alignItems: 'center',
|
|
340
|
-
mb: 2,
|
|
341
|
-
}, children: [_jsx(Heading, { as: "h4", sx: {
|
|
321
|
+
return (_jsxs(Box, { children: [_jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2, children: [_jsx(Heading, { as: "h4", sx: {
|
|
342
322
|
fontSize: 1,
|
|
343
323
|
fontWeight: 'semibold',
|
|
344
324
|
color: 'fg.muted',
|
|
345
|
-
}, children: "Context Usage" }), _jsxs(Box, {
|
|
346
|
-
p: 3,
|
|
347
|
-
bg: 'canvas.subtle',
|
|
348
|
-
borderRadius: 2,
|
|
349
|
-
border: '1px solid',
|
|
350
|
-
borderColor: 'border.default',
|
|
351
|
-
}, children: [_jsx(Box, { sx: { mb: 3 }, children: _jsxs(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: ["Total usage: ", formatTokens(totalTokens)] }) }), (sessionUsage || turnUsage) && (_jsxs(Box, { sx: {
|
|
352
|
-
display: 'flex',
|
|
353
|
-
gap: 3,
|
|
354
|
-
mb: 3,
|
|
355
|
-
flexWrap: 'wrap',
|
|
356
|
-
}, children: [sessionUsage && (_jsxs(Box, { sx: {
|
|
357
|
-
flex: 1,
|
|
358
|
-
minWidth: 120,
|
|
359
|
-
p: 2,
|
|
360
|
-
bg: 'canvas.default',
|
|
361
|
-
borderRadius: 2,
|
|
362
|
-
border: '1px solid',
|
|
363
|
-
borderColor: 'border.muted',
|
|
364
|
-
}, children: [_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', display: 'block' }, children: ["Session (", sessionUsage.turns, " turns)"] }), _jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: formatTokens(sessionUsage.inputTokens + sessionUsage.outputTokens) }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [' ', "in ", formatDuration(sessionUsage.durationSeconds)] })] })), turnUsage && (_jsxs(Box, { sx: {
|
|
365
|
-
flex: 1,
|
|
366
|
-
minWidth: 120,
|
|
367
|
-
p: 2,
|
|
368
|
-
bg: 'canvas.default',
|
|
369
|
-
borderRadius: 2,
|
|
370
|
-
border: '1px solid',
|
|
371
|
-
borderColor: 'border.muted',
|
|
372
|
-
}, children: [_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', display: 'block' }, children: ["Last Turn (", turnUsage.requests, " reqs)"] }), _jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: formatTokens(turnUsage.inputTokens + turnUsage.outputTokens) }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [' ', "in ", formatDuration(turnUsage.durationSeconds)] })] }))] })), _jsxs(Box, { sx: {
|
|
373
|
-
display: 'flex',
|
|
374
|
-
justifyContent: 'space-between',
|
|
375
|
-
alignItems: 'center',
|
|
376
|
-
mb: 2,
|
|
377
|
-
}, children: [_jsxs(SegmentedControl, { "aria-label": "View mode", size: "small", onChange: index => {
|
|
325
|
+
}, children: "Context Usage" }), _jsxs(Box, { display: "flex", alignItems: "center", gap: 2, children: [sentMessageCount > 0 && (_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [sentMessageCount, ' ', sentMessageCount === 1 ? 'message sent' : 'messages sent'] })), _jsx(Button, { size: "small", variant: "invisible", leadingVisual: DownloadIcon, onClick: () => downloadContextUsageAsCSV(snapshotData), children: "Download" })] })] }), _jsxs(Box, { p: 3, bg: "canvas.subtle", borderRadius: 2, border: "1px solid", borderColor: "border.default", children: [_jsx(Box, { mb: 3, children: _jsxs(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: ["Total usage: ", formatTokens(totalTokens)] }) }), (sessionUsage || turnUsage) && (_jsxs(Box, { display: "flex", gap: 3, mb: 3, flexWrap: "wrap", children: [sessionUsage && (_jsxs(Box, { flex: 1, minWidth: 120, p: 2, bg: "canvas.default", borderRadius: 2, border: "1px solid", borderColor: "border.muted", children: [_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', display: 'block' }, children: ["Session (", sessionUsage.turns, " turns)"] }), _jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: formatTokens(sessionUsage.inputTokens + sessionUsage.outputTokens) }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [' ', "in ", formatDuration(sessionUsage.durationSeconds)] })] })), turnUsage && (_jsxs(Box, { flex: 1, minWidth: 120, p: 2, bg: "canvas.default", borderRadius: 2, border: "1px solid", borderColor: "border.muted", children: [_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', display: 'block' }, children: ["Last Turn (", turnUsage.requests, " reqs)"] }), _jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: formatTokens(turnUsage.inputTokens + turnUsage.outputTokens) }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [' ', "in ", formatDuration(turnUsage.durationSeconds)] })] }))] })), _jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2, children: [_jsxs(SegmentedControl, { "aria-label": "View mode", size: "small", onChange: index => {
|
|
378
326
|
const modes = ['overview', 'distribution', 'history'];
|
|
379
327
|
setViewMode(modes[index]);
|
|
380
|
-
}, children: [_jsx(SegmentedControl.IconButton, { "aria-label": "Overview", selected: viewMode === 'overview', icon: ListUnorderedIcon }), _jsx(SegmentedControl.IconButton, { "aria-label": "Distribution", selected: viewMode === 'distribution', icon: AppsIcon, disabled: !hasDistributionData }), _jsx(SegmentedControl.IconButton, { "aria-label": "History", selected: viewMode === 'history', icon: GraphIcon })] }), viewMode === 'overview' && (_jsx(Button, { size: "small", variant: "invisible", onClick: () => setShowDetails(!showDetails), children: showDetails ? 'Less' : 'More' }))] }), viewMode === 'overview' && (_jsxs(Box, { children: [_jsxs(Box, {
|
|
328
|
+
}, children: [_jsx(SegmentedControl.IconButton, { "aria-label": "Overview", selected: viewMode === 'overview', icon: ListUnorderedIcon }), _jsx(SegmentedControl.IconButton, { "aria-label": "Distribution", selected: viewMode === 'distribution', icon: AppsIcon, disabled: !hasDistributionData }), _jsx(SegmentedControl.IconButton, { "aria-label": "History", selected: viewMode === 'history', icon: GraphIcon })] }), viewMode === 'overview' && (_jsx(Button, { size: "small", variant: "invisible", onClick: () => setShowDetails(!showDetails), children: showDetails ? 'Less' : 'More' }))] }), viewMode === 'overview' && (_jsxs(Box, { children: [_jsxs(Box, { display: "flex", flexDirection: "column", gap: 2, children: [hasDistributionData &&
|
|
381
329
|
distribution.children.map(category => {
|
|
382
330
|
const CategoryIcon = getCategoryIcon(category.name);
|
|
383
331
|
const categoryPercent = (category.value / contextWindow) * 100;
|
|
384
|
-
return (_jsxs(Box, { sx: {
|
|
385
|
-
display: 'flex',
|
|
386
|
-
alignItems: 'center',
|
|
387
|
-
gap: 2,
|
|
388
|
-
}, children: [_jsx(Box, { sx: { color: 'fg.muted', width: 20 }, children: _jsx(CategoryIcon, { size: 16 }) }), _jsx(Text, { sx: { fontSize: 1, flex: 1 }, children: category.name }), _jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', minWidth: 60 }, children: formatTokens(category.value) }), _jsx(Box, { sx: { width: 80 }, children: _jsx(ProgressBar, { progress: categoryPercent, sx: { height: 4 } }) })] }, category.name));
|
|
332
|
+
return (_jsxs(Box, { display: "flex", alignItems: "center", gap: 2, children: [_jsx(Box, { color: "fg.muted", width: 20, children: _jsx(CategoryIcon, { size: 16 }) }), _jsx(Text, { sx: { fontSize: 1, flex: 1 }, children: category.name }), _jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', minWidth: 60 }, children: formatTokens(category.value) }), _jsx(Box, { width: 80, children: _jsx(ProgressBar, { progress: categoryPercent, sx: { height: 4 } }) })] }, category.name));
|
|
389
333
|
}), !hasDistributionData && (_jsx(Text, { sx: {
|
|
390
334
|
color: 'fg.muted',
|
|
391
335
|
fontSize: 1,
|
|
392
336
|
textAlign: 'center',
|
|
393
337
|
py: 2,
|
|
394
|
-
}, children: "No context data yet. Start a conversation to see usage." }))] }), showDetails && hasDistributionData && (_jsxs(Box, { sx: {
|
|
395
|
-
mt: 3,
|
|
396
|
-
p: 2,
|
|
397
|
-
bg: 'canvas.default',
|
|
398
|
-
borderRadius: 2,
|
|
399
|
-
border: '1px solid',
|
|
400
|
-
borderColor: 'border.muted',
|
|
401
|
-
fontSize: 0,
|
|
402
|
-
}, children: [snapshotData.systemPromptTokens > 0 && (_jsxs(Box, { sx: { mb: 2 }, children: [_jsxs(Text, { sx: { fontWeight: 'semibold' }, children: ["System Prompts:", ' ', formatTokens(snapshotData.systemPromptTokens), " tokens"] }), snapshotData.systemPrompts
|
|
338
|
+
}, children: "No context data yet. Start a conversation to see usage." }))] }), showDetails && hasDistributionData && (_jsxs(Box, { mt: 3, p: 2, bg: "canvas.default", borderRadius: 2, border: "1px solid", borderColor: "border.muted", fontSize: 0, children: [snapshotData.systemPromptTokens > 0 && (_jsxs(Box, { mb: 2, children: [_jsxs(Text, { sx: { fontWeight: 'semibold' }, children: ["System Prompts:", ' ', formatTokens(snapshotData.systemPromptTokens), " tokens"] }), snapshotData.systemPrompts
|
|
403
339
|
.slice(0, 2)
|
|
404
340
|
.map((prompt, idx) => (_jsxs(Text, { sx: {
|
|
405
341
|
display: 'block',
|
|
@@ -408,22 +344,11 @@ export function ContextPanel({ agentId, apiBase, liveData, messageCount = 0, def
|
|
|
408
344
|
color: 'fg.muted',
|
|
409
345
|
}, children: ["\u2022", ' ', prompt.length > 80
|
|
410
346
|
? prompt.slice(0, 80) + '...'
|
|
411
|
-
: prompt] }, idx)))] })), snapshotData.toolTokens > 0 && (_jsxs(Box, {
|
|
412
|
-
snapshotData.assistantMessageTokens > 0) && (_jsxs(Box, {
|
|
413
|
-
snapshotData.assistantMessageTokens), ' ', "tokens"] }), _jsxs(Box, {
|
|
414
|
-
mt: 2,
|
|
415
|
-
maxHeight: '150px',
|
|
416
|
-
overflowY: 'auto',
|
|
417
|
-
fontSize: 0,
|
|
418
|
-
}, children: snapshotData.perRequestUsage
|
|
347
|
+
: prompt] }, idx)))] })), snapshotData.toolTokens > 0 && (_jsxs(Box, { mb: 2, children: [_jsxs(Text, { sx: { fontWeight: 'semibold' }, children: ["Tools: ", formatTokens(snapshotData.toolTokens), " tokens (", snapshotData.tools.length, " tools)"] }), _jsxs(Box, { ml: 2, mt: 1, children: [snapshotData.tools.slice(0, 4).map((tool, idx) => (_jsxs(Text, { sx: { display: 'block', color: 'fg.muted' }, children: ["\u2022 ", tool.name, ": ", formatTokens(tool.totalTokens)] }, idx))), snapshotData.tools.length > 4 && (_jsxs(Text, { sx: { color: 'fg.muted', fontStyle: 'italic' }, children: ["...and ", snapshotData.tools.length - 4, " more"] }))] })] })), (snapshotData.userMessageTokens > 0 ||
|
|
348
|
+
snapshotData.assistantMessageTokens > 0) && (_jsxs(Box, { mb: 2, children: [_jsxs(Text, { sx: { fontWeight: 'semibold' }, children: ["Messages:", ' ', formatTokens(snapshotData.userMessageTokens +
|
|
349
|
+
snapshotData.assistantMessageTokens), ' ', "tokens"] }), _jsxs(Box, { ml: 2, mt: 1, children: [_jsxs(Text, { sx: { display: 'block', color: 'fg.muted' }, children: ["\u2022 User: ", formatTokens(snapshotData.userMessageTokens)] }), _jsxs(Text, { sx: { display: 'block', color: 'fg.muted' }, children: ["\u2022 Assistant:", ' ', formatTokens(snapshotData.assistantMessageTokens)] }), snapshotData.toolCallTokens > 0 && (_jsxs(Text, { sx: { display: 'block', color: 'fg.muted' }, children: ["\u2022 Tool calls:", ' ', formatTokens(snapshotData.toolCallTokens)] }))] })] }))] }))] })), viewMode === 'distribution' && treemapOption && (_jsx(ReactECharts, { option: treemapOption, style: { height: chartHeight }, opts: { renderer: 'svg' } })), viewMode === 'history' && historyChartOption && (_jsxs(Box, { children: [_jsx(ReactECharts, { option: historyChartOption, style: { height: chartHeight }, opts: { renderer: 'svg' } }), showDetails && snapshotData.perRequestUsage.length > 0 && (_jsx(Box, { mt: 2, maxHeight: "150px", overflowY: "auto", fontSize: 0, children: snapshotData.perRequestUsage
|
|
419
350
|
.slice(-10)
|
|
420
351
|
.reverse()
|
|
421
|
-
.map((req, idx) => (_jsxs(Box, { sx: {
|
|
422
|
-
display: 'flex',
|
|
423
|
-
gap: 2,
|
|
424
|
-
py: 1,
|
|
425
|
-
borderBottom: idx < 9 ? '1px solid' : 'none',
|
|
426
|
-
borderColor: 'border.muted',
|
|
427
|
-
}, children: [_jsxs(Text, { sx: { fontWeight: 'semibold', minWidth: 30 }, children: ["#", req.requestNum] }), _jsxs(Text, { sx: { color: '#3B82F6' }, children: ["\u2193", formatTokens(req.inputTokens)] }), _jsxs(Text, { sx: { color: '#10B981' }, children: ["\u2191", formatTokens(req.outputTokens)] }), req.toolNames.length > 0 && (_jsxs(Text, { sx: { color: 'fg.muted' }, children: ["\uD83D\uDD27 ", req.toolNames.join(', ')] }))] }, req.requestNum))) }))] })), viewMode === 'history' && !historyChartOption && (_jsx(Box, { sx: { py: 3 }, children: _jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "No history" }) }))] })] }));
|
|
352
|
+
.map((req, idx) => (_jsxs(Box, { display: "flex", gap: 2, py: 1, borderBottom: idx < 9 ? '1px solid' : 'none', borderColor: "border.muted", children: [_jsxs(Text, { sx: { fontWeight: 'semibold', minWidth: 30 }, children: ["#", req.requestNum] }), _jsxs(Text, { sx: { color: '#3B82F6' }, children: ["\u2193", formatTokens(req.inputTokens)] }), _jsxs(Text, { sx: { color: '#10B981' }, children: ["\u2191", formatTokens(req.outputTokens)] }), req.toolNames.length > 0 && (_jsxs(Text, { sx: { color: 'fg.muted' }, children: ["\uD83D\uDD27 ", req.toolNames.join(', ')] }))] }, req.requestNum))) }))] })), viewMode === 'history' && !historyChartOption && (_jsx(Box, { py: 3, children: _jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "No history" }) }))] })] }));
|
|
428
353
|
}
|
|
429
354
|
export default ContextPanel;
|
|
@@ -5,7 +5,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
* ContextUsage component - Shows context usage details with token breakdown.
|
|
6
6
|
*/
|
|
7
7
|
import { CommentDiscussionIcon, DatabaseIcon, FileIcon, ToolsIcon, ClockIcon, } from '@primer/octicons-react';
|
|
8
|
-
import { Box
|
|
8
|
+
import { Box } from '@datalayer/primer-addons';
|
|
9
|
+
import { Heading, Text, ProgressBar, Spinner } from '@primer/react';
|
|
9
10
|
import { useQuery } from '@tanstack/react-query';
|
|
10
11
|
function getLocalApiBase() {
|
|
11
12
|
if (typeof window === 'undefined') {
|
|
@@ -73,16 +74,7 @@ export function ContextUsage({ agentId, baseUrl }) {
|
|
|
73
74
|
fontWeight: 'semibold',
|
|
74
75
|
mb: 2,
|
|
75
76
|
color: 'fg.muted',
|
|
76
|
-
}, children: "Cumulative Context Usage" }), _jsxs(Box, { sx: {
|
|
77
|
-
p: 3,
|
|
78
|
-
bg: 'canvas.subtle',
|
|
79
|
-
borderRadius: 2,
|
|
80
|
-
border: '1px solid',
|
|
81
|
-
borderColor: 'border.default',
|
|
82
|
-
display: 'flex',
|
|
83
|
-
alignItems: 'center',
|
|
84
|
-
gap: 2,
|
|
85
|
-
}, children: [_jsx(Spinner, { size: "small" }), _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Loading context details..." })] })] }));
|
|
77
|
+
}, children: "Cumulative Context Usage" }), _jsxs(Box, { p: 3, bg: "canvas.subtle", borderRadius: 2, border: "1px solid", borderColor: "border.default", display: "flex", alignItems: "center", gap: 2, children: [_jsx(Spinner, { size: "small" }), _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Loading context details..." })] })] }));
|
|
86
78
|
}
|
|
87
79
|
if (error || !contextData) {
|
|
88
80
|
return (_jsxs(Box, { children: [_jsx(Heading, { as: "h4", sx: {
|
|
@@ -90,13 +82,7 @@ export function ContextUsage({ agentId, baseUrl }) {
|
|
|
90
82
|
fontWeight: 'semibold',
|
|
91
83
|
mb: 2,
|
|
92
84
|
color: 'fg.muted',
|
|
93
|
-
}, children: "Cumulative Context Usage" }), _jsx(Box, { sx: {
|
|
94
|
-
p: 3,
|
|
95
|
-
bg: 'canvas.subtle',
|
|
96
|
-
borderRadius: 2,
|
|
97
|
-
border: '1px solid',
|
|
98
|
-
borderColor: 'border.default',
|
|
99
|
-
}, children: _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Failed to load context details" }) })] }));
|
|
85
|
+
}, children: "Cumulative Context Usage" }), _jsx(Box, { p: 3, bg: "canvas.subtle", borderRadius: 2, border: "1px solid", borderColor: "border.default", children: _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Failed to load context details" }) })] }));
|
|
100
86
|
}
|
|
101
87
|
const contextUsagePercent = (contextData.usedTokens / contextData.totalTokens) * 100;
|
|
102
88
|
return (_jsxs(Box, { children: [_jsx(Heading, { as: "h4", sx: {
|
|
@@ -104,24 +90,10 @@ export function ContextUsage({ agentId, baseUrl }) {
|
|
|
104
90
|
fontWeight: 'semibold',
|
|
105
91
|
mb: 2,
|
|
106
92
|
color: 'fg.muted',
|
|
107
|
-
}, children: "Cumulative Context Usage" }), _jsxs(Box, { sx: {
|
|
108
|
-
p: 3,
|
|
109
|
-
bg: 'canvas.subtle',
|
|
110
|
-
borderRadius: 2,
|
|
111
|
-
border: '1px solid',
|
|
112
|
-
borderColor: 'border.default',
|
|
113
|
-
}, children: [_jsxs(Box, { sx: { mb: 3 }, children: [_jsxs(Box, { sx: {
|
|
114
|
-
display: 'flex',
|
|
115
|
-
justifyContent: 'space-between',
|
|
116
|
-
mb: 1,
|
|
117
|
-
}, children: [_jsxs(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: [formatTokens(contextData.usedTokens), " /", ' ', formatTokens(contextData.totalTokens), " tokens"] }), _jsxs(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: [contextUsagePercent.toFixed(0), "%"] })] }), _jsx(ProgressBar, { progress: contextUsagePercent, sx: { height: 8 }, bg: contextUsagePercent > 80 ? 'danger.emphasis' : 'accent.emphasis' })] }), _jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: contextData.children.map(category => {
|
|
93
|
+
}, children: "Cumulative Context Usage" }), _jsxs(Box, { p: 3, bg: "canvas.subtle", borderRadius: 2, border: "1px solid", borderColor: "border.default", children: [_jsxs(Box, { mb: 3, children: [_jsxs(Box, { display: "flex", justifyContent: "space-between", mb: 1, children: [_jsxs(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: [formatTokens(contextData.usedTokens), " /", ' ', formatTokens(contextData.totalTokens), " tokens"] }), _jsxs(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: [contextUsagePercent.toFixed(0), "%"] })] }), _jsx(ProgressBar, { progress: contextUsagePercent, sx: { height: 8 }, bg: contextUsagePercent > 80 ? 'danger.emphasis' : 'accent.emphasis' })] }), _jsx(Box, { display: "flex", flexDirection: "column", gap: 2, children: contextData.children.map(category => {
|
|
118
94
|
const CategoryIcon = getCategoryIcon(category.name);
|
|
119
95
|
const categoryPercent = (category.value / contextData.totalTokens) * 100;
|
|
120
|
-
return (_jsxs(Box, { sx: {
|
|
121
|
-
display: 'flex',
|
|
122
|
-
alignItems: 'center',
|
|
123
|
-
gap: 2,
|
|
124
|
-
}, children: [_jsx(Box, { sx: { color: 'fg.muted', width: 20 }, children: _jsx(CategoryIcon, { size: 16 }) }), _jsx(Text, { sx: { fontSize: 1, flex: 1 }, children: category.name }), _jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', minWidth: 60 }, children: formatTokens(category.value) }), _jsx(Box, { sx: { width: 80 }, children: _jsx(ProgressBar, { progress: categoryPercent, sx: { height: 4 } }) })] }, category.name));
|
|
96
|
+
return (_jsxs(Box, { display: "flex", alignItems: "center", gap: 2, children: [_jsx(Box, { color: "fg.muted", width: 20, children: _jsx(CategoryIcon, { size: 16 }) }), _jsx(Text, { sx: { fontSize: 1, flex: 1 }, children: category.name }), _jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', minWidth: 60 }, children: formatTokens(category.value) }), _jsx(Box, { width: 80, children: _jsx(ProgressBar, { progress: categoryPercent, sx: { height: 4 } }) })] }, category.name));
|
|
125
97
|
}) })] })] }));
|
|
126
98
|
}
|
|
127
99
|
export default ContextUsage;
|
|
@@ -11,7 +11,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
*
|
|
12
12
|
* @module components/context/CostTracker
|
|
13
13
|
*/
|
|
14
|
-
import { Box
|
|
14
|
+
import { Box } from '@datalayer/primer-addons';
|
|
15
|
+
import { Heading, Text, ProgressBar, Flash, Label } from '@primer/react';
|
|
15
16
|
import { CreditCardIcon, AlertIcon } from '@primer/octicons-react';
|
|
16
17
|
function formatUsd(amount) {
|
|
17
18
|
if (amount < 0.01)
|
|
@@ -33,7 +34,7 @@ function formatTokens(tokens) {
|
|
|
33
34
|
export function CostTracker({ agentId: _agentId, compact = false, liveData, }) {
|
|
34
35
|
const costData = liveData;
|
|
35
36
|
if (!costData) {
|
|
36
|
-
return (_jsx(Box, {
|
|
37
|
+
return (_jsx(Box, { p: 2, children: _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Waiting for websocket snapshot..." }) }));
|
|
37
38
|
}
|
|
38
39
|
const cumulativePercent = costData.cumulativeBudgetUsd != null && costData.cumulativeBudgetUsd > 0
|
|
39
40
|
? (costData.cumulativeCostUsd / costData.cumulativeBudgetUsd) * 100
|
|
@@ -49,54 +50,18 @@ export function CostTracker({ agentId: _agentId, compact = false, liveData, }) {
|
|
|
49
50
|
const displayUsd = (amount) => hasUnresolvedPricing && amount === 0 ? '…' : formatUsd(amount);
|
|
50
51
|
// Compact: single row summary
|
|
51
52
|
if (compact) {
|
|
52
|
-
return (_jsxs(Box, { sx: {
|
|
53
|
-
display: 'flex',
|
|
54
|
-
alignItems: 'center',
|
|
55
|
-
gap: 2,
|
|
56
|
-
px: 2,
|
|
57
|
-
py: 1,
|
|
58
|
-
}, children: [_jsx(CreditCardIcon, { size: 14 }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: ["Cumulative: ", displayUsd(costData.cumulativeCostUsd), costData.cumulativeBudgetUsd != null &&
|
|
53
|
+
return (_jsxs(Box, { display: "flex", alignItems: "center", gap: 2, px: 2, py: 1, children: [_jsx(CreditCardIcon, { size: 14 }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: ["Cumulative: ", displayUsd(costData.cumulativeCostUsd), costData.cumulativeBudgetUsd != null &&
|
|
59
54
|
` (budget ${formatUsd(costData.cumulativeBudgetUsd)})`, ' | ', "Last turn: ", displayUsd(lastTurnCostUsd), costData.perRunBudgetUsd != null &&
|
|
60
55
|
` (budget ${formatUsd(costData.perRunBudgetUsd)})`] }), isOverBudget && (_jsx(Label, { variant: "danger", size: "small", children: "Over budget" })), !isOverBudget && isNearBudget && (_jsx(Label, { variant: "attention", size: "small", children: "Near limit" }))] }));
|
|
61
56
|
}
|
|
62
57
|
// Full display
|
|
63
|
-
return (_jsxs(Box, { children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, fontWeight: 'semibold', mb: 2, color: 'fg.muted' }, children: "Cost Tracker" }), isOverBudget && (_jsxs(Flash, { variant: "danger", sx: { mb: 2 }, children: [_jsx(AlertIcon, { size: 16 }), "Cumulative cost (", formatUsd(costData.cumulativeCostUsd), ") exceeds budget (", formatUsd(costData.cumulativeBudgetUsd), ")."] })), hasUnresolvedPricing && costData.requestCount > 0 && (_jsxs(Flash, { variant: "warning", sx: { mb: 2 }, children: [_jsx(AlertIcon, { size: 16 }), "Some model pricing could not be resolved yet, so cost may remain at \u2026 even when requests/tokens are increasing."] })), _jsxs(Box, { sx: {
|
|
64
|
-
p: 3,
|
|
65
|
-
bg: 'canvas.subtle',
|
|
66
|
-
borderRadius: 2,
|
|
67
|
-
border: '1px solid',
|
|
68
|
-
borderColor: 'border.default',
|
|
69
|
-
}, children: [_jsxs(Box, { sx: { mb: 3 }, children: [_jsxs(Box, { sx: {
|
|
70
|
-
display: 'flex',
|
|
71
|
-
justifyContent: 'space-between',
|
|
72
|
-
mb: 1,
|
|
73
|
-
}, children: [_jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: "Cumulative" }), _jsxs(Text, { sx: { fontSize: 1 }, children: [displayUsd(costData.cumulativeCostUsd), costData.cumulativeBudgetUsd != null &&
|
|
58
|
+
return (_jsxs(Box, { children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, fontWeight: 'semibold', mb: 2, color: 'fg.muted' }, children: "Cost Tracker" }), isOverBudget && (_jsxs(Flash, { variant: "danger", sx: { mb: 2 }, children: [_jsx(AlertIcon, { size: 16 }), "Cumulative cost (", formatUsd(costData.cumulativeCostUsd), ") exceeds budget (", formatUsd(costData.cumulativeBudgetUsd), ")."] })), hasUnresolvedPricing && costData.requestCount > 0 && (_jsxs(Flash, { variant: "warning", sx: { mb: 2 }, children: [_jsx(AlertIcon, { size: 16 }), "Some model pricing could not be resolved yet, so cost may remain at \u2026 even when requests/tokens are increasing."] })), _jsxs(Box, { p: 3, bg: "canvas.subtle", borderRadius: 2, border: "1px solid", borderColor: "border.default", children: [_jsxs(Box, { mb: 3, children: [_jsxs(Box, { display: "flex", justifyContent: "space-between", mb: 1, children: [_jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: "Cumulative" }), _jsxs(Text, { sx: { fontSize: 1 }, children: [displayUsd(costData.cumulativeCostUsd), costData.cumulativeBudgetUsd != null &&
|
|
74
59
|
` (budget ${formatUsd(costData.cumulativeBudgetUsd)})`] })] }), cumulativePercent != null && (_jsx(ProgressBar, { progress: Math.min(cumulativePercent, 100), sx: { height: 6 }, bg: cumulativePercent > 100
|
|
75
60
|
? 'danger.emphasis'
|
|
76
61
|
: cumulativePercent > 80
|
|
77
62
|
? 'attention.emphasis'
|
|
78
|
-
: 'accent.emphasis' }))] }), _jsxs(Box, {
|
|
79
|
-
|
|
80
|
-
justifyContent: 'space-between',
|
|
81
|
-
mb: 1,
|
|
82
|
-
}, children: [_jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: "Last turn" }), _jsxs(Text, { sx: { fontSize: 1 }, children: [displayUsd(lastTurnCostUsd), costData.perRunBudgetUsd != null &&
|
|
83
|
-
` (budget ${formatUsd(costData.perRunBudgetUsd)})`] })] }), lastTurnPercent != null && (_jsx(ProgressBar, { progress: Math.min(lastTurnPercent, 100), sx: { height: 6 }, bg: lastTurnPercent > 80 ? 'danger.emphasis' : 'accent.emphasis' }))] }), _jsxs(Box, { sx: {
|
|
84
|
-
display: 'flex',
|
|
85
|
-
gap: 3,
|
|
86
|
-
borderTop: '1px solid',
|
|
87
|
-
borderColor: 'border.default',
|
|
88
|
-
pt: 2,
|
|
89
|
-
}, children: [_jsxs(Box, { children: [_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', display: 'block' }, children: "Requests" }), _jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: costData.requestCount })] }), _jsxs(Box, { children: [_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', display: 'block' }, children: "Tokens" }), _jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: formatTokens(costData.totalTokensUsed) })] })] }), costData.modelBreakdown.length > 0 && (_jsxs(Box, { sx: {
|
|
90
|
-
mt: 2,
|
|
91
|
-
pt: 2,
|
|
92
|
-
borderTop: '1px solid',
|
|
93
|
-
borderColor: 'border.default',
|
|
94
|
-
}, children: [_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', display: 'block', mb: 1 }, children: "By model" }), costData.modelBreakdown.map(m => (_jsxs(Box, { sx: {
|
|
95
|
-
display: 'flex',
|
|
96
|
-
justifyContent: 'space-between',
|
|
97
|
-
alignItems: 'center',
|
|
98
|
-
py: '2px',
|
|
99
|
-
}, children: [_jsx(Text, { sx: { fontSize: 0 }, children: m.model }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [displayUsd(m.costUsd), " (", m.requests, " req)", hasUnresolvedPricing && m.costUsd === 0
|
|
63
|
+
: 'accent.emphasis' }))] }), _jsxs(Box, { mb: 3, children: [_jsxs(Box, { display: "flex", justifyContent: "space-between", mb: 1, children: [_jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: "Last turn" }), _jsxs(Text, { sx: { fontSize: 1 }, children: [displayUsd(lastTurnCostUsd), costData.perRunBudgetUsd != null &&
|
|
64
|
+
` (budget ${formatUsd(costData.perRunBudgetUsd)})`] })] }), lastTurnPercent != null && (_jsx(ProgressBar, { progress: Math.min(lastTurnPercent, 100), sx: { height: 6 }, bg: lastTurnPercent > 80 ? 'danger.emphasis' : 'accent.emphasis' }))] }), _jsxs(Box, { display: "flex", gap: 3, borderTop: "1px solid", borderColor: "border.default", pt: 2, children: [_jsxs(Box, { children: [_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', display: 'block' }, children: "Requests" }), _jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: costData.requestCount })] }), _jsxs(Box, { children: [_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', display: 'block' }, children: "Tokens" }), _jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: formatTokens(costData.totalTokensUsed) })] })] }), costData.modelBreakdown.length > 0 && (_jsxs(Box, { mt: 2, pt: 2, borderTop: "1px solid", borderColor: "border.default", children: [_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', display: 'block', mb: 1 }, children: "By model" }), costData.modelBreakdown.map(m => (_jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "center", py: "2px", children: [_jsx(Text, { sx: { fontSize: 0 }, children: m.model }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [displayUsd(m.costUsd), " (", m.requests, " req)", hasUnresolvedPricing && m.costUsd === 0
|
|
100
65
|
? ' - pricing pending'
|
|
101
66
|
: ''] })] }, m.model)))] }))] })] }));
|
|
102
67
|
}
|
|
@@ -48,26 +48,12 @@ export function MessageDetailView({ message }) {
|
|
|
48
48
|
role: chatRole,
|
|
49
49
|
parts: [{ type: 'text', text }],
|
|
50
50
|
};
|
|
51
|
-
return (_jsxs(Box, { sx: {
|
|
52
|
-
p: 2,
|
|
53
|
-
mb: 1,
|
|
54
|
-
bg: message.inContext ? 'canvas.default' : 'canvas.inset',
|
|
55
|
-
border: '1px solid',
|
|
56
|
-
borderColor: message.inContext ? 'border.default' : 'border.muted',
|
|
57
|
-
borderRadius: 2,
|
|
58
|
-
opacity: message.inContext ? 1 : 0.7,
|
|
59
|
-
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2, mb: 1 }, children: [_jsx(RoleIcon, { size: 14 }), _jsx(Text, { sx: {
|
|
51
|
+
return (_jsxs(Box, { p: 2, mb: 1, bg: message.inContext ? 'canvas.default' : 'canvas.inset', border: "1px solid", borderColor: message.inContext ? 'border.default' : 'border.muted', borderRadius: 2, opacity: message.inContext ? 1 : 0.7, children: [_jsxs(Box, { display: "flex", alignItems: "center", gap: 2, mb: 1, children: [_jsx(RoleIcon, { size: 14 }), _jsx(Text, { sx: {
|
|
60
52
|
fontWeight: 'semibold',
|
|
61
53
|
fontSize: 0,
|
|
62
54
|
color: roleColors[message.role] || 'fg.default',
|
|
63
55
|
textTransform: 'capitalize',
|
|
64
|
-
}, children: message.role }), message.toolName && (_jsx(Label, { size: "small", variant: "secondary", children: message.toolName })), message.isToolCall && (_jsx(Label, { size: "small", variant: "accent", children: "call" })), message.isToolResult && (_jsx(Label, { size: "small", variant: "success", children: "result" })), message.inContext ? (_jsx(CheckCircleIcon, { size: 12, fill: "var(--fgColor-success)" })) : (_jsx(XCircleIcon, { size: 12, fill: "var(--fgColor-muted)" })), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', ml: 'auto' }, children: [formatTokens(message.estimatedTokens), " tokens"] })] }), _jsx(Box, {
|
|
65
|
-
borderWidth: '2px',
|
|
66
|
-
borderStyle: 'solid',
|
|
67
|
-
borderColor: 'border.default',
|
|
68
|
-
borderRadius: 2,
|
|
69
|
-
overflow: 'hidden',
|
|
70
|
-
}, children: _jsx(TextPart, { text: text, message: uiMessage, isLastPart: false, onRegenerate: () => {
|
|
56
|
+
}, children: message.role }), message.toolName && (_jsx(Label, { size: "small", variant: "secondary", children: message.toolName })), message.isToolCall && (_jsx(Label, { size: "small", variant: "accent", children: "call" })), message.isToolResult && (_jsx(Label, { size: "small", variant: "success", children: "result" })), message.inContext ? (_jsx(CheckCircleIcon, { size: 12, fill: "var(--fgColor-success)" })) : (_jsx(XCircleIcon, { size: 12, fill: "var(--fgColor-muted)" })), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', ml: 'auto' }, children: [formatTokens(message.estimatedTokens), " tokens"] })] }), _jsx(Box, { borderWidth: "2px", borderStyle: "solid", borderColor: "border.default", borderRadius: 2, overflow: "hidden", children: _jsx(TextPart, { text: text, message: uiMessage, isLastPart: false, onRegenerate: () => {
|
|
71
57
|
return;
|
|
72
58
|
} }) })] }));
|
|
73
59
|
}
|
|
@@ -92,27 +78,7 @@ export function MessageHistory({ messages }) {
|
|
|
92
78
|
}
|
|
93
79
|
return messages.reduce((sum, message) => sum + (message.estimatedTokens || 0), 0);
|
|
94
80
|
}, [messages]);
|
|
95
|
-
return (_jsxs(Box, {
|
|
96
|
-
display: 'flex',
|
|
97
|
-
alignItems: 'center',
|
|
98
|
-
gap: 2,
|
|
99
|
-
width: '100%',
|
|
100
|
-
p: 2,
|
|
101
|
-
bg: 'canvas.subtle',
|
|
102
|
-
border: '1px solid',
|
|
103
|
-
borderColor: 'border.default',
|
|
104
|
-
borderRadius: 2,
|
|
105
|
-
cursor: 'pointer',
|
|
106
|
-
'&:hover': {
|
|
107
|
-
bg: 'canvas.inset',
|
|
108
|
-
},
|
|
109
|
-
}, children: [expanded ? (_jsx(ChevronDownIcon, { size: 16 })) : (_jsx(ChevronRightIcon, { size: 16 })), _jsx(CommentDiscussionIcon, { size: 16 }), _jsx(Text, { sx: { fontWeight: 'semibold', flex: 1, textAlign: 'left' }, children: "Message History" }), _jsx(Label, { variant: "secondary", size: "small", children: messages?.length || 0 }), messageHistoryTokens > 0 && (_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [formatTokens(messageHistoryTokens), " tokens"] }))] }), expanded && (_jsx(Box, { sx: {
|
|
110
|
-
border: '1px solid',
|
|
111
|
-
borderColor: 'border.default',
|
|
112
|
-
borderTop: 'none',
|
|
113
|
-
borderRadius: '0 0 6px 6px',
|
|
114
|
-
p: 2,
|
|
115
|
-
}, children: !messages || messages.length === 0 ? (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "No messages yet" })) : (_jsxs(_Fragment, { children: [outOfContextMessages.length > 0 && (_jsxs(Box, { sx: { mb: 3 }, children: [_jsxs(Text, { sx: {
|
|
81
|
+
return (_jsxs(Box, { mb: 2, children: [_jsxs(Box, { as: "button", onClick: () => setExpanded(!expanded), display: "flex", alignItems: "center", gap: 2, width: "100%", p: 2, bg: "canvas.subtle", border: "1px solid", borderColor: "border.default", borderRadius: 2, cursor: "pointer", hover: { bg: 'canvas.inset' }, children: [expanded ? (_jsx(ChevronDownIcon, { size: 16 })) : (_jsx(ChevronRightIcon, { size: 16 })), _jsx(CommentDiscussionIcon, { size: 16 }), _jsx(Text, { sx: { fontWeight: 'semibold', flex: 1, textAlign: 'left' }, children: "Message History" }), _jsx(Label, { variant: "secondary", size: "small", children: messages?.length || 0 }), messageHistoryTokens > 0 && (_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [formatTokens(messageHistoryTokens), " tokens"] }))] }), expanded && (_jsx(Box, { border: "1px solid", borderColor: "border.default", borderTop: "none", borderRadius: "0 0 6px 6px", p: 2, children: !messages || messages.length === 0 ? (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "No messages yet" })) : (_jsxs(_Fragment, { children: [outOfContextMessages.length > 0 && (_jsxs(Box, { mb: 3, children: [_jsxs(Text, { sx: {
|
|
116
82
|
fontWeight: 'semibold',
|
|
117
83
|
fontSize: 1,
|
|
118
84
|
color: 'fg.muted',
|