@agent-native/core 0.46.0 → 0.48.1
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/bin/agent-native.js +41 -0
- package/dist/a2a/handlers.js +2 -2
- package/dist/a2a/handlers.js.map +1 -1
- package/dist/a2a/server.js +2 -2
- package/dist/a2a/server.js.map +1 -1
- package/dist/action.d.ts +43 -2
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js.map +1 -1
- package/dist/agent/context-xray/actions/context-evict.d.ts +7 -1
- package/dist/agent/context-xray/actions/context-evict.d.ts.map +1 -1
- package/dist/agent/context-xray/actions/context-manifest-get.d.ts +4 -1
- package/dist/agent/context-xray/actions/context-manifest-get.d.ts.map +1 -1
- package/dist/agent/context-xray/actions/context-pin.d.ts +7 -1
- package/dist/agent/context-xray/actions/context-pin.d.ts.map +1 -1
- package/dist/agent/context-xray/actions/context-report.d.ts +12 -1
- package/dist/agent/context-xray/actions/context-report.d.ts.map +1 -1
- package/dist/agent/context-xray/actions/context-restore.d.ts +7 -1
- package/dist/agent/context-xray/actions/context-restore.d.ts.map +1 -1
- package/dist/agent/context-xray/apply-directives.d.ts.map +1 -1
- package/dist/agent/context-xray/apply-directives.js.map +1 -1
- package/dist/agent/context-xray/schema.d.ts +10 -10
- package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.js +26 -3
- package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
- package/dist/agent/engine/anthropic-engine.d.ts +1 -1
- package/dist/agent/engine/anthropic-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.d.ts +1 -1
- package/dist/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.js +47 -8
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/engine/builtin.js +1 -1
- package/dist/agent/engine/builtin.js.map +1 -1
- package/dist/agent/engine/output-tokens.d.ts +1 -1
- package/dist/agent/engine/output-tokens.d.ts.map +1 -1
- package/dist/agent/engine/output-tokens.js +6 -2
- package/dist/agent/engine/output-tokens.js.map +1 -1
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +7 -4
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/engine/types.d.ts +19 -0
- package/dist/agent/engine/types.d.ts.map +1 -1
- package/dist/agent/engine/types.js +6 -0
- package/dist/agent/engine/types.js.map +1 -1
- package/dist/agent/model-config.d.ts +22 -14
- package/dist/agent/model-config.d.ts.map +1 -1
- package/dist/agent/model-config.js +113 -8
- package/dist/agent/model-config.js.map +1 -1
- package/dist/agent/production-agent.d.ts +47 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +267 -46
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
- package/dist/agent/run-loop-with-resume.js +10 -0
- package/dist/agent/run-loop-with-resume.js.map +1 -1
- package/dist/agent/run-manager.d.ts +1 -0
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +36 -9
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/run-store.d.ts +47 -4
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +154 -4
- package/dist/agent/run-store.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +57 -2
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/agent/types.d.ts +3 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/agent-web/generator.d.ts +3 -3
- package/dist/appearance/actions/change-appearance.d.ts +6 -1
- package/dist/appearance/actions/change-appearance.d.ts.map +1 -1
- package/dist/application-state/handlers.d.ts +2 -2
- package/dist/application-state/handlers.d.ts.map +1 -1
- package/dist/application-state/store.d.ts.map +1 -1
- package/dist/application-state/store.js +17 -0
- package/dist/application-state/store.js.map +1 -1
- package/dist/catalog.json +2 -1
- package/dist/cli/code-agent-commands.d.ts.map +1 -1
- package/dist/cli/code-agent-commands.js +2 -0
- package/dist/cli/code-agent-commands.js.map +1 -1
- package/dist/cli/code-agent-connector.js +7 -13
- package/dist/cli/code-agent-connector.js.map +1 -1
- package/dist/cli/code-agent-executor.d.ts +54 -2
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +504 -48
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/code-agent-runs.d.ts +13 -0
- package/dist/cli/code-agent-runs.d.ts.map +1 -1
- package/dist/cli/code-agent-runs.js +36 -0
- package/dist/cli/code-agent-runs.js.map +1 -1
- package/dist/cli/code.js +59 -5
- package/dist/cli/code.js.map +1 -1
- package/dist/cli/connect.js +141 -3
- package/dist/cli/connect.js.map +1 -1
- package/dist/cli/index.js +0 -0
- package/dist/cli/pr-visual-recap-workflow.js +1 -1
- package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
- package/dist/cli/recap.js +476 -46
- package/dist/cli/recap.js.map +1 -1
- package/dist/cli/skills.js +331 -179
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +29 -2
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AgentTaskCard.d.ts.map +1 -1
- package/dist/client/AgentTaskCard.js +17 -2
- package/dist/client/AgentTaskCard.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +310 -1732
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/CommandMenu.d.ts +1 -1
- package/dist/client/CommandMenu.d.ts.map +1 -1
- package/dist/client/CommandMenu.js +1 -1
- package/dist/client/CommandMenu.js.map +1 -1
- package/dist/client/HighlightedCodeBlock.d.ts +40 -0
- package/dist/client/HighlightedCodeBlock.d.ts.map +1 -0
- package/dist/client/HighlightedCodeBlock.js +110 -0
- package/dist/client/HighlightedCodeBlock.js.map +1 -0
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +8 -1
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/PoweredByBadge.d.ts +2 -2
- package/dist/client/PoweredByBadge.d.ts.map +1 -1
- package/dist/client/RunStuckBanner.d.ts +1 -1
- package/dist/client/RunStuckBanner.d.ts.map +1 -1
- package/dist/client/StarfieldBackground.d.ts.map +1 -1
- package/dist/client/StarfieldBackground.js +10 -5
- package/dist/client/StarfieldBackground.js.map +1 -1
- package/dist/client/Turnstile.d.ts +1 -1
- package/dist/client/Turnstile.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts +3 -2
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +13 -9
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/app-providers.d.ts +99 -0
- package/dist/client/app-providers.d.ts.map +1 -0
- package/dist/client/app-providers.js +19 -0
- package/dist/client/app-providers.js.map +1 -0
- package/dist/client/assistant-ui-recovery.d.ts +1 -1
- package/dist/client/auth-redirect-url.d.ts +1 -1
- package/dist/client/auth-redirect-url.d.ts.map +1 -1
- package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts +0 -19
- package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/AnnotatedCodeBlock.js +141 -55
- package/dist/client/blocks/library/AnnotatedCodeBlock.js.map +1 -1
- package/dist/client/blocks/library/DiffBlock.js +1 -1
- package/dist/client/blocks/library/DiffBlock.js.map +1 -1
- package/dist/client/blocks/library/FileTreeBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/FileTreeBlock.js +1 -1
- package/dist/client/blocks/library/FileTreeBlock.js.map +1 -1
- package/dist/client/blocks/library/HighlightedCode.d.ts.map +1 -1
- package/dist/client/blocks/library/HighlightedCode.js +5 -3
- package/dist/client/blocks/library/HighlightedCode.js.map +1 -1
- package/dist/client/blocks/library/annotation-rail.d.ts +5 -4
- package/dist/client/blocks/library/annotation-rail.d.ts.map +1 -1
- package/dist/client/blocks/library/annotation-rail.js +22 -3
- package/dist/client/blocks/library/annotation-rail.js.map +1 -1
- package/dist/client/blocks/library/diagram.js +1 -1
- package/dist/client/blocks/library/diagram.js.map +1 -1
- package/dist/client/blocks/library/diff.config.d.ts +3 -2
- package/dist/client/blocks/library/diff.config.d.ts.map +1 -1
- package/dist/client/blocks/library/diff.config.js +4 -3
- package/dist/client/blocks/library/diff.config.js.map +1 -1
- package/dist/client/blocks/library/question-form.d.ts.map +1 -1
- package/dist/client/blocks/library/question-form.js +2 -1
- package/dist/client/blocks/library/question-form.js.map +1 -1
- package/dist/client/blocks/library/wireframe-kit.d.ts +1 -1
- package/dist/client/blocks/library/wireframe-kit.d.ts.map +1 -1
- package/dist/client/blocks/library/wireframe.js +1 -1
- package/dist/client/blocks/library/wireframe.js.map +1 -1
- package/dist/client/chat/attachment-adapters.d.ts +58 -0
- package/dist/client/chat/attachment-adapters.d.ts.map +1 -0
- package/dist/client/chat/attachment-adapters.js +331 -0
- package/dist/client/chat/attachment-adapters.js.map +1 -0
- package/dist/client/chat/index.d.ts +13 -0
- package/dist/client/chat/index.d.ts.map +1 -0
- package/dist/client/chat/index.js +13 -0
- package/dist/client/chat/index.js.map +1 -0
- package/dist/client/chat/markdown-renderer.d.ts +49 -0
- package/dist/client/chat/markdown-renderer.d.ts.map +1 -0
- package/dist/client/chat/markdown-renderer.js +391 -0
- package/dist/client/chat/markdown-renderer.js.map +1 -0
- package/dist/client/chat/message-components.d.ts +35 -0
- package/dist/client/chat/message-components.d.ts.map +1 -0
- package/dist/client/chat/message-components.js +452 -0
- package/dist/client/chat/message-components.js.map +1 -0
- package/dist/client/chat/repo-helpers.d.ts +41 -0
- package/dist/client/chat/repo-helpers.d.ts.map +1 -0
- package/dist/client/chat/repo-helpers.js +61 -0
- package/dist/client/chat/repo-helpers.js.map +1 -0
- package/dist/client/chat/run-recovery.d.ts +41 -0
- package/dist/client/chat/run-recovery.d.ts.map +1 -0
- package/dist/client/chat/run-recovery.js +348 -0
- package/dist/client/chat/run-recovery.js.map +1 -0
- package/dist/client/chat/tool-call-display.d.ts +34 -0
- package/dist/client/chat/tool-call-display.d.ts.map +1 -0
- package/dist/client/chat/tool-call-display.js +284 -0
- package/dist/client/chat/tool-call-display.js.map +1 -0
- package/dist/client/code-agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/code-agent-chat-adapter.js +20 -0
- package/dist/client/code-agent-chat-adapter.js.map +1 -1
- package/dist/client/collab/index.d.ts +10 -0
- package/dist/client/collab/index.d.ts.map +1 -0
- package/dist/client/collab/index.js +10 -0
- package/dist/client/collab/index.js.map +1 -0
- package/dist/client/components/AgentPresenceChip.d.ts +1 -1
- package/dist/client/components/AgentPresenceChip.d.ts.map +1 -1
- package/dist/client/components/ApiKeySettings.d.ts +1 -1
- package/dist/client/components/ApiKeySettings.d.ts.map +1 -1
- package/dist/client/components/CodeAgentIndicator.d.ts +1 -1
- package/dist/client/components/CodeAgentIndicator.d.ts.map +1 -1
- package/dist/client/components/CodeRequiredDialog.d.ts +1 -1
- package/dist/client/components/CodeRequiredDialog.d.ts.map +1 -1
- package/dist/client/components/LiveCursorOverlay.d.ts.map +1 -1
- package/dist/client/components/LiveCursorOverlay.js.map +1 -1
- package/dist/client/components/PresenceBar.d.ts +1 -1
- package/dist/client/components/PresenceBar.d.ts.map +1 -1
- package/dist/client/composer/PromptComposer.d.ts.map +1 -1
- package/dist/client/composer/PromptComposer.js +6 -26
- package/dist/client/composer/PromptComposer.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +8 -2
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +21 -9
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/composer/VoiceButton.d.ts +2 -2
- package/dist/client/composer/VoiceButton.d.ts.map +1 -1
- package/dist/client/composer/index.d.ts +1 -1
- package/dist/client/composer/index.d.ts.map +1 -1
- package/dist/client/composer/index.js +1 -1
- package/dist/client/composer/index.js.map +1 -1
- package/dist/client/composer/use-skills.d.ts +1 -1
- package/dist/client/context-xray/ContextMeter.d.ts +1 -1
- package/dist/client/context-xray/ContextMeter.d.ts.map +1 -1
- package/dist/client/context-xray/ContextMeter.js +3 -3
- package/dist/client/context-xray/ContextMeter.js.map +1 -1
- package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -1
- package/dist/client/context-xray/ContextXRayPanel.js +4 -3
- package/dist/client/context-xray/ContextXRayPanel.js.map +1 -1
- package/dist/client/context-xray/format.d.ts +11 -0
- package/dist/client/context-xray/format.d.ts.map +1 -1
- package/dist/client/context-xray/format.js +16 -0
- package/dist/client/context-xray/format.js.map +1 -1
- package/dist/client/conversation/AgentConversation.d.ts.map +1 -1
- package/dist/client/conversation/AgentConversation.js +8 -53
- package/dist/client/conversation/AgentConversation.js.map +1 -1
- package/dist/client/conversation/use-near-bottom-autoscroll.d.ts +1 -1
- package/dist/client/conversation/use-near-bottom-autoscroll.d.ts.map +1 -1
- package/dist/client/conversation/use-near-bottom-autoscroll.js +14 -1
- package/dist/client/conversation/use-near-bottom-autoscroll.js.map +1 -1
- package/dist/client/create-query-client.d.ts +28 -0
- package/dist/client/create-query-client.d.ts.map +1 -0
- package/dist/client/create-query-client.js +78 -0
- package/dist/client/create-query-client.js.map +1 -0
- package/dist/client/db-admin/DevDatabaseLink.d.ts +1 -1
- package/dist/client/db-admin/DevDatabaseLink.d.ts.map +1 -1
- package/dist/client/db-admin/RowSidePanel.d.ts +1 -1
- package/dist/client/db-admin/RowSidePanel.d.ts.map +1 -1
- package/dist/client/db-admin/RowSidePanel.js +2 -2
- package/dist/client/db-admin/RowSidePanel.js.map +1 -1
- package/dist/client/db-admin/TableEditor.d.ts +1 -1
- package/dist/client/db-admin/TableEditor.d.ts.map +1 -1
- package/dist/client/db-admin/TableEditor.js +1 -1
- package/dist/client/db-admin/TableEditor.js.map +1 -1
- package/dist/client/db-admin/cell-format.d.ts +1 -1
- package/dist/client/db-admin/cell-format.d.ts.map +1 -1
- package/dist/client/dev-overlay/DevOverlay.d.ts +1 -1
- package/dist/client/dev-overlay/DevOverlay.d.ts.map +1 -1
- package/dist/client/editor/index.d.ts +2 -0
- package/dist/client/editor/index.d.ts.map +1 -0
- package/dist/client/editor/index.js +2 -0
- package/dist/client/editor/index.js.map +1 -0
- package/dist/client/error-format.d.ts.map +1 -1
- package/dist/client/error-format.js +4 -0
- package/dist/client/error-format.js.map +1 -1
- package/dist/client/extensions/AgentNativeExtensionFrame.d.ts +1 -1
- package/dist/client/extensions/AgentNativeExtensionFrame.d.ts.map +1 -1
- package/dist/client/extensions/EmbeddedExtension.d.ts +1 -1
- package/dist/client/extensions/EmbeddedExtension.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionSlot.d.ts +1 -1
- package/dist/client/extensions/ExtensionSlot.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionViewerPage.d.ts +1 -1
- package/dist/client/extensions/ExtensionViewerPage.d.ts.map +1 -1
- package/dist/client/guided-questions.d.ts +6 -6
- package/dist/client/host-bridge.d.ts.map +1 -1
- package/dist/client/host-bridge.js +2 -0
- package/dist/client/host-bridge.js.map +1 -1
- package/dist/client/index.d.ts +7 -6
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +5 -3
- package/dist/client/index.js.map +1 -1
- package/dist/client/onboarding/OnboardingBanner.d.ts +1 -1
- package/dist/client/onboarding/OnboardingBanner.d.ts.map +1 -1
- package/dist/client/onboarding/OnboardingPanel.d.ts +1 -1
- package/dist/client/onboarding/OnboardingPanel.d.ts.map +1 -1
- package/dist/client/onboarding/SetupButton.d.ts +1 -1
- package/dist/client/onboarding/SetupButton.d.ts.map +1 -1
- package/dist/client/org/InvitationBanner.d.ts +1 -1
- package/dist/client/org/InvitationBanner.d.ts.map +1 -1
- package/dist/client/org/OrgSwitcher.d.ts +1 -1
- package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
- package/dist/client/org/RequireActiveOrg.d.ts +1 -1
- package/dist/client/org/RequireActiveOrg.d.ts.map +1 -1
- package/dist/client/org/hooks.d.ts +3 -3
- package/dist/client/org/hooks.d.ts.map +1 -1
- package/dist/client/progress/RunsTray.d.ts +2 -2
- package/dist/client/progress/RunsTray.d.ts.map +1 -1
- package/dist/client/progress/RunsTray.js +34 -9
- package/dist/client/progress/RunsTray.js.map +1 -1
- package/dist/client/resources/ResourceEditor.d.ts.map +1 -1
- package/dist/client/resources/ResourceEditor.js +1 -1
- package/dist/client/resources/ResourceEditor.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +2 -0
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts +1 -1
- package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/CodeBlockNode.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/CodeBlockNode.js +2 -1
- package/dist/client/rich-markdown-editor/CodeBlockNode.js.map +1 -1
- package/dist/client/rich-markdown-editor/ImageExtension.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/ImageExtension.js +2 -1
- package/dist/client/rich-markdown-editor/ImageExtension.js.map +1 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.d.ts +1 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js +1 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js.map +1 -1
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts +1 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.js +2 -3
- package/dist/client/rich-markdown-editor/SharedRichEditor.js.map +1 -1
- package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts +1 -1
- package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts.map +1 -1
- package/dist/client/route-state.d.ts +12 -2
- package/dist/client/route-state.d.ts.map +1 -1
- package/dist/client/route-state.js +1 -1
- package/dist/client/route-state.js.map +1 -1
- package/dist/client/route-warmup.d.ts +1 -1
- package/dist/client/route-warmup.d.ts.map +1 -1
- package/dist/client/settings/VoiceTranscriptionSection.js +1 -1
- package/dist/client/settings/VoiceTranscriptionSection.js.map +1 -1
- package/dist/client/settings/useBuilderStatus.d.ts +2 -2
- package/dist/client/sharing/ShareDialog.d.ts +1 -1
- package/dist/client/sharing/ShareDialog.d.ts.map +1 -1
- package/dist/client/sse-event-processor.d.ts +8 -0
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +33 -10
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/client/terminal/AgentTerminal.d.ts +1 -1
- package/dist/client/terminal/AgentTerminal.d.ts.map +1 -1
- package/dist/client/terminal/AgentTerminal.js +4 -2
- package/dist/client/terminal/AgentTerminal.js.map +1 -1
- package/dist/client/tool-cells/BashCell.d.ts +25 -0
- package/dist/client/tool-cells/BashCell.d.ts.map +1 -0
- package/dist/client/tool-cells/BashCell.js +49 -0
- package/dist/client/tool-cells/BashCell.js.map +1 -0
- package/dist/client/tool-cells/EditCell.d.ts +24 -0
- package/dist/client/tool-cells/EditCell.d.ts.map +1 -0
- package/dist/client/tool-cells/EditCell.js +126 -0
- package/dist/client/tool-cells/EditCell.js.map +1 -0
- package/dist/client/tool-cells/FilesChangedSummary.d.ts +13 -0
- package/dist/client/tool-cells/FilesChangedSummary.d.ts.map +1 -0
- package/dist/client/tool-cells/FilesChangedSummary.js +98 -0
- package/dist/client/tool-cells/FilesChangedSummary.js.map +1 -0
- package/dist/client/tool-cells/WriteCell.d.ts +17 -0
- package/dist/client/tool-cells/WriteCell.d.ts.map +1 -0
- package/dist/client/tool-cells/WriteCell.js +26 -0
- package/dist/client/tool-cells/WriteCell.js.map +1 -0
- package/dist/client/tool-cells/index.d.ts +8 -0
- package/dist/client/tool-cells/index.d.ts.map +1 -0
- package/dist/client/tool-cells/index.js +5 -0
- package/dist/client/tool-cells/index.js.map +1 -0
- package/dist/client/transcription/BuilderTranscriptionCta.d.ts +1 -1
- package/dist/client/transcription/BuilderTranscriptionCta.d.ts.map +1 -1
- package/dist/client/use-chat-threads.d.ts +1 -1
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +11 -8
- package/dist/client/use-chat-threads.js.map +1 -1
- package/dist/client/use-db-sync.d.ts +2 -0
- package/dist/client/use-db-sync.d.ts.map +1 -1
- package/dist/client/use-db-sync.js +329 -302
- package/dist/client/use-db-sync.js.map +1 -1
- package/dist/code-agents/transcript-normalizer.d.ts +15 -1
- package/dist/code-agents/transcript-normalizer.d.ts.map +1 -1
- package/dist/code-agents/transcript-normalizer.js +47 -0
- package/dist/code-agents/transcript-normalizer.js.map +1 -1
- package/dist/coding-tools/index.d.ts +75 -0
- package/dist/coding-tools/index.d.ts.map +1 -1
- package/dist/coding-tools/index.js +137 -10
- package/dist/coding-tools/index.js.map +1 -1
- package/dist/coding-tools/run-code.d.ts +40 -0
- package/dist/coding-tools/run-code.d.ts.map +1 -0
- package/dist/coding-tools/run-code.js +511 -0
- package/dist/coding-tools/run-code.js.map +1 -0
- package/dist/collab/client.d.ts.map +1 -1
- package/dist/collab/client.js +15 -9
- package/dist/collab/client.js.map +1 -1
- package/dist/collab/ydoc-manager.d.ts +1 -1
- package/dist/collab/ydoc-manager.d.ts.map +1 -1
- package/dist/collab/ydoc-manager.js +1 -1
- package/dist/collab/ydoc-manager.js.map +1 -1
- package/dist/db/client.d.ts +9 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +204 -48
- package/dist/db/client.js.map +1 -1
- package/dist/db/create-get-db.d.ts +38 -0
- package/dist/db/create-get-db.d.ts.map +1 -1
- package/dist/db/create-get-db.js +204 -4
- package/dist/db/create-get-db.js.map +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +159 -67
- package/dist/db/migrations.js.map +1 -1
- package/dist/demo/actions/toggle-demo-mode.d.ts +6 -1
- package/dist/demo/actions/toggle-demo-mode.d.ts.map +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +80 -39
- package/dist/deploy/build.js.map +1 -1
- package/dist/deploy/workspace-deploy.js +20 -10
- package/dist/deploy/workspace-deploy.js.map +1 -1
- package/dist/extensions/fetch-tool.d.ts.map +1 -1
- package/dist/extensions/fetch-tool.js +62 -7
- package/dist/extensions/fetch-tool.js.map +1 -1
- package/dist/extensions/schema.d.ts +51 -51
- package/dist/extensions/slots/schema.d.ts +13 -13
- package/dist/extensions/web-search-tool.d.ts +41 -0
- package/dist/extensions/web-search-tool.d.ts.map +1 -0
- package/dist/extensions/web-search-tool.js +200 -0
- package/dist/extensions/web-search-tool.js.map +1 -0
- package/dist/file-upload/actions/upload-image.d.ts +26 -1
- package/dist/file-upload/actions/upload-image.d.ts.map +1 -1
- package/dist/file-upload/index.d.ts +1 -1
- package/dist/file-upload/index.d.ts.map +1 -1
- package/dist/file-upload/index.js +1 -1
- package/dist/file-upload/index.js.map +1 -1
- package/dist/file-upload/pre-upload-attachments.d.ts +37 -0
- package/dist/file-upload/pre-upload-attachments.d.ts.map +1 -1
- package/dist/file-upload/pre-upload-attachments.js +79 -19
- package/dist/file-upload/pre-upload-attachments.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/adapters/slack.js +1 -1
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/integrations/plugin.js +1 -1
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/jobs/scheduler.js +70 -21
- package/dist/jobs/scheduler.js.map +1 -1
- package/dist/mcp/actions/create-org-service-token.d.ts +14 -0
- package/dist/mcp/actions/create-org-service-token.d.ts.map +1 -0
- package/dist/mcp/actions/create-org-service-token.js +74 -0
- package/dist/mcp/actions/create-org-service-token.js.map +1 -0
- package/dist/mcp/actions/list-org-service-tokens.d.ts +17 -0
- package/dist/mcp/actions/list-org-service-tokens.d.ts.map +1 -0
- package/dist/mcp/actions/list-org-service-tokens.js +42 -0
- package/dist/mcp/actions/list-org-service-tokens.js.map +1 -0
- package/dist/mcp/actions/revoke-org-service-token.d.ts +7 -0
- package/dist/mcp/actions/revoke-org-service-token.d.ts.map +1 -0
- package/dist/mcp/actions/revoke-org-service-token.js +28 -0
- package/dist/mcp/actions/revoke-org-service-token.js.map +1 -0
- package/dist/mcp/actions/service-token-access.d.ts +24 -0
- package/dist/mcp/actions/service-token-access.d.ts.map +1 -0
- package/dist/mcp/actions/service-token-access.js +63 -0
- package/dist/mcp/actions/service-token-access.js.map +1 -0
- package/dist/mcp/build-server.d.ts +42 -11
- package/dist/mcp/build-server.d.ts.map +1 -1
- package/dist/mcp/build-server.js +53 -3
- package/dist/mcp/build-server.js.map +1 -1
- package/dist/mcp/connect-route.d.ts +35 -0
- package/dist/mcp/connect-route.d.ts.map +1 -1
- package/dist/mcp/connect-route.js +57 -2
- package/dist/mcp/connect-route.js.map +1 -1
- package/dist/mcp/connect-store.d.ts +43 -0
- package/dist/mcp/connect-store.d.ts.map +1 -1
- package/dist/mcp/connect-store.js +129 -12
- package/dist/mcp/connect-store.js.map +1 -1
- package/dist/mcp/oauth-token.d.ts +10 -0
- package/dist/mcp/oauth-token.d.ts.map +1 -1
- package/dist/mcp/oauth-token.js +2 -0
- package/dist/mcp/oauth-token.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +3 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp-client/routes.js +1 -1
- package/dist/mcp-client/routes.js.map +1 -1
- package/dist/org/context.d.ts +4 -0
- package/dist/org/context.d.ts.map +1 -1
- package/dist/org/context.js +10 -0
- package/dist/org/context.js.map +1 -1
- package/dist/org/handlers.d.ts +11 -7
- package/dist/org/handlers.d.ts.map +1 -1
- package/dist/org/handlers.js +0 -8
- package/dist/org/handlers.js.map +1 -1
- package/dist/org/migrations.d.ts.map +1 -1
- package/dist/org/migrations.js +8 -0
- package/dist/org/migrations.js.map +1 -1
- package/dist/org/schema.d.ts +15 -15
- package/dist/progress/actions.d.ts.map +1 -1
- package/dist/progress/actions.js +13 -5
- package/dist/progress/actions.js.map +1 -1
- package/dist/provider-api/actions/delete-staged-dataset.d.ts +9 -0
- package/dist/provider-api/actions/delete-staged-dataset.d.ts.map +1 -0
- package/dist/provider-api/actions/delete-staged-dataset.js +35 -0
- package/dist/provider-api/actions/delete-staged-dataset.js.map +1 -0
- package/dist/provider-api/actions/list-staged-datasets.d.ts +15 -0
- package/dist/provider-api/actions/list-staged-datasets.d.ts.map +1 -0
- package/dist/provider-api/actions/list-staged-datasets.js +41 -0
- package/dist/provider-api/actions/list-staged-datasets.js.map +1 -0
- package/dist/provider-api/actions/query-staged-dataset.d.ts +29 -0
- package/dist/provider-api/actions/query-staged-dataset.d.ts.map +1 -0
- package/dist/provider-api/actions/query-staged-dataset.js +116 -0
- package/dist/provider-api/actions/query-staged-dataset.js.map +1 -0
- package/dist/provider-api/custom-registry.d.ts +92 -0
- package/dist/provider-api/custom-registry.d.ts.map +1 -0
- package/dist/provider-api/custom-registry.js +289 -0
- package/dist/provider-api/custom-registry.js.map +1 -0
- package/dist/provider-api/index.d.ts +88 -52
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +569 -23
- package/dist/provider-api/index.js.map +1 -1
- package/dist/provider-api/staged-datasets-aggregate.d.ts +46 -0
- package/dist/provider-api/staged-datasets-aggregate.d.ts.map +1 -0
- package/dist/provider-api/staged-datasets-aggregate.js +209 -0
- package/dist/provider-api/staged-datasets-aggregate.js.map +1 -0
- package/dist/provider-api/staged-datasets-store.d.ts +76 -0
- package/dist/provider-api/staged-datasets-store.d.ts.map +1 -0
- package/dist/provider-api/staged-datasets-store.js +319 -0
- package/dist/provider-api/staged-datasets-store.js.map +1 -0
- package/dist/provider-api/staging.d.ts +100 -0
- package/dist/provider-api/staging.d.ts.map +1 -0
- package/dist/provider-api/staging.js +281 -0
- package/dist/provider-api/staging.js.map +1 -0
- package/dist/resources/handlers.d.ts.map +1 -1
- package/dist/resources/handlers.js +13 -1
- package/dist/resources/handlers.js.map +1 -1
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +1 -2
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/scripts/resources/migrate-learnings.d.ts +1 -1
- package/dist/scripts/resources/migrate-learnings.d.ts.map +1 -1
- package/dist/scripts/resources/migrate-learnings.js +1 -1
- package/dist/scripts/resources/migrate-learnings.js.map +1 -1
- package/dist/secrets/register-framework-secrets.d.ts.map +1 -1
- package/dist/secrets/register-framework-secrets.js +36 -3
- package/dist/secrets/register-framework-secrets.js.map +1 -1
- package/dist/secrets/schema.d.ts +7 -7
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +14 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/action-routes.d.ts.map +1 -1
- package/dist/server/action-routes.js +3 -2
- package/dist/server/action-routes.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +69 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +369 -179
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-discovery.d.ts.map +1 -1
- package/dist/server/agent-discovery.js +13 -16
- package/dist/server/agent-discovery.js.map +1 -1
- package/dist/server/agent-teams-run-queue.d.ts +31 -8
- package/dist/server/agent-teams-run-queue.d.ts.map +1 -1
- package/dist/server/agent-teams-run-queue.js +61 -18
- package/dist/server/agent-teams-run-queue.js.map +1 -1
- package/dist/server/agent-teams.d.ts +27 -1
- package/dist/server/agent-teams.d.ts.map +1 -1
- package/dist/server/agent-teams.js +214 -14
- package/dist/server/agent-teams.js.map +1 -1
- package/dist/server/app-base-path.d.ts +20 -0
- package/dist/server/app-base-path.d.ts.map +1 -1
- package/dist/server/app-base-path.js +36 -0
- package/dist/server/app-base-path.js.map +1 -1
- package/dist/server/attachment-actions.d.ts +43 -0
- package/dist/server/attachment-actions.d.ts.map +1 -0
- package/dist/server/attachment-actions.js +214 -0
- package/dist/server/attachment-actions.js.map +1 -0
- package/dist/server/auth.js +1 -1
- package/dist/server/auth.js.map +1 -1
- package/dist/server/complete-text.d.ts +56 -0
- package/dist/server/complete-text.d.ts.map +1 -0
- package/dist/server/complete-text.js +147 -0
- package/dist/server/complete-text.js.map +1 -0
- package/dist/server/core-routes-plugin.d.ts +1 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +37 -27
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/cors-origins.d.ts.map +1 -1
- package/dist/server/cors-origins.js +6 -1
- package/dist/server/cors-origins.js.map +1 -1
- package/dist/server/create-server.d.ts.map +1 -1
- package/dist/server/create-server.js +2 -1
- package/dist/server/create-server.js.map +1 -1
- package/dist/server/csrf.d.ts +1 -1
- package/dist/server/csrf.d.ts.map +1 -1
- package/dist/server/email-actions.d.ts +19 -0
- package/dist/server/email-actions.d.ts.map +1 -0
- package/dist/server/email-actions.js +191 -0
- package/dist/server/email-actions.js.map +1 -0
- package/dist/server/embed-route.js +1 -1
- package/dist/server/embed-route.js.map +1 -1
- package/dist/server/embed-session.d.ts.map +1 -1
- package/dist/server/embed-session.js +5 -1
- package/dist/server/embed-session.js.map +1 -1
- package/dist/server/entry-server.d.ts +24 -0
- package/dist/server/entry-server.d.ts.map +1 -0
- package/dist/server/entry-server.js +54 -0
- package/dist/server/entry-server.js.map +1 -0
- package/dist/server/framework-request-handler.d.ts.map +1 -1
- package/dist/server/framework-request-handler.js +2 -10
- package/dist/server/framework-request-handler.js.map +1 -1
- package/dist/server/google-oauth.d.ts.map +1 -1
- package/dist/server/google-oauth.js +2 -9
- package/dist/server/google-oauth.js.map +1 -1
- package/dist/server/google-realtime-session.d.ts.map +1 -1
- package/dist/server/google-realtime-session.js +6 -4
- package/dist/server/google-realtime-session.js.map +1 -1
- package/dist/server/h3-helpers.d.ts +39 -0
- package/dist/server/h3-helpers.d.ts.map +1 -1
- package/dist/server/h3-helpers.js +104 -1
- package/dist/server/h3-helpers.js.map +1 -1
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +1 -8
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/server/open-route.d.ts.map +1 -1
- package/dist/server/open-route.js +1 -0
- package/dist/server/open-route.js.map +1 -1
- package/dist/server/prompts/framework-core-compact.d.ts +19 -0
- package/dist/server/prompts/framework-core-compact.d.ts.map +1 -0
- package/dist/server/prompts/framework-core-compact.js +69 -0
- package/dist/server/prompts/framework-core-compact.js.map +1 -0
- package/dist/server/prompts/framework-core.d.ts +26 -0
- package/dist/server/prompts/framework-core.d.ts.map +1 -0
- package/dist/server/prompts/framework-core.js +130 -0
- package/dist/server/prompts/framework-core.js.map +1 -0
- package/dist/server/prompts/index.d.ts +9 -0
- package/dist/server/prompts/index.d.ts.map +1 -0
- package/dist/server/prompts/index.js +9 -0
- package/dist/server/prompts/index.js.map +1 -0
- package/dist/server/prompts/model-overlays.d.ts +18 -0
- package/dist/server/prompts/model-overlays.d.ts.map +1 -0
- package/dist/server/prompts/model-overlays.js +46 -0
- package/dist/server/prompts/model-overlays.js.map +1 -0
- package/dist/server/prompts/shared-rules.d.ts +29 -0
- package/dist/server/prompts/shared-rules.d.ts.map +1 -0
- package/dist/server/prompts/shared-rules.js +54 -0
- package/dist/server/prompts/shared-rules.js.map +1 -0
- package/dist/server/security-headers.d.ts +7 -1
- package/dist/server/security-headers.d.ts.map +1 -1
- package/dist/server/security-headers.js +11 -0
- package/dist/server/security-headers.js.map +1 -1
- package/dist/server/ssr-handler.d.ts.map +1 -1
- package/dist/server/ssr-handler.js +135 -46
- package/dist/server/ssr-handler.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts.map +1 -1
- package/dist/server/transcribe-voice.js +7 -4
- package/dist/server/transcribe-voice.js.map +1 -1
- package/dist/settings/store.d.ts.map +1 -1
- package/dist/settings/store.js +9 -0
- package/dist/settings/store.js.map +1 -1
- package/dist/shared/markdown-block-split.d.ts +39 -0
- package/dist/shared/markdown-block-split.d.ts.map +1 -0
- package/dist/shared/markdown-block-split.js +97 -0
- package/dist/shared/markdown-block-split.js.map +1 -0
- package/dist/shared/reasoning-effort.js +13 -1
- package/dist/shared/reasoning-effort.js.map +1 -1
- package/dist/shared/streaming-text-smoothing.d.ts +18 -0
- package/dist/shared/streaming-text-smoothing.d.ts.map +1 -1
- package/dist/shared/streaming-text-smoothing.js +70 -4
- package/dist/shared/streaming-text-smoothing.js.map +1 -1
- package/dist/sharing/actions/list-resource-shares.d.ts +24 -1
- package/dist/sharing/actions/list-resource-shares.d.ts.map +1 -1
- package/dist/sharing/actions/set-resource-visibility.d.ts +8 -1
- package/dist/sharing/actions/set-resource-visibility.d.ts.map +1 -1
- package/dist/sharing/actions/share-resource.d.ts +12 -1
- package/dist/sharing/actions/share-resource.d.ts.map +1 -1
- package/dist/sharing/actions/unshare-resource.d.ts +8 -1
- package/dist/sharing/actions/unshare-resource.d.ts.map +1 -1
- package/dist/sharing/schema.d.ts +10 -10
- package/dist/styles/agent-conversation.css +239 -0
- package/dist/templates/default/.agents/skills/delegate-to-agent/SKILL.md +50 -2
- package/dist/templates/default/AGENTS.md +1 -1
- package/dist/templates/default/DEVELOPING.md +19 -0
- package/dist/templates/default/app/entry.client.tsx +4 -1
- package/dist/templates/default/app/entry.server.tsx +4 -56
- package/dist/templates/default/app/global.css +3 -2
- package/dist/templates/default/app/root.tsx +8 -24
- package/dist/templates/default/app/routes/_index.tsx +0 -13
- package/dist/templates/default/package.json +6 -5
- package/dist/templates/default/tsconfig.json +2 -1
- package/dist/templates/starter-shell-sync.spec.ts +118 -0
- package/dist/templates/ui-primitives-sync.spec.ts +399 -0
- package/dist/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +50 -2
- package/dist/terminal/pty-server.js +1 -1
- package/dist/terminal/pty-server.js.map +1 -1
- package/dist/triggers/dispatcher.js +1 -1
- package/dist/triggers/dispatcher.js.map +1 -1
- package/dist/usage/store.d.ts.map +1 -1
- package/dist/usage/store.js +60 -7
- package/dist/usage/store.js.map +1 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +44 -12
- package/dist/vite/client.js.map +1 -1
- package/dist/workspace-files/index.d.ts +4 -0
- package/dist/workspace-files/index.d.ts.map +1 -0
- package/dist/workspace-files/index.js +4 -0
- package/dist/workspace-files/index.js.map +1 -0
- package/dist/workspace-files/schema.d.ts +195 -0
- package/dist/workspace-files/schema.d.ts.map +1 -0
- package/dist/workspace-files/schema.js +48 -0
- package/dist/workspace-files/schema.js.map +1 -0
- package/dist/workspace-files/store.d.ts +89 -0
- package/dist/workspace-files/store.d.ts.map +1 -0
- package/dist/workspace-files/store.js +298 -0
- package/dist/workspace-files/store.js.map +1 -0
- package/dist/workspace-files/tool.d.ts +15 -0
- package/dist/workspace-files/tool.d.ts.map +1 -0
- package/dist/workspace-files/tool.js +225 -0
- package/dist/workspace-files/tool.js.map +1 -0
- package/docs/content/a2a-protocol.md +18 -12
- package/docs/content/actions.md +42 -10
- package/docs/content/agent-mentions.md +7 -8
- package/docs/content/agent-teams.md +23 -37
- package/docs/content/agent-web-surfaces.md +18 -9
- package/docs/content/authentication.md +6 -17
- package/docs/content/automations.md +43 -15
- package/docs/content/cli-adapters.md +25 -24
- package/docs/content/client.md +66 -17
- package/docs/content/cloneable-saas.md +19 -23
- package/docs/content/code-agents-ui.md +3 -31
- package/docs/content/components.md +308 -0
- package/docs/content/context-awareness.md +4 -0
- package/docs/content/creating-templates.md +4 -2
- package/docs/content/cross-app-sso.md +45 -19
- package/docs/content/database.md +26 -1
- package/docs/content/deployment.md +3 -1
- package/docs/content/dispatch.md +9 -37
- package/docs/content/drop-in-agent.md +123 -2
- package/docs/content/embedding-sdk.md +35 -0
- package/docs/content/extensions.md +2 -2
- package/docs/content/external-agents.md +86 -171
- package/docs/content/faq.md +6 -27
- package/docs/content/frames.md +9 -12
- package/docs/content/getting-started.md +80 -77
- package/docs/content/key-concepts.md +29 -19
- package/docs/content/mcp-apps.md +103 -0
- package/docs/content/mcp-clients.md +2 -2
- package/docs/content/mcp-protocol.md +40 -17
- package/docs/content/messaging.md +11 -4
- package/docs/content/migration-workbench.md +4 -47
- package/docs/content/multi-app-workspace.md +48 -17
- package/docs/content/multi-tenancy.md +1 -1
- package/docs/content/notifications.md +8 -6
- package/docs/content/observability.md +26 -15
- package/docs/content/onboarding.md +7 -1
- package/docs/content/pr-visual-recap.md +203 -23
- package/docs/content/progress.md +5 -5
- package/docs/content/pure-agent-apps.md +3 -1
- package/docs/content/real-time-collaboration.md +106 -0
- package/docs/content/recurring-jobs.md +17 -1
- package/docs/content/security.md +17 -3
- package/docs/content/server.md +39 -3
- package/docs/content/sharing.md +20 -1
- package/docs/content/skills-guide.md +151 -125
- package/docs/content/template-analytics.md +8 -0
- package/docs/content/template-assets.md +2 -0
- package/docs/content/template-brain.md +59 -3
- package/docs/content/template-calendar.md +8 -0
- package/docs/content/template-clips.md +11 -2
- package/docs/content/template-content.md +24 -4
- package/docs/content/template-design.md +19 -17
- package/docs/content/template-dispatch.md +2 -0
- package/docs/content/template-forms.md +28 -1
- package/docs/content/template-mail.md +17 -0
- package/docs/content/template-plan.md +177 -10
- package/docs/content/template-slides.md +51 -12
- package/docs/content/template-videos.md +17 -0
- package/docs/content/tracking.md +17 -13
- package/docs/content/using-your-agent.md +15 -5
- package/docs/content/voice-input.md +1 -1
- package/docs/content/what-is-agent-native.md +5 -6
- package/docs/content/workspace-connections.md +138 -424
- package/docs/content/workspace-management.md +12 -128
- package/docs/content/workspace.md +125 -199
- package/docs/content/writing-agent-instructions.md +17 -1
- package/package.json +26 -6
- package/src/templates/default/.agents/skills/delegate-to-agent/SKILL.md +50 -2
- package/src/templates/default/AGENTS.md +1 -1
- package/src/templates/default/DEVELOPING.md +19 -0
- package/src/templates/default/app/entry.client.tsx +4 -1
- package/src/templates/default/app/entry.server.tsx +4 -56
- package/src/templates/default/app/global.css +3 -2
- package/src/templates/default/app/root.tsx +8 -24
- package/src/templates/default/app/routes/_index.tsx +0 -13
- package/src/templates/default/package.json +6 -5
- package/src/templates/default/tsconfig.json +2 -1
- package/src/templates/starter-shell-sync.spec.ts +118 -0
- package/src/templates/ui-primitives-sync.spec.ts +399 -0
- package/src/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +50 -2
- package/tsconfig.base.json +2 -10
- package/dist/cli/app-skill.d.ts +0 -157
- package/dist/cli/app-skill.d.ts.map +0 -1
- package/dist/cli/audit-agent-web.d.ts +0 -2
- package/dist/cli/audit-agent-web.d.ts.map +0 -1
- package/dist/cli/code-agent-connector.d.ts +0 -17
- package/dist/cli/code-agent-connector.d.ts.map +0 -1
- package/dist/cli/code.d.ts +0 -66
- package/dist/cli/code.d.ts.map +0 -1
- package/dist/cli/connect.d.ts +0 -140
- package/dist/cli/connect.d.ts.map +0 -1
- package/dist/cli/context-xray-local.d.ts +0 -16
- package/dist/cli/context-xray-local.d.ts.map +0 -1
- package/dist/cli/create-workspace.d.ts +0 -8
- package/dist/cli/create-workspace.d.ts.map +0 -1
- package/dist/cli/index.d.ts +0 -3
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/info.d.ts +0 -2
- package/dist/cli/info.d.ts.map +0 -1
- package/dist/cli/mcp-config-writers.d.ts +0 -82
- package/dist/cli/mcp-config-writers.d.ts.map +0 -1
- package/dist/cli/mcp.d.ts +0 -16
- package/dist/cli/mcp.d.ts.map +0 -1
- package/dist/cli/migrate.d.ts +0 -38
- package/dist/cli/migrate.d.ts.map +0 -1
- package/dist/cli/plan-local.d.ts +0 -43
- package/dist/cli/plan-local.d.ts.map +0 -1
- package/dist/cli/plan-publish-store.d.ts +0 -62
- package/dist/cli/plan-publish-store.d.ts.map +0 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts +0 -11
- package/dist/cli/pr-visual-recap-workflow.d.ts.map +0 -1
- package/dist/cli/recap.d.ts +0 -297
- package/dist/cli/recap.d.ts.map +0 -1
- package/dist/cli/skills.d.ts +0 -162
- package/dist/cli/skills.d.ts.map +0 -1
- package/dist/cli/workspace-dev.d.ts +0 -96
- package/dist/cli/workspace-dev.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wireframe-kit.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/wireframe-kit.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;GAaG;AAMH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC;AAkBjD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAS7D;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAqBD,wBAAgB,iBAAiB,IAAI,cAAc,CAMlD;AAED,8EAA8E;AAC9E,wBAAgB,SAAS,IAAI,OAAO,CAYnC;AAMD;;;GAGG;AACH,eAAO,MAAM,gBAAgB;eAChB,OAAO;aACT,MAAM;YACP,OAAO,GAAG,MAAM;YAChB,SAAS,GAAG,OAAO;EACvB,CAAC;AAEP,QAAA,MAAM,CAAC;;;;;;;;;;;;;;;;;;;CAmBG,CAAC;AAEX,KAAK,UAAU,GAAG;IAAE,EAAE,EAAE,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,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,kDAyGA"}
|
|
@@ -128,7 +128,7 @@ function ArtboardFrame({ surface, compact, canvasSize, canvasWidth, skeleton, re
|
|
|
128
128
|
/* -------------------------------------------------------------------------- */
|
|
129
129
|
/* HTML artboard — author HTML, themed + roughened by the renderer. */
|
|
130
130
|
/* -------------------------------------------------------------------------- */
|
|
131
|
-
function HtmlArtboard({ data, ctx, compact, }) {
|
|
131
|
+
function HtmlArtboard({ data, ctx: _ctx, compact, }) {
|
|
132
132
|
const renderMode = data.renderMode ?? "wireframe";
|
|
133
133
|
// Sanitize author HTML/CSS at the render point (defense-in-depth against stored
|
|
134
134
|
// XSS). Self-contained in core via the shared block sanitizer (DOM-based in the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wireframe.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/wireframe.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,EACL,eAAe,EACf,YAAY,GAGb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,MAAM,EACN,WAAW,EACX,SAAS,EACT,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,GACf,MAAM,oBAAoB,CAAC;AA+C5B,MAAM,eAAe,GAA4C;IAC/D,6EAA6E;IAC7E,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE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MAAM,UAAU,eAAe,CAAC,EAAE,IAAI,EAAE,GAAG,EAAiC;IAC1E,OAAO,KAAC,oBAAoB,IAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;AACxD,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAgB;IACvD,IAAI,EAAE,WAAW;IACjB,MAAM,EAAE,eAAe;IACvB,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,eAAe;IACrB,SAAS,EAAE,CAAC,OAAO,CAAC;IACpB,WAAW,EAAE,QAAQ;IACrB,KAAK,EAAE,WAAW;IAClB,WAAW,EACT,4JAA4J;IAC9J,8EAA8E;IAC9E,2EAA2E;IAC3E,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;CAClD,CAAC,CAAC","sourcesContent":["import {\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { defineBlock } from \"../types.js\";\nimport type {\n BlockReadProps,\n BlockEditProps,\n BlockRenderContext,\n} from \"../types.js\";\nimport {\n wireframeSchema,\n wireframeMdx,\n type WireframeData,\n type WireframeSurface,\n} from \"./wireframe.config.js\";\nimport {\n HTML_ROUGH_SELECTOR,\n KitConfigContext,\n RoughOverlay,\n Screen,\n renderNodes,\n useIsDark,\n useWireframeStyle,\n} from \"./wireframe-kit.js\";\nimport {\n sanitizeWireframeCss,\n sanitizeWireframeHtml,\n scopeDesignCss,\n} from \"./sanitize-html.js\";\n\n/**\n * Shared `wireframe` block — a hand-drawn low-fi mockup of one screen, rendered\n * from either a declarative kit tree (`data.screen`) or a self-contained HTML\n * mockup (`data.html`), inside a surface-locked frame (desktop/mobile/popover/\n * panel/browser) with a rough.js sketch overlay. Lives in core so any app can\n * register it (it originated in the plan template).\n *\n * DECOUPLING from the plan original:\n * - Theme: `useIsDark()` reads `document.documentElement.classList` instead of\n * `next-themes` (the MermaidBlock precedent), so core stays dependency-light.\n * - HTML sanitize: the HTML path runs `data.html`/`data.css` through the\n * app-injected `ctx.sanitizeHtml`. If no sanitizer is wired the HTML path is\n * skipped (kit tree or an empty frame renders) — core never injects unsanitized\n * author HTML.\n * - The plan-only prototype runtime, design-element selection, and legacy region\n * fallback are intentionally NOT ported; those are plan-canvas features, not\n * part of the document-block render. The kit element vocabulary, the `--wf-*`\n * token contract, and the `.plan-wf` / `[data-rough]` classes the overlay\n * measures are preserved exactly.\n *\n * The section carries the app-neutral `an-block` class plus the legacy\n * `plan-block` class so plan renders byte-identically while any other app gets\n * the theme-token treatment from core's `blocks.css`.\n *\n * The wireframe is canvas / agent-patch edited (node-addressable content patches\n * applied server-side), NOT schema-form edited in the browser — so `Edit` reuses\n * the same static render as `Read`, mirroring the plan `WireframeEditor`.\n */\n\ntype SurfacePreset = {\n width: number;\n /**\n * Floor height for the surface. The frame is AUTO-HEIGHT (content-driven): it\n * grows past this when content is tall and shrinks toward its content height\n * when content is short, but never collapses below this floor — so an empty or\n * near-empty frame still reads as that surface instead of a thin sliver. This\n * is a `min-height`, not a fixed `height`: it is the lower bound the old fixed\n * preset height used to also be the UPPER bound, which is what left a big empty\n * vertical band below short content (e.g. a header + one dropdown padded to a\n * tall fixed aspect).\n */\n minHeight: number;\n radius: number;\n};\n\nconst SURFACE_PRESETS: Record<WireframeSurface, SurfacePreset> = {\n // mobile keeps a tall floor: a phone frame reads as a phone even when short.\n mobile: { width: 300, minHeight: 360, radius: 30 },\n desktop: { width: 840, minHeight: 200, radius: 14 },\n browser: { width: 900, minHeight: 200, radius: 14 },\n popover: { width: 360, minHeight: 120, radius: 16 },\n panel: { width: 420, minHeight: 200, radius: 16 },\n};\n\nfunction isHtmlData(data: WireframeData): boolean {\n return typeof data.html === \"string\" && data.html.trim().length > 0;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Shared frame shell: surface-locked WIDTH + auto (content-driven) height + */\n/* theme + rough overlay. The frame keeps each surface's footprint and chrome */\n/* but fits its content height instead of padding to a fixed aspect, so short */\n/* content yields a short frame and tall content grows. Pass `canvasSize` to */\n/* opt a fixed-aspect canvas artboard back into a hard pixel height. */\n/* -------------------------------------------------------------------------- */\n\nfunction ArtboardFrame({\n surface,\n compact,\n canvasSize,\n canvasWidth,\n skeleton,\n renderMode,\n roughOverlay = true,\n selector,\n caption,\n render,\n}: {\n surface: WireframeSurface;\n compact?: boolean;\n /**\n * Force a FIXED pixel height instead of the auto-height (content-driven)\n * default. Reserved for fixed-aspect canvas artboards (pan/zoom). Document-flow\n * wireframes — what recaps render — leave this unset so the frame fits content.\n */\n canvasSize?: number;\n canvasWidth?: number;\n skeleton?: boolean;\n renderMode?: \"wireframe\" | \"design\";\n roughOverlay?: boolean;\n selector: string;\n caption?: string;\n render: (ctx: {\n theme: \"light\" | \"dark\";\n style: \"sketchy\" | \"clean\";\n }) => ReactNode;\n}) {\n const ref = useRef<HTMLDivElement>(null);\n const fitRef = useRef<HTMLDivElement>(null);\n const isDark = useIsDark();\n const theme: \"light\" | \"dark\" = isDark ? \"dark\" : \"light\";\n const style = useWireframeStyle();\n const preset = SURFACE_PRESETS[surface] ?? SURFACE_PRESETS.desktop;\n const width = canvasWidth ?? preset.width;\n // AUTO-HEIGHT: with no explicit `canvasSize` the artboard height is driven by\n // its content (`height: auto`), floored at the surface's `minHeight` so a short\n // screen produces a short frame and a tall screen grows — instead of every\n // surface being padded to a fixed preset height that left a big empty band\n // below short content. A `canvasSize` (fixed-aspect canvas artboard) overrides\n // this with a hard pixel height.\n const fixedHeight = canvasSize;\n const minHeight = fixedHeight ?? preset.minHeight;\n const baseScale = compact ? Math.min(1, 320 / preset.width) : 1;\n const maxFrameWidth = compact ? preset.width * baseScale : width;\n const [fitScale, setFitScale] = useState(baseScale);\n // The scaled artboard is `transform: scale()`-ed, which does not change its\n // layout box, so the wrapper that reserves vertical space must track the\n // artboard's ACTUAL rendered height. With a fixed height that's known up front;\n // with auto-height we measure it.\n const [measuredHeight, setMeasuredHeight] = useState<number | null>(\n fixedHeight ?? null,\n );\n const designMode = renderMode === \"design\";\n const sketchy = !designMode && style === \"sketchy\" && !skeleton;\n const roughEnabled = sketchy && roughOverlay;\n const paper = designMode\n ? \"hsl(var(--background))\"\n : \"var(--plan-document, hsl(var(--background)))\";\n const frameBorder = skeleton\n ? \"var(--plan-placeholder-line, var(--plan-line, hsl(var(--border))))\"\n : \"var(--plan-line, hsl(var(--border)))\";\n\n useEffect(() => {\n const element = fitRef.current;\n if (!element) return;\n const measure = () => {\n const availableWidth = element.clientWidth;\n const nextScale =\n availableWidth > 0\n ? Math.min(baseScale, availableWidth / width)\n : baseScale;\n setFitScale((current) =>\n Math.abs(current - nextScale) < 0.001 ? current : nextScale,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, [baseScale, width]);\n\n // Track the auto-height artboard's rendered height so the (un-transformed)\n // wrapper reserves exactly the scaled space the frame occupies. Skipped when a\n // fixed height is supplied — there's nothing to measure.\n useEffect(() => {\n if (fixedHeight != null) return;\n const element = ref.current;\n if (!element) return;\n const measure = () => {\n const next = element.offsetHeight;\n setMeasuredHeight((current) =>\n current != null && Math.abs(current - next) < 0.5 ? current : next,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, [fixedHeight]);\n\n // Height the wrapper reserves: the measured (or fixed) artboard height scaled\n // by the fit factor. Falls back to the surface floor before the first measure\n // so SSR / first paint reserves a sensible box rather than collapsing.\n const reservedHeight = (measuredHeight ?? minHeight) * fitScale;\n\n return (\n <div\n ref={fitRef}\n className=\"plan-kit-wireframe\"\n style={{\n width: \"100%\",\n maxWidth: maxFrameWidth,\n }}\n >\n <div\n style={{\n width: \"100%\",\n maxWidth: maxFrameWidth,\n height: reservedHeight,\n marginInline: \"auto\",\n }}\n >\n <div\n ref={ref}\n className=\"plan-kit-artboard relative\"\n style={{\n width,\n // Auto-height by default (content-driven, floored at `minHeight`);\n // a fixed `canvasSize` locks the height for canvas artboards.\n ...(fixedHeight != null ? { height: fixedHeight } : { minHeight }),\n borderRadius: preset.radius,\n background: paper,\n boxShadow: \"0 10px 34px hsl(var(--foreground) / 0.10)\",\n ...(fitScale !== 1\n ? {\n transform: `scale(${fitScale})`,\n transformOrigin: \"top left\",\n }\n : {}),\n }}\n >\n {/* Content drives the artboard height in flow when auto-height; for a\n fixed height it's pinned to the box. Rounded corners clip overflow\n either way. */}\n <div\n className=\"overflow-hidden\"\n style={{\n borderRadius: preset.radius,\n ...(fixedHeight != null\n ? { position: \"absolute\", inset: 0 }\n : { minHeight }),\n }}\n >\n {render({ theme, style })}\n </div>\n {!roughEnabled && (\n <div\n className=\"pointer-events-none absolute inset-0\"\n style={{\n borderRadius: preset.radius,\n border: `1.5px solid ${frameBorder}`,\n }}\n />\n )}\n <RoughOverlay\n scopeRef={ref}\n enabled={roughEnabled}\n frameRadius={preset.radius}\n selector={selector}\n />\n </div>\n </div>\n {caption && (\n <p className=\"mt-2 text-center text-xs text-plan-muted\">{caption}</p>\n )}\n </div>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* HTML artboard — author HTML, themed + roughened by the renderer. */\n/* -------------------------------------------------------------------------- */\n\nfunction HtmlArtboard({\n data,\n ctx,\n compact,\n}: {\n data: WireframeData;\n ctx: BlockRenderContext;\n compact?: boolean;\n}) {\n const renderMode = data.renderMode ?? \"wireframe\";\n // Sanitize author HTML/CSS at the render point (defense-in-depth against stored\n // XSS). Self-contained in core via the shared block sanitizer (DOM-based in the\n // browser, regex fallback on the server) so the HTML mockup path renders in any\n // app without the host wiring a sanitizer hook.\n const safeHtml = useMemo(() => sanitizeWireframeHtml(data.html), [data.html]);\n const scopeId = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n const scopedCss = useMemo(() => {\n const safeCss = sanitizeWireframeCss(data.css);\n // Scope every author selector under this instance's artboard so global\n // selectors (body, *, .app-shell, :root) can't restyle/hide the host app.\n return safeCss\n ? scopeDesignCss(safeCss, `[data-plan-design-scope=\"${scopeId}\"]`)\n : \"\";\n }, [data.css, scopeId]);\n\n return (\n <ArtboardFrame\n surface={data.surface}\n compact={compact}\n skeleton={data.skeleton}\n renderMode={renderMode}\n selector={HTML_ROUGH_SELECTOR}\n caption={data.caption}\n render={({ theme, style }) => (\n <div\n className=\"plan-html-frame\"\n data-theme={theme}\n data-style={style}\n data-render-mode={renderMode}\n data-plan-design-scope={scopeId}\n data-skeleton={data.skeleton ? \"true\" : undefined}\n >\n {scopedCss && <style>{scopedCss}</style>}\n <div\n className=\"plan-html-frame-content\"\n dangerouslySetInnerHTML={{ __html: safeHtml }}\n />\n </div>\n )}\n />\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Kit artboard — declarative kit tree. */\n/* -------------------------------------------------------------------------- */\n\nfunction KitArtboard({\n data,\n compact,\n}: {\n data: WireframeData;\n compact?: boolean;\n}) {\n return (\n <ArtboardFrame\n surface={data.surface}\n compact={compact}\n skeleton={data.skeleton}\n selector=\"[data-rough]\"\n caption={data.caption}\n render={({ theme, style }) => (\n <KitConfigContext.Provider\n value={{ skeleton: data.skeleton, theme, style }}\n >\n {renderKitScreen(data.screen ?? [])}\n </KitConfigContext.Provider>\n )}\n />\n );\n}\n\nfunction renderKitScreen(\n nodes: NonNullable<WireframeData[\"screen\"]>,\n): ReactNode {\n if (nodes.length === 1 && nodes[0]?.el === \"screen\") {\n return renderNodes(nodes);\n }\n // `minHeight` (not `height`) so the screen fills the auto-height artboard floor\n // but grows past it when content is tall, instead of locking to a fixed box.\n return (\n <Screen pad=\"calc(var(--pad) * 1.35)\" style={{ minHeight: \"100%\" }}>\n {renderNodes(nodes)}\n </Screen>\n );\n}\n\n/**\n * The bare wireframe surface (no block section / title). Routes to the HTML\n * mockup when `data.html` is present and a sanitizer is wired; otherwise renders\n * the kit tree.\n */\nfunction WireframeSurfaceView({\n data,\n ctx,\n compact,\n}: {\n data: WireframeData;\n ctx: BlockRenderContext;\n compact?: boolean;\n}) {\n if (isHtmlData(data)) {\n return <HtmlArtboard data={data} ctx={ctx} compact={compact} />;\n }\n return <KitArtboard data={data} compact={compact} />;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Block Read / Edit */\n/* -------------------------------------------------------------------------- */\n\n/** Read-only renderer for a `wireframe` block. */\nexport function WireframeBlock({\n data,\n blockId,\n title,\n summary,\n ctx,\n}: BlockReadProps<WireframeData>) {\n return (\n <section\n className=\"an-block plan-block an-wireframe\"\n data-block-id={blockId}\n >\n {title && <div className=\"an-block-label plan-block-label\">{title}</div>}\n <WireframeSurfaceView data={data} ctx={ctx} />\n {summary && <p className=\"mt-5 text-plan-muted\">{summary}</p>}\n </section>\n );\n}\n\n/**\n * Editor for the `wireframe` block. The wireframe is canvas / agent-patch edited\n * (it never calls `onChange`), so edit mode reuses the read surface — mirroring\n * the plan `WireframeEditor`. The host document editor already wraps the registry\n * edit path in a titled section, so this renders only the surface to avoid\n * double-nesting.\n */\nexport function WireframeEditor({ data, ctx }: BlockEditProps<WireframeData>) {\n return <WireframeSurfaceView data={data} ctx={ctx} />;\n}\n\n/** Full client spec for the shared `wireframe` block (schema + MDX + Read/Edit). */\nexport const wireframeBlock = defineBlock<WireframeData>({\n type: \"wireframe\",\n schema: wireframeSchema,\n mdx: wireframeMdx,\n Read: WireframeBlock,\n Edit: WireframeEditor,\n placement: [\"block\"],\n editSurface: \"inline\",\n label: \"Wireframe\",\n description:\n \"A sketch wireframe of one screen built from kit primitives (or an HTML mockup), rendered in a chosen surface frame (desktop/mobile/popover/panel/browser).\",\n // `surface` is the only required field; `screen` defaults to []. Start on the\n // desktop surface with an empty screen so the canvas/agent can fill it in.\n empty: () => ({ surface: \"desktop\", screen: [] }),\n});\n"]}
|
|
1
|
+
{"version":3,"file":"wireframe.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/wireframe.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,SA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EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAI,CAAC;AACvD,CAAC;AAED,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,kDAAkD;AAClD,MAAM,UAAU,cAAc,CAAC,EAC7B,IAAI,EACJ,OAAO,EACP,KAAK,EACL,OAAO,EACP,GAAG,GAC2B;IAC9B,OAAO,CACL,mBACE,SAAS,EAAC,kCAAkC,mBAC7B,OAAO,aAErB,KAAK,IAAI,cAAK,SAAS,EAAC,iCAAiC,YAAE,KAAK,GAAO,EACxE,KAAC,oBAAoB,IAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,GAAI,EAC7C,OAAO,IAAI,YAAG,SAAS,EAAC,sBAAsB,YAAE,OAAO,GAAK,IACrD,CACX,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,EAAE,IAAI,EAAE,GAAG,EAAiC;IAC1E,OAAO,KAAC,oBAAoB,IAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;AACxD,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAgB;IACvD,IAAI,EAAE,WAAW;IACjB,MAAM,EAAE,eAAe;IACvB,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,eAAe;IACrB,SAAS,EAAE,CAAC,OAAO,CAAC;IACpB,WAAW,EAAE,QAAQ;IACrB,KAAK,EAAE,WAAW;IAClB,WAAW,EACT,4JAA4J;IAC9J,8EAA8E;IAC9E,2EAA2E;IAC3E,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;CAClD,CAAC,CAAC","sourcesContent":["import {\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { defineBlock } from \"../types.js\";\nimport type {\n BlockReadProps,\n BlockEditProps,\n BlockRenderContext,\n} from \"../types.js\";\nimport {\n wireframeSchema,\n wireframeMdx,\n type WireframeData,\n type WireframeSurface,\n} from \"./wireframe.config.js\";\nimport {\n HTML_ROUGH_SELECTOR,\n KitConfigContext,\n RoughOverlay,\n Screen,\n renderNodes,\n useIsDark,\n useWireframeStyle,\n} from \"./wireframe-kit.js\";\nimport {\n sanitizeWireframeCss,\n sanitizeWireframeHtml,\n scopeDesignCss,\n} from \"./sanitize-html.js\";\n\n/**\n * Shared `wireframe` block — a hand-drawn low-fi mockup of one screen, rendered\n * from either a declarative kit tree (`data.screen`) or a self-contained HTML\n * mockup (`data.html`), inside a surface-locked frame (desktop/mobile/popover/\n * panel/browser) with a rough.js sketch overlay. Lives in core so any app can\n * register it (it originated in the plan template).\n *\n * DECOUPLING from the plan original:\n * - Theme: `useIsDark()` reads `document.documentElement.classList` instead of\n * `next-themes` (the MermaidBlock precedent), so core stays dependency-light.\n * - HTML sanitize: the HTML path runs `data.html`/`data.css` through the\n * app-injected `ctx.sanitizeHtml`. If no sanitizer is wired the HTML path is\n * skipped (kit tree or an empty frame renders) — core never injects unsanitized\n * author HTML.\n * - The plan-only prototype runtime, design-element selection, and legacy region\n * fallback are intentionally NOT ported; those are plan-canvas features, not\n * part of the document-block render. The kit element vocabulary, the `--wf-*`\n * token contract, and the `.plan-wf` / `[data-rough]` classes the overlay\n * measures are preserved exactly.\n *\n * The section carries the app-neutral `an-block` class plus the legacy\n * `plan-block` class so plan renders byte-identically while any other app gets\n * the theme-token treatment from core's `blocks.css`.\n *\n * The wireframe is canvas / agent-patch edited (node-addressable content patches\n * applied server-side), NOT schema-form edited in the browser — so `Edit` reuses\n * the same static render as `Read`, mirroring the plan `WireframeEditor`.\n */\n\ntype SurfacePreset = {\n width: number;\n /**\n * Floor height for the surface. The frame is AUTO-HEIGHT (content-driven): it\n * grows past this when content is tall and shrinks toward its content height\n * when content is short, but never collapses below this floor — so an empty or\n * near-empty frame still reads as that surface instead of a thin sliver. This\n * is a `min-height`, not a fixed `height`: it is the lower bound the old fixed\n * preset height used to also be the UPPER bound, which is what left a big empty\n * vertical band below short content (e.g. a header + one dropdown padded to a\n * tall fixed aspect).\n */\n minHeight: number;\n radius: number;\n};\n\nconst SURFACE_PRESETS: Record<WireframeSurface, SurfacePreset> = {\n // mobile keeps a tall floor: a phone frame reads as a phone even when short.\n mobile: { width: 300, minHeight: 360, radius: 30 },\n desktop: { width: 840, minHeight: 200, radius: 14 },\n browser: { width: 900, minHeight: 200, radius: 14 },\n popover: { width: 360, minHeight: 120, radius: 16 },\n panel: { width: 420, minHeight: 200, radius: 16 },\n};\n\nfunction isHtmlData(data: WireframeData): boolean {\n return typeof data.html === \"string\" && data.html.trim().length > 0;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Shared frame shell: surface-locked WIDTH + auto (content-driven) height + */\n/* theme + rough overlay. The frame keeps each surface's footprint and chrome */\n/* but fits its content height instead of padding to a fixed aspect, so short */\n/* content yields a short frame and tall content grows. Pass `canvasSize` to */\n/* opt a fixed-aspect canvas artboard back into a hard pixel height. */\n/* -------------------------------------------------------------------------- */\n\nfunction ArtboardFrame({\n surface,\n compact,\n canvasSize,\n canvasWidth,\n skeleton,\n renderMode,\n roughOverlay = true,\n selector,\n caption,\n render,\n}: {\n surface: WireframeSurface;\n compact?: boolean;\n /**\n * Force a FIXED pixel height instead of the auto-height (content-driven)\n * default. Reserved for fixed-aspect canvas artboards (pan/zoom). Document-flow\n * wireframes — what recaps render — leave this unset so the frame fits content.\n */\n canvasSize?: number;\n canvasWidth?: number;\n skeleton?: boolean;\n renderMode?: \"wireframe\" | \"design\";\n roughOverlay?: boolean;\n selector: string;\n caption?: string;\n render: (ctx: {\n theme: \"light\" | \"dark\";\n style: \"sketchy\" | \"clean\";\n }) => ReactNode;\n}) {\n const ref = useRef<HTMLDivElement>(null);\n const fitRef = useRef<HTMLDivElement>(null);\n const isDark = useIsDark();\n const theme: \"light\" | \"dark\" = isDark ? \"dark\" : \"light\";\n const style = useWireframeStyle();\n const preset = SURFACE_PRESETS[surface] ?? SURFACE_PRESETS.desktop;\n const width = canvasWidth ?? preset.width;\n // AUTO-HEIGHT: with no explicit `canvasSize` the artboard height is driven by\n // its content (`height: auto`), floored at the surface's `minHeight` so a short\n // screen produces a short frame and a tall screen grows — instead of every\n // surface being padded to a fixed preset height that left a big empty band\n // below short content. A `canvasSize` (fixed-aspect canvas artboard) overrides\n // this with a hard pixel height.\n const fixedHeight = canvasSize;\n const minHeight = fixedHeight ?? preset.minHeight;\n const baseScale = compact ? Math.min(1, 320 / preset.width) : 1;\n const maxFrameWidth = compact ? preset.width * baseScale : width;\n const [fitScale, setFitScale] = useState(baseScale);\n // The scaled artboard is `transform: scale()`-ed, which does not change its\n // layout box, so the wrapper that reserves vertical space must track the\n // artboard's ACTUAL rendered height. With a fixed height that's known up front;\n // with auto-height we measure it.\n const [measuredHeight, setMeasuredHeight] = useState<number | null>(\n fixedHeight ?? null,\n );\n const designMode = renderMode === \"design\";\n const sketchy = !designMode && style === \"sketchy\" && !skeleton;\n const roughEnabled = sketchy && roughOverlay;\n const paper = designMode\n ? \"hsl(var(--background))\"\n : \"var(--plan-document, hsl(var(--background)))\";\n const frameBorder = skeleton\n ? \"var(--plan-placeholder-line, var(--plan-line, hsl(var(--border))))\"\n : \"var(--plan-line, hsl(var(--border)))\";\n\n useEffect(() => {\n const element = fitRef.current;\n if (!element) return;\n const measure = () => {\n const availableWidth = element.clientWidth;\n const nextScale =\n availableWidth > 0\n ? Math.min(baseScale, availableWidth / width)\n : baseScale;\n setFitScale((current) =>\n Math.abs(current - nextScale) < 0.001 ? current : nextScale,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, [baseScale, width]);\n\n // Track the auto-height artboard's rendered height so the (un-transformed)\n // wrapper reserves exactly the scaled space the frame occupies. Skipped when a\n // fixed height is supplied — there's nothing to measure.\n useEffect(() => {\n if (fixedHeight != null) return;\n const element = ref.current;\n if (!element) return;\n const measure = () => {\n const next = element.offsetHeight;\n setMeasuredHeight((current) =>\n current != null && Math.abs(current - next) < 0.5 ? current : next,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, [fixedHeight]);\n\n // Height the wrapper reserves: the measured (or fixed) artboard height scaled\n // by the fit factor. Falls back to the surface floor before the first measure\n // so SSR / first paint reserves a sensible box rather than collapsing.\n const reservedHeight = (measuredHeight ?? minHeight) * fitScale;\n\n return (\n <div\n ref={fitRef}\n className=\"plan-kit-wireframe\"\n style={{\n width: \"100%\",\n maxWidth: maxFrameWidth,\n }}\n >\n <div\n style={{\n width: \"100%\",\n maxWidth: maxFrameWidth,\n height: reservedHeight,\n marginInline: \"auto\",\n }}\n >\n <div\n ref={ref}\n className=\"plan-kit-artboard relative\"\n style={{\n width,\n // Auto-height by default (content-driven, floored at `minHeight`);\n // a fixed `canvasSize` locks the height for canvas artboards.\n ...(fixedHeight != null ? { height: fixedHeight } : { minHeight }),\n borderRadius: preset.radius,\n background: paper,\n boxShadow: \"0 10px 34px hsl(var(--foreground) / 0.10)\",\n ...(fitScale !== 1\n ? {\n transform: `scale(${fitScale})`,\n transformOrigin: \"top left\",\n }\n : {}),\n }}\n >\n {/* Content drives the artboard height in flow when auto-height; for a\n fixed height it's pinned to the box. Rounded corners clip overflow\n either way. */}\n <div\n className=\"overflow-hidden\"\n style={{\n borderRadius: preset.radius,\n ...(fixedHeight != null\n ? { position: \"absolute\", inset: 0 }\n : { minHeight }),\n }}\n >\n {render({ theme, style })}\n </div>\n {!roughEnabled && (\n <div\n className=\"pointer-events-none absolute inset-0\"\n style={{\n borderRadius: preset.radius,\n border: `1.5px solid ${frameBorder}`,\n }}\n />\n )}\n <RoughOverlay\n scopeRef={ref}\n enabled={roughEnabled}\n frameRadius={preset.radius}\n selector={selector}\n />\n </div>\n </div>\n {caption && (\n <p className=\"mt-2 text-center text-xs text-plan-muted\">{caption}</p>\n )}\n </div>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* HTML artboard — author HTML, themed + roughened by the renderer. */\n/* -------------------------------------------------------------------------- */\n\nfunction HtmlArtboard({\n data,\n ctx: _ctx,\n compact,\n}: {\n data: WireframeData;\n ctx: BlockRenderContext;\n compact?: boolean;\n}) {\n const renderMode = data.renderMode ?? \"wireframe\";\n // Sanitize author HTML/CSS at the render point (defense-in-depth against stored\n // XSS). Self-contained in core via the shared block sanitizer (DOM-based in the\n // browser, regex fallback on the server) so the HTML mockup path renders in any\n // app without the host wiring a sanitizer hook.\n const safeHtml = useMemo(() => sanitizeWireframeHtml(data.html), [data.html]);\n const scopeId = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n const scopedCss = useMemo(() => {\n const safeCss = sanitizeWireframeCss(data.css);\n // Scope every author selector under this instance's artboard so global\n // selectors (body, *, .app-shell, :root) can't restyle/hide the host app.\n return safeCss\n ? scopeDesignCss(safeCss, `[data-plan-design-scope=\"${scopeId}\"]`)\n : \"\";\n }, [data.css, scopeId]);\n\n return (\n <ArtboardFrame\n surface={data.surface}\n compact={compact}\n skeleton={data.skeleton}\n renderMode={renderMode}\n selector={HTML_ROUGH_SELECTOR}\n caption={data.caption}\n render={({ theme, style }) => (\n <div\n className=\"plan-html-frame\"\n data-theme={theme}\n data-style={style}\n data-render-mode={renderMode}\n data-plan-design-scope={scopeId}\n data-skeleton={data.skeleton ? \"true\" : undefined}\n >\n {scopedCss && <style>{scopedCss}</style>}\n <div\n className=\"plan-html-frame-content\"\n dangerouslySetInnerHTML={{ __html: safeHtml }}\n />\n </div>\n )}\n />\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Kit artboard — declarative kit tree. */\n/* -------------------------------------------------------------------------- */\n\nfunction KitArtboard({\n data,\n compact,\n}: {\n data: WireframeData;\n compact?: boolean;\n}) {\n return (\n <ArtboardFrame\n surface={data.surface}\n compact={compact}\n skeleton={data.skeleton}\n selector=\"[data-rough]\"\n caption={data.caption}\n render={({ theme, style }) => (\n <KitConfigContext.Provider\n value={{ skeleton: data.skeleton, theme, style }}\n >\n {renderKitScreen(data.screen ?? [])}\n </KitConfigContext.Provider>\n )}\n />\n );\n}\n\nfunction renderKitScreen(\n nodes: NonNullable<WireframeData[\"screen\"]>,\n): ReactNode {\n if (nodes.length === 1 && nodes[0]?.el === \"screen\") {\n return renderNodes(nodes);\n }\n // `minHeight` (not `height`) so the screen fills the auto-height artboard floor\n // but grows past it when content is tall, instead of locking to a fixed box.\n return (\n <Screen pad=\"calc(var(--pad) * 1.35)\" style={{ minHeight: \"100%\" }}>\n {renderNodes(nodes)}\n </Screen>\n );\n}\n\n/**\n * The bare wireframe surface (no block section / title). Routes to the HTML\n * mockup when `data.html` is present and a sanitizer is wired; otherwise renders\n * the kit tree.\n */\nfunction WireframeSurfaceView({\n data,\n ctx,\n compact,\n}: {\n data: WireframeData;\n ctx: BlockRenderContext;\n compact?: boolean;\n}) {\n if (isHtmlData(data)) {\n return <HtmlArtboard data={data} ctx={ctx} compact={compact} />;\n }\n return <KitArtboard data={data} compact={compact} />;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Block Read / Edit */\n/* -------------------------------------------------------------------------- */\n\n/** Read-only renderer for a `wireframe` block. */\nexport function WireframeBlock({\n data,\n blockId,\n title,\n summary,\n ctx,\n}: BlockReadProps<WireframeData>) {\n return (\n <section\n className=\"an-block plan-block an-wireframe\"\n data-block-id={blockId}\n >\n {title && <div className=\"an-block-label plan-block-label\">{title}</div>}\n <WireframeSurfaceView data={data} ctx={ctx} />\n {summary && <p className=\"mt-5 text-plan-muted\">{summary}</p>}\n </section>\n );\n}\n\n/**\n * Editor for the `wireframe` block. The wireframe is canvas / agent-patch edited\n * (it never calls `onChange`), so edit mode reuses the read surface — mirroring\n * the plan `WireframeEditor`. The host document editor already wraps the registry\n * edit path in a titled section, so this renders only the surface to avoid\n * double-nesting.\n */\nexport function WireframeEditor({ data, ctx }: BlockEditProps<WireframeData>) {\n return <WireframeSurfaceView data={data} ctx={ctx} />;\n}\n\n/** Full client spec for the shared `wireframe` block (schema + MDX + Read/Edit). */\nexport const wireframeBlock = defineBlock<WireframeData>({\n type: \"wireframe\",\n schema: wireframeSchema,\n mdx: wireframeMdx,\n Read: WireframeBlock,\n Edit: WireframeEditor,\n placement: [\"block\"],\n editSurface: \"inline\",\n label: \"Wireframe\",\n description:\n \"A sketch wireframe of one screen built from kit primitives (or an HTML mockup), rendered in a chosen surface frame (desktop/mobile/popover/panel/browser).\",\n // `surface` is the only required field; `screen` defaults to []. Start on the\n // desktop surface with an empty screen so the canvas/agent can fill it in.\n empty: () => ({ surface: \"desktop\", screen: [] }),\n});\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { AttachmentAdapter, CompleteAttachment, PendingAttachment } from "@assistant-ui/react";
|
|
2
|
+
export declare const MAX_PDF_BYTES: number;
|
|
3
|
+
export declare const MAX_IMAGE_BYTES: number;
|
|
4
|
+
export declare const MAX_IMAGE_DIMENSION = 2048;
|
|
5
|
+
export declare const MAX_ESTIMATED_BODY_BYTES: number;
|
|
6
|
+
export declare const AGGRESSIVE_MAX_IMAGE_DIMENSION = 1024;
|
|
7
|
+
export declare const AGGRESSIVE_JPEG_QUALITY = 0.7;
|
|
8
|
+
export declare function inferDocumentContentType(file: File): string;
|
|
9
|
+
export declare function getFileDataURL(file: File | Blob): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Transcode an image to a web-safe JPEG or PNG via canvas and return its
|
|
12
|
+
* data-URL. Throws if canvas is unavailable.
|
|
13
|
+
*/
|
|
14
|
+
export declare function transcodeImageToDataURL(file: File, opts?: {
|
|
15
|
+
maxDimension?: number;
|
|
16
|
+
jpegQuality?: number;
|
|
17
|
+
}): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Return a web-safe, size-bounded data-URL for an image file.
|
|
20
|
+
*
|
|
21
|
+
* - Always transcodes formats that vision APIs reject (HEIC, TIFF, AVIF, BMP, …)
|
|
22
|
+
* to JPEG/PNG via canvas, regardless of file size.
|
|
23
|
+
* - Also downscales files over MAX_IMAGE_BYTES so large screenshots/photos
|
|
24
|
+
* don't blow up the request body.
|
|
25
|
+
* - Throws (does NOT silently fall back) when the format is non-web-safe and
|
|
26
|
+
* canvas transcoding fails — the adapter should surface a visible error.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getImageFileDataURL(file: File): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Estimate the serialized byte cost of a collection of attachment data-URLs
|
|
31
|
+
* (base64 strings, accounting for JSON string escaping overhead).
|
|
32
|
+
*/
|
|
33
|
+
export declare function estimateAttachmentBodyBytes(dataUrls: string[]): number;
|
|
34
|
+
export type QueuedAttachment = CompleteAttachment;
|
|
35
|
+
export declare class DownscalingImageAttachmentAdapter implements AttachmentAdapter {
|
|
36
|
+
accept: string;
|
|
37
|
+
add(state: {
|
|
38
|
+
file: File;
|
|
39
|
+
}): Promise<PendingAttachment>;
|
|
40
|
+
send(attachment: PendingAttachment): Promise<CompleteAttachment>;
|
|
41
|
+
remove(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
export declare class BinaryDocumentAttachmentAdapter implements AttachmentAdapter {
|
|
44
|
+
accept: string;
|
|
45
|
+
add(state: {
|
|
46
|
+
file: File;
|
|
47
|
+
}): Promise<PendingAttachment>;
|
|
48
|
+
send(attachment: PendingAttachment): Promise<CompleteAttachment>;
|
|
49
|
+
remove(): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
export declare function imageContentTypeFromDataUrl(dataUrl: string): string;
|
|
52
|
+
export declare function imageExtensionFromContentType(contentType: string): string;
|
|
53
|
+
export declare function createAgentImageAttachments(images?: readonly string[]): QueuedAttachment[] | undefined;
|
|
54
|
+
export declare function isTextLikeFile(file: File): boolean;
|
|
55
|
+
export declare function textFileAttachmentEnvelope(file: File, text: string): string;
|
|
56
|
+
export declare function serializeAttachmentContentPart(part: Record<string, unknown>): QueuedAttachment["content"][number] | null;
|
|
57
|
+
export declare function serializeQueuedAttachments(attachments?: ReadonlyArray<unknown>): Promise<QueuedAttachment[] | undefined>;
|
|
58
|
+
//# sourceMappingURL=attachment-adapters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-adapters.d.ts","sourceRoot":"","sources":["../../../src/client/chat/attachment-adapters.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,aAAa,QAAkB,CAAC;AAM7C,eAAO,MAAM,eAAe,QAAkB,CAAC;AAC/C,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAGxC,eAAO,MAAM,wBAAwB,QAAoB,CAAC;AAE1D,eAAO,MAAM,8BAA8B,OAAO,CAAC;AACnD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAW3C,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAI3D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAOjE;AAmBD;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,EACV,IAAI,GAAE;IACJ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACjB,GACL,OAAO,CAAC,MAAM,CAAC,CA0BjB;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAkCrE;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAItE;AAED,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAElD,qBAAa,iCAAkC,YAAW,iBAAiB;IAClE,MAAM,SAAa;IAEb,GAAG,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAWtD,IAAI,CACf,UAAU,EAAE,iBAAiB,GAC5B,OAAO,CAAC,kBAAkB,CAAC;IAajB,MAAM;CAGpB;AAED,qBAAa,+BAAgC,YAAW,iBAAiB;IAChE,MAAM,SAA0B;IAE1B,GAAG,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAWtD,IAAI,CACf,UAAU,EAAE,iBAAiB,GAC5B,OAAO,CAAC,kBAAkB,CAAC;IAsBjB,MAAM;CAGpB;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGnE;AAED,wBAAgB,6BAA6B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAKzE;AAED,wBAAgB,2BAA2B,CACzC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,GACzB,gBAAgB,EAAE,GAAG,SAAS,CAiBhC;AAMD,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAIlD;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG3E;AAED,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,gBAAgB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,CAmB5C;AAED,wBAAsB,0BAA0B,CAC9C,WAAW,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,GACnC,OAAO,CAAC,gBAAgB,EAAE,GAAG,SAAS,CAAC,CA0EzC"}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
// Owns: image/document/text attachment adapters and attachment serialization helpers.
|
|
2
|
+
// Maximum PDF/document size (4 MB). Larger PDFs would bloat the JSON POST
|
|
3
|
+
// body past Vercel's ~4.5 MB limit after base64 encoding (+33% overhead).
|
|
4
|
+
export const MAX_PDF_BYTES = 4 * 1024 * 1024;
|
|
5
|
+
// Anthropic / OpenAI vision inputs choke on multi-megabyte images, and
|
|
6
|
+
// base64-encoding a raw screenshot eats enough heap to crash the composer
|
|
7
|
+
// (PayloadTooLarge / "Maximum call stack" in serializers). Downscale large
|
|
8
|
+
// images on the client before we ever serialize them.
|
|
9
|
+
export const MAX_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
10
|
+
export const MAX_IMAGE_DIMENSION = 2048;
|
|
11
|
+
// Estimated total serialized body budget (JSON POST). Vercel/Netlify cap ~4.5 MB.
|
|
12
|
+
// We stop well below to leave room for the text payload and JSON framing.
|
|
13
|
+
export const MAX_ESTIMATED_BODY_BYTES = 3.5 * 1024 * 1024;
|
|
14
|
+
// At 3.5 MB of serializable attachments, aggressively re-downscale images.
|
|
15
|
+
export const AGGRESSIVE_MAX_IMAGE_DIMENSION = 1024;
|
|
16
|
+
export const AGGRESSIVE_JPEG_QUALITY = 0.7;
|
|
17
|
+
/** MIME types that vision models accept natively (no canvas transcoding needed). */
|
|
18
|
+
const WEB_SAFE_IMAGE_TYPES = new Set([
|
|
19
|
+
"image/jpeg",
|
|
20
|
+
"image/jpg",
|
|
21
|
+
"image/png",
|
|
22
|
+
"image/gif",
|
|
23
|
+
"image/webp",
|
|
24
|
+
]);
|
|
25
|
+
export function inferDocumentContentType(file) {
|
|
26
|
+
if (file.type)
|
|
27
|
+
return file.type;
|
|
28
|
+
if (file.name.toLowerCase().endsWith(".pdf"))
|
|
29
|
+
return "application/pdf";
|
|
30
|
+
return "application/octet-stream";
|
|
31
|
+
}
|
|
32
|
+
export function getFileDataURL(file) {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
const reader = new FileReader();
|
|
35
|
+
reader.onload = () => resolve(reader.result);
|
|
36
|
+
reader.onerror = (error) => reject(error);
|
|
37
|
+
reader.readAsDataURL(file);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function loadImage(url) {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
const img = new Image();
|
|
43
|
+
img.onload = () => resolve(img);
|
|
44
|
+
img.onerror = () => reject(new Error("Failed to decode pasted image"));
|
|
45
|
+
img.src = url;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns true when the MIME type is natively accepted by vision APIs
|
|
50
|
+
* (jpeg / png / gif / webp). HEIC, TIFF, AVIF, BMP, etc. return false.
|
|
51
|
+
*/
|
|
52
|
+
function isWebSafeImageType(mimeType) {
|
|
53
|
+
return WEB_SAFE_IMAGE_TYPES.has(mimeType.toLowerCase());
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Transcode an image to a web-safe JPEG or PNG via canvas and return its
|
|
57
|
+
* data-URL. Throws if canvas is unavailable.
|
|
58
|
+
*/
|
|
59
|
+
export async function transcodeImageToDataURL(file, opts = {}) {
|
|
60
|
+
const maxDimension = opts.maxDimension ?? MAX_IMAGE_DIMENSION;
|
|
61
|
+
const jpegQuality = opts.jpegQuality ?? 0.85;
|
|
62
|
+
const objectUrl = URL.createObjectURL(file);
|
|
63
|
+
try {
|
|
64
|
+
const img = await loadImage(objectUrl);
|
|
65
|
+
const ratio = Math.min(maxDimension / img.naturalWidth, maxDimension / img.naturalHeight, 1);
|
|
66
|
+
const width = Math.max(1, Math.round(img.naturalWidth * ratio));
|
|
67
|
+
const height = Math.max(1, Math.round(img.naturalHeight * ratio));
|
|
68
|
+
const canvas = document.createElement("canvas");
|
|
69
|
+
canvas.width = width;
|
|
70
|
+
canvas.height = height;
|
|
71
|
+
const ctx = canvas.getContext("2d");
|
|
72
|
+
if (!ctx)
|
|
73
|
+
throw new Error("Canvas 2D context unavailable");
|
|
74
|
+
ctx.drawImage(img, 0, 0, width, height);
|
|
75
|
+
const keepPng = file.type === "image/png" && file.size <= MAX_IMAGE_BYTES * 2;
|
|
76
|
+
return canvas.toDataURL(keepPng ? "image/png" : "image/jpeg", jpegQuality);
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
URL.revokeObjectURL(objectUrl);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Return a web-safe, size-bounded data-URL for an image file.
|
|
84
|
+
*
|
|
85
|
+
* - Always transcodes formats that vision APIs reject (HEIC, TIFF, AVIF, BMP, …)
|
|
86
|
+
* to JPEG/PNG via canvas, regardless of file size.
|
|
87
|
+
* - Also downscales files over MAX_IMAGE_BYTES so large screenshots/photos
|
|
88
|
+
* don't blow up the request body.
|
|
89
|
+
* - Throws (does NOT silently fall back) when the format is non-web-safe and
|
|
90
|
+
* canvas transcoding fails — the adapter should surface a visible error.
|
|
91
|
+
*/
|
|
92
|
+
export async function getImageFileDataURL(file) {
|
|
93
|
+
const needsTranscode = !isWebSafeImageType(file.type);
|
|
94
|
+
const tooBig = file.size > MAX_IMAGE_BYTES;
|
|
95
|
+
if (!needsTranscode && !tooBig) {
|
|
96
|
+
// Already a supported type and within size budget — serve raw.
|
|
97
|
+
return getFileDataURL(file);
|
|
98
|
+
}
|
|
99
|
+
if (typeof document === "undefined" || typeof Image === "undefined") {
|
|
100
|
+
if (needsTranscode) {
|
|
101
|
+
// Can't transcode server-side — surface an error rather than silently
|
|
102
|
+
// attaching garbage bytes that the model cannot decode.
|
|
103
|
+
throw new Error(`"${file.name}" is a ${file.type || "unknown"} image. Only JPEG, PNG, GIF, and WebP are supported in this environment.`);
|
|
104
|
+
}
|
|
105
|
+
// Can't downscale but the type is fine — send raw and hope for the best.
|
|
106
|
+
return getFileDataURL(file);
|
|
107
|
+
}
|
|
108
|
+
// Transcode via canvas. Throws on decode failure for non-web-safe types
|
|
109
|
+
// so the adapter can surface a visible error; falls back to raw for
|
|
110
|
+
// oversized-but-supported types (the older behaviour).
|
|
111
|
+
try {
|
|
112
|
+
return await transcodeImageToDataURL(file);
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
if (needsTranscode) {
|
|
116
|
+
// Re-throw so the DownscalingImageAttachmentAdapter.send() can surface it.
|
|
117
|
+
throw err;
|
|
118
|
+
}
|
|
119
|
+
// Safe type, just couldn't downscale — fall back to the raw file.
|
|
120
|
+
return getFileDataURL(file);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Estimate the serialized byte cost of a collection of attachment data-URLs
|
|
125
|
+
* (base64 strings, accounting for JSON string escaping overhead).
|
|
126
|
+
*/
|
|
127
|
+
export function estimateAttachmentBodyBytes(dataUrls) {
|
|
128
|
+
// JSON.stringify adds ~2 bytes of quotes per string; base64 is already
|
|
129
|
+
// accounted for in the string length. Add 15% for JSON framing.
|
|
130
|
+
return dataUrls.reduce((sum, url) => sum + url.length, 0) * 1.15;
|
|
131
|
+
}
|
|
132
|
+
export class DownscalingImageAttachmentAdapter {
|
|
133
|
+
accept = "image/*";
|
|
134
|
+
async add(state) {
|
|
135
|
+
return {
|
|
136
|
+
id: crypto.randomUUID(),
|
|
137
|
+
type: "image",
|
|
138
|
+
name: state.file.name,
|
|
139
|
+
contentType: state.file.type,
|
|
140
|
+
file: state.file,
|
|
141
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async send(attachment) {
|
|
145
|
+
return {
|
|
146
|
+
...attachment,
|
|
147
|
+
status: { type: "complete" },
|
|
148
|
+
content: [
|
|
149
|
+
{
|
|
150
|
+
type: "image",
|
|
151
|
+
image: await getImageFileDataURL(attachment.file),
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
async remove() {
|
|
157
|
+
// noop
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export class BinaryDocumentAttachmentAdapter {
|
|
161
|
+
accept = "application/pdf,.pdf";
|
|
162
|
+
async add(state) {
|
|
163
|
+
return {
|
|
164
|
+
id: state.file.name,
|
|
165
|
+
type: "document",
|
|
166
|
+
name: state.file.name,
|
|
167
|
+
contentType: inferDocumentContentType(state.file),
|
|
168
|
+
file: state.file,
|
|
169
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
async send(attachment) {
|
|
173
|
+
if (attachment.file && attachment.file.size > MAX_PDF_BYTES) {
|
|
174
|
+
const mb = (attachment.file.size / 1024 / 1024).toFixed(1);
|
|
175
|
+
const maxMb = (MAX_PDF_BYTES / 1024 / 1024).toFixed(0);
|
|
176
|
+
throw new Error(`"${attachment.name}" is ${mb} MB — PDFs are capped at ${maxMb} MB to stay within message limits. Please reduce the file size or split it into smaller parts.`);
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
...attachment,
|
|
180
|
+
status: { type: "complete" },
|
|
181
|
+
content: [
|
|
182
|
+
{
|
|
183
|
+
type: "file",
|
|
184
|
+
filename: attachment.name,
|
|
185
|
+
data: await getFileDataURL(attachment.file),
|
|
186
|
+
mimeType: inferDocumentContentType(attachment.file),
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
async remove() {
|
|
192
|
+
// noop
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
export function imageContentTypeFromDataUrl(dataUrl) {
|
|
196
|
+
const match = /^data:([^;,]+)/.exec(dataUrl);
|
|
197
|
+
return match?.[1] || "image/jpeg";
|
|
198
|
+
}
|
|
199
|
+
export function imageExtensionFromContentType(contentType) {
|
|
200
|
+
if (contentType === "image/png")
|
|
201
|
+
return "png";
|
|
202
|
+
if (contentType === "image/webp")
|
|
203
|
+
return "webp";
|
|
204
|
+
if (contentType === "image/gif")
|
|
205
|
+
return "gif";
|
|
206
|
+
return "jpg";
|
|
207
|
+
}
|
|
208
|
+
export function createAgentImageAttachments(images) {
|
|
209
|
+
const validImages = (images ?? []).filter((image) => image.trim().length > 0);
|
|
210
|
+
if (validImages.length === 0)
|
|
211
|
+
return undefined;
|
|
212
|
+
return validImages.map((image, index) => {
|
|
213
|
+
const contentType = imageContentTypeFromDataUrl(image);
|
|
214
|
+
const extension = imageExtensionFromContentType(contentType);
|
|
215
|
+
const name = `image-${index + 1}.${extension}`;
|
|
216
|
+
return {
|
|
217
|
+
id: `agent-chat-image-${index + 1}`,
|
|
218
|
+
type: "image",
|
|
219
|
+
name,
|
|
220
|
+
contentType,
|
|
221
|
+
status: { type: "complete" },
|
|
222
|
+
content: [{ type: "image", image }],
|
|
223
|
+
};
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
function escapeQueuedAttachmentAttribute(value) {
|
|
227
|
+
return value.replace(/&/g, "&").replace(/"/g, """);
|
|
228
|
+
}
|
|
229
|
+
export function isTextLikeFile(file) {
|
|
230
|
+
if (file.type.startsWith("text/"))
|
|
231
|
+
return true;
|
|
232
|
+
if (file.type === "application/json")
|
|
233
|
+
return true;
|
|
234
|
+
return /\.(txt|md|markdown|csv|json|yaml|yml)$/i.test(file.name);
|
|
235
|
+
}
|
|
236
|
+
export function textFileAttachmentEnvelope(file, text) {
|
|
237
|
+
const contentType = file.type || "text/plain";
|
|
238
|
+
return `<attachment name="${escapeQueuedAttachmentAttribute(file.name)}" contentType="${escapeQueuedAttachmentAttribute(contentType)}">\n${text}\n</attachment>`;
|
|
239
|
+
}
|
|
240
|
+
export function serializeAttachmentContentPart(part) {
|
|
241
|
+
if (part.type === "image" && typeof part.image === "string") {
|
|
242
|
+
return { type: "image", image: part.image };
|
|
243
|
+
}
|
|
244
|
+
if (part.type === "text" && typeof part.text === "string") {
|
|
245
|
+
return { type: "text", text: part.text };
|
|
246
|
+
}
|
|
247
|
+
if (part.type === "file" && typeof part.data === "string") {
|
|
248
|
+
return {
|
|
249
|
+
type: "file",
|
|
250
|
+
data: part.data,
|
|
251
|
+
mimeType: typeof part.mimeType === "string"
|
|
252
|
+
? part.mimeType
|
|
253
|
+
: "application/octet-stream",
|
|
254
|
+
...(typeof part.filename === "string" ? { filename: part.filename } : {}),
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
export async function serializeQueuedAttachments(attachments) {
|
|
260
|
+
const queued = [];
|
|
261
|
+
for (const raw of attachments ?? []) {
|
|
262
|
+
const attachment = raw;
|
|
263
|
+
const name = attachment.name || attachment.file?.name || "attachment";
|
|
264
|
+
const id = attachment.id || name;
|
|
265
|
+
const type = attachment.type || "file";
|
|
266
|
+
const contentType = attachment.contentType || attachment.file?.type;
|
|
267
|
+
if (Array.isArray(attachment.content) && attachment.content.length > 0) {
|
|
268
|
+
const content = attachment.content
|
|
269
|
+
.map((part) => serializeAttachmentContentPart(part))
|
|
270
|
+
.filter((part) => !!part);
|
|
271
|
+
if (content.length > 0) {
|
|
272
|
+
queued.push({
|
|
273
|
+
id,
|
|
274
|
+
type,
|
|
275
|
+
name,
|
|
276
|
+
contentType,
|
|
277
|
+
status: { type: "complete" },
|
|
278
|
+
content,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (typeof File !== "undefined" && attachment.file instanceof File) {
|
|
284
|
+
const file = attachment.file;
|
|
285
|
+
if (file.type.startsWith("image/")) {
|
|
286
|
+
queued.push({
|
|
287
|
+
id,
|
|
288
|
+
type: "image",
|
|
289
|
+
name,
|
|
290
|
+
contentType: file.type,
|
|
291
|
+
status: { type: "complete" },
|
|
292
|
+
content: [{ type: "image", image: await getImageFileDataURL(file) }],
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
else if (isTextLikeFile(file)) {
|
|
296
|
+
queued.push({
|
|
297
|
+
id,
|
|
298
|
+
type: "file",
|
|
299
|
+
name,
|
|
300
|
+
contentType: file.type || "text/plain",
|
|
301
|
+
status: { type: "complete" },
|
|
302
|
+
content: [
|
|
303
|
+
{
|
|
304
|
+
type: "text",
|
|
305
|
+
text: textFileAttachmentEnvelope(file, await file.text()),
|
|
306
|
+
},
|
|
307
|
+
],
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
queued.push({
|
|
312
|
+
id,
|
|
313
|
+
type: "document",
|
|
314
|
+
name,
|
|
315
|
+
contentType: inferDocumentContentType(file),
|
|
316
|
+
status: { type: "complete" },
|
|
317
|
+
content: [
|
|
318
|
+
{
|
|
319
|
+
type: "file",
|
|
320
|
+
filename: file.name,
|
|
321
|
+
data: await getFileDataURL(file),
|
|
322
|
+
mimeType: inferDocumentContentType(file),
|
|
323
|
+
},
|
|
324
|
+
],
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return queued.length > 0 ? queued : undefined;
|
|
330
|
+
}
|
|
331
|
+
//# sourceMappingURL=attachment-adapters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-adapters.js","sourceRoot":"","sources":["../../../src/client/chat/attachment-adapters.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAStF,0EAA0E;AAC1E,0EAA0E;AAC1E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAE7C,uEAAuE;AACvE,0EAA0E;AAC1E,2EAA2E;AAC3E,sDAAsD;AACtD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAC/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACxC,kFAAkF;AAClF,0EAA0E;AAC1E,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1D,2EAA2E;AAC3E,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,CAAC;AACnD,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,oFAAoF;AACpF,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,YAAY;IACZ,WAAW;IACX,WAAW;IACX,WAAW;IACX,Y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YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAChD,CAAC","sourcesContent":["// Owns: image/document/text attachment adapters and attachment serialization helpers.\n\nimport type {\n AttachmentAdapter,\n CompleteAttachment,\n PendingAttachment,\n Attachment,\n} from \"@assistant-ui/react\";\n\n// Maximum PDF/document size (4 MB). Larger PDFs would bloat the JSON POST\n// body past Vercel's ~4.5 MB limit after base64 encoding (+33% overhead).\nexport const MAX_PDF_BYTES = 4 * 1024 * 1024;\n\n// Anthropic / OpenAI vision inputs choke on multi-megabyte images, and\n// base64-encoding a raw screenshot eats enough heap to crash the composer\n// (PayloadTooLarge / \"Maximum call stack\" in serializers). Downscale large\n// images on the client before we ever serialize them.\nexport const MAX_IMAGE_BYTES = 4 * 1024 * 1024;\nexport const MAX_IMAGE_DIMENSION = 2048;\n// Estimated total serialized body budget (JSON POST). Vercel/Netlify cap ~4.5 MB.\n// We stop well below to leave room for the text payload and JSON framing.\nexport const MAX_ESTIMATED_BODY_BYTES = 3.5 * 1024 * 1024;\n// At 3.5 MB of serializable attachments, aggressively re-downscale images.\nexport const AGGRESSIVE_MAX_IMAGE_DIMENSION = 1024;\nexport const AGGRESSIVE_JPEG_QUALITY = 0.7;\n\n/** MIME types that vision models accept natively (no canvas transcoding needed). */\nconst WEB_SAFE_IMAGE_TYPES = new Set([\n \"image/jpeg\",\n \"image/jpg\",\n \"image/png\",\n \"image/gif\",\n \"image/webp\",\n]);\n\nexport function inferDocumentContentType(file: File): string {\n if (file.type) return file.type;\n if (file.name.toLowerCase().endsWith(\".pdf\")) return \"application/pdf\";\n return \"application/octet-stream\";\n}\n\nexport function getFileDataURL(file: File | Blob): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => resolve(reader.result as string);\n reader.onerror = (error) => reject(error);\n reader.readAsDataURL(file);\n });\n}\n\nfunction loadImage(url: string): Promise<HTMLImageElement> {\n return new Promise((resolve, reject) => {\n const img = new Image();\n img.onload = () => resolve(img);\n img.onerror = () => reject(new Error(\"Failed to decode pasted image\"));\n img.src = url;\n });\n}\n\n/**\n * Returns true when the MIME type is natively accepted by vision APIs\n * (jpeg / png / gif / webp). HEIC, TIFF, AVIF, BMP, etc. return false.\n */\nfunction isWebSafeImageType(mimeType: string): boolean {\n return WEB_SAFE_IMAGE_TYPES.has(mimeType.toLowerCase());\n}\n\n/**\n * Transcode an image to a web-safe JPEG or PNG via canvas and return its\n * data-URL. Throws if canvas is unavailable.\n */\nexport async function transcodeImageToDataURL(\n file: File,\n opts: {\n maxDimension?: number;\n jpegQuality?: number;\n } = {},\n): Promise<string> {\n const maxDimension = opts.maxDimension ?? MAX_IMAGE_DIMENSION;\n const jpegQuality = opts.jpegQuality ?? 0.85;\n\n const objectUrl = URL.createObjectURL(file);\n try {\n const img = await loadImage(objectUrl);\n const ratio = Math.min(\n maxDimension / img.naturalWidth,\n maxDimension / img.naturalHeight,\n 1,\n );\n const width = Math.max(1, Math.round(img.naturalWidth * ratio));\n const height = Math.max(1, Math.round(img.naturalHeight * ratio));\n const canvas = document.createElement(\"canvas\");\n canvas.width = width;\n canvas.height = height;\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) throw new Error(\"Canvas 2D context unavailable\");\n ctx.drawImage(img, 0, 0, width, height);\n const keepPng =\n file.type === \"image/png\" && file.size <= MAX_IMAGE_BYTES * 2;\n return canvas.toDataURL(keepPng ? \"image/png\" : \"image/jpeg\", jpegQuality);\n } finally {\n URL.revokeObjectURL(objectUrl);\n }\n}\n\n/**\n * Return a web-safe, size-bounded data-URL for an image file.\n *\n * - Always transcodes formats that vision APIs reject (HEIC, TIFF, AVIF, BMP, …)\n * to JPEG/PNG via canvas, regardless of file size.\n * - Also downscales files over MAX_IMAGE_BYTES so large screenshots/photos\n * don't blow up the request body.\n * - Throws (does NOT silently fall back) when the format is non-web-safe and\n * canvas transcoding fails — the adapter should surface a visible error.\n */\nexport async function getImageFileDataURL(file: File): Promise<string> {\n const needsTranscode = !isWebSafeImageType(file.type);\n const tooBig = file.size > MAX_IMAGE_BYTES;\n\n if (!needsTranscode && !tooBig) {\n // Already a supported type and within size budget — serve raw.\n return getFileDataURL(file);\n }\n\n if (typeof document === \"undefined\" || typeof Image === \"undefined\") {\n if (needsTranscode) {\n // Can't transcode server-side — surface an error rather than silently\n // attaching garbage bytes that the model cannot decode.\n throw new Error(\n `\"${file.name}\" is a ${file.type || \"unknown\"} image. Only JPEG, PNG, GIF, and WebP are supported in this environment.`,\n );\n }\n // Can't downscale but the type is fine — send raw and hope for the best.\n return getFileDataURL(file);\n }\n\n // Transcode via canvas. Throws on decode failure for non-web-safe types\n // so the adapter can surface a visible error; falls back to raw for\n // oversized-but-supported types (the older behaviour).\n try {\n return await transcodeImageToDataURL(file);\n } catch (err) {\n if (needsTranscode) {\n // Re-throw so the DownscalingImageAttachmentAdapter.send() can surface it.\n throw err;\n }\n // Safe type, just couldn't downscale — fall back to the raw file.\n return getFileDataURL(file);\n }\n}\n\n/**\n * Estimate the serialized byte cost of a collection of attachment data-URLs\n * (base64 strings, accounting for JSON string escaping overhead).\n */\nexport function estimateAttachmentBodyBytes(dataUrls: string[]): number {\n // JSON.stringify adds ~2 bytes of quotes per string; base64 is already\n // accounted for in the string length. Add 15% for JSON framing.\n return dataUrls.reduce((sum, url) => sum + url.length, 0) * 1.15;\n}\n\nexport type QueuedAttachment = CompleteAttachment;\n\nexport class DownscalingImageAttachmentAdapter implements AttachmentAdapter {\n public accept = \"image/*\";\n\n public async add(state: { file: File }): Promise<PendingAttachment> {\n return {\n id: crypto.randomUUID(),\n type: \"image\",\n name: state.file.name,\n contentType: state.file.type,\n file: state.file,\n status: { type: \"requires-action\", reason: \"composer-send\" },\n };\n }\n\n public async send(\n attachment: PendingAttachment,\n ): Promise<CompleteAttachment> {\n return {\n ...attachment,\n status: { type: \"complete\" },\n content: [\n {\n type: \"image\",\n image: await getImageFileDataURL(attachment.file),\n },\n ],\n };\n }\n\n public async remove() {\n // noop\n }\n}\n\nexport class BinaryDocumentAttachmentAdapter implements AttachmentAdapter {\n public accept = \"application/pdf,.pdf\";\n\n public async add(state: { file: File }): Promise<PendingAttachment> {\n return {\n id: state.file.name,\n type: \"document\",\n name: state.file.name,\n contentType: inferDocumentContentType(state.file),\n file: state.file,\n status: { type: \"requires-action\", reason: \"composer-send\" },\n };\n }\n\n public async send(\n attachment: PendingAttachment,\n ): Promise<CompleteAttachment> {\n if (attachment.file && attachment.file.size > MAX_PDF_BYTES) {\n const mb = (attachment.file.size / 1024 / 1024).toFixed(1);\n const maxMb = (MAX_PDF_BYTES / 1024 / 1024).toFixed(0);\n throw new Error(\n `\"${attachment.name}\" is ${mb} MB — PDFs are capped at ${maxMb} MB to stay within message limits. Please reduce the file size or split it into smaller parts.`,\n );\n }\n return {\n ...attachment,\n status: { type: \"complete\" },\n content: [\n {\n type: \"file\",\n filename: attachment.name,\n data: await getFileDataURL(attachment.file),\n mimeType: inferDocumentContentType(attachment.file),\n },\n ],\n };\n }\n\n public async remove() {\n // noop\n }\n}\n\nexport function imageContentTypeFromDataUrl(dataUrl: string): string {\n const match = /^data:([^;,]+)/.exec(dataUrl);\n return match?.[1] || \"image/jpeg\";\n}\n\nexport function imageExtensionFromContentType(contentType: string): string {\n if (contentType === \"image/png\") return \"png\";\n if (contentType === \"image/webp\") return \"webp\";\n if (contentType === \"image/gif\") return \"gif\";\n return \"jpg\";\n}\n\nexport function createAgentImageAttachments(\n images?: readonly string[],\n): QueuedAttachment[] | undefined {\n const validImages = (images ?? []).filter((image) => image.trim().length > 0);\n if (validImages.length === 0) return undefined;\n\n return validImages.map((image, index) => {\n const contentType = imageContentTypeFromDataUrl(image);\n const extension = imageExtensionFromContentType(contentType);\n const name = `image-${index + 1}.${extension}`;\n return {\n id: `agent-chat-image-${index + 1}`,\n type: \"image\",\n name,\n contentType,\n status: { type: \"complete\" },\n content: [{ type: \"image\", image }],\n };\n });\n}\n\nfunction escapeQueuedAttachmentAttribute(value: string): string {\n return value.replace(/&/g, \"&\").replace(/\"/g, \""\");\n}\n\nexport function isTextLikeFile(file: File): boolean {\n if (file.type.startsWith(\"text/\")) return true;\n if (file.type === \"application/json\") return true;\n return /\\.(txt|md|markdown|csv|json|yaml|yml)$/i.test(file.name);\n}\n\nexport function textFileAttachmentEnvelope(file: File, text: string): string {\n const contentType = file.type || \"text/plain\";\n return `<attachment name=\"${escapeQueuedAttachmentAttribute(file.name)}\" contentType=\"${escapeQueuedAttachmentAttribute(contentType)}\">\\n${text}\\n</attachment>`;\n}\n\nexport function serializeAttachmentContentPart(\n part: Record<string, unknown>,\n): QueuedAttachment[\"content\"][number] | null {\n if (part.type === \"image\" && typeof part.image === \"string\") {\n return { type: \"image\", image: part.image };\n }\n if (part.type === \"text\" && typeof part.text === \"string\") {\n return { type: \"text\", text: part.text };\n }\n if (part.type === \"file\" && typeof part.data === \"string\") {\n return {\n type: \"file\",\n data: part.data,\n mimeType:\n typeof part.mimeType === \"string\"\n ? part.mimeType\n : \"application/octet-stream\",\n ...(typeof part.filename === \"string\" ? { filename: part.filename } : {}),\n };\n }\n return null;\n}\n\nexport async function serializeQueuedAttachments(\n attachments?: ReadonlyArray<unknown>,\n): Promise<QueuedAttachment[] | undefined> {\n const queued: QueuedAttachment[] = [];\n for (const raw of attachments ?? []) {\n const attachment = raw as Partial<Attachment> & { file?: File };\n const name = attachment.name || attachment.file?.name || \"attachment\";\n const id = attachment.id || name;\n const type = attachment.type || \"file\";\n const contentType = attachment.contentType || attachment.file?.type;\n\n if (Array.isArray(attachment.content) && attachment.content.length > 0) {\n const content = attachment.content\n .map((part) =>\n serializeAttachmentContentPart(part as Record<string, unknown>),\n )\n .filter((part): part is QueuedAttachment[\"content\"][number] => !!part);\n if (content.length > 0) {\n queued.push({\n id,\n type,\n name,\n contentType,\n status: { type: \"complete\" },\n content,\n });\n }\n continue;\n }\n\n if (typeof File !== \"undefined\" && attachment.file instanceof File) {\n const file = attachment.file;\n if (file.type.startsWith(\"image/\")) {\n queued.push({\n id,\n type: \"image\",\n name,\n contentType: file.type,\n status: { type: \"complete\" },\n content: [{ type: \"image\", image: await getImageFileDataURL(file) }],\n });\n } else if (isTextLikeFile(file)) {\n queued.push({\n id,\n type: \"file\",\n name,\n contentType: file.type || \"text/plain\",\n status: { type: \"complete\" },\n content: [\n {\n type: \"text\",\n text: textFileAttachmentEnvelope(file, await file.text()),\n },\n ],\n });\n } else {\n queued.push({\n id,\n type: \"document\",\n name,\n contentType: inferDocumentContentType(file),\n status: { type: \"complete\" },\n content: [\n {\n type: \"file\",\n filename: file.name,\n data: await getFileDataURL(file),\n mimeType: inferDocumentContentType(file),\n },\n ],\n });\n }\n }\n }\n\n return queued.length > 0 ? queued : undefined;\n}\n"]}
|