@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,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module validate
|
|
3
|
+
*
|
|
4
|
+
* Pre-write structural sniff for AI-emitted HTML artifacts.
|
|
5
|
+
*
|
|
6
|
+
* Defends an HTML-artifact persistence path against the failure mode where a
|
|
7
|
+
* model emits an `<artifact type="text/html">…</artifact>` block whose body
|
|
8
|
+
* is a prose summary instead of a complete document. Without this gate, such
|
|
9
|
+
* content can land on disk as a real `.html` file and pollute a file panel
|
|
10
|
+
* as a phantom artifact tab.
|
|
11
|
+
*
|
|
12
|
+
* Policy (intentionally narrow — false positives here block real saves):
|
|
13
|
+
* - non-empty after trimming BOM and leading whitespace
|
|
14
|
+
* - meets a minimum length threshold
|
|
15
|
+
* - the *first* non-whitespace token is `<!doctype html>` or `<html`
|
|
16
|
+
* (anchored at the start; mid-string mentions of these tags do NOT count —
|
|
17
|
+
* prose like "Updated the <html lang> attribute…" must be rejected)
|
|
18
|
+
* - URL-bearing attributes or CSS `url(...)` / `@import` values do not point
|
|
19
|
+
* at a reserved internal workspace-storage path
|
|
20
|
+
*
|
|
21
|
+
* What this gate is NOT:
|
|
22
|
+
* - It is **not** an HTML linter or validator. Malformed but
|
|
23
|
+
* recognizably document-shaped HTML passes; only content that obviously
|
|
24
|
+
* isn't a document fails. The guarantee is "blocks obvious prose-as-HTML",
|
|
25
|
+
* not "validates well-formed HTML."
|
|
26
|
+
* - It does **not** cover `.jsx`/`.tsx` or any other artifact kind — a caller
|
|
27
|
+
* should only invoke this for an HTML-typed artifact.
|
|
28
|
+
* - It does **not** apply to user-driven file saves through some other path;
|
|
29
|
+
* those may legitimately persist partial drafts.
|
|
30
|
+
*
|
|
31
|
+
* Threshold note: 64 chars rejects minimal empty-body documents like
|
|
32
|
+
* `<!doctype html><html><body></body></html>` (49 chars) — AI-emitted
|
|
33
|
+
* artifacts are expected to be non-trivial deliverables, not test fixtures,
|
|
34
|
+
* so the lower bound favors fewer phantom files over preserving
|
|
35
|
+
* fixture-grade empties.
|
|
36
|
+
*/
|
|
37
|
+
const MIN_HTML_LENGTH = 64;
|
|
38
|
+
const STARTS_WITH_DOCUMENT_RE = /^(?:<!doctype\s+html\b|<html\b)/i;
|
|
39
|
+
/** Path segments reserved for internal workspace/artifact storage that a saved document must never reference. */
|
|
40
|
+
const RESERVED_WORKSPACE_PATH_RE = /(?:^|\/|\.\/)(?:\.live-artifacts|\.workspace|\.tmp)(?=$|[/?#"'`\s>)])/i;
|
|
41
|
+
const URL_SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
|
|
42
|
+
const URL_ATTRIBUTE_RE = /\b(href|src|srcset|poster|action|formaction|data|xlink:href)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'`=<>]+))/gi;
|
|
43
|
+
const STYLE_ATTRIBUTE_RE = /\bstyle\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'`=<>]+))/gi;
|
|
44
|
+
const HTML_TAG_RE = /<[a-z][^>]*>/gi;
|
|
45
|
+
const STYLE_BLOCK_RE = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
46
|
+
const CSS_URL_RE = /\burl\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*?))\s*\)/gi;
|
|
47
|
+
const CSS_IMPORT_RE = /@import\s+(?:url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*?))\s*\)|"([^"]*)"|'([^']*)')/gi;
|
|
48
|
+
/**
|
|
49
|
+
* Sniff-test whether `content` looks like a complete HTML document rather
|
|
50
|
+
* than prose that happens to mention HTML.
|
|
51
|
+
*
|
|
52
|
+
* @complexity O(n) in `content.length` — a handful of linear regex scans.
|
|
53
|
+
*/
|
|
54
|
+
export function validateHtmlArtifact(content) {
|
|
55
|
+
const trimmed = content.replace(/^/, '').trim();
|
|
56
|
+
if (trimmed.length === 0) {
|
|
57
|
+
return { ok: false, reason: 'empty content' };
|
|
58
|
+
}
|
|
59
|
+
if (trimmed.length < MIN_HTML_LENGTH) {
|
|
60
|
+
return { ok: false, reason: `content too short to be HTML (got ${trimmed.length} chars, need ≥${MIN_HTML_LENGTH})` };
|
|
61
|
+
}
|
|
62
|
+
if (!STARTS_WITH_DOCUMENT_RE.test(trimmed)) {
|
|
63
|
+
return { ok: false, reason: 'content does not start with <!doctype html> or <html — looks like prose, not a complete HTML document' };
|
|
64
|
+
}
|
|
65
|
+
if (referencesReservedWorkspacePath(trimmed)) {
|
|
66
|
+
return { ok: false, reason: 'content references a reserved internal workspace-storage path' };
|
|
67
|
+
}
|
|
68
|
+
return { ok: true };
|
|
69
|
+
}
|
|
70
|
+
function referencesReservedWorkspacePath(content) {
|
|
71
|
+
return hasReservedWorkspacePathInTags(content) || hasReservedWorkspacePathInStyleBlocks(content);
|
|
72
|
+
}
|
|
73
|
+
function hasReservedWorkspacePathInTags(content) {
|
|
74
|
+
HTML_TAG_RE.lastIndex = 0;
|
|
75
|
+
let match;
|
|
76
|
+
while ((match = HTML_TAG_RE.exec(content)) !== null) {
|
|
77
|
+
// A successful regex-exec result's whole-match slot (`match[0]`) is never
|
|
78
|
+
// undefined; the assertion just satisfies `noUncheckedIndexedAccess`.
|
|
79
|
+
const tag = match[0];
|
|
80
|
+
if (hasReservedWorkspacePathAttribute(tag) || hasReservedWorkspacePathInStyleAttributes(tag)) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
function hasReservedWorkspacePathAttribute(tag) {
|
|
87
|
+
URL_ATTRIBUTE_RE.lastIndex = 0;
|
|
88
|
+
let match;
|
|
89
|
+
while ((match = URL_ATTRIBUTE_RE.exec(tag)) !== null) {
|
|
90
|
+
const attributeName = match[1]?.toLowerCase();
|
|
91
|
+
// Exactly one of the three quote-form alternatives (groups 2/3/4)
|
|
92
|
+
// participates in any successful match, so this is always defined; the
|
|
93
|
+
// cast just satisfies `noUncheckedIndexedAccess`.
|
|
94
|
+
const candidate = (match[2] ?? match[3] ?? match[4]);
|
|
95
|
+
if (candidateReferencesReservedWorkspacePath(candidate, attributeName === 'srcset')) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
function hasReservedWorkspacePathInStyleAttributes(tag) {
|
|
102
|
+
STYLE_ATTRIBUTE_RE.lastIndex = 0;
|
|
103
|
+
let match;
|
|
104
|
+
while ((match = STYLE_ATTRIBUTE_RE.exec(tag)) !== null) {
|
|
105
|
+
// Exactly one of the three quote-form alternatives (groups 1/2/3)
|
|
106
|
+
// participates in any successful match, so this is always defined; the
|
|
107
|
+
// cast just satisfies `noUncheckedIndexedAccess`.
|
|
108
|
+
const cssText = (match[1] ?? match[2] ?? match[3]);
|
|
109
|
+
if (cssTextReferencesReservedWorkspacePath(cssText)) {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
function hasReservedWorkspacePathInStyleBlocks(content) {
|
|
116
|
+
STYLE_BLOCK_RE.lastIndex = 0;
|
|
117
|
+
let match;
|
|
118
|
+
while ((match = STYLE_BLOCK_RE.exec(content)) !== null) {
|
|
119
|
+
// The style-block body group uses a lazy `*?` quantifier (matches even an
|
|
120
|
+
// empty body), so it always participates in a successful match; the
|
|
121
|
+
// assertion just satisfies `noUncheckedIndexedAccess`.
|
|
122
|
+
const cssText = match[1];
|
|
123
|
+
if (cssTextReferencesReservedWorkspacePath(cssText)) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
function cssTextReferencesReservedWorkspacePath(cssText) {
|
|
130
|
+
for (const pattern of [CSS_URL_RE, CSS_IMPORT_RE]) {
|
|
131
|
+
pattern.lastIndex = 0;
|
|
132
|
+
let match;
|
|
133
|
+
while ((match = pattern.exec(cssText)) !== null) {
|
|
134
|
+
// Both CSS_URL_RE and CSS_IMPORT_RE are single top-level alternations
|
|
135
|
+
// across all their capture groups, so exactly one group is ever defined
|
|
136
|
+
// on a successful match — `.find` always finds it; the assertion just
|
|
137
|
+
// satisfies `noUncheckedIndexedAccess`.
|
|
138
|
+
const candidate = match.slice(1).find((value) => value !== undefined);
|
|
139
|
+
if (candidateReferencesReservedWorkspacePath(candidate, false)) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
function candidateReferencesReservedWorkspacePath(candidate, splitCandidates) {
|
|
147
|
+
const paths = splitCandidates ? srcsetCandidateUrls(candidate) : [firstUrlToken(candidate)];
|
|
148
|
+
return paths.some((path) => {
|
|
149
|
+
if (!isLocalPathLike(path)) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
return RESERVED_WORKSPACE_PATH_RE.test(pathnameOnly(path));
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function pathnameOnly(path) {
|
|
156
|
+
const separator = path.search(/[?#]/);
|
|
157
|
+
if (separator === -1) {
|
|
158
|
+
return path;
|
|
159
|
+
}
|
|
160
|
+
return path.slice(0, separator);
|
|
161
|
+
}
|
|
162
|
+
function srcsetCandidateUrls(srcset) {
|
|
163
|
+
const candidates = [];
|
|
164
|
+
let start = 0;
|
|
165
|
+
let sawCandidate = false;
|
|
166
|
+
let dataUrlCandidate = false;
|
|
167
|
+
let sawWhitespaceAfterUrl = false;
|
|
168
|
+
for (let index = 0; index < srcset.length; index += 1) {
|
|
169
|
+
const char = srcset[index];
|
|
170
|
+
if (!sawCandidate) {
|
|
171
|
+
if (char === ',' || /\s/.test(char)) {
|
|
172
|
+
start = index + 1;
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
sawCandidate = true;
|
|
176
|
+
dataUrlCandidate = /^data:/i.test(srcset.slice(index));
|
|
177
|
+
}
|
|
178
|
+
if (/\s/.test(char)) {
|
|
179
|
+
sawWhitespaceAfterUrl = true;
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (char === ',' && (!dataUrlCandidate || sawWhitespaceAfterUrl)) {
|
|
183
|
+
candidates.push(srcset.slice(start, index));
|
|
184
|
+
start = index + 1;
|
|
185
|
+
sawCandidate = false;
|
|
186
|
+
dataUrlCandidate = false;
|
|
187
|
+
sawWhitespaceAfterUrl = false;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
candidates.push(srcset.slice(start));
|
|
191
|
+
return candidates.map(firstUrlToken).filter(Boolean);
|
|
192
|
+
}
|
|
193
|
+
function firstUrlToken(value) {
|
|
194
|
+
// `String.split()` on a regex separator always returns at least one
|
|
195
|
+
// element (even `''.split(/\s+/)` is `['']`), so `[0]` is never
|
|
196
|
+
// `undefined` here — the assertion only satisfies `noUncheckedIndexedAccess`.
|
|
197
|
+
return value.trim().split(/\s+/)[0];
|
|
198
|
+
}
|
|
199
|
+
function isLocalPathLike(path) {
|
|
200
|
+
return path.length > 0 && !path.startsWith('#') && !path.startsWith('//') && !URL_SCHEME_RE.test(path);
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/core/util/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,uBAAuB,GAAG,kCAAkC,CAAC;AACnE,iHAAiH;AACjH,MAAM,0BAA0B,GAAG,wEAAwE,CAAC;AAC5G,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAC7C,MAAM,gBAAgB,GAAG,6GAA6G,CAAC;AACvI,MAAM,kBAAkB,GAAG,wDAAwD,CAAC;AACpF,MAAM,WAAW,GAAG,gBAAgB,CAAC;AACrC,MAAM,cAAc,GAAG,qCAAqC,CAAC;AAC7D,MAAM,UAAU,GAAG,mDAAmD,CAAC;AACvE,MAAM,aAAa,GAAG,mFAAmF,CAAC;AA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;QACD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACpB,qBAAqB,GAAG,IAAI,CAAC;YAC7B,SAAS;QACX,CAAC;QACD,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,gBAAgB,IAAI,qBAAqB,CAAC,EAAE,CAAC;YACjE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;YAC5C,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC;YAClB,YAAY,GAAG,KAAK,CAAC;YACrB,gBAAgB,GAAG,KAAK,CAAC;YACzB,qBAAqB,GAAG,KAAK,CAAC;QAChC,CAAC;IACH,CAAC;IAED,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,oEAAoE;IACpE,gEAAgE;IAChE,8EAA8E;IAC9E,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,CAAC;AACvC,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzG,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type PageDriver } from '@jini-ai/agentic';
|
|
2
|
+
import type { ChatPaneAgentBridgeAccess, ChatPaneAgentToolAction } from '../features/chat-pane/types.js';
|
|
3
|
+
export interface FrontendSessionBridgeOptions {
|
|
4
|
+
/** Daemon origin. Defaults to same-origin, which is how the dev server proxies `/api`. */
|
|
5
|
+
readonly baseUrl?: string;
|
|
6
|
+
/** Supplying one claims the six `page.*` verbs. Omit for a chat-only surface. */
|
|
7
|
+
readonly pageDriver?: PageDriver;
|
|
8
|
+
/**
|
|
9
|
+
* Product capabilities, keyed by id prefix (`'cms.'`). Each claims every capability under it.
|
|
10
|
+
* This is how a consumer exposes verbs the engine has never heard of.
|
|
11
|
+
*/
|
|
12
|
+
readonly executors?: Readonly<Record<string, (capabilityId: string, input: Record<string, unknown>) => Promise<unknown>>>;
|
|
13
|
+
/** Called for every invocation before it runs — the hook a product uses to show an activity trail. */
|
|
14
|
+
readonly onInvocation?: (action: ChatPaneAgentToolAction) => void;
|
|
15
|
+
/** Reported for failures that are nobody's tool call: stream errors, malformed frames. */
|
|
16
|
+
readonly onError?: (error: unknown) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface FrontendSessionBridge {
|
|
19
|
+
/** Hand this to `ChatPane`'s `agentControl.bridgeAccess`. */
|
|
20
|
+
readonly bridgeAccess: ChatPaneAgentBridgeAccess;
|
|
21
|
+
/**
|
|
22
|
+
* Resolves the *first* time the daemon attaches this surface — an "is it live yet" signal.
|
|
23
|
+
*
|
|
24
|
+
* Its `bindToken` is only correct until the next reconnect, so do not stash it. Call
|
|
25
|
+
* {@link FrontendSessionBridge.bindToken} when building a run request instead.
|
|
26
|
+
*/
|
|
27
|
+
readonly ready: Promise<{
|
|
28
|
+
sessionId: string;
|
|
29
|
+
bindToken: string;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* The token for the attachment that is live *now*, or `undefined` before the first attach and
|
|
33
|
+
* after {@link FrontendSessionBridge.close}. Read it at run-start; see the module doc.
|
|
34
|
+
*/
|
|
35
|
+
bindToken(): string | undefined;
|
|
36
|
+
close(): void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Opens the surface's connection and starts routing invocations.
|
|
40
|
+
*
|
|
41
|
+
* @param options - What this page can serve and where the daemon is.
|
|
42
|
+
* @returns The pane's bridge, the attach result, and a teardown.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createFrontendSessionBridge(options?: FrontendSessionBridgeOptions): FrontendSessionBridge;
|
|
45
|
+
//# sourceMappingURL=frontend-session-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend-session-bridge.d.ts","sourceRoot":"","sources":["../../../src/react/agent-bridge/frontend-session-bridge.ts"],"names":[],"mappings":"AAsCA,OAAO,EAA4C,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE7F,OAAO,KAAK,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAKzG,MAAM,WAAW,4BAA4B;IAC3C,0FAA0F;IAC1F,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1H,sGAAsG;IACtG,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAClE,0FAA0F;IAC1F,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7C;AAED,MAAM,WAAW,qBAAqB;IACpC,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,EAAE,yBAAyB,CAAC;IACjD;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClE;;;OAGG;IACH,SAAS,IAAI,MAAM,GAAG,SAAS,CAAC;IAChC,KAAK,IAAI,IAAI,CAAC;CACf;AAkBD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,4BAAiC,GAAG,qBAAqB,CAmK7G"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agent-bridge/frontend-session-bridge
|
|
3
|
+
*
|
|
4
|
+
* The browser half of agent-driven frontend control: one SSE connection to the daemon, and the
|
|
5
|
+
* routing that turns each relayed invocation into a call on something in this page.
|
|
6
|
+
*
|
|
7
|
+
* Everything on the server side already existed — `FrontendSessionRegistry` addresses a run to a
|
|
8
|
+
* surface, the frontend-session routes carry invocations out and answers back, and
|
|
9
|
+
* `createFrontendControl` assembles them. `ChatPaneAgentBridgeAccess` declared the contract this
|
|
10
|
+
* satisfies and had **zero implementations**, which is why an agent could reach a tool and the
|
|
11
|
+
* tool could reach nothing.
|
|
12
|
+
*
|
|
13
|
+
* Design notes worth knowing before changing this:
|
|
14
|
+
*
|
|
15
|
+
* - **The connection is owned here, not by `subscribe`.** `ChatPaneAgentBridgeAccess.subscribe` is
|
|
16
|
+
* called by the chat pane's own effect, so tying the stream's lifetime to it would mean page
|
|
17
|
+
* control dies when the pane unmounts — and the page is drivable whether or not a chat pane
|
|
18
|
+
* exists. `subscribe` registers a listener; `close()` tears the connection down.
|
|
19
|
+
* - **Capabilities are claimed from what is actually wired.** The claim sent at connect time is
|
|
20
|
+
* derived from the presence of a `pageDriver` and the keys of `executors`, never from a static
|
|
21
|
+
* list. A surface that claims what it cannot serve turns a fast, named refusal into a timeout.
|
|
22
|
+
* - **An executed invocation is never executed twice.** If the stream drops between the daemon
|
|
23
|
+
* delivering an invocation and this page POSTing the answer, the daemon correctly fails that
|
|
24
|
+
* call — but the click already happened. Without the `executed` set below, the retry clicks
|
|
25
|
+
* again. Buttons are not idempotent.
|
|
26
|
+
* - **The bind token never leaves this module except to the host.** It arrives on the `attached`
|
|
27
|
+
* event and must ride to run-start; it deliberately does not appear in any URL (see
|
|
28
|
+
* `@jini-ai/daemon`'s `FrontendSessionHandle`).
|
|
29
|
+
* - **Read the bind token at send time, not once.** `EventSource` reconnects on its own — after a
|
|
30
|
+
* daemon restart, a sleeping laptop, or an ordinary network blip — and each reattach mints a new
|
|
31
|
+
* session and a new token. A host that captured `ready`'s token keeps sending a dead one, every
|
|
32
|
+
* later run fails to bind, and the only trace is a daemon-side log line: the agent is simply told
|
|
33
|
+
* "no frontend is bound to this run". `ready` therefore answers "has it attached at least once";
|
|
34
|
+
* {@link FrontendSessionBridge.bindToken} answers "what is valid now", and only the latter
|
|
35
|
+
* belongs in a run request.
|
|
36
|
+
*/
|
|
37
|
+
import { FETCH_TIMEOUT_MS, fetchWithTimeout } from '@jini-ai/platform/fetch-with-timeout';
|
|
38
|
+
import { CHAT_CAPABILITIES } from '../../core/index.js';
|
|
39
|
+
import { PAGE_CAPABILITIES, executePageCapability } from '@jini-ai/agentic';
|
|
40
|
+
/** How many settled invocation ids to remember for replay suppression. */
|
|
41
|
+
const EXECUTED_MEMORY = 256;
|
|
42
|
+
/** Ids this surface can actually serve, given what the host wired up. */
|
|
43
|
+
function claimedCapabilities(options) {
|
|
44
|
+
const claims = CHAT_CAPABILITIES.map((capability) => capability.id);
|
|
45
|
+
if (options.pageDriver !== undefined) {
|
|
46
|
+
claims.push(...PAGE_CAPABILITIES.map((capability) => capability.id));
|
|
47
|
+
}
|
|
48
|
+
for (const [prefix, _executor] of Object.entries(options.executors ?? {})) {
|
|
49
|
+
claims.push(prefix);
|
|
50
|
+
}
|
|
51
|
+
return claims;
|
|
52
|
+
}
|
|
53
|
+
function errorMessage(error) {
|
|
54
|
+
return error instanceof Error ? error.message : String(error);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Opens the surface's connection and starts routing invocations.
|
|
58
|
+
*
|
|
59
|
+
* @param options - What this page can serve and where the daemon is.
|
|
60
|
+
* @returns The pane's bridge, the attach result, and a teardown.
|
|
61
|
+
*/
|
|
62
|
+
export function createFrontendSessionBridge(options = {}) {
|
|
63
|
+
const base = options.baseUrl ?? '';
|
|
64
|
+
const capabilities = claimedCapabilities(options);
|
|
65
|
+
let sessionId;
|
|
66
|
+
/** Replaced on every reattach; a promise resolved once could never carry this. */
|
|
67
|
+
let currentBindToken;
|
|
68
|
+
// Definite assignment rather than no-op placeholders: a Promise executor runs synchronously, so
|
|
69
|
+
// both are set before this line finishes, and placeholders would only add two functions that
|
|
70
|
+
// can never be called.
|
|
71
|
+
let resolveReady;
|
|
72
|
+
let rejectReady;
|
|
73
|
+
const ready = new Promise((resolve, reject) => {
|
|
74
|
+
resolveReady = resolve;
|
|
75
|
+
rejectReady = reject;
|
|
76
|
+
});
|
|
77
|
+
/** Chat-pane listeners. The pane registers exactly one; a second host could register another. */
|
|
78
|
+
const chatListeners = new Set();
|
|
79
|
+
/** Invocation ids already run here, so a stream reconnect cannot double-click a button. */
|
|
80
|
+
const executed = new Set();
|
|
81
|
+
const query = capabilities.map((id) => `capability=${encodeURIComponent(id)}`).join('&');
|
|
82
|
+
const source = new EventSource(`${base}/api/frontend-sessions/stream?${query}`);
|
|
83
|
+
async function respond(invocationId, body) {
|
|
84
|
+
if (sessionId === undefined)
|
|
85
|
+
throw new Error('the surface is not attached yet');
|
|
86
|
+
const response = await fetchWithTimeout(`${base}/api/frontend-sessions/${encodeURIComponent(sessionId)}/responses`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ invocationId, ...body }) }, { timeoutMs: FETCH_TIMEOUT_MS.QUICK });
|
|
87
|
+
if (!response.ok)
|
|
88
|
+
throw new Error(`answering "${invocationId}" failed: ${response.status}`);
|
|
89
|
+
}
|
|
90
|
+
const respondSuccess = (invocationId, output) => respond(invocationId, { ok: true, output });
|
|
91
|
+
const respondError = (invocationId, message) => respond(invocationId, { ok: false, message });
|
|
92
|
+
/** Runs one non-chat invocation here and answers it. Chat ones go to the pane instead. */
|
|
93
|
+
async function serveLocally(action) {
|
|
94
|
+
let output;
|
|
95
|
+
try {
|
|
96
|
+
if (options.pageDriver !== undefined && action.capabilityId.startsWith('page.')) {
|
|
97
|
+
output = await executePageCapability(options.pageDriver, action.capabilityId, action.input);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const entry = Object.entries(options.executors ?? {})
|
|
101
|
+
.find(([prefix]) => action.capabilityId.startsWith(prefix));
|
|
102
|
+
if (entry === undefined)
|
|
103
|
+
throw new Error(`nothing on this page serves "${action.capabilityId}"`);
|
|
104
|
+
output = await entry[1](action.capabilityId, action.input);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
await respondError(action.invocationId, errorMessage(error)).catch(options.onError ?? (() => undefined));
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
await respondSuccess(action.invocationId, output).catch(options.onError ?? (() => undefined));
|
|
112
|
+
}
|
|
113
|
+
function remember(invocationId) {
|
|
114
|
+
executed.add(invocationId);
|
|
115
|
+
if (executed.size > EXECUTED_MEMORY) {
|
|
116
|
+
const oldest = executed.values().next().value;
|
|
117
|
+
if (oldest !== undefined)
|
|
118
|
+
executed.delete(oldest);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
source.addEventListener('message', (event) => {
|
|
122
|
+
let parsed;
|
|
123
|
+
try {
|
|
124
|
+
parsed = JSON.parse(event.data);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
options.onError?.(error);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
// `JSON.parse` succeeds on any valid JSON value, not just objects — a bare `null`, number,
|
|
131
|
+
// string or boolean parses cleanly and would throw *outside* this try/catch on the very next
|
|
132
|
+
// `frame['type']` read (`null` is the one of those that actually throws; the others just read
|
|
133
|
+
// back `undefined` harmlessly). Guarding here routes every one of those through the same
|
|
134
|
+
// `onError` path as an unparseable frame, rather than only some of them crashing the listener.
|
|
135
|
+
if (parsed === null || typeof parsed !== 'object') {
|
|
136
|
+
options.onError?.(new Error(`malformed frame: expected a JSON object, got ${JSON.stringify(parsed)}`));
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const frame = parsed;
|
|
140
|
+
if (frame['type'] === 'attached') {
|
|
141
|
+
sessionId = String(frame['sessionId']);
|
|
142
|
+
currentBindToken = String(frame['bindToken']);
|
|
143
|
+
// A no-op after the first attach — which is exactly why `currentBindToken` exists.
|
|
144
|
+
resolveReady({ sessionId, bindToken: currentBindToken });
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (frame['type'] === 'error') {
|
|
148
|
+
rejectReady(new Error(String(frame['message'])));
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
// Unknown frame types are ignored rather than treated as errors, so the daemon's event
|
|
152
|
+
// vocabulary can grow without every deployed surface needing to ship first.
|
|
153
|
+
if (frame['type'] !== 'invocation')
|
|
154
|
+
return;
|
|
155
|
+
const rawInvocationId = frame['invocationId'];
|
|
156
|
+
if (typeof rawInvocationId !== 'string' || rawInvocationId.length === 0) {
|
|
157
|
+
options.onError?.(new Error('invocation frame missing invocationId'));
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const action = {
|
|
161
|
+
invocationId: rawInvocationId,
|
|
162
|
+
capabilityId: String(frame['capabilityId']),
|
|
163
|
+
input: (frame['input'] ?? {}),
|
|
164
|
+
};
|
|
165
|
+
// A redelivery after a dropped answer must not re-run the side effect.
|
|
166
|
+
if (executed.has(action.invocationId)) {
|
|
167
|
+
void respondError(action.invocationId, 'already executed on this surface').catch(() => undefined);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
remember(action.invocationId);
|
|
171
|
+
options.onInvocation?.(action);
|
|
172
|
+
if (action.capabilityId.startsWith('chat.')) {
|
|
173
|
+
for (const listener of chatListeners)
|
|
174
|
+
listener(action);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
void serveLocally(action);
|
|
178
|
+
});
|
|
179
|
+
source.addEventListener('error', (event) => {
|
|
180
|
+
// The daemon deletes a session's bind token the instant that connection drops, so by the time
|
|
181
|
+
// this fires the token in hand is already gone from the registry. Holding it until the next
|
|
182
|
+
// `attached` frame leaves a window where `bindToken()` hands back something dead, and a run
|
|
183
|
+
// started in that window fails to bind — reported to the agent only as "no frontend is bound
|
|
184
|
+
// to this run", with the real reason (a reconnect it never saw) nowhere in view.
|
|
185
|
+
// Reporting no token is the honest answer for a surface that is, right now, not attached.
|
|
186
|
+
currentBindToken = undefined;
|
|
187
|
+
sessionId = undefined;
|
|
188
|
+
options.onError?.(event);
|
|
189
|
+
});
|
|
190
|
+
const bridgeAccess = {
|
|
191
|
+
subscribe(onAction) {
|
|
192
|
+
chatListeners.add(onAction);
|
|
193
|
+
// Removes this listener only. The connection outlives any one pane — see the module doc.
|
|
194
|
+
return () => chatListeners.delete(onAction);
|
|
195
|
+
},
|
|
196
|
+
respondSuccess,
|
|
197
|
+
respondError,
|
|
198
|
+
};
|
|
199
|
+
return {
|
|
200
|
+
bridgeAccess,
|
|
201
|
+
ready,
|
|
202
|
+
bindToken: () => currentBindToken,
|
|
203
|
+
close() {
|
|
204
|
+
source.close();
|
|
205
|
+
chatListeners.clear();
|
|
206
|
+
// A closed bridge serves nothing, so binding a run to it would strand that run rather than
|
|
207
|
+
// fail it — this is what stops a torn-down surface (a StrictMode remount, a route change)
|
|
208
|
+
// from handing its dead token to the next run.
|
|
209
|
+
currentBindToken = undefined;
|
|
210
|
+
sessionId = undefined;
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=frontend-session-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend-session-bridge.js","sourceRoot":"","sources":["../../../src/react/agent-bridge/frontend-session-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
|
3
|
+
*
|
|
4
|
+
* Minimal `ArtifactFile`/`ArtifactRenderer`/`RendererRegistry` shapes,
|
|
5
|
+
* defined locally per this task's SCOPE NOTE: r4b calls the artifact-renderer
|
|
6
|
+
* package `@jini-ai/artifacts-react`; the actual locked name
|
|
7
|
+
* (`ADS-memory/reports/jini-port/extraction-plan.md` §3) is `@jini-ai/renderers-react`, which
|
|
8
|
+
* is still a placeholder stub being built in a separate session. `chat-react`
|
|
9
|
+
* needs these shapes now (for `useArtifactStream` and the `ArtifactFile`
|
|
10
|
+
* field on `ProjectContextValue`), so they are defined here to the exact
|
|
11
|
+
* shape r4b §2 specifies, with the intent that a future pass re-points every
|
|
12
|
+
* import below at `@jini-ai/renderers-react`'s real exports once that package
|
|
13
|
+
* lands, deletes this file, and removes the re-export from `index.ts`.
|
|
14
|
+
*
|
|
15
|
+
* TODO(renderers-react): replace this file's contents with
|
|
16
|
+
* `export * from '@jini-ai/renderers-react'` (or the equivalent named
|
|
17
|
+
* re-exports) once `@jini-ai/renderers-react` ships real `ArtifactFile`/
|
|
18
|
+
* `ArtifactRenderer`/`RendererRegistry` implementations. Do not block this
|
|
19
|
+
* package's other work on that package landing first.
|
|
20
|
+
*/
|
|
21
|
+
import type { ArtifactManifest } from '../core/index.js';
|
|
22
|
+
/** Generic artifact-file shape a host's project/workspace file maps onto. */
|
|
23
|
+
export interface ArtifactFile {
|
|
24
|
+
name: string;
|
|
25
|
+
kind: string;
|
|
26
|
+
content?: string;
|
|
27
|
+
url?: string;
|
|
28
|
+
manifest?: ArtifactManifest;
|
|
29
|
+
}
|
|
30
|
+
export interface ArtifactRenderContext {
|
|
31
|
+
file: ArtifactFile;
|
|
32
|
+
hints?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
export interface ArtifactRenderer {
|
|
35
|
+
id: string;
|
|
36
|
+
supportsStreaming: boolean;
|
|
37
|
+
renderPartial?: (content: string) => string;
|
|
38
|
+
canRender: (ctx: ArtifactRenderContext) => boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface ArtifactRenderMatch {
|
|
41
|
+
renderer: ArtifactRenderer;
|
|
42
|
+
file: ArtifactFile;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A minimal ordered registry of `ArtifactRenderer`s: first-registered,
|
|
46
|
+
* first-matched (later registrations can still override by registering
|
|
47
|
+
* before resolution, mirroring the tool-renderer registry's "last writer
|
|
48
|
+
* wins on the same id" convention is intentionally NOT used here — artifact
|
|
49
|
+
* renderers are matched by predicate, not by name, so ordering is the
|
|
50
|
+
* override mechanism instead).
|
|
51
|
+
*/
|
|
52
|
+
export declare class RendererRegistry {
|
|
53
|
+
private readonly renderers;
|
|
54
|
+
/** Registers `renderer`, returning an unregister handle. */
|
|
55
|
+
register(renderer: ArtifactRenderer): () => void;
|
|
56
|
+
/** The first registered renderer whose `canRender` accepts `ctx`, or `null`. */
|
|
57
|
+
resolve(ctx: ArtifactRenderContext): ArtifactRenderMatch | null;
|
|
58
|
+
/** Visible mainly for tests. */
|
|
59
|
+
list(): readonly ArtifactRenderer[];
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=artifact-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-types.d.ts","sourceRoot":"","sources":["../../src/react/artifact-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5C,SAAS,EAAE,CAAC,GAAG,EAAE,qBAAqB,KAAK,OAAO,CAAC;CACpD;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;IAEpD,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,IAAI;IAQhD,gFAAgF;IAChF,OAAO,CAAC,GAAG,EAAE,qBAAqB,GAAG,mBAAmB,GAAG,IAAI;IAO/D,gCAAgC;IAChC,IAAI,IAAI,SAAS,gBAAgB,EAAE;CAGpC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal ordered registry of `ArtifactRenderer`s: first-registered,
|
|
3
|
+
* first-matched (later registrations can still override by registering
|
|
4
|
+
* before resolution, mirroring the tool-renderer registry's "last writer
|
|
5
|
+
* wins on the same id" convention is intentionally NOT used here — artifact
|
|
6
|
+
* renderers are matched by predicate, not by name, so ordering is the
|
|
7
|
+
* override mechanism instead).
|
|
8
|
+
*/
|
|
9
|
+
export class RendererRegistry {
|
|
10
|
+
renderers = [];
|
|
11
|
+
/** Registers `renderer`, returning an unregister handle. */
|
|
12
|
+
register(renderer) {
|
|
13
|
+
this.renderers.unshift(renderer);
|
|
14
|
+
return () => {
|
|
15
|
+
const idx = this.renderers.indexOf(renderer);
|
|
16
|
+
if (idx !== -1)
|
|
17
|
+
this.renderers.splice(idx, 1);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** The first registered renderer whose `canRender` accepts `ctx`, or `null`. */
|
|
21
|
+
resolve(ctx) {
|
|
22
|
+
for (const renderer of this.renderers) {
|
|
23
|
+
if (renderer.canRender(ctx))
|
|
24
|
+
return { renderer, file: ctx.file };
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
/** Visible mainly for tests. */
|
|
29
|
+
list() {
|
|
30
|
+
return this.renderers;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=artifact-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-types.js","sourceRoot":"","sources":["../../src/react/artifact-types.ts"],"names":[],"mappings":"AAgDA;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IACV,SAAS,GAAuB,EAAE,CAAC;IAEpD,4DAA4D;IAC5D,QAAQ,CAAC,QAA0B;QACjC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACjC,OAAO,GAAG,EAAE;YACV,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC7C,IAAI,GAAG,KAAK,CAAC,CAAC;gBAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAChD,CAAC,CAAC;IACJ,CAAC;IAED,gFAAgF;IAChF,OAAO,CAAC,GAA0B;QAChC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC;gBAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;QACnE,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gCAAgC;IAChC,IAAI;QACF,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@jini-ai/chat/react/chat-pane` — the canonical public surface for `ChatPane`, the one
|
|
3
|
+
* product-like composition this package ships (REF-001 Step C, 2026-08-05).
|
|
4
|
+
*
|
|
5
|
+
* This subpath exists so a minimal-controller or non-React-preset host can depend on
|
|
6
|
+
* `@jini-ai/chat/react` without pulling in `ChatPane` at all, and so `ChatPane` itself has a
|
|
7
|
+
* package-boundary home distinct from the neutral engine surface — see
|
|
8
|
+
* `ADS-memory/reports/refactor/2026-08-05-ref-001-steps-bcd-proposal.md` §1 and §5 (Step C) for
|
|
9
|
+
* the full history: the original REF-001 finding wanted `ChatPane` removed from the generic
|
|
10
|
+
* barrel entirely; Section 1 resolved instead to keep it exported and guard it (R10 in
|
|
11
|
+
* `scripts/check-chatpane-public-surface.ts`, which treats *this* file as the public barrel to
|
|
12
|
+
* check `features/chat-pane/**`'s reach against — update `barrelPath` there if this file ever
|
|
13
|
+
* moves again).
|
|
14
|
+
*
|
|
15
|
+
* `@jini-ai/chat/react`'s own barrel (`index.ts`) re-exports these same names from here, marked
|
|
16
|
+
* `@deprecated`, so every existing `import { ChatPane } from '@jini-ai/chat/react'` keeps working
|
|
17
|
+
* unchanged. New code should import from this subpath directly.
|
|
18
|
+
*/
|
|
19
|
+
export { AgentRuntimePicker, CHAT_PANE_AGENT_TOOLS, ChatPane, createDaemonAttachmentUploader, createMcpUiToolCaller, defaultChatPaneSelection, orderChatPaneAgents, resolveChatPaneSelection, useChatPane, useChatPaneAgentControl, useChatPaneRuntimeInventory, useChatPaneWorkingDirectory, } from './features/chat-pane/index.js';
|
|
20
|
+
export type { AgentRuntimePickerProps, ByokRuntimeSummary, ChatPaneActivity, ChatPaneAgent, ChatPaneAgentBridgeAccess, ChatPaneAgentControlOptions, ChatPaneAgentOption, ChatPaneAgentSelection, ChatPaneAgentToolAction, ChatPaneAgentToolDef, ChatPaneAgentToolInputSchema, ChatPaneAgentToolRisk, ChatPaneAttachmentUploadOptions, ChatPaneComposerHandle, ChatPaneProps, ChatPaneRunContext, ChatPaneRunContextInput, ChatPaneRuntimeAccess, ChatPaneVariant, ChatPaneWorkingDirectoryAccess, CreateDaemonAttachmentUploaderOptions, CreateMcpUiToolCallerOptions, McpUiToolCallRequest, RuntimePickerPlacement, UseChatPaneAgentControlOptions, UseChatPaneOptions, UseChatPaneResult, UseChatPaneRuntimeInventoryOptions, UseChatPaneRuntimeInventoryResult, UseChatPaneWorkingDirectoryOptions, UseChatPaneWorkingDirectoryResult, } from './features/chat-pane/index.js';
|
|
21
|
+
//# sourceMappingURL=chat-pane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-pane.d.ts","sourceRoot":"","sources":["../../src/react/chat-pane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,QAAQ,EACR,8BAA8B,EAC9B,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,WAAW,EACX,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACV,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,yBAAyB,EACzB,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,4BAA4B,EAC5B,qBAAqB,EACrB,+BAA+B,EAC/B,sBAAsB,EACtB,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,EACf,8BAA8B,EAC9B,qCAAqC,EACrC,4BAA4B,EAC5B,oBAAoB,EACpB,sBAAsB,EACtB,8BAA8B,EAC9B,kBAAkB,EAClB,iBAAiB,EACjB,kCAAkC,EAClC,iCAAiC,EACjC,kCAAkC,EAClC,iCAAiC,GAClC,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@jini-ai/chat/react/chat-pane` — the canonical public surface for `ChatPane`, the one
|
|
3
|
+
* product-like composition this package ships (REF-001 Step C, 2026-08-05).
|
|
4
|
+
*
|
|
5
|
+
* This subpath exists so a minimal-controller or non-React-preset host can depend on
|
|
6
|
+
* `@jini-ai/chat/react` without pulling in `ChatPane` at all, and so `ChatPane` itself has a
|
|
7
|
+
* package-boundary home distinct from the neutral engine surface — see
|
|
8
|
+
* `ADS-memory/reports/refactor/2026-08-05-ref-001-steps-bcd-proposal.md` §1 and §5 (Step C) for
|
|
9
|
+
* the full history: the original REF-001 finding wanted `ChatPane` removed from the generic
|
|
10
|
+
* barrel entirely; Section 1 resolved instead to keep it exported and guard it (R10 in
|
|
11
|
+
* `scripts/check-chatpane-public-surface.ts`, which treats *this* file as the public barrel to
|
|
12
|
+
* check `features/chat-pane/**`'s reach against — update `barrelPath` there if this file ever
|
|
13
|
+
* moves again).
|
|
14
|
+
*
|
|
15
|
+
* `@jini-ai/chat/react`'s own barrel (`index.ts`) re-exports these same names from here, marked
|
|
16
|
+
* `@deprecated`, so every existing `import { ChatPane } from '@jini-ai/chat/react'` keeps working
|
|
17
|
+
* unchanged. New code should import from this subpath directly.
|
|
18
|
+
*/
|
|
19
|
+
export { AgentRuntimePicker, CHAT_PANE_AGENT_TOOLS, ChatPane, createDaemonAttachmentUploader, createMcpUiToolCaller, defaultChatPaneSelection, orderChatPaneAgents, resolveChatPaneSelection, useChatPane, useChatPaneAgentControl, useChatPaneRuntimeInventory, useChatPaneWorkingDirectory, } from './features/chat-pane/index.js';
|
|
20
|
+
//# sourceMappingURL=chat-pane.js.map
|