@jini-ai/chat 0.1.0
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/LICENSE +201 -0
- package/README.md +109 -0
- package/dist/core/agentic/chat-capabilities.d.ts +19 -0
- package/dist/core/agentic/chat-capabilities.d.ts.map +1 -0
- package/dist/core/agentic/chat-capabilities.js +106 -0
- package/dist/core/agentic/chat-capabilities.js.map +1 -0
- package/dist/core/agentic/index.d.ts +22 -0
- package/dist/core/agentic/index.d.ts.map +1 -0
- package/dist/core/agentic/index.js +21 -0
- package/dist/core/agentic/index.js.map +1 -0
- package/dist/core/events.d.ts +84 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/events.js +14 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/index.d.ts +40 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +40 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/messages.d.ts +53 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +16 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/partial-json.d.ts +36 -0
- package/dist/core/partial-json.d.ts.map +1 -0
- package/dist/core/partial-json.js +119 -0
- package/dist/core/partial-json.js.map +1 -0
- package/dist/core/persistence/index.d.ts +11 -0
- package/dist/core/persistence/index.d.ts.map +1 -0
- package/dist/core/persistence/index.js +11 -0
- package/dist/core/persistence/index.js.map +1 -0
- package/dist/core/persistence/ports.d.ts +124 -0
- package/dist/core/persistence/ports.d.ts.map +1 -0
- package/dist/core/persistence/ports.js +2 -0
- package/dist/core/persistence/ports.js.map +1 -0
- package/dist/core/persistence/title.d.ts +35 -0
- package/dist/core/persistence/title.d.ts.map +1 -0
- package/dist/core/persistence/title.js +137 -0
- package/dist/core/persistence/title.js.map +1 -0
- package/dist/core/question-form/format.d.ts +27 -0
- package/dist/core/question-form/format.d.ts.map +1 -0
- package/dist/core/question-form/format.js +45 -0
- package/dist/core/question-form/format.js.map +1 -0
- package/dist/core/question-form/normalize.d.ts +30 -0
- package/dist/core/question-form/normalize.d.ts.map +1 -0
- package/dist/core/question-form/normalize.js +192 -0
- package/dist/core/question-form/normalize.js.map +1 -0
- package/dist/core/question-form/scan.d.ts +50 -0
- package/dist/core/question-form/scan.d.ts.map +1 -0
- package/dist/core/question-form/scan.js +404 -0
- package/dist/core/question-form/scan.js.map +1 -0
- package/dist/core/question-form/types.d.ts +83 -0
- package/dist/core/question-form/types.d.ts.map +1 -0
- package/dist/core/question-form/types.js +11 -0
- package/dist/core/question-form/types.js.map +1 -0
- package/dist/core/question-form.d.ts +39 -0
- package/dist/core/question-form.d.ts.map +1 -0
- package/dist/core/question-form.js +4 -0
- package/dist/core/question-form.js.map +1 -0
- package/dist/core/todos.d.ts +70 -0
- package/dist/core/todos.d.ts.map +1 -0
- package/dist/core/todos.js +175 -0
- package/dist/core/todos.js.map +1 -0
- package/dist/core/tool-events.d.ts +18 -0
- package/dist/core/tool-events.d.ts.map +1 -0
- package/dist/core/tool-events.js +36 -0
- package/dist/core/tool-events.js.map +1 -0
- package/dist/core/tools.d.ts +51 -0
- package/dist/core/tools.d.ts.map +1 -0
- package/dist/core/tools.js +41 -0
- package/dist/core/tools.js.map +1 -0
- package/dist/core/transcript.d.ts +81 -0
- package/dist/core/transcript.d.ts.map +1 -0
- package/dist/core/transcript.js +133 -0
- package/dist/core/transcript.js.map +1 -0
- package/dist/core/transport.d.ts +109 -0
- package/dist/core/transport.d.ts.map +1 -0
- package/dist/core/transport.js +2 -0
- package/dist/core/transport.js.map +1 -0
- package/dist/core/util/index.d.ts +16 -0
- package/dist/core/util/index.d.ts.map +1 -0
- package/dist/core/util/index.js +16 -0
- package/dist/core/util/index.js.map +1 -0
- package/dist/core/util/manifest.d.ts +39 -0
- package/dist/core/util/manifest.d.ts.map +1 -0
- package/dist/core/util/manifest.js +173 -0
- package/dist/core/util/manifest.js.map +1 -0
- package/dist/core/util/markdown-context.d.ts +47 -0
- package/dist/core/util/markdown-context.d.ts.map +1 -0
- package/dist/core/util/markdown-context.js +125 -0
- package/dist/core/util/markdown-context.js.map +1 -0
- package/dist/core/util/markup-attributes.d.ts +20 -0
- package/dist/core/util/markup-attributes.d.ts.map +1 -0
- package/dist/core/util/markup-attributes.js +33 -0
- package/dist/core/util/markup-attributes.js.map +1 -0
- package/dist/core/util/parser.d.ts +42 -0
- package/dist/core/util/parser.d.ts.map +1 -0
- package/dist/core/util/parser.js +238 -0
- package/dist/core/util/parser.js.map +1 -0
- package/dist/core/util/pointer.d.ts +28 -0
- package/dist/core/util/pointer.d.ts.map +1 -0
- package/dist/core/util/pointer.js +75 -0
- package/dist/core/util/pointer.js.map +1 -0
- package/dist/core/util/recover.d.ts +40 -0
- package/dist/core/util/recover.d.ts.map +1 -0
- package/dist/core/util/recover.js +117 -0
- package/dist/core/util/recover.js.map +1 -0
- package/dist/core/util/strip.d.ts +112 -0
- package/dist/core/util/strip.d.ts.map +1 -0
- package/dist/core/util/strip.js +333 -0
- package/dist/core/util/strip.js.map +1 -0
- package/dist/core/util/types.d.ts +31 -0
- package/dist/core/util/types.d.ts.map +1 -0
- package/dist/core/util/types.js +2 -0
- package/dist/core/util/types.js.map +1 -0
- package/dist/core/util/validate.d.ts +50 -0
- package/dist/core/util/validate.d.ts.map +1 -0
- package/dist/core/util/validate.js +202 -0
- package/dist/core/util/validate.js.map +1 -0
- package/dist/react/agent-bridge/frontend-session-bridge.d.ts +45 -0
- package/dist/react/agent-bridge/frontend-session-bridge.d.ts.map +1 -0
- package/dist/react/agent-bridge/frontend-session-bridge.js +214 -0
- package/dist/react/agent-bridge/frontend-session-bridge.js.map +1 -0
- package/dist/react/artifact-types.d.ts +61 -0
- package/dist/react/artifact-types.d.ts.map +1 -0
- package/dist/react/artifact-types.js +33 -0
- package/dist/react/artifact-types.js.map +1 -0
- package/dist/react/chat-pane.d.ts +21 -0
- package/dist/react/chat-pane.d.ts.map +1 -0
- package/dist/react/chat-pane.js +20 -0
- package/dist/react/chat-pane.js.map +1 -0
- package/dist/react/components/A2uiSurfaceCard.d.ts +35 -0
- package/dist/react/components/A2uiSurfaceCard.d.ts.map +1 -0
- package/dist/react/components/A2uiSurfaceCard.js +272 -0
- package/dist/react/components/A2uiSurfaceCard.js.map +1 -0
- package/dist/react/components/AttachmentTray.d.ts +6 -0
- package/dist/react/components/AttachmentTray.d.ts.map +1 -0
- package/dist/react/components/AttachmentTray.js +30 -0
- package/dist/react/components/AttachmentTray.js.map +1 -0
- package/dist/react/components/ChatFab.d.ts +8 -0
- package/dist/react/components/ChatFab.d.ts.map +1 -0
- package/dist/react/components/ChatFab.js +24 -0
- package/dist/react/components/ChatFab.js.map +1 -0
- package/dist/react/components/Composer.d.ts +34 -0
- package/dist/react/components/Composer.d.ts.map +1 -0
- package/dist/react/components/Composer.js +300 -0
- package/dist/react/components/Composer.js.map +1 -0
- package/dist/react/components/ComposerDiscovery.d.ts +46 -0
- package/dist/react/components/ComposerDiscovery.d.ts.map +1 -0
- package/dist/react/components/ComposerDiscovery.js +38 -0
- package/dist/react/components/ComposerDiscovery.js.map +1 -0
- package/dist/react/components/ConversationList.d.ts +31 -0
- package/dist/react/components/ConversationList.d.ts.map +1 -0
- package/dist/react/components/ConversationList.js +221 -0
- package/dist/react/components/ConversationList.js.map +1 -0
- package/dist/react/components/ExtEventErrorBoundary.d.ts +35 -0
- package/dist/react/components/ExtEventErrorBoundary.d.ts.map +1 -0
- package/dist/react/components/ExtEventErrorBoundary.js +38 -0
- package/dist/react/components/ExtEventErrorBoundary.js.map +1 -0
- package/dist/react/components/Icon.d.ts +17 -0
- package/dist/react/components/Icon.d.ts.map +1 -0
- package/dist/react/components/Icon.js +46 -0
- package/dist/react/components/Icon.js.map +1 -0
- package/dist/react/components/JiniChatProvider.d.ts +45 -0
- package/dist/react/components/JiniChatProvider.d.ts.map +1 -0
- package/dist/react/components/JiniChatProvider.js +44 -0
- package/dist/react/components/JiniChatProvider.js.map +1 -0
- package/dist/react/components/Markdown.d.ts +5 -0
- package/dist/react/components/Markdown.d.ts.map +1 -0
- package/dist/react/components/Markdown.js +390 -0
- package/dist/react/components/Markdown.js.map +1 -0
- package/dist/react/components/McpUiSurfaceCard.d.ts +51 -0
- package/dist/react/components/McpUiSurfaceCard.d.ts.map +1 -0
- package/dist/react/components/McpUiSurfaceCard.js +159 -0
- package/dist/react/components/McpUiSurfaceCard.js.map +1 -0
- package/dist/react/components/MessageList.d.ts +15 -0
- package/dist/react/components/MessageList.d.ts.map +1 -0
- package/dist/react/components/MessageList.js +81 -0
- package/dist/react/components/MessageList.js.map +1 -0
- package/dist/react/components/MessageRow.d.ts +60 -0
- package/dist/react/components/MessageRow.d.ts.map +1 -0
- package/dist/react/components/MessageRow.js +156 -0
- package/dist/react/components/MessageRow.js.map +1 -0
- package/dist/react/components/NextStepActions.d.ts +34 -0
- package/dist/react/components/NextStepActions.d.ts.map +1 -0
- package/dist/react/components/NextStepActions.js +9 -0
- package/dist/react/components/NextStepActions.js.map +1 -0
- package/dist/react/components/QuestionForm.d.ts +26 -0
- package/dist/react/components/QuestionForm.d.ts.map +1 -0
- package/dist/react/components/QuestionForm.js +238 -0
- package/dist/react/components/QuestionForm.js.map +1 -0
- package/dist/react/components/QuestionsPanel.d.ts +13 -0
- package/dist/react/components/QuestionsPanel.d.ts.map +1 -0
- package/dist/react/components/QuestionsPanel.js +33 -0
- package/dist/react/components/QuestionsPanel.js.map +1 -0
- package/dist/react/components/TodoCard.d.ts +8 -0
- package/dist/react/components/TodoCard.d.ts.map +1 -0
- package/dist/react/components/TodoCard.js +29 -0
- package/dist/react/components/TodoCard.js.map +1 -0
- package/dist/react/components/ToolCard.d.ts +22 -0
- package/dist/react/components/ToolCard.d.ts.map +1 -0
- package/dist/react/components/ToolCard.js +298 -0
- package/dist/react/components/ToolCard.js.map +1 -0
- package/dist/react/components/composer-discovery.d.ts +107 -0
- package/dist/react/components/composer-discovery.d.ts.map +1 -0
- package/dist/react/components/composer-discovery.js +176 -0
- package/dist/react/components/composer-discovery.js.map +1 -0
- package/dist/react/ext-event-renderer-registry.d.ts +51 -0
- package/dist/react/ext-event-renderer-registry.d.ts.map +1 -0
- package/dist/react/ext-event-renderer-registry.js +20 -0
- package/dist/react/ext-event-renderer-registry.js.map +1 -0
- package/dist/react/features/chat-pane/agent-tools.d.ts +14 -0
- package/dist/react/features/chat-pane/agent-tools.d.ts.map +1 -0
- package/dist/react/features/chat-pane/agent-tools.js +22 -0
- package/dist/react/features/chat-pane/agent-tools.js.map +1 -0
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +12 -0
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts.map +1 -0
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +106 -0
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.js.map +1 -0
- package/dist/react/features/chat-pane/components/ChatPane.d.ts +10 -0
- package/dist/react/features/chat-pane/components/ChatPane.d.ts.map +1 -0
- package/dist/react/features/chat-pane/components/ChatPane.js +169 -0
- package/dist/react/features/chat-pane/components/ChatPane.js.map +1 -0
- package/dist/react/features/chat-pane/create-daemon-attachment-uploader.d.ts +21 -0
- package/dist/react/features/chat-pane/create-daemon-attachment-uploader.d.ts.map +1 -0
- package/dist/react/features/chat-pane/create-daemon-attachment-uploader.js +213 -0
- package/dist/react/features/chat-pane/create-daemon-attachment-uploader.js.map +1 -0
- package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts +70 -0
- package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts.map +1 -0
- package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.js +76 -0
- package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.js.map +1 -0
- package/dist/react/features/chat-pane/hooks/useAgentRuntimePicker.hooks.d.ts +133 -0
- package/dist/react/features/chat-pane/hooks/useAgentRuntimePicker.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/hooks/useAgentRuntimePicker.hooks.js +258 -0
- package/dist/react/features/chat-pane/hooks/useAgentRuntimePicker.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +66 -0
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +224 -0
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.d.ts +38 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js +252 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneControlsHeight.hooks.d.ts +16 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneControlsHeight.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneControlsHeight.hooks.js +59 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneControlsHeight.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts +26 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js +74 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneRuntimeInventory.hooks.d.ts +25 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneRuntimeInventory.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneRuntimeInventory.hooks.js +88 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneRuntimeInventory.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneWorkingDirectory.hooks.d.ts +38 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneWorkingDirectory.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneWorkingDirectory.hooks.js +184 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneWorkingDirectory.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/index.d.ts +12 -0
- package/dist/react/features/chat-pane/index.d.ts.map +1 -0
- package/dist/react/features/chat-pane/index.js +11 -0
- package/dist/react/features/chat-pane/index.js.map +1 -0
- package/dist/react/features/chat-pane/react/components/AgentRuntimePicker.d.ts +12 -0
- package/dist/react/features/chat-pane/react/components/AgentRuntimePicker.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/components/AgentRuntimePicker.js +102 -0
- package/dist/react/features/chat-pane/react/components/AgentRuntimePicker.js.map +1 -0
- package/dist/react/features/chat-pane/react/components/ChatPane.d.ts +10 -0
- package/dist/react/features/chat-pane/react/components/ChatPane.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/components/ChatPane.js +137 -0
- package/dist/react/features/chat-pane/react/components/ChatPane.js.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useAgentRuntimePicker.hooks.d.ts +133 -0
- package/dist/react/features/chat-pane/react/hooks/useAgentRuntimePicker.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useAgentRuntimePicker.hooks.js +258 -0
- package/dist/react/features/chat-pane/react/hooks/useAgentRuntimePicker.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPane.hooks.d.ts +66 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPane.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPane.hooks.js +223 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPane.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneAgentControl.hooks.d.ts +38 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneAgentControl.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneAgentControl.hooks.js +252 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneAgentControl.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneFileDrop.hooks.d.ts +26 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneFileDrop.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneFileDrop.hooks.js +60 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneFileDrop.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneRuntimeInventory.hooks.d.ts +25 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneRuntimeInventory.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneRuntimeInventory.hooks.js +83 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneRuntimeInventory.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneWorkingDirectory.hooks.d.ts +38 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneWorkingDirectory.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneWorkingDirectory.hooks.js +184 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneWorkingDirectory.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/react/styles.d.ts +2 -0
- package/dist/react/features/chat-pane/react/styles.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/styles.js +863 -0
- package/dist/react/features/chat-pane/react/styles.js.map +1 -0
- package/dist/react/features/chat-pane/rules.d.ts +31 -0
- package/dist/react/features/chat-pane/rules.d.ts.map +1 -0
- package/dist/react/features/chat-pane/rules.js +81 -0
- package/dist/react/features/chat-pane/rules.js.map +1 -0
- package/dist/react/features/chat-pane/styles.d.ts +2 -0
- package/dist/react/features/chat-pane/styles.d.ts.map +1 -0
- package/dist/react/features/chat-pane/styles.js +1327 -0
- package/dist/react/features/chat-pane/styles.js.map +1 -0
- package/dist/react/features/chat-pane/types.d.ts +248 -0
- package/dist/react/features/chat-pane/types.d.ts.map +1 -0
- package/dist/react/features/chat-pane/types.js +2 -0
- package/dist/react/features/chat-pane/types.js.map +1 -0
- package/dist/react/features/model-picker/components/CredentialStatusBadge.d.ts +7 -0
- package/dist/react/features/model-picker/components/CredentialStatusBadge.d.ts.map +1 -0
- package/dist/react/features/model-picker/components/CredentialStatusBadge.js +20 -0
- package/dist/react/features/model-picker/components/CredentialStatusBadge.js.map +1 -0
- package/dist/react/features/model-picker/components/ModelPicker.d.ts +9 -0
- package/dist/react/features/model-picker/components/ModelPicker.d.ts.map +1 -0
- package/dist/react/features/model-picker/components/ModelPicker.js +34 -0
- package/dist/react/features/model-picker/components/ModelPicker.js.map +1 -0
- package/dist/react/features/model-picker/constants.d.ts +6 -0
- package/dist/react/features/model-picker/constants.d.ts.map +1 -0
- package/dist/react/features/model-picker/constants.js +9 -0
- package/dist/react/features/model-picker/constants.js.map +1 -0
- package/dist/react/features/model-picker/dependencies.d.ts +11 -0
- package/dist/react/features/model-picker/dependencies.d.ts.map +1 -0
- package/dist/react/features/model-picker/dependencies.js +10 -0
- package/dist/react/features/model-picker/dependencies.js.map +1 -0
- package/dist/react/features/model-picker/hooks/useModelPicker.hooks.d.ts +27 -0
- package/dist/react/features/model-picker/hooks/useModelPicker.hooks.d.ts.map +1 -0
- package/dist/react/features/model-picker/hooks/useModelPicker.hooks.js +62 -0
- package/dist/react/features/model-picker/hooks/useModelPicker.hooks.js.map +1 -0
- package/dist/react/features/model-picker/index.d.ts +32 -0
- package/dist/react/features/model-picker/index.d.ts.map +1 -0
- package/dist/react/features/model-picker/index.js +29 -0
- package/dist/react/features/model-picker/index.js.map +1 -0
- package/dist/react/features/model-picker/ports.d.ts +11 -0
- package/dist/react/features/model-picker/ports.d.ts.map +1 -0
- package/dist/react/features/model-picker/ports.js +2 -0
- package/dist/react/features/model-picker/ports.js.map +1 -0
- package/dist/react/features/model-picker/react/components/CredentialStatusBadge.d.ts +7 -0
- package/dist/react/features/model-picker/react/components/CredentialStatusBadge.d.ts.map +1 -0
- package/dist/react/features/model-picker/react/components/CredentialStatusBadge.js +20 -0
- package/dist/react/features/model-picker/react/components/CredentialStatusBadge.js.map +1 -0
- package/dist/react/features/model-picker/react/components/ModelPicker.d.ts +9 -0
- package/dist/react/features/model-picker/react/components/ModelPicker.d.ts.map +1 -0
- package/dist/react/features/model-picker/react/components/ModelPicker.js +34 -0
- package/dist/react/features/model-picker/react/components/ModelPicker.js.map +1 -0
- package/dist/react/features/model-picker/react/hooks/useModelPicker.hooks.d.ts +27 -0
- package/dist/react/features/model-picker/react/hooks/useModelPicker.hooks.d.ts.map +1 -0
- package/dist/react/features/model-picker/react/hooks/useModelPicker.hooks.js +62 -0
- package/dist/react/features/model-picker/react/hooks/useModelPicker.hooks.js.map +1 -0
- package/dist/react/features/model-picker/rules.d.ts +26 -0
- package/dist/react/features/model-picker/rules.d.ts.map +1 -0
- package/dist/react/features/model-picker/rules.js +84 -0
- package/dist/react/features/model-picker/rules.js.map +1 -0
- package/dist/react/features/model-picker/types.d.ts +38 -0
- package/dist/react/features/model-picker/types.d.ts.map +1 -0
- package/dist/react/features/model-picker/types.js +2 -0
- package/dist/react/features/model-picker/types.js.map +1 -0
- package/dist/react/hooks/composer-draft-cache.d.ts +65 -0
- package/dist/react/hooks/composer-draft-cache.d.ts.map +1 -0
- package/dist/react/hooks/composer-draft-cache.js +89 -0
- package/dist/react/hooks/composer-draft-cache.js.map +1 -0
- package/dist/react/hooks/context.d.ts +18 -0
- package/dist/react/hooks/context.d.ts.map +1 -0
- package/dist/react/hooks/context.js +60 -0
- package/dist/react/hooks/context.js.map +1 -0
- package/dist/react/hooks/testing/fake-transport.d.ts +34 -0
- package/dist/react/hooks/testing/fake-transport.d.ts.map +1 -0
- package/dist/react/hooks/testing/fake-transport.js +46 -0
- package/dist/react/hooks/testing/fake-transport.js.map +1 -0
- package/dist/react/hooks/useArtifactStream.d.ts +18 -0
- package/dist/react/hooks/useArtifactStream.d.ts.map +1 -0
- package/dist/react/hooks/useArtifactStream.js +55 -0
- package/dist/react/hooks/useArtifactStream.js.map +1 -0
- package/dist/react/hooks/useChatFabDrag.d.ts +25 -0
- package/dist/react/hooks/useChatFabDrag.d.ts.map +1 -0
- package/dist/react/hooks/useChatFabDrag.js +88 -0
- package/dist/react/hooks/useChatFabDrag.js.map +1 -0
- package/dist/react/hooks/useComposer.d.ts +48 -0
- package/dist/react/hooks/useComposer.d.ts.map +1 -0
- package/dist/react/hooks/useComposer.js +121 -0
- package/dist/react/hooks/useComposer.js.map +1 -0
- package/dist/react/hooks/useConversation.d.ts +34 -0
- package/dist/react/hooks/useConversation.d.ts.map +1 -0
- package/dist/react/hooks/useConversation.js +163 -0
- package/dist/react/hooks/useConversation.js.map +1 -0
- package/dist/react/hooks/useCopyToClipboard.d.ts +14 -0
- package/dist/react/hooks/useCopyToClipboard.d.ts.map +1 -0
- package/dist/react/hooks/useCopyToClipboard.js +98 -0
- package/dist/react/hooks/useCopyToClipboard.js.map +1 -0
- package/dist/react/hooks/useExtEventGroups.d.ts +7 -0
- package/dist/react/hooks/useExtEventGroups.d.ts.map +1 -0
- package/dist/react/hooks/useExtEventGroups.js +32 -0
- package/dist/react/hooks/useExtEventGroups.js.map +1 -0
- package/dist/react/hooks/useLatestOperation.d.ts +31 -0
- package/dist/react/hooks/useLatestOperation.d.ts.map +1 -0
- package/dist/react/hooks/useLatestOperation.js +74 -0
- package/dist/react/hooks/useLatestOperation.js.map +1 -0
- package/dist/react/hooks/usePinnedTodos.d.ts +15 -0
- package/dist/react/hooks/usePinnedTodos.d.ts.map +1 -0
- package/dist/react/hooks/usePinnedTodos.js +43 -0
- package/dist/react/hooks/usePinnedTodos.js.map +1 -0
- package/dist/react/hooks/useQuestionForms.d.ts +28 -0
- package/dist/react/hooks/useQuestionForms.d.ts.map +1 -0
- package/dist/react/hooks/useQuestionForms.js +113 -0
- package/dist/react/hooks/useQuestionForms.js.map +1 -0
- package/dist/react/hooks/useRunStream.d.ts +27 -0
- package/dist/react/hooks/useRunStream.d.ts.map +1 -0
- package/dist/react/hooks/useRunStream.js +180 -0
- package/dist/react/hooks/useRunStream.js.map +1 -0
- package/dist/react/hooks/useToolTimeline.d.ts +33 -0
- package/dist/react/hooks/useToolTimeline.d.ts.map +1 -0
- package/dist/react/hooks/useToolTimeline.js +47 -0
- package/dist/react/hooks/useToolTimeline.js.map +1 -0
- package/dist/react/index.d.ts +158 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +118 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/message-blocks.d.ts +86 -0
- package/dist/react/message-blocks.d.ts.map +1 -0
- package/dist/react/message-blocks.js +78 -0
- package/dist/react/message-blocks.js.map +1 -0
- package/dist/react/poc-mcp-ui-official/PocMcpUiCard.d.ts +9 -0
- package/dist/react/poc-mcp-ui-official/PocMcpUiCard.d.ts.map +1 -0
- package/dist/react/poc-mcp-ui-official/PocMcpUiCard.js +29 -0
- package/dist/react/poc-mcp-ui-official/PocMcpUiCard.js.map +1 -0
- package/dist/react/poc-mcp-ui-official/create-poc-resource.d.ts +30 -0
- package/dist/react/poc-mcp-ui-official/create-poc-resource.d.ts.map +1 -0
- package/dist/react/poc-mcp-ui-official/create-poc-resource.js +44 -0
- package/dist/react/poc-mcp-ui-official/create-poc-resource.js.map +1 -0
- package/dist/react/slots.d.ts +215 -0
- package/dist/react/slots.d.ts.map +1 -0
- package/dist/react/slots.js +2 -0
- package/dist/react/slots.js.map +1 -0
- package/dist/react/styles/reference.css +298 -0
- package/dist/react/tool-renderer-registry.d.ts +41 -0
- package/dist/react/tool-renderer-registry.d.ts.map +1 -0
- package/dist/react/tool-renderer-registry.js +22 -0
- package/dist/react/tool-renderer-registry.js.map +1 -0
- package/dist/react/util/defined-props.d.ts +31 -0
- package/dist/react/util/defined-props.d.ts.map +1 -0
- package/dist/react/util/defined-props.js +28 -0
- package/dist/react/util/defined-props.js.map +1 -0
- package/package.json +99 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* All of `AgentRuntimePicker`'s behavior, so the component itself is only markup.
|
|
3
|
+
*
|
|
4
|
+
* What lives here is popover mechanics — open/close, dismissal, viewport-bounded positioning,
|
|
5
|
+
* focus restoration, and roving/trapped keyboard focus — plus the two derived labels the view
|
|
6
|
+
* shows. None of it is chat-specific; the only reason it is scoped to this feature rather than
|
|
7
|
+
* promoted to `@jini-ai/ui` is noted at the bottom of this comment.
|
|
8
|
+
*
|
|
9
|
+
* The pure functions below are separated from the hook deliberately: geometry and key-to-index
|
|
10
|
+
* resolution have real input/output contracts and edge cases (viewport clamping, `currentIndex`
|
|
11
|
+
* of `-1`, Tab-at-an-edge) that are far cheaper to test directly than to drive through a rendered
|
|
12
|
+
* popover with a mocked `getBoundingClientRect`. The hook itself owns only React lifecycle.
|
|
13
|
+
*
|
|
14
|
+
* **Not yet using `@jini-ai/ui`'s `useDismissOnOutsideOrEscape`**, which covers the same
|
|
15
|
+
* outside-click/Escape ground and whose own doc notes six features had hand-rolled it before this
|
|
16
|
+
* one. Two concrete mismatches block a drop-in: it takes a single `containerRef`, whereas here
|
|
17
|
+
* "inside" means the trigger *or* the portaled popover (two disjoint subtrees, since the popover
|
|
18
|
+
* renders into `document.body`); and it exposes one `onDismiss` with no indication of which input
|
|
19
|
+
* dismissed, while this popover must restore focus on the next tick for a pointer and immediately
|
|
20
|
+
* for Escape (see the comment on that timeout). Consolidating means extending the shared hook to
|
|
21
|
+
* accept multiple containers and report the dismissal cause — worth doing, but as its own change
|
|
22
|
+
* to a package other features already depend on, not as a side effect of this extraction.
|
|
23
|
+
*/
|
|
24
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState, } from 'react';
|
|
25
|
+
import { orderChatPaneAgents } from '../../rules.js';
|
|
26
|
+
/** Everything in the popover a roving/trapping key handler is allowed to move focus between. */
|
|
27
|
+
const FOCUSABLE_CONTROLS = 'button:not(:disabled), select:not(:disabled), input:not(:disabled)';
|
|
28
|
+
/**
|
|
29
|
+
* Resolves the user-facing label for a selected model or reasoning option.
|
|
30
|
+
*
|
|
31
|
+
* @complexity Time: O(n) in the supplied option count; space: O(1).
|
|
32
|
+
* @overallScore 100/100
|
|
33
|
+
*/
|
|
34
|
+
export function runtimeOptionLabel(options, value, fallback) {
|
|
35
|
+
if (!value || value === 'default')
|
|
36
|
+
return fallback;
|
|
37
|
+
return options?.find((option) => option.id === value)?.label ?? value;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Computes a viewport-bounded fixed position for the body-portaled picker.
|
|
41
|
+
*
|
|
42
|
+
* @complexity Time/space: O(1).
|
|
43
|
+
* @overallScore 100/100
|
|
44
|
+
*/
|
|
45
|
+
export function runtimePopoverPosition(trigger, placement) {
|
|
46
|
+
const margin = 12;
|
|
47
|
+
const gap = 8;
|
|
48
|
+
const width = Math.min(320, window.innerWidth - margin * 2);
|
|
49
|
+
const left = Math.min(Math.max(trigger.left + trigger.width / 2 - width / 2, margin), window.innerWidth - width - margin);
|
|
50
|
+
if (placement === 'up') {
|
|
51
|
+
const availableHeight = Math.max(0, trigger.top - margin - gap);
|
|
52
|
+
return {
|
|
53
|
+
position: 'fixed',
|
|
54
|
+
left,
|
|
55
|
+
bottom: Math.max(margin, window.innerHeight - trigger.top + gap),
|
|
56
|
+
width,
|
|
57
|
+
maxHeight: Math.min(620, availableHeight),
|
|
58
|
+
overflowY: 'auto',
|
|
59
|
+
zIndex: 1000,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const top = trigger.bottom + gap;
|
|
63
|
+
const availableHeight = Math.max(0, window.innerHeight - top - margin);
|
|
64
|
+
return {
|
|
65
|
+
position: 'fixed',
|
|
66
|
+
top,
|
|
67
|
+
left,
|
|
68
|
+
width,
|
|
69
|
+
maxHeight: Math.min(620, availableHeight),
|
|
70
|
+
overflowY: 'auto',
|
|
71
|
+
zIndex: 1000,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** `Tab` wraps focus around the popover's control list instead of leaving it (the popover is a
|
|
75
|
+
* modal-ish dialog). Returns the index to wrap TO, or `null` when `Tab` should behave natively
|
|
76
|
+
* (not at an edge). `currentIndex` may be `-1` (active element not in `controls`); `atStart`/
|
|
77
|
+
* `atEnd` below only matter when it legitimately is 0 or `count - 1`. */
|
|
78
|
+
export function resolveTabWrapIndex(shiftKey, currentIndex, count) {
|
|
79
|
+
if (shiftKey && currentIndex === 0)
|
|
80
|
+
return count - 1;
|
|
81
|
+
if (!shiftKey && currentIndex === count - 1)
|
|
82
|
+
return 0;
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
/** Arrow/Home/End roving-tabindex target, or `null` for any other key. `currentIndex === -1`
|
|
86
|
+
* (nothing in `controls` focused yet) is a legitimate input — the modulo arithmetic below relies
|
|
87
|
+
* on it wrapping the same way a real index would. */
|
|
88
|
+
export function resolveRovingIndex(key, currentIndex, count) {
|
|
89
|
+
if (key === 'Home')
|
|
90
|
+
return 0;
|
|
91
|
+
if (key === 'End')
|
|
92
|
+
return count - 1;
|
|
93
|
+
if (key === 'ArrowDown')
|
|
94
|
+
return (currentIndex + 1 + count) % count;
|
|
95
|
+
if (key === 'ArrowUp')
|
|
96
|
+
return (currentIndex - 1 + count) % count;
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The control index the popover's key handler should move focus to, or `null` to leave focus alone
|
|
101
|
+
* (and, in the caller, to skip `preventDefault()`). `Tab` is resolved and returned immediately —
|
|
102
|
+
* it must never fall through to the roving-tabindex logic below it.
|
|
103
|
+
*/
|
|
104
|
+
export function resolvePopoverKeyAction(key, shiftKey, isButtonTarget, currentIndex, count) {
|
|
105
|
+
if (key === 'Tab')
|
|
106
|
+
return resolveTabWrapIndex(shiftKey, currentIndex, count);
|
|
107
|
+
// Native selects own their arrow/Home/End behavior. Roving applies only
|
|
108
|
+
// when a button (including the agent radios) has focus.
|
|
109
|
+
if (!isButtonTarget)
|
|
110
|
+
return null;
|
|
111
|
+
return resolveRovingIndex(key, currentIndex, count);
|
|
112
|
+
}
|
|
113
|
+
/** Builds the one-line "which runtime am I talking to" summary shown in the popover head. */
|
|
114
|
+
export function runtimeSummaryText(selectedAgent, modelLabel, t) {
|
|
115
|
+
if (selectedAgent === undefined)
|
|
116
|
+
return t('No agent selected');
|
|
117
|
+
const version = selectedAgent.version ? ` · ${selectedAgent.version}` : '';
|
|
118
|
+
return `${selectedAgent.name}${version} · ${modelLabel}`;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The head/trigger labels while `executionMode` is `'api'`.
|
|
122
|
+
*
|
|
123
|
+
* Separate from {@link runtimeSummaryText} rather than folded into it because the two describe
|
|
124
|
+
* different things and fail differently: that one names a detected CLI and its model, this one
|
|
125
|
+
* names a provider and the model the credential is configured for, and neither has a sensible
|
|
126
|
+
* fallback to the other. A missing provider label here is not "no agent selected" — the API path is
|
|
127
|
+
* still what will run — so the fallback is a generic mode name, never a CLI's.
|
|
128
|
+
*
|
|
129
|
+
* @complexity Time/space: O(1).
|
|
130
|
+
*/
|
|
131
|
+
export function byokSummaryText(byokRuntime, t) {
|
|
132
|
+
const title = byokRuntime?.providerLabel?.trim() || t('API · BYOK');
|
|
133
|
+
const model = byokRuntime?.model?.trim();
|
|
134
|
+
const modelLabel = model || t('No model configured');
|
|
135
|
+
return { title, modelLabel, summary: `${title} · ${modelLabel}` };
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Owns the runtime picker's popover state so the component stays presentational.
|
|
139
|
+
*
|
|
140
|
+
* @complexity Time: O(n) in the agent count for ordering/selection; space: O(n) for the ordered
|
|
141
|
+
* snapshot. The DOM queries are O(c) in the popover's own control count.
|
|
142
|
+
*/
|
|
143
|
+
export function useAgentRuntimePicker({ agents, value, placement, t, executionMode = 'local', byokRuntime, }) {
|
|
144
|
+
const dialogId = useId();
|
|
145
|
+
const [open, setOpen] = useState(false);
|
|
146
|
+
const [position, setPosition] = useState();
|
|
147
|
+
const triggerRef = useRef(null);
|
|
148
|
+
const popoverRef = useRef(null);
|
|
149
|
+
const orderedAgents = useMemo(() => orderChatPaneAgents(agents.filter((agent) => agent.available !== false)), [agents]);
|
|
150
|
+
const selectedAgent = orderedAgents.find((agent) => agent.id === value.agentId);
|
|
151
|
+
// `selectedAgent` stays resolved in BOTH modes on purpose — the CLI selection is still the stored
|
|
152
|
+
// one, and switching back to Local CLI must not have silently lost it. What changes in `'api'` is
|
|
153
|
+
// only what gets DESCRIBED, because none of the CLI's labels are true of an API turn.
|
|
154
|
+
const localModelLabel = runtimeOptionLabel(selectedAgent?.models, value.model, t('Default model'));
|
|
155
|
+
const byok = byokSummaryText(byokRuntime, t);
|
|
156
|
+
const isApi = executionMode === 'api';
|
|
157
|
+
const modelLabel = isApi ? byok.modelLabel : localModelLabel;
|
|
158
|
+
const runtimeSummary = isApi ? byok.summary : runtimeSummaryText(selectedAgent, localModelLabel, t);
|
|
159
|
+
const triggerTitle = isApi ? byok.title : (selectedAgent?.name ?? t('Choose agent'));
|
|
160
|
+
// Read during render rather than in an effect: the popover only mounts once `open` is true, which
|
|
161
|
+
// is itself a re-render, and `triggerRef` is populated at the first commit — so by the time this
|
|
162
|
+
// value is used it is always resolved. See `originTheme` on the result type for why it exists.
|
|
163
|
+
const originTheme = triggerRef.current?.closest('[data-theme]')?.getAttribute('data-theme') ?? null;
|
|
164
|
+
const focusTrigger = useCallback(() => {
|
|
165
|
+
triggerRef.current?.focus();
|
|
166
|
+
}, []);
|
|
167
|
+
const toggleOpen = useCallback(() => {
|
|
168
|
+
setOpen((current) => !current);
|
|
169
|
+
}, []);
|
|
170
|
+
useEffect(() => {
|
|
171
|
+
if (!open)
|
|
172
|
+
return;
|
|
173
|
+
const closeOnOutsidePointer = (event) => {
|
|
174
|
+
const target = event.target;
|
|
175
|
+
if (triggerRef.current?.contains(target)
|
|
176
|
+
|| popoverRef.current?.contains(target)
|
|
177
|
+
// A control INSIDE the popover may itself portal its menu to `document.body` —
|
|
178
|
+
// `@jini-ai/ui`'s `CustomSelect` (and so `SearchableModelSelect`, which the BYOK model row
|
|
179
|
+
// uses) does exactly that. Such a menu is a descendant of neither ref, so without this the
|
|
180
|
+
// first mousedown on a model option would be read as an outside click and close the
|
|
181
|
+
// popover out from under the selection the operator was making.
|
|
182
|
+
|| (target instanceof Element && target.closest('.jini-select-menu') !== null))
|
|
183
|
+
return;
|
|
184
|
+
setOpen(false);
|
|
185
|
+
// Let the pointer's click complete before restoring focus. Otherwise the
|
|
186
|
+
// browser focuses the clicked node after this mousedown handler runs.
|
|
187
|
+
window.setTimeout(focusTrigger, 0);
|
|
188
|
+
};
|
|
189
|
+
const closeOnEscape = (event) => {
|
|
190
|
+
if (event.key !== 'Escape')
|
|
191
|
+
return;
|
|
192
|
+
setOpen(false);
|
|
193
|
+
focusTrigger();
|
|
194
|
+
};
|
|
195
|
+
document.addEventListener('mousedown', closeOnOutsidePointer);
|
|
196
|
+
document.addEventListener('keydown', closeOnEscape);
|
|
197
|
+
return () => {
|
|
198
|
+
document.removeEventListener('mousedown', closeOnOutsidePointer);
|
|
199
|
+
document.removeEventListener('keydown', closeOnEscape);
|
|
200
|
+
};
|
|
201
|
+
}, [focusTrigger, open]);
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
if (!open)
|
|
204
|
+
return;
|
|
205
|
+
const update = () => {
|
|
206
|
+
const rect = triggerRef.current?.getBoundingClientRect();
|
|
207
|
+
if (rect)
|
|
208
|
+
setPosition(runtimePopoverPosition(rect, placement));
|
|
209
|
+
};
|
|
210
|
+
update();
|
|
211
|
+
window.addEventListener('resize', update);
|
|
212
|
+
// Capture phase: a scroll inside any ancestor moves the trigger too, and scroll does not bubble.
|
|
213
|
+
window.addEventListener('scroll', update, true);
|
|
214
|
+
return () => {
|
|
215
|
+
window.removeEventListener('resize', update);
|
|
216
|
+
window.removeEventListener('scroll', update, true);
|
|
217
|
+
};
|
|
218
|
+
}, [open, placement]);
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
if (!open || !position)
|
|
221
|
+
return;
|
|
222
|
+
const popover = popoverRef.current;
|
|
223
|
+
const selectedRadio = popover?.querySelector('[role="radio"][aria-checked="true"]');
|
|
224
|
+
const fallback = popover?.querySelector(FOCUSABLE_CONTROLS);
|
|
225
|
+
(selectedRadio ?? fallback)?.focus();
|
|
226
|
+
}, [open, position]);
|
|
227
|
+
const handlePopoverKeyDown = useCallback((event) => {
|
|
228
|
+
// No `?? []` fallback for a null ref: this handler is only ever reachable via the
|
|
229
|
+
// `onKeyDown` React wires to the exact element `popoverRef` is attached to, and
|
|
230
|
+
// React attaches refs during commit — before that element can dispatch any event — so
|
|
231
|
+
// `popoverRef.current` is guaranteed non-null by the time this runs.
|
|
232
|
+
const controls = [...popoverRef.current.querySelectorAll(FOCUSABLE_CONTROLS)];
|
|
233
|
+
if (controls.length === 0)
|
|
234
|
+
return;
|
|
235
|
+
const currentIndex = controls.indexOf(document.activeElement);
|
|
236
|
+
const nextIndex = resolvePopoverKeyAction(event.key, event.shiftKey, event.target instanceof HTMLButtonElement, currentIndex, controls.length);
|
|
237
|
+
if (nextIndex === null)
|
|
238
|
+
return;
|
|
239
|
+
event.preventDefault();
|
|
240
|
+
controls[nextIndex]?.focus();
|
|
241
|
+
}, []);
|
|
242
|
+
return {
|
|
243
|
+
dialogId,
|
|
244
|
+
open,
|
|
245
|
+
position,
|
|
246
|
+
triggerRef,
|
|
247
|
+
popoverRef,
|
|
248
|
+
orderedAgents,
|
|
249
|
+
selectedAgent,
|
|
250
|
+
modelLabel,
|
|
251
|
+
runtimeSummary,
|
|
252
|
+
triggerTitle,
|
|
253
|
+
originTheme,
|
|
254
|
+
toggleOpen,
|
|
255
|
+
handlePopoverKeyDown,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=useAgentRuntimePicker.hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAgentRuntimePicker.hooks.js","sourceRoot":"","sources":["../../../../../../src/react/features/chat-pane/react/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E,CAAC,CAAC;IAEP,OAAO;QACL,QAAQ;QACR,IAAI;QACJ,QAAQ;QACR,UAAU;QACV,UAAU;QACV,aAAa;QACb,aAAa;QACb,UAAU;QACV,cAAc;QACd,YAAY;QACZ,WAAW;QACX,UAAU;QACV,oBAAoB;KACrB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type ChatPaneSendBlocker } from '../../rules.js';
|
|
2
|
+
import type { ChatPaneActivity, ChatPaneAgent, ChatPaneAttachmentUploadOptions, ChatPaneAgentSelection, ChatPaneRunContext, ChatPaneWorkingDirectoryAccess } from '../../types.js';
|
|
3
|
+
import type { ChatAttachment, ChatMessage } from '@jini-ai/chat/core';
|
|
4
|
+
import type { ChatTransport } from '@jini-ai/chat/core';
|
|
5
|
+
import { type UseComposerResult } from '../../../../hooks/useComposer.js';
|
|
6
|
+
import { type UseConversationResult } from '../../../../hooks/useConversation.js';
|
|
7
|
+
import { type UseChatPaneWorkingDirectoryResult } from './useChatPaneWorkingDirectory.hooks.js';
|
|
8
|
+
export interface UseChatPaneOptions {
|
|
9
|
+
transport: ChatTransport;
|
|
10
|
+
agents: readonly ChatPaneAgent[];
|
|
11
|
+
initialMessages?: ChatMessage[];
|
|
12
|
+
conversationId?: string | null;
|
|
13
|
+
initialSelection?: ChatPaneAgentSelection;
|
|
14
|
+
selection?: ChatPaneAgentSelection;
|
|
15
|
+
onSelectionChange?: (selection: ChatPaneAgentSelection) => void;
|
|
16
|
+
runContext?: ChatPaneRunContext;
|
|
17
|
+
initialDraft?: string;
|
|
18
|
+
uploadAttachments?: (files: File[], options?: ChatPaneAttachmentUploadOptions) => Promise<ChatAttachment[]>;
|
|
19
|
+
onActivityChange?: (activity: ChatPaneActivity) => void;
|
|
20
|
+
onMessagesChange?: (messages: ChatMessage[]) => void;
|
|
21
|
+
workingDirectory?: string | null;
|
|
22
|
+
initialWorkingDirectory?: string | null;
|
|
23
|
+
onChangeWorkingDirectory?: (workingDirectory: string | null) => void;
|
|
24
|
+
workingDirectoryAccess?: ChatPaneWorkingDirectoryAccess;
|
|
25
|
+
}
|
|
26
|
+
export interface UseChatPaneResult extends UseChatPaneWorkingDirectoryResult {
|
|
27
|
+
conversation: UseConversationResult;
|
|
28
|
+
composer: UseComposerResult;
|
|
29
|
+
selection: ChatPaneAgentSelection;
|
|
30
|
+
selectedAgent: ChatPaneAgent | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The runtime inventory this pane is choosing from.
|
|
33
|
+
*
|
|
34
|
+
* Exposed so a caller can tell whether a selection *would* be honored before making it.
|
|
35
|
+
* {@link setSelection} normalizes an unknown or unavailable agent to the first available one —
|
|
36
|
+
* right for a picker, which must not break when a runtime disappears, and wrong for a
|
|
37
|
+
* programmatic caller, which would otherwise be told its choice succeeded while a different
|
|
38
|
+
* runtime was selected.
|
|
39
|
+
*/
|
|
40
|
+
agents: readonly ChatPaneAgent[];
|
|
41
|
+
activity: ChatPaneActivity;
|
|
42
|
+
canSend: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Why a send would be refused, or `null` when the pane is ready. `canSend` additionally requires
|
|
45
|
+
* a submittable composer; a caller supplying its own prompt should gate on this instead.
|
|
46
|
+
*/
|
|
47
|
+
sendBlocker: ChatPaneSendBlocker | null;
|
|
48
|
+
isUploadingAttachments: boolean;
|
|
49
|
+
attachmentError: Error | null;
|
|
50
|
+
setSelection: (selection: ChatPaneAgentSelection) => void;
|
|
51
|
+
addAttachments: (files: File[]) => Promise<void>;
|
|
52
|
+
send: () => Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Sends `prompt` through the same guarded path as the composer's `send()` — same blocker checks,
|
|
55
|
+
* staged attachments, composer reset, attachment-batch rotation, and `onActivityChange('queued')`.
|
|
56
|
+
* Exists so non-composer callers (agent control) cannot drift into a weaker send.
|
|
57
|
+
*
|
|
58
|
+
* @throws If {@link UseChatPaneResult.sendBlocker} is non-null, or `prompt` is blank. `send()`
|
|
59
|
+
* pre-checks and never triggers this; agent-driven callers get a describable refusal instead of a
|
|
60
|
+
* silent no-op.
|
|
61
|
+
*/
|
|
62
|
+
sendPrompt: (prompt: string) => Promise<void>;
|
|
63
|
+
reset: () => void;
|
|
64
|
+
}
|
|
65
|
+
export declare function useChatPane(options: UseChatPaneOptions): UseChatPaneResult;
|
|
66
|
+
//# sourceMappingURL=useChatPane.hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChatPane.hooks.d.ts","sourceRoot":"","sources":["../../../../../../src/react/features/chat-pane/react/hooks/useChatPane.hooks.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,+BAA+B,EAC/B,sBAAsB,EACtB,kBAAkB,EAClB,8BAA8B,EAC/B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACvF,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAEL,KAAK,iCAAiC,EACvC,MAAM,wCAAwC,CAAC;AAEhD,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,aAAa,CAAC;IACzB,MAAM,EAAE,SAAS,aAAa,EAAE,CAAC;IACjC,eAAe,CAAC,EAAE,WAAW,EAAE,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAC1C,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAChE,UAAU,CAA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AQG;IACH,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AA+CD,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,iBAAiB,CA6L1E"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { describeChatPaneSendBlocker, findChatPaneSendBlocker, resolveChatPaneSelection, } from '../../rules.js';
|
|
3
|
+
import { definedProps } from '../../../../util/defined-props.js';
|
|
4
|
+
import { useComposer } from '../../../../hooks/useComposer.js';
|
|
5
|
+
import { useConversation, } from '../../../../hooks/useConversation.js';
|
|
6
|
+
import { useChatPaneWorkingDirectory, } from './useChatPaneWorkingDirectory.hooks.js';
|
|
7
|
+
function createAttachmentBatchId() {
|
|
8
|
+
return globalThis.crypto?.randomUUID?.()
|
|
9
|
+
?? `chat-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
10
|
+
}
|
|
11
|
+
/** Module scope so each branch costs 1 cognitive point instead of 2 (nested one level inside
|
|
12
|
+
* `useChatPane` where it used to live as a ternary chain). */
|
|
13
|
+
function resolveChatPaneActivity(selectedAgent, conversation) {
|
|
14
|
+
if (selectedAgent === undefined)
|
|
15
|
+
return 'unavailable';
|
|
16
|
+
if (conversation.error)
|
|
17
|
+
return 'failed';
|
|
18
|
+
if (conversation.isStreaming)
|
|
19
|
+
return 'streaming';
|
|
20
|
+
return 'ready';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Runs one attachment upload and, unless superseded/unmounted/aborted by the time it resolves,
|
|
24
|
+
* hands the results (or error) to the caller's effects. Concurrent by design — unlike
|
|
25
|
+
* {@link useLatestOperation}'s latest-wins model, several batches may be in flight at once
|
|
26
|
+
* (`addAttachments`'s `activeUploadsRef` is a `Set`, not a single slot) — so this takes an explicit
|
|
27
|
+
* `stillWanted()` check per attempt rather than a shared generation token.
|
|
28
|
+
*/
|
|
29
|
+
async function uploadAttachmentBatch(files, effects) {
|
|
30
|
+
try {
|
|
31
|
+
const uploaded = await effects.upload(files, { signal: effects.signal, batchId: effects.batchId });
|
|
32
|
+
if (!effects.stillWanted())
|
|
33
|
+
return;
|
|
34
|
+
for (const attachment of uploaded)
|
|
35
|
+
effects.onAttachment(attachment);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (!effects.stillWanted())
|
|
39
|
+
return;
|
|
40
|
+
effects.onError(error instanceof Error ? error : new Error(String(error)));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function useChatPane(options) {
|
|
44
|
+
const [activeUploadCount, setActiveUploadCount] = useState(0);
|
|
45
|
+
const [attachmentError, setAttachmentError] = useState(null);
|
|
46
|
+
const mountedRef = useRef(true);
|
|
47
|
+
const attachmentGenerationRef = useRef(0);
|
|
48
|
+
const attachmentBatchIdRef = useRef(createAttachmentBatchId());
|
|
49
|
+
const activeUploadsRef = useRef(new Set());
|
|
50
|
+
const [internalSelection, setInternalSelection] = useState(options.initialSelection ?? { agentId: '' });
|
|
51
|
+
const workingDirectoryState = useChatPaneWorkingDirectory(definedProps({
|
|
52
|
+
workingDirectory: options.workingDirectory,
|
|
53
|
+
initialWorkingDirectory: options.initialWorkingDirectory,
|
|
54
|
+
onChangeWorkingDirectory: options.onChangeWorkingDirectory,
|
|
55
|
+
workingDirectoryAccess: options.workingDirectoryAccess,
|
|
56
|
+
}));
|
|
57
|
+
const requestedSelection = options.selection ?? internalSelection;
|
|
58
|
+
const selection = useMemo(() => resolveChatPaneSelection(options.agents, requestedSelection), [options.agents, requestedSelection]);
|
|
59
|
+
const selectedAgent = options.agents.find((agent) => agent.id === selection.agentId);
|
|
60
|
+
const composer = useComposer(definedProps({
|
|
61
|
+
initialDraft: options.initialDraft,
|
|
62
|
+
initialAgent: selection,
|
|
63
|
+
}));
|
|
64
|
+
const conversation = useConversation(definedProps({
|
|
65
|
+
transport: options.transport,
|
|
66
|
+
initialMessages: options.initialMessages,
|
|
67
|
+
conversationId: options.conversationId,
|
|
68
|
+
// Keys off an empty string, not `undefined` — `selection.agentId` is always a string (never
|
|
69
|
+
// absent), so only the falsy "no agent selected" case should omit the key.
|
|
70
|
+
agentId: selection.agentId || undefined,
|
|
71
|
+
}));
|
|
72
|
+
const activity = resolveChatPaneActivity(selectedAgent, conversation);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
options.onActivityChange?.(activity);
|
|
75
|
+
}, [activity, options.onActivityChange]);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
options.onMessagesChange?.(conversation.messages);
|
|
78
|
+
}, [conversation.messages, options.onMessagesChange]);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
mountedRef.current = true;
|
|
81
|
+
return () => {
|
|
82
|
+
mountedRef.current = false;
|
|
83
|
+
attachmentGenerationRef.current += 1;
|
|
84
|
+
for (const controller of activeUploadsRef.current)
|
|
85
|
+
controller.abort();
|
|
86
|
+
activeUploadsRef.current.clear();
|
|
87
|
+
};
|
|
88
|
+
}, []);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (!selection.agentId)
|
|
91
|
+
return;
|
|
92
|
+
if (requestedSelection.agentId === selection.agentId
|
|
93
|
+
&& requestedSelection.model === selection.model
|
|
94
|
+
&& requestedSelection.reasoning === selection.reasoning)
|
|
95
|
+
return;
|
|
96
|
+
if (options.selection === undefined)
|
|
97
|
+
setInternalSelection(selection);
|
|
98
|
+
composer.setAgent(selection);
|
|
99
|
+
options.onSelectionChange?.(selection);
|
|
100
|
+
}, [
|
|
101
|
+
composer,
|
|
102
|
+
options.onSelectionChange,
|
|
103
|
+
options.selection,
|
|
104
|
+
requestedSelection.agentId,
|
|
105
|
+
requestedSelection.model,
|
|
106
|
+
requestedSelection.reasoning,
|
|
107
|
+
selection,
|
|
108
|
+
]);
|
|
109
|
+
const setSelection = useCallback((next) => {
|
|
110
|
+
const validated = resolveChatPaneSelection(options.agents, next);
|
|
111
|
+
setInternalSelection(validated);
|
|
112
|
+
composer.setAgent(validated);
|
|
113
|
+
options.onSelectionChange?.(validated);
|
|
114
|
+
}, [composer, options.agents, options.onSelectionChange]);
|
|
115
|
+
const sendBlocker = findChatPaneSendBlocker({
|
|
116
|
+
selectedAgent,
|
|
117
|
+
isStreaming: conversation.isStreaming,
|
|
118
|
+
activeUploadCount,
|
|
119
|
+
workingDirectoryPending: workingDirectoryState.workingDirectoryPending,
|
|
120
|
+
workingDirectoryInvalid: workingDirectoryState.workingDirectoryInvalid,
|
|
121
|
+
workingDirectoryError: workingDirectoryState.workingDirectoryError,
|
|
122
|
+
});
|
|
123
|
+
const canSend = sendBlocker === null && composer.canSubmit;
|
|
124
|
+
const addAttachments = useCallback(async (files) => {
|
|
125
|
+
if (files.length === 0 || options.uploadAttachments === undefined)
|
|
126
|
+
return;
|
|
127
|
+
const generation = attachmentGenerationRef.current;
|
|
128
|
+
const controller = new AbortController();
|
|
129
|
+
activeUploadsRef.current.add(controller);
|
|
130
|
+
setActiveUploadCount(activeUploadsRef.current.size);
|
|
131
|
+
setAttachmentError(null);
|
|
132
|
+
try {
|
|
133
|
+
await uploadAttachmentBatch(files, {
|
|
134
|
+
upload: options.uploadAttachments,
|
|
135
|
+
signal: controller.signal,
|
|
136
|
+
batchId: attachmentBatchIdRef.current,
|
|
137
|
+
stillWanted: () => mountedRef.current
|
|
138
|
+
&& !controller.signal.aborted
|
|
139
|
+
&& generation === attachmentGenerationRef.current,
|
|
140
|
+
onAttachment: (attachment) => composer.addAttachment(attachment),
|
|
141
|
+
onError: setAttachmentError,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
if (activeUploadsRef.current.delete(controller) && mountedRef.current) {
|
|
146
|
+
setActiveUploadCount(activeUploadsRef.current.size);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}, [composer, options.uploadAttachments]);
|
|
150
|
+
const sendPrompt = useCallback(async (prompt) => {
|
|
151
|
+
const trimmed = prompt.trim();
|
|
152
|
+
if (!trimmed)
|
|
153
|
+
throw new Error('cannot send: the prompt is empty');
|
|
154
|
+
if (sendBlocker !== null) {
|
|
155
|
+
throw new Error(`cannot send: ${describeChatPaneSendBlocker(sendBlocker)}`);
|
|
156
|
+
}
|
|
157
|
+
const attachments = composer.attachments;
|
|
158
|
+
const context = typeof options.runContext === 'function'
|
|
159
|
+
? options.runContext({
|
|
160
|
+
prompt: trimmed,
|
|
161
|
+
selection,
|
|
162
|
+
workingDirectory: workingDirectoryState.workingDirectory,
|
|
163
|
+
})
|
|
164
|
+
: options.runContext;
|
|
165
|
+
composer.reset();
|
|
166
|
+
attachmentGenerationRef.current += 1;
|
|
167
|
+
attachmentBatchIdRef.current = createAttachmentBatchId();
|
|
168
|
+
options.onActivityChange?.('queued');
|
|
169
|
+
await conversation.sendMessage(trimmed, definedProps({
|
|
170
|
+
agentId: selection.agentId,
|
|
171
|
+
// Omitted when the array is EMPTY, not merely absent — an empty `attachments: []` would be a
|
|
172
|
+
// different (valid, present) value to the transport than "no attachments key at all".
|
|
173
|
+
attachments: attachments.length === 0 ? undefined : attachments,
|
|
174
|
+
context,
|
|
175
|
+
}));
|
|
176
|
+
}, [
|
|
177
|
+
composer,
|
|
178
|
+
conversation,
|
|
179
|
+
options.onActivityChange,
|
|
180
|
+
options.runContext,
|
|
181
|
+
selection,
|
|
182
|
+
sendBlocker,
|
|
183
|
+
workingDirectoryState.workingDirectory,
|
|
184
|
+
]);
|
|
185
|
+
const send = useCallback(async () => {
|
|
186
|
+
const prompt = composer.draft.trim()
|
|
187
|
+
|| (composer.attachments.length > 0 ? 'Review the attached file(s).' : '');
|
|
188
|
+
if (!prompt || !canSend)
|
|
189
|
+
return;
|
|
190
|
+
await sendPrompt(prompt);
|
|
191
|
+
}, [canSend, composer, sendPrompt]);
|
|
192
|
+
const reset = useCallback(() => {
|
|
193
|
+
attachmentGenerationRef.current += 1;
|
|
194
|
+
attachmentBatchIdRef.current = createAttachmentBatchId();
|
|
195
|
+
for (const controller of activeUploadsRef.current)
|
|
196
|
+
controller.abort();
|
|
197
|
+
activeUploadsRef.current.clear();
|
|
198
|
+
setActiveUploadCount(0);
|
|
199
|
+
conversation.cancel();
|
|
200
|
+
conversation.setMessages(options.initialMessages ?? []);
|
|
201
|
+
composer.reset();
|
|
202
|
+
setAttachmentError(null);
|
|
203
|
+
}, [composer, conversation, options.initialMessages]);
|
|
204
|
+
return {
|
|
205
|
+
conversation,
|
|
206
|
+
composer,
|
|
207
|
+
selection,
|
|
208
|
+
selectedAgent,
|
|
209
|
+
agents: options.agents,
|
|
210
|
+
activity,
|
|
211
|
+
canSend,
|
|
212
|
+
sendBlocker,
|
|
213
|
+
isUploadingAttachments: activeUploadCount > 0,
|
|
214
|
+
attachmentError,
|
|
215
|
+
...workingDirectoryState,
|
|
216
|
+
setSelection,
|
|
217
|
+
addAttachments,
|
|
218
|
+
send,
|
|
219
|
+
sendPrompt,
|
|
220
|
+
reset,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=useChatPane.hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChatPane.hooks.js","sourceRoot":"","sources":["../../../../../../src/react/features/chat-pane/react/hooks/useChatPane.hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,wBAAwB,GAEzB,MAAM,gBAAgB,CAAC;AAWxB,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,WAAW,EAA0B,MAAM,kCAAkC,CAAC;AACvF,OAAO,EACL,eAAe,GAEhB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,2BAA2B,GAE5B,MAAM,wCAAw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|
1
|
+
import type { ChatPaneAgentBridgeAccess } from '../../types.js';
|
|
2
|
+
import type { UseChatPaneResult } from './useChatPane.hooks.js';
|
|
3
|
+
export interface UseChatPaneAgentControlOptions {
|
|
4
|
+
/** Defaults to `false` — agent control is opt-in. */
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
bridgeAccess?: ChatPaneAgentBridgeAccess;
|
|
7
|
+
/**
|
|
8
|
+
* Register these tools with the in-page WebMCP surface (`document.modelContext`). Defaults to
|
|
9
|
+
* `false`, and that default is a security position rather than caution.
|
|
10
|
+
*
|
|
11
|
+
* The daemon-relayed channel routes every call through `ToolExecutor` — policy, confirmation,
|
|
12
|
+
* timeout, audit. A WebMCP call cannot: it originates inside the page from a browser-native
|
|
13
|
+
* caller, with no run and no principal to authorize against, so there is nothing for the gate to
|
|
14
|
+
* decide on and no run to attribute the action to. Routing it through the daemon would mean
|
|
15
|
+
* inventing both, which is worse than not gating — an invented principal is a gate that says yes.
|
|
16
|
+
*
|
|
17
|
+
* So a host that turns this on is accepting that anything able to reach `document.modelContext`
|
|
18
|
+
* — a browser extension, another script on the page — can drive this pane ungated. That is a
|
|
19
|
+
* legitimate choice for a trusted first-party surface and a bad one for a page hosting untrusted
|
|
20
|
+
* content, which is exactly why it has to be the host's call and not a default.
|
|
21
|
+
*/
|
|
22
|
+
webmcp?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Wires the chat pane's own actions (send/draft/selection/cancel/reset/working-directory/state) up
|
|
26
|
+
* to the outside-caller surfaces the pane supports: a daemon-relayed action channel when
|
|
27
|
+
* `bridgeAccess` is supplied, so an HTTP- or MCP-driven caller can reach this SAME live pane
|
|
28
|
+
* instance, and — only when the host sets `webmcp` — in-page WebMCP tool registration
|
|
29
|
+
* (`document.modelContext.registerTool`, feature-detected). Both dispatch through one identical
|
|
30
|
+
* action map (`runChatPaneAction`, module scope above), so the two callers can never diverge in
|
|
31
|
+
* *behavior*.
|
|
32
|
+
*
|
|
33
|
+
* They do differ in *authorization*, and that difference is the reason WebMCP is off by default.
|
|
34
|
+
* The relayed channel arrives having already passed `ToolExecutor`; a WebMCP call has no run and
|
|
35
|
+
* no principal, so it cannot. See {@link UseChatPaneAgentControlOptions.webmcp}.
|
|
36
|
+
*/
|
|
37
|
+
export declare function useChatPaneAgentControl(pane: UseChatPaneResult, options?: UseChatPaneAgentControlOptions): void;
|
|
38
|
+
//# sourceMappingURL=useChatPaneAgentControl.hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChatPaneAgentControl.hooks.d.ts","sourceRoot":"","sources":["../../../../../../src/react/features/chat-pane/react/hooks/useChatPaneAgentControl.hooks.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAA2B,MAAM,gBAAgB,CAAC;AAEzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,WAAW,8BAA8B;IAC7C,qDAAqD;IACrD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,yBAAyB,CAAC;IACzC;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAoOD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,iBAAiB,EACvB,OAAO,GAAE,8BAAmC,GAC3C,IAAI,CA+DN"}
|