@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,175 @@
|
|
|
1
|
+
const TODO_WRITE_TOOL_NAMES = new Set([
|
|
2
|
+
'TodoWrite',
|
|
3
|
+
'todowrite',
|
|
4
|
+
'todo_write',
|
|
5
|
+
'update_plan',
|
|
6
|
+
]);
|
|
7
|
+
/** `true` when `name` is one of the accepted plan/TodoWrite tool-name spellings. */
|
|
8
|
+
export function isTodoWriteToolName(name) {
|
|
9
|
+
return TODO_WRITE_TOOL_NAMES.has(name);
|
|
10
|
+
}
|
|
11
|
+
function normalizeTodoStatus(status) {
|
|
12
|
+
if (status === 'completed' || status === 'in_progress' || status === 'stopped') {
|
|
13
|
+
return status;
|
|
14
|
+
}
|
|
15
|
+
if (status === 'cancelled' || status === 'canceled' || status === 'failed') {
|
|
16
|
+
return 'stopped';
|
|
17
|
+
}
|
|
18
|
+
return 'pending';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Parse a plan-tool call's raw `input` into a normalized `TodoItem[]`,
|
|
22
|
+
* tolerating the several shapes different agent runtimes emit (`todos` vs
|
|
23
|
+
* `plan` array; `content`/`step`/`description`/`label`/`text` for the item
|
|
24
|
+
* body; `activeForm`/`active_form`).
|
|
25
|
+
*
|
|
26
|
+
* @param input - The `tool_use` event's `input`, of unknown shape.
|
|
27
|
+
* @returns Normalized items; entries with no recognizable body text are dropped.
|
|
28
|
+
* @complexity O(n) in the number of raw plan entries.
|
|
29
|
+
*/
|
|
30
|
+
export function parseTodoWriteInput(input) {
|
|
31
|
+
if (!input || typeof input !== 'object')
|
|
32
|
+
return [];
|
|
33
|
+
const obj = input;
|
|
34
|
+
const rawItems = Array.isArray(obj.todos) ? obj.todos : Array.isArray(obj.plan) ? obj.plan : [];
|
|
35
|
+
return rawItems
|
|
36
|
+
.map((todo) => {
|
|
37
|
+
if (!todo || typeof todo !== 'object')
|
|
38
|
+
return null;
|
|
39
|
+
const record = todo;
|
|
40
|
+
const content = typeof record.content === 'string'
|
|
41
|
+
? record.content
|
|
42
|
+
: typeof record.step === 'string'
|
|
43
|
+
? record.step
|
|
44
|
+
: typeof record.description === 'string'
|
|
45
|
+
? record.description
|
|
46
|
+
: typeof record.label === 'string'
|
|
47
|
+
? record.label
|
|
48
|
+
: typeof record.text === 'string'
|
|
49
|
+
? record.text
|
|
50
|
+
: '';
|
|
51
|
+
if (!content)
|
|
52
|
+
return null;
|
|
53
|
+
return {
|
|
54
|
+
content,
|
|
55
|
+
status: normalizeTodoStatus(record.status),
|
|
56
|
+
activeForm: typeof record.activeForm === 'string'
|
|
57
|
+
? record.activeForm
|
|
58
|
+
: typeof record.active_form === 'string'
|
|
59
|
+
? record.active_form
|
|
60
|
+
: undefined,
|
|
61
|
+
};
|
|
62
|
+
})
|
|
63
|
+
.filter((todo) => todo !== null);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Find the most recent plan-tool `tool_use` in a single turn's events and
|
|
67
|
+
* return its parsed items, or `[]` if this turn never wrote a plan.
|
|
68
|
+
* @complexity O(n), scanning from the end.
|
|
69
|
+
*/
|
|
70
|
+
export function latestTodosFromEvents(events) {
|
|
71
|
+
if (!events)
|
|
72
|
+
return [];
|
|
73
|
+
for (let i = events.length - 1; i >= 0; i -= 1) {
|
|
74
|
+
const event = events[i];
|
|
75
|
+
if (event?.kind !== 'tool_use' || !isTodoWriteToolName(event.name))
|
|
76
|
+
continue;
|
|
77
|
+
return parseTodoWriteInput(event.input);
|
|
78
|
+
}
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
/** The subset of {@link latestTodosFromEvents} not yet marked `completed`. */
|
|
82
|
+
export function unfinishedTodosFromEvents(events) {
|
|
83
|
+
return latestTodosFromEvents(events).filter((todo) => todo.status !== 'completed');
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Walk a conversation in reverse to find the most recent plan-tool
|
|
87
|
+
* `tool_use` across every message and return its raw (un-parsed) `input`, so
|
|
88
|
+
* a caller can hand it straight to a plan/todo card without re-implementing
|
|
89
|
+
* the discovery walk.
|
|
90
|
+
*
|
|
91
|
+
* @param messages - Conversation turns, oldest first (only `events` is read).
|
|
92
|
+
* @returns The raw tool input, or `null` if no plan tool has run yet.
|
|
93
|
+
* @complexity O(n*m) worst case (n messages, m events each), but returns on
|
|
94
|
+
* the first hit scanning backwards, so the common case (a recent plan
|
|
95
|
+
* update) is far cheaper.
|
|
96
|
+
*/
|
|
97
|
+
export function latestTodoWriteInputFromMessages(messages) {
|
|
98
|
+
if (!messages || messages.length === 0)
|
|
99
|
+
return null;
|
|
100
|
+
for (let mi = messages.length - 1; mi >= 0; mi -= 1) {
|
|
101
|
+
const events = messages[mi]?.events;
|
|
102
|
+
if (!events || events.length === 0)
|
|
103
|
+
continue;
|
|
104
|
+
for (let ei = events.length - 1; ei >= 0; ei -= 1) {
|
|
105
|
+
const event = events[ei];
|
|
106
|
+
if (event?.kind !== 'tool_use')
|
|
107
|
+
continue;
|
|
108
|
+
if (!isTodoWriteToolName(event.name))
|
|
109
|
+
continue;
|
|
110
|
+
return event.input;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
/** Convenience alias for {@link latestTodoWriteInputFromMessages} matching the `latestTodoWriteInput()` name in the target API. */
|
|
116
|
+
export const latestTodoWriteInput = latestTodoWriteInputFromMessages;
|
|
117
|
+
function hasTerminalRunEnded(runStatus, endedAt) {
|
|
118
|
+
return (runStatus === 'succeeded' ||
|
|
119
|
+
runStatus === 'failed' ||
|
|
120
|
+
runStatus === 'canceled' ||
|
|
121
|
+
(runStatus === undefined && endedAt !== undefined));
|
|
122
|
+
}
|
|
123
|
+
function stoppedTodoWriteInput(input) {
|
|
124
|
+
if (!input || typeof input !== 'object')
|
|
125
|
+
return input;
|
|
126
|
+
const obj = input;
|
|
127
|
+
const key = Array.isArray(obj.todos) ? 'todos' : Array.isArray(obj.plan) ? 'plan' : null;
|
|
128
|
+
if (!key)
|
|
129
|
+
return input;
|
|
130
|
+
const items = obj[key];
|
|
131
|
+
return {
|
|
132
|
+
...input,
|
|
133
|
+
[key]: items.map((todo) => {
|
|
134
|
+
if (!todo || typeof todo !== 'object')
|
|
135
|
+
return todo;
|
|
136
|
+
const record = todo;
|
|
137
|
+
if (record.status !== 'in_progress')
|
|
138
|
+
return todo;
|
|
139
|
+
return { ...record, status: 'stopped' };
|
|
140
|
+
}),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Variant of {@link latestTodoWriteInputFromMessages} for a "pinned progress
|
|
145
|
+
* card" that must stay honest once its owning run has ended: while the run
|
|
146
|
+
* is still active the raw input is returned as-is, but once the run is
|
|
147
|
+
* terminal any item still marked `in_progress` is flipped to `stopped` (the
|
|
148
|
+
* agent process exited before marking it done or failed).
|
|
149
|
+
*
|
|
150
|
+
* @complexity Same as {@link latestTodoWriteInputFromMessages}, plus an O(m)
|
|
151
|
+
* remap of the winning turn's items when the run has ended.
|
|
152
|
+
*/
|
|
153
|
+
export function latestTodoWriteInputForPinnedCard(messages) {
|
|
154
|
+
if (!messages || messages.length === 0)
|
|
155
|
+
return null;
|
|
156
|
+
for (let mi = messages.length - 1; mi >= 0; mi -= 1) {
|
|
157
|
+
const message = messages[mi];
|
|
158
|
+
const events = message?.events;
|
|
159
|
+
if (!events || events.length === 0)
|
|
160
|
+
continue;
|
|
161
|
+
for (let ei = events.length - 1; ei >= 0; ei -= 1) {
|
|
162
|
+
const event = events[ei];
|
|
163
|
+
if (event?.kind !== 'tool_use')
|
|
164
|
+
continue;
|
|
165
|
+
if (!isTodoWriteToolName(event.name))
|
|
166
|
+
continue;
|
|
167
|
+
if (!hasTerminalRunEnded(message.runStatus, message.endedAt)) {
|
|
168
|
+
return event.input;
|
|
169
|
+
}
|
|
170
|
+
return stoppedTodoWriteInput(event.input);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=todos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todos.js","sourceRo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AI,CAAC;IACpD,KAAK,IAAI,EAAE,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,OAAO,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC7B,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;QAC/B,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS;QAC7C,KAAK,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;YAClD,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;YACzB,IAAI,KAAK,EAAE,IAAI,KAAK,UAAU;gBAAE,SAAS;YACzC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC;gBAAE,SAAS;YAC/C,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC7D,OAAO,KAAK,CAAC,KAAK,CAAC;YACrB,CAAC;YACD,OAAO,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AgentEvent } from './events.js';
|
|
2
|
+
/**
|
|
3
|
+
* Drop repeated `tool_use` events that share an `id`. A retried/duplicated
|
|
4
|
+
* stream can replay the same tool-call id (e.g. reconnect-and-replay landing
|
|
5
|
+
* an event twice); rendering it twice would show a phantom second call.
|
|
6
|
+
* Non-`tool_use` events (and the first occurrence of each id) pass through
|
|
7
|
+
* unchanged and in original order.
|
|
8
|
+
*
|
|
9
|
+
* @param events - The event list to dedupe, or `undefined` for an empty conversation turn.
|
|
10
|
+
* @returns A new array with later duplicate `tool_use` events removed, or the
|
|
11
|
+
* original array reference when nothing needed to change (cheap no-op for
|
|
12
|
+
* the common case).
|
|
13
|
+
* @complexity O(n) time / O(k) extra space, where `n` is `events.length` and
|
|
14
|
+
* `k` is the number of distinct `tool_use` ids seen — one linear pass with
|
|
15
|
+
* a `Set` membership check.
|
|
16
|
+
*/
|
|
17
|
+
export declare function dedupeToolUsesById(events: AgentEvent[] | undefined): AgentEvent[];
|
|
18
|
+
//# sourceMappingURL=tool-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-events.d.ts","sourceRoot":"","sources":["../../src/core/tool-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,GAAG,UAAU,EAAE,CAkBjF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drop repeated `tool_use` events that share an `id`. A retried/duplicated
|
|
3
|
+
* stream can replay the same tool-call id (e.g. reconnect-and-replay landing
|
|
4
|
+
* an event twice); rendering it twice would show a phantom second call.
|
|
5
|
+
* Non-`tool_use` events (and the first occurrence of each id) pass through
|
|
6
|
+
* unchanged and in original order.
|
|
7
|
+
*
|
|
8
|
+
* @param events - The event list to dedupe, or `undefined` for an empty conversation turn.
|
|
9
|
+
* @returns A new array with later duplicate `tool_use` events removed, or the
|
|
10
|
+
* original array reference when nothing needed to change (cheap no-op for
|
|
11
|
+
* the common case).
|
|
12
|
+
* @complexity O(n) time / O(k) extra space, where `n` is `events.length` and
|
|
13
|
+
* `k` is the number of distinct `tool_use` ids seen — one linear pass with
|
|
14
|
+
* a `Set` membership check.
|
|
15
|
+
*/
|
|
16
|
+
export function dedupeToolUsesById(events) {
|
|
17
|
+
if (!events || events.length === 0)
|
|
18
|
+
return [];
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
let deduped = null;
|
|
21
|
+
for (let i = 0; i < events.length; i += 1) {
|
|
22
|
+
const event = events[i];
|
|
23
|
+
if (event.kind === 'tool_use') {
|
|
24
|
+
if (seen.has(event.id)) {
|
|
25
|
+
if (!deduped)
|
|
26
|
+
deduped = events.slice(0, i);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
seen.add(event.id);
|
|
30
|
+
}
|
|
31
|
+
if (deduped)
|
|
32
|
+
deduped.push(event);
|
|
33
|
+
}
|
|
34
|
+
return deduped ?? events;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=tool-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-events.js","sourceRoot":"","sources":["../../src/core/tool-events.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAgC;IACjE,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAE9C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,IAAI,OAAO,GAAwB,IAAI,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAE,CAAC;QACzB,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC9B,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;gBACvB,IAAI,CAAC,OAAO;oBAAE,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC3C,SAAS;YACX,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACrB,CAAC;QACD,IAAI,OAAO;YAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,OAAO,IAAI,MAAM,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module tools
|
|
3
|
+
*
|
|
4
|
+
* Pure tool-lifecycle derivation shared by any host's tool-call renderer.
|
|
5
|
+
* Deliberately does NOT include the renderer-registry/registration
|
|
6
|
+
* mechanism (`registerToolRenderer`/`getToolRenderer` in OD's
|
|
7
|
+
* `runtime/tool-renderers.ts`) — that is a presentational, React-facing
|
|
8
|
+
* extension point that belongs to `@jini-ai/chat-react` (or
|
|
9
|
+
* `@jini-ai/renderers-react`), not this framework-free package. See
|
|
10
|
+
* source-map.md.
|
|
11
|
+
*/
|
|
12
|
+
import type { ToolResultEvent, ToolResultMediaBlock, ToolUseEvent } from './events.js';
|
|
13
|
+
export { dedupeToolUsesById } from './tool-events.js';
|
|
14
|
+
/** The four-state tool-call lifecycle agreed across AG-UI / CopilotKit / LangGraph render props. */
|
|
15
|
+
export type ToolStatus = 'inProgress' | 'executing' | 'complete' | 'error';
|
|
16
|
+
/** The render-prop payload a tool-call UI needs, independent of any framework. */
|
|
17
|
+
export interface ToolRenderProps {
|
|
18
|
+
status: ToolStatus;
|
|
19
|
+
name: string;
|
|
20
|
+
args: unknown;
|
|
21
|
+
result: string | undefined;
|
|
22
|
+
/** Mirrors `tool_result.isError`. Terminal failures without a `tool_result` surface via `status: 'error'` instead. */
|
|
23
|
+
isError: boolean;
|
|
24
|
+
/** Mirrors `tool_result.media`. `undefined` for the overwhelming majority of tool results, which carry none. */
|
|
25
|
+
media: readonly ToolResultMediaBlock[] | undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Map a tool call to its AG-UI-style lifecycle status.
|
|
29
|
+
*
|
|
30
|
+
* - `error` — the tool returned with `isError`.
|
|
31
|
+
* - `complete` — the tool returned cleanly.
|
|
32
|
+
* - `executing` — no result yet and the run is still streaming.
|
|
33
|
+
* - `complete` — no result yet but the run finished successfully (some
|
|
34
|
+
* stored assistant turns are missing a trailing `tool_result` even though
|
|
35
|
+
* the run succeeded).
|
|
36
|
+
* - `error` — no result after a run that finished unsuccessfully.
|
|
37
|
+
*
|
|
38
|
+
* @param result - The matching `tool_result` event, if one has arrived.
|
|
39
|
+
* @param runStreaming - Whether the owning run is still emitting events.
|
|
40
|
+
* @param runSucceeded - Whether the (already-terminal) run succeeded. Ignored while `runStreaming` is true.
|
|
41
|
+
* @complexity O(1).
|
|
42
|
+
*/
|
|
43
|
+
export declare function deriveToolStatus(result: ToolResultEvent | undefined, runStreaming: boolean, runSucceeded?: boolean): ToolStatus;
|
|
44
|
+
/**
|
|
45
|
+
* Project a `tool_use`/`tool_result` pair plus run state into the render-prop
|
|
46
|
+
* shape a tool-call UI consumes.
|
|
47
|
+
*
|
|
48
|
+
* @complexity O(1) — delegates its only branching to {@link deriveToolStatus}.
|
|
49
|
+
*/
|
|
50
|
+
export declare function toRenderProps(use: ToolUseEvent, result: ToolResultEvent | undefined, runStreaming: boolean, runSucceeded?: boolean): ToolRenderProps;
|
|
51
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/core/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,oGAAoG;AACpG,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,WAAW,GAAG,UAAU,GAAG,OAAO,CAAC;AAE3E,kFAAkF;AAClF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,sHAAsH;IACtH,OAAO,EAAE,OAAO,CAAC;IACjB,gHAAgH;IAChH,KAAK,EAAE,SAAS,oBAAoB,EAAE,GAAG,SAAS,CAAC;CACpD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,eAAe,GAAG,SAAS,EACnC,YAAY,EAAE,OAAO,EACrB,YAAY,UAAQ,GACnB,UAAU,CAIZ;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,eAAe,GAAG,SAAS,EACnC,YAAY,EAAE,OAAO,EACrB,YAAY,UAAQ,GACnB,eAAe,CASjB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export { dedupeToolUsesById } from './tool-events.js';
|
|
2
|
+
/**
|
|
3
|
+
* Map a tool call to its AG-UI-style lifecycle status.
|
|
4
|
+
*
|
|
5
|
+
* - `error` — the tool returned with `isError`.
|
|
6
|
+
* - `complete` — the tool returned cleanly.
|
|
7
|
+
* - `executing` — no result yet and the run is still streaming.
|
|
8
|
+
* - `complete` — no result yet but the run finished successfully (some
|
|
9
|
+
* stored assistant turns are missing a trailing `tool_result` even though
|
|
10
|
+
* the run succeeded).
|
|
11
|
+
* - `error` — no result after a run that finished unsuccessfully.
|
|
12
|
+
*
|
|
13
|
+
* @param result - The matching `tool_result` event, if one has arrived.
|
|
14
|
+
* @param runStreaming - Whether the owning run is still emitting events.
|
|
15
|
+
* @param runSucceeded - Whether the (already-terminal) run succeeded. Ignored while `runStreaming` is true.
|
|
16
|
+
* @complexity O(1).
|
|
17
|
+
*/
|
|
18
|
+
export function deriveToolStatus(result, runStreaming, runSucceeded = false) {
|
|
19
|
+
if (result)
|
|
20
|
+
return result.isError ? 'error' : 'complete';
|
|
21
|
+
if (runStreaming)
|
|
22
|
+
return 'executing';
|
|
23
|
+
return runSucceeded ? 'complete' : 'error';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Project a `tool_use`/`tool_result` pair plus run state into the render-prop
|
|
27
|
+
* shape a tool-call UI consumes.
|
|
28
|
+
*
|
|
29
|
+
* @complexity O(1) — delegates its only branching to {@link deriveToolStatus}.
|
|
30
|
+
*/
|
|
31
|
+
export function toRenderProps(use, result, runStreaming, runSucceeded = false) {
|
|
32
|
+
return {
|
|
33
|
+
status: deriveToolStatus(result, runStreaming, runSucceeded),
|
|
34
|
+
name: use.name,
|
|
35
|
+
args: use.input,
|
|
36
|
+
result: result?.content,
|
|
37
|
+
isError: result?.isError ?? false,
|
|
38
|
+
media: result?.media,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/core/tools.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAiBtD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAmC,EACnC,YAAqB,EACrB,YAAY,GAAG,KAAK;IAEpB,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC;IACzD,IAAI,YAAY;QAAE,OAAO,WAAW,CAAC;IACrC,OAAO,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAiB,EACjB,MAAmC,EACnC,YAAqB,EACrB,YAAY,GAAG,KAAK;IAEpB,OAAO;QACL,MAAM,EAAE,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC;QAC5D,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,IAAI,EAAE,GAAG,CAAC,KAAK;QACf,MAAM,EAAE,MAAM,EAAE,OAAO;QACvB,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,KAAK;QACjC,KAAK,EAAE,MAAM,EAAE,KAAK;KACrB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module transcript
|
|
3
|
+
*
|
|
4
|
+
* Pure transcript-assembly helpers: turning a `ChatMessage[]` history into
|
|
5
|
+
* the flattened text a host sends to an agent as prior-turn context.
|
|
6
|
+
*
|
|
7
|
+
* Adapted from OD's `providers/daemon.ts` transcript section (see
|
|
8
|
+
* source-map.md). The OD original also owned SSE/fetch transport
|
|
9
|
+
* (`streamViaDaemon`, `DaemonStreamHandlers`) — none of that is ported here;
|
|
10
|
+
* only the pure string-assembly helpers. It also hard-coded OD's BYOK/
|
|
11
|
+
* OpenCode agent-family policy and an `agent-browser`-tool-specific
|
|
12
|
+
* context-warning heuristic; both are OD product policy, not generic
|
|
13
|
+
* transcript assembly, so they are generalized into caller-supplied hooks
|
|
14
|
+
* (or dropped) below — see source-map.md for the full accounting.
|
|
15
|
+
*/
|
|
16
|
+
import type { ChatMessage } from './messages.js';
|
|
17
|
+
import type { PersistedArtifactFileRef } from './util/strip.js';
|
|
18
|
+
/** The most recent `user`-authored message's content, or `''` if there isn't one. */
|
|
19
|
+
export declare function latestUserPromptFromHistory(history: ChatMessage[]): string;
|
|
20
|
+
/**
|
|
21
|
+
* Strip transcript-echo hazards from a prior assistant turn before it goes
|
|
22
|
+
* back to the agent as history: an already-answered `<question-form>` /
|
|
23
|
+
* `<ask-question>` block (and a fenced JSON schema echo of the same shape),
|
|
24
|
+
* plus any `<artifact>` body CONFIRMED persisted to `persistedArtifactFiles`
|
|
25
|
+
* (replaced with a one-line pointer to the on-disk file — see
|
|
26
|
+
* {@link summarizeArtifactsForTranscript}).
|
|
27
|
+
*
|
|
28
|
+
* Leaving an answered form literal in the transcript causes a weak/plain
|
|
29
|
+
* model to pattern-match it as a template and re-emit an identical form on
|
|
30
|
+
* the user's next turn, looking like the clarification loop never breaks.
|
|
31
|
+
*
|
|
32
|
+
* User-authored content is never sanitized by this function — a user
|
|
33
|
+
* legitimately quoting `<question-form>` markup must not be mangled; only
|
|
34
|
+
* assistant turns should be passed in.
|
|
35
|
+
*
|
|
36
|
+
* @complexity O(n) in `content.length` (a small fixed number of regex
|
|
37
|
+
* passes) plus {@link summarizeArtifactsForTranscript}'s cost.
|
|
38
|
+
*/
|
|
39
|
+
export declare function sanitizePriorAssistantTurn(content: string, persistedArtifactFiles?: ReadonlyArray<PersistedArtifactFileRef>): string;
|
|
40
|
+
export interface BuildTranscriptOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Scope the transcript to messages from this agent's family onward,
|
|
43
|
+
* dropping any older history from a different agent. Omit to include the
|
|
44
|
+
* full history (no scoping).
|
|
45
|
+
*/
|
|
46
|
+
targetAgentId?: string;
|
|
47
|
+
/**
|
|
48
|
+
* How to decide two agent ids belong to the "same family" for the
|
|
49
|
+
* purposes of `targetAgentId` scoping (e.g. a host may route several
|
|
50
|
+
* model ids through one shared agent identity). Defaults to exact-id
|
|
51
|
+
* equality when omitted.
|
|
52
|
+
*/
|
|
53
|
+
isSameAgentFamily?: (agentId: string, targetAgentId: string) => boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Resolve the files a given message's artifacts were confirmed persisted
|
|
56
|
+
* to, so their bodies can be summarized instead of replayed verbatim. A
|
|
57
|
+
* host derives this from its own file-write bookkeeping — chat-core's
|
|
58
|
+
* `ChatMessage` intentionally carries no `producedFiles`-shaped field.
|
|
59
|
+
* Defaults to "nothing persisted" (no summarization).
|
|
60
|
+
*/
|
|
61
|
+
resolvePersistedArtifactFiles?: (message: ChatMessage) => ReadonlyArray<PersistedArtifactFileRef>;
|
|
62
|
+
/** Per-message character cap before truncation. @default 12000 */
|
|
63
|
+
maxMessageChars?: number;
|
|
64
|
+
/** `tool_result.content` length above which a result counts as "large" for the context warning. @default 8000 */
|
|
65
|
+
largeToolResultChars?: number;
|
|
66
|
+
/** `usage.inputTokens` above which the context warning fires. @default 200000 */
|
|
67
|
+
highInputTokenWarningThreshold?: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Flatten a conversation history into the `## role\n<content>` transcript
|
|
71
|
+
* text sent to an agent as prior-turn context: scopes to the target agent
|
|
72
|
+
* family (if requested), sanitizes each assistant turn, truncates
|
|
73
|
+
* over-length messages, and prepends a compact-turn warning when prior-run
|
|
74
|
+
* telemetry suggests one is warranted.
|
|
75
|
+
*
|
|
76
|
+
* @complexity O(n) in the total transcript character count — one pass to
|
|
77
|
+
* scope, one to sanitize/truncate/join each message, one to scan events
|
|
78
|
+
* for the warning.
|
|
79
|
+
*/
|
|
80
|
+
export declare function buildTranscript(history: ChatMessage[], options?: BuildTranscriptOptions): string;
|
|
81
|
+
//# sourceMappingURL=transcript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../src/core/transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAOhE,qFAAqF;AACrF,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAM1E;AA0DD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,sBAAsB,GAAE,aAAa,CAAC,wBAAwB,CAAM,GAAG,MAAM,CAqBxI;AAED,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC;IACxE;;;;;;OAMG;IACH,6BAA6B,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,aAAa,CAAC,wBAAwB,CAAC,CAAC;IAClG,kEAAkE;IAClE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iHAAiH;IACjH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iFAAiF;IACjF,8BAA8B,CAAC,EAAE,MAAM,CAAC;CACzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,OAAO,GAAE,sBAA2B,GAAG,MAAM,CAiBpG"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { summarizeArtifactsForTranscript } from './util/strip.js';
|
|
2
|
+
const DEFAULT_MAX_TRANSCRIPT_MESSAGE_CHARS = 12_000;
|
|
3
|
+
const DEFAULT_LARGE_TOOL_RESULT_CHARS = 8_000;
|
|
4
|
+
const DEFAULT_HIGH_INPUT_TOKEN_WARNING_THRESHOLD = 200_000;
|
|
5
|
+
/** The most recent `user`-authored message's content, or `''` if there isn't one. */
|
|
6
|
+
export function latestUserPromptFromHistory(history) {
|
|
7
|
+
for (let i = history.length - 1; i >= 0; i -= 1) {
|
|
8
|
+
const message = history[i];
|
|
9
|
+
if (message?.role === 'user')
|
|
10
|
+
return message.content;
|
|
11
|
+
}
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
function truncateForTranscript(content, maxChars) {
|
|
15
|
+
if (content.length <= maxChars)
|
|
16
|
+
return content;
|
|
17
|
+
const omitted = content.length - maxChars;
|
|
18
|
+
return `${content.slice(0, maxChars)}\n\n[truncated ${omitted} chars from this prior message before sending it to the agent. Full content remains in persisted history.]`;
|
|
19
|
+
}
|
|
20
|
+
function escapeTranscriptRoleDelimiters(content) {
|
|
21
|
+
return content.replace(/^(## (?:user|assistant)[ \t]*)(\r?)$/gm, '\\$1$2');
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Build a short warning block when prior-run telemetry embedded in
|
|
25
|
+
* `history`'s events suggests the next turn should keep its own output
|
|
26
|
+
* compact (a previous run reported a very high input-token count, or
|
|
27
|
+
* carries large persisted tool results that a fresh turn shouldn't replay
|
|
28
|
+
* verbatim).
|
|
29
|
+
* @complexity O(n) across all messages' events.
|
|
30
|
+
*/
|
|
31
|
+
function buildPriorRunContextWarning(history, largeToolResultChars, highInputTokenWarningThreshold) {
|
|
32
|
+
let highestInputTokens = 0;
|
|
33
|
+
let largeToolResults = 0;
|
|
34
|
+
for (const message of history) {
|
|
35
|
+
for (const event of message.events ?? []) {
|
|
36
|
+
if (event.kind === 'usage' && typeof event.inputTokens === 'number') {
|
|
37
|
+
highestInputTokens = Math.max(highestInputTokens, event.inputTokens);
|
|
38
|
+
}
|
|
39
|
+
if (event.kind === 'tool_result' && event.content.length > largeToolResultChars) {
|
|
40
|
+
largeToolResults += 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const notes = [];
|
|
45
|
+
if (highestInputTokens >= highInputTokenWarningThreshold) {
|
|
46
|
+
notes.push(`a previous run reported ${highestInputTokens} input tokens`);
|
|
47
|
+
}
|
|
48
|
+
if (largeToolResults > 0) {
|
|
49
|
+
notes.push(`${largeToolResults} large prior tool result${largeToolResults === 1 ? '' : 's'} exist only in persisted event history`);
|
|
50
|
+
}
|
|
51
|
+
if (notes.length === 0)
|
|
52
|
+
return null;
|
|
53
|
+
return ['## context warning', `Detected ${notes.join(', ')}.`, 'Keep this turn compact: summarize prior tool output, read large references from temp files, and quote only task-relevant lines.'].join('\n');
|
|
54
|
+
}
|
|
55
|
+
function scopeHistoryToAgent(history, targetAgentId, isSameAgentFamily) {
|
|
56
|
+
if (!targetAgentId)
|
|
57
|
+
return history;
|
|
58
|
+
for (let i = history.length - 1; i >= 0; i -= 1) {
|
|
59
|
+
const message = history[i];
|
|
60
|
+
if (message?.role === 'assistant' && message.agentId && !isSameAgentFamily(message.agentId, targetAgentId)) {
|
|
61
|
+
return history.slice(i + 1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return history;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Strip transcript-echo hazards from a prior assistant turn before it goes
|
|
68
|
+
* back to the agent as history: an already-answered `<question-form>` /
|
|
69
|
+
* `<ask-question>` block (and a fenced JSON schema echo of the same shape),
|
|
70
|
+
* plus any `<artifact>` body CONFIRMED persisted to `persistedArtifactFiles`
|
|
71
|
+
* (replaced with a one-line pointer to the on-disk file — see
|
|
72
|
+
* {@link summarizeArtifactsForTranscript}).
|
|
73
|
+
*
|
|
74
|
+
* Leaving an answered form literal in the transcript causes a weak/plain
|
|
75
|
+
* model to pattern-match it as a template and re-emit an identical form on
|
|
76
|
+
* the user's next turn, looking like the clarification loop never breaks.
|
|
77
|
+
*
|
|
78
|
+
* User-authored content is never sanitized by this function — a user
|
|
79
|
+
* legitimately quoting `<question-form>` markup must not be mangled; only
|
|
80
|
+
* assistant turns should be passed in.
|
|
81
|
+
*
|
|
82
|
+
* @complexity O(n) in `content.length` (a small fixed number of regex
|
|
83
|
+
* passes) plus {@link summarizeArtifactsForTranscript}'s cost.
|
|
84
|
+
*/
|
|
85
|
+
export function sanitizePriorAssistantTurn(content, persistedArtifactFiles = []) {
|
|
86
|
+
let sanitized = content.replace(
|
|
87
|
+
// `\1` backreference keeps the open/close tag names matched so this never
|
|
88
|
+
// splices across a `<question-form>…</ask-question>` mismatch.
|
|
89
|
+
/<(question-form|ask-question)\b[^>]*>[\s\S]*?<\/\1>/g, '[question-form was emitted here on a prior turn; the user already answered, see their reply below.]');
|
|
90
|
+
// Strip ```json (or plain ```) fenced blocks whose body matches the form
|
|
91
|
+
// schema shape — `"questions": [` is the strongest tell. A generic JSON
|
|
92
|
+
// snippet without that key is left intact.
|
|
93
|
+
sanitized = sanitized.replace(/```(?:json)?\s*\n([\s\S]*?)\n```/g, (match, body) => {
|
|
94
|
+
if (/"questions"\s*:\s*\[/.test(body)) {
|
|
95
|
+
return '[form schema was echoed here on a prior turn; stripped to avoid a loop.]';
|
|
96
|
+
}
|
|
97
|
+
return match;
|
|
98
|
+
});
|
|
99
|
+
// Replace prior-turn `<artifact>` HTML with a one-line summary for
|
|
100
|
+
// artifacts CONFIRMED persisted (see summarizeArtifactsForTranscript's own
|
|
101
|
+
// doc for why an unconfirmed save is left verbatim).
|
|
102
|
+
sanitized = summarizeArtifactsForTranscript(sanitized, persistedArtifactFiles);
|
|
103
|
+
return sanitized;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Flatten a conversation history into the `## role\n<content>` transcript
|
|
107
|
+
* text sent to an agent as prior-turn context: scopes to the target agent
|
|
108
|
+
* family (if requested), sanitizes each assistant turn, truncates
|
|
109
|
+
* over-length messages, and prepends a compact-turn warning when prior-run
|
|
110
|
+
* telemetry suggests one is warranted.
|
|
111
|
+
*
|
|
112
|
+
* @complexity O(n) in the total transcript character count — one pass to
|
|
113
|
+
* scope, one to sanitize/truncate/join each message, one to scan events
|
|
114
|
+
* for the warning.
|
|
115
|
+
*/
|
|
116
|
+
export function buildTranscript(history, options = {}) {
|
|
117
|
+
const maxMessageChars = options.maxMessageChars ?? DEFAULT_MAX_TRANSCRIPT_MESSAGE_CHARS;
|
|
118
|
+
const largeToolResultChars = options.largeToolResultChars ?? DEFAULT_LARGE_TOOL_RESULT_CHARS;
|
|
119
|
+
const highInputTokenWarningThreshold = options.highInputTokenWarningThreshold ?? DEFAULT_HIGH_INPUT_TOKEN_WARNING_THRESHOLD;
|
|
120
|
+
const isSameAgentFamily = options.isSameAgentFamily ?? ((agentId, targetAgentId) => agentId === targetAgentId);
|
|
121
|
+
const resolvePersistedArtifactFiles = options.resolvePersistedArtifactFiles ?? (() => []);
|
|
122
|
+
const scopedHistory = scopeHistoryToAgent(history, options.targetAgentId, isSameAgentFamily);
|
|
123
|
+
const transcript = scopedHistory
|
|
124
|
+
.map((m) => {
|
|
125
|
+
const trimmed = m.content.trim();
|
|
126
|
+
const sanitized = m.role === 'assistant' ? sanitizePriorAssistantTurn(trimmed, resolvePersistedArtifactFiles(m)) : trimmed;
|
|
127
|
+
return `## ${m.role}\n${escapeTranscriptRoleDelimiters(truncateForTranscript(sanitized, maxMessageChars))}`;
|
|
128
|
+
})
|
|
129
|
+
.join('\n\n');
|
|
130
|
+
const warning = buildPriorRunContextWarning(scopedHistory, largeToolResultChars, highInputTokenWarningThreshold);
|
|
131
|
+
return warning ? `${warning}\n\n${transcript}` : transcript;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=transcript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript.js","sourceRoot":"","sources":["../../src/core/transcript.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,oCAAoC,GAAG,MAAM,CAAC;AACpD,MAAM,+BAA+B,GAAG,KAAK,CAAC;AAC9C,MAAM,0CAA0C,GAAG,OAAO,CAAC;AAE3D,qFAAqF;AACrF,MAAM,UAAU,2BAA2B,CAAC,OAAsB;IAChE,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,OAAO,EAAE,IAAI,KAAK,MAAM;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC;IACvD,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAe,EAAE,QAAgB;IAC9D,IAAI,OAAO,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,OAAO,CAAC;IAC/C,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC;IAC1C,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAA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