@flanksource/clicky-ui 0.3.25 → 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/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 +22 -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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolPreferencesList.js","sources":["../../../src/data/ai/ToolPreferencesList.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { UiChevronDown, UiChevronRight } from \"../../icons\";\nimport { cn } from \"../../lib/utils\";\nimport { Icon } from \"../Icon\";\nimport type { ToolMeta, ToolMode } from \"../chat/types\";\nimport {\n BADGE_DESCRIPTION,\n BADGE_LABEL,\n NO_PARENT,\n commonMode,\n entryMode,\n groupedToolEntriesWithPreferences,\n groupToolMode,\n nextMode,\n type BadgeMode,\n type ToolGroup,\n type ToolPreferenceEntry,\n type ToolSubGroup,\n} from \"./ToolPreferences.model\";\n\nexport type CompactToolPreferencesListProps = {\n tools: ToolMeta[];\n value: Record<string, ToolMode>;\n onChange: (prefs: Record<string, ToolMode>) => void;\n title?: string | undefined;\n emptyLabel?: string | undefined;\n className?: string | undefined;\n};\n\nfunction ModeBadge({ mode }: { mode: BadgeMode }) {\n return (\n <span\n className={cn(\n \"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium\",\n mode === \"on\" &&\n \"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400\",\n mode === \"auto\" && \"bg-sky-500/10 text-sky-600 dark:text-sky-400\",\n mode === \"ask\" && \"bg-amber-500/10 text-amber-600 dark:text-amber-500\",\n mode === \"off\" && \"text-muted-foreground\",\n mode === \"mixed\" &&\n \"bg-muted text-muted-foreground ring-1 ring-inset ring-border\",\n )}\n title={BADGE_DESCRIPTION[mode]}\n >\n {BADGE_LABEL[mode]}\n </span>\n );\n}\n\nfunction ToolGroupHeader({\n group,\n count,\n collapsed,\n mode,\n onCollapseToggle,\n onModeToggle,\n}: {\n group: string;\n count: number;\n collapsed: boolean;\n mode: BadgeMode;\n onCollapseToggle: () => void;\n onModeToggle: () => void;\n}) {\n return (\n <div className=\"grid grid-cols-[1.25rem_minmax(0,1fr)] items-center gap-1 px-1 py-0.5\">\n <button\n type=\"button\"\n aria-label={`${collapsed ? \"Expand\" : \"Collapse\"} ${group}`}\n title={`${collapsed ? \"Expand\" : \"Collapse\"} ${group}`}\n className=\"inline-flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-background hover:text-foreground\"\n onClick={onCollapseToggle}\n >\n <Icon\n icon={collapsed ? UiChevronRight : UiChevronDown}\n className=\"size-3.5\"\n />\n </button>\n <button\n type=\"button\"\n aria-label={`Toggle ${group} group`}\n title={`Cycle all ${count} ${count === 1 ? \"tool\" : \"tools\"} in ${group}`}\n className=\"flex min-w-0 items-center gap-1.5 rounded px-1 py-0.5 text-left hover:bg-background/70\"\n onClick={onModeToggle}\n >\n <span className=\"flex min-w-0 flex-1 items-center gap-1.5\">\n <span className=\"min-w-0 truncate text-[10px] font-semibold uppercase tracking-wider text-muted-foreground\">\n {group}\n </span>\n <span className=\"shrink-0 rounded bg-background px-1 text-[10px] text-muted-foreground\">\n {count}\n </span>\n </span>\n <ModeBadge mode={mode} />\n </button>\n </div>\n );\n}\n\nfunction ToolRow({\n entry,\n mode,\n onToggle,\n indented = false,\n}: {\n entry: ToolPreferenceEntry;\n mode: ToolMode;\n onToggle: (entry: ToolPreferenceEntry, current: ToolMode) => void;\n indented?: boolean;\n}) {\n return (\n <button\n type=\"button\"\n className={cn(\n \"flex w-full items-center justify-between gap-2 rounded px-1.5 py-0.5 text-left hover:bg-accent\",\n indented && \"pl-7\",\n )}\n title={entry.tool.name}\n onClick={() => onToggle(entry, mode)}\n >\n <span\n className={cn(\n \"min-w-0 truncate text-xs\",\n mode === \"off\" && \"text-muted-foreground line-through\",\n )}\n >\n {entry.label}\n </span>\n <ModeBadge mode={mode} />\n </button>\n );\n}\n\nfunction ToolParentHeader({\n parent,\n count,\n collapsed,\n mode,\n onCollapseToggle,\n onModeToggle,\n}: {\n parent: string;\n count: number;\n collapsed: boolean;\n mode: BadgeMode;\n onCollapseToggle: () => void;\n onModeToggle: () => void;\n}) {\n return (\n <div className=\"grid grid-cols-[1.25rem_minmax(0,1fr)] items-center gap-1 py-0.5 pl-4 pr-1\">\n <button\n type=\"button\"\n aria-label={`${collapsed ? \"Expand\" : \"Collapse\"} ${parent}`}\n title={`${collapsed ? \"Expand\" : \"Collapse\"} ${parent}`}\n className=\"inline-flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-background hover:text-foreground\"\n onClick={onCollapseToggle}\n >\n <Icon\n icon={collapsed ? UiChevronRight : UiChevronDown}\n className=\"size-3.5\"\n />\n </button>\n <button\n type=\"button\"\n aria-label={`Toggle ${parent} tools`}\n title={`Cycle all ${count} ${count === 1 ? \"tool\" : \"tools\"} in ${parent}`}\n className=\"flex min-w-0 items-center gap-1.5 rounded px-1 py-0.5 text-left hover:bg-background/70\"\n onClick={onModeToggle}\n >\n <span className=\"flex min-w-0 flex-1 items-center gap-1.5\">\n <span className=\"min-w-0 truncate text-[11px] font-medium text-foreground/70\">\n {parent}\n </span>\n <span className=\"shrink-0 rounded bg-background px-1 text-[10px] text-muted-foreground\">\n {count}\n </span>\n </span>\n <ModeBadge mode={mode} />\n </button>\n </div>\n );\n}\n\nfunction ToolSubGroupBlock({\n subGroup,\n value,\n open,\n onToggle,\n onToggleEntry,\n onCycleEntries,\n}: {\n subGroup: ToolSubGroup;\n value: Record<string, ToolMode>;\n open: boolean;\n onToggle: () => void;\n onToggleEntry: (entry: ToolPreferenceEntry, current: ToolMode) => void;\n onCycleEntries: (entries: ToolPreferenceEntry[], current: ToolMode) => void;\n}) {\n const hasParent = subGroup.parent !== NO_PARENT;\n const rows = subGroup.entries.map((entry) => (\n <ToolRow\n key={entry.key}\n entry={entry}\n mode={entryMode(entry, value)}\n onToggle={onToggleEntry}\n indented={hasParent}\n />\n ));\n if (!hasParent) return <>{rows}</>;\n return (\n <div>\n <ToolParentHeader\n parent={subGroup.parent}\n count={subGroup.entries.length}\n collapsed={!open}\n mode={commonMode(subGroup.entries, value)}\n onCollapseToggle={onToggle}\n onModeToggle={() =>\n onCycleEntries(\n subGroup.entries,\n groupToolMode(subGroup.entries, value),\n )\n }\n />\n {open && rows}\n </div>\n );\n}\n\nexport function CompactToolList({\n groups,\n value,\n onChange,\n emptyLabel = \"No tools available\",\n}: {\n groups: ToolGroup[];\n value: Record<string, ToolMode>;\n onChange: (prefs: Record<string, ToolMode>) => void;\n emptyLabel?: string | undefined;\n}) {\n const [expanded, setExpanded] = useState<Set<string>>(() => new Set());\n if (groups.length === 0) {\n return (\n <div className=\"px-2 py-2 text-xs text-muted-foreground\">\n {emptyLabel}\n </div>\n );\n }\n const isOpen = (key: string) => expanded.has(key);\n const toggle = (key: string) =>\n setExpanded((current) => {\n const next = new Set(current);\n if (next.has(key)) next.delete(key);\n else next.add(key);\n return next;\n });\n const handleToggle = (entry: ToolPreferenceEntry, current: ToolMode) =>\n onChange({ ...value, [entry.key]: nextMode(current) });\n const cycleEntries = (entries: ToolPreferenceEntry[], current: ToolMode) => {\n const next = nextMode(current);\n const updated = { ...value };\n for (const entry of entries) updated[entry.key] = next;\n onChange(updated);\n };\n return (\n <div className=\"space-y-1\">\n {groups.map((group) => {\n const groupOpen = isOpen(group.group);\n return (\n <div key={group.group}>\n <ToolGroupHeader\n group={group.group}\n count={group.entries.length}\n collapsed={!groupOpen}\n mode={commonMode(group.entries, value)}\n onCollapseToggle={() => toggle(group.group)}\n onModeToggle={() =>\n cycleEntries(group.entries, groupToolMode(group.entries, value))\n }\n />\n {groupOpen && (\n <div className=\"space-y-0.5 p-0.5\">\n {group.subGroups.map((subGroup) => {\n const parentKey = `${group.group}///${subGroup.parent}`;\n return (\n <ToolSubGroupBlock\n key={subGroup.parent}\n subGroup={subGroup}\n value={value}\n open={isOpen(parentKey)}\n onToggle={() => toggle(parentKey)}\n onToggleEntry={handleToggle}\n onCycleEntries={cycleEntries}\n />\n );\n })}\n </div>\n )}\n </div>\n );\n })}\n </div>\n );\n}\n\nexport function CompactToolPreferencesList({\n tools,\n value,\n onChange,\n title = \"Tools preferences\",\n emptyLabel = \"No tools available\",\n className,\n}: CompactToolPreferencesListProps) {\n const groups = useMemo(\n () => groupedToolEntriesWithPreferences(tools, value),\n [tools, value],\n );\n return (\n <div className={cn(\"space-y-2\", className)}>\n {title && (\n <div className=\"text-xs font-medium text-muted-foreground\">{title}</div>\n )}\n <CompactToolList\n groups={groups}\n value={value}\n onChange={onChange}\n emptyLabel={emptyLabel}\n />\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;AA6BA,SAAS,UAAU,EAAE,QAA6B;AAChD,SACE;AAA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AAAA,YACf,gBAAgB;AAAA,UAAA;AAAA,UANX,SAAS;AAAA,QAAA;AAAA,MASpB,CAAC,EAAA,CACH;AAAA,IAAA,EAAA,GA3BM,MAAM,KA6BhB;AAAA,EAEJ,CAAC,EAAA,CACH;AAEJ;AAEO,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,aAAa;AAAA,EACb;AACF,GAAoC;AAClC,QAAM,SAAS;AAAA,IACb,MAAM,kCAAkC,OAAO,KAAK;AAAA,IACpD,CAAC,OAAO,KAAK;AAAA,EAAA;AAEf,8BACG,OAAA,EAAI,WAAW,GAAG,aAAa,SAAS,GACtC,UAAA;AAAA,IAAA,SACC,oBAAC,OAAA,EAAI,WAAU,6CAA6C,UAAA,OAAM;AAAA,IAEpE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"ToolPreferencesList.js","sources":["../../../src/data/ai/ToolPreferencesList.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { UiChevronDown, UiChevronRight } from \"../../icons\";\nimport { cn } from \"../../lib/utils\";\nimport { Icon } from \"../Icon\";\nimport type { ToolMeta, ToolPolicy } from \"../chat/types\";\nimport type { PermissionRule } from \"../chat/tool-policy\";\nimport {\n BADGE_DESCRIPTION,\n BADGE_LABEL,\n NO_PARENT,\n commonMode,\n entryMode,\n groupedToolEntriesWithPreferences,\n groupToolPolicy,\n nextMode,\n type BadgePolicy,\n type ToolGroup,\n type ToolPreferenceEntry,\n type ToolSubGroup,\n} from \"./ToolPreferences.model\";\n\nexport type CompactToolPreferencesListProps = {\n tools: ToolMeta[];\n /** The effective mode of every tool, keyed by name — what the rows render. */\n value: Record<string, ToolPolicy>;\n /** Emits the rule a toggle means: a group header emits a group rule, a parent\n * header a group+parent rule, and a row a name rule. The caller appends it to\n * the user's list, where a name rule outranks the group rule above it.\n *\n * This is deliberately not \"here is the new map\". A group toggle that wrote\n * every current member's name would stop applying the moment the catalog\n * gained a member, and the user would have no way to tell. */\n onRule: (rule: PermissionRule) => void;\n title?: string | undefined;\n emptyLabel?: string | undefined;\n className?: string | undefined;\n};\n\nfunction ModeBadge({ mode }: { mode: BadgePolicy }) {\n return (\n <span\n className={cn(\n \"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium\",\n mode === \"allow\" &&\n \"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400\",\n mode === \"auto\" && \"bg-sky-500/10 text-sky-600 dark:text-sky-400\",\n mode === \"ask\" && \"bg-amber-500/10 text-amber-600 dark:text-amber-500\",\n mode === \"deny\" && \"text-muted-foreground\",\n mode === \"mixed\" &&\n \"bg-muted text-muted-foreground ring-1 ring-inset ring-border\",\n )}\n title={BADGE_DESCRIPTION[mode]}\n >\n {BADGE_LABEL[mode]}\n </span>\n );\n}\n\nfunction ToolGroupHeader({\n group,\n count,\n collapsed,\n mode,\n onCollapseToggle,\n onModeToggle,\n}: {\n group: string;\n count: number;\n collapsed: boolean;\n mode: BadgePolicy;\n onCollapseToggle: () => void;\n onModeToggle: () => void;\n}) {\n return (\n <div className=\"grid grid-cols-[1.25rem_minmax(0,1fr)] items-center gap-1 px-1 py-0.5\">\n <button\n type=\"button\"\n aria-label={`${collapsed ? \"Expand\" : \"Collapse\"} ${group}`}\n title={`${collapsed ? \"Expand\" : \"Collapse\"} ${group}`}\n className=\"inline-flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-background hover:text-foreground\"\n onClick={onCollapseToggle}\n >\n <Icon\n icon={collapsed ? UiChevronRight : UiChevronDown}\n className=\"size-3.5\"\n />\n </button>\n <button\n type=\"button\"\n aria-label={`Toggle ${group} group`}\n title={`Cycle all ${count} ${count === 1 ? \"tool\" : \"tools\"} in ${group}`}\n className=\"flex min-w-0 items-center gap-1.5 rounded px-1 py-0.5 text-left hover:bg-background/70\"\n onClick={onModeToggle}\n >\n <span className=\"flex min-w-0 flex-1 items-center gap-1.5\">\n <span className=\"min-w-0 truncate text-[10px] font-semibold uppercase tracking-wider text-muted-foreground\">\n {group}\n </span>\n <span className=\"shrink-0 rounded bg-background px-1 text-[10px] text-muted-foreground\">\n {count}\n </span>\n </span>\n <ModeBadge mode={mode} />\n </button>\n </div>\n );\n}\n\nfunction ToolRow({\n entry,\n mode,\n onToggle,\n indented = false,\n}: {\n entry: ToolPreferenceEntry;\n mode: ToolPolicy;\n onToggle: (entry: ToolPreferenceEntry, current: ToolPolicy) => void;\n indented?: boolean;\n}) {\n return (\n <button\n type=\"button\"\n className={cn(\n \"flex w-full items-center justify-between gap-2 rounded px-1.5 py-0.5 text-left hover:bg-accent\",\n indented && \"pl-7\",\n )}\n title={entry.tool.name}\n onClick={() => onToggle(entry, mode)}\n >\n <span\n className={cn(\n \"min-w-0 truncate text-xs\",\n mode === \"deny\" && \"text-muted-foreground line-through\",\n )}\n >\n {entry.label}\n </span>\n <ModeBadge mode={mode} />\n </button>\n );\n}\n\nfunction ToolParentHeader({\n parent,\n count,\n collapsed,\n mode,\n onCollapseToggle,\n onModeToggle,\n}: {\n parent: string;\n count: number;\n collapsed: boolean;\n mode: BadgePolicy;\n onCollapseToggle: () => void;\n onModeToggle: () => void;\n}) {\n return (\n <div className=\"grid grid-cols-[1.25rem_minmax(0,1fr)] items-center gap-1 py-0.5 pl-4 pr-1\">\n <button\n type=\"button\"\n aria-label={`${collapsed ? \"Expand\" : \"Collapse\"} ${parent}`}\n title={`${collapsed ? \"Expand\" : \"Collapse\"} ${parent}`}\n className=\"inline-flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-background hover:text-foreground\"\n onClick={onCollapseToggle}\n >\n <Icon\n icon={collapsed ? UiChevronRight : UiChevronDown}\n className=\"size-3.5\"\n />\n </button>\n <button\n type=\"button\"\n aria-label={`Toggle ${parent} tools`}\n title={`Cycle all ${count} ${count === 1 ? \"tool\" : \"tools\"} in ${parent}`}\n className=\"flex min-w-0 items-center gap-1.5 rounded px-1 py-0.5 text-left hover:bg-background/70\"\n onClick={onModeToggle}\n >\n <span className=\"flex min-w-0 flex-1 items-center gap-1.5\">\n <span className=\"min-w-0 truncate text-[11px] font-medium text-foreground/70\">\n {parent}\n </span>\n <span className=\"shrink-0 rounded bg-background px-1 text-[10px] text-muted-foreground\">\n {count}\n </span>\n </span>\n <ModeBadge mode={mode} />\n </button>\n </div>\n );\n}\n\nfunction ToolSubGroupBlock({\n subGroup,\n value,\n open,\n onToggle,\n onToggleEntry,\n onCycleSubGroup,\n}: {\n subGroup: ToolSubGroup;\n value: Record<string, ToolPolicy>;\n open: boolean;\n onToggle: () => void;\n onToggleEntry: (entry: ToolPreferenceEntry, current: ToolPolicy) => void;\n onCycleSubGroup: (subGroup: ToolSubGroup, current: ToolPolicy) => void;\n}) {\n const hasParent = subGroup.parent !== NO_PARENT;\n const rows = subGroup.entries.map((entry) => (\n <ToolRow\n key={entry.key}\n entry={entry}\n mode={entryMode(entry, value)}\n onToggle={onToggleEntry}\n indented={hasParent}\n />\n ));\n if (!hasParent) return <>{rows}</>;\n return (\n <div>\n <ToolParentHeader\n parent={subGroup.parent}\n count={subGroup.entries.length}\n collapsed={!open}\n mode={commonMode(subGroup.entries, value)}\n onCollapseToggle={onToggle}\n onModeToggle={() =>\n onCycleSubGroup(subGroup, groupToolPolicy(subGroup.entries, value))\n }\n />\n {open && rows}\n </div>\n );\n}\n\nexport function CompactToolList({\n groups,\n value,\n onRule,\n emptyLabel = \"No tools available\",\n}: {\n groups: ToolGroup[];\n value: Record<string, ToolPolicy>;\n onRule: (rule: PermissionRule) => void;\n emptyLabel?: string | undefined;\n}) {\n const [expanded, setExpanded] = useState<Set<string>>(() => new Set());\n if (groups.length === 0) {\n return (\n <div className=\"px-2 py-2 text-xs text-muted-foreground\">\n {emptyLabel}\n </div>\n );\n }\n const isOpen = (key: string) => expanded.has(key);\n const toggle = (key: string) =>\n setExpanded((current) => {\n const next = new Set(current);\n if (next.has(key)) next.delete(key);\n else next.add(key);\n return next;\n });\n const handleToggle = (entry: ToolPreferenceEntry, current: ToolPolicy) =>\n onRule({ name: entry.key, policy: nextMode(current) });\n const cycleGroup = (group: ToolGroup, current: ToolPolicy) =>\n onRule({ group: group.group, policy: nextMode(current) });\n // A parent is a subdivision of one group, not a group of its own, so the rule\n // has to name both — a bare `parent` would reach the same display title under\n // a different group.\n const cycleSubGroup = (\n group: ToolGroup,\n subGroup: ToolSubGroup,\n current: ToolPolicy,\n ) =>\n onRule({\n group: group.group,\n parent: subGroup.parent,\n policy: nextMode(current),\n });\n return (\n <div className=\"space-y-1\">\n {groups.map((group) => {\n const groupOpen = isOpen(group.group);\n return (\n <div key={group.group}>\n <ToolGroupHeader\n group={group.group}\n count={group.entries.length}\n collapsed={!groupOpen}\n mode={commonMode(group.entries, value)}\n onCollapseToggle={() => toggle(group.group)}\n onModeToggle={() =>\n cycleGroup(group, groupToolPolicy(group.entries, value))\n }\n />\n {groupOpen && (\n <div className=\"space-y-0.5 p-0.5\">\n {group.subGroups.map((subGroup) => {\n const parentKey = `${group.group}///${subGroup.parent}`;\n return (\n <ToolSubGroupBlock\n key={subGroup.parent}\n subGroup={subGroup}\n value={value}\n open={isOpen(parentKey)}\n onToggle={() => toggle(parentKey)}\n onToggleEntry={handleToggle}\n onCycleSubGroup={(sub, current) =>\n cycleSubGroup(group, sub, current)\n }\n />\n );\n })}\n </div>\n )}\n </div>\n );\n })}\n </div>\n );\n}\n\nexport function CompactToolPreferencesList({\n tools,\n value,\n onRule,\n title = \"Tools preferences\",\n emptyLabel = \"No tools available\",\n className,\n}: CompactToolPreferencesListProps) {\n const groups = useMemo(\n () => groupedToolEntriesWithPreferences(tools, value),\n [tools, value],\n );\n return (\n <div className={cn(\"space-y-2\", className)}>\n {title && (\n <div className=\"text-xs font-medium text-muted-foreground\">{title}</div>\n )}\n <CompactToolList\n groups={groups}\n value={value}\n onRule={onRule}\n emptyLabel={empty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AA,UAAA;AAAA,YAEC;AAAA,YACA;AAAA,YACA,MAAM,OAAO,SAAS;AAAA,YACtB,UAAU,MAAM,OAAO,SAAS;AAAA,YAChC,eAAe;AAAA,YACf,iBAAiB,CAAC,KAAK,YACrB,cAAc,OAAO,KAAK,OAAO;AAAA,UAAA;AAAA,UAP9B,SAAS;AAAA,QAAA;AAAA,MAWpB,CAAC,EAAA,CACH;AAAA,IAAA,EAAA,GA7BM,MAAM,KA+BhB;AAAA,EAEJ,CAAC,EAAA,CACH;AAEJ;AAEO,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,aAAa;AAAA,EACb;AACF,GAAoC;AAClC,QAAM,SAAS;AAAA,IACb,MAAM,kCAAkC,OAAO,KAAK;AAAA,IACpD,CAAC,OAAO,KAAK;AAAA,EAAA;AAEf,8BACG,OAAA,EAAI,WAAW,GAAG,aAAa,SAAS,GACtC,UAAA;AAAA,IAAA,SACC,oBAAC,OAAA,EAAI,WAAU,6CAA6C,UAAA,OAAM;AAAA,IAEpE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,GACF;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-window-context.cjs","sources":["../../../src/data/ai/chat-window-context.ts"],"sourcesContent":["// Non-component half of the chat window manager: the context object, the hook,\n// id helpers, persistence and layout maths. Split from the Provider (a .tsx\n// component) so this file stays JSX-free — matching the repo idiom of keeping\n// context/hooks in a .ts (see hooks/use-theme.ts, data/test-runner/context.ts)\n// and keeping React-Fast-Refresh happy.\nimport { createContext, useContext } from \"react\";\nimport type { ChatContextItem } from \"./context\";\nimport type {
|
|
1
|
+
{"version":3,"file":"chat-window-context.cjs","sources":["../../../src/data/ai/chat-window-context.ts"],"sourcesContent":["// Non-component half of the chat window manager: the context object, the hook,\n// id helpers, persistence and layout maths. Split from the Provider (a .tsx\n// component) so this file stays JSX-free — matching the repo idiom of keeping\n// context/hooks in a .ts (see hooks/use-theme.ts, data/test-runner/context.ts)\n// and keeping React-Fast-Refresh happy.\nimport { createContext, useContext } from \"react\";\nimport type { ChatContextItem } from \"./context\";\nimport type { PermissionPolicy } from \"../chat/tool-policy\";\nimport { zIndex } from \"../../overlay/zIndex\";\n\n/** Live state of one floating chat window. Position/size/maximized are\n * persisted to localStorage; the rest is session-only. */\nexport interface ChatWindowState {\n id: string;\n threadId: string | null;\n initialModel: string | null;\n x: number;\n y: number;\n width: number;\n height: number;\n zIndex: number;\n maximized: boolean;\n /** A prompt to auto-send when the window mounts (the `id` lets the window\n * detect a fresh request even if the text repeats). */\n initialPrompt: { id: number; text: string } | null;\n contextItems: ChatContextItem[];\n /** The ordered rules the surface that opened this window declares. They sit\n * under the user.s own rules and over the tool catalog.s defaults, so a\n * surface can narrow a family without overriding a toggle. */\n toolPolicy: PermissionPolicy;\n}\n\nexport interface OpenPanelOpts {\n threadId?: string | null;\n initialModel?: string | null;\n initialPrompt?: { id: number; text: string } | null;\n contextItems?: ChatContextItem[];\n /** See {@link ChatWindowState.toolPolicy}. */\n toolPolicy?: PermissionPolicy;\n}\n\nexport interface ChatWindowManagerValue {\n panels: ChatWindowState[];\n openPanel: (opts?: OpenPanelOpts) => string;\n closePanel: (id: string) => void;\n updatePanel: (id: string, partial: Partial<ChatWindowState>) => void;\n bringToFront: (id: string) => void;\n maximizePanel: (id: string) => void;\n /** Reuses the front-most existing window (merging in any new prompt/context)\n * or opens a fresh one when none exist. */\n findOrCreatePanel: (opts?: OpenPanelOpts) => string;\n}\n\nexport const ChatWindowManagerContext = createContext<ChatWindowManagerValue | null>(null);\n\nexport function useChatWindowManager(): ChatWindowManagerValue {\n const ctx = useContext(ChatWindowManagerContext);\n if (!ctx) throw new Error(\"useChatWindowManager must be used within <ChatWindowManagerProvider>\");\n return ctx;\n}\n\nexport const MAX_PANELS = 6;\nexport const DEFAULT_WIDTH = 520;\nexport const DEFAULT_HEIGHT = 700;\nexport const CASCADE_OFFSET = 30;\nexport const Z_BASE = zIndex.chatWindow;\n\nfunction storageKey(storageId: string) {\n return `chat-panels:${storageId}`;\n}\n\ninterface PersistedPanel {\n id: string;\n threadId: string | null;\n x: number;\n y: number;\n width: number;\n height: number;\n maximized: boolean;\n}\n\nexport function loadPanels(storageId: string): ChatWindowState[] {\n if (typeof window === \"undefined\") return [];\n try {\n const raw = localStorage.getItem(storageKey(storageId));\n if (!raw) return [];\n const persisted: PersistedPanel[] = JSON.parse(raw);\n return persisted.map((p, i) => ({\n ...p,\n initialModel: null,\n zIndex: Z_BASE + i,\n initialPrompt: null,\n contextItems: [],\n // A restored window is not attached to a surface yet, so tools fall back\n // to the catalog defaults until one reopens it.\n toolPolicy: [],\n }));\n } catch {\n return [];\n }\n}\n\nexport function savePanels(storageId: string, panels: ChatWindowState[]) {\n const persisted: PersistedPanel[] = panels.map((p) => ({\n id: p.id,\n threadId: p.threadId,\n x: p.x,\n y: p.y,\n width: p.width,\n height: p.height,\n maximized: p.maximized,\n }));\n localStorage.setItem(storageKey(storageId), JSON.stringify(persisted));\n}\n\nlet _panelId = 0;\nexport function nextPanelId(): string {\n return `panel-${++_panelId}-${Date.now()}`;\n}\n\nlet _promptId = 0;\n/** A monotonic id stamped onto an `initialPrompt` so a window re-sends even when\n * the same text is requested twice. */\nexport function nextPromptId(): number {\n return ++_promptId;\n}\n\n/** Re-indexes z so values stay compact (61, 62, …) with `frontId` on top. */\nexport function reindex(panels: ChatWindowState[], frontId?: string): ChatWindowState[] {\n const sorted = [...panels].sort((a, b) => a.zIndex - b.zIndex);\n if (frontId) {\n const idx = sorted.findIndex((p) => p.id === frontId);\n if (idx >= 0) {\n const [item] = sorted.splice(idx, 1);\n if (item) sorted.push(item);\n }\n }\n return sorted.map((p, i) => ({ ...p, zIndex: Z_BASE + i }));\n}\n"],"names":["createContext","useContext","zIndex"],"mappings":";;;;AAqDO,MAAM,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AACrC,SAAO,EAAE;AACX;AAGO,SAAS,QAAQ,QAA2B,SAAqC;AACtF,QAAM,SAAS,CAAC,GAAG,MAAM,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM;AAC7D,MAAI,SAAS;AACX,UAAM,MAAM,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,OAAO;AACpD,QAAI,OAAO,GAAG;AACZ,YAAM,CAAC,IAAI,IAAI,OAAO,OAAO,KAAK,CAAC;AACnC,UAAI,KAAM,QAAO,KAAK,IAAI;AAAA,IAC5B;AAAA,EACF;AACA,SAAO,OAAO,IAAI,CAAC,GAAG,OAAO,EAAE,GAAG,GAAG,QAAQ,SAAS,EAAA,EAAI;AAC5D;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChatContextItem } from './context';
|
|
2
|
-
import {
|
|
2
|
+
import { PermissionPolicy } from '../chat/tool-policy';
|
|
3
3
|
/** Live state of one floating chat window. Position/size/maximized are
|
|
4
4
|
* persisted to localStorage; the rest is session-only. */
|
|
5
5
|
export interface ChatWindowState {
|
|
@@ -19,10 +19,10 @@ export interface ChatWindowState {
|
|
|
19
19
|
text: string;
|
|
20
20
|
} | null;
|
|
21
21
|
contextItems: ChatContextItem[];
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
22
|
+
/** The ordered rules the surface that opened this window declares. They sit
|
|
23
|
+
* under the user.s own rules and over the tool catalog.s defaults, so a
|
|
24
|
+
* surface can narrow a family without overriding a toggle. */
|
|
25
|
+
toolPolicy: PermissionPolicy;
|
|
26
26
|
}
|
|
27
27
|
export interface OpenPanelOpts {
|
|
28
28
|
threadId?: string | null;
|
|
@@ -32,8 +32,8 @@ export interface OpenPanelOpts {
|
|
|
32
32
|
text: string;
|
|
33
33
|
} | null;
|
|
34
34
|
contextItems?: ChatContextItem[];
|
|
35
|
-
/** See {@link ChatWindowState.
|
|
36
|
-
|
|
35
|
+
/** See {@link ChatWindowState.toolPolicy}. */
|
|
36
|
+
toolPolicy?: PermissionPolicy;
|
|
37
37
|
}
|
|
38
38
|
export interface ChatWindowManagerValue {
|
|
39
39
|
panels: ChatWindowState[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-window-context.d.ts","sourceRoot":"","sources":["../../../src/data/ai/chat-window-context.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"chat-window-context.d.ts","sourceRoot":"","sources":["../../../src/data/ai/chat-window-context.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG5D;2DAC2D;AAC3D,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB;4DACwD;IACxD,aAAa,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACnD,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC;;mEAE+D;IAC/D,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE;QAAE,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CAAC,MAAM,EAAE,eAAe,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,eAAe,EAAE,CAUtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-window-context.js","sources":["../../../src/data/ai/chat-window-context.ts"],"sourcesContent":["// Non-component half of the chat window manager: the context object, the hook,\n// id helpers, persistence and layout maths. Split from the Provider (a .tsx\n// component) so this file stays JSX-free — matching the repo idiom of keeping\n// context/hooks in a .ts (see hooks/use-theme.ts, data/test-runner/context.ts)\n// and keeping React-Fast-Refresh happy.\nimport { createContext, useContext } from \"react\";\nimport type { ChatContextItem } from \"./context\";\nimport type {
|
|
1
|
+
{"version":3,"file":"chat-window-context.js","sources":["../../../src/data/ai/chat-window-context.ts"],"sourcesContent":["// Non-component half of the chat window manager: the context object, the hook,\n// id helpers, persistence and layout maths. Split from the Provider (a .tsx\n// component) so this file stays JSX-free — matching the repo idiom of keeping\n// context/hooks in a .ts (see hooks/use-theme.ts, data/test-runner/context.ts)\n// and keeping React-Fast-Refresh happy.\nimport { createContext, useContext } from \"react\";\nimport type { ChatContextItem } from \"./context\";\nimport type { PermissionPolicy } from \"../chat/tool-policy\";\nimport { zIndex } from \"../../overlay/zIndex\";\n\n/** Live state of one floating chat window. Position/size/maximized are\n * persisted to localStorage; the rest is session-only. */\nexport interface ChatWindowState {\n id: string;\n threadId: string | null;\n initialModel: string | null;\n x: number;\n y: number;\n width: number;\n height: number;\n zIndex: number;\n maximized: boolean;\n /** A prompt to auto-send when the window mounts (the `id` lets the window\n * detect a fresh request even if the text repeats). */\n initialPrompt: { id: number; text: string } | null;\n contextItems: ChatContextItem[];\n /** The ordered rules the surface that opened this window declares. They sit\n * under the user.s own rules and over the tool catalog.s defaults, so a\n * surface can narrow a family without overriding a toggle. */\n toolPolicy: PermissionPolicy;\n}\n\nexport interface OpenPanelOpts {\n threadId?: string | null;\n initialModel?: string | null;\n initialPrompt?: { id: number; text: string } | null;\n contextItems?: ChatContextItem[];\n /** See {@link ChatWindowState.toolPolicy}. */\n toolPolicy?: PermissionPolicy;\n}\n\nexport interface ChatWindowManagerValue {\n panels: ChatWindowState[];\n openPanel: (opts?: OpenPanelOpts) => string;\n closePanel: (id: string) => void;\n updatePanel: (id: string, partial: Partial<ChatWindowState>) => void;\n bringToFront: (id: string) => void;\n maximizePanel: (id: string) => void;\n /** Reuses the front-most existing window (merging in any new prompt/context)\n * or opens a fresh one when none exist. */\n findOrCreatePanel: (opts?: OpenPanelOpts) => string;\n}\n\nexport const ChatWindowManagerContext = createContext<ChatWindowManagerValue | null>(null);\n\nexport function useChatWindowManager(): ChatWindowManagerValue {\n const ctx = useContext(ChatWindowManagerContext);\n if (!ctx) throw new Error(\"useChatWindowManager must be used within <ChatWindowManagerProvider>\");\n return ctx;\n}\n\nexport const MAX_PANELS = 6;\nexport const DEFAULT_WIDTH = 520;\nexport const DEFAULT_HEIGHT = 700;\nexport const CASCADE_OFFSET = 30;\nexport const Z_BASE = zIndex.chatWindow;\n\nfunction storageKey(storageId: string) {\n return `chat-panels:${storageId}`;\n}\n\ninterface PersistedPanel {\n id: string;\n threadId: string | null;\n x: number;\n y: number;\n width: number;\n height: number;\n maximized: boolean;\n}\n\nexport function loadPanels(storageId: string): ChatWindowState[] {\n if (typeof window === \"undefined\") return [];\n try {\n const raw = localStorage.getItem(storageKey(storageId));\n if (!raw) return [];\n const persisted: PersistedPanel[] = JSON.parse(raw);\n return persisted.map((p, i) => ({\n ...p,\n initialModel: null,\n zIndex: Z_BASE + i,\n initialPrompt: null,\n contextItems: [],\n // A restored window is not attached to a surface yet, so tools fall back\n // to the catalog defaults until one reopens it.\n toolPolicy: [],\n }));\n } catch {\n return [];\n }\n}\n\nexport function savePanels(storageId: string, panels: ChatWindowState[]) {\n const persisted: PersistedPanel[] = panels.map((p) => ({\n id: p.id,\n threadId: p.threadId,\n x: p.x,\n y: p.y,\n width: p.width,\n height: p.height,\n maximized: p.maximized,\n }));\n localStorage.setItem(storageKey(storageId), JSON.stringify(persisted));\n}\n\nlet _panelId = 0;\nexport function nextPanelId(): string {\n return `panel-${++_panelId}-${Date.now()}`;\n}\n\nlet _promptId = 0;\n/** A monotonic id stamped onto an `initialPrompt` so a window re-sends even when\n * the same text is requested twice. */\nexport function nextPromptId(): number {\n return ++_promptId;\n}\n\n/** Re-indexes z so values stay compact (61, 62, …) with `frontId` on top. */\nexport function reindex(panels: ChatWindowState[], frontId?: string): ChatWindowState[] {\n const sorted = [...panels].sort((a, b) => a.zIndex - b.zIndex);\n if (frontId) {\n const idx = sorted.findIndex((p) => p.id === frontId);\n if (idx >= 0) {\n const [item] = sorted.splice(idx, 1);\n if (item) sorted.push(item);\n }\n }\n return sorted.map((p, i) => ({ ...p, zIndex: Z_BASE + i }));\n}\n"],"names":[],"mappings":";;AAqDO,MAAM,2BAA2B,cAA6C,IAAI;AAElF,SAAS,uBAA+C;AAC7D,QAAM,MAAM,WAAW,wBAAwB;AAC/C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,sEAAsE;AAChG,SAAO;AACT;AAEO,MAAM,aAAa;AACnB,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AACvB,MAAM,iBAAiB;AACvB,MAAM,SAAS,OAAO;AAE7B,SAAS,WAAW,WAAmB;AACrC,SAAO,eAAe,SAAS;AACjC;AAYO,SAAS,WAAW,WAAsC;AAC/D,MAAI,OAAO,WAAW,YAAa,QAAO,CAAA;AAC1C,MAAI;AACF,UAAM,MAAM,aAAa,QAAQ,WAAW,SAAS,CAAC;AACtD,QAAI,CAAC,IAAK,QAAO,CAAA;AACjB,UAAM,YAA8B,KAAK,MAAM,GAAG;AAClD,WAAO,UAAU,IAAI,CAAC,GAAG,OAAO;AAAA,MAC9B,GAAG;AAAA,MACH,cAAc;AAAA,MACd,QAAQ,SAAS;AAAA,MACjB,eAAe;AAAA,MACf,cAAc,CAAA;AAAA;AAAA;AAAA,MAGd,YAAY,CAAA;AAAA,IAAC,EACb;AAAA,EACJ,QAAQ;AACN,WAAO,CAAA;AAAA,EACT;AACF;AAEO,SAAS,WAAW,WAAmB,QAA2B;AACvE,QAAM,YAA8B,OAAO,IAAI,CAAC,OAAO;AAAA,IACrD,IAAI,EAAE;AAAA,IACN,UAAU,EAAE;AAAA,IACZ,GAAG,EAAE;AAAA,IACL,GAAG,EAAE;AAAA,IACL,OAAO,EAAE;AAAA,IACT,QAAQ,EAAE;AAAA,IACV,WAAW,EAAE;AAAA,EAAA,EACb;AACF,eAAa,QAAQ,WAAW,SAAS,GAAG,KAAK,UAAU,SAAS,CAAC;AACvE;AAEA,IAAI,WAAW;AACR,SAAS,cAAsB;AACpC,SAAO,SAAS,EAAE,QAAQ,IAAI,KAAK,KAAK;AAC1C;AAEA,IAAI,YAAY;AAGT,SAAS,eAAuB;AACrC,SAAO,EAAE;AACX;AAGO,SAAS,QAAQ,QAA2B,SAAqC;AACtF,QAAM,SAAS,CAAC,GAAG,MAAM,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM;AAC7D,MAAI,SAAS;AACX,UAAM,MAAM,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,OAAO;AACpD,QAAI,OAAO,GAAG;AACZ,YAAM,CAAC,IAAI,IAAI,OAAO,OAAO,KAAK,CAAC;AACnC,UAAI,KAAM,QAAO,KAAK,IAAI;AAAA,IAC5B;AAAA,EACF;AACA,SAAO,OAAO,IAAI,CAAC,GAAG,OAAO,EAAE,GAAG,GAAG,QAAQ,SAAS,EAAA,EAAI;AAC5D;"}
|
package/dist/data/ai/index.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ export { ChatFab, type ChatFabProps } from './ChatFab';
|
|
|
5
5
|
export { ChatButton, type ChatButtonProps } from './ChatButton';
|
|
6
6
|
export { ThreadPicker, type ThreadPickerProps, type ThreadSummary, type ThreadSource, } from './ThreadPicker';
|
|
7
7
|
export { ContextBadges, ContextBadgesReadonly, type ContextBadgesProps, } from './ContextBadges';
|
|
8
|
-
export { ToolPreferences, CompactToolPreferencesList, type CompactToolPreferencesListProps, type ToolPreferencesProps, type ClaudePermissionMode, type ToolAnnotations, type ToolMeta, type
|
|
8
|
+
export { ToolPreferences, CompactToolPreferencesList, type CompactToolPreferencesListProps, type ToolPreferencesProps, type ClaudePermissionMode, type ToolAnnotations, type ToolMeta, type ToolPolicy, } from './ToolPreferences';
|
|
9
|
+
export { effectiveToolPolicies, withUserRule, type ToolGroup, type ToolPreferenceEntry, type ToolSubGroup, } from './ToolPreferences.model';
|
|
10
|
+
export { normalizeToolPolicy } from '../chat/types';
|
|
9
11
|
export { CLAUDE_PERMISSION_MODES, CLAUDE_PERMISSION_MODE_OPTIONS, type ClaudePermissionModeOption, } from '../chat/types';
|
|
10
12
|
export { ToolSchemaBrowser, ToolSchemaBrowser as SchemaBrowser, type ToolSchemaBrowserProps, } from './ToolSchemaBrowser';
|
|
11
13
|
export { SpecRuntimeEditor, type SpecRuntimeEditorProps, type SpecRuntimeSecretSelectorConfig, type AISpecRuntimeValue, } from './SpecRuntimeEditor';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/data/ai/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,yBAAyB,EACzB,KAAK,8BAA8B,GACpC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,UAAU,EACV,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,4BAA4B,GAClC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,KAAK,+BAA+B,EACpC,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/data/ai/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,yBAAyB,EACzB,KAAK,8BAA8B,GACpC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,UAAU,EACV,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,4BAA4B,GAClC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,KAAK,+BAA+B,EACpC,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,UAAU,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qBAAqB,EACrB,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,YAAY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AQ,EACR,eAAe,EACf,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,QAAQ,EACb,KAAK,SAAS,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,cAAc,EACd,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const types = require("./types.cjs");
|
|
3
4
|
function clickyOperationsToTools(operations, surfaces) {
|
|
4
5
|
const surfacesByKey = /* @__PURE__ */ new Map();
|
|
5
6
|
for (const surface of surfaces ?? []) {
|
|
@@ -27,7 +28,7 @@ function operationToTool(operation, resolved, surfacesByKey) {
|
|
|
27
28
|
const surface = (meta == null ? void 0 : meta.surface) ? surfacesByKey == null ? void 0 : surfacesByKey.get(meta.surface) : void 0;
|
|
28
29
|
const parent = (surface == null ? void 0 : surface.title) || (hints == null ? void 0 : hints.parent) || (surface == null ? void 0 : surface.entity);
|
|
29
30
|
const icon = (hints == null ? void 0 : hints.icon) || (surface == null ? void 0 : surface.icon);
|
|
30
|
-
const defaultPermission = hints == null ? void 0 : hints.defaultPermission;
|
|
31
|
+
const defaultPermission = types.normalizeToolPolicy(hints == null ? void 0 : hints.defaultPermission);
|
|
31
32
|
const description = operation.description ?? operation.summary;
|
|
32
33
|
return {
|
|
33
34
|
name: operation.operationId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clickyOperationsToTools.cjs","sources":["../../../src/data/chat/clickyOperationsToTools.ts"],"sourcesContent":["import type {\n ClickySurface,\n OpenAPIOperation,\n OpenAPIParameter,\n OpenAPISchema,\n ResolvedOperation,\n} from \"../../rpc/types\";\nimport type {\n ChatToolInputSchema,\n JSONSchemaProperty,\n ToolAnnotations,\n ToolMeta,\n} from \"./types\";\n\n/** Converts a clicky RPC operation catalog into AI-tool metadata for display\n * and request scoping. Execution stays in the Go backend; this maps an\n * operation's `operationId` → tool name, a short `x-clicky` verb/action →\n * label, the `x-clicky` surface → group, `summary`/`description` → description,\n * and `parameters` + `requestBody` → a JSON-Schema input. Operations without an\n * `operationId` are skipped (a tool needs a stable name). */\nexport function clickyOperationsToTools(\n operations: ResolvedOperation[],\n surfaces?: ClickySurface[],\n): ToolMeta[] {\n const surfacesByKey = new Map<string, ClickySurface>();\n for (const surface of surfaces ?? []) {\n surfacesByKey.set(surface.key, surface);\n }\n const tools: ToolMeta[] = [];\n for (const resolved of operations) {\n const tool = operationToTool(resolved.operation, resolved, surfacesByKey);\n if (tool) {\n tools.push(tool);\n }\n }\n return tools;\n}\n\nexport function operationToTool(\n operation: OpenAPIOperation,\n resolved?: Pick<ResolvedOperation, \"path\" | \"method\">,\n surfacesByKey?: Map<string, ClickySurface>,\n): ToolMeta | null {\n if (!operation.operationId) {\n return null;\n }\n if (isCobraHelpOrCompletionOperation(operation, resolved)) {\n return null;\n }\n const meta = operation[\"x-clicky\"];\n const hints = meta?.toolHints;\n const group = operationToolGroup(operation);\n const surface = meta?.surface ? surfacesByKey?.get(meta.surface) : undefined;\n const parent = surface?.title || hints?.parent || surface?.entity;\n const icon = hints?.icon || surface?.icon;\n const defaultPermission = hints?.defaultPermission;\n const description = operation.description ?? operation.summary;\n return {\n name: operation.operationId,\n label: toolLabel(operation),\n ...(group\n ? { group, preferenceKey: group }\n : meta?.surface\n ? { group: meta.surface }\n : {}),\n ...(defaultPermission ? { defaultPermission } : {}),\n ...(parent ? { parent } : {}),\n ...(surface?.entity ? { entity: surface.entity } : {}),\n ...(icon ? { icon } : {}),\n ...(description ? { description } : {}),\n ...(resolved?.method ? { method: resolved.method.toUpperCase() } : {}),\n ...(resolved?.path ? { path: resolved.path } : {}),\n strict: hints?.strict ?? true,\n annotations: toolAnnotations(operation, resolved, description),\n inputSchema: buildInputSchema(operation),\n };\n}\n\nfunction toolAnnotations(\n operation: OpenAPIOperation,\n resolved: Pick<ResolvedOperation, \"path\" | \"method\"> | undefined,\n description: string | undefined,\n): ToolAnnotations {\n const hints = operation[\"x-clicky\"]?.toolHints;\n const method = resolved?.method?.toUpperCase() ?? \"\";\n const annotations: ToolAnnotations = {};\n const title =\n hints?.title ??\n operation.summary ??\n operation[\"x-clicky\"]?.actionName ??\n description;\n if (title) annotations.title = title;\n if (hints?.readOnlyHint !== undefined) {\n annotations.readOnlyHint = hints.readOnlyHint;\n } else if (resolved?.method?.toUpperCase() === \"GET\") {\n annotations.readOnlyHint = true;\n }\n if (hints?.idempotentHint !== undefined) {\n annotations.idempotentHint = hints.idempotentHint;\n } else if (isIdempotentMethod(method)) {\n annotations.idempotentHint = true;\n }\n if (hints?.destructiveHint !== undefined) {\n annotations.destructiveHint = hints.destructiveHint;\n } else if (isDestructiveTool(operation, resolved)) {\n annotations.destructiveHint = true;\n }\n if (hints?.openWorldHint !== undefined) {\n annotations.openWorldHint = hints.openWorldHint;\n }\n return annotations;\n}\n\nfunction isIdempotentMethod(method: string): boolean {\n return (\n method === \"GET\" ||\n method === \"HEAD\" ||\n method === \"OPTIONS\" ||\n method === \"PUT\" ||\n method === \"DELETE\"\n );\n}\n\nfunction isDestructiveTool(\n operation: OpenAPIOperation,\n resolved: Pick<ResolvedOperation, \"path\" | \"method\"> | undefined,\n): boolean {\n const method = resolved?.method?.toUpperCase() ?? \"\";\n if (method === \"DELETE\") return true;\n if (method === \"GET\" || method === \"HEAD\" || method === \"OPTIONS\")\n return false;\n const text = `${resolved?.path ?? \"\"} ${operation.operationId ?? \"\"}`.toLowerCase();\n return /\\b(write|delete|remove|destroy|void|sync|create|update|patch|post)\\b/.test(\n text,\n );\n}\n\nfunction operationToolGroup(\n operation: OpenAPIOperation,\n): string | undefined {\n const meta = operation[\"x-clicky\"];\n if (meta?.toolHints?.group) return meta.toolHints.group;\n if (meta?.group) return meta.group;\n return undefined;\n}\n\nfunction isCobraHelpOrCompletionOperation(\n operation: OpenAPIOperation,\n resolved?: Pick<ResolvedOperation, \"path\" | \"method\">,\n): boolean {\n return (\n commandStartsWithCobraBuiltin(operation.operationId) ||\n commandStartsWithCobraBuiltin(operation[\"x-clicky\"]?.command) ||\n pathContainsCobraBuiltin(resolved?.path)\n );\n}\n\nfunction commandStartsWithCobraBuiltin(raw: string | undefined): boolean {\n if (!raw) return false;\n const normalized = raw\n .replace(/([a-z\\d])([A-Z])/g, \"$1 $2\")\n .replace(/[/_.-]+/g, \" \")\n .trim()\n .toLowerCase();\n const first = normalized.split(/\\s+/)[0];\n return first === \"completion\" || first === \"help\";\n}\n\nfunction pathContainsCobraBuiltin(path: string | undefined): boolean {\n if (!path) return false;\n const parts = path\n .split(\"/\")\n .filter(Boolean)\n .map((part) => part.toLowerCase());\n const commandParts =\n parts[0] === \"api\" && /^v\\d+$/.test(parts[1] ?? \"\")\n ? parts.slice(2)\n : parts;\n const first = commandParts[0];\n return first === \"completion\" || first === \"help\";\n}\n\n\n/** A concise popover label: the clicky action/verb (capitalized) when present,\n * else the operation summary, else a humanized operationId. Mirrors the intent\n * of rpc/clickyMetadata.ts `surfaceActionLabel`. */\nfunction toolLabel(operation: OpenAPIOperation): string {\n const meta = operation[\"x-clicky\"];\n const short = meta?.actionName?.trim() || meta?.verb?.trim();\n if (short && short !== \"action\") {\n return short.charAt(0).toUpperCase() + short.slice(1);\n }\n if (operation.summary) {\n return operation.summary;\n }\n return humanize(operation.operationId ?? \"\");\n}\n\nfunction humanize(operationId: string): string {\n const spaced = operationId\n .replace(/[_-]+/g, \" \")\n .replace(/([a-z\\d])([A-Z])/g, \"$1 $2\");\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n\nfunction buildInputSchema(operation: OpenAPIOperation): ChatToolInputSchema {\n const properties: Record<string, JSONSchemaProperty> = {};\n const required: string[] = [];\n\n for (const param of operation.parameters ?? []) {\n properties[param.name] = parameterToProperty(param);\n if (param.required) {\n required.push(param.name);\n }\n }\n\n const body = requestBodySchema(operation);\n if (body?.properties) {\n for (const [name, schema] of Object.entries(body.properties)) {\n properties[name] = schemaToProperty(schema);\n }\n }\n\n return { type: \"object\", properties, required, additionalProperties: false };\n}\n\nfunction parameterToProperty(param: OpenAPIParameter): JSONSchemaProperty {\n const prop = schemaToProperty(param.schema);\n if (param.description && !prop.description) {\n prop.description = param.description;\n }\n return prop;\n}\n\nfunction schemaToProperty(\n schema: OpenAPISchema | undefined,\n): JSONSchemaProperty {\n if (!schema) {\n return { type: \"string\" };\n }\n const prop: JSONSchemaProperty = { type: jsonSchemaType(schema.type) };\n if (schema.description !== undefined) {\n prop.description = schema.description;\n }\n if (schema.enum !== undefined) {\n prop.enum = schema.enum;\n }\n if (schema.default !== undefined) {\n prop.default = schema.default;\n }\n return prop;\n}\n\nfunction jsonSchemaType(\n type: string | undefined,\n): NonNullable<JSONSchemaProperty[\"type\"]> {\n switch (type) {\n case \"object\":\n case \"array\":\n case \"string\":\n case \"integer\":\n case \"number\":\n case \"boolean\":\n case \"null\":\n return type;\n default:\n return \"string\";\n }\n}\n\nfunction requestBodySchema(\n operation: OpenAPIOperation,\n): OpenAPISchema | undefined {\n const content = operation.requestBody?.content;\n if (!content) {\n return undefined;\n }\n return (\n content[\"application/json\"]?.schema ?? Object.values(content)[0]?.schema\n );\n}\n"],"names":[],"mappings":";;AAoBO,SAAS,wBACd,YACA,UACY;AACZ,QAAM,oCAAoB,IAAA;AAC1B,aAAW,WAAW,YAAY,IAAI;AACpC,kBAAc,IAAI,QAAQ,KAAK,OAAO;AAAA,EACxC;AACA,QAAM,QAAoB,CAAA;AAC1B,aAAW,YAAY,YAAY;AACjC,UAAM,OAAO,gBAAgB,SAAS,WAAW,UAAU,aAAa;AACxE,QAAI,MAAM;AACR,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,gBACd,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B,QAAM,WAAU,eAAU,gBAAV,mBAAuB;AACvC,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AACA,WACE,aAAQ,kBAAkB,MAA1B,mBAA6B,aAAU,YAAO,OAAO,OAAO,EAAE,CAAC,MAAxB,mBAA2B;AAEtE;;;"}
|
|
1
|
+
{"version":3,"file":"clickyOperationsToTools.cjs","sources":["../../../src/data/chat/clickyOperationsToTools.ts"],"sourcesContent":["import type {\n ClickySurface,\n OpenAPIOperation,\n OpenAPIParameter,\n OpenAPISchema,\n ResolvedOperation,\n} from \"../../rpc/types\";\nimport type {\n ChatToolInputSchema,\n JSONSchemaProperty,\n ToolAnnotations,\n ToolMeta,\n} from \"./types\";\nimport { normalizeToolPolicy } from \"./types\";\n\n/** Converts a clicky RPC operation catalog into AI-tool metadata for display\n * and request scoping. Execution stays in the Go backend; this maps an\n * operation's `operationId` → tool name, a short `x-clicky` verb/action →\n * label, the `x-clicky` surface → group, `summary`/`description` → description,\n * and `parameters` + `requestBody` → a JSON-Schema input. Operations without an\n * `operationId` are skipped (a tool needs a stable name). */\nexport function clickyOperationsToTools(\n operations: ResolvedOperation[],\n surfaces?: ClickySurface[],\n): ToolMeta[] {\n const surfacesByKey = new Map<string, ClickySurface>();\n for (const surface of surfaces ?? []) {\n surfacesByKey.set(surface.key, surface);\n }\n const tools: ToolMeta[] = [];\n for (const resolved of operations) {\n const tool = operationToTool(resolved.operation, resolved, surfacesByKey);\n if (tool) {\n tools.push(tool);\n }\n }\n return tools;\n}\n\nexport function operationToTool(\n operation: OpenAPIOperation,\n resolved?: Pick<ResolvedOperation, \"path\" | \"method\">,\n surfacesByKey?: Map<string, ClickySurface>,\n): ToolMeta | null {\n if (!operation.operationId) {\n return null;\n }\n if (isCobraHelpOrCompletionOperation(operation, resolved)) {\n return null;\n }\n const meta = operation[\"x-clicky\"];\n const hints = meta?.toolHints;\n const group = operationToolGroup(operation);\n const surface = meta?.surface ? surfacesByKey?.get(meta.surface) : undefined;\n const parent = surface?.title || hints?.parent || surface?.entity;\n const icon = hints?.icon || surface?.icon;\n // Operation hints still carry the legacy on/off spellings, so this is a real\n // translation, not a pass-through.\n const defaultPermission = normalizeToolPolicy(hints?.defaultPermission);\n const description = operation.description ?? operation.summary;\n return {\n name: operation.operationId,\n label: toolLabel(operation),\n ...(group\n ? { group, preferenceKey: group }\n : meta?.surface\n ? { group: meta.surface }\n : {}),\n ...(defaultPermission ? { defaultPermission } : {}),\n ...(parent ? { parent } : {}),\n ...(surface?.entity ? { entity: surface.entity } : {}),\n ...(icon ? { icon } : {}),\n ...(description ? { description } : {}),\n ...(resolved?.method ? { method: resolved.method.toUpperCase() } : {}),\n ...(resolved?.path ? { path: resolved.path } : {}),\n strict: hints?.strict ?? true,\n annotations: toolAnnotations(operation, resolved, description),\n inputSchema: buildInputSchema(operation),\n };\n}\n\nfunction toolAnnotations(\n operation: OpenAPIOperation,\n resolved: Pick<ResolvedOperation, \"path\" | \"method\"> | undefined,\n description: string | undefined,\n): ToolAnnotations {\n const hints = operation[\"x-clicky\"]?.toolHints;\n const method = resolved?.method?.toUpperCase() ?? \"\";\n const annotations: ToolAnnotations = {};\n const title =\n hints?.title ??\n operation.summary ??\n operation[\"x-clicky\"]?.actionName ??\n description;\n if (title) annotations.title = title;\n if (hints?.readOnlyHint !== undefined) {\n annotations.readOnlyHint = hints.readOnlyHint;\n } else if (resolved?.method?.toUpperCase() === \"GET\") {\n annotations.readOnlyHint = true;\n }\n if (hints?.idempotentHint !== undefined) {\n annotations.idempotentHint = hints.idempotentHint;\n } else if (isIdempotentMethod(method)) {\n annotations.idempotentHint = true;\n }\n if (hints?.destructiveHint !== undefined) {\n annotations.destructiveHint = hints.destructiveHint;\n } else if (isDestructiveTool(operation, resolved)) {\n annotations.destructiveHint = true;\n }\n if (hints?.openWorldHint !== undefined) {\n annotations.openWorldHint = hints.openWorldHint;\n }\n return annotations;\n}\n\nfunction isIdempotentMethod(method: string): boolean {\n return (\n method === \"GET\" ||\n method === \"HEAD\" ||\n method === \"OPTIONS\" ||\n method === \"PUT\" ||\n method === \"DELETE\"\n );\n}\n\nfunction isDestructiveTool(\n operation: OpenAPIOperation,\n resolved: Pick<ResolvedOperation, \"path\" | \"method\"> | undefined,\n): boolean {\n const method = resolved?.method?.toUpperCase() ?? \"\";\n if (method === \"DELETE\") return true;\n if (method === \"GET\" || method === \"HEAD\" || method === \"OPTIONS\")\n return false;\n const text = `${resolved?.path ?? \"\"} ${operation.operationId ?? \"\"}`.toLowerCase();\n return /\\b(write|delete|remove|destroy|void|sync|create|update|patch|post)\\b/.test(\n text,\n );\n}\n\nfunction operationToolGroup(\n operation: OpenAPIOperation,\n): string | undefined {\n const meta = operation[\"x-clicky\"];\n if (meta?.toolHints?.group) return meta.toolHints.group;\n if (meta?.group) return meta.group;\n return undefined;\n}\n\nfunction isCobraHelpOrCompletionOperation(\n operation: OpenAPIOperation,\n resolved?: Pick<ResolvedOperation, \"path\" | \"method\">,\n): boolean {\n return (\n commandStartsWithCobraBuiltin(operation.operationId) ||\n commandStartsWithCobraBuiltin(operation[\"x-clicky\"]?.command) ||\n pathContainsCobraBuiltin(resolved?.path)\n );\n}\n\nfunction commandStartsWithCobraBuiltin(raw: string | undefined): boolean {\n if (!raw) return false;\n const normalized = raw\n .replace(/([a-z\\d])([A-Z])/g, \"$1 $2\")\n .replace(/[/_.-]+/g, \" \")\n .trim()\n .toLowerCase();\n const first = normalized.split(/\\s+/)[0];\n return first === \"completion\" || first === \"help\";\n}\n\nfunction pathContainsCobraBuiltin(path: string | undefined): boolean {\n if (!path) return false;\n const parts = path\n .split(\"/\")\n .filter(Boolean)\n .map((part) => part.toLowerCase());\n const commandParts =\n parts[0] === \"api\" && /^v\\d+$/.test(parts[1] ?? \"\")\n ? parts.slice(2)\n : parts;\n const first = commandParts[0];\n return first === \"completion\" || first === \"help\";\n}\n\n\n/** A concise popover label: the clicky action/verb (capitalized) when present,\n * else the operation summary, else a humanized operationId. Mirrors the intent\n * of rpc/clickyMetadata.ts `surfaceActionLabel`. */\nfunction toolLabel(operation: OpenAPIOperation): string {\n const meta = operation[\"x-clicky\"];\n const short = meta?.actionName?.trim() || meta?.verb?.trim();\n if (short && short !== \"action\") {\n return short.charAt(0).toUpperCase() + short.slice(1);\n }\n if (operation.summary) {\n return operation.summary;\n }\n return humanize(operation.operationId ?? \"\");\n}\n\nfunction humanize(operationId: string): string {\n const spaced = operationId\n .replace(/[_-]+/g, \" \")\n .replace(/([a-z\\d])([A-Z])/g, \"$1 $2\");\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n\nfunction buildInputSchema(operation: OpenAPIOperation): ChatToolInputSchema {\n const properties: Record<string, JSONSchemaProperty> = {};\n const required: string[] = [];\n\n for (const param of operation.parameters ?? []) {\n properties[param.name] = parameterToProperty(param);\n if (param.required) {\n required.push(param.name);\n }\n }\n\n const body = requestBodySchema(operation);\n if (body?.properties) {\n for (const [name, schema] of Object.entries(body.properties)) {\n properties[name] = schemaToProperty(schema);\n }\n }\n\n return { type: \"object\", properties, required, additionalProperties: false };\n}\n\nfunction parameterToProperty(param: OpenAPIParameter): JSONSchemaProperty {\n const prop = schemaToProperty(param.schema);\n if (param.description && !prop.description) {\n prop.description = param.description;\n }\n return prop;\n}\n\nfunction schemaToProperty(\n schema: OpenAPISchema | undefined,\n): JSONSchemaProperty {\n if (!schema) {\n return { type: \"string\" };\n }\n const prop: JSONSchemaProperty = { type: jsonSchemaType(schema.type) };\n if (schema.description !== undefined) {\n prop.description = schema.description;\n }\n if (schema.enum !== undefined) {\n prop.enum = schema.enum;\n }\n if (schema.default !== undefined) {\n prop.default = schema.default;\n }\n return prop;\n}\n\nfunction jsonSchemaType(\n type: string | undefined,\n): NonNullable<JSONSchemaProperty[\"type\"]> {\n switch (type) {\n case \"object\":\n case \"array\":\n case \"string\":\n case \"integer\":\n case \"number\":\n case \"boolean\":\n case \"null\":\n return type;\n default:\n return \"string\";\n }\n}\n\nfunction requestBodySchema(\n operation: OpenAPIOperation,\n): OpenAPISchema | undefined {\n const content = operation.requestBody?.content;\n if (!content) {\n return undefined;\n }\n return (\n content[\"application/json\"]?.schema ?? Object.values(content)[0]?.schema\n );\n}\n"],"names":["normalizeToolPolicy"],"mappings":";;;AAqBO,SAAS,wBACd,YACA,UACY;AACZ,QAAM,oCAAoB,IAAA;AAC1B,aAAW,WAAW,YAAY,IAAI;AACpC,kBAAc,IAAI,QAAQ,KAAK,OAAO;AAAA,EACxC;AACA,QAAM,QAAoB,CAAA;AAC1B,aAAW,YAAY,YAAY;AACjC,UAAM,OAAO,gBAAgB,SAAS,WAAW,UAAU,aAAa;AACxE,QAAI,MAAM;AACR,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,gBACd,WACA,UACA,eACiB;AACjB,MAAI,CAAC,UAAU,aAAa;AAC1B,WAAO;AAAA,EACT;AACA,MAAI,iCAAiC,WAAW,QAAQ,GAAG;AACzD,WAAO;AAAA,EACT;AACA,QAAM,OAAO,UAAU,UAAU;AACjC,QAAM,QAAQ,6BAAM;AACpB,QAAM,QAAQ,mBAAmB,SAAS;AAC1C,QAAM,WAAU,6BAAM,WAAU,+CAAe,IAAI,KAAK,WAAW;AACnE,QAAM,UAAS,mCAAS,WAAS,+BAAO,YAAU,mCAAS;AAC3D,QAAM,QAAO,+BAAO,UAAQ,mCAAS;AAGrC,QAAM,oBAAoBA,MAAAA,oBAAoB,+BAAO,iBAAiB;AACtE,QAAM,cAAc,UAAU,eAAe,UAAU;AACvD,SAAO;AAAA,IACL,MAAM,UAAU;AAAA,IAChB,OAAO,UAAU,SAAS;AAAA,IAC1B,GAAI,QACA,EAAE,OAAO,eAAe,MAAA,KACxB,6BAAM,WACJ,EAAE,OAAO,KAAK,QAAA,IACd,CAAA;AAAA,IACN,GAAI,oBAAoB,EAAE,kBAAA,IAAsB,CAAA;AAAA,IAChD,GAAI,SAAS,EAAE,OAAA,IAAW,CAAA;AAAA,IAC1B,IAAI,mCAAS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AM,OAA2B,EAAE,MAAM,eAAe,OAAO,IAAI,EAAA;AACnE,MAAI,OAAO,gBAAgB,QAAW;AACpC,SAAK,cAAc,OAAO;AAAA,EAC5B;AACA,MAAI,OAAO,SAAS,QAAW;AAC7B,SAAK,OAAO,OAAO;AAAA,EACrB;AACA,MAAI,OAAO,YAAY,QAAW;AAChC,SAAK,UAAU,OAAO;AAAA,EACxB;AACA,SAAO;AACT;AAEA,SAAS,eACP,MACyC;AACzC,UAAQ,MAAA;AAAA,IACN,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EAAA;AAEb;AAEA,SAAS,kBACP,WAC2B;;AAC3B,QAAM,WAAU,eAAU,gBAAV,mBAAuB;AACvC,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AACA,WACE,aAAQ,kBAAkB,MAA1B,mBAA6B,aAAU,YAAO,OAAO,OAAO,EAAE,CAAC,MAAxB,mBAA2B;AAEtE;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clickyOperationsToTools.d.ts","sourceRoot":"","sources":["../../../src/data/chat/clickyOperationsToTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAGhB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAIV,QAAQ,EACT,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"clickyOperationsToTools.d.ts","sourceRoot":"","sources":["../../../src/data/chat/clickyOperationsToTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAGhB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAIV,QAAQ,EACT,MAAM,SAAS,CAAC;AAGjB;;;;;8DAK8D;AAC9D,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,iBAAiB,EAAE,EAC/B,QAAQ,CAAC,EAAE,aAAa,EAAE,GACzB,QAAQ,EAAE,CAaZ;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,QAAQ,CAAC,EACrD,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,GACzC,QAAQ,GAAG,IAAI,CAoCjB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeToolPolicy } from "./types.js";
|
|
1
2
|
function clickyOperationsToTools(operations, surfaces) {
|
|
2
3
|
const surfacesByKey = /* @__PURE__ */ new Map();
|
|
3
4
|
for (const surface of surfaces ?? []) {
|
|
@@ -25,7 +26,7 @@ function operationToTool(operation, resolved, surfacesByKey) {
|
|
|
25
26
|
const surface = (meta == null ? void 0 : meta.surface) ? surfacesByKey == null ? void 0 : surfacesByKey.get(meta.surface) : void 0;
|
|
26
27
|
const parent = (surface == null ? void 0 : surface.title) || (hints == null ? void 0 : hints.parent) || (surface == null ? void 0 : surface.entity);
|
|
27
28
|
const icon = (hints == null ? void 0 : hints.icon) || (surface == null ? void 0 : surface.icon);
|
|
28
|
-
const defaultPermission = hints == null ? void 0 : hints.defaultPermission;
|
|
29
|
+
const defaultPermission = normalizeToolPolicy(hints == null ? void 0 : hints.defaultPermission);
|
|
29
30
|
const description = operation.description ?? operation.summary;
|
|
30
31
|
return {
|
|
31
32
|
name: operation.operationId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clickyOperationsToTools.js","sources":["../../../src/data/chat/clickyOperationsToTools.ts"],"sourcesContent":["import type {\n ClickySurface,\n OpenAPIOperation,\n OpenAPIParameter,\n OpenAPISchema,\n ResolvedOperation,\n} from \"../../rpc/types\";\nimport type {\n ChatToolInputSchema,\n JSONSchemaProperty,\n ToolAnnotations,\n ToolMeta,\n} from \"./types\";\n\n/** Converts a clicky RPC operation catalog into AI-tool metadata for display\n * and request scoping. Execution stays in the Go backend; this maps an\n * operation's `operationId` → tool name, a short `x-clicky` verb/action →\n * label, the `x-clicky` surface → group, `summary`/`description` → description,\n * and `parameters` + `requestBody` → a JSON-Schema input. Operations without an\n * `operationId` are skipped (a tool needs a stable name). */\nexport function clickyOperationsToTools(\n operations: ResolvedOperation[],\n surfaces?: ClickySurface[],\n): ToolMeta[] {\n const surfacesByKey = new Map<string, ClickySurface>();\n for (const surface of surfaces ?? []) {\n surfacesByKey.set(surface.key, surface);\n }\n const tools: ToolMeta[] = [];\n for (const resolved of operations) {\n const tool = operationToTool(resolved.operation, resolved, surfacesByKey);\n if (tool) {\n tools.push(tool);\n }\n }\n return tools;\n}\n\nexport function operationToTool(\n operation: OpenAPIOperation,\n resolved?: Pick<ResolvedOperation, \"path\" | \"method\">,\n surfacesByKey?: Map<string, ClickySurface>,\n): ToolMeta | null {\n if (!operation.operationId) {\n return null;\n }\n if (isCobraHelpOrCompletionOperation(operation, resolved)) {\n return null;\n }\n const meta = operation[\"x-clicky\"];\n const hints = meta?.toolHints;\n const group = operationToolGroup(operation);\n const surface = meta?.surface ? surfacesByKey?.get(meta.surface) : undefined;\n const parent = surface?.title || hints?.parent || surface?.entity;\n const icon = hints?.icon || surface?.icon;\n const defaultPermission = hints?.defaultPermission;\n const description = operation.description ?? operation.summary;\n return {\n name: operation.operationId,\n label: toolLabel(operation),\n ...(group\n ? { group, preferenceKey: group }\n : meta?.surface\n ? { group: meta.surface }\n : {}),\n ...(defaultPermission ? { defaultPermission } : {}),\n ...(parent ? { parent } : {}),\n ...(surface?.entity ? { entity: surface.entity } : {}),\n ...(icon ? { icon } : {}),\n ...(description ? { description } : {}),\n ...(resolved?.method ? { method: resolved.method.toUpperCase() } : {}),\n ...(resolved?.path ? { path: resolved.path } : {}),\n strict: hints?.strict ?? true,\n annotations: toolAnnotations(operation, resolved, description),\n inputSchema: buildInputSchema(operation),\n };\n}\n\nfunction toolAnnotations(\n operation: OpenAPIOperation,\n resolved: Pick<ResolvedOperation, \"path\" | \"method\"> | undefined,\n description: string | undefined,\n): ToolAnnotations {\n const hints = operation[\"x-clicky\"]?.toolHints;\n const method = resolved?.method?.toUpperCase() ?? \"\";\n const annotations: ToolAnnotations = {};\n const title =\n hints?.title ??\n operation.summary ??\n operation[\"x-clicky\"]?.actionName ??\n description;\n if (title) annotations.title = title;\n if (hints?.readOnlyHint !== undefined) {\n annotations.readOnlyHint = hints.readOnlyHint;\n } else if (resolved?.method?.toUpperCase() === \"GET\") {\n annotations.readOnlyHint = true;\n }\n if (hints?.idempotentHint !== undefined) {\n annotations.idempotentHint = hints.idempotentHint;\n } else if (isIdempotentMethod(method)) {\n annotations.idempotentHint = true;\n }\n if (hints?.destructiveHint !== undefined) {\n annotations.destructiveHint = hints.destructiveHint;\n } else if (isDestructiveTool(operation, resolved)) {\n annotations.destructiveHint = true;\n }\n if (hints?.openWorldHint !== undefined) {\n annotations.openWorldHint = hints.openWorldHint;\n }\n return annotations;\n}\n\nfunction isIdempotentMethod(method: string): boolean {\n return (\n method === \"GET\" ||\n method === \"HEAD\" ||\n method === \"OPTIONS\" ||\n method === \"PUT\" ||\n method === \"DELETE\"\n );\n}\n\nfunction isDestructiveTool(\n operation: OpenAPIOperation,\n resolved: Pick<ResolvedOperation, \"path\" | \"method\"> | undefined,\n): boolean {\n const method = resolved?.method?.toUpperCase() ?? \"\";\n if (method === \"DELETE\") return true;\n if (method === \"GET\" || method === \"HEAD\" || method === \"OPTIONS\")\n return false;\n const text = `${resolved?.path ?? \"\"} ${operation.operationId ?? \"\"}`.toLowerCase();\n return /\\b(write|delete|remove|destroy|void|sync|create|update|patch|post)\\b/.test(\n text,\n );\n}\n\nfunction operationToolGroup(\n operation: OpenAPIOperation,\n): string | undefined {\n const meta = operation[\"x-clicky\"];\n if (meta?.toolHints?.group) return meta.toolHints.group;\n if (meta?.group) return meta.group;\n return undefined;\n}\n\nfunction isCobraHelpOrCompletionOperation(\n operation: OpenAPIOperation,\n resolved?: Pick<ResolvedOperation, \"path\" | \"method\">,\n): boolean {\n return (\n commandStartsWithCobraBuiltin(operation.operationId) ||\n commandStartsWithCobraBuiltin(operation[\"x-clicky\"]?.command) ||\n pathContainsCobraBuiltin(resolved?.path)\n );\n}\n\nfunction commandStartsWithCobraBuiltin(raw: string | undefined): boolean {\n if (!raw) return false;\n const normalized = raw\n .replace(/([a-z\\d])([A-Z])/g, \"$1 $2\")\n .replace(/[/_.-]+/g, \" \")\n .trim()\n .toLowerCase();\n const first = normalized.split(/\\s+/)[0];\n return first === \"completion\" || first === \"help\";\n}\n\nfunction pathContainsCobraBuiltin(path: string | undefined): boolean {\n if (!path) return false;\n const parts = path\n .split(\"/\")\n .filter(Boolean)\n .map((part) => part.toLowerCase());\n const commandParts =\n parts[0] === \"api\" && /^v\\d+$/.test(parts[1] ?? \"\")\n ? parts.slice(2)\n : parts;\n const first = commandParts[0];\n return first === \"completion\" || first === \"help\";\n}\n\n\n/** A concise popover label: the clicky action/verb (capitalized) when present,\n * else the operation summary, else a humanized operationId. Mirrors the intent\n * of rpc/clickyMetadata.ts `surfaceActionLabel`. */\nfunction toolLabel(operation: OpenAPIOperation): string {\n const meta = operation[\"x-clicky\"];\n const short = meta?.actionName?.trim() || meta?.verb?.trim();\n if (short && short !== \"action\") {\n return short.charAt(0).toUpperCase() + short.slice(1);\n }\n if (operation.summary) {\n return operation.summary;\n }\n return humanize(operation.operationId ?? \"\");\n}\n\nfunction humanize(operationId: string): string {\n const spaced = operationId\n .replace(/[_-]+/g, \" \")\n .replace(/([a-z\\d])([A-Z])/g, \"$1 $2\");\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n\nfunction buildInputSchema(operation: OpenAPIOperation): ChatToolInputSchema {\n const properties: Record<string, JSONSchemaProperty> = {};\n const required: string[] = [];\n\n for (const param of operation.parameters ?? []) {\n properties[param.name] = parameterToProperty(param);\n if (param.required) {\n required.push(param.name);\n }\n }\n\n const body = requestBodySchema(operation);\n if (body?.properties) {\n for (const [name, schema] of Object.entries(body.properties)) {\n properties[name] = schemaToProperty(schema);\n }\n }\n\n return { type: \"object\", properties, required, additionalProperties: false };\n}\n\nfunction parameterToProperty(param: OpenAPIParameter): JSONSchemaProperty {\n const prop = schemaToProperty(param.schema);\n if (param.description && !prop.description) {\n prop.description = param.description;\n }\n return prop;\n}\n\nfunction schemaToProperty(\n schema: OpenAPISchema | undefined,\n): JSONSchemaProperty {\n if (!schema) {\n return { type: \"string\" };\n }\n const prop: JSONSchemaProperty = { type: jsonSchemaType(schema.type) };\n if (schema.description !== undefined) {\n prop.description = schema.description;\n }\n if (schema.enum !== undefined) {\n prop.enum = schema.enum;\n }\n if (schema.default !== undefined) {\n prop.default = schema.default;\n }\n return prop;\n}\n\nfunction jsonSchemaType(\n type: string | undefined,\n): NonNullable<JSONSchemaProperty[\"type\"]> {\n switch (type) {\n case \"object\":\n case \"array\":\n case \"string\":\n case \"integer\":\n case \"number\":\n case \"boolean\":\n case \"null\":\n return type;\n default:\n return \"string\";\n }\n}\n\nfunction requestBodySchema(\n operation: OpenAPIOperation,\n): OpenAPISchema | undefined {\n const content = operation.requestBody?.content;\n if (!content) {\n return undefined;\n }\n return (\n content[\"application/json\"]?.schema ?? Object.values(content)[0]?.schema\n );\n}\n"],"names":[],"mappings":"AAoBO,SAAS,wBACd,YACA,UACY;AACZ,QAAM,oCAAoB,IAAA;AAC1B,aAAW,WAAW,YAAY,IAAI;AACpC,kBAAc,IAAI,QAAQ,KAAK,OAAO;AAAA,EACxC;AACA,QAAM,QAAoB,CAAA;AAC1B,aAAW,YAAY,YAAY;AACjC,UAAM,OAAO,gBAAgB,SAAS,WAAW,UAAU,aAAa;AACxE,QAAI,MAAM;AACR,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,gBACd,WACA,UACA,eACiB;AACjB,MAAI,CAAC,UAAU,aAAa;AAC1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L,QAAM,WAAU,eAAU,gBAAV,mBAAuB;AACvC,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AACA,WACE,aAAQ,kBAAkB,MAA1B,mBAA6B,aAAU,YAAO,OAAO,OAAO,EAAE,CAAC,MAAxB,mBAA2B;AAEtE;"}
|
|
1
|
+
{"version":3,"file":"clickyOperationsToTools.js","sources":["../../../src/data/chat/clickyOperationsToTools.ts"],"sourcesContent":["import type {\n ClickySurface,\n OpenAPIOperation,\n OpenAPIParameter,\n OpenAPISchema,\n ResolvedOperation,\n} from \"../../rpc/types\";\nimport type {\n ChatToolInputSchema,\n JSONSchemaProperty,\n ToolAnnotations,\n ToolMeta,\n} from \"./types\";\nimport { normalizeToolPolicy } from \"./types\";\n\n/** Converts a clicky RPC operation catalog into AI-tool metadata for display\n * and request scoping. Execution stays in the Go backend; this maps an\n * operation's `operationId` → tool name, a short `x-clicky` verb/action →\n * label, the `x-clicky` surface → group, `summary`/`description` → description,\n * and `parameters` + `requestBody` → a JSON-Schema input. Operations without an\n * `operationId` are skipped (a tool needs a stable name). */\nexport function clickyOperationsToTools(\n operations: ResolvedOperation[],\n surfaces?: ClickySurface[],\n): ToolMeta[] {\n const surfacesByKey = new Map<string, ClickySurface>();\n for (const surface of surfaces ?? []) {\n surfacesByKey.set(surface.key, surface);\n }\n const tools: ToolMeta[] = [];\n for (const resolved of operations) {\n const tool = operationToTool(resolved.operation, resolved, surfacesByKey);\n if (tool) {\n tools.push(tool);\n }\n }\n return tools;\n}\n\nexport function operationToTool(\n operation: OpenAPIOperation,\n resolved?: Pick<ResolvedOperation, \"path\" | \"method\">,\n surfacesByKey?: Map<string, ClickySurface>,\n): ToolMeta | null {\n if (!operation.operationId) {\n return null;\n }\n if (isCobraHelpOrCompletionOperation(operation, resolved)) {\n return null;\n }\n const meta = operation[\"x-clicky\"];\n const hints = meta?.toolHints;\n const group = operationToolGroup(operation);\n const surface = meta?.surface ? surfacesByKey?.get(meta.surface) : undefined;\n const parent = surface?.title || hints?.parent || surface?.entity;\n const icon = hints?.icon || surface?.icon;\n // Operation hints still carry the legacy on/off spellings, so this is a real\n // translation, not a pass-through.\n const defaultPermission = normalizeToolPolicy(hints?.defaultPermission);\n const description = operation.description ?? operation.summary;\n return {\n name: operation.operationId,\n label: toolLabel(operation),\n ...(group\n ? { group, preferenceKey: group }\n : meta?.surface\n ? { group: meta.surface }\n : {}),\n ...(defaultPermission ? { defaultPermission } : {}),\n ...(parent ? { parent } : {}),\n ...(surface?.entity ? { entity: surface.entity } : {}),\n ...(icon ? { icon } : {}),\n ...(description ? { description } : {}),\n ...(resolved?.method ? { method: resolved.method.toUpperCase() } : {}),\n ...(resolved?.path ? { path: resolved.path } : {}),\n strict: hints?.strict ?? true,\n annotations: toolAnnotations(operation, resolved, description),\n inputSchema: buildInputSchema(operation),\n };\n}\n\nfunction toolAnnotations(\n operation: OpenAPIOperation,\n resolved: Pick<ResolvedOperation, \"path\" | \"method\"> | undefined,\n description: string | undefined,\n): ToolAnnotations {\n const hints = operation[\"x-clicky\"]?.toolHints;\n const method = resolved?.method?.toUpperCase() ?? \"\";\n const annotations: ToolAnnotations = {};\n const title =\n hints?.title ??\n operation.summary ??\n operation[\"x-clicky\"]?.actionName ??\n description;\n if (title) annotations.title = title;\n if (hints?.readOnlyHint !== undefined) {\n annotations.readOnlyHint = hints.readOnlyHint;\n } else if (resolved?.method?.toUpperCase() === \"GET\") {\n annotations.readOnlyHint = true;\n }\n if (hints?.idempotentHint !== undefined) {\n annotations.idempotentHint = hints.idempotentHint;\n } else if (isIdempotentMethod(method)) {\n annotations.idempotentHint = true;\n }\n if (hints?.destructiveHint !== undefined) {\n annotations.destructiveHint = hints.destructiveHint;\n } else if (isDestructiveTool(operation, resolved)) {\n annotations.destructiveHint = true;\n }\n if (hints?.openWorldHint !== undefined) {\n annotations.openWorldHint = hints.openWorldHint;\n }\n return annotations;\n}\n\nfunction isIdempotentMethod(method: string): boolean {\n return (\n method === \"GET\" ||\n method === \"HEAD\" ||\n method === \"OPTIONS\" ||\n method === \"PUT\" ||\n method === \"DELETE\"\n );\n}\n\nfunction isDestructiveTool(\n operation: OpenAPIOperation,\n resolved: Pick<ResolvedOperation, \"path\" | \"method\"> | undefined,\n): boolean {\n const method = resolved?.method?.toUpperCase() ?? \"\";\n if (method === \"DELETE\") return true;\n if (method === \"GET\" || method === \"HEAD\" || method === \"OPTIONS\")\n return false;\n const text = `${resolved?.path ?? \"\"} ${operation.operationId ?? \"\"}`.toLowerCase();\n return /\\b(write|delete|remove|destroy|void|sync|create|update|patch|post)\\b/.test(\n text,\n );\n}\n\nfunction operationToolGroup(\n operation: OpenAPIOperation,\n): string | undefined {\n const meta = operation[\"x-clicky\"];\n if (meta?.toolHints?.group) return meta.toolHints.group;\n if (meta?.group) return meta.group;\n return undefined;\n}\n\nfunction isCobraHelpOrCompletionOperation(\n operation: OpenAPIOperation,\n resolved?: Pick<ResolvedOperation, \"path\" | \"method\">,\n): boolean {\n return (\n commandStartsWithCobraBuiltin(operation.operationId) ||\n commandStartsWithCobraBuiltin(operation[\"x-clicky\"]?.command) ||\n pathContainsCobraBuiltin(resolved?.path)\n );\n}\n\nfunction commandStartsWithCobraBuiltin(raw: string | undefined): boolean {\n if (!raw) return false;\n const normalized = raw\n .replace(/([a-z\\d])([A-Z])/g, \"$1 $2\")\n .replace(/[/_.-]+/g, \" \")\n .trim()\n .toLowerCase();\n const first = normalized.split(/\\s+/)[0];\n return first === \"completion\" || first === \"help\";\n}\n\nfunction pathContainsCobraBuiltin(path: string | undefined): boolean {\n if (!path) return false;\n const parts = path\n .split(\"/\")\n .filter(Boolean)\n .map((part) => part.toLowerCase());\n const commandParts =\n parts[0] === \"api\" && /^v\\d+$/.test(parts[1] ?? \"\")\n ? parts.slice(2)\n : parts;\n const first = commandParts[0];\n return first === \"completion\" || first === \"help\";\n}\n\n\n/** A concise popover label: the clicky action/verb (capitalized) when present,\n * else the operation summary, else a humanized operationId. Mirrors the intent\n * of rpc/clickyMetadata.ts `surfaceActionLabel`. */\nfunction toolLabel(operation: OpenAPIOperation): string {\n const meta = operation[\"x-clicky\"];\n const short = meta?.actionName?.trim() || meta?.verb?.trim();\n if (short && short !== \"action\") {\n return short.charAt(0).toUpperCase() + short.slice(1);\n }\n if (operation.summary) {\n return operation.summary;\n }\n return humanize(operation.operationId ?? \"\");\n}\n\nfunction humanize(operationId: string): string {\n const spaced = operationId\n .replace(/[_-]+/g, \" \")\n .replace(/([a-z\\d])([A-Z])/g, \"$1 $2\");\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n\nfunction buildInputSchema(operation: OpenAPIOperation): ChatToolInputSchema {\n const properties: Record<string, JSONSchemaProperty> = {};\n const required: string[] = [];\n\n for (const param of operation.parameters ?? []) {\n properties[param.name] = parameterToProperty(param);\n if (param.required) {\n required.push(param.name);\n }\n }\n\n const body = requestBodySchema(operation);\n if (body?.properties) {\n for (const [name, schema] of Object.entries(body.properties)) {\n properties[name] = schemaToProperty(schema);\n }\n }\n\n return { type: \"object\", properties, required, additionalProperties: false };\n}\n\nfunction parameterToProperty(param: OpenAPIParameter): JSONSchemaProperty {\n const prop = schemaToProperty(param.schema);\n if (param.description && !prop.description) {\n prop.description = param.description;\n }\n return prop;\n}\n\nfunction schemaToProperty(\n schema: OpenAPISchema | undefined,\n): JSONSchemaProperty {\n if (!schema) {\n return { type: \"string\" };\n }\n const prop: JSONSchemaProperty = { type: jsonSchemaType(schema.type) };\n if (schema.description !== undefined) {\n prop.description = schema.description;\n }\n if (schema.enum !== undefined) {\n prop.enum = schema.enum;\n }\n if (schema.default !== undefined) {\n prop.default = schema.default;\n }\n return prop;\n}\n\nfunction jsonSchemaType(\n type: string | undefined,\n): NonNullable<JSONSchemaProperty[\"type\"]> {\n switch (type) {\n case \"object\":\n case \"array\":\n case \"string\":\n case \"integer\":\n case \"number\":\n case \"boolean\":\n case \"null\":\n return type;\n default:\n return \"string\";\n }\n}\n\nfunction requestBodySchema(\n operation: OpenAPIOperation,\n): OpenAPISchema | undefined {\n const content = operation.requestBody?.content;\n if (!content) {\n return undefined;\n }\n return (\n content[\"application/json\"]?.schema ?? Object.values(content)[0]?.schema\n );\n}\n"],"names":[],"mappings":";AAqBO,SAAS,wBACd,YACA,UACY;AACZ,QAAM,oCAAoB,IAAA;AAC1B,aAAW,WAAW,YAAY,IAAI;AACpC,kBAAc,IAAI,QAAQ,KAAK,OAAO;AAAA,EACxC;AACA,QAAM,QAAoB,CAAA;AAC1B,aAAW,YAAY,YAAY;AACjC,UAAM,OAAO,gBAAgB,SAAS,WAAW,UAAU,aAAa;AACxE,QAAI,MAAM;AACR,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,gBACd,WACA,UACA,eACiB;AACjB,MAAI,CAAC,UAAU,aAAa;AAC1B,WAAO;AAAA,EACT;AACA,MAAI,iCAAiC,WAAW,QAAQ,GAAG;AACzD,WAAO;AAAA,EACT;AACA,QAAM,OAAO,UAAU,UAAU;AACjC,QAAM,QAAQ,6BAAM;AACpB,QAAM,QAAQ,mBAAmB,SAAS;AAC1C,QAAM,WAAU,6BAAM,WAAU,+CAAe,IAAI,KAAK,WAAW;AACnE,QAAM,UAAS,mCAAS,WAAS,+BAAO,YAAU,mCAAS;AAC3D,QAAM,QAAO,+BAAO,UAAQ,mCAAS;AAGrC,QAAM,oBAAoB,oBAAoB,+BAAO,iBAAiB;AACtE,QAAM,cAAc,UAAU,eAAe,UAAU;AACvD,SAAO;AAAA,IACL,MAAM,UAAU;AAAA,IAChB,OAAO,UAAU,SAAS;AAAA,IAC1B,GAAI,QACA,EAAE,OAAO,eAAe,MAAA,KACxB,6BAAM,WACJ,EAAE,OAAO,KAAK,QAAA,IACd,CAAA;AAAA,IACN,GAAI,oBAAoB,EAAE,kBAAA,IAAsB,CAAA;AAAA,IAChD,GAAI,SAAS,EAAE,OAAA,IAAW,CAAA;AAAA,IAC1B,IAAI,mCAAS,UAAS,EAAE,QAAQ,QAAQ,O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OAAO,IAAI,EAAA;AACnE,MAAI,OAAO,gBAAgB,QAAW;AACpC,SAAK,cAAc,OAAO;AAAA,EAC5B;AACA,MAAI,OAAO,SAAS,QAAW;AAC7B,SAAK,OAAO,OAAO;AAAA,EACrB;AACA,MAAI,OAAO,YAAY,QAAW;AAChC,SAAK,UAAU,OAAO;AAAA,EACxB;AACA,SAAO;AACT;AAEA,SAAS,eACP,MACyC;AACzC,UAAQ,MAAA;AAAA,IACN,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EAAA;AAEb;AAEA,SAAS,kBACP,WAC2B;;AAC3B,QAAM,WAAU,eAAU,gBAAV,mBAAuB;AACvC,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AACA,WACE,aAAQ,kBAAkB,MAA1B,mBAA6B,aAAU,YAAO,OAAO,OAAO,EAAE,CAAC,MAAxB,mBAA2B;AAEtE;"}
|
|
@@ -16,5 +16,6 @@ export { createAttachmentUploadAdapter, DEFAULT_ATTACHMENT_LIMITS, type Attachme
|
|
|
16
16
|
export { clickyOperationsToTools, operationToTool, } from './clickyOperationsToTools';
|
|
17
17
|
export { ToolRenderRegistry, createToolRenderRegistry, toToolRenderRegistry, toolNameAdapter, ToolRenderRegistryProvider, useToolRenderRegistry, defaultToolInputView, defaultToolOutputView, defaultToolRenderAdapters, knownToolRenderAdapters, defaultToolSummary, summarizeToolValue, normalizeToolOutput, classifyToolValue, deriveColumns, fieldMetaFromSchema, listItemsSchema, orderFieldKeys, ToolParams, ToolFieldValue, ToolArgs, ToolValue, type ToolRenderAdapter, type ToolRenderAdapterContext, type ToolRenderBaseContext, type ToolRenderRegistryOptions, type ToolRenderSurface, type NormalizedToolOutput, type ClassifiedToolValue, type ToolValueShape, type ToolPageInfo, type ToolFieldMeta, type ToolParamsProps, type ToolArgsProps, type ToolValueProps, } from './tool-render';
|
|
18
18
|
export { mockChatTransport, MOCK_MODELS } from './Chat.fixtures';
|
|
19
|
-
export { isDynamicToolPart, isTypedToolPart, isReasoningPart, isFilePart, toolPartName, suggestionLabel, suggestionPrompt, CLAUDE_PERMISSION_MODES, CLAUDE_PERMISSION_MODE_OPTIONS, type AnyToolPart, type ChatModel, type ChatModelRuntime, type RuntimeAvailability, type RuntimeAvailabilityState, type ChatMessageMetadata, type ChatUsageSummary, type ChatBudgetConfig, type ChatUsageBreakdown, type ChatCostBreakdown, type ChatStatus, type ChatToolInputSchema, type ClaudePermissionMode, type ClaudePermissionModeOption, type ToolResultRenderArgs, type ToolResultRenderer, type ToolAnnotations, type ToolMeta, type
|
|
19
|
+
export { isDynamicToolPart, isTypedToolPart, isReasoningPart, isFilePart, toolPartName, suggestionLabel, suggestionPrompt, CLAUDE_PERMISSION_MODES, CLAUDE_PERMISSION_MODE_OPTIONS, type AnyToolPart, type ChatModel, type ChatModelRuntime, type RuntimeAvailability, type RuntimeAvailabilityState, type ChatMessageMetadata, type ChatUsageSummary, type ChatBudgetConfig, type ChatUsageBreakdown, type ChatCostBreakdown, type ChatStatus, type ChatToolInputSchema, type ClaudePermissionMode, type ClaudePermissionModeOption, type ToolResultRenderArgs, type ToolResultRenderer, type ToolAnnotations, type ToolMeta, type ToolPolicy, normalizeToolPolicy, type DynamicToolUIPart, type FileUIPart, type JSONSchemaProperty, type ReasoningUIPart, type Suggestion, type ToolUIPart, type UIMessage, } from './types';
|
|
20
|
+
export { appendToolPolicy, matchItems, matchesTool, normalizeToolPolicyRules, resolveToolPolicy, toolPolicyFromPreferences, type MatchPatterns, type PermissionPolicy, type PermissionRule, type ToolMatch, } from './tool-policy';
|
|
20
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/data/chat/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,E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7B,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,UAAU,EAIf,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,SAAS,GACf,MAAM,SAAS,CAAC;AAKjB,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,wBAAwB,EACxB,iBAAiB,EACjB,yBAAyB,EACzB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,SAAS,GACf,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const types = require("./types.cjs");
|
|
4
|
+
const MATCH_FACETS = [
|
|
5
|
+
"name",
|
|
6
|
+
"group",
|
|
7
|
+
"parent",
|
|
8
|
+
"entity",
|
|
9
|
+
"action",
|
|
10
|
+
"verb",
|
|
11
|
+
"method",
|
|
12
|
+
"scope"
|
|
13
|
+
];
|
|
14
|
+
function matchItems(item, patterns) {
|
|
15
|
+
const normalized = normalizePatterns(patterns);
|
|
16
|
+
if (normalized.length === 0) return true;
|
|
17
|
+
const sorted = [...normalized].sort(
|
|
18
|
+
(a, b) => exclusionRank(a) - exclusionRank(b)
|
|
19
|
+
);
|
|
20
|
+
for (const pattern of sorted) {
|
|
21
|
+
if (pattern.startsWith("!")) {
|
|
22
|
+
if (matchPattern(item, pattern.slice(1))) return false;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (matchPattern(item, pattern)) return true;
|
|
26
|
+
}
|
|
27
|
+
return sorted.every((pattern) => pattern.startsWith("!"));
|
|
28
|
+
}
|
|
29
|
+
function normalizePatterns(patterns) {
|
|
30
|
+
if (patterns === void 0) return [];
|
|
31
|
+
const list = typeof patterns === "string" ? [patterns] : patterns;
|
|
32
|
+
const out = [];
|
|
33
|
+
for (const raw of list) {
|
|
34
|
+
if (typeof raw !== "string") continue;
|
|
35
|
+
const parts = raw.split(",");
|
|
36
|
+
for (const part of parts) {
|
|
37
|
+
const trimmed = part.trim();
|
|
38
|
+
if (trimmed === "" && parts.length > 1) continue;
|
|
39
|
+
if (trimmed !== "") out.push(trimmed);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
function exclusionRank(pattern) {
|
|
45
|
+
if (pattern === "!*") return 0;
|
|
46
|
+
return pattern.startsWith("!") ? 1 : 2;
|
|
47
|
+
}
|
|
48
|
+
function matchPattern(item, pattern) {
|
|
49
|
+
if (pattern === "*") return true;
|
|
50
|
+
const value = item.toLowerCase();
|
|
51
|
+
const glob = pattern.toLowerCase();
|
|
52
|
+
if (value === glob) return true;
|
|
53
|
+
if (glob.startsWith("*") && glob.endsWith("*")) {
|
|
54
|
+
if (value.includes(glob.slice(1, -1))) return true;
|
|
55
|
+
}
|
|
56
|
+
if (glob.startsWith("*") && value.endsWith(glob.slice(1))) return true;
|
|
57
|
+
if (glob.endsWith("*") && value.startsWith(glob.slice(0, -1))) return true;
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
function resolveToolPolicy(policy, tool) {
|
|
61
|
+
let resolved;
|
|
62
|
+
for (const rule of policy ?? []) {
|
|
63
|
+
if (matchesTool(rule, tool)) resolved = rule.policy;
|
|
64
|
+
}
|
|
65
|
+
return resolved;
|
|
66
|
+
}
|
|
67
|
+
function matchesTool(match, tool) {
|
|
68
|
+
var _a, _b, _c;
|
|
69
|
+
const facets = {
|
|
70
|
+
name: tool.name ?? "",
|
|
71
|
+
group: tool.group ?? "",
|
|
72
|
+
parent: tool.parent ?? "",
|
|
73
|
+
entity: tool.entity ?? "",
|
|
74
|
+
action: tool.action ?? "",
|
|
75
|
+
verb: tool.verb ?? "",
|
|
76
|
+
method: tool.method ?? "",
|
|
77
|
+
scope: tool.scope ?? ""
|
|
78
|
+
};
|
|
79
|
+
for (const facet of MATCH_FACETS) {
|
|
80
|
+
if (!matchItems(facets[facet], match[facet])) return false;
|
|
81
|
+
}
|
|
82
|
+
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);
|
|
83
|
+
}
|
|
84
|
+
function matchesHint(want, have) {
|
|
85
|
+
if (want === void 0) return true;
|
|
86
|
+
return have !== void 0 && have === want;
|
|
87
|
+
}
|
|
88
|
+
function toolPolicyFromPreferences(prefs) {
|
|
89
|
+
const keys = Object.keys(prefs ?? {}).filter((key) => key.trim() !== "").sort();
|
|
90
|
+
if (keys.length === 0) return [];
|
|
91
|
+
const policies = /* @__PURE__ */ new Map();
|
|
92
|
+
for (const key of keys) {
|
|
93
|
+
const policy = types.normalizeToolPolicy(prefs == null ? void 0 : prefs[key]);
|
|
94
|
+
if (policy) policies.set(key, policy);
|
|
95
|
+
}
|
|
96
|
+
const ordered = [...policies.keys()];
|
|
97
|
+
return [
|
|
98
|
+
...ordered.map((key) => ({ group: key, policy: policies.get(key) })),
|
|
99
|
+
...ordered.map((key) => ({ name: key, policy: policies.get(key) }))
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
function appendToolPolicy(earlier, later) {
|
|
103
|
+
return [...earlier ?? [], ...later ?? []];
|
|
104
|
+
}
|
|
105
|
+
function normalizeToolPolicyRules(value) {
|
|
106
|
+
if (!Array.isArray(value)) return [];
|
|
107
|
+
const rules = [];
|
|
108
|
+
for (const raw of value) {
|
|
109
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
|
|
110
|
+
const item = raw;
|
|
111
|
+
const policy = types.normalizeToolPolicy(item.policy);
|
|
112
|
+
if (!policy) continue;
|
|
113
|
+
const match = {};
|
|
114
|
+
for (const facet of MATCH_FACETS) {
|
|
115
|
+
const patterns = normalizePatterns(item[facet]);
|
|
116
|
+
if (patterns.length > 0) match[facet] = patterns;
|
|
117
|
+
}
|
|
118
|
+
for (const hint of ["readOnly", "destructive", "idempotent"]) {
|
|
119
|
+
if (typeof item[hint] === "boolean") match[hint] = item[hint];
|
|
120
|
+
}
|
|
121
|
+
if (Object.keys(match).length === 0) continue;
|
|
122
|
+
rules.push({ ...match, policy });
|
|
123
|
+
}
|
|
124
|
+
return rules;
|
|
125
|
+
}
|
|
126
|
+
exports.appendToolPolicy = appendToolPolicy;
|
|
127
|
+
exports.matchItems = matchItems;
|
|
128
|
+
exports.matchesTool = matchesTool;
|
|
129
|
+
exports.normalizeToolPolicyRules = normalizeToolPolicyRules;
|
|
130
|
+
exports.resolveToolPolicy = resolveToolPolicy;
|
|
131
|
+
exports.toolPolicyFromPreferences = toolPolicyFromPreferences;
|
|
132
|
+
//# sourceMappingURL=tool-policy.cjs.map
|