@comma-agents/tui 2.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +10 -0
- package/dist/App/App.d.ts +24 -0
- package/dist/App/App.theme.d.ts +12 -0
- package/dist/App/App.types.d.ts +8 -0
- package/dist/App/index.d.ts +4 -0
- package/dist/Theme/DefineTheme.d.ts +53 -0
- package/dist/Theme/Theme.d.ts +11 -0
- package/dist/Theme/Theme.types.d.ts +100 -0
- package/dist/Theme/index.d.ts +9 -0
- package/dist/Theme/themes/dark.d.ts +14 -0
- package/dist/Theme/themes/dracula.d.ts +9 -0
- package/dist/Theme/themes/index.d.ts +25 -0
- package/dist/Theme/themes/light.d.ts +10 -0
- package/dist/Theme/themes/solarized-dark.d.ts +9 -0
- package/dist/Theme/useTheme/index.d.ts +3 -0
- package/dist/Theme/useTheme/useTheme.context.d.ts +31 -0
- package/dist/Theme/useTheme/useTheme.d.ts +11 -0
- package/dist/Theme/useTheme/useTheme.types.d.ts +10 -0
- package/dist/components/BorderedPanel/BorderedPanel.d.ts +70 -0
- package/dist/components/BorderedPanel/BorderedPanel.theme.d.ts +59 -0
- package/dist/components/BorderedPanel/index.d.ts +4 -0
- package/dist/components/Button/Button.d.ts +69 -0
- package/dist/components/Button/Button.theme.d.ts +50 -0
- package/dist/components/Button/Button.types.d.ts +9 -0
- package/dist/components/Button/index.d.ts +4 -0
- package/dist/components/ChatTextArea/ChatTextArea.d.ts +85 -0
- package/dist/components/ChatTextArea/ChatTextArea.theme.d.ts +34 -0
- package/dist/components/ChatTextArea/index.d.ts +2 -0
- package/dist/components/CodeView/CodeView.constants.d.ts +9 -0
- package/dist/components/CodeView/CodeView.d.ts +23 -0
- package/dist/components/CodeView/CodeView.theme.d.ts +26 -0
- package/dist/components/CodeView/index.d.ts +4 -0
- package/dist/components/CommandPalette/CommandPalette.constants.d.ts +8 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +62 -0
- package/dist/components/CommandPalette/CommandPalette.theme.d.ts +50 -0
- package/dist/components/CommandPalette/CommandPalette.types.d.ts +50 -0
- package/dist/components/CommandPalette/CommandPalette.utils.d.ts +6 -0
- package/dist/components/CommandPalette/index.d.ts +5 -0
- package/dist/components/CommandPalette/pages/HelpPage/HelpPage.constants.d.ts +2 -0
- package/dist/components/CommandPalette/pages/HelpPage/HelpPage.d.ts +12 -0
- package/dist/components/CommandPalette/pages/HelpPage/HelpPage.types.d.ts +5 -0
- package/dist/components/CommandPalette/pages/HelpPage/index.d.ts +3 -0
- package/dist/components/CommandPalette/pages/ListProvidersPage/ListProvidersPage.d.ts +42 -0
- package/dist/components/CommandPalette/pages/ListProvidersPage/index.d.ts +1 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/RegisteredProvidersPage.constants.d.ts +3 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/RegisteredProvidersPage.d.ts +40 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/RegisteredProvidersPage.types.d.ts +13 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/RegisteredProvidersPage.utils.d.ts +9 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/index.d.ts +2 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/RunPickerPage.constants.d.ts +3 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/RunPickerPage.d.ts +31 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/RunPickerPage.types.d.ts +8 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/RunPickerPage.utils.d.ts +7 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/index.d.ts +3 -0
- package/dist/components/CommandPalette/pages/SettingsPage/SettingsPage.d.ts +24 -0
- package/dist/components/CommandPalette/pages/SettingsPage/index.d.ts +2 -0
- package/dist/components/Frame/Frame.d.ts +48 -0
- package/dist/components/Frame/Frame.theme.d.ts +52 -0
- package/dist/components/Frame/index.d.ts +4 -0
- package/dist/components/Hide/Hide.d.ts +20 -0
- package/dist/components/Hide/Hide.types.d.ts +12 -0
- package/dist/components/Hide/index.d.ts +2 -0
- package/dist/components/MessageList/AgentMessage/AgentMessage.d.ts +71 -0
- package/dist/components/MessageList/AgentMessage/index.d.ts +2 -0
- package/dist/components/MessageList/ContextUsageModal/ContextUsageModal.constants.d.ts +2 -0
- package/dist/components/MessageList/ContextUsageModal/ContextUsageModal.d.ts +9 -0
- package/dist/components/MessageList/ContextUsageModal/ContextUsageModal.types.d.ts +12 -0
- package/dist/components/MessageList/ContextUsageModal/index.d.ts +4 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.constants.d.ts +51 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.d.ts +34 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.theme.d.ts +89 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.types.d.ts +96 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.utils.d.ts +58 -0
- package/dist/components/MessageList/MarkdownView/index.d.ts +6 -0
- package/dist/components/MessageList/MessageList.d.ts +20 -0
- package/dist/components/MessageList/MessageList.theme.d.ts +170 -0
- package/dist/components/MessageList/MessageList.types.d.ts +26 -0
- package/dist/components/MessageList/OutputModal/OutputModal.constants.d.ts +22 -0
- package/dist/components/MessageList/OutputModal/OutputModal.d.ts +37 -0
- package/dist/components/MessageList/OutputModal/OutputModal.theme.d.ts +68 -0
- package/dist/components/MessageList/OutputModal/OutputModal.types.d.ts +56 -0
- package/dist/components/MessageList/OutputModal/OutputModal.utils.d.ts +3 -0
- package/dist/components/MessageList/OutputModal/index.d.ts +6 -0
- package/dist/components/MessageList/SpawnedStrategyView/SpawnedStrategyView.d.ts +47 -0
- package/dist/components/MessageList/SpawnedStrategyView/SpawnedStrategyView.theme.d.ts +58 -0
- package/dist/components/MessageList/SpawnedStrategyView/index.d.ts +4 -0
- package/dist/components/MessageList/SystemMessage/SystemMessage.d.ts +21 -0
- package/dist/components/MessageList/SystemMessage/index.d.ts +2 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.constants.d.ts +42 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.d.ts +71 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.theme.d.ts +47 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.types.d.ts +60 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.utils.d.ts +40 -0
- package/dist/components/MessageList/ToolCallView/index.d.ts +8 -0
- package/dist/components/MessageList/UserMessage/UserMessage.d.ts +25 -0
- package/dist/components/MessageList/UserMessage/index.d.ts +2 -0
- package/dist/components/MessageList/index.d.ts +14 -0
- package/dist/components/Modal/Modal.d.ts +64 -0
- package/dist/components/Modal/Modal.theme.d.ts +29 -0
- package/dist/components/Modal/index.d.ts +4 -0
- package/dist/components/MouseProvider/MouseContext.d.ts +36 -0
- package/dist/components/MouseProvider/MouseProvider.d.ts +20 -0
- package/dist/components/MouseProvider/index.d.ts +4 -0
- package/dist/components/PermissionPrompt/PermissionPrompt.d.ts +33 -0
- package/dist/components/PermissionPrompt/index.d.ts +2 -0
- package/dist/components/QuestionPrompt/QuestionPrompt.d.ts +4 -0
- package/dist/components/QuestionPrompt/QuestionPrompt.types.d.ts +18 -0
- package/dist/components/QuestionPrompt/index.d.ts +2 -0
- package/dist/components/ScrollableList/ScrollableList.d.ts +33 -0
- package/dist/components/ScrollableList/ScrollableList.theme.d.ts +33 -0
- package/dist/components/ScrollableList/ScrollableList.types.d.ts +66 -0
- package/dist/components/ScrollableList/index.d.ts +4 -0
- package/dist/components/ScrollableView/ScrollableView.d.ts +34 -0
- package/dist/components/ScrollableView/ScrollableView.theme.d.ts +34 -0
- package/dist/components/ScrollableView/ScrollableView.types.d.ts +113 -0
- package/dist/components/ScrollableView/index.d.ts +4 -0
- package/dist/components/Scrollbar/Scrollbar.d.ts +21 -0
- package/dist/components/Scrollbar/Scrollbar.theme.d.ts +16 -0
- package/dist/components/Scrollbar/Scrollbar.types.d.ts +27 -0
- package/dist/components/Scrollbar/Scrollbar.utils.d.ts +21 -0
- package/dist/components/Scrollbar/index.d.ts +4 -0
- package/dist/components/SearchInput/SearchInput.d.ts +22 -0
- package/dist/components/SearchInput/SearchInput.theme.d.ts +30 -0
- package/dist/components/SearchInput/SearchInput.types.d.ts +25 -0
- package/dist/components/SearchInput/SearchInput.utils.d.ts +22 -0
- package/dist/components/SearchInput/index.d.ts +5 -0
- package/dist/components/Separator/Separator.d.ts +39 -0
- package/dist/components/Separator/Separator.theme.d.ts +22 -0
- package/dist/components/Separator/index.d.ts +4 -0
- package/dist/components/StatusBar/StatusBar.d.ts +4 -0
- package/dist/components/StatusBar/StatusBar.theme.d.ts +35 -0
- package/dist/components/StatusBar/StatusBar.types.d.ts +24 -0
- package/dist/components/StatusBar/index.d.ts +2 -0
- package/dist/components/TextAreaInput/TextAreaInput.d.ts +68 -0
- package/dist/components/TextAreaInput/TextAreaInput.theme.d.ts +14 -0
- package/dist/components/TextAreaInput/TextAreaInput.utils.d.ts +69 -0
- package/dist/components/TextAreaInput/index.d.ts +2 -0
- package/dist/components/TitleIcon/TitleIcon.d.ts +13 -0
- package/dist/components/TitleIcon/TitleIcon.theme.d.ts +19 -0
- package/dist/components/TitleIcon/index.d.ts +1 -0
- package/dist/components/index.d.ts +61 -0
- package/dist/hooks/index.d.ts +27 -0
- package/dist/hooks/useBreakpoint/index.d.ts +2 -0
- package/dist/hooks/useBreakpoint/useBreakpoint.d.ts +15 -0
- package/dist/hooks/useBreakpoint/useBreakpoint.types.d.ts +18 -0
- package/dist/hooks/useChat/index.d.ts +22 -0
- package/dist/hooks/useChat/useChat.context.d.ts +7 -0
- package/dist/hooks/useChat/useChat.d.ts +11 -0
- package/dist/hooks/useChat/useChat.types.d.ts +209 -0
- package/dist/hooks/useChat/useChat.utils.d.ts +18 -0
- package/dist/hooks/useChat/useChatActions.d.ts +10 -0
- package/dist/hooks/useChat/useChatAgentMessages/index.d.ts +1 -0
- package/dist/hooks/useChat/useChatAgentMessages/useChatAgentMessages.d.ts +2 -0
- package/dist/hooks/useChat/useChatInputRequests/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatInputRequests/useChatInputRequests.d.ts +3 -0
- package/dist/hooks/useChat/useChatInputRequests/useChatInputRequests.types.d.ts +4 -0
- package/dist/hooks/useChat/useChatLifecycle.d.ts +5 -0
- package/dist/hooks/useChat/useChatPermissionRequests/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatPermissionRequests/useChatPermissionRequestSubscriptions.d.ts +2 -0
- package/dist/hooks/useChat/useChatPermissionRequests/useChatPermissionRequests.d.ts +3 -0
- package/dist/hooks/useChat/useChatPermissionRequests/useChatPermissionRequests.types.d.ts +4 -0
- package/dist/hooks/useChat/useChatQuestionRequests/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatQuestionRequests/useChatQuestionRequestSubscriptions.d.ts +2 -0
- package/dist/hooks/useChat/useChatQuestionRequests/useChatQuestionRequests.d.ts +3 -0
- package/dist/hooks/useChat/useChatQuestionRequests/useChatQuestionRequests.types.d.ts +4 -0
- package/dist/hooks/useChat/useChatRunLifecycle/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatRunLifecycle/useChatRunLifecycle.d.ts +3 -0
- package/dist/hooks/useChat/useChatRunLifecycle/useChatRunLifecycle.types.d.ts +11 -0
- package/dist/hooks/useChat/useChatRunLifecycle/useChatRunLifecycleSubscriptions.d.ts +2 -0
- package/dist/hooks/useChat/useChatRunStore/index.d.ts +1 -0
- package/dist/hooks/useChat/useChatRunStore/useChatRunStore.d.ts +3 -0
- package/dist/hooks/useChat/useChatRuns.d.ts +10 -0
- package/dist/hooks/useChat/useChatState.d.ts +17 -0
- package/dist/hooks/useChat/useChatSteering/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatSteering/useChatSteering.d.ts +3 -0
- package/dist/hooks/useChat/useChatSteering/useChatSteering.types.d.ts +4 -0
- package/dist/hooks/useChat/useChatStepMessages/index.d.ts +1 -0
- package/dist/hooks/useChat/useChatStepMessages/useChatStepMessages.d.ts +2 -0
- package/dist/hooks/useChat/usePersistedRunList/index.d.ts +2 -0
- package/dist/hooks/useChat/usePersistedRunList/usePersistedRunList.d.ts +3 -0
- package/dist/hooks/useChat/usePersistedRunList/usePersistedRunList.types.d.ts +5 -0
- package/dist/hooks/useDaemon/index.d.ts +6 -0
- package/dist/hooks/useDaemon/useDaemon.context.d.ts +18 -0
- package/dist/hooks/useDaemon/useDaemon.d.ts +7 -0
- package/dist/hooks/useDaemon/useDaemon.types.d.ts +62 -0
- package/dist/hooks/useDaemon/useDaemonCommand/index.d.ts +2 -0
- package/dist/hooks/useDaemon/useDaemonCommand/useDaemonCommand.d.ts +20 -0
- package/dist/hooks/useDaemon/useDaemonCommand/useDaemonCommand.types.d.ts +28 -0
- package/dist/hooks/useDaemon/useDaemonSubscription/index.d.ts +1 -0
- package/dist/hooks/useDaemon/useDaemonSubscription/useDaemonSubscription.d.ts +18 -0
- package/dist/hooks/useDebugRender/index.d.ts +2 -0
- package/dist/hooks/useDebugRender/useDebugRender.constants.d.ts +18 -0
- package/dist/hooks/useDebugRender/useDebugRender.d.ts +35 -0
- package/dist/hooks/useDebugRender/useDebugRender.types.d.ts +60 -0
- package/dist/hooks/useDebugRender/useDebugRender.utils.d.ts +34 -0
- package/dist/hooks/useLogs/index.d.ts +3 -0
- package/dist/hooks/useLogs/logStore.d.ts +18 -0
- package/dist/hooks/useLogs/useLogs.constants.d.ts +2 -0
- package/dist/hooks/useLogs/useLogs.d.ts +15 -0
- package/dist/hooks/useLogs/useLogs.types.d.ts +47 -0
- package/dist/hooks/useLogs/useLogs.utils.d.ts +13 -0
- package/dist/hooks/useModal/index.d.ts +3 -0
- package/dist/hooks/useModal/useModal.context.d.ts +20 -0
- package/dist/hooks/useModal/useModal.d.ts +22 -0
- package/dist/hooks/useModal/useModal.types.d.ts +49 -0
- package/dist/hooks/useMouse/index.d.ts +2 -0
- package/dist/hooks/useMouse/useMouse.types.d.ts +43 -0
- package/dist/hooks/useMouse/useMouse.utils.d.ts +30 -0
- package/dist/hooks/useMouseClick/index.d.ts +2 -0
- package/dist/hooks/useMouseClick/useMouseClick.d.ts +23 -0
- package/dist/hooks/useMouseClick/useMouseClick.types.d.ts +28 -0
- package/dist/hooks/useMouseHover/index.d.ts +2 -0
- package/dist/hooks/useMouseHover/useMouseHover.d.ts +25 -0
- package/dist/hooks/useMouseHover/useMouseHover.types.d.ts +38 -0
- package/dist/hooks/useMouseWheelScroll/index.d.ts +2 -0
- package/dist/hooks/useMouseWheelScroll/useMouseWheelScroll.d.ts +28 -0
- package/dist/hooks/useMouseWheelScroll/useMouseWheelScroll.types.d.ts +32 -0
- package/dist/hooks/useRegion/index.d.ts +3 -0
- package/dist/hooks/useRegion/useRegion.d.ts +21 -0
- package/dist/hooks/useRegion/useRegion.types.d.ts +41 -0
- package/dist/hooks/useRegion/useRegion.utils.d.ts +51 -0
- package/dist/hooks/useStrategies/useStrategies.d.ts +10 -0
- package/dist/hooks/useToolSpinner/index.d.ts +1 -0
- package/dist/hooks/useToolSpinner/useToolSpinner.d.ts +28 -0
- package/dist/hooks/useUserConfig/index.d.ts +4 -0
- package/dist/hooks/useUserConfig/useUserConfig.constants.d.ts +17 -0
- package/dist/hooks/useUserConfig/useUserConfig.context.d.ts +9 -0
- package/dist/hooks/useUserConfig/useUserConfig.d.ts +9 -0
- package/dist/hooks/useUserConfig/useUserConfig.types.d.ts +30 -0
- package/dist/hooks/useUserConfig/useUserConfig.utils.d.ts +19 -0
- package/dist/hooks/useWebSocket/index.d.ts +2 -0
- package/dist/hooks/useWebSocket/useWebSocket.d.ts +17 -0
- package/dist/hooks/useWebSocket/useWebSocket.types.d.ts +27 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10592 -0
- package/dist/main.js +10655 -0
- package/dist/pages/ChatPage/ChatPage.constants.d.ts +2 -0
- package/dist/pages/ChatPage/ChatPage.d.ts +25 -0
- package/dist/pages/ChatPage/ChatPage.theme.d.ts +56 -0
- package/dist/pages/ChatPage/index.d.ts +4 -0
- package/dist/pages/IntroPage/IntroPage.d.ts +14 -0
- package/dist/pages/IntroPage/IntroPage.theme.d.ts +13 -0
- package/dist/pages/IntroPage/index.d.ts +4 -0
- package/dist/pages/LogsPage/LogsPage.d.ts +14 -0
- package/dist/pages/LogsPage/LogsPage.theme.d.ts +49 -0
- package/dist/pages/LogsPage/LogsPage.utils.d.ts +5 -0
- package/dist/pages/LogsPage/index.d.ts +4 -0
- package/dist/pages/SpawnedStrategyPage/SpawnedStrategyPage.d.ts +12 -0
- package/dist/pages/SpawnedStrategyPage/index.d.ts +2 -0
- package/dist/run-tui.d.ts +12 -0
- package/dist/run-tui.types.d.ts +12 -0
- package/dist/utils/debug.d.ts +12 -0
- package/dist/utils/mouseEscape.d.ts +29 -0
- package/dist/utils/yogaLayout.d.ts +32 -0
- package/package.json +66 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { UseMouseHoverOptions, UseMouseHoverResult } from "./useMouseHover.types";
|
|
2
|
+
/**
|
|
3
|
+
* Track whether the mouse cursor is hovering over a specific element.
|
|
4
|
+
*
|
|
5
|
+
* Requires `?1003h` (any-event motion tracking) which {@link MouseProvider}
|
|
6
|
+
* enables automatically while at least one `useMouseHover` hook is mounted.
|
|
7
|
+
* Wrap the component tree in `<MouseProvider>` (done by `<Frame>`) before
|
|
8
|
+
* using this hook.
|
|
9
|
+
*
|
|
10
|
+
* AABB hit-testing is performed on every mouse event by walking the Yoga
|
|
11
|
+
* layout tree. The `isHovered` boolean only triggers a re-render on
|
|
12
|
+
* enter/leave transitions to minimise unnecessary renders.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* const ref = useRef<DOMElement>(null);
|
|
17
|
+
* const { isHovered } = useMouseHover({
|
|
18
|
+
* ref,
|
|
19
|
+
* onEnter: () => console.log("entered"),
|
|
20
|
+
* onLeave: () => console.log("left"),
|
|
21
|
+
* });
|
|
22
|
+
* return <Box ref={ref} backgroundColor={isHovered ? "blue" : undefined} />;
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function useMouseHover({ ref, onEnter, onLeave, onMove, }: UseMouseHoverOptions): UseMouseHoverResult;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { DOMElement } from "ink";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { MouseEvent } from "../useMouse/useMouse.types";
|
|
4
|
+
/**
|
|
5
|
+
* Options accepted by {@link useMouseHover}.
|
|
6
|
+
*/
|
|
7
|
+
export interface UseMouseHoverOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Ref to the `DOMElement` (Ink `<Box>` or similar) whose bounds are used
|
|
10
|
+
* for hit-testing. The element must be mounted before hover events fire.
|
|
11
|
+
*/
|
|
12
|
+
readonly ref: React.RefObject<DOMElement | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Called once when the mouse cursor enters the element's bounding box.
|
|
15
|
+
* Receives the first mouse event that triggered the transition.
|
|
16
|
+
*/
|
|
17
|
+
readonly onEnter?: (event: MouseEvent) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Called once when the mouse cursor leaves the element's bounding box.
|
|
20
|
+
* Receives the first mouse event that triggered the transition.
|
|
21
|
+
*/
|
|
22
|
+
readonly onLeave?: (event: MouseEvent) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Called for every mouse event while the cursor is inside the bounding box.
|
|
25
|
+
* This includes the first event that triggered `onEnter`.
|
|
26
|
+
*/
|
|
27
|
+
readonly onMove?: (event: MouseEvent) => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Result returned by {@link useMouseHover}.
|
|
31
|
+
*/
|
|
32
|
+
export interface UseMouseHoverResult {
|
|
33
|
+
/**
|
|
34
|
+
* `true` while the mouse cursor is inside the element's bounding box,
|
|
35
|
+
* `false` otherwise. Transitions cause a re-render of the consumer.
|
|
36
|
+
*/
|
|
37
|
+
readonly isHovered: boolean;
|
|
38
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { UseMouseWheelScrollOptions } from "./useMouseWheelScroll.types";
|
|
2
|
+
/**
|
|
3
|
+
* Subscribe to mouse-wheel scroll events via the global {@link MouseProvider}
|
|
4
|
+
* event bus.
|
|
5
|
+
*
|
|
6
|
+
* Shares the single `useInput` subscription in {@link MouseProvider} with all
|
|
7
|
+
* other mouse hooks rather than registering its own.
|
|
8
|
+
*
|
|
9
|
+
* Optionally accepts a `ref` for AABB hit-testing: when provided, only wheel
|
|
10
|
+
* ticks whose terminal coordinates fall inside the element's bounding box are
|
|
11
|
+
* forwarded to `onScroll`. This is useful when multiple scrollable regions
|
|
12
|
+
* are on screen simultaneously — each can restrict its listener to its own
|
|
13
|
+
* box without coordinating with siblings.
|
|
14
|
+
*
|
|
15
|
+
* Requires `<MouseProvider>` to be mounted (provided by `<Frame>`).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* // Global — any wheel tick triggers onScroll.
|
|
20
|
+
* useMouseWheelScroll({ onScroll: ({ direction }) => step(direction) });
|
|
21
|
+
*
|
|
22
|
+
* // Scoped — only ticks inside this element trigger onScroll.
|
|
23
|
+
* const ref = useRef<DOMElement>(null);
|
|
24
|
+
* useMouseWheelScroll({ ref, onScroll: ({ direction }) => step(direction) });
|
|
25
|
+
* return <Box ref={ref}>...</Box>;
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function useMouseWheelScroll({ onScroll, ref, }: UseMouseWheelScrollOptions): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Direction of a mouse-wheel scroll tick. */
|
|
2
|
+
export type MouseScrollDirection = "up" | "down";
|
|
3
|
+
/**
|
|
4
|
+
* A parsed mouse-scroll event delivered to {@link useMouseWheelScroll}'s
|
|
5
|
+
* `onScroll` callback.
|
|
6
|
+
*
|
|
7
|
+
* Coordinates follow the SGR (1006) protocol: `column` and `row` are
|
|
8
|
+
* 1-indexed terminal cell coordinates reported by the terminal at the time
|
|
9
|
+
* the scroll tick was emitted.
|
|
10
|
+
*/
|
|
11
|
+
export interface MouseScrollEvent {
|
|
12
|
+
readonly direction: MouseScrollDirection;
|
|
13
|
+
readonly column: number;
|
|
14
|
+
readonly row: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Options for {@link useMouseWheelScroll}.
|
|
18
|
+
*/
|
|
19
|
+
export interface UseMouseWheelScrollOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Invoked for every mouse-wheel tick whose position falls inside the
|
|
22
|
+
* element's bounding box, or for every tick regardless of position when
|
|
23
|
+
* `ref` is omitted.
|
|
24
|
+
*/
|
|
25
|
+
readonly onScroll: (event: MouseScrollEvent) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Optional ref to a `DOMElement`. When provided, only wheel ticks whose
|
|
28
|
+
* terminal coordinates land inside the element's bounding box are
|
|
29
|
+
* forwarded to `onScroll`. When omitted, all wheel ticks are forwarded.
|
|
30
|
+
*/
|
|
31
|
+
readonly ref?: React.RefObject<import("ink").DOMElement | null>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { useRegion } from "./useRegion";
|
|
2
|
+
export type { RegionDimensions, RegionHandle, RegionOptions, RegionPosition, } from "./useRegion.types";
|
|
3
|
+
export { buildRegionOutput, CURSOR_RESTORE, CURSOR_SAVE, cursorTo, fitToWidth, getAbsolutePosition, padToWidth, visibleLength, } from "./useRegion.utils";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RegionHandle, RegionOptions } from "./useRegion.types";
|
|
2
|
+
/**
|
|
3
|
+
* Reserve a rectangular region in Ink's layout and write to it
|
|
4
|
+
* directly via ANSI cursor positioning, bypassing Ink's renderer.
|
|
5
|
+
*
|
|
6
|
+
* Attach the returned `ref` to a placeholder `<Box>` with matching
|
|
7
|
+
* dimensions. Then call `write(lines)` to paint content into that
|
|
8
|
+
* region without triggering a React / Ink re-render.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const region = useRegion({ width: 40, height: 20 });
|
|
13
|
+
*
|
|
14
|
+
* useEffect(() => {
|
|
15
|
+
* region.write(["Hello, world!"]);
|
|
16
|
+
* }, [region]);
|
|
17
|
+
*
|
|
18
|
+
* return <Box ref={region.ref} width={40} height={20} />;
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function useRegion(options: RegionOptions): RegionHandle;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { DOMElement } from "ink";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
/** Configuration for a direct-write region. */
|
|
4
|
+
export interface RegionOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Width of the region in columns.
|
|
7
|
+
* Use `"auto"` to measure from the parent Box's Yoga layout.
|
|
8
|
+
*/
|
|
9
|
+
readonly width: number | "auto";
|
|
10
|
+
/** Height of the region in rows. */
|
|
11
|
+
readonly height: number;
|
|
12
|
+
}
|
|
13
|
+
/** Measured dimensions of the region's reserved area. */
|
|
14
|
+
export interface RegionDimensions {
|
|
15
|
+
/** Width in terminal columns. */
|
|
16
|
+
readonly width: number;
|
|
17
|
+
/** Height in terminal rows. */
|
|
18
|
+
readonly height: number;
|
|
19
|
+
}
|
|
20
|
+
/** Absolute position of the region within the terminal. */
|
|
21
|
+
export interface RegionPosition {
|
|
22
|
+
/** Row offset from the top of Ink's output (0-indexed). */
|
|
23
|
+
readonly top: number;
|
|
24
|
+
/** Column offset from the left edge (0-indexed). */
|
|
25
|
+
readonly left: number;
|
|
26
|
+
}
|
|
27
|
+
/** Handle returned by `useRegion`. */
|
|
28
|
+
export interface RegionHandle {
|
|
29
|
+
/** Ref to attach to the placeholder `<Box>`. */
|
|
30
|
+
readonly ref: React.Ref<DOMElement>;
|
|
31
|
+
/**
|
|
32
|
+
* Write lines directly to stdout at the region's position.
|
|
33
|
+
* Each element in `lines` corresponds to one terminal row.
|
|
34
|
+
* Lines are truncated or padded to the region width.
|
|
35
|
+
*/
|
|
36
|
+
readonly write: (lines: readonly string[]) => void;
|
|
37
|
+
/** Current measured dimensions of the region. */
|
|
38
|
+
readonly dimensions: RegionDimensions;
|
|
39
|
+
/** Current absolute position of the region within Ink's output. */
|
|
40
|
+
readonly position: RegionPosition;
|
|
41
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { getAbsolutePosition } from "../../utils/yogaLayout";
|
|
2
|
+
export { getAbsolutePosition };
|
|
3
|
+
/** ANSI escape: save cursor position. */
|
|
4
|
+
export declare const CURSOR_SAVE = "\u001B7";
|
|
5
|
+
/** ANSI escape: restore cursor position. */
|
|
6
|
+
export declare const CURSOR_RESTORE = "\u001B8";
|
|
7
|
+
/**
|
|
8
|
+
* ANSI CUP (Cursor Position) escape — moves cursor to an absolute
|
|
9
|
+
* row and column. Both are 1-indexed per the ANSI spec.
|
|
10
|
+
*/
|
|
11
|
+
export declare function cursorTo(row: number, col: number): string;
|
|
12
|
+
/**
|
|
13
|
+
* Build a single string that saves the cursor, writes each line at
|
|
14
|
+
* the correct absolute position, then restores the cursor.
|
|
15
|
+
*
|
|
16
|
+
* @param lines - Array of pre-formatted line strings (may contain ANSI color codes).
|
|
17
|
+
* @param top - 0-indexed row offset of the region's first line within Ink output.
|
|
18
|
+
* @param left - 0-indexed column offset of the region's left edge.
|
|
19
|
+
* @param width - Region width in columns. Lines shorter than this are right-padded
|
|
20
|
+
* with spaces to clear stale content.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildRegionOutput(lines: readonly string[], top: number, left: number, width: number): string;
|
|
23
|
+
/**
|
|
24
|
+
* Strip ANSI escape sequences from a string to calculate its
|
|
25
|
+
* visible character length.
|
|
26
|
+
*/
|
|
27
|
+
export declare function visibleLength(str: string): number;
|
|
28
|
+
/**
|
|
29
|
+
* Pad a string to at least `width` visible characters.
|
|
30
|
+
* ANSI escape sequences are not counted toward the width.
|
|
31
|
+
*
|
|
32
|
+
* Note: this does not truncate — use {@link fitToWidth} when you need both
|
|
33
|
+
* padding and clipping.
|
|
34
|
+
*/
|
|
35
|
+
export declare function padToWidth(str: string, width: number): string;
|
|
36
|
+
/**
|
|
37
|
+
* Pad or truncate a string to exactly `width` visible characters while
|
|
38
|
+
* preserving ANSI SGR (color/style) escape sequences.
|
|
39
|
+
*
|
|
40
|
+
* - If the visible length is less than `width`, the string is right-padded
|
|
41
|
+
* with spaces.
|
|
42
|
+
* - If the visible length exceeds `width`, the string is clipped at the
|
|
43
|
+
* `width`-th visible character. Any ANSI SGR escapes encountered before
|
|
44
|
+
* the clip point are preserved verbatim, and a reset (`\x1b[0m`) is
|
|
45
|
+
* appended if any escape was emitted, to prevent color bleeding into
|
|
46
|
+
* subsequent output.
|
|
47
|
+
*
|
|
48
|
+
* @param str - Input string, possibly containing ANSI SGR escapes.
|
|
49
|
+
* @param width - Target visible width in columns.
|
|
50
|
+
*/
|
|
51
|
+
export declare function fitToWidth(str: string, width: number): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DiscoveredStrategy } from "@comma-agents/core";
|
|
2
|
+
/**
|
|
3
|
+
* Discover available strategies once on mount.
|
|
4
|
+
*
|
|
5
|
+
* `discoverStrategies()` is async (parses & validates each candidate),
|
|
6
|
+
* so we kick it off in `useEffect` and store the result in state.
|
|
7
|
+
* Initial value is an empty array; the picker renders empty for a
|
|
8
|
+
* single frame and then populates.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useDiscoveredStrategies(): readonly DiscoveredStrategy[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TOOL_SPINNER_FRAMES, TOOL_SPINNER_INTERVAL_MS, useToolSpinner, } from "./useToolSpinner";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spinner glyph rotation used to indicate an in-flight tool call.
|
|
3
|
+
*
|
|
4
|
+
* Four-frame Braille-style rotation chosen for legibility on dark and
|
|
5
|
+
* light terminals while staying single-cell wide so it can sit at the
|
|
6
|
+
* head of a tool-call row without disturbing column alignment.
|
|
7
|
+
*/
|
|
8
|
+
export declare const TOOL_SPINNER_FRAMES: readonly ["◜", "◝", "◞", "◟"];
|
|
9
|
+
/**
|
|
10
|
+
* Animation interval in milliseconds. 120ms gives a perceptibly active
|
|
11
|
+
* spin without burning frames or causing terminals to drop redraws.
|
|
12
|
+
*/
|
|
13
|
+
export declare const TOOL_SPINNER_INTERVAL_MS = 120;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the current tool-spinner frame.
|
|
16
|
+
*
|
|
17
|
+
* - When `running` is `false`, the hook returns `null` and never
|
|
18
|
+
* subscribes to the shared tick — components rendering completed or
|
|
19
|
+
* errored tool calls pay zero re-render cost.
|
|
20
|
+
* - When `running` is `true`, the hook subscribes to the shared tick
|
|
21
|
+
* and re-renders the consuming component every {@link
|
|
22
|
+
* TOOL_SPINNER_INTERVAL_MS} ms with the next frame from {@link
|
|
23
|
+
* TOOL_SPINNER_FRAMES}.
|
|
24
|
+
*
|
|
25
|
+
* The shared interval is reference-counted: it starts when the first
|
|
26
|
+
* subscriber mounts and stops when the last one unmounts.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useToolSpinner(running: boolean): string | null;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useUserConfig } from "./useUserConfig";
|
|
2
|
+
export { CONFIG_FILE_NAME, CONFIG_SUBDIRECTORY, DEFAULT_USER_CONFIG, resolveConfigRoot, resolveDefaultConfigFilePath, } from "./useUserConfig.constants";
|
|
3
|
+
export { UserConfigContextProvider } from "./useUserConfig.context";
|
|
4
|
+
export type { UserConfig, UserConfigContextProviderProps, UserConfigContextType, } from "./useUserConfig.types";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { UserConfig } from "./useUserConfig.types";
|
|
2
|
+
/** Subdirectory under the OS config dir that holds all comma-agents files. */
|
|
3
|
+
export declare const CONFIG_SUBDIRECTORY = "comma-agents";
|
|
4
|
+
/** Filename of the persisted TUI configuration. */
|
|
5
|
+
export declare const CONFIG_FILE_NAME = "tui-config.json";
|
|
6
|
+
/** Defaults applied when no config file exists or fields are missing. */
|
|
7
|
+
export declare const DEFAULT_USER_CONFIG: UserConfig;
|
|
8
|
+
/**
|
|
9
|
+
* Resolve the platform-appropriate config directory root.
|
|
10
|
+
*
|
|
11
|
+
* - macOS: `~/Library/Application Support`
|
|
12
|
+
* - Windows: `%APPDATA%` (falls back to `~/AppData/Roaming`)
|
|
13
|
+
* - Linux/other: `$XDG_CONFIG_HOME` or `~/.config`
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveConfigRoot(): string;
|
|
16
|
+
/** Absolute path to the TUI config file for this user. */
|
|
17
|
+
export declare function resolveDefaultConfigFilePath(): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { UserConfigContextProviderProps, UserConfigContextType } from "./useUserConfig.types";
|
|
3
|
+
export declare const UserConfigContext: React.Context<UserConfigContextType | null>;
|
|
4
|
+
/**
|
|
5
|
+
* Loads the persisted user config synchronously on first render so the
|
|
6
|
+
* initial paint already uses the correct theme. Subsequent updates flush
|
|
7
|
+
* to disk asynchronously via `setConfig` / `updateConfig`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function UserConfigContextProvider({ configFilePath: configFilePathProp, children, }: UserConfigContextProviderProps): React.ReactElement;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { UserConfigContextType } from "./useUserConfig.types";
|
|
2
|
+
/**
|
|
3
|
+
* Access the current user configuration and mutators.
|
|
4
|
+
*
|
|
5
|
+
* Must be called from within a `<UserConfigContextProvider>`. Throws when
|
|
6
|
+
* no provider is present so a missing wiring fails loudly at the call site
|
|
7
|
+
* rather than surfacing as a confusing `undefined` deeper in rendering.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useUserConfig(): UserConfigContextType;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ThemeName } from "../../Theme";
|
|
2
|
+
/**
|
|
3
|
+
* Persisted user configuration for the TUI.
|
|
4
|
+
*
|
|
5
|
+
* Stored as JSON at `{config_dir}/comma-agents/tui-config.json`. New optional
|
|
6
|
+
* fields can be added without breaking older config files because
|
|
7
|
+
* `loadUserConfig` merges any partial input over the defaults.
|
|
8
|
+
*/
|
|
9
|
+
export interface UserConfig {
|
|
10
|
+
/** Active theme name. */
|
|
11
|
+
readonly themeName: ThemeName;
|
|
12
|
+
}
|
|
13
|
+
/** Public hook return type / React context value. */
|
|
14
|
+
export interface UserConfigContextType {
|
|
15
|
+
/** Current resolved user config (defaults merged in). */
|
|
16
|
+
readonly config: UserConfig;
|
|
17
|
+
/** Replace the config entirely. Persists to disk asynchronously. */
|
|
18
|
+
readonly setConfig: (next: UserConfig) => void;
|
|
19
|
+
/** Patch a subset of the config and persist. */
|
|
20
|
+
readonly updateConfig: (patch: Partial<UserConfig>) => void;
|
|
21
|
+
/** Absolute path to the config file on disk. */
|
|
22
|
+
readonly configFilePath: string;
|
|
23
|
+
}
|
|
24
|
+
/** Props for `UserConfigContextProvider`. */
|
|
25
|
+
export interface UserConfigContextProviderProps {
|
|
26
|
+
/** Optional override for the config file path (used in tests). */
|
|
27
|
+
readonly configFilePath?: string;
|
|
28
|
+
/** Child components that can consume the user config. */
|
|
29
|
+
readonly children: React.ReactNode;
|
|
30
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { UserConfig } from "./useUserConfig.types";
|
|
2
|
+
/**
|
|
3
|
+
* Sanitize a parsed JSON object into a valid `UserConfig`. Unknown or
|
|
4
|
+
* mistyped fields fall back to defaults so old config files keep working
|
|
5
|
+
* after schema additions.
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalizeUserConfig(raw: unknown): UserConfig;
|
|
8
|
+
/**
|
|
9
|
+
* Synchronously load the config file from disk. Returns defaults when the
|
|
10
|
+
* file does not exist or fails to parse — startup must never crash because
|
|
11
|
+
* of a corrupt config.
|
|
12
|
+
*/
|
|
13
|
+
export declare function loadUserConfig(filePath: string): UserConfig;
|
|
14
|
+
/**
|
|
15
|
+
* Persist the config file to disk, creating the parent directory as needed.
|
|
16
|
+
* Errors are swallowed so a read-only filesystem cannot crash the TUI — the
|
|
17
|
+
* in-memory state remains correct for the current session.
|
|
18
|
+
*/
|
|
19
|
+
export declare function saveUserConfig(filePath: string, config: UserConfig): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { UseWebSocketConfig, WebSocketState } from "./useWebSocket.types";
|
|
2
|
+
/**
|
|
3
|
+
* Generic WebSocket connection hook.
|
|
4
|
+
*
|
|
5
|
+
* Connects eagerly on mount, reconnects after dropped connections, and
|
|
6
|
+
* disconnects on unmount. Reconnects immediately when the `url` changes.
|
|
7
|
+
*
|
|
8
|
+
* @param config - Connection configuration including URL and event callbacks.
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const { status, send } = useWebSocket({
|
|
12
|
+
* url: "ws://localhost:7422/ws",
|
|
13
|
+
* onMessage: (data) => console.log("received", data),
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function useWebSocket(config: UseWebSocketConfig): WebSocketState;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Lifecycle states of a WebSocket connection. */
|
|
2
|
+
export type WebSocketStatus = "disconnected" | "connecting" | "connected" | "error";
|
|
3
|
+
/** Configuration for the `useWebSocket` hook. */
|
|
4
|
+
export interface UseWebSocketConfig {
|
|
5
|
+
/** WebSocket endpoint URL (e.g. "ws://localhost:7422/ws"). */
|
|
6
|
+
readonly url: string;
|
|
7
|
+
/** Delay before reconnecting after a dropped connection. Default: 2000ms. */
|
|
8
|
+
readonly reconnectDelayMs?: number;
|
|
9
|
+
/** Called with every incoming message (raw string data). */
|
|
10
|
+
readonly onMessage: (data: string) => void;
|
|
11
|
+
/** Called when the connection status changes. */
|
|
12
|
+
readonly onStatus?: (status: WebSocketStatus) => void;
|
|
13
|
+
/** Called when a connection attempt reports an error. */
|
|
14
|
+
readonly onError?: (error: string) => void;
|
|
15
|
+
}
|
|
16
|
+
/** Return value of the `useWebSocket` hook. */
|
|
17
|
+
export interface WebSocketState {
|
|
18
|
+
/** Current connection lifecycle status. */
|
|
19
|
+
readonly status: WebSocketStatus;
|
|
20
|
+
/**
|
|
21
|
+
* Send a string payload over the socket.
|
|
22
|
+
* Returns `true` if the message was sent or queued while connecting.
|
|
23
|
+
*/
|
|
24
|
+
readonly send: (data: string) => boolean;
|
|
25
|
+
/** Manually close the connection and stop reconnecting. */
|
|
26
|
+
readonly close: () => void;
|
|
27
|
+
}
|
package/dist/index.d.ts
ADDED