@agent-native/core 0.80.2 → 0.80.5
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/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +66 -2
- package/corpus/core/docs/content/locales/ar-SA/real-time-collaboration.mdx +2 -2
- package/corpus/core/docs/content/locales/ar-SA/template-design.mdx +1 -1
- package/corpus/core/docs/content/locales/de-DE/real-time-collaboration.mdx +3 -3
- package/corpus/core/docs/content/locales/de-DE/template-design.mdx +1 -1
- package/corpus/core/docs/content/locales/es-ES/real-time-collaboration.mdx +2 -2
- package/corpus/core/docs/content/locales/es-ES/template-design.mdx +1 -1
- package/corpus/core/docs/content/locales/fr-FR/real-time-collaboration.mdx +2 -2
- package/corpus/core/docs/content/locales/fr-FR/template-design.mdx +1 -1
- package/corpus/core/docs/content/locales/hi-IN/template-design.mdx +1 -1
- package/corpus/core/docs/content/locales/ja-JP/real-time-collaboration.mdx +2 -2
- package/corpus/core/docs/content/locales/ja-JP/template-design.mdx +1 -1
- package/corpus/core/docs/content/locales/ko-KR/real-time-collaboration.mdx +2 -2
- package/corpus/core/docs/content/locales/ko-KR/template-design.mdx +1 -1
- package/corpus/core/docs/content/locales/pt-BR/real-time-collaboration.mdx +2 -2
- package/corpus/core/docs/content/locales/pt-BR/template-design.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-CN/real-time-collaboration.mdx +2 -2
- package/corpus/core/docs/content/locales/zh-CN/template-design.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-TW/real-time-collaboration.mdx +2 -2
- package/corpus/core/docs/content/locales/zh-TW/template-design.mdx +1 -1
- package/corpus/core/docs/content/real-time-collaboration.mdx +2 -2
- package/corpus/core/docs/content/template-design.mdx +1 -1
- package/corpus/core/package.json +3 -7
- package/corpus/core/src/action.ts +32 -0
- package/corpus/core/src/agent/durable-background.ts +32 -11
- package/corpus/core/src/agent/production-agent.ts +14 -1
- package/corpus/core/src/agent/run-loop-with-resume.ts +3 -1
- package/corpus/core/src/brand-kit/fig/index.ts +17 -37
- package/corpus/core/src/cli/index.ts +1 -1
- package/corpus/core/src/cli/mcp-config-writers.ts +187 -51
- package/corpus/core/src/cli/plan-local.ts +445 -108
- package/corpus/core/src/cli/skills.ts +32 -8
- package/corpus/core/src/client/AssistantChat.tsx +11 -1
- package/corpus/core/src/client/agent-chat.ts +12 -1
- package/corpus/core/src/client/composer/PromptComposer.tsx +100 -41
- package/corpus/core/src/client/org/OrgSwitcher.tsx +1 -1
- package/corpus/core/src/client/sharing/ShareButton.tsx +3 -27
- package/corpus/core/src/collab/presence.ts +1 -1
- package/corpus/core/src/mcp/connect-route.ts +34 -5
- package/corpus/core/src/server/action-discovery.ts +4 -0
- package/corpus/core/src/server/action-routes.ts +14 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +20 -0
- package/corpus/core/src/vite/client.ts +15 -1
- package/corpus/templates/analytics/actions/dashboard-mutation-api.ts +2 -0
- package/corpus/templates/analytics/actions/update-dashboard.ts +8 -0
- package/corpus/templates/analytics/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +117 -33
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +4 -0
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/types.ts +7 -0
- package/corpus/templates/analytics/changelog/2026-06-27-dashboards-can-now-nest-under-a-parent-in-the-sidebar-via-a-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-06-29-analytics-pages-now-sit-closer-under-the-header-with-tighter.md +6 -0
- package/corpus/templates/assets/actions/generate-image-batch.ts +3 -0
- package/corpus/templates/assets/actions/generate-image.ts +3 -0
- package/corpus/templates/assets/changelog/2026-06-29-longer-agent-generation-window.md +6 -0
- package/corpus/templates/assets/netlify.toml +3 -3
- package/corpus/templates/assets/server/plugins/agent-chat.ts +4 -1
- package/corpus/templates/clips/app/components/capture-install-options.tsx +7 -8
- package/corpus/templates/clips/app/components/player/timestamped-comment-button.tsx +162 -0
- package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +1 -1
- package/corpus/templates/clips/app/i18n/ar-SA.ts +4 -0
- package/corpus/templates/clips/app/i18n/de-DE.ts +4 -0
- package/corpus/templates/clips/app/i18n/en-US.ts +4 -0
- package/corpus/templates/clips/app/i18n/es-ES.ts +4 -0
- package/corpus/templates/clips/app/i18n/fr-FR.ts +4 -0
- package/corpus/templates/clips/app/i18n/hi-IN.ts +4 -0
- package/corpus/templates/clips/app/i18n/ja-JP.ts +4 -0
- package/corpus/templates/clips/app/i18n/ko-KR.ts +4 -0
- package/corpus/templates/clips/app/i18n/pt-BR.ts +4 -0
- package/corpus/templates/clips/app/i18n/zh-CN.ts +4 -0
- package/corpus/templates/clips/app/i18n/zh-TW.ts +4 -0
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +42 -18
- package/corpus/templates/content/AGENTS.md +12 -0
- package/corpus/templates/content/app/blocks/BuilderDocsBlocks.tsx +10 -0
- package/corpus/templates/content/app/components/editor/BubbleToolbar.tsx +1 -0
- package/corpus/templates/content/app/components/editor/ContentReferencePreview.tsx +185 -0
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +3 -0
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +19 -0
- package/corpus/templates/content/app/components/editor/extensions/ContentReferenceNode.tsx +82 -0
- package/corpus/templates/content/app/global.css +9 -0
- package/corpus/templates/content/app/i18n/zh-TW.ts +12 -0
- package/corpus/templates/content/app/i18n-data.ts +140 -0
- package/corpus/templates/content/changelog/2026-06-29-reusable-mdx-references-now-preview-linked-local-documents-i.md +6 -0
- package/corpus/templates/content/shared/builder-docs-blocks.ts +8 -0
- package/corpus/templates/content/shared/builder-mdx.ts +141 -4
- package/corpus/templates/content/shared/nfm.ts +62 -0
- package/corpus/templates/design/.agents/skills/design-systems/SKILL.md +10 -11
- package/corpus/templates/design/AGENTS.md +5 -0
- package/corpus/templates/design/_gitignore +7 -0
- package/corpus/templates/design/actions/apply-visual-edit.ts +22 -12
- package/corpus/templates/design/actions/create-design-system.ts +15 -4
- package/corpus/templates/design/actions/create-file.ts +20 -1
- package/corpus/templates/design/actions/delete-design-system.ts +2 -2
- package/corpus/templates/design/actions/duplicate-design.ts +35 -9
- package/corpus/templates/design/actions/generate-design.ts +146 -69
- package/corpus/templates/design/actions/generate-screens.ts +51 -19
- package/corpus/templates/design/actions/get-design-snapshot.ts +5 -1
- package/corpus/templates/design/actions/get-design.ts +2 -0
- package/corpus/templates/design/actions/import-design-project.ts +28 -9
- package/corpus/templates/design/actions/import-document.ts +22 -8
- package/corpus/templates/design/actions/index-design-system-with-builder.ts +6 -153
- package/corpus/templates/design/actions/navigate.ts +105 -54
- package/corpus/templates/design/actions/set-default-design-system.ts +17 -3
- package/corpus/templates/design/actions/show-design-questions.ts +2 -0
- package/corpus/templates/design/actions/update-design.ts +2 -1
- package/corpus/templates/design/actions/view-screen.ts +12 -6
- package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +4 -4
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +159 -41
- package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +8 -4
- package/corpus/templates/design/app/components/design/DrawOverlay.tsx +37 -42
- package/corpus/templates/design/app/components/design/EditPanel.tsx +336 -183
- package/corpus/templates/design/app/components/design/LayersPanel.tsx +153 -34
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +135 -33
- package/corpus/templates/design/app/components/design/QuestionFlow.tsx +6 -0
- package/corpus/templates/design/app/components/design/TweaksPanel.tsx +2 -1
- package/corpus/templates/design/app/components/design/inspector/AlignmentMatrix.tsx +4 -10
- package/corpus/templates/design/app/components/design/inspector/AutoLayoutMatrix.tsx +84 -43
- package/corpus/templates/design/app/components/design/inspector/ConstraintsWidget.tsx +4 -4
- package/corpus/templates/design/app/components/design/inspector/{FigmaColorPicker.tsx → DesignColorPicker.tsx} +89 -62
- package/corpus/templates/design/app/components/design/inspector/ExportSettingsPanel.tsx +14 -26
- package/corpus/templates/design/app/components/design/inspector/GradientEditor.tsx +40 -12
- package/corpus/templates/design/app/components/design/inspector/ImageFillControls.tsx +13 -4
- package/corpus/templates/design/app/components/design/inspector/SHADER_INTEGRATION.md +13 -13
- package/corpus/templates/design/app/components/design/inspector/ScrubInput.tsx +13 -9
- package/corpus/templates/design/app/components/design/inspector/ShaderControls.tsx +13 -4
- package/corpus/templates/design/app/components/design/inspector/ShaderFillsPanel.tsx +6 -6
- package/corpus/templates/design/app/components/design/inspector/{figma-icons.tsx → design-icons.tsx} +2 -2
- package/corpus/templates/design/app/components/design/inspector/index.ts +12 -12
- package/corpus/templates/design/app/components/design/inspector/scrub-input-utils.ts +5 -2
- package/corpus/templates/design/app/components/editor/PromptDialog.tsx +3 -3
- package/corpus/templates/design/app/components/layout/Layout.tsx +5 -2
- package/corpus/templates/design/app/components/layout/Sidebar.tsx +1 -1
- package/corpus/templates/design/app/components/visual-editor/CanvasCommentPins.tsx +167 -91
- package/corpus/templates/design/app/components/visual-editor/DrawOverlay.tsx +16 -3
- package/corpus/templates/design/app/components/visual-editor/SaveStatusIndicator.tsx +15 -0
- package/corpus/templates/design/app/global.css +4 -0
- package/corpus/templates/design/app/hooks/use-design-system.ts +4 -1
- package/corpus/templates/design/app/hooks/use-navigation-state.ts +38 -3
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +9 -2
- package/corpus/templates/design/app/i18n/zh-TW.ts +22 -0
- package/corpus/templates/design/app/i18n-data.ts +527 -0
- package/corpus/templates/design/app/lib/design-systems.ts +6 -4
- package/corpus/templates/design/app/lib/design-templates.ts +15 -3
- package/corpus/templates/design/app/pages/DesignEditor.tsx +641 -158
- package/corpus/templates/design/app/pages/DesignSystemSetup.tsx +42 -34
- package/corpus/templates/design/app/pages/VisualEdit.tsx +100 -0
- package/corpus/templates/design/app/root.tsx +42 -9
- package/corpus/templates/design/app/routes/visual-edit.tsx +7 -0
- package/corpus/templates/design/changelog/2026-06-28-live-cursors-now-keep-names-beside-a-cleaner-pointer-marker.md +1 -1
- package/corpus/templates/design/changelog/2026-06-28-mode-switching-now-lives-in-a-compact-bottom-right-icon-dock.md +1 -1
- package/corpus/templates/design/changelog/2026-06-28-visual-code-design-mode.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-generation-prompts-now-show-connect-ai-before-sending.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-mode-top-chrome-now-groups-collaborators-preview-shar.md +1 -1
- package/corpus/templates/design/changelog/2026-06-29-fixed-design-editor-exports-and-gradient-edits-so-multi-scre.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-longer-hosted-agent-turns.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-png-export-handles-modern-css-color-functions-more-reliably.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-png-export-now-ignores-duplicate-clicks-while-a-download-is-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-public-visual-edit-and-shared-design-links-now-invite-visito.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-visual-edit-actions-now-reject-missing-design-targets-before.md +6 -0
- package/corpus/templates/design/e2e/README.md +71 -0
- package/corpus/templates/design/e2e/global-setup.ts +157 -0
- package/corpus/templates/design/e2e/helpers.ts +148 -0
- package/corpus/templates/design/netlify.toml +3 -4
- package/corpus/templates/design/package.json +5 -1
- package/corpus/templates/design/playwright.config.ts +51 -0
- package/corpus/templates/design/server/handlers/index-design-system-with-builder.ts +121 -0
- package/corpus/templates/design/server/handlers/uploads.ts +89 -38
- package/corpus/templates/design/server/lib/builder-design-system-proxy.ts +181 -0
- package/corpus/templates/design/server/lib/coding-handoff.ts +33 -4
- package/corpus/templates/design/server/lib/design-export.ts +35 -8
- package/corpus/templates/design/server/plugins/agent-chat.ts +4 -0
- package/corpus/templates/design/server/plugins/auth.ts +10 -1
- package/corpus/templates/design/server/routes/api/index-design-system-with-builder.post.ts +1 -0
- package/corpus/templates/design/shared/api.ts +2 -0
- package/corpus/templates/design/shared/apply-edits.ts +12 -8
- package/corpus/templates/design/shared/canvas-math.ts +19 -1
- package/corpus/templates/design/shared/code-layer.ts +87 -28
- package/corpus/templates/design/shared/generation-session.ts +1 -0
- package/corpus/templates/design/shared/resolve-tweaks.ts +4 -3
- package/corpus/templates/design/shared/shader-presets.ts +10 -0
- package/corpus/templates/design/shared/source-mode.ts +9 -0
- package/corpus/templates/design/vitest.config.ts +2 -1
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +1 -1
- package/corpus/templates/plan/.agents/skills/visual-plan/references/canvas.md +1 -1
- package/corpus/templates/plan/.agents/skills/visual-plan/references/local-files.md +14 -5
- package/corpus/templates/plan/.agents/skills/visual-recap/references/local-files.md +14 -5
- package/corpus/templates/plan/AGENTS.md +1 -1
- package/corpus/templates/plan/actions/create-plan-design.ts +1 -1
- package/corpus/templates/plan/actions/validate-local-plan-source.ts +110 -0
- package/corpus/templates/plan/app/pages/PlansPage.tsx +1 -0
- package/corpus/templates/plan/docs/commenting-ux-plan.md +2 -2
- package/corpus/templates/plan/server/lib/plan-connector-catalog.ts +1 -0
- package/corpus/templates/plan/server/lib/public-action-paths.ts +1 -0
- package/corpus/templates/plan/server/plan-content.ts +1 -1
- package/corpus/templates/plan/server/ui-plan-html.ts +2 -2
- package/corpus/templates/slides/actions/index-design-system-with-builder.ts +6 -153
- package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +53 -38
- package/corpus/templates/slides/app/components/design-system/{fig-import-response.ts → builder-index-response.ts} +9 -6
- package/corpus/templates/slides/app/components/visual-editor/MultiSelectChip.tsx +1 -1
- package/corpus/templates/slides/changelog/2026-06-29-design-system-setup-now-indexes-uploaded-design-files-throug.md +6 -0
- package/corpus/templates/slides/changelog/2026-06-29-longer-hosted-agent-turns.md +6 -0
- package/corpus/templates/slides/netlify.toml +3 -6
- package/corpus/templates/slides/server/handlers/index-design-system-with-builder.ts +116 -0
- package/corpus/templates/slides/server/lib/builder-design-system-proxy.ts +179 -0
- package/corpus/templates/slides/server/plugins/agent-chat.ts +4 -1
- package/corpus/templates/slides/server/routes/api/index-design-system-with-builder.post.ts +1 -0
- package/dist/action.d.ts +23 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +9 -0
- package/dist/action.js.map +1 -1
- package/dist/agent/durable-background.d.ts +9 -7
- package/dist/agent/durable-background.d.ts.map +1 -1
- package/dist/agent/durable-background.js +27 -11
- package/dist/agent/durable-background.js.map +1 -1
- package/dist/agent/production-agent.d.ts +10 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +4 -1
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-loop-with-resume.d.ts +2 -1
- package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
- package/dist/agent/run-loop-with-resume.js +2 -2
- package/dist/agent/run-loop-with-resume.js.map +1 -1
- package/dist/brand-kit/fig/index.d.ts +4 -4
- package/dist/brand-kit/fig/index.d.ts.map +1 -1
- package/dist/brand-kit/fig/index.js +14 -27
- package/dist/brand-kit/fig/index.js.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/mcp-config-writers.d.ts +15 -7
- package/dist/cli/mcp-config-writers.d.ts.map +1 -1
- package/dist/cli/mcp-config-writers.js +198 -45
- package/dist/cli/mcp-config-writers.js.map +1 -1
- package/dist/cli/plan-local.d.ts +30 -0
- package/dist/cli/plan-local.d.ts.map +1 -1
- package/dist/cli/plan-local.js +281 -56
- package/dist/cli/plan-local.js.map +1 -1
- package/dist/cli/skills.d.ts +2 -2
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +32 -8
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +11 -1
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/agent-chat.d.ts.map +1 -1
- package/dist/client/agent-chat.js +15 -2
- package/dist/client/agent-chat.js.map +1 -1
- package/dist/client/composer/PromptComposer.d.ts.map +1 -1
- package/dist/client/composer/PromptComposer.js +35 -1
- package/dist/client/composer/PromptComposer.js.map +1 -1
- package/dist/client/org/OrgSwitcher.js +1 -1
- package/dist/client/org/OrgSwitcher.js.map +1 -1
- package/dist/client/sharing/ShareButton.d.ts +1 -1
- package/dist/client/sharing/ShareButton.d.ts.map +1 -1
- package/dist/client/sharing/ShareButton.js +2 -15
- package/dist/client/sharing/ShareButton.js.map +1 -1
- package/dist/collab/presence.d.ts +1 -1
- package/dist/collab/presence.js +1 -1
- package/dist/collab/presence.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +2 -2
- package/dist/mcp/connect-route.d.ts.map +1 -1
- package/dist/mcp/connect-route.js +34 -5
- package/dist/mcp/connect-route.js.map +1 -1
- package/dist/observability/routes.d.ts +2 -2
- package/dist/progress/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +5 -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 +14 -0
- package/dist/server/action-routes.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +6 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +12 -3
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +12 -1
- package/dist/vite/client.js.map +1 -1
- package/docs/content/locales/ar-SA/real-time-collaboration.mdx +2 -2
- package/docs/content/locales/ar-SA/template-design.mdx +1 -1
- package/docs/content/locales/de-DE/real-time-collaboration.mdx +3 -3
- package/docs/content/locales/de-DE/template-design.mdx +1 -1
- package/docs/content/locales/es-ES/real-time-collaboration.mdx +2 -2
- package/docs/content/locales/es-ES/template-design.mdx +1 -1
- package/docs/content/locales/fr-FR/real-time-collaboration.mdx +2 -2
- package/docs/content/locales/fr-FR/template-design.mdx +1 -1
- package/docs/content/locales/hi-IN/template-design.mdx +1 -1
- package/docs/content/locales/ja-JP/real-time-collaboration.mdx +2 -2
- package/docs/content/locales/ja-JP/template-design.mdx +1 -1
- package/docs/content/locales/ko-KR/real-time-collaboration.mdx +2 -2
- package/docs/content/locales/ko-KR/template-design.mdx +1 -1
- package/docs/content/locales/pt-BR/real-time-collaboration.mdx +2 -2
- package/docs/content/locales/pt-BR/template-design.mdx +1 -1
- package/docs/content/locales/zh-CN/real-time-collaboration.mdx +2 -2
- package/docs/content/locales/zh-CN/template-design.mdx +1 -1
- package/docs/content/locales/zh-TW/real-time-collaboration.mdx +2 -2
- package/docs/content/locales/zh-TW/template-design.mdx +1 -1
- package/docs/content/real-time-collaboration.mdx +2 -2
- package/docs/content/template-design.mdx +1 -1
- package/package.json +3 -7
- package/corpus/core/src/brand-kit/fig/decode.ts +0 -410
- package/corpus/core/src/brand-kit/fig/extract-design-system.ts +0 -947
- package/corpus/core/src/brand-kit/fig/fig-to-html.ts +0 -1906
- package/corpus/templates/design/actions/import-figma.ts +0 -55
- package/corpus/templates/design/changelog/2026-06-28-figma-style-code-design-mode.md +0 -6
- package/corpus/templates/design/server/handlers/import-figma-system.ts +0 -86
- package/corpus/templates/design/server/routes/api/import-figma-system.post.ts +0 -1
- package/corpus/templates/slides/server/handlers/import-figma-system.ts +0 -101
- package/corpus/templates/slides/server/routes/api/import-figma-system.post.ts +0 -1
- package/dist/brand-kit/fig/decode.d.ts +0 -33
- package/dist/brand-kit/fig/decode.d.ts.map +0 -1
- package/dist/brand-kit/fig/decode.js +0 -358
- package/dist/brand-kit/fig/decode.js.map +0 -1
- package/dist/brand-kit/fig/extract-design-system.d.ts +0 -44
- package/dist/brand-kit/fig/extract-design-system.d.ts.map +0 -1
- package/dist/brand-kit/fig/extract-design-system.js +0 -752
- package/dist/brand-kit/fig/extract-design-system.js.map +0 -1
- package/dist/brand-kit/fig/fig-to-html.d.ts +0 -246
- package/dist/brand-kit/fig/fig-to-html.d.ts.map +0 -1
- package/dist/brand-kit/fig/fig-to-html.js +0 -1506
- package/dist/brand-kit/fig/fig-to-html.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-chat.d.ts","sourceRoot":"","sources":["../../src/client/agent-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAmBrE,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,MAAM,CAAC;AAElD,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,yCAAyC;IACzC,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC1B,kFAAkF;IAClF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,6FAA6F;IAC7F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;OAGG;IACH,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,sCAAsC;IACtC,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,wDA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;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,kEAAkE;IAClE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,6FAA6F;AAC7F,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,YAAY,GAClB,gBAAgB,GAAG,IAAI,CAoCzB;AAgCD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAgG9D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,0BAA0B,GAC/B,IAAI,CAUN;AAED,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,gCAA0B,CAAC;AAE7D,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,gCAA0B,CAAC;AAE7D,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,sBAAsB,EAC3B,OAAO,GAAE,mCAAwC,GAChD,IAAI,CAYN;AAED,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,MAAM,GAAG,6BAA6B,GAChD,IAAI,CAeN;AAED,wBAAgB,qBAAqB,CACnC,IAAI,GAAE,+BAAoC,GACzC,IAAI,CAQN;AAED,wBAAgB,8BAA8B,IAAI,IAAI,CAGrD"}
|
|
@@ -26,6 +26,7 @@ let agentChatContextState = {
|
|
|
26
26
|
updatedAt: 0,
|
|
27
27
|
};
|
|
28
28
|
const agentChatContextListeners = new Set();
|
|
29
|
+
let agentChatContextNotifyQueued = false;
|
|
29
30
|
/**
|
|
30
31
|
* Listen for chatRunning messages from the frame (postMessage)
|
|
31
32
|
* and re-dispatch as a CustomEvent so hooks like useAgentChatGenerating() work.
|
|
@@ -143,8 +144,20 @@ function withReplacedAgentChatContextItem(items, item) {
|
|
|
143
144
|
return items.map((current, currentIndex) => currentIndex === index ? item : current);
|
|
144
145
|
}
|
|
145
146
|
function notifyAgentChatContextListeners() {
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
if (agentChatContextNotifyQueued)
|
|
148
|
+
return;
|
|
149
|
+
agentChatContextNotifyQueued = true;
|
|
150
|
+
const notify = () => {
|
|
151
|
+
agentChatContextNotifyQueued = false;
|
|
152
|
+
for (const listener of Array.from(agentChatContextListeners))
|
|
153
|
+
listener();
|
|
154
|
+
};
|
|
155
|
+
if (typeof queueMicrotask === "function") {
|
|
156
|
+
queueMicrotask(notify);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
setTimeout(notify, 0);
|
|
160
|
+
}
|
|
148
161
|
}
|
|
149
162
|
function persistAgentChatContextState(state) {
|
|
150
163
|
if (typeof window === "undefined" || typeof fetch !== "function")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-chat.js","sourceRoot":"","sources":["../../src/client/agent-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,4BAA4B,EAC5B,iCAAiC,GAClC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AA+I1D,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AACzD,MAAM,4BAA4B,GAAG,oBAAoB,CAAC;AAC1D,MAAM,wBAAwB,GAAG,wBAAwB,CAAC;AAC1D,MAAM,CAAC,MAAM,gCAAgC,GAC3C,gCAAgC,CAAC;AACnC,MAAM,CAAC,MAAM,mCAAmC,GAAG,4BAA4B,CAA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actions.\n * Messages are sent via postMessage to the parent window (or self if top-level).\n * Builder frames are special: code requests go to Builder, but content prompts\n * stay inside the embedded app so its own AgentSidebar can receive them.\n */\n\nimport type { ReasoningEffort } from \"../shared/reasoning-effort.js\";\nimport { agentNativePath } from \"./api-path.js\";\nimport {\n isInBuilderFrame,\n isTrustedBuilderMessage,\n sendToBuilderChat,\n} from \"./builder-frame.js\";\nimport {\n isEmbedAuthActive,\n isEmbedMcpChatBridgeActive,\n markEmbedMcpChatBridgeActive,\n readEmbedMcpChatBridgeFlagFromUrl,\n} from \"./embed-auth.js\";\nimport {\n getFramePostMessageTargetOrigin,\n isTrustedFrameMessage,\n} from \"./frame.js\";\nimport { sendMcpAppHostMessage } from \"./mcp-app-host.js\";\n\nexport type AgentChatRequestMode = \"act\" | \"plan\";\n\nexport interface AgentChatMessage {\n /** The visible prompt message sent to the chat */\n message: string;\n /** Hidden context appended to the message (not shown in chat UI) */\n context?: string;\n /** true = auto-submit, false = prefill only, omit = use project setting */\n submit?: boolean;\n /** Optional project slug for structured context */\n projectSlug?: string;\n /** Optional preset name for downstream consumers */\n preset?: string;\n /** Optional reference image paths */\n referenceImagePaths?: string[];\n /** Optional uploaded reference images */\n uploadedReferenceImages?: string[];\n /** Optional image data URLs to include in the submitted chat message */\n images?: string[];\n /** Stable tab identifier — auto-generated if omitted */\n tabId?: string;\n /**\n * Message routing type:\n * - \"content\" (default): stays in the embedded app agent for content/data operations\n * - \"code\": routes to the code editing frame (Agent Native Desktop or Builder.io)\n *\n * When type is \"code\" and no frame is connected, a dialog is shown.\n * `requiresCode: true` is treated as `type: \"code\"` for backward compatibility.\n */\n type?: \"content\" | \"code\";\n /** @deprecated Use `type: \"code\"` instead. If true, treated as `type: \"code\"`. */\n requiresCode?: boolean;\n /** Model preference for this sub-agent (e.g. \"claude-haiku-4-5\"). Uses default if omitted */\n model?: string;\n /** Engine preference paired with model for cross-provider switches. */\n engine?: string;\n /** Reasoning effort preference paired with model. */\n effort?: ReasoningEffort;\n /**\n * Execution mode for this submitted turn. When omitted, sendToAgentChat\n * snapshots the current AgentPanel mode from localStorage when available.\n */\n mode?: AgentChatRequestMode;\n /** @deprecated Use `mode` instead. */\n requestMode?: AgentChatRequestMode;\n /** Scoped system prompt additions for this sub-agent */\n instructions?: string;\n /**\n * Message delivery target. Auto-submitted MCP App messages normally relay to\n * the host chat; use \"local\" when a control explicitly targets this app's\n * own AgentSidebar.\n */\n chatTarget?: \"auto\" | \"local\";\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true — submitting a chat should make the response visible.\n * Pass `false` for background/silent sends that shouldn't pop the UI open.\n */\n openSidebar?: boolean;\n /**\n * When true, opens a new chat tab before sending the message.\n * Use for creation requests (create tool, dashboard, etc.) that deserve\n * their own isolated thread rather than cluttering an existing conversation.\n */\n newTab?: boolean;\n /**\n * When true with newTab, creates the tab in the background without\n * focusing it or opening the sidebar. The message runs silently.\n */\n background?: boolean;\n}\n\nexport interface AgentChatContextItem {\n /** Stable key used to replace an existing context nugget. */\n key: string;\n /** Short label shown in the composer context chip. */\n title: string;\n /** Hidden context included with the next submitted prompt. */\n context: string;\n}\n\nexport interface AgentChatContextSetOptions extends AgentChatContextItem {\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true so the user can see the staged context.\n */\n openSidebar?: boolean;\n}\n\n/** @deprecated Use `AgentChatContextSetOptions` instead. */\nexport type AgentChatContextMessage = AgentChatContextSetOptions;\n\nexport interface AgentChatContextState {\n items: AgentChatContextItem[];\n updatedAt: number;\n}\n\nexport interface AgentComposerReference {\n label: string;\n icon?: string;\n source?: string;\n refType: string;\n refId?: string | null;\n refPath?: string | null;\n /** Stable composer slot this reference occupies. Slot references replace older values. */\n slotKey?: string;\n /** Short label shown before the selected value in the composer chip. */\n slotLabel?: string;\n /** Additional app-defined data used by the client for filtering and grouping. */\n metadata?: Record<string, unknown>;\n /** Slots to remove when this reference is inserted or removed. */\n clearsSlots?: string[];\n /** Additional references to insert before this one. */\n relatedReferences?: AgentComposerReference[];\n}\n\nexport interface AgentComposerReferenceInsertOptions {\n /**\n * Whether to open the agent sidebar before inserting the reference.\n * Defaults to false so contextual auto-tags can stay quiet.\n */\n openSidebar?: boolean;\n}\n\nexport interface AgentComposerReferenceInsertPayload extends AgentComposerReference {\n insertMessageId: string;\n}\n\nexport interface AgentChatContextMutationOptions {\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true for set/add and false for remove/clear.\n */\n openSidebar?: boolean;\n}\n\nexport interface AgentChatContextRemoveOptions extends AgentChatContextMutationOptions {\n /** Stable key of the staged context nugget to remove. */\n key: string;\n}\n\nconst AGENT_CHAT_MESSAGE_TYPE = \"agentNative.submitChat\";\nconst AGENT_CHAT_CONTEXT_STATE_KEY = \"agent-chat-context\";\nconst AGENT_CHAT_EXEC_MODE_KEY = \"agent-native-exec-mode\";\nexport const AGENT_CHAT_CONTEXT_CHANGED_EVENT =\n \"agentNative.chatContextChanged\";\nexport const AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE = \"agentNative.setChatContext\";\nexport const AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE =\n \"agentNative.removeChatContext\";\nexport const AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE =\n \"agentNative.clearChatContext\";\nexport const AGENT_CHAT_INSERT_REFERENCE_MESSAGE_TYPE =\n \"agentNative.insertComposerReference\";\nexport const AGENT_CHAT_INSERT_REFERENCE_EVENT =\n \"agentNative:insert-composer-reference\";\nconst AGENT_PANEL_PREPARE_EVENT = \"agent-panel:prepare\";\n\nlet agentChatContextState: AgentChatContextState = {\n items: [],\n updatedAt: 0,\n};\nconst agentChatContextListeners = new Set<() => void>();\n\n/**\n * Listen for chatRunning messages from the frame (postMessage)\n * and re-dispatch as a CustomEvent so hooks like useAgentChatGenerating() work.\n */\nif (typeof window !== \"undefined\") {\n window.addEventListener(\"message\", (event) => {\n if (!isTrustedFrameMessage(event) && !isTrustedBuilderMessage(event)) {\n return;\n }\n if (\n event.data?.type === \"agentNative.chatRunning\" ||\n event.data?.type === \"builder.chatRunning\"\n ) {\n window.dispatchEvent(\n new CustomEvent(\"agentNative.chatRunning\", {\n detail: event.data.detail ?? event.data.data,\n }),\n );\n }\n });\n}\n\n/** Generate a unique tab ID */\nexport function generateTabId(): string {\n return `chat-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\n/** Unique id for one submitted message, used to dedup live + replayed sends. */\nfunction generateSubmitMessageId(): string {\n return `submit-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\n// Self-submit buffer: same-window sends post to `window` itself, but the\n// receiver is lazy-loaded and may not be listening yet. Buffer each submit so\n// the panel can replay it on mount; claimAgentChatSubmit dedups by id so a\n// submit received both live and replayed is delivered exactly once.\ninterface BufferedSelfSubmit {\n id: string;\n data: Record<string, unknown>;\n at: number;\n}\n\nconst SELF_SUBMIT_BUFFER_TTL_MS = 8000;\nconst bufferedSelfSubmits: BufferedSelfSubmit[] = [];\nconst claimedSubmitIds = new Set<string>();\n\nfunction pruneSelfSubmitBuffer(now: number): void {\n for (let i = bufferedSelfSubmits.length - 1; i >= 0; i -= 1) {\n if (now - bufferedSelfSubmits[i].at > SELF_SUBMIT_BUFFER_TTL_MS) {\n const [removed] = bufferedSelfSubmits.splice(i, 1);\n if (removed) claimedSubmitIds.delete(removed.id);\n }\n }\n}\n\nfunction bufferSelfSubmit(data: Record<string, unknown>): void {\n const id =\n typeof data.submitMessageId === \"string\" ? data.submitMessageId : undefined;\n if (!id) return;\n const now = Date.now();\n pruneSelfSubmitBuffer(now);\n bufferedSelfSubmits.push({ id, data, at: now });\n}\n\n/** Unclaimed self-submit payloads, for the panel to replay once it mounts. */\nexport function drainBufferedAgentChatSubmits(): Array<\n Record<string, unknown>\n> {\n pruneSelfSubmitBuffer(Date.now());\n return bufferedSelfSubmits\n .filter((entry) => !claimedSubmitIds.has(entry.id))\n .map((entry) => entry.data);\n}\n\n/** Claim a submit; false if already handled. Idless submits always pass. */\nexport function claimAgentChatSubmit(id: string | undefined): boolean {\n if (!id) return true;\n if (claimedSubmitIds.has(id)) return false;\n claimedSubmitIds.add(id);\n return true;\n}\n\n/** Test-only: reset the self-submit buffer and claim set. */\nexport function _resetAgentChatSubmitBufferForTests(): void {\n bufferedSelfSubmits.length = 0;\n claimedSubmitIds.clear();\n}\n\nexport function normalizeAgentChatContextItem(\n item: unknown,\n): AgentChatContextItem | null {\n if (typeof item !== \"object\" || item === null) return null;\n const candidate = item as Partial<AgentChatContextItem>;\n if (\n typeof candidate.key !== \"string\" ||\n typeof candidate.context !== \"string\" ||\n typeof candidate.title !== \"string\"\n ) {\n return null;\n }\n const key = candidate.key.trim();\n const context = candidate.context.trim();\n if (!key || !context) return null;\n return {\n key,\n title: candidate.title.trim() || key,\n context,\n };\n}\n\nexport function normalizeAgentChatContextItems(\n items: unknown,\n): AgentChatContextItem[] {\n if (!Array.isArray(items)) return [];\n const deduped = new Map<string, AgentChatContextItem>();\n for (const rawItem of items) {\n const item = normalizeAgentChatContextItem(rawItem);\n if (!item) continue;\n deduped.set(item.key, item);\n }\n return [...deduped.values()];\n}\n\nfunction normalizeAgentChatContextState(\n value: unknown,\n): AgentChatContextState | null {\n if (!value || typeof value !== \"object\") return null;\n const raw = value as {\n value?: unknown;\n items?: unknown;\n updatedAt?: unknown;\n };\n const candidate =\n raw.value && typeof raw.value === \"object\"\n ? (raw.value as { items?: unknown; updatedAt?: unknown })\n : raw;\n const items = normalizeAgentChatContextItems(candidate.items);\n return {\n items,\n updatedAt:\n typeof candidate.updatedAt === \"number\" ? candidate.updatedAt : 0,\n };\n}\n\nfunction withReplacedAgentChatContextItem(\n items: readonly AgentChatContextItem[],\n item: AgentChatContextItem,\n): AgentChatContextItem[] {\n const index = items.findIndex((current) => current.key === item.key);\n if (index === -1) return [...items, item];\n return items.map((current, currentIndex) =>\n currentIndex === index ? item : current,\n );\n}\n\nfunction notifyAgentChatContextListeners(): void {\n for (const listener of agentChatContextListeners) listener();\n}\n\nfunction persistAgentChatContextState(state: AgentChatContextState): void {\n if (typeof window === \"undefined\" || typeof fetch !== \"function\") return;\n fetch(\n agentNativePath(\n `/_agent-native/application-state/${AGENT_CHAT_CONTEXT_STATE_KEY}`,\n ),\n {\n method: \"PUT\",\n keepalive: true,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(state),\n },\n ).catch(() => {});\n}\n\nexport function publishAgentChatContextItems(\n items: readonly AgentChatContextItem[],\n options?: { persist?: boolean; updatedAt?: number },\n): AgentChatContextState {\n const next: AgentChatContextState = {\n items: normalizeAgentChatContextItems([...items]),\n updatedAt: options?.updatedAt ?? Date.now(),\n };\n if (next.updatedAt < agentChatContextState.updatedAt) {\n return agentChatContextState;\n }\n agentChatContextState = next;\n notifyAgentChatContextListeners();\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(AGENT_CHAT_CONTEXT_CHANGED_EVENT, {\n detail: next,\n }),\n );\n }\n if (options?.persist !== false) {\n persistAgentChatContextState(next);\n }\n return next;\n}\n\nexport function getAgentChatContextState(): AgentChatContextState {\n return agentChatContextState;\n}\n\nexport function listAgentChatContext(): AgentChatContextItem[] {\n return [...agentChatContextState.items];\n}\n\nexport function subscribeAgentChatContext(listener: () => void): () => void {\n agentChatContextListeners.add(listener);\n return () => {\n agentChatContextListeners.delete(listener);\n };\n}\n\nexport async function refreshAgentChatContext(): Promise<AgentChatContextState> {\n if (typeof window === \"undefined\" || typeof fetch !== \"function\") {\n return agentChatContextState;\n }\n try {\n const res = await fetch(\n agentNativePath(\n `/_agent-native/application-state/${AGENT_CHAT_CONTEXT_STATE_KEY}`,\n ),\n );\n if (!res.ok || res.status === 204) return agentChatContextState;\n const text = await res.text();\n if (!text) return agentChatContextState;\n const state = normalizeAgentChatContextState(JSON.parse(text));\n if (!state) return agentChatContextState;\n return publishAgentChatContextItems(state.items, {\n persist: false,\n updatedAt: state.updatedAt,\n });\n } catch {\n return agentChatContextState;\n }\n}\n\nexport function formatAgentChatContextItemsForPrompt(\n items: readonly AgentChatContextItem[],\n): string {\n return items\n .map(normalizeAgentChatContextItem)\n .filter((item): item is AgentChatContextItem => item !== null)\n .map((item) => [`## ${item.title}`, item.context].join(\"\\n\"))\n .join(\"\\n\\n\");\n}\n\nexport function appendAgentChatContextToMessage(\n message: string,\n context: string,\n): string {\n const trimmedContext = context.trim();\n if (!trimmedContext) return message;\n return `${message.trim()}\\n\\n<context>\\n${trimmedContext}\\n</context>`;\n}\n\nfunction normalizeStringArray(value: unknown): string[] | undefined {\n if (!Array.isArray(value)) return undefined;\n const normalized = value\n .filter((item): item is string => typeof item === \"string\")\n .map((item) => item.trim())\n .filter(Boolean);\n return normalized.length > 0 ? normalized : undefined;\n}\n\nfunction normalizeMetadata(\n value: unknown,\n): Record<string, unknown> | undefined {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return undefined;\n }\n return value as Record<string, unknown>;\n}\n\nfunction normalizeAgentComposerReferenceInternal(\n value: unknown,\n depth: number,\n): AgentComposerReference | null {\n if (typeof value !== \"object\" || value === null) return null;\n const candidate = value as Partial<AgentComposerReference>;\n const label =\n typeof candidate.label === \"string\" ? candidate.label.trim() : \"\";\n const refType =\n typeof candidate.refType === \"string\" ? candidate.refType.trim() : \"\";\n if (!label || !refType) return null;\n const normalized: AgentComposerReference = {\n label,\n icon:\n typeof candidate.icon === \"string\" && candidate.icon.trim()\n ? candidate.icon.trim()\n : undefined,\n source:\n typeof candidate.source === \"string\" && candidate.source.trim()\n ? candidate.source.trim()\n : undefined,\n refType,\n refId:\n typeof candidate.refId === \"string\" && candidate.refId.trim()\n ? candidate.refId.trim()\n : null,\n refPath:\n typeof candidate.refPath === \"string\" && candidate.refPath.trim()\n ? candidate.refPath.trim()\n : null,\n };\n const slotKey =\n typeof candidate.slotKey === \"string\" ? candidate.slotKey.trim() : \"\";\n if (slotKey) normalized.slotKey = slotKey;\n const slotLabel =\n typeof candidate.slotLabel === \"string\" ? candidate.slotLabel.trim() : \"\";\n if (slotLabel) normalized.slotLabel = slotLabel;\n const metadata = normalizeMetadata(candidate.metadata);\n if (metadata) normalized.metadata = metadata;\n const clearsSlots = normalizeStringArray(candidate.clearsSlots);\n if (clearsSlots) normalized.clearsSlots = clearsSlots;\n if (depth < 3 && Array.isArray(candidate.relatedReferences)) {\n const relatedReferences = candidate.relatedReferences\n .map((item) => normalizeAgentComposerReferenceInternal(item, depth + 1))\n .filter((item): item is AgentComposerReference => item !== null);\n if (relatedReferences.length > 0) {\n normalized.relatedReferences = relatedReferences;\n }\n }\n return normalized;\n}\n\nexport function normalizeAgentComposerReference(\n value: unknown,\n): AgentComposerReference | null {\n return normalizeAgentComposerReferenceInternal(value, 0);\n}\n\nfunction postAgentChatContextMessage(\n type:\n | typeof AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE\n | typeof AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE\n | typeof AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE,\n data: unknown,\n options: { openSidebar: boolean },\n): void {\n if (typeof window === \"undefined\") return;\n\n const shouldForwardOpenSidebar =\n (type === AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE &&\n options.openSidebar === false) ||\n (type !== AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE &&\n options.openSidebar === true);\n const payloadData =\n shouldForwardOpenSidebar && typeof data === \"object\" && data !== null\n ? {\n ...(data as Record<string, unknown>),\n openSidebar: options.openSidebar,\n }\n : data;\n const payload = { type, data: payloadData };\n const targetSelf = isInBuilderFrame() || isDirectMcpAppEmbedSession();\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n\n if (options.openSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n const postToTarget = () => target.postMessage(payload, targetOrigin);\n if (target === window) {\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n}\n\nfunction postAgentChatReferenceMessage(\n payload: AgentComposerReferenceInsertPayload,\n options: { openSidebar: boolean },\n): void {\n if (typeof window === \"undefined\") return;\n\n const message = {\n type: AGENT_CHAT_INSERT_REFERENCE_MESSAGE_TYPE,\n data: payload,\n };\n const targetSelf = isInBuilderFrame() || isDirectMcpAppEmbedSession();\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n\n if (options.openSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n window.dispatchEvent(\n new CustomEvent(AGENT_CHAT_INSERT_REFERENCE_EVENT, {\n detail: payload,\n }),\n );\n\n const postToTarget = () => target.postMessage(message, targetOrigin);\n if (target === window) {\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n}\n\nfunction isMcpAppChatBridgeEnabled(): boolean {\n if (typeof window === \"undefined\" || window.parent === window) return false;\n if (readEmbedMcpChatBridgeFlagFromUrl()) markEmbedMcpChatBridgeActive();\n return isEmbedMcpChatBridgeActive() && isEmbedAuthActive();\n}\n\nfunction isDirectMcpAppEmbedSession(): boolean {\n if (typeof window === \"undefined\" || window.parent === window) return false;\n if (readEmbedMcpChatBridgeFlagFromUrl()) markEmbedMcpChatBridgeActive();\n return isEmbedAuthActive() && !isEmbedMcpChatBridgeActive();\n}\n\nfunction dispatchAgentChatRunning(isRunning: boolean): void {\n if (typeof window === \"undefined\") return;\n window.dispatchEvent(\n new CustomEvent(\"agentNative.chatRunning\", {\n detail: { isRunning },\n }),\n );\n}\n\nfunction normalizeAgentChatRequestMode(\n value: unknown,\n): AgentChatRequestMode | undefined {\n return value === \"act\" || value === \"plan\" ? value : undefined;\n}\n\n/** A normalized `agentNative.submitChat` payload — decode via {@link parseSubmitChatMessage}. */\nexport interface ParsedSubmitChat {\n /** Visible prompt text (non-empty). */\n message: string;\n context?: string;\n /** Submit (true) or prefill only (false); defaults to true. */\n submit: boolean;\n openSidebar?: boolean;\n model?: string;\n /** Raw effort hint; the receiver validates it against the model. */\n effort?: unknown;\n newTab?: boolean;\n background?: boolean;\n tabId?: string;\n images?: string[];\n /** Mode as sent; the receiver falls back to its exec mode when undefined. */\n requestMode?: AgentChatRequestMode;\n /** Id used to dedup the live post against a cold-start replay. */\n submitMessageId?: string;\n}\n\n/** Decode a `message` event into a submit payload, or null if it isn't one / has no text. */\nexport function parseSubmitChatMessage(\n event: MessageEvent,\n): ParsedSubmitChat | null {\n const envelope =\n event.data && typeof event.data === \"object\"\n ? (event.data as { type?: unknown; data?: unknown })\n : null;\n if (!envelope || envelope.type !== AGENT_CHAT_MESSAGE_TYPE) return null;\n const raw =\n envelope.data && typeof envelope.data === \"object\"\n ? (envelope.data as Record<string, unknown>)\n : null;\n if (!raw) return null;\n const message = typeof raw.message === \"string\" ? raw.message : \"\";\n if (!message) return null;\n const images = Array.isArray(raw.images)\n ? raw.images.filter(\n (image): image is string =>\n typeof image === \"string\" && image.length > 0,\n )\n : undefined;\n return {\n message,\n context: typeof raw.context === \"string\" ? raw.context : undefined,\n submit: raw.submit !== false,\n openSidebar:\n typeof raw.openSidebar === \"boolean\" ? raw.openSidebar : undefined,\n model: typeof raw.model === \"string\" ? raw.model : undefined,\n effort: raw.effort,\n newTab: typeof raw.newTab === \"boolean\" ? raw.newTab : undefined,\n background:\n typeof raw.background === \"boolean\" ? raw.background : undefined,\n tabId: typeof raw.tabId === \"string\" ? raw.tabId : undefined,\n images,\n requestMode: normalizeAgentChatRequestMode(raw.requestMode ?? raw.mode),\n submitMessageId:\n typeof raw.submitMessageId === \"string\" ? raw.submitMessageId : undefined,\n };\n}\n\nfunction normalizeStoredAgentChatExecMode(\n value: string | null,\n): AgentChatRequestMode | undefined {\n if (value === \"plan\") return \"plan\";\n if (value === \"build\" || value === \"act\") return \"act\";\n return undefined;\n}\n\nfunction readStoredAgentChatRequestMode(): AgentChatRequestMode | undefined {\n if (typeof window === \"undefined\") return undefined;\n try {\n const storage = window.localStorage;\n const saved = normalizeStoredAgentChatExecMode(\n storage.getItem(AGENT_CHAT_EXEC_MODE_KEY),\n );\n if (saved) return saved;\n const scopedModes: AgentChatRequestMode[] = [];\n for (let index = 0; index < storage.length; index += 1) {\n const key = storage.key(index);\n if (!key?.startsWith(`${AGENT_CHAT_EXEC_MODE_KEY}:`)) continue;\n const scopedSaved = normalizeStoredAgentChatExecMode(\n storage.getItem(key),\n );\n if (scopedSaved) scopedModes.push(scopedSaved);\n }\n if (scopedModes.length === 1) return scopedModes[0];\n } catch {}\n return undefined;\n}\n\n/**\n * Send a message to the agent chat via postMessage.\n * Returns the stable tabId for tracking this chat run.\n */\nexport function sendToAgentChat(opts: AgentChatMessage): string {\n const tabId = opts.tabId ?? generateTabId();\n const isCodeRequest = opts.type === \"code\" || opts.requiresCode === true;\n const localChatTarget = opts.chatTarget === \"local\";\n const requestMode =\n normalizeAgentChatRequestMode(opts.requestMode ?? opts.mode) ??\n readStoredAgentChatRequestMode();\n if (isCodeRequest && isInBuilderFrame()) {\n sendToBuilderChat({\n message: opts.message,\n context: opts.context,\n submit: opts.submit,\n ...(requestMode ? { mode: requestMode, requestMode } : {}),\n });\n return tabId;\n }\n\n const submitMessageId = generateSubmitMessageId();\n const payload = {\n type: AGENT_CHAT_MESSAGE_TYPE,\n data: {\n ...opts,\n tabId,\n submitMessageId,\n ...(requestMode ? { mode: requestMode, requestMode } : {}),\n },\n };\n\n if (\n opts.submit !== false &&\n !localChatTarget &&\n isMcpAppChatBridgeEnabled()\n ) {\n const directHostMessage = sendMcpAppHostMessage({\n message: opts.message,\n context: opts.context,\n ...(requestMode ? { mode: requestMode, requestMode } : {}),\n });\n if (directHostMessage) {\n void Promise.resolve(directHostMessage)\n .then((ok) => {\n if (!ok) {\n window.parent.postMessage(\n payload,\n getFramePostMessageTargetOrigin() || \"*\",\n );\n }\n })\n .finally(() => {\n dispatchAgentChatRunning(false);\n });\n return tabId;\n }\n window.parent.postMessage(\n payload,\n getFramePostMessageTargetOrigin() || \"*\",\n );\n return tabId;\n }\n\n const shouldOpenSidebar = opts.openSidebar !== false && !opts.background;\n\n const targetSelf =\n !isCodeRequest &&\n (localChatTarget || isInBuilderFrame() || isDirectMcpAppEmbedSession());\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n if (shouldOpenSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else if (!isCodeRequest) {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n const postToTarget = () => target.postMessage(payload, targetOrigin);\n\n // Same-window: defer one tick so a sidebar mounting now can attach its\n // listener, and buffer the submit so the lazy panel can replay it if it\n // mounts later. The live post and the replay dedup by submitMessageId.\n if (!isCodeRequest && target === window) {\n bufferSelfSubmit(payload.data);\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n return tabId;\n}\n\n/**\n * Add or replace a keyed context nugget in the active agent chat composer.\n * The context is not submitted until the user sends the prompt.\n */\nexport function setAgentChatContextItem(\n opts: AgentChatContextSetOptions,\n): void {\n const item = normalizeAgentChatContextItem(opts);\n if (!item || typeof window === \"undefined\") return;\n\n publishAgentChatContextItems(\n withReplacedAgentChatContextItem(agentChatContextState.items, item),\n );\n postAgentChatContextMessage(AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE, item, {\n openSidebar: opts.openSidebar !== false,\n });\n}\n\n/** @deprecated Use `setAgentChatContextItem` instead. */\nexport const setContextToAgentChat = setAgentChatContextItem;\n\n/** @deprecated Use `setAgentChatContextItem` instead. */\nexport const addContextToAgentChat = setAgentChatContextItem;\n\nexport function insertAgentComposerReference(\n ref: AgentComposerReference,\n options: AgentComposerReferenceInsertOptions = {},\n): void {\n const normalized = normalizeAgentComposerReference(ref);\n if (!normalized || typeof window === \"undefined\") return;\n postAgentChatReferenceMessage(\n {\n ...normalized,\n insertMessageId: `reference-${Date.now()}-${Math.random()\n .toString(36)\n .slice(2, 8)}`,\n },\n { openSidebar: options.openSidebar === true },\n );\n}\n\nexport function removeAgentChatContextItem(\n keyOrOpts: string | AgentChatContextRemoveOptions,\n): void {\n const key =\n typeof keyOrOpts === \"string\" ? keyOrOpts.trim() : keyOrOpts.key.trim();\n if (!key || typeof window === \"undefined\") return;\n const openSidebar =\n typeof keyOrOpts === \"string\" ? false : keyOrOpts.openSidebar === true;\n\n publishAgentChatContextItems(\n agentChatContextState.items.filter((item) => item.key !== key),\n );\n postAgentChatContextMessage(\n AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE,\n { key },\n { openSidebar },\n );\n}\n\nexport function clearAgentChatContext(\n opts: AgentChatContextMutationOptions = {},\n): void {\n if (typeof window === \"undefined\") return;\n publishAgentChatContextItems([]);\n postAgentChatContextMessage(\n AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE,\n {},\n { openSidebar: opts.openSidebar === true },\n );\n}\n\nexport function _resetAgentChatContextForTests(): void {\n agentChatContextState = { items: [], updatedAt: 0 };\n notifyAgentChatContextListeners();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agent-chat.js","sourceRoot":"","sources":["../../src/client/agent-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,gBAAgB,E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AAC,GAAG,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAClD,MAAM,WAAW,GACf,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,KAAK,IAAI,CAAC;IAEzE,4BAA4B,CAC1B,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,CAC/D,CAAC;IACF,2BAA2B,CACzB,sCAAsC,EACtC,EAAE,GAAG,EAAE,EACP,EAAE,WAAW,EAAE,CAChB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,IAAI,GAAoC,EAAE;IAE1C,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAC1C,4BAA4B,CAAC,EAAE,CAAC,CAAC;IACjC,2BAA2B,CACzB,qCAAqC,EACrC,EAAE,EACF,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE,CAC3C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,qBAAqB,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACpD,+BAA+B,EAAE,CAAC;AACpC,CAAC","sourcesContent":["/**\n * Agent Chat Bridge (browser)\n *\n * Sends structured messages to the agent chat from UI interactions.\n * Messages are sent via postMessage to the parent window (or self if top-level).\n * Builder frames are special: code requests go to Builder, but content prompts\n * stay inside the embedded app so its own AgentSidebar can receive them.\n */\n\nimport type { ReasoningEffort } from \"../shared/reasoning-effort.js\";\nimport { agentNativePath } from \"./api-path.js\";\nimport {\n isInBuilderFrame,\n isTrustedBuilderMessage,\n sendToBuilderChat,\n} from \"./builder-frame.js\";\nimport {\n isEmbedAuthActive,\n isEmbedMcpChatBridgeActive,\n markEmbedMcpChatBridgeActive,\n readEmbedMcpChatBridgeFlagFromUrl,\n} from \"./embed-auth.js\";\nimport {\n getFramePostMessageTargetOrigin,\n isTrustedFrameMessage,\n} from \"./frame.js\";\nimport { sendMcpAppHostMessage } from \"./mcp-app-host.js\";\n\nexport type AgentChatRequestMode = \"act\" | \"plan\";\n\nexport interface AgentChatMessage {\n /** The visible prompt message sent to the chat */\n message: string;\n /** Hidden context appended to the message (not shown in chat UI) */\n context?: string;\n /** true = auto-submit, false = prefill only, omit = use project setting */\n submit?: boolean;\n /** Optional project slug for structured context */\n projectSlug?: string;\n /** Optional preset name for downstream consumers */\n preset?: string;\n /** Optional reference image paths */\n referenceImagePaths?: string[];\n /** Optional uploaded reference images */\n uploadedReferenceImages?: string[];\n /** Optional image data URLs to include in the submitted chat message */\n images?: string[];\n /** Stable tab identifier — auto-generated if omitted */\n tabId?: string;\n /**\n * Message routing type:\n * - \"content\" (default): stays in the embedded app agent for content/data operations\n * - \"code\": routes to the code editing frame (Agent Native Desktop or Builder.io)\n *\n * When type is \"code\" and no frame is connected, a dialog is shown.\n * `requiresCode: true` is treated as `type: \"code\"` for backward compatibility.\n */\n type?: \"content\" | \"code\";\n /** @deprecated Use `type: \"code\"` instead. If true, treated as `type: \"code\"`. */\n requiresCode?: boolean;\n /** Model preference for this sub-agent (e.g. \"claude-haiku-4-5\"). Uses default if omitted */\n model?: string;\n /** Engine preference paired with model for cross-provider switches. */\n engine?: string;\n /** Reasoning effort preference paired with model. */\n effort?: ReasoningEffort;\n /**\n * Execution mode for this submitted turn. When omitted, sendToAgentChat\n * snapshots the current AgentPanel mode from localStorage when available.\n */\n mode?: AgentChatRequestMode;\n /** @deprecated Use `mode` instead. */\n requestMode?: AgentChatRequestMode;\n /** Scoped system prompt additions for this sub-agent */\n instructions?: string;\n /**\n * Message delivery target. Auto-submitted MCP App messages normally relay to\n * the host chat; use \"local\" when a control explicitly targets this app's\n * own AgentSidebar.\n */\n chatTarget?: \"auto\" | \"local\";\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true — submitting a chat should make the response visible.\n * Pass `false` for background/silent sends that shouldn't pop the UI open.\n */\n openSidebar?: boolean;\n /**\n * When true, opens a new chat tab before sending the message.\n * Use for creation requests (create tool, dashboard, etc.) that deserve\n * their own isolated thread rather than cluttering an existing conversation.\n */\n newTab?: boolean;\n /**\n * When true with newTab, creates the tab in the background without\n * focusing it or opening the sidebar. The message runs silently.\n */\n background?: boolean;\n}\n\nexport interface AgentChatContextItem {\n /** Stable key used to replace an existing context nugget. */\n key: string;\n /** Short label shown in the composer context chip. */\n title: string;\n /** Hidden context included with the next submitted prompt. */\n context: string;\n}\n\nexport interface AgentChatContextSetOptions extends AgentChatContextItem {\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true so the user can see the staged context.\n */\n openSidebar?: boolean;\n}\n\n/** @deprecated Use `AgentChatContextSetOptions` instead. */\nexport type AgentChatContextMessage = AgentChatContextSetOptions;\n\nexport interface AgentChatContextState {\n items: AgentChatContextItem[];\n updatedAt: number;\n}\n\nexport interface AgentComposerReference {\n label: string;\n icon?: string;\n source?: string;\n refType: string;\n refId?: string | null;\n refPath?: string | null;\n /** Stable composer slot this reference occupies. Slot references replace older values. */\n slotKey?: string;\n /** Short label shown before the selected value in the composer chip. */\n slotLabel?: string;\n /** Additional app-defined data used by the client for filtering and grouping. */\n metadata?: Record<string, unknown>;\n /** Slots to remove when this reference is inserted or removed. */\n clearsSlots?: string[];\n /** Additional references to insert before this one. */\n relatedReferences?: AgentComposerReference[];\n}\n\nexport interface AgentComposerReferenceInsertOptions {\n /**\n * Whether to open the agent sidebar before inserting the reference.\n * Defaults to false so contextual auto-tags can stay quiet.\n */\n openSidebar?: boolean;\n}\n\nexport interface AgentComposerReferenceInsertPayload extends AgentComposerReference {\n insertMessageId: string;\n}\n\nexport interface AgentChatContextMutationOptions {\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true for set/add and false for remove/clear.\n */\n openSidebar?: boolean;\n}\n\nexport interface AgentChatContextRemoveOptions extends AgentChatContextMutationOptions {\n /** Stable key of the staged context nugget to remove. */\n key: string;\n}\n\nconst AGENT_CHAT_MESSAGE_TYPE = \"agentNative.submitChat\";\nconst AGENT_CHAT_CONTEXT_STATE_KEY = \"agent-chat-context\";\nconst AGENT_CHAT_EXEC_MODE_KEY = \"agent-native-exec-mode\";\nexport const AGENT_CHAT_CONTEXT_CHANGED_EVENT =\n \"agentNative.chatContextChanged\";\nexport const AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE = \"agentNative.setChatContext\";\nexport const AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE =\n \"agentNative.removeChatContext\";\nexport const AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE =\n \"agentNative.clearChatContext\";\nexport const AGENT_CHAT_INSERT_REFERENCE_MESSAGE_TYPE =\n \"agentNative.insertComposerReference\";\nexport const AGENT_CHAT_INSERT_REFERENCE_EVENT =\n \"agentNative:insert-composer-reference\";\nconst AGENT_PANEL_PREPARE_EVENT = \"agent-panel:prepare\";\n\nlet agentChatContextState: AgentChatContextState = {\n items: [],\n updatedAt: 0,\n};\nconst agentChatContextListeners = new Set<() => void>();\nlet agentChatContextNotifyQueued = false;\n\n/**\n * Listen for chatRunning messages from the frame (postMessage)\n * and re-dispatch as a CustomEvent so hooks like useAgentChatGenerating() work.\n */\nif (typeof window !== \"undefined\") {\n window.addEventListener(\"message\", (event) => {\n if (!isTrustedFrameMessage(event) && !isTrustedBuilderMessage(event)) {\n return;\n }\n if (\n event.data?.type === \"agentNative.chatRunning\" ||\n event.data?.type === \"builder.chatRunning\"\n ) {\n window.dispatchEvent(\n new CustomEvent(\"agentNative.chatRunning\", {\n detail: event.data.detail ?? event.data.data,\n }),\n );\n }\n });\n}\n\n/** Generate a unique tab ID */\nexport function generateTabId(): string {\n return `chat-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\n/** Unique id for one submitted message, used to dedup live + replayed sends. */\nfunction generateSubmitMessageId(): string {\n return `submit-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\n// Self-submit buffer: same-window sends post to `window` itself, but the\n// receiver is lazy-loaded and may not be listening yet. Buffer each submit so\n// the panel can replay it on mount; claimAgentChatSubmit dedups by id so a\n// submit received both live and replayed is delivered exactly once.\ninterface BufferedSelfSubmit {\n id: string;\n data: Record<string, unknown>;\n at: number;\n}\n\nconst SELF_SUBMIT_BUFFER_TTL_MS = 8000;\nconst bufferedSelfSubmits: BufferedSelfSubmit[] = [];\nconst claimedSubmitIds = new Set<string>();\n\nfunction pruneSelfSubmitBuffer(now: number): void {\n for (let i = bufferedSelfSubmits.length - 1; i >= 0; i -= 1) {\n if (now - bufferedSelfSubmits[i].at > SELF_SUBMIT_BUFFER_TTL_MS) {\n const [removed] = bufferedSelfSubmits.splice(i, 1);\n if (removed) claimedSubmitIds.delete(removed.id);\n }\n }\n}\n\nfunction bufferSelfSubmit(data: Record<string, unknown>): void {\n const id =\n typeof data.submitMessageId === \"string\" ? data.submitMessageId : undefined;\n if (!id) return;\n const now = Date.now();\n pruneSelfSubmitBuffer(now);\n bufferedSelfSubmits.push({ id, data, at: now });\n}\n\n/** Unclaimed self-submit payloads, for the panel to replay once it mounts. */\nexport function drainBufferedAgentChatSubmits(): Array<\n Record<string, unknown>\n> {\n pruneSelfSubmitBuffer(Date.now());\n return bufferedSelfSubmits\n .filter((entry) => !claimedSubmitIds.has(entry.id))\n .map((entry) => entry.data);\n}\n\n/** Claim a submit; false if already handled. Idless submits always pass. */\nexport function claimAgentChatSubmit(id: string | undefined): boolean {\n if (!id) return true;\n if (claimedSubmitIds.has(id)) return false;\n claimedSubmitIds.add(id);\n return true;\n}\n\n/** Test-only: reset the self-submit buffer and claim set. */\nexport function _resetAgentChatSubmitBufferForTests(): void {\n bufferedSelfSubmits.length = 0;\n claimedSubmitIds.clear();\n}\n\nexport function normalizeAgentChatContextItem(\n item: unknown,\n): AgentChatContextItem | null {\n if (typeof item !== \"object\" || item === null) return null;\n const candidate = item as Partial<AgentChatContextItem>;\n if (\n typeof candidate.key !== \"string\" ||\n typeof candidate.context !== \"string\" ||\n typeof candidate.title !== \"string\"\n ) {\n return null;\n }\n const key = candidate.key.trim();\n const context = candidate.context.trim();\n if (!key || !context) return null;\n return {\n key,\n title: candidate.title.trim() || key,\n context,\n };\n}\n\nexport function normalizeAgentChatContextItems(\n items: unknown,\n): AgentChatContextItem[] {\n if (!Array.isArray(items)) return [];\n const deduped = new Map<string, AgentChatContextItem>();\n for (const rawItem of items) {\n const item = normalizeAgentChatContextItem(rawItem);\n if (!item) continue;\n deduped.set(item.key, item);\n }\n return [...deduped.values()];\n}\n\nfunction normalizeAgentChatContextState(\n value: unknown,\n): AgentChatContextState | null {\n if (!value || typeof value !== \"object\") return null;\n const raw = value as {\n value?: unknown;\n items?: unknown;\n updatedAt?: unknown;\n };\n const candidate =\n raw.value && typeof raw.value === \"object\"\n ? (raw.value as { items?: unknown; updatedAt?: unknown })\n : raw;\n const items = normalizeAgentChatContextItems(candidate.items);\n return {\n items,\n updatedAt:\n typeof candidate.updatedAt === \"number\" ? candidate.updatedAt : 0,\n };\n}\n\nfunction withReplacedAgentChatContextItem(\n items: readonly AgentChatContextItem[],\n item: AgentChatContextItem,\n): AgentChatContextItem[] {\n const index = items.findIndex((current) => current.key === item.key);\n if (index === -1) return [...items, item];\n return items.map((current, currentIndex) =>\n currentIndex === index ? item : current,\n );\n}\n\nfunction notifyAgentChatContextListeners(): void {\n if (agentChatContextNotifyQueued) return;\n agentChatContextNotifyQueued = true;\n const notify = () => {\n agentChatContextNotifyQueued = false;\n for (const listener of Array.from(agentChatContextListeners)) listener();\n };\n if (typeof queueMicrotask === \"function\") {\n queueMicrotask(notify);\n } else {\n setTimeout(notify, 0);\n }\n}\n\nfunction persistAgentChatContextState(state: AgentChatContextState): void {\n if (typeof window === \"undefined\" || typeof fetch !== \"function\") return;\n fetch(\n agentNativePath(\n `/_agent-native/application-state/${AGENT_CHAT_CONTEXT_STATE_KEY}`,\n ),\n {\n method: \"PUT\",\n keepalive: true,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(state),\n },\n ).catch(() => {});\n}\n\nexport function publishAgentChatContextItems(\n items: readonly AgentChatContextItem[],\n options?: { persist?: boolean; updatedAt?: number },\n): AgentChatContextState {\n const next: AgentChatContextState = {\n items: normalizeAgentChatContextItems([...items]),\n updatedAt: options?.updatedAt ?? Date.now(),\n };\n if (next.updatedAt < agentChatContextState.updatedAt) {\n return agentChatContextState;\n }\n agentChatContextState = next;\n notifyAgentChatContextListeners();\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(AGENT_CHAT_CONTEXT_CHANGED_EVENT, {\n detail: next,\n }),\n );\n }\n if (options?.persist !== false) {\n persistAgentChatContextState(next);\n }\n return next;\n}\n\nexport function getAgentChatContextState(): AgentChatContextState {\n return agentChatContextState;\n}\n\nexport function listAgentChatContext(): AgentChatContextItem[] {\n return [...agentChatContextState.items];\n}\n\nexport function subscribeAgentChatContext(listener: () => void): () => void {\n agentChatContextListeners.add(listener);\n return () => {\n agentChatContextListeners.delete(listener);\n };\n}\n\nexport async function refreshAgentChatContext(): Promise<AgentChatContextState> {\n if (typeof window === \"undefined\" || typeof fetch !== \"function\") {\n return agentChatContextState;\n }\n try {\n const res = await fetch(\n agentNativePath(\n `/_agent-native/application-state/${AGENT_CHAT_CONTEXT_STATE_KEY}`,\n ),\n );\n if (!res.ok || res.status === 204) return agentChatContextState;\n const text = await res.text();\n if (!text) return agentChatContextState;\n const state = normalizeAgentChatContextState(JSON.parse(text));\n if (!state) return agentChatContextState;\n return publishAgentChatContextItems(state.items, {\n persist: false,\n updatedAt: state.updatedAt,\n });\n } catch {\n return agentChatContextState;\n }\n}\n\nexport function formatAgentChatContextItemsForPrompt(\n items: readonly AgentChatContextItem[],\n): string {\n return items\n .map(normalizeAgentChatContextItem)\n .filter((item): item is AgentChatContextItem => item !== null)\n .map((item) => [`## ${item.title}`, item.context].join(\"\\n\"))\n .join(\"\\n\\n\");\n}\n\nexport function appendAgentChatContextToMessage(\n message: string,\n context: string,\n): string {\n const trimmedContext = context.trim();\n if (!trimmedContext) return message;\n return `${message.trim()}\\n\\n<context>\\n${trimmedContext}\\n</context>`;\n}\n\nfunction normalizeStringArray(value: unknown): string[] | undefined {\n if (!Array.isArray(value)) return undefined;\n const normalized = value\n .filter((item): item is string => typeof item === \"string\")\n .map((item) => item.trim())\n .filter(Boolean);\n return normalized.length > 0 ? normalized : undefined;\n}\n\nfunction normalizeMetadata(\n value: unknown,\n): Record<string, unknown> | undefined {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return undefined;\n }\n return value as Record<string, unknown>;\n}\n\nfunction normalizeAgentComposerReferenceInternal(\n value: unknown,\n depth: number,\n): AgentComposerReference | null {\n if (typeof value !== \"object\" || value === null) return null;\n const candidate = value as Partial<AgentComposerReference>;\n const label =\n typeof candidate.label === \"string\" ? candidate.label.trim() : \"\";\n const refType =\n typeof candidate.refType === \"string\" ? candidate.refType.trim() : \"\";\n if (!label || !refType) return null;\n const normalized: AgentComposerReference = {\n label,\n icon:\n typeof candidate.icon === \"string\" && candidate.icon.trim()\n ? candidate.icon.trim()\n : undefined,\n source:\n typeof candidate.source === \"string\" && candidate.source.trim()\n ? candidate.source.trim()\n : undefined,\n refType,\n refId:\n typeof candidate.refId === \"string\" && candidate.refId.trim()\n ? candidate.refId.trim()\n : null,\n refPath:\n typeof candidate.refPath === \"string\" && candidate.refPath.trim()\n ? candidate.refPath.trim()\n : null,\n };\n const slotKey =\n typeof candidate.slotKey === \"string\" ? candidate.slotKey.trim() : \"\";\n if (slotKey) normalized.slotKey = slotKey;\n const slotLabel =\n typeof candidate.slotLabel === \"string\" ? candidate.slotLabel.trim() : \"\";\n if (slotLabel) normalized.slotLabel = slotLabel;\n const metadata = normalizeMetadata(candidate.metadata);\n if (metadata) normalized.metadata = metadata;\n const clearsSlots = normalizeStringArray(candidate.clearsSlots);\n if (clearsSlots) normalized.clearsSlots = clearsSlots;\n if (depth < 3 && Array.isArray(candidate.relatedReferences)) {\n const relatedReferences = candidate.relatedReferences\n .map((item) => normalizeAgentComposerReferenceInternal(item, depth + 1))\n .filter((item): item is AgentComposerReference => item !== null);\n if (relatedReferences.length > 0) {\n normalized.relatedReferences = relatedReferences;\n }\n }\n return normalized;\n}\n\nexport function normalizeAgentComposerReference(\n value: unknown,\n): AgentComposerReference | null {\n return normalizeAgentComposerReferenceInternal(value, 0);\n}\n\nfunction postAgentChatContextMessage(\n type:\n | typeof AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE\n | typeof AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE\n | typeof AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE,\n data: unknown,\n options: { openSidebar: boolean },\n): void {\n if (typeof window === \"undefined\") return;\n\n const shouldForwardOpenSidebar =\n (type === AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE &&\n options.openSidebar === false) ||\n (type !== AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE &&\n options.openSidebar === true);\n const payloadData =\n shouldForwardOpenSidebar && typeof data === \"object\" && data !== null\n ? {\n ...(data as Record<string, unknown>),\n openSidebar: options.openSidebar,\n }\n : data;\n const payload = { type, data: payloadData };\n const targetSelf = isInBuilderFrame() || isDirectMcpAppEmbedSession();\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n\n if (options.openSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n const postToTarget = () => target.postMessage(payload, targetOrigin);\n if (target === window) {\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n}\n\nfunction postAgentChatReferenceMessage(\n payload: AgentComposerReferenceInsertPayload,\n options: { openSidebar: boolean },\n): void {\n if (typeof window === \"undefined\") return;\n\n const message = {\n type: AGENT_CHAT_INSERT_REFERENCE_MESSAGE_TYPE,\n data: payload,\n };\n const targetSelf = isInBuilderFrame() || isDirectMcpAppEmbedSession();\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n\n if (options.openSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n window.dispatchEvent(\n new CustomEvent(AGENT_CHAT_INSERT_REFERENCE_EVENT, {\n detail: payload,\n }),\n );\n\n const postToTarget = () => target.postMessage(message, targetOrigin);\n if (target === window) {\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n}\n\nfunction isMcpAppChatBridgeEnabled(): boolean {\n if (typeof window === \"undefined\" || window.parent === window) return false;\n if (readEmbedMcpChatBridgeFlagFromUrl()) markEmbedMcpChatBridgeActive();\n return isEmbedMcpChatBridgeActive() && isEmbedAuthActive();\n}\n\nfunction isDirectMcpAppEmbedSession(): boolean {\n if (typeof window === \"undefined\" || window.parent === window) return false;\n if (readEmbedMcpChatBridgeFlagFromUrl()) markEmbedMcpChatBridgeActive();\n return isEmbedAuthActive() && !isEmbedMcpChatBridgeActive();\n}\n\nfunction dispatchAgentChatRunning(isRunning: boolean): void {\n if (typeof window === \"undefined\") return;\n window.dispatchEvent(\n new CustomEvent(\"agentNative.chatRunning\", {\n detail: { isRunning },\n }),\n );\n}\n\nfunction normalizeAgentChatRequestMode(\n value: unknown,\n): AgentChatRequestMode | undefined {\n return value === \"act\" || value === \"plan\" ? value : undefined;\n}\n\n/** A normalized `agentNative.submitChat` payload — decode via {@link parseSubmitChatMessage}. */\nexport interface ParsedSubmitChat {\n /** Visible prompt text (non-empty). */\n message: string;\n context?: string;\n /** Submit (true) or prefill only (false); defaults to true. */\n submit: boolean;\n openSidebar?: boolean;\n model?: string;\n /** Raw effort hint; the receiver validates it against the model. */\n effort?: unknown;\n newTab?: boolean;\n background?: boolean;\n tabId?: string;\n images?: string[];\n /** Mode as sent; the receiver falls back to its exec mode when undefined. */\n requestMode?: AgentChatRequestMode;\n /** Id used to dedup the live post against a cold-start replay. */\n submitMessageId?: string;\n}\n\n/** Decode a `message` event into a submit payload, or null if it isn't one / has no text. */\nexport function parseSubmitChatMessage(\n event: MessageEvent,\n): ParsedSubmitChat | null {\n const envelope =\n event.data && typeof event.data === \"object\"\n ? (event.data as { type?: unknown; data?: unknown })\n : null;\n if (!envelope || envelope.type !== AGENT_CHAT_MESSAGE_TYPE) return null;\n const raw =\n envelope.data && typeof envelope.data === \"object\"\n ? (envelope.data as Record<string, unknown>)\n : null;\n if (!raw) return null;\n const message = typeof raw.message === \"string\" ? raw.message : \"\";\n if (!message) return null;\n const images = Array.isArray(raw.images)\n ? raw.images.filter(\n (image): image is string =>\n typeof image === \"string\" && image.length > 0,\n )\n : undefined;\n return {\n message,\n context: typeof raw.context === \"string\" ? raw.context : undefined,\n submit: raw.submit !== false,\n openSidebar:\n typeof raw.openSidebar === \"boolean\" ? raw.openSidebar : undefined,\n model: typeof raw.model === \"string\" ? raw.model : undefined,\n effort: raw.effort,\n newTab: typeof raw.newTab === \"boolean\" ? raw.newTab : undefined,\n background:\n typeof raw.background === \"boolean\" ? raw.background : undefined,\n tabId: typeof raw.tabId === \"string\" ? raw.tabId : undefined,\n images,\n requestMode: normalizeAgentChatRequestMode(raw.requestMode ?? raw.mode),\n submitMessageId:\n typeof raw.submitMessageId === \"string\" ? raw.submitMessageId : undefined,\n };\n}\n\nfunction normalizeStoredAgentChatExecMode(\n value: string | null,\n): AgentChatRequestMode | undefined {\n if (value === \"plan\") return \"plan\";\n if (value === \"build\" || value === \"act\") return \"act\";\n return undefined;\n}\n\nfunction readStoredAgentChatRequestMode(): AgentChatRequestMode | undefined {\n if (typeof window === \"undefined\") return undefined;\n try {\n const storage = window.localStorage;\n const saved = normalizeStoredAgentChatExecMode(\n storage.getItem(AGENT_CHAT_EXEC_MODE_KEY),\n );\n if (saved) return saved;\n const scopedModes: AgentChatRequestMode[] = [];\n for (let index = 0; index < storage.length; index += 1) {\n const key = storage.key(index);\n if (!key?.startsWith(`${AGENT_CHAT_EXEC_MODE_KEY}:`)) continue;\n const scopedSaved = normalizeStoredAgentChatExecMode(\n storage.getItem(key),\n );\n if (scopedSaved) scopedModes.push(scopedSaved);\n }\n if (scopedModes.length === 1) return scopedModes[0];\n } catch {}\n return undefined;\n}\n\n/**\n * Send a message to the agent chat via postMessage.\n * Returns the stable tabId for tracking this chat run.\n */\nexport function sendToAgentChat(opts: AgentChatMessage): string {\n const tabId = opts.tabId ?? generateTabId();\n const isCodeRequest = opts.type === \"code\" || opts.requiresCode === true;\n const localChatTarget = opts.chatTarget === \"local\";\n const requestMode =\n normalizeAgentChatRequestMode(opts.requestMode ?? opts.mode) ??\n readStoredAgentChatRequestMode();\n if (isCodeRequest && isInBuilderFrame()) {\n sendToBuilderChat({\n message: opts.message,\n context: opts.context,\n submit: opts.submit,\n ...(requestMode ? { mode: requestMode, requestMode } : {}),\n });\n return tabId;\n }\n\n const submitMessageId = generateSubmitMessageId();\n const payload = {\n type: AGENT_CHAT_MESSAGE_TYPE,\n data: {\n ...opts,\n tabId,\n submitMessageId,\n ...(requestMode ? { mode: requestMode, requestMode } : {}),\n },\n };\n\n if (\n opts.submit !== false &&\n !localChatTarget &&\n isMcpAppChatBridgeEnabled()\n ) {\n const directHostMessage = sendMcpAppHostMessage({\n message: opts.message,\n context: opts.context,\n ...(requestMode ? { mode: requestMode, requestMode } : {}),\n });\n if (directHostMessage) {\n void Promise.resolve(directHostMessage)\n .then((ok) => {\n if (!ok) {\n window.parent.postMessage(\n payload,\n getFramePostMessageTargetOrigin() || \"*\",\n );\n }\n })\n .finally(() => {\n dispatchAgentChatRunning(false);\n });\n return tabId;\n }\n window.parent.postMessage(\n payload,\n getFramePostMessageTargetOrigin() || \"*\",\n );\n return tabId;\n }\n\n const shouldOpenSidebar = opts.openSidebar !== false && !opts.background;\n\n const targetSelf =\n !isCodeRequest &&\n (localChatTarget || isInBuilderFrame() || isDirectMcpAppEmbedSession());\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n if (shouldOpenSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else if (!isCodeRequest) {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n const postToTarget = () => target.postMessage(payload, targetOrigin);\n\n // Same-window: defer one tick so a sidebar mounting now can attach its\n // listener, and buffer the submit so the lazy panel can replay it if it\n // mounts later. The live post and the replay dedup by submitMessageId.\n if (!isCodeRequest && target === window) {\n bufferSelfSubmit(payload.data);\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n return tabId;\n}\n\n/**\n * Add or replace a keyed context nugget in the active agent chat composer.\n * The context is not submitted until the user sends the prompt.\n */\nexport function setAgentChatContextItem(\n opts: AgentChatContextSetOptions,\n): void {\n const item = normalizeAgentChatContextItem(opts);\n if (!item || typeof window === \"undefined\") return;\n\n publishAgentChatContextItems(\n withReplacedAgentChatContextItem(agentChatContextState.items, item),\n );\n postAgentChatContextMessage(AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE, item, {\n openSidebar: opts.openSidebar !== false,\n });\n}\n\n/** @deprecated Use `setAgentChatContextItem` instead. */\nexport const setContextToAgentChat = setAgentChatContextItem;\n\n/** @deprecated Use `setAgentChatContextItem` instead. */\nexport const addContextToAgentChat = setAgentChatContextItem;\n\nexport function insertAgentComposerReference(\n ref: AgentComposerReference,\n options: AgentComposerReferenceInsertOptions = {},\n): void {\n const normalized = normalizeAgentComposerReference(ref);\n if (!normalized || typeof window === \"undefined\") return;\n postAgentChatReferenceMessage(\n {\n ...normalized,\n insertMessageId: `reference-${Date.now()}-${Math.random()\n .toString(36)\n .slice(2, 8)}`,\n },\n { openSidebar: options.openSidebar === true },\n );\n}\n\nexport function removeAgentChatContextItem(\n keyOrOpts: string | AgentChatContextRemoveOptions,\n): void {\n const key =\n typeof keyOrOpts === \"string\" ? keyOrOpts.trim() : keyOrOpts.key.trim();\n if (!key || typeof window === \"undefined\") return;\n const openSidebar =\n typeof keyOrOpts === \"string\" ? false : keyOrOpts.openSidebar === true;\n\n publishAgentChatContextItems(\n agentChatContextState.items.filter((item) => item.key !== key),\n );\n postAgentChatContextMessage(\n AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE,\n { key },\n { openSidebar },\n );\n}\n\nexport function clearAgentChatContext(\n opts: AgentChatContextMutationOptions = {},\n): void {\n if (typeof window === \"undefined\") return;\n publishAgentChatContextItems([]);\n postAgentChatContextMessage(\n AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE,\n {},\n { openSidebar: opts.openSidebar === true },\n );\n}\n\nexport function _resetAgentChatContextForTests(): void {\n agentChatContextState = { items: [], updatedAt: 0 };\n notifyAgentChatContextListeners();\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptComposer.d.ts","sourceRoot":"","sources":["../../../src/client/composer/PromptComposer.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,GAAG,EACR,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"PromptComposer.d.ts","sourceRoot":"","sources":["../../../src/client/composer/PromptComposer.ts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AK,IAAI,CAAC;IACnD;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,qDAAqD;IACrD,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,mDAAmD;IACnD,WAAW,CAAC,EAAE,GAAG,CAAC,oBAAoB,CAAC,CAAC;CACzC;AAwED,wBAAsB,6BAA6B,CAAC,OAAO,EAAE;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACtC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,IAAI,EAAE,CAAA;CAAE,CAAC,CAyC3C;AAmXD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,+BAoCxD"}
|
|
@@ -4,7 +4,9 @@ import { CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, } from "@assi
|
|
|
4
4
|
import { IconX } from "@tabler/icons-react";
|
|
5
5
|
import { useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
6
6
|
import { AssistantUiStaleIndexErrorBoundary } from "../assistant-ui-recovery.js";
|
|
7
|
+
import { BuilderSetupCard } from "../chat/run-recovery.js";
|
|
7
8
|
import { TooltipProvider } from "../components/ui/tooltip.js";
|
|
9
|
+
import { fetchAgentEngineConfiguredState, useAgentEngineConfigured, } from "../use-agent-engine-configured.js";
|
|
8
10
|
import { useChatModels } from "../use-chat-models.js";
|
|
9
11
|
import { cn } from "../utils.js";
|
|
10
12
|
import { AgentComposerFrame } from "./AgentComposerFrame.js";
|
|
@@ -15,6 +17,7 @@ import { PastedTextChip } from "./PastedTextChip.js";
|
|
|
15
17
|
import { escapePromptAttachmentAttribute } from "./prompt-attachments.js";
|
|
16
18
|
import { DEFAULT_VOICE_DICTATION_ENABLED, TiptapComposer, } from "./TiptapComposer.js";
|
|
17
19
|
const MAX_INLINE_TEXT_FILE_CHARS = 60_000;
|
|
20
|
+
const SUBMIT_ENGINE_STATUS_TIMEOUT_MS = 1000;
|
|
18
21
|
// Minimal pass-through adapter. PromptComposer always submits through
|
|
19
22
|
// onSubmitOverride, so the runtime never actually calls this — but
|
|
20
23
|
// `useLocalRuntime` needs *something* shaped like a ChatModelAdapter.
|
|
@@ -200,6 +203,37 @@ function PromptComposerInner({ onSubmit, placeholder, disabled, autoFocus, class
|
|
|
200
203
|
const handleEffortChange = showModelSelector
|
|
201
204
|
? (onEffortChange ?? models.onEffortChange)
|
|
202
205
|
: undefined;
|
|
206
|
+
const agentEngineConfigured = useAgentEngineConfigured(resolvedModelStatusChecksEnabled);
|
|
207
|
+
const missingApiKey = agentEngineConfigured.missing;
|
|
208
|
+
const [missingKeyBouncePulse, setMissingKeyBouncePulse] = useState(0);
|
|
209
|
+
const bounceMissingKeySetup = useCallback(() => {
|
|
210
|
+
setMissingKeyBouncePulse((pulse) => pulse + 1);
|
|
211
|
+
if (typeof window !== "undefined") {
|
|
212
|
+
window.dispatchEvent(new Event("agent-chat:missing-api-key"));
|
|
213
|
+
}
|
|
214
|
+
}, []);
|
|
215
|
+
const handleBuilderConnected = useCallback(() => {
|
|
216
|
+
if (typeof window !== "undefined") {
|
|
217
|
+
window.dispatchEvent(new Event("agent-engine:configured-changed"));
|
|
218
|
+
}
|
|
219
|
+
}, []);
|
|
220
|
+
const ensureAgentEngineReadyForSubmit = useCallback(async () => {
|
|
221
|
+
if (!resolvedModelStatusChecksEnabled)
|
|
222
|
+
return true;
|
|
223
|
+
const state = agentEngineConfigured.state === "missing"
|
|
224
|
+
? "missing"
|
|
225
|
+
: await fetchAgentEngineConfiguredState(resolvedModelStatusChecksEnabled, {
|
|
226
|
+
timeoutMs: SUBMIT_ENGINE_STATUS_TIMEOUT_MS,
|
|
227
|
+
});
|
|
228
|
+
if (state !== "missing")
|
|
229
|
+
return true;
|
|
230
|
+
bounceMissingKeySetup();
|
|
231
|
+
return false;
|
|
232
|
+
}, [
|
|
233
|
+
agentEngineConfigured.state,
|
|
234
|
+
bounceMissingKeySetup,
|
|
235
|
+
resolvedModelStatusChecksEnabled,
|
|
236
|
+
]);
|
|
203
237
|
useEffect(() => {
|
|
204
238
|
if (!autoFocus)
|
|
205
239
|
return;
|
|
@@ -229,7 +263,7 @@ function PromptComposerInner({ onSubmit, placeholder, disabled, autoFocus, class
|
|
|
229
263
|
effort: composerEffort,
|
|
230
264
|
});
|
|
231
265
|
}, [composerEffort, composerEngine, composerModel, onSubmit]);
|
|
232
|
-
return (_jsxs(AgentComposerFrame, { className: cn("text-start", className), rootClassName: rootClassName, style: style, rootStyle: rootStyle, layoutVariant: layoutVariant, children: [_jsx(PromptAttachmentStrip, {}), _jsx(TiptapComposer, { focusRef: handleRef, disabled: disabled, placeholder: placeholder, initialText: initialText, initialTextKey: initialTextKey, onSubmit: handleSubmit, clearOnSubmit: !preserveDraftOnSubmit, plusMenuMode: plusMenuMode ?? (attachmentsEnabled ? "upload-only" : "hidden"), attachButton: attachButton, modeControl: modeControl, toolbarSlot: toolbarSlot, actionButton: actionButton, extraActionButton: extraActionButton, layoutVariant: layoutVariant, slashCommands: slashCommands, slashSkills: slashSkills, includeDefaultSlashCommands: includeDefaultSlashCommands, includeDefaultSlashSkills: includeDefaultSlashSkills, onSlashCommand: onSlashCommand, voiceEnabled: voiceEnabled, onTextChange: onTextChange, draftScope: draftScope, selectedModel: composerModel, selectedEffort: composerEffort, availableModels: composerModelGroups, onModelChange: handleModelChange, onEffortChange: handleEffortChange, providerConnectStatusEnabled: resolvedModelStatusChecksEnabled, onConnectProvider: onConnectProvider })] }));
|
|
266
|
+
return (_jsxs(_Fragment, { children: [missingApiKey ? (_jsx(BuilderSetupCard, { onConnected: handleBuilderConnected, bouncePulse: missingKeyBouncePulse, fullWidth: true, layout: "sidebar" })) : null, _jsxs(AgentComposerFrame, { className: cn("text-start", missingApiKey && "cursor-pointer", className), rootClassName: rootClassName, style: style, rootStyle: rootStyle, layoutVariant: layoutVariant, onClick: missingApiKey ? bounceMissingKeySetup : undefined, children: [_jsx(PromptAttachmentStrip, {}), _jsx(TiptapComposer, { focusRef: handleRef, disabled: disabled || missingApiKey, placeholder: missingApiKey ? "Connect AI above to continue..." : placeholder, initialText: initialText, initialTextKey: initialTextKey, onSubmit: handleSubmit, onBeforeSubmit: ensureAgentEngineReadyForSubmit, clearOnSubmit: !preserveDraftOnSubmit, plusMenuMode: plusMenuMode ?? (attachmentsEnabled ? "upload-only" : "hidden"), attachButton: attachButton, modeControl: modeControl, toolbarSlot: toolbarSlot, actionButton: actionButton, extraActionButton: extraActionButton, layoutVariant: layoutVariant, slashCommands: slashCommands, slashSkills: slashSkills, includeDefaultSlashCommands: includeDefaultSlashCommands, includeDefaultSlashSkills: includeDefaultSlashSkills, onSlashCommand: onSlashCommand, voiceEnabled: voiceEnabled, onTextChange: onTextChange, draftScope: draftScope, selectedModel: composerModel, selectedEffort: composerEffort, availableModels: composerModelGroups, onModelChange: handleModelChange, onEffortChange: handleEffortChange, providerConnectStatusEnabled: resolvedModelStatusChecksEnabled, onConnectProvider: onConnectProvider })] })] }));
|
|
233
267
|
}
|
|
234
268
|
/**
|
|
235
269
|
* Standalone composer that mirrors the agent sidebar's input experience —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptComposer.js","sourceRoot":"","sources":["../../../src/client/composer/PromptComposer.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,wBAAwB,EACxB,eAAe,EACf,MAAM,EACN,WAAW,EACX,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAI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C,IAAI,CAAC,GAAG,CAAC,CAAC;IAEZ,OAAO,CACL,KAAC,eAAe,IAAC,aAAa,EAAE,GAAG,YACjC,KAAC,wBAAwB,IAAC,OAAO,EAAE,OAAO,YACxC,KAAC,eAAe,CAAC,IAAI,IACnB,SAAS,EAAC,UAAU,EACpB,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,YAE9B,KAAC,kCAAkC,IACjC,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAC,gBAAgB,YAE9B,KAAC,mBAAmB,OAAK,KAAK,GAAI,GACC,GAChB,GACE,GACX,CACnB,CAAC;AACJ,CAAC","sourcesContent":["import {\n AssistantRuntimeProvider,\n ThreadPrimitive,\n useAui,\n useComposer,\n useLocalRuntime,\n} from \"@assistant-ui/react\";\nimport type {\n Attachment,\n AttachmentAdapter,\n ChatModelAdapter,\n CompleteAttachment,\n PendingAttachment,\n} from \"@assistant-ui/react\";\nimport {\n CompositeAttachmentAdapter,\n SimpleImageAttachmentAdapter,\n} from \"@assistant-ui/react\";\nimport { IconX } from \"@tabler/icons-react\";\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type Ref,\n type ReactNode,\n} from \"react\";\n\nimport type { ReasoningEffort } from \"../../shared/reasoning-effort.js\";\nimport { AssistantUiStaleIndexErrorBoundary } from \"../assistant-ui-recovery.js\";\nimport { TooltipProvider } from \"../components/ui/tooltip.js\";\nimport { useChatModels, type EngineModelGroup } from \"../use-chat-models.js\";\nimport { cn } from \"../utils.js\";\nimport { AgentComposerFrame } from \"./AgentComposerFrame.js\";\nimport { IMAGE_ATTACHMENT_ACCEPT } from \"./attachment-accept.js\";\nimport {\n PROMPT_DOCUMENT_ATTACHMENT_ACCEPT,\n TextAttachmentAdapter,\n} from \"./attachment-accept.js\";\nimport { isPastedTextAttachmentName } from \"./pasted-text.js\";\nimport { PastedTextChip } from \"./PastedTextChip.js\";\nimport { escapePromptAttachmentAttribute } from \"./prompt-attachments.js\";\nimport {\n DEFAULT_VOICE_DICTATION_ENABLED,\n TiptapComposer,\n type ComposerSubmitIntent,\n type TiptapComposerHandle,\n type TiptapComposerSubmitOptions,\n} from \"./TiptapComposer.js\";\nimport type {\n AgentComposerLayoutVariant,\n Reference,\n SkillResult,\n SlashCommand,\n} from \"./types.js\";\n\nconst MAX_INLINE_TEXT_FILE_CHARS = 60_000;\n\n/**\n * Files the user attached via the \"+\" button in PromptComposer. The host owns\n * what to do with them — typically POST to a per-app upload endpoint and pass\n * the resulting URLs/paths into the prompt that gets sent to the agent.\n */\nexport type PromptComposerFile = File;\n\nexport interface PromptComposerSubmitOptions {\n intent?: ComposerSubmitIntent;\n model?: string;\n engine?: string;\n effort?: ReasoningEffort;\n}\n\nexport interface PromptComposerProps {\n /** Called when the user submits the composer. */\n onSubmit: (\n text: string,\n files: PromptComposerFile[],\n references: Reference[],\n options: PromptComposerSubmitOptions,\n ) => void;\n placeholder?: string;\n disabled?: boolean;\n autoFocus?: boolean;\n className?: string;\n style?: CSSProperties;\n rootClassName?: string;\n rootStyle?: CSSProperties;\n /** Forwarded to TiptapComposer for draft persistence. */\n draftScope?: string;\n /** Keep the submitted prompt in the editor. Default: false. */\n preserveDraftOnSubmit?: boolean;\n /** Show the model selector (default: true). */\n showModelSelector?: boolean;\n /** Show the voice dictation button. Defaults to DEFAULT_VOICE_DICTATION_ENABLED. */\n voiceEnabled?: boolean;\n /** Show file upload controls and pass submitted files to onSubmit (default: true). */\n attachmentsEnabled?: boolean;\n /**\n * Controls the shared \"+\" affordance. Defaults to upload-only for standalone\n * prompt forms; chat surfaces can opt into the full sidebar menu.\n */\n plusMenuMode?: \"full\" | \"upload-only\" | \"hidden\";\n /** Programmatically seed the composer with plain text. */\n initialText?: string;\n /** Stable key used to re-apply `initialText` when the host picks a preset. */\n initialTextKey?: string | number;\n /** Optional host-owned control rendered directly after the \"+\" button. */\n modeControl?: ReactNode;\n /** Explicit host-owned toolbar slot rendered directly after the \"+\" button. */\n toolbarSlot?: ReactNode;\n /** Custom attachment button to render instead of the default \"+\" affordance. */\n attachButton?: ReactNode;\n /** Custom action button to render instead of the default send button. */\n actionButton?: ReactNode;\n /** Extra button rendered alongside the default send button. */\n extraActionButton?: ReactNode;\n /** Shared sizing/layout variant for host surfaces. Default keeps sidebar behavior. */\n layoutVariant?: AgentComposerLayoutVariant;\n /** Additional slash commands surfaced in the shared / menu. */\n slashCommands?: SlashCommand[];\n /** Additional slash skills surfaced in the shared / menu. */\n slashSkills?: SkillResult[];\n /** Include built-in sidebar slash commands like /clear and /help. Default true. */\n includeDefaultSlashCommands?: boolean;\n /** Include app-discovered skills from the default agent endpoint. Default true. */\n includeDefaultSlashSkills?: boolean;\n /** Called when a slash command from the shared / menu is executed. */\n onSlashCommand?: (command: string) => void;\n /** External model list for hosts that already resolve models outside the app. */\n availableModels?: EngineModelGroup[];\n selectedModel?: string;\n selectedEngine?: string;\n selectedEffort?: ReasoningEffort;\n onModelChange?: (model: string, engine: string) => void;\n onEffortChange?: (effort: ReasoningEffort) => void;\n /**\n * Enable server-backed model/provider status checks. Defaults off when the\n * host supplies model state and callbacks, otherwise on.\n */\n modelStatusChecksEnabled?: boolean;\n /** Called whenever the plain editor text changes. */\n onTextChange?: (text: string) => void;\n /**\n * Override the Builder.io connect action in the model picker. When provided,\n * clicking \"Connect Builder.io\" calls this instead of opening a browser popup.\n * Used by the Electron desktop app to route through the native IPC handler.\n */\n onConnectProvider?: () => void;\n /** Imperative handle for focusing the composer. */\n composerRef?: Ref<TiptapComposerHandle>;\n}\n\n// Minimal pass-through adapter. PromptComposer always submits through\n// onSubmitOverride, so the runtime never actually calls this — but\n// `useLocalRuntime` needs *something* shaped like a ChatModelAdapter.\nconst NOOP_ADAPTER: ChatModelAdapter = {\n async *run() {\n return;\n },\n};\n\n/**\n * Local binary document adapter so reference PDFs, decks, and docs can be\n * attached without dragging the whole assistant chat module into bundles that\n * just want a prompt popover.\n */\nclass BinaryDocumentAttachmentAdapter implements AttachmentAdapter {\n public accept = PROMPT_DOCUMENT_ATTACHMENT_ACCEPT;\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: state.file.type || \"application/octet-stream\",\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 }\n\n public async remove() {\n /* noop */\n }\n}\n\nclass RasterImageAttachmentAdapter extends SimpleImageAttachmentAdapter {\n public accept = IMAGE_ATTACHMENT_ACCEPT;\n}\n\nfunction isInlineableTextFile(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|html?|css|xml)$/i.test(\n file.name,\n );\n}\n\nfunction formatInlineTextFile(name: string, text: string): string {\n const truncated = text.length > MAX_INLINE_TEXT_FILE_CHARS;\n const body = truncated ? text.slice(0, MAX_INLINE_TEXT_FILE_CHARS) : text;\n return [\n `<uploaded-text-file name=\"${escapePromptAttachmentAttribute(name)}\">`,\n body,\n truncated\n ? `[Truncated after ${MAX_INLINE_TEXT_FILE_CHARS} characters.]`\n : \"\",\n \"</uploaded-text-file>\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n}\n\nexport async function buildPromptComposerSubmission(options: {\n text: string;\n attachments?: ReadonlyArray<unknown>;\n}): Promise<{ text: string; files: File[] }> {\n const files: File[] = [];\n const pastedTextBlocks: string[] = [];\n const rawText = options.text;\n\n for (const att of options.attachments ?? []) {\n const a = att as Attachment;\n if (\"file\" in a && a.file instanceof File) {\n const file = a.file;\n if (isPastedTextAttachmentName(file.name)) {\n try {\n pastedTextBlocks.push(await file.text());\n } catch {\n files.push(file);\n }\n } else {\n if (isInlineableTextFile(file)) {\n try {\n pastedTextBlocks.push(\n formatInlineTextFile(file.name, await file.text()),\n );\n } catch {\n // Keep the upload path fallback below.\n }\n }\n // Note: images are NOT inlined into the prompt text even when small.\n // Inlining a base64 data-URL into a text string consumes an enormous\n // number of tokens (≈ 700 K per MB) and most hosts handle images via\n // proper attachment channels. The `files` array below carries the image\n // for the host to process through a dedicated attachment pipeline.\n files.push(file);\n }\n }\n }\n\n return {\n text: pastedTextBlocks.length\n ? [rawText.trim(), ...pastedTextBlocks].filter(Boolean).join(\"\\n\\n\")\n : rawText,\n files,\n };\n}\n\nfunction getImageSrc(attachment: Attachment): string | null {\n if (attachment.type !== \"image\") return null;\n if (\"file\" in attachment && attachment.file) {\n return URL.createObjectURL(attachment.file);\n }\n const imagePart = attachment.content?.find((part) => part.type === \"image\");\n return imagePart && \"image\" in imagePart ? imagePart.image : null;\n}\n\nfunction ImagePreviewLightbox({\n src,\n alt,\n onClose,\n}: {\n src: string;\n alt: string;\n onClose: () => void;\n}) {\n useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") onClose();\n };\n document.addEventListener(\"keydown\", handler);\n document.body.style.overflow = \"hidden\";\n return () => {\n document.removeEventListener(\"keydown\", handler);\n document.body.style.overflow = \"\";\n };\n }, [onClose]);\n\n return (\n <div\n role=\"dialog\"\n aria-label=\"Image preview\"\n onClick={onClose}\n className=\"fixed inset-0 z-[300] flex items-center justify-center bg-black/80 p-6 cursor-zoom-out\"\n >\n <img\n src={src}\n alt={alt}\n onClick={(e) => e.stopPropagation()}\n className=\"max-h-full max-w-full object-contain rounded-md shadow-2xl cursor-default\"\n />\n <button\n type=\"button\"\n onClick={onClose}\n aria-label=\"Close preview\"\n className=\"absolute end-4 top-4 flex h-8 w-8 cursor-pointer items-center justify-center rounded-full border border-white/30 bg-black/40 text-white hover:bg-black/60\"\n >\n <IconX className=\"h-4 w-4\" />\n </button>\n </div>\n );\n}\n\nfunction AttachmentChip({\n attachment,\n onRemove,\n}: {\n attachment: Attachment;\n onRemove: (id: string) => void;\n}) {\n const src = useMemo(() => getImageSrc(attachment), [attachment]);\n const [previewOpen, setPreviewOpen] = useState(false);\n useEffect(\n () => () => {\n if (src?.startsWith(\"blob:\")) URL.revokeObjectURL(src);\n },\n [src],\n );\n\n if (isPastedTextAttachmentName(attachment.name)) {\n return <PastedTextChip attachment={attachment} onRemove={onRemove} />;\n }\n\n if (src) {\n return (\n <>\n <button\n type=\"button\"\n onClick={() => setPreviewOpen(true)}\n aria-label={`Preview ${attachment.name}`}\n className=\"agent-composer-attachment-image group relative flex h-16 min-w-16 max-w-28 cursor-zoom-in items-center justify-center overflow-hidden rounded-lg border border-border/70 bg-muted/50\"\n >\n <img\n src={src}\n alt={attachment.name}\n className=\"max-h-full max-w-full object-contain p-1\"\n />\n <span\n role=\"button\"\n tabIndex={0}\n onClick={(e) => {\n e.stopPropagation();\n onRemove(attachment.id);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n e.stopPropagation();\n onRemove(attachment.id);\n }\n }}\n aria-label={`Remove ${attachment.name}`}\n className=\"absolute end-1 top-1 flex h-5 w-5 cursor-pointer items-center justify-center rounded-full border border-border/60 bg-background/90 text-muted-foreground hover:text-foreground\"\n >\n <IconX className=\"h-3 w-3\" />\n </span>\n </button>\n {previewOpen ? (\n <ImagePreviewLightbox\n src={src}\n alt={attachment.name}\n onClose={() => setPreviewOpen(false)}\n />\n ) : null}\n </>\n );\n }\n\n return (\n <div className=\"agent-composer-attachment-chip group relative inline-flex max-w-[200px] items-center gap-2 rounded-md border border-border/70 bg-muted/50 px-2 py-1.5 text-xs\">\n <div className=\"flex h-6 w-6 shrink-0 items-center justify-center rounded bg-background text-[9px] font-semibold uppercase text-muted-foreground\">\n {attachment.name.split(\".\").pop() || \"file\"}\n </div>\n <span className=\"min-w-0 truncate font-medium\">{attachment.name}</span>\n <button\n type=\"button\"\n onClick={() => onRemove(attachment.id)}\n aria-label={`Remove ${attachment.name}`}\n className=\"flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center rounded text-muted-foreground hover:text-foreground\"\n >\n <IconX className=\"h-3 w-3\" />\n </button>\n </div>\n );\n}\n\nfunction PromptAttachmentStrip() {\n const attachments = useComposer((state) => state.attachments);\n const aui = useAui();\n\n const handleRemove = useCallback(\n (id: string) => {\n void aui.composer().attachment({ id }).remove();\n },\n [aui],\n );\n\n if (attachments.length === 0) return null;\n return (\n <div className=\"agent-composer-attachment-strip flex flex-wrap gap-2 px-2 pt-2\">\n {attachments.map((attachment) => (\n <AttachmentChip\n key={attachment.id}\n attachment={attachment}\n onRemove={handleRemove}\n />\n ))}\n </div>\n );\n}\n\nfunction PromptComposerInner({\n onSubmit,\n placeholder,\n disabled,\n autoFocus,\n className,\n style,\n rootClassName,\n rootStyle,\n draftScope,\n preserveDraftOnSubmit = false,\n showModelSelector = true,\n voiceEnabled = DEFAULT_VOICE_DICTATION_ENABLED,\n attachmentsEnabled = true,\n plusMenuMode,\n initialText,\n initialTextKey,\n modeControl,\n toolbarSlot,\n attachButton,\n actionButton,\n extraActionButton,\n layoutVariant,\n slashCommands,\n slashSkills,\n includeDefaultSlashCommands,\n includeDefaultSlashSkills,\n onSlashCommand,\n availableModels,\n selectedModel,\n selectedEngine,\n selectedEffort,\n onModelChange,\n onEffortChange,\n modelStatusChecksEnabled,\n onTextChange,\n onConnectProvider,\n composerRef,\n}: PromptComposerProps) {\n const localRef = useRef<TiptapComposerHandle>(null);\n const handleRef = composerRef ?? localRef;\n const hostManagedModels = Boolean(\n availableModels && selectedModel && onModelChange,\n );\n const resolvedModelStatusChecksEnabled =\n modelStatusChecksEnabled ?? !hostManagedModels;\n const models = useChatModels({\n enabled: showModelSelector && resolvedModelStatusChecksEnabled,\n });\n const composerModel = showModelSelector\n ? (selectedModel ?? models.selectedModel)\n : undefined;\n const composerEngine = showModelSelector\n ? (selectedEngine ?? models.selectedEngine)\n : undefined;\n const composerEffort = showModelSelector\n ? (selectedEffort ?? models.selectedEffort)\n : undefined;\n const composerModelGroups = showModelSelector\n ? (availableModels ?? models.availableModels)\n : undefined;\n const handleModelChange = showModelSelector\n ? (onModelChange ?? models.onModelChange)\n : undefined;\n const handleEffortChange = showModelSelector\n ? (onEffortChange ?? models.onEffortChange)\n : undefined;\n\n useEffect(() => {\n if (!autoFocus) return;\n const id = window.setTimeout(() => {\n const target =\n typeof handleRef === \"object\" && handleRef && \"current\" in handleRef\n ? handleRef.current\n : null;\n target?.focus();\n }, 50);\n return () => window.clearTimeout(id);\n }, [autoFocus, handleRef]);\n\n const handleSubmit = useCallback(\n async (\n text: string,\n references: Reference[],\n attachments?: ReadonlyArray<unknown>,\n submitOptions?: TiptapComposerSubmitOptions,\n ) => {\n // PromptComposer hosts (NewWorkspaceAppFlow, create-extension, create-deck,\n // …) submit a single string prompt — they don't run the assistant-ui\n // attachment send pipeline. TiptapComposer auto-converts large pastes\n // into a \"Pasted text\" chip, which would otherwise disappear into an\n // unprocessed File. Inline the chip body back into the prompt text so\n // newlines and full content survive the round-trip.\n const { text: finalText, files } = await buildPromptComposerSubmission({\n text,\n attachments,\n });\n onSubmit(finalText, files, references, {\n intent: submitOptions?.intent ?? \"immediate\",\n model: composerModel,\n engine: composerEngine,\n effort: composerEffort,\n });\n },\n [composerEffort, composerEngine, composerModel, onSubmit],\n );\n\n return (\n <AgentComposerFrame\n className={cn(\"text-start\", className)}\n rootClassName={rootClassName}\n style={style}\n rootStyle={rootStyle}\n layoutVariant={layoutVariant}\n >\n <PromptAttachmentStrip />\n <TiptapComposer\n focusRef={handleRef}\n disabled={disabled}\n placeholder={placeholder}\n initialText={initialText}\n initialTextKey={initialTextKey}\n onSubmit={handleSubmit}\n clearOnSubmit={!preserveDraftOnSubmit}\n plusMenuMode={\n plusMenuMode ?? (attachmentsEnabled ? \"upload-only\" : \"hidden\")\n }\n attachButton={attachButton}\n modeControl={modeControl}\n toolbarSlot={toolbarSlot}\n actionButton={actionButton}\n extraActionButton={extraActionButton}\n layoutVariant={layoutVariant}\n slashCommands={slashCommands}\n slashSkills={slashSkills}\n includeDefaultSlashCommands={includeDefaultSlashCommands}\n includeDefaultSlashSkills={includeDefaultSlashSkills}\n onSlashCommand={onSlashCommand}\n voiceEnabled={voiceEnabled}\n onTextChange={onTextChange}\n draftScope={draftScope}\n selectedModel={composerModel}\n selectedEffort={composerEffort}\n availableModels={composerModelGroups}\n onModelChange={handleModelChange}\n onEffortChange={handleEffortChange}\n providerConnectStatusEnabled={resolvedModelStatusChecksEnabled}\n onConnectProvider={onConnectProvider}\n />\n </AgentComposerFrame>\n );\n}\n\n/**\n * Standalone composer that mirrors the agent sidebar's input experience —\n * voice dictation, file upload, model selector, submit-on-Enter — for use in\n * popovers and inline prompt forms (create tool, create deck, create dashboard,\n * the Dispatch new-app flow, etc.).\n *\n * The host owns submission: when the user presses Enter or clicks submit,\n * `onSubmit(text, files, references, options)` is called. PromptComposer runs\n * its own minimal assistant-ui runtime so it can be dropped into any subtree\n * without needing the outer chat to be mounted.\n */\nexport function PromptComposer(props: PromptComposerProps) {\n const attachmentAdapter = useMemo(\n () =>\n new CompositeAttachmentAdapter([\n new RasterImageAttachmentAdapter(),\n new BinaryDocumentAttachmentAdapter(),\n new TextAttachmentAdapter(),\n ]),\n [],\n );\n const runtime = useLocalRuntime(NOOP_ADAPTER, {\n adapters: { attachments: attachmentAdapter },\n });\n const resetKey = [\n props.draftScope ?? \"\",\n props.initialTextKey ?? \"\",\n props.initialText ?? \"\",\n ].join(\":\");\n\n return (\n <TooltipProvider delayDuration={200}>\n <AssistantRuntimeProvider runtime={runtime}>\n <ThreadPrimitive.Root\n className=\"contents\"\n style={{ display: \"contents\" }}\n >\n <AssistantUiStaleIndexErrorBoundary\n resetKey={resetKey}\n componentName=\"PromptComposer\"\n >\n <PromptComposerInner {...props} />\n </AssistantUiStaleIndexErrorBoundary>\n </ThreadPrimitive.Root>\n </AssistantRuntimeProvider>\n </TooltipProvider>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PromptComposer.js","sourceRoot":"","sources":["../../../src/client/composer/PromptComposer.tsx"],"names":[],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useAui,\n useComposer,\n useLocalRuntime,\n} from \"@assistant-ui/react\";\nimport type {\n Attachment,\n AttachmentAdapter,\n ChatModelAdapter,\n CompleteAttachment,\n PendingAttachment,\n} from \"@assistant-ui/react\";\nimport {\n CompositeAttachmentAdapter,\n SimpleImageAttachmentAdapter,\n} from \"@assistant-ui/react\";\nimport { IconX } from \"@tabler/icons-react\";\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type Ref,\n type ReactNode,\n} from \"react\";\n\nimport type { ReasoningEffort } from \"../../shared/reasoning-effort.js\";\nimport { AssistantUiStaleIndexErrorBoundary } from \"../assistant-ui-recovery.js\";\nimport { BuilderSetupCard } from \"../chat/run-recovery.js\";\nimport { TooltipProvider } from \"../components/ui/tooltip.js\";\nimport {\n fetchAgentEngineConfiguredState,\n useAgentEngineConfigured,\n} from \"../use-agent-engine-configured.js\";\nimport { useChatModels, type EngineModelGroup } from \"../use-chat-models.js\";\nimport { cn } from \"../utils.js\";\nimport { AgentComposerFrame } from \"./AgentComposerFrame.js\";\nimport { IMAGE_ATTACHMENT_ACCEPT } from \"./attachment-accept.js\";\nimport {\n PROMPT_DOCUMENT_ATTACHMENT_ACCEPT,\n TextAttachmentAdapter,\n} from \"./attachment-accept.js\";\nimport { isPastedTextAttachmentName } from \"./pasted-text.js\";\nimport { PastedTextChip } from \"./PastedTextChip.js\";\nimport { escapePromptAttachmentAttribute } from \"./prompt-attachments.js\";\nimport {\n DEFAULT_VOICE_DICTATION_ENABLED,\n TiptapComposer,\n type ComposerSubmitIntent,\n type TiptapComposerHandle,\n type TiptapComposerSubmitOptions,\n} from \"./TiptapComposer.js\";\nimport type {\n AgentComposerLayoutVariant,\n Reference,\n SkillResult,\n SlashCommand,\n} from \"./types.js\";\n\nconst MAX_INLINE_TEXT_FILE_CHARS = 60_000;\nconst SUBMIT_ENGINE_STATUS_TIMEOUT_MS = 1000;\n\n/**\n * Files the user attached via the \"+\" button in PromptComposer. The host owns\n * what to do with them — typically POST to a per-app upload endpoint and pass\n * the resulting URLs/paths into the prompt that gets sent to the agent.\n */\nexport type PromptComposerFile = File;\n\nexport interface PromptComposerSubmitOptions {\n intent?: ComposerSubmitIntent;\n model?: string;\n engine?: string;\n effort?: ReasoningEffort;\n}\n\nexport interface PromptComposerProps {\n /** Called when the user submits the composer. */\n onSubmit: (\n text: string,\n files: PromptComposerFile[],\n references: Reference[],\n options: PromptComposerSubmitOptions,\n ) => void;\n placeholder?: string;\n disabled?: boolean;\n autoFocus?: boolean;\n className?: string;\n style?: CSSProperties;\n rootClassName?: string;\n rootStyle?: CSSProperties;\n /** Forwarded to TiptapComposer for draft persistence. */\n draftScope?: string;\n /** Keep the submitted prompt in the editor. Default: false. */\n preserveDraftOnSubmit?: boolean;\n /** Show the model selector (default: true). */\n showModelSelector?: boolean;\n /** Show the voice dictation button. Defaults to DEFAULT_VOICE_DICTATION_ENABLED. */\n voiceEnabled?: boolean;\n /** Show file upload controls and pass submitted files to onSubmit (default: true). */\n attachmentsEnabled?: boolean;\n /**\n * Controls the shared \"+\" affordance. Defaults to upload-only for standalone\n * prompt forms; chat surfaces can opt into the full sidebar menu.\n */\n plusMenuMode?: \"full\" | \"upload-only\" | \"hidden\";\n /** Programmatically seed the composer with plain text. */\n initialText?: string;\n /** Stable key used to re-apply `initialText` when the host picks a preset. */\n initialTextKey?: string | number;\n /** Optional host-owned control rendered directly after the \"+\" button. */\n modeControl?: ReactNode;\n /** Explicit host-owned toolbar slot rendered directly after the \"+\" button. */\n toolbarSlot?: ReactNode;\n /** Custom attachment button to render instead of the default \"+\" affordance. */\n attachButton?: ReactNode;\n /** Custom action button to render instead of the default send button. */\n actionButton?: ReactNode;\n /** Extra button rendered alongside the default send button. */\n extraActionButton?: ReactNode;\n /** Shared sizing/layout variant for host surfaces. Default keeps sidebar behavior. */\n layoutVariant?: AgentComposerLayoutVariant;\n /** Additional slash commands surfaced in the shared / menu. */\n slashCommands?: SlashCommand[];\n /** Additional slash skills surfaced in the shared / menu. */\n slashSkills?: SkillResult[];\n /** Include built-in sidebar slash commands like /clear and /help. Default true. */\n includeDefaultSlashCommands?: boolean;\n /** Include app-discovered skills from the default agent endpoint. Default true. */\n includeDefaultSlashSkills?: boolean;\n /** Called when a slash command from the shared / menu is executed. */\n onSlashCommand?: (command: string) => void;\n /** External model list for hosts that already resolve models outside the app. */\n availableModels?: EngineModelGroup[];\n selectedModel?: string;\n selectedEngine?: string;\n selectedEffort?: ReasoningEffort;\n onModelChange?: (model: string, engine: string) => void;\n onEffortChange?: (effort: ReasoningEffort) => void;\n /**\n * Enable server-backed model/provider status checks. Defaults off when the\n * host supplies model state and callbacks, otherwise on.\n */\n modelStatusChecksEnabled?: boolean;\n /** Called whenever the plain editor text changes. */\n onTextChange?: (text: string) => void;\n /**\n * Override the Builder.io connect action in the model picker. When provided,\n * clicking \"Connect Builder.io\" calls this instead of opening a browser popup.\n * Used by the Electron desktop app to route through the native IPC handler.\n */\n onConnectProvider?: () => void;\n /** Imperative handle for focusing the composer. */\n composerRef?: Ref<TiptapComposerHandle>;\n}\n\n// Minimal pass-through adapter. PromptComposer always submits through\n// onSubmitOverride, so the runtime never actually calls this — but\n// `useLocalRuntime` needs *something* shaped like a ChatModelAdapter.\nconst NOOP_ADAPTER: ChatModelAdapter = {\n async *run() {\n return;\n },\n};\n\n/**\n * Local binary document adapter so reference PDFs, decks, and docs can be\n * attached without dragging the whole assistant chat module into bundles that\n * just want a prompt popover.\n */\nclass BinaryDocumentAttachmentAdapter implements AttachmentAdapter {\n public accept = PROMPT_DOCUMENT_ATTACHMENT_ACCEPT;\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: state.file.type || \"application/octet-stream\",\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 }\n\n public async remove() {\n /* noop */\n }\n}\n\nclass RasterImageAttachmentAdapter extends SimpleImageAttachmentAdapter {\n public accept = IMAGE_ATTACHMENT_ACCEPT;\n}\n\nfunction isInlineableTextFile(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|html?|css|xml)$/i.test(\n file.name,\n );\n}\n\nfunction formatInlineTextFile(name: string, text: string): string {\n const truncated = text.length > MAX_INLINE_TEXT_FILE_CHARS;\n const body = truncated ? text.slice(0, MAX_INLINE_TEXT_FILE_CHARS) : text;\n return [\n `<uploaded-text-file name=\"${escapePromptAttachmentAttribute(name)}\">`,\n body,\n truncated\n ? `[Truncated after ${MAX_INLINE_TEXT_FILE_CHARS} characters.]`\n : \"\",\n \"</uploaded-text-file>\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n}\n\nexport async function buildPromptComposerSubmission(options: {\n text: string;\n attachments?: ReadonlyArray<unknown>;\n}): Promise<{ text: string; files: File[] }> {\n const files: File[] = [];\n const pastedTextBlocks: string[] = [];\n const rawText = options.text;\n\n for (const att of options.attachments ?? []) {\n const a = att as Attachment;\n if (\"file\" in a && a.file instanceof File) {\n const file = a.file;\n if (isPastedTextAttachmentName(file.name)) {\n try {\n pastedTextBlocks.push(await file.text());\n } catch {\n files.push(file);\n }\n } else {\n if (isInlineableTextFile(file)) {\n try {\n pastedTextBlocks.push(\n formatInlineTextFile(file.name, await file.text()),\n );\n } catch {\n // Keep the upload path fallback below.\n }\n }\n // Note: images are NOT inlined into the prompt text even when small.\n // Inlining a base64 data-URL into a text string consumes an enormous\n // number of tokens (≈ 700 K per MB) and most hosts handle images via\n // proper attachment channels. The `files` array below carries the image\n // for the host to process through a dedicated attachment pipeline.\n files.push(file);\n }\n }\n }\n\n return {\n text: pastedTextBlocks.length\n ? [rawText.trim(), ...pastedTextBlocks].filter(Boolean).join(\"\\n\\n\")\n : rawText,\n files,\n };\n}\n\nfunction getImageSrc(attachment: Attachment): string | null {\n if (attachment.type !== \"image\") return null;\n if (\"file\" in attachment && attachment.file) {\n return URL.createObjectURL(attachment.file);\n }\n const imagePart = attachment.content?.find((part) => part.type === \"image\");\n return imagePart && \"image\" in imagePart ? imagePart.image : null;\n}\n\nfunction ImagePreviewLightbox({\n src,\n alt,\n onClose,\n}: {\n src: string;\n alt: string;\n onClose: () => void;\n}) {\n useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") onClose();\n };\n document.addEventListener(\"keydown\", handler);\n document.body.style.overflow = \"hidden\";\n return () => {\n document.removeEventListener(\"keydown\", handler);\n document.body.style.overflow = \"\";\n };\n }, [onClose]);\n\n return (\n <div\n role=\"dialog\"\n aria-label=\"Image preview\"\n onClick={onClose}\n className=\"fixed inset-0 z-[300] flex items-center justify-center bg-black/80 p-6 cursor-zoom-out\"\n >\n <img\n src={src}\n alt={alt}\n onClick={(e) => e.stopPropagation()}\n className=\"max-h-full max-w-full object-contain rounded-md shadow-2xl cursor-default\"\n />\n <button\n type=\"button\"\n onClick={onClose}\n aria-label=\"Close preview\"\n className=\"absolute end-4 top-4 flex h-8 w-8 cursor-pointer items-center justify-center rounded-full border border-white/30 bg-black/40 text-white hover:bg-black/60\"\n >\n <IconX className=\"h-4 w-4\" />\n </button>\n </div>\n );\n}\n\nfunction AttachmentChip({\n attachment,\n onRemove,\n}: {\n attachment: Attachment;\n onRemove: (id: string) => void;\n}) {\n const src = useMemo(() => getImageSrc(attachment), [attachment]);\n const [previewOpen, setPreviewOpen] = useState(false);\n useEffect(\n () => () => {\n if (src?.startsWith(\"blob:\")) URL.revokeObjectURL(src);\n },\n [src],\n );\n\n if (isPastedTextAttachmentName(attachment.name)) {\n return <PastedTextChip attachment={attachment} onRemove={onRemove} />;\n }\n\n if (src) {\n return (\n <>\n <button\n type=\"button\"\n onClick={() => setPreviewOpen(true)}\n aria-label={`Preview ${attachment.name}`}\n className=\"agent-composer-attachment-image group relative flex h-16 min-w-16 max-w-28 cursor-zoom-in items-center justify-center overflow-hidden rounded-lg border border-border/70 bg-muted/50\"\n >\n <img\n src={src}\n alt={attachment.name}\n className=\"max-h-full max-w-full object-contain p-1\"\n />\n <span\n role=\"button\"\n tabIndex={0}\n onClick={(e) => {\n e.stopPropagation();\n onRemove(attachment.id);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n e.stopPropagation();\n onRemove(attachment.id);\n }\n }}\n aria-label={`Remove ${attachment.name}`}\n className=\"absolute end-1 top-1 flex h-5 w-5 cursor-pointer items-center justify-center rounded-full border border-border/60 bg-background/90 text-muted-foreground hover:text-foreground\"\n >\n <IconX className=\"h-3 w-3\" />\n </span>\n </button>\n {previewOpen ? (\n <ImagePreviewLightbox\n src={src}\n alt={attachment.name}\n onClose={() => setPreviewOpen(false)}\n />\n ) : null}\n </>\n );\n }\n\n return (\n <div className=\"agent-composer-attachment-chip group relative inline-flex max-w-[200px] items-center gap-2 rounded-md border border-border/70 bg-muted/50 px-2 py-1.5 text-xs\">\n <div className=\"flex h-6 w-6 shrink-0 items-center justify-center rounded bg-background text-[9px] font-semibold uppercase text-muted-foreground\">\n {attachment.name.split(\".\").pop() || \"file\"}\n </div>\n <span className=\"min-w-0 truncate font-medium\">{attachment.name}</span>\n <button\n type=\"button\"\n onClick={() => onRemove(attachment.id)}\n aria-label={`Remove ${attachment.name}`}\n className=\"flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center rounded text-muted-foreground hover:text-foreground\"\n >\n <IconX className=\"h-3 w-3\" />\n </button>\n </div>\n );\n}\n\nfunction PromptAttachmentStrip() {\n const attachments = useComposer((state) => state.attachments);\n const aui = useAui();\n\n const handleRemove = useCallback(\n (id: string) => {\n void aui.composer().attachment({ id }).remove();\n },\n [aui],\n );\n\n if (attachments.length === 0) return null;\n return (\n <div className=\"agent-composer-attachment-strip flex flex-wrap gap-2 px-2 pt-2\">\n {attachments.map((attachment) => (\n <AttachmentChip\n key={attachment.id}\n attachment={attachment}\n onRemove={handleRemove}\n />\n ))}\n </div>\n );\n}\n\nfunction PromptComposerInner({\n onSubmit,\n placeholder,\n disabled,\n autoFocus,\n className,\n style,\n rootClassName,\n rootStyle,\n draftScope,\n preserveDraftOnSubmit = false,\n showModelSelector = true,\n voiceEnabled = DEFAULT_VOICE_DICTATION_ENABLED,\n attachmentsEnabled = true,\n plusMenuMode,\n initialText,\n initialTextKey,\n modeControl,\n toolbarSlot,\n attachButton,\n actionButton,\n extraActionButton,\n layoutVariant,\n slashCommands,\n slashSkills,\n includeDefaultSlashCommands,\n includeDefaultSlashSkills,\n onSlashCommand,\n availableModels,\n selectedModel,\n selectedEngine,\n selectedEffort,\n onModelChange,\n onEffortChange,\n modelStatusChecksEnabled,\n onTextChange,\n onConnectProvider,\n composerRef,\n}: PromptComposerProps) {\n const localRef = useRef<TiptapComposerHandle>(null);\n const handleRef = composerRef ?? localRef;\n const hostManagedModels = Boolean(\n availableModels && selectedModel && onModelChange,\n );\n const resolvedModelStatusChecksEnabled =\n modelStatusChecksEnabled ?? !hostManagedModels;\n const models = useChatModels({\n enabled: showModelSelector && resolvedModelStatusChecksEnabled,\n });\n const composerModel = showModelSelector\n ? (selectedModel ?? models.selectedModel)\n : undefined;\n const composerEngine = showModelSelector\n ? (selectedEngine ?? models.selectedEngine)\n : undefined;\n const composerEffort = showModelSelector\n ? (selectedEffort ?? models.selectedEffort)\n : undefined;\n const composerModelGroups = showModelSelector\n ? (availableModels ?? models.availableModels)\n : undefined;\n const handleModelChange = showModelSelector\n ? (onModelChange ?? models.onModelChange)\n : undefined;\n const handleEffortChange = showModelSelector\n ? (onEffortChange ?? models.onEffortChange)\n : undefined;\n const agentEngineConfigured = useAgentEngineConfigured(\n resolvedModelStatusChecksEnabled,\n );\n const missingApiKey = agentEngineConfigured.missing;\n const [missingKeyBouncePulse, setMissingKeyBouncePulse] = useState(0);\n const bounceMissingKeySetup = useCallback(() => {\n setMissingKeyBouncePulse((pulse) => pulse + 1);\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new Event(\"agent-chat:missing-api-key\"));\n }\n }, []);\n const handleBuilderConnected = useCallback(() => {\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new Event(\"agent-engine:configured-changed\"));\n }\n }, []);\n const ensureAgentEngineReadyForSubmit = useCallback(async () => {\n if (!resolvedModelStatusChecksEnabled) return true;\n const state =\n agentEngineConfigured.state === \"missing\"\n ? \"missing\"\n : await fetchAgentEngineConfiguredState(\n resolvedModelStatusChecksEnabled,\n {\n timeoutMs: SUBMIT_ENGINE_STATUS_TIMEOUT_MS,\n },\n );\n if (state !== \"missing\") return true;\n bounceMissingKeySetup();\n return false;\n }, [\n agentEngineConfigured.state,\n bounceMissingKeySetup,\n resolvedModelStatusChecksEnabled,\n ]);\n\n useEffect(() => {\n if (!autoFocus) return;\n const id = window.setTimeout(() => {\n const target =\n typeof handleRef === \"object\" && handleRef && \"current\" in handleRef\n ? handleRef.current\n : null;\n target?.focus();\n }, 50);\n return () => window.clearTimeout(id);\n }, [autoFocus, handleRef]);\n\n const handleSubmit = useCallback(\n async (\n text: string,\n references: Reference[],\n attachments?: ReadonlyArray<unknown>,\n submitOptions?: TiptapComposerSubmitOptions,\n ) => {\n // PromptComposer hosts (NewWorkspaceAppFlow, create-extension, create-deck,\n // …) submit a single string prompt — they don't run the assistant-ui\n // attachment send pipeline. TiptapComposer auto-converts large pastes\n // into a \"Pasted text\" chip, which would otherwise disappear into an\n // unprocessed File. Inline the chip body back into the prompt text so\n // newlines and full content survive the round-trip.\n const { text: finalText, files } = await buildPromptComposerSubmission({\n text,\n attachments,\n });\n onSubmit(finalText, files, references, {\n intent: submitOptions?.intent ?? \"immediate\",\n model: composerModel,\n engine: composerEngine,\n effort: composerEffort,\n });\n },\n [composerEffort, composerEngine, composerModel, onSubmit],\n );\n\n return (\n <>\n {missingApiKey ? (\n <BuilderSetupCard\n onConnected={handleBuilderConnected}\n bouncePulse={missingKeyBouncePulse}\n fullWidth\n layout=\"sidebar\"\n />\n ) : null}\n <AgentComposerFrame\n className={cn(\n \"text-start\",\n missingApiKey && \"cursor-pointer\",\n className,\n )}\n rootClassName={rootClassName}\n style={style}\n rootStyle={rootStyle}\n layoutVariant={layoutVariant}\n onClick={missingApiKey ? bounceMissingKeySetup : undefined}\n >\n <PromptAttachmentStrip />\n <TiptapComposer\n focusRef={handleRef}\n disabled={disabled || missingApiKey}\n placeholder={\n missingApiKey ? \"Connect AI above to continue...\" : placeholder\n }\n initialText={initialText}\n initialTextKey={initialTextKey}\n onSubmit={handleSubmit}\n onBeforeSubmit={ensureAgentEngineReadyForSubmit}\n clearOnSubmit={!preserveDraftOnSubmit}\n plusMenuMode={\n plusMenuMode ?? (attachmentsEnabled ? \"upload-only\" : \"hidden\")\n }\n attachButton={attachButton}\n modeControl={modeControl}\n toolbarSlot={toolbarSlot}\n actionButton={actionButton}\n extraActionButton={extraActionButton}\n layoutVariant={layoutVariant}\n slashCommands={slashCommands}\n slashSkills={slashSkills}\n includeDefaultSlashCommands={includeDefaultSlashCommands}\n includeDefaultSlashSkills={includeDefaultSlashSkills}\n onSlashCommand={onSlashCommand}\n voiceEnabled={voiceEnabled}\n onTextChange={onTextChange}\n draftScope={draftScope}\n selectedModel={composerModel}\n selectedEffort={composerEffort}\n availableModels={composerModelGroups}\n onModelChange={handleModelChange}\n onEffortChange={handleEffortChange}\n providerConnectStatusEnabled={resolvedModelStatusChecksEnabled}\n onConnectProvider={onConnectProvider}\n />\n </AgentComposerFrame>\n </>\n );\n}\n\n/**\n * Standalone composer that mirrors the agent sidebar's input experience —\n * voice dictation, file upload, model selector, submit-on-Enter — for use in\n * popovers and inline prompt forms (create tool, create deck, create dashboard,\n * the Dispatch new-app flow, etc.).\n *\n * The host owns submission: when the user presses Enter or clicks submit,\n * `onSubmit(text, files, references, options)` is called. PromptComposer runs\n * its own minimal assistant-ui runtime so it can be dropped into any subtree\n * without needing the outer chat to be mounted.\n */\nexport function PromptComposer(props: PromptComposerProps) {\n const attachmentAdapter = useMemo(\n () =>\n new CompositeAttachmentAdapter([\n new RasterImageAttachmentAdapter(),\n new BinaryDocumentAttachmentAdapter(),\n new TextAttachmentAdapter(),\n ]),\n [],\n );\n const runtime = useLocalRuntime(NOOP_ADAPTER, {\n adapters: { attachments: attachmentAdapter },\n });\n const resetKey = [\n props.draftScope ?? \"\",\n props.initialTextKey ?? \"\",\n props.initialText ?? \"\",\n ].join(\":\");\n\n return (\n <TooltipProvider delayDuration={200}>\n <AssistantRuntimeProvider runtime={runtime}>\n <ThreadPrimitive.Root\n className=\"contents\"\n style={{ display: \"contents\" }}\n >\n <AssistantUiStaleIndexErrorBoundary\n resetKey={resetKey}\n componentName=\"PromptComposer\"\n >\n <PromptComposerInner {...props} />\n </AssistantUiStaleIndexErrorBoundary>\n </ThreadPrimitive.Root>\n </AssistantRuntimeProvider>\n </TooltipProvider>\n );\n}\n"]}
|
|
@@ -156,7 +156,7 @@ export function OrgSwitcher({ className, hideWhenSingle, reserveSpace, settingsP
|
|
|
156
156
|
const organizationSettingsHref = settingsPath
|
|
157
157
|
? organizationSettingsPath(settingsPath)
|
|
158
158
|
: null;
|
|
159
|
-
return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: handleOpenChange, children: [_jsx(PopoverPrimitive.Trigger, { asChild: true, children: _jsxs("button", { type: "button", className: `flex w-full items-center gap-2 rounded-md border border-border/
|
|
159
|
+
return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: handleOpenChange, children: [_jsx(PopoverPrimitive.Trigger, { asChild: true, children: _jsxs("button", { type: "button", className: `flex w-full items-center gap-2 rounded-md border border-border/70 px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent/50 hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring cursor-pointer ${className ?? ""}`, children: [_jsx(ButtonIcon, { className: "h-3.5 w-3.5 shrink-0" }), _jsx("span", { className: "truncate flex-1 text-start", children: buttonLabel }), _jsx(IconSelector, { className: "h-3 w-3 shrink-0 opacity-50" })] }) }), _jsx(PopoverPrimitive.Portal, { children: _jsxs(PopoverPrimitive.Content, { side: "top", align: "start", sideOffset: 6, collisionPadding: 12, className: POPOVER_CONTENT_CLASS, onOpenAutoFocus: (e) => {
|
|
160
160
|
// Don't auto-focus the first item — feels heavy on a switcher.
|
|
161
161
|
if (mode === "list")
|
|
162
162
|
e.preventDefault();
|