@flanksource/clicky-ui 0.3.24 → 0.3.26
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/NOTICE.md +1 -0
- package/dist/ai.cjs +4 -0
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.js +6 -2
- package/dist/ai.js.map +1 -1
- package/dist/chat.cjs +8 -0
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.js +9 -1
- package/dist/chat.js.map +1 -1
- package/dist/comments/CommentCard.cjs +89 -14
- package/dist/comments/CommentCard.cjs.map +1 -1
- package/dist/comments/CommentCard.d.ts.map +1 -1
- package/dist/comments/CommentCard.js +90 -15
- package/dist/comments/CommentCard.js.map +1 -1
- package/dist/comments/CommentComposer.cjs +25 -2
- package/dist/comments/CommentComposer.cjs.map +1 -1
- package/dist/comments/CommentComposer.d.ts.map +1 -1
- package/dist/comments/CommentComposer.js +25 -2
- package/dist/comments/CommentComposer.js.map +1 -1
- package/dist/comments/CommentProvider.cjs +21 -14
- package/dist/comments/CommentProvider.cjs.map +1 -1
- package/dist/comments/CommentProvider.d.ts +1 -1
- package/dist/comments/CommentProvider.d.ts.map +1 -1
- package/dist/comments/CommentProvider.js +21 -14
- package/dist/comments/CommentProvider.js.map +1 -1
- package/dist/comments/CommentSidePanel.cjs +1 -1
- package/dist/comments/CommentSidePanel.cjs.map +1 -1
- package/dist/comments/CommentSidePanel.js +1 -1
- package/dist/comments/CommentSidePanel.js.map +1 -1
- package/dist/comments/comment-types.cjs.map +1 -1
- package/dist/comments/comment-types.d.ts +6 -0
- package/dist/comments/comment-types.d.ts.map +1 -1
- package/dist/comments/comment-types.js.map +1 -1
- package/dist/components/DimensionField.cjs +56 -0
- package/dist/components/DimensionField.cjs.map +1 -0
- package/dist/components/DimensionField.d.ts +17 -0
- package/dist/components/DimensionField.d.ts.map +1 -0
- package/dist/components/DimensionField.js +56 -0
- package/dist/components/DimensionField.js.map +1 -0
- package/dist/components.cjs +4 -0
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.ts +2 -0
- package/dist/components.d.ts.map +1 -1
- package/dist/components.js +4 -0
- package/dist/components.js.map +1 -1
- package/dist/data/Clicky.cjs +4 -5
- package/dist/data/Clicky.cjs.map +1 -1
- package/dist/data/Clicky.d.ts.map +1 -1
- package/dist/data/Clicky.js +4 -5
- package/dist/data/Clicky.js.map +1 -1
- package/dist/data/TaskExecDetails.cjs +8 -3
- package/dist/data/TaskExecDetails.cjs.map +1 -1
- package/dist/data/TaskExecDetails.d.ts +4 -0
- package/dist/data/TaskExecDetails.d.ts.map +1 -1
- package/dist/data/TaskExecDetails.js +9 -4
- package/dist/data/TaskExecDetails.js.map +1 -1
- package/dist/data/TaskManagerButton.cjs +101 -7
- package/dist/data/TaskManagerButton.cjs.map +1 -1
- package/dist/data/TaskManagerButton.d.ts +6 -1
- package/dist/data/TaskManagerButton.d.ts.map +1 -1
- package/dist/data/TaskManagerButton.js +103 -9
- package/dist/data/TaskManagerButton.js.map +1 -1
- package/dist/data/TaskProcessDetails.cjs +2 -0
- package/dist/data/TaskProcessDetails.cjs.map +1 -1
- package/dist/data/TaskProcessDetails.d.ts.map +1 -1
- package/dist/data/TaskProcessDetails.js +2 -0
- package/dist/data/TaskProcessDetails.js.map +1 -1
- package/dist/data/TaskProgress.cjs +14 -4
- package/dist/data/TaskProgress.cjs.map +1 -1
- package/dist/data/TaskProgress.js +14 -4
- package/dist/data/TaskProgress.js.map +1 -1
- package/dist/data/TaskSnapshot.cjs.map +1 -1
- package/dist/data/TaskSnapshot.d.ts +1 -0
- package/dist/data/TaskSnapshot.d.ts.map +1 -1
- package/dist/data/TaskSnapshot.js.map +1 -1
- package/dist/data/ai/ChatWindow.cjs +18 -23
- package/dist/data/ai/ChatWindow.cjs.map +1 -1
- package/dist/data/ai/ChatWindow.d.ts +1 -1
- package/dist/data/ai/ChatWindow.d.ts.map +1 -1
- package/dist/data/ai/ChatWindow.js +19 -24
- package/dist/data/ai/ChatWindow.js.map +1 -1
- package/dist/data/ai/ChatWindow.preferences.cjs +12 -21
- package/dist/data/ai/ChatWindow.preferences.cjs.map +1 -1
- package/dist/data/ai/ChatWindow.preferences.d.ts +3 -2
- package/dist/data/ai/ChatWindow.preferences.d.ts.map +1 -1
- package/dist/data/ai/ChatWindow.preferences.js +12 -21
- package/dist/data/ai/ChatWindow.preferences.js.map +1 -1
- package/dist/data/ai/ChatWindow.tool-catalog.cjs +21 -38
- package/dist/data/ai/ChatWindow.tool-catalog.cjs.map +1 -1
- package/dist/data/ai/ChatWindow.tool-catalog.d.ts +5 -5
- package/dist/data/ai/ChatWindow.tool-catalog.d.ts.map +1 -1
- package/dist/data/ai/ChatWindow.tool-catalog.js +21 -38
- package/dist/data/ai/ChatWindow.tool-catalog.js.map +1 -1
- package/dist/data/ai/ChatWindow.types.d.ts +2 -2
- package/dist/data/ai/ChatWindow.types.d.ts.map +1 -1
- package/dist/data/ai/ChatWindowManager.cjs +2 -2
- package/dist/data/ai/ChatWindowManager.cjs.map +1 -1
- package/dist/data/ai/ChatWindowManager.js +2 -2
- package/dist/data/ai/ChatWindowManager.js.map +1 -1
- package/dist/data/ai/ChatWindowRequestBody.cjs +4 -2
- package/dist/data/ai/ChatWindowRequestBody.cjs.map +1 -1
- package/dist/data/ai/ChatWindowRequestBody.d.ts +15 -3
- package/dist/data/ai/ChatWindowRequestBody.d.ts.map +1 -1
- package/dist/data/ai/ChatWindowRequestBody.js +4 -2
- package/dist/data/ai/ChatWindowRequestBody.js.map +1 -1
- package/dist/data/ai/ToolPreferences.cjs +5 -5
- package/dist/data/ai/ToolPreferences.cjs.map +1 -1
- package/dist/data/ai/ToolPreferences.d.ts +6 -5
- package/dist/data/ai/ToolPreferences.d.ts.map +1 -1
- package/dist/data/ai/ToolPreferences.js +5 -5
- package/dist/data/ai/ToolPreferences.js.map +1 -1
- package/dist/data/ai/ToolPreferences.model.cjs +61 -37
- package/dist/data/ai/ToolPreferences.model.cjs.map +1 -1
- package/dist/data/ai/ToolPreferences.model.d.ts +32 -13
- package/dist/data/ai/ToolPreferences.model.d.ts.map +1 -1
- package/dist/data/ai/ToolPreferences.model.js +62 -38
- package/dist/data/ai/ToolPreferences.model.js.map +1 -1
- package/dist/data/ai/ToolPreferencesList.cjs +17 -20
- package/dist/data/ai/ToolPreferencesList.cjs.map +1 -1
- package/dist/data/ai/ToolPreferencesList.d.ts +16 -7
- package/dist/data/ai/ToolPreferencesList.d.ts.map +1 -1
- package/dist/data/ai/ToolPreferencesList.js +18 -21
- package/dist/data/ai/ToolPreferencesList.js.map +1 -1
- package/dist/data/ai/chat-window-context.cjs +1 -1
- package/dist/data/ai/chat-window-context.cjs.map +1 -1
- package/dist/data/ai/chat-window-context.d.ts +7 -7
- package/dist/data/ai/chat-window-context.d.ts.map +1 -1
- package/dist/data/ai/chat-window-context.js +1 -1
- package/dist/data/ai/chat-window-context.js.map +1 -1
- package/dist/data/ai/index.d.ts +3 -1
- package/dist/data/ai/index.d.ts.map +1 -1
- package/dist/data/chat/Chat.cjs +8 -4
- package/dist/data/chat/Chat.cjs.map +1 -1
- package/dist/data/chat/Chat.d.ts.map +1 -1
- package/dist/data/chat/Chat.js +8 -4
- package/dist/data/chat/Chat.js.map +1 -1
- package/dist/data/chat/ChatRuntimeToolbar.cjs +11 -7
- package/dist/data/chat/ChatRuntimeToolbar.cjs.map +1 -1
- package/dist/data/chat/ChatRuntimeToolbar.d.ts.map +1 -1
- package/dist/data/chat/ChatRuntimeToolbar.js +11 -7
- package/dist/data/chat/ChatRuntimeToolbar.js.map +1 -1
- package/dist/data/chat/ContextMeter.cjs +64 -27
- package/dist/data/chat/ContextMeter.cjs.map +1 -1
- package/dist/data/chat/ContextMeter.d.ts +11 -4
- package/dist/data/chat/ContextMeter.d.ts.map +1 -1
- package/dist/data/chat/ContextMeter.js +64 -27
- package/dist/data/chat/ContextMeter.js.map +1 -1
- package/dist/data/chat/clickyOperationsToTools.cjs +2 -1
- package/dist/data/chat/clickyOperationsToTools.cjs.map +1 -1
- package/dist/data/chat/clickyOperationsToTools.d.ts.map +1 -1
- package/dist/data/chat/clickyOperationsToTools.js +2 -1
- package/dist/data/chat/clickyOperationsToTools.js.map +1 -1
- package/dist/data/chat/index.d.ts +2 -1
- package/dist/data/chat/index.d.ts.map +1 -1
- package/dist/data/chat/tool-policy.cjs +132 -0
- package/dist/data/chat/tool-policy.cjs.map +1 -0
- package/dist/data/chat/tool-policy.d.ts +81 -0
- package/dist/data/chat/tool-policy.d.ts.map +1 -0
- package/dist/data/chat/tool-policy.js +132 -0
- package/dist/data/chat/tool-policy.js.map +1 -0
- package/dist/data/chat/types.cjs +20 -0
- package/dist/data/chat/types.cjs.map +1 -1
- package/dist/data/chat/types.d.ts +41 -2
- package/dist/data/chat/types.d.ts.map +1 -1
- package/dist/data/chat/types.js +20 -0
- package/dist/data/chat/types.js.map +1 -1
- package/dist/data/chat/usage-snapshot.cjs +10 -1
- package/dist/data/chat/usage-snapshot.cjs.map +1 -1
- package/dist/data/chat/usage-snapshot.d.ts.map +1 -1
- package/dist/data/chat/usage-snapshot.js +10 -1
- package/dist/data/chat/usage-snapshot.js.map +1 -1
- package/dist/data/debugConsoleSignal.cjs +64 -0
- package/dist/data/debugConsoleSignal.cjs.map +1 -0
- package/dist/data/debugConsoleSignal.d.ts +83 -0
- package/dist/data/debugConsoleSignal.d.ts.map +1 -0
- package/dist/data/debugConsoleSignal.js +64 -0
- package/dist/data/debugConsoleSignal.js.map +1 -0
- package/dist/data/har/HarPanel.cjs +20 -14
- package/dist/data/har/HarPanel.cjs.map +1 -1
- package/dist/data/har/HarPanel.d.ts.map +1 -1
- package/dist/data/har/HarPanel.js +20 -14
- package/dist/data/har/HarPanel.js.map +1 -1
- package/dist/data/har/types.d.ts +18 -0
- package/dist/data/har/types.d.ts.map +1 -1
- package/dist/data/query-browser/QueryBrowser.cjs +4 -42
- package/dist/data/query-browser/QueryBrowser.cjs.map +1 -1
- package/dist/data/query-browser/QueryBrowser.d.ts.map +1 -1
- package/dist/data/query-browser/QueryBrowser.js +5 -43
- package/dist/data/query-browser/QueryBrowser.js.map +1 -1
- package/dist/data/query-browser/QueryBrowser.types.cjs.map +1 -1
- package/dist/data/query-browser/QueryBrowser.types.d.ts +0 -1
- package/dist/data/query-browser/QueryBrowser.types.d.ts.map +1 -1
- package/dist/data/query-browser/QueryBrowser.types.js.map +1 -1
- package/dist/data/useDebugAction.cjs +29 -0
- package/dist/data/useDebugAction.cjs.map +1 -0
- package/dist/data/useDebugAction.d.ts +16 -0
- package/dist/data/useDebugAction.d.ts.map +1 -0
- package/dist/data/useDebugAction.js +29 -0
- package/dist/data/useDebugAction.js.map +1 -0
- package/dist/data/version-info.cjs +3 -3
- package/dist/data/version-info.js +3 -3
- package/dist/data.cjs +16 -8
- package/dist/data.cjs.map +1 -1
- package/dist/data.d.ts +3 -2
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +16 -8
- package/dist/devtools/DebugConsole.cjs +138 -0
- package/dist/devtools/DebugConsole.cjs.map +1 -0
- package/dist/devtools/DebugConsole.d.ts +23 -0
- package/dist/devtools/DebugConsole.d.ts.map +1 -0
- package/dist/devtools/DebugConsole.js +138 -0
- package/dist/devtools/DebugConsole.js.map +1 -0
- package/dist/devtools/DebugConsoleButton.cjs +59 -0
- package/dist/devtools/DebugConsoleButton.cjs.map +1 -0
- package/dist/devtools/DebugConsoleButton.d.ts +20 -0
- package/dist/devtools/DebugConsoleButton.d.ts.map +1 -0
- package/dist/devtools/DebugConsoleButton.js +59 -0
- package/dist/devtools/DebugConsoleButton.js.map +1 -0
- package/dist/devtools/DebugConsoleDock.cjs +112 -0
- package/dist/devtools/DebugConsoleDock.cjs.map +1 -0
- package/dist/devtools/DebugConsoleDock.d.ts +26 -0
- package/dist/devtools/DebugConsoleDock.d.ts.map +1 -0
- package/dist/devtools/DebugConsoleDock.js +112 -0
- package/dist/devtools/DebugConsoleDock.js.map +1 -0
- package/dist/devtools/ExecutionDetail.cjs +135 -0
- package/dist/devtools/ExecutionDetail.cjs.map +1 -0
- package/dist/devtools/ExecutionDetail.d.ts +19 -0
- package/dist/devtools/ExecutionDetail.d.ts.map +1 -0
- package/dist/devtools/ExecutionDetail.js +135 -0
- package/dist/devtools/ExecutionDetail.js.map +1 -0
- package/dist/devtools/debugClient.cjs +172 -0
- package/dist/devtools/debugClient.cjs.map +1 -0
- package/dist/devtools/debugClient.d.ts +98 -0
- package/dist/devtools/debugClient.d.ts.map +1 -0
- package/dist/devtools/debugClient.js +172 -0
- package/dist/devtools/debugClient.js.map +1 -0
- package/dist/devtools/debugStore.cjs +115 -0
- package/dist/devtools/debugStore.cjs.map +1 -0
- package/dist/devtools/debugStore.d.ts +83 -0
- package/dist/devtools/debugStore.d.ts.map +1 -0
- package/dist/devtools/debugStore.js +115 -0
- package/dist/devtools/debugStore.js.map +1 -0
- package/dist/devtools/dockState.cjs +51 -0
- package/dist/devtools/dockState.cjs.map +1 -0
- package/dist/devtools/dockState.d.ts +31 -0
- package/dist/devtools/dockState.d.ts.map +1 -0
- package/dist/devtools/dockState.js +51 -0
- package/dist/devtools/dockState.js.map +1 -0
- package/dist/devtools/tabs/ConsoleTab.cjs +36 -0
- package/dist/devtools/tabs/ConsoleTab.cjs.map +1 -0
- package/dist/devtools/tabs/ConsoleTab.d.ts +19 -0
- package/dist/devtools/tabs/ConsoleTab.d.ts.map +1 -0
- package/dist/devtools/tabs/ConsoleTab.js +36 -0
- package/dist/devtools/tabs/ConsoleTab.js.map +1 -0
- package/dist/devtools/tabs/InspectionCaches.cjs +150 -0
- package/dist/devtools/tabs/InspectionCaches.cjs.map +1 -0
- package/dist/devtools/tabs/InspectionCaches.d.ts +23 -0
- package/dist/devtools/tabs/InspectionCaches.d.ts.map +1 -0
- package/dist/devtools/tabs/InspectionCaches.js +150 -0
- package/dist/devtools/tabs/InspectionCaches.js.map +1 -0
- package/dist/devtools/tabs/InspectionTab.cjs +316 -0
- package/dist/devtools/tabs/InspectionTab.cjs.map +1 -0
- package/dist/devtools/tabs/InspectionTab.d.ts +27 -0
- package/dist/devtools/tabs/InspectionTab.d.ts.map +1 -0
- package/dist/devtools/tabs/InspectionTab.js +316 -0
- package/dist/devtools/tabs/InspectionTab.js.map +1 -0
- package/dist/devtools/tabs/NetworkTab.cjs +91 -0
- package/dist/devtools/tabs/NetworkTab.cjs.map +1 -0
- package/dist/devtools/tabs/NetworkTab.d.ts +20 -0
- package/dist/devtools/tabs/NetworkTab.d.ts.map +1 -0
- package/dist/devtools/tabs/NetworkTab.js +91 -0
- package/dist/devtools/tabs/NetworkTab.js.map +1 -0
- package/dist/devtools/tabs/QueriesTab.cjs +85 -0
- package/dist/devtools/tabs/QueriesTab.cjs.map +1 -0
- package/dist/devtools/tabs/QueriesTab.d.ts +24 -0
- package/dist/devtools/tabs/QueriesTab.d.ts.map +1 -0
- package/dist/devtools/tabs/QueriesTab.js +85 -0
- package/dist/devtools/tabs/QueriesTab.js.map +1 -0
- package/dist/devtools/types.cjs +26 -0
- package/dist/devtools/types.cjs.map +1 -0
- package/dist/devtools/types.d.ts +235 -0
- package/dist/devtools/types.d.ts.map +1 -0
- package/dist/devtools/types.js +26 -0
- package/dist/devtools/types.js.map +1 -0
- package/dist/devtools/useDebugStream.cjs +46 -0
- package/dist/devtools/useDebugStream.cjs.map +1 -0
- package/dist/devtools/useDebugStream.d.ts +23 -0
- package/dist/devtools/useDebugStream.d.ts.map +1 -0
- package/dist/devtools/useDebugStream.js +46 -0
- package/dist/devtools/useDebugStream.js.map +1 -0
- package/dist/devtools.cjs +51 -0
- package/dist/devtools.cjs.map +1 -0
- package/dist/devtools.d.ts +37 -0
- package/dist/devtools.d.ts.map +1 -0
- package/dist/devtools.js +51 -0
- package/dist/devtools.js.map +1 -0
- package/dist/icons/components/UiOpenScad.cjs +10 -0
- package/dist/icons/components/UiOpenScad.cjs.map +1 -0
- package/dist/icons/components/UiOpenScad.d.ts +9 -0
- package/dist/icons/components/UiOpenScad.d.ts.map +1 -0
- package/dist/icons/components/UiOpenScad.js +10 -0
- package/dist/icons/components/UiOpenScad.js.map +1 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.d.ts.map +1 -1
- package/dist/icons/registry.cjs +2 -0
- package/dist/icons/registry.cjs.map +1 -1
- package/dist/icons/registry.d.ts.map +1 -1
- package/dist/icons/registry.js +2 -0
- package/dist/icons/registry.js.map +1 -1
- package/dist/icons.cjs +2 -0
- package/dist/icons.cjs.map +1 -1
- package/dist/icons.js +2 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.cjs +20 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -8
- package/dist/index.js.map +1 -1
- package/dist/layout/AppShell.cjs +15 -10
- package/dist/layout/AppShell.cjs.map +1 -1
- package/dist/layout/AppShell.d.ts +11 -0
- package/dist/layout/AppShell.d.ts.map +1 -1
- package/dist/layout/AppShell.js +15 -10
- package/dist/layout/AppShell.js.map +1 -1
- package/dist/layout/AppShell.nav.cjs +170 -49
- package/dist/layout/AppShell.nav.cjs.map +1 -1
- package/dist/layout/AppShell.nav.d.ts.map +1 -1
- package/dist/layout/AppShell.nav.js +170 -49
- package/dist/layout/AppShell.nav.js.map +1 -1
- package/dist/overlay/CellActions.cjs +18 -124
- package/dist/overlay/CellActions.cjs.map +1 -1
- package/dist/overlay/CellActions.d.ts +1 -1
- package/dist/overlay/CellActions.d.ts.map +1 -1
- package/dist/overlay/CellActions.js +18 -124
- package/dist/overlay/CellActions.js.map +1 -1
- package/dist/overlay/ContextMenu.cjs +144 -0
- package/dist/overlay/ContextMenu.cjs.map +1 -0
- package/dist/overlay/ContextMenu.d.ts +8 -0
- package/dist/overlay/ContextMenu.d.ts.map +1 -0
- package/dist/overlay/ContextMenu.js +144 -0
- package/dist/overlay/ContextMenu.js.map +1 -0
- package/dist/profiles/connections/connectionBrowserModel.cjs +14 -65
- package/dist/profiles/connections/connectionBrowserModel.cjs.map +1 -1
- package/dist/profiles/connections/connectionBrowserModel.d.ts +35 -35
- package/dist/profiles/connections/connectionBrowserModel.d.ts.map +1 -1
- package/dist/profiles/connections/connectionBrowserModel.js +14 -65
- package/dist/profiles/connections/connectionBrowserModel.js.map +1 -1
- package/dist/profiles/connections/connectionQueryWorkspace.cjs +29 -9
- package/dist/profiles/connections/connectionQueryWorkspace.cjs.map +1 -1
- package/dist/profiles/connections/connectionQueryWorkspace.d.ts +3 -2
- package/dist/profiles/connections/connectionQueryWorkspace.d.ts.map +1 -1
- package/dist/profiles/connections/connectionQueryWorkspace.js +30 -10
- package/dist/profiles/connections/connectionQueryWorkspace.js.map +1 -1
- package/dist/profiles/connections/connectionQueryWorkspaceModel.cjs +15 -0
- package/dist/profiles/connections/connectionQueryWorkspaceModel.cjs.map +1 -1
- package/dist/profiles/connections/connectionQueryWorkspaceModel.d.ts +22 -1
- package/dist/profiles/connections/connectionQueryWorkspaceModel.d.ts.map +1 -1
- package/dist/profiles/connections/connectionQueryWorkspaceModel.js +15 -0
- package/dist/profiles/connections/connectionQueryWorkspaceModel.js.map +1 -1
- package/dist/profiles/connections/index.d.ts +1 -0
- package/dist/profiles/connections/index.d.ts.map +1 -1
- package/dist/profiles/connections/inspectionStatus.cjs +44 -0
- package/dist/profiles/connections/inspectionStatus.cjs.map +1 -0
- package/dist/profiles/connections/inspectionStatus.d.ts +5 -0
- package/dist/profiles/connections/inspectionStatus.d.ts.map +1 -0
- package/dist/profiles/connections/inspectionStatus.js +44 -0
- package/dist/profiles/connections/inspectionStatus.js.map +1 -0
- package/dist/profiles/connections/useInspection.cjs +123 -0
- package/dist/profiles/connections/useInspection.cjs.map +1 -0
- package/dist/profiles/connections/useInspection.d.ts +35 -0
- package/dist/profiles/connections/useInspection.d.ts.map +1 -0
- package/dist/profiles/connections/useInspection.js +123 -0
- package/dist/profiles/connections/useInspection.js.map +1 -0
- package/dist/profiles/editor/profileBuilderWorkspace.cjs +55 -23
- package/dist/profiles/editor/profileBuilderWorkspace.cjs.map +1 -1
- package/dist/profiles/editor/profileBuilderWorkspace.d.ts.map +1 -1
- package/dist/profiles/editor/profileBuilderWorkspace.js +56 -24
- package/dist/profiles/editor/profileBuilderWorkspace.js.map +1 -1
- package/dist/profiles/elasticsearch/esQueryBuilder.cjs +12 -3
- package/dist/profiles/elasticsearch/esQueryBuilder.cjs.map +1 -1
- package/dist/profiles/elasticsearch/esQueryBuilder.d.ts +2 -2
- package/dist/profiles/elasticsearch/esQueryBuilder.d.ts.map +1 -1
- package/dist/profiles/elasticsearch/esQueryBuilder.js +12 -3
- package/dist/profiles/elasticsearch/esQueryBuilder.js.map +1 -1
- package/dist/profiles/fields/profileFieldEditor.cjs +137 -22
- package/dist/profiles/fields/profileFieldEditor.cjs.map +1 -1
- package/dist/profiles/fields/profileFieldEditor.d.ts.map +1 -1
- package/dist/profiles/fields/profileFieldEditor.js +137 -22
- package/dist/profiles/fields/profileFieldEditor.js.map +1 -1
- package/dist/profiles/fields/profileFieldFilterEditor.cjs +171 -82
- package/dist/profiles/fields/profileFieldFilterEditor.cjs.map +1 -1
- package/dist/profiles/fields/profileFieldFilterEditor.d.ts +0 -9
- package/dist/profiles/fields/profileFieldFilterEditor.d.ts.map +1 -1
- package/dist/profiles/fields/profileFieldFilterEditor.js +174 -85
- package/dist/profiles/fields/profileFieldFilterEditor.js.map +1 -1
- package/dist/profiles/fields/profileFieldIcons.cjs +6 -3
- package/dist/profiles/fields/profileFieldIcons.cjs.map +1 -1
- package/dist/profiles/fields/profileFieldIcons.js +6 -3
- package/dist/profiles/fields/profileFieldIcons.js.map +1 -1
- package/dist/profiles/query/profileSampleFilterLookup.cjs +34 -0
- package/dist/profiles/query/profileSampleFilterLookup.cjs.map +1 -0
- package/dist/profiles/query/profileSampleFilterLookup.d.ts +12 -0
- package/dist/profiles/query/profileSampleFilterLookup.d.ts.map +1 -0
- package/dist/profiles/query/profileSampleFilterLookup.js +34 -0
- package/dist/profiles/query/profileSampleFilterLookup.js.map +1 -0
- package/dist/profiles/query/profileSamplePayload.cjs +6 -4
- package/dist/profiles/query/profileSamplePayload.cjs.map +1 -1
- package/dist/profiles/query/profileSamplePayload.d.ts +11 -4
- package/dist/profiles/query/profileSamplePayload.d.ts.map +1 -1
- package/dist/profiles/query/profileSamplePayload.js +6 -4
- package/dist/profiles/query/profileSamplePayload.js.map +1 -1
- package/dist/profiles/query/profileSampleResult.cjs +26 -0
- package/dist/profiles/query/profileSampleResult.cjs.map +1 -0
- package/dist/profiles/query/profileSampleResult.d.ts +11 -0
- package/dist/profiles/query/profileSampleResult.d.ts.map +1 -0
- package/dist/profiles/query/profileSampleResult.js +26 -0
- package/dist/profiles/query/profileSampleResult.js.map +1 -0
- package/dist/profiles/query/queryTargetPicker.cjs +5 -3
- package/dist/profiles/query/queryTargetPicker.cjs.map +1 -1
- package/dist/profiles/query/queryTargetPicker.d.ts +3 -2
- package/dist/profiles/query/queryTargetPicker.d.ts.map +1 -1
- package/dist/profiles/query/queryTargetPicker.js +5 -3
- package/dist/profiles/query/queryTargetPicker.js.map +1 -1
- package/dist/profiles/wizard/profileWizard.cjs +14 -5
- package/dist/profiles/wizard/profileWizard.cjs.map +1 -1
- package/dist/profiles/wizard/profileWizard.d.ts.map +1 -1
- package/dist/profiles/wizard/profileWizard.js +15 -6
- package/dist/profiles/wizard/profileWizard.js.map +1 -1
- package/dist/profiles/wizard/profileWizardModel.cjs +35 -6
- package/dist/profiles/wizard/profileWizardModel.cjs.map +1 -1
- package/dist/profiles/wizard/profileWizardModel.d.ts +29 -4
- package/dist/profiles/wizard/profileWizardModel.d.ts.map +1 -1
- package/dist/profiles/wizard/profileWizardModel.js +35 -6
- package/dist/profiles/wizard/profileWizardModel.js.map +1 -1
- package/dist/profiles/wizard/profileWizardQueryStep.cjs +44 -11
- package/dist/profiles/wizard/profileWizardQueryStep.cjs.map +1 -1
- package/dist/profiles/wizard/profileWizardQueryStep.d.ts.map +1 -1
- package/dist/profiles/wizard/profileWizardQueryStep.js +46 -13
- package/dist/profiles/wizard/profileWizardQueryStep.js.map +1 -1
- package/dist/profiles/wizard/profileWizardSteps.cjs +33 -2
- package/dist/profiles/wizard/profileWizardSteps.cjs.map +1 -1
- package/dist/profiles/wizard/profileWizardSteps.d.ts +11 -2
- package/dist/profiles/wizard/profileWizardSteps.d.ts.map +1 -1
- package/dist/profiles/wizard/profileWizardSteps.js +33 -2
- package/dist/profiles/wizard/profileWizardSteps.js.map +1 -1
- package/dist/profiles.cjs +8 -2
- package/dist/profiles.cjs.map +1 -1
- package/dist/profiles.js +10 -4
- package/dist/profiles.js.map +1 -1
- package/dist/rpc/FilterForm.cjs +21 -237
- package/dist/rpc/FilterForm.cjs.map +1 -1
- package/dist/rpc/FilterForm.d.ts +3 -1
- package/dist/rpc/FilterForm.d.ts.map +1 -1
- package/dist/rpc/FilterForm.js +21 -237
- package/dist/rpc/FilterForm.js.map +1 -1
- package/dist/rpc/FilterFormFields.cjs +240 -0
- package/dist/rpc/FilterFormFields.cjs.map +1 -0
- package/dist/rpc/FilterFormFields.d.ts +12 -0
- package/dist/rpc/FilterFormFields.d.ts.map +1 -0
- package/dist/rpc/FilterFormFields.js +240 -0
- package/dist/rpc/FilterFormFields.js.map +1 -0
- package/dist/rpc/router.cjs +3 -2
- package/dist/rpc/router.cjs.map +1 -1
- package/dist/rpc/router.d.ts.map +1 -1
- package/dist/rpc/router.js +3 -2
- package/dist/rpc/router.js.map +1 -1
- package/dist/rpc/types.cjs.map +1 -1
- package/dist/rpc/types.d.ts +3 -1
- package/dist/rpc/types.d.ts.map +1 -1
- package/dist/rpc/types.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +6 -1
- package/dist/data/query-info/QueryInfoDialog.cjs +0 -106
- package/dist/data/query-info/QueryInfoDialog.cjs.map +0 -1
- package/dist/data/query-info/QueryInfoDialog.d.ts +0 -16
- package/dist/data/query-info/QueryInfoDialog.d.ts.map +0 -1
- package/dist/data/query-info/QueryInfoDialog.js +0 -106
- package/dist/data/query-info/QueryInfoDialog.js.map +0 -1
- package/dist/data/query-info/index.d.ts +0 -4
- package/dist/data/query-info/index.d.ts.map +0 -1
- package/dist/data/query-info/queryInfo.cjs +0 -42
- package/dist/data/query-info/queryInfo.cjs.map +0 -1
- package/dist/data/query-info/queryInfo.d.ts +0 -45
- package/dist/data/query-info/queryInfo.d.ts.map +0 -1
- package/dist/data/query-info/queryInfo.js +0 -42
- package/dist/data/query-info/queryInfo.js.map +0 -1
- package/dist/data/query-info/useQueryInfo.cjs +0 -48
- package/dist/data/query-info/useQueryInfo.cjs.map +0 -1
- package/dist/data/query-info/useQueryInfo.d.ts +0 -26
- package/dist/data/query-info/useQueryInfo.d.ts.map +0 -1
- package/dist/data/query-info/useQueryInfo.js +0 -48
- package/dist/data/query-info/useQueryInfo.js.map +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { normalizeToolPolicy } from "./types.js";
|
|
2
|
+
const MATCH_FACETS = [
|
|
3
|
+
"name",
|
|
4
|
+
"group",
|
|
5
|
+
"parent",
|
|
6
|
+
"entity",
|
|
7
|
+
"action",
|
|
8
|
+
"verb",
|
|
9
|
+
"method",
|
|
10
|
+
"scope"
|
|
11
|
+
];
|
|
12
|
+
function matchItems(item, patterns) {
|
|
13
|
+
const normalized = normalizePatterns(patterns);
|
|
14
|
+
if (normalized.length === 0) return true;
|
|
15
|
+
const sorted = [...normalized].sort(
|
|
16
|
+
(a, b) => exclusionRank(a) - exclusionRank(b)
|
|
17
|
+
);
|
|
18
|
+
for (const pattern of sorted) {
|
|
19
|
+
if (pattern.startsWith("!")) {
|
|
20
|
+
if (matchPattern(item, pattern.slice(1))) return false;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (matchPattern(item, pattern)) return true;
|
|
24
|
+
}
|
|
25
|
+
return sorted.every((pattern) => pattern.startsWith("!"));
|
|
26
|
+
}
|
|
27
|
+
function normalizePatterns(patterns) {
|
|
28
|
+
if (patterns === void 0) return [];
|
|
29
|
+
const list = typeof patterns === "string" ? [patterns] : patterns;
|
|
30
|
+
const out = [];
|
|
31
|
+
for (const raw of list) {
|
|
32
|
+
if (typeof raw !== "string") continue;
|
|
33
|
+
const parts = raw.split(",");
|
|
34
|
+
for (const part of parts) {
|
|
35
|
+
const trimmed = part.trim();
|
|
36
|
+
if (trimmed === "" && parts.length > 1) continue;
|
|
37
|
+
if (trimmed !== "") out.push(trimmed);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
function exclusionRank(pattern) {
|
|
43
|
+
if (pattern === "!*") return 0;
|
|
44
|
+
return pattern.startsWith("!") ? 1 : 2;
|
|
45
|
+
}
|
|
46
|
+
function matchPattern(item, pattern) {
|
|
47
|
+
if (pattern === "*") return true;
|
|
48
|
+
const value = item.toLowerCase();
|
|
49
|
+
const glob = pattern.toLowerCase();
|
|
50
|
+
if (value === glob) return true;
|
|
51
|
+
if (glob.startsWith("*") && glob.endsWith("*")) {
|
|
52
|
+
if (value.includes(glob.slice(1, -1))) return true;
|
|
53
|
+
}
|
|
54
|
+
if (glob.startsWith("*") && value.endsWith(glob.slice(1))) return true;
|
|
55
|
+
if (glob.endsWith("*") && value.startsWith(glob.slice(0, -1))) return true;
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
function resolveToolPolicy(policy, tool) {
|
|
59
|
+
let resolved;
|
|
60
|
+
for (const rule of policy ?? []) {
|
|
61
|
+
if (matchesTool(rule, tool)) resolved = rule.policy;
|
|
62
|
+
}
|
|
63
|
+
return resolved;
|
|
64
|
+
}
|
|
65
|
+
function matchesTool(match, tool) {
|
|
66
|
+
var _a, _b, _c;
|
|
67
|
+
const facets = {
|
|
68
|
+
name: tool.name ?? "",
|
|
69
|
+
group: tool.group ?? "",
|
|
70
|
+
parent: tool.parent ?? "",
|
|
71
|
+
entity: tool.entity ?? "",
|
|
72
|
+
action: tool.action ?? "",
|
|
73
|
+
verb: tool.verb ?? "",
|
|
74
|
+
method: tool.method ?? "",
|
|
75
|
+
scope: tool.scope ?? ""
|
|
76
|
+
};
|
|
77
|
+
for (const facet of MATCH_FACETS) {
|
|
78
|
+
if (!matchItems(facets[facet], match[facet])) return false;
|
|
79
|
+
}
|
|
80
|
+
return matchesHint(match.readOnly, (_a = tool.annotations) == null ? void 0 : _a.readOnlyHint) && matchesHint(match.destructive, (_b = tool.annotations) == null ? void 0 : _b.destructiveHint) && matchesHint(match.idempotent, (_c = tool.annotations) == null ? void 0 : _c.idempotentHint);
|
|
81
|
+
}
|
|
82
|
+
function matchesHint(want, have) {
|
|
83
|
+
if (want === void 0) return true;
|
|
84
|
+
return have !== void 0 && have === want;
|
|
85
|
+
}
|
|
86
|
+
function toolPolicyFromPreferences(prefs) {
|
|
87
|
+
const keys = Object.keys(prefs ?? {}).filter((key) => key.trim() !== "").sort();
|
|
88
|
+
if (keys.length === 0) return [];
|
|
89
|
+
const policies = /* @__PURE__ */ new Map();
|
|
90
|
+
for (const key of keys) {
|
|
91
|
+
const policy = normalizeToolPolicy(prefs == null ? void 0 : prefs[key]);
|
|
92
|
+
if (policy) policies.set(key, policy);
|
|
93
|
+
}
|
|
94
|
+
const ordered = [...policies.keys()];
|
|
95
|
+
return [
|
|
96
|
+
...ordered.map((key) => ({ group: key, policy: policies.get(key) })),
|
|
97
|
+
...ordered.map((key) => ({ name: key, policy: policies.get(key) }))
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
function appendToolPolicy(earlier, later) {
|
|
101
|
+
return [...earlier ?? [], ...later ?? []];
|
|
102
|
+
}
|
|
103
|
+
function normalizeToolPolicyRules(value) {
|
|
104
|
+
if (!Array.isArray(value)) return [];
|
|
105
|
+
const rules = [];
|
|
106
|
+
for (const raw of value) {
|
|
107
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
|
|
108
|
+
const item = raw;
|
|
109
|
+
const policy = normalizeToolPolicy(item.policy);
|
|
110
|
+
if (!policy) continue;
|
|
111
|
+
const match = {};
|
|
112
|
+
for (const facet of MATCH_FACETS) {
|
|
113
|
+
const patterns = normalizePatterns(item[facet]);
|
|
114
|
+
if (patterns.length > 0) match[facet] = patterns;
|
|
115
|
+
}
|
|
116
|
+
for (const hint of ["readOnly", "destructive", "idempotent"]) {
|
|
117
|
+
if (typeof item[hint] === "boolean") match[hint] = item[hint];
|
|
118
|
+
}
|
|
119
|
+
if (Object.keys(match).length === 0) continue;
|
|
120
|
+
rules.push({ ...match, policy });
|
|
121
|
+
}
|
|
122
|
+
return rules;
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
appendToolPolicy,
|
|
126
|
+
matchItems,
|
|
127
|
+
matchesTool,
|
|
128
|
+
normalizeToolPolicyRules,
|
|
129
|
+
resolveToolPolicy,
|
|
130
|
+
toolPolicyFromPreferences
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=tool-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-policy.js","sources":["../../../src/data/chat/tool-policy.ts"],"sourcesContent":["import type { ToolMeta, ToolPolicy } from \"./types\";\nimport { normalizeToolPolicy } from \"./types\";\n\n/** The client half of Captain's ordered tool-permission policy.\n *\n * A tool's authority is decided by an ordered rule list evaluated\n * last-match-wins: weakest rule first, strongest last. The layers this file\n * composes are the surface's rules (what the page the chat opened on declares)\n * followed by the user's own (what they toggled in the preferences popover), so\n * a toggle beats the surface and the surface beats the application's baseline —\n * which the server appends underneath both.\n *\n * The matching is a port of Go's `commons/collections.MatchItems`, and it is a\n * port rather than a re-interpretation on purpose: the same rule list is\n * evaluated on both sides of the wire — here to render what a tool will do, and\n * on the server to enforce it — and a client that disagreed would show a state\n * the request does not produce. */\n\n/** A glob pattern list. A bare string is one pattern, so a rule can be written\n * `{ group: \"provider.xero.*\" }` without list ceremony. */\nexport type MatchPatterns = string | string[];\n\n/** Which tools a rule applies to. Every declared facet must match (AND across\n * facets); within one facet the patterns are alternatives (OR). An undeclared\n * facet does not constrain. */\nexport type ToolMatch = {\n name?: MatchPatterns;\n group?: MatchPatterns;\n parent?: MatchPatterns;\n entity?: MatchPatterns;\n action?: MatchPatterns;\n verb?: MatchPatterns;\n method?: MatchPatterns;\n scope?: MatchPatterns;\n /** A declared hint requires the tool to declare the same hint with the same\n * value. An undeclared hint on the tool does NOT match: \"this tool never said\n * whether it is read-only\" and \"this tool said it is not\" are different\n * claims, and reading the first as the second is how an unannotated tool\n * would inherit a permissive rule. */\n readOnly?: boolean;\n destructive?: boolean;\n idempotent?: boolean;\n};\n\n/** One ordered rule: the tools it selects and the authority they get. */\nexport type PermissionRule = ToolMatch & { policy: ToolPolicy };\n\n/** The ordered rule list, evaluated last-match-wins. */\nexport type PermissionPolicy = PermissionRule[];\n\nconst MATCH_FACETS = [\n \"name\",\n \"group\",\n \"parent\",\n \"entity\",\n \"action\",\n \"verb\",\n \"method\",\n \"scope\",\n] as const;\n\n/** Reports whether `item` satisfies these patterns, following MatchItems:\n * `!` negates and takes precedence over any positive match, `*` wildcards a\n * prefix, suffix or the whole item, matching is case-insensitive, and one\n * string may carry comma-separated alternatives. An empty list matches\n * everything — an undeclared facet imposes no constraint. */\nexport function matchItems(\n item: string,\n patterns: MatchPatterns | undefined,\n): boolean {\n const normalized = normalizePatterns(patterns);\n if (normalized.length === 0) return true;\n // Exclusions are checked first so `!` wins however the rule was written:\n // [\"a*\", \"!abc\"] must reject \"abc\" rather than accept it on the wildcard.\n const sorted = [...normalized].sort(\n (a, b) => exclusionRank(a) - exclusionRank(b),\n );\n for (const pattern of sorted) {\n if (pattern.startsWith(\"!\")) {\n if (matchPattern(item, pattern.slice(1))) return false;\n continue;\n }\n if (matchPattern(item, pattern)) return true;\n }\n // Every pattern excluded and none of them matched, so the item is admitted.\n return sorted.every((pattern) => pattern.startsWith(\"!\"));\n}\n\nfunction normalizePatterns(patterns: MatchPatterns | undefined): string[] {\n if (patterns === undefined) return [];\n const list = typeof patterns === \"string\" ? [patterns] : patterns;\n const out: string[] = [];\n for (const raw of list) {\n if (typeof raw !== \"string\") continue;\n const parts = raw.split(\",\");\n for (const part of parts) {\n const trimmed = part.trim();\n if (trimmed === \"\" && parts.length > 1) continue;\n if (trimmed !== \"\") out.push(trimmed);\n }\n }\n return out;\n}\n\nfunction exclusionRank(pattern: string): number {\n if (pattern === \"!*\") return 0;\n return pattern.startsWith(\"!\") ? 1 : 2;\n}\n\nfunction matchPattern(item: string, pattern: string): boolean {\n if (pattern === \"*\") return true;\n const value = item.toLowerCase();\n const glob = pattern.toLowerCase();\n if (value === glob) return true;\n if (glob.startsWith(\"*\") && glob.endsWith(\"*\")) {\n if (value.includes(glob.slice(1, -1))) return true;\n }\n if (glob.startsWith(\"*\") && value.endsWith(glob.slice(1))) return true;\n if (glob.endsWith(\"*\") && value.startsWith(glob.slice(0, -1))) return true;\n return false;\n}\n\n/** Resolves the authority for one tool: the policy of the LAST rule that\n * matches it, or undefined when no rule does.\n *\n * Last, not first, because the list runs weakest to strongest — a user rule\n * appended after a surface rule is meant to win. A first-match-wins reading\n * would invert the whole contract. */\nexport function resolveToolPolicy(\n policy: PermissionPolicy | undefined,\n tool: ToolMeta,\n): ToolPolicy | undefined {\n let resolved: ToolPolicy | undefined;\n for (const rule of policy ?? []) {\n if (matchesTool(rule, tool)) resolved = rule.policy;\n }\n return resolved;\n}\n\nexport function matchesTool(match: ToolMatch, tool: ToolMeta): boolean {\n const facets: Record<(typeof MATCH_FACETS)[number], string> = {\n name: tool.name ?? \"\",\n group: tool.group ?? \"\",\n parent: tool.parent ?? \"\",\n entity: tool.entity ?? \"\",\n action: tool.action ?? \"\",\n verb: tool.verb ?? \"\",\n method: tool.method ?? \"\",\n scope: tool.scope ?? \"\",\n };\n for (const facet of MATCH_FACETS) {\n if (!matchItems(facets[facet], match[facet])) return false;\n }\n return (\n matchesHint(match.readOnly, tool.annotations?.readOnlyHint) &&\n matchesHint(match.destructive, tool.annotations?.destructiveHint) &&\n matchesHint(match.idempotent, tool.annotations?.idempotentHint)\n );\n}\n\nfunction matchesHint(want: boolean | undefined, have: boolean | undefined) {\n if (want === undefined) return true;\n return have !== undefined && have === want;\n}\n\n/** Lowers a flat tool→policy map into ordered rules, so the legacy shape and the\n * rule list share one evaluation path instead of two that can disagree.\n *\n * A key is ambiguous — it may name a tool or its group — so each key emits both\n * a group rule and a name rule, with every group rule placed before every name\n * rule. A key that names a group matches no tool name and vice versa, so the\n * ambiguity costs nothing; and where a key is both, the name rule comes later\n * and wins. That is exactly the precedence the popover needs, where a per-tool\n * toggle must beat the group toggle above it.\n *\n * Keys are sorted so the request body is stable: an unstable order would make\n * every render look like a changed request. */\nexport function toolPolicyFromPreferences(\n prefs: Record<string, ToolPolicy> | undefined,\n): PermissionPolicy {\n const keys = Object.keys(prefs ?? {})\n .filter((key) => key.trim() !== \"\")\n .sort();\n if (keys.length === 0) return [];\n const policies = new Map<string, ToolPolicy>();\n for (const key of keys) {\n const policy = normalizeToolPolicy(prefs?.[key]);\n if (policy) policies.set(key, policy);\n }\n const ordered = [...policies.keys()];\n return [\n ...ordered.map((key) => ({ group: key, policy: policies.get(key)! })),\n ...ordered.map((key) => ({ name: key, policy: policies.get(key)! })),\n ];\n}\n\n/** Appends `later` onto `earlier`, the later winning. Composition rather than\n * mutation, so one caller's user rules cannot leak into another's. */\nexport function appendToolPolicy(\n earlier: PermissionPolicy | undefined,\n later: PermissionPolicy | undefined,\n): PermissionPolicy {\n return [...(earlier ?? []), ...(later ?? [])];\n}\n\n/** Parses a rule list off the wire, dropping anything malformed rather than\n * letting it silently become the last word on every tool: a rule with no facet\n * matches everything, and being last-match-wins that is the one mistake with\n * unbounded reach. */\nexport function normalizeToolPolicyRules(value: unknown): PermissionPolicy {\n if (!Array.isArray(value)) return [];\n const rules: PermissionPolicy = [];\n for (const raw of value) {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) continue;\n const item = raw as Record<string, unknown>;\n const policy = normalizeToolPolicy(item.policy);\n if (!policy) continue;\n const match: ToolMatch = {};\n for (const facet of MATCH_FACETS) {\n const patterns = normalizePatterns(item[facet] as MatchPatterns);\n if (patterns.length > 0) match[facet] = patterns;\n }\n for (const hint of [\"readOnly\", \"destructive\", \"idempotent\"] as const) {\n if (typeof item[hint] === \"boolean\") match[hint] = item[hint] as boolean;\n }\n if (Object.keys(match).length === 0) continue;\n rules.push({ ...match, policy });\n }\n return rules;\n}\n"],"names":[],"mappings":";AAkDA,MAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOO,SAAS,WACd,MACA,UACS;AACT,QAAM,aAAa,kBAAkB,QAAQ;AAC7C,MAAI,WAAW,WAAW,EAAG,QAAO;AAGpC,QAAM,SAAS,CAAC,GAAG,UAAU,EAAE;AAAA,IAC7B,CAAC,GAAG,MAAM,cAAc,CAAC,IAAI,cAAc,CAAC;AAAA,EAAA;AAE9C,aAAW,WAAW,QAAQ;AAC5B,QAAI,QAAQ,WAAW,GAAG,GAAG;AAC3B,UAAI,aAAa,MAAM,QAAQ,MAAM,CAAC,CAAC,EAAG,QAAO;AACjD;AAAA,IACF;AACA,QAAI,aAAa,MAAM,OAAO,EAAG,QAAO;AAAA,EAC1C;AAEA,SAAO,OAAO,MAAM,CAAC,YAAY,QAAQ,WAAW,GAAG,CAAC;AAC1D;AAEA,SAAS,kBAAkB,UAA+C;AACxE,MAAI,aAAa,OAAW,QAAO,CAAA;AACnC,QAAM,OAAO,OAAO,aAAa,WAAW,CAAC,QAAQ,IAAI;AACzD,QAAM,MAAgB,CAAA;AACtB,aAAW,OAAO,MAAM;AACtB,QAAI,OAAO,QAAQ,SAAU;AAC7B,UAAM,QAAQ,IAAI,MAAM,GAAG;AAC3B,eAAW,QAAQ,OAAO;AACxB,YAAM,UAAU,KAAK,KAAA;AACrB,UAAI,YAAY,MAAM,MAAM,SAAS,EAAG;AACxC,UAAI,YAAY,GAAI,KAAI,KAAK,OAAO;AAAA,IACtC;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,cAAc,SAAyB;AAC9C,MAAI,YAAY,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AG,OAAM,KAAK,IAAI;AAAA,IAC1C;AACA,eAAW,QAAQ,CAAC,YAAY,eAAe,YAAY,GAAY;AACrE,UAAI,OAAO,KAAK,IAAI,MAAM,UAAW,OAAM,IAAI,IAAI,KAAK,IAAI;AAAA,IAC9D;AACA,QAAI,OAAO,KAAK,KAAK,EAAE,WAAW,EAAG;AACrC,UAAM,KAAK,EAAE,GAAG,OAAO,QAAQ;AAAA,EACjC;AACA,SAAO;AACT;"}
|
package/dist/data/chat/types.cjs
CHANGED
|
@@ -52,6 +52,25 @@ const CLAUDE_PERMISSION_MODE_OPTIONS = [
|
|
|
52
52
|
description: "Bypass permission checks when explicitly allowed by the host."
|
|
53
53
|
}
|
|
54
54
|
];
|
|
55
|
+
function normalizeToolPolicy(value) {
|
|
56
|
+
if (typeof value !== "string") return void 0;
|
|
57
|
+
switch (value.trim().toLowerCase()) {
|
|
58
|
+
case "allow":
|
|
59
|
+
case "on":
|
|
60
|
+
case "enabled":
|
|
61
|
+
return "allow";
|
|
62
|
+
case "ask":
|
|
63
|
+
return "ask";
|
|
64
|
+
case "deny":
|
|
65
|
+
case "off":
|
|
66
|
+
case "disabled":
|
|
67
|
+
return "deny";
|
|
68
|
+
case "auto":
|
|
69
|
+
return "auto";
|
|
70
|
+
default:
|
|
71
|
+
return void 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
55
74
|
function isDynamicToolPart(part) {
|
|
56
75
|
return part.type === "dynamic-tool";
|
|
57
76
|
}
|
|
@@ -70,6 +89,7 @@ exports.isDynamicToolPart = isDynamicToolPart;
|
|
|
70
89
|
exports.isFilePart = isFilePart;
|
|
71
90
|
exports.isReasoningPart = isReasoningPart;
|
|
72
91
|
exports.isTypedToolPart = isTypedToolPart;
|
|
92
|
+
exports.normalizeToolPolicy = normalizeToolPolicy;
|
|
73
93
|
exports.suggestionLabel = suggestionLabel;
|
|
74
94
|
exports.suggestionPrompt = suggestionPrompt;
|
|
75
95
|
exports.toolPartName = toolPartName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sources":["../../../src/data/chat/types.ts"],"sourcesContent":["import type {\n UIMessage,\n ToolUIPart,\n DynamicToolUIPart,\n ChatStatus,\n ReasoningUIPart,\n FileUIPart,\n} from \"ai\";\nimport type { ReactNode } from \"react\";\nimport type {\n JsonSchemaObject,\n JsonSchemaProperty as FormJsonSchemaProperty,\n} from \"../../components/json-schema-form-types\";\n\nexport type {\n UIMessage,\n ToolUIPart,\n DynamicToolUIPart,\n ChatStatus,\n ReasoningUIPart,\n FileUIPart,\n};\n\n/** A selectable chat model, as served by the backend's GET /api/chat/models.\n * `configured` is false for catalogued models whose provider has no API key. */\nexport interface ChatModelRuntime {\n model?: string;\n id?: string;\n backend?: string;\n mode?: string;\n temperature?: number;\n effort?: string;\n noCache?: boolean;\n fallbacks?: ChatModelRuntime[];\n}\n\nexport type RuntimeAvailabilityState =\n | \"available\"\n | \"disabled\"\n | \"missing_credentials\"\n | \"not_authenticated\"\n | \"missing_executable\"\n | \"missing_dependency\"\n | \"unsupported\"\n | \"unavailable\";\n\nexport interface RuntimeAvailability {\n state: RuntimeAvailabilityState;\n reason?: string;\n remediation?: string;\n}\n\nexport interface ChatModel {\n id: string;\n provider: string;\n label: string;\n /** Exact Captain Model wire value submitted when this display row is selected. */\n runtime?: ChatModelRuntime;\n reasoning: boolean;\n /** True when backend metadata is authoritative, including explicit unsupported values. */\n capabilitiesKnown?: boolean;\n /** Ordered reasoning-effort tiers accepted by this exact model. */\n supportedEfforts?: string[];\n /** Backend-recommended effort used when the current selection is invalid. */\n defaultEffort?: string;\n /** Whether the model honours the temperature sampling control. */\n temperature?: boolean;\n configured?: boolean;\n availability?: RuntimeAvailability;\n /**\n * The catalog's own declared default — the row a picker seeds with when the\n * caller names no model. At most one row carries it, and a catalog that\n * declares none (or whose default is unconfigured) falls back to the first\n * configured row.\n */\n default?: boolean;\n /** Concrete runtime backends that advertised this model. Empty/omitted means provider-wide. */\n backends?: string[];\n /** Max context tokens — the denominator for a usage gauge. */\n contextWindow?: number;\n /** MIME patterns accepted as model inputs, e.g. image/* or application/pdf. */\n inputMediaTypes?: string[];\n}\n\n/** Per-message metadata the backend rides on the SSE `finish` part\n * (`messageMetadata`), applied by the AI SDK to the assistant `UIMessage`. */\nexport interface ChatMessageMetadata {\n usage?: ChatUsageBreakdown;\n costBreakdown?: ChatCostBreakdown;\n /** This turn's cost in USD. */\n cost?: number;\n /** Cumulative thread cost in USD (when the turn is persisted to a thread). */\n threadCostUsd?: number;\n /** This turn's input-token count, ≈ current context-window occupancy. */\n contextTokens?: number;\n}\n\n/** A flattened usage snapshot a chat surfaces for a gauge: tokens used out of the\n * model's context window, plus cumulative cost. */\nexport interface ChatUsageSummary {\n usedTokens: number;\n maxTokens: number;\n cost?: number;\n usage?: ChatUsageBreakdown;\n costBreakdown?: ChatCostBreakdown;\n messageCount: number;\n modelLabel?: string;\n}\n\nexport interface ChatBudgetConfig {\n /** Per-thread/request cost cap in USD. */\n cost?: number;\n /** Max output tokens for one model call. */\n maxTokens?: number;\n}\n\nexport interface ChatUsageBreakdown {\n inputTokens?: number;\n outputTokens?: number;\n reasoningTokens?: number;\n cacheReadTokens?: number;\n cacheWriteTokens?: number;\n totalTokens?: number;\n}\n\nexport interface ChatCostBreakdown {\n model?: string;\n inputUsd?: number;\n outputUsd?: number;\n reasoningUsd?: number;\n cacheReadUsd?: number;\n cacheWriteUsd?: number;\n totalUsd?: number;\n}\n\n/** A suggested prompt shown on the empty state. A bare string is both the label\n * and the submitted text; the object form separates them. */\nexport type Suggestion = string | { label: string; prompt: string };\n\n/** The label shown for a suggestion. */\nexport function suggestionLabel(s: Suggestion): string {\n return typeof s === \"string\" ? s : s.label;\n}\n\n/** The text submitted when a suggestion is clicked. */\nexport function suggestionPrompt(s: Suggestion): string {\n return typeof s === \"string\" ? s : s.prompt;\n}\n\n/** Returns true for an assistant reasoning (\"thinking\") part. */\nexport function isReasoningPart(part: {\n type: string;\n}): part is ReasoningUIPart {\n return part.type === \"reasoning\";\n}\n\n/** Returns true for a file/attachment part. */\nexport function isFilePart(part: { type: string }): part is FileUIPart {\n return part.type === \"file\";\n}\n\n/** A tool part as it appears in an assistant UIMessage — either a typed\n * `tool-<name>` part or the generic `dynamic-tool` part. clicky operations\n * surface as dynamic tools, so the chat UI renders both shapes. */\nexport type AnyToolPart = ToolUIPart | DynamicToolUIPart;\n\n/** Claude Agent SDK permission modes accepted by `permissionMode`. */\nexport const CLAUDE_PERMISSION_MODES = [\n \"default\",\n \"acceptEdits\",\n \"bypassPermissions\",\n \"plan\",\n \"dontAsk\",\n \"auto\",\n] as const;\n\nexport type ClaudePermissionMode = (typeof CLAUDE_PERMISSION_MODES)[number];\n\nexport type ClaudePermissionModeOption = {\n value: ClaudePermissionMode;\n label: string;\n description: string;\n};\n\nexport const CLAUDE_PERMISSION_MODE_OPTIONS: ClaudePermissionModeOption[] = [\n {\n value: \"default\",\n label: \"Default\",\n description:\n \"Prompt for dangerous operations using standard Claude behavior.\",\n },\n {\n value: \"auto\",\n label: \"Auto\",\n description:\n \"Use Claude's classifier to approve or deny permission prompts.\",\n },\n {\n value: \"acceptEdits\",\n label: \"Accept edits\",\n description: \"Automatically accept file edit operations.\",\n },\n {\n value: \"dontAsk\",\n label: \"Don't ask\",\n description: \"Do not prompt; deny actions that are not pre-approved.\",\n },\n {\n value: \"plan\",\n label: \"Plan\",\n description: \"Planning mode with no tool execution.\",\n },\n {\n value: \"bypassPermissions\",\n label: \"Bypass\",\n description:\n \"Bypass permission checks when explicitly allowed by the host.\",\n },\n];\n\n/** Tool metadata shared by the chat shell. It both configures the\n * tool-preferences popover (`name`/`label`/`group`) and carries the schema\n * derived from a clicky RPC operation (`description`/`inputSchema`). The Go\n * backend owns execution; the client uses this only for display and to scope\n * which tools a request may call (passed in the transport `body`). */\nexport type ToolMode = \"on\" | \"ask\" | \"off\" | \"auto\";\n\nexport interface ToolAnnotations {\n title?: string;\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n [key: string]: unknown;\n}\n\nexport interface ToolMeta {\n /** Stable tool name sent to the model (the operation id). */\n name: string;\n /** Human-readable label shown in the tool-preferences popover. */\n label: string;\n /** Bucket heading in the popover — the clicky surface for RPC operations. */\n group?: string;\n /** Display title of the tool's parent surface/entity (e.g. \"Xero Accounts\").\n * Used to nest tools under their entity within a group, and as the\n * disambiguating prefix in flat lists so sibling verbs (\"List\", \"Get\") stay\n * distinguishable. Resolved from the operation's `x-clicky.surface`. */\n parent?: string;\n /** Raw entity name of the tool's surface (e.g. \"accounts\"), when known. */\n entity?: string;\n /** Preference key sent to the backend. Defaults to `name`; group-backed\n * clicky tools set this to the backend tool group. */\n preferenceKey?: string;\n /** Initial backend-owned permission when the chat window first sees this tool. */\n defaultPermission?: ToolMode;\n /** Opaque icon name emitted by the backend, resolved by the host UI. */\n icon?: string;\n /** Description shown in tool pickers / tool-call headers. */\n description?: string;\n /** Short usage hints shown in the tool browser. */\n hints?: string[];\n source?: \"clicky\" | \"custom\" | \"mcp\" | string;\n server?: string;\n method?: string;\n path?: string;\n operationName?: string;\n title?: string;\n /** Whether the runtime should treat the tool input schema as strict/closed. */\n strict?: boolean;\n /** Runtime tool annotations/hints, e.g. MCP/Genkit well-known hints. */\n annotations?: ToolAnnotations;\n /** JSON-Schema for the tool's input, assembled from an operation's\n * parameters + request body. Omitted for hand-authored tools. */\n inputSchema?: ChatToolInputSchema;\n outputSchema?: ChatToolInputSchema;\n}\n\nexport type ChatToolInputSchema = JsonSchemaObject;\nexport type JsonSchemaProperty = FormJsonSchemaProperty;\nexport type JSONSchemaProperty = FormJsonSchemaProperty;\n\n/** Returns true for a `dynamic-tool` part (clicky operations surface this way). */\nexport function isDynamicToolPart(part: {\n type: string;\n}): part is DynamicToolUIPart {\n return part.type === \"dynamic-tool\";\n}\n\n/** Returns true for a typed `tool-<name>` part. */\nexport function isTypedToolPart(part: { type: string }): part is ToolUIPart {\n return part.type.startsWith(\"tool-\");\n}\n\n/** The display name of a tool part: the explicit `toolName` for dynamic tools,\n * otherwise the suffix after `tool-`. */\nexport function toolPartName(part: AnyToolPart): string {\n if (isDynamicToolPart(part)) {\n return part.toolName;\n }\n return part.type.slice(\"tool-\".length);\n}\n\nexport interface ToolResultRenderArgs {\n part: AnyToolPart;\n toolName: string;\n output: unknown;\n}\n\nexport type ToolResultRenderer = (args: ToolResultRenderArgs) => ReactNode;\n"],"names":[],"mappings":";;AA4IO,SAAS,gBAAgB,GAAuB;AACrD,SAAO,OAAO,MAAM,WAAW,IAAI,EAAE;AACvC;AAGO,SAAS,iBAAiB,GAAuB;AACtD,SAAO,OAAO,MAAM,WAAW,IAAI,EAAE;AACvC;AAGO,SAAS,gBAAgB,MAEJ;AAC1B,SAAO,KAAK,SAAS;AACvB;AAGO,SAAS,WAAW,MAA4C;AACrE,SAAO,KAAK,SAAS;AACvB;AAQO,MAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAUO,MAAM,iCAA+D;AAAA,EAC1E;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aACE;AAAA,EAAA;AAAA,EAEJ;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aACE;AAAA,EAAA;AAAA,EAEJ;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aAAa;AAAA,EAAA;AAAA,EAEf;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aAAa;AAAA,EAAA;AAAA,EAEf;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aAAa;AAAA,EAAA;AAAA,EAEf;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aACE;AAAA,EAAA;AAEN;AAgEO,SAAS,kBAAkB,MAEJ;AAC5B,SAAO,KAAK,SAAS;AACvB;AAGO,SAAS,gBAAgB,MAA4C;AAC1E,SAAO,KAAK,KAAK,WAAW,OAAO;AACrC;AAIO,SAAS,aAAa,MAA2B;AACtD,MAAI,kBAAkB,IAAI,GAAG;AAC3B,WAAO,KAAK;AAAA,EACd;AACA,SAAO,KAAK,KAAK,MAAM,QAAQ,MAAM;AACvC;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"types.cjs","sources":["../../../src/data/chat/types.ts"],"sourcesContent":["import type {\n UIMessage,\n ToolUIPart,\n DynamicToolUIPart,\n ChatStatus,\n ReasoningUIPart,\n FileUIPart,\n} from \"ai\";\nimport type { ReactNode } from \"react\";\nimport type {\n JsonSchemaObject,\n JsonSchemaProperty as FormJsonSchemaProperty,\n} from \"../../components/json-schema-form-types\";\n\nexport type {\n UIMessage,\n ToolUIPart,\n DynamicToolUIPart,\n ChatStatus,\n ReasoningUIPart,\n FileUIPart,\n};\n\n/** A selectable chat model, as served by the backend's GET /api/chat/models.\n * `configured` is false for catalogued models whose provider has no API key. */\nexport interface ChatModelRuntime {\n model?: string;\n id?: string;\n backend?: string;\n mode?: string;\n temperature?: number;\n effort?: string;\n noCache?: boolean;\n fallbacks?: ChatModelRuntime[];\n}\n\nexport type RuntimeAvailabilityState =\n | \"available\"\n | \"disabled\"\n | \"missing_credentials\"\n | \"not_authenticated\"\n | \"missing_executable\"\n | \"missing_dependency\"\n | \"unsupported\"\n | \"unavailable\";\n\nexport interface RuntimeAvailability {\n state: RuntimeAvailabilityState;\n reason?: string;\n remediation?: string;\n}\n\nexport interface ChatModel {\n id: string;\n provider: string;\n label: string;\n /** Exact Captain Model wire value submitted when this display row is selected. */\n runtime?: ChatModelRuntime;\n reasoning: boolean;\n /** True when backend metadata is authoritative, including explicit unsupported values. */\n capabilitiesKnown?: boolean;\n /** Ordered reasoning-effort tiers accepted by this exact model. */\n supportedEfforts?: string[];\n /** Backend-recommended effort used when the current selection is invalid. */\n defaultEffort?: string;\n /** Whether the model honours the temperature sampling control. */\n temperature?: boolean;\n configured?: boolean;\n availability?: RuntimeAvailability;\n /**\n * The catalog's own declared default — the row a picker seeds with when the\n * caller names no model. At most one row carries it, and a catalog that\n * declares none (or whose default is unconfigured) falls back to the first\n * configured row.\n */\n default?: boolean;\n /** Concrete runtime backends that advertised this model. Empty/omitted means provider-wide. */\n backends?: string[];\n /** Max context tokens — the denominator for a usage gauge. */\n contextWindow?: number;\n /** MIME patterns accepted as model inputs, e.g. image/* or application/pdf. */\n inputMediaTypes?: string[];\n}\n\n/** Per-message metadata the backend rides on the SSE `finish` part\n * (`messageMetadata`), applied by the AI SDK to the assistant `UIMessage`. */\nexport interface ChatMessageMetadata {\n backend?: string;\n executionMode?: string;\n model?: string;\n captainSessionId?: string;\n providerSessionId?: string;\n threadId?: string;\n turnId?: string;\n success?: boolean;\n interrupted?: boolean;\n usage?: ChatUsageBreakdown;\n costBreakdown?: ChatCostBreakdown;\n /** This turn's cost in USD. */\n cost?: number;\n /** Cumulative thread cost in USD (when the turn is persisted to a thread). */\n threadCostUsd?: number;\n /** This turn's input-token count, ≈ current context-window occupancy. */\n contextTokens?: number;\n}\n\n/** A flattened usage snapshot a chat surfaces for a gauge: tokens used out of the\n * model's context window, plus cumulative cost. */\nexport interface ChatUsageSummary {\n usedTokens: number;\n maxTokens: number;\n cost?: number;\n usage?: ChatUsageBreakdown;\n costBreakdown?: ChatCostBreakdown;\n messageCount: number;\n backend?: string;\n executionMode?: string;\n model?: string;\n captainSessionId?: string;\n providerSessionId?: string;\n threadId?: string;\n turnId?: string;\n success?: boolean;\n interrupted?: boolean;\n /** @deprecated Use `model`; retained for compatibility with existing consumers. */\n modelLabel?: string;\n}\n\nexport interface ChatBudgetConfig {\n /** Per-thread/request cost cap in USD. */\n cost?: number;\n /** Max output tokens for one model call. */\n maxTokens?: number;\n}\n\nexport interface ChatUsageBreakdown {\n inputTokens?: number;\n outputTokens?: number;\n reasoningTokens?: number;\n cacheReadTokens?: number;\n cacheWriteTokens?: number;\n totalTokens?: number;\n}\n\nexport interface ChatCostBreakdown {\n model?: string;\n inputUsd?: number;\n outputUsd?: number;\n reasoningUsd?: number;\n cacheReadUsd?: number;\n cacheWriteUsd?: number;\n totalUsd?: number;\n}\n\n/** A suggested prompt shown on the empty state. A bare string is both the label\n * and the submitted text; the object form separates them. */\nexport type Suggestion = string | { label: string; prompt: string };\n\n/** The label shown for a suggestion. */\nexport function suggestionLabel(s: Suggestion): string {\n return typeof s === \"string\" ? s : s.label;\n}\n\n/** The text submitted when a suggestion is clicked. */\nexport function suggestionPrompt(s: Suggestion): string {\n return typeof s === \"string\" ? s : s.prompt;\n}\n\n/** Returns true for an assistant reasoning (\"thinking\") part. */\nexport function isReasoningPart(part: {\n type: string;\n}): part is ReasoningUIPart {\n return part.type === \"reasoning\";\n}\n\n/** Returns true for a file/attachment part. */\nexport function isFilePart(part: { type: string }): part is FileUIPart {\n return part.type === \"file\";\n}\n\n/** A tool part as it appears in an assistant UIMessage — either a typed\n * `tool-<name>` part or the generic `dynamic-tool` part. clicky operations\n * surface as dynamic tools, so the chat UI renders both shapes. */\nexport type AnyToolPart = ToolUIPart | DynamicToolUIPart;\n\n/** Claude Agent SDK permission modes accepted by `permissionMode`. */\nexport const CLAUDE_PERMISSION_MODES = [\n \"default\",\n \"acceptEdits\",\n \"bypassPermissions\",\n \"plan\",\n \"dontAsk\",\n \"auto\",\n] as const;\n\nexport type ClaudePermissionMode = (typeof CLAUDE_PERMISSION_MODES)[number];\n\nexport type ClaudePermissionModeOption = {\n value: ClaudePermissionMode;\n label: string;\n description: string;\n};\n\nexport const CLAUDE_PERMISSION_MODE_OPTIONS: ClaudePermissionModeOption[] = [\n {\n value: \"default\",\n label: \"Default\",\n description:\n \"Prompt for dangerous operations using standard Claude behavior.\",\n },\n {\n value: \"auto\",\n label: \"Auto\",\n description:\n \"Use Claude's classifier to approve or deny permission prompts.\",\n },\n {\n value: \"acceptEdits\",\n label: \"Accept edits\",\n description: \"Automatically accept file edit operations.\",\n },\n {\n value: \"dontAsk\",\n label: \"Don't ask\",\n description: \"Do not prompt; deny actions that are not pre-approved.\",\n },\n {\n value: \"plan\",\n label: \"Plan\",\n description: \"Planning mode with no tool execution.\",\n },\n {\n value: \"bypassPermissions\",\n label: \"Bypass\",\n description:\n \"Bypass permission checks when explicitly allowed by the host.\",\n },\n];\n\n/** Tool metadata shared by the chat shell. It both configures the\n * tool-preferences popover (`name`/`label`/`group`) and carries the schema\n * derived from a clicky RPC operation (`description`/`inputSchema`). The Go\n * backend owns execution; the client uses this only for display and to scope\n * which tools a request may call (passed in the transport `body`). */\n/** Authority for one tool, in Captain's tool vocabulary. The legacy `on`/`off`\n * spellings are still accepted on the way in (see `normalizeToolPolicyValue`)\n * and mean `allow`/`deny`; they are never produced here. The UI still *labels*\n * these On and Off — see `POLICY_LABEL`. */\nexport type ToolPolicy = \"allow\" | \"ask\" | \"deny\" | \"auto\";\n\n/** Canonicalizes a tool policy from the wire, accepting the legacy `on`/`off`\n * spellings the backend still emits from older catalogs and MCP `_meta`.\n *\n * `on` means allow rather than auto: the catalog encoding has no separate allow\n * list, so `on` was always its way of saying auto-run. Keeping private copies of\n * this rule per call site is how the UI and the server drifted apart, so this is\n * the only one. */\nexport function normalizeToolPolicy(value: unknown): ToolPolicy | undefined {\n if (typeof value !== \"string\") return undefined;\n switch (value.trim().toLowerCase()) {\n case \"allow\":\n case \"on\":\n case \"enabled\":\n return \"allow\";\n case \"ask\":\n return \"ask\";\n case \"deny\":\n case \"off\":\n case \"disabled\":\n return \"deny\";\n case \"auto\":\n return \"auto\";\n default:\n return undefined;\n }\n}\n\nexport interface ToolAnnotations {\n title?: string;\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n [key: string]: unknown;\n}\n\nexport interface ToolMeta {\n /** Stable tool name sent to the model (the operation id). */\n name: string;\n /** Human-readable label shown in the tool-preferences popover. */\n label: string;\n /** Bucket heading in the popover — the clicky surface for RPC operations. */\n group?: string;\n /** Display title of the tool's parent surface/entity (e.g. \"Xero Accounts\").\n * Used to nest tools under their entity within a group, and as the\n * disambiguating prefix in flat lists so sibling verbs (\"List\", \"Get\") stay\n * distinguishable. Resolved from the operation's `x-clicky.surface`. */\n parent?: string;\n /** Raw entity name of the tool's surface (e.g. \"accounts\"), when known. */\n entity?: string;\n /** Preference key sent to the backend. Defaults to `name`; group-backed\n * clicky tools set this to the backend tool group. */\n preferenceKey?: string;\n /** Initial backend-owned permission when the chat window first sees this tool. */\n defaultPermission?: ToolPolicy;\n /** Opaque icon name emitted by the backend, resolved by the host UI. */\n icon?: string;\n /** Description shown in tool pickers / tool-call headers. */\n description?: string;\n /** Short usage hints shown in the tool browser. */\n hints?: string[];\n source?: \"clicky\" | \"custom\" | \"mcp\" | string;\n server?: string;\n method?: string;\n path?: string;\n operationName?: string;\n /** The entity verb (list/get/create/update/delete, or a custom action), the\n * custom action's name, and whether the operation addresses a collection or a\n * single entity. Carried so a permission rule resolves the same way here as\n * it does on the server; empty for a tool that projects no clicky operation.\n * @see resolveToolPolicy */\n verb?: string;\n action?: string;\n scope?: string;\n title?: string;\n /** Whether the runtime should treat the tool input schema as strict/closed. */\n strict?: boolean;\n /** Runtime tool annotations/hints, e.g. MCP/Genkit well-known hints. */\n annotations?: ToolAnnotations;\n /** JSON-Schema for the tool's input, assembled from an operation's\n * parameters + request body. Omitted for hand-authored tools. */\n inputSchema?: ChatToolInputSchema;\n outputSchema?: ChatToolInputSchema;\n}\n\nexport type ChatToolInputSchema = JsonSchemaObject;\nexport type JsonSchemaProperty = FormJsonSchemaProperty;\nexport type JSONSchemaProperty = FormJsonSchemaProperty;\n\n/** Returns true for a `dynamic-tool` part (clicky operations surface this way). */\nexport function isDynamicToolPart(part: {\n type: string;\n}): part is DynamicToolUIPart {\n return part.type === \"dynamic-tool\";\n}\n\n/** Returns true for a typed `tool-<name>` part. */\nexport function isTypedToolPart(part: { type: string }): part is ToolUIPart {\n return part.type.startsWith(\"tool-\");\n}\n\n/** The display name of a tool part: the explicit `toolName` for dynamic tools,\n * otherwise the suffix after `tool-`. */\nexport function toolPartName(part: AnyToolPart): string {\n if (isDynamicToolPart(part)) {\n return part.toolName;\n }\n return part.type.slice(\"tool-\".length);\n}\n\nexport interface ToolResultRenderArgs {\n part: AnyToolPart;\n toolName: string;\n output: unknown;\n}\n\nexport type ToolResultRenderer = (args: ToolResultRenderArgs) => ReactNode;\n"],"names":[],"mappings":";;AA+JO,SAAS,gBAAgB,GAAuB;AACrD,SAAO,OAAO,MAAM,WAAW,IAAI,EAAE;AACvC;AAGO,SAAS,iBAAiB,GAAuB;AACtD,SAAO,OAAO,MAAM,WAAW,IAAI,EAAE;AACvC;AAGO,SAAS,gBAAgB,MAEJ;AAC1B,SAAO,KAAK,SAAS;AACvB;AAGO,SAAS,WAAW,MAA4C;AACrE,SAAO,KAAK,SAAS;AACvB;AAQO,MAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAUO,MAAM,iCAA+D;AAAA,EAC1E;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aACE;AAAA,EAAA;AAAA,EAEJ;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aACE;AAAA,EAAA;AAAA,EAEJ;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aAAa;AAAA,EAAA;AAAA,EAEf;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aAAa;AAAA,EAAA;AAAA,EAEf;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aAAa;AAAA,EAAA;AAAA,EAEf;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aACE;AAAA,EAAA;AAEN;AAoBO,SAAS,oBAAoB,OAAwC;AAC1E,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,UAAQ,MAAM,KAAA,EAAO,YAAA,GAAY;AAAA,IAC/B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EAAA;AAEb;AAiEO,SAAS,kBAAkB,MAEJ;AAC5B,SAAO,KAAK,SAAS;AACvB;AAGO,SAAS,gBAAgB,MAA4C;AAC1E,SAAO,KAAK,KAAK,WAAW,OAAO;AACrC;AAIO,SAAS,aAAa,MAA2B;AACtD,MAAI,kBAAkB,IAAI,GAAG;AAC3B,WAAO,KAAK;AAAA,EACd;AACA,SAAO,KAAK,KAAK,MAAM,QAAQ,MAAM;AACvC;;;;;;;;;;;"}
|
|
@@ -54,6 +54,15 @@ export interface ChatModel {
|
|
|
54
54
|
/** Per-message metadata the backend rides on the SSE `finish` part
|
|
55
55
|
* (`messageMetadata`), applied by the AI SDK to the assistant `UIMessage`. */
|
|
56
56
|
export interface ChatMessageMetadata {
|
|
57
|
+
backend?: string;
|
|
58
|
+
executionMode?: string;
|
|
59
|
+
model?: string;
|
|
60
|
+
captainSessionId?: string;
|
|
61
|
+
providerSessionId?: string;
|
|
62
|
+
threadId?: string;
|
|
63
|
+
turnId?: string;
|
|
64
|
+
success?: boolean;
|
|
65
|
+
interrupted?: boolean;
|
|
57
66
|
usage?: ChatUsageBreakdown;
|
|
58
67
|
costBreakdown?: ChatCostBreakdown;
|
|
59
68
|
/** This turn's cost in USD. */
|
|
@@ -72,6 +81,16 @@ export interface ChatUsageSummary {
|
|
|
72
81
|
usage?: ChatUsageBreakdown;
|
|
73
82
|
costBreakdown?: ChatCostBreakdown;
|
|
74
83
|
messageCount: number;
|
|
84
|
+
backend?: string;
|
|
85
|
+
executionMode?: string;
|
|
86
|
+
model?: string;
|
|
87
|
+
captainSessionId?: string;
|
|
88
|
+
providerSessionId?: string;
|
|
89
|
+
threadId?: string;
|
|
90
|
+
turnId?: string;
|
|
91
|
+
success?: boolean;
|
|
92
|
+
interrupted?: boolean;
|
|
93
|
+
/** @deprecated Use `model`; retained for compatibility with existing consumers. */
|
|
75
94
|
modelLabel?: string;
|
|
76
95
|
}
|
|
77
96
|
export interface ChatBudgetConfig {
|
|
@@ -133,7 +152,19 @@ export declare const CLAUDE_PERMISSION_MODE_OPTIONS: ClaudePermissionModeOption[
|
|
|
133
152
|
* derived from a clicky RPC operation (`description`/`inputSchema`). The Go
|
|
134
153
|
* backend owns execution; the client uses this only for display and to scope
|
|
135
154
|
* which tools a request may call (passed in the transport `body`). */
|
|
136
|
-
|
|
155
|
+
/** Authority for one tool, in Captain's tool vocabulary. The legacy `on`/`off`
|
|
156
|
+
* spellings are still accepted on the way in (see `normalizeToolPolicyValue`)
|
|
157
|
+
* and mean `allow`/`deny`; they are never produced here. The UI still *labels*
|
|
158
|
+
* these On and Off — see `POLICY_LABEL`. */
|
|
159
|
+
export type ToolPolicy = "allow" | "ask" | "deny" | "auto";
|
|
160
|
+
/** Canonicalizes a tool policy from the wire, accepting the legacy `on`/`off`
|
|
161
|
+
* spellings the backend still emits from older catalogs and MCP `_meta`.
|
|
162
|
+
*
|
|
163
|
+
* `on` means allow rather than auto: the catalog encoding has no separate allow
|
|
164
|
+
* list, so `on` was always its way of saying auto-run. Keeping private copies of
|
|
165
|
+
* this rule per call site is how the UI and the server drifted apart, so this is
|
|
166
|
+
* the only one. */
|
|
167
|
+
export declare function normalizeToolPolicy(value: unknown): ToolPolicy | undefined;
|
|
137
168
|
export interface ToolAnnotations {
|
|
138
169
|
title?: string;
|
|
139
170
|
readOnlyHint?: boolean;
|
|
@@ -160,7 +191,7 @@ export interface ToolMeta {
|
|
|
160
191
|
* clicky tools set this to the backend tool group. */
|
|
161
192
|
preferenceKey?: string;
|
|
162
193
|
/** Initial backend-owned permission when the chat window first sees this tool. */
|
|
163
|
-
defaultPermission?:
|
|
194
|
+
defaultPermission?: ToolPolicy;
|
|
164
195
|
/** Opaque icon name emitted by the backend, resolved by the host UI. */
|
|
165
196
|
icon?: string;
|
|
166
197
|
/** Description shown in tool pickers / tool-call headers. */
|
|
@@ -172,6 +203,14 @@ export interface ToolMeta {
|
|
|
172
203
|
method?: string;
|
|
173
204
|
path?: string;
|
|
174
205
|
operationName?: string;
|
|
206
|
+
/** The entity verb (list/get/create/update/delete, or a custom action), the
|
|
207
|
+
* custom action's name, and whether the operation addresses a collection or a
|
|
208
|
+
* single entity. Carried so a permission rule resolves the same way here as
|
|
209
|
+
* it does on the server; empty for a tool that projects no clicky operation.
|
|
210
|
+
* @see resolveToolPolicy */
|
|
211
|
+
verb?: string;
|
|
212
|
+
action?: string;
|
|
213
|
+
scope?: string;
|
|
175
214
|
title?: string;
|
|
176
215
|
/** Whether the runtime should treat the tool input schema as strict/closed. */
|
|
177
216
|
strict?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/data/chat/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,UAAU,EACX,MAAM,IAAI,CAAC;AACZ,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,IAAI,sBAAsB,EAC7C,MAAM,yCAAyC,CAAC;AAEjD,YAAY,EACV,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,UAAU,GACX,CAAC;AAEF;iFACiF;AACjF,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAA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AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,oBAAoB,KAAK,SAAS,CAAC"}
|
package/dist/data/chat/types.js
CHANGED
|
@@ -50,6 +50,25 @@ const CLAUDE_PERMISSION_MODE_OPTIONS = [
|
|
|
50
50
|
description: "Bypass permission checks when explicitly allowed by the host."
|
|
51
51
|
}
|
|
52
52
|
];
|
|
53
|
+
function normalizeToolPolicy(value) {
|
|
54
|
+
if (typeof value !== "string") return void 0;
|
|
55
|
+
switch (value.trim().toLowerCase()) {
|
|
56
|
+
case "allow":
|
|
57
|
+
case "on":
|
|
58
|
+
case "enabled":
|
|
59
|
+
return "allow";
|
|
60
|
+
case "ask":
|
|
61
|
+
return "ask";
|
|
62
|
+
case "deny":
|
|
63
|
+
case "off":
|
|
64
|
+
case "disabled":
|
|
65
|
+
return "deny";
|
|
66
|
+
case "auto":
|
|
67
|
+
return "auto";
|
|
68
|
+
default:
|
|
69
|
+
return void 0;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
53
72
|
function isDynamicToolPart(part) {
|
|
54
73
|
return part.type === "dynamic-tool";
|
|
55
74
|
}
|
|
@@ -69,6 +88,7 @@ export {
|
|
|
69
88
|
isFilePart,
|
|
70
89
|
isReasoningPart,
|
|
71
90
|
isTypedToolPart,
|
|
91
|
+
normalizeToolPolicy,
|
|
72
92
|
suggestionLabel,
|
|
73
93
|
suggestionPrompt,
|
|
74
94
|
toolPartName
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/data/chat/types.ts"],"sourcesContent":["import type {\n UIMessage,\n ToolUIPart,\n DynamicToolUIPart,\n ChatStatus,\n ReasoningUIPart,\n FileUIPart,\n} from \"ai\";\nimport type { ReactNode } from \"react\";\nimport type {\n JsonSchemaObject,\n JsonSchemaProperty as FormJsonSchemaProperty,\n} from \"../../components/json-schema-form-types\";\n\nexport type {\n UIMessage,\n ToolUIPart,\n DynamicToolUIPart,\n ChatStatus,\n ReasoningUIPart,\n FileUIPart,\n};\n\n/** A selectable chat model, as served by the backend's GET /api/chat/models.\n * `configured` is false for catalogued models whose provider has no API key. */\nexport interface ChatModelRuntime {\n model?: string;\n id?: string;\n backend?: string;\n mode?: string;\n temperature?: number;\n effort?: string;\n noCache?: boolean;\n fallbacks?: ChatModelRuntime[];\n}\n\nexport type RuntimeAvailabilityState =\n | \"available\"\n | \"disabled\"\n | \"missing_credentials\"\n | \"not_authenticated\"\n | \"missing_executable\"\n | \"missing_dependency\"\n | \"unsupported\"\n | \"unavailable\";\n\nexport interface RuntimeAvailability {\n state: RuntimeAvailabilityState;\n reason?: string;\n remediation?: string;\n}\n\nexport interface ChatModel {\n id: string;\n provider: string;\n label: string;\n /** Exact Captain Model wire value submitted when this display row is selected. */\n runtime?: ChatModelRuntime;\n reasoning: boolean;\n /** True when backend metadata is authoritative, including explicit unsupported values. */\n capabilitiesKnown?: boolean;\n /** Ordered reasoning-effort tiers accepted by this exact model. */\n supportedEfforts?: string[];\n /** Backend-recommended effort used when the current selection is invalid. */\n defaultEffort?: string;\n /** Whether the model honours the temperature sampling control. */\n temperature?: boolean;\n configured?: boolean;\n availability?: RuntimeAvailability;\n /**\n * The catalog's own declared default — the row a picker seeds with when the\n * caller names no model. At most one row carries it, and a catalog that\n * declares none (or whose default is unconfigured) falls back to the first\n * configured row.\n */\n default?: boolean;\n /** Concrete runtime backends that advertised this model. Empty/omitted means provider-wide. */\n backends?: string[];\n /** Max context tokens — the denominator for a usage gauge. */\n contextWindow?: number;\n /** MIME patterns accepted as model inputs, e.g. image/* or application/pdf. */\n inputMediaTypes?: string[];\n}\n\n/** Per-message metadata the backend rides on the SSE `finish` part\n * (`messageMetadata`), applied by the AI SDK to the assistant `UIMessage`. */\nexport interface ChatMessageMetadata {\n usage?: ChatUsageBreakdown;\n costBreakdown?: ChatCostBreakdown;\n /** This turn's cost in USD. */\n cost?: number;\n /** Cumulative thread cost in USD (when the turn is persisted to a thread). */\n threadCostUsd?: number;\n /** This turn's input-token count, ≈ current context-window occupancy. */\n contextTokens?: number;\n}\n\n/** A flattened usage snapshot a chat surfaces for a gauge: tokens used out of the\n * model's context window, plus cumulative cost. */\nexport interface ChatUsageSummary {\n usedTokens: number;\n maxTokens: number;\n cost?: number;\n usage?: ChatUsageBreakdown;\n costBreakdown?: ChatCostBreakdown;\n messageCount: number;\n modelLabel?: string;\n}\n\nexport interface ChatBudgetConfig {\n /** Per-thread/request cost cap in USD. */\n cost?: number;\n /** Max output tokens for one model call. */\n maxTokens?: number;\n}\n\nexport interface ChatUsageBreakdown {\n inputTokens?: number;\n outputTokens?: number;\n reasoningTokens?: number;\n cacheReadTokens?: number;\n cacheWriteTokens?: number;\n totalTokens?: number;\n}\n\nexport interface ChatCostBreakdown {\n model?: string;\n inputUsd?: number;\n outputUsd?: number;\n reasoningUsd?: number;\n cacheReadUsd?: number;\n cacheWriteUsd?: number;\n totalUsd?: number;\n}\n\n/** A suggested prompt shown on the empty state. A bare string is both the label\n * and the submitted text; the object form separates them. */\nexport type Suggestion = string | { label: string; prompt: string };\n\n/** The label shown for a suggestion. */\nexport function suggestionLabel(s: Suggestion): string {\n return typeof s === \"string\" ? s : s.label;\n}\n\n/** The text submitted when a suggestion is clicked. */\nexport function suggestionPrompt(s: Suggestion): string {\n return typeof s === \"string\" ? s : s.prompt;\n}\n\n/** Returns true for an assistant reasoning (\"thinking\") part. */\nexport function isReasoningPart(part: {\n type: string;\n}): part is ReasoningUIPart {\n return part.type === \"reasoning\";\n}\n\n/** Returns true for a file/attachment part. */\nexport function isFilePart(part: { type: string }): part is FileUIPart {\n return part.type === \"file\";\n}\n\n/** A tool part as it appears in an assistant UIMessage — either a typed\n * `tool-<name>` part or the generic `dynamic-tool` part. clicky operations\n * surface as dynamic tools, so the chat UI renders both shapes. */\nexport type AnyToolPart = ToolUIPart | DynamicToolUIPart;\n\n/** Claude Agent SDK permission modes accepted by `permissionMode`. */\nexport const CLAUDE_PERMISSION_MODES = [\n \"default\",\n \"acceptEdits\",\n \"bypassPermissions\",\n \"plan\",\n \"dontAsk\",\n \"auto\",\n] as const;\n\nexport type ClaudePermissionMode = (typeof CLAUDE_PERMISSION_MODES)[number];\n\nexport type ClaudePermissionModeOption = {\n value: ClaudePermissionMode;\n label: string;\n description: string;\n};\n\nexport const CLAUDE_PERMISSION_MODE_OPTIONS: ClaudePermissionModeOption[] = [\n {\n value: \"default\",\n label: \"Default\",\n description:\n \"Prompt for dangerous operations using standard Claude behavior.\",\n },\n {\n value: \"auto\",\n label: \"Auto\",\n description:\n \"Use Claude's classifier to approve or deny permission prompts.\",\n },\n {\n value: \"acceptEdits\",\n label: \"Accept edits\",\n description: \"Automatically accept file edit operations.\",\n },\n {\n value: \"dontAsk\",\n label: \"Don't ask\",\n description: \"Do not prompt; deny actions that are not pre-approved.\",\n },\n {\n value: \"plan\",\n label: \"Plan\",\n description: \"Planning mode with no tool execution.\",\n },\n {\n value: \"bypassPermissions\",\n label: \"Bypass\",\n description:\n \"Bypass permission checks when explicitly allowed by the host.\",\n },\n];\n\n/** Tool metadata shared by the chat shell. It both configures the\n * tool-preferences popover (`name`/`label`/`group`) and carries the schema\n * derived from a clicky RPC operation (`description`/`inputSchema`). The Go\n * backend owns execution; the client uses this only for display and to scope\n * which tools a request may call (passed in the transport `body`). */\nexport type ToolMode = \"on\" | \"ask\" | \"off\" | \"auto\";\n\nexport interface ToolAnnotations {\n title?: string;\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n [key: string]: unknown;\n}\n\nexport interface ToolMeta {\n /** Stable tool name sent to the model (the operation id). */\n name: string;\n /** Human-readable label shown in the tool-preferences popover. */\n label: string;\n /** Bucket heading in the popover — the clicky surface for RPC operations. */\n group?: string;\n /** Display title of the tool's parent surface/entity (e.g. \"Xero Accounts\").\n * Used to nest tools under their entity within a group, and as the\n * disambiguating prefix in flat lists so sibling verbs (\"List\", \"Get\") stay\n * distinguishable. Resolved from the operation's `x-clicky.surface`. */\n parent?: string;\n /** Raw entity name of the tool's surface (e.g. \"accounts\"), when known. */\n entity?: string;\n /** Preference key sent to the backend. Defaults to `name`; group-backed\n * clicky tools set this to the backend tool group. */\n preferenceKey?: string;\n /** Initial backend-owned permission when the chat window first sees this tool. */\n defaultPermission?: ToolMode;\n /** Opaque icon name emitted by the backend, resolved by the host UI. */\n icon?: string;\n /** Description shown in tool pickers / tool-call headers. */\n description?: string;\n /** Short usage hints shown in the tool browser. */\n hints?: string[];\n source?: \"clicky\" | \"custom\" | \"mcp\" | string;\n server?: string;\n method?: string;\n path?: string;\n operationName?: string;\n title?: string;\n /** Whether the runtime should treat the tool input schema as strict/closed. */\n strict?: boolean;\n /** Runtime tool annotations/hints, e.g. MCP/Genkit well-known hints. */\n annotations?: ToolAnnotations;\n /** JSON-Schema for the tool's input, assembled from an operation's\n * parameters + request body. Omitted for hand-authored tools. */\n inputSchema?: ChatToolInputSchema;\n outputSchema?: ChatToolInputSchema;\n}\n\nexport type ChatToolInputSchema = JsonSchemaObject;\nexport type JsonSchemaProperty = FormJsonSchemaProperty;\nexport type JSONSchemaProperty = FormJsonSchemaProperty;\n\n/** Returns true for a `dynamic-tool` part (clicky operations surface this way). */\nexport function isDynamicToolPart(part: {\n type: string;\n}): part is DynamicToolUIPart {\n return part.type === \"dynamic-tool\";\n}\n\n/** Returns true for a typed `tool-<name>` part. */\nexport function isTypedToolPart(part: { type: string }): part is ToolUIPart {\n return part.type.startsWith(\"tool-\");\n}\n\n/** The display name of a tool part: the explicit `toolName` for dynamic tools,\n * otherwise the suffix after `tool-`. */\nexport function toolPartName(part: AnyToolPart): string {\n if (isDynamicToolPart(part)) {\n return part.toolName;\n }\n return part.type.slice(\"tool-\".length);\n}\n\nexport interface ToolResultRenderArgs {\n part: AnyToolPart;\n toolName: string;\n output: unknown;\n}\n\nexport type ToolResultRenderer = (args: ToolResultRenderArgs) => ReactNode;\n"],"names":[],"mappings":"AA4IO,SAAS,gBAAgB,GAAuB;AACrD,SAAO,OAAO,MAAM,WAAW,IAAI,EAAE;AACvC;AAGO,SAAS,iBAAiB,GAAuB;AACtD,SAAO,OAAO,MAAM,WAAW,IAAI,EAAE;AACvC;AAGO,SAAS,gBAAgB,MAEJ;AAC1B,SAAO,KAAK,SAAS;AACvB;AAGO,SAAS,WAAW,MAA4C;AACrE,SAAO,KAAK,SAAS;AACvB;AAQO,MAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAUO,MAAM,iCAA+D;AAAA,EAC1E;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aACE;AAAA,EAAA;AAAA,EAEJ;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aACE;AAAA,EAAA;AAAA,EAEJ;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aAAa;AAAA,EAAA;AAAA,EAEf;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aAAa;AAAA,EAAA;AAAA,EAEf;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aAAa;AAAA,EAAA;AAAA,EAEf;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,aACE;AAAA,EAAA;AAEN;AAgEO,SAAS,kBAAkB,MAEJ;AAC5B,SAAO,KAAK,SAAS;AACvB;AAGO,SAAS,gBAAgB,MAA4C;AAC1E,SAAO,KAAK,KAAK,WAAW,OAAO;AACrC;AAIO,SAAS,aAAa,MAA2B;AACtD,MAAI,kBAAkB,IAAI,GAAG;AAC3B,WAAO,KAAK;AAAA,EACd;AACA,SAAO,KAAK,KAAK,MAAM,QAAQ,MAAM;AACvC;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/data/chat/types.ts"],"sourcesContent":["import type {\n UIMessage,\n ToolUIPart,\n DynamicToolUIPart,\n ChatStatus,\n ReasoningUIPart,\n FileUIPart,\n} from \"ai\";\nimport type { ReactNode } from \"react\";\nimport type {\n JsonSchemaObject,\n JsonSchemaProperty as FormJsonSchemaProperty,\n} from \"../../components/json-schema-form-types\";\n\nexport type {\n UIMessage,\n ToolUIPart,\n DynamicToolUIPart,\n ChatStatus,\n ReasoningUIPart,\n FileUIPart,\n};\n\n/** A selectable chat model, as served by the backend's GET /api/chat/models.\n * `configured` is false for catalogued models whose provider has no API key. */\nexport interface ChatModelRuntime {\n model?: string;\n id?: string;\n backend?: string;\n mode?: string;\n temperature?: number;\n effort?: string;\n noCache?: boolean;\n fallbacks?: ChatModelRuntime[];\n}\n\nexport type RuntimeAvailabilityState =\n | \"available\"\n | \"disabled\"\n | \"missing_credentials\"\n | \"not_authenticated\"\n | \"missing_executable\"\n | \"missing_dependency\"\n | \"unsupported\"\n | \"unavailable\";\n\nexport interface RuntimeAvailability {\n state: RuntimeAvailabilityState;\n reason?: string;\n remediation?: string;\n}\n\nexport interface ChatModel {\n id: string;\n provider: string;\n label: string;\n /** Exact Captain Model wire value submitted when this display row is selected. */\n runtime?: ChatModelRuntime;\n reasoning: boolean;\n /** True when backend metadata is authoritative, including explicit unsupported values. */\n capabilitiesKnown?: boolean;\n /** Ordered reasoning-effort tiers accepted by this exact model. */\n supportedEfforts?: string[];\n /** Backend-recommended effort used when the current selection is invalid. */\n defaultEffort?: string;\n /** Whether the model honours the temperature sampling control. */\n temperature?: boolean;\n configured?: boolean;\n availability?: RuntimeAvailability;\n /**\n * The catalog's own declared default — the row a picker seeds with when the\n * caller names no model. At most one row carries it, and a catalog that\n * declares none (or whose default is unconfigured) falls back to the first\n * configured row.\n */\n default?: boolean;\n /** Concrete runtime backends that advertised this model. Empty/omitted means provider-wide. */\n backends?: string[];\n /** Max context tokens — the denominator for a usage gauge. */\n contextWindow?: number;\n /** MIME patterns accepted as model inputs, e.g. image/* or application/pdf. */\n inputMediaTypes?: string[];\n}\n\n/** Per-message metadata the backend rides on the SSE `finish` part\n * (`messageMetadata`), applied by the AI SDK to the assistant `UIMessage`. */\nexport interface ChatMessageMetadata {\n backend?: string;\n executionMode?: string;\n model?: string;\n captainSessionId?: string;\n providerSessionId?: string;\n threadId?: string;\n turnId?: string;\n success?: boolean;\n interrupted?: boolean;\n usage?: ChatUsageBreakdown;\n costBreakdown?: ChatCostBreakdown;\n /** This turn's cost in USD. */\n cost?: number;\n /** Cumulative thread cost in USD (when the turn is persisted to a thread). */\n threadCostUsd?: number;\n /** This turn's input-token count, ≈ current context-window occupancy. */\n contextTokens?: number;\n}\n\n/** A flattened usage snapshot a chat surfaces for a gauge: tokens used out of the\n * model's context window, plus cumulative cost. */\nexport interface ChatUsageSummary {\n usedTokens: number;\n maxTokens: number;\n cost?: number;\n usage?: ChatUsageBreakdown;\n costBreakdown?: ChatCostBreakdown;\n messageCount: number;\n backend?: string;\n executionMode?: string;\n model?: string;\n captainSessionId?: string;\n providerSessionId?: string;\n threadId?: string;\n turnId?: string;\n success?: boolean;\n interrupted?: boolean;\n /** @deprecated Use `model`; retained for compatibility with existing consumers. */\n modelLabel?: string;\n}\n\nexport interface ChatBudgetConfig {\n /** Per-thread/request cost cap in USD. */\n cost?: number;\n /** Max output tokens for one model call. */\n maxTokens?: number;\n}\n\nexport interface ChatUsageBreakdown {\n inputTokens?: number;\n outputTokens?: number;\n reasoningTokens?: number;\n cacheReadTokens?: number;\n cacheWriteTokens?: number;\n totalTokens?: number;\n}\n\nexport interface ChatCostBreakdown {\n model?: string;\n inputUsd?: number;\n outputUsd?: number;\n reasoningUsd?: number;\n cacheReadUsd?: number;\n cacheWriteUsd?: number;\n totalUsd?: number;\n}\n\n/** A suggested prompt shown on the empty state. A bare string is both the label\n * and the submitted text; the object form separates them. */\nexport type Suggestion = string | { label: string; prompt: string };\n\n/** The label shown for a suggestion. */\nexport function suggestionLabel(s: Suggestion): string {\n return typeof s === \"string\" ? s : s.label;\n}\n\n/** The text submitted when a suggestion is clicked. */\nexport function suggestionPrompt(s: Suggestion): string {\n return typeof s === \"string\" ? s : s.prompt;\n}\n\n/** Returns true for an assistant reasoning (\"thinking\") part. */\nexport function isReasoningPart(part: {\n type: string;\n}): part is ReasoningUIPart {\n return part.type === \"reasoning\";\n}\n\n/** Returns true for a file/attachment part. */\nexport function isFilePart(part: { type: string }): part is FileUIPart {\n return part.type === \"file\";\n}\n\n/** A tool part as it appears in an assistant UIMessage — either a typed\n * `tool-<name>` part or the generic `dynamic-tool` part. clicky operations\n * surface as dynamic tools, so the chat UI renders both shapes. */\nexport type AnyToolPart = ToolUIPart | DynamicToolUIPart;\n\n/** Claude Agent SDK permission modes accepted by `permissionMode`. */\nexport const CLAUDE_PERMISSION_MODES = [\n \"default\",\n \"acceptEdits\",\n \"bypassPermissions\",\n \"plan\",\n \"dontAsk\",\n \"auto\",\n] as const;\n\nexport type ClaudePermissionMode = (typeof CLAUDE_PERMISSION_MODES)[number];\n\nexport type ClaudePermissionModeOption = {\n value: ClaudePermissionMode;\n label: string;\n description: string;\n};\n\nexport const CLAUDE_PERMISSION_MODE_OPTIONS: ClaudePermissionModeOption[] = [\n {\n value: \"default\",\n label: \"Default\",\n description:\n \"Prompt for dangerous operations using standard Claude behavior.\",\n },\n {\n value: \"auto\",\n label: \"Auto\",\n description:\n \"Use Claude's classifier to approve or deny permission prompts.\",\n },\n {\n value: \"acceptEdits\",\n label: \"Accept edits\",\n description: \"Automatically accept file edit operations.\",\n },\n {\n value: \"dontAsk\",\n label: \"Don't ask\",\n description: \"Do not prompt; deny actions that are not pre-approved.\",\n },\n {\n value: \"plan\",\n label: \"Plan\",\n description: \"Planning mode with no tool execution.\",\n },\n {\n value: \"bypassPermissions\",\n label: \"Bypass\",\n description:\n \"Bypass permission checks when explicitly allowed by the host.\",\n },\n];\n\n/** Tool metadata shared by the chat shell. It both configures the\n * tool-preferences popover (`name`/`label`/`group`) and carries the schema\n * derived from a clicky RPC operation (`description`/`inputSchema`). The Go\n * backend owns execution; the client uses this only for display and to scope\n * which tools a request may call (passed in the transport `body`). */\n/** Authority for one tool, in Captain's tool vocabulary. The legacy `on`/`off`\n * spellings are still accepted on the way in (see `normalizeToolPolicyValue`)\n * and mean `allow`/`deny`; they are never produced here. The UI still *labels*\n * these On and Off — see `POLICY_LABEL`. */\nexport type ToolPolicy = \"allow\" | \"ask\" | \"deny\" | \"auto\";\n\n/** Canonicalizes a tool policy from the wire, accepting the legacy `on`/`off`\n * spellings the backend still emits from older catalogs and MCP `_meta`.\n *\n * `on` means allow rather than auto: the catalog encoding has no separate allow\n * list, so `on` was always its way of saying auto-run. Keeping private copies of\n * this rule per call site is how the UI and the server drifted apart, so this is\n * the only one. */\nexport function normalizeToolPolicy(value: unknown): ToolPolicy | undefined {\n if (typeof value !== \"string\") return undefined;\n switch (value.trim().toLowerCase()) {\n case \"allow\":\n case \"on\":\n case \"enabled\":\n return \"allow\";\n case \"ask\":\n return \"ask\";\n case \"deny\":\n case \"off\":\n case \"disabled\":\n return \"deny\";\n case \"auto\":\n return \"auto\";\n default:\n return undefined;\n }\n}\n\nexport interface ToolAnnotations {\n title?: string;\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n [key: string]: unknown;\n}\n\nexport interface ToolMeta {\n /** Stable tool name sent to the model (the operation id). */\n name: string;\n /** Human-readable label shown in the tool-preferences popover. */\n label: string;\n /** Bucket heading in the popover — the clicky surface for RPC operations. */\n group?: string;\n /** Display title of the tool's parent surface/entity (e.g. \"Xero Accounts\").\n * Used to nest tools under their entity within a group, and as the\n * disambiguating prefix in flat lists so sibling verbs (\"List\", \"Get\") stay\n * distinguishable. Resolved from the operation's `x-clicky.surface`. */\n parent?: string;\n /** Raw entity name of the tool's surface (e.g. \"accounts\"), when known. */\n entity?: string;\n /** Preference key sent to the backend. Defaults to `name`; group-backed\n * clicky tools set this to the backend tool group. */\n preferenceKey?: string;\n /** Initial backend-owned permission when the chat window first sees this tool. */\n defaultPermission?: ToolPolicy;\n /** Opaque icon name emitted by the backend, resolved by the host UI. */\n icon?: string;\n /** Description shown in tool pickers / tool-call headers. */\n description?: string;\n /** Short usage hints shown in the tool browser. */\n hints?: string[];\n source?: \"clicky\" | \"custom\" | \"mcp\" | string;\n server?: string;\n method?: string;\n path?: string;\n operationName?: string;\n /** The entity verb (list/get/create/update/delete, or a custom action), the\n * custom action's name, and whether the operation addresses a collection or a\n * single entity. Carried so a permission rule resolves the same way here as\n * it does on the server; empty for a tool that projects no clicky operation.\n * @see resolveToolPolicy */\n verb?: string;\n action?: string;\n scope?: string;\n title?: string;\n /** Whether the runtime should treat the tool input schema as strict/closed. */\n strict?: boolean;\n /** Runtime tool annotations/hints, e.g. MCP/Genkit well-known hints. */\n annotations?: ToolAnnotations;\n /** JSON-Schema for the tool's input, assembled from an operation's\n * parameters + request body. Omitted for hand-authored tools. */\n inputSchema?: ChatToolInputSchema;\n outputSchema?: ChatToolInputSchema;\n}\n\nexport type ChatToolInputSchema = JsonSchemaObject;\nexport type JsonSchemaProperty = FormJsonSchemaProperty;\nexport type JSONSchemaProperty = FormJsonSchemaProperty;\n\n/** Returns true for a `dynamic-tool` part (clicky operations surface this way). */\nexport function isDynamicToolPart(part: {\n type: string;\n}): part is DynamicToolUIPart {\n return part.type === \"dynamic-tool\";\n}\n\n/** Returns true for a typed `tool-<name>` part. */\nexport function isTypedToolPart(part: { type: string }): part is ToolUIPart {\n return part.type.startsWith(\"tool-\");\n}\n\n/** The display name of a tool part: the explicit `toolName` for dynamic tools,\n * otherwise the suffix after `tool-`. */\nexport function toolPartName(part: AnyToolPart): string {\n if (isDynamicToolPart(part)) {\n return part.toolName;\n }\n return part.type.slice(\"tool-\".length);\n}\n\nexport interface ToolResultRenderArgs {\n part: AnyToolPart;\n toolName: string;\n output: unknown;\n}\n\nexport type ToolResultRenderer = (args: ToolResultRenderArgs) => ReactNode;\n"],"names":[],"mappings":"AA+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BAAgB,MAA4C;AAC1E,SAAO,KAAK,KAAK,WAAW,OAAO;AACrC;AAIO,SAAS,aAAa,MAA2B;AACtD,MAAI,kBAAkB,IAAI,GAAG;AAC3B,WAAO,KAAK;AAAA,EACd;AACA,SAAO,KAAK,KAAK,MAAM,QAAQ,MAAM;AACvC;"}
|
|
@@ -10,7 +10,16 @@ function usageSnapshotFromMetadata(metadata, options) {
|
|
|
10
10
|
...cost != null ? { cost } : {},
|
|
11
11
|
...metadata.usage ? { usage: metadata.usage } : {},
|
|
12
12
|
...metadata.costBreakdown ? { costBreakdown: metadata.costBreakdown } : {},
|
|
13
|
-
...
|
|
13
|
+
...metadata.backend !== void 0 ? { backend: metadata.backend } : {},
|
|
14
|
+
...metadata.executionMode !== void 0 ? { executionMode: metadata.executionMode } : {},
|
|
15
|
+
...metadata.model !== void 0 ? { model: metadata.model } : {},
|
|
16
|
+
...metadata.model !== void 0 && options.modelLabel ? { modelLabel: options.modelLabel } : {},
|
|
17
|
+
...metadata.captainSessionId !== void 0 ? { captainSessionId: metadata.captainSessionId } : {},
|
|
18
|
+
...metadata.providerSessionId !== void 0 ? { providerSessionId: metadata.providerSessionId } : {},
|
|
19
|
+
...metadata.threadId !== void 0 ? { threadId: metadata.threadId } : {},
|
|
20
|
+
...metadata.turnId !== void 0 ? { turnId: metadata.turnId } : {},
|
|
21
|
+
...metadata.success !== void 0 ? { success: metadata.success } : {},
|
|
22
|
+
...metadata.interrupted !== void 0 ? { interrupted: metadata.interrupted } : {}
|
|
14
23
|
};
|
|
15
24
|
}
|
|
16
25
|
exports.usageSnapshotFromMetadata = usageSnapshotFromMetadata;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-snapshot.cjs","sources":["../../../src/data/chat/usage-snapshot.ts"],"sourcesContent":["import type { ChatMessageMetadata, ChatUsageSummary } from \"./types\";\n\n/**\n * Builds the usage snapshot a chat surfaces (gauge, hover card, config panel)\n * from the last settled assistant turn's metadata.\n *\n * The cost precedence matters: `threadCostUsd` is the conversation's running\n * total, while `cost` is only the turn that just finished. Preferring the\n * cumulative figure is what makes the meter report what the conversation has\n * actually spent — on a multi-turn thread the two differ by roughly the number\n * of turns taken. Backends that do not report a thread total still degrade to\n * the per-turn value rather than showing nothing.\n *\n * Token fields stay per-turn; the whole-conversation breakdown is served\n * separately by the thread costs endpoint.\n */\nexport function usageSnapshotFromMetadata(\n metadata: ChatMessageMetadata,\n options: {
|
|
1
|
+
{"version":3,"file":"usage-snapshot.cjs","sources":["../../../src/data/chat/usage-snapshot.ts"],"sourcesContent":["import type { ChatMessageMetadata, ChatUsageSummary } from \"./types\";\n\n/**\n * Builds the usage snapshot a chat surfaces (gauge, hover card, config panel)\n * from the last settled assistant turn's metadata.\n *\n * The cost precedence matters: `threadCostUsd` is the conversation's running\n * total, while `cost` is only the turn that just finished. Preferring the\n * cumulative figure is what makes the meter report what the conversation has\n * actually spent — on a multi-turn thread the two differ by roughly the number\n * of turns taken. Backends that do not report a thread total still degrade to\n * the per-turn value rather than showing nothing.\n *\n * Token fields stay per-turn; the whole-conversation breakdown is served\n * separately by the thread costs endpoint.\n */\nexport function usageSnapshotFromMetadata(\n metadata: ChatMessageMetadata,\n options: {\n contextWindow?: number | undefined;\n modelLabel?: string | undefined;\n messageCount: number;\n },\n): ChatUsageSummary {\n const cost =\n metadata.threadCostUsd ?? metadata.costBreakdown?.totalUsd ?? metadata.cost;\n return {\n usedTokens: metadata.contextTokens ?? metadata.usage?.totalTokens ?? 0,\n maxTokens: options.contextWindow ?? 0,\n messageCount: options.messageCount,\n ...(cost != null ? { cost } : {}),\n ...(metadata.usage ? { usage: metadata.usage } : {}),\n ...(metadata.costBreakdown ? { costBreakdown: metadata.costBreakdown } : {}),\n ...(metadata.backend !== undefined ? { backend: metadata.backend } : {}),\n ...(metadata.executionMode !== undefined\n ? { executionMode: metadata.executionMode }\n : {}),\n ...(metadata.model !== undefined ? { model: metadata.model } : {}),\n ...(metadata.model !== undefined && options.modelLabel\n ? { modelLabel: options.modelLabel }\n : {}),\n ...(metadata.captainSessionId !== undefined\n ? { captainSessionId: metadata.captainSessionId }\n : {}),\n ...(metadata.providerSessionId !== undefined\n ? { providerSessionId: metadata.providerSessionId }\n : {}),\n ...(metadata.threadId !== undefined ? { threadId: metadata.threadId } : {}),\n ...(metadata.turnId !== undefined ? { turnId: metadata.turnId } : {}),\n ...(metadata.success !== undefined ? { success: metadata.success } : {}),\n ...(metadata.interrupted !== undefined\n ? { interrupted: metadata.interrupted }\n : {}),\n };\n}\n"],"names":[],"mappings":";;AAgBO,SAAS,0BACd,UACA,SAKkB;;AAClB,QAAM,OACJ,SAAS,mBAAiB,cAAS,kBAAT,mBAAwB,aAAY,SAAS;AACzE,SAAO;AAAA,IACL,YAAY,SAAS,mBAAiB,cAAS,UAAT,mBAAgB,gBAAe;AAAA,IACrE,WAAW,QAAQ,iBAAiB;AAAA,IACpC,cAAc,QAAQ;AAAA,IACtB,GAAI,QAAQ,OAAO,EAAE,KAAA,IAAS,CAAA;AAAA,IAC9B,GAAI,SAAS,QAAQ,EAAE,OAAO,SAAS,MAAA,IAAU,CAAA;AAAA,IACjD,GAAI,SAAS,gBAAgB,EAAE,eAAe,SAAS,cAAA,IAAkB,CAAA;AAAA,IACzE,GAAI,SAAS,YAAY,SAAY,EAAE,SAAS,SAAS,QAAA,IAAY,CAAA;AAAA,IACrE,GAAI,SAAS,kBAAkB,SAC3B,EAAE,eAAe,SAAS,cAAA,IAC1B,CAAA;AAAA,IACJ,GAAI,SAAS,UAAU,SAAY,EAAE,OAAO,SAAS,MAAA,IAAU,CAAA;AAAA,IAC/D,GAAI,SAAS,UAAU,UAAa,QAAQ,aACxC,EAAE,YAAY,QAAQ,WAAA,IACtB,CAAA;AAAA,IACJ,GAAI,SAAS,qBAAqB,SAC9B,EAAE,kBAAkB,SAAS,iBAAA,IAC7B,CAAA;AAAA,IACJ,GAAI,SAAS,sBAAsB,SAC/B,EAAE,mBAAmB,SAAS,kBAAA,IAC9B,CAAA;AAAA,IACJ,GAAI,SAAS,aAAa,SAAY,EAAE,UAAU,SAAS,SAAA,IAAa,CAAA;AAAA,IACxE,GAAI,SAAS,WAAW,SAAY,EAAE,QAAQ,SAAS,OAAA,IAAW,CAAA;AAAA,IAClE,GAAI,SAAS,YAAY,SAAY,EAAE,SAAS,SAAS,QAAA,IAAY,CAAA;AAAA,IACrE,GAAI,SAAS,gBAAgB,SACzB,EAAE,aAAa,SAAS,gBACxB,CAAA;AAAA,EAAC;AAET;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-snapshot.d.ts","sourceRoot":"","sources":["../../../src/data/chat/usage-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAErE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"usage-snapshot.d.ts","sourceRoot":"","sources":["../../../src/data/chat/usage-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAErE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE;IACP,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,YAAY,EAAE,MAAM,CAAC;CACtB,GACA,gBAAgB,CA+BlB"}
|
|
@@ -8,7 +8,16 @@ function usageSnapshotFromMetadata(metadata, options) {
|
|
|
8
8
|
...cost != null ? { cost } : {},
|
|
9
9
|
...metadata.usage ? { usage: metadata.usage } : {},
|
|
10
10
|
...metadata.costBreakdown ? { costBreakdown: metadata.costBreakdown } : {},
|
|
11
|
-
...
|
|
11
|
+
...metadata.backend !== void 0 ? { backend: metadata.backend } : {},
|
|
12
|
+
...metadata.executionMode !== void 0 ? { executionMode: metadata.executionMode } : {},
|
|
13
|
+
...metadata.model !== void 0 ? { model: metadata.model } : {},
|
|
14
|
+
...metadata.model !== void 0 && options.modelLabel ? { modelLabel: options.modelLabel } : {},
|
|
15
|
+
...metadata.captainSessionId !== void 0 ? { captainSessionId: metadata.captainSessionId } : {},
|
|
16
|
+
...metadata.providerSessionId !== void 0 ? { providerSessionId: metadata.providerSessionId } : {},
|
|
17
|
+
...metadata.threadId !== void 0 ? { threadId: metadata.threadId } : {},
|
|
18
|
+
...metadata.turnId !== void 0 ? { turnId: metadata.turnId } : {},
|
|
19
|
+
...metadata.success !== void 0 ? { success: metadata.success } : {},
|
|
20
|
+
...metadata.interrupted !== void 0 ? { interrupted: metadata.interrupted } : {}
|
|
12
21
|
};
|
|
13
22
|
}
|
|
14
23
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-snapshot.js","sources":["../../../src/data/chat/usage-snapshot.ts"],"sourcesContent":["import type { ChatMessageMetadata, ChatUsageSummary } from \"./types\";\n\n/**\n * Builds the usage snapshot a chat surfaces (gauge, hover card, config panel)\n * from the last settled assistant turn's metadata.\n *\n * The cost precedence matters: `threadCostUsd` is the conversation's running\n * total, while `cost` is only the turn that just finished. Preferring the\n * cumulative figure is what makes the meter report what the conversation has\n * actually spent — on a multi-turn thread the two differ by roughly the number\n * of turns taken. Backends that do not report a thread total still degrade to\n * the per-turn value rather than showing nothing.\n *\n * Token fields stay per-turn; the whole-conversation breakdown is served\n * separately by the thread costs endpoint.\n */\nexport function usageSnapshotFromMetadata(\n metadata: ChatMessageMetadata,\n options: {
|
|
1
|
+
{"version":3,"file":"usage-snapshot.js","sources":["../../../src/data/chat/usage-snapshot.ts"],"sourcesContent":["import type { ChatMessageMetadata, ChatUsageSummary } from \"./types\";\n\n/**\n * Builds the usage snapshot a chat surfaces (gauge, hover card, config panel)\n * from the last settled assistant turn's metadata.\n *\n * The cost precedence matters: `threadCostUsd` is the conversation's running\n * total, while `cost` is only the turn that just finished. Preferring the\n * cumulative figure is what makes the meter report what the conversation has\n * actually spent — on a multi-turn thread the two differ by roughly the number\n * of turns taken. Backends that do not report a thread total still degrade to\n * the per-turn value rather than showing nothing.\n *\n * Token fields stay per-turn; the whole-conversation breakdown is served\n * separately by the thread costs endpoint.\n */\nexport function usageSnapshotFromMetadata(\n metadata: ChatMessageMetadata,\n options: {\n contextWindow?: number | undefined;\n modelLabel?: string | undefined;\n messageCount: number;\n },\n): ChatUsageSummary {\n const cost =\n metadata.threadCostUsd ?? metadata.costBreakdown?.totalUsd ?? metadata.cost;\n return {\n usedTokens: metadata.contextTokens ?? metadata.usage?.totalTokens ?? 0,\n maxTokens: options.contextWindow ?? 0,\n messageCount: options.messageCount,\n ...(cost != null ? { cost } : {}),\n ...(metadata.usage ? { usage: metadata.usage } : {}),\n ...(metadata.costBreakdown ? { costBreakdown: metadata.costBreakdown } : {}),\n ...(metadata.backend !== undefined ? { backend: metadata.backend } : {}),\n ...(metadata.executionMode !== undefined\n ? { executionMode: metadata.executionMode }\n : {}),\n ...(metadata.model !== undefined ? { model: metadata.model } : {}),\n ...(metadata.model !== undefined && options.modelLabel\n ? { modelLabel: options.modelLabel }\n : {}),\n ...(metadata.captainSessionId !== undefined\n ? { captainSessionId: metadata.captainSessionId }\n : {}),\n ...(metadata.providerSessionId !== undefined\n ? { providerSessionId: metadata.providerSessionId }\n : {}),\n ...(metadata.threadId !== undefined ? { threadId: metadata.threadId } : {}),\n ...(metadata.turnId !== undefined ? { turnId: metadata.turnId } : {}),\n ...(metadata.success !== undefined ? { success: metadata.success } : {}),\n ...(metadata.interrupted !== undefined\n ? { interrupted: metadata.interrupted }\n : {}),\n };\n}\n"],"names":[],"mappings":"AAgBO,SAAS,0BACd,UACA,SAKkB;AAPb;AAQL,QAAM,OACJ,SAAS,mBAAiB,cAAS,kBAAT,mBAAwB,aAAY,SAAS;AACzE,SA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4
|
+
const watchers = /* @__PURE__ */ new Set();
|
|
5
|
+
function registerDebugConsole(listener) {
|
|
6
|
+
listeners.add(listener);
|
|
7
|
+
notify();
|
|
8
|
+
return () => {
|
|
9
|
+
listeners.delete(listener);
|
|
10
|
+
notify();
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function subscribeToDebugConsole(onChange) {
|
|
14
|
+
watchers.add(onChange);
|
|
15
|
+
return () => {
|
|
16
|
+
watchers.delete(onChange);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function notify() {
|
|
20
|
+
for (const watcher of watchers) watcher();
|
|
21
|
+
}
|
|
22
|
+
function debugConsoleAvailable() {
|
|
23
|
+
return listeners.size > 0;
|
|
24
|
+
}
|
|
25
|
+
let consoleOpen = false;
|
|
26
|
+
function setDebugConsoleOpen(open) {
|
|
27
|
+
if (consoleOpen === open) return;
|
|
28
|
+
consoleOpen = open;
|
|
29
|
+
notify();
|
|
30
|
+
}
|
|
31
|
+
function debugConsoleOpen() {
|
|
32
|
+
return consoleOpen && listeners.size > 0;
|
|
33
|
+
}
|
|
34
|
+
function revealDebugConsole(request = {}) {
|
|
35
|
+
for (const listener of listeners) listener(request);
|
|
36
|
+
}
|
|
37
|
+
const DEBUG_CAPTURE_HEADER = "X-Debug-Level";
|
|
38
|
+
const DEBUG_REFRESH_INSPECTION_HEADER = "X-Debug-Refresh-Inspection";
|
|
39
|
+
let captureLevel = "off";
|
|
40
|
+
let refreshInspection = false;
|
|
41
|
+
function setDebugCaptureLevel(level) {
|
|
42
|
+
captureLevel = level;
|
|
43
|
+
}
|
|
44
|
+
function setDebugRefreshInspection(refresh) {
|
|
45
|
+
refreshInspection = refresh;
|
|
46
|
+
}
|
|
47
|
+
function debugCaptureHeaders() {
|
|
48
|
+
if (captureLevel === "off" || listeners.size === 0) return {};
|
|
49
|
+
const headers = { [DEBUG_CAPTURE_HEADER]: captureLevel };
|
|
50
|
+
if (refreshInspection) headers[DEBUG_REFRESH_INSPECTION_HEADER] = "true";
|
|
51
|
+
return headers;
|
|
52
|
+
}
|
|
53
|
+
exports.DEBUG_CAPTURE_HEADER = DEBUG_CAPTURE_HEADER;
|
|
54
|
+
exports.DEBUG_REFRESH_INSPECTION_HEADER = DEBUG_REFRESH_INSPECTION_HEADER;
|
|
55
|
+
exports.debugCaptureHeaders = debugCaptureHeaders;
|
|
56
|
+
exports.debugConsoleAvailable = debugConsoleAvailable;
|
|
57
|
+
exports.debugConsoleOpen = debugConsoleOpen;
|
|
58
|
+
exports.registerDebugConsole = registerDebugConsole;
|
|
59
|
+
exports.revealDebugConsole = revealDebugConsole;
|
|
60
|
+
exports.setDebugCaptureLevel = setDebugCaptureLevel;
|
|
61
|
+
exports.setDebugConsoleOpen = setDebugConsoleOpen;
|
|
62
|
+
exports.setDebugRefreshInspection = setDebugRefreshInspection;
|
|
63
|
+
exports.subscribeToDebugConsole = subscribeToDebugConsole;
|
|
64
|
+
//# sourceMappingURL=debugConsoleSignal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugConsoleSignal.cjs","sources":["../../src/data/debugConsoleSignal.ts"],"sourcesContent":["/**\n * The one thing a result table and the debug console have to agree on: \"show me\n * this\".\n *\n * It is a bare emitter with no dependencies, and it lives here rather than in\n * `devtools/` on purpose. Tables ship in the `data` entry point and the console\n * ships in `devtools`; if the table imported the console to reveal it, every app\n * with a table would carry the console's tables, HAR panel and SSE client\n * whether or not it ever opens one. The dependency runs the other way instead:\n * the console imports this and registers itself.\n */\n\nexport type DebugConsoleRequest = {\n /** The capture to open, when the caller knows which one it produced. */\n recordId?: string | undefined;\n /** The tab to land on, e.g. \"queries\" or \"network\". */\n tab?: string | undefined;\n /**\n * Closes an already-open console instead of re-opening it.\n *\n * Only the console's own trigger sets this. A \"Debug\" action that toggled\n * would close the console for someone who clicked it while it was already\n * open — the opposite of what asking to see a query means.\n */\n toggle?: boolean | undefined;\n};\n\ntype Listener = (request: DebugConsoleRequest) => void;\n\nconst listeners = new Set<Listener>();\nconst watchers = new Set<() => void>();\n\n/**\n * Registers a console. The returned function unregisters it, so a dock that\n * unmounts stops claiming a console exists.\n */\nexport function registerDebugConsole(listener: Listener): () => void {\n listeners.add(listener);\n notify();\n return () => {\n listeners.delete(listener);\n notify();\n };\n}\n\n/**\n * Watches whether a console is mounted, so a menu built before the dock renders\n * gains its \"Debug\" item when the dock arrives rather than staying stale.\n */\nexport function subscribeToDebugConsole(onChange: () => void): () => void {\n watchers.add(onChange);\n return () => {\n watchers.delete(onChange);\n };\n}\n\nfunction notify(): void {\n for (const watcher of watchers) watcher();\n}\n\n/**\n * Whether a console is mounted to reveal.\n *\n * Callers use this to decide whether to offer the action at all: a \"Debug\" menu\n * item that does nothing is worse than no menu item, because it reads as broken\n * rather than as absent.\n */\nexport function debugConsoleAvailable(): boolean {\n return listeners.size > 0;\n}\n\nlet consoleOpen = false;\n\n/**\n * Published by the mounted console as it opens and closes.\n *\n * Its trigger lives in the app's navbar, outside the console's own tree, so\n * \"am I showing an open console\" is not state either side can read from the\n * other without this.\n */\nexport function setDebugConsoleOpen(open: boolean): void {\n if (consoleOpen === open) return;\n consoleOpen = open;\n notify();\n}\n\n/** Whether the mounted console is currently showing. */\nexport function debugConsoleOpen(): boolean {\n return consoleOpen && listeners.size > 0;\n}\n\n/** Asks the mounted console to open, optionally focused on one capture. */\nexport function revealDebugConsole(request: DebugConsoleRequest = {}): void {\n for (const listener of listeners) listener(request);\n}\n\n/** The headers a request arms the server with. Named once, here. */\nexport const DEBUG_CAPTURE_HEADER = \"X-Debug-Level\";\nexport const DEBUG_REFRESH_INSPECTION_HEADER = \"X-Debug-Refresh-Inspection\";\n\nlet captureLevel = \"off\";\nlet refreshInspection = false;\n\n/**\n * Published by the mounted console whenever its level picker changes.\n *\n * It lives beside the reveal signal for the same reason: a component that makes\n * a bare `fetch` — the profile builder's sample call, say — has to arm it, and\n * importing the console to read one string would drag the whole console into\n * that bundle.\n */\nexport function setDebugCaptureLevel(level: string): void {\n captureLevel = level;\n}\n\n/**\n * Published by the console alongside the level: whether requests should also\n * rebuild every metadata lookup instead of reading the cache.\n */\nexport function setDebugRefreshInspection(refresh: boolean): void {\n refreshInspection = refresh;\n}\n\n/**\n * Headers that arm a request at whatever the console is currently set to, and\n * nothing at all when no console is open.\n *\n * Spread into a bare `fetch`. Requests that go through a wrapped client are\n * armed by the wrapper instead and need not call this.\n */\nexport function debugCaptureHeaders(): Record<string, string> {\n if (captureLevel === \"off\" || listeners.size === 0) return {};\n const headers: Record<string, string> = { [DEBUG_CAPTURE_HEADER]: captureLevel };\n // Only present when on: a header carrying \"false\" would make every request\n // look like it had opted out of something.\n if (refreshInspection) headers[DEBUG_REFRESH_INSPECTION_HEADER] = \"true\";\n return headers;\n}\n"],"names":[],"mappings":";;AA6BA,MAAM,gCAAgB,IAAA;AACtB,MAAM,+BAAe,IAAA;AAMd,SAAS,qBAAqB,UAAgC;AACnE,YAAU,IAAI,QAAQ;AACtB,SAAA;AACA,SAAO,MAAM;AACX,cAAU,OAAO,QAAQ;AACzB,WAAA;AAAA,EACF;AACF;AAMO,SAAS,wBAAwB,UAAkC;AACxE,WAAS,IAAI,QAAQ;AACrB,SAAO,MAAM;AACX,aAAS,OAAO,QAAQ;AAAA,EAC1B;AACF;AAEA,SAAS,SAAe;AACtB,aAAW,WAAW,SAAU,SAAA;AAClC;AASO,SAAS,wBAAiC;AAC/C,SAAO,UAAU,OAAO;AAC1B;AAEA,IAAI,cAAc;AASX,SAAS,oBAAoB,MAAqB;AACvD,MAAI,gBAAgB,KAAM;AAC1B,gBAAc;AACd,SAAA;AACF;AAGO,SAAS,mBAA4B;AAC1C,SAAO,eAAe,UAAU,OAAO;AACzC;AAGO,SAAS,mBAAmB,UAA+B,IAAU;AAC1E,aAAW,YAAY,UAAW,UAAS,OAAO;AACpD;AAGO,MAAM,uBAAuB;AAC7B,MAAM,kCAAkC;AAE/C,IAAI,eAAe;AACnB,IAAI,oBAAoB;AAUjB,SAAS,qBAAqB,OAAqB;AACxD,iBAAe;AACjB;AAMO,SAAS,0BAA0B,SAAwB;AAChE,sBAAoB;AACtB;AASO,SAAS,sBAA8C;AAC5D,MAAI,iBAAiB,SAAS,UAAU,SAAS,UAAU,CAAA;AAC3D,QAAM,UAAkC,EAAE,CAAC,oBAAoB,GAAG,aAAA;AAGlE,MAAI,kBAAmB,SAAQ,+BAA+B,IAAI;AAClE,SAAO;AACT;;;;;;;;;;;;"}
|