@agent-native/toolkit 0.0.0-beta-20260819143124
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/README.md +151 -0
- package/agent-native.eject.json +588 -0
- package/dist/app-shell/header-actions.d.ts +18 -0
- package/dist/app-shell/header-actions.d.ts.map +1 -0
- package/dist/app-shell/header-actions.js +52 -0
- package/dist/app-shell/header-actions.js.map +1 -0
- package/dist/app-shell/index.d.ts +3 -0
- package/dist/app-shell/index.d.ts.map +1 -0
- package/dist/app-shell/index.js +3 -0
- package/dist/app-shell/index.js.map +1 -0
- package/dist/app-shell/sidebar-footer-actions.d.ts +14 -0
- package/dist/app-shell/sidebar-footer-actions.d.ts.map +1 -0
- package/dist/app-shell/sidebar-footer-actions.js +10 -0
- package/dist/app-shell/sidebar-footer-actions.js.map +1 -0
- package/dist/app-shell/sidebar-footer-actions.spec.d.ts +2 -0
- package/dist/app-shell/sidebar-footer-actions.spec.d.ts.map +1 -0
- package/dist/app-shell/sidebar-footer-actions.spec.js +43 -0
- package/dist/app-shell/sidebar-footer-actions.spec.js.map +1 -0
- package/dist/canvas-annotations/CanvasCommentPins.d.ts +68 -0
- package/dist/canvas-annotations/CanvasCommentPins.d.ts.map +1 -0
- package/dist/canvas-annotations/CanvasCommentPins.js +513 -0
- package/dist/canvas-annotations/CanvasCommentPins.js.map +1 -0
- package/dist/canvas-annotations/DrawOverlay.d.ts +108 -0
- package/dist/canvas-annotations/DrawOverlay.d.ts.map +1 -0
- package/dist/canvas-annotations/DrawOverlay.js +746 -0
- package/dist/canvas-annotations/DrawOverlay.js.map +1 -0
- package/dist/canvas-annotations/DrawOverlay.spec.d.ts +2 -0
- package/dist/canvas-annotations/DrawOverlay.spec.d.ts.map +1 -0
- package/dist/canvas-annotations/DrawOverlay.spec.js +111 -0
- package/dist/canvas-annotations/DrawOverlay.spec.js.map +1 -0
- package/dist/canvas-annotations/index.d.ts +4 -0
- package/dist/canvas-annotations/index.d.ts.map +1 -0
- package/dist/canvas-annotations/index.js +3 -0
- package/dist/canvas-annotations/index.js.map +1 -0
- package/dist/canvas-annotations/types.d.ts +8 -0
- package/dist/canvas-annotations/types.d.ts.map +1 -0
- package/dist/canvas-annotations/types.js +2 -0
- package/dist/canvas-annotations/types.js.map +1 -0
- package/dist/canvas-interactions/canvas-interactions.d.ts +334 -0
- package/dist/canvas-interactions/canvas-interactions.d.ts.map +1 -0
- package/dist/canvas-interactions/canvas-interactions.js +486 -0
- package/dist/canvas-interactions/canvas-interactions.js.map +1 -0
- package/dist/canvas-interactions/canvas-interactions.spec.d.ts +2 -0
- package/dist/canvas-interactions/canvas-interactions.spec.d.ts.map +1 -0
- package/dist/canvas-interactions/canvas-interactions.spec.js +593 -0
- package/dist/canvas-interactions/canvas-interactions.spec.js.map +1 -0
- package/dist/canvas-interactions/index.d.ts +2 -0
- package/dist/canvas-interactions/index.d.ts.map +1 -0
- package/dist/canvas-interactions/index.js +2 -0
- package/dist/canvas-interactions/index.js.map +1 -0
- package/dist/chat-history/ChatHistoryList.d.ts +103 -0
- package/dist/chat-history/ChatHistoryList.d.ts.map +1 -0
- package/dist/chat-history/ChatHistoryList.js +102 -0
- package/dist/chat-history/ChatHistoryList.js.map +1 -0
- package/dist/chat-history/ChatHistoryList.spec.d.ts +2 -0
- package/dist/chat-history/ChatHistoryList.spec.d.ts.map +1 -0
- package/dist/chat-history/ChatHistoryList.spec.js +293 -0
- package/dist/chat-history/ChatHistoryList.spec.js.map +1 -0
- package/dist/chat-history/ChatHistoryRail.d.ts +33 -0
- package/dist/chat-history/ChatHistoryRail.d.ts.map +1 -0
- package/dist/chat-history/ChatHistoryRail.js +35 -0
- package/dist/chat-history/ChatHistoryRail.js.map +1 -0
- package/dist/chat-history/ChatHistoryRail.spec.d.ts +2 -0
- package/dist/chat-history/ChatHistoryRail.spec.d.ts.map +1 -0
- package/dist/chat-history/ChatHistoryRail.spec.js +157 -0
- package/dist/chat-history/ChatHistoryRail.spec.js.map +1 -0
- package/dist/chat-history/index.d.ts +4 -0
- package/dist/chat-history/index.d.ts.map +1 -0
- package/dist/chat-history/index.js +4 -0
- package/dist/chat-history/index.js.map +1 -0
- package/dist/chat-history/useChatHistoryRailController.d.ts +26 -0
- package/dist/chat-history/useChatHistoryRailController.d.ts.map +1 -0
- package/dist/chat-history/useChatHistoryRailController.js +36 -0
- package/dist/chat-history/useChatHistoryRailController.js.map +1 -0
- package/dist/chat-history/useChatHistoryRailController.spec.d.ts +2 -0
- package/dist/chat-history/useChatHistoryRailController.spec.d.ts.map +1 -0
- package/dist/chat-history/useChatHistoryRailController.spec.js +101 -0
- package/dist/chat-history/useChatHistoryRailController.spec.js.map +1 -0
- package/dist/chat-history.css +469 -0
- package/dist/collab-ui/AgentPresenceChip.d.ts +12 -0
- package/dist/collab-ui/AgentPresenceChip.d.ts.map +1 -0
- package/dist/collab-ui/AgentPresenceChip.js +42 -0
- package/dist/collab-ui/AgentPresenceChip.js.map +1 -0
- package/dist/collab-ui/LiveCursorOverlay.d.ts +46 -0
- package/dist/collab-ui/LiveCursorOverlay.d.ts.map +1 -0
- package/dist/collab-ui/LiveCursorOverlay.js +125 -0
- package/dist/collab-ui/LiveCursorOverlay.js.map +1 -0
- package/dist/collab-ui/PresenceBar.d.ts +30 -0
- package/dist/collab-ui/PresenceBar.d.ts.map +1 -0
- package/dist/collab-ui/PresenceBar.js +172 -0
- package/dist/collab-ui/PresenceBar.js.map +1 -0
- package/dist/collab-ui/PresenceBar.spec.d.ts +2 -0
- package/dist/collab-ui/PresenceBar.spec.d.ts.map +1 -0
- package/dist/collab-ui/PresenceBar.spec.js +30 -0
- package/dist/collab-ui/PresenceBar.spec.js.map +1 -0
- package/dist/collab-ui/RecentEditHighlights.d.ts +46 -0
- package/dist/collab-ui/RecentEditHighlights.d.ts.map +1 -0
- package/dist/collab-ui/RecentEditHighlights.js +154 -0
- package/dist/collab-ui/RecentEditHighlights.js.map +1 -0
- package/dist/collab-ui/RemoteSelectionRings.d.ts +53 -0
- package/dist/collab-ui/RemoteSelectionRings.d.ts.map +1 -0
- package/dist/collab-ui/RemoteSelectionRings.js +130 -0
- package/dist/collab-ui/RemoteSelectionRings.js.map +1 -0
- package/dist/collab-ui/agent-identity.d.ts +9 -0
- package/dist/collab-ui/agent-identity.d.ts.map +1 -0
- package/dist/collab-ui/agent-identity.js +9 -0
- package/dist/collab-ui/agent-identity.js.map +1 -0
- package/dist/collab-ui/index.d.ts +9 -0
- package/dist/collab-ui/index.d.ts.map +1 -0
- package/dist/collab-ui/index.js +9 -0
- package/dist/collab-ui/index.js.map +1 -0
- package/dist/collab-ui/lead-client.d.ts +3 -0
- package/dist/collab-ui/lead-client.d.ts.map +1 -0
- package/dist/collab-ui/lead-client.js +29 -0
- package/dist/collab-ui/lead-client.js.map +1 -0
- package/dist/collab-ui/types.d.ts +48 -0
- package/dist/collab-ui/types.d.ts.map +1 -0
- package/dist/collab-ui/types.js +52 -0
- package/dist/collab-ui/types.js.map +1 -0
- package/dist/collab-ui/types.spec.d.ts +2 -0
- package/dist/collab-ui/types.spec.d.ts.map +1 -0
- package/dist/collab-ui/types.spec.js +15 -0
- package/dist/collab-ui/types.spec.js.map +1 -0
- package/dist/composer/AgentComposerFrame.d.ts +19 -0
- package/dist/composer/AgentComposerFrame.d.ts.map +1 -0
- package/dist/composer/AgentComposerFrame.js +17 -0
- package/dist/composer/AgentComposerFrame.js.map +1 -0
- package/dist/composer/ComposerPlusMenu.d.ts +30 -0
- package/dist/composer/ComposerPlusMenu.d.ts.map +1 -0
- package/dist/composer/ComposerPlusMenu.js +635 -0
- package/dist/composer/ComposerPlusMenu.js.map +1 -0
- package/dist/composer/ComposerPlusMenu.spec.d.ts +2 -0
- package/dist/composer/ComposerPlusMenu.spec.d.ts.map +1 -0
- package/dist/composer/ComposerPlusMenu.spec.js +12 -0
- package/dist/composer/ComposerPlusMenu.spec.js.map +1 -0
- package/dist/composer/MentionPopover.d.ts +29 -0
- package/dist/composer/MentionPopover.d.ts.map +1 -0
- package/dist/composer/MentionPopover.js +221 -0
- package/dist/composer/MentionPopover.js.map +1 -0
- package/dist/composer/PastedTextChip.d.ts +9 -0
- package/dist/composer/PastedTextChip.d.ts.map +1 -0
- package/dist/composer/PastedTextChip.js +71 -0
- package/dist/composer/PastedTextChip.js.map +1 -0
- package/dist/composer/PastedTextChip.spec.d.ts +2 -0
- package/dist/composer/PastedTextChip.spec.d.ts.map +1 -0
- package/dist/composer/PastedTextChip.spec.js +42 -0
- package/dist/composer/PastedTextChip.spec.js.map +1 -0
- package/dist/composer/PromptComposer.d.ts +151 -0
- package/dist/composer/PromptComposer.d.ts.map +1 -0
- package/dist/composer/PromptComposer.js +322 -0
- package/dist/composer/PromptComposer.js.map +1 -0
- package/dist/composer/PromptComposer.spec.d.ts +2 -0
- package/dist/composer/PromptComposer.spec.d.ts.map +1 -0
- package/dist/composer/PromptComposer.spec.js +87 -0
- package/dist/composer/PromptComposer.spec.js.map +1 -0
- package/dist/composer/RealtimeVoiceMode.d.ts +108 -0
- package/dist/composer/RealtimeVoiceMode.d.ts.map +1 -0
- package/dist/composer/RealtimeVoiceMode.js +312 -0
- package/dist/composer/RealtimeVoiceMode.js.map +1 -0
- package/dist/composer/RealtimeVoiceMode.spec.d.ts +2 -0
- package/dist/composer/RealtimeVoiceMode.spec.d.ts.map +1 -0
- package/dist/composer/RealtimeVoiceMode.spec.js +540 -0
- package/dist/composer/RealtimeVoiceMode.spec.js.map +1 -0
- package/dist/composer/TiptapComposer.d.ts +288 -0
- package/dist/composer/TiptapComposer.d.ts.map +1 -0
- package/dist/composer/TiptapComposer.js +2233 -0
- package/dist/composer/TiptapComposer.js.map +1 -0
- package/dist/composer/TiptapComposer.spec.d.ts +2 -0
- package/dist/composer/TiptapComposer.spec.d.ts.map +1 -0
- package/dist/composer/TiptapComposer.spec.js +415 -0
- package/dist/composer/TiptapComposer.spec.js.map +1 -0
- package/dist/composer/VoiceButton.d.ts +27 -0
- package/dist/composer/VoiceButton.d.ts.map +1 -0
- package/dist/composer/VoiceButton.js +151 -0
- package/dist/composer/VoiceButton.js.map +1 -0
- package/dist/composer/VoiceButton.spec.d.ts +2 -0
- package/dist/composer/VoiceButton.spec.d.ts.map +1 -0
- package/dist/composer/VoiceButton.spec.js +27 -0
- package/dist/composer/VoiceButton.spec.js.map +1 -0
- package/dist/composer/asset-picker-url.d.ts +16 -0
- package/dist/composer/asset-picker-url.d.ts.map +1 -0
- package/dist/composer/asset-picker-url.js +64 -0
- package/dist/composer/asset-picker-url.js.map +1 -0
- package/dist/composer/asset-picker-url.spec.d.ts +2 -0
- package/dist/composer/asset-picker-url.spec.d.ts.map +1 -0
- package/dist/composer/asset-picker-url.spec.js +23 -0
- package/dist/composer/asset-picker-url.spec.js.map +1 -0
- package/dist/composer/attachment-accept.d.ts +9 -0
- package/dist/composer/attachment-accept.d.ts.map +1 -0
- package/dist/composer/attachment-accept.js +69 -0
- package/dist/composer/attachment-accept.js.map +1 -0
- package/dist/composer/attachment-accept.spec.d.ts +2 -0
- package/dist/composer/attachment-accept.spec.d.ts.map +1 -0
- package/dist/composer/attachment-accept.spec.js +24 -0
- package/dist/composer/attachment-accept.spec.js.map +1 -0
- package/dist/composer/draft-key.d.ts +2 -0
- package/dist/composer/draft-key.d.ts.map +1 -0
- package/dist/composer/draft-key.js +8 -0
- package/dist/composer/draft-key.js.map +1 -0
- package/dist/composer/draft-key.spec.d.ts +2 -0
- package/dist/composer/draft-key.spec.d.ts.map +1 -0
- package/dist/composer/draft-key.spec.js +13 -0
- package/dist/composer/draft-key.spec.js.map +1 -0
- package/dist/composer/extensions/FileReference.d.ts +3 -0
- package/dist/composer/extensions/FileReference.d.ts.map +1 -0
- package/dist/composer/extensions/FileReference.js +36 -0
- package/dist/composer/extensions/FileReference.js.map +1 -0
- package/dist/composer/extensions/MentionReference.d.ts +3 -0
- package/dist/composer/extensions/MentionReference.d.ts.map +1 -0
- package/dist/composer/extensions/MentionReference.js +66 -0
- package/dist/composer/extensions/MentionReference.js.map +1 -0
- package/dist/composer/extensions/SkillReference.d.ts +3 -0
- package/dist/composer/extensions/SkillReference.d.ts.map +1 -0
- package/dist/composer/extensions/SkillReference.js +40 -0
- package/dist/composer/extensions/SkillReference.js.map +1 -0
- package/dist/composer/index.d.ts +16 -0
- package/dist/composer/index.d.ts.map +1 -0
- package/dist/composer/index.js +14 -0
- package/dist/composer/index.js.map +1 -0
- package/dist/composer/model-selection.d.ts +12 -0
- package/dist/composer/model-selection.d.ts.map +1 -0
- package/dist/composer/model-selection.js +31 -0
- package/dist/composer/model-selection.js.map +1 -0
- package/dist/composer/model-selection.spec.d.ts +2 -0
- package/dist/composer/model-selection.spec.d.ts.map +1 -0
- package/dist/composer/model-selection.spec.js +38 -0
- package/dist/composer/model-selection.spec.js.map +1 -0
- package/dist/composer/pasted-text.d.ts +31 -0
- package/dist/composer/pasted-text.d.ts.map +1 -0
- package/dist/composer/pasted-text.js +130 -0
- package/dist/composer/pasted-text.js.map +1 -0
- package/dist/composer/pasted-text.spec.d.ts +2 -0
- package/dist/composer/pasted-text.spec.d.ts.map +1 -0
- package/dist/composer/pasted-text.spec.js +107 -0
- package/dist/composer/pasted-text.spec.js.map +1 -0
- package/dist/composer/prompt-attachments.d.ts +18 -0
- package/dist/composer/prompt-attachments.d.ts.map +1 -0
- package/dist/composer/prompt-attachments.js +65 -0
- package/dist/composer/prompt-attachments.js.map +1 -0
- package/dist/composer/prompt-attachments.spec.d.ts +2 -0
- package/dist/composer/prompt-attachments.spec.d.ts.map +1 -0
- package/dist/composer/prompt-attachments.spec.js +63 -0
- package/dist/composer/prompt-attachments.spec.js.map +1 -0
- package/dist/composer/realtime-voice-audio-level.d.ts +14 -0
- package/dist/composer/realtime-voice-audio-level.d.ts.map +1 -0
- package/dist/composer/realtime-voice-audio-level.js +48 -0
- package/dist/composer/realtime-voice-audio-level.js.map +1 -0
- package/dist/composer/realtime-voice-audio-level.spec.d.ts +2 -0
- package/dist/composer/realtime-voice-audio-level.spec.d.ts.map +1 -0
- package/dist/composer/realtime-voice-audio-level.spec.js +32 -0
- package/dist/composer/realtime-voice-audio-level.spec.js.map +1 -0
- package/dist/composer/realtime-voice-transcript.d.ts +26 -0
- package/dist/composer/realtime-voice-transcript.d.ts.map +1 -0
- package/dist/composer/realtime-voice-transcript.js +103 -0
- package/dist/composer/realtime-voice-transcript.js.map +1 -0
- package/dist/composer/realtime-voice-transcript.spec.d.ts +2 -0
- package/dist/composer/realtime-voice-transcript.spec.d.ts.map +1 -0
- package/dist/composer/realtime-voice-transcript.spec.js +76 -0
- package/dist/composer/realtime-voice-transcript.spec.js.map +1 -0
- package/dist/composer/runtime-adapters.d.ts +169 -0
- package/dist/composer/runtime-adapters.d.ts.map +1 -0
- package/dist/composer/runtime-adapters.js +141 -0
- package/dist/composer/runtime-adapters.js.map +1 -0
- package/dist/composer/runtime-adapters.spec.d.ts +2 -0
- package/dist/composer/runtime-adapters.spec.d.ts.map +1 -0
- package/dist/composer/runtime-adapters.spec.js +69 -0
- package/dist/composer/runtime-adapters.spec.js.map +1 -0
- package/dist/composer/types.d.ts +60 -0
- package/dist/composer/types.d.ts.map +1 -0
- package/dist/composer/types.js +2 -0
- package/dist/composer/types.js.map +1 -0
- package/dist/composer/use-file-search.d.ts +6 -0
- package/dist/composer/use-file-search.d.ts.map +1 -0
- package/dist/composer/use-file-search.js +53 -0
- package/dist/composer/use-file-search.js.map +1 -0
- package/dist/composer/use-mention-search.d.ts +6 -0
- package/dist/composer/use-mention-search.d.ts.map +1 -0
- package/dist/composer/use-mention-search.js +75 -0
- package/dist/composer/use-mention-search.js.map +1 -0
- package/dist/composer/use-skills.d.ts +7 -0
- package/dist/composer/use-skills.d.ts.map +1 -0
- package/dist/composer/use-skills.js +40 -0
- package/dist/composer/use-skills.js.map +1 -0
- package/dist/composer/useRealtimeVoiceMode.d.ts +189 -0
- package/dist/composer/useRealtimeVoiceMode.d.ts.map +1 -0
- package/dist/composer/useRealtimeVoiceMode.js +1899 -0
- package/dist/composer/useRealtimeVoiceMode.js.map +1 -0
- package/dist/composer/useRealtimeVoiceMode.spec.d.ts +2 -0
- package/dist/composer/useRealtimeVoiceMode.spec.d.ts.map +1 -0
- package/dist/composer/useRealtimeVoiceMode.spec.js +716 -0
- package/dist/composer/useRealtimeVoiceMode.spec.js.map +1 -0
- package/dist/composer/useVoiceDictation.browser.spec.d.ts +2 -0
- package/dist/composer/useVoiceDictation.browser.spec.d.ts.map +1 -0
- package/dist/composer/useVoiceDictation.browser.spec.js +220 -0
- package/dist/composer/useVoiceDictation.browser.spec.js.map +1 -0
- package/dist/composer/useVoiceDictation.d.ts +58 -0
- package/dist/composer/useVoiceDictation.d.ts.map +1 -0
- package/dist/composer/useVoiceDictation.js +1058 -0
- package/dist/composer/useVoiceDictation.js.map +1 -0
- package/dist/composer/useVoiceDictation.spec.d.ts +2 -0
- package/dist/composer/useVoiceDictation.spec.d.ts.map +1 -0
- package/dist/composer/useVoiceDictation.spec.js +32 -0
- package/dist/composer/useVoiceDictation.spec.js.map +1 -0
- package/dist/conformance/__fixtures__/css-in-js-adapter.d.ts +7 -0
- package/dist/conformance/__fixtures__/css-in-js-adapter.d.ts.map +1 -0
- package/dist/conformance/__fixtures__/css-in-js-adapter.js +84 -0
- package/dist/conformance/__fixtures__/css-in-js-adapter.js.map +1 -0
- package/dist/conformance/conformance.spec.d.ts +2 -0
- package/dist/conformance/conformance.spec.d.ts.map +1 -0
- package/dist/conformance/conformance.spec.js +87 -0
- package/dist/conformance/conformance.spec.js.map +1 -0
- package/dist/conformance/index.d.ts +4 -0
- package/dist/conformance/index.d.ts.map +1 -0
- package/dist/conformance/index.js +4 -0
- package/dist/conformance/index.js.map +1 -0
- package/dist/conformance/runner.d.ts +12 -0
- package/dist/conformance/runner.d.ts.map +1 -0
- package/dist/conformance/runner.js +515 -0
- package/dist/conformance/runner.js.map +1 -0
- package/dist/conformance/types.d.ts +26 -0
- package/dist/conformance/types.d.ts.map +1 -0
- package/dist/conformance/types.js +13 -0
- package/dist/conformance/types.js.map +1 -0
- package/dist/conformance/version.d.ts +6 -0
- package/dist/conformance/version.d.ts.map +1 -0
- package/dist/conformance/version.js +14 -0
- package/dist/conformance/version.js.map +1 -0
- package/dist/context-ui/ContextMeter.d.ts +11 -0
- package/dist/context-ui/ContextMeter.d.ts.map +1 -0
- package/dist/context-ui/ContextMeter.js +40 -0
- package/dist/context-ui/ContextMeter.js.map +1 -0
- package/dist/context-ui/ContextMeter.spec.d.ts +2 -0
- package/dist/context-ui/ContextMeter.spec.d.ts.map +1 -0
- package/dist/context-ui/ContextMeter.spec.js +52 -0
- package/dist/context-ui/ContextMeter.spec.js.map +1 -0
- package/dist/context-ui/ContextSegmentRow.d.ts +16 -0
- package/dist/context-ui/ContextSegmentRow.d.ts.map +1 -0
- package/dist/context-ui/ContextSegmentRow.js +92 -0
- package/dist/context-ui/ContextSegmentRow.js.map +1 -0
- package/dist/context-ui/ContextTreemap.d.ts +8 -0
- package/dist/context-ui/ContextTreemap.d.ts.map +1 -0
- package/dist/context-ui/ContextTreemap.js +58 -0
- package/dist/context-ui/ContextTreemap.js.map +1 -0
- package/dist/context-ui/ContextXRayPanel.d.ts +14 -0
- package/dist/context-ui/ContextXRayPanel.d.ts.map +1 -0
- package/dist/context-ui/ContextXRayPanel.js +209 -0
- package/dist/context-ui/ContextXRayPanel.js.map +1 -0
- package/dist/context-ui/format.d.ts +6 -0
- package/dist/context-ui/format.d.ts.map +1 -0
- package/dist/context-ui/format.js +58 -0
- package/dist/context-ui/format.js.map +1 -0
- package/dist/context-ui/index.d.ts +7 -0
- package/dist/context-ui/index.d.ts.map +1 -0
- package/dist/context-ui/index.js +6 -0
- package/dist/context-ui/index.js.map +1 -0
- package/dist/context-ui/types.d.ts +41 -0
- package/dist/context-ui/types.d.ts.map +1 -0
- package/dist/context-ui/types.js +8 -0
- package/dist/context-ui/types.js.map +1 -0
- package/dist/dashboard/DataTable.d.ts +20 -0
- package/dist/dashboard/DataTable.d.ts.map +1 -0
- package/dist/dashboard/DataTable.js +87 -0
- package/dist/dashboard/DataTable.js.map +1 -0
- package/dist/dashboard/DateRangePicker.d.ts +15 -0
- package/dist/dashboard/DateRangePicker.d.ts.map +1 -0
- package/dist/dashboard/DateRangePicker.js +15 -0
- package/dist/dashboard/DateRangePicker.js.map +1 -0
- package/dist/dashboard/GenericChartPanel.d.ts +57 -0
- package/dist/dashboard/GenericChartPanel.d.ts.map +1 -0
- package/dist/dashboard/GenericChartPanel.js +119 -0
- package/dist/dashboard/GenericChartPanel.js.map +1 -0
- package/dist/dashboard/GenericChartPanel.spec.d.ts +2 -0
- package/dist/dashboard/GenericChartPanel.spec.d.ts.map +1 -0
- package/dist/dashboard/GenericChartPanel.spec.js +41 -0
- package/dist/dashboard/GenericChartPanel.spec.js.map +1 -0
- package/dist/dashboard/MetricCard.d.ts +14 -0
- package/dist/dashboard/MetricCard.d.ts.map +1 -0
- package/dist/dashboard/MetricCard.js +10 -0
- package/dist/dashboard/MetricCard.js.map +1 -0
- package/dist/dashboard/StatsCard.d.ts +16 -0
- package/dist/dashboard/StatsCard.d.ts.map +1 -0
- package/dist/dashboard/StatsCard.js +8 -0
- package/dist/dashboard/StatsCard.js.map +1 -0
- package/dist/dashboard/dashboard-layout.d.ts +49 -0
- package/dist/dashboard/dashboard-layout.d.ts.map +1 -0
- package/dist/dashboard/dashboard-layout.js +231 -0
- package/dist/dashboard/dashboard-layout.js.map +1 -0
- package/dist/dashboard/dashboard-layout.spec.d.ts +2 -0
- package/dist/dashboard/dashboard-layout.spec.d.ts.map +1 -0
- package/dist/dashboard/dashboard-layout.spec.js +52 -0
- package/dist/dashboard/dashboard-layout.spec.js.map +1 -0
- package/dist/dashboard/index.d.ts +7 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +7 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/data-grid/DataGrid.d.ts +92 -0
- package/dist/data-grid/DataGrid.d.ts.map +1 -0
- package/dist/data-grid/DataGrid.js +315 -0
- package/dist/data-grid/DataGrid.js.map +1 -0
- package/dist/data-grid/DataGrid.spec.d.ts +2 -0
- package/dist/data-grid/DataGrid.spec.d.ts.map +1 -0
- package/dist/data-grid/DataGrid.spec.js +134 -0
- package/dist/data-grid/DataGrid.spec.js.map +1 -0
- package/dist/data-grid/index.d.ts +2 -0
- package/dist/data-grid/index.d.ts.map +1 -0
- package/dist/data-grid/index.js +2 -0
- package/dist/data-grid/index.js.map +1 -0
- package/dist/design-system/components.d.ts +58 -0
- package/dist/design-system/components.d.ts.map +1 -0
- package/dist/design-system/components.js +88 -0
- package/dist/design-system/components.js.map +1 -0
- package/dist/design-system/context.d.ts +11 -0
- package/dist/design-system/context.d.ts.map +1 -0
- package/dist/design-system/context.js +17 -0
- package/dist/design-system/context.js.map +1 -0
- package/dist/design-system/default-adapter.d.ts +3 -0
- package/dist/design-system/default-adapter.d.ts.map +1 -0
- package/dist/design-system/default-adapter.js +172 -0
- package/dist/design-system/default-adapter.js.map +1 -0
- package/dist/design-system/default-adapter.spec.d.ts +2 -0
- package/dist/design-system/default-adapter.spec.d.ts.map +1 -0
- package/dist/design-system/default-adapter.spec.js +108 -0
- package/dist/design-system/default-adapter.spec.js.map +1 -0
- package/dist/design-system/definition.d.ts +9 -0
- package/dist/design-system/definition.d.ts.map +1 -0
- package/dist/design-system/definition.js +4 -0
- package/dist/design-system/definition.js.map +1 -0
- package/dist/design-system/design-system.spec.d.ts +2 -0
- package/dist/design-system/design-system.spec.d.ts.map +1 -0
- package/dist/design-system/design-system.spec.js +208 -0
- package/dist/design-system/design-system.spec.js.map +1 -0
- package/dist/design-system/error-boundary.d.ts +18 -0
- package/dist/design-system/error-boundary.d.ts.map +1 -0
- package/dist/design-system/error-boundary.js +16 -0
- package/dist/design-system/error-boundary.js.map +1 -0
- package/dist/design-system/index.d.ts +8 -0
- package/dist/design-system/index.d.ts.map +1 -0
- package/dist/design-system/index.js +8 -0
- package/dist/design-system/index.js.map +1 -0
- package/dist/design-system/theme.d.ts +30 -0
- package/dist/design-system/theme.d.ts.map +1 -0
- package/dist/design-system/theme.js +95 -0
- package/dist/design-system/theme.js.map +1 -0
- package/dist/design-system/theme.spec.d.ts +2 -0
- package/dist/design-system/theme.spec.d.ts.map +1 -0
- package/dist/design-system/theme.spec.js +43 -0
- package/dist/design-system/theme.spec.js.map +1 -0
- package/dist/design-system/types.d.ts +292 -0
- package/dist/design-system/types.d.ts.map +1 -0
- package/dist/design-system/types.js +2 -0
- package/dist/design-system/types.js.map +1 -0
- package/dist/design-tweaks/index.d.ts +2 -0
- package/dist/design-tweaks/index.d.ts.map +1 -0
- package/dist/design-tweaks/index.js +2 -0
- package/dist/design-tweaks/index.js.map +1 -0
- package/dist/design-tweaks/scrub-input-utils.d.ts +61 -0
- package/dist/design-tweaks/scrub-input-utils.d.ts.map +1 -0
- package/dist/design-tweaks/scrub-input-utils.js +235 -0
- package/dist/design-tweaks/scrub-input-utils.js.map +1 -0
- package/dist/design-tweaks/scrub-input.d.ts +70 -0
- package/dist/design-tweaks/scrub-input.d.ts.map +1 -0
- package/dist/design-tweaks/scrub-input.js +319 -0
- package/dist/design-tweaks/scrub-input.js.map +1 -0
- package/dist/design-tweaks/visual-style-controls.d.ts +90 -0
- package/dist/design-tweaks/visual-style-controls.d.ts.map +1 -0
- package/dist/design-tweaks/visual-style-controls.js +423 -0
- package/dist/design-tweaks/visual-style-controls.js.map +1 -0
- package/dist/design-tweaks/visual-style-controls.spec.d.ts +2 -0
- package/dist/design-tweaks/visual-style-controls.spec.d.ts.map +1 -0
- package/dist/design-tweaks/visual-style-controls.spec.js +84 -0
- package/dist/design-tweaks/visual-style-controls.spec.js.map +1 -0
- package/dist/editor/BubbleToolbar.d.ts +37 -0
- package/dist/editor/BubbleToolbar.d.ts.map +1 -0
- package/dist/editor/BubbleToolbar.js +171 -0
- package/dist/editor/BubbleToolbar.js.map +1 -0
- package/dist/editor/CodeBlockNode.d.ts +49 -0
- package/dist/editor/CodeBlockNode.d.ts.map +1 -0
- package/dist/editor/CodeBlockNode.js +127 -0
- package/dist/editor/CodeBlockNode.js.map +1 -0
- package/dist/editor/DragHandle.d.ts +103 -0
- package/dist/editor/DragHandle.d.ts.map +1 -0
- package/dist/editor/DragHandle.js +1101 -0
- package/dist/editor/DragHandle.js.map +1 -0
- package/dist/editor/DragHandle.spec.d.ts +2 -0
- package/dist/editor/DragHandle.spec.d.ts.map +1 -0
- package/dist/editor/DragHandle.spec.js +495 -0
- package/dist/editor/DragHandle.spec.js.map +1 -0
- package/dist/editor/ImageExtension.d.ts +63 -0
- package/dist/editor/ImageExtension.d.ts.map +1 -0
- package/dist/editor/ImageExtension.js +243 -0
- package/dist/editor/ImageExtension.js.map +1 -0
- package/dist/editor/ImageExtension.roundtrip.spec.d.ts +2 -0
- package/dist/editor/ImageExtension.roundtrip.spec.d.ts.map +1 -0
- package/dist/editor/ImageExtension.roundtrip.spec.js +103 -0
- package/dist/editor/ImageExtension.roundtrip.spec.js.map +1 -0
- package/dist/editor/RegistryBlockContext.d.ts +68 -0
- package/dist/editor/RegistryBlockContext.d.ts.map +1 -0
- package/dist/editor/RegistryBlockContext.js +10 -0
- package/dist/editor/RegistryBlockContext.js.map +1 -0
- package/dist/editor/RegistryBlockNode.d.ts +66 -0
- package/dist/editor/RegistryBlockNode.d.ts.map +1 -0
- package/dist/editor/RegistryBlockNode.js +406 -0
- package/dist/editor/RegistryBlockNode.js.map +1 -0
- package/dist/editor/RegistryBlockNode.spec.d.ts +2 -0
- package/dist/editor/RegistryBlockNode.spec.d.ts.map +1 -0
- package/dist/editor/RegistryBlockNode.spec.js +215 -0
- package/dist/editor/RegistryBlockNode.spec.js.map +1 -0
- package/dist/editor/RichMarkdownEditor.collab.spec.d.ts +2 -0
- package/dist/editor/RichMarkdownEditor.collab.spec.d.ts.map +1 -0
- package/dist/editor/RichMarkdownEditor.collab.spec.js +65 -0
- package/dist/editor/RichMarkdownEditor.collab.spec.js.map +1 -0
- package/dist/editor/RichMarkdownEditor.d.ts +52 -0
- package/dist/editor/RichMarkdownEditor.d.ts.map +1 -0
- package/dist/editor/RichMarkdownEditor.js +38 -0
- package/dist/editor/RichMarkdownEditor.js.map +1 -0
- package/dist/editor/RichMarkdownEditor.roundtrip.spec.d.ts +2 -0
- package/dist/editor/RichMarkdownEditor.roundtrip.spec.d.ts.map +1 -0
- package/dist/editor/RichMarkdownEditor.roundtrip.spec.js +186 -0
- package/dist/editor/RichMarkdownEditor.roundtrip.spec.js.map +1 -0
- package/dist/editor/RunId.d.ts +28 -0
- package/dist/editor/RunId.d.ts.map +1 -0
- package/dist/editor/RunId.js +60 -0
- package/dist/editor/RunId.js.map +1 -0
- package/dist/editor/SharedRichEditor.d.ts +112 -0
- package/dist/editor/SharedRichEditor.d.ts.map +1 -0
- package/dist/editor/SharedRichEditor.js +159 -0
- package/dist/editor/SharedRichEditor.js.map +1 -0
- package/dist/editor/SharedRichEditor.spec.d.ts +2 -0
- package/dist/editor/SharedRichEditor.spec.d.ts.map +1 -0
- package/dist/editor/SharedRichEditor.spec.js +63 -0
- package/dist/editor/SharedRichEditor.spec.js.map +1 -0
- package/dist/editor/SlashCommandMenu.d.ts +59 -0
- package/dist/editor/SlashCommandMenu.d.ts.map +1 -0
- package/dist/editor/SlashCommandMenu.js +279 -0
- package/dist/editor/SlashCommandMenu.js.map +1 -0
- package/dist/editor/SlashCommandMenu.spec.d.ts +2 -0
- package/dist/editor/SlashCommandMenu.spec.d.ts.map +1 -0
- package/dist/editor/SlashCommandMenu.spec.js +67 -0
- package/dist/editor/SlashCommandMenu.spec.js.map +1 -0
- package/dist/editor/disableHistory.spec.d.ts +2 -0
- package/dist/editor/disableHistory.spec.d.ts.map +1 -0
- package/dist/editor/disableHistory.spec.js +73 -0
- package/dist/editor/disableHistory.spec.js.map +1 -0
- package/dist/editor/extensions.d.ts +178 -0
- package/dist/editor/extensions.d.ts.map +1 -0
- package/dist/editor/extensions.js +264 -0
- package/dist/editor/extensions.js.map +1 -0
- package/dist/editor/gfmDoc.d.ts +24 -0
- package/dist/editor/gfmDoc.d.ts.map +1 -0
- package/dist/editor/gfmDoc.js +83 -0
- package/dist/editor/gfmDoc.js.map +1 -0
- package/dist/editor/gfmDoc.spec.d.ts +2 -0
- package/dist/editor/gfmDoc.spec.d.ts.map +1 -0
- package/dist/editor/gfmDoc.spec.js +194 -0
- package/dist/editor/gfmDoc.spec.js.map +1 -0
- package/dist/editor/index.d.ts +16 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/index.js +15 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/editor/registrySlashCommands.d.ts +68 -0
- package/dist/editor/registrySlashCommands.d.ts.map +1 -0
- package/dist/editor/registrySlashCommands.js +51 -0
- package/dist/editor/registrySlashCommands.js.map +1 -0
- package/dist/editor/structuralReorderUndo.spec.d.ts +2 -0
- package/dist/editor/structuralReorderUndo.spec.d.ts.map +1 -0
- package/dist/editor/structuralReorderUndo.spec.js +120 -0
- package/dist/editor/structuralReorderUndo.spec.js.map +1 -0
- package/dist/editor/surgical-apply.d.ts +66 -0
- package/dist/editor/surgical-apply.d.ts.map +1 -0
- package/dist/editor/surgical-apply.js +147 -0
- package/dist/editor/surgical-apply.js.map +1 -0
- package/dist/editor/surgical-apply.spec.d.ts +2 -0
- package/dist/editor/surgical-apply.spec.d.ts.map +1 -0
- package/dist/editor/surgical-apply.spec.js +257 -0
- package/dist/editor/surgical-apply.spec.js.map +1 -0
- package/dist/editor/useCollabReconcile.concurrent.spec.d.ts +2 -0
- package/dist/editor/useCollabReconcile.concurrent.spec.d.ts.map +1 -0
- package/dist/editor/useCollabReconcile.concurrent.spec.js +641 -0
- package/dist/editor/useCollabReconcile.concurrent.spec.js.map +1 -0
- package/dist/editor/useCollabReconcile.d.ts +117 -0
- package/dist/editor/useCollabReconcile.d.ts.map +1 -0
- package/dist/editor/useCollabReconcile.idempotent.spec.d.ts +2 -0
- package/dist/editor/useCollabReconcile.idempotent.spec.d.ts.map +1 -0
- package/dist/editor/useCollabReconcile.idempotent.spec.js +248 -0
- package/dist/editor/useCollabReconcile.idempotent.spec.js.map +1 -0
- package/dist/editor/useCollabReconcile.js +521 -0
- package/dist/editor/useCollabReconcile.js.map +1 -0
- package/dist/editor.css +587 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +3 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +16 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/hooks/use-toast.d.ts +45 -0
- package/dist/hooks/use-toast.d.ts.map +1 -0
- package/dist/hooks/use-toast.js +127 -0
- package/dist/hooks/use-toast.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/onboarding/index.d.ts +2 -0
- package/dist/onboarding/index.d.ts.map +1 -0
- package/dist/onboarding/index.js +2 -0
- package/dist/onboarding/index.js.map +1 -0
- package/dist/provider.d.ts +15 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +60 -0
- package/dist/provider.js.map +1 -0
- package/dist/sharing/SharePrimitives.d.ts +42 -0
- package/dist/sharing/SharePrimitives.d.ts.map +1 -0
- package/dist/sharing/SharePrimitives.js +53 -0
- package/dist/sharing/SharePrimitives.js.map +1 -0
- package/dist/sharing/VisibilityBadge.d.ts +11 -0
- package/dist/sharing/VisibilityBadge.d.ts.map +1 -0
- package/dist/sharing/VisibilityBadge.js +19 -0
- package/dist/sharing/VisibilityBadge.js.map +1 -0
- package/dist/sharing/VisibilityBadge.spec.d.ts +2 -0
- package/dist/sharing/VisibilityBadge.spec.d.ts.map +1 -0
- package/dist/sharing/VisibilityBadge.spec.js +60 -0
- package/dist/sharing/VisibilityBadge.spec.js.map +1 -0
- package/dist/sharing/index.d.ts +3 -0
- package/dist/sharing/index.d.ts.map +1 -0
- package/dist/sharing/index.js +3 -0
- package/dist/sharing/index.js.map +1 -0
- package/dist/styles.css +232 -0
- package/dist/ui/accordion.d.ts +8 -0
- package/dist/ui/accordion.d.ts.map +1 -0
- package/dist/ui/accordion.js +14 -0
- package/dist/ui/accordion.js.map +1 -0
- package/dist/ui/alert-dialog.d.ts +21 -0
- package/dist/ui/alert-dialog.d.ts.map +1 -0
- package/dist/ui/alert-dialog.js +27 -0
- package/dist/ui/alert-dialog.js.map +1 -0
- package/dist/ui/alert.d.ts +9 -0
- package/dist/ui/alert.d.ts.map +1 -0
- package/dist/ui/alert.js +23 -0
- package/dist/ui/alert.js.map +1 -0
- package/dist/ui/aspect-ratio.d.ts +4 -0
- package/dist/ui/aspect-ratio.d.ts.map +1 -0
- package/dist/ui/aspect-ratio.js +4 -0
- package/dist/ui/aspect-ratio.js.map +1 -0
- package/dist/ui/avatar.d.ts +7 -0
- package/dist/ui/avatar.d.ts.map +1 -0
- package/dist/ui/avatar.js +12 -0
- package/dist/ui/avatar.js.map +1 -0
- package/dist/ui/badge.d.ts +10 -0
- package/dist/ui/badge.d.ts.map +1 -0
- package/dist/ui/badge.js +21 -0
- package/dist/ui/badge.js.map +1 -0
- package/dist/ui/breadcrumb.d.ts +20 -0
- package/dist/ui/breadcrumb.d.ts.map +1 -0
- package/dist/ui/breadcrumb.js +24 -0
- package/dist/ui/breadcrumb.js.map +1 -0
- package/dist/ui/button.d.ts +18 -0
- package/dist/ui/button.d.ts.map +1 -0
- package/dist/ui/button.js +67 -0
- package/dist/ui/button.js.map +1 -0
- package/dist/ui/calendar.d.ts +9 -0
- package/dist/ui/calendar.d.ts.map +1 -0
- package/dist/ui/calendar.js +74 -0
- package/dist/ui/calendar.js.map +1 -0
- package/dist/ui/card.d.ts +9 -0
- package/dist/ui/card.d.ts.map +1 -0
- package/dist/ui/card.js +17 -0
- package/dist/ui/card.js.map +1 -0
- package/dist/ui/carousel.d.ts +19 -0
- package/dist/ui/carousel.d.ts.map +1 -0
- package/dist/ui/carousel.js +99 -0
- package/dist/ui/carousel.js.map +1 -0
- package/dist/ui/chart.d.ts +80 -0
- package/dist/ui/chart.d.ts.map +1 -0
- package/dist/ui/chart.js +131 -0
- package/dist/ui/chart.js.map +1 -0
- package/dist/ui/checkbox.d.ts +5 -0
- package/dist/ui/checkbox.d.ts.map +1 -0
- package/dist/ui/checkbox.js +9 -0
- package/dist/ui/checkbox.js.map +1 -0
- package/dist/ui/collapsible.d.ts +6 -0
- package/dist/ui/collapsible.d.ts.map +1 -0
- package/dist/ui/collapsible.js +6 -0
- package/dist/ui/collapsible.js.map +1 -0
- package/dist/ui/command.d.ts +85 -0
- package/dist/ui/command.d.ts.map +1 -0
- package/dist/ui/command.js +29 -0
- package/dist/ui/command.js.map +1 -0
- package/dist/ui/command.spec.d.ts +2 -0
- package/dist/ui/command.spec.d.ts.map +1 -0
- package/dist/ui/command.spec.js +29 -0
- package/dist/ui/command.spec.js.map +1 -0
- package/dist/ui/context-menu.d.ts +28 -0
- package/dist/ui/context-menu.d.ts.map +1 -0
- package/dist/ui/context-menu.js +34 -0
- package/dist/ui/context-menu.js.map +1 -0
- package/dist/ui/date-picker.d.ts +10 -0
- package/dist/ui/date-picker.d.ts.map +1 -0
- package/dist/ui/date-picker.js +20 -0
- package/dist/ui/date-picker.js.map +1 -0
- package/dist/ui/dialog.d.ts +32 -0
- package/dist/ui/dialog.d.ts.map +1 -0
- package/dist/ui/dialog.js +26 -0
- package/dist/ui/dialog.js.map +1 -0
- package/dist/ui/dialog.spec.d.ts +2 -0
- package/dist/ui/dialog.spec.d.ts.map +1 -0
- package/dist/ui/dialog.spec.js +21 -0
- package/dist/ui/dialog.spec.js.map +1 -0
- package/dist/ui/drawer.d.ts +35 -0
- package/dist/ui/drawer.d.ts.map +1 -0
- package/dist/ui/drawer.js +25 -0
- package/dist/ui/drawer.js.map +1 -0
- package/dist/ui/dropdown-menu.d.ts +32 -0
- package/dist/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/ui/dropdown-menu.js +42 -0
- package/dist/ui/dropdown-menu.js.map +1 -0
- package/dist/ui/form.d.ts +26 -0
- package/dist/ui/form.d.ts.map +1 -0
- package/dist/ui/form.js +63 -0
- package/dist/ui/form.js.map +1 -0
- package/dist/ui/hover-card.d.ts +7 -0
- package/dist/ui/hover-card.d.ts.map +1 -0
- package/dist/ui/hover-card.js +10 -0
- package/dist/ui/hover-card.js.map +1 -0
- package/dist/ui/index.d.ts +53 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +53 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/input-otp.d.ts +35 -0
- package/dist/ui/input-otp.d.ts.map +1 -0
- package/dist/ui/input-otp.js +19 -0
- package/dist/ui/input-otp.js.map +1 -0
- package/dist/ui/input.d.ts +4 -0
- package/dist/ui/input.d.ts.map +1 -0
- package/dist/ui/input.js +9 -0
- package/dist/ui/input.js.map +1 -0
- package/dist/ui/label.d.ts +6 -0
- package/dist/ui/label.d.ts.map +1 -0
- package/dist/ui/label.js +10 -0
- package/dist/ui/label.js.map +1 -0
- package/dist/ui/logo.d.ts +7 -0
- package/dist/ui/logo.d.ts.map +1 -0
- package/dist/ui/logo.js +10 -0
- package/dist/ui/logo.js.map +1 -0
- package/dist/ui/menubar.d.ts +29 -0
- package/dist/ui/menubar.d.ts.map +1 -0
- package/dist/ui/menubar.js +36 -0
- package/dist/ui/menubar.js.map +1 -0
- package/dist/ui/navigation-menu.d.ts +13 -0
- package/dist/ui/navigation-menu.d.ts.map +1 -0
- package/dist/ui/navigation-menu.js +25 -0
- package/dist/ui/navigation-menu.js.map +1 -0
- package/dist/ui/pagination.d.ts +29 -0
- package/dist/ui/pagination.d.ts.map +1 -0
- package/dist/ui/pagination.js +24 -0
- package/dist/ui/pagination.js.map +1 -0
- package/dist/ui/popover.d.ts +11 -0
- package/dist/ui/popover.d.ts.map +1 -0
- package/dist/ui/popover.js +16 -0
- package/dist/ui/popover.js.map +1 -0
- package/dist/ui/progress.d.ts +5 -0
- package/dist/ui/progress.d.ts.map +1 -0
- package/dist/ui/progress.js +8 -0
- package/dist/ui/progress.js.map +1 -0
- package/dist/ui/radio-group.d.ts +6 -0
- package/dist/ui/radio-group.d.ts.map +1 -0
- package/dist/ui/radio-group.js +15 -0
- package/dist/ui/radio-group.js.map +1 -0
- package/dist/ui/resizable.d.ts +8 -0
- package/dist/ui/resizable.d.ts.map +1 -0
- package/dist/ui/resizable.js +9 -0
- package/dist/ui/resizable.js.map +1 -0
- package/dist/ui/scroll-area.d.ts +6 -0
- package/dist/ui/scroll-area.d.ts.map +1 -0
- package/dist/ui/scroll-area.js +12 -0
- package/dist/ui/scroll-area.js.map +1 -0
- package/dist/ui/select.d.ts +16 -0
- package/dist/ui/select.d.ts.map +1 -0
- package/dist/ui/select.js +27 -0
- package/dist/ui/select.js.map +1 -0
- package/dist/ui/separator.d.ts +5 -0
- package/dist/ui/separator.d.ts.map +1 -0
- package/dist/ui/separator.js +8 -0
- package/dist/ui/separator.js.map +1 -0
- package/dist/ui/sheet.d.ts +29 -0
- package/dist/ui/sheet.d.ts.map +1 -0
- package/dist/ui/sheet.js +37 -0
- package/dist/ui/sheet.js.map +1 -0
- package/dist/ui/sidebar.d.ts +71 -0
- package/dist/ui/sidebar.d.ts.map +1 -0
- package/dist/ui/sidebar.js +230 -0
- package/dist/ui/sidebar.js.map +1 -0
- package/dist/ui/skeleton.d.ts +3 -0
- package/dist/ui/skeleton.d.ts.map +1 -0
- package/dist/ui/skeleton.js +7 -0
- package/dist/ui/skeleton.js.map +1 -0
- package/dist/ui/slider.d.ts +5 -0
- package/dist/ui/slider.d.ts.map +1 -0
- package/dist/ui/slider.js +8 -0
- package/dist/ui/slider.js.map +1 -0
- package/dist/ui/sonner.d.ts +5 -0
- package/dist/ui/sonner.d.ts.map +1 -0
- package/dist/ui/sonner.js +25 -0
- package/dist/ui/sonner.js.map +1 -0
- package/dist/ui/spinner.d.ts +3 -0
- package/dist/ui/spinner.d.ts.map +1 -0
- package/dist/ui/spinner.js +7 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/ui/switch.d.ts +5 -0
- package/dist/ui/switch.d.ts.map +1 -0
- package/dist/ui/switch.js +8 -0
- package/dist/ui/switch.js.map +1 -0
- package/dist/ui/table.d.ts +11 -0
- package/dist/ui/table.d.ts.map +1 -0
- package/dist/ui/table.js +21 -0
- package/dist/ui/table.js.map +1 -0
- package/dist/ui/tabs.d.ts +8 -0
- package/dist/ui/tabs.d.ts.map +1 -0
- package/dist/ui/tabs.js +13 -0
- package/dist/ui/tabs.js.map +1 -0
- package/dist/ui/textarea.d.ts +6 -0
- package/dist/ui/textarea.d.ts.map +1 -0
- package/dist/ui/textarea.js +9 -0
- package/dist/ui/textarea.js.map +1 -0
- package/dist/ui/toast.d.ts +16 -0
- package/dist/ui/toast.d.ts.map +1 -0
- package/dist/ui/toast.js +34 -0
- package/dist/ui/toast.js.map +1 -0
- package/dist/ui/toaster.d.ts +2 -0
- package/dist/ui/toaster.d.ts.map +1 -0
- package/dist/ui/toaster.js +10 -0
- package/dist/ui/toaster.js.map +1 -0
- package/dist/ui/toggle-group.d.ts +13 -0
- package/dist/ui/toggle-group.d.ts.map +1 -0
- package/dist/ui/toggle-group.js +21 -0
- package/dist/ui/toggle-group.js.map +1 -0
- package/dist/ui/toggle.d.ts +13 -0
- package/dist/ui/toggle.d.ts.map +1 -0
- package/dist/ui/toggle.js +26 -0
- package/dist/ui/toggle.js.map +1 -0
- package/dist/ui/tooltip.d.ts +11 -0
- package/dist/ui/tooltip.d.ts.map +1 -0
- package/dist/ui/tooltip.js +18 -0
- package/dist/ui/tooltip.js.map +1 -0
- package/dist/ui/use-toast.d.ts +3 -0
- package/dist/ui/use-toast.d.ts.map +1 -0
- package/dist/ui/use-toast.js +3 -0
- package/dist/ui/use-toast.js.map +1 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +7 -0
- package/dist/utils.js.map +1 -0
- package/migration-manifest.json +4 -0
- package/package.json +369 -0
- package/src/app-shell/header-actions.tsx +84 -0
- package/src/app-shell/index.ts +2 -0
- package/src/app-shell/sidebar-footer-actions.spec.tsx +81 -0
- package/src/app-shell/sidebar-footer-actions.tsx +45 -0
- package/src/canvas-annotations/CanvasCommentPins.tsx +861 -0
- package/src/canvas-annotations/DrawOverlay.spec.tsx +145 -0
- package/src/canvas-annotations/DrawOverlay.tsx +1233 -0
- package/src/canvas-annotations/index.ts +15 -0
- package/src/canvas-annotations/types.ts +14 -0
- package/src/canvas-interactions/canvas-interactions.spec.ts +765 -0
- package/src/canvas-interactions/canvas-interactions.ts +965 -0
- package/src/canvas-interactions/index.ts +67 -0
- package/src/chat-history/ChatHistoryList.spec.tsx +485 -0
- package/src/chat-history/ChatHistoryList.tsx +481 -0
- package/src/chat-history/ChatHistoryRail.spec.tsx +312 -0
- package/src/chat-history/ChatHistoryRail.tsx +150 -0
- package/src/chat-history/index.ts +21 -0
- package/src/chat-history/useChatHistoryRailController.spec.tsx +131 -0
- package/src/chat-history/useChatHistoryRailController.ts +76 -0
- package/src/chat-history.css +469 -0
- package/src/collab-ui/AgentPresenceChip.tsx +69 -0
- package/src/collab-ui/LiveCursorOverlay.tsx +241 -0
- package/src/collab-ui/PresenceBar.spec.tsx +44 -0
- package/src/collab-ui/PresenceBar.tsx +373 -0
- package/src/collab-ui/RecentEditHighlights.tsx +239 -0
- package/src/collab-ui/RemoteSelectionRings.tsx +227 -0
- package/src/collab-ui/agent-identity.ts +16 -0
- package/src/collab-ui/index.ts +39 -0
- package/src/collab-ui/lead-client.ts +32 -0
- package/src/collab-ui/types.spec.ts +18 -0
- package/src/collab-ui/types.ts +96 -0
- package/src/composer/AgentComposerFrame.tsx +62 -0
- package/src/composer/ComposerPlusMenu.spec.ts +14 -0
- package/src/composer/ComposerPlusMenu.tsx +1266 -0
- package/src/composer/MentionPopover.tsx +483 -0
- package/src/composer/PastedTextChip.spec.tsx +58 -0
- package/src/composer/PastedTextChip.tsx +178 -0
- package/src/composer/PromptComposer.spec.ts +110 -0
- package/src/composer/PromptComposer.tsx +796 -0
- package/src/composer/RealtimeVoiceMode.spec.tsx +998 -0
- package/src/composer/RealtimeVoiceMode.tsx +1019 -0
- package/src/composer/TiptapComposer.spec.ts +592 -0
- package/src/composer/TiptapComposer.tsx +3746 -0
- package/src/composer/VoiceButton.spec.ts +49 -0
- package/src/composer/VoiceButton.tsx +329 -0
- package/src/composer/asset-picker-url.spec.ts +56 -0
- package/src/composer/asset-picker-url.ts +80 -0
- package/src/composer/attachment-accept.spec.ts +32 -0
- package/src/composer/attachment-accept.ts +75 -0
- package/src/composer/draft-key.spec.ts +19 -0
- package/src/composer/draft-key.ts +7 -0
- package/src/composer/extensions/FileReference.tsx +55 -0
- package/src/composer/extensions/MentionReference.tsx +93 -0
- package/src/composer/extensions/SkillReference.tsx +56 -0
- package/src/composer/index.ts +86 -0
- package/src/composer/model-selection.spec.ts +45 -0
- package/src/composer/model-selection.ts +51 -0
- package/src/composer/pasted-text.spec.ts +162 -0
- package/src/composer/pasted-text.ts +160 -0
- package/src/composer/prompt-attachments.spec.ts +80 -0
- package/src/composer/prompt-attachments.ts +93 -0
- package/src/composer/realtime-voice-audio-level.spec.ts +47 -0
- package/src/composer/realtime-voice-audio-level.ts +65 -0
- package/src/composer/realtime-voice-transcript.spec.ts +95 -0
- package/src/composer/realtime-voice-transcript.ts +134 -0
- package/src/composer/runtime-adapters.spec.tsx +102 -0
- package/src/composer/runtime-adapters.tsx +364 -0
- package/src/composer/types.ts +66 -0
- package/src/composer/use-file-search.ts +64 -0
- package/src/composer/use-mention-search.ts +90 -0
- package/src/composer/use-skills.ts +45 -0
- package/src/composer/useRealtimeVoiceMode.spec.ts +952 -0
- package/src/composer/useRealtimeVoiceMode.tsx +2388 -0
- package/src/composer/useVoiceDictation.browser.spec.tsx +265 -0
- package/src/composer/useVoiceDictation.spec.ts +45 -0
- package/src/composer/useVoiceDictation.ts +1256 -0
- package/src/conformance/__fixtures__/css-in-js-adapter.tsx +401 -0
- package/src/conformance/conformance.spec.tsx +143 -0
- package/src/conformance/index.ts +3 -0
- package/src/conformance/runner.tsx +862 -0
- package/src/conformance/types.ts +45 -0
- package/src/conformance/version.ts +22 -0
- package/src/context-ui/ContextMeter.spec.tsx +73 -0
- package/src/context-ui/ContextMeter.tsx +131 -0
- package/src/context-ui/ContextSegmentRow.tsx +273 -0
- package/src/context-ui/ContextTreemap.tsx +131 -0
- package/src/context-ui/ContextXRayPanel.tsx +491 -0
- package/src/context-ui/format.ts +42 -0
- package/src/context-ui/index.ts +15 -0
- package/src/context-ui/types.ts +57 -0
- package/src/dashboard/DataTable.tsx +273 -0
- package/src/dashboard/DateRangePicker.tsx +57 -0
- package/src/dashboard/GenericChartPanel.spec.tsx +53 -0
- package/src/dashboard/GenericChartPanel.tsx +461 -0
- package/src/dashboard/MetricCard.tsx +54 -0
- package/src/dashboard/StatsCard.tsx +49 -0
- package/src/dashboard/dashboard-layout.spec.ts +79 -0
- package/src/dashboard/dashboard-layout.ts +329 -0
- package/src/dashboard/index.ts +6 -0
- package/src/data-grid/DataGrid.spec.tsx +243 -0
- package/src/data-grid/DataGrid.tsx +754 -0
- package/src/data-grid/index.ts +15 -0
- package/src/design-system/components.tsx +196 -0
- package/src/design-system/context.tsx +31 -0
- package/src/design-system/default-adapter.spec.tsx +158 -0
- package/src/design-system/default-adapter.tsx +923 -0
- package/src/design-system/definition.ts +14 -0
- package/src/design-system/design-system.spec.tsx +356 -0
- package/src/design-system/error-boundary.tsx +37 -0
- package/src/design-system/index.ts +7 -0
- package/src/design-system/theme.spec.ts +61 -0
- package/src/design-system/theme.ts +145 -0
- package/src/design-system/types.ts +367 -0
- package/src/design-tweaks/index.ts +1 -0
- package/src/design-tweaks/scrub-input-utils.ts +311 -0
- package/src/design-tweaks/scrub-input.tsx +525 -0
- package/src/design-tweaks/visual-style-controls.spec.tsx +172 -0
- package/src/design-tweaks/visual-style-controls.tsx +1043 -0
- package/src/editor/BubbleToolbar.tsx +253 -0
- package/src/editor/CodeBlockNode.tsx +254 -0
- package/src/editor/DragHandle.spec.ts +694 -0
- package/src/editor/DragHandle.ts +1491 -0
- package/src/editor/ImageExtension.roundtrip.spec.ts +117 -0
- package/src/editor/ImageExtension.ts +306 -0
- package/src/editor/RegistryBlockContext.tsx +107 -0
- package/src/editor/RegistryBlockNode.spec.ts +279 -0
- package/src/editor/RegistryBlockNode.tsx +652 -0
- package/src/editor/RichMarkdownEditor.collab.spec.ts +79 -0
- package/src/editor/RichMarkdownEditor.roundtrip.spec.ts +226 -0
- package/src/editor/RichMarkdownEditor.tsx +81 -0
- package/src/editor/RunId.ts +61 -0
- package/src/editor/SharedRichEditor.spec.tsx +82 -0
- package/src/editor/SharedRichEditor.tsx +353 -0
- package/src/editor/SlashCommandMenu.spec.ts +90 -0
- package/src/editor/SlashCommandMenu.tsx +396 -0
- package/src/editor/disableHistory.spec.ts +85 -0
- package/src/editor/extensions.ts +454 -0
- package/src/editor/gfmDoc.spec.ts +230 -0
- package/src/editor/gfmDoc.ts +92 -0
- package/src/editor/index.ts +96 -0
- package/src/editor/registrySlashCommands.ts +131 -0
- package/src/editor/structuralReorderUndo.spec.ts +144 -0
- package/src/editor/surgical-apply.spec.ts +279 -0
- package/src/editor/surgical-apply.ts +192 -0
- package/src/editor/useCollabReconcile.concurrent.spec.ts +781 -0
- package/src/editor/useCollabReconcile.idempotent.spec.ts +324 -0
- package/src/editor/useCollabReconcile.ts +684 -0
- package/src/editor.css +587 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-mobile.tsx +21 -0
- package/src/hooks/use-toast.ts +188 -0
- package/src/index.ts +10 -0
- package/src/onboarding/index.ts +1 -0
- package/src/provider.tsx +148 -0
- package/src/sharing/SharePrimitives.tsx +224 -0
- package/src/sharing/VisibilityBadge.spec.ts +96 -0
- package/src/sharing/VisibilityBadge.tsx +37 -0
- package/src/sharing/index.ts +16 -0
- package/src/styles.css +232 -0
- package/src/ui/accordion.tsx +56 -0
- package/src/ui/alert-dialog.tsx +141 -0
- package/src/ui/alert.tsx +59 -0
- package/src/ui/aspect-ratio.tsx +5 -0
- package/src/ui/avatar.tsx +48 -0
- package/src/ui/badge.tsx +37 -0
- package/src/ui/breadcrumb.tsx +115 -0
- package/src/ui/button.tsx +167 -0
- package/src/ui/calendar.tsx +214 -0
- package/src/ui/card.tsx +86 -0
- package/src/ui/carousel.tsx +260 -0
- package/src/ui/chart.tsx +375 -0
- package/src/ui/checkbox.tsx +28 -0
- package/src/ui/collapsible.tsx +9 -0
- package/src/ui/command.spec.tsx +51 -0
- package/src/ui/command.tsx +174 -0
- package/src/ui/context-menu.tsx +202 -0
- package/src/ui/date-picker.tsx +67 -0
- package/src/ui/dialog.spec.tsx +43 -0
- package/src/ui/dialog.tsx +171 -0
- package/src/ui/drawer.tsx +126 -0
- package/src/ui/dropdown-menu.tsx +222 -0
- package/src/ui/form.tsx +177 -0
- package/src/ui/hover-card.tsx +27 -0
- package/src/ui/index.ts +52 -0
- package/src/ui/input-otp.tsx +69 -0
- package/src/ui/input.tsx +22 -0
- package/src/ui/label.tsx +24 -0
- package/src/ui/logo.tsx +36 -0
- package/src/ui/menubar.tsx +235 -0
- package/src/ui/navigation-menu.tsx +128 -0
- package/src/ui/pagination.tsx +121 -0
- package/src/ui/popover.tsx +58 -0
- package/src/ui/progress.tsx +27 -0
- package/src/ui/radio-group.tsx +42 -0
- package/src/ui/resizable.tsx +43 -0
- package/src/ui/scroll-area.tsx +46 -0
- package/src/ui/select.tsx +162 -0
- package/src/ui/separator.tsx +29 -0
- package/src/ui/sheet.tsx +160 -0
- package/src/ui/sidebar.tsx +776 -0
- package/src/ui/skeleton.tsx +18 -0
- package/src/ui/slider.tsx +26 -0
- package/src/ui/sonner.tsx +58 -0
- package/src/ui/spinner.tsx +17 -0
- package/src/ui/switch.tsx +27 -0
- package/src/ui/table.tsx +110 -0
- package/src/ui/tabs.tsx +53 -0
- package/src/ui/textarea.tsx +23 -0
- package/src/ui/toast.tsx +127 -0
- package/src/ui/toaster.tsx +33 -0
- package/src/ui/toggle-group.tsx +59 -0
- package/src/ui/toggle.tsx +43 -0
- package/src/ui/tooltip.tsx +57 -0
- package/src/ui/use-toast.ts +3 -0
- package/src/utils.ts +8 -0
|
@@ -0,0 +1,3746 @@
|
|
|
1
|
+
import { Skeleton } from "@agent-native/toolkit/ui/skeleton";
|
|
2
|
+
import { useComposer, useComposerRuntime } from "@assistant-ui/react";
|
|
3
|
+
import {
|
|
4
|
+
IconArrowUp,
|
|
5
|
+
IconCheck,
|
|
6
|
+
IconChevronDown,
|
|
7
|
+
IconChevronRight,
|
|
8
|
+
IconBulb,
|
|
9
|
+
IconClock,
|
|
10
|
+
IconBolt,
|
|
11
|
+
IconTool,
|
|
12
|
+
IconX,
|
|
13
|
+
IconClipboardList,
|
|
14
|
+
IconKey,
|
|
15
|
+
IconPencil,
|
|
16
|
+
IconPlugConnected,
|
|
17
|
+
IconHelpCircle,
|
|
18
|
+
} from "@tabler/icons-react";
|
|
19
|
+
import Placeholder from "@tiptap/extension-placeholder";
|
|
20
|
+
import type { EditorView } from "@tiptap/pm/view";
|
|
21
|
+
import { useEditor, EditorContent } from "@tiptap/react";
|
|
22
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
23
|
+
import React, {
|
|
24
|
+
useState,
|
|
25
|
+
useRef,
|
|
26
|
+
useEffect,
|
|
27
|
+
useCallback,
|
|
28
|
+
useImperativeHandle,
|
|
29
|
+
useMemo,
|
|
30
|
+
} from "react";
|
|
31
|
+
|
|
32
|
+
import {
|
|
33
|
+
Popover,
|
|
34
|
+
PopoverAnchor,
|
|
35
|
+
PopoverContent,
|
|
36
|
+
PopoverTrigger,
|
|
37
|
+
} from "../ui/popover.js";
|
|
38
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip.js";
|
|
39
|
+
import {
|
|
40
|
+
ComposerPlusMenu,
|
|
41
|
+
type ComposerTerminalModeControl,
|
|
42
|
+
} from "./ComposerPlusMenu.js";
|
|
43
|
+
import { getComposerDraftKey } from "./draft-key.js";
|
|
44
|
+
import { FileReference } from "./extensions/FileReference.js";
|
|
45
|
+
import { MentionReference } from "./extensions/MentionReference.js";
|
|
46
|
+
import { SkillReference } from "./extensions/SkillReference.js";
|
|
47
|
+
import { MentionPopover, type MentionPopoverRef } from "./MentionPopover.js";
|
|
48
|
+
import {
|
|
49
|
+
isClaudeCodeAgentId,
|
|
50
|
+
isLunaModel,
|
|
51
|
+
resolvePreferredAgentModel,
|
|
52
|
+
} from "./model-selection.js";
|
|
53
|
+
import {
|
|
54
|
+
createPastedAttachmentFile,
|
|
55
|
+
readClipboardPaste,
|
|
56
|
+
shouldConvertClipboardToAttachment,
|
|
57
|
+
} from "./pasted-text.js";
|
|
58
|
+
import {
|
|
59
|
+
AGENT_CHAT_INSERT_REFERENCE_EVENT,
|
|
60
|
+
AGENT_CHAT_INSERT_REFERENCE_MESSAGE_TYPE,
|
|
61
|
+
DEFAULT_REASONING_EFFORT,
|
|
62
|
+
formatPromptContextItems,
|
|
63
|
+
getReasoningEffortOptionsForModel,
|
|
64
|
+
reasoningEffortLabel,
|
|
65
|
+
resolveReasoningEffortSelection,
|
|
66
|
+
type AgentChatContextItem,
|
|
67
|
+
type AgentComposerReference,
|
|
68
|
+
type AgentComposerReferenceInsertPayload,
|
|
69
|
+
type ComposerTranslate,
|
|
70
|
+
type ReasoningEffort,
|
|
71
|
+
type VoiceContextPack,
|
|
72
|
+
useComposerRuntimeAdapters,
|
|
73
|
+
} from "./runtime-adapters.js";
|
|
74
|
+
import type {
|
|
75
|
+
MentionItem,
|
|
76
|
+
SkillResult,
|
|
77
|
+
Reference,
|
|
78
|
+
SlashCommand,
|
|
79
|
+
ComposerMode,
|
|
80
|
+
AgentComposerLayoutVariant,
|
|
81
|
+
} from "./types.js";
|
|
82
|
+
import { useMentionSearch } from "./use-mention-search.js";
|
|
83
|
+
import { useSkills } from "./use-skills.js";
|
|
84
|
+
import { RealtimeVoiceModeBoundary } from "./useRealtimeVoiceMode.js";
|
|
85
|
+
import { useVoiceDictation } from "./useVoiceDictation.js";
|
|
86
|
+
import { VoiceButton, VoiceRecordingOverlay } from "./VoiceButton.js";
|
|
87
|
+
export interface TiptapComposerHandle {
|
|
88
|
+
focus(): void;
|
|
89
|
+
setText(text: string): void;
|
|
90
|
+
insertReference(ref: AgentComposerReference): void;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type ComposerSubmitIntent = "immediate" | "queued";
|
|
94
|
+
|
|
95
|
+
export const DEFAULT_VOICE_DICTATION_ENABLED = false;
|
|
96
|
+
|
|
97
|
+
export interface TiptapComposerSubmitOptions {
|
|
98
|
+
intent?: ComposerSubmitIntent;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function canSubmitComposerContent(options: {
|
|
102
|
+
hasEditorContent: boolean;
|
|
103
|
+
attachmentCount: number;
|
|
104
|
+
disabled?: boolean;
|
|
105
|
+
}): boolean {
|
|
106
|
+
return (
|
|
107
|
+
!options.disabled &&
|
|
108
|
+
(options.hasEditorContent || options.attachmentCount > 0)
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const VOICE_TERMINAL_PUNCTUATION = /[.!?…。!?:;](?:["'”’»)\]}]*)$/;
|
|
113
|
+
|
|
114
|
+
export function formatVoiceTranscriptForComposer(text: string): string {
|
|
115
|
+
const trimmed = text.trim();
|
|
116
|
+
if (!trimmed) return "";
|
|
117
|
+
return `${trimmed}${VOICE_TERMINAL_PUNCTUATION.test(trimmed) ? "" : "."} `;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function canRemoveVoicePreview(options: {
|
|
121
|
+
documentSize: number;
|
|
122
|
+
anchor: number;
|
|
123
|
+
previewText: string;
|
|
124
|
+
currentText: string;
|
|
125
|
+
}): boolean {
|
|
126
|
+
if (!options.previewText) return false;
|
|
127
|
+
if (options.anchor < 1) return false;
|
|
128
|
+
if (options.anchor + options.previewText.length > options.documentSize) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
return options.currentText === options.previewText;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function resolveComposerPrimaryAction(options: {
|
|
135
|
+
canSubmit: boolean;
|
|
136
|
+
hasStopButton: boolean;
|
|
137
|
+
}): "send" | "stop" {
|
|
138
|
+
return !options.canSubmit && options.hasStopButton ? "stop" : "send";
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function getComposerSendTooltipKey(
|
|
142
|
+
willQueue: boolean,
|
|
143
|
+
): "composer.queueMessage" | "composer.sendMessage" {
|
|
144
|
+
return willQueue ? "composer.queueMessage" : "composer.sendMessage";
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export type ContextChipBackspaceAction =
|
|
148
|
+
| { type: "select"; key: string }
|
|
149
|
+
| { type: "remove"; key: string }
|
|
150
|
+
| null;
|
|
151
|
+
|
|
152
|
+
export function resolveContextChipBackspaceAction(options: {
|
|
153
|
+
contextItemKeys: string[];
|
|
154
|
+
selectedKey: string | null;
|
|
155
|
+
cursorAtStart: boolean;
|
|
156
|
+
}): ContextChipBackspaceAction {
|
|
157
|
+
if (!options.cursorAtStart || options.contextItemKeys.length === 0) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
if (
|
|
161
|
+
options.selectedKey &&
|
|
162
|
+
options.contextItemKeys.includes(options.selectedKey)
|
|
163
|
+
) {
|
|
164
|
+
return { type: "remove", key: options.selectedKey };
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
type: "select",
|
|
168
|
+
key: options.contextItemKeys[options.contextItemKeys.length - 1],
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const MAX_DOCUMENT_ATTACHMENT_BYTES = 4 * 1024 * 1024;
|
|
173
|
+
|
|
174
|
+
function composerReferenceFromMentionItem(
|
|
175
|
+
item: MentionItem,
|
|
176
|
+
): AgentComposerReference {
|
|
177
|
+
return {
|
|
178
|
+
label: item.label,
|
|
179
|
+
icon: item.icon || "file",
|
|
180
|
+
source: item.source,
|
|
181
|
+
refType: item.refType,
|
|
182
|
+
refId: item.refId || null,
|
|
183
|
+
refPath: item.refPath || null,
|
|
184
|
+
slotKey: item.slotKey,
|
|
185
|
+
slotLabel: item.slotLabel,
|
|
186
|
+
metadata: item.metadata,
|
|
187
|
+
clearsSlots: item.clearsSlots,
|
|
188
|
+
relatedReferences: item.relatedReferences,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function mentionReferenceAttrs(ref: AgentComposerReference) {
|
|
193
|
+
return {
|
|
194
|
+
label: ref.label,
|
|
195
|
+
icon: ref.icon || "file",
|
|
196
|
+
source: ref.source,
|
|
197
|
+
refType: ref.refType,
|
|
198
|
+
refId: ref.refId || null,
|
|
199
|
+
refPath: ref.refPath || null,
|
|
200
|
+
slotKey: ref.slotKey || null,
|
|
201
|
+
slotLabel: ref.slotLabel || null,
|
|
202
|
+
metadata: ref.metadata || null,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function referenceFromComposerReference(
|
|
207
|
+
ref: AgentComposerReference,
|
|
208
|
+
): Reference {
|
|
209
|
+
return {
|
|
210
|
+
type:
|
|
211
|
+
ref.refType === "file"
|
|
212
|
+
? "file"
|
|
213
|
+
: ref.refType === "agent"
|
|
214
|
+
? "agent"
|
|
215
|
+
: ref.refType === "custom-agent"
|
|
216
|
+
? "custom-agent"
|
|
217
|
+
: "mention",
|
|
218
|
+
path: ref.refPath || "",
|
|
219
|
+
name: ref.label,
|
|
220
|
+
source: ref.source || "",
|
|
221
|
+
refType: ref.refType,
|
|
222
|
+
refId: ref.refId || undefined,
|
|
223
|
+
slotKey: ref.slotKey,
|
|
224
|
+
slotLabel: ref.slotLabel,
|
|
225
|
+
metadata: ref.metadata,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function applySlotReferenceChanges(
|
|
230
|
+
current: AgentComposerReference[],
|
|
231
|
+
references: AgentComposerReference[],
|
|
232
|
+
): AgentComposerReference[] {
|
|
233
|
+
let next = current;
|
|
234
|
+
|
|
235
|
+
const applyOne = (ref: AgentComposerReference) => {
|
|
236
|
+
for (const related of ref.relatedReferences ?? []) {
|
|
237
|
+
applyOne(related);
|
|
238
|
+
}
|
|
239
|
+
if (!ref.slotKey) return;
|
|
240
|
+
const cleared = new Set([ref.slotKey, ...(ref.clearsSlots ?? [])]);
|
|
241
|
+
next = next.filter((existing) => !cleared.has(existing.slotKey ?? ""));
|
|
242
|
+
next = [...next, ref];
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
for (const ref of references) {
|
|
246
|
+
applyOne(ref);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return next;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function removeSlotReference(
|
|
253
|
+
current: AgentComposerReference[],
|
|
254
|
+
ref: AgentComposerReference,
|
|
255
|
+
): AgentComposerReference[] {
|
|
256
|
+
const removed = new Set([ref.slotKey, ...(ref.clearsSlots ?? [])]);
|
|
257
|
+
return current.filter((existing) => !removed.has(existing.slotKey ?? ""));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function slotReferenceTitle(ref: AgentComposerReference): string {
|
|
261
|
+
return ref.slotLabel ? `${ref.slotLabel}: ${ref.label}` : ref.label;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function metadataString(
|
|
265
|
+
metadata: Record<string, unknown> | undefined,
|
|
266
|
+
key: string,
|
|
267
|
+
): string | null {
|
|
268
|
+
const value = metadata?.[key];
|
|
269
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function trimVoiceContextValue(value: string, maxChars: number): string | null {
|
|
273
|
+
const trimmed = value.replace(/\0/g, "").trim();
|
|
274
|
+
if (!trimmed) return null;
|
|
275
|
+
if (trimmed.length <= maxChars) return trimmed;
|
|
276
|
+
return `${trimmed.slice(0, maxChars).trimEnd()}\n[truncated]`;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function filterMentionItemsForSlots(
|
|
280
|
+
items: MentionItem[],
|
|
281
|
+
slotReferences: AgentComposerReference[],
|
|
282
|
+
): MentionItem[] {
|
|
283
|
+
return items.filter((item) => {
|
|
284
|
+
const requiredSlotKey = metadataString(item.metadata, "requiredSlotKey");
|
|
285
|
+
const requiredRefId = metadataString(item.metadata, "requiredRefId");
|
|
286
|
+
if (!requiredSlotKey || !requiredRefId) return true;
|
|
287
|
+
const selected = slotReferences.find(
|
|
288
|
+
(ref) => ref.slotKey === requiredSlotKey,
|
|
289
|
+
);
|
|
290
|
+
if (!selected?.refId) return true;
|
|
291
|
+
return selected.refId === requiredRefId;
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function isDocumentAttachment(value: Record<string, unknown>): boolean {
|
|
296
|
+
if (value.type === "document") return true;
|
|
297
|
+
const contentType = String(value.contentType ?? "").toLowerCase();
|
|
298
|
+
const name = String(value.name ?? "").toLowerCase();
|
|
299
|
+
return contentType === "application/pdf" || name.endsWith(".pdf");
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export function getOversizedDocumentAttachmentError(
|
|
303
|
+
attachments: ReadonlyArray<unknown>,
|
|
304
|
+
options: {
|
|
305
|
+
maxBytes?: number;
|
|
306
|
+
label?: string;
|
|
307
|
+
translate?: ComposerTranslate;
|
|
308
|
+
} = {},
|
|
309
|
+
): string | null {
|
|
310
|
+
const maxBytes = options.maxBytes ?? MAX_DOCUMENT_ATTACHMENT_BYTES;
|
|
311
|
+
const label = options.label ?? "PDFs";
|
|
312
|
+
const t = options.translate;
|
|
313
|
+
for (const attachment of attachments) {
|
|
314
|
+
if (!attachment || typeof attachment !== "object") continue;
|
|
315
|
+
const candidate = attachment as Record<string, unknown>;
|
|
316
|
+
if (!isDocumentAttachment(candidate)) continue;
|
|
317
|
+
const file = candidate.file;
|
|
318
|
+
if (!(file instanceof File)) continue;
|
|
319
|
+
if (file.size <= maxBytes) continue;
|
|
320
|
+
const name =
|
|
321
|
+
typeof candidate.name === "string" && candidate.name.trim()
|
|
322
|
+
? candidate.name
|
|
323
|
+
: file.name;
|
|
324
|
+
const mb = (file.size / 1024 / 1024).toFixed(1);
|
|
325
|
+
const maxMb = (maxBytes / 1024 / 1024).toFixed(0);
|
|
326
|
+
return (
|
|
327
|
+
t?.("agentChat.composer.documentTooLarge", {
|
|
328
|
+
defaultValue:
|
|
329
|
+
'"{{name}}" is {{size}} MB. {{label}} are capped at {{maxSize}} MB to stay within message limits. Please reduce the file size or split it into smaller parts.',
|
|
330
|
+
name,
|
|
331
|
+
size: mb,
|
|
332
|
+
label,
|
|
333
|
+
maxSize: maxMb,
|
|
334
|
+
}) ??
|
|
335
|
+
`"${name}" is ${mb} MB. ${label} are capped at ${maxMb} MB to stay within message limits. Please reduce the file size or split it into smaller parts.`
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export function getComposerSubmitIntentForEnterKey(
|
|
342
|
+
event: Pick<KeyboardEvent, "key" | "shiftKey" | "metaKey" | "ctrlKey">,
|
|
343
|
+
isMac: boolean,
|
|
344
|
+
): ComposerSubmitIntent | null {
|
|
345
|
+
if (event.key !== "Enter" || event.shiftKey) return null;
|
|
346
|
+
|
|
347
|
+
const queuedModifierPressed = isMac ? event.metaKey : event.ctrlKey;
|
|
348
|
+
if (queuedModifierPressed) return "queued";
|
|
349
|
+
|
|
350
|
+
if (!event.metaKey && !event.ctrlKey) return "immediate";
|
|
351
|
+
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export function insertComposerHardBreakAndScrollIntoView(
|
|
356
|
+
view: Pick<EditorView, "state" | "dispatch">,
|
|
357
|
+
): boolean {
|
|
358
|
+
const hardBreak = view.state.schema.nodes.hardBreak;
|
|
359
|
+
if (!hardBreak) return false;
|
|
360
|
+
|
|
361
|
+
view.dispatch(
|
|
362
|
+
view.state.tr.replaceSelectionWith(hardBreak.create()).scrollIntoView(),
|
|
363
|
+
);
|
|
364
|
+
return true;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export function getComposerPopoverPosition(
|
|
368
|
+
view: Pick<EditorView, "coordsAtPos">,
|
|
369
|
+
pos: number,
|
|
370
|
+
): { top: number; left: number } | null {
|
|
371
|
+
try {
|
|
372
|
+
const coords = view.coordsAtPos(pos);
|
|
373
|
+
if (!Number.isFinite(coords.top) || !Number.isFinite(coords.left)) {
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
return { top: coords.top, left: coords.left };
|
|
377
|
+
} catch {
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export function displayableComposerModeMessage(options: {
|
|
383
|
+
messagePrefix: string;
|
|
384
|
+
trimmedText: string;
|
|
385
|
+
attachmentCount: number;
|
|
386
|
+
attachedContextFallback?: string;
|
|
387
|
+
}): string {
|
|
388
|
+
const modePrompt =
|
|
389
|
+
options.trimmedText ||
|
|
390
|
+
(options.attachmentCount > 0
|
|
391
|
+
? (options.attachedContextFallback ?? "Use the attached context.")
|
|
392
|
+
: "");
|
|
393
|
+
return `${options.messagePrefix}${modePrompt}`;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function uniquifyComposerImageFile(file: File): File {
|
|
397
|
+
if (!file.type.startsWith("image/")) return file;
|
|
398
|
+
const uniqueName = `${Date.now()}-${Math.random().toString(36).slice(2)}-${file.name}`;
|
|
399
|
+
return new File([file], uniqueName, { type: file.type });
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
function composerDocumentHasContent(doc: {
|
|
403
|
+
textContent: string;
|
|
404
|
+
descendants: (callback: (node: any) => boolean | void) => void;
|
|
405
|
+
}): boolean {
|
|
406
|
+
if (doc.textContent.trim().length > 0) return true;
|
|
407
|
+
let hasContent = false;
|
|
408
|
+
doc.descendants((node: any) => {
|
|
409
|
+
if (
|
|
410
|
+
node.type.name === "mentionReference" ||
|
|
411
|
+
node.type.name === "fileReference" ||
|
|
412
|
+
node.type.name === "skillReference"
|
|
413
|
+
) {
|
|
414
|
+
hasContent = true;
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
return true;
|
|
418
|
+
});
|
|
419
|
+
return hasContent;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export function handleComposerFileDrop(options: {
|
|
423
|
+
event: Pick<DragEvent, "dataTransfer" | "preventDefault" | "stopPropagation">;
|
|
424
|
+
addAttachment: (file: File) => Promise<unknown>;
|
|
425
|
+
onError?: (error: unknown) => void;
|
|
426
|
+
}): boolean {
|
|
427
|
+
const droppedFiles = Array.from(options.event.dataTransfer?.files ?? []);
|
|
428
|
+
if (droppedFiles.length === 0) return false;
|
|
429
|
+
|
|
430
|
+
options.event.preventDefault();
|
|
431
|
+
options.event.stopPropagation();
|
|
432
|
+
const attachments = droppedFiles.map(uniquifyComposerImageFile);
|
|
433
|
+
void Promise.all(
|
|
434
|
+
attachments.map((file) => options.addAttachment(file)),
|
|
435
|
+
).catch((error) => {
|
|
436
|
+
options.onError?.(error);
|
|
437
|
+
});
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function builtInCommands(t: ComposerTranslate): SlashCommand[] {
|
|
442
|
+
return [
|
|
443
|
+
{
|
|
444
|
+
name: "clear",
|
|
445
|
+
description: t("agentChat.commands.clearShort", {
|
|
446
|
+
defaultValue: "Start a new chat",
|
|
447
|
+
}),
|
|
448
|
+
icon: "clear",
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
name: "new",
|
|
452
|
+
description: t("agentChat.commands.newShort", {
|
|
453
|
+
defaultValue: "Start a new chat",
|
|
454
|
+
}),
|
|
455
|
+
icon: "new",
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
name: "history",
|
|
459
|
+
description: t("agentChat.commands.history", {
|
|
460
|
+
defaultValue: "Browse all chats",
|
|
461
|
+
}),
|
|
462
|
+
icon: "history",
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
name: "plan",
|
|
466
|
+
description: t("agentChat.commands.plan", {
|
|
467
|
+
defaultValue: "Switch to read-only planning",
|
|
468
|
+
}),
|
|
469
|
+
icon: "plan",
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
name: "act",
|
|
473
|
+
description: t("agentChat.commands.act", {
|
|
474
|
+
defaultValue: "Switch back to acting",
|
|
475
|
+
}),
|
|
476
|
+
icon: "act",
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
name: "help",
|
|
480
|
+
description: t("agentChat.commands.help", {
|
|
481
|
+
defaultValue: "Show available commands",
|
|
482
|
+
}),
|
|
483
|
+
icon: "help",
|
|
484
|
+
},
|
|
485
|
+
];
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function normalizeSlashCommandName(name: string): string {
|
|
489
|
+
return name.replace(/^\/+/, "").trim().toLowerCase();
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function mergeSlashCommands(commands: SlashCommand[]): SlashCommand[] {
|
|
493
|
+
const seen = new Set<string>();
|
|
494
|
+
const merged: SlashCommand[] = [];
|
|
495
|
+
for (const command of commands) {
|
|
496
|
+
const name = normalizeSlashCommandName(command.name);
|
|
497
|
+
if (!name || seen.has(name)) continue;
|
|
498
|
+
seen.add(name);
|
|
499
|
+
merged.push({ ...command, name });
|
|
500
|
+
}
|
|
501
|
+
return merged;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function mergeSlashSkills(skills: SkillResult[]): SkillResult[] {
|
|
505
|
+
const seen = new Set<string>();
|
|
506
|
+
const merged: SkillResult[] = [];
|
|
507
|
+
for (const skill of skills) {
|
|
508
|
+
const key = `${skill.source ?? ""}:${skill.path ?? ""}:${skill.name}`;
|
|
509
|
+
if (!skill.name || seen.has(key)) continue;
|
|
510
|
+
seen.add(key);
|
|
511
|
+
merged.push(skill);
|
|
512
|
+
}
|
|
513
|
+
return merged;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
const COMPOSER_MODE_CONFIGS: Record<
|
|
517
|
+
ComposerMode,
|
|
518
|
+
{
|
|
519
|
+
icon: React.ComponentType<{ className?: string }>;
|
|
520
|
+
getContext: (prompt: string) => string;
|
|
521
|
+
beforeSend?: () => void;
|
|
522
|
+
}
|
|
523
|
+
> = {
|
|
524
|
+
skill: {
|
|
525
|
+
icon: IconBulb,
|
|
526
|
+
getContext: (prompt) =>
|
|
527
|
+
`The user wants to create an agent skill. Their description: "${prompt}"
|
|
528
|
+
|
|
529
|
+
Follow the create-skill pattern to build this. Before writing:
|
|
530
|
+
|
|
531
|
+
1. **Determine the skill name** — derive a hyphen-case name from the description (e.g. "code review" → "code-review")
|
|
532
|
+
2. **Determine the skill type** — Pattern (architectural rule), Workflow (step-by-step), or Generator (scaffolding)
|
|
533
|
+
3. **Write the skill** as a personal resource at path "skills/<name>/SKILL.md" using the \`resources\` tool with \`action: "write"\`
|
|
534
|
+
|
|
535
|
+
The skill file MUST have YAML frontmatter with name and description (under 40 words), then markdown with:
|
|
536
|
+
- Clear rule/purpose statement
|
|
537
|
+
- Why this skill exists
|
|
538
|
+
- How to follow it (with code examples where helpful)
|
|
539
|
+
- Common violations to avoid
|
|
540
|
+
- Related skills
|
|
541
|
+
|
|
542
|
+
After creating, update the shared AGENTS.md resource to reference the new skill in its skills table.
|
|
543
|
+
|
|
544
|
+
Keep the skill concise (under 500 lines) and actionable.`,
|
|
545
|
+
},
|
|
546
|
+
job: {
|
|
547
|
+
icon: IconClock,
|
|
548
|
+
getContext: (prompt) =>
|
|
549
|
+
`The user wants to create a recurring job. Their description: "${prompt}"
|
|
550
|
+
|
|
551
|
+
Use the manage-jobs tool with action "create" to create this. You need to:
|
|
552
|
+
1. Derive a hyphen-case name from the description
|
|
553
|
+
2. Convert the schedule to a cron expression (e.g., "every weekday at 9am" → "0 9 * * 1-5")
|
|
554
|
+
3. Write clear, self-contained instructions for what the agent should do each time the job runs
|
|
555
|
+
4. Create it in personal scope
|
|
556
|
+
|
|
557
|
+
The job will run automatically on the schedule. Make the instructions specific — include which actions to call and what to do with results.`,
|
|
558
|
+
},
|
|
559
|
+
automation: {
|
|
560
|
+
icon: IconBolt,
|
|
561
|
+
beforeSend: () => {
|
|
562
|
+
window.dispatchEvent(
|
|
563
|
+
new CustomEvent("agent-panel:set-mode", {
|
|
564
|
+
detail: { mode: "chat" },
|
|
565
|
+
}),
|
|
566
|
+
);
|
|
567
|
+
},
|
|
568
|
+
getContext: (prompt) =>
|
|
569
|
+
`The user wants to create a new automation. Scope: personal. Their description: "${prompt}"
|
|
570
|
+
|
|
571
|
+
Use manage-automations with action=define to create it. Ask clarifying questions if needed about what event to trigger on, conditions, and what actions to take.`,
|
|
572
|
+
},
|
|
573
|
+
extension: {
|
|
574
|
+
icon: IconTool,
|
|
575
|
+
getContext: (prompt) =>
|
|
576
|
+
`The user wants to create an interactive extension (sandboxed mini-app). Their description: "${prompt}"
|
|
577
|
+
|
|
578
|
+
Use the create-extension action with Alpine.js HTML content. The extension runs as a sandboxed iframe with Tailwind CSS and modest default canvas padding. For edge-to-edge layouts, put data-extension-layout="full-bleed" on the outermost element.
|
|
579
|
+
|
|
580
|
+
After creating the extension, navigate the user to it with the path returned by create-extension; extension URLs may include a friendly "/extensions/<id>/<slug>" suffix.
|
|
581
|
+
|
|
582
|
+
Make the extension functional and visually polished. Extensions can use extensionFetch() for external API calls, appAction()/appFetch() for app operations and app data writes, extensionData for per-extension persistence, and dbQuery() only for read-only inspection of existing app tables.
|
|
583
|
+
|
|
584
|
+
Prefer appAction()/appFetch() for app data. Some actions return JSON strings for CLI compatibility, so parse string results before counting rows or reading arrays. Do not guess raw SQL table names or columns for app data; use dbQuery() only when the table is known to exist in the current schema.`,
|
|
585
|
+
},
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
function localizedComposerModeConfig(mode: ComposerMode, t: ComposerTranslate) {
|
|
589
|
+
const config = COMPOSER_MODE_CONFIGS[mode];
|
|
590
|
+
const copies: Record<
|
|
591
|
+
ComposerMode,
|
|
592
|
+
{ label: string; placeholder: string; messagePrefix: string }
|
|
593
|
+
> = {
|
|
594
|
+
skill: {
|
|
595
|
+
label: t("agentChat.composer.createSkill", {
|
|
596
|
+
defaultValue: "Create Skill",
|
|
597
|
+
}),
|
|
598
|
+
placeholder: t("agentChat.composer.describeSkill", {
|
|
599
|
+
defaultValue: "Describe the skill you want to create...",
|
|
600
|
+
}),
|
|
601
|
+
messagePrefix: t("agentChat.composer.createSkillPrefix", {
|
|
602
|
+
defaultValue: "Create a skill: ",
|
|
603
|
+
}),
|
|
604
|
+
},
|
|
605
|
+
job: {
|
|
606
|
+
label: t("agentChat.composer.scheduleTask", {
|
|
607
|
+
defaultValue: "Schedule Task",
|
|
608
|
+
}),
|
|
609
|
+
placeholder: t("agentChat.composer.describeSchedule", {
|
|
610
|
+
defaultValue: "Describe what should happen and when...",
|
|
611
|
+
}),
|
|
612
|
+
messagePrefix: t("agentChat.composer.scheduleTaskPrefix", {
|
|
613
|
+
defaultValue: "Create a recurring job: ",
|
|
614
|
+
}),
|
|
615
|
+
},
|
|
616
|
+
automation: {
|
|
617
|
+
label: t("agentChat.composer.createAutomation", {
|
|
618
|
+
defaultValue: "Create Automation",
|
|
619
|
+
}),
|
|
620
|
+
placeholder: t("agentChat.composer.describeAutomation", {
|
|
621
|
+
defaultValue: "Describe what you want to automate...",
|
|
622
|
+
}),
|
|
623
|
+
messagePrefix: t("agentChat.composer.createAutomationPrefix", {
|
|
624
|
+
defaultValue: "Create an automation: ",
|
|
625
|
+
}),
|
|
626
|
+
},
|
|
627
|
+
extension: {
|
|
628
|
+
label: t("agentChat.composer.createExtension", {
|
|
629
|
+
defaultValue: "Create Extension",
|
|
630
|
+
}),
|
|
631
|
+
placeholder: t("agentChat.composer.describeExtension", {
|
|
632
|
+
defaultValue: "Describe the interactive extension you want to build...",
|
|
633
|
+
}),
|
|
634
|
+
messagePrefix: t("agentChat.composer.createExtensionPrefix", {
|
|
635
|
+
defaultValue: "Create an extension: ",
|
|
636
|
+
}),
|
|
637
|
+
},
|
|
638
|
+
};
|
|
639
|
+
return { ...config, ...copies[mode] };
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function ComposerModeChip({
|
|
643
|
+
mode,
|
|
644
|
+
onRemove,
|
|
645
|
+
}: {
|
|
646
|
+
mode: ComposerMode;
|
|
647
|
+
onRemove: () => void;
|
|
648
|
+
}) {
|
|
649
|
+
const t = useComposerRuntimeAdapters().translate!;
|
|
650
|
+
const config = localizedComposerModeConfig(mode, t);
|
|
651
|
+
const Icon = config.icon;
|
|
652
|
+
return (
|
|
653
|
+
<span className="inline-flex items-center gap-1 rounded-md border border-border bg-muted/50 px-1.5 py-0.5 text-xs font-medium text-foreground">
|
|
654
|
+
<Icon className="h-3 w-3 text-muted-foreground" />
|
|
655
|
+
{config.label}
|
|
656
|
+
<button
|
|
657
|
+
type="button"
|
|
658
|
+
onClick={onRemove}
|
|
659
|
+
className="ms-0.5 rounded-sm text-muted-foreground hover:text-foreground cursor-pointer"
|
|
660
|
+
>
|
|
661
|
+
<IconX className="h-3 w-3" />
|
|
662
|
+
</button>
|
|
663
|
+
</span>
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
type ExecMode = "build" | "plan";
|
|
668
|
+
|
|
669
|
+
export interface ComposerAgentOption {
|
|
670
|
+
/** Stable host-defined identifier for the agent runtime. */
|
|
671
|
+
id: string;
|
|
672
|
+
/** Human-readable runtime name shown in the picker. */
|
|
673
|
+
label: string;
|
|
674
|
+
/** Optional icon shown beside the runtime name. */
|
|
675
|
+
icon?: React.ReactNode;
|
|
676
|
+
/** Optional short detail shown below the runtime name. */
|
|
677
|
+
description?: string;
|
|
678
|
+
/** Whether this runtime can be selected right now. */
|
|
679
|
+
configured?: boolean;
|
|
680
|
+
/** Optional status text such as "Installed" or "Sign in". */
|
|
681
|
+
statusLabel?: string;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
export interface TiptapComposerProps {
|
|
685
|
+
placeholder?: string;
|
|
686
|
+
disabled?: boolean;
|
|
687
|
+
/** Override the generic document attachment cap for a multipart host. */
|
|
688
|
+
maxDocumentAttachmentBytes?: number;
|
|
689
|
+
/** Label used in the visible document attachment limit error. */
|
|
690
|
+
documentAttachmentLimitLabel?: string;
|
|
691
|
+
focusRef?: React.Ref<TiptapComposerHandle>;
|
|
692
|
+
/** Programmatically seed the editor with plain text. */
|
|
693
|
+
initialText?: string;
|
|
694
|
+
/** Stable key used to re-apply the seeded text. */
|
|
695
|
+
initialTextKey?: string | number;
|
|
696
|
+
/**
|
|
697
|
+
* When provided, called instead of composerRuntime.send(). Used for queue
|
|
698
|
+
* mode and standalone prompt popovers. Receives the live composer
|
|
699
|
+
* attachments so callers (e.g. PromptComposer) can surface uploaded files.
|
|
700
|
+
*/
|
|
701
|
+
onSubmit?: (
|
|
702
|
+
text: string,
|
|
703
|
+
references: Reference[],
|
|
704
|
+
attachments?: ReadonlyArray<unknown>,
|
|
705
|
+
options?: TiptapComposerSubmitOptions,
|
|
706
|
+
) => void | Promise<void>;
|
|
707
|
+
/** Return false to stop a submit before it enters the chat runtime. */
|
|
708
|
+
onBeforeSubmit?: () => boolean | Promise<boolean>;
|
|
709
|
+
/**
|
|
710
|
+
* Clear the editor after an onSubmit handler runs. Standalone workflows that
|
|
711
|
+
* may fail outside the composer can keep the draft visible for quick edits.
|
|
712
|
+
*/
|
|
713
|
+
clearOnSubmit?: boolean;
|
|
714
|
+
/** Called whenever the plain editor text changes. */
|
|
715
|
+
onTextChange?: (text: string) => void;
|
|
716
|
+
/** Custom action button (e.g. stop button) to render instead of the default send button. */
|
|
717
|
+
actionButton?: React.ReactNode;
|
|
718
|
+
/** Whether the default send action will wait behind existing work. */
|
|
719
|
+
willQueue?: boolean;
|
|
720
|
+
/** Extra button to render alongside the primary action. */
|
|
721
|
+
extraActionButton?: React.ReactNode;
|
|
722
|
+
/**
|
|
723
|
+
* Stop control shown instead of the disabled send button while the composer
|
|
724
|
+
* has no sendable content. Typing or attaching content restores send.
|
|
725
|
+
*/
|
|
726
|
+
stopButton?: React.ReactNode;
|
|
727
|
+
/** Custom attachment button to render instead of ComposerPrimitive.AddAttachment. */
|
|
728
|
+
attachButton?: React.ReactNode;
|
|
729
|
+
/** Custom host-owned control rendered next to the attachment affordance. */
|
|
730
|
+
modeControl?: React.ReactNode;
|
|
731
|
+
/** Explicit host-owned toolbar slot rendered next to the attachment affordance. */
|
|
732
|
+
toolbarSlot?: React.ReactNode;
|
|
733
|
+
/** Shared sizing/layout variant for host surfaces. Default keeps sidebar behavior. */
|
|
734
|
+
layoutVariant?: AgentComposerLayoutVariant;
|
|
735
|
+
/** Additional slash commands surfaced in the shared / menu. */
|
|
736
|
+
slashCommands?: SlashCommand[];
|
|
737
|
+
/** Additional slash skills surfaced in the shared / menu. */
|
|
738
|
+
slashSkills?: SkillResult[];
|
|
739
|
+
/** Include built-in sidebar slash commands like /clear and /help. Default true. */
|
|
740
|
+
includeDefaultSlashCommands?: boolean;
|
|
741
|
+
/** Include app-discovered skills from the default agent endpoint. Default true. */
|
|
742
|
+
includeDefaultSlashSkills?: boolean;
|
|
743
|
+
/** Called when a slash command (e.g. /clear, /help) is executed */
|
|
744
|
+
onSlashCommand?: (command: string) => void;
|
|
745
|
+
/** Current execution mode (build/plan) */
|
|
746
|
+
execMode?: ExecMode;
|
|
747
|
+
/** Callback to change execution mode */
|
|
748
|
+
onExecModeChange?: (mode: ExecMode) => void;
|
|
749
|
+
/** Disable Plan mode while leaving Act mode available. */
|
|
750
|
+
planModeDisabled?: boolean;
|
|
751
|
+
/** Explanation shown next to the disabled Plan option. */
|
|
752
|
+
planModeDisabledReason?: string;
|
|
753
|
+
/** Show the microphone button for voice dictation. Defaults to DEFAULT_VOICE_DICTATION_ENABLED. */
|
|
754
|
+
voiceEnabled?: boolean;
|
|
755
|
+
/** Selected model override for this conversation */
|
|
756
|
+
selectedModel?: string;
|
|
757
|
+
/** Selected effort override for this conversation */
|
|
758
|
+
selectedEffort?: ReasoningEffort;
|
|
759
|
+
/** Show the legacy provider-level Auto model option (default: true). */
|
|
760
|
+
showAutoModelOption?: boolean;
|
|
761
|
+
/** Controlled open state for hosts that resize around the model picker. */
|
|
762
|
+
modelSelectorOpen?: boolean;
|
|
763
|
+
/** Available models grouped by provider */
|
|
764
|
+
availableModels?: Array<{
|
|
765
|
+
engine: string;
|
|
766
|
+
label: string;
|
|
767
|
+
models: string[];
|
|
768
|
+
configured: boolean;
|
|
769
|
+
statusLabel?: string;
|
|
770
|
+
isSubscription?: boolean;
|
|
771
|
+
}>;
|
|
772
|
+
/** Whether the model list is still being resolved. */
|
|
773
|
+
modelListLoading?: boolean;
|
|
774
|
+
/** Callback when user picks a model */
|
|
775
|
+
onModelChange?: (model: string, engine: string) => void;
|
|
776
|
+
/** Callback when user picks an effort */
|
|
777
|
+
onEffortChange?: (effort: ReasoningEffort) => void;
|
|
778
|
+
/** Local or hosted agent runtimes shown above the model list. */
|
|
779
|
+
availableAgents?: ComposerAgentOption[];
|
|
780
|
+
/** Selected agent runtime identifier. Defaults to the built-in agent. */
|
|
781
|
+
selectedAgent?: string;
|
|
782
|
+
/** Show only the selected agent in the model control. */
|
|
783
|
+
agentOnly?: boolean;
|
|
784
|
+
/** Mark the selected runtime as the hosted tools-only harness mode. */
|
|
785
|
+
hostedHarness?: boolean;
|
|
786
|
+
/** Callback when the user picks an agent runtime. */
|
|
787
|
+
onAgentChange?: (agent: string) => void;
|
|
788
|
+
/** Called when the shared model picker opens or closes. */
|
|
789
|
+
onModelSelectorOpenChange?: (open: boolean) => void;
|
|
790
|
+
/**
|
|
791
|
+
* Disable Builder/provider status polling for hosts that supply provider
|
|
792
|
+
* state through another channel, such as Electron IPC.
|
|
793
|
+
*/
|
|
794
|
+
providerConnectStatusEnabled?: boolean;
|
|
795
|
+
/**
|
|
796
|
+
* Override the Builder.io connect action in the model picker. When provided,
|
|
797
|
+
* clicking "Connect Builder.io" calls this instead of opening a browser popup.
|
|
798
|
+
* Used by the Electron desktop app to route through the native IPC handler.
|
|
799
|
+
*/
|
|
800
|
+
onConnectProvider?: () => void;
|
|
801
|
+
/** Route local runtime setup through the host's native bridge. */
|
|
802
|
+
onConnectLocalRuntime?: (engine: string) => void;
|
|
803
|
+
/**
|
|
804
|
+
* Optional secondary model menu (e.g. an image-generation model) rendered as
|
|
805
|
+
* an extra section inside the model picker. Opt-in; omit for chat-only apps.
|
|
806
|
+
*/
|
|
807
|
+
imageModelMenu?: ComposerImageModelMenu;
|
|
808
|
+
/** Stable scope for persisted drafts, usually the active thread or tab id. */
|
|
809
|
+
draftScope?: string;
|
|
810
|
+
/** Keyed context nuggets staged for the next submitted prompt. */
|
|
811
|
+
contextItems?: AgentChatContextItem[];
|
|
812
|
+
/** Remove a staged context nugget by key. */
|
|
813
|
+
onRemoveContextItem?: (key: string) => void;
|
|
814
|
+
/**
|
|
815
|
+
* Controls the "+" menu next to the composer. `"full"` (default) shows the
|
|
816
|
+
* normal Upload / Skill / Job / Automation / MCP picker, plus Extension when
|
|
817
|
+
* `extensionTools` is true. `"upload-only"` collapses it to a single button
|
|
818
|
+
* that opens the file picker directly. `"hidden"` hides attachment controls
|
|
819
|
+
* for text-only prompt surfaces.
|
|
820
|
+
*/
|
|
821
|
+
plusMenuMode?: "full" | "upload-only" | "terminal" | "hidden";
|
|
822
|
+
/** Controls the terminal-specific plus menu when `plusMenuMode` is terminal. */
|
|
823
|
+
terminalModeControl?: ComposerTerminalModeControl;
|
|
824
|
+
/**
|
|
825
|
+
* Include extension creation in the full "+" menu. Defaults to false so
|
|
826
|
+
* apps opt into the extension capability deliberately.
|
|
827
|
+
*/
|
|
828
|
+
extensionTools?: boolean;
|
|
829
|
+
/**
|
|
830
|
+
* When true and the composer is running inside the Builder.io webview/iframe,
|
|
831
|
+
* intercept "build me an app/agent" prompts and forward them to the parent
|
|
832
|
+
* Builder chat via `builder.submitChat` instead of sending to the local
|
|
833
|
+
* agent. Off by default — the chat sidebar opts in; standalone prompt
|
|
834
|
+
* forms (NewWorkspaceAppFlow, etc.) handle delegation themselves with
|
|
835
|
+
* extra context (vault keys, computed app ids) that the raw composer
|
|
836
|
+
* text lacks.
|
|
837
|
+
*/
|
|
838
|
+
interceptBuildRequestsForBuilder?: boolean;
|
|
839
|
+
/**
|
|
840
|
+
* Called when a drag-drop or paste attachment fails (e.g. unsupported format,
|
|
841
|
+
* size cap). Use this to surface a visible error in the parent chat surface
|
|
842
|
+
* rather than silently swallowing the problem.
|
|
843
|
+
*/
|
|
844
|
+
onAttachmentError?: (message: string) => void;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
function plainTextToDoc(text: string) {
|
|
848
|
+
const lines = text.length > 0 ? text.split(/\r?\n/) : [""];
|
|
849
|
+
return {
|
|
850
|
+
type: "doc",
|
|
851
|
+
content: lines.map((line) => ({
|
|
852
|
+
type: "paragraph",
|
|
853
|
+
content: line ? [{ type: "text", text: line }] : [],
|
|
854
|
+
})),
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/** Tiptap keeps the Editor object truthy after destroy but clears commandManager. */
|
|
859
|
+
export function isComposerEditorUsable<T extends { isDestroyed?: boolean }>(
|
|
860
|
+
editor: T | null | undefined,
|
|
861
|
+
): editor is T {
|
|
862
|
+
return Boolean(editor && editor.isDestroyed !== true);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
export function createTiptapComposerExtensions(
|
|
866
|
+
getPlaceholder: () => string | undefined,
|
|
867
|
+
) {
|
|
868
|
+
return [
|
|
869
|
+
StarterKit.configure({
|
|
870
|
+
heading: false,
|
|
871
|
+
horizontalRule: false,
|
|
872
|
+
bulletList: false,
|
|
873
|
+
orderedList: false,
|
|
874
|
+
listItem: false,
|
|
875
|
+
listKeymap: false,
|
|
876
|
+
blockquote: false,
|
|
877
|
+
codeBlock: false,
|
|
878
|
+
strike: false,
|
|
879
|
+
italic: false,
|
|
880
|
+
bold: false,
|
|
881
|
+
code: false,
|
|
882
|
+
dropcursor: false,
|
|
883
|
+
gapcursor: false,
|
|
884
|
+
link: false,
|
|
885
|
+
trailingNode: false,
|
|
886
|
+
underline: false,
|
|
887
|
+
}),
|
|
888
|
+
Placeholder.configure({
|
|
889
|
+
placeholder: () => getPlaceholder() ?? "",
|
|
890
|
+
emptyEditorClass: "is-editor-empty",
|
|
891
|
+
showOnlyCurrent: false,
|
|
892
|
+
}),
|
|
893
|
+
FileReference,
|
|
894
|
+
SkillReference,
|
|
895
|
+
MentionReference,
|
|
896
|
+
];
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
function ModeSelector({
|
|
900
|
+
mode,
|
|
901
|
+
onChange,
|
|
902
|
+
planModeDisabled = false,
|
|
903
|
+
planModeDisabledReason,
|
|
904
|
+
}: {
|
|
905
|
+
mode: ExecMode;
|
|
906
|
+
onChange: (mode: ExecMode) => void;
|
|
907
|
+
planModeDisabled?: boolean;
|
|
908
|
+
planModeDisabledReason?: string;
|
|
909
|
+
}) {
|
|
910
|
+
const t = useComposerRuntimeAdapters().translate!;
|
|
911
|
+
const [open, setOpen] = useState(false);
|
|
912
|
+
const resolvedPlanModeDisabledReason =
|
|
913
|
+
planModeDisabledReason ??
|
|
914
|
+
t("agentChat.composer.planDesktopRequired", {
|
|
915
|
+
defaultValue: "Open Agent Native Desktop to use Plan mode.",
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
return (
|
|
919
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
920
|
+
<PopoverTrigger asChild>
|
|
921
|
+
<button
|
|
922
|
+
type="button"
|
|
923
|
+
aria-label={
|
|
924
|
+
mode === "build"
|
|
925
|
+
? t("agentChat.composer.actMode", { defaultValue: "Act mode" })
|
|
926
|
+
: t("agentChat.plan.mode", { defaultValue: "Plan mode" })
|
|
927
|
+
}
|
|
928
|
+
data-agent-composer-slot="mode-button"
|
|
929
|
+
className="agent-composer-mode-button shrink-0 flex items-center gap-1 rounded-md px-2 py-1 text-[12px] font-medium text-muted-foreground hover:bg-accent/50 hover:text-foreground"
|
|
930
|
+
>
|
|
931
|
+
{mode === "build"
|
|
932
|
+
? t("agentChat.plan.act", { defaultValue: "Act" })
|
|
933
|
+
: t("agentChat.composer.plan", { defaultValue: "Plan" })}
|
|
934
|
+
<IconChevronDown className="h-3 w-3 opacity-60" />
|
|
935
|
+
</button>
|
|
936
|
+
</PopoverTrigger>
|
|
937
|
+
<PopoverContent
|
|
938
|
+
side="top"
|
|
939
|
+
align="end"
|
|
940
|
+
sideOffset={6}
|
|
941
|
+
collisionPadding={8}
|
|
942
|
+
data-agent-native-composer-popover="true"
|
|
943
|
+
className="z-[260] w-60 rounded-lg border-border p-0 py-1 shadow-lg"
|
|
944
|
+
style={{ fontSize: 13 }}
|
|
945
|
+
>
|
|
946
|
+
<button
|
|
947
|
+
type="button"
|
|
948
|
+
onClick={() => {
|
|
949
|
+
onChange("build");
|
|
950
|
+
setOpen(false);
|
|
951
|
+
}}
|
|
952
|
+
className="flex w-full items-center gap-3 px-3 py-2 hover:bg-accent/50 text-start"
|
|
953
|
+
>
|
|
954
|
+
<IconPencil className="h-4 w-4 shrink-0 text-muted-foreground" />
|
|
955
|
+
<div className="flex-1 min-w-0">
|
|
956
|
+
<span className="font-medium text-foreground text-[13px]">
|
|
957
|
+
{t("agentChat.plan.act", { defaultValue: "Act" })}
|
|
958
|
+
</span>
|
|
959
|
+
<p className="text-[11px] text-muted-foreground mt-0.5">
|
|
960
|
+
{t("agentChat.composer.actDescription", {
|
|
961
|
+
defaultValue: "Use tools and make approved changes",
|
|
962
|
+
})}
|
|
963
|
+
</p>
|
|
964
|
+
</div>
|
|
965
|
+
{mode === "build" && (
|
|
966
|
+
<IconCheck className="size-4 shrink-0 text-primary" />
|
|
967
|
+
)}
|
|
968
|
+
</button>
|
|
969
|
+
<button
|
|
970
|
+
type="button"
|
|
971
|
+
disabled={planModeDisabled}
|
|
972
|
+
title={planModeDisabled ? resolvedPlanModeDisabledReason : undefined}
|
|
973
|
+
onClick={() => {
|
|
974
|
+
if (planModeDisabled) return;
|
|
975
|
+
onChange("plan");
|
|
976
|
+
setOpen(false);
|
|
977
|
+
}}
|
|
978
|
+
className={`flex w-full items-center gap-3 px-3 py-2 text-start ${
|
|
979
|
+
planModeDisabled
|
|
980
|
+
? "cursor-not-allowed opacity-60"
|
|
981
|
+
: "hover:bg-accent/50"
|
|
982
|
+
}`}
|
|
983
|
+
>
|
|
984
|
+
<IconClipboardList className="h-4 w-4 shrink-0 text-muted-foreground" />
|
|
985
|
+
<div className="flex-1 min-w-0">
|
|
986
|
+
<span className="font-medium text-foreground text-[13px]">
|
|
987
|
+
{t("agentChat.composer.plan", { defaultValue: "Plan" })}
|
|
988
|
+
</span>
|
|
989
|
+
<p className="text-[11px] text-muted-foreground mt-0.5">
|
|
990
|
+
{planModeDisabled
|
|
991
|
+
? resolvedPlanModeDisabledReason
|
|
992
|
+
: t("agentChat.composer.planDescription", {
|
|
993
|
+
defaultValue: "Read-only research and approval first",
|
|
994
|
+
})}
|
|
995
|
+
</p>
|
|
996
|
+
</div>
|
|
997
|
+
{mode === "plan" && !planModeDisabled && (
|
|
998
|
+
<IconCheck className="size-4 shrink-0 text-primary" />
|
|
999
|
+
)}
|
|
1000
|
+
</button>
|
|
1001
|
+
</PopoverContent>
|
|
1002
|
+
</Popover>
|
|
1003
|
+
);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
const FRIENDLY_MODEL_NAMES: Record<string, string> = {
|
|
1007
|
+
auto: "Default model",
|
|
1008
|
+
"codex-cli": "Codex",
|
|
1009
|
+
"claude-cli": "Claude Code",
|
|
1010
|
+
"pi-cli": "Pi",
|
|
1011
|
+
"opencode-cli": "OpenCode",
|
|
1012
|
+
"claude-fable-5": "Fable 5",
|
|
1013
|
+
"kimi-k2-5": "Kimi K2.5",
|
|
1014
|
+
"deepseek-v3-1": "DeepSeek v3.1",
|
|
1015
|
+
"z-ai/glm-5.2": "GLM 5.2",
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
const LOCAL_RUNTIME_ENGINES = new Set([
|
|
1019
|
+
"codex-cli",
|
|
1020
|
+
"claude-cli",
|
|
1021
|
+
"pi-cli",
|
|
1022
|
+
"opencode-cli",
|
|
1023
|
+
]);
|
|
1024
|
+
|
|
1025
|
+
function isOpenAiModelId(model: string): boolean {
|
|
1026
|
+
const normalizedModel = model.toLowerCase();
|
|
1027
|
+
return (
|
|
1028
|
+
normalizedModel.startsWith("gpt-") ||
|
|
1029
|
+
normalizedModel.startsWith("openai/gpt-")
|
|
1030
|
+
);
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
export function isOpenAiModelProviderGroup(group: {
|
|
1034
|
+
engine: string;
|
|
1035
|
+
label: string;
|
|
1036
|
+
models: string[];
|
|
1037
|
+
}): boolean {
|
|
1038
|
+
const engine = group.engine.toLowerCase();
|
|
1039
|
+
const label = group.label.toLowerCase();
|
|
1040
|
+
if (engine === "codex-cli") {
|
|
1041
|
+
return group.models.some(isOpenAiModelId);
|
|
1042
|
+
}
|
|
1043
|
+
return (
|
|
1044
|
+
engine.includes("openai") ||
|
|
1045
|
+
label.includes("openai") ||
|
|
1046
|
+
group.models.some(isOpenAiModelId)
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
const HARNESS_AGENTS_DOCS_URL =
|
|
1051
|
+
"https://www.agent-native.com/docs/harness-agents";
|
|
1052
|
+
|
|
1053
|
+
export const MODEL_SELECTOR_POPOVER_STYLE = {
|
|
1054
|
+
fontSize: 13,
|
|
1055
|
+
maxHeight: "min(500px, var(--radix-popover-content-available-height, 500px))",
|
|
1056
|
+
} satisfies React.CSSProperties;
|
|
1057
|
+
|
|
1058
|
+
const MODEL_SELECTOR_POPOVER_CLASS =
|
|
1059
|
+
"box-border w-64 rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-lg outline-none";
|
|
1060
|
+
const PICKER_HELP_BUTTON_CLASS =
|
|
1061
|
+
"flex size-3 shrink-0 items-center justify-center rounded text-muted-foreground/60 hover:text-foreground";
|
|
1062
|
+
const PICKER_HELP_ICON_CLASS = "size-2";
|
|
1063
|
+
|
|
1064
|
+
export function shouldShowModelSelectorSkeleton(
|
|
1065
|
+
isLoading: boolean,
|
|
1066
|
+
engineCount: number,
|
|
1067
|
+
): boolean {
|
|
1068
|
+
return isLoading && engineCount === 0;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
/**
|
|
1072
|
+
* With nothing connected, every family is a dead "needs API key" row, so the
|
|
1073
|
+
* picker shows only the connect CTAs. Never hide the list unless a CTA is
|
|
1074
|
+
* there to replace it — an empty popover reads as more broken, not less.
|
|
1075
|
+
*/
|
|
1076
|
+
export function shouldShowOnlyConnectPath(
|
|
1077
|
+
showBuilderCta: boolean,
|
|
1078
|
+
groups: ReadonlyArray<{ configured: boolean }>,
|
|
1079
|
+
): boolean {
|
|
1080
|
+
return showBuilderCta && groups.every((group) => !group.configured);
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
function friendlyModelName(model: string, t?: ComposerTranslate): string {
|
|
1084
|
+
if (model === "auto") {
|
|
1085
|
+
return (
|
|
1086
|
+
t?.("agentChat.composer.defaultModel", {
|
|
1087
|
+
defaultValue: "Default model",
|
|
1088
|
+
}) ?? "Default model"
|
|
1089
|
+
);
|
|
1090
|
+
}
|
|
1091
|
+
if (FRIENDLY_MODEL_NAMES[model]) return FRIENDLY_MODEL_NAMES[model];
|
|
1092
|
+
// Claude: claude-{tier}-{major}[-minor][-dateYYYYMMDD] → Tier Major[.Minor]
|
|
1093
|
+
const claude = model.match(
|
|
1094
|
+
/^claude-(opus|sonnet|haiku)-(\d+)(?:-(\d+))?(?:-\d{8,})?$/,
|
|
1095
|
+
);
|
|
1096
|
+
if (claude) {
|
|
1097
|
+
const tier = claude[1][0].toUpperCase() + claude[1].slice(1);
|
|
1098
|
+
return `${tier} ${claude[2]}${claude[3] ? `.${claude[3]}` : ""}`;
|
|
1099
|
+
}
|
|
1100
|
+
// GPT: gpt-{major}-{minor}[-suffix] or gpt-{major}.{minor}[-suffix]
|
|
1101
|
+
if (model.startsWith("gpt-")) {
|
|
1102
|
+
const rest = model.slice(4);
|
|
1103
|
+
const gpt = rest.match(/^(\d+)[.-](\d+)(?:[.-](.+))?$/);
|
|
1104
|
+
if (gpt) {
|
|
1105
|
+
const suffix = gpt[3]
|
|
1106
|
+
? " " +
|
|
1107
|
+
gpt[3]
|
|
1108
|
+
.split("-")
|
|
1109
|
+
.map((s) => s[0].toUpperCase() + s.slice(1))
|
|
1110
|
+
.join(" ")
|
|
1111
|
+
: "";
|
|
1112
|
+
return `GPT-${gpt[1]}.${gpt[2]}${suffix}`;
|
|
1113
|
+
}
|
|
1114
|
+
return `GPT-${rest}`;
|
|
1115
|
+
}
|
|
1116
|
+
if (/^o\d/.test(model)) return model;
|
|
1117
|
+
// Gemini: gemini-{major}-{minor}-{variant}[-preview] → Gemini Major.Minor Variant
|
|
1118
|
+
const geminiVersioned = model.match(
|
|
1119
|
+
/^gemini-(\d+)-(\d+)-(.+?)(?:-preview)?$/,
|
|
1120
|
+
);
|
|
1121
|
+
if (geminiVersioned) {
|
|
1122
|
+
const variant = geminiVersioned[3]
|
|
1123
|
+
.split("-")
|
|
1124
|
+
.map((s) => s[0].toUpperCase() + s.slice(1))
|
|
1125
|
+
.join(" ");
|
|
1126
|
+
return `Gemini ${geminiVersioned[1]}.${geminiVersioned[2]} ${variant}`;
|
|
1127
|
+
}
|
|
1128
|
+
// Gemini: gemini-{version.parts}[-preview] → Gemini Version Parts
|
|
1129
|
+
const gemini = model.match(/^gemini-(.+?)(?:-preview)?$/);
|
|
1130
|
+
if (gemini) {
|
|
1131
|
+
const parts = gemini[1]
|
|
1132
|
+
.split("-")
|
|
1133
|
+
.map((s) => s[0].toUpperCase() + s.slice(1))
|
|
1134
|
+
.join(" ");
|
|
1135
|
+
return `Gemini ${parts}`;
|
|
1136
|
+
}
|
|
1137
|
+
return model;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
export function compactComposerModelName(
|
|
1141
|
+
model: string,
|
|
1142
|
+
t?: ComposerTranslate,
|
|
1143
|
+
): string {
|
|
1144
|
+
const gpt56Variant = model.match(
|
|
1145
|
+
/^(?:openai\/)?gpt-5[.-]6[.-](sol|terra|luna)$/i,
|
|
1146
|
+
)?.[1];
|
|
1147
|
+
if (gpt56Variant) {
|
|
1148
|
+
const variant =
|
|
1149
|
+
gpt56Variant[0].toUpperCase() + gpt56Variant.slice(1).toLowerCase();
|
|
1150
|
+
return `GPT-5.6 ${variant}`;
|
|
1151
|
+
}
|
|
1152
|
+
return friendlyModelName(model, t);
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
export function compactComposerReasoningEffortLabel(
|
|
1156
|
+
effort: ReasoningEffort,
|
|
1157
|
+
t?: ComposerTranslate,
|
|
1158
|
+
): string {
|
|
1159
|
+
if (effort === "medium" || effort === "auto") {
|
|
1160
|
+
return (
|
|
1161
|
+
t?.("agentChat.composer.reasoningMediumShort", {
|
|
1162
|
+
defaultValue: "Med",
|
|
1163
|
+
}) ?? "Med"
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1166
|
+
if (effort === "minimal") {
|
|
1167
|
+
return (
|
|
1168
|
+
t?.("agentChat.composer.reasoningMinimalShort", {
|
|
1169
|
+
defaultValue: "Min",
|
|
1170
|
+
}) ?? "Min"
|
|
1171
|
+
);
|
|
1172
|
+
}
|
|
1173
|
+
if (effort === "xhigh") {
|
|
1174
|
+
return (
|
|
1175
|
+
t?.("agentChat.composer.reasoningExtraHighShort", {
|
|
1176
|
+
defaultValue: "XHigh",
|
|
1177
|
+
}) ?? "XHigh"
|
|
1178
|
+
);
|
|
1179
|
+
}
|
|
1180
|
+
return t
|
|
1181
|
+
? localizedReasoningEffortLabel(t, effort, reasoningEffortLabel(effort))
|
|
1182
|
+
: reasoningEffortLabel(effort);
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
function localizedReasoningEffortLabel(
|
|
1186
|
+
t: ComposerTranslate,
|
|
1187
|
+
effort: ReasoningEffort,
|
|
1188
|
+
defaultValue: string,
|
|
1189
|
+
): string {
|
|
1190
|
+
switch (effort) {
|
|
1191
|
+
case "auto":
|
|
1192
|
+
return t("agentChat.composer.reasoningEffort.auto", { defaultValue });
|
|
1193
|
+
case "none":
|
|
1194
|
+
return t("agentChat.composer.reasoningEffort.none", { defaultValue });
|
|
1195
|
+
case "minimal":
|
|
1196
|
+
return t("agentChat.composer.reasoningEffort.minimal", { defaultValue });
|
|
1197
|
+
case "low":
|
|
1198
|
+
return t("agentChat.composer.reasoningEffort.low", { defaultValue });
|
|
1199
|
+
case "medium":
|
|
1200
|
+
return t("agentChat.composer.reasoningEffort.medium", { defaultValue });
|
|
1201
|
+
case "high":
|
|
1202
|
+
return t("agentChat.composer.reasoningEffort.high", { defaultValue });
|
|
1203
|
+
case "xhigh":
|
|
1204
|
+
return t("agentChat.composer.reasoningEffort.xhigh", { defaultValue });
|
|
1205
|
+
case "max":
|
|
1206
|
+
return t("agentChat.composer.reasoningEffort.max", { defaultValue });
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* Deduplicate models to only the latest version per family.
|
|
1212
|
+
* e.g. [opus-4-7, opus-4-6, opus-4-5] → [opus-4-7]
|
|
1213
|
+
*/
|
|
1214
|
+
function latestModelsOnly(models: string[]): string[] {
|
|
1215
|
+
const seen = new Set<string>();
|
|
1216
|
+
return models.filter((m) => {
|
|
1217
|
+
// Claude: family = tier (opus/sonnet/haiku)
|
|
1218
|
+
const claude = m.match(/^claude-(opus|sonnet|haiku)-/);
|
|
1219
|
+
if (claude) {
|
|
1220
|
+
if (seen.has(claude[1])) return false;
|
|
1221
|
+
seen.add(claude[1]);
|
|
1222
|
+
return true;
|
|
1223
|
+
}
|
|
1224
|
+
// GPT: family = gpt-{major} (e.g. gpt-5.6-sol and gpt-5.6-luna are different)
|
|
1225
|
+
// OpenAI effort: each is its own family
|
|
1226
|
+
// Gemini: family = gemini-{major} + variant
|
|
1227
|
+
const gemini = m.match(/^gemini-(\d+(?:\.\d+)?)-(.+?)(?:-preview)?$/);
|
|
1228
|
+
if (gemini) {
|
|
1229
|
+
const family = gemini[2]; // flash, pro, etc.
|
|
1230
|
+
if (seen.has(`gemini-${family}`)) return false;
|
|
1231
|
+
seen.add(`gemini-${family}`);
|
|
1232
|
+
return true;
|
|
1233
|
+
}
|
|
1234
|
+
return true;
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
/**
|
|
1239
|
+
* Coarse relative cost per model, rendered as a quiet `$`…`$$$` suffix.
|
|
1240
|
+
*
|
|
1241
|
+
* Tokens and their order mirror `MODEL_COST_ORDER` in `@agent-native/core`'s
|
|
1242
|
+
* chat-model-groups, which sorts these same rows — the toolkit cannot import
|
|
1243
|
+
* from core, so a new model family has to be added in both places. Tiers are
|
|
1244
|
+
* each provider's own entry/mid/flagship ladder, not a cross-provider price
|
|
1245
|
+
* claim; anything unlisted has no tier rather than a guessed one.
|
|
1246
|
+
*/
|
|
1247
|
+
const MODEL_COST_TIERS: ReadonlyArray<readonly [string, 1 | 2 | 3]> = [
|
|
1248
|
+
["luna", 1],
|
|
1249
|
+
["terra", 2],
|
|
1250
|
+
["sol", 3],
|
|
1251
|
+
["haiku", 1],
|
|
1252
|
+
["sonnet", 2],
|
|
1253
|
+
["opus", 3],
|
|
1254
|
+
["fable", 3],
|
|
1255
|
+
["flash", 1],
|
|
1256
|
+
["pro", 3],
|
|
1257
|
+
];
|
|
1258
|
+
|
|
1259
|
+
export function composerModelCostTier(model: string): 1 | 2 | 3 | undefined {
|
|
1260
|
+
const normalized = model.toLowerCase();
|
|
1261
|
+
return MODEL_COST_TIERS.find(([token]) => normalized.includes(token))?.[1];
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
function ModelCostTier({ model }: { model: string }) {
|
|
1265
|
+
const t = useComposerRuntimeAdapters().translate!;
|
|
1266
|
+
const tier = composerModelCostTier(model);
|
|
1267
|
+
if (!tier) return null;
|
|
1268
|
+
const costLabel =
|
|
1269
|
+
tier === 1
|
|
1270
|
+
? t("agentChat.composer.costLower", { defaultValue: "Lower cost" })
|
|
1271
|
+
: tier === 2
|
|
1272
|
+
? t("agentChat.composer.costMedium", { defaultValue: "Medium cost" })
|
|
1273
|
+
: t("agentChat.composer.costHigher", { defaultValue: "Higher cost" });
|
|
1274
|
+
return <span className="sr-only">{costLabel}</span>;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Optional secondary model menu for apps that drive a separate generation model
|
|
1279
|
+
* alongside the chat LLM (e.g. the Assets app's image-generation model). When
|
|
1280
|
+
* provided, the model picker renders an extra collapsible section so the user
|
|
1281
|
+
* can see and pick both "what reasons about my request" (the chat model) and
|
|
1282
|
+
* "what produces the output" (this model). Opt-in — omit it and nothing changes.
|
|
1283
|
+
*/
|
|
1284
|
+
export interface ComposerImageModelMenu {
|
|
1285
|
+
/** Currently-selected model id for this secondary menu. */
|
|
1286
|
+
value: string;
|
|
1287
|
+
/** Selectable options (stable id + human label). */
|
|
1288
|
+
options: Array<{ value: string; label: string }>;
|
|
1289
|
+
/** Invoked when the user picks a different option. */
|
|
1290
|
+
onChange: (value: string) => void;
|
|
1291
|
+
/** Section header. Defaults to "Image model". */
|
|
1292
|
+
label?: string;
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
export function getComposerReasoningEffortOptions(
|
|
1296
|
+
model: string,
|
|
1297
|
+
): ReasoningEffort[] {
|
|
1298
|
+
return model === "auto"
|
|
1299
|
+
? ["low", "medium", "high", "xhigh", "max"]
|
|
1300
|
+
: getReasoningEffortOptionsForModel(model);
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
function ModelSelector({
|
|
1304
|
+
model,
|
|
1305
|
+
effort,
|
|
1306
|
+
engines,
|
|
1307
|
+
agents,
|
|
1308
|
+
selectedAgent,
|
|
1309
|
+
agentOnly = false,
|
|
1310
|
+
hostedHarness = false,
|
|
1311
|
+
showAutoModelOption = true,
|
|
1312
|
+
modelListLoading = false,
|
|
1313
|
+
open: controlledOpen,
|
|
1314
|
+
onChange,
|
|
1315
|
+
onEffortChange,
|
|
1316
|
+
onAgentChange,
|
|
1317
|
+
onModelSelectorOpenChange,
|
|
1318
|
+
providerConnectStatusEnabled = true,
|
|
1319
|
+
onConnectProvider,
|
|
1320
|
+
onConnectLocalRuntime,
|
|
1321
|
+
imageModel,
|
|
1322
|
+
}: {
|
|
1323
|
+
model: string;
|
|
1324
|
+
effort?: ReasoningEffort;
|
|
1325
|
+
agents?: ComposerAgentOption[];
|
|
1326
|
+
selectedAgent?: string;
|
|
1327
|
+
hostedHarness?: boolean;
|
|
1328
|
+
engines: Array<{
|
|
1329
|
+
engine: string;
|
|
1330
|
+
label: string;
|
|
1331
|
+
models: string[];
|
|
1332
|
+
configured: boolean;
|
|
1333
|
+
statusLabel?: string;
|
|
1334
|
+
isSubscription?: boolean;
|
|
1335
|
+
}>;
|
|
1336
|
+
agentOnly?: boolean;
|
|
1337
|
+
showAutoModelOption?: boolean;
|
|
1338
|
+
modelListLoading?: boolean;
|
|
1339
|
+
onChange: (model: string, engine: string) => void;
|
|
1340
|
+
onEffortChange?: (effort: ReasoningEffort) => void;
|
|
1341
|
+
onAgentChange?: (agent: string) => void;
|
|
1342
|
+
providerConnectStatusEnabled?: boolean;
|
|
1343
|
+
onConnectProvider?: () => void;
|
|
1344
|
+
onConnectLocalRuntime?: (engine: string) => void;
|
|
1345
|
+
onModelSelectorOpenChange?: (open: boolean) => void;
|
|
1346
|
+
imageModel?: ComposerImageModelMenu;
|
|
1347
|
+
open?: boolean;
|
|
1348
|
+
}) {
|
|
1349
|
+
const adapters = useComposerRuntimeAdapters();
|
|
1350
|
+
const t = adapters.translate!;
|
|
1351
|
+
const reasoning = adapters.models?.reasoning;
|
|
1352
|
+
const defaultEffort = reasoning?.defaultEffort ?? DEFAULT_REASONING_EFFORT;
|
|
1353
|
+
const [internalOpen, setInternalOpen] = useState(false);
|
|
1354
|
+
const open = controlledOpen ?? internalOpen;
|
|
1355
|
+
const isClaudeCodeAgent = isClaudeCodeAgentId(selectedAgent);
|
|
1356
|
+
const autoModelGroup = showAutoModelOption
|
|
1357
|
+
? isClaudeCodeAgent
|
|
1358
|
+
? undefined
|
|
1359
|
+
: engines.find((group) => group.models.includes("auto"))
|
|
1360
|
+
: undefined;
|
|
1361
|
+
const providerGroups = useMemo(
|
|
1362
|
+
() =>
|
|
1363
|
+
engines
|
|
1364
|
+
.map((group) => ({
|
|
1365
|
+
...group,
|
|
1366
|
+
models: group.models.filter((candidate) => candidate !== "auto"),
|
|
1367
|
+
}))
|
|
1368
|
+
.filter((group) => group.models.length > 0),
|
|
1369
|
+
[engines],
|
|
1370
|
+
);
|
|
1371
|
+
const isCodexAgent =
|
|
1372
|
+
selectedAgent === "codex" || selectedAgent === "codex-cli";
|
|
1373
|
+
const modelProviderGroups = useMemo(() => {
|
|
1374
|
+
const hasCodexLocalGroup = providerGroups.some(
|
|
1375
|
+
(group) => group.engine === "codex-cli",
|
|
1376
|
+
);
|
|
1377
|
+
const groups = providerGroups.flatMap((group) => {
|
|
1378
|
+
if (group.engine === "codex-cli") {
|
|
1379
|
+
return isCodexAgent && isOpenAiModelProviderGroup(group) ? [group] : [];
|
|
1380
|
+
}
|
|
1381
|
+
if (
|
|
1382
|
+
isCodexAgent &&
|
|
1383
|
+
hasCodexLocalGroup &&
|
|
1384
|
+
group.engine === "ai-sdk:openai"
|
|
1385
|
+
) {
|
|
1386
|
+
return [];
|
|
1387
|
+
}
|
|
1388
|
+
if (LOCAL_RUNTIME_ENGINES.has(group.engine)) return [];
|
|
1389
|
+
if (!isCodexAgent) return [group];
|
|
1390
|
+
if (!isOpenAiModelProviderGroup(group)) return [];
|
|
1391
|
+
|
|
1392
|
+
const isExplicitOpenAiProvider =
|
|
1393
|
+
group.engine.toLowerCase().includes("openai") ||
|
|
1394
|
+
group.label.toLowerCase().includes("openai");
|
|
1395
|
+
const models = isExplicitOpenAiProvider
|
|
1396
|
+
? group.models
|
|
1397
|
+
: group.models.filter(isOpenAiModelId);
|
|
1398
|
+
return models.length > 0 ? [{ ...group, models }] : [];
|
|
1399
|
+
});
|
|
1400
|
+
if (!isClaudeCodeAgent) return groups;
|
|
1401
|
+
return groups
|
|
1402
|
+
.map((group) => ({
|
|
1403
|
+
...group,
|
|
1404
|
+
models: group.models.filter((candidate) => !isLunaModel(candidate)),
|
|
1405
|
+
}))
|
|
1406
|
+
.filter((group) => group.models.length > 0);
|
|
1407
|
+
}, [isClaudeCodeAgent, isCodexAgent, providerGroups]);
|
|
1408
|
+
const preferredAgentModel = useMemo(
|
|
1409
|
+
() => resolvePreferredAgentModel(selectedAgent, providerGroups),
|
|
1410
|
+
[providerGroups, selectedAgent],
|
|
1411
|
+
);
|
|
1412
|
+
useEffect(() => {
|
|
1413
|
+
if (!isClaudeCodeAgent || !isLunaModel(model) || !preferredAgentModel) {
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
if (
|
|
1417
|
+
preferredAgentModel.model === model &&
|
|
1418
|
+
preferredAgentModel.engine ===
|
|
1419
|
+
engines.find((group) => group.models.includes(model))?.engine
|
|
1420
|
+
) {
|
|
1421
|
+
return;
|
|
1422
|
+
}
|
|
1423
|
+
onChange(preferredAgentModel.model, preferredAgentModel.engine);
|
|
1424
|
+
}, [engines, isClaudeCodeAgent, model, onChange, preferredAgentModel]);
|
|
1425
|
+
const effortOptions = agentOnly
|
|
1426
|
+
? []
|
|
1427
|
+
: (reasoning?.getOptionsForModel?.(model) ??
|
|
1428
|
+
getComposerReasoningEffortOptions(model));
|
|
1429
|
+
const selectedEffort =
|
|
1430
|
+
reasoning?.resolve?.(model, effort) ??
|
|
1431
|
+
resolveReasoningEffortSelection(model, effort ?? defaultEffort);
|
|
1432
|
+
const effortLabel = useCallback(
|
|
1433
|
+
(value: ReasoningEffort) =>
|
|
1434
|
+
localizedReasoningEffortLabel(
|
|
1435
|
+
t,
|
|
1436
|
+
value,
|
|
1437
|
+
(reasoning?.label ?? reasoningEffortLabel)(value),
|
|
1438
|
+
),
|
|
1439
|
+
[reasoning?.label, t],
|
|
1440
|
+
);
|
|
1441
|
+
const selectedAgentOption = agents?.find(
|
|
1442
|
+
(agent) => agent.id === (selectedAgent ?? "default"),
|
|
1443
|
+
);
|
|
1444
|
+
const selectedAgentLabel = selectedAgentOption?.label ?? "Default";
|
|
1445
|
+
const selectedModelLabel = friendlyModelName(model, t).replace(/^GPT-/, "");
|
|
1446
|
+
|
|
1447
|
+
const [detailSection, setDetailSection] = useState<
|
|
1448
|
+
"agent" | "model" | "effort" | null
|
|
1449
|
+
>(null);
|
|
1450
|
+
const resolvedSection = detailSection ?? (agentOnly ? "agent" : "model");
|
|
1451
|
+
|
|
1452
|
+
const setPickerOpen = useCallback(
|
|
1453
|
+
(nextOpen: boolean) => {
|
|
1454
|
+
if (controlledOpen === undefined) setInternalOpen(nextOpen);
|
|
1455
|
+
if (nextOpen) setDetailSection(agentOnly ? "agent" : null);
|
|
1456
|
+
onModelSelectorOpenChange?.(nextOpen);
|
|
1457
|
+
},
|
|
1458
|
+
[agentOnly, controlledOpen, onModelSelectorOpenChange],
|
|
1459
|
+
);
|
|
1460
|
+
|
|
1461
|
+
const visibleProviderGroups = modelProviderGroups;
|
|
1462
|
+
const showModelListSkeleton = shouldShowModelSelectorSkeleton(
|
|
1463
|
+
modelListLoading,
|
|
1464
|
+
engines.length,
|
|
1465
|
+
);
|
|
1466
|
+
|
|
1467
|
+
// Keep setup actions beside model choices while any visible provider still
|
|
1468
|
+
// needs configuration. The model rows remain visible so the user can see
|
|
1469
|
+
// what becomes available after connecting or adding a key.
|
|
1470
|
+
const builderFlow = adapters.builder!.useConnectFlow!({
|
|
1471
|
+
enabled: providerConnectStatusEnabled,
|
|
1472
|
+
trackingSource: "composer_builder_cta",
|
|
1473
|
+
});
|
|
1474
|
+
const hasConfiguredBuilderModels = providerGroups.some(
|
|
1475
|
+
(group) => group.engine === "builder" && group.configured,
|
|
1476
|
+
);
|
|
1477
|
+
const hasConnectedSubscription = providerGroups.some(
|
|
1478
|
+
(group) => group.configured && group.isSubscription,
|
|
1479
|
+
);
|
|
1480
|
+
const hasUnconfiguredVisibleModels = modelProviderGroups.some(
|
|
1481
|
+
(group) => !group.configured,
|
|
1482
|
+
);
|
|
1483
|
+
const showBuilderAction =
|
|
1484
|
+
hasUnconfiguredVisibleModels &&
|
|
1485
|
+
(Boolean(onConnectProvider) ||
|
|
1486
|
+
(providerConnectStatusEnabled &&
|
|
1487
|
+
!builderFlow.configured &&
|
|
1488
|
+
!builderFlow.envManaged &&
|
|
1489
|
+
!hasConfiguredBuilderModels &&
|
|
1490
|
+
!hasConnectedSubscription));
|
|
1491
|
+
const showAddKeysAction = hasUnconfiguredVisibleModels;
|
|
1492
|
+
const showProviderActions = showBuilderAction || showAddKeysAction;
|
|
1493
|
+
const onlyConnectPathAvailable =
|
|
1494
|
+
shouldShowOnlyConnectPath(showBuilderAction, providerGroups) &&
|
|
1495
|
+
modelProviderGroups.length === 0;
|
|
1496
|
+
const openLlmSettings = useCallback(() => {
|
|
1497
|
+
try {
|
|
1498
|
+
window.location.hash = "llm";
|
|
1499
|
+
} catch {}
|
|
1500
|
+
window.dispatchEvent(new CustomEvent("agent-panel:open-settings"));
|
|
1501
|
+
setPickerOpen(false);
|
|
1502
|
+
}, [setPickerOpen]);
|
|
1503
|
+
const connectLocalRuntime = useCallback(
|
|
1504
|
+
(engine: string) => {
|
|
1505
|
+
onConnectLocalRuntime?.(engine);
|
|
1506
|
+
setPickerOpen(false);
|
|
1507
|
+
},
|
|
1508
|
+
[onConnectLocalRuntime, setPickerOpen],
|
|
1509
|
+
);
|
|
1510
|
+
|
|
1511
|
+
return (
|
|
1512
|
+
<Popover open={open} onOpenChange={setPickerOpen}>
|
|
1513
|
+
<PopoverTrigger asChild>
|
|
1514
|
+
<button
|
|
1515
|
+
type="button"
|
|
1516
|
+
data-agent-composer-slot="model-button"
|
|
1517
|
+
aria-label={`${t("agentChat.composer.model", {
|
|
1518
|
+
defaultValue: "Model",
|
|
1519
|
+
})}: ${friendlyModelName(model, t)}${
|
|
1520
|
+
effortOptions.length > 0
|
|
1521
|
+
? `. ${t("agentChat.composer.effort", {
|
|
1522
|
+
defaultValue: "Effort",
|
|
1523
|
+
})}: ${effortLabel(selectedEffort)}`
|
|
1524
|
+
: ""
|
|
1525
|
+
}${
|
|
1526
|
+
selectedAgentOption && selectedAgentOption.id !== "default"
|
|
1527
|
+
? `. Agent: ${selectedAgentLabel}`
|
|
1528
|
+
: ""
|
|
1529
|
+
}`}
|
|
1530
|
+
className="agent-composer-model-button flex min-w-0 max-w-[10.5rem] shrink items-center gap-1 rounded-md px-2 py-1 text-[12px] font-medium text-muted-foreground hover:bg-accent/50 hover:text-foreground"
|
|
1531
|
+
>
|
|
1532
|
+
<span className="min-w-0 truncate">
|
|
1533
|
+
{selectedAgentOption?.icon ? (
|
|
1534
|
+
<span className="me-1 inline-flex shrink-0 align-[-2px] text-muted-foreground">
|
|
1535
|
+
{selectedAgentOption.icon}
|
|
1536
|
+
</span>
|
|
1537
|
+
) : null}
|
|
1538
|
+
{selectedAgentOption && selectedAgentOption.id !== "default"
|
|
1539
|
+
? selectedAgentLabel
|
|
1540
|
+
: compactComposerModelName(model, t)}
|
|
1541
|
+
</span>
|
|
1542
|
+
{effortOptions.length > 0 && (
|
|
1543
|
+
<span className="agent-composer-model-effort min-w-0 shrink truncate text-muted-foreground/70">
|
|
1544
|
+
· {compactComposerReasoningEffortLabel(selectedEffort, t)}
|
|
1545
|
+
</span>
|
|
1546
|
+
)}
|
|
1547
|
+
<IconChevronDown className="h-3 w-3 shrink-0 opacity-60" />
|
|
1548
|
+
</button>
|
|
1549
|
+
</PopoverTrigger>
|
|
1550
|
+
<PopoverContent
|
|
1551
|
+
side="top"
|
|
1552
|
+
align="end"
|
|
1553
|
+
sideOffset={6}
|
|
1554
|
+
collisionPadding={8}
|
|
1555
|
+
data-agent-native-composer-popover="true"
|
|
1556
|
+
className={`z-[260] overflow-visible ${MODEL_SELECTOR_POPOVER_CLASS}`}
|
|
1557
|
+
style={MODEL_SELECTOR_POPOVER_STYLE}
|
|
1558
|
+
>
|
|
1559
|
+
<Popover open={detailSection !== null} onOpenChange={() => undefined}>
|
|
1560
|
+
<PopoverAnchor asChild>
|
|
1561
|
+
<div
|
|
1562
|
+
className="flex flex-col"
|
|
1563
|
+
role="tablist"
|
|
1564
|
+
aria-label={t("agentChat.composer.pickerSections", {
|
|
1565
|
+
defaultValue: "Picker sections",
|
|
1566
|
+
})}
|
|
1567
|
+
>
|
|
1568
|
+
{agents && agents.length > 0 && (
|
|
1569
|
+
<button
|
|
1570
|
+
type="button"
|
|
1571
|
+
role="tab"
|
|
1572
|
+
aria-selected={resolvedSection === "agent"}
|
|
1573
|
+
onClick={() => setDetailSection("agent")}
|
|
1574
|
+
onMouseEnter={() => setDetailSection("agent")}
|
|
1575
|
+
className={`flex w-full min-w-0 items-center gap-1 rounded-md px-2 py-2 text-start transition-colors ${
|
|
1576
|
+
resolvedSection === "agent"
|
|
1577
|
+
? "bg-accent text-foreground"
|
|
1578
|
+
: "text-muted-foreground hover:bg-accent/50 hover:text-foreground"
|
|
1579
|
+
}`}
|
|
1580
|
+
>
|
|
1581
|
+
<span className="flex min-w-0 items-center">
|
|
1582
|
+
<span className="shrink-0 text-[12px] font-medium">
|
|
1583
|
+
Agent
|
|
1584
|
+
</span>
|
|
1585
|
+
<Tooltip>
|
|
1586
|
+
<TooltipTrigger asChild>
|
|
1587
|
+
<span
|
|
1588
|
+
role="img"
|
|
1589
|
+
aria-label={t("agentChat.composer.harnessAgentHelp", {
|
|
1590
|
+
defaultValue: "Learn about harness agents",
|
|
1591
|
+
})}
|
|
1592
|
+
onClick={(event) => event.stopPropagation()}
|
|
1593
|
+
className={`ms-1.5 ${PICKER_HELP_BUTTON_CLASS}`}
|
|
1594
|
+
>
|
|
1595
|
+
<IconHelpCircle
|
|
1596
|
+
aria-hidden="true"
|
|
1597
|
+
className={PICKER_HELP_ICON_CLASS}
|
|
1598
|
+
strokeWidth={1.8}
|
|
1599
|
+
/>
|
|
1600
|
+
</span>
|
|
1601
|
+
</TooltipTrigger>
|
|
1602
|
+
<TooltipContent side="right" className="z-[400] max-w-xs">
|
|
1603
|
+
<span className="block">
|
|
1604
|
+
{hostedHarness
|
|
1605
|
+
? t("agentChat.composer.hostedHarnessDescription", {
|
|
1606
|
+
defaultValue:
|
|
1607
|
+
"Hosted mode uses app tools only. For full coding with a repository and shell, use Agent Native Desktop.",
|
|
1608
|
+
})
|
|
1609
|
+
: t("agentChat.composer.harnessAgentDescription", {
|
|
1610
|
+
defaultValue:
|
|
1611
|
+
"Harnesses run their own coding loop and local tools.",
|
|
1612
|
+
})}
|
|
1613
|
+
</span>
|
|
1614
|
+
<a
|
|
1615
|
+
href={HARNESS_AGENTS_DOCS_URL}
|
|
1616
|
+
target="_blank"
|
|
1617
|
+
rel="noreferrer"
|
|
1618
|
+
className="mt-1 block underline underline-offset-2 hover:no-underline"
|
|
1619
|
+
>
|
|
1620
|
+
{t("agentChat.composer.learnMoreHarnessAgents", {
|
|
1621
|
+
defaultValue: "Learn more about harness agents",
|
|
1622
|
+
})}
|
|
1623
|
+
</a>
|
|
1624
|
+
</TooltipContent>
|
|
1625
|
+
</Tooltip>
|
|
1626
|
+
</span>
|
|
1627
|
+
<span className="ms-auto min-w-0 max-w-[6rem] truncate text-end text-[11px] text-muted-foreground/80">
|
|
1628
|
+
{selectedAgentLabel}
|
|
1629
|
+
</span>
|
|
1630
|
+
<IconChevronRight className="h-3 w-3 shrink-0 opacity-60 rtl:-scale-x-100" />
|
|
1631
|
+
</button>
|
|
1632
|
+
)}
|
|
1633
|
+
{!agentOnly && (
|
|
1634
|
+
<button
|
|
1635
|
+
type="button"
|
|
1636
|
+
role="tab"
|
|
1637
|
+
aria-selected={resolvedSection === "model"}
|
|
1638
|
+
onClick={() => setDetailSection("model")}
|
|
1639
|
+
onMouseEnter={() => setDetailSection("model")}
|
|
1640
|
+
className={`flex w-full min-w-0 items-center gap-1 rounded-md px-2 py-2 text-start transition-colors ${
|
|
1641
|
+
resolvedSection === "model"
|
|
1642
|
+
? "bg-accent text-foreground"
|
|
1643
|
+
: "text-muted-foreground hover:bg-accent/50 hover:text-foreground"
|
|
1644
|
+
}`}
|
|
1645
|
+
>
|
|
1646
|
+
<span className="shrink-0 text-[12px] font-medium">
|
|
1647
|
+
Model
|
|
1648
|
+
</span>
|
|
1649
|
+
<span className="ms-auto min-w-0 max-w-[6rem] truncate text-end text-[11px] text-muted-foreground/80">
|
|
1650
|
+
{selectedModelLabel}
|
|
1651
|
+
</span>
|
|
1652
|
+
<IconChevronRight className="h-3 w-3 shrink-0 opacity-60 rtl:-scale-x-100" />
|
|
1653
|
+
</button>
|
|
1654
|
+
)}
|
|
1655
|
+
{!agentOnly && effortOptions.length > 0 && (
|
|
1656
|
+
<button
|
|
1657
|
+
type="button"
|
|
1658
|
+
role="tab"
|
|
1659
|
+
aria-selected={resolvedSection === "effort"}
|
|
1660
|
+
onClick={() => setDetailSection("effort")}
|
|
1661
|
+
onMouseEnter={() => setDetailSection("effort")}
|
|
1662
|
+
className={`flex w-full min-w-0 items-center gap-1 rounded-md px-2 py-2 text-start transition-colors ${
|
|
1663
|
+
resolvedSection === "effort"
|
|
1664
|
+
? "bg-accent text-foreground"
|
|
1665
|
+
: "text-muted-foreground hover:bg-accent/50 hover:text-foreground"
|
|
1666
|
+
}`}
|
|
1667
|
+
>
|
|
1668
|
+
<span className="shrink-0 text-[12px] font-medium">
|
|
1669
|
+
{t("agentChat.composer.effort", {
|
|
1670
|
+
defaultValue: "Effort",
|
|
1671
|
+
})}
|
|
1672
|
+
</span>
|
|
1673
|
+
<span className="ms-auto min-w-0 max-w-[6rem] truncate text-end text-[11px] text-muted-foreground/80">
|
|
1674
|
+
{effortLabel(selectedEffort)}
|
|
1675
|
+
</span>
|
|
1676
|
+
<IconChevronRight className="h-3 w-3 shrink-0 opacity-60 rtl:-scale-x-100" />
|
|
1677
|
+
</button>
|
|
1678
|
+
)}
|
|
1679
|
+
</div>
|
|
1680
|
+
</PopoverAnchor>
|
|
1681
|
+
<PopoverContent
|
|
1682
|
+
side="right"
|
|
1683
|
+
align="start"
|
|
1684
|
+
sideOffset={4}
|
|
1685
|
+
alignOffset={-8}
|
|
1686
|
+
collisionPadding={8}
|
|
1687
|
+
className={`z-[320] overflow-visible ${MODEL_SELECTOR_POPOVER_CLASS}`}
|
|
1688
|
+
style={MODEL_SELECTOR_POPOVER_STYLE}
|
|
1689
|
+
>
|
|
1690
|
+
<div className="max-h-[min(500px,var(--radix-popover-content-available-height,500px))] overflow-y-auto">
|
|
1691
|
+
<div
|
|
1692
|
+
className="min-h-0 min-w-0"
|
|
1693
|
+
role="tabpanel"
|
|
1694
|
+
aria-label={resolvedSection}
|
|
1695
|
+
>
|
|
1696
|
+
{resolvedSection === "agent" && agents && (
|
|
1697
|
+
<div className="flex flex-col">
|
|
1698
|
+
{agents.map((agent) => {
|
|
1699
|
+
const isSelected =
|
|
1700
|
+
agent.id === (selectedAgent ?? "default");
|
|
1701
|
+
const isConfigured = agent.configured !== false;
|
|
1702
|
+
const canConnect =
|
|
1703
|
+
!isConfigured && Boolean(onConnectLocalRuntime);
|
|
1704
|
+
const statusLabel =
|
|
1705
|
+
agent.statusLabel ??
|
|
1706
|
+
(!isConfigured ? "Unavailable" : undefined);
|
|
1707
|
+
return (
|
|
1708
|
+
<div
|
|
1709
|
+
key={agent.id}
|
|
1710
|
+
className="group flex items-center rounded-md hover:bg-accent/30"
|
|
1711
|
+
>
|
|
1712
|
+
<button
|
|
1713
|
+
type="button"
|
|
1714
|
+
disabled={!isConfigured || !onAgentChange}
|
|
1715
|
+
aria-current={isSelected ? "true" : undefined}
|
|
1716
|
+
onClick={() => {
|
|
1717
|
+
if (!isConfigured) return;
|
|
1718
|
+
onAgentChange?.(agent.id);
|
|
1719
|
+
setPickerOpen(false);
|
|
1720
|
+
}}
|
|
1721
|
+
className={`flex min-w-0 flex-1 items-center gap-0.5 px-2 py-2 text-start ${
|
|
1722
|
+
isConfigured
|
|
1723
|
+
? "hover:bg-accent/50"
|
|
1724
|
+
: "cursor-default opacity-50"
|
|
1725
|
+
}`}
|
|
1726
|
+
>
|
|
1727
|
+
{agent.icon ? (
|
|
1728
|
+
<span
|
|
1729
|
+
className="flex size-4 shrink-0 items-center justify-center text-muted-foreground"
|
|
1730
|
+
aria-hidden="true"
|
|
1731
|
+
>
|
|
1732
|
+
{agent.icon}
|
|
1733
|
+
</span>
|
|
1734
|
+
) : null}
|
|
1735
|
+
<span
|
|
1736
|
+
className={`min-w-0 truncate text-[12px] ${
|
|
1737
|
+
isSelected
|
|
1738
|
+
? "text-foreground"
|
|
1739
|
+
: "text-muted-foreground"
|
|
1740
|
+
}`}
|
|
1741
|
+
>
|
|
1742
|
+
{agent.label}
|
|
1743
|
+
</span>
|
|
1744
|
+
{agent.description && (
|
|
1745
|
+
<Tooltip>
|
|
1746
|
+
<TooltipTrigger asChild>
|
|
1747
|
+
<span
|
|
1748
|
+
role="img"
|
|
1749
|
+
aria-label={`${agent.label} details`}
|
|
1750
|
+
onClick={(event) => event.stopPropagation()}
|
|
1751
|
+
className={PICKER_HELP_BUTTON_CLASS}
|
|
1752
|
+
>
|
|
1753
|
+
<IconHelpCircle
|
|
1754
|
+
aria-hidden="true"
|
|
1755
|
+
className={PICKER_HELP_ICON_CLASS}
|
|
1756
|
+
strokeWidth={1.8}
|
|
1757
|
+
/>
|
|
1758
|
+
</span>
|
|
1759
|
+
</TooltipTrigger>
|
|
1760
|
+
<TooltipContent
|
|
1761
|
+
side="left"
|
|
1762
|
+
className="z-[400] max-w-xs"
|
|
1763
|
+
>
|
|
1764
|
+
{agent.description}
|
|
1765
|
+
</TooltipContent>
|
|
1766
|
+
</Tooltip>
|
|
1767
|
+
)}
|
|
1768
|
+
<span
|
|
1769
|
+
className="min-w-0 flex-1"
|
|
1770
|
+
aria-hidden="true"
|
|
1771
|
+
/>
|
|
1772
|
+
{isSelected && isConfigured && (
|
|
1773
|
+
<IconCheck className="size-4 shrink-0 text-primary" />
|
|
1774
|
+
)}
|
|
1775
|
+
</button>
|
|
1776
|
+
{!isConfigured && statusLabel && (
|
|
1777
|
+
<button
|
|
1778
|
+
type="button"
|
|
1779
|
+
disabled={!canConnect}
|
|
1780
|
+
className="ms-auto max-w-[6rem] shrink-0 truncate px-2 py-2 text-end text-[10px] text-muted-foreground/70 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 hover:text-foreground focus-visible:opacity-100 disabled:cursor-default"
|
|
1781
|
+
onClick={() => {
|
|
1782
|
+
if (canConnect) connectLocalRuntime(agent.id);
|
|
1783
|
+
}}
|
|
1784
|
+
>
|
|
1785
|
+
{statusLabel}
|
|
1786
|
+
</button>
|
|
1787
|
+
)}
|
|
1788
|
+
</div>
|
|
1789
|
+
);
|
|
1790
|
+
})}
|
|
1791
|
+
</div>
|
|
1792
|
+
)}
|
|
1793
|
+
{resolvedSection === "model" && (
|
|
1794
|
+
<>
|
|
1795
|
+
{showProviderActions && (
|
|
1796
|
+
<>
|
|
1797
|
+
{showBuilderAction && (
|
|
1798
|
+
<>
|
|
1799
|
+
<button
|
|
1800
|
+
type="button"
|
|
1801
|
+
onClick={() => {
|
|
1802
|
+
if (onConnectProvider) {
|
|
1803
|
+
onConnectProvider();
|
|
1804
|
+
} else {
|
|
1805
|
+
builderFlow.start();
|
|
1806
|
+
}
|
|
1807
|
+
}}
|
|
1808
|
+
disabled={
|
|
1809
|
+
!onConnectProvider && builderFlow.connecting
|
|
1810
|
+
}
|
|
1811
|
+
className="flex w-full items-start gap-2 rounded-md px-2 py-2 text-start hover:bg-accent/50 disabled:opacity-60"
|
|
1812
|
+
>
|
|
1813
|
+
<IconPlugConnected className="mt-0.5 h-4 w-4 shrink-0 text-primary" />
|
|
1814
|
+
<span className="min-w-0 flex-1">
|
|
1815
|
+
<span className="block text-[12px] font-medium text-foreground">
|
|
1816
|
+
{!onConnectProvider && builderFlow.connecting
|
|
1817
|
+
? t("agentPanel.connectingBuilder", {
|
|
1818
|
+
defaultValue: "Connecting Builder.io…",
|
|
1819
|
+
})
|
|
1820
|
+
: t("agentPanel.connectBuilderIo", {
|
|
1821
|
+
defaultValue: "Connect Builder.io",
|
|
1822
|
+
})}
|
|
1823
|
+
</span>
|
|
1824
|
+
<span className="block text-[11px] text-muted-foreground">
|
|
1825
|
+
{t("agentPanel.builderModelCredits", {
|
|
1826
|
+
defaultValue:
|
|
1827
|
+
"Free credits for Claude, OpenAI & Gemini",
|
|
1828
|
+
})}
|
|
1829
|
+
</span>
|
|
1830
|
+
</span>
|
|
1831
|
+
</button>
|
|
1832
|
+
{!onConnectProvider && builderFlow.error && (
|
|
1833
|
+
<p
|
|
1834
|
+
role="alert"
|
|
1835
|
+
className="px-2 pb-2 ps-8 text-[11px] text-destructive"
|
|
1836
|
+
>
|
|
1837
|
+
{builderFlow.error}
|
|
1838
|
+
</p>
|
|
1839
|
+
)}
|
|
1840
|
+
</>
|
|
1841
|
+
)}
|
|
1842
|
+
{showAddKeysAction && (
|
|
1843
|
+
<button
|
|
1844
|
+
type="button"
|
|
1845
|
+
onClick={openLlmSettings}
|
|
1846
|
+
className="flex w-full items-start gap-2 rounded-md px-2 py-2 text-start hover:bg-accent/50"
|
|
1847
|
+
>
|
|
1848
|
+
<IconKey className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" />
|
|
1849
|
+
<span className="min-w-0 flex-1">
|
|
1850
|
+
<span className="block text-[12px] font-medium text-foreground">
|
|
1851
|
+
{t("agentPanel.addOwnKeys", {
|
|
1852
|
+
defaultValue: "Add your own keys",
|
|
1853
|
+
})}
|
|
1854
|
+
</span>
|
|
1855
|
+
<span className="block text-[11px] text-muted-foreground">
|
|
1856
|
+
{t("agentPanel.configureProviderKeys", {
|
|
1857
|
+
defaultValue:
|
|
1858
|
+
"Choose a cloud, gateway, or local provider",
|
|
1859
|
+
})}
|
|
1860
|
+
</span>
|
|
1861
|
+
</span>
|
|
1862
|
+
</button>
|
|
1863
|
+
)}
|
|
1864
|
+
</>
|
|
1865
|
+
)}
|
|
1866
|
+
{imageModel && imageModel.options.length > 0 && (
|
|
1867
|
+
<div className="mt-2 pt-1">
|
|
1868
|
+
<div className="px-2 py-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground">
|
|
1869
|
+
{imageModel.label ??
|
|
1870
|
+
t("agentChat.composer.imageModel", {
|
|
1871
|
+
defaultValue: "Image model",
|
|
1872
|
+
})}
|
|
1873
|
+
</div>
|
|
1874
|
+
{imageModel.options.map((option) => (
|
|
1875
|
+
<button
|
|
1876
|
+
key={option.value}
|
|
1877
|
+
type="button"
|
|
1878
|
+
onClick={() => {
|
|
1879
|
+
imageModel.onChange(option.value);
|
|
1880
|
+
setPickerOpen(false);
|
|
1881
|
+
}}
|
|
1882
|
+
className="flex w-full items-center gap-3 rounded-md px-2 py-2 text-start hover:bg-accent/50"
|
|
1883
|
+
>
|
|
1884
|
+
<span
|
|
1885
|
+
className={`min-w-0 flex-1 truncate text-[12px] ${
|
|
1886
|
+
option.value === imageModel.value
|
|
1887
|
+
? "text-foreground"
|
|
1888
|
+
: "text-muted-foreground"
|
|
1889
|
+
}`}
|
|
1890
|
+
>
|
|
1891
|
+
{option.label}
|
|
1892
|
+
</span>
|
|
1893
|
+
{option.value === imageModel.value && (
|
|
1894
|
+
<IconCheck className="size-4 shrink-0 text-primary" />
|
|
1895
|
+
)}
|
|
1896
|
+
</button>
|
|
1897
|
+
))}
|
|
1898
|
+
</div>
|
|
1899
|
+
)}
|
|
1900
|
+
{showModelListSkeleton && <ModelSelectorSkeleton />}
|
|
1901
|
+
{isCodexAgent &&
|
|
1902
|
+
!showModelListSkeleton &&
|
|
1903
|
+
!onlyConnectPathAvailable &&
|
|
1904
|
+
modelProviderGroups.length === 0 && (
|
|
1905
|
+
<button
|
|
1906
|
+
type="button"
|
|
1907
|
+
onClick={openLlmSettings}
|
|
1908
|
+
className="flex w-full items-center rounded-md px-2 py-2 text-start hover:bg-accent/50"
|
|
1909
|
+
>
|
|
1910
|
+
<span className="min-w-0 flex-1 truncate text-[12px] text-muted-foreground">
|
|
1911
|
+
{t("agentChat.composer.noOpenAiModels", {
|
|
1912
|
+
defaultValue: "No OpenAI models configured",
|
|
1913
|
+
})}
|
|
1914
|
+
</span>
|
|
1915
|
+
<span className="shrink-0 text-[11px] text-muted-foreground/70">
|
|
1916
|
+
Configure
|
|
1917
|
+
</span>
|
|
1918
|
+
</button>
|
|
1919
|
+
)}
|
|
1920
|
+
{autoModelGroup && !onlyConnectPathAvailable && (
|
|
1921
|
+
<button
|
|
1922
|
+
type="button"
|
|
1923
|
+
onClick={() => {
|
|
1924
|
+
onChange("auto", autoModelGroup.engine);
|
|
1925
|
+
setPickerOpen(false);
|
|
1926
|
+
}}
|
|
1927
|
+
className="mt-1 flex w-full items-center gap-3 rounded-md px-2 py-1.5 text-start hover:bg-accent/50"
|
|
1928
|
+
>
|
|
1929
|
+
<span
|
|
1930
|
+
className={`min-w-0 flex-1 truncate text-[13px] ${
|
|
1931
|
+
model === "auto"
|
|
1932
|
+
? "text-foreground"
|
|
1933
|
+
: "text-muted-foreground"
|
|
1934
|
+
}`}
|
|
1935
|
+
>
|
|
1936
|
+
{t("agentChat.composer.auto", {
|
|
1937
|
+
defaultValue: "Auto",
|
|
1938
|
+
})}
|
|
1939
|
+
</span>
|
|
1940
|
+
{model === "auto" && (
|
|
1941
|
+
<IconCheck className="size-4 shrink-0 text-primary" />
|
|
1942
|
+
)}
|
|
1943
|
+
</button>
|
|
1944
|
+
)}
|
|
1945
|
+
{!onlyConnectPathAvailable &&
|
|
1946
|
+
visibleProviderGroups.map((group, groupIndex) => {
|
|
1947
|
+
const models = latestModelsOnly(group.models);
|
|
1948
|
+
const showProviderLabels =
|
|
1949
|
+
visibleProviderGroups.length > 1;
|
|
1950
|
+
const isLocalRuntime =
|
|
1951
|
+
group.engine === "codex-cli" ||
|
|
1952
|
+
group.engine === "claude-cli";
|
|
1953
|
+
const canConnectLocalRuntime =
|
|
1954
|
+
isLocalRuntime && Boolean(onConnectLocalRuntime);
|
|
1955
|
+
const statusLabel =
|
|
1956
|
+
group.statusLabel ??
|
|
1957
|
+
(!group.configured
|
|
1958
|
+
? canConnectLocalRuntime
|
|
1959
|
+
? t("agentChat.auth.logIn", {
|
|
1960
|
+
defaultValue: "Sign in",
|
|
1961
|
+
})
|
|
1962
|
+
: t("agentChat.composer.needsApiKey", {
|
|
1963
|
+
defaultValue: "needs API key",
|
|
1964
|
+
})
|
|
1965
|
+
: undefined);
|
|
1966
|
+
return (
|
|
1967
|
+
<div
|
|
1968
|
+
key={`${group.engine}:${group.label}`}
|
|
1969
|
+
className={
|
|
1970
|
+
showProviderLabels && groupIndex > 0
|
|
1971
|
+
? "mt-2 pt-1"
|
|
1972
|
+
: ""
|
|
1973
|
+
}
|
|
1974
|
+
>
|
|
1975
|
+
{showProviderLabels && (
|
|
1976
|
+
<div className="group flex items-center px-2 py-1">
|
|
1977
|
+
<span className="shrink-0 text-[11px] font-medium uppercase tracking-wide text-muted-foreground">
|
|
1978
|
+
{group.label}
|
|
1979
|
+
</span>
|
|
1980
|
+
{!group.configured && statusLabel && (
|
|
1981
|
+
<button
|
|
1982
|
+
type="button"
|
|
1983
|
+
aria-label={statusLabel}
|
|
1984
|
+
className="ms-auto max-w-[9rem] shrink-0 cursor-pointer truncate px-0 py-1 text-end text-[10px] text-muted-foreground/60 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 hover:text-foreground focus-visible:opacity-100"
|
|
1985
|
+
onClick={() =>
|
|
1986
|
+
canConnectLocalRuntime
|
|
1987
|
+
? connectLocalRuntime(group.engine)
|
|
1988
|
+
: openLlmSettings()
|
|
1989
|
+
}
|
|
1990
|
+
>
|
|
1991
|
+
{statusLabel}
|
|
1992
|
+
</button>
|
|
1993
|
+
)}
|
|
1994
|
+
{group.configured && statusLabel && (
|
|
1995
|
+
<span className="ms-auto max-w-[9rem] shrink-0 truncate py-1 text-end text-[10px] text-muted-foreground/70 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100">
|
|
1996
|
+
{statusLabel}
|
|
1997
|
+
</span>
|
|
1998
|
+
)}
|
|
1999
|
+
</div>
|
|
2000
|
+
)}
|
|
2001
|
+
{models.map((m) => {
|
|
2002
|
+
const isSelected =
|
|
2003
|
+
m === model && group.configured;
|
|
2004
|
+
return (
|
|
2005
|
+
<button
|
|
2006
|
+
key={m}
|
|
2007
|
+
type="button"
|
|
2008
|
+
onClick={() => {
|
|
2009
|
+
if (!group.configured) {
|
|
2010
|
+
if (canConnectLocalRuntime) {
|
|
2011
|
+
connectLocalRuntime(group.engine);
|
|
2012
|
+
} else {
|
|
2013
|
+
openLlmSettings();
|
|
2014
|
+
}
|
|
2015
|
+
return;
|
|
2016
|
+
}
|
|
2017
|
+
onChange(m, group.engine);
|
|
2018
|
+
const nextOptions =
|
|
2019
|
+
getReasoningEffortOptionsForModel(m);
|
|
2020
|
+
if (
|
|
2021
|
+
nextOptions.length > 0 &&
|
|
2022
|
+
!nextOptions.includes(selectedEffort)
|
|
2023
|
+
) {
|
|
2024
|
+
onEffortChange?.(defaultEffort);
|
|
2025
|
+
}
|
|
2026
|
+
setPickerOpen(false);
|
|
2027
|
+
}}
|
|
2028
|
+
className={`group flex w-full items-center gap-3 rounded-md px-2 py-2 text-start ${
|
|
2029
|
+
group.configured
|
|
2030
|
+
? "hover:bg-accent/50"
|
|
2031
|
+
: "cursor-default opacity-40"
|
|
2032
|
+
}`}
|
|
2033
|
+
>
|
|
2034
|
+
<span
|
|
2035
|
+
className={`min-w-0 flex-1 truncate text-[12px] ${
|
|
2036
|
+
isSelected
|
|
2037
|
+
? "text-foreground"
|
|
2038
|
+
: "text-muted-foreground"
|
|
2039
|
+
}`}
|
|
2040
|
+
>
|
|
2041
|
+
{friendlyModelName(m, t)}
|
|
2042
|
+
</span>
|
|
2043
|
+
<ModelCostTier model={m} />
|
|
2044
|
+
{!showProviderLabels && statusLabel && (
|
|
2045
|
+
<span className="hidden max-w-[9rem] shrink-0 truncate text-[10px] text-muted-foreground/70 group-hover:inline">
|
|
2046
|
+
{statusLabel}
|
|
2047
|
+
</span>
|
|
2048
|
+
)}
|
|
2049
|
+
{isSelected && (
|
|
2050
|
+
<IconCheck className="size-4 shrink-0 text-primary" />
|
|
2051
|
+
)}
|
|
2052
|
+
</button>
|
|
2053
|
+
);
|
|
2054
|
+
})}
|
|
2055
|
+
</div>
|
|
2056
|
+
);
|
|
2057
|
+
})}
|
|
2058
|
+
</>
|
|
2059
|
+
)}
|
|
2060
|
+
{resolvedSection === "effort" && effortOptions.length > 0 && (
|
|
2061
|
+
<div className="flex flex-col">
|
|
2062
|
+
{effortOptions.map((option) => (
|
|
2063
|
+
<button
|
|
2064
|
+
key={option}
|
|
2065
|
+
type="button"
|
|
2066
|
+
onClick={() => onEffortChange?.(option)}
|
|
2067
|
+
className="flex w-full items-center gap-3 rounded-md px-2 py-2 text-start hover:bg-accent/50"
|
|
2068
|
+
>
|
|
2069
|
+
<span
|
|
2070
|
+
className={`min-w-0 flex-1 truncate text-[12px] ${
|
|
2071
|
+
option === selectedEffort
|
|
2072
|
+
? "text-foreground"
|
|
2073
|
+
: "text-muted-foreground"
|
|
2074
|
+
}`}
|
|
2075
|
+
>
|
|
2076
|
+
{effortLabel(option)}
|
|
2077
|
+
</span>
|
|
2078
|
+
{option === selectedEffort && (
|
|
2079
|
+
<IconCheck className="size-4 shrink-0 text-primary" />
|
|
2080
|
+
)}
|
|
2081
|
+
</button>
|
|
2082
|
+
))}
|
|
2083
|
+
</div>
|
|
2084
|
+
)}
|
|
2085
|
+
</div>
|
|
2086
|
+
</div>
|
|
2087
|
+
</PopoverContent>
|
|
2088
|
+
</Popover>
|
|
2089
|
+
</PopoverContent>
|
|
2090
|
+
</Popover>
|
|
2091
|
+
);
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
function ModelSelectorSkeleton() {
|
|
2095
|
+
const t = useComposerRuntimeAdapters().translate!;
|
|
2096
|
+
return (
|
|
2097
|
+
<div
|
|
2098
|
+
className="space-y-1 px-2 py-2"
|
|
2099
|
+
role="status"
|
|
2100
|
+
aria-label={t("agentChat.composer.loadingModels", {
|
|
2101
|
+
defaultValue: "Loading models",
|
|
2102
|
+
})}
|
|
2103
|
+
>
|
|
2104
|
+
<span className="sr-only">
|
|
2105
|
+
{t("agentChat.composer.loadingModelsProgress", {
|
|
2106
|
+
defaultValue: "Loading models…",
|
|
2107
|
+
})}
|
|
2108
|
+
</span>
|
|
2109
|
+
{["w-24", "w-32", "w-20", "w-28"].map((width, index) => (
|
|
2110
|
+
<div key={index} className="flex items-center gap-1.5 px-1 py-1.5">
|
|
2111
|
+
<Skeleton className="size-3 rounded-sm" />
|
|
2112
|
+
<Skeleton className={`h-3 ${width}`} />
|
|
2113
|
+
</div>
|
|
2114
|
+
))}
|
|
2115
|
+
</div>
|
|
2116
|
+
);
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
type PopoverState = {
|
|
2120
|
+
type: "@" | "/";
|
|
2121
|
+
position: { top: number; left: number };
|
|
2122
|
+
startPos: number;
|
|
2123
|
+
query: string;
|
|
2124
|
+
} | null;
|
|
2125
|
+
|
|
2126
|
+
export function TiptapComposer({
|
|
2127
|
+
placeholder,
|
|
2128
|
+
disabled = false,
|
|
2129
|
+
maxDocumentAttachmentBytes = MAX_DOCUMENT_ATTACHMENT_BYTES,
|
|
2130
|
+
documentAttachmentLimitLabel = "PDFs",
|
|
2131
|
+
focusRef,
|
|
2132
|
+
initialText,
|
|
2133
|
+
initialTextKey,
|
|
2134
|
+
onSubmit,
|
|
2135
|
+
onBeforeSubmit,
|
|
2136
|
+
clearOnSubmit = true,
|
|
2137
|
+
onTextChange,
|
|
2138
|
+
actionButton,
|
|
2139
|
+
willQueue = false,
|
|
2140
|
+
extraActionButton,
|
|
2141
|
+
stopButton,
|
|
2142
|
+
attachButton,
|
|
2143
|
+
modeControl,
|
|
2144
|
+
toolbarSlot,
|
|
2145
|
+
layoutVariant = "default",
|
|
2146
|
+
slashCommands = [],
|
|
2147
|
+
slashSkills = [],
|
|
2148
|
+
includeDefaultSlashCommands = true,
|
|
2149
|
+
includeDefaultSlashSkills = true,
|
|
2150
|
+
onSlashCommand,
|
|
2151
|
+
execMode,
|
|
2152
|
+
onExecModeChange,
|
|
2153
|
+
planModeDisabled = false,
|
|
2154
|
+
planModeDisabledReason,
|
|
2155
|
+
voiceEnabled = DEFAULT_VOICE_DICTATION_ENABLED,
|
|
2156
|
+
selectedModel,
|
|
2157
|
+
selectedEffort,
|
|
2158
|
+
showAutoModelOption = true,
|
|
2159
|
+
modelSelectorOpen,
|
|
2160
|
+
availableModels,
|
|
2161
|
+
modelListLoading,
|
|
2162
|
+
onModelChange,
|
|
2163
|
+
onEffortChange,
|
|
2164
|
+
availableAgents,
|
|
2165
|
+
selectedAgent,
|
|
2166
|
+
agentOnly = false,
|
|
2167
|
+
hostedHarness,
|
|
2168
|
+
onAgentChange,
|
|
2169
|
+
onModelSelectorOpenChange,
|
|
2170
|
+
providerConnectStatusEnabled,
|
|
2171
|
+
onConnectProvider,
|
|
2172
|
+
onConnectLocalRuntime,
|
|
2173
|
+
imageModelMenu,
|
|
2174
|
+
draftScope,
|
|
2175
|
+
contextItems = [],
|
|
2176
|
+
onRemoveContextItem,
|
|
2177
|
+
plusMenuMode = "full",
|
|
2178
|
+
terminalModeControl,
|
|
2179
|
+
extensionTools = false,
|
|
2180
|
+
interceptBuildRequestsForBuilder = false,
|
|
2181
|
+
onAttachmentError,
|
|
2182
|
+
}: TiptapComposerProps) {
|
|
2183
|
+
const adapters = useComposerRuntimeAdapters();
|
|
2184
|
+
const t = adapters.translate!;
|
|
2185
|
+
const sendButtonTooltip = t(getComposerSendTooltipKey(willQueue), {
|
|
2186
|
+
defaultValue: willQueue ? "Queue message" : "Send message",
|
|
2187
|
+
});
|
|
2188
|
+
const [popover, setPopover] = useState<PopoverState>(null);
|
|
2189
|
+
const popoverRef = useRef<MentionPopoverRef>(null);
|
|
2190
|
+
const composerRuntime = useComposerRuntime();
|
|
2191
|
+
const lastComposerRuntimeSyncRef = useRef<{
|
|
2192
|
+
text: string;
|
|
2193
|
+
runConfigSignature: string;
|
|
2194
|
+
} | null>(null);
|
|
2195
|
+
const submitInFlightRef = useRef(false);
|
|
2196
|
+
const [editorHasText, setEditorHasText] = useState(false);
|
|
2197
|
+
const [slotReferences, setSlotReferences] = useState<
|
|
2198
|
+
AgentComposerReference[]
|
|
2199
|
+
>([]);
|
|
2200
|
+
const [selectedContextItemKey, setSelectedContextItemKey] = useState<
|
|
2201
|
+
string | null
|
|
2202
|
+
>(null);
|
|
2203
|
+
const composerText = useComposer((state) => state.text);
|
|
2204
|
+
const composerAttachments = useComposer((state) => state.attachments);
|
|
2205
|
+
const canSend = canSubmitComposerContent({
|
|
2206
|
+
hasEditorContent: editorHasText || slotReferences.length > 0,
|
|
2207
|
+
attachmentCount: composerAttachments.length,
|
|
2208
|
+
disabled,
|
|
2209
|
+
});
|
|
2210
|
+
const primaryAction = resolveComposerPrimaryAction({
|
|
2211
|
+
canSubmit: canSend,
|
|
2212
|
+
hasStopButton: Boolean(stopButton),
|
|
2213
|
+
});
|
|
2214
|
+
const hasContextRows = contextItems.length > 0 || slotReferences.length > 0;
|
|
2215
|
+
const [composerMode, setComposerMode] = useState<ComposerMode | null>(null);
|
|
2216
|
+
const composerModeRef = useRef<ComposerMode | null>(null);
|
|
2217
|
+
const isMac =
|
|
2218
|
+
typeof navigator !== "undefined" &&
|
|
2219
|
+
/Mac|iPhone|iPad/.test(navigator.userAgent);
|
|
2220
|
+
|
|
2221
|
+
// Refs for values accessed in handleKeyDown (ProseMirror doesn't re-bind)
|
|
2222
|
+
const popoverStateRef = useRef<PopoverState>(null);
|
|
2223
|
+
const onAttachmentErrorRef = useRef(onAttachmentError);
|
|
2224
|
+
onAttachmentErrorRef.current = onAttachmentError;
|
|
2225
|
+
const execModeRef = useRef(execMode);
|
|
2226
|
+
execModeRef.current = execMode;
|
|
2227
|
+
const onExecModeChangeRef = useRef(onExecModeChange);
|
|
2228
|
+
onExecModeChangeRef.current = onExecModeChange;
|
|
2229
|
+
const planModeDisabledRef = useRef(planModeDisabled);
|
|
2230
|
+
planModeDisabledRef.current = planModeDisabled;
|
|
2231
|
+
|
|
2232
|
+
const { items: mentionItems, isLoading: mentionsLoading } = useMentionSearch(
|
|
2233
|
+
popover?.type === "@" ? popover.query : "",
|
|
2234
|
+
popover?.type === "@",
|
|
2235
|
+
);
|
|
2236
|
+
const filteredMentionItems = useMemo(
|
|
2237
|
+
() => filterMentionItemsForSlots(mentionItems, slotReferences),
|
|
2238
|
+
[mentionItems, slotReferences],
|
|
2239
|
+
);
|
|
2240
|
+
|
|
2241
|
+
const {
|
|
2242
|
+
skills,
|
|
2243
|
+
hint,
|
|
2244
|
+
isLoading: skillsLoading,
|
|
2245
|
+
} = useSkills(includeDefaultSlashSkills && popover?.type === "/");
|
|
2246
|
+
|
|
2247
|
+
const allSlashCommands = useMemo(
|
|
2248
|
+
() =>
|
|
2249
|
+
mergeSlashCommands([
|
|
2250
|
+
...(includeDefaultSlashCommands ? builtInCommands(t) : []),
|
|
2251
|
+
...slashCommands,
|
|
2252
|
+
]),
|
|
2253
|
+
[includeDefaultSlashCommands, slashCommands, t],
|
|
2254
|
+
);
|
|
2255
|
+
|
|
2256
|
+
const allSlashSkills = useMemo(
|
|
2257
|
+
() =>
|
|
2258
|
+
mergeSlashSkills([
|
|
2259
|
+
...(includeDefaultSlashSkills ? skills : []),
|
|
2260
|
+
...slashSkills,
|
|
2261
|
+
]),
|
|
2262
|
+
[includeDefaultSlashSkills, skills, slashSkills],
|
|
2263
|
+
);
|
|
2264
|
+
|
|
2265
|
+
const filteredCommands = useMemo(() => {
|
|
2266
|
+
if (!popover || popover.type !== "/") return allSlashCommands;
|
|
2267
|
+
const q = popover.query.toLowerCase();
|
|
2268
|
+
if (!q) return allSlashCommands;
|
|
2269
|
+
return allSlashCommands.filter(
|
|
2270
|
+
(c) =>
|
|
2271
|
+
c.name.toLowerCase().includes(q) ||
|
|
2272
|
+
c.description.toLowerCase().includes(q),
|
|
2273
|
+
);
|
|
2274
|
+
}, [allSlashCommands, popover]);
|
|
2275
|
+
|
|
2276
|
+
const filteredSkills = useMemo(() => {
|
|
2277
|
+
if (!popover || popover.type !== "/") return allSlashSkills;
|
|
2278
|
+
const q = popover.query.toLowerCase();
|
|
2279
|
+
if (!q) return allSlashSkills;
|
|
2280
|
+
return allSlashSkills.filter(
|
|
2281
|
+
(s) =>
|
|
2282
|
+
s.name.toLowerCase().includes(q) ||
|
|
2283
|
+
s.description?.toLowerCase().includes(q),
|
|
2284
|
+
);
|
|
2285
|
+
}, [allSlashSkills, popover]);
|
|
2286
|
+
|
|
2287
|
+
// Keep refs in sync with state
|
|
2288
|
+
const mentionItemsRef = useRef(filteredMentionItems);
|
|
2289
|
+
mentionItemsRef.current = filteredMentionItems;
|
|
2290
|
+
const filteredCommandsRef = useRef(filteredCommands);
|
|
2291
|
+
filteredCommandsRef.current = filteredCommands;
|
|
2292
|
+
const filteredSkillsRef = useRef(filteredSkills);
|
|
2293
|
+
filteredSkillsRef.current = filteredSkills;
|
|
2294
|
+
const onSlashCommandRef = useRef(onSlashCommand);
|
|
2295
|
+
onSlashCommandRef.current = onSlashCommand;
|
|
2296
|
+
const onTextChangeRef = useRef(onTextChange);
|
|
2297
|
+
onTextChangeRef.current = onTextChange;
|
|
2298
|
+
const contextItemsRef = useRef(contextItems);
|
|
2299
|
+
contextItemsRef.current = contextItems;
|
|
2300
|
+
const onRemoveContextItemRef = useRef(onRemoveContextItem);
|
|
2301
|
+
onRemoveContextItemRef.current = onRemoveContextItem;
|
|
2302
|
+
const selectedContextItemKeyRef = useRef<string | null>(null);
|
|
2303
|
+
selectedContextItemKeyRef.current = selectedContextItemKey;
|
|
2304
|
+
const initialTextKeyRef = useRef<string | number | undefined>(undefined);
|
|
2305
|
+
const seenReferenceInsertIdsRef = useRef<Set<string>>(new Set());
|
|
2306
|
+
|
|
2307
|
+
useEffect(() => {
|
|
2308
|
+
if (
|
|
2309
|
+
selectedContextItemKey &&
|
|
2310
|
+
!contextItems.some((item) => item.key === selectedContextItemKey)
|
|
2311
|
+
) {
|
|
2312
|
+
selectedContextItemKeyRef.current = null;
|
|
2313
|
+
setSelectedContextItemKey(null);
|
|
2314
|
+
}
|
|
2315
|
+
}, [contextItems, selectedContextItemKey]);
|
|
2316
|
+
|
|
2317
|
+
const closePopover = useCallback(() => {
|
|
2318
|
+
setPopover(null);
|
|
2319
|
+
popoverStateRef.current = null;
|
|
2320
|
+
}, []);
|
|
2321
|
+
|
|
2322
|
+
// Persist draft to localStorage so hot-reloads don't lose the prompt
|
|
2323
|
+
const draftKey = getComposerDraftKey(draftScope);
|
|
2324
|
+
const draftTimerRef = useRef<ReturnType<typeof setTimeout>>(undefined);
|
|
2325
|
+
useEffect(() => {
|
|
2326
|
+
return () => {
|
|
2327
|
+
clearTimeout(draftTimerRef.current);
|
|
2328
|
+
};
|
|
2329
|
+
}, []);
|
|
2330
|
+
useEffect(() => {
|
|
2331
|
+
lastComposerRuntimeSyncRef.current = null;
|
|
2332
|
+
}, [composerRuntime]);
|
|
2333
|
+
// Tiptap reads extension config once at init; ref keeps runtime prop
|
|
2334
|
+
// changes visible to Placeholder's function form.
|
|
2335
|
+
const resolvedPlaceholder = composerMode
|
|
2336
|
+
? localizedComposerModeConfig(composerMode, t).placeholder
|
|
2337
|
+
: (placeholder ??
|
|
2338
|
+
t("agentChat.composer.messageAgent", {
|
|
2339
|
+
defaultValue: "Message agent...",
|
|
2340
|
+
}));
|
|
2341
|
+
const placeholderRef = useRef(resolvedPlaceholder);
|
|
2342
|
+
placeholderRef.current = resolvedPlaceholder;
|
|
2343
|
+
|
|
2344
|
+
const editor = useEditor({
|
|
2345
|
+
extensions: createTiptapComposerExtensions(() => placeholderRef.current),
|
|
2346
|
+
editable: !disabled,
|
|
2347
|
+
onCreate: ({ editor: ed }) => {
|
|
2348
|
+
// Restore draft on mount
|
|
2349
|
+
try {
|
|
2350
|
+
if (initialText !== undefined) {
|
|
2351
|
+
ed.commands.setContent(plainTextToDoc(initialText));
|
|
2352
|
+
ed.commands.focus("end");
|
|
2353
|
+
setEditorHasText(composerDocumentHasContent(ed.state.doc));
|
|
2354
|
+
initialTextKeyRef.current = initialTextKey ?? initialText;
|
|
2355
|
+
} else {
|
|
2356
|
+
const saved = localStorage.getItem(draftKey);
|
|
2357
|
+
if (saved) {
|
|
2358
|
+
ed.commands.setContent(saved);
|
|
2359
|
+
ed.commands.focus("end");
|
|
2360
|
+
setEditorHasText(composerDocumentHasContent(ed.state.doc));
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
onTextChangeRef.current?.(ed.state.doc.textContent.trim());
|
|
2364
|
+
} catch {}
|
|
2365
|
+
},
|
|
2366
|
+
onUpdate: ({ editor: ed }) => {
|
|
2367
|
+
// Drive the send button's enabled state from the actual editor contents;
|
|
2368
|
+
// the composer runtime is only synced on submit, so its isEmpty lags.
|
|
2369
|
+
setEditorHasText(composerDocumentHasContent(ed.state.doc));
|
|
2370
|
+
onTextChangeRef.current?.(ed.state.doc.textContent.trim());
|
|
2371
|
+
|
|
2372
|
+
// Debounce-save draft to localStorage
|
|
2373
|
+
clearTimeout(draftTimerRef.current);
|
|
2374
|
+
draftTimerRef.current = setTimeout(() => {
|
|
2375
|
+
try {
|
|
2376
|
+
const html = ed.getHTML();
|
|
2377
|
+
const isEmpty = !composerDocumentHasContent(ed.state.doc);
|
|
2378
|
+
if (isEmpty) {
|
|
2379
|
+
localStorage.removeItem(draftKey);
|
|
2380
|
+
} else {
|
|
2381
|
+
localStorage.setItem(draftKey, html);
|
|
2382
|
+
}
|
|
2383
|
+
} catch {}
|
|
2384
|
+
}, 300);
|
|
2385
|
+
},
|
|
2386
|
+
onSelectionUpdate: ({ editor: ed }) => {
|
|
2387
|
+
const { from, to } = ed.state.selection;
|
|
2388
|
+
if (selectedContextItemKeyRef.current && (from !== to || from > 1)) {
|
|
2389
|
+
selectedContextItemKeyRef.current = null;
|
|
2390
|
+
setSelectedContextItemKey(null);
|
|
2391
|
+
}
|
|
2392
|
+
},
|
|
2393
|
+
editorProps: {
|
|
2394
|
+
attributes: {
|
|
2395
|
+
"data-agent-composer-variant": layoutVariant,
|
|
2396
|
+
"data-agent-composer-slot": "editor-input",
|
|
2397
|
+
class:
|
|
2398
|
+
"agent-composer-prosemirror flex-1 resize-none bg-transparent text-sm text-foreground outline-none leading-[1.625rem] min-h-[3.25rem] max-h-[10rem] overflow-y-auto",
|
|
2399
|
+
},
|
|
2400
|
+
handlePaste: (_view, event) => {
|
|
2401
|
+
const paste = readClipboardPaste(event.clipboardData);
|
|
2402
|
+
const pastedText = paste.text;
|
|
2403
|
+
const files = Array.from(event.clipboardData?.files ?? []).filter(
|
|
2404
|
+
(file) => file.type.startsWith("image/"),
|
|
2405
|
+
);
|
|
2406
|
+
if (files.length > 0) {
|
|
2407
|
+
event.preventDefault();
|
|
2408
|
+
const attachments: File[] = files.map((file) => {
|
|
2409
|
+
// SimpleImageAttachmentAdapter uses file.name as the attachment id.
|
|
2410
|
+
// Clipboard images (e.g. screenshots) are typically all named
|
|
2411
|
+
// "image.png", so a second paste would replace the first instead of
|
|
2412
|
+
// appending. Prepend a unique token so each paste gets a distinct id.
|
|
2413
|
+
const uniqueName = `${Date.now()}-${Math.random().toString(36).slice(2)}-${file.name}`;
|
|
2414
|
+
return new File([file], uniqueName, { type: file.type });
|
|
2415
|
+
});
|
|
2416
|
+
|
|
2417
|
+
// Google Docs rich clipboard payloads can contain both embedded
|
|
2418
|
+
// image files and the document text. Since handling files means we
|
|
2419
|
+
// prevent Tiptap's default paste, preserve any text as its own chip
|
|
2420
|
+
// instead of silently dropping the source material.
|
|
2421
|
+
if (pastedText.trim()) {
|
|
2422
|
+
attachments.push(createPastedAttachmentFile(paste));
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
void Promise.all(
|
|
2426
|
+
attachments.map((file) => composerRuntime.addAttachment(file)),
|
|
2427
|
+
).catch((error) => {
|
|
2428
|
+
const msg =
|
|
2429
|
+
error instanceof Error
|
|
2430
|
+
? error.message
|
|
2431
|
+
: t("agentChat.composer.pastedImageError", {
|
|
2432
|
+
defaultValue:
|
|
2433
|
+
"Could not attach the pasted image. Try a different format.",
|
|
2434
|
+
});
|
|
2435
|
+
onAttachmentErrorRef.current?.(msg);
|
|
2436
|
+
});
|
|
2437
|
+
return true;
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
// Page-sized pastes turn into a `Pasted text` attachment chip so the
|
|
2441
|
+
// prompt stays readable while normal paragraphs and lists stay inline.
|
|
2442
|
+
// When the paste is HTML (e.g. an Alpine.js extension or a document the
|
|
2443
|
+
// user wants hosted), it's stored as a real .html attachment so it
|
|
2444
|
+
// travels the same rail as uploading that file — the agent reads it
|
|
2445
|
+
// verbatim via contentFromAttachment instead of retyping it inline,
|
|
2446
|
+
// which cuts off mid-stream on large files and triggers a spin.
|
|
2447
|
+
if (shouldConvertClipboardToAttachment(paste)) {
|
|
2448
|
+
event.preventDefault();
|
|
2449
|
+
void composerRuntime
|
|
2450
|
+
.addAttachment(createPastedAttachmentFile(paste))
|
|
2451
|
+
.catch((error) => {
|
|
2452
|
+
const msg =
|
|
2453
|
+
error instanceof Error
|
|
2454
|
+
? error.message
|
|
2455
|
+
: t("agentChat.composer.pastedTextError", {
|
|
2456
|
+
defaultValue: "Could not attach the pasted text.",
|
|
2457
|
+
});
|
|
2458
|
+
onAttachmentErrorRef.current?.(msg);
|
|
2459
|
+
});
|
|
2460
|
+
return true;
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2463
|
+
return false;
|
|
2464
|
+
},
|
|
2465
|
+
handleDrop: (_view, event) => {
|
|
2466
|
+
// Drag-and-drop files (decks, images, PDFs, etc.) into the composer.
|
|
2467
|
+
// Mark handled drops as consumed so the chat-wide drop target does not
|
|
2468
|
+
// add the same file a second time.
|
|
2469
|
+
return handleComposerFileDrop({
|
|
2470
|
+
event: event as DragEvent,
|
|
2471
|
+
addAttachment: (file) => composerRuntime.addAttachment(file),
|
|
2472
|
+
onError: (error) => {
|
|
2473
|
+
const msg =
|
|
2474
|
+
error instanceof Error
|
|
2475
|
+
? error.message
|
|
2476
|
+
: t("agentChat.composer.droppedFileError", {
|
|
2477
|
+
defaultValue:
|
|
2478
|
+
"Could not attach the dropped file. Try a different format.",
|
|
2479
|
+
});
|
|
2480
|
+
onAttachmentErrorRef.current?.(msg);
|
|
2481
|
+
},
|
|
2482
|
+
});
|
|
2483
|
+
},
|
|
2484
|
+
handleKeyDown: (view, event) => {
|
|
2485
|
+
const pop = popoverStateRef.current;
|
|
2486
|
+
|
|
2487
|
+
// Handle popover keyboard nav
|
|
2488
|
+
if (pop) {
|
|
2489
|
+
if (event.key === "ArrowUp") {
|
|
2490
|
+
event.preventDefault();
|
|
2491
|
+
popoverRef.current?.moveUp();
|
|
2492
|
+
return true;
|
|
2493
|
+
}
|
|
2494
|
+
if (event.key === "ArrowDown") {
|
|
2495
|
+
event.preventDefault();
|
|
2496
|
+
popoverRef.current?.moveDown();
|
|
2497
|
+
return true;
|
|
2498
|
+
}
|
|
2499
|
+
if (event.key === "Enter") {
|
|
2500
|
+
event.preventDefault();
|
|
2501
|
+
const idx = popoverRef.current?.getSelectedIndex() ?? 0;
|
|
2502
|
+
const currentCommands = filteredCommandsRef.current;
|
|
2503
|
+
const currentSkills = filteredSkillsRef.current;
|
|
2504
|
+
if (pop.type === "@") {
|
|
2505
|
+
const item = popoverRef.current?.getSelectedMention();
|
|
2506
|
+
if (item) selectMention(view, pop, item);
|
|
2507
|
+
} else if (pop.type === "/") {
|
|
2508
|
+
const cmd = popoverRef.current?.getSelectedCommand();
|
|
2509
|
+
if (cmd) {
|
|
2510
|
+
executeCommand(view, pop, cmd);
|
|
2511
|
+
} else {
|
|
2512
|
+
const skillIdx = idx - currentCommands.length;
|
|
2513
|
+
if (currentSkills[skillIdx]) {
|
|
2514
|
+
selectSkill(view, pop, currentSkills[skillIdx]);
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
return true;
|
|
2519
|
+
}
|
|
2520
|
+
if (event.key === "Escape") {
|
|
2521
|
+
event.preventDefault();
|
|
2522
|
+
popoverStateRef.current = null;
|
|
2523
|
+
setPopover(null);
|
|
2524
|
+
return true;
|
|
2525
|
+
}
|
|
2526
|
+
if (event.key === " " && pop.query === "") {
|
|
2527
|
+
popoverStateRef.current = null;
|
|
2528
|
+
setPopover(null);
|
|
2529
|
+
return false;
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2533
|
+
const { from, to } = view.state.selection;
|
|
2534
|
+
const cursorAtStart = from === to && from <= 1;
|
|
2535
|
+
if (event.key === "Backspace" && onRemoveContextItemRef.current) {
|
|
2536
|
+
const chipAction = resolveContextChipBackspaceAction({
|
|
2537
|
+
contextItemKeys: contextItemsRef.current.map((item) => item.key),
|
|
2538
|
+
selectedKey: selectedContextItemKeyRef.current,
|
|
2539
|
+
cursorAtStart,
|
|
2540
|
+
});
|
|
2541
|
+
if (chipAction) {
|
|
2542
|
+
event.preventDefault();
|
|
2543
|
+
if (chipAction.type === "select") {
|
|
2544
|
+
selectedContextItemKeyRef.current = chipAction.key;
|
|
2545
|
+
setSelectedContextItemKey(chipAction.key);
|
|
2546
|
+
} else {
|
|
2547
|
+
selectedContextItemKeyRef.current = null;
|
|
2548
|
+
setSelectedContextItemKey(null);
|
|
2549
|
+
contextItemsRef.current = contextItemsRef.current.filter(
|
|
2550
|
+
(item) => item.key !== chipAction.key,
|
|
2551
|
+
);
|
|
2552
|
+
onRemoveContextItemRef.current?.(chipAction.key);
|
|
2553
|
+
}
|
|
2554
|
+
return true;
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
if (selectedContextItemKeyRef.current) {
|
|
2558
|
+
selectedContextItemKeyRef.current = null;
|
|
2559
|
+
setSelectedContextItemKey(null);
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
// Backspace removes composer mode chip when editor is empty
|
|
2563
|
+
if (event.key === "Backspace" && composerModeRef.current) {
|
|
2564
|
+
if (
|
|
2565
|
+
view.state.doc.textContent.trim() === "" &&
|
|
2566
|
+
from === to &&
|
|
2567
|
+
from <= 1
|
|
2568
|
+
) {
|
|
2569
|
+
setComposerMode(null);
|
|
2570
|
+
composerModeRef.current = null;
|
|
2571
|
+
return true;
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
// Keyboard shortcut toggles Act/Plan mode from inside the editor.
|
|
2576
|
+
if (event.key === "Tab" && event.shiftKey) {
|
|
2577
|
+
event.preventDefault();
|
|
2578
|
+
const current = execModeRef.current;
|
|
2579
|
+
const cb = onExecModeChangeRef.current;
|
|
2580
|
+
if (current && cb) {
|
|
2581
|
+
const next = current === "build" ? "plan" : "build";
|
|
2582
|
+
if (next !== "plan" || !planModeDisabledRef.current) {
|
|
2583
|
+
cb(next);
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
return true;
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2589
|
+
// Submit on Enter. Shift+Enter inserts a newline and keeps the
|
|
2590
|
+
// composer scrolled to the caret.
|
|
2591
|
+
// Cmd+Enter on macOS / Ctrl+Enter elsewhere marks the submit queued.
|
|
2592
|
+
if (event.key === "Enter" && event.shiftKey) {
|
|
2593
|
+
event.preventDefault();
|
|
2594
|
+
return insertComposerHardBreakAndScrollIntoView(view);
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
const submitIntent = getComposerSubmitIntentForEnterKey(event, isMac);
|
|
2598
|
+
if (submitIntent) {
|
|
2599
|
+
event.preventDefault();
|
|
2600
|
+
void submitComposer(submitIntent);
|
|
2601
|
+
return true;
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
// Detect @ trigger — only when preceded by start-of-text, space, or newline
|
|
2605
|
+
// (not after alphanumeric chars, which would indicate an email address)
|
|
2606
|
+
if (event.key === "@") {
|
|
2607
|
+
const { from } = view.state.selection;
|
|
2608
|
+
const textBefore = view.state.doc.textBetween(
|
|
2609
|
+
Math.max(0, from - 1),
|
|
2610
|
+
from,
|
|
2611
|
+
);
|
|
2612
|
+
if (from === 1 || textBefore === "" || /\s/.test(textBefore)) {
|
|
2613
|
+
const position = getComposerPopoverPosition(view, from);
|
|
2614
|
+
if (!position) return false;
|
|
2615
|
+
setTimeout(() => {
|
|
2616
|
+
const state: PopoverState = {
|
|
2617
|
+
type: "@",
|
|
2618
|
+
position,
|
|
2619
|
+
startPos: view.state.selection.from,
|
|
2620
|
+
query: "",
|
|
2621
|
+
};
|
|
2622
|
+
popoverStateRef.current = state;
|
|
2623
|
+
setPopover(state);
|
|
2624
|
+
}, 0);
|
|
2625
|
+
}
|
|
2626
|
+
return false;
|
|
2627
|
+
}
|
|
2628
|
+
|
|
2629
|
+
// Detect / trigger (only at start of line or after whitespace)
|
|
2630
|
+
if (event.key === "/") {
|
|
2631
|
+
const { from } = view.state.selection;
|
|
2632
|
+
const textBefore = view.state.doc.textBetween(
|
|
2633
|
+
Math.max(0, from - 1),
|
|
2634
|
+
from,
|
|
2635
|
+
);
|
|
2636
|
+
if (from === 1 || textBefore === "" || /\s/.test(textBefore)) {
|
|
2637
|
+
const position = getComposerPopoverPosition(view, from);
|
|
2638
|
+
if (!position) return false;
|
|
2639
|
+
setTimeout(() => {
|
|
2640
|
+
const state: PopoverState = {
|
|
2641
|
+
type: "/",
|
|
2642
|
+
position,
|
|
2643
|
+
startPos: view.state.selection.from,
|
|
2644
|
+
query: "",
|
|
2645
|
+
};
|
|
2646
|
+
popoverStateRef.current = state;
|
|
2647
|
+
setPopover(state);
|
|
2648
|
+
}, 0);
|
|
2649
|
+
}
|
|
2650
|
+
return false;
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
return false;
|
|
2654
|
+
},
|
|
2655
|
+
},
|
|
2656
|
+
});
|
|
2657
|
+
|
|
2658
|
+
// Placeholder decorations are computed by ProseMirror. Dispatching an empty
|
|
2659
|
+
// transaction makes a locale or composer-mode change visible immediately.
|
|
2660
|
+
useEffect(() => {
|
|
2661
|
+
if (!isComposerEditorUsable(editor)) return;
|
|
2662
|
+
editor.view.dispatch(editor.state.tr.setSelection(editor.state.selection));
|
|
2663
|
+
}, [editor, resolvedPlaceholder]);
|
|
2664
|
+
|
|
2665
|
+
// A tab can stay mounted while becoming the active composer later. Publish
|
|
2666
|
+
// its existing draft when the host starts observing it so contextual UI is
|
|
2667
|
+
// correct immediately after a tab switch, not only after the next keystroke.
|
|
2668
|
+
useEffect(() => {
|
|
2669
|
+
if (!isComposerEditorUsable(editor) || !onTextChange) return;
|
|
2670
|
+
onTextChange(editor.state.doc.textContent.trim());
|
|
2671
|
+
}, [editor, onTextChange]);
|
|
2672
|
+
|
|
2673
|
+
const insertReference = useCallback(
|
|
2674
|
+
(ref: AgentComposerReference) => {
|
|
2675
|
+
const normalized = adapters.agentChat!.normalizeReference!(ref) as any;
|
|
2676
|
+
const ed = editor;
|
|
2677
|
+
if (!normalized || !isComposerEditorUsable(ed)) return;
|
|
2678
|
+
if (normalized.slotKey) {
|
|
2679
|
+
setSlotReferences((current) =>
|
|
2680
|
+
applySlotReferenceChanges(current, [normalized]),
|
|
2681
|
+
);
|
|
2682
|
+
ed.commands.focus("end");
|
|
2683
|
+
return;
|
|
2684
|
+
}
|
|
2685
|
+
if (
|
|
2686
|
+
normalized.relatedReferences?.some(
|
|
2687
|
+
(item: AgentComposerReference) => item.slotKey,
|
|
2688
|
+
)
|
|
2689
|
+
) {
|
|
2690
|
+
setSlotReferences((current) =>
|
|
2691
|
+
applySlotReferenceChanges(
|
|
2692
|
+
current,
|
|
2693
|
+
normalized.relatedReferences ?? [],
|
|
2694
|
+
),
|
|
2695
|
+
);
|
|
2696
|
+
}
|
|
2697
|
+
ed.chain()
|
|
2698
|
+
.focus()
|
|
2699
|
+
.insertContent({
|
|
2700
|
+
type: "mentionReference",
|
|
2701
|
+
attrs: mentionReferenceAttrs(normalized),
|
|
2702
|
+
})
|
|
2703
|
+
.insertContent(" ")
|
|
2704
|
+
.run();
|
|
2705
|
+
setEditorHasText(true);
|
|
2706
|
+
},
|
|
2707
|
+
[editor],
|
|
2708
|
+
);
|
|
2709
|
+
|
|
2710
|
+
const insertReferenceIfEmpty = useCallback(
|
|
2711
|
+
(payload: AgentComposerReferenceInsertPayload) => {
|
|
2712
|
+
const insertMessageId =
|
|
2713
|
+
typeof payload.insertMessageId === "string"
|
|
2714
|
+
? payload.insertMessageId
|
|
2715
|
+
: "";
|
|
2716
|
+
if (insertMessageId) {
|
|
2717
|
+
if (seenReferenceInsertIdsRef.current.has(insertMessageId)) return;
|
|
2718
|
+
seenReferenceInsertIdsRef.current.add(insertMessageId);
|
|
2719
|
+
}
|
|
2720
|
+
const ed = editor;
|
|
2721
|
+
if (!isComposerEditorUsable(ed) || disabled || composerModeRef.current)
|
|
2722
|
+
return;
|
|
2723
|
+
const normalized = adapters.agentChat!.normalizeReference!(
|
|
2724
|
+
payload,
|
|
2725
|
+
) as any;
|
|
2726
|
+
if (normalized?.slotKey) {
|
|
2727
|
+
insertReference(normalized);
|
|
2728
|
+
return;
|
|
2729
|
+
}
|
|
2730
|
+
if (composerAttachments.length > 0) return;
|
|
2731
|
+
if (composerDocumentHasContent(ed.state.doc)) return;
|
|
2732
|
+
insertReference(payload);
|
|
2733
|
+
},
|
|
2734
|
+
[composerAttachments.length, disabled, editor, insertReference],
|
|
2735
|
+
);
|
|
2736
|
+
|
|
2737
|
+
useEffect(() => {
|
|
2738
|
+
if (typeof window === "undefined") return;
|
|
2739
|
+
const handleEvent = (event: Event) => {
|
|
2740
|
+
const payload = (event as CustomEvent).detail;
|
|
2741
|
+
const normalized = adapters.agentChat!.normalizeReference!(
|
|
2742
|
+
payload,
|
|
2743
|
+
) as any;
|
|
2744
|
+
if (!normalized) return;
|
|
2745
|
+
insertReferenceIfEmpty({
|
|
2746
|
+
...normalized,
|
|
2747
|
+
insertMessageId:
|
|
2748
|
+
typeof payload?.insertMessageId === "string"
|
|
2749
|
+
? payload.insertMessageId
|
|
2750
|
+
: "",
|
|
2751
|
+
});
|
|
2752
|
+
};
|
|
2753
|
+
const handleMessage = (event: MessageEvent) => {
|
|
2754
|
+
if (
|
|
2755
|
+
!adapters.builder!.isTrustedFrameMessage!(event) &&
|
|
2756
|
+
!adapters.builder!.isTrustedBuilderMessage!(event)
|
|
2757
|
+
) {
|
|
2758
|
+
return;
|
|
2759
|
+
}
|
|
2760
|
+
if (event.data?.type !== AGENT_CHAT_INSERT_REFERENCE_MESSAGE_TYPE) {
|
|
2761
|
+
return;
|
|
2762
|
+
}
|
|
2763
|
+
const payload = event.data.data;
|
|
2764
|
+
const normalized = adapters.agentChat!.normalizeReference!(
|
|
2765
|
+
payload,
|
|
2766
|
+
) as any;
|
|
2767
|
+
if (!normalized) return;
|
|
2768
|
+
insertReferenceIfEmpty({
|
|
2769
|
+
...normalized,
|
|
2770
|
+
insertMessageId:
|
|
2771
|
+
typeof payload?.insertMessageId === "string"
|
|
2772
|
+
? payload.insertMessageId
|
|
2773
|
+
: "",
|
|
2774
|
+
});
|
|
2775
|
+
};
|
|
2776
|
+
window.addEventListener(AGENT_CHAT_INSERT_REFERENCE_EVENT, handleEvent);
|
|
2777
|
+
window.addEventListener("message", handleMessage);
|
|
2778
|
+
return () => {
|
|
2779
|
+
window.removeEventListener(
|
|
2780
|
+
AGENT_CHAT_INSERT_REFERENCE_EVENT,
|
|
2781
|
+
handleEvent,
|
|
2782
|
+
);
|
|
2783
|
+
window.removeEventListener("message", handleMessage);
|
|
2784
|
+
};
|
|
2785
|
+
}, [adapters, insertReferenceIfEmpty]);
|
|
2786
|
+
|
|
2787
|
+
useImperativeHandle(focusRef, () => ({
|
|
2788
|
+
focus() {
|
|
2789
|
+
if (isComposerEditorUsable(editor)) editor.commands.focus("end");
|
|
2790
|
+
},
|
|
2791
|
+
setText(text: string) {
|
|
2792
|
+
if (!isComposerEditorUsable(editor)) return;
|
|
2793
|
+
editor.commands.setContent(plainTextToDoc(text));
|
|
2794
|
+
editor.commands.focus("end");
|
|
2795
|
+
const trimmed = editor.state.doc.textContent.trim();
|
|
2796
|
+
setEditorHasText(trimmed.length > 0);
|
|
2797
|
+
setSlotReferences([]);
|
|
2798
|
+
composerRuntime.setText(trimmed);
|
|
2799
|
+
onTextChangeRef.current?.(trimmed);
|
|
2800
|
+
try {
|
|
2801
|
+
if (trimmed) {
|
|
2802
|
+
localStorage.setItem(draftKey, editor.getHTML());
|
|
2803
|
+
} else {
|
|
2804
|
+
localStorage.removeItem(draftKey);
|
|
2805
|
+
}
|
|
2806
|
+
} catch {}
|
|
2807
|
+
},
|
|
2808
|
+
insertReference,
|
|
2809
|
+
}));
|
|
2810
|
+
|
|
2811
|
+
const handleSelectMode = useCallback(
|
|
2812
|
+
(mode: ComposerMode) => {
|
|
2813
|
+
setComposerMode(mode);
|
|
2814
|
+
composerModeRef.current = mode;
|
|
2815
|
+
setTimeout(() => {
|
|
2816
|
+
if (isComposerEditorUsable(editor)) editor.commands.focus("end");
|
|
2817
|
+
}, 50);
|
|
2818
|
+
},
|
|
2819
|
+
[editor],
|
|
2820
|
+
);
|
|
2821
|
+
|
|
2822
|
+
// --- Live voice transcription: text appears in the editor as the user speaks ---
|
|
2823
|
+
const voiceAnchorRef = useRef<number | null>(null);
|
|
2824
|
+
const prevVoiceInsertRef = useRef("");
|
|
2825
|
+
|
|
2826
|
+
const handleLiveUpdate = useCallback(
|
|
2827
|
+
(finalText: string, interimText: string) => {
|
|
2828
|
+
const ed = editor;
|
|
2829
|
+
if (!isComposerEditorUsable(ed)) return;
|
|
2830
|
+
|
|
2831
|
+
if (voiceAnchorRef.current == null) {
|
|
2832
|
+
const { from } = ed.state.selection;
|
|
2833
|
+
const prevChar =
|
|
2834
|
+
from > 1 ? ed.state.doc.textBetween(from - 1, from) : "";
|
|
2835
|
+
if (prevChar && !/\s/.test(prevChar)) {
|
|
2836
|
+
ed.chain().insertContent(" ").run();
|
|
2837
|
+
}
|
|
2838
|
+
voiceAnchorRef.current = ed.state.selection.from;
|
|
2839
|
+
prevVoiceInsertRef.current = "";
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
const anchor = voiceAnchorRef.current;
|
|
2843
|
+
const prevLen = prevVoiceInsertRef.current.length;
|
|
2844
|
+
const newText = finalText + interimText;
|
|
2845
|
+
|
|
2846
|
+
if (newText === prevVoiceInsertRef.current) return;
|
|
2847
|
+
|
|
2848
|
+
ed.chain()
|
|
2849
|
+
.deleteRange({ from: anchor, to: anchor + prevLen })
|
|
2850
|
+
.insertContentAt(anchor, newText)
|
|
2851
|
+
.run();
|
|
2852
|
+
|
|
2853
|
+
prevVoiceInsertRef.current = newText;
|
|
2854
|
+
},
|
|
2855
|
+
[editor],
|
|
2856
|
+
);
|
|
2857
|
+
|
|
2858
|
+
const insertTranscript = useCallback(
|
|
2859
|
+
(text: string) => {
|
|
2860
|
+
const ed = editor;
|
|
2861
|
+
if (!isComposerEditorUsable(ed)) return;
|
|
2862
|
+
const formattedText = formatVoiceTranscriptForComposer(text);
|
|
2863
|
+
|
|
2864
|
+
const anchor = voiceAnchorRef.current;
|
|
2865
|
+
if (anchor != null) {
|
|
2866
|
+
const prevLen = prevVoiceInsertRef.current.length;
|
|
2867
|
+
if (formattedText) {
|
|
2868
|
+
ed.chain()
|
|
2869
|
+
.focus()
|
|
2870
|
+
.deleteRange({ from: anchor, to: anchor + prevLen })
|
|
2871
|
+
.insertContentAt(anchor, formattedText)
|
|
2872
|
+
.run();
|
|
2873
|
+
} else if (prevLen > 0) {
|
|
2874
|
+
ed.chain()
|
|
2875
|
+
.deleteRange({ from: anchor, to: anchor + prevLen })
|
|
2876
|
+
.run();
|
|
2877
|
+
}
|
|
2878
|
+
voiceAnchorRef.current = null;
|
|
2879
|
+
prevVoiceInsertRef.current = "";
|
|
2880
|
+
} else if (formattedText) {
|
|
2881
|
+
const { from } = ed.state.selection;
|
|
2882
|
+
const prevChar =
|
|
2883
|
+
from > 1 ? ed.state.doc.textBetween(from - 1, from) : "";
|
|
2884
|
+
const needsLead = prevChar && !/\s/.test(prevChar);
|
|
2885
|
+
ed.chain()
|
|
2886
|
+
.focus()
|
|
2887
|
+
.insertContent((needsLead ? " " : "") + formattedText)
|
|
2888
|
+
.run();
|
|
2889
|
+
}
|
|
2890
|
+
},
|
|
2891
|
+
[editor],
|
|
2892
|
+
);
|
|
2893
|
+
|
|
2894
|
+
const buildVoiceContextPack = useCallback(():
|
|
2895
|
+
| VoiceContextPack
|
|
2896
|
+
| undefined => {
|
|
2897
|
+
const snippets: Array<{ label: string; value: string }> = [];
|
|
2898
|
+
|
|
2899
|
+
const activeContext = trimVoiceContextValue(
|
|
2900
|
+
adapters.agentChat!.formatContextItems!(contextItems) ||
|
|
2901
|
+
formatPromptContextItems(contextItems),
|
|
2902
|
+
3200,
|
|
2903
|
+
);
|
|
2904
|
+
if (activeContext) {
|
|
2905
|
+
snippets.push({
|
|
2906
|
+
label: t("agentChat.composer.activeAppContext", {
|
|
2907
|
+
defaultValue: "Active app context",
|
|
2908
|
+
}),
|
|
2909
|
+
value: activeContext,
|
|
2910
|
+
});
|
|
2911
|
+
}
|
|
2912
|
+
|
|
2913
|
+
const selectedReferences = trimVoiceContextValue(
|
|
2914
|
+
slotReferences.map((ref) => slotReferenceTitle(ref)).join(", "),
|
|
2915
|
+
1200,
|
|
2916
|
+
);
|
|
2917
|
+
if (selectedReferences) {
|
|
2918
|
+
snippets.push({
|
|
2919
|
+
label: t("agentChat.composer.selectedReferences", {
|
|
2920
|
+
defaultValue: "Selected references",
|
|
2921
|
+
}),
|
|
2922
|
+
value: selectedReferences,
|
|
2923
|
+
});
|
|
2924
|
+
}
|
|
2925
|
+
|
|
2926
|
+
const draft = isComposerEditorUsable(editor)
|
|
2927
|
+
? trimVoiceContextValue(editor.state.doc.textContent, 1200)
|
|
2928
|
+
: null;
|
|
2929
|
+
if (draft) {
|
|
2930
|
+
snippets.push({
|
|
2931
|
+
label: t("agentChat.composer.currentDraft", {
|
|
2932
|
+
defaultValue: "Current draft",
|
|
2933
|
+
}),
|
|
2934
|
+
value: draft,
|
|
2935
|
+
});
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
if (typeof document !== "undefined") {
|
|
2939
|
+
const title = trimVoiceContextValue(document.title, 160);
|
|
2940
|
+
if (title) {
|
|
2941
|
+
snippets.push({
|
|
2942
|
+
label: t("agentChat.composer.pageTitle", {
|
|
2943
|
+
defaultValue: "Page title",
|
|
2944
|
+
}),
|
|
2945
|
+
value: title,
|
|
2946
|
+
});
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
|
|
2950
|
+
if (typeof window !== "undefined") {
|
|
2951
|
+
const route = trimVoiceContextValue(window.location.pathname, 240);
|
|
2952
|
+
if (route) {
|
|
2953
|
+
snippets.push({
|
|
2954
|
+
label: t("agentChat.composer.route", { defaultValue: "Route" }),
|
|
2955
|
+
value: route,
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
}
|
|
2959
|
+
|
|
2960
|
+
if (snippets.length === 0) return undefined;
|
|
2961
|
+
return {
|
|
2962
|
+
surface: "agent-composer",
|
|
2963
|
+
mode: "dictation",
|
|
2964
|
+
snippets,
|
|
2965
|
+
};
|
|
2966
|
+
}, [adapters, contextItems, editor, slotReferences, t]);
|
|
2967
|
+
|
|
2968
|
+
const voice = useVoiceDictation({
|
|
2969
|
+
onTranscript: insertTranscript,
|
|
2970
|
+
onLiveUpdate: handleLiveUpdate,
|
|
2971
|
+
contextPack: buildVoiceContextPack,
|
|
2972
|
+
});
|
|
2973
|
+
|
|
2974
|
+
// Clean up live text if voice session ends without a final transcript (cancel/error)
|
|
2975
|
+
useEffect(() => {
|
|
2976
|
+
if (voice.state === "idle" && voiceAnchorRef.current != null) {
|
|
2977
|
+
const anchor = voiceAnchorRef.current;
|
|
2978
|
+
const prevLen = prevVoiceInsertRef.current.length;
|
|
2979
|
+
if (isComposerEditorUsable(editor) && prevLen > 0) {
|
|
2980
|
+
const documentSize = editor.state.doc.content.size;
|
|
2981
|
+
const currentText =
|
|
2982
|
+
anchor >= 1 && anchor + prevLen <= documentSize
|
|
2983
|
+
? editor.state.doc.textBetween(anchor, anchor + prevLen, "", "\n")
|
|
2984
|
+
: "";
|
|
2985
|
+
if (
|
|
2986
|
+
canRemoveVoicePreview({
|
|
2987
|
+
documentSize,
|
|
2988
|
+
anchor,
|
|
2989
|
+
previewText: prevVoiceInsertRef.current,
|
|
2990
|
+
currentText,
|
|
2991
|
+
})
|
|
2992
|
+
) {
|
|
2993
|
+
editor
|
|
2994
|
+
.chain()
|
|
2995
|
+
.deleteRange({ from: anchor, to: anchor + prevLen })
|
|
2996
|
+
.run();
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
voiceAnchorRef.current = null;
|
|
3000
|
+
prevVoiceInsertRef.current = "";
|
|
3001
|
+
}
|
|
3002
|
+
}, [voice.state, editor]);
|
|
3003
|
+
|
|
3004
|
+
// Global shortcut: Cmd/Ctrl + Shift + M toggles dictation. Escape cancels
|
|
3005
|
+
// while recording. Scoped to avoid firing when focus is outside the app.
|
|
3006
|
+
useEffect(() => {
|
|
3007
|
+
if (!voiceEnabled || !voice.supported) return;
|
|
3008
|
+
const handler = (e: KeyboardEvent) => {
|
|
3009
|
+
// e.key can be undefined on some trusted keydown events (autofill/IME
|
|
3010
|
+
// quirks) — seen crashing in production (AGENT-NATIVE-BROWSER-S).
|
|
3011
|
+
const isToggleCombo =
|
|
3012
|
+
typeof e.key === "string" &&
|
|
3013
|
+
e.key.toLowerCase() === "m" &&
|
|
3014
|
+
e.shiftKey &&
|
|
3015
|
+
(e.metaKey || e.ctrlKey) &&
|
|
3016
|
+
!e.altKey;
|
|
3017
|
+
if (isToggleCombo) {
|
|
3018
|
+
e.preventDefault();
|
|
3019
|
+
if (voice.state === "recording" || voice.state === "starting") {
|
|
3020
|
+
voice.stop();
|
|
3021
|
+
} else if (voice.state !== "transcribing") {
|
|
3022
|
+
void voice.start();
|
|
3023
|
+
}
|
|
3024
|
+
return;
|
|
3025
|
+
}
|
|
3026
|
+
if (
|
|
3027
|
+
e.key === "Escape" &&
|
|
3028
|
+
(voice.state === "recording" || voice.state === "starting")
|
|
3029
|
+
) {
|
|
3030
|
+
e.preventDefault();
|
|
3031
|
+
voice.cancel();
|
|
3032
|
+
}
|
|
3033
|
+
};
|
|
3034
|
+
window.addEventListener("keydown", handler);
|
|
3035
|
+
return () => window.removeEventListener("keydown", handler);
|
|
3036
|
+
}, [voiceEnabled, voice]);
|
|
3037
|
+
|
|
3038
|
+
const extractComposerPayload = useCallback(() => {
|
|
3039
|
+
const ed = editor;
|
|
3040
|
+
if (!isComposerEditorUsable(ed)) {
|
|
3041
|
+
return {
|
|
3042
|
+
text: slotReferences.map((ref) => slotReferenceTitle(ref)).join(", "),
|
|
3043
|
+
references: slotReferences.map(referenceFromComposerReference),
|
|
3044
|
+
};
|
|
3045
|
+
}
|
|
3046
|
+
|
|
3047
|
+
const references: Reference[] = slotReferences.map(
|
|
3048
|
+
referenceFromComposerReference,
|
|
3049
|
+
);
|
|
3050
|
+
|
|
3051
|
+
// Build text that preserves @mentions (getText() strips them).
|
|
3052
|
+
// Walk the document and reconstruct with @name for mention/file/skill nodes.
|
|
3053
|
+
const textParts: string[] = [];
|
|
3054
|
+
ed.state.doc.descendants((node: any) => {
|
|
3055
|
+
if (node.isText) {
|
|
3056
|
+
textParts.push(node.text);
|
|
3057
|
+
} else if (node.type.name === "mentionReference") {
|
|
3058
|
+
textParts.push(`@[${node.attrs.label}|${node.attrs.icon || "file"}]`);
|
|
3059
|
+
} else if (node.type.name === "fileReference") {
|
|
3060
|
+
const label = node.attrs.path?.split("/").pop() || node.attrs.path;
|
|
3061
|
+
textParts.push(`@[${label}|file]`);
|
|
3062
|
+
} else if (node.type.name === "skillReference") {
|
|
3063
|
+
textParts.push(`/${node.attrs.name}`);
|
|
3064
|
+
} else if (node.type.name === "hardBreak") {
|
|
3065
|
+
textParts.push("\n");
|
|
3066
|
+
} else if (
|
|
3067
|
+
node.type.name === "paragraph" &&
|
|
3068
|
+
textParts.length > 0 &&
|
|
3069
|
+
textParts[textParts.length - 1] !== "\n"
|
|
3070
|
+
) {
|
|
3071
|
+
textParts.push("\n");
|
|
3072
|
+
}
|
|
3073
|
+
});
|
|
3074
|
+
const rawText = textParts.join("").trim();
|
|
3075
|
+
const text =
|
|
3076
|
+
rawText ||
|
|
3077
|
+
slotReferences.map((ref) => slotReferenceTitle(ref)).join(", ");
|
|
3078
|
+
|
|
3079
|
+
ed.state.doc.descendants((node: any) => {
|
|
3080
|
+
if (node.type.name === "fileReference") {
|
|
3081
|
+
// Legacy support
|
|
3082
|
+
references.push({
|
|
3083
|
+
type: "file",
|
|
3084
|
+
path: node.attrs.path,
|
|
3085
|
+
name: node.attrs.path?.split("/").pop() || node.attrs.path,
|
|
3086
|
+
source: node.attrs.source || "codebase",
|
|
3087
|
+
});
|
|
3088
|
+
} else if (node.type.name === "mentionReference") {
|
|
3089
|
+
const refType = node.attrs.refType;
|
|
3090
|
+
references.push({
|
|
3091
|
+
type:
|
|
3092
|
+
refType === "file"
|
|
3093
|
+
? "file"
|
|
3094
|
+
: refType === "agent"
|
|
3095
|
+
? "agent"
|
|
3096
|
+
: refType === "custom-agent"
|
|
3097
|
+
? "custom-agent"
|
|
3098
|
+
: "mention",
|
|
3099
|
+
path: node.attrs.refPath || "",
|
|
3100
|
+
name: node.attrs.label,
|
|
3101
|
+
source: node.attrs.source,
|
|
3102
|
+
refType: node.attrs.refType,
|
|
3103
|
+
refId: node.attrs.refId,
|
|
3104
|
+
slotKey: node.attrs.slotKey,
|
|
3105
|
+
slotLabel: node.attrs.slotLabel,
|
|
3106
|
+
metadata: node.attrs.metadata,
|
|
3107
|
+
});
|
|
3108
|
+
} else if (node.type.name === "skillReference") {
|
|
3109
|
+
references.push({
|
|
3110
|
+
type: "skill",
|
|
3111
|
+
path: node.attrs.path,
|
|
3112
|
+
name: node.attrs.name,
|
|
3113
|
+
source: node.attrs.source || "codebase",
|
|
3114
|
+
});
|
|
3115
|
+
}
|
|
3116
|
+
});
|
|
3117
|
+
|
|
3118
|
+
return { text, references };
|
|
3119
|
+
}, [editor, slotReferences]);
|
|
3120
|
+
|
|
3121
|
+
const syncComposerRuntimeState = useCallback(
|
|
3122
|
+
(text: string, references: Reference[]) => {
|
|
3123
|
+
const requestMode =
|
|
3124
|
+
execMode === "plan" ? "plan" : execMode === "build" ? "act" : undefined;
|
|
3125
|
+
const custom: {
|
|
3126
|
+
references?: Reference[];
|
|
3127
|
+
requestMode?: "act" | "plan";
|
|
3128
|
+
} = {};
|
|
3129
|
+
if (references.length > 0) {
|
|
3130
|
+
custom.references = references;
|
|
3131
|
+
}
|
|
3132
|
+
if (requestMode) {
|
|
3133
|
+
custom.requestMode = requestMode;
|
|
3134
|
+
}
|
|
3135
|
+
const runConfig = Object.keys(custom).length > 0 ? { custom } : {};
|
|
3136
|
+
const runConfigSignature = JSON.stringify(runConfig);
|
|
3137
|
+
const last = lastComposerRuntimeSyncRef.current;
|
|
3138
|
+
if (
|
|
3139
|
+
last?.text === text &&
|
|
3140
|
+
last.runConfigSignature === runConfigSignature
|
|
3141
|
+
) {
|
|
3142
|
+
return;
|
|
3143
|
+
}
|
|
3144
|
+
composerRuntime.setText(text);
|
|
3145
|
+
composerRuntime.setRunConfig(runConfig);
|
|
3146
|
+
lastComposerRuntimeSyncRef.current = { text, runConfigSignature };
|
|
3147
|
+
},
|
|
3148
|
+
[composerRuntime, execMode],
|
|
3149
|
+
);
|
|
3150
|
+
|
|
3151
|
+
const resetComposerRuntimeState = useCallback(() => {
|
|
3152
|
+
const runConfigSignature = "{}";
|
|
3153
|
+
const last = lastComposerRuntimeSyncRef.current;
|
|
3154
|
+
if (last?.text === "" && last.runConfigSignature === runConfigSignature) {
|
|
3155
|
+
return;
|
|
3156
|
+
}
|
|
3157
|
+
composerRuntime.setText("");
|
|
3158
|
+
composerRuntime.setRunConfig({});
|
|
3159
|
+
lastComposerRuntimeSyncRef.current = { text: "", runConfigSignature };
|
|
3160
|
+
}, [composerRuntime]);
|
|
3161
|
+
|
|
3162
|
+
const syncComposerState = useCallback(() => {
|
|
3163
|
+
const { text, references } = extractComposerPayload();
|
|
3164
|
+
syncComposerRuntimeState(text, references);
|
|
3165
|
+
return { text, references };
|
|
3166
|
+
}, [extractComposerPayload, syncComposerRuntimeState]);
|
|
3167
|
+
|
|
3168
|
+
const clearEditorAfterSubmit = useCallback(() => {
|
|
3169
|
+
const ed = editor;
|
|
3170
|
+
if (!isComposerEditorUsable(ed)) return;
|
|
3171
|
+
ed.commands.clearContent();
|
|
3172
|
+
setEditorHasText(false);
|
|
3173
|
+
setSlotReferences([]);
|
|
3174
|
+
resetComposerRuntimeState();
|
|
3175
|
+
try {
|
|
3176
|
+
localStorage.removeItem(draftKey);
|
|
3177
|
+
} catch {}
|
|
3178
|
+
closePopover();
|
|
3179
|
+
}, [closePopover, draftKey, editor, resetComposerRuntimeState]);
|
|
3180
|
+
|
|
3181
|
+
const submitComposer = useCallback(
|
|
3182
|
+
async (intent: ComposerSubmitIntent = "immediate") => {
|
|
3183
|
+
const ed = editor;
|
|
3184
|
+
if (!isComposerEditorUsable(ed)) return;
|
|
3185
|
+
if (submitInFlightRef.current) return;
|
|
3186
|
+
|
|
3187
|
+
const { text, references } = syncComposerState();
|
|
3188
|
+
const attachments = composerRuntime.getState().attachments;
|
|
3189
|
+
if (!text.trim() && references.length === 0 && attachments.length === 0)
|
|
3190
|
+
return;
|
|
3191
|
+
const oversizedDocumentError = getOversizedDocumentAttachmentError(
|
|
3192
|
+
attachments,
|
|
3193
|
+
{
|
|
3194
|
+
maxBytes: maxDocumentAttachmentBytes,
|
|
3195
|
+
label: documentAttachmentLimitLabel,
|
|
3196
|
+
translate: t,
|
|
3197
|
+
},
|
|
3198
|
+
);
|
|
3199
|
+
if (oversizedDocumentError) {
|
|
3200
|
+
onAttachmentErrorRef.current?.(oversizedDocumentError);
|
|
3201
|
+
return;
|
|
3202
|
+
}
|
|
3203
|
+
const cancelActiveVoice = () => {
|
|
3204
|
+
if (
|
|
3205
|
+
voice.state === "recording" ||
|
|
3206
|
+
voice.state === "starting" ||
|
|
3207
|
+
voice.state === "transcribing"
|
|
3208
|
+
) {
|
|
3209
|
+
voice.cancel();
|
|
3210
|
+
}
|
|
3211
|
+
};
|
|
3212
|
+
|
|
3213
|
+
// Intercept slash commands typed directly (e.g. "/clear" + Enter)
|
|
3214
|
+
const trimmed = text.trim();
|
|
3215
|
+
if (trimmed.startsWith("/") && references.length === 0) {
|
|
3216
|
+
const cmdName = normalizeSlashCommandName(trimmed);
|
|
3217
|
+
const matched = allSlashCommands.find((c) => c.name === cmdName);
|
|
3218
|
+
if (matched) {
|
|
3219
|
+
clearEditorAfterSubmit();
|
|
3220
|
+
onSlashCommandRef.current?.(matched.name);
|
|
3221
|
+
return;
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
|
|
3225
|
+
// Builder iframe delegation: when this app is mounted inside the
|
|
3226
|
+
// Builder.io webview and the user typed a "build me an app/agent"
|
|
3227
|
+
// prompt, hand it up to the parent Builder chat instead of sending
|
|
3228
|
+
// it to this app's domain agent. Builder is the code-writing agent;
|
|
3229
|
+
// the local agent (dispatch, mail, etc.) cannot scaffold workspace
|
|
3230
|
+
// apps from inside its own iframe.
|
|
3231
|
+
if (
|
|
3232
|
+
!composerMode &&
|
|
3233
|
+
interceptBuildRequestsForBuilder &&
|
|
3234
|
+
adapters.builder!.tryDelegateBuildRequest!(trimmed)
|
|
3235
|
+
) {
|
|
3236
|
+
cancelActiveVoice();
|
|
3237
|
+
clearEditorAfterSubmit();
|
|
3238
|
+
return;
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
if (onBeforeSubmit) {
|
|
3242
|
+
submitInFlightRef.current = true;
|
|
3243
|
+
try {
|
|
3244
|
+
const shouldSubmit = await onBeforeSubmit();
|
|
3245
|
+
if (!shouldSubmit) return;
|
|
3246
|
+
} finally {
|
|
3247
|
+
submitInFlightRef.current = false;
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
if (!isComposerEditorUsable(ed)) return;
|
|
3251
|
+
|
|
3252
|
+
// Composer mode: send with context via agent chat bridge
|
|
3253
|
+
if (composerMode) {
|
|
3254
|
+
const config = localizedComposerModeConfig(composerMode, t);
|
|
3255
|
+
config.beforeSend?.();
|
|
3256
|
+
const message = displayableComposerModeMessage({
|
|
3257
|
+
messagePrefix: config.messagePrefix,
|
|
3258
|
+
trimmedText: trimmed,
|
|
3259
|
+
attachmentCount: attachments.length,
|
|
3260
|
+
attachedContextFallback: t("agentChat.composer.useAttachedContext", {
|
|
3261
|
+
defaultValue: "Use the attached context.",
|
|
3262
|
+
}),
|
|
3263
|
+
});
|
|
3264
|
+
const modePrompt =
|
|
3265
|
+
trimmed ||
|
|
3266
|
+
(attachments.length > 0
|
|
3267
|
+
? t("agentChat.composer.useAttachedContext", {
|
|
3268
|
+
defaultValue: "Use the attached context.",
|
|
3269
|
+
})
|
|
3270
|
+
: "");
|
|
3271
|
+
if (attachments.length > 0) {
|
|
3272
|
+
composerRuntime.setText(
|
|
3273
|
+
`${message}\n\n<context>\n${config.getContext(modePrompt)}\n</context>`,
|
|
3274
|
+
);
|
|
3275
|
+
composerRuntime.send();
|
|
3276
|
+
} else {
|
|
3277
|
+
adapters.agentChat!.sendToAgentChat!({
|
|
3278
|
+
message,
|
|
3279
|
+
context: config.getContext(modePrompt),
|
|
3280
|
+
mode:
|
|
3281
|
+
execMode === "plan"
|
|
3282
|
+
? "plan"
|
|
3283
|
+
: execMode === "build"
|
|
3284
|
+
? "act"
|
|
3285
|
+
: undefined,
|
|
3286
|
+
submit: true,
|
|
3287
|
+
});
|
|
3288
|
+
}
|
|
3289
|
+
cancelActiveVoice();
|
|
3290
|
+
if (isComposerEditorUsable(ed)) ed.commands.clearContent();
|
|
3291
|
+
setEditorHasText(false);
|
|
3292
|
+
setSlotReferences([]);
|
|
3293
|
+
setComposerMode(null);
|
|
3294
|
+
composerModeRef.current = null;
|
|
3295
|
+
try {
|
|
3296
|
+
localStorage.removeItem(draftKey);
|
|
3297
|
+
} catch {}
|
|
3298
|
+
closePopover();
|
|
3299
|
+
return;
|
|
3300
|
+
}
|
|
3301
|
+
|
|
3302
|
+
if (onSubmit) {
|
|
3303
|
+
try {
|
|
3304
|
+
await onSubmit(text, references, attachments, { intent });
|
|
3305
|
+
} catch {
|
|
3306
|
+
// Hosts own their submit errors. Keep the draft and attachments
|
|
3307
|
+
// available for recovery when a host rejects the submission.
|
|
3308
|
+
return;
|
|
3309
|
+
}
|
|
3310
|
+
// Clear any pending attachments now that the host has them.
|
|
3311
|
+
void composerRuntime.clearAttachments().catch(() => {});
|
|
3312
|
+
if (!clearOnSubmit) {
|
|
3313
|
+
closePopover();
|
|
3314
|
+
return;
|
|
3315
|
+
}
|
|
3316
|
+
cancelActiveVoice();
|
|
3317
|
+
clearEditorAfterSubmit();
|
|
3318
|
+
return;
|
|
3319
|
+
} else {
|
|
3320
|
+
composerRuntime.send();
|
|
3321
|
+
}
|
|
3322
|
+
cancelActiveVoice();
|
|
3323
|
+
if (isComposerEditorUsable(ed)) ed.commands.clearContent();
|
|
3324
|
+
setEditorHasText(false);
|
|
3325
|
+
setSlotReferences([]);
|
|
3326
|
+
try {
|
|
3327
|
+
localStorage.removeItem(draftKey);
|
|
3328
|
+
} catch {}
|
|
3329
|
+
closePopover();
|
|
3330
|
+
},
|
|
3331
|
+
[
|
|
3332
|
+
closePopover,
|
|
3333
|
+
clearEditorAfterSubmit,
|
|
3334
|
+
composerMode,
|
|
3335
|
+
composerRuntime,
|
|
3336
|
+
draftKey,
|
|
3337
|
+
editor,
|
|
3338
|
+
interceptBuildRequestsForBuilder,
|
|
3339
|
+
clearOnSubmit,
|
|
3340
|
+
onBeforeSubmit,
|
|
3341
|
+
onSubmit,
|
|
3342
|
+
syncComposerState,
|
|
3343
|
+
voice,
|
|
3344
|
+
allSlashCommands,
|
|
3345
|
+
t,
|
|
3346
|
+
],
|
|
3347
|
+
);
|
|
3348
|
+
|
|
3349
|
+
// Helper functions that operate on the editor view directly
|
|
3350
|
+
// These are called from handleKeyDown which can't use React state
|
|
3351
|
+
function selectMention(
|
|
3352
|
+
_view: any,
|
|
3353
|
+
pop: NonNullable<PopoverState>,
|
|
3354
|
+
item: MentionItem,
|
|
3355
|
+
) {
|
|
3356
|
+
const ed = editor;
|
|
3357
|
+
if (!isComposerEditorUsable(ed)) return;
|
|
3358
|
+
const currentPos = ed.state.selection.from;
|
|
3359
|
+
// startPos is after the trigger char, so -1 to include the @ or /
|
|
3360
|
+
const deleteFrom = Math.max(0, pop.startPos - 1);
|
|
3361
|
+
ed.chain().focus().deleteRange({ from: deleteFrom, to: currentPos }).run();
|
|
3362
|
+
insertReference(composerReferenceFromMentionItem(item));
|
|
3363
|
+
popoverStateRef.current = null;
|
|
3364
|
+
setPopover(null);
|
|
3365
|
+
}
|
|
3366
|
+
|
|
3367
|
+
function executeCommand(
|
|
3368
|
+
_view: any,
|
|
3369
|
+
pop: NonNullable<PopoverState>,
|
|
3370
|
+
command: SlashCommand,
|
|
3371
|
+
) {
|
|
3372
|
+
const ed = editor;
|
|
3373
|
+
if (!isComposerEditorUsable(ed)) return;
|
|
3374
|
+
const currentPos = ed.state.selection.from;
|
|
3375
|
+
const deleteFrom = Math.max(0, pop.startPos - 1);
|
|
3376
|
+
ed.chain().focus().deleteRange({ from: deleteFrom, to: currentPos }).run();
|
|
3377
|
+
popoverStateRef.current = null;
|
|
3378
|
+
setPopover(null);
|
|
3379
|
+
onSlashCommandRef.current?.(command.name);
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3382
|
+
function selectSkill(
|
|
3383
|
+
_view: any,
|
|
3384
|
+
pop: NonNullable<PopoverState>,
|
|
3385
|
+
skill: SkillResult,
|
|
3386
|
+
) {
|
|
3387
|
+
const ed = editor;
|
|
3388
|
+
if (!isComposerEditorUsable(ed)) return;
|
|
3389
|
+
const currentPos = ed.state.selection.from;
|
|
3390
|
+
const deleteFrom = Math.max(0, pop.startPos - 1);
|
|
3391
|
+
ed.chain()
|
|
3392
|
+
.focus()
|
|
3393
|
+
.deleteRange({ from: deleteFrom, to: currentPos })
|
|
3394
|
+
.insertContent({
|
|
3395
|
+
type: "skillReference",
|
|
3396
|
+
attrs: { name: skill.name, path: skill.path, source: skill.source },
|
|
3397
|
+
})
|
|
3398
|
+
.insertContent(" ")
|
|
3399
|
+
.run();
|
|
3400
|
+
popoverStateRef.current = null;
|
|
3401
|
+
setPopover(null);
|
|
3402
|
+
}
|
|
3403
|
+
|
|
3404
|
+
// Popover select handlers for click-based selection (from MentionPopover)
|
|
3405
|
+
const handleSelectMention = useCallback(
|
|
3406
|
+
(item: MentionItem) => {
|
|
3407
|
+
if (!isComposerEditorUsable(editor) || !popover) return;
|
|
3408
|
+
const currentPos = editor.state.selection.from;
|
|
3409
|
+
const deleteFrom = Math.max(0, popover.startPos - 1);
|
|
3410
|
+
editor
|
|
3411
|
+
.chain()
|
|
3412
|
+
.focus()
|
|
3413
|
+
.deleteRange({ from: deleteFrom, to: currentPos })
|
|
3414
|
+
.run();
|
|
3415
|
+
insertReference(composerReferenceFromMentionItem(item));
|
|
3416
|
+
closePopover();
|
|
3417
|
+
},
|
|
3418
|
+
[editor, popover, closePopover, insertReference],
|
|
3419
|
+
);
|
|
3420
|
+
|
|
3421
|
+
const handleSelectCommand = useCallback(
|
|
3422
|
+
(command: SlashCommand) => {
|
|
3423
|
+
if (!isComposerEditorUsable(editor) || !popover) return;
|
|
3424
|
+
const currentPos = editor.state.selection.from;
|
|
3425
|
+
const deleteFrom = Math.max(0, popover.startPos - 1);
|
|
3426
|
+
editor
|
|
3427
|
+
.chain()
|
|
3428
|
+
.focus()
|
|
3429
|
+
.deleteRange({ from: deleteFrom, to: currentPos })
|
|
3430
|
+
.run();
|
|
3431
|
+
closePopover();
|
|
3432
|
+
onSlashCommand?.(command.name);
|
|
3433
|
+
},
|
|
3434
|
+
[editor, popover, closePopover, onSlashCommand],
|
|
3435
|
+
);
|
|
3436
|
+
|
|
3437
|
+
const handleSelectSkill = useCallback(
|
|
3438
|
+
(skill: SkillResult) => {
|
|
3439
|
+
if (!isComposerEditorUsable(editor) || !popover) return;
|
|
3440
|
+
const currentPos = editor.state.selection.from;
|
|
3441
|
+
const deleteFrom = Math.max(0, popover.startPos - 1);
|
|
3442
|
+
editor
|
|
3443
|
+
.chain()
|
|
3444
|
+
.focus()
|
|
3445
|
+
.deleteRange({ from: deleteFrom, to: currentPos })
|
|
3446
|
+
.insertContent({
|
|
3447
|
+
type: "skillReference",
|
|
3448
|
+
attrs: { name: skill.name, path: skill.path, source: skill.source },
|
|
3449
|
+
})
|
|
3450
|
+
.insertContent(" ")
|
|
3451
|
+
.run();
|
|
3452
|
+
closePopover();
|
|
3453
|
+
},
|
|
3454
|
+
[editor, popover, closePopover],
|
|
3455
|
+
);
|
|
3456
|
+
|
|
3457
|
+
// Track query text as user types after trigger
|
|
3458
|
+
useEffect(() => {
|
|
3459
|
+
if (!isComposerEditorUsable(editor) || !popover) return;
|
|
3460
|
+
|
|
3461
|
+
const updateHandler = () => {
|
|
3462
|
+
const pop = popoverStateRef.current;
|
|
3463
|
+
if (!pop) return;
|
|
3464
|
+
const { from } = editor.state.selection;
|
|
3465
|
+
const { startPos, type } = pop;
|
|
3466
|
+
|
|
3467
|
+
if (from < startPos) {
|
|
3468
|
+
closePopover();
|
|
3469
|
+
return;
|
|
3470
|
+
}
|
|
3471
|
+
|
|
3472
|
+
const text = editor.state.doc.textBetween(startPos, from);
|
|
3473
|
+
|
|
3474
|
+
// Verify the trigger character is still there
|
|
3475
|
+
if (startPos > 0) {
|
|
3476
|
+
const triggerChar = editor.state.doc.textBetween(
|
|
3477
|
+
startPos - 1,
|
|
3478
|
+
startPos,
|
|
3479
|
+
);
|
|
3480
|
+
if (
|
|
3481
|
+
(type === "@" && triggerChar !== "@") ||
|
|
3482
|
+
(type === "/" && triggerChar !== "/")
|
|
3483
|
+
) {
|
|
3484
|
+
closePopover();
|
|
3485
|
+
return;
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
|
|
3489
|
+
if (pop.query === text) return;
|
|
3490
|
+
const updated = { ...pop, query: text };
|
|
3491
|
+
popoverStateRef.current = updated;
|
|
3492
|
+
setPopover(updated);
|
|
3493
|
+
};
|
|
3494
|
+
|
|
3495
|
+
editor.on("update", updateHandler);
|
|
3496
|
+
editor.on("selectionUpdate", updateHandler);
|
|
3497
|
+
return () => {
|
|
3498
|
+
if (isComposerEditorUsable(editor)) {
|
|
3499
|
+
editor.off("update", updateHandler);
|
|
3500
|
+
editor.off("selectionUpdate", updateHandler);
|
|
3501
|
+
}
|
|
3502
|
+
};
|
|
3503
|
+
}, [editor, popover, closePopover]);
|
|
3504
|
+
|
|
3505
|
+
useEffect(() => {
|
|
3506
|
+
if (!isComposerEditorUsable(editor)) return;
|
|
3507
|
+
if (composerText !== "") return;
|
|
3508
|
+
if (editor.isEmpty) return;
|
|
3509
|
+
editor.commands.clearContent();
|
|
3510
|
+
}, [composerText, editor]);
|
|
3511
|
+
|
|
3512
|
+
useEffect(() => {
|
|
3513
|
+
if (!isComposerEditorUsable(editor) || initialText === undefined) return;
|
|
3514
|
+
const key = initialTextKey ?? initialText;
|
|
3515
|
+
if (initialTextKeyRef.current === key) return;
|
|
3516
|
+
initialTextKeyRef.current = key;
|
|
3517
|
+
editor.commands.setContent(plainTextToDoc(initialText));
|
|
3518
|
+
editor.commands.focus("end");
|
|
3519
|
+
const trimmed = editor.state.doc.textContent.trim();
|
|
3520
|
+
setEditorHasText(trimmed.length > 0);
|
|
3521
|
+
composerRuntime.setText(trimmed);
|
|
3522
|
+
onTextChangeRef.current?.(trimmed);
|
|
3523
|
+
try {
|
|
3524
|
+
if (trimmed) {
|
|
3525
|
+
localStorage.setItem(draftKey, editor.getHTML());
|
|
3526
|
+
} else {
|
|
3527
|
+
localStorage.removeItem(draftKey);
|
|
3528
|
+
}
|
|
3529
|
+
} catch {}
|
|
3530
|
+
}, [composerRuntime, draftKey, editor, initialText, initialTextKey]);
|
|
3531
|
+
|
|
3532
|
+
// Tiptap only reads `editable` at init; prop changes need setEditable.
|
|
3533
|
+
useEffect(() => {
|
|
3534
|
+
if (!isComposerEditorUsable(editor)) return;
|
|
3535
|
+
editor.setEditable(!disabled);
|
|
3536
|
+
if (disabled) editor.commands.blur();
|
|
3537
|
+
}, [editor, disabled]);
|
|
3538
|
+
|
|
3539
|
+
return (
|
|
3540
|
+
<RealtimeVoiceModeBoundary>
|
|
3541
|
+
<style>{`
|
|
3542
|
+
.aui-composer .ProseMirror p.is-editor-empty:first-child::before {
|
|
3543
|
+
content: attr(data-placeholder);
|
|
3544
|
+
color: var(--color-muted-foreground);
|
|
3545
|
+
opacity: 0.5;
|
|
3546
|
+
float: left;
|
|
3547
|
+
height: 0;
|
|
3548
|
+
pointer-events: none;
|
|
3549
|
+
}
|
|
3550
|
+
`}</style>
|
|
3551
|
+
{composerMode && (
|
|
3552
|
+
<div
|
|
3553
|
+
data-agent-composer-variant={layoutVariant}
|
|
3554
|
+
data-agent-composer-slot="mode-row"
|
|
3555
|
+
className="agent-composer-mode-row px-2.5 pt-2 pb-0"
|
|
3556
|
+
>
|
|
3557
|
+
<ComposerModeChip
|
|
3558
|
+
mode={composerMode}
|
|
3559
|
+
onRemove={() => {
|
|
3560
|
+
setComposerMode(null);
|
|
3561
|
+
composerModeRef.current = null;
|
|
3562
|
+
if (isComposerEditorUsable(editor)) {
|
|
3563
|
+
editor.commands.focus("end");
|
|
3564
|
+
}
|
|
3565
|
+
}}
|
|
3566
|
+
/>
|
|
3567
|
+
</div>
|
|
3568
|
+
)}
|
|
3569
|
+
{hasContextRows && (
|
|
3570
|
+
<div
|
|
3571
|
+
data-agent-composer-variant={layoutVariant}
|
|
3572
|
+
data-agent-composer-slot="context-row"
|
|
3573
|
+
className="agent-composer-context-row flex flex-wrap gap-1.5 px-2.5 pt-2 pb-0"
|
|
3574
|
+
>
|
|
3575
|
+
{slotReferences.map((ref) => (
|
|
3576
|
+
<span
|
|
3577
|
+
key={ref.slotKey}
|
|
3578
|
+
className="inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-background px-2 py-1 text-[11px] font-medium text-foreground shadow-sm"
|
|
3579
|
+
>
|
|
3580
|
+
<IconClipboardList className="h-3 w-3 shrink-0 text-muted-foreground" />
|
|
3581
|
+
{ref.slotLabel && (
|
|
3582
|
+
<span className="shrink-0 text-muted-foreground">
|
|
3583
|
+
{ref.slotLabel}
|
|
3584
|
+
</span>
|
|
3585
|
+
)}
|
|
3586
|
+
<span className="min-w-0 truncate">{ref.label}</span>
|
|
3587
|
+
<button
|
|
3588
|
+
type="button"
|
|
3589
|
+
onClick={() => {
|
|
3590
|
+
setSlotReferences((current) =>
|
|
3591
|
+
removeSlotReference(current, ref),
|
|
3592
|
+
);
|
|
3593
|
+
if (isComposerEditorUsable(editor)) {
|
|
3594
|
+
editor.commands.focus("end");
|
|
3595
|
+
}
|
|
3596
|
+
}}
|
|
3597
|
+
aria-label={t("agentChat.composer.removeReference", {
|
|
3598
|
+
defaultValue: "Remove {{name}} reference",
|
|
3599
|
+
name: slotReferenceTitle(ref),
|
|
3600
|
+
})}
|
|
3601
|
+
className="ms-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground"
|
|
3602
|
+
>
|
|
3603
|
+
<IconX className="h-3 w-3" />
|
|
3604
|
+
</button>
|
|
3605
|
+
</span>
|
|
3606
|
+
))}
|
|
3607
|
+
{contextItems.map((item) => (
|
|
3608
|
+
<span
|
|
3609
|
+
key={item.key}
|
|
3610
|
+
data-state={
|
|
3611
|
+
selectedContextItemKey === item.key ? "selected" : undefined
|
|
3612
|
+
}
|
|
3613
|
+
className={`inline-flex max-w-full items-center gap-1.5 rounded-md border px-2 py-1 text-[11px] font-medium text-foreground ${
|
|
3614
|
+
selectedContextItemKey === item.key
|
|
3615
|
+
? "border-ring bg-accent ring-2 ring-ring/40"
|
|
3616
|
+
: "border-border bg-muted/50"
|
|
3617
|
+
}`}
|
|
3618
|
+
>
|
|
3619
|
+
<IconClipboardList className="h-3 w-3 shrink-0 text-muted-foreground" />
|
|
3620
|
+
<span className="min-w-0 truncate">{item.title}</span>
|
|
3621
|
+
<button
|
|
3622
|
+
type="button"
|
|
3623
|
+
onClick={() => {
|
|
3624
|
+
selectedContextItemKeyRef.current = null;
|
|
3625
|
+
setSelectedContextItemKey(null);
|
|
3626
|
+
onRemoveContextItem?.(item.key);
|
|
3627
|
+
}}
|
|
3628
|
+
aria-label={t("agentChat.composer.removeContext", {
|
|
3629
|
+
defaultValue: "Remove {{name}} context",
|
|
3630
|
+
name: item.title,
|
|
3631
|
+
})}
|
|
3632
|
+
className="ms-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground"
|
|
3633
|
+
>
|
|
3634
|
+
<IconX className="h-3 w-3" />
|
|
3635
|
+
</button>
|
|
3636
|
+
</span>
|
|
3637
|
+
))}
|
|
3638
|
+
</div>
|
|
3639
|
+
)}
|
|
3640
|
+
<div
|
|
3641
|
+
data-agent-composer-variant={layoutVariant}
|
|
3642
|
+
data-agent-composer-slot="editor-wrap"
|
|
3643
|
+
className={`agent-composer-editor-wrap ${
|
|
3644
|
+
composerMode || hasContextRows ? "px-2 pt-1 pb-1" : "px-2 pt-2 pb-1"
|
|
3645
|
+
}`}
|
|
3646
|
+
>
|
|
3647
|
+
<EditorContent
|
|
3648
|
+
editor={editor}
|
|
3649
|
+
data-agent-composer-variant={layoutVariant}
|
|
3650
|
+
data-agent-composer-slot="editor"
|
|
3651
|
+
className="agent-composer-editor aui-composer flex-1 min-w-0 [&_.ProseMirror]:outline-none [&_.ProseMirror_p]:m-0 px-0.5"
|
|
3652
|
+
/>
|
|
3653
|
+
</div>
|
|
3654
|
+
{voiceEnabled && <VoiceRecordingOverlay voice={voice} />}
|
|
3655
|
+
<div
|
|
3656
|
+
data-agent-composer-variant={layoutVariant}
|
|
3657
|
+
data-agent-composer-slot="toolbar"
|
|
3658
|
+
className="agent-composer-toolbar flex items-center gap-1 px-2 py-1.5"
|
|
3659
|
+
>
|
|
3660
|
+
{attachButton ??
|
|
3661
|
+
(plusMenuMode === "hidden" ? null : (
|
|
3662
|
+
<ComposerPlusMenu
|
|
3663
|
+
onSelectMode={handleSelectMode}
|
|
3664
|
+
mode={plusMenuMode}
|
|
3665
|
+
terminalModeControl={terminalModeControl}
|
|
3666
|
+
extensionTools={extensionTools}
|
|
3667
|
+
onAttachmentError={onAttachmentError}
|
|
3668
|
+
/>
|
|
3669
|
+
))}
|
|
3670
|
+
{toolbarSlot ?? modeControl}
|
|
3671
|
+
<div data-agent-composer-slot="toolbar-spacer" className="flex-1" />
|
|
3672
|
+
{selectedModel && availableModels && onModelChange && (
|
|
3673
|
+
<ModelSelector
|
|
3674
|
+
model={selectedModel}
|
|
3675
|
+
open={modelSelectorOpen}
|
|
3676
|
+
effort={selectedEffort}
|
|
3677
|
+
engines={availableModels}
|
|
3678
|
+
agents={availableAgents}
|
|
3679
|
+
selectedAgent={selectedAgent}
|
|
3680
|
+
agentOnly={agentOnly}
|
|
3681
|
+
hostedHarness={hostedHarness}
|
|
3682
|
+
showAutoModelOption={showAutoModelOption}
|
|
3683
|
+
modelListLoading={modelListLoading}
|
|
3684
|
+
onChange={onModelChange}
|
|
3685
|
+
onEffortChange={onEffortChange}
|
|
3686
|
+
onAgentChange={onAgentChange}
|
|
3687
|
+
onModelSelectorOpenChange={onModelSelectorOpenChange}
|
|
3688
|
+
providerConnectStatusEnabled={providerConnectStatusEnabled}
|
|
3689
|
+
onConnectProvider={onConnectProvider}
|
|
3690
|
+
onConnectLocalRuntime={onConnectLocalRuntime}
|
|
3691
|
+
imageModel={imageModelMenu}
|
|
3692
|
+
/>
|
|
3693
|
+
)}
|
|
3694
|
+
{execMode && onExecModeChange && (
|
|
3695
|
+
<ModeSelector
|
|
3696
|
+
mode={execMode}
|
|
3697
|
+
onChange={onExecModeChange}
|
|
3698
|
+
planModeDisabled={planModeDisabled}
|
|
3699
|
+
planModeDisabledReason={planModeDisabledReason}
|
|
3700
|
+
/>
|
|
3701
|
+
)}
|
|
3702
|
+
{actionButton ?? (
|
|
3703
|
+
<>
|
|
3704
|
+
{extraActionButton}
|
|
3705
|
+
{voiceEnabled && (
|
|
3706
|
+
<VoiceButton voice={voice} isMac={isMac} disabled={disabled} />
|
|
3707
|
+
)}
|
|
3708
|
+
{primaryAction === "stop" ? (
|
|
3709
|
+
stopButton
|
|
3710
|
+
) : (
|
|
3711
|
+
<Tooltip>
|
|
3712
|
+
<TooltipTrigger asChild>
|
|
3713
|
+
<button
|
|
3714
|
+
type="button"
|
|
3715
|
+
onClick={() => void submitComposer("immediate")}
|
|
3716
|
+
disabled={!canSend}
|
|
3717
|
+
data-agent-composer-slot="send-button"
|
|
3718
|
+
className="agent-composer-send-button shrink-0 flex h-7 w-7 items-center justify-center rounded-md bg-primary text-primary-foreground hover:opacity-90 transition-[opacity,transform] duration-150 active:scale-[0.97] disabled:opacity-30 disabled:cursor-not-allowed"
|
|
3719
|
+
>
|
|
3720
|
+
<IconArrowUp className="h-3.5 w-3.5" />
|
|
3721
|
+
</button>
|
|
3722
|
+
</TooltipTrigger>
|
|
3723
|
+
<TooltipContent>{sendButtonTooltip}</TooltipContent>
|
|
3724
|
+
</Tooltip>
|
|
3725
|
+
)}
|
|
3726
|
+
</>
|
|
3727
|
+
)}
|
|
3728
|
+
</div>
|
|
3729
|
+
<MentionPopover
|
|
3730
|
+
ref={popoverRef}
|
|
3731
|
+
type={popover?.type ?? "@"}
|
|
3732
|
+
position={popover?.position ?? null}
|
|
3733
|
+
mentionItems={filteredMentionItems}
|
|
3734
|
+
skills={filteredSkills}
|
|
3735
|
+
commands={filteredCommands}
|
|
3736
|
+
hint={hint}
|
|
3737
|
+
isLoading={popover?.type === "@" ? mentionsLoading : skillsLoading}
|
|
3738
|
+
query={popover?.query ?? ""}
|
|
3739
|
+
onSelectMention={handleSelectMention}
|
|
3740
|
+
onSelectSkill={handleSelectSkill}
|
|
3741
|
+
onSelectCommand={handleSelectCommand}
|
|
3742
|
+
onClose={closePopover}
|
|
3743
|
+
/>
|
|
3744
|
+
</RealtimeVoiceModeBoundary>
|
|
3745
|
+
);
|
|
3746
|
+
}
|