@jini-ai/chat 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +109 -0
- package/dist/core/agentic/chat-capabilities.d.ts +19 -0
- package/dist/core/agentic/chat-capabilities.d.ts.map +1 -0
- package/dist/core/agentic/chat-capabilities.js +106 -0
- package/dist/core/agentic/chat-capabilities.js.map +1 -0
- package/dist/core/agentic/index.d.ts +22 -0
- package/dist/core/agentic/index.d.ts.map +1 -0
- package/dist/core/agentic/index.js +21 -0
- package/dist/core/agentic/index.js.map +1 -0
- package/dist/core/events.d.ts +84 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/events.js +14 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/index.d.ts +40 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +40 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/messages.d.ts +53 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +16 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/partial-json.d.ts +36 -0
- package/dist/core/partial-json.d.ts.map +1 -0
- package/dist/core/partial-json.js +119 -0
- package/dist/core/partial-json.js.map +1 -0
- package/dist/core/persistence/index.d.ts +11 -0
- package/dist/core/persistence/index.d.ts.map +1 -0
- package/dist/core/persistence/index.js +11 -0
- package/dist/core/persistence/index.js.map +1 -0
- package/dist/core/persistence/ports.d.ts +124 -0
- package/dist/core/persistence/ports.d.ts.map +1 -0
- package/dist/core/persistence/ports.js +2 -0
- package/dist/core/persistence/ports.js.map +1 -0
- package/dist/core/persistence/title.d.ts +35 -0
- package/dist/core/persistence/title.d.ts.map +1 -0
- package/dist/core/persistence/title.js +137 -0
- package/dist/core/persistence/title.js.map +1 -0
- package/dist/core/question-form/format.d.ts +27 -0
- package/dist/core/question-form/format.d.ts.map +1 -0
- package/dist/core/question-form/format.js +45 -0
- package/dist/core/question-form/format.js.map +1 -0
- package/dist/core/question-form/normalize.d.ts +30 -0
- package/dist/core/question-form/normalize.d.ts.map +1 -0
- package/dist/core/question-form/normalize.js +192 -0
- package/dist/core/question-form/normalize.js.map +1 -0
- package/dist/core/question-form/scan.d.ts +50 -0
- package/dist/core/question-form/scan.d.ts.map +1 -0
- package/dist/core/question-form/scan.js +404 -0
- package/dist/core/question-form/scan.js.map +1 -0
- package/dist/core/question-form/types.d.ts +83 -0
- package/dist/core/question-form/types.d.ts.map +1 -0
- package/dist/core/question-form/types.js +11 -0
- package/dist/core/question-form/types.js.map +1 -0
- package/dist/core/question-form.d.ts +39 -0
- package/dist/core/question-form.d.ts.map +1 -0
- package/dist/core/question-form.js +4 -0
- package/dist/core/question-form.js.map +1 -0
- package/dist/core/todos.d.ts +70 -0
- package/dist/core/todos.d.ts.map +1 -0
- package/dist/core/todos.js +175 -0
- package/dist/core/todos.js.map +1 -0
- package/dist/core/tool-events.d.ts +18 -0
- package/dist/core/tool-events.d.ts.map +1 -0
- package/dist/core/tool-events.js +36 -0
- package/dist/core/tool-events.js.map +1 -0
- package/dist/core/tools.d.ts +51 -0
- package/dist/core/tools.d.ts.map +1 -0
- package/dist/core/tools.js +41 -0
- package/dist/core/tools.js.map +1 -0
- package/dist/core/transcript.d.ts +81 -0
- package/dist/core/transcript.d.ts.map +1 -0
- package/dist/core/transcript.js +133 -0
- package/dist/core/transcript.js.map +1 -0
- package/dist/core/transport.d.ts +109 -0
- package/dist/core/transport.d.ts.map +1 -0
- package/dist/core/transport.js +2 -0
- package/dist/core/transport.js.map +1 -0
- package/dist/core/util/index.d.ts +16 -0
- package/dist/core/util/index.d.ts.map +1 -0
- package/dist/core/util/index.js +16 -0
- package/dist/core/util/index.js.map +1 -0
- package/dist/core/util/manifest.d.ts +39 -0
- package/dist/core/util/manifest.d.ts.map +1 -0
- package/dist/core/util/manifest.js +173 -0
- package/dist/core/util/manifest.js.map +1 -0
- package/dist/core/util/markdown-context.d.ts +47 -0
- package/dist/core/util/markdown-context.d.ts.map +1 -0
- package/dist/core/util/markdown-context.js +125 -0
- package/dist/core/util/markdown-context.js.map +1 -0
- package/dist/core/util/markup-attributes.d.ts +20 -0
- package/dist/core/util/markup-attributes.d.ts.map +1 -0
- package/dist/core/util/markup-attributes.js +33 -0
- package/dist/core/util/markup-attributes.js.map +1 -0
- package/dist/core/util/parser.d.ts +42 -0
- package/dist/core/util/parser.d.ts.map +1 -0
- package/dist/core/util/parser.js +238 -0
- package/dist/core/util/parser.js.map +1 -0
- package/dist/core/util/pointer.d.ts +28 -0
- package/dist/core/util/pointer.d.ts.map +1 -0
- package/dist/core/util/pointer.js +75 -0
- package/dist/core/util/pointer.js.map +1 -0
- package/dist/core/util/recover.d.ts +40 -0
- package/dist/core/util/recover.d.ts.map +1 -0
- package/dist/core/util/recover.js +117 -0
- package/dist/core/util/recover.js.map +1 -0
- package/dist/core/util/strip.d.ts +112 -0
- package/dist/core/util/strip.d.ts.map +1 -0
- package/dist/core/util/strip.js +333 -0
- package/dist/core/util/strip.js.map +1 -0
- package/dist/core/util/types.d.ts +31 -0
- package/dist/core/util/types.d.ts.map +1 -0
- package/dist/core/util/types.js +2 -0
- package/dist/core/util/types.js.map +1 -0
- package/dist/core/util/validate.d.ts +50 -0
- package/dist/core/util/validate.d.ts.map +1 -0
- package/dist/core/util/validate.js +202 -0
- package/dist/core/util/validate.js.map +1 -0
- package/dist/react/agent-bridge/frontend-session-bridge.d.ts +45 -0
- package/dist/react/agent-bridge/frontend-session-bridge.d.ts.map +1 -0
- package/dist/react/agent-bridge/frontend-session-bridge.js +214 -0
- package/dist/react/agent-bridge/frontend-session-bridge.js.map +1 -0
- package/dist/react/artifact-types.d.ts +61 -0
- package/dist/react/artifact-types.d.ts.map +1 -0
- package/dist/react/artifact-types.js +33 -0
- package/dist/react/artifact-types.js.map +1 -0
- package/dist/react/chat-pane.d.ts +21 -0
- package/dist/react/chat-pane.d.ts.map +1 -0
- package/dist/react/chat-pane.js +20 -0
- package/dist/react/chat-pane.js.map +1 -0
- package/dist/react/components/A2uiSurfaceCard.d.ts +35 -0
- package/dist/react/components/A2uiSurfaceCard.d.ts.map +1 -0
- package/dist/react/components/A2uiSurfaceCard.js +272 -0
- package/dist/react/components/A2uiSurfaceCard.js.map +1 -0
- package/dist/react/components/AttachmentTray.d.ts +6 -0
- package/dist/react/components/AttachmentTray.d.ts.map +1 -0
- package/dist/react/components/AttachmentTray.js +30 -0
- package/dist/react/components/AttachmentTray.js.map +1 -0
- package/dist/react/components/ChatFab.d.ts +8 -0
- package/dist/react/components/ChatFab.d.ts.map +1 -0
- package/dist/react/components/ChatFab.js +24 -0
- package/dist/react/components/ChatFab.js.map +1 -0
- package/dist/react/components/Composer.d.ts +34 -0
- package/dist/react/components/Composer.d.ts.map +1 -0
- package/dist/react/components/Composer.js +300 -0
- package/dist/react/components/Composer.js.map +1 -0
- package/dist/react/components/ComposerDiscovery.d.ts +46 -0
- package/dist/react/components/ComposerDiscovery.d.ts.map +1 -0
- package/dist/react/components/ComposerDiscovery.js +38 -0
- package/dist/react/components/ComposerDiscovery.js.map +1 -0
- package/dist/react/components/ConversationList.d.ts +31 -0
- package/dist/react/components/ConversationList.d.ts.map +1 -0
- package/dist/react/components/ConversationList.js +221 -0
- package/dist/react/components/ConversationList.js.map +1 -0
- package/dist/react/components/ExtEventErrorBoundary.d.ts +35 -0
- package/dist/react/components/ExtEventErrorBoundary.d.ts.map +1 -0
- package/dist/react/components/ExtEventErrorBoundary.js +38 -0
- package/dist/react/components/ExtEventErrorBoundary.js.map +1 -0
- package/dist/react/components/Icon.d.ts +17 -0
- package/dist/react/components/Icon.d.ts.map +1 -0
- package/dist/react/components/Icon.js +46 -0
- package/dist/react/components/Icon.js.map +1 -0
- package/dist/react/components/JiniChatProvider.d.ts +45 -0
- package/dist/react/components/JiniChatProvider.d.ts.map +1 -0
- package/dist/react/components/JiniChatProvider.js +44 -0
- package/dist/react/components/JiniChatProvider.js.map +1 -0
- package/dist/react/components/Markdown.d.ts +5 -0
- package/dist/react/components/Markdown.d.ts.map +1 -0
- package/dist/react/components/Markdown.js +390 -0
- package/dist/react/components/Markdown.js.map +1 -0
- package/dist/react/components/McpUiSurfaceCard.d.ts +51 -0
- package/dist/react/components/McpUiSurfaceCard.d.ts.map +1 -0
- package/dist/react/components/McpUiSurfaceCard.js +159 -0
- package/dist/react/components/McpUiSurfaceCard.js.map +1 -0
- package/dist/react/components/MessageList.d.ts +15 -0
- package/dist/react/components/MessageList.d.ts.map +1 -0
- package/dist/react/components/MessageList.js +81 -0
- package/dist/react/components/MessageList.js.map +1 -0
- package/dist/react/components/MessageRow.d.ts +60 -0
- package/dist/react/components/MessageRow.d.ts.map +1 -0
- package/dist/react/components/MessageRow.js +156 -0
- package/dist/react/components/MessageRow.js.map +1 -0
- package/dist/react/components/NextStepActions.d.ts +34 -0
- package/dist/react/components/NextStepActions.d.ts.map +1 -0
- package/dist/react/components/NextStepActions.js +9 -0
- package/dist/react/components/NextStepActions.js.map +1 -0
- package/dist/react/components/QuestionForm.d.ts +26 -0
- package/dist/react/components/QuestionForm.d.ts.map +1 -0
- package/dist/react/components/QuestionForm.js +238 -0
- package/dist/react/components/QuestionForm.js.map +1 -0
- package/dist/react/components/QuestionsPanel.d.ts +13 -0
- package/dist/react/components/QuestionsPanel.d.ts.map +1 -0
- package/dist/react/components/QuestionsPanel.js +33 -0
- package/dist/react/components/QuestionsPanel.js.map +1 -0
- package/dist/react/components/TodoCard.d.ts +8 -0
- package/dist/react/components/TodoCard.d.ts.map +1 -0
- package/dist/react/components/TodoCard.js +29 -0
- package/dist/react/components/TodoCard.js.map +1 -0
- package/dist/react/components/ToolCard.d.ts +22 -0
- package/dist/react/components/ToolCard.d.ts.map +1 -0
- package/dist/react/components/ToolCard.js +298 -0
- package/dist/react/components/ToolCard.js.map +1 -0
- package/dist/react/components/composer-discovery.d.ts +107 -0
- package/dist/react/components/composer-discovery.d.ts.map +1 -0
- package/dist/react/components/composer-discovery.js +176 -0
- package/dist/react/components/composer-discovery.js.map +1 -0
- package/dist/react/ext-event-renderer-registry.d.ts +51 -0
- package/dist/react/ext-event-renderer-registry.d.ts.map +1 -0
- package/dist/react/ext-event-renderer-registry.js +20 -0
- package/dist/react/ext-event-renderer-registry.js.map +1 -0
- package/dist/react/features/chat-pane/agent-tools.d.ts +14 -0
- package/dist/react/features/chat-pane/agent-tools.d.ts.map +1 -0
- package/dist/react/features/chat-pane/agent-tools.js +22 -0
- package/dist/react/features/chat-pane/agent-tools.js.map +1 -0
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +12 -0
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts.map +1 -0
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +106 -0
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.js.map +1 -0
- package/dist/react/features/chat-pane/components/ChatPane.d.ts +10 -0
- package/dist/react/features/chat-pane/components/ChatPane.d.ts.map +1 -0
- package/dist/react/features/chat-pane/components/ChatPane.js +169 -0
- package/dist/react/features/chat-pane/components/ChatPane.js.map +1 -0
- package/dist/react/features/chat-pane/create-daemon-attachment-uploader.d.ts +21 -0
- package/dist/react/features/chat-pane/create-daemon-attachment-uploader.d.ts.map +1 -0
- package/dist/react/features/chat-pane/create-daemon-attachment-uploader.js +213 -0
- package/dist/react/features/chat-pane/create-daemon-attachment-uploader.js.map +1 -0
- package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts +70 -0
- package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts.map +1 -0
- package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.js +76 -0
- package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.js.map +1 -0
- package/dist/react/features/chat-pane/hooks/useAgentRuntimePicker.hooks.d.ts +133 -0
- package/dist/react/features/chat-pane/hooks/useAgentRuntimePicker.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/hooks/useAgentRuntimePicker.hooks.js +258 -0
- package/dist/react/features/chat-pane/hooks/useAgentRuntimePicker.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +66 -0
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +224 -0
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.d.ts +38 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js +252 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneControlsHeight.hooks.d.ts +16 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneControlsHeight.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneControlsHeight.hooks.js +59 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneControlsHeight.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts +26 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js +74 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneRuntimeInventory.hooks.d.ts +25 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneRuntimeInventory.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneRuntimeInventory.hooks.js +88 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneRuntimeInventory.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneWorkingDirectory.hooks.d.ts +38 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneWorkingDirectory.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneWorkingDirectory.hooks.js +184 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneWorkingDirectory.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/index.d.ts +12 -0
- package/dist/react/features/chat-pane/index.d.ts.map +1 -0
- package/dist/react/features/chat-pane/index.js +11 -0
- package/dist/react/features/chat-pane/index.js.map +1 -0
- package/dist/react/features/chat-pane/react/components/AgentRuntimePicker.d.ts +12 -0
- package/dist/react/features/chat-pane/react/components/AgentRuntimePicker.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/components/AgentRuntimePicker.js +102 -0
- package/dist/react/features/chat-pane/react/components/AgentRuntimePicker.js.map +1 -0
- package/dist/react/features/chat-pane/react/components/ChatPane.d.ts +10 -0
- package/dist/react/features/chat-pane/react/components/ChatPane.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/components/ChatPane.js +137 -0
- package/dist/react/features/chat-pane/react/components/ChatPane.js.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useAgentRuntimePicker.hooks.d.ts +133 -0
- package/dist/react/features/chat-pane/react/hooks/useAgentRuntimePicker.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useAgentRuntimePicker.hooks.js +258 -0
- package/dist/react/features/chat-pane/react/hooks/useAgentRuntimePicker.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPane.hooks.d.ts +66 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPane.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPane.hooks.js +223 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPane.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneAgentControl.hooks.d.ts +38 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneAgentControl.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneAgentControl.hooks.js +252 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneAgentControl.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneFileDrop.hooks.d.ts +26 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneFileDrop.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneFileDrop.hooks.js +60 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneFileDrop.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneRuntimeInventory.hooks.d.ts +25 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneRuntimeInventory.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneRuntimeInventory.hooks.js +83 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneRuntimeInventory.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneWorkingDirectory.hooks.d.ts +38 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneWorkingDirectory.hooks.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneWorkingDirectory.hooks.js +184 -0
- package/dist/react/features/chat-pane/react/hooks/useChatPaneWorkingDirectory.hooks.js.map +1 -0
- package/dist/react/features/chat-pane/react/styles.d.ts +2 -0
- package/dist/react/features/chat-pane/react/styles.d.ts.map +1 -0
- package/dist/react/features/chat-pane/react/styles.js +863 -0
- package/dist/react/features/chat-pane/react/styles.js.map +1 -0
- package/dist/react/features/chat-pane/rules.d.ts +31 -0
- package/dist/react/features/chat-pane/rules.d.ts.map +1 -0
- package/dist/react/features/chat-pane/rules.js +81 -0
- package/dist/react/features/chat-pane/rules.js.map +1 -0
- package/dist/react/features/chat-pane/styles.d.ts +2 -0
- package/dist/react/features/chat-pane/styles.d.ts.map +1 -0
- package/dist/react/features/chat-pane/styles.js +1327 -0
- package/dist/react/features/chat-pane/styles.js.map +1 -0
- package/dist/react/features/chat-pane/types.d.ts +248 -0
- package/dist/react/features/chat-pane/types.d.ts.map +1 -0
- package/dist/react/features/chat-pane/types.js +2 -0
- package/dist/react/features/chat-pane/types.js.map +1 -0
- package/dist/react/features/model-picker/components/CredentialStatusBadge.d.ts +7 -0
- package/dist/react/features/model-picker/components/CredentialStatusBadge.d.ts.map +1 -0
- package/dist/react/features/model-picker/components/CredentialStatusBadge.js +20 -0
- package/dist/react/features/model-picker/components/CredentialStatusBadge.js.map +1 -0
- package/dist/react/features/model-picker/components/ModelPicker.d.ts +9 -0
- package/dist/react/features/model-picker/components/ModelPicker.d.ts.map +1 -0
- package/dist/react/features/model-picker/components/ModelPicker.js +34 -0
- package/dist/react/features/model-picker/components/ModelPicker.js.map +1 -0
- package/dist/react/features/model-picker/constants.d.ts +6 -0
- package/dist/react/features/model-picker/constants.d.ts.map +1 -0
- package/dist/react/features/model-picker/constants.js +9 -0
- package/dist/react/features/model-picker/constants.js.map +1 -0
- package/dist/react/features/model-picker/dependencies.d.ts +11 -0
- package/dist/react/features/model-picker/dependencies.d.ts.map +1 -0
- package/dist/react/features/model-picker/dependencies.js +10 -0
- package/dist/react/features/model-picker/dependencies.js.map +1 -0
- package/dist/react/features/model-picker/hooks/useModelPicker.hooks.d.ts +27 -0
- package/dist/react/features/model-picker/hooks/useModelPicker.hooks.d.ts.map +1 -0
- package/dist/react/features/model-picker/hooks/useModelPicker.hooks.js +62 -0
- package/dist/react/features/model-picker/hooks/useModelPicker.hooks.js.map +1 -0
- package/dist/react/features/model-picker/index.d.ts +32 -0
- package/dist/react/features/model-picker/index.d.ts.map +1 -0
- package/dist/react/features/model-picker/index.js +29 -0
- package/dist/react/features/model-picker/index.js.map +1 -0
- package/dist/react/features/model-picker/ports.d.ts +11 -0
- package/dist/react/features/model-picker/ports.d.ts.map +1 -0
- package/dist/react/features/model-picker/ports.js +2 -0
- package/dist/react/features/model-picker/ports.js.map +1 -0
- package/dist/react/features/model-picker/react/components/CredentialStatusBadge.d.ts +7 -0
- package/dist/react/features/model-picker/react/components/CredentialStatusBadge.d.ts.map +1 -0
- package/dist/react/features/model-picker/react/components/CredentialStatusBadge.js +20 -0
- package/dist/react/features/model-picker/react/components/CredentialStatusBadge.js.map +1 -0
- package/dist/react/features/model-picker/react/components/ModelPicker.d.ts +9 -0
- package/dist/react/features/model-picker/react/components/ModelPicker.d.ts.map +1 -0
- package/dist/react/features/model-picker/react/components/ModelPicker.js +34 -0
- package/dist/react/features/model-picker/react/components/ModelPicker.js.map +1 -0
- package/dist/react/features/model-picker/react/hooks/useModelPicker.hooks.d.ts +27 -0
- package/dist/react/features/model-picker/react/hooks/useModelPicker.hooks.d.ts.map +1 -0
- package/dist/react/features/model-picker/react/hooks/useModelPicker.hooks.js +62 -0
- package/dist/react/features/model-picker/react/hooks/useModelPicker.hooks.js.map +1 -0
- package/dist/react/features/model-picker/rules.d.ts +26 -0
- package/dist/react/features/model-picker/rules.d.ts.map +1 -0
- package/dist/react/features/model-picker/rules.js +84 -0
- package/dist/react/features/model-picker/rules.js.map +1 -0
- package/dist/react/features/model-picker/types.d.ts +38 -0
- package/dist/react/features/model-picker/types.d.ts.map +1 -0
- package/dist/react/features/model-picker/types.js +2 -0
- package/dist/react/features/model-picker/types.js.map +1 -0
- package/dist/react/hooks/composer-draft-cache.d.ts +65 -0
- package/dist/react/hooks/composer-draft-cache.d.ts.map +1 -0
- package/dist/react/hooks/composer-draft-cache.js +89 -0
- package/dist/react/hooks/composer-draft-cache.js.map +1 -0
- package/dist/react/hooks/context.d.ts +18 -0
- package/dist/react/hooks/context.d.ts.map +1 -0
- package/dist/react/hooks/context.js +60 -0
- package/dist/react/hooks/context.js.map +1 -0
- package/dist/react/hooks/testing/fake-transport.d.ts +34 -0
- package/dist/react/hooks/testing/fake-transport.d.ts.map +1 -0
- package/dist/react/hooks/testing/fake-transport.js +46 -0
- package/dist/react/hooks/testing/fake-transport.js.map +1 -0
- package/dist/react/hooks/useArtifactStream.d.ts +18 -0
- package/dist/react/hooks/useArtifactStream.d.ts.map +1 -0
- package/dist/react/hooks/useArtifactStream.js +55 -0
- package/dist/react/hooks/useArtifactStream.js.map +1 -0
- package/dist/react/hooks/useChatFabDrag.d.ts +25 -0
- package/dist/react/hooks/useChatFabDrag.d.ts.map +1 -0
- package/dist/react/hooks/useChatFabDrag.js +88 -0
- package/dist/react/hooks/useChatFabDrag.js.map +1 -0
- package/dist/react/hooks/useComposer.d.ts +48 -0
- package/dist/react/hooks/useComposer.d.ts.map +1 -0
- package/dist/react/hooks/useComposer.js +121 -0
- package/dist/react/hooks/useComposer.js.map +1 -0
- package/dist/react/hooks/useConversation.d.ts +34 -0
- package/dist/react/hooks/useConversation.d.ts.map +1 -0
- package/dist/react/hooks/useConversation.js +163 -0
- package/dist/react/hooks/useConversation.js.map +1 -0
- package/dist/react/hooks/useCopyToClipboard.d.ts +14 -0
- package/dist/react/hooks/useCopyToClipboard.d.ts.map +1 -0
- package/dist/react/hooks/useCopyToClipboard.js +98 -0
- package/dist/react/hooks/useCopyToClipboard.js.map +1 -0
- package/dist/react/hooks/useExtEventGroups.d.ts +7 -0
- package/dist/react/hooks/useExtEventGroups.d.ts.map +1 -0
- package/dist/react/hooks/useExtEventGroups.js +32 -0
- package/dist/react/hooks/useExtEventGroups.js.map +1 -0
- package/dist/react/hooks/useLatestOperation.d.ts +31 -0
- package/dist/react/hooks/useLatestOperation.d.ts.map +1 -0
- package/dist/react/hooks/useLatestOperation.js +74 -0
- package/dist/react/hooks/useLatestOperation.js.map +1 -0
- package/dist/react/hooks/usePinnedTodos.d.ts +15 -0
- package/dist/react/hooks/usePinnedTodos.d.ts.map +1 -0
- package/dist/react/hooks/usePinnedTodos.js +43 -0
- package/dist/react/hooks/usePinnedTodos.js.map +1 -0
- package/dist/react/hooks/useQuestionForms.d.ts +28 -0
- package/dist/react/hooks/useQuestionForms.d.ts.map +1 -0
- package/dist/react/hooks/useQuestionForms.js +113 -0
- package/dist/react/hooks/useQuestionForms.js.map +1 -0
- package/dist/react/hooks/useRunStream.d.ts +27 -0
- package/dist/react/hooks/useRunStream.d.ts.map +1 -0
- package/dist/react/hooks/useRunStream.js +180 -0
- package/dist/react/hooks/useRunStream.js.map +1 -0
- package/dist/react/hooks/useToolTimeline.d.ts +33 -0
- package/dist/react/hooks/useToolTimeline.d.ts.map +1 -0
- package/dist/react/hooks/useToolTimeline.js +47 -0
- package/dist/react/hooks/useToolTimeline.js.map +1 -0
- package/dist/react/index.d.ts +158 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +118 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/message-blocks.d.ts +86 -0
- package/dist/react/message-blocks.d.ts.map +1 -0
- package/dist/react/message-blocks.js +78 -0
- package/dist/react/message-blocks.js.map +1 -0
- package/dist/react/poc-mcp-ui-official/PocMcpUiCard.d.ts +9 -0
- package/dist/react/poc-mcp-ui-official/PocMcpUiCard.d.ts.map +1 -0
- package/dist/react/poc-mcp-ui-official/PocMcpUiCard.js +29 -0
- package/dist/react/poc-mcp-ui-official/PocMcpUiCard.js.map +1 -0
- package/dist/react/poc-mcp-ui-official/create-poc-resource.d.ts +30 -0
- package/dist/react/poc-mcp-ui-official/create-poc-resource.d.ts.map +1 -0
- package/dist/react/poc-mcp-ui-official/create-poc-resource.js +44 -0
- package/dist/react/poc-mcp-ui-official/create-poc-resource.js.map +1 -0
- package/dist/react/slots.d.ts +215 -0
- package/dist/react/slots.d.ts.map +1 -0
- package/dist/react/slots.js +2 -0
- package/dist/react/slots.js.map +1 -0
- package/dist/react/styles/reference.css +298 -0
- package/dist/react/tool-renderer-registry.d.ts +41 -0
- package/dist/react/tool-renderer-registry.d.ts.map +1 -0
- package/dist/react/tool-renderer-registry.js +22 -0
- package/dist/react/tool-renderer-registry.js.map +1 -0
- package/dist/react/util/defined-props.d.ts +31 -0
- package/dist/react/util/defined-props.d.ts.map +1 -0
- package/dist/react/util/defined-props.js +28 -0
- package/dist/react/util/defined-props.js.map +1 -0
- package/package.json +99 -0
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module question-form/scan
|
|
3
|
+
*
|
|
4
|
+
* Markup segmentation for `<question-form>` / `<ask-question>` blocks:
|
|
5
|
+
* locating open/close tags, splitting prose from form JSON, and the
|
|
6
|
+
* tolerant streaming-recovery path that renders a partial form before its
|
|
7
|
+
* JSON body has finished arriving. Split out of the original single-file
|
|
8
|
+
* `question-form.ts`; see `../question-form.ts` for the public facade, the
|
|
9
|
+
* block format, and the tag-name-alias rule.
|
|
10
|
+
*/
|
|
11
|
+
import { parsePartialJson } from '../partial-json.js';
|
|
12
|
+
import { parseQuotedAttrs } from '../util/markup-attributes.js';
|
|
13
|
+
import { mapRawQuestion } from './normalize.js';
|
|
14
|
+
// `question-form` is the canonical tag; `ask-question` is an alias the model
|
|
15
|
+
// occasionally drifts to. The close tag must match the open tag name, so each
|
|
16
|
+
// match captures the name and computes its own close-tag string. Matching is
|
|
17
|
+
// case-insensitive so `<Question-Form>` / `<ASK-QUESTION>` still parse.
|
|
18
|
+
const OPEN_RE = /<(question-form|ask-question)\b([^>]*)>/i;
|
|
19
|
+
// Group 1 is a mandatory (non-optional) alternation and group 2 is an
|
|
20
|
+
// unconditional `*`-quantified capture, so both always participate whenever
|
|
21
|
+
// `m` itself is non-null — `noUncheckedIndexedAccess` just can't see that
|
|
22
|
+
// from the regex alone. Centralized here so the six call sites below don't
|
|
23
|
+
// each repeat the same assertion and reasoning.
|
|
24
|
+
function matchedTagAndAttrs(m) {
|
|
25
|
+
return { tagName: m[1].toLowerCase(), rawAttrs: m[2] };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Split `input` into ordered prose/form segments. Scans repeatedly for
|
|
29
|
+
* `question-form`/`ask-question` opens; for each, locates the matching close
|
|
30
|
+
* tag and tries to parse the JSON body. A block that doesn't parse cleanly,
|
|
31
|
+
* or has no close tag yet, is left in the prose stream verbatim.
|
|
32
|
+
*
|
|
33
|
+
* @complexity O(n) amortized in `input.length` — each iteration advances the
|
|
34
|
+
* cursor past the segment it just emitted.
|
|
35
|
+
*/
|
|
36
|
+
export function splitOnQuestionForms(input) {
|
|
37
|
+
const out = [];
|
|
38
|
+
let cursor = 0;
|
|
39
|
+
while (cursor < input.length) {
|
|
40
|
+
const slice = input.slice(cursor);
|
|
41
|
+
const m = OPEN_RE.exec(slice);
|
|
42
|
+
if (!m) {
|
|
43
|
+
out.push({ kind: 'text', text: slice });
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
const { tagName, rawAttrs } = matchedTagAndAttrs(m);
|
|
47
|
+
const closeTag = `</${tagName}>`;
|
|
48
|
+
const openStart = cursor + m.index;
|
|
49
|
+
const openEnd = openStart + m[0].length;
|
|
50
|
+
const closeIdx = findCloseTag(input, openEnd, closeTag);
|
|
51
|
+
if (closeIdx === -1) {
|
|
52
|
+
// Unterminated — leave the rest as prose so we don't swallow it.
|
|
53
|
+
out.push({ kind: 'text', text: slice });
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
if (openStart > cursor) {
|
|
57
|
+
out.push({ kind: 'text', text: input.slice(cursor, openStart) });
|
|
58
|
+
}
|
|
59
|
+
const body = input.slice(openEnd, closeIdx);
|
|
60
|
+
const attrs = parseQuotedAttrs(rawAttrs);
|
|
61
|
+
const form = tryParseForm(body, attrs);
|
|
62
|
+
const blockEnd = closeIdx + closeTag.length;
|
|
63
|
+
if (form) {
|
|
64
|
+
out.push({ kind: 'form', form, raw: input.slice(openStart, blockEnd) });
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Malformed — keep raw text so the user can still see it.
|
|
68
|
+
out.push({ kind: 'text', text: input.slice(openStart, blockEnd) });
|
|
69
|
+
}
|
|
70
|
+
cursor = blockEnd;
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
/** The first complete, parseable `<question-form>` in `input`, or `null`. */
|
|
75
|
+
export function findFirstQuestionForm(input) {
|
|
76
|
+
for (const seg of splitOnQuestionForms(input)) {
|
|
77
|
+
if (seg.kind === 'form')
|
|
78
|
+
return { form: seg.form, raw: seg.raw };
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Convenience wrapper over {@link findFirstQuestionForm} matching the
|
|
84
|
+
* `parseQuestionForm()` name from the target API — returns just the form
|
|
85
|
+
* (dropping the matched raw text), or `null` when `input` has no complete
|
|
86
|
+
* question-form block. For a still-streaming block use
|
|
87
|
+
* {@link parsePartialQuestionForm} instead.
|
|
88
|
+
*/
|
|
89
|
+
export function parseQuestionForm(input) {
|
|
90
|
+
return findFirstQuestionForm(input)?.form ?? null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Drop a trailing, not-yet-closed question-form block from streaming text so
|
|
94
|
+
* a chat surface doesn't flash raw `<question-form>{…` markup before the
|
|
95
|
+
* JSON finishes. Returns the visible text plus whether such an open block
|
|
96
|
+
* existed (meaning a form is mid-generation).
|
|
97
|
+
*/
|
|
98
|
+
export function stripTrailingOpenQuestionForm(input) {
|
|
99
|
+
let cursor = 0;
|
|
100
|
+
while (cursor < input.length) {
|
|
101
|
+
const slice = input.slice(cursor);
|
|
102
|
+
const m = OPEN_RE.exec(slice);
|
|
103
|
+
if (!m)
|
|
104
|
+
break;
|
|
105
|
+
const { tagName } = matchedTagAndAttrs(m);
|
|
106
|
+
const closeTag = `</${tagName}>`;
|
|
107
|
+
const openStart = cursor + m.index;
|
|
108
|
+
const openEnd = openStart + m[0].length;
|
|
109
|
+
const closeIdx = findCloseTag(input, openEnd, closeTag);
|
|
110
|
+
if (closeIdx === -1) {
|
|
111
|
+
return { text: input.slice(0, openStart), hadOpenForm: true };
|
|
112
|
+
}
|
|
113
|
+
cursor = closeIdx + closeTag.length;
|
|
114
|
+
}
|
|
115
|
+
return { text: input, hadOpenForm: false };
|
|
116
|
+
}
|
|
117
|
+
/** `true` when a question-form open tag is present but its close tag hasn't streamed in yet. */
|
|
118
|
+
export function hasUnterminatedQuestionForm(input) {
|
|
119
|
+
return stripTrailingOpenQuestionForm(input).hadOpenForm;
|
|
120
|
+
}
|
|
121
|
+
function findCloseTag(input, from, closeTag) {
|
|
122
|
+
const closeLower = closeTag.toLowerCase();
|
|
123
|
+
const tagLen = closeTag.length;
|
|
124
|
+
const maxStart = input.length - tagLen;
|
|
125
|
+
for (let i = from; i <= maxStart; i++) {
|
|
126
|
+
if (input.slice(i, i + tagLen).toLowerCase() === closeLower) {
|
|
127
|
+
return i;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return -1;
|
|
131
|
+
}
|
|
132
|
+
function tryParseForm(body, attrs) {
|
|
133
|
+
const trimmed = body.trim();
|
|
134
|
+
if (!trimmed)
|
|
135
|
+
return null;
|
|
136
|
+
// Allow the JSON to be wrapped in a fenced ```json block — common when the
|
|
137
|
+
// model echoes its own indented body.
|
|
138
|
+
const stripped = trimmed
|
|
139
|
+
.replace(/^```(?:json)?\s*/i, '')
|
|
140
|
+
.replace(/```\s*$/i, '')
|
|
141
|
+
.trim();
|
|
142
|
+
let data;
|
|
143
|
+
try {
|
|
144
|
+
data = JSON.parse(stripped);
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
if (!data || typeof data !== 'object')
|
|
150
|
+
return null;
|
|
151
|
+
const obj = data;
|
|
152
|
+
const rawQuestions = Array.isArray(obj.questions) ? obj.questions : null;
|
|
153
|
+
if (!rawQuestions)
|
|
154
|
+
return null;
|
|
155
|
+
const questions = [];
|
|
156
|
+
rawQuestions.forEach((q, i) => {
|
|
157
|
+
const mapped = mapRawQuestion(q, i);
|
|
158
|
+
if (mapped)
|
|
159
|
+
questions.push(mapped);
|
|
160
|
+
});
|
|
161
|
+
if (questions.length === 0)
|
|
162
|
+
return null;
|
|
163
|
+
const id = attrs.id ?? (typeof obj.id === 'string' ? obj.id : 'discovery');
|
|
164
|
+
const title = attrs.title ?? (typeof obj.title === 'string' ? obj.title : 'A few quick questions');
|
|
165
|
+
const description = typeof obj.description === 'string' ? obj.description : undefined;
|
|
166
|
+
const submitLabel = typeof obj.submitLabel === 'string' ? obj.submitLabel : undefined;
|
|
167
|
+
return {
|
|
168
|
+
id,
|
|
169
|
+
title,
|
|
170
|
+
questions,
|
|
171
|
+
...(description ? { description } : {}),
|
|
172
|
+
...(submitLabel ? { submitLabel } : {}),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Tolerant parser for a still-streaming `<question-form>` block. Unlike
|
|
177
|
+
* {@link tryParseForm} it does not require valid, complete JSON: it reads the
|
|
178
|
+
* title/id from the open tag's attrs (available the instant the tag streams
|
|
179
|
+
* in) and extracts however many *complete* question objects have arrived so
|
|
180
|
+
* far, so a Questions panel can render a frame immediately and fill
|
|
181
|
+
* questions in progressively. Returns `null` only when no open tag is
|
|
182
|
+
* present at all.
|
|
183
|
+
*
|
|
184
|
+
* @complexity O(n) in `input.length` (one regex scan plus a linear
|
|
185
|
+
* string-aware brace walk via {@link parsePartialJson}).
|
|
186
|
+
*/
|
|
187
|
+
export function parsePartialQuestionForm(input) {
|
|
188
|
+
const m = OPEN_RE.exec(input);
|
|
189
|
+
if (!m)
|
|
190
|
+
return null;
|
|
191
|
+
const { tagName, rawAttrs } = matchedTagAndAttrs(m);
|
|
192
|
+
const closeTag = `</${tagName}>`;
|
|
193
|
+
const openEnd = m.index + m[0].length;
|
|
194
|
+
const attrs = parseQuotedAttrs(rawAttrs);
|
|
195
|
+
const closeIdx = findCloseTag(input, openEnd, closeTag);
|
|
196
|
+
const rawBody = closeIdx === -1 ? input.slice(openEnd) : input.slice(openEnd, closeIdx);
|
|
197
|
+
// Strip the fenced ```json wrapper some models emit. The opening fence is
|
|
198
|
+
// removed always; the trailing fence is removed too once it streams in
|
|
199
|
+
// (possibly only a partial ``` so far) — otherwise leftover backticks make
|
|
200
|
+
// the JSON unparseable in the gap between "fence closed" and
|
|
201
|
+
// "</question-form> arrived", dropping the live preview back to empty.
|
|
202
|
+
const body = stripTrailingFence(rawBody.replace(/^\s*```(?:json)?\s*/i, ''));
|
|
203
|
+
// Derive form-level metadata from the *parsed top-level object*, not a
|
|
204
|
+
// whole-body regex scan: a nested question/option `id`/`title`/`description`
|
|
205
|
+
// must not masquerade as the form's own.
|
|
206
|
+
const parsed = parsePartialJson(body);
|
|
207
|
+
const top = parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {};
|
|
208
|
+
const topTitle = typeof top.title === 'string' && top.title.trim().length > 0 ? top.title : undefined;
|
|
209
|
+
// `id` keys a still-editable panel, so it must be stable for the whole
|
|
210
|
+
// stream — don't adopt it until its string literal is fully terminated,
|
|
211
|
+
// otherwise it would churn character-by-character and remount the panel.
|
|
212
|
+
const id = attrs.id ?? completeTopLevelString(body, 'id') ?? 'discovery';
|
|
213
|
+
const title = attrs.title ?? topTitle ?? 'A few quick questions';
|
|
214
|
+
const description = typeof top.description === 'string' ? top.description : undefined;
|
|
215
|
+
const submitLabel = typeof top.submitLabel === 'string' ? top.submitLabel : undefined;
|
|
216
|
+
const questions = shapeStreamingQuestions(top.questions, countClosedQuestionObjects(body));
|
|
217
|
+
return {
|
|
218
|
+
id,
|
|
219
|
+
title,
|
|
220
|
+
questions,
|
|
221
|
+
...(description ? { description } : {}),
|
|
222
|
+
...(submitLabel ? { submitLabel } : {}),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
// Strip a trailing ``` fence (possibly only partially streamed) from a form
|
|
226
|
+
// body — but only when those backticks are the closing wrapper, not content
|
|
227
|
+
// of a JSON string value still being typed.
|
|
228
|
+
function stripTrailingFence(body) {
|
|
229
|
+
const m = /\s*`{1,3}\s*$/.exec(body);
|
|
230
|
+
if (!m)
|
|
231
|
+
return body;
|
|
232
|
+
const before = body.slice(0, m.index);
|
|
233
|
+
if (endsInsideJsonString(before))
|
|
234
|
+
return body;
|
|
235
|
+
return before;
|
|
236
|
+
}
|
|
237
|
+
function endsInsideJsonString(s) {
|
|
238
|
+
let inStr = false;
|
|
239
|
+
let esc = false;
|
|
240
|
+
for (let i = 0; i < s.length; i++) {
|
|
241
|
+
const c = s[i];
|
|
242
|
+
if (inStr) {
|
|
243
|
+
if (esc)
|
|
244
|
+
esc = false;
|
|
245
|
+
else if (c === '\\')
|
|
246
|
+
esc = true;
|
|
247
|
+
else if (c === '"')
|
|
248
|
+
inStr = false;
|
|
249
|
+
}
|
|
250
|
+
else if (c === '"') {
|
|
251
|
+
inStr = true;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return inStr;
|
|
255
|
+
}
|
|
256
|
+
// Return a top-level (depth-1) string field's value ONLY if its string
|
|
257
|
+
// literal is fully terminated in the (possibly partial) body. Depth-aware so
|
|
258
|
+
// a nested question `id` can't be mistaken for the form's own.
|
|
259
|
+
function completeTopLevelString(body, field) {
|
|
260
|
+
const marker = `"${field}"`;
|
|
261
|
+
let depth = 0;
|
|
262
|
+
let inStr = false;
|
|
263
|
+
let esc = false;
|
|
264
|
+
for (let i = 0; i < body.length; i++) {
|
|
265
|
+
const c = body[i];
|
|
266
|
+
if (inStr) {
|
|
267
|
+
if (esc)
|
|
268
|
+
esc = false;
|
|
269
|
+
else if (c === '\\')
|
|
270
|
+
esc = true;
|
|
271
|
+
else if (c === '"')
|
|
272
|
+
inStr = false;
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (c === '{' || c === '[') {
|
|
276
|
+
depth++;
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
if (c === '}' || c === ']') {
|
|
280
|
+
depth--;
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (c === '"') {
|
|
284
|
+
if (depth === 1 && body.startsWith(marker, i)) {
|
|
285
|
+
let j = i + marker.length;
|
|
286
|
+
while (j < body.length && /\s/.test(body[j]))
|
|
287
|
+
j++;
|
|
288
|
+
if (body[j] !== ':') {
|
|
289
|
+
inStr = true; // it's a value string, not our key — skip it
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
j++;
|
|
293
|
+
while (j < body.length && /\s/.test(body[j]))
|
|
294
|
+
j++;
|
|
295
|
+
if (body[j] !== '"')
|
|
296
|
+
return undefined; // value not a (started) string
|
|
297
|
+
let value = '';
|
|
298
|
+
let vesc = false;
|
|
299
|
+
for (let k = j + 1; k < body.length; k++) {
|
|
300
|
+
const vc = body[k];
|
|
301
|
+
if (vesc) {
|
|
302
|
+
value += vc;
|
|
303
|
+
vesc = false;
|
|
304
|
+
}
|
|
305
|
+
else if (vc === '\\') {
|
|
306
|
+
value += vc;
|
|
307
|
+
vesc = true;
|
|
308
|
+
}
|
|
309
|
+
else if (vc === '"') {
|
|
310
|
+
try {
|
|
311
|
+
return JSON.parse(`"${value}"`);
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
return value;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
value += vc;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return undefined; // closing quote hasn't streamed yet
|
|
322
|
+
}
|
|
323
|
+
inStr = true;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return undefined;
|
|
327
|
+
}
|
|
328
|
+
function shapeStreamingQuestions(rawQuestions, closedCount) {
|
|
329
|
+
if (!Array.isArray(rawQuestions))
|
|
330
|
+
return [];
|
|
331
|
+
const out = [];
|
|
332
|
+
rawQuestions.forEach((raw, index) => {
|
|
333
|
+
if (!raw || typeof raw !== 'object')
|
|
334
|
+
return;
|
|
335
|
+
const q = raw;
|
|
336
|
+
const label = q.label;
|
|
337
|
+
if (typeof label !== 'string' || label.trim().length === 0)
|
|
338
|
+
return;
|
|
339
|
+
// Surface a question only once its canonical id is determinable, so the
|
|
340
|
+
// preview id matches what the final parse assigns: a closed object's id
|
|
341
|
+
// is final; an in-flight object needs an explicit id already present.
|
|
342
|
+
const isClosed = index < closedCount;
|
|
343
|
+
const hasId = typeof q.id === 'string' && q.id.trim().length > 0;
|
|
344
|
+
if (!isClosed && !hasId)
|
|
345
|
+
return;
|
|
346
|
+
const mapped = mapRawQuestion(raw, index);
|
|
347
|
+
if (mapped)
|
|
348
|
+
out.push(mapped);
|
|
349
|
+
});
|
|
350
|
+
return out;
|
|
351
|
+
}
|
|
352
|
+
// Count how many question objects in a partial `"questions": [ … ]` body
|
|
353
|
+
// have their closing brace already streamed (string-aware).
|
|
354
|
+
function countClosedQuestionObjects(body) {
|
|
355
|
+
const keyMatch = /"questions"\s*:\s*\[/.exec(body);
|
|
356
|
+
if (!keyMatch)
|
|
357
|
+
return 0;
|
|
358
|
+
let i = keyMatch.index + keyMatch[0].length;
|
|
359
|
+
let count = 0;
|
|
360
|
+
while (i < body.length) {
|
|
361
|
+
while (i < body.length && /[\s,]/.test(body[i]))
|
|
362
|
+
i++;
|
|
363
|
+
if (i >= body.length || body[i] === ']')
|
|
364
|
+
break;
|
|
365
|
+
if (body[i] !== '{')
|
|
366
|
+
break;
|
|
367
|
+
const obj = extractBalancedObject(body, i);
|
|
368
|
+
if (!obj)
|
|
369
|
+
break; // trailing object hasn't closed yet
|
|
370
|
+
count++;
|
|
371
|
+
i += obj.length;
|
|
372
|
+
}
|
|
373
|
+
return count;
|
|
374
|
+
}
|
|
375
|
+
// Return the substring for the balanced `{...}` object starting at `start`,
|
|
376
|
+
// or null if it never closes (string-aware so braces inside strings don't count).
|
|
377
|
+
function extractBalancedObject(s, start) {
|
|
378
|
+
let depth = 0;
|
|
379
|
+
let inStr = false;
|
|
380
|
+
let esc = false;
|
|
381
|
+
for (let i = start; i < s.length; i++) {
|
|
382
|
+
const c = s[i];
|
|
383
|
+
if (inStr) {
|
|
384
|
+
if (esc)
|
|
385
|
+
esc = false;
|
|
386
|
+
else if (c === '\\')
|
|
387
|
+
esc = true;
|
|
388
|
+
else if (c === '"')
|
|
389
|
+
inStr = false;
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
if (c === '"')
|
|
393
|
+
inStr = true;
|
|
394
|
+
else if (c === '{')
|
|
395
|
+
depth++;
|
|
396
|
+
else if (c === '}') {
|
|
397
|
+
depth--;
|
|
398
|
+
if (depth === 0)
|
|
399
|
+
return s.slice(start, i + 1);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
//# sourceMappingURL=scan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../../src/core/question-form/scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,6EAA6E;AAC7E,8EAA8E;AAC9E,6EAA6E;AAC7E,wEAAwE;AACxE,MAAM,OAAO,GAAG,0CAA0C,CAAC;AAE3D,sEAAsE;AACtE,4EAA4E;AAC5E,0EAA0E;AAC1E,2EAA2E;AAC3E,gDAAgD;AAChD,SAAS,kBAAkB,CAAC,CAAkB;IAC5C,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC;AAC3D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,MAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,OAAO,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAClC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,CAAC,IAAI,CAAC,EAAE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AI,CAAC,KAAK,GAAG;YAAE,KAAK,GAAG,IAAI,CAAC;aACvB,IAAI,CAAC,KAAK,GAAG;YAAE,KAAK,EAAE,CAAC;aACvB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YACnB,KAAK,EAAE,CAAC;YACR,IAAI,KAAK,KAAK,CAAC;gBAAE,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module question-form/types
|
|
3
|
+
*
|
|
4
|
+
* Type vocabulary for the `<question-form>` parser, split out of the
|
|
5
|
+
* original single-file `question-form.ts` so `scan.ts` / `normalize.ts` /
|
|
6
|
+
* `format.ts` can each import just the types they need without pulling in
|
|
7
|
+
* one another's implementation. See `../question-form.ts` for the public
|
|
8
|
+
* facade and the block format this vocabulary describes.
|
|
9
|
+
*/
|
|
10
|
+
export type QuestionType = 'radio' | 'checkbox' | 'select' | 'text' | 'textarea' | 'number' | 'range' | 'date' | 'time' | 'datetime-local' | 'color' | 'url' | 'email' | 'tel' | 'file' | 'switch' | 'direction-cards';
|
|
11
|
+
/**
|
|
12
|
+
* Rich card metadata for a single `direction-cards` option. A direction
|
|
13
|
+
* picker renders a swatch row, a serif/sans type sample, a mood blurb, and a
|
|
14
|
+
* "references" line so users can scan visually instead of reading radio
|
|
15
|
+
* labels. The agent emits this metadata inline in the form JSON so a host
|
|
16
|
+
* can render it without additional fetches.
|
|
17
|
+
*/
|
|
18
|
+
export interface DirectionCard {
|
|
19
|
+
/** The radio value — what comes back in the user's answer. Must match a label/value in `options`. */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Short headline on the card. */
|
|
22
|
+
label: string;
|
|
23
|
+
/** One- or two-sentence mood blurb. */
|
|
24
|
+
mood: string;
|
|
25
|
+
/** Real-world exemplars (kept to at most 6 by the parser). */
|
|
26
|
+
references: string[];
|
|
27
|
+
/** Swatch hex / OKLch strings for the palette row (kept to at most 8 by the parser). */
|
|
28
|
+
palette: string[];
|
|
29
|
+
/** Display (headline) font stack, for a live "Aa" sample. */
|
|
30
|
+
displayFont: string;
|
|
31
|
+
/** Body font stack, for a secondary sample. */
|
|
32
|
+
bodyFont: string;
|
|
33
|
+
}
|
|
34
|
+
export interface FormOption {
|
|
35
|
+
label: string;
|
|
36
|
+
value: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface FormQuestion {
|
|
40
|
+
id: string;
|
|
41
|
+
label: string;
|
|
42
|
+
type: QuestionType;
|
|
43
|
+
options?: FormOption[];
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
required?: boolean;
|
|
46
|
+
help?: string;
|
|
47
|
+
defaultValue?: string | string[];
|
|
48
|
+
/** Only applies when `type === 'checkbox'`. Caps the number of selected options. */
|
|
49
|
+
maxSelections?: number;
|
|
50
|
+
/**
|
|
51
|
+
* For finite-choice controls, show a free-form override beside the
|
|
52
|
+
* generated options so the user can supply their own value.
|
|
53
|
+
*/
|
|
54
|
+
allowCustom?: boolean;
|
|
55
|
+
customLabel?: string;
|
|
56
|
+
customPlaceholder?: string;
|
|
57
|
+
/** Numeric/range inputs only. */
|
|
58
|
+
min?: number;
|
|
59
|
+
max?: number;
|
|
60
|
+
step?: number;
|
|
61
|
+
/** File inputs only. The answer serializes selected file names, not bytes. */
|
|
62
|
+
multiple?: boolean;
|
|
63
|
+
/** File inputs only. Mirrors the native file input `accept` attribute. */
|
|
64
|
+
accept?: string;
|
|
65
|
+
/** Only present when `type === 'direction-cards'`. Mapped to `options` by `id`. */
|
|
66
|
+
cards?: DirectionCard[];
|
|
67
|
+
}
|
|
68
|
+
export interface QuestionForm {
|
|
69
|
+
id: string;
|
|
70
|
+
title: string;
|
|
71
|
+
description?: string;
|
|
72
|
+
questions: FormQuestion[];
|
|
73
|
+
submitLabel?: string;
|
|
74
|
+
}
|
|
75
|
+
export type FormSegment = {
|
|
76
|
+
kind: 'text';
|
|
77
|
+
text: string;
|
|
78
|
+
} | {
|
|
79
|
+
kind: 'form';
|
|
80
|
+
form: QuestionForm;
|
|
81
|
+
raw: string;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/question-form/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,UAAU,GACV,QAAQ,GACR,MAAM,GACN,UAAU,GACV,QAAQ,GACR,OAAO,GACP,MAAM,GACN,MAAM,GACN,gBAAgB,GAChB,OAAO,GACP,KAAK,GACL,OAAO,GACP,KAAK,GACL,MAAM,GACN,QAAQ,GACR,iBAAiB,CAAC;AAEtB;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,qGAAqG;IACrG,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,wFAAwF;IACxF,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,oFAAoF;IACpF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iCAAiC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module question-form/types
|
|
3
|
+
*
|
|
4
|
+
* Type vocabulary for the `<question-form>` parser, split out of the
|
|
5
|
+
* original single-file `question-form.ts` so `scan.ts` / `normalize.ts` /
|
|
6
|
+
* `format.ts` can each import just the types they need without pulling in
|
|
7
|
+
* one another's implementation. See `../question-form.ts` for the public
|
|
8
|
+
* facade and the block format this vocabulary describes.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/question-form/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module question-form
|
|
3
|
+
*
|
|
4
|
+
* Parser for inline `<question-form>...</question-form>` blocks an agent
|
|
5
|
+
* emits to ask the user a structured set of clarifying questions before
|
|
6
|
+
* proceeding. Body must be JSON, e.g.:
|
|
7
|
+
*
|
|
8
|
+
* <question-form id="discovery" title="Quick brief">
|
|
9
|
+
* {
|
|
10
|
+
* "questions": [
|
|
11
|
+
* { "id": "platform", "label": "Platform", "type": "radio",
|
|
12
|
+
* "options": ["Mobile (iOS/Android)", "Desktop web", "Responsive"],
|
|
13
|
+
* "required": true }
|
|
14
|
+
* ]
|
|
15
|
+
* }
|
|
16
|
+
* </question-form>
|
|
17
|
+
*
|
|
18
|
+
* `<ask-question>...</ask-question>` is accepted as an alias for
|
|
19
|
+
* `<question-form>`, so a model that drifts to the colloquial tag name
|
|
20
|
+
* still renders correctly instead of leaking raw markup into prose.
|
|
21
|
+
*
|
|
22
|
+
* Splits a final assistant text payload into ordered segments — prose +
|
|
23
|
+
* forms — so a host's message renderer can render the form inline.
|
|
24
|
+
*
|
|
25
|
+
* This module is a stable public facade. The implementation is split across
|
|
26
|
+
* `question-form/` by responsibility, each with its own invariants:
|
|
27
|
+
* - `types.ts` — the shared type vocabulary
|
|
28
|
+
* - `scan.ts` — tag matching, prose/form segmentation, and the
|
|
29
|
+
* tolerant streaming-recovery path
|
|
30
|
+
* - `normalize.ts` — raw-JSON-to-`FormQuestion` normalization, including
|
|
31
|
+
* the `isRenderableColor` CSS-injection guard
|
|
32
|
+
* - `format.ts` — turning submitted answers into agent-readable prose
|
|
33
|
+
* Only re-exports live here; do not add implementation directly to this file.
|
|
34
|
+
*/
|
|
35
|
+
export type { QuestionType, DirectionCard, FormOption, FormQuestion, QuestionForm, FormSegment } from './question-form/types.js';
|
|
36
|
+
export { splitOnQuestionForms, findFirstQuestionForm, parseQuestionForm, stripTrailingOpenQuestionForm, hasUnterminatedQuestionForm, parsePartialQuestionForm, } from './question-form/scan.js';
|
|
37
|
+
export { isRenderableColor } from './question-form/normalize.js';
|
|
38
|
+
export { formatFormAnswers, formOptionLabelForValue, formOptionValueForLabel } from './question-form/format.js';
|
|
39
|
+
//# sourceMappingURL=question-form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question-form.d.ts","sourceRoot":"","sources":["../../src/core/question-form.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACjI,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,6BAA6B,EAC7B,2BAA2B,EAC3B,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { splitOnQuestionForms, findFirstQuestionForm, parseQuestionForm, stripTrailingOpenQuestionForm, hasUnterminatedQuestionForm, parsePartialQuestionForm, } from './question-form/scan.js';
|
|
2
|
+
export { isRenderableColor } from './question-form/normalize.js';
|
|
3
|
+
export { formatFormAnswers, formOptionLabelForValue, formOptionValueForLabel } from './question-form/format.js';
|
|
4
|
+
//# sourceMappingURL=question-form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question-form.js","sourceRoot":"","sources":["../../src/core/question-form.ts"],"names":[],"mappings":"AAmCA,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,6BAA6B,EAC7B,2BAA2B,EAC3B,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module todos
|
|
3
|
+
*
|
|
4
|
+
* Pure TodoWrite-style plan-tool snapshot parsing/derivation. Reads the
|
|
5
|
+
* structured plan a `TodoWrite`/`update_plan`-shaped tool call carries and
|
|
6
|
+
* derives the "latest plan state" a pinned progress card renders — no I/O,
|
|
7
|
+
* no framework.
|
|
8
|
+
*/
|
|
9
|
+
import type { AgentEvent } from './events.js';
|
|
10
|
+
import type { ChatRunStatus } from './messages.js';
|
|
11
|
+
export type TodoStatus = 'pending' | 'in_progress' | 'completed' | 'stopped';
|
|
12
|
+
export interface TodoItem {
|
|
13
|
+
content: string;
|
|
14
|
+
status: TodoStatus;
|
|
15
|
+
activeForm?: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** `true` when `name` is one of the accepted plan/TodoWrite tool-name spellings. */
|
|
18
|
+
export declare function isTodoWriteToolName(name: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Parse a plan-tool call's raw `input` into a normalized `TodoItem[]`,
|
|
21
|
+
* tolerating the several shapes different agent runtimes emit (`todos` vs
|
|
22
|
+
* `plan` array; `content`/`step`/`description`/`label`/`text` for the item
|
|
23
|
+
* body; `activeForm`/`active_form`).
|
|
24
|
+
*
|
|
25
|
+
* @param input - The `tool_use` event's `input`, of unknown shape.
|
|
26
|
+
* @returns Normalized items; entries with no recognizable body text are dropped.
|
|
27
|
+
* @complexity O(n) in the number of raw plan entries.
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseTodoWriteInput(input: unknown): TodoItem[];
|
|
30
|
+
/**
|
|
31
|
+
* Find the most recent plan-tool `tool_use` in a single turn's events and
|
|
32
|
+
* return its parsed items, or `[]` if this turn never wrote a plan.
|
|
33
|
+
* @complexity O(n), scanning from the end.
|
|
34
|
+
*/
|
|
35
|
+
export declare function latestTodosFromEvents(events: AgentEvent[] | undefined): TodoItem[];
|
|
36
|
+
/** The subset of {@link latestTodosFromEvents} not yet marked `completed`. */
|
|
37
|
+
export declare function unfinishedTodosFromEvents(events: AgentEvent[] | undefined): TodoItem[];
|
|
38
|
+
/**
|
|
39
|
+
* Walk a conversation in reverse to find the most recent plan-tool
|
|
40
|
+
* `tool_use` across every message and return its raw (un-parsed) `input`, so
|
|
41
|
+
* a caller can hand it straight to a plan/todo card without re-implementing
|
|
42
|
+
* the discovery walk.
|
|
43
|
+
*
|
|
44
|
+
* @param messages - Conversation turns, oldest first (only `events` is read).
|
|
45
|
+
* @returns The raw tool input, or `null` if no plan tool has run yet.
|
|
46
|
+
* @complexity O(n*m) worst case (n messages, m events each), but returns on
|
|
47
|
+
* the first hit scanning backwards, so the common case (a recent plan
|
|
48
|
+
* update) is far cheaper.
|
|
49
|
+
*/
|
|
50
|
+
export declare function latestTodoWriteInputFromMessages(messages: ReadonlyArray<{
|
|
51
|
+
events?: AgentEvent[] | undefined;
|
|
52
|
+
}> | undefined): unknown | null;
|
|
53
|
+
/** Convenience alias for {@link latestTodoWriteInputFromMessages} matching the `latestTodoWriteInput()` name in the target API. */
|
|
54
|
+
export declare const latestTodoWriteInput: typeof latestTodoWriteInputFromMessages;
|
|
55
|
+
/**
|
|
56
|
+
* Variant of {@link latestTodoWriteInputFromMessages} for a "pinned progress
|
|
57
|
+
* card" that must stay honest once its owning run has ended: while the run
|
|
58
|
+
* is still active the raw input is returned as-is, but once the run is
|
|
59
|
+
* terminal any item still marked `in_progress` is flipped to `stopped` (the
|
|
60
|
+
* agent process exited before marking it done or failed).
|
|
61
|
+
*
|
|
62
|
+
* @complexity Same as {@link latestTodoWriteInputFromMessages}, plus an O(m)
|
|
63
|
+
* remap of the winning turn's items when the run has ended.
|
|
64
|
+
*/
|
|
65
|
+
export declare function latestTodoWriteInputForPinnedCard<T extends {
|
|
66
|
+
events?: AgentEvent[] | undefined;
|
|
67
|
+
runStatus?: ChatRunStatus | undefined;
|
|
68
|
+
endedAt?: number | undefined;
|
|
69
|
+
}>(messages: ReadonlyArray<T> | undefined): unknown | null;
|
|
70
|
+
//# sourceMappingURL=todos.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todos.d.ts","sourceRoot":"","sources":["../../src/core/todos.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,SAAS,CAAC;AAE7E,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AASD,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD;AAYD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,EAAE,CAiC9D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,GAAG,QAAQ,EAAE,CAQlF;AAED,8EAA8E;AAC9E,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,GAAG,QAAQ,EAAE,CAEtF;AAED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